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

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 get_transaction(&self, _h: Hash) -> Option<Transaction>

source§

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

source§

fn transaction_received( &self, _: Transaction, _stem: bool ) -> Result<bool, Error>

A valid transaction has been received from one of our peers
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 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>

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>

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>

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>

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>

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_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

Update txhashset downloading progress
source§

fn get_tmp_dir(&self) -> PathBuf

Get the Grin 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
source§

fn get_kernel_segment( &self, _hash: Hash, _id: SegmentIdentifier ) -> Result<Segment<TxKernel>, Error>

source§

fn get_bitmap_segment( &self, _hash: Hash, _id: SegmentIdentifier ) -> Result<(Segment<BitmapChunk>, Hash), Error>

source§

fn get_output_segment( &self, _hash: Hash, _id: SegmentIdentifier ) -> Result<(Segment<OutputIdentifier>, Hash), Error>

source§

fn get_rangeproof_segment( &self, _hash: Hash, _id: SegmentIdentifier ) -> Result<Segment<RangeProof>, Error>

source§

fn receive_bitmap_segment( &self, _block_hash: Hash, _output_root: Hash, _segment: Segment<BitmapChunk> ) -> Result<bool, Error>

source§

fn receive_output_segment( &self, _block_hash: Hash, _bitmap_root: Hash, _segment: Segment<OutputIdentifier> ) -> Result<bool, Error>

source§

fn receive_rangeproof_segment( &self, _block_hash: Hash, _segment: Segment<RangeProof> ) -> Result<bool, Error>

source§

fn receive_kernel_segment( &self, _block_hash: Hash, _segment: Segment<TxKernel> ) -> Result<bool, Error>

source§

impl NetAdapter for DummyAdapter

source§

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>)

A list of peers has been received from one of our peers.
source§

fn peer_difficulty(&self, _: PeerAddr, _: Difficulty, _: u64)

Heard total_difficulty from a connected peer (via ping/pong).
source§

fn is_banned(&self, _: PeerAddr) -> bool

Is this peer currently banned?

Auto Trait Implementations§

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, 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.

§

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

§

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

§

type Output = T

Should always be Self
source§

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

§

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>,

§

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.
§

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