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

[3.0.8.0] Fast Rewind #4082

Open
wants to merge 23 commits into
base: release/3.0.8.0
Choose a base branch
from

Conversation

quantumagi
Copy link
Contributor

for (int i = 0; i < addChangesTimes; i++)
var random = new Random();

while (currentHeight > 1)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this going to loop until random returns a 0?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes we keep rewinding between >0% and 100% of the remaining blocks until there is nothing left to rewind.

currentHeight = random.Next(currentHeight - 1) + 1; will always reduce currentHeight.

@@ -75,8 +75,7 @@ public uint256 NewBlock()

public uint256 Rewind()
{
this.hash = this.coinView.Rewind();
this.blockHeight--;
this.hash = this.coinView.Rewind(--this.blockHeight);
Copy link
Collaborator

@codingupastorm codingupastorm Nov 20, 2019

Choose a reason for hiding this comment

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

Is this correct? This is different functionality to previously. This will pass blockHeight-1 to Rewind.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. It's the target height. Previously we implicitly passed blockHeight-1 to Rewind. Now its explicit.

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.

None yet

2 participants