forked from Qortal/qortal
Added feature trigger timestamp (TBC) to increase online accounts mempow difficulty (also TBC).
This commit is contained in:
parent
59a804c560
commit
166425bee9
@ -73,7 +73,8 @@ public class BlockChain {
|
|||||||
calcChainWeightTimestamp,
|
calcChainWeightTimestamp,
|
||||||
transactionV5Timestamp,
|
transactionV5Timestamp,
|
||||||
transactionV6Timestamp,
|
transactionV6Timestamp,
|
||||||
disableReferenceTimestamp;
|
disableReferenceTimestamp,
|
||||||
|
increaseOnlineAccountsDifficultyTimestamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Custom transaction fees
|
// Custom transaction fees
|
||||||
@ -478,6 +479,10 @@ public class BlockChain {
|
|||||||
return this.featureTriggers.get(FeatureTrigger.disableReferenceTimestamp.name()).longValue();
|
return this.featureTriggers.get(FeatureTrigger.disableReferenceTimestamp.name()).longValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public long getIncreaseOnlineAccountsDifficultyTimestamp() {
|
||||||
|
return this.featureTriggers.get(FeatureTrigger.increaseOnlineAccountsDifficultyTimestamp.name()).longValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// More complex getters for aspects that change by height or timestamp
|
// More complex getters for aspects that change by height or timestamp
|
||||||
|
|
||||||
|
@ -66,7 +66,8 @@ public class OnlineAccountsManager {
|
|||||||
|
|
||||||
// MemoryPoW - mainnet
|
// MemoryPoW - mainnet
|
||||||
public static final int POW_BUFFER_SIZE = 1 * 1024 * 1024; // bytes
|
public static final int POW_BUFFER_SIZE = 1 * 1024 * 1024; // bytes
|
||||||
public static final int POW_DIFFICULTY = 18; // leading zero bits
|
public static final int POW_DIFFICULTY_V1 = 18; // leading zero bits
|
||||||
|
public static final int POW_DIFFICULTY_V2 = 19; // leading zero bits
|
||||||
|
|
||||||
// MemoryPoW - testnet
|
// MemoryPoW - testnet
|
||||||
public static final int POW_BUFFER_SIZE_TESTNET = 1 * 1024 * 1024; // bytes
|
public static final int POW_BUFFER_SIZE_TESTNET = 1 * 1024 * 1024; // bytes
|
||||||
@ -128,11 +129,14 @@ public class OnlineAccountsManager {
|
|||||||
return POW_BUFFER_SIZE;
|
return POW_BUFFER_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int getPoWDifficulty() {
|
private static int getPoWDifficulty(long timestamp) {
|
||||||
if (Settings.getInstance().isTestNet())
|
if (Settings.getInstance().isTestNet())
|
||||||
return POW_DIFFICULTY_TESTNET;
|
return POW_DIFFICULTY_TESTNET;
|
||||||
|
|
||||||
return POW_DIFFICULTY;
|
if (timestamp >= BlockChain.getInstance().getIncreaseOnlineAccountsDifficultyTimestamp())
|
||||||
|
return POW_DIFFICULTY_V2;
|
||||||
|
|
||||||
|
return POW_DIFFICULTY_V1;
|
||||||
}
|
}
|
||||||
|
|
||||||
private OnlineAccountsManager() {
|
private OnlineAccountsManager() {
|
||||||
@ -628,7 +632,8 @@ public class OnlineAccountsManager {
|
|||||||
final long nextOnlineAccountsTimestamp = toOnlineAccountTimestamp(startTime) + getOnlineTimestampModulus();
|
final long nextOnlineAccountsTimestamp = toOnlineAccountTimestamp(startTime) + getOnlineTimestampModulus();
|
||||||
long timeUntilNextTimestamp = nextOnlineAccountsTimestamp - startTime;
|
long timeUntilNextTimestamp = nextOnlineAccountsTimestamp - startTime;
|
||||||
|
|
||||||
Integer nonce = MemoryPoW.compute2(bytes, getPoWBufferSize(), getPoWDifficulty(), timeUntilNextTimestamp);
|
int difficulty = getPoWDifficulty(onlineAccountsTimestamp);
|
||||||
|
Integer nonce = MemoryPoW.compute2(bytes, getPoWBufferSize(), difficulty, timeUntilNextTimestamp);
|
||||||
|
|
||||||
double totalSeconds = (NTP.getTime() - startTime) / 1000.0f;
|
double totalSeconds = (NTP.getTime() - startTime) / 1000.0f;
|
||||||
int minutes = (int) ((totalSeconds % 3600) / 60);
|
int minutes = (int) ((totalSeconds % 3600) / 60);
|
||||||
@ -637,7 +642,7 @@ public class OnlineAccountsManager {
|
|||||||
|
|
||||||
LOGGER.info(String.format("Computed nonce for timestamp %d and account %.8s: %d. Buffer size: %d. Difficulty: %d. " +
|
LOGGER.info(String.format("Computed nonce for timestamp %d and account %.8s: %d. Buffer size: %d. Difficulty: %d. " +
|
||||||
"Time taken: %02d:%02d. Hashrate: %f", onlineAccountsTimestamp, Base58.encode(publicKey),
|
"Time taken: %02d:%02d. Hashrate: %f", onlineAccountsTimestamp, Base58.encode(publicKey),
|
||||||
nonce, getPoWBufferSize(), getPoWDifficulty(), minutes, seconds, hashRate));
|
nonce, getPoWBufferSize(), difficulty, minutes, seconds, hashRate));
|
||||||
|
|
||||||
return nonce;
|
return nonce;
|
||||||
}
|
}
|
||||||
@ -658,7 +663,7 @@ public class OnlineAccountsManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Verify the nonce
|
// Verify the nonce
|
||||||
return MemoryPoW.verify2(mempowBytes, workBuffer, getPoWBufferSize(), getPoWDifficulty(), nonce);
|
return MemoryPoW.verify2(mempowBytes, workBuffer, getPoWBufferSize(), getPoWDifficulty(onlineAccountData.getTimestamp()), nonce);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -79,7 +79,8 @@
|
|||||||
"calcChainWeightTimestamp": 1620579600000,
|
"calcChainWeightTimestamp": 1620579600000,
|
||||||
"transactionV5Timestamp": 1642176000000,
|
"transactionV5Timestamp": 1642176000000,
|
||||||
"transactionV6Timestamp": 9999999999999,
|
"transactionV6Timestamp": 9999999999999,
|
||||||
"disableReferenceTimestamp": 1655222400000
|
"disableReferenceTimestamp": 1655222400000,
|
||||||
|
"increaseOnlineAccountsDifficultyTimestamp": 9999999999999
|
||||||
},
|
},
|
||||||
"genesisInfo": {
|
"genesisInfo": {
|
||||||
"version": 4,
|
"version": 4,
|
||||||
|
Loading…
Reference in New Issue
Block a user