Rename op processing methods on BeaconChain
This commit is contained in:
parent
2b53851062
commit
8bf7a83f37
@ -6,7 +6,7 @@ use db::{
|
|||||||
ClientDB, DBError,
|
ClientDB, DBError,
|
||||||
};
|
};
|
||||||
use fork_choice::{ForkChoice, ForkChoiceError};
|
use fork_choice::{ForkChoice, ForkChoiceError};
|
||||||
use log::{debug, trace, warn};
|
use log::{debug, trace};
|
||||||
use operation_pool::DepositInsertStatus;
|
use operation_pool::DepositInsertStatus;
|
||||||
use operation_pool::OperationPool;
|
use operation_pool::OperationPool;
|
||||||
use parking_lot::{RwLock, RwLockReadGuard};
|
use parking_lot::{RwLock, RwLockReadGuard};
|
||||||
@ -560,7 +560,7 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Accept some deposit and queue it for inclusion in an appropriate block.
|
/// Accept some deposit and queue it for inclusion in an appropriate block.
|
||||||
pub fn receive_deposit_for_inclusion(
|
pub fn process_deposit(
|
||||||
&self,
|
&self,
|
||||||
deposit: Deposit,
|
deposit: Deposit,
|
||||||
) -> Result<DepositInsertStatus, DepositValidationError> {
|
) -> Result<DepositInsertStatus, DepositValidationError> {
|
||||||
@ -570,27 +570,21 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Accept some exit and queue it for inclusion in an appropriate block.
|
/// Accept some exit and queue it for inclusion in an appropriate block.
|
||||||
pub fn receive_exit_for_inclusion(
|
pub fn process_voluntary_exit(&self, exit: VoluntaryExit) -> Result<(), ExitValidationError> {
|
||||||
&self,
|
|
||||||
exit: VoluntaryExit,
|
|
||||||
) -> Result<(), ExitValidationError> {
|
|
||||||
self.op_pool
|
self.op_pool
|
||||||
.write()
|
.write()
|
||||||
.insert_voluntary_exit(exit, &*self.state.read(), &self.spec)
|
.insert_voluntary_exit(exit, &*self.state.read(), &self.spec)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Accept some transfer and queue it for inclusion in an appropriate block.
|
/// Accept some transfer and queue it for inclusion in an appropriate block.
|
||||||
pub fn receive_transfer_for_inclusion(
|
pub fn process_transfer(&self, transfer: Transfer) -> Result<(), TransferValidationError> {
|
||||||
&self,
|
|
||||||
transfer: Transfer,
|
|
||||||
) -> Result<(), TransferValidationError> {
|
|
||||||
self.op_pool
|
self.op_pool
|
||||||
.write()
|
.write()
|
||||||
.insert_transfer(transfer, &*self.state.read(), &self.spec)
|
.insert_transfer(transfer, &*self.state.read(), &self.spec)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Accept some proposer slashing and queue it for inclusion in an appropriate block.
|
/// 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,
|
&self,
|
||||||
proposer_slashing: ProposerSlashing,
|
proposer_slashing: ProposerSlashing,
|
||||||
) -> Result<(), ProposerSlashingValidationError> {
|
) -> Result<(), ProposerSlashingValidationError> {
|
||||||
@ -602,7 +596,7 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Accept some attester slashing and queue it for inclusion in an appropriate block.
|
/// 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,
|
&self,
|
||||||
attester_slashing: AttesterSlashing,
|
attester_slashing: AttesterSlashing,
|
||||||
) -> Result<(), AttesterSlashingValidationError> {
|
) -> 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<bool, Error> {
|
|
||||||
Ok(!self.block_store.exists(beacon_block_root)?)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Accept some block and attempt to add it to block DAG.
|
/// 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.
|
/// Will accept blocks from prior slots, however it will reject any block from a future slot.
|
||||||
@ -817,6 +806,11 @@ where
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns `true` if the given block root has not been processed.
|
||||||
|
pub fn is_new_block_root(&self, beacon_block_root: &Hash256) -> Result<bool, Error> {
|
||||||
|
Ok(!self.block_store.exists(beacon_block_root)?)
|
||||||
|
}
|
||||||
|
|
||||||
/// Dumps the entire canonical chain, from the head to genesis to a vector for analysis.
|
/// 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
|
/// This could be a very expensive operation and should only be done in testing/analysis
|
||||||
|
@ -285,9 +285,7 @@ impl BeaconChainHarness {
|
|||||||
/// If a new `ValidatorHarness` was created, the validator should become fully operational as
|
/// If a new `ValidatorHarness` was created, the validator should become fully operational as
|
||||||
/// if the validator were created during `BeaconChainHarness` instantiation.
|
/// if the validator were created during `BeaconChainHarness` instantiation.
|
||||||
pub fn add_deposit(&mut self, deposit: Deposit, keypair: Option<Keypair>) {
|
pub fn add_deposit(&mut self, deposit: Deposit, keypair: Option<Keypair>) {
|
||||||
self.beacon_chain
|
self.beacon_chain.process_deposit(deposit).unwrap();
|
||||||
.receive_deposit_for_inclusion(deposit)
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
// If a keypair is present, add a new `ValidatorHarness` to the rig.
|
// If a keypair is present, add a new `ValidatorHarness` to the rig.
|
||||||
if let Some(keypair) = keypair {
|
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
|
/// will stop receiving duties from the beacon chain and just do nothing when prompted to
|
||||||
/// produce/attest.
|
/// produce/attest.
|
||||||
pub fn add_exit(&mut self, exit: VoluntaryExit) {
|
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.
|
/// Submit an transfer to the `BeaconChain` for inclusion in some block.
|
||||||
pub fn add_transfer(&mut self, transfer: Transfer) {
|
pub fn add_transfer(&mut self, transfer: Transfer) {
|
||||||
self.beacon_chain
|
self.beacon_chain.process_transfer(transfer).unwrap();
|
||||||
.receive_transfer_for_inclusion(transfer)
|
|
||||||
.unwrap();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Submit a proposer slashing to the `BeaconChain` for inclusion in some block.
|
/// Submit a proposer slashing to the `BeaconChain` for inclusion in some block.
|
||||||
pub fn add_proposer_slashing(&mut self, proposer_slashing: ProposerSlashing) {
|
pub fn add_proposer_slashing(&mut self, proposer_slashing: ProposerSlashing) {
|
||||||
self.beacon_chain
|
self.beacon_chain
|
||||||
.receive_proposer_slashing_for_inclusion(proposer_slashing)
|
.process_proposer_slashing(proposer_slashing)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Submit an attester slashing to the `BeaconChain` for inclusion in some block.
|
/// Submit an attester slashing to the `BeaconChain` for inclusion in some block.
|
||||||
pub fn add_attester_slashing(&mut self, attester_slashing: AttesterSlashing) {
|
pub fn add_attester_slashing(&mut self, attester_slashing: AttesterSlashing) {
|
||||||
self.beacon_chain
|
self.beacon_chain
|
||||||
.receive_attester_slashing_for_inclusion(attester_slashing)
|
.process_attester_slashing(attester_slashing)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user