Check for transaction forwarding delay to detect an expired transaction before forwarding it (#4249)

Also refactored code for forwarding packets, and added test for it
This commit is contained in:
Pankaj Garg
2019-05-10 14:28:38 -07:00
committed by GitHub
parent 06a93dcb43
commit 133be2df51
2 changed files with 61 additions and 10 deletions

View File

@ -24,6 +24,10 @@ pub const MAX_HASH_AGE_IN_SECONDS: usize = 120;
// This must be <= MAX_HASH_AGE_IN_SECONDS, otherwise there's risk for DuplicateSignature errors
pub const MAX_RECENT_BLOCKHASHES: usize = MAX_HASH_AGE_IN_SECONDS;
/// This is maximum time consumed in forwarding a transaction from one node to next, before
/// it can be processed in the target node
pub const MAX_TRANSACTION_FORWARDING_DELAY: usize = 3;
pub fn duration_as_ns(d: &Duration) -> u64 {
d.as_secs() * 1_000_000_000 + u64::from(d.subsec_nanos())
}