rebuild nonce and swqos strategy

This commit is contained in:
wood
2025-09-20 14:00:45 +08:00
parent 4df22f2057
commit b46582a273
7 changed files with 120 additions and 124 deletions
+25 -2
View File
@@ -19,6 +19,15 @@ pub struct NonceInfo {
pub used: bool,
}
/// DurableNonceInfo structure to store durable nonce-related information
#[derive(Clone)]
pub struct DurableNonceInfo {
/// Nonce account address
pub nonce_account: Option<Pubkey>,
/// Current nonce value
pub current_nonce: Option<Hash>,
}
/// NonceInfoStore singleton for storing and managing NonceInfo
pub struct NonceCache {
/// Internally stored NonceInfo data
@@ -50,8 +59,8 @@ impl NonceCache {
self.update_nonce_info_partial(nonce_account, None, Some(false));
}
/// Get a copy of NonceInfo
pub fn get_nonce_info(&self) -> NonceInfo {
/// Get a copy of NonceInfo
pub fn get_nonce_info(&self) -> NonceInfo {
let nonce_info = self.nonce_info.lock();
NonceInfo {
nonce_account: nonce_info.nonce_account,
@@ -60,6 +69,20 @@ impl NonceCache {
}
}
pub fn get_durable_nonce_info() -> DurableNonceInfo {
let nonce_info = Self::get_instance().get_nonce_info();
let nonce_account = nonce_info.nonce_account;
let current_nonce = if nonce_account.is_some() && nonce_info.current_nonce != Hash::default() {
Some(nonce_info.current_nonce)
} else {
None
};
DurableNonceInfo {
nonce_account,
current_nonce,
}
}
/// Partially update NonceInfo, only update the passed fields
pub fn update_nonce_info_partial(
&self,