complete various todos in tributary (#520)

* complete various todos

* fix pr comments

* Document bounds on unique hashes in TransactionKind

---------

Co-authored-by: Luke Parker <lukeparker5132@gmail.com>
This commit is contained in:
akildemir
2024-02-05 11:50:55 +03:00
committed by GitHub
parent af12cec3b9
commit ad0ecc5185
11 changed files with 184 additions and 165 deletions

View File

@@ -175,9 +175,8 @@ impl<T: TransactionTrait> Block<T> {
mut locally_provided: HashMap<&'static str, VecDeque<T>>,
get_and_increment_nonce: &mut G,
schema: &N::SignatureScheme,
commit: impl Fn(u32) -> Option<Commit<N::SignatureScheme>>,
unsigned_in_chain: impl Fn([u8; 32]) -> bool,
provided_in_chain: impl Fn([u8; 32]) -> bool, // TODO: merge this with unsigned_on_chain?
commit: impl Fn(u64) -> Option<Commit<N::SignatureScheme>>,
provided_or_unsigned_in_chain: impl Fn([u8; 32]) -> bool,
allow_non_local_provided: bool,
) -> Result<(), BlockError> {
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
@@ -213,7 +212,7 @@ impl<T: TransactionTrait> Block<T> {
let current_tx_order = match tx.kind() {
TransactionKind::Provided(order) => {
if provided_in_chain(tx_hash) {
if provided_or_unsigned_in_chain(tx_hash) {
Err(BlockError::ProvidedAlreadyIncluded)?;
}
@@ -233,7 +232,7 @@ impl<T: TransactionTrait> Block<T> {
}
TransactionKind::Unsigned => {
// check we don't already have the tx in the chain
if unsigned_in_chain(tx_hash) || included_in_block.contains(&tx_hash) {
if provided_or_unsigned_in_chain(tx_hash) || included_in_block.contains(&tx_hash) {
Err(BlockError::UnsignedAlreadyIncluded)?;
}
included_in_block.insert(tx_hash);