Skip to content

Commit

Permalink
Merge pull request #445 from gurrpi/issues/408
Browse files Browse the repository at this point in the history
Correct GetBlockHashes chunk size after first phase
  • Loading branch information
longfin authored Aug 17, 2019
2 parents b1cb141 + d4e866e commit 7375170
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
3 changes: 3 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]]
- `BlockHashes` messages became to contain one more higher hash. [[#408], [#445]]
- `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 All @@ -154,6 +156,7 @@ To be released.
[#439]: https://github.com/planetarium/libplanet/pull/439
[#442]: https://github.com/planetarium/libplanet/issues/442
[#443]: https://github.com/planetarium/libplanet/pull/443
[#445]: https://github.com/planetarium/libplanet/pull/445
[LiteDB #1268]: https://github.com/mbdavid/LiteDB/issues/1268
[floating-point determinism]: https://wp.me/p1fTCO-kT

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 7375170

Please sign in to comment.