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