NetToChainAdapter

Struct NetToChainAdapter 

Source
pub struct NetToChainAdapter<B, P>
where B: BlockChain, P: PoolAdapter,
{ /* private fields */ }
Expand description

Implementation of the NetAdapter for the . Gets notified when new blocks and transactions are received and forwards to the chain and pool implementations.

Implementations§

Source§

impl<B, P> NetToChainAdapter<B, P>
where B: BlockChain, P: PoolAdapter,

Source

pub fn new( sync_state: Arc<SyncState>, chain: Arc<Chain>, tx_pool: Arc<RwLock<TransactionPool<B, P>>>, config: ServerConfig, hooks: Vec<Box<dyn NetEvents + Send + Sync>>, ) -> Self

Construct a new NetToChainAdapter instance

Source

pub fn init(&self, peers: Arc<Peers>)

Initialize a NetToChainAdaptor with reference to a Peers object. Should only be called once.

Trait Implementations§

Source§

impl<B, P> ChainAdapter for NetToChainAdapter<B, P>
where B: BlockChain, P: PoolAdapter,

Source§

fn get_block(&self, h: Hash) -> Option<Block>

Gets a full block by its hash.

Source§

fn txhashset_read(&self, h: Hash) -> Option<TxHashSetRead>

Provides a reading view into the current txhashset state as well as the required indexes for a consumer to rewind to a consistent state at the provided block hash.

Source§

fn txhashset_write( &self, h: Hash, txhashset_data: File, _peer_info: &PeerInfo, ) -> Result<bool, Error>

Writes a reading view on a txhashset state that’s been provided to us. If we’re willing to accept that new state, the data stream will be read as a zip file, unzipped and the resulting state files should be rewound to the provided indexes.

Source§

fn total_difficulty(&self) -> Result<Difficulty, Error>

Current total difficulty on our chain
Source§

fn total_height(&self) -> Result<u64, Error>

Current total height
Source§

fn total_header_height(&self) -> Result<u64, Error>

Current total header height
Source§

fn get_transaction(&self, kernel_hash: Hash) -> Option<Transaction>

Source§

fn tx_kernel_received( &self, kernel_hash: Hash, peer_info: &PeerInfo, ) -> Result<bool, Error>

Source§

fn transaction_received( &self, tx: Transaction, stem: bool, ) -> Result<bool, Error>

A valid transaction has been received from one of our peers
Source§

fn block_received( &self, b: Block, peer_info: &PeerInfo, opts: Options, ) -> Result<bool, Error>

A block has been received from one of our peers. Returns true if the block could be handled properly and is not deemed defective by the chain. Returning false means the block will never be valid and may result in the peer being banned.
Source§

fn compact_block_received( &self, cb: CompactBlock, peer_info: &PeerInfo, ) -> Result<bool, Error>

Source§

fn header_received( &self, bh: BlockHeader, peer_info: &PeerInfo, ) -> Result<bool, Error>

Source§

fn headers_received( &self, bhs: &[BlockHeader], peer_info: &PeerInfo, ) -> Result<bool, Error>

A set of block header has been received, typically in response to a block header request.
Source§

fn locate_headers( &self, locator: &[Hash], offset: &u8, ) -> Result<Vec<BlockHeader>, Error>

Finds a list of block headers based on the provided locator. Tries to identify the common chain and gets the headers that follow it immediately.
Source§

fn kernel_data_read(&self) -> Result<File, Error>

Source§

fn kernel_data_write(&self, reader: &mut dyn Read) -> Result<bool, Error>

Source§

fn txhashset_archive_header(&self) -> Result<BlockHeader, Error>

Header of the txhashset archive currently being served to peers.
Source§

fn txhashset_receive_ready(&self) -> bool

Whether the node is ready to accept a new txhashset. If this isn’t the case, the archive is provided without being requested and likely an attack attempt. This should be checked before downloading the whole state data.
Source§

fn txhashset_download_update( &self, start_time: DateTime<Utc>, downloaded_size: u64, total_size: u64, ) -> bool

Update txhashset downloading progress
Source§

fn get_tmp_dir(&self) -> PathBuf

Get the Epic specific tmp dir
Source§

fn get_tmpfile_pathname(&self, tmpfile_name: String) -> PathBuf

Get a tmp file path in above specific tmp dir (create tmp dir if not exist) Delete file if tmp file already exists

Auto Trait Implementations§

§

impl<B, P> Freeze for NetToChainAdapter<B, P>

§

impl<B, P> !RefUnwindSafe for NetToChainAdapter<B, P>

§

impl<B, P> Send for NetToChainAdapter<B, P>

§

impl<B, P> Sync for NetToChainAdapter<B, P>

§

impl<B, P> Unpin for NetToChainAdapter<B, P>

§

impl<B, P> !UnwindSafe for NetToChainAdapter<B, P>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> SafeBorrow<T> for T
where T: ?Sized,

Source§

fn borrow_replacement(ptr: &T) -> &T

Given ptr, which was obtained from a prior call to Self::borrow(), return a value with the same nominal lifetime which is guaranteed to survive mutations to Self. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> Erased for T

Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> UnsafeAny for T
where T: Any,