fix: consider the possibility that a peer is no longer available in send_block

Signed-off-by: ljedrz <ljedrz@gmail.com>
This commit is contained in:
ljedrz 2020-08-05 14:32:19 +02:00
parent b5c0dcf907
commit d20131077a

View File

@ -159,11 +159,9 @@ impl Bitswap {
/// Called from a Strategy.
pub fn send_block(&mut self, peer_id: PeerId, block: Block) {
trace!("queueing block to be sent to {}: {}", peer_id, block.cid);
let ledger = self
.connected_peers
.get_mut(&peer_id)
.expect("Peer not in ledger?!");
ledger.add_block(block);
if let Some(ledger) = self.connected_peers.get_mut(&peer_id) {
ledger.add_block(block);
}
}
/// Sends the wantlist to the peer.