[−][src]Trait grin_p2p::types::ChainAdapter
Bridge between the networking layer and the rest of the system. Handles the forwarding or querying of blocks and transactions from the network among other things.
Required methods
fn total_difficulty(&self) -> Result<Difficulty, Error>
Current total difficulty on our chain
fn total_height(&self) -> Result<u64, Error>
Current total height
fn transaction_received(
&self,
tx: Transaction,
stem: bool
) -> Result<bool, Error>
&self,
tx: Transaction,
stem: bool
) -> Result<bool, Error>
A valid transaction has been received from one of our peers
fn get_transaction(&self, kernel_hash: Hash) -> Option<Transaction>
fn tx_kernel_received(
&self,
kernel_hash: Hash,
peer_info: &PeerInfo
) -> Result<bool, Error>
&self,
kernel_hash: Hash,
peer_info: &PeerInfo
) -> Result<bool, Error>
fn block_received(
&self,
b: Block,
peer_info: &PeerInfo,
opts: Options
) -> Result<bool, Error>
&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>
&self,
cb: CompactBlock,
peer_info: &PeerInfo
) -> Result<bool, Error>
fn header_received(
&self,
bh: BlockHeader,
peer_info: &PeerInfo
) -> Result<bool, Error>
&self,
bh: BlockHeader,
peer_info: &PeerInfo
) -> Result<bool, Error>
fn headers_received(
&self,
bh: &[BlockHeader],
peer_info: &PeerInfo
) -> Result<bool, Error>
&self,
bh: &[BlockHeader],
peer_info: &PeerInfo
) -> Result<bool, Error>
A set of block header has been received, typically in response to a block header request.
fn locate_headers(&self, locator: &[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.
fn get_block(&self, h: Hash, peer_info: &PeerInfo) -> Option<Block>
Gets a full block by its hash. Converts block to v2 compatibility if necessary (based on peer protocol version).
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.
fn txhashset_archive_header(&self) -> Result<BlockHeader, Error>
Header of the txhashset archive currently being served to peers.
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.
fn txhashset_download_update(
&self,
start_time: DateTime<Utc>,
downloaded_size: u64,
total_size: u64
) -> bool
&self,
start_time: DateTime<Utc>,
downloaded_size: u64,
total_size: u64
) -> bool
Update txhashset downloading progress
fn txhashset_write(
&self,
h: Hash,
txhashset_data: File,
peer_peer_info: &PeerInfo
) -> Result<bool, Error>
&self,
h: Hash,
txhashset_data: File,
peer_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.
fn get_tmp_dir(&self) -> PathBuf
Get the Grin specific tmp dir
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
Implementors
impl ChainAdapter for DummyAdapter
[src]
fn total_difficulty(&self) -> Result<Difficulty, Error>
[src]
fn total_height(&self) -> Result<u64, Error>
[src]
fn get_transaction(&self, _h: Hash) -> Option<Transaction>
[src]
fn tx_kernel_received(
&self,
_h: Hash,
_peer_info: &PeerInfo
) -> Result<bool, Error>
[src]
&self,
_h: Hash,
_peer_info: &PeerInfo
) -> Result<bool, Error>
fn transaction_received(
&self,
_: Transaction,
_stem: bool
) -> Result<bool, Error>
[src]
&self,
_: Transaction,
_stem: bool
) -> Result<bool, Error>
fn compact_block_received(
&self,
_cb: CompactBlock,
_peer_info: &PeerInfo
) -> Result<bool, Error>
[src]
&self,
_cb: CompactBlock,
_peer_info: &PeerInfo
) -> Result<bool, Error>
fn header_received(
&self,
_bh: BlockHeader,
_peer_info: &PeerInfo
) -> Result<bool, Error>
[src]
&self,
_bh: BlockHeader,
_peer_info: &PeerInfo
) -> Result<bool, Error>
fn block_received(
&self,
_: Block,
_: &PeerInfo,
_: Options
) -> Result<bool, Error>
[src]
&self,
_: Block,
_: &PeerInfo,
_: Options
) -> Result<bool, Error>
fn headers_received(
&self,
_: &[BlockHeader],
_: &PeerInfo
) -> Result<bool, Error>
[src]
&self,
_: &[BlockHeader],
_: &PeerInfo
) -> Result<bool, Error>
fn locate_headers(&self, _: &[Hash]) -> Result<Vec<BlockHeader>, Error>
[src]
fn get_block(&self, _: Hash, _: &PeerInfo) -> Option<Block>
[src]
fn txhashset_read(&self, _h: Hash) -> Option<TxHashSetRead>
[src]
fn txhashset_archive_header(&self) -> Result<BlockHeader, Error>
[src]
fn txhashset_receive_ready(&self) -> bool
[src]
fn txhashset_write(
&self,
_h: Hash,
_txhashset_data: File,
_peer_info: &PeerInfo
) -> Result<bool, Error>
[src]
&self,
_h: Hash,
_txhashset_data: File,
_peer_info: &PeerInfo
) -> Result<bool, Error>
fn txhashset_download_update(
&self,
_start_time: DateTime<Utc>,
_downloaded_size: u64,
_total_size: u64
) -> bool
[src]
&self,
_start_time: DateTime<Utc>,
_downloaded_size: u64,
_total_size: u64
) -> bool
fn get_tmp_dir(&self) -> PathBuf
[src]
fn get_tmpfile_pathname(&self, _tmpfile_name: String) -> PathBuf
[src]
impl ChainAdapter for Peers
[src]
fn total_difficulty(&self) -> Result<Difficulty, Error>
[src]
fn total_height(&self) -> Result<u64, Error>
[src]
fn get_transaction(&self, kernel_hash: Hash) -> Option<Transaction>
[src]
fn tx_kernel_received(
&self,
kernel_hash: Hash,
peer_info: &PeerInfo
) -> Result<bool, Error>
[src]
&self,
kernel_hash: Hash,
peer_info: &PeerInfo
) -> Result<bool, Error>
fn transaction_received(
&self,
tx: Transaction,
stem: bool
) -> Result<bool, Error>
[src]
&self,
tx: Transaction,
stem: bool
) -> Result<bool, Error>
fn block_received(
&self,
b: Block,
peer_info: &PeerInfo,
opts: Options
) -> Result<bool, Error>
[src]
&self,
b: Block,
peer_info: &PeerInfo,
opts: Options
) -> Result<bool, Error>
fn compact_block_received(
&self,
cb: CompactBlock,
peer_info: &PeerInfo
) -> Result<bool, Error>
[src]
&self,
cb: CompactBlock,
peer_info: &PeerInfo
) -> Result<bool, Error>
fn header_received(
&self,
bh: BlockHeader,
peer_info: &PeerInfo
) -> Result<bool, Error>
[src]
&self,
bh: BlockHeader,
peer_info: &PeerInfo
) -> Result<bool, Error>
fn headers_received(
&self,
headers: &[BlockHeader],
peer_info: &PeerInfo
) -> Result<bool, Error>
[src]
&self,
headers: &[BlockHeader],
peer_info: &PeerInfo
) -> Result<bool, Error>
fn locate_headers(&self, hs: &[Hash]) -> Result<Vec<BlockHeader>, Error>
[src]
fn get_block(&self, h: Hash, peer_info: &PeerInfo) -> Option<Block>
[src]
fn txhashset_read(&self, h: Hash) -> Option<TxHashSetRead>
[src]
fn txhashset_archive_header(&self) -> Result<BlockHeader, Error>
[src]
fn txhashset_receive_ready(&self) -> bool
[src]
fn txhashset_write(
&self,
h: Hash,
txhashset_data: File,
peer_info: &PeerInfo
) -> Result<bool, Error>
[src]
&self,
h: Hash,
txhashset_data: File,
peer_info: &PeerInfo
) -> Result<bool, Error>
fn txhashset_download_update(
&self,
start_time: DateTime<Utc>,
downloaded_size: u64,
total_size: u64
) -> bool
[src]
&self,
start_time: DateTime<Utc>,
downloaded_size: u64,
total_size: u64
) -> bool