mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 20:31:13 +00:00
Do not try to synchronize from light client (#2039)
* do not try to sync from light node * use Roles' utility methods
This commit is contained in:
committed by
Gavin Wood
parent
5bde98e95a
commit
a29fd10859
@@ -181,7 +181,7 @@ impl<B: BlockT> ChainSync<B> {
|
||||
info: &ClientInfo<B>,
|
||||
) -> Self {
|
||||
let mut required_block_attributes = message::BlockAttributes::HEADER | message::BlockAttributes::JUSTIFICATION;
|
||||
if role.intersects(Roles::FULL | Roles::AUTHORITY) {
|
||||
if role.is_full() {
|
||||
required_block_attributes |= message::BlockAttributes::BODY;
|
||||
}
|
||||
|
||||
@@ -233,6 +233,12 @@ impl<B: BlockT> ChainSync<B> {
|
||||
/// Handle new connected peer. Call this method whenever we connect to a new peer.
|
||||
pub(crate) fn new_peer(&mut self, protocol: &mut Context<B>, who: PeerId) {
|
||||
if let Some(info) = protocol.peer_info(&who) {
|
||||
// there's nothing sync can get from the node that has no blockchain data
|
||||
// (the opposite is not true, but all requests are served at protocol level)
|
||||
if !info.roles.is_full() {
|
||||
return;
|
||||
}
|
||||
|
||||
let status = block_status(&*protocol.client(), &self.queue_blocks, info.best_hash);
|
||||
match (status, info.best_number) {
|
||||
(Err(e), _) => {
|
||||
|
||||
Reference in New Issue
Block a user