Extract snapshot to own crate (#11010)
* Move snapshot to own crate Sort out imports * WIP cargo toml * Make snapshotting generic over the client Sort out tests * Sort out types from blockchain and client * Sort out sync * Sort out imports and generics * Sort out main binary * Fix sync test-helpers * Sort out import for secret-store * Sort out more imports * Fix easy todos * cleanup * Cleanup * remove unneded workspace member * cleanup * Sort out test-helpers dependency on account-db * Update ethcore/client-traits/src/lib.rs Co-Authored-By: Niklas Adolfsson <niklasadolfsson1@gmail.com> * Update ethcore/snapshot/Cargo.toml
This commit is contained in:
@@ -29,6 +29,7 @@ use common_types::{
|
||||
blockchain_info::BlockChainInfo,
|
||||
BlockNumber,
|
||||
call_analytics::CallAnalytics,
|
||||
chain_notify::{NewBlocks, ChainMessageType},
|
||||
client_types::Mode,
|
||||
encoded,
|
||||
engines::{epoch::Transition as EpochTransition, machine::Executed},
|
||||
@@ -40,7 +41,7 @@ use common_types::{
|
||||
pruning_info::PruningInfo,
|
||||
receipt::LocalizedReceipt,
|
||||
trace_filter::Filter as TraceFilter,
|
||||
transaction::{self, LocalizedTransaction, CallError, SignedTransaction},
|
||||
transaction::{self, LocalizedTransaction, CallError, SignedTransaction, UnverifiedTransaction},
|
||||
tree_route::TreeRoute,
|
||||
verification::{VerificationQueueInfo, Unverified},
|
||||
};
|
||||
@@ -119,7 +120,7 @@ pub trait ChainInfo {
|
||||
}
|
||||
|
||||
/// Provides various information on a block by it's ID
|
||||
pub trait BlockInfo {
|
||||
pub trait BlockInfo: Send + Sync {
|
||||
/// Get raw block header data by block id.
|
||||
fn block_header(&self, id: BlockId) -> Option<encoded::Header>;
|
||||
|
||||
@@ -474,3 +475,38 @@ pub trait SnapshotWriter {
|
||||
/// with the chunks written.
|
||||
fn finish(self, manifest: common_types::snapshot::ManifestData) -> std::io::Result<()> where Self: Sized;
|
||||
}
|
||||
|
||||
|
||||
/// Represents what has to be handled by actor listening to chain events
|
||||
pub trait ChainNotify: Send + Sync {
|
||||
/// fires when chain has new blocks.
|
||||
fn new_blocks(&self, _new_blocks: NewBlocks) {
|
||||
// does nothing by default
|
||||
}
|
||||
|
||||
/// fires when chain achieves active mode
|
||||
fn start(&self) {
|
||||
// does nothing by default
|
||||
}
|
||||
|
||||
/// fires when chain achieves passive mode
|
||||
fn stop(&self) {
|
||||
// does nothing by default
|
||||
}
|
||||
|
||||
/// fires when chain broadcasts a message
|
||||
fn broadcast(&self, _message_type: ChainMessageType) {
|
||||
// does nothing by default
|
||||
}
|
||||
|
||||
/// fires when new block is about to be imported
|
||||
/// implementations should be light
|
||||
fn block_pre_import(&self, _bytes: &Bytes, _hash: &H256, _difficulty: &U256) {
|
||||
// does nothing by default
|
||||
}
|
||||
|
||||
/// fires when new transactions are received from a peer
|
||||
fn transactions_received(&self, _txs: &[UnverifiedTransaction], _peer_id: usize) {
|
||||
// does nothing by default
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user