Skip to content

Conversation

@romanornr
Copy link
Contributor

@romanornr romanornr commented Jul 8, 2017

if (nCheckDepth <= 0)
    nCheckDepth = 1000000000; // suffices until the year 19000
if (nCheckDepth > chainActive.Height())
    nCheckDepth = chainActive.Height();

These lines confuse me.
Correct me if I am wrong, but we can't check any more blocks than we have right?
If someone requests <= 0 it get set it into some huge number and then immediately limit it to the chain height in the following statement.

if (nCheckDepth > chainActive.Height())
    nCheckDepth = chainActive.Height();

when using --checkblocks=Z When Z is 0 or any other negative number, it will check all blocks.

I think it should be changed to this maybe.

if (nCheckDepth <= 0 || nCheckDepth > chainActive.Height())
    nCheckDepth = chainActive.Height();

Which gets rid of that huge number which is confusing for any other altcoins that have a different block time.

@promag
Copy link
Contributor

promag commented Jul 8, 2017

That code was added in #972 by @sipa.

utACK d9d1bd3.

@sipa
Copy link
Member

sipa commented Jul 8, 2017

utACK

@TheBlueMatt
Copy link
Contributor

utACK

1 similar comment
@btcdrak
Copy link
Contributor

btcdrak commented Jul 9, 2017

utACK

@laanwj laanwj merged commit d9d1bd3 into bitcoin:master Jul 20, 2017
laanwj added a commit that referenced this pull request Jul 20, 2017
d9d1bd3 nCheckDepth chain height fix (romanornr)

Pull request description:

  ````
  if (nCheckDepth <= 0)
      nCheckDepth = 1000000000; // suffices until the year 19000
  if (nCheckDepth > chainActive.Height())
      nCheckDepth = chainActive.Height();
  ````

  These lines confuse me.
  Correct me if I am wrong, but we can't check any more blocks than we have right?
  If someone requests <= 0 it get set it into some huge number and then immediately limit it to the chain height in the following statement.
  ````
  if (nCheckDepth > chainActive.Height())
      nCheckDepth = chainActive.Height();
  ````
  when using ````--checkblocks=Z```` When Z is ````0```` or any other negative number, it will check all blocks.

  I think it should be changed to this maybe.
  ````
  if (nCheckDepth <= 0 || nCheckDepth > chainActive.Height())
      nCheckDepth = chainActive.Height();
  ````
  Which gets rid of that huge number which is confusing for any other altcoins that have a different block time.

Tree-SHA512: 8ee0ae5f33b399fa74dc16926709694ccfe1fc8a043cba2f5d00884220ac1b9b13f2df4588041f4133be634e5c7b14f4eebe24294028dafe91581a97dbe627f3
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Aug 12, 2019
d9d1bd3 nCheckDepth chain height fix (romanornr)

Pull request description:

  ````
  if (nCheckDepth <= 0)
      nCheckDepth = 1000000000; // suffices until the year 19000
  if (nCheckDepth > chainActive.Height())
      nCheckDepth = chainActive.Height();
  ````

  These lines confuse me.
  Correct me if I am wrong, but we can't check any more blocks than we have right?
  If someone requests <= 0 it get set it into some huge number and then immediately limit it to the chain height in the following statement.
  ````
  if (nCheckDepth > chainActive.Height())
      nCheckDepth = chainActive.Height();
  ````
  when using ````--checkblocks=Z```` When Z is ````0```` or any other negative number, it will check all blocks.

  I think it should be changed to this maybe.
  ````
  if (nCheckDepth <= 0 || nCheckDepth > chainActive.Height())
      nCheckDepth = chainActive.Height();
  ````
  Which gets rid of that huge number which is confusing for any other altcoins that have a different block time.

Tree-SHA512: 8ee0ae5f33b399fa74dc16926709694ccfe1fc8a043cba2f5d00884220ac1b9b13f2df4588041f4133be634e5c7b14f4eebe24294028dafe91581a97dbe627f3
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants