Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
herr-seppia committed Sep 3, 2024
1 parent 357db74 commit ecb19d4
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions rusk/src/lib/node/rusk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
//
// Copyright (c) DUSK NETWORK. All rights reserved.

use std::collections::{BTreeMap, HashMap};
use std::path::Path;
use std::sync::{mpsc, Arc, LazyLock};
use std::time::{Duration, Instant};
Expand Down Expand Up @@ -124,6 +125,9 @@ impl Rusk {

let mut event_hasher = Sha3_256::new();

let mut pending = HashMap::new();
let mut last_tx_account = None;

for unspent_tx in txs {
if let Some(timeout) = self.generation_timeout {
if started.elapsed() > timeout {
Expand Down Expand Up @@ -169,6 +173,11 @@ impl Rusk {
let err = receipt.data.err().map(|e| format!("{e}"));
info!("Tx {tx_id} executed with {gas_spent} gas and err {err:?}");

last_tx_account = unspent_tx
.inner
.from_account()
.map(|s| s.to_raw_bytes());

update_hasher(&mut event_hasher, &receipt.events);

block_gas_left -= gas_spent;
Expand All @@ -190,6 +199,15 @@ impl Rusk {

// TODO: Try to process the transaction as soon as the
// nonce is unlocked
if let ProtocolTransaction::Moonlight(m) = &unspent_tx.inner
{
let sender = m.from_account();
let nonce = m.nonce();
let account_queue = pending
.entry(sender.to_raw_bytes())
.or_insert(BTreeMap::new());
account_queue.insert(nonce, unspent_tx);
}
}
Err(e) => {
info!("discard tx {tx_id} due to {e:?}");
Expand Down

0 comments on commit ecb19d4

Please sign in to comment.