copy bank for TPU
This commit is contained in:
parent
3e1a926aa6
commit
1f9ab7f58f
|
@ -251,6 +251,21 @@ impl AccountsDB {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Accounts {
|
impl Accounts {
|
||||||
|
// TODO use a fork
|
||||||
|
pub fn copy_for_tpu(&self) -> Self {
|
||||||
|
let copy = Accounts::default();
|
||||||
|
|
||||||
|
{
|
||||||
|
let mut accounts_db = copy.accounts_db.write().unwrap();
|
||||||
|
for (key, val) in self.accounts_db.read().unwrap().accounts.iter() {
|
||||||
|
accounts_db.accounts.insert(key.clone(), val.clone());
|
||||||
|
}
|
||||||
|
accounts_db.transaction_count = self.transaction_count();
|
||||||
|
}
|
||||||
|
|
||||||
|
copy
|
||||||
|
}
|
||||||
|
|
||||||
pub fn keys(&self) -> Vec<Pubkey> {
|
pub fn keys(&self) -> Vec<Pubkey> {
|
||||||
self.accounts_db.read().unwrap().keys()
|
self.accounts_db.read().unwrap().keys()
|
||||||
}
|
}
|
||||||
|
|
11
src/bank.rs
11
src/bank.rs
|
@ -137,6 +137,17 @@ impl Bank {
|
||||||
*sub = subscriptions
|
*sub = subscriptions
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn copy_for_tpu(&self) -> Self {
|
||||||
|
Self {
|
||||||
|
accounts: self.accounts.copy_for_tpu(),
|
||||||
|
last_ids: RwLock::new(self.last_ids.read().unwrap().clone()),
|
||||||
|
confirmation_time: AtomicUsize::new(self.confirmation_time()),
|
||||||
|
leader_scheduler: self.leader_scheduler.clone(),
|
||||||
|
storage_state: StorageState::new(),
|
||||||
|
subscriptions: RwLock::new(Box::new(Arc::new(LocalSubscriptions::default()))),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn process_genesis_block(&self, genesis_block: &GenesisBlock) {
|
fn process_genesis_block(&self, genesis_block: &GenesisBlock) {
|
||||||
assert!(genesis_block.mint_id != Pubkey::default());
|
assert!(genesis_block.mint_id != Pubkey::default());
|
||||||
assert!(genesis_block.tokens >= genesis_block.bootstrap_leader_tokens);
|
assert!(genesis_block.tokens >= genesis_block.bootstrap_leader_tokens);
|
||||||
|
|
|
@ -278,7 +278,7 @@ impl Fullnode {
|
||||||
};
|
};
|
||||||
|
|
||||||
let tpu = Tpu::new(
|
let tpu = Tpu::new(
|
||||||
&bank,
|
&Arc::new(bank.copy_for_tpu()),
|
||||||
Default::default(),
|
Default::default(),
|
||||||
node.sockets
|
node.sockets
|
||||||
.tpu
|
.tpu
|
||||||
|
@ -360,7 +360,7 @@ impl Fullnode {
|
||||||
let (to_validator_sender, to_validator_receiver) = channel();
|
let (to_validator_sender, to_validator_receiver) = channel();
|
||||||
self.role_notifiers.1 = to_validator_receiver;
|
self.role_notifiers.1 = to_validator_receiver;
|
||||||
self.node_services.tpu.switch_to_leader(
|
self.node_services.tpu.switch_to_leader(
|
||||||
&self.bank,
|
&Arc::new(self.bank.copy_for_tpu()),
|
||||||
Default::default(),
|
Default::default(),
|
||||||
self.tpu_sockets
|
self.tpu_sockets
|
||||||
.iter()
|
.iter()
|
||||||
|
|
|
@ -49,6 +49,7 @@ struct StatusEntry<T> {
|
||||||
statuses: StatusMap<T>,
|
statuses: StatusMap<T>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Clone)]
|
||||||
pub struct StatusDeque<T> {
|
pub struct StatusDeque<T> {
|
||||||
/// A FIFO queue of `last_id` items, where each item is a set of signatures
|
/// A FIFO queue of `last_id` items, where each item is a set of signatures
|
||||||
/// that have been processed using that `last_id`. Rejected `last_id`
|
/// that have been processed using that `last_id`. Rejected `last_id`
|
||||||
|
|
Loading…
Reference in New Issue