From 8bf7a83f373a34070fb7765daaa7dd20fd28867c Mon Sep 17 00:00:00 2001 From: Paul Hauner Date: Fri, 29 Mar 2019 19:09:01 +1100 Subject: [PATCH] Rename op processing methods on BeaconChain --- beacon_node/beacon_chain/src/beacon_chain.rs | 28 ++++++++----------- .../test_harness/src/beacon_chain_harness.rs | 14 ++++------ 2 files changed, 16 insertions(+), 26 deletions(-) diff --git a/beacon_node/beacon_chain/src/beacon_chain.rs b/beacon_node/beacon_chain/src/beacon_chain.rs index 4d3ba9cab..d3b9e2bdc 100644 --- a/beacon_node/beacon_chain/src/beacon_chain.rs +++ b/beacon_node/beacon_chain/src/beacon_chain.rs @@ -6,7 +6,7 @@ use db::{ ClientDB, DBError, }; use fork_choice::{ForkChoice, ForkChoiceError}; -use log::{debug, trace, warn}; +use log::{debug, trace}; use operation_pool::DepositInsertStatus; use operation_pool::OperationPool; use parking_lot::{RwLock, RwLockReadGuard}; @@ -560,7 +560,7 @@ where } /// Accept some deposit and queue it for inclusion in an appropriate block. - pub fn receive_deposit_for_inclusion( + pub fn process_deposit( &self, deposit: Deposit, ) -> Result { @@ -570,27 +570,21 @@ where } /// Accept some exit and queue it for inclusion in an appropriate block. - pub fn receive_exit_for_inclusion( - &self, - exit: VoluntaryExit, - ) -> Result<(), ExitValidationError> { + pub fn process_voluntary_exit(&self, exit: VoluntaryExit) -> Result<(), ExitValidationError> { self.op_pool .write() .insert_voluntary_exit(exit, &*self.state.read(), &self.spec) } /// Accept some transfer and queue it for inclusion in an appropriate block. - pub fn receive_transfer_for_inclusion( - &self, - transfer: Transfer, - ) -> Result<(), TransferValidationError> { + pub fn process_transfer(&self, transfer: Transfer) -> Result<(), TransferValidationError> { self.op_pool .write() .insert_transfer(transfer, &*self.state.read(), &self.spec) } /// Accept some proposer slashing and queue it for inclusion in an appropriate block. - pub fn receive_proposer_slashing_for_inclusion( + pub fn process_proposer_slashing( &self, proposer_slashing: ProposerSlashing, ) -> Result<(), ProposerSlashingValidationError> { @@ -602,7 +596,7 @@ where } /// Accept some attester slashing and queue it for inclusion in an appropriate block. - pub fn receive_attester_slashing_for_inclusion( + pub fn process_attester_slashing( &self, attester_slashing: AttesterSlashing, ) -> Result<(), AttesterSlashingValidationError> { @@ -613,11 +607,6 @@ where ) } - /// Returns `true` if the given block root has not been processed. - pub fn is_new_block_root(&self, beacon_block_root: &Hash256) -> Result { - Ok(!self.block_store.exists(beacon_block_root)?) - } - /// Accept some block and attempt to add it to block DAG. /// /// Will accept blocks from prior slots, however it will reject any block from a future slot. @@ -817,6 +806,11 @@ where Ok(()) } + /// Returns `true` if the given block root has not been processed. + pub fn is_new_block_root(&self, beacon_block_root: &Hash256) -> Result { + Ok(!self.block_store.exists(beacon_block_root)?) + } + /// Dumps the entire canonical chain, from the head to genesis to a vector for analysis. /// /// This could be a very expensive operation and should only be done in testing/analysis diff --git a/beacon_node/beacon_chain/test_harness/src/beacon_chain_harness.rs b/beacon_node/beacon_chain/test_harness/src/beacon_chain_harness.rs index 0784e5fd3..7d6a690e0 100644 --- a/beacon_node/beacon_chain/test_harness/src/beacon_chain_harness.rs +++ b/beacon_node/beacon_chain/test_harness/src/beacon_chain_harness.rs @@ -285,9 +285,7 @@ impl BeaconChainHarness { /// If a new `ValidatorHarness` was created, the validator should become fully operational as /// if the validator were created during `BeaconChainHarness` instantiation. pub fn add_deposit(&mut self, deposit: Deposit, keypair: Option) { - self.beacon_chain - .receive_deposit_for_inclusion(deposit) - .unwrap(); + self.beacon_chain.process_deposit(deposit).unwrap(); // If a keypair is present, add a new `ValidatorHarness` to the rig. if let Some(keypair) = keypair { @@ -303,27 +301,25 @@ impl BeaconChainHarness { /// will stop receiving duties from the beacon chain and just do nothing when prompted to /// produce/attest. pub fn add_exit(&mut self, exit: VoluntaryExit) { - self.beacon_chain.receive_exit_for_inclusion(exit).unwrap(); + self.beacon_chain.process_voluntary_exit(exit).unwrap(); } /// Submit an transfer to the `BeaconChain` for inclusion in some block. pub fn add_transfer(&mut self, transfer: Transfer) { - self.beacon_chain - .receive_transfer_for_inclusion(transfer) - .unwrap(); + self.beacon_chain.process_transfer(transfer).unwrap(); } /// Submit a proposer slashing to the `BeaconChain` for inclusion in some block. pub fn add_proposer_slashing(&mut self, proposer_slashing: ProposerSlashing) { self.beacon_chain - .receive_proposer_slashing_for_inclusion(proposer_slashing) + .process_proposer_slashing(proposer_slashing) .unwrap(); } /// Submit an attester slashing to the `BeaconChain` for inclusion in some block. pub fn add_attester_slashing(&mut self, attester_slashing: AttesterSlashing) { self.beacon_chain - .receive_attester_slashing_for_inclusion(attester_slashing) + .process_attester_slashing(attester_slashing) .unwrap(); }