mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-27 13:57:58 +00:00
Add block announce validator. (#3346)
* Add `BlockAnnounceValidator` trait. * Add associated data to block announcement. * Make tests compile. * Move validator into `sync.rs`. * Smaller changes. * Update core/network/src/protocol.rs Co-Authored-By: Kian Paimani <5588131+kianenigma@users.noreply.github.com> * Update core/network/src/protocol.rs Co-Authored-By: Bastian Köcher <bkchr@users.noreply.github.com> * Update core/network/src/test/sync.rs Co-Authored-By: Bastian Köcher <bkchr@users.noreply.github.com> * Formatting. * Remove assoc. data from `BlockImportNotification`. * Use `Option<Vec<u8>>` for associated data. * Update core/network/src/protocol/sync.rs Co-Authored-By: Bastian Köcher <bkchr@users.noreply.github.com> * Fix type error.
This commit is contained in:
committed by
Bastian Köcher
parent
4888c253a3
commit
af0d71d389
@@ -47,7 +47,7 @@ use state_machine::{
|
||||
};
|
||||
use executor::{RuntimeVersion, RuntimeInfo};
|
||||
use consensus::{
|
||||
Error as ConsensusError, BlockImportParams,
|
||||
Error as ConsensusError, BlockStatus, BlockImportParams,
|
||||
ImportResult, BlockOrigin, ForkChoiceStrategy,
|
||||
SelectChain, self,
|
||||
};
|
||||
@@ -171,21 +171,6 @@ pub struct ClientInfo<Block: BlockT> {
|
||||
pub used_state_cache_size: Option<usize>,
|
||||
}
|
||||
|
||||
/// Block status.
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub enum BlockStatus {
|
||||
/// Added to the import queue.
|
||||
Queued,
|
||||
/// Already in the blockchain and the state is available.
|
||||
InChainWithState,
|
||||
/// In the blockchain, but the state is not available.
|
||||
InChainPruned,
|
||||
/// Block or parent is known to be bad.
|
||||
KnownBad,
|
||||
/// Not in the queue or the blockchain.
|
||||
Unknown,
|
||||
}
|
||||
|
||||
/// Summary of an imported block
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct BlockImportNotification<Block: BlockT> {
|
||||
@@ -1187,10 +1172,7 @@ impl<B, E, Block, RA> Client<B, E, Block, RA> where
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn notify_imported(
|
||||
&self,
|
||||
notify_import: ImportSummary<Block>,
|
||||
) -> error::Result<()> {
|
||||
fn notify_imported(&self, notify_import: ImportSummary<Block>) -> error::Result<()> {
|
||||
if let Some(storage_changes) = notify_import.storage_changes {
|
||||
// TODO [ToDr] How to handle re-orgs? Should we re-emit all storage changes?
|
||||
self.storage_notifications.lock()
|
||||
@@ -1839,6 +1821,16 @@ pub mod utils {
|
||||
}
|
||||
}
|
||||
|
||||
impl<BE, E, B, RA> consensus::block_validation::Chain<B> for Client<BE, E, B, RA>
|
||||
where BE: backend::Backend<B, Blake2Hasher>,
|
||||
E: CallExecutor<B, Blake2Hasher>,
|
||||
B: BlockT<Hash = H256>
|
||||
{
|
||||
fn block_status(&self, id: &BlockId<B>) -> Result<BlockStatus, Box<dyn std::error::Error + Send>> {
|
||||
Client::block_status(self, id).map_err(|e| Box::new(e) as Box<_>)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
pub(crate) mod tests {
|
||||
use std::collections::HashMap;
|
||||
|
||||
Reference in New Issue
Block a user