some more sync boilerplate

This commit is contained in:
realbigsean
2022-02-20 07:22:46 -07:00
parent 4008da6c60
commit ebc0ccd02a
6 changed files with 78 additions and 6 deletions

View File

@@ -53,7 +53,7 @@ use std::ops::Sub;
use std::sync::Arc;
use std::time::Duration;
use tokio::sync::mpsc;
use types::{EthSpec, Hash256, SignedBeaconBlock, Slot};
use types::{BlobWrapper, Epoch, EthSpec, Hash256, SignedBeaconBlock, Slot};
/// The number of slots ahead of us that is allowed before requesting a long-range (batch) Sync
/// from a peer. If a peer is within this tolerance (forwards or backwards), it is treated as a
@@ -88,6 +88,18 @@ pub enum SyncMessage<T: EthSpec> {
/// A block has been received from the RPC.
RpcBlock {
request_id: RequestId,
beacon_block: Option<Box<SignedBeaconBlock<T>>>,
},
/// A [`TxBlobsByRangeResponse`] response has been received.
TxBlobsByRangeResponse {
peer_id: PeerId,
request_id: RequestId,
blob_wrapper: Option<Box<BlobWrapper<T>>>,
},
/// A [`BlocksByRoot`] response has been received.
BlocksByRootResponse {
peer_id: PeerId,
beacon_block: Option<Arc<SignedBeaconBlock<T>>>,
seen_timestamp: Duration,

View File

@@ -55,7 +55,7 @@ use lru_cache::LRUTimeCache;
use slog::{crit, debug, trace, warn};
use std::collections::HashMap;
use std::sync::Arc;
use types::{Epoch, EthSpec, Hash256, SignedBeaconBlock, Slot};
use types::{BlobWrapper, Epoch, EthSpec, Hash256, SignedBeaconBlock, Slot};
/// For how long we store failed finalized chains to prevent retries.
const FAILED_CHAINS_EXPIRY_SECONDS: u64 = 30;