From 8b1a91e9eec1d11ad833586ad43526eb465c6f21 Mon Sep 17 00:00:00 2001 From: Paul Hauner Date: Fri, 29 Mar 2019 18:40:50 +1100 Subject: [PATCH] Add `process_attestation` to `BeaconChain` --- beacon_node/beacon_chain/src/beacon_chain.rs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/beacon_node/beacon_chain/src/beacon_chain.rs b/beacon_node/beacon_chain/src/beacon_chain.rs index 1d0cfe8e3..5eadb3763 100644 --- a/beacon_node/beacon_chain/src/beacon_chain.rs +++ b/beacon_node/beacon_chain/src/beacon_chain.rs @@ -541,6 +541,17 @@ where Ok(aggregation_outcome) } + /// Accept a new attestation from the network. + /// + /// If valid, the attestation is added to the `op_pool` and aggregated with another attestation + /// if possible. + pub fn process_attestation(&self, attestation: Attestation) { + let _ = + self.op_pool + .write() + .insert_attestation(attestation, &*self.state.read(), &self.spec); + } + /// Accept some deposit and queue it for inclusion in an appropriate block. pub fn receive_deposit_for_inclusion(&self, deposit: Deposit) { // Bad deposits are ignored. @@ -701,9 +712,9 @@ where trace!("Finding attestations for new block..."); let attestations = self - .attestation_aggregator + .op_pool .read() - .get_attestations_for_state(&state, &self.spec); + .get_attestations(&*self.state.read(), &self.spec); trace!( "Inserting {} attestation(s) into new block.",