Closed afck closed 5 years ago
Adding some more detail to this, I think removing peers can be done on ChangeState::Complete(Change::NodeChange(pub_keys))
:
by first adding those existing validators not in pub_keys
to this new map, call it last_epochs
;
for each such validator, sending all messages to it up to its last epoch (this implies that the sending node has advanced past the last epoch), then removing that validator from both peer_epochs
and last_epochs
.
The sender queue already automatically adds peers based on
StateChange::InProgress
, so that joining nodes are guaranteed to receive their messages. It should also remove peers that have left the network:SenderQueue
probably needs a map that assigns to each peer the epoch after which they left, which would be updated inupdate_epoch
. Thendefer_messages
would drop all messages from later epochs. When all outgoing messages to a removed peer have been sent, the peer can be removed from both maps.