Add support for multiple orderings in Provided

Necessary as our Tributary chains needed to agree when a Serai block has
occurred, and when a Monero block has occurred. Since those could happen at the
same time, some validators may put SeraiBlock before ExternalBlock and vice
versa, causing a chain halt. Now they can have distinct ordering queues.
This commit is contained in:
Luke Parker
2023-04-20 07:30:49 -04:00
parent a26ca1a92f
commit 294ad08e00
8 changed files with 79 additions and 43 deletions

View File

@@ -1,4 +1,4 @@
use std::collections::VecDeque;
use std::collections::{VecDeque, HashMap};
use zeroize::Zeroizing;
use rand::{RngCore, rngs::OsRng};
@@ -187,10 +187,10 @@ fn provided_transaction() {
assert_eq!(txs.provide(tx.clone()), Err(ProvidedError::AlreadyProvided));
assert_eq!(
ProvidedTransactions::<_, ProvidedTransaction>::new(db.clone(), genesis).transactions,
VecDeque::from([tx.clone()]),
HashMap::from([("provided", VecDeque::from([tx.clone()]))]),
);
let mut txn = db.txn();
txs.complete(&mut txn, tx.hash());
txs.complete(&mut txn, "provided", tx.hash());
txn.commit();
assert!(ProvidedTransactions::<_, ProvidedTransaction>::new(db.clone(), genesis)
.transactions