mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-29 17:17:56 +00:00
Fix transaction pruning in tx-pool (#6276)
The `tree_route` generated by the import notification is only from the old best block to the new best parent. This means, it does not contain the new best block in `enacted()`. We need to prune the transactions of the new best block "manually" to fix this bug. Besides that, this pr also changed the `id` parameter of the `NewBlock` chain event to `hash`. The hash of a block is unique in contrast to the block number. (Block id can either be number or hash)
This commit is contained in:
@@ -234,7 +234,7 @@ pub struct BlockImportNotification<Block: BlockT> {
|
||||
pub header: Block::Header,
|
||||
/// Is this the new best block.
|
||||
pub is_new_best: bool,
|
||||
/// Tree route from old best to new best.
|
||||
/// Tree route from old best to new best parent.
|
||||
///
|
||||
/// If `None`, there was no re-org while importing.
|
||||
pub tree_route: Option<Arc<sp_blockchain::TreeRoute<Block>>>,
|
||||
@@ -248,3 +248,22 @@ pub struct FinalityNotification<Block: BlockT> {
|
||||
/// Imported block header.
|
||||
pub header: Block::Header,
|
||||
}
|
||||
|
||||
impl<B: BlockT> From<BlockImportNotification<B>> for sp_transaction_pool::ChainEvent<B> {
|
||||
fn from(n: BlockImportNotification<B>) -> Self {
|
||||
Self::NewBlock {
|
||||
is_new_best: n.is_new_best,
|
||||
hash: n.hash,
|
||||
header: n.header,
|
||||
tree_route: n.tree_route,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<B: BlockT> From<FinalityNotification<B>> for sp_transaction_pool::ChainEvent<B> {
|
||||
fn from(n: FinalityNotification<B>) -> Self {
|
||||
Self::Finalized {
|
||||
hash: n.hash,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user