mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-10 21:19:24 +00:00
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:
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user