-
-
Save jamoes/5f6a60f56aef26ab98bc to your computer and use it in GitHub Desktop.
Diff Between NXT v1.1.6 and BURST v1.0.0
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/java/nxt/Account.java b/java/nxt/Account.java | |
index ca16347..cdd7c48 100644 | |
--- a/java/nxt/Account.java | |
+++ b/java/nxt/Account.java | |
@@ -549,9 +549,6 @@ public final class Account { | |
} | |
private void checkBalance() { | |
- if (id.equals(Genesis.CREATOR_ID)) { | |
- return; | |
- } | |
if (balanceNQT < 0) { | |
throw new DoubleSpendingException("Negative balance for account " + Convert.toUnsignedLong(id)); | |
} | |
diff --git a/java/nxt/Block.java b/java/nxt/Block.java | |
index 70381da..ac35175 100644 | |
--- a/java/nxt/Block.java | |
+++ b/java/nxt/Block.java | |
@@ -18,6 +18,10 @@ public interface Block { | |
int getTimestamp(); | |
Long getGeneratorId(); | |
+ | |
+ Long getNonce(); | |
+ | |
+ int getScoopNum(); | |
byte[] getGeneratorPublicKey(); | |
@@ -44,6 +48,8 @@ public interface Block { | |
byte[] getBlockSignature(); | |
long getBaseTarget(); | |
+ | |
+ long getBlockReward(); | |
BigInteger getCumulativeDifficulty(); | |
diff --git a/java/nxt/BlockDb.java b/java/nxt/BlockDb.java | |
index 1c50678..2c00373 100644 | |
--- a/java/nxt/BlockDb.java | |
+++ b/java/nxt/BlockDb.java | |
@@ -82,11 +82,12 @@ final class BlockDb { | |
byte[] payloadHash = rs.getBytes("payload_hash"); | |
Long id = rs.getLong("id"); | |
+ long nonce = rs.getLong("nonce"); | |
List<TransactionImpl> transactions = TransactionDb.findBlockTransactions(con, id); | |
BlockImpl block = new BlockImpl(version, timestamp, previousBlockId, totalAmountNQT, totalFeeNQT, payloadLength, payloadHash, | |
generatorPublicKey, generationSignature, blockSignature, previousBlockHash, transactions, | |
- cumulativeDifficulty, baseTarget, nextBlockId, height, id); | |
+ cumulativeDifficulty, baseTarget, nextBlockId, height, id, nonce); | |
for (TransactionImpl transaction : transactions) { | |
transaction.setBlock(block); | |
@@ -103,8 +104,8 @@ final class BlockDb { | |
try { | |
try (PreparedStatement pstmt = con.prepareStatement("INSERT INTO block (id, version, timestamp, previous_block_id, " | |
+ "total_amount, total_fee, payload_length, generator_public_key, previous_block_hash, cumulative_difficulty, " | |
- + "base_target, next_block_id, height, generation_signature, block_signature, payload_hash, generator_id) " | |
- + " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")) { | |
+ + "base_target, next_block_id, height, generation_signature, block_signature, payload_hash, generator_id, nonce) " | |
+ + " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")) { | |
int i = 0; | |
pstmt.setLong(++i, block.getId()); | |
pstmt.setInt(++i, block.getVersion()); | |
@@ -131,6 +132,7 @@ final class BlockDb { | |
pstmt.setBytes(++i, block.getBlockSignature()); | |
pstmt.setBytes(++i, block.getPayloadHash()); | |
pstmt.setLong(++i, block.getGeneratorId()); | |
+ pstmt.setLong(++i, block.getNonce()); | |
pstmt.executeUpdate(); | |
TransactionDb.saveTransactions(con, block.getTransactions()); | |
} | |
diff --git a/java/nxt/BlockImpl.java b/java/nxt/BlockImpl.java | |
index 48dc591..9577a76 100644 | |
--- a/java/nxt/BlockImpl.java | |
+++ b/java/nxt/BlockImpl.java | |
@@ -3,9 +3,13 @@ package nxt; | |
import nxt.crypto.Crypto; | |
import nxt.util.Convert; | |
import nxt.util.Logger; | |
+import nxt.util.MiningPlot; | |
+ | |
import org.json.simple.JSONArray; | |
import org.json.simple.JSONObject; | |
+import fr.cryptohash.Shabal256; | |
+ | |
import java.math.BigInteger; | |
import java.nio.ByteBuffer; | |
import java.nio.ByteOrder; | |
@@ -38,10 +42,11 @@ final class BlockImpl implements Block { | |
private volatile Long id; | |
private volatile String stringId = null; | |
private volatile Long generatorId; | |
+ private long nonce; | |
BlockImpl(int version, int timestamp, Long previousBlockId, long totalAmountNQT, long totalFeeNQT, int payloadLength, byte[] payloadHash, | |
- byte[] generatorPublicKey, byte[] generationSignature, byte[] blockSignature, byte[] previousBlockHash, List<TransactionImpl> transactions) | |
+ byte[] generatorPublicKey, byte[] generationSignature, byte[] blockSignature, byte[] previousBlockHash, List<TransactionImpl> transactions, long nonce) | |
throws NxtException.ValidationException { | |
if (transactions.size() > Constants.MAX_NUMBER_OF_TRANSACTIONS) { | |
@@ -75,16 +80,16 @@ final class BlockImpl implements Block { | |
previousId = transaction.getId(); | |
} | |
this.transactionIds = Collections.unmodifiableList(transactionIds); | |
- | |
+ this.nonce = nonce; | |
} | |
BlockImpl(int version, int timestamp, Long previousBlockId, long totalAmountNQT, long totalFeeNQT, int payloadLength, | |
byte[] payloadHash, byte[] generatorPublicKey, byte[] generationSignature, byte[] blockSignature, | |
byte[] previousBlockHash, List<TransactionImpl> transactions, BigInteger cumulativeDifficulty, | |
- long baseTarget, Long nextBlockId, int height, Long id) | |
+ long baseTarget, Long nextBlockId, int height, Long id, long nonce) | |
throws NxtException.ValidationException { | |
this(version, timestamp, previousBlockId, totalAmountNQT, totalFeeNQT, payloadLength, payloadHash, | |
- generatorPublicKey, generationSignature, blockSignature, previousBlockHash, transactions); | |
+ generatorPublicKey, generationSignature, blockSignature, previousBlockHash, transactions, nonce); | |
this.cumulativeDifficulty = cumulativeDifficulty; | |
this.baseTarget = baseTarget; | |
this.nextBlockId = nextBlockId; | |
@@ -212,6 +217,23 @@ final class BlockImpl implements Block { | |
} | |
return generatorId; | |
} | |
+ | |
+ @Override | |
+ public Long getNonce() { | |
+ return nonce; | |
+ } | |
+ | |
+ @Override | |
+ public int getScoopNum() { | |
+ ByteBuffer posbuf = ByteBuffer.allocate(32 + 8); | |
+ posbuf.put(generationSignature); | |
+ posbuf.putLong(getHeight()); | |
+ Shabal256 md = new Shabal256(); | |
+ md.update(posbuf.array()); | |
+ BigInteger hashnum = new BigInteger(1, md.digest()); | |
+ int scoopNum = hashnum.mod(BigInteger.valueOf(MiningPlot.SCOOPS_PER_PLOT)).intValue(); | |
+ return scoopNum; | |
+ } | |
@Override | |
public boolean equals(Object o) { | |
@@ -244,12 +266,13 @@ final class BlockImpl implements Block { | |
transactionsData.add(transaction.getJSONObject()); | |
} | |
json.put("transactions", transactionsData); | |
+ json.put("nonce", Convert.toUnsignedLong(nonce)); | |
return json; | |
} | |
byte[] getBytes() { | |
- ByteBuffer buffer = ByteBuffer.allocate(4 + 4 + 8 + 4 + (version < 3 ? (4 + 4) : (8 + 8)) + 4 + 32 + 32 + (32 + 32) + 64); | |
+ ByteBuffer buffer = ByteBuffer.allocate(4 + 4 + 8 + 4 + (version < 3 ? (4 + 4) : (8 + 8)) + 4 + 32 + 32 + (32 + 32) + 8 + 64); | |
buffer.order(ByteOrder.LITTLE_ENDIAN); | |
buffer.putInt(version); | |
buffer.putInt(timestamp); | |
@@ -269,6 +292,7 @@ final class BlockImpl implements Block { | |
if (version > 1) { | |
buffer.put(previousBlockHash); | |
} | |
+ buffer.putLong(nonce); | |
buffer.put(blockSignature); | |
return buffer.array(); | |
} | |
@@ -285,17 +309,11 @@ final class BlockImpl implements Block { | |
} | |
boolean verifyBlockSignature() { | |
- | |
- Account account = Account.getAccount(getGeneratorId()); | |
- if (account == null) { | |
- return false; | |
- } | |
- | |
byte[] data = getBytes(); | |
byte[] data2 = new byte[data.length - 64]; | |
System.arraycopy(data, 0, data2, 0, data2.length); | |
- return Crypto.verify(blockSignature, data2, generatorPublicKey, version >= 3) && account.setOrVerify(generatorPublicKey, this.height); | |
+ return Crypto.verify(blockSignature, data2, generatorPublicKey, version >= 3); | |
} | |
@@ -308,36 +326,40 @@ final class BlockImpl implements Block { | |
throw new BlockchainProcessor.BlockOutOfOrderException("Can't verify signature because previous block is missing"); | |
} | |
- if (version == 1 && !Crypto.verify(generationSignature, previousBlock.generationSignature, generatorPublicKey, version >= 3)) { | |
- return false; | |
- } | |
- | |
- Account account = Account.getAccount(getGeneratorId()); | |
- long effectiveBalance = account == null ? 0 : account.getEffectiveBalanceNXT(); | |
- if (effectiveBalance <= 0) { | |
- return false; | |
+ //Account account = Account.getAccount(getGeneratorId()); | |
+ | |
+ ByteBuffer gensigbuf = ByteBuffer.allocate(32 + 8); | |
+ gensigbuf.put(previousBlock.getGenerationSignature()); | |
+ gensigbuf.putLong(previousBlock.getGeneratorId()); | |
+ | |
+ Shabal256 md = new Shabal256(); | |
+ md.update(gensigbuf.array()); | |
+ byte[] correctGenerationSignature = md.digest(); | |
+ if(!Arrays.equals(generationSignature, correctGenerationSignature)) { | |
+ return false; | |
} | |
- | |
+ | |
+ // verify poc also | |
+ MiningPlot plot = new MiningPlot(getGeneratorId(), nonce); | |
+ | |
+ ByteBuffer posbuf = ByteBuffer.allocate(32 + 8); | |
+ posbuf.put(correctGenerationSignature); | |
+ posbuf.putLong(previousBlock.getHeight() + 1); | |
+ md.reset(); | |
+ md.update(posbuf.array()); | |
+ BigInteger hashnum = new BigInteger(1, md.digest()); | |
+ int scoopNum = hashnum.mod(BigInteger.valueOf(MiningPlot.SCOOPS_PER_PLOT)).intValue(); | |
+ | |
+ md.reset(); | |
+ md.update(correctGenerationSignature); | |
+ plot.hashScoop(md, scoopNum); | |
+ byte[] hash = md.digest(); | |
+ BigInteger hit = new BigInteger(1, new byte[] {hash[7], hash[6], hash[5], hash[4], hash[3], hash[2], hash[1], hash[0]}); | |
+ BigInteger hitTime = hit.divide(BigInteger.valueOf(previousBlock.getBaseTarget())); | |
+ | |
int elapsedTime = timestamp - previousBlock.timestamp; | |
- BigInteger target = BigInteger.valueOf(Nxt.getBlockchain().getLastBlock().getBaseTarget()) | |
- .multiply(BigInteger.valueOf(effectiveBalance)) | |
- .multiply(BigInteger.valueOf(elapsedTime)); | |
- | |
- MessageDigest digest = Crypto.sha256(); | |
- byte[] generationSignatureHash; | |
- if (version == 1) { | |
- generationSignatureHash = digest.digest(generationSignature); | |
- } else { | |
- digest.update(previousBlock.generationSignature); | |
- generationSignatureHash = digest.digest(generatorPublicKey); | |
- if (!Arrays.equals(generationSignature, generationSignatureHash)) { | |
- return false; | |
- } | |
- } | |
- | |
- BigInteger hit = new BigInteger(1, new byte[] {generationSignatureHash[7], generationSignatureHash[6], generationSignatureHash[5], generationSignatureHash[4], generationSignatureHash[3], generationSignatureHash[2], generationSignatureHash[1], generationSignatureHash[0]}); | |
- | |
- return hit.compareTo(target) < 0; | |
+ | |
+ return BigInteger.valueOf(elapsedTime).compareTo(hitTime) > 0; | |
} catch (RuntimeException e) { | |
@@ -351,15 +373,28 @@ final class BlockImpl implements Block { | |
void apply() { | |
Account generatorAccount = Account.addOrGetAccount(getGeneratorId()); | |
generatorAccount.apply(generatorPublicKey, this.height); | |
- generatorAccount.addToBalanceAndUnconfirmedBalanceNQT(totalFeeNQT); | |
- generatorAccount.addToForgedBalanceNQT(totalFeeNQT); | |
+ generatorAccount.addToBalanceAndUnconfirmedBalanceNQT(totalFeeNQT + getBlockReward()); | |
+ generatorAccount.addToForgedBalanceNQT(totalFeeNQT + getBlockReward()); | |
} | |
void undo() { | |
Account generatorAccount = Account.getAccount(getGeneratorId()); | |
generatorAccount.undo(getHeight()); | |
- generatorAccount.addToBalanceAndUnconfirmedBalanceNQT(-totalFeeNQT); | |
- generatorAccount.addToForgedBalanceNQT(-totalFeeNQT); | |
+ generatorAccount.addToBalanceAndUnconfirmedBalanceNQT(-totalFeeNQT + (getBlockReward() * -1)); | |
+ generatorAccount.addToForgedBalanceNQT(-totalFeeNQT + (getBlockReward() * -1)); | |
+ } | |
+ | |
+ @Override | |
+ public long getBlockReward() { | |
+ if(this.height == 0 || this.height >= 1944000) { | |
+ return 0; | |
+ } | |
+ int month = this.height / 10800; | |
+ long reward = BigInteger.valueOf(10000) | |
+ .multiply(BigInteger.valueOf(95).pow(month)) | |
+ .divide(BigInteger.valueOf(100).pow(month)).longValue() * Constants.ONE_NXT; | |
+ | |
+ return reward; | |
} | |
void setPrevious(BlockImpl previousBlock) { | |
@@ -383,21 +418,33 @@ final class BlockImpl implements Block { | |
if (this.getId().equals(Genesis.GENESIS_BLOCK_ID) && previousBlockId == null) { | |
baseTarget = Constants.INITIAL_BASE_TARGET; | |
cumulativeDifficulty = BigInteger.ZERO; | |
+ } else if(this.height < 4) { | |
+ baseTarget = Constants.INITIAL_BASE_TARGET; | |
+ cumulativeDifficulty = previousBlock.cumulativeDifficulty.add(Convert.two64.divide(BigInteger.valueOf(Constants.INITIAL_BASE_TARGET))); | |
} else { | |
- long curBaseTarget = previousBlock.baseTarget; | |
+ Block itBlock = previousBlock; | |
+ BigInteger avgBaseTarget = BigInteger.valueOf(itBlock.getBaseTarget()); | |
+ do { | |
+ itBlock = Nxt.getBlockchain().getBlock(itBlock.getPreviousBlockId()); | |
+ avgBaseTarget = avgBaseTarget.add(BigInteger.valueOf(itBlock.getBaseTarget())); | |
+ } while(itBlock.getHeight() > this.height - 4); | |
+ avgBaseTarget = avgBaseTarget.divide(BigInteger.valueOf(4)); | |
+ long difTime = this.timestamp - itBlock.getTimestamp(); | |
+ | |
+ long curBaseTarget = avgBaseTarget.longValue(); | |
long newBaseTarget = BigInteger.valueOf(curBaseTarget) | |
- .multiply(BigInteger.valueOf(this.timestamp - previousBlock.timestamp)) | |
- .divide(BigInteger.valueOf(60)).longValue(); | |
+ .multiply(BigInteger.valueOf(difTime)) | |
+ .divide(BigInteger.valueOf(240 * 4)).longValue(); | |
if (newBaseTarget < 0 || newBaseTarget > Constants.MAX_BASE_TARGET) { | |
newBaseTarget = Constants.MAX_BASE_TARGET; | |
} | |
- if (newBaseTarget < curBaseTarget / 2) { | |
- newBaseTarget = curBaseTarget / 2; | |
+ if (newBaseTarget < (curBaseTarget * 9 / 10)) { | |
+ newBaseTarget = curBaseTarget * 9 / 10; | |
} | |
if (newBaseTarget == 0) { | |
newBaseTarget = 1; | |
} | |
- long twofoldCurBaseTarget = curBaseTarget * 2; | |
+ long twofoldCurBaseTarget = curBaseTarget * 11 / 10; | |
if (twofoldCurBaseTarget < 0) { | |
twofoldCurBaseTarget = Constants.MAX_BASE_TARGET; | |
} | |
diff --git a/java/nxt/BlockchainProcessorImpl.java b/java/nxt/BlockchainProcessorImpl.java | |
index b09abcd..5c84cd1 100644 | |
--- a/java/nxt/BlockchainProcessorImpl.java | |
+++ b/java/nxt/BlockchainProcessorImpl.java | |
@@ -10,11 +10,15 @@ import nxt.util.Listener; | |
import nxt.util.Listeners; | |
import nxt.util.Logger; | |
import nxt.util.ThreadPool; | |
+ | |
import org.json.simple.JSONArray; | |
import org.json.simple.JSONObject; | |
import org.json.simple.JSONStreamAware; | |
+import fr.cryptohash.Shabal256; | |
+ | |
import java.math.BigInteger; | |
+import java.nio.ByteBuffer; | |
import java.security.MessageDigest; | |
import java.sql.Connection; | |
import java.sql.PreparedStatement; | |
@@ -33,11 +37,6 @@ import java.util.TreeMap; | |
import java.util.TreeSet; | |
final class BlockchainProcessorImpl implements BlockchainProcessor { | |
- | |
- private static final byte[] CHECKSUM_TRANSPARENT_FORGING = new byte[]{27, -54, -59, -98, 49, -42, 48, -68, -112, 49, 41, 94, -41, 78, -84, 27, -87, -22, -28, 36, -34, -90, 112, -50, -9, 5, 89, -35, 80, -121, -128, 112}; | |
- private static final byte[] CHECKSUM_NQT_BLOCK = Constants.isTestnet ? new byte[]{-126, -117, -94, -16, 125, -94, 38, 10, 11, 37, -33, 4, -70, -8, -40, -80, 18, -21, -54, -126, 109, -73, 63, -56, 67, 59, -30, 83, -6, -91, -24, 34} | |
- : new byte[]{-125, 17, 63, -20, 90, -98, 52, 114, 7, -100, -20, -103, -50, 76, 46, -38, -29, -43, -43, 45, 81, 12, -30, 100, -67, -50, -112, -15, 22, -57, 84, -106}; | |
- | |
private static final BlockchainProcessorImpl instance = new BlockchainProcessorImpl(); | |
static BlockchainProcessorImpl getInstance() { | |
@@ -427,19 +426,13 @@ final class BlockchainProcessorImpl implements BlockchainProcessor { | |
try { | |
SortedMap<Long,TransactionImpl> transactionsMap = new TreeMap<>(); | |
- for (int i = 0; i < Genesis.GENESIS_RECIPIENTS.length; i++) { | |
- TransactionImpl transaction = new TransactionImpl(TransactionType.Payment.ORDINARY, 0, (short) 0, Genesis.CREATOR_PUBLIC_KEY, | |
- Genesis.GENESIS_RECIPIENTS[i], Genesis.GENESIS_AMOUNTS[i] * Constants.ONE_NXT, 0, (String)null, Genesis.GENESIS_SIGNATURES[i]); | |
- transactionsMap.put(transaction.getId(), transaction); | |
- } | |
- | |
MessageDigest digest = Crypto.sha256(); | |
for (Transaction transaction : transactionsMap.values()) { | |
digest.update(transaction.getBytes()); | |
} | |
- BlockImpl genesisBlock = new BlockImpl(-1, 0, null, Constants.MAX_BALANCE_NQT, 0, transactionsMap.size() * 128, digest.digest(), | |
- Genesis.CREATOR_PUBLIC_KEY, new byte[64], Genesis.GENESIS_BLOCK_SIGNATURE, null, new ArrayList<>(transactionsMap.values())); | |
+ BlockImpl genesisBlock = new BlockImpl(-1, 0, null, 0, 0, transactionsMap.size() * 128, digest.digest(), | |
+ Genesis.CREATOR_PUBLIC_KEY, new byte[32], Genesis.GENESIS_BLOCK_SIGNATURE, null, new ArrayList<>(transactionsMap.values()), 0); | |
genesisBlock.setPrevious(null); | |
@@ -451,21 +444,6 @@ final class BlockchainProcessorImpl implements BlockchainProcessor { | |
} | |
} | |
- private byte[] calculateTransactionsChecksum() { | |
- MessageDigest digest = Crypto.sha256(); | |
- try (Connection con = Db.getConnection(); | |
- PreparedStatement pstmt = con.prepareStatement( | |
- "SELECT * FROM transaction ORDER BY id ASC, timestamp ASC"); | |
- DbIterator<TransactionImpl> iterator = blockchain.getTransactions(con, pstmt)) { | |
- while (iterator.hasNext()) { | |
- digest.update(iterator.next().getBytes()); | |
- } | |
- } catch (SQLException e) { | |
- throw new RuntimeException(e.toString(), e); | |
- } | |
- return digest.digest(); | |
- } | |
- | |
private void pushBlock(final BlockImpl block) throws BlockNotAcceptedException { | |
int curTime = Convert.getEpochTime(); | |
@@ -479,34 +457,6 @@ final class BlockchainProcessorImpl implements BlockchainProcessor { | |
throw new BlockOutOfOrderException("Previous block id doesn't match"); | |
} | |
- if (! verifyVersion(block, previousLastBlock.getHeight())) { | |
- throw new BlockNotAcceptedException("Invalid version " + block.getVersion()); | |
- } | |
- | |
- if (previousLastBlock.getHeight() == Constants.TRANSPARENT_FORGING_BLOCK) { | |
- byte[] checksum = calculateTransactionsChecksum(); | |
- if (CHECKSUM_TRANSPARENT_FORGING == null) { | |
- Logger.logMessage("Checksum calculated:\n" + Arrays.toString(checksum)); | |
- } else if (!Arrays.equals(checksum, CHECKSUM_TRANSPARENT_FORGING)) { | |
- Logger.logMessage("Checksum failed at block " + Constants.TRANSPARENT_FORGING_BLOCK); | |
- throw new BlockNotAcceptedException("Checksum failed"); | |
- } else { | |
- Logger.logMessage("Checksum passed at block " + Constants.TRANSPARENT_FORGING_BLOCK); | |
- } | |
- } | |
- | |
- if (previousLastBlock.getHeight() == Constants.NQT_BLOCK) { | |
- byte[] checksum = calculateTransactionsChecksum(); | |
- if (CHECKSUM_NQT_BLOCK == null) { | |
- Logger.logMessage("Checksum calculated:\n" + Arrays.toString(checksum)); | |
- } else if (!Arrays.equals(checksum, CHECKSUM_NQT_BLOCK)) { | |
- Logger.logMessage("Checksum failed at block " + Constants.NQT_BLOCK); | |
- throw new BlockNotAcceptedException("Checksum failed"); | |
- } else { | |
- Logger.logMessage("Checksum passed at block " + Constants.NQT_BLOCK); | |
- } | |
- } | |
- | |
if (block.getVersion() != 1 && ! Arrays.equals(Crypto.sha256().digest(previousLastBlock.getBytes()), block.getPreviousBlockHash())) { | |
throw new BlockNotAcceptedException("Previous block hash doesn't match"); | |
} | |
@@ -536,9 +486,8 @@ final class BlockchainProcessorImpl implements BlockchainProcessor { | |
for (TransactionImpl transaction : block.getTransactions()) { | |
- // cfb: Block 303 contains a transaction which expired before the block timestamp | |
if (transaction.getTimestamp() > curTime + 15 || transaction.getTimestamp() > block.getTimestamp() + 15 | |
- || (transaction.getExpiration() < block.getTimestamp() && previousLastBlock.getHeight() != 303)) { | |
+ || transaction.getExpiration() < block.getTimestamp()) { | |
throw new TransactionNotAcceptedException("Invalid transaction timestamp " + transaction.getTimestamp() | |
+ " for transaction " + transaction.getStringId() + ", current time is " + curTime | |
+ ", block timestamp is " + block.getTimestamp(), transaction); | |
@@ -656,7 +605,7 @@ final class BlockchainProcessorImpl implements BlockchainProcessor { | |
} | |
} | |
- void generateBlock(String secretPhrase) { | |
+ void generateBlock(String secretPhrase, Long nonce) { | |
Set<TransactionImpl> sortedTransactions = new TreeSet<>(); | |
@@ -726,8 +675,13 @@ final class BlockchainProcessorImpl implements BlockchainProcessor { | |
return; | |
} | |
- digest.update(previousBlock.getGenerationSignature()); | |
- byte[] generationSignature = digest.digest(publicKey); | |
+ ByteBuffer gensigbuf = ByteBuffer.allocate(32 + 8); | |
+ gensigbuf.put(previousBlock.getGenerationSignature()); | |
+ gensigbuf.putLong(previousBlock.getGeneratorId()); | |
+ | |
+ Shabal256 md = new Shabal256(); | |
+ md.update(gensigbuf.array()); | |
+ byte[] generationSignature = md.digest(); | |
BlockImpl block; | |
int version = previousBlock.getHeight() < Constants.NQT_BLOCK ? 2 : 3; | |
@@ -736,7 +690,7 @@ final class BlockchainProcessorImpl implements BlockchainProcessor { | |
try { | |
block = new BlockImpl(version, blockTimestamp, previousBlock.getId(), totalAmountNQT, totalFeeNQT, payloadLength, | |
- payloadHash, publicKey, generationSignature, null, previousBlockHash, new ArrayList<>(newTransactions.values())); | |
+ payloadHash, publicKey, generationSignature, null, previousBlockHash, new ArrayList<>(newTransactions.values()), nonce); | |
} catch (NxtException.ValidationException e) { | |
// shouldn't happen because all transactions are already validated | |
@@ -779,6 +733,7 @@ final class BlockchainProcessorImpl implements BlockchainProcessor { | |
byte[] generationSignature = Convert.parseHexString((String) blockData.get("generationSignature")); | |
byte[] blockSignature = Convert.parseHexString((String) blockData.get("blockSignature")); | |
byte[] previousBlockHash = version == 1 ? null : Convert.parseHexString((String) blockData.get("previousBlockHash")); | |
+ Long nonce = Convert.parseUnsignedLong((String)blockData.get("nonce")); | |
SortedMap<Long, TransactionImpl> blockTransactions = new TreeMap<>(); | |
JSONArray transactionsData = (JSONArray)blockData.get("transactions"); | |
@@ -790,14 +745,7 @@ final class BlockchainProcessorImpl implements BlockchainProcessor { | |
} | |
return new BlockImpl(version, timestamp, previousBlock, totalAmountNQT, totalFeeNQT, payloadLength, payloadHash, generatorPublicKey, | |
- generationSignature, blockSignature, previousBlockHash, new ArrayList<>(blockTransactions.values())); | |
- } | |
- | |
- private boolean verifyVersion(Block block, int currentHeight) { | |
- return block.getVersion() == | |
- (currentHeight < Constants.TRANSPARENT_FORGING_BLOCK ? 1 | |
- : currentHeight < Constants.NQT_BLOCK ? 2 | |
- : 3); | |
+ generationSignature, blockSignature, previousBlockHash, new ArrayList<>(blockTransactions.values()), nonce); | |
} | |
private boolean hasAllReferencedTransactions(Transaction transaction, int timestamp, int count) { | |
@@ -832,7 +780,7 @@ final class BlockchainProcessorImpl implements BlockchainProcessor { | |
transactionProcessor.clear(); | |
Generator.clear(); | |
blockchain.setLastBlock(BlockDb.findBlock(Genesis.GENESIS_BLOCK_ID)); | |
- Account.addOrGetAccount(Genesis.CREATOR_ID).apply(Genesis.CREATOR_PUBLIC_KEY, 0); | |
+ //Account.addOrGetAccount(Genesis.CREATOR_ID).apply(Genesis.CREATOR_PUBLIC_KEY, 0); | |
try (Connection con = Db.getConnection(); PreparedStatement pstmt = con.prepareStatement("SELECT * FROM block ORDER BY db_id ASC")) { | |
Long currentBlockId = Genesis.GENESIS_BLOCK_ID; | |
BlockImpl currentBlock; | |
@@ -841,15 +789,15 @@ final class BlockchainProcessorImpl implements BlockchainProcessor { | |
while (rs.next()) { | |
currentBlock = BlockDb.loadBlock(con, rs); | |
if (! currentBlock.getId().equals(currentBlockId)) { | |
+ if(currentBlockId == Genesis.GENESIS_BLOCK_ID) { | |
+ Logger.logDebugMessage("Wrong genesis block id set. Should be: " + currentBlock.getId().toString()); | |
+ } | |
throw new NxtException.ValidationException("Database blocks in the wrong order!"); | |
} | |
if (validateAtScan && ! currentBlockId.equals(Genesis.GENESIS_BLOCK_ID)) { | |
if (!currentBlock.verifyBlockSignature() || !currentBlock.verifyGenerationSignature()) { | |
throw new NxtException.ValidationException("Invalid block signature"); | |
} | |
- if (! verifyVersion(currentBlock, blockchain.getHeight())) { | |
- throw new NxtException.ValidationException("Invalid block version"); | |
- } | |
for (TransactionImpl transaction : currentBlock.getTransactions()) { | |
if (!transaction.verify()) { | |
throw new NxtException.ValidationException("Invalid transaction signature"); | |
diff --git a/java/nxt/Constants.java b/java/nxt/Constants.java | |
index da42255..df43224 100644 | |
--- a/java/nxt/Constants.java | |
+++ b/java/nxt/Constants.java | |
@@ -1,5 +1,6 @@ | |
package nxt; | |
+import java.math.BigInteger; | |
import java.util.Calendar; | |
import java.util.TimeZone; | |
@@ -8,12 +9,12 @@ public final class Constants { | |
public static final int BLOCK_HEADER_LENGTH = 232; | |
public static final int MAX_NUMBER_OF_TRANSACTIONS = 255; | |
public static final int MAX_PAYLOAD_LENGTH = MAX_NUMBER_OF_TRANSACTIONS * 160; | |
- public static final long MAX_BALANCE_NXT = 1000000000; | |
+ public static final long MAX_BALANCE_NXT = 2158812800L; | |
public static final long ONE_NXT = 100000000; | |
public static final long MAX_BALANCE_NQT = MAX_BALANCE_NXT * ONE_NXT; | |
- public static final long INITIAL_BASE_TARGET = 153722867; | |
- public static final long MAX_BASE_TARGET = MAX_BALANCE_NXT * INITIAL_BASE_TARGET; | |
- | |
+ public static final long INITIAL_BASE_TARGET = 18325193796L; | |
+ public static final long MAX_BASE_TARGET = 18325193796L; | |
+ | |
public static final int MAX_ALIAS_URI_LENGTH = 1000; | |
public static final int MAX_ALIAS_LENGTH = 100; | |
@@ -47,20 +48,20 @@ public final class Constants { | |
public static final boolean isTestnet = Nxt.getBooleanProperty("nxt.isTestnet"); | |
- public static final int ALIAS_SYSTEM_BLOCK = 22000; | |
- public static final int TRANSPARENT_FORGING_BLOCK = 30000; | |
- public static final int ARBITRARY_MESSAGES_BLOCK = 40000; | |
- public static final int TRANSPARENT_FORGING_BLOCK_2 = 47000; | |
- public static final int TRANSPARENT_FORGING_BLOCK_3 = 51000; | |
- public static final int TRANSPARENT_FORGING_BLOCK_4 = 64000; | |
- public static final int TRANSPARENT_FORGING_BLOCK_5 = 67000; | |
- public static final int TRANSPARENT_FORGING_BLOCK_6 = isTestnet ? 75000 : 130000; | |
+ public static final int ALIAS_SYSTEM_BLOCK = 0; | |
+ public static final int TRANSPARENT_FORGING_BLOCK = 0; | |
+ public static final int ARBITRARY_MESSAGES_BLOCK = 0; | |
+ public static final int TRANSPARENT_FORGING_BLOCK_2 = 0; | |
+ public static final int TRANSPARENT_FORGING_BLOCK_3 = 0; | |
+ public static final int TRANSPARENT_FORGING_BLOCK_4 = 0; | |
+ public static final int TRANSPARENT_FORGING_BLOCK_5 = 0; | |
+ public static final int TRANSPARENT_FORGING_BLOCK_6 = 0; | |
public static final int TRANSPARENT_FORGING_BLOCK_7 = isTestnet ? 75000 : Integer.MAX_VALUE; | |
- public static final int NQT_BLOCK = isTestnet ? 76500 : 132000; | |
- public static final int FRACTIONAL_BLOCK = isTestnet ? NQT_BLOCK : 134000; | |
- public static final int ASSET_EXCHANGE_BLOCK = isTestnet ? NQT_BLOCK : 135000; | |
- public static final int REFERENCED_TRANSACTION_FULL_HASH_BLOCK = isTestnet ? 78000 : 140000; | |
- public static final int REFERENCED_TRANSACTION_FULL_HASH_BLOCK_TIMESTAMP = isTestnet ? 13031352 : 15134204; | |
+ public static final int NQT_BLOCK = 0; | |
+ public static final int FRACTIONAL_BLOCK = 0; | |
+ public static final int ASSET_EXCHANGE_BLOCK = 0; | |
+ public static final int REFERENCED_TRANSACTION_FULL_HASH_BLOCK = 0; | |
+ public static final int REFERENCED_TRANSACTION_FULL_HASH_BLOCK_TIMESTAMP = 0; | |
public static final int VOTING_SYSTEM_BLOCK = isTestnet ? 0 : Integer.MAX_VALUE; | |
public static final int DIGITAL_GOODS_STORE_BLOCK = isTestnet ? 0 : Integer.MAX_VALUE; | |
@@ -69,10 +70,10 @@ public final class Constants { | |
public static final long EPOCH_BEGINNING; | |
static { | |
Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("UTC")); | |
- calendar.set(Calendar.YEAR, 2013); | |
- calendar.set(Calendar.MONTH, Calendar.NOVEMBER); | |
- calendar.set(Calendar.DAY_OF_MONTH, 24); | |
- calendar.set(Calendar.HOUR_OF_DAY, 12); | |
+ calendar.set(Calendar.YEAR, 2014); | |
+ calendar.set(Calendar.MONTH, Calendar.AUGUST); | |
+ calendar.set(Calendar.DAY_OF_MONTH, 11); | |
+ calendar.set(Calendar.HOUR_OF_DAY, 2); | |
calendar.set(Calendar.MINUTE, 0); | |
calendar.set(Calendar.SECOND, 0); | |
calendar.set(Calendar.MILLISECOND, 0); | |
diff --git a/java/nxt/DbVersion.java b/java/nxt/DbVersion.java | |
index 7106d2a..0dc6153 100644 | |
--- a/java/nxt/DbVersion.java | |
+++ b/java/nxt/DbVersion.java | |
@@ -66,7 +66,7 @@ final class DbVersion { | |
+ "previous_block_hash BINARY(32), cumulative_difficulty VARBINARY NOT NULL, base_target BIGINT NOT NULL, " | |
+ "next_block_id BIGINT, FOREIGN KEY (next_block_id) REFERENCES block (id) ON DELETE SET NULL, " | |
+ "index INT NOT NULL, height INT NOT NULL, generation_signature BINARY(64) NOT NULL, " | |
- + "block_signature BINARY(64) NOT NULL, payload_hash BINARY(32) NOT NULL, generator_account_id BIGINT NOT NULL)"); | |
+ + "block_signature BINARY(64) NOT NULL, payload_hash BINARY(32) NOT NULL, generator_account_id BIGINT NOT NULL, nonce BIGINT NOT NULL)"); | |
case 2: | |
apply("CREATE UNIQUE INDEX IF NOT EXISTS block_id_idx ON block (id)"); | |
case 3: | |
@@ -143,7 +143,7 @@ final class DbVersion { | |
case 36: | |
apply("CREATE TABLE IF NOT EXISTS peer (address VARCHAR PRIMARY KEY)"); | |
case 37: | |
- if (!Constants.isTestnet) { | |
+ /*if (!Constants.isTestnet) { | |
apply("INSERT INTO peer (address) VALUES " + | |
"('samson.vps.nxtcrypto.org'), ('210.70.137.216:80'), ('178.15.99.67'), ('114.215.130.79'), " + | |
"('85.25.198.120'), ('82.192.39.33'), ('84.242.91.139'), ('178.33.203.157'), ('bitsy08.vps.nxtcrypto.org'), " + | |
@@ -174,7 +174,8 @@ final class DbVersion { | |
"('178.150.207.53'), ('192.241.223.132'), ('node9.mynxtcoin.org'), ('node10.mynxtcoin.org'), " + | |
"('node3.mynxtcoin.org'), ('109.87.169.253'), ('nxtnet.fr'), ('50.112.241.97'), " + | |
"('2.84.142.149'), ('bug.airdns.org'), ('83.212.103.14'), ('62.210.131.30')"); | |
- } | |
+ }*/ | |
+ apply(null); | |
case 38: | |
apply("ALTER TABLE transaction ADD COLUMN IF NOT EXISTS full_hash BINARY(32)"); | |
case 39: | |
diff --git a/java/nxt/Generator.java b/java/nxt/Generator.java | |
index c8e0a1f..85456ec 100644 | |
--- a/java/nxt/Generator.java | |
+++ b/java/nxt/Generator.java | |
@@ -6,14 +6,21 @@ import nxt.util.Listener; | |
import nxt.util.Listeners; | |
import nxt.util.Logger; | |
import nxt.util.ThreadPool; | |
+import nxt.util.MiningPlot; | |
import java.math.BigInteger; | |
+import java.nio.ByteBuffer; | |
import java.security.MessageDigest; | |
import java.util.Collection; | |
import java.util.Collections; | |
+import java.util.Iterator; | |
+import java.util.Map; | |
+import java.util.Map.Entry; | |
import java.util.concurrent.ConcurrentHashMap; | |
import java.util.concurrent.ConcurrentMap; | |
+import fr.cryptohash.Shabal256; | |
+ | |
public final class Generator { | |
public static enum Event { | |
@@ -22,9 +29,6 @@ public final class Generator { | |
private static final Listeners<Generator,Event> listeners = new Listeners<>(); | |
- private static final ConcurrentMap<Long, Block> lastBlocks = new ConcurrentHashMap<>(); | |
- private static final ConcurrentMap<Long, BigInteger> hits = new ConcurrentHashMap<>(); | |
- | |
private static final ConcurrentMap<String, Generator> generators = new ConcurrentHashMap<>(); | |
private static final Collection<Generator> allGenerators = Collections.unmodifiableCollection(generators.values()); | |
@@ -34,9 +38,20 @@ public final class Generator { | |
public void run() { | |
try { | |
+ if (Nxt.getBlockchainProcessor().isScanning()) { | |
+ return; | |
+ } | |
try { | |
- for (Generator generator : generators.values()) { | |
- generator.forge(); | |
+ long currentBlock = Nxt.getBlockchain().getLastBlock().getHeight(); | |
+ Iterator<Entry<String, Generator>> it = generators.entrySet().iterator(); | |
+ while(it.hasNext()) { | |
+ Entry<String, Generator> generator = it.next(); | |
+ if(currentBlock < generator.getValue().getBlock()) { | |
+ generator.getValue().forge(); | |
+ } | |
+ else { | |
+ it.remove(); | |
+ } | |
} | |
} catch (Exception e) { | |
Logger.logDebugMessage("Error in block generation thread", e); | |
@@ -58,8 +73,6 @@ public final class Generator { | |
static void init() {} | |
static void clear() { | |
- lastBlocks.clear(); | |
- hits.clear(); | |
} | |
public static boolean addListener(Listener<Generator> listener, Event eventType) { | |
@@ -71,78 +84,97 @@ public final class Generator { | |
} | |
public static Generator startForging(String secretPhrase) { | |
- byte[] publicKey = Crypto.getPublicKey(secretPhrase); | |
- return startForging(secretPhrase, publicKey); | |
+ return null; | |
+ } | |
+ | |
+ public static Generator addNonce(String secretPhrase, Long nonce) { | |
+ byte[] publicKey = Crypto.getPublicKey(secretPhrase); | |
+ return addNonce(secretPhrase, nonce, publicKey); | |
} | |
public static Generator startForging(String secretPhrase, byte[] publicKey) { | |
- Account account = Account.getAccount(publicKey); | |
- if (account == null) { | |
- return null; | |
- } | |
- Generator generator = new Generator(secretPhrase, publicKey, account); | |
- Generator old = generators.putIfAbsent(secretPhrase, generator); | |
- if (old != null) { | |
- Logger.logDebugMessage("Account " + Convert.toUnsignedLong(account.getId()) + " is already forging"); | |
- return old; | |
- } | |
- listeners.notify(generator, Event.START_FORGING); | |
- Logger.logDebugMessage("Account " + Convert.toUnsignedLong(account.getId()) + " started forging, deadline " | |
- + generator.getDeadline() + " seconds"); | |
- return generator; | |
+ return null; | |
+ } | |
+ | |
+ public static Generator addNonce(String secretPhrase, Long nonce, byte[] publicKey) { | |
+ byte[] publicKeyHash = Crypto.sha256().digest(publicKey); | |
+ Long id = Convert.fullHashToId(publicKeyHash); | |
+ | |
+ Generator generator = new Generator(secretPhrase, nonce, publicKey, id); | |
+ Generator curGen = generators.get(secretPhrase); | |
+ if(curGen == null || generator.getBlock() > curGen.getBlock() || generator.getDeadline().compareTo(curGen.getDeadline()) < 0) { | |
+ generators.put(secretPhrase, generator); | |
+ listeners.notify(generator, Event.START_FORGING); | |
+ Logger.logDebugMessage("Account " + Convert.toUnsignedLong(id) + " started mining, deadline " | |
+ + generator.getDeadline() + " seconds"); | |
+ } | |
+ else { | |
+ Logger.logDebugMessage("Account " + Convert.toUnsignedLong(id) + " already has better nonce"); | |
+ } | |
+ | |
+ return generator; | |
} | |
public static Generator stopForging(String secretPhrase) { | |
- Generator generator = generators.remove(secretPhrase); | |
- if (generator != null) { | |
- lastBlocks.remove(generator.accountId); | |
- hits.remove(generator.accountId); | |
- Logger.logDebugMessage("Account " + Convert.toUnsignedLong(generator.getAccountId()) + " stopped forging"); | |
- listeners.notify(generator, Event.STOP_FORGING); | |
- } | |
- return generator; | |
+ return null; | |
} | |
public static Generator getGenerator(String secretPhrase) { | |
- return generators.get(secretPhrase); | |
+ return generators.get(secretPhrase); | |
} | |
public static Collection<Generator> getAllGenerators() { | |
return allGenerators; | |
} | |
- static long getHitTime(Account account, Block block) { | |
- return getHitTime(account.getEffectiveBalanceNXT(), getHit(account.getPublicKey(), block), block); | |
- } | |
- | |
- private static BigInteger getHit(byte[] publicKey, Block block) { | |
- if (block.getHeight() < Constants.TRANSPARENT_FORGING_BLOCK) { | |
- throw new IllegalArgumentException("Not supported below Transparent Forging Block"); | |
- } | |
- MessageDigest digest = Crypto.sha256(); | |
- digest.update(block.getGenerationSignature()); | |
- byte[] generationSignatureHash = digest.digest(publicKey); | |
- return new BigInteger(1, new byte[] {generationSignatureHash[7], generationSignatureHash[6], generationSignatureHash[5], generationSignatureHash[4], generationSignatureHash[3], generationSignatureHash[2], generationSignatureHash[1], generationSignatureHash[0]}); | |
- } | |
- | |
- private static long getHitTime(long effectiveBalanceNXT, BigInteger hit, Block block) { | |
- return block.getTimestamp() | |
- + hit.divide(BigInteger.valueOf(block.getBaseTarget()) | |
- .multiply(BigInteger.valueOf(effectiveBalanceNXT))).longValue(); | |
- } | |
- | |
- | |
private final Long accountId; | |
private final String secretPhrase; | |
private final byte[] publicKey; | |
- private volatile long deadline; | |
+ private volatile BigInteger deadline; | |
+ private final long nonce; | |
+ private final long block; | |
- private Generator(String secretPhrase, byte[] publicKey, Account account) { | |
+ private Generator(String secretPhrase, Long nonce, byte[] publicKey, Long account) { | |
this.secretPhrase = secretPhrase; | |
this.publicKey = publicKey; | |
// need to store publicKey in addition to accountId, because the account may not have had its publicKey set yet | |
- this.accountId = account.getId(); | |
- forge(); // initialize deadline | |
+ this.accountId = account; | |
+ this.nonce = nonce; | |
+ this.block = Nxt.getBlockchain().getLastBlock().getHeight() + 1; | |
+ | |
+ // get new generation signature | |
+ Block lastBlock = Nxt.getBlockchain().getLastBlock(); | |
+ byte[] lastGenSig = lastBlock.getGenerationSignature(); | |
+ Long lastGenerator = lastBlock.getGeneratorId(); | |
+ | |
+ ByteBuffer gensigbuf = ByteBuffer.allocate(32 + 8); | |
+ gensigbuf.put(lastGenSig); | |
+ gensigbuf.putLong(lastGenerator); | |
+ | |
+ Shabal256 md = new Shabal256(); | |
+ md.update(gensigbuf.array()); | |
+ byte[] newGenSig = md.digest(); | |
+ | |
+ // calculate deadline | |
+ MiningPlot plot = new MiningPlot(accountId, nonce); | |
+ | |
+ ByteBuffer posbuf = ByteBuffer.allocate(32 + 8); | |
+ posbuf.put(newGenSig); | |
+ posbuf.putLong(lastBlock.getHeight() + 1); | |
+ md.reset(); | |
+ md.update(posbuf.array()); | |
+ BigInteger hashnum = new BigInteger(1, md.digest()); | |
+ int scoopNum = hashnum.mod(BigInteger.valueOf(MiningPlot.SCOOPS_PER_PLOT)).intValue(); | |
+ | |
+ md.reset(); | |
+ md.update(newGenSig); | |
+ plot.hashScoop(md, scoopNum); | |
+ byte[] hash = md.digest(); | |
+ BigInteger hit = new BigInteger(1, new byte[] {hash[7], hash[6], hash[5], hash[4], hash[3], hash[2], hash[1], hash[0]}); | |
+ | |
+ deadline = hit.divide(BigInteger.valueOf(lastBlock.getBaseTarget())); | |
+ | |
+ forge(); | |
} | |
public byte[] getPublicKey() { | |
@@ -153,52 +185,20 @@ public final class Generator { | |
return accountId; | |
} | |
- public long getDeadline() { | |
+ public BigInteger getDeadline() { | |
return deadline; | |
} | |
+ | |
+ public long getBlock() { | |
+ return block; | |
+ } | |
private void forge() { | |
- | |
- if (Nxt.getBlockchainProcessor().isScanning()) { | |
- return; | |
- } | |
- | |
- Account account = Account.getAccount(accountId); | |
- if (account == null) { | |
- return; | |
- } | |
- long effectiveBalance = account.getEffectiveBalanceNXT(); | |
- if (effectiveBalance <= 0) { | |
- return; | |
- } | |
- | |
Block lastBlock = Nxt.getBlockchain().getLastBlock(); | |
- if (lastBlock.getHeight() < Constants.ASSET_EXCHANGE_BLOCK) { | |
- return; | |
- } | |
- | |
- if (! lastBlock.equals(lastBlocks.get(accountId))) { | |
- | |
- BigInteger hit = getHit(publicKey, lastBlock); | |
- | |
- lastBlocks.put(accountId, lastBlock); | |
- hits.put(accountId, hit); | |
- | |
- deadline = Math.max(getHitTime(account.getEffectiveBalanceNXT(), hit, lastBlock) - Convert.getEpochTime(), 0); | |
- | |
- listeners.notify(this, Event.GENERATION_DEADLINE); | |
- | |
- } | |
- | |
int elapsedTime = Convert.getEpochTime() - lastBlock.getTimestamp(); | |
- if (elapsedTime > 0) { | |
- BigInteger target = BigInteger.valueOf(lastBlock.getBaseTarget()) | |
- .multiply(BigInteger.valueOf(effectiveBalance)) | |
- .multiply(BigInteger.valueOf(elapsedTime)); | |
- if (hits.get(accountId).compareTo(target) < 0) { | |
- BlockchainProcessorImpl.getInstance().generateBlock(secretPhrase); | |
- } | |
+ if (BigInteger.valueOf(elapsedTime).compareTo(deadline) > 0) { | |
+ BlockchainProcessorImpl.getInstance().generateBlock(secretPhrase, nonce); | |
} | |
} | |
diff --git a/java/nxt/Genesis.java b/java/nxt/Genesis.java | |
index 9b81b6d..27c5612 100644 | |
--- a/java/nxt/Genesis.java | |
+++ b/java/nxt/Genesis.java | |
@@ -4,242 +4,21 @@ import java.math.BigInteger; | |
public final class Genesis { | |
- public static final Long GENESIS_BLOCK_ID = 2680262203532249785L; | |
- public static final Long CREATOR_ID = 1739068987193023818L; | |
+ public static final Long GENESIS_BLOCK_ID = 3444294670862540038L; | |
+ public static final Long CREATOR_ID = 0L; | |
public static final byte[] CREATOR_PUBLIC_KEY = { | |
- 18, 89, -20, 33, -45, 26, 48, -119, -115, 124, -47, 96, -97, -128, -39, 102, | |
- -117, 71, 120, -29, -39, 126, -108, 16, 68, -77, -97, 12, 68, -46, -27, 27 | |
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 | |
}; | |
- public static final Long[] GENESIS_RECIPIENTS = { | |
- (new BigInteger("163918645372308887")).longValue(), | |
- (new BigInteger("620741658595224146")).longValue(), | |
- (new BigInteger("723492359641172834")).longValue(), | |
- (new BigInteger("818877006463198736")).longValue(), | |
- (new BigInteger("1264744488939798088")).longValue(), | |
- (new BigInteger("1600633904360147460")).longValue(), | |
- (new BigInteger("1796652256451468602")).longValue(), | |
- (new BigInteger("1814189588814307776")).longValue(), | |
- (new BigInteger("1965151371996418680")).longValue(), | |
- (new BigInteger("2175830371415049383")).longValue(), | |
- (new BigInteger("2401730748874927467")).longValue(), | |
- (new BigInteger("2584657662098653454")).longValue(), | |
- (new BigInteger("2694765945307858403")).longValue(), | |
- (new BigInteger("3143507805486077020")).longValue(), | |
- (new BigInteger("3684449848581573439")).longValue(), | |
- (new BigInteger("4071545868996394636")).longValue(), | |
- (new BigInteger("4277298711855908797")).longValue(), | |
- (new BigInteger("4454381633636789149")).longValue(), | |
- (new BigInteger("4747512364439223888")).longValue(), | |
- (new BigInteger("4777958973882919649")).longValue(), | |
- (new BigInteger("4803826772380379922")).longValue(), | |
- (new BigInteger("5095742298090230979")).longValue(), | |
- (new BigInteger("5271441507933314159")).longValue(), | |
- (new BigInteger("5430757907205901788")).longValue(), | |
- (new BigInteger("5491587494620055787")).longValue(), | |
- (new BigInteger("5622658764175897611")).longValue(), | |
- (new BigInteger("5982846390354787993")).longValue(), | |
- (new BigInteger("6290807999797358345")).longValue(), | |
- (new BigInteger("6785084810899231190")).longValue(), | |
- (new BigInteger("6878906112724074600")).longValue(), | |
- (new BigInteger("7017504655955743955")).longValue(), | |
- (new BigInteger("7085298282228890923")).longValue(), | |
- (new BigInteger("7446331133773682477")).longValue(), | |
- (new BigInteger("7542917420413518667")).longValue(), | |
- (new BigInteger("7549995577397145669")).longValue(), | |
- (new BigInteger("7577840883495855927")).longValue(), | |
- (new BigInteger("7579216551136708118")).longValue(), | |
- (new BigInteger("8278234497743900807")).longValue(), | |
- (new BigInteger("8517842408878875334")).longValue(), | |
- (new BigInteger("8870453786186409991")).longValue(), | |
- (new BigInteger("9037328626462718729")).longValue(), | |
- (new BigInteger("9161949457233564608")).longValue(), | |
- (new BigInteger("9230759115816986914")).longValue(), | |
- (new BigInteger("9306550122583806885")).longValue(), | |
- (new BigInteger("9433259657262176905")).longValue(), | |
- (new BigInteger("9988839211066715803")).longValue(), | |
- (new BigInteger("10105875265190846103")).longValue(), | |
- (new BigInteger("10339765764359265796")).longValue(), | |
- (new BigInteger("10738613957974090819")).longValue(), | |
- (new BigInteger("10890046632913063215")).longValue(), | |
- (new BigInteger("11494237785755831723")).longValue(), | |
- (new BigInteger("11541844302056663007")).longValue(), | |
- (new BigInteger("11706312660844961581")).longValue(), | |
- (new BigInteger("12101431510634235443")).longValue(), | |
- (new BigInteger("12186190861869148835")).longValue(), | |
- (new BigInteger("12558748907112364526")).longValue(), | |
- (new BigInteger("13138516747685979557")).longValue(), | |
- (new BigInteger("13330279748251018740")).longValue(), | |
- (new BigInteger("14274119416917666908")).longValue(), | |
- (new BigInteger("14557384677985343260")).longValue(), | |
- (new BigInteger("14748294830376619968")).longValue(), | |
- (new BigInteger("14839596582718854826")).longValue(), | |
- (new BigInteger("15190676494543480574")).longValue(), | |
- (new BigInteger("15253761794338766759")).longValue(), | |
- (new BigInteger("15558257163011348529")).longValue(), | |
- (new BigInteger("15874940801139996458")).longValue(), | |
- (new BigInteger("16516270647696160902")).longValue(), | |
- (new BigInteger("17156841960446798306")).longValue(), | |
- (new BigInteger("17228894143802851995")).longValue(), | |
- (new BigInteger("17240396975291969151")).longValue(), | |
- (new BigInteger("17491178046969559641")).longValue(), | |
- (new BigInteger("18345202375028346230")).longValue(), | |
- (new BigInteger("18388669820699395594")).longValue()}; | |
+ public static final Long[] GENESIS_RECIPIENTS = {}; | |
- public static final int[] GENESIS_AMOUNTS = { | |
- 36742, | |
- 1970092, | |
- 349130, | |
- 24880020, | |
- 2867856, | |
- 9975150, | |
- 2690963, | |
- 7648, | |
- 5486333, | |
- 34913026, | |
- 997515, | |
- 30922966, | |
- 6650, | |
- 44888, | |
- 2468850, | |
- 49875751, | |
- 49875751, | |
- 9476393, | |
- 49875751, | |
- 14887912, | |
- 528683, | |
- 583546, | |
- 7315, | |
- 19925363, | |
- 29856290, | |
- 5320, | |
- 4987575, | |
- 5985, | |
- 24912938, | |
- 49875751, | |
- 2724712, | |
- 1482474, | |
- 200999, | |
- 1476156, | |
- 498758, | |
- 987540, | |
- 16625250, | |
- 5264386, | |
- 15487585, | |
- 2684479, | |
- 14962725, | |
- 34913026, | |
- 5033128, | |
- 2916900, | |
- 49875751, | |
- 4962637, | |
- 170486123, | |
- 8644631, | |
- 22166945, | |
- 6668388, | |
- 233751, | |
- 4987575, | |
- 11083556, | |
- 1845403, | |
- 49876, | |
- 3491, | |
- 3491, | |
- 9476, | |
- 49876, | |
- 6151, | |
- 682633, | |
- 49875751, | |
- 482964, | |
- 4988, | |
- 49875751, | |
- 4988, | |
- 9144, | |
- 503745, | |
- 49875751, | |
- 52370, | |
- 29437998, | |
- 585375, | |
- 9975150 | |
- }; | |
+ public static final int[] GENESIS_AMOUNTS = {}; | |
- public static final byte[][] GENESIS_SIGNATURES = { | |
- {41, 115, -41, 7, 37, 21, -3, -41, 120, 119, 63, -101, 108, 48, -117, 1, -43, 32, 85, 95, 65, 42, 92, -22, 123, -36, 6, -99, -61, -53, 93, 7, 23, 8, -30, 65, 57, -127, -2, 42, -92, -104, 11, 72, -66, 108, 17, 113, 99, -117, -75, 123, 110, 107, 119, -25, 67, 64, 32, 117, 111, 54, 82, -14}, | |
- {118, 43, 84, -91, -110, -102, 100, -40, -33, -47, -13, -7, -88, 2, -42, -66, -38, -22, 105, -42, -69, 78, 51, -55, -48, 49, -89, 116, -96, -104, -114, 14, 94, 58, -115, -8, 111, -44, 76, -104, 54, -15, 126, 31, 6, -80, 65, 6, 124, 37, -73, 92, 4, 122, 122, -108, 1, -54, 31, -38, -117, -1, -52, -56}, | |
- {79, 100, -101, 107, -6, -61, 40, 32, -98, 32, 80, -59, -76, -23, -62, 38, 4, 105, -106, -105, -121, -85, 13, -98, -77, 126, -125, 103, 12, -41, 1, 2, 45, -62, -69, 102, 116, -61, 101, -14, -68, -31, 9, 110, 18, 2, 33, -98, -37, -128, 17, -19, 124, 125, -63, 92, -70, 96, 96, 125, 91, 8, -65, -12}, | |
- {58, -99, 14, -97, -75, -10, 110, -102, 119, -3, -2, -12, -82, -33, -27, 118, -19, 55, -109, 6, 110, -10, 108, 30, 94, -113, -5, -98, 19, 12, -125, 14, -77, 33, -128, -21, 36, -120, -12, -81, 64, 95, 67, -3, 100, 122, -47, 127, -92, 114, 68, 72, 2, -40, 80, 117, -17, -56, 103, 37, -119, 3, 22, 23}, | |
- {76, 22, 121, -4, -77, -127, 18, -102, 7, 94, -73, -96, 108, -11, 81, -18, -37, -85, -75, 86, -119, 94, 126, 95, 47, -36, -16, -50, -9, 95, 60, 15, 14, 93, -108, -83, -67, 29, 2, -53, 10, -118, -51, -46, 92, -23, -56, 60, 46, -90, -84, 126, 60, 78, 12, 53, 61, 121, -6, 77, 112, 60, 40, 63}, | |
- {64, 121, -73, 68, 4, -103, 81, 55, -41, -81, -63, 10, 117, -74, 54, -13, -85, 79, 21, 116, -25, -12, 21, 120, -36, -80, 53, -78, 103, 25, 55, 6, -75, 96, 80, -125, -11, -103, -20, -41, 121, -61, -40, 63, 24, -81, -125, 90, -12, -40, -52, -1, -114, 14, -44, -112, -80, 83, -63, 88, -107, -10, -114, -86}, | |
- {-81, 126, -41, -34, 66, -114, -114, 114, 39, 32, -125, -19, -95, -50, -111, -51, -33, 51, 99, -127, 58, 50, -110, 44, 80, -94, -96, 68, -69, 34, 86, 3, -82, -69, 28, 20, -111, 69, 18, -41, -23, 27, -118, 20, 72, 21, -112, 53, -87, -81, -47, -101, 123, -80, 99, -15, 33, -120, -8, 82, 80, -8, -10, -45}, | |
- {92, 77, 53, -87, 26, 13, -121, -39, -62, -42, 47, 4, 7, 108, -15, 112, 103, 38, -50, -74, 60, 56, -63, 43, -116, 49, -106, 69, 118, 65, 17, 12, 31, 127, -94, 55, -117, -29, -117, 31, -95, -110, -2, 63, -73, -106, -88, -41, -19, 69, 60, -17, -16, 61, 32, -23, 88, -106, -96, 37, -96, 114, -19, -99}, | |
- {68, -26, 57, -56, -30, 108, 61, 24, 106, -56, -92, 99, -59, 107, 25, -110, -57, 80, 79, -92, -107, 90, 54, -73, -40, -39, 78, 109, -57, -62, -17, 6, -25, -29, 37, 90, -24, -27, -61, -69, 44, 121, 107, -72, -57, 108, 32, -69, -21, -41, 126, 91, 118, 11, -91, 50, -11, 116, 126, -96, -39, 110, 105, -52}, | |
- {48, 108, 123, 50, -50, -58, 33, 14, 59, 102, 17, -18, -119, 4, 10, -29, 36, -56, -31, 43, -71, -48, -14, 87, 119, -119, 40, 104, -44, -76, -24, 2, 48, -96, -7, 16, -119, -3, 108, 78, 125, 88, 61, -53, -3, -16, 20, -83, 74, 124, -47, -17, -15, -21, -23, -119, -47, 105, -4, 115, -20, 77, 57, 88}, | |
- {33, 101, 79, -35, 32, -119, 20, 120, 34, -80, -41, 90, -22, 93, -20, -45, 9, 24, -46, 80, -55, -9, -24, -78, -124, 27, -120, -36, -51, 59, -38, 7, 113, 125, 68, 109, 24, -121, 111, 37, -71, 100, -111, 78, -43, -14, -76, -44, 64, 103, 16, -28, -44, -103, 74, 81, -118, -74, 47, -77, -65, 8, 42, -100}, | |
- {-63, -96, -95, -111, -85, -98, -85, 42, 87, 29, -62, -57, 57, 48, 9, -39, -110, 63, -103, -114, -48, -11, -92, 105, -26, -79, -11, 78, -118, 14, -39, 1, -115, 74, 70, -41, -119, -68, -39, -60, 64, 31, 25, -111, -16, -20, 61, -22, 17, -13, 57, -110, 24, 61, -104, 21, -72, -69, 56, 116, -117, 93, -1, -123}, | |
- {-18, -70, 12, 112, -111, 10, 22, 31, -120, 26, 53, 14, 10, 69, 51, 45, -50, -127, -22, 95, 54, 17, -8, 54, -115, 36, -79, 12, -79, 82, 4, 1, 92, 59, 23, -13, -85, -87, -110, -58, 84, -31, -48, -105, -101, -92, -9, 28, -109, 77, -47, 100, -48, -83, 106, -102, 70, -95, 94, -1, -99, -15, 21, 99}, | |
- {109, 123, 54, 40, -120, 32, -118, 49, -52, 0, -103, 103, 101, -9, 32, 78, 124, -56, 88, -19, 101, -32, 70, 67, -41, 85, -103, 1, 1, -105, -51, 10, 4, 51, -26, -19, 39, -43, 63, -41, -101, 80, 106, -66, 125, 47, -117, -120, -93, -120, 99, -113, -17, 61, 102, -2, 72, 9, -124, 123, -128, 78, 43, 96}, | |
- {-22, -63, 20, 65, 5, -89, -123, -61, 14, 34, 83, -113, 34, 85, 26, -21, 1, 16, 88, 55, -92, -111, 14, -31, -37, -67, -8, 85, 39, -112, -33, 8, 28, 16, 107, -29, 1, 3, 100, -53, 2, 81, 52, -94, -14, 36, -123, -82, -6, -118, 104, 75, -99, -82, -100, 7, 30, -66, 0, -59, 108, -54, 31, 20}, | |
- {0, 13, -74, 28, -54, -12, 45, 36, -24, 55, 43, -110, -72, 117, -110, -56, -72, 85, 79, -89, -92, 65, -67, -34, -24, 38, 67, 42, 84, -94, 91, 13, 100, 89, 20, -95, -76, 2, 116, 34, 67, 52, -80, -101, -22, -32, 51, 32, -76, 44, -93, 11, 42, -69, -12, 7, -52, -55, 122, -10, 48, 21, 92, 110}, | |
- {-115, 19, 115, 28, -56, 118, 111, 26, 18, 123, 111, -96, -115, 120, 105, 62, -123, -124, 101, 51, 3, 18, -89, 127, 48, -27, 39, -78, -118, 5, -2, 6, -105, 17, 123, 26, 25, -62, -37, 49, 117, 3, 10, 97, -7, 54, 121, -90, -51, -49, 11, 104, -66, 11, -6, 57, 5, -64, -8, 59, 82, -126, 26, -113}, | |
- {16, -53, 94, 99, -46, -29, 64, -89, -59, 116, -21, 53, 14, -77, -71, 95, 22, -121, -51, 125, -14, -96, 95, 95, 32, 96, 79, 41, -39, -128, 79, 0, 5, 6, -115, 104, 103, 77, -92, 93, -109, 58, 96, 97, -22, 116, -62, 11, 30, -122, 14, 28, 69, 124, 63, -119, 19, 80, -36, -116, -76, -58, 36, 87}, | |
- {109, -82, 33, -119, 17, 109, -109, -16, 98, 108, 111, 5, 98, 1, -15, -32, 22, 46, -65, 117, -78, 119, 35, -35, -3, 41, 23, -97, 55, 69, 58, 9, 20, -113, -121, -13, -41, -48, 22, -73, -1, -44, -73, 3, -10, -122, 19, -103, 10, -26, -128, 62, 34, 55, 54, -43, 35, -30, 115, 64, -80, -20, -25, 67}, | |
- {-16, -74, -116, -128, 52, 96, -75, 17, -22, 72, -43, 22, -95, -16, 32, -72, 98, 46, -4, 83, 34, -58, -108, 18, 17, -58, -123, 53, -108, 116, 18, 2, 7, -94, -126, -45, 72, -69, -65, -89, 64, 31, -78, 78, -115, 106, 67, 55, -123, 104, -128, 36, -23, -90, -14, -87, 78, 19, 18, -128, 39, 73, 35, 120}, | |
- {20, -30, 15, 111, -82, 39, -108, 57, -80, 98, -19, -27, 100, -18, 47, 77, -41, 95, 80, -113, -128, -88, -76, 115, 65, -53, 83, 115, 7, 2, -104, 3, 120, 115, 14, -116, 33, -15, -120, 22, -56, -8, -69, 5, -75, 94, 124, 12, -126, -48, 51, -105, 22, -66, -93, 16, -63, -74, 32, 114, -54, -3, -47, -126}, | |
- {56, -101, 55, -1, 64, 4, -64, 95, 31, -15, 72, 46, 67, -9, 68, -43, -55, 28, -63, -17, -16, 65, 11, -91, -91, 32, 88, 41, 60, 67, 105, 8, 58, 102, -79, -5, -113, -113, -67, 82, 50, -26, 116, -78, -103, 107, 102, 23, -74, -47, 115, -50, -35, 63, -80, -32, 72, 117, 47, 68, 86, -20, -35, 8}, | |
- {21, 27, 20, -59, 117, -102, -42, 22, -10, 121, 41, -59, 115, 15, -43, 54, -79, -62, -16, 58, 116, 15, 88, 108, 114, 67, 3, -30, -99, 78, 103, 11, 49, 63, -4, -110, -27, 41, 70, -57, -69, -18, 70, 30, -21, 66, -104, -27, 3, 53, 50, 100, -33, 54, -3, -78, 92, 85, -78, 54, 19, 32, 95, 9}, | |
- {-93, 65, -64, -79, 82, 85, -34, -90, 122, -29, -40, 3, -80, -40, 32, 26, 102, -73, 17, 53, -93, -29, 122, 86, 107, -100, 50, 56, -28, 124, 90, 14, 93, -88, 97, 101, -85, -50, 46, -109, -88, -127, -112, 63, -89, 24, -34, -9, -116, -59, -87, -86, -12, 111, -111, 87, -87, -13, -73, -124, -47, 7, 1, 9}, | |
- {60, -99, -77, -20, 112, -75, -34, 100, -4, -96, 81, 71, -116, -62, 38, -68, 105, 7, -126, 21, -125, -25, -56, -11, -59, 95, 117, 108, 32, -38, -65, 13, 46, 65, -46, -89, 0, 120, 5, 23, 40, 110, 114, 79, 111, -70, 8, 16, -49, -52, -82, -18, 108, -43, 81, 96, 72, -65, 70, 7, -37, 58, 46, -14}, | |
- {-95, -32, 85, 78, 74, -53, 93, -102, -26, -110, 86, 1, -93, -50, -23, -108, -37, 97, 19, 103, 94, -65, -127, -21, 60, 98, -51, -118, 82, -31, 27, 7, -112, -45, 79, 95, -20, 90, -4, -40, 117, 100, -6, 19, -47, 53, 53, 48, 105, 91, -70, -34, -5, -87, -57, -103, -112, -108, -40, 87, -25, 13, -76, -116}, | |
- {44, -122, -70, 125, -60, -32, 38, 69, -77, -103, 49, -124, -4, 75, -41, -84, 68, 74, 118, 15, -13, 115, 117, -78, 42, 89, 0, -20, -12, -58, -97, 10, -48, 95, 81, 101, 23, -67, -23, 74, -79, 21, 97, 123, 103, 101, -50, -115, 116, 112, 51, 50, -124, 27, 76, 40, 74, 10, 65, -49, 102, 95, 5, 35}, | |
- {-6, 57, 71, 5, -61, -100, -21, -9, 47, -60, 59, 108, -75, 105, 56, 41, -119, 31, 37, 27, -86, 120, -125, -108, 121, 104, -21, -70, -57, -104, 2, 11, 118, 104, 68, 6, 7, -90, -70, -61, -16, 77, -8, 88, 31, -26, 35, -44, 8, 50, 51, -88, -62, -103, 54, -41, -2, 117, 98, -34, 49, -123, 83, -58}, | |
- {54, 21, -36, 126, -50, -72, 82, -5, -122, -116, 72, -19, -18, -68, -71, -27, 97, -22, 53, -94, 47, -6, 15, -92, -55, 127, 13, 13, -69, 81, -82, 8, -50, 10, 84, 110, -87, -44, 61, -78, -65, 84, -32, 48, -8, -105, 35, 116, -68, -116, -6, 75, -77, 120, -95, 74, 73, 105, 39, -87, 98, -53, 47, 10}, | |
- {-113, 116, 37, -1, 95, -89, -93, 113, 36, -70, -57, -99, 94, 52, -81, -118, 98, 58, -36, 73, 82, -67, -80, 46, 83, -127, -8, 73, 66, -27, 43, 7, 108, 32, 73, 1, -56, -108, 41, -98, -15, 49, 1, 107, 65, 44, -68, 126, -28, -53, 120, -114, 126, -79, -14, -105, -33, 53, 5, -119, 67, 52, 35, -29}, | |
- {98, 23, 23, 83, 78, -89, 13, 55, -83, 97, -30, -67, 99, 24, 47, -4, -117, -34, -79, -97, 95, 74, 4, 21, 66, -26, 15, 80, 60, -25, -118, 14, 36, -55, -41, -124, 90, -1, 84, 52, 31, 88, 83, 121, -47, -59, -10, 17, 51, -83, 23, 108, 19, 104, 32, 29, -66, 24, 21, 110, 104, -71, -23, -103}, | |
- {12, -23, 60, 35, 6, -52, -67, 96, 15, -128, -47, -15, 40, 3, 54, -81, 3, 94, 3, -98, -94, -13, -74, -101, 40, -92, 90, -64, -98, 68, -25, 2, -62, -43, 112, 32, -78, -123, 26, -80, 126, 120, -88, -92, 126, -128, 73, -43, 87, -119, 81, 111, 95, -56, -128, -14, 51, -40, -42, 102, 46, 106, 6, 6}, | |
- {-38, -120, -11, -114, -7, -105, -98, 74, 114, 49, 64, -100, 4, 40, 110, -21, 25, 6, -92, -40, -61, 48, 94, -116, -71, -87, 75, -31, 13, -119, 1, 5, 33, -69, -16, -125, -79, -46, -36, 3, 40, 1, -88, -118, -107, 95, -23, -107, -49, 44, -39, 2, 108, -23, 39, 50, -51, -59, -4, -42, -10, 60, 10, -103}, | |
- {67, -53, 55, -32, -117, 3, 94, 52, -115, -127, -109, 116, -121, -27, -115, -23, 98, 90, -2, 48, -54, -76, 108, -56, 99, 30, -35, -18, -59, 25, -122, 3, 43, -13, -109, 34, -10, 123, 117, 113, -112, -85, -119, -62, -78, -114, -96, 101, 72, -98, 28, 89, -98, -121, 20, 115, 89, -20, 94, -55, 124, 27, -76, 94}, | |
- {15, -101, 98, -21, 8, 5, -114, -64, 74, 123, 99, 28, 125, -33, 22, 23, -2, -56, 13, 91, 27, -105, -113, 19, 60, -7, -67, 107, 70, 103, -107, 13, -38, -108, -77, -29, 2, 9, -12, 21, 12, 65, 108, -16, 69, 77, 96, -54, 55, -78, -7, 41, -48, 124, -12, 64, 113, -45, -21, -119, -113, 88, -116, 113}, | |
- {-17, 77, 10, 84, -57, -12, 101, 21, -91, 92, 17, -32, -26, 77, 70, 46, 81, -55, 40, 44, 118, -35, -97, 47, 5, 125, 41, -127, -72, 66, -18, 2, 115, -13, -74, 126, 86, 80, 11, -122, -29, -68, 113, 54, -117, 107, -75, -107, -54, 72, -44, 98, -111, -33, -56, -40, 93, -47, 84, -43, -45, 86, 65, -84}, | |
- {-126, 60, -56, 121, 31, -124, -109, 100, -118, -29, 106, 94, 5, 27, 13, -79, 91, -111, -38, -42, 18, 61, -100, 118, -18, -4, -60, 121, 46, -22, 6, 4, -37, -20, 124, -43, 51, -57, -49, -44, -24, -38, 81, 60, -14, -97, -109, -11, -5, -85, 75, -17, -124, -96, -53, 52, 64, 100, -118, -120, 6, 60, 76, -110}, | |
- {-12, -40, 115, -41, 68, 85, 20, 91, -44, -5, 73, -105, -81, 32, 116, 32, -28, 69, 88, -54, 29, -53, -51, -83, 54, 93, -102, -102, -23, 7, 110, 15, 34, 122, 84, 52, -121, 37, -103, -91, 37, -77, -101, 64, -18, 63, -27, -75, -112, -11, 1, -69, -25, -123, -99, -31, 116, 11, 4, -42, -124, 98, -2, 53}, | |
- {-128, -69, -16, -33, -8, -112, 39, -57, 113, -76, -29, -37, 4, 121, -63, 12, -54, -66, -121, 13, -4, -44, 50, 27, 103, 101, 44, -115, 12, -4, -8, 10, 53, 108, 90, -47, 46, -113, 5, -3, -111, 8, -66, -73, 57, 72, 90, -33, 47, 99, 50, -55, 53, -4, 96, 87, 57, 26, 53, -45, -83, 39, -17, 45}, | |
- {-121, 125, 60, -9, -79, -128, -19, 113, 54, 77, -23, -89, 105, -5, 47, 114, -120, -88, 31, 25, -96, -75, -6, 76, 9, -83, 75, -109, -126, -47, -6, 2, -59, 64, 3, 74, 100, 110, -96, 66, -3, 10, -124, -6, 8, 50, 109, 14, -109, 79, 73, 77, 67, 63, -50, 10, 86, -63, -125, -86, 35, -26, 7, 83}, | |
- {36, 31, -77, 126, 106, 97, 63, 81, -37, -126, 69, -127, -22, -69, 104, -111, 93, -49, 77, -3, -38, -112, 47, -55, -23, -68, -8, 78, -127, -28, -59, 10, 22, -61, -127, -13, -72, -14, -87, 14, 61, 76, -89, 81, -97, -97, -105, 94, -93, -9, -3, -104, -83, 59, 104, 121, -30, 106, -2, 62, -51, -72, -63, 55}, | |
- {81, -88, -8, -96, -31, 118, -23, -38, -94, 80, 35, -20, -93, -102, 124, 93, 0, 15, 36, -127, -41, -19, 6, -124, 94, -49, 44, 26, -69, 43, -58, 9, -18, -3, -2, 60, -122, -30, -47, 124, 71, 47, -74, -68, 4, -101, -16, 77, -120, -15, 45, -12, 68, -77, -74, 63, -113, 44, -71, 56, 122, -59, 53, -44}, | |
- {122, 30, 27, -79, 32, 115, -104, -28, -53, 109, 120, 121, -115, -65, -87, 101, 23, 10, 122, 101, 29, 32, 56, 63, -23, -48, -51, 51, 16, -124, -41, 6, -71, 49, -20, 26, -57, 65, 49, 45, 7, 49, -126, 54, -122, -43, 1, -5, 111, 117, 104, 117, 126, 114, -77, 66, -127, -50, 69, 14, 70, 73, 60, 112}, | |
- {104, -117, 105, -118, 35, 16, -16, 105, 27, -87, -43, -59, -13, -23, 5, 8, -112, -28, 18, -1, 48, 94, -82, 55, 32, 16, 59, -117, 108, -89, 101, 9, -35, 58, 70, 62, 65, 91, 14, -43, -104, 97, 1, -72, 16, -24, 79, 79, -85, -51, -79, -55, -128, 23, 109, -95, 17, 92, -38, 109, 65, -50, 46, -114}, | |
- {44, -3, 102, -60, -85, 66, 121, -119, 9, 82, -47, -117, 67, -28, 108, 57, -47, -52, -24, -82, 65, -13, 85, 107, -21, 16, -24, -85, 102, -92, 73, 5, 7, 21, 41, 47, -118, 72, 43, 51, -5, -64, 100, -34, -25, 53, -45, -115, 30, -72, -114, 126, 66, 60, -24, -67, 44, 48, 22, 117, -10, -33, -89, -108}, | |
- {-7, 71, -93, -66, 3, 30, -124, -116, -48, -76, -7, -62, 125, -122, -60, -104, -30, 71, 36, -110, 34, -126, 31, 10, 108, 102, -53, 56, 104, -56, -48, 12, 25, 21, 19, -90, 45, -122, -73, -112, 97, 96, 115, 71, 127, -7, -46, 84, -24, 102, -104, -96, 28, 8, 37, -84, -13, -65, -6, 61, -85, -117, -30, 70}, | |
- {-112, 39, -39, -24, 127, -115, 68, -1, -111, -43, 101, 20, -12, 39, -70, 67, -50, 68, 105, 69, -91, -106, 91, 4, -52, 75, 64, -121, 46, -117, 31, 10, -125, 77, 51, -3, -93, 58, 79, 121, 126, -29, 56, -101, 1, -28, 49, 16, -80, 92, -62, 83, 33, 17, 106, 89, -9, 60, 79, 38, -74, -48, 119, 24}, | |
- {105, -118, 34, 52, 111, 30, 38, -73, 125, -116, 90, 69, 2, 126, -34, -25, -41, -67, -23, -105, -12, -75, 10, 69, -51, -95, -101, 92, -80, -73, -120, 2, 71, 46, 11, -85, -18, 125, 81, 117, 33, -89, -42, 118, 51, 60, 89, 110, 97, -118, -111, -36, 75, 112, -4, -8, -36, -49, -55, 35, 92, 70, -37, 36}, | |
- {71, 4, -113, 13, -48, 29, -56, 82, 115, -38, -20, -79, -8, 126, -111, 5, -12, -56, -107, 98, 111, 19, 127, -10, -42, 24, -38, -123, 59, 51, -64, 3, 47, -1, -83, -127, -58, 86, 33, -76, 5, 71, -80, -50, -62, 116, 75, 20, -126, 23, -31, -21, 24, -83, -19, 114, -17, 1, 110, -70, -119, 126, 82, -83}, | |
- {-77, -69, -45, -78, -78, 69, 35, 85, 84, 25, -66, -25, 53, -38, -2, 125, -38, 103, 88, 31, -9, -43, 15, -93, 69, -22, -13, -20, 73, 3, -100, 7, 26, -18, 123, -14, -78, 113, 79, -57, -109, -118, 105, -104, 75, -88, -24, -109, 73, -126, 9, 55, 98, -120, 93, 114, 74, 0, -86, -68, 47, 29, 75, 67}, | |
- {-104, 11, -85, 16, -124, -91, 66, -91, 18, -67, -122, -57, -114, 88, 79, 11, -60, -119, 89, 64, 57, 120, -11, 8, 52, -18, -67, -127, 26, -19, -69, 2, -82, -56, 11, -90, -104, 110, -10, -68, 87, 21, 28, 87, -5, -74, -21, -84, 120, 70, -17, 102, 72, -116, -69, 108, -86, -79, -74, 115, -78, -67, 6, 45}, | |
- {-6, -101, -17, 38, -25, -7, -93, 112, 13, -33, 121, 71, -79, -122, -95, 22, 47, -51, 16, 84, 55, -39, -26, 37, -36, -18, 11, 119, 106, -57, 42, 8, -1, 23, 7, -63, -9, -50, 30, 35, -125, 83, 9, -60, -94, -15, -76, 120, 18, -103, -70, 95, 26, 48, -103, -95, 10, 113, 66, 54, -96, -4, 37, 111}, | |
- {-124, -53, 43, -59, -73, 99, 71, -36, -31, 61, -25, -14, -71, 48, 17, 10, -26, -21, -22, 104, 64, -128, 27, -40, 111, -70, -90, 91, -81, -88, -10, 11, -62, 127, -124, -2, -67, -69, 65, 73, 40, 82, 112, -112, 100, -26, 30, 86, 30, 1, -105, 45, 103, -47, -124, 58, 105, 24, 20, 108, -101, 84, -34, 80}, | |
- {28, -1, 84, 111, 43, 109, 57, -23, 52, -95, 110, -50, 77, 15, 80, 85, 125, -117, -10, 8, 59, -58, 18, 97, -58, 45, 92, -3, 56, 24, -117, 9, -73, -9, 48, -99, 50, -24, -3, -41, -43, 48, -77, -8, -89, -42, 126, 73, 28, -65, -108, 54, 6, 34, 32, 2, -73, -123, -106, -52, -73, -106, -112, 109}, | |
- {73, -76, -7, 49, 67, -34, 124, 80, 111, -91, -22, -121, -74, 42, -4, -18, 84, -3, 38, 126, 31, 54, -120, 65, -122, -14, -38, -80, -124, 90, 37, 1, 51, 123, 69, 48, 109, -112, -63, 27, 67, -127, 29, 79, -26, 99, -24, -100, 51, 103, -105, 13, 85, 74, 12, -37, 43, 80, -113, 6, 70, -107, -5, -80}, | |
- {110, -54, 109, 21, -124, 98, 90, -26, 69, -44, 17, 117, 78, -91, -7, -18, -81, -43, 20, 80, 48, -109, 117, 125, -67, 19, -15, 69, -28, 47, 15, 4, 34, -54, 51, -128, 18, 61, -77, -122, 100, -58, -118, -36, 5, 32, 43, 15, 60, -55, 120, 123, -77, -76, -121, 77, 93, 16, -73, 54, 46, -83, -39, 125}, | |
- {115, -15, -42, 111, -124, 52, 29, -124, -10, -23, 41, -128, 65, -60, -121, 6, -42, 14, 98, -80, 80, -46, -38, 64, 16, 84, -50, 47, -97, 11, -88, 12, 68, -127, -92, 87, -22, 54, -49, 33, -4, -68, 21, -7, -45, 84, 107, 57, 8, -106, 0, -87, -104, 93, -43, -98, -92, -72, 110, -14, -66, 119, 14, -68}, | |
- {-19, 7, 7, 66, -94, 18, 36, 8, -58, -31, 21, -113, -124, -5, -12, 105, 40, -62, 57, -56, 25, 117, 49, 17, -33, 49, 105, 113, -26, 78, 97, 2, -22, -84, 49, 67, -6, 33, 89, 28, 30, 12, -3, -23, -45, 7, -4, -39, -20, 25, -91, 55, 53, 21, -94, 17, -54, 109, 125, 124, 122, 117, -125, 60}, | |
- {-28, -104, -46, -22, 71, -79, 100, 48, -90, -57, -30, -23, -24, 1, 2, -31, 85, -6, -113, -116, 105, -31, -109, 106, 1, 78, -3, 103, -6, 100, -44, 15, -100, 97, 59, -42, 22, 83, 113, -118, 112, -57, 80, -45, -86, 72, 77, -26, -106, 50, 28, -24, 41, 22, -73, 108, 18, -93, 30, 8, -11, -16, 124, 106}, | |
- {16, -119, -109, 115, 67, 36, 28, 74, 101, -58, -82, 91, 4, -97, 111, -77, -37, -125, 126, 3, 10, -99, -115, 91, -66, -83, -81, 10, 7, 92, 26, 6, -45, 66, -26, 118, -77, 13, -91, 20, -18, -33, -103, 43, 75, -100, -5, -64, 117, 30, 5, -100, -90, 13, 18, -52, 26, 24, -10, 24, -31, 53, 88, 112}, | |
- {7, -90, 46, 109, -42, 108, -84, 124, -28, -63, 34, -19, -76, 88, -121, 23, 54, -73, -15, -52, 84, -119, 64, 20, 92, -91, -58, -121, -117, -90, -102, 1, 49, 21, 3, -85, -3, 38, 117, 73, -38, -71, -37, 40, -2, -50, -47, -46, 75, -105, 125, 126, -13, 68, 50, -81, -43, -93, 85, -79, 52, 98, 118, 50}, | |
- {-104, 65, -61, 12, 68, 106, 37, -64, 40, -114, 61, 73, 74, 61, -113, -79, 57, 47, -57, -21, -68, -62, 23, -18, 93, -7, -55, -88, -106, 104, -126, 5, 53, 97, 100, -67, -112, -88, 41, 24, 95, 15, 25, -67, 79, -69, 53, 21, -128, -101, 73, 17, 7, -98, 5, -2, 33, -113, 99, -72, 125, 7, 18, -105}, | |
- {-17, 28, 79, 34, 110, 86, 43, 27, -114, -112, -126, -98, -121, 126, -21, 111, 58, -114, -123, 75, 117, -116, 7, 107, 90, 80, -75, -121, 116, -11, -76, 0, -117, -52, 76, -116, 115, -117, 61, -7, 55, -34, 38, 101, 86, -19, -36, -92, -94, 61, 88, -128, -121, -103, 84, 19, -83, -102, 122, -111, 62, 112, 20, 3}, | |
- {-127, -90, 28, -77, -48, -56, -10, 84, -41, 59, -115, 68, -74, -104, -119, -49, -37, -90, -57, 66, 108, 110, -62, -107, 88, 90, 29, -65, 74, -38, 95, 8, 120, 88, 96, -65, -109, 68, -63, -4, -16, 90, 7, 39, -56, -110, -100, 86, -39, -53, -89, -35, 127, -42, -48, -36, 53, -66, 109, -51, 51, -23, -12, 73}, | |
- {-12, 78, 81, 30, 124, 22, 56, -112, 58, -99, 30, -98, 103, 66, 89, 92, -52, -20, 26, 82, -92, -18, 96, 7, 38, 21, -9, -25, -17, 4, 43, 15, 111, 103, -48, -50, -83, 52, 59, 103, 102, 83, -105, 87, 20, -120, 35, -7, -39, -24, 29, -39, -35, -87, 88, 120, 126, 19, 108, 34, -59, -20, 86, 47}, | |
- {19, -70, 36, 55, -42, -49, 33, 100, 105, -5, 89, 43, 3, -85, 60, -96, 43, -46, 86, -33, 120, -123, -99, -100, -34, 48, 82, -37, 34, 78, 127, 12, -39, -76, -26, 117, 74, -60, -68, -2, -37, -56, -6, 94, -27, 81, 32, -96, -19, -32, -77, 22, -56, -49, -38, -60, 45, -69, 40, 106, -106, -34, 101, -75}, | |
- {57, -92, -44, 8, -79, -88, -82, 58, -116, 93, 103, -127, 87, -121, -28, 31, -108, -14, -23, 38, 57, -83, -33, -110, 24, 6, 68, 124, -89, -35, -127, 5, -118, -78, -127, -35, 112, -34, 30, 24, -70, -71, 126, 39, -124, 122, -35, -97, -18, 25, 119, 79, 119, -65, 59, -20, -84, 120, -47, 4, -106, -125, -38, -113}, | |
- {18, -93, 34, -80, -43, 127, 57, -118, 24, -119, 25, 71, 59, -29, -108, -99, -122, 58, 44, 0, 42, -111, 25, 94, -36, 41, -64, -53, -78, -119, 85, 7, -45, -70, 81, -84, 71, -61, -68, -79, 112, 117, 19, 18, 70, 95, 108, -58, 48, 116, -89, 43, 66, 55, 37, -37, -60, 104, 47, -19, -56, 97, 73, 26}, | |
- {78, 4, -111, -36, 120, 111, -64, 46, 99, 125, -5, 97, -126, -21, 60, -78, -33, 89, 25, -60, 0, -49, 59, -118, 18, 3, -60, 30, 105, -92, -101, 15, 63, 50, 25, 2, -116, 78, -5, -25, -59, 74, -116, 64, -55, -121, 1, 69, 51, -119, 43, -6, -81, 14, 5, 84, -67, -73, 67, 24, 82, -37, 109, -93}, | |
- {-44, -30, -64, -68, -21, 74, 124, 122, 114, -89, -91, -51, 89, 32, 96, -1, -101, -112, -94, 98, -24, -31, -50, 100, -72, 56, 24, 30, 105, 115, 15, 3, -67, 107, -18, 111, -38, -93, -11, 24, 36, 73, -23, 108, 14, -41, -65, 32, 51, 22, 95, 41, 85, -121, -35, -107, 0, 105, -112, 59, 48, -22, -84, 46}, | |
- {4, 38, 54, -84, -78, 24, -48, 8, -117, 78, -95, 24, 25, -32, -61, 26, -97, -74, 46, -120, -125, 27, 73, 107, -17, -21, -6, -52, 47, -68, 66, 5, -62, -12, -102, -127, 48, -69, -91, -81, -33, -13, -9, -12, -44, -73, 40, -58, 120, -120, 108, 101, 18, -14, -17, -93, 113, 49, 76, -4, -113, -91, -93, -52}, | |
- {28, -48, 70, -35, 123, -31, 16, -52, 72, 84, -51, 78, 104, 59, -102, -112, 29, 28, 25, 66, 12, 75, 26, -85, 56, -12, -4, -92, 49, 86, -27, 12, 44, -63, 108, 82, -76, -97, -41, 95, -48, -95, -115, 1, 64, -49, -97, 90, 65, 46, -114, -127, -92, 79, 100, 49, 116, -58, -106, 9, 117, -7, -91, 96}, | |
- {58, 26, 18, 76, 127, -77, -58, -87, -116, -44, 60, -32, -4, -76, -124, 4, -60, 82, -5, -100, -95, 18, 2, -53, -50, -96, -126, 105, 93, 19, 74, 13, 87, 125, -72, -10, 42, 14, 91, 44, 78, 52, 60, -59, -27, -37, -57, 17, -85, 31, -46, 113, 100, -117, 15, 108, -42, 12, 47, 63, 1, 11, -122, -3} | |
- }; | |
+ public static final byte[][] GENESIS_SIGNATURES = {}; | |
public static final byte[] GENESIS_BLOCK_SIGNATURE = new byte[]{ | |
- 105, -44, 38, -60, -104, -73, 10, -58, -47, 103, -127, -128, 53, 101, 39, -63, -2, -32, 48, -83, 115, 47, -65, 118, 114, -62, 38, 109, 22, 106, 76, 8, -49, -113, -34, -76, 82, 79, -47, -76, -106, -69, -54, -85, 3, -6, 110, 103, 118, 15, 109, -92, 82, 37, 20, 2, 36, -112, 21, 72, 108, 72, 114, 17 | |
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 | |
}; | |
private Genesis() {} // never | |
diff --git a/java/nxt/Hub.java b/java/nxt/Hub.java | |
index 25d89a2..edaa613 100644 | |
--- a/java/nxt/Hub.java | |
+++ b/java/nxt/Hub.java | |
@@ -48,7 +48,7 @@ public class Hub { | |
public static List<Hit> getHubHits(Block block) { | |
- synchronized (Hub.class) { | |
+ /*synchronized (Hub.class) { | |
if (block.getId().equals(lastBlockId) && lastHits != null) { | |
return lastHits; | |
} | |
@@ -73,8 +73,8 @@ public class Hub { | |
lastHits = currentHits; | |
lastBlockId = currentLastBlockId; | |
} | |
- return lastHits; | |
- | |
+ return lastHits;*/ | |
+ return null; | |
} | |
private final Long accountId; | |
diff --git a/java/nxt/Nxt.java b/java/nxt/Nxt.java | |
index 382576c..89e5218 100644 | |
--- a/java/nxt/Nxt.java | |
+++ b/java/nxt/Nxt.java | |
@@ -16,11 +16,11 @@ import java.util.Properties; | |
public final class Nxt { | |
- public static final String VERSION = "1.1.6"; | |
+ public static final String VERSION = "1.0.0"; | |
private static final Properties defaultProperties = new Properties(); | |
static { | |
- System.out.println("Initializing Nxt server version " + Nxt.VERSION); | |
+ System.out.println("Initializing Burst server version " + Nxt.VERSION); | |
try (InputStream is = ClassLoader.getSystemResourceAsStream("nxt-default.properties")) { | |
if (is != null) { | |
Nxt.defaultProperties.load(is); | |
@@ -143,7 +143,7 @@ public final class Nxt { | |
TransactionProcessorImpl.getInstance().shutdown(); | |
ThreadPool.shutdown(); | |
Db.shutdown(); | |
- Logger.logMessage("Nxt server " + VERSION + " stopped."); | |
+ Logger.logMessage("Burst server " + VERSION + " stopped."); | |
Logger.shutdown(); | |
} | |
@@ -166,7 +166,7 @@ public final class Nxt { | |
long currentTime = System.currentTimeMillis(); | |
Logger.logDebugMessage("Initialization took " + (currentTime - startTime) / 1000 + " seconds"); | |
- Logger.logMessage("Nxt server " + VERSION + " started successfully."); | |
+ Logger.logMessage("Burst server " + VERSION + " started successfully."); | |
if (Constants.isTestnet) { | |
Logger.logMessage("RUNNING ON TESTNET - DO NOT USE REAL ACCOUNTS!"); | |
} | |
diff --git a/java/nxt/TransactionImpl.java b/java/nxt/TransactionImpl.java | |
index 964418b..33979ba 100644 | |
--- a/java/nxt/TransactionImpl.java | |
+++ b/java/nxt/TransactionImpl.java | |
@@ -37,9 +37,7 @@ final class TransactionImpl implements Transaction { | |
TransactionImpl(TransactionType type, int timestamp, short deadline, byte[] senderPublicKey, Long recipientId, | |
long amountNQT, long feeNQT, String referencedTransactionFullHash, byte[] signature) throws NxtException.ValidationException { | |
- if ((timestamp == 0 && Arrays.equals(senderPublicKey, Genesis.CREATOR_PUBLIC_KEY)) | |
- ? (deadline != 0 || feeNQT != 0) | |
- : (deadline < 1 || feeNQT < Constants.ONE_NXT) | |
+ if ((deadline < 1 || feeNQT < Constants.ONE_NXT) | |
|| feeNQT > Constants.MAX_BALANCE_NQT | |
|| amountNQT < 0 | |
|| amountNQT > Constants.MAX_BALANCE_NQT | |
diff --git a/java/nxt/TransactionType.java b/java/nxt/TransactionType.java | |
index 7596f75..2db2447 100644 | |
--- a/java/nxt/TransactionType.java | |
+++ b/java/nxt/TransactionType.java | |
@@ -142,8 +142,7 @@ public abstract class TransactionType { | |
&& transaction.getTimestamp() > Constants.REFERENCED_TRANSACTION_FULL_HASH_BLOCK_TIMESTAMP) { | |
totalAmountNQT = Convert.safeAdd(totalAmountNQT, Constants.UNCONFIRMED_POOL_DEPOSIT_NQT); | |
} | |
- if (senderAccount.getUnconfirmedBalanceNQT() < totalAmountNQT | |
- && ! (transaction.getTimestamp() == 0 && Arrays.equals(senderAccount.getPublicKey(), Genesis.CREATOR_PUBLIC_KEY))) { | |
+ if (senderAccount.getUnconfirmedBalanceNQT() < totalAmountNQT) { | |
return false; | |
} | |
senderAccount.addToUnconfirmedBalanceNQT(- totalAmountNQT); | |
diff --git a/java/nxt/http/API.java b/java/nxt/http/API.java | |
index cec58e9..688e507 100644 | |
--- a/java/nxt/http/API.java | |
+++ b/java/nxt/http/API.java | |
@@ -95,7 +95,7 @@ public final class API { | |
} | |
ServletHandler apiHandler = new ServletHandler(); | |
- apiHandler.addServletWithMapping(APIServlet.class, "/nxt"); | |
+ apiHandler.addServletWithMapping(APIServlet.class, "/burst"); | |
apiHandler.addServletWithMapping(APITestServlet.class, "/test"); | |
if (Nxt.getBooleanProperty("nxt.apiServerCORS")) { | |
diff --git a/java/nxt/http/APIServlet.java b/java/nxt/http/APIServlet.java | |
index 741a93f..ca58fdc 100644 | |
--- a/java/nxt/http/APIServlet.java | |
+++ b/java/nxt/http/APIServlet.java | |
@@ -79,10 +79,11 @@ public final class APIServlet extends HttpServlet { | |
map.put("getBlockchainStatus", GetBlockchainStatus.instance); | |
map.put("getConstants", GetConstants.instance); | |
map.put("getGuaranteedBalance", GetGuaranteedBalance.instance); | |
+ map.put("getMiningInfo", GetMiningInfo.instance); | |
map.put("getMyInfo", GetMyInfo.instance); | |
- if (Constants.isTestnet) { | |
- map.put("getNextBlockGenerators", GetNextBlockGenerators.instance); | |
- } | |
+ //if (Constants.isTestnet) { | |
+ // map.put("getNextBlockGenerators", GetNextBlockGenerators.instance); | |
+ //} | |
map.put("getPeer", GetPeer.instance); | |
map.put("getPeers", GetPeers.instance); | |
map.put("getPoll", GetPoll.instance); | |
@@ -115,9 +116,10 @@ public final class APIServlet extends HttpServlet { | |
map.put("setAccountInfo", SetAccountInfo.instance); | |
map.put("setAlias", SetAlias.instance); | |
map.put("signTransaction", SignTransaction.instance); | |
- map.put("startForging", StartForging.instance); | |
- map.put("stopForging", StopForging.instance); | |
- map.put("getForging", GetForging.instance); | |
+ //map.put("startForging", StartForging.instance); | |
+ //map.put("stopForging", StopForging.instance); | |
+ map.put("submitNonce", SubmitNonce.instance); | |
+ //map.put("getForging", GetForging.instance); | |
map.put("transferAsset", TransferAsset.instance); | |
apiRequestHandlers = Collections.unmodifiableMap(map); | |
diff --git a/java/nxt/http/APITestServlet.java b/java/nxt/http/APITestServlet.java | |
index a79e7ff..ead1ce4 100644 | |
--- a/java/nxt/http/APITestServlet.java | |
+++ b/java/nxt/http/APITestServlet.java | |
@@ -30,7 +30,7 @@ public class APITestServlet extends HttpServlet { | |
" </style>\n" + | |
" <script type=\"text/javascript\">\n" + | |
" function submitForm(form) {\n" + | |
- " var url = '/nxt';\n" + | |
+ " var url = '/burst';\n" + | |
" var params = '';\n" + | |
" for (i = 0; i < form.elements.length; i++) {\n" + | |
" if (! form.elements[i].name) {\n" + | |
@@ -123,7 +123,7 @@ public class APITestServlet extends HttpServlet { | |
buf.append("</div> <!-- panel-heading -->"); | |
buf.append("<div id=\"collapse").append(requestType).append("\" class=\"panel-collapse collapse\">"); | |
buf.append("<div class=\"panel-body\">"); | |
- buf.append("<form action=\"/nxt\" method=\"POST\" onsubmit=\"return submitForm(this);\">"); | |
+ buf.append("<form action=\"/burst\" method=\"POST\" onsubmit=\"return submitForm(this);\">"); | |
buf.append("<pre class=\"result\" style=\"float:right;width:50%;\">JSON response</pre>"); | |
buf.append("<input type=\"hidden\" name=\"requestType\" value=\"").append(requestType).append("\"/>"); | |
buf.append("<table class=\"table\" style=\"width:46%;\">"); | |
diff --git a/java/nxt/http/GetForging.java b/java/nxt/http/GetForging.java | |
deleted file mode 100644 | |
index 00f0109..0000000 | |
--- a/java/nxt/http/GetForging.java | |
+++ /dev/null | |
@@ -1,57 +0,0 @@ | |
-package nxt.http; | |
- | |
-import nxt.Account; | |
-import nxt.Generator; | |
-import nxt.Nxt; | |
-import nxt.crypto.Crypto; | |
-import nxt.util.Convert; | |
-import org.json.simple.JSONObject; | |
-import org.json.simple.JSONStreamAware; | |
- | |
-import javax.servlet.http.HttpServletRequest; | |
- | |
-import static nxt.http.JSONResponses.MISSING_SECRET_PHRASE; | |
-import static nxt.http.JSONResponses.NOT_FORGING; | |
-import static nxt.http.JSONResponses.UNKNOWN_ACCOUNT; | |
- | |
- | |
-public final class GetForging extends APIServlet.APIRequestHandler { | |
- | |
- static final GetForging instance = new GetForging(); | |
- | |
- private GetForging() { | |
- super("secretPhrase"); | |
- } | |
- | |
- @Override | |
- JSONStreamAware processRequest(HttpServletRequest req) { | |
- | |
- String secretPhrase = req.getParameter("secretPhrase"); | |
- if (secretPhrase == null) { | |
- return MISSING_SECRET_PHRASE; | |
- } | |
- Account account = Account.getAccount(Crypto.getPublicKey(secretPhrase)); | |
- if (account == null) { | |
- return UNKNOWN_ACCOUNT; | |
- } | |
- | |
- Generator generator = Generator.getGenerator(secretPhrase); | |
- if (generator == null) { | |
- return NOT_FORGING; | |
- } | |
- | |
- JSONObject response = new JSONObject(); | |
- long deadline = generator.getDeadline(); | |
- response.put("deadline", deadline); | |
- int elapsedTime = Convert.getEpochTime() - Nxt.getBlockchain().getLastBlock().getTimestamp(); | |
- response.put("remaining", Math.max(deadline - elapsedTime, 0)); | |
- return response; | |
- | |
- } | |
- | |
- @Override | |
- boolean requirePost() { | |
- return true; | |
- } | |
- | |
-} | |
diff --git a/java/nxt/http/GetNextBlockGenerators.java b/java/nxt/http/GetNextBlockGenerators.java | |
deleted file mode 100644 | |
index fc357f9..0000000 | |
--- a/java/nxt/http/GetNextBlockGenerators.java | |
+++ /dev/null | |
@@ -1,77 +0,0 @@ | |
-package nxt.http; | |
- | |
-import nxt.Block; | |
-import nxt.Constants; | |
-import nxt.Hub; | |
-import nxt.Nxt; | |
-import nxt.util.Convert; | |
-import org.json.simple.JSONArray; | |
-import org.json.simple.JSONObject; | |
-import org.json.simple.JSONStreamAware; | |
- | |
-import javax.servlet.http.HttpServletRequest; | |
-import java.util.Iterator; | |
- | |
-public final class GetNextBlockGenerators extends APIServlet.APIRequestHandler { | |
- | |
- static final GetNextBlockGenerators instance = new GetNextBlockGenerators(); | |
- | |
- private GetNextBlockGenerators() {} | |
- | |
- @Override | |
- JSONStreamAware processRequest(HttpServletRequest req) { | |
- | |
- /* implement later, if needed | |
- Block curBlock; | |
- | |
- String block = req.getParameter("block"); | |
- if (block == null) { | |
- curBlock = Nxt.getBlockchain().getLastBlock(); | |
- } else { | |
- try { | |
- curBlock = Nxt.getBlockchain().getBlock(Convert.parseUnsignedLong(block)); | |
- if (curBlock == null) { | |
- return UNKNOWN_BLOCK; | |
- } | |
- } catch (RuntimeException e) { | |
- return INCORRECT_BLOCK; | |
- } | |
- } | |
- */ | |
- | |
- Block curBlock = Nxt.getBlockchain().getLastBlock(); | |
- if (curBlock.getHeight() < Constants.TRANSPARENT_FORGING_BLOCK_7) { | |
- return JSONResponses.FEATURE_NOT_AVAILABLE; | |
- } | |
- | |
- | |
- JSONObject response = new JSONObject(); | |
- response.put("time", Convert.getEpochTime()); | |
- response.put("lastBlock", Convert.toUnsignedLong(curBlock.getId())); | |
- JSONArray hubs = new JSONArray(); | |
- | |
- int limit; | |
- try { | |
- limit = Integer.parseInt(req.getParameter("limit")); | |
- } catch (RuntimeException e) { | |
- limit = Integer.MAX_VALUE; | |
- } | |
- | |
- Iterator<Hub.Hit> iterator = Hub.getHubHits(curBlock).iterator(); | |
- while (iterator.hasNext() && hubs.size() < limit) { | |
- JSONObject hub = new JSONObject(); | |
- Hub.Hit hit = iterator.next(); | |
- hub.put("account", Convert.toUnsignedLong(hit.hub.getAccountId())); | |
- hub.put("minFeePerByteNQT", hit.hub.getMinFeePerByteNQT()); | |
- hub.put("time", hit.hitTime); | |
- JSONArray uris = new JSONArray(); | |
- uris.addAll(hit.hub.getUris()); | |
- hub.put("uris", uris); | |
- hubs.add(hub); | |
- } | |
- | |
- response.put("hubs", hubs); | |
- return response; | |
- } | |
- | |
-} | |
diff --git a/java/nxt/http/JSONData.java b/java/nxt/http/JSONData.java | |
index ef7eb69..4cbadf1 100644 | |
--- a/java/nxt/http/JSONData.java | |
+++ b/java/nxt/http/JSONData.java | |
@@ -5,6 +5,7 @@ import nxt.Alias; | |
import nxt.Asset; | |
import nxt.Attachment; | |
import nxt.Block; | |
+import nxt.Constants; | |
import nxt.Nxt; | |
import nxt.Order; | |
import nxt.Poll; | |
@@ -15,6 +16,7 @@ import nxt.crypto.Crypto; | |
import nxt.peer.Hallmark; | |
import nxt.peer.Peer; | |
import nxt.util.Convert; | |
+ | |
import org.json.simple.JSONArray; | |
import org.json.simple.JSONObject; | |
@@ -95,10 +97,13 @@ final class JSONData { | |
json.put("height", block.getHeight()); | |
json.put("generator", Convert.toUnsignedLong(block.getGeneratorId())); | |
json.put("generatorRS", Convert.rsAccount(block.getGeneratorId())); | |
+ json.put("nonce", Convert.toUnsignedLong(block.getNonce())); | |
+ json.put("scoopNum", block.getScoopNum()); | |
json.put("timestamp", block.getTimestamp()); | |
json.put("numberOfTransactions", block.getTransactionIds().size()); | |
json.put("totalAmountNQT", String.valueOf(block.getTotalAmountNQT())); | |
json.put("totalFeeNQT", String.valueOf(block.getTotalFeeNQT())); | |
+ json.put("blockReward", Convert.toUnsignedLong(block.getBlockReward() / Constants.ONE_NXT)); | |
json.put("payloadLength", block.getPayloadLength()); | |
json.put("version", block.getVersion()); | |
json.put("baseTarget", Convert.toUnsignedLong(block.getBaseTarget())); | |
diff --git a/java/nxt/peer/PeerImpl.java b/java/nxt/peer/PeerImpl.java | |
index ef14475..8d0da4e 100644 | |
--- a/java/nxt/peer/PeerImpl.java | |
+++ b/java/nxt/peer/PeerImpl.java | |
@@ -260,7 +260,7 @@ final class PeerImpl implements Peer { | |
log = "\"" + address + "\": " + stringWriter.toString(); | |
} | |
- URL url = new URL("http://" + address + (port <= 0 ? ":" + (Constants.isTestnet ? Peers.TESTNET_PEER_PORT : Peers.DEFAULT_PEER_PORT) : "") + "/nxt"); | |
+ URL url = new URL("http://" + address + (port <= 0 ? ":" + (Constants.isTestnet ? Peers.TESTNET_PEER_PORT : Peers.DEFAULT_PEER_PORT) : "") + "/burst"); | |
connection = (HttpURLConnection)url.openConnection(); | |
connection.setRequestMethod("POST"); | |
connection.setDoOutput(true); | |
diff --git a/java/nxt/peer/PeerServlet.java b/java/nxt/peer/PeerServlet.java | |
index 6e8680a..8e9f9ab 100644 | |
--- a/java/nxt/peer/PeerServlet.java | |
+++ b/java/nxt/peer/PeerServlet.java | |
@@ -97,7 +97,7 @@ public final class PeerServlet extends HttpServlet { | |
return; | |
} | |
- if (request.get("protocol") != null && ((Number)request.get("protocol")).intValue() == 1) { | |
+ if (request.get("protocol") != null && ((String)request.get("protocol")).equals("B1")) { | |
PeerRequestHandler peerRequestHandler = peerRequestHandlers.get(request.get("requestType")); | |
if (peerRequestHandler != null) { | |
response = peerRequestHandler.processRequest(request, peer); | |
diff --git a/java/nxt/peer/Peers.java b/java/nxt/peer/Peers.java | |
index a59ca40..5f224be 100644 | |
--- a/java/nxt/peer/Peers.java | |
+++ b/java/nxt/peer/Peers.java | |
@@ -60,8 +60,8 @@ public final class Peers { | |
static final int readTimeout; | |
static final int blacklistingPeriod; | |
- static final int DEFAULT_PEER_PORT = 7874; | |
- static final int TESTNET_PEER_PORT = 6874; | |
+ static final int DEFAULT_PEER_PORT = 8123; | |
+ static final int TESTNET_PEER_PORT = 7123; | |
private static final String myPlatform; | |
private static final String myAddress; | |
private static final int myPeerServerPort; | |
diff --git a/java/nxt/user/Users.java b/java/nxt/user/Users.java | |
index 41208bb..9514a44 100644 | |
--- a/java/nxt/user/Users.java | |
+++ b/java/nxt/user/Users.java | |
@@ -128,7 +128,7 @@ public final class Users { | |
} | |
ServletHandler userHandler = new ServletHandler(); | |
- ServletHolder userHolder = userHandler.addServletWithMapping(UserServlet.class, "/nxt"); | |
+ ServletHolder userHolder = userHandler.addServletWithMapping(UserServlet.class, "/burst"); | |
userHolder.setAsyncSupported(true); | |
if (Nxt.getBooleanProperty("nxt.uiServerCORS")) { | |
diff --git a/java/nxt/util/Convert.java b/java/nxt/util/Convert.java | |
index 1ce1baa..d2fa73e 100644 | |
--- a/java/nxt/util/Convert.java | |
+++ b/java/nxt/util/Convert.java | |
@@ -13,6 +13,7 @@ public final class Convert { | |
private static final long[] multipliers = {1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000}; | |
public static final BigInteger two64 = new BigInteger("18446744073709551616"); | |
+ public static final BigInteger two256 = new BigInteger("10000000000000000000000000000000000000000000000000000000000000000", 16); | |
private Convert() {} //never | |
@@ -68,15 +69,15 @@ public final class Convert { | |
return null; | |
} | |
account = account.toUpperCase(); | |
- if (account.startsWith("NXT-")) { | |
- return zeroToNull(Crypto.rsDecode(account.substring(4))); | |
+ if (account.startsWith("BURST-")) { | |
+ return zeroToNull(Crypto.rsDecode(account.substring(6))); | |
} else { | |
return parseUnsignedLong(account); | |
} | |
} | |
public static String rsAccount(Long accountId) { | |
- return "NXT-" + Crypto.rsEncode(nullToZero(accountId)); | |
+ return "BURST-" + Crypto.rsEncode(nullToZero(accountId)); | |
} | |
public static Long fullHashToId(byte[] hash) { | |
diff --git a/java/nxt/util/JSON.java b/java/nxt/util/JSON.java | |
index 84c5bda..64f3e07 100644 | |
--- a/java/nxt/util/JSON.java | |
+++ b/java/nxt/util/JSON.java | |
@@ -23,7 +23,7 @@ public final class JSON { | |
} | |
public static JSONStreamAware prepareRequest(final JSONObject json) { | |
- json.put("protocol", 1); | |
+ json.put("protocol", "B1"); | |
return prepare(json); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment