mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-02-12 18:25:51 +00:00
Don't validate difficulty transitions on the testnet as there was a recent rule change, and nobody cares about security on testnet anyway.
This commit is contained in:
parent
40e4ac0a49
commit
b008cd0388
@ -207,6 +207,7 @@ public class BlockChain {
|
||||
// Create a new StoredBlock from this block. It will throw away the transaction data so when block goes
|
||||
// out of scope we will reclaim the used memory.
|
||||
StoredBlock newStoredBlock = storedPrev.build(block);
|
||||
if (params.checkBlockDifficulty)
|
||||
checkDifficultyTransitions(storedPrev, newStoredBlock);
|
||||
blockStore.put(newStoredBlock);
|
||||
connectBlock(newStoredBlock, storedPrev, block.transactions);
|
||||
|
@ -94,6 +94,11 @@ public class NetworkParameters implements Serializable {
|
||||
* signatures using it.
|
||||
*/
|
||||
public byte[] alertSigningKey;
|
||||
/**
|
||||
* Whether to check block difficulty on this network. The rules for testnet have changed and become
|
||||
* quite complicated, so don't bother verifying them. It's only a useful security check on the main network.
|
||||
*/
|
||||
public boolean checkBlockDifficulty;
|
||||
|
||||
/**
|
||||
* See getId(). This may be null for old deserialized wallets. In that case we derive it heuristically
|
||||
@ -153,6 +158,7 @@ public class NetworkParameters implements Serializable {
|
||||
n.genesisBlock.setDifficultyTarget(0x1d07fff8L);
|
||||
n.genesisBlock.setNonce(384568319);
|
||||
n.id = ID_TESTNET;
|
||||
n.checkBlockDifficulty = false;
|
||||
String genesisHash = n.genesisBlock.getHashAsString();
|
||||
checkState(genesisHash.equals("00000007199508e34a9ff81e6ec0c477a4cccff2a4767a8eee39c11db367b008"),
|
||||
genesisHash);
|
||||
@ -182,6 +188,7 @@ public class NetworkParameters implements Serializable {
|
||||
n.genesisBlock.setTime(1231006505L);
|
||||
n.genesisBlock.setNonce(2083236893);
|
||||
n.id = ID_PRODNET;
|
||||
n.checkBlockDifficulty = true;
|
||||
String genesisHash = n.genesisBlock.getHashAsString();
|
||||
checkState(genesisHash.equals("000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f"),
|
||||
genesisHash);
|
||||
@ -197,6 +204,7 @@ public class NetworkParameters implements Serializable {
|
||||
n.genesisBlock.setDifficultyTarget(Block.EASIEST_DIFFICULTY_TARGET);
|
||||
n.interval = 10;
|
||||
n.targetTimespan = 200000000; // 6 years. Just a very big number.
|
||||
n.checkBlockDifficulty = true;
|
||||
n.id = "com.google.bitcoin.unittest";
|
||||
return n;
|
||||
}
|
||||
@ -216,6 +224,12 @@ public class NetworkParameters implements Serializable {
|
||||
return id;
|
||||
}
|
||||
|
||||
public boolean equals(Object other) {
|
||||
if (!(other instanceof NetworkParameters)) return false;
|
||||
NetworkParameters o = (NetworkParameters) other;
|
||||
return o.getId().equals(getId());
|
||||
}
|
||||
|
||||
/** Returns the network parameters for the given string ID or NULL if not recognized. */
|
||||
public static NetworkParameters fromID(String id) {
|
||||
if (id.equals(ID_PRODNET)) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user