Skip to content

Commit 11c65a2

Browse files
committed
Fixes #104 caused by an infinite loop in Blockchain::segmentChain
Infinite loop occured when the number of transactions being split was less than the number of requested segments.
1 parent 47b53ff commit 11c65a2

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/chain/blockchain.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ namespace blocksci {
2525
auto lastTx = chain[endBlock - BlockHeight{1}].endTxIndex();
2626
auto firstTx = chain[startBlock].firstTxIndex();
2727
auto totalTxCount = lastTx - firstTx;
28-
double segmentSize = static_cast<double>(totalTxCount) / segmentCount;
28+
double segmentSize = std::max(static_cast<double>(totalTxCount) / segmentCount, 1.0);
2929

3030
std::vector<std::vector<Block>> segments;
3131
auto it = chain.begin();

0 commit comments

Comments
 (0)