@@ -338,8 +338,8 @@ impl RuskNode {
338338 Ok ( response)
339339 }
340340
341- async fn get_account ( & self , pk : & str ) -> anyhow:: Result < ResponseData > {
342- let pk = bs58:: decode ( pk )
341+ async fn get_account ( & self , pk_str : & str ) -> anyhow:: Result < ResponseData > {
342+ let pk = bs58:: decode ( pk_str )
343343 . into_vec ( )
344344 . map_err ( |_| anyhow:: anyhow!( "Invalid bs58 account" ) ) ?;
345345 let pk = BlsPublicKey :: from_slice ( & pk)
@@ -357,29 +357,31 @@ impl RuskNode {
357357 // Determine the next available nonce not already used in the mempool.
358358 // This ensures that any in-flight transactions using sequential nonces
359359 // are accounted for.
360- // If the account has no transactions in the mempool, the mempool_nonce
361- // will be `None`, indicating that the next nonce is the same as the
362- // account's current nonce.
363- let mempool_nonce = db
360+ // If the account has no transactions in the mempool, the next_nonceis
361+ // the same as the account's current nonce + 1.
362+ let next_nonce = db
364363 . read ( )
365364 . await
366365 . view ( |t| {
367- let mut next_nonce = account. nonce ;
366+ let mut next_nonce = account. nonce + 1 ;
368367 loop {
369368 let id = SpendingId :: AccountNonce ( pk, next_nonce) ;
370369 if t. mempool_txs_by_spendable_ids ( & [ id] ) . is_empty ( ) {
371370 break ;
372371 }
373372 next_nonce += 1 ;
374373 }
375- anyhow:: Ok ( ( next_nonce > account . nonce ) . then_some ( next_nonce ) )
374+ anyhow:: Ok ( next_nonce)
376375 } )
377- . map_err ( |e| anyhow:: anyhow!( "Cannot check the mempool {e}" ) ) ?;
376+ . unwrap_or_else ( |e| {
377+ error ! ( "Failed to check the mempool for account {pk_str}: {e}" ) ;
378+ account. nonce + 1
379+ } ) ;
378380
379381 Ok ( ResponseData :: new ( json ! ( {
380382 "balance" : account. balance,
381383 "nonce" : account. nonce,
382- "mempool_nonce " : mempool_nonce ,
384+ "next_nonce " : next_nonce ,
383385 } ) ) )
384386 }
385387}
0 commit comments