Split Context::send_message into multiple methods (#2409)

* Split Context::send_message into multiple methods

* Apply suggestions from code review

Co-Authored-By: tomaka <pierre.krieger1708@gmail.com>
This commit is contained in:
Pierre Krieger
2019-04-29 13:54:19 +02:00
committed by Gavin Wood
parent 9d7a72027c
commit ebbd6c8ec4
3 changed files with 39 additions and 19 deletions
+6 -6
View File
@@ -29,7 +29,7 @@ use crate::blocks::BlockCollection;
use runtime_primitives::Justification;
use runtime_primitives::traits::{Block as BlockT, Header as HeaderT, As, NumberFor, Zero, CheckedSub};
use runtime_primitives::generic::BlockId;
use crate::message::{self, generic::Message as GenericMessage};
use crate::message;
use crate::config::Roles;
use std::collections::HashSet;
use std::sync::Arc;
@@ -200,7 +200,7 @@ impl<B: BlockT> PendingJustifications<B> {
max: Some(1),
};
protocol.send_message(peer, GenericMessage::BlockRequest(request));
protocol.send_block_request(peer, request);
}
self.pending_requests.append(&mut unhandled_requests);
@@ -984,7 +984,7 @@ impl<B: BlockT> ChainSync<B> {
max: Some(1),
};
peer.state = PeerSyncState::DownloadingStale(*hash);
protocol.send_message(who, GenericMessage::BlockRequest(request));
protocol.send_block_request(who, request);
},
_ => (),
}
@@ -1005,7 +1005,7 @@ impl<B: BlockT> ChainSync<B> {
max: Some(MAX_UNKNOWN_FORK_DOWNLOAD_LEN),
};
peer.state = PeerSyncState::DownloadingStale(*hash);
protocol.send_message(who, GenericMessage::BlockRequest(request));
protocol.send_block_request(who, request);
},
_ => (),
}
@@ -1034,7 +1034,7 @@ impl<B: BlockT> ChainSync<B> {
max: Some((range.end - range.start).as_() as u32),
};
peer.state = PeerSyncState::DownloadingNew(range.start);
protocol.send_message(who, GenericMessage::BlockRequest(request));
protocol.send_block_request(who, request);
} else {
trace!(target: "sync", "Nothing to request");
}
@@ -1054,7 +1054,7 @@ impl<B: BlockT> ChainSync<B> {
direction: message::Direction::Ascending,
max: Some(1),
};
protocol.send_message(who, GenericMessage::BlockRequest(request));
protocol.send_block_request(who, request);
}
}