Add a UID function to messages

When we receive messages, we're provided with a message ID we can use to
prevent handling an item multiple times. That doesn't prevent us from *sending*
an item multiple times though. Thanks to the UID system, we can now not send if
already present.

Alternatively, we can remove the ordered message ID for just the UID, allowing
duplicates to be sent without issue, and handled on the receiving end.
This commit is contained in:
Luke Parker
2023-04-25 02:36:20 -04:00
parent 09d96822ca
commit cc531d630e
5 changed files with 173 additions and 12 deletions

View File

@@ -383,6 +383,7 @@ async fn handle_coordinator_msg<D: Db, C: Coin, Co: Coordinator>(
messages::substrate::CoordinatorMessage::SubstrateBlock {
context,
network,
block,
key: key_vec,
burns,
@@ -408,7 +409,11 @@ async fn handle_coordinator_msg<D: Db, C: Coin, Co: Coordinator>(
instruction: OutInstruction { address, data },
balance,
} = out;
// TODO: Check network is this coin's network
assert_eq!(balance.coin.network(), network);
if let Ok(address) = C::Address::try_from(address.consume()) {
// TODO: Add coin to payment
payments.push(Payment {
address,
data: data.map(|data| data.consume()),
@@ -426,6 +431,7 @@ async fn handle_coordinator_msg<D: Db, C: Coin, Co: Coordinator>(
coordinator
.send(ProcessorMessage::Coordinator(
messages::coordinator::ProcessorMessage::SubstrateBlockAck {
network,
block,
plans: plans.iter().map(|plan| plan.id()).collect(),
},