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,
impl<B, P> NetToChainAdapter<B, P>where
B: BlockChain,
P: PoolAdapter,
Trait Implementations§
Source§impl<B, P> ChainAdapter for NetToChainAdapter<B, P>where
B: BlockChain,
P: PoolAdapter,
impl<B, P> ChainAdapter for NetToChainAdapter<B, P>where
B: BlockChain,
P: PoolAdapter,
Source§fn txhashset_read(&self, h: Hash) -> Option<TxHashSetRead>
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>
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>
fn total_difficulty(&self) -> Result<Difficulty, Error>
Current total difficulty on our chain
fn get_transaction(&self, kernel_hash: Hash) -> Option<Transaction>
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>
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>
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.
fn compact_block_received( &self, cb: CompactBlock, peer_info: &PeerInfo, ) -> Result<bool, Error>
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>
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>
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.
fn kernel_data_read(&self) -> Result<File, Error>
fn kernel_data_write(&self, reader: &mut dyn Read) -> Result<bool, Error>
Source§fn txhashset_archive_header(&self) -> Result<BlockHeader, Error>
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
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
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
fn get_tmp_dir(&self) -> PathBuf
Get the Epic specific tmp dir
Source§fn get_tmpfile_pathname(&self, tmpfile_name: String) -> PathBuf
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more