Correct publication of Completed Tributary TXs

This commit is contained in:
Luke Parker 2023-09-02 00:50:54 -04:00
parent fddc605c65
commit cd4c3a6c88
No known key found for this signature in database
3 changed files with 13 additions and 2 deletions

View file

@ -748,6 +748,13 @@ pub async fn handle_processors<D: Db, Pro: Processors, P: P2p>(
panic!("provided an invalid transaction: {res:?}");
}
}
TransactionKind::Unsigned => {
log::trace!("publishing unsigned transaction {}", hex::encode(tx.hash()));
// Ignores the result since we can't differentiate already in-mempool from already
// on-chain from invalid
// TODO: Don't ignore the result
tributary.add_transaction(tx).await;
}
TransactionKind::Signed(_) => {
// Get the next nonce
// TODO: This should be deterministic, not just DB-backed, to allow rebuilding validators
@ -767,7 +774,6 @@ pub async fn handle_processors<D: Db, Pro: Processors, P: P2p>(
// txn.commit();
}
_ => panic!("created an unexpected transaction"),
}
}

View file

@ -550,6 +550,11 @@ pub async fn handle_application_tx<
}
}
Transaction::SignCompleted { plan, tx_hash, .. } => {
log::info!(
"on-chain SignCompleted claims {} completes {}",
hex::encode(&tx_hash),
hex::encode(plan)
);
// TODO: Confirm this is a valid plan ID
// TODO: Confirm this signer hasn't prior published a completion
let Some(key_pair) = TributaryDb::<D>::key_pair(txn, spec.set()) else { todo!() };

View file

@ -221,7 +221,7 @@ impl<D: Db, T: TransactionTrait, P: P2p> Tributary<D, T, P> {
self.network.blockchain.read().await.next_nonce(signer)
}
// Returns if the transaction was valid.
// Returns if the transaction was new and valid.
// Safe to be &self since the only meaningful usage of self is self.network.blockchain which
// successfully acquires its own write lock
pub async fn add_transaction(&self, tx: T) -> bool {