Skip to content

Commit

Permalink
Implement only sending one notification at a time as per RFC 56 (pari…
Browse files Browse the repository at this point in the history
…tytech#2813)

cc paritytech#2812
cc polkadot-fellows/RFCs#56

Since this is a one line of code change, and for the sake of this not
taking six months to be done, I've opted to open a PR myself.

---------

Co-authored-by: Aaro Altonen <48052676+altonen@users.noreply.github.com>
  • Loading branch information
tomaka and altonen authored Jan 2, 2024
1 parent e3b824c commit 8a443ed
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion substrate/client/network/transactions/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,20 @@ where
propagated_to.entry(hash).or_default().push(who.to_base58());
}
trace!(target: "sync", "Sending {} transactions to {}", to_send.len(), who);
let _ = self.notification_service.send_sync_notification(who, to_send.encode());
// Historically, the format of a notification of the transactions protocol
// consisted in a (SCALE-encoded) `Vec<Transaction>`.
// After RFC 56, the format was modified in a backwards-compatible way to be
// a (SCALE-encoded) tuple `(Compact(1), Transaction)`, which is the same encoding
// as a `Vec` of length one. This is no coincidence, as the change was
// intentionally done in a backwards-compatible way.
// In other words, the `Vec` that is sent below **must** always have only a single
// element in it.
// See <https://github.com/polkadot-fellows/RFCs/blob/main/text/0056-one-transaction-per-notification.md>
for to_send in to_send {
let _ = self
.notification_service
.send_sync_notification(who, vec![to_send].encode());
}
}
}

Expand Down

0 comments on commit 8a443ed

Please sign in to comment.