Limit transaction pool size (#1676)

* Avoid excessive hashing. Store extrinsic len.

* Implement pool limits.

* Fix issues.

* Make sure we return error in case it doesn't make into the pool.

* Pass parameters from CLI.

* Remove redundant todo.

* Fix tests.
This commit is contained in:
Tomasz Drwięga
2019-02-06 19:03:05 +01:00
committed by Gav Wood
parent 461cd384fc
commit 4e3eace15f
14 changed files with 398 additions and 38 deletions
+4 -2
View File
@@ -75,7 +75,9 @@ impl<T, Block> txpool::ChainApi for ChainApi<T, Block> where
Ok(self.client.block_hash_from_id(at)?)
}
fn hash(&self, ex: &txpool::ExtrinsicFor<Self>) -> Self::Hash {
Blake2Hasher::hash(&ex.encode())
fn hash_and_length(&self, ex: &txpool::ExtrinsicFor<Self>) -> (Self::Hash, usize) {
ex.using_encoded(|x| {
(Blake2Hasher::hash(x), x.len())
})
}
}