mirror of
https://github.com/mimblewimble/grin.git
synced 2025-01-21 11:31:08 +03:00
Do not request orphan predecessor if we have its header. Shows we're already on it (sync).
This commit is contained in:
parent
154d52e548
commit
cd72be893e
1 changed files with 23 additions and 26 deletions
|
@ -388,10 +388,12 @@ impl NetToChainAdapter {
|
||||||
Ok(_) => true,
|
Ok(_) => true,
|
||||||
Err(chain::Error::Orphan) => {
|
Err(chain::Error::Orphan) => {
|
||||||
// make sure we did not miss the parent block
|
// make sure we did not miss the parent block
|
||||||
if !self.currently_syncing.load(Ordering::Relaxed) && !chain.is_orphan(&prev_hash) {
|
if !chain.is_orphan(&prev_hash) {
|
||||||
|
if let Err(_) = chain.get_block_header(&prev_hash) {
|
||||||
debug!(LOGGER, "adapter: process_block: received an orphan block, checking the parent: {:}", prev_hash);
|
debug!(LOGGER, "adapter: process_block: received an orphan block, checking the parent: {:}", prev_hash);
|
||||||
self.request_block_by_hash(prev_hash, &addr)
|
self.request_block_by_hash(prev_hash, &addr)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
Err(ref e) if e.is_bad_data() => {
|
Err(ref e) if e.is_bad_data() => {
|
||||||
|
@ -415,8 +417,6 @@ impl NetToChainAdapter {
|
||||||
// After receiving a compact block if we cannot successfully hydrate
|
// After receiving a compact block if we cannot successfully hydrate
|
||||||
// it into a full block then fallback to requesting the full block
|
// it into a full block then fallback to requesting the full block
|
||||||
// from the same peer that gave us the compact block
|
// from the same peer that gave us the compact block
|
||||||
//
|
|
||||||
// TODO - currently only request block from a single peer
|
|
||||||
// consider additional peers for redundancy?
|
// consider additional peers for redundancy?
|
||||||
fn request_block(&self, bh: &BlockHeader, addr: &SocketAddr) {
|
fn request_block(&self, bh: &BlockHeader, addr: &SocketAddr) {
|
||||||
self.request_block_by_hash(bh.hash(), addr)
|
self.request_block_by_hash(bh.hash(), addr)
|
||||||
|
@ -429,9 +429,6 @@ impl NetToChainAdapter {
|
||||||
// After we have received a block header in "header first" propagation
|
// After we have received a block header in "header first" propagation
|
||||||
// we need to go request the block (compact representation) from the
|
// we need to go request the block (compact representation) from the
|
||||||
// same peer that gave us the header (unless we have already accepted the block)
|
// same peer that gave us the header (unless we have already accepted the block)
|
||||||
//
|
|
||||||
// TODO - currently only request block from a single peer
|
|
||||||
// consider additional peers for redundancy?
|
|
||||||
fn request_compact_block(&self, bh: &BlockHeader, addr: &SocketAddr) {
|
fn request_compact_block(&self, bh: &BlockHeader, addr: &SocketAddr) {
|
||||||
self.send_block_request_to_peer(bh.hash(), addr, |peer, h| {
|
self.send_block_request_to_peer(bh.hash(), addr, |peer, h| {
|
||||||
peer.send_compact_block_request(h)
|
peer.send_compact_block_request(h)
|
||||||
|
|
Loading…
Reference in a new issue