Struct grin_p2p::DummyAdapter
source · pub struct DummyAdapter {}
Expand description
A no-op network adapter used for testing.
Trait Implementations§
source§impl ChainAdapter for DummyAdapter
impl ChainAdapter for DummyAdapter
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, _h: Hash) -> Option<Transaction>
fn tx_kernel_received( &self, _h: Hash, _peer_info: &PeerInfo ) -> Result<bool, Error>
source§fn transaction_received(
&self,
_: Transaction,
_stem: bool
) -> Result<bool, Error>
fn transaction_received( &self, _: Transaction, _stem: bool ) -> Result<bool, Error>
A valid transaction has been received from one of our peers
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 block_received(
&self,
_: Block,
_: &PeerInfo,
_: Options
) -> Result<bool, Error>
fn block_received( &self, _: Block, _: &PeerInfo, _: 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 headers_received(
&self,
_: &[BlockHeader],
_: &PeerInfo
) -> Result<bool, Error>
fn headers_received( &self, _: &[BlockHeader], _: &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, _: &[Hash]) -> Result<Vec<BlockHeader>, Error>
fn locate_headers(&self, _: &[Hash]) -> 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 get_block(&self, _: Hash, _: &PeerInfo) -> Option<Block>
fn get_block(&self, _: Hash, _: &PeerInfo) -> Option<Block>
Gets a full block by its hash.
Converts block to v2 compatibility if necessary (based on peer protocol version).
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 consistant state
at the provided block hash.
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_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 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 Grin 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
fn get_kernel_segment( &self, _hash: Hash, _id: SegmentIdentifier ) -> Result<Segment<TxKernel>, Error>
fn get_bitmap_segment( &self, _hash: Hash, _id: SegmentIdentifier ) -> Result<(Segment<BitmapChunk>, Hash), Error>
fn get_output_segment( &self, _hash: Hash, _id: SegmentIdentifier ) -> Result<(Segment<OutputIdentifier>, Hash), Error>
fn get_rangeproof_segment( &self, _hash: Hash, _id: SegmentIdentifier ) -> Result<Segment<RangeProof>, Error>
fn receive_bitmap_segment( &self, _block_hash: Hash, _output_root: Hash, _segment: Segment<BitmapChunk> ) -> Result<bool, Error>
fn receive_output_segment( &self, _block_hash: Hash, _bitmap_root: Hash, _segment: Segment<OutputIdentifier> ) -> Result<bool, Error>
fn receive_rangeproof_segment( &self, _block_hash: Hash, _segment: Segment<RangeProof> ) -> Result<bool, Error>
fn receive_kernel_segment( &self, _block_hash: Hash, _segment: Segment<TxKernel> ) -> Result<bool, Error>
source§impl NetAdapter for DummyAdapter
impl NetAdapter for DummyAdapter
source§fn find_peer_addrs(&self, _: Capabilities) -> Vec<PeerAddr>
fn find_peer_addrs(&self, _: Capabilities) -> Vec<PeerAddr>
Find good peers we know with the provided capability and return their
addresses.
source§fn peer_addrs_received(&self, _: Vec<PeerAddr>)
fn peer_addrs_received(&self, _: Vec<PeerAddr>)
A list of peers has been received from one of our peers.
source§fn peer_difficulty(&self, _: PeerAddr, _: Difficulty, _: u64)
fn peer_difficulty(&self, _: PeerAddr, _: Difficulty, _: u64)
Heard total_difficulty from a connected peer (via ping/pong).
Auto Trait Implementations§
impl RefUnwindSafe for DummyAdapter
impl Send for DummyAdapter
impl Sync for DummyAdapter
impl Unpin for DummyAdapter
impl UnwindSafe for DummyAdapter
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
§impl<T> SafeBorrow<T> for Twhere
T: ?Sized,
impl<T> SafeBorrow<T> for Twhere
T: ?Sized,
§fn borrow_replacement(ptr: &T) -> &T
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