mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-02-07 23:03:04 +00:00
Split expensive blocks into sigExpensive and largeReorg.
This commit is contained in:
parent
d1e689e6c5
commit
1dadb33c28
@ -45,6 +45,8 @@ public class BitcoindComparisonTool {
|
|||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
BriefLogFormatter.init();
|
BriefLogFormatter.init();
|
||||||
|
System.out.println("USAGE: runLargeReorgs(1/0)");
|
||||||
|
boolean runLargeReorgs = Integer.parseInt(args[0]) == 1;
|
||||||
|
|
||||||
params = NetworkParameters.testNet2();
|
params = NetworkParameters.testNet2();
|
||||||
/**
|
/**
|
||||||
@ -53,7 +55,7 @@ public class BitcoindComparisonTool {
|
|||||||
* You can also opt to comment out these lines to use the default, however that will cause this tool to be
|
* You can also opt to comment out these lines to use the default, however that will cause this tool to be
|
||||||
* very significantly less efficient and useful (it will likely run forever trying to mine new blocks).
|
* very significantly less efficient and useful (it will likely run forever trying to mine new blocks).
|
||||||
*
|
*
|
||||||
* You could also simply use git apply to apply the "bitcoind-comparison.patch" file included with bitcoinj
|
* You could also simply use git apply to apply the test-patches included with bitcoind
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// bnProofOfWorkLimit set in main.cpp
|
// bnProofOfWorkLimit set in main.cpp
|
||||||
@ -69,7 +71,7 @@ public class BitcoindComparisonTool {
|
|||||||
// Also set block.nTime = 1296688602; in the same block
|
// Also set block.nTime = 1296688602; in the same block
|
||||||
|
|
||||||
FullBlockTestGenerator generator = new FullBlockTestGenerator(params);
|
FullBlockTestGenerator generator = new FullBlockTestGenerator(params);
|
||||||
BlockAndValidityList blockList = generator.getBlocksToTest(true);
|
BlockAndValidityList blockList = generator.getBlocksToTest(true, runLargeReorgs);
|
||||||
|
|
||||||
// Only needs to be set in bitcoinj
|
// Only needs to be set in bitcoinj
|
||||||
params.allowEmptyPeerChains = true;
|
params.allowEmptyPeerChains = true;
|
||||||
|
@ -75,7 +75,7 @@ public class FullBlockTestGenerator {
|
|||||||
Utils.rollMockClock(0); // Set a mock clock for timestamp tests
|
Utils.rollMockClock(0); // Set a mock clock for timestamp tests
|
||||||
}
|
}
|
||||||
|
|
||||||
public BlockAndValidityList getBlocksToTest(boolean addExpensiveBlocks) throws ScriptException, ProtocolException, IOException {
|
public BlockAndValidityList getBlocksToTest(boolean addSigExpensiveBlocks, boolean runLargeReorgs) throws ScriptException, ProtocolException, IOException {
|
||||||
List<BlockAndValidity> blocks = new LinkedList<BlockAndValidity>();
|
List<BlockAndValidity> blocks = new LinkedList<BlockAndValidity>();
|
||||||
BlockAndValidityList ret = new BlockAndValidityList(blocks, 10);
|
BlockAndValidityList ret = new BlockAndValidityList(blocks, 10);
|
||||||
|
|
||||||
@ -730,7 +730,7 @@ public class FullBlockTestGenerator {
|
|||||||
blocks.add(new BlockAndValidity(blockToHeightMap, b40, false, true, b39.getHash(), chainHeadHeight + 12, "b40"));
|
blocks.add(new BlockAndValidity(blockToHeightMap, b40, false, true, b39.getHash(), chainHeadHeight + 12, "b40"));
|
||||||
|
|
||||||
Block b41 = null;
|
Block b41 = null;
|
||||||
if (addExpensiveBlocks) {
|
if (addSigExpensiveBlocks) {
|
||||||
b41 = createNextBlock(b39, chainHeadHeight + 13, out12, null);
|
b41 = createNextBlock(b39, chainHeadHeight + 13, out12, null);
|
||||||
{
|
{
|
||||||
int sigOps = 0;
|
int sigOps = 0;
|
||||||
@ -1304,7 +1304,7 @@ public class FullBlockTestGenerator {
|
|||||||
b73.getTransactions().get(0).getOutputs().get(0).getValue(),
|
b73.getTransactions().get(0).getOutputs().get(0).getValue(),
|
||||||
b73.getTransactions().get(0).getOutputs().get(0).getScriptPubKey()));
|
b73.getTransactions().get(0).getOutputs().get(0).getScriptPubKey()));
|
||||||
|
|
||||||
if (addExpensiveBlocks) {
|
if (runLargeReorgs) {
|
||||||
Block lastBlock = b73;
|
Block lastBlock = b73;
|
||||||
int nextHeight = chainHeadHeight + 24;
|
int nextHeight = chainHeadHeight + 24;
|
||||||
TransactionOutPoint lastOutput = new TransactionOutPoint(params, 2, b73.getTransactions().get(1).getHash());
|
TransactionOutPoint lastOutput = new TransactionOutPoint(params, 2, b73.getTransactions().get(1).getHash());
|
||||||
|
@ -65,7 +65,7 @@ public class FullPrunedBlockChainTest {
|
|||||||
public void testGeneratedChain() throws Exception {
|
public void testGeneratedChain() throws Exception {
|
||||||
// Tests various test cases from FullBlockTestGenerator
|
// Tests various test cases from FullBlockTestGenerator
|
||||||
FullBlockTestGenerator generator = new FullBlockTestGenerator(unitTestParams);
|
FullBlockTestGenerator generator = new FullBlockTestGenerator(unitTestParams);
|
||||||
BlockAndValidityList blockList = generator.getBlocksToTest(false);
|
BlockAndValidityList blockList = generator.getBlocksToTest(false, false);
|
||||||
|
|
||||||
store = new MemoryFullPrunedBlockStore(unitTestParams, blockList.maximumReorgBlockCount);
|
store = new MemoryFullPrunedBlockStore(unitTestParams, blockList.maximumReorgBlockCount);
|
||||||
chain = new FullPrunedBlockChain(unitTestParams, store);
|
chain = new FullPrunedBlockChain(unitTestParams, store);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user