Improve provided handling (#381)

* fix typos

* remove tributary sleeping

* handle not locally provided txs

* use topic number instead of waiting list

* Clean-up, fixes

1) Uses a single TXN in provided
2) Doesn't continue on non-local provided inside verify_block, skipping further
   execution of checks
3) Upon local provision of already on-chain TX, compares

---------

Co-authored-by: Luke Parker <lukeparker5132@gmail.com>
This commit is contained in:
akildemir
2023-10-14 02:45:47 +03:00
committed by GitHub
parent f6e8bc3352
commit d5c6ed1a03
12 changed files with 363 additions and 102 deletions

View File

@@ -62,7 +62,11 @@ impl ReadWrite for ProvidedTransaction {
impl Transaction for ProvidedTransaction {
fn kind(&self) -> TransactionKind<'_> {
TransactionKind::Provided("provided")
match self.0[0] {
1 => TransactionKind::Provided("order1"),
2 => TransactionKind::Provided("order2"),
_ => panic!("unknown order"),
}
}
fn hash(&self) -> [u8; 32] {
@@ -74,9 +78,17 @@ impl Transaction for ProvidedTransaction {
}
}
pub fn random_provided_transaction<R: RngCore + CryptoRng>(rng: &mut R) -> ProvidedTransaction {
pub fn random_provided_transaction<R: RngCore + CryptoRng>(
rng: &mut R,
order: &str,
) -> ProvidedTransaction {
let mut data = vec![0; 512];
rng.fill_bytes(&mut data);
data[0] = match order {
"order1" => 1,
"order2" => 2,
_ => panic!("unknown order"),
};
ProvidedTransaction(data)
}