Skip to content
This repository has been archived by the owner on Aug 16, 2021. It is now read-only.

Bugfix/issue 277 blocking push block #333

Merged

Conversation

Aprogiena
Copy link
Contributor

Inversion of logic of enforcing LBP.MaxBufferedSize - blocks are not asked anymore if it is expected that they would violate the limit.

Fix #277
Fix #327

@@ -190,7 +196,8 @@ public LookaheadBlockPuller(ConcurrentChain chain, IConnectionManager connection
public void SetLocation(ChainedBlock tip)
{
Guard.NotNull(tip, nameof(tip));
this.location = tip;
lock (this.locationLock)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the rare cases where I prefer brackets over a one like lock.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And I agree with you, I was just testing the grounds. I don't like it either. Will fix.

}

this.logger.LogTrace("(-)");
}

/// <summary>
/// Adds requests to download blocks to the queue.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can make this comment more explanatory? (what was the doc code for sentence?)

}
else
{
// The buffer is either full, so we do not want to ask for more blocks.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah by the way what happens on a reorg? do we clean all the lists?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do have issues with reorgs in all code, we do have an issue for a memory leak somewhere but I believe there will be more issues. The good thing here is that it seems that reorg will just cause requested blocks from different chain to be downloaded. So they will arrive earlier then they would otherwise (if we cleaned the list). So there seems to be not even a memory leak in this queue in case of reorg. So maybe there is no problem to solve here. But again, I think there are problems with reorgs and many yet to be uncovered.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yeah this list will just clear itself true so no issue here.
There are issue with reorgs true but if we keep proper separation then the issues will be contained to each feature, so we just solve reorg per feature.

In the puller case we still need to clean the download collections on reorg.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's create discussion issue for reorgs elsewhere - #337

}

WaitHandle.WaitAny(new[] { this.pushed, cancellationToken.WaitHandle }, WaitNextBlockRoundTimeMs);
while (!cancellationToken.IsCancellationRequested)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see what you mean by complicating the logic

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The weirdest part is that in the same method - NBC - you set this.consumed and you also wait for this.consumed AND you expect only one thread to exist in the node that executes NBC. That is the weird part. But due to the logic of NC that it actually calls AskBlocks and because AskBlocks then calls ProcessQueue it actually works. But is very nontrivial to grasp. The original idea with the thread would separate the logic and the design would be very clean, but yes, it would cost the thread :)

/// <exception cref="InvalidOperationException">Thrown in case of data inconsistency between synchronized structures, which should never happen.</exception>
internal void ReleaseAllPeerDownloadTaskAssignments(BlockPullerBehavior peer)
internal void ReleaseAllPeerDownloadTaskAssignments(BlockPullerBehavior peer, bool peerDisconnected)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest to name it disconnectPeer.

If set to true the peer needs to be is set to a disconnected state and should be prevented from being assigned additional work.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

@Aprogiena
Copy link
Contributor Author

OK, should be ready to go.

@dangershony dangershony merged commit db91725 into stratisproject:master Aug 17, 2017
@Aprogiena Aprogiena deleted the bugfix/issue-277-blocking-PushBlock branch August 29, 2017 13:04
codingupastorm pushed a commit to codingupastorm/StratisBitcoinFullNode that referenced this pull request Jul 8, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants