Skip to content

Commit

Permalink
Correct GetBlockHashes chunk size after first phase
Browse files Browse the repository at this point in the history
  • Loading branch information
baumstern committed Aug 16, 2019
1 parent b1cb141 commit 4b3c1ac
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ To be released.
instead of the window size of a chunk (i.e., 500). [[#396], [#399]]
- `Swarm<T>.PreloadAsync()` became to get the first parameter, `progress`,
which accepts `IProgress<PreloadState>`. [[#397], [#400]]
- Response of `getBlockHashes()` now contains one more higher hash. [[#408]]
- `Swarm<T>.PreloadAsync()` became safe from data corruption even
if a preloading process suddenly gets shutdown. [[#417]]
- `FileStore` and `LiteDBStore` became to guarantee atomicity of storing
Expand Down Expand Up @@ -138,6 +139,7 @@ To be released.
[#398]: https://github.com/planetarium/libplanet/pull/398
[#399]: https://github.com/planetarium/libplanet/pull/399
[#400]: https://github.com/planetarium/libplanet/pull/400
[#408]: https://github.com/planetarium/libplanet/issues/408
[#410]: https://github.com/planetarium/libplanet/issues/410
[#413]: https://github.com/planetarium/libplanet/pull/413
[#414]: https://github.com/planetarium/libplanet/pull/414
Expand Down
11 changes: 11 additions & 0 deletions Libplanet/Blockchain/BlockChain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -770,6 +770,17 @@ internal IEnumerable<HashDigest<SHA256>> FindNextHashes(

HashDigest<SHA256> branchPoint = FindBranchPoint(locator);
var branchPointIndex = (int)Blocks[branchPoint].Index;

// FIXME: Currently, increasing count by one to satisfy
// the number defined by FindNextHashesChunkSize variable
// when branchPointIndex didn't indicate genesis block.
// Since branchPointIndex is same as the latest block of
// requesting peer.
if (branchPointIndex > 0)
{
count++;
}

IEnumerable<HashDigest<SHA256>> hashes = Store
.IterateIndex(Id.ToString(), branchPointIndex, count);

Expand Down

0 comments on commit 4b3c1ac

Please sign in to comment.