From e5fcf5b48e76c79a00a476440ae0eeae953fbf75 Mon Sep 17 00:00:00 2001
From: Chris Beams
Date: Fri, 26 Dec 2014 09:36:37 +0100
Subject: [PATCH] Strip trailing whitespace
---
README.md | 12 +-
TODO.md | 28 ++--
ethereumj-core/README.md | 20 +--
ethereumj-core/pom.xml | 2 +-
.../org/ethereum/config/SystemProperties.java | 12 +-
.../java/org/ethereum/core/AccountState.java | 40 ++---
.../main/java/org/ethereum/core/Block.java | 46 +++---
.../java/org/ethereum/core/BlockHeader.java | 50 +++---
.../org/ethereum/core/BlockchainImpl.java | 40 ++---
.../java/org/ethereum/core/Denomination.java | 10 +-
.../main/java/org/ethereum/core/Genesis.java | 34 ++--
.../java/org/ethereum/core/Transaction.java | 16 +-
.../org/ethereum/core/TransactionReceipt.java | 6 +-
.../main/java/org/ethereum/core/Wallet.java | 10 +-
.../main/java/org/ethereum/crypto/ECKey.java | 46 +++---
.../java/org/ethereum/crypto/HashUtil.java | 10 +-
.../java/org/ethereum/crypto/SHA3Helper.java | 16 +-
.../org/ethereum/db/ByteArrayWrapper.java | 6 +-
.../java/org/ethereum/db/ContractDetails.java | 2 +-
.../main/java/org/ethereum/db/Database.java | 16 +-
.../java/org/ethereum/db/DatabaseImpl.java | 20 +--
.../java/org/ethereum/facade/Repository.java | 66 ++++----
.../org/ethereum/json/EtherObjectMapper.java | 16 +-
.../java/org/ethereum/json/JSONHelper.java | 50 +++---
.../ethereum/jsontestsuite/JSONReader.java | 4 +-
.../java/org/ethereum/jsontestsuite/Logs.java | 2 +-
.../org/ethereum/jsontestsuite/TestCase.java | 8 +-
.../ethereum/jsontestsuite/TestRunner.java | 2 +-
.../org/ethereum/manager/WorldManager.java | 16 +-
.../main/java/org/ethereum/mine/Miner.java | 36 ++---
.../java/org/ethereum/net/BlockQueue.java | 40 ++---
.../org/ethereum/net/MessageRoundtrip.java | 2 +-
.../org/ethereum/net/client/Capability.java | 8 +-
.../org/ethereum/net/client/PeerClient.java | 4 +-
.../ethereum/net/eth/BlockHashesMessage.java | 2 +-
.../java/org/ethereum/net/eth/EthMessage.java | 2 +-
.../org/ethereum/net/eth/EthMessageCodes.java | 6 +-
.../net/eth/GetBlockHashesMessage.java | 10 +-
.../ethereum/net/eth/GetBlocksMessage.java | 2 +-
.../net/eth/GetTransactionsMessage.java | 4 +-
.../org/ethereum/net/eth/NewBlockMessage.java | 4 +-
.../org/ethereum/net/eth/StatusMessage.java | 4 +-
.../ethereum/net/eth/TransactionsMessage.java | 14 +-
.../org/ethereum/net/message/Message.java | 12 +-
.../org/ethereum/net/message/ReasonCode.java | 32 ++--
.../ethereum/net/message/StaticMessages.java | 6 +-
.../org/ethereum/net/p2p/GetPeersMessage.java | 2 +-
.../org/ethereum/net/p2p/HelloMessage.java | 8 +-
.../java/org/ethereum/net/p2p/P2pHandler.java | 12 +-
.../main/java/org/ethereum/net/p2p/Peer.java | 2 +-
.../org/ethereum/net/p2p/PeersMessage.java | 2 +-
.../org/ethereum/net/p2p/PingMessage.java | 2 +-
.../org/ethereum/net/p2p/PongMessage.java | 2 +-
.../net/peerdiscovery/DiscoveryChannel.java | 2 +-
.../net/peerdiscovery/PeerDiscovery.java | 6 +-
.../net/peerdiscovery/RejectionLogger.java | 4 +-
.../net/peerdiscovery/WorkerThread.java | 2 +-
.../org/ethereum/net/server/PeerServer.java | 2 +-
.../java/org/ethereum/net/shh/ShhHandler.java | 4 +-
.../org/ethereum/net/shh/ShhMessageCodes.java | 2 +-
.../org/ethereum/net/wire/MessageDecoder.java | 4 +-
.../org/ethereum/net/wire/MessageEncoder.java | 4 +-
.../org/ethereum/serpent/SerpentCompiler.java | 2 +-
.../main/java/org/ethereum/trie/Cache.java | 6 +-
.../src/main/java/org/ethereum/trie/Node.java | 46 +++---
.../src/main/java/org/ethereum/trie/Trie.java | 28 ++--
.../main/java/org/ethereum/trie/TrieImpl.java | 32 ++--
.../java/org/ethereum/trie/TrieIterator.java | 6 +-
.../main/java/org/ethereum/util/ByteUtil.java | 48 +++---
.../org/ethereum/util/CompactEncoder.java | 46 +++---
.../java/org/ethereum/util/DecodeResult.java | 10 +-
.../ethereum/util/FastByteComparisons.java | 6 +-
.../main/java/org/ethereum/util/LRUMap.java | 2 +-
.../src/main/java/org/ethereum/util/RLP.java | 72 ++++-----
.../main/java/org/ethereum/util/RLPItem.java | 6 +-
.../main/java/org/ethereum/util/RLPList.java | 2 +-
.../main/java/org/ethereum/util/Utils.java | 18 +--
.../main/java/org/ethereum/util/Value.java | 6 +-
.../main/java/org/ethereum/vm/DataWord.java | 36 ++---
.../main/java/org/ethereum/vm/GasCost.java | 6 +-
.../java/org/ethereum/vm/MessageCall.java | 12 +-
.../src/main/java/org/ethereum/vm/OpCode.java | 42 ++---
.../main/java/org/ethereum/vm/Program.java | 92 +++++------
.../ethereum/vm/ProgramInvokeFactoryImpl.java | 10 +-
.../org/ethereum/vm/ProgramInvokeImpl.java | 4 +-
.../ethereum/vm/ProgramInvokeMockImpl.java | 12 +-
.../src/main/java/org/ethereum/vm/VM.java | 146 +++++++++---------
.../src/main/resources/system.properties | 6 +-
.../java/test/ethereum/core/BlockTest.java | 14 +-
.../java/test/ethereum/core/MinerTest.java | 10 +-
.../java/test/ethereum/core/StateTest.java | 4 +-
.../test/ethereum/core/TransactionTest.java | 38 ++---
.../java/test/ethereum/crypto/ECKeyTest.java | 36 ++---
.../ethereum/db/ByteArrayWrapperTest.java | 20 +--
.../test/ethereum/db/TrackDatabaseTest.java | 4 +-
.../jsontestsuite/GitHubJSONTestSuite.java | 8 +-
.../jsontestsuite/GitHubStateTest.java | 2 +-
.../ethereum/jsontestsuite/GitHubVMTest.java | 16 +-
.../java/test/ethereum/mine/MinerThread.java | 2 +-
.../ethereum/net/BlockHashesMessageTest.java | 14 +-
.../test/ethereum/net/BlocksMessageTest.java | 2 +-
.../ethereum/net/DisconnectMessageTest.java | 4 +-
.../net/GetBlockHashesMessageTest.java | 18 +--
.../ethereum/net/GetBlocksMessageTest.java | 14 +-
.../test/ethereum/net/HelloMessageTest.java | 4 +-
.../test/ethereum/net/PeersMessageTest.java | 2 +-
.../ethereum/net/PingPongMessageTest.java | 4 +-
.../ethereum/net/TransactionsMessageTest.java | 18 +--
.../ethereum/serpent/SerpentCompileTest.java | 8 +-
.../java/test/ethereum/trie/TrieTest.java | 56 +++----
.../java/test/ethereum/util/ByteUtilTest.java | 34 ++--
.../ethereum/util/CompactEncoderTest.java | 6 +-
.../java/test/ethereum/util/HashUtilTest.java | 16 +-
.../test/java/test/ethereum/util/RLPTest.java | 134 ++++++++--------
.../java/test/ethereum/util/RlpTestData.java | 30 ++--
.../java/test/ethereum/util/UtilsTest.java | 8 +-
.../java/test/ethereum/util/ValueTest.java | 4 +-
.../java/test/ethereum/vm/DataWordTest.java | 44 +++---
.../test/ethereum/vm/ProgramMemoryTest.java | 62 ++++----
.../java/test/ethereum/vm/VMComplexTest.java | 16 +-
.../java/test/ethereum/vm/VMCustomTest.java | 70 ++++-----
.../test/java/test/ethereum/vm/VMTest.java | 82 +++++-----
.../src/test/resources/system.properties | 8 +-
ethereumj-core/track-untrack-local.bat | 4 +-
ethereumj-studio/README.md | 14 +-
ethereumj-studio/pom.xml | 2 +-
ethereumj-studio/samples/call-me-more.se | 10 +-
.../main/java/org/ethereum/geo/IpGeoDB.java | 2 +-
.../org/ethereum/gui/AccountsListWindow.java | 36 ++---
.../org/ethereum/gui/ConsoleTokenMaker.java | 2 +-
.../org/ethereum/gui/ContractCallDialog.java | 12 +-
.../ethereum/gui/ContractSubmitDialog.java | 6 +-
.../org/ethereum/gui/MessageAwareDialog.java | 2 +-
.../java/org/ethereum/gui/PayOutDialog.java | 2 +-
.../java/org/ethereum/gui/PeerInfoWindow.java | 4 +-
.../org/ethereum/gui/PeersTableModel.java | 2 +-
.../org/ethereum/gui/ProgramPlayDialog.java | 18 +--
.../java/org/ethereum/gui/SerpentEditor.java | 2 +-
.../org/ethereum/gui/StateExplorerWindow.java | 102 ++++++------
.../main/java/org/ethereum/gui/ToolBar.java | 4 +-
.../src/main/resources/system.properties | 6 +-
ethereumj-studio/track-untrack-local.bat | 4 +-
142 files changed, 1301 insertions(+), 1301 deletions(-)
diff --git a/README.md b/README.md
index 40f8e1d7..4cfd8190 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,7 @@
[![ScreenShot](http://i.imgur.com/lJw1Tui.jpg)]
-# Welcome to ethereumj
+# Welcome to ethereumj
[![Gitter](https://badges.gitter.im/Join Chat.svg)](https://gitter.im/ethereum/ethereumj?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![Build Status](https://travis-ci.org/ethereum/ethereumj.svg?branch=master)](https://travis-ci.org/ethereum/ethereumj) [![Coverage Status](https://coveralls.io/repos/ethereum/ethereumj/badge.png?branch=master)](https://coveralls.io/r/ethereum/ethereumj?branch=master)
[![Stories in Progress](https://badge.waffle.io/ethereum/ethereumj.png?title=In%20Progress&label=in_progress)](https://waffle.io/ethereum/ethereumj)
@@ -10,18 +10,18 @@
The ethereumj library is a Java implementation of the Ethereum protocol.
-This repository currently contains:
+This repository currently contains:
* [core](ethereumj-core): the core library which can be included into your own Java project.
- * [studio](ethereumj-studio): a simple graphic interface for Ethereum functionality and set of showcases for core usage.
+ * [studio](ethereumj-studio): a simple graphic interface for Ethereum functionality and set of showcases for core usage.
For an early peek, have a looki at this [video](https://youtu.be/D5ok7jh7AOg)
# Todo
The Ethereum protocol is currenty heavily in development, thus so is this implementation.
-You can find a todo-list right [here](TODO.md) and the [milestone schedule](https://github.com/ethereum/ethereumj/milestones).
+You can find a todo-list right [here](TODO.md) and the [milestone schedule](https://github.com/ethereum/ethereumj/milestones).
For questions you can reach us in #ethereumj on Freenode.
-
+
# Documentation
To start you can visit [Ethereum.org](https://www.ethereum.org) and if you are looking for more information on the concept, the [ethereum white paper](https://github.com/ethereum/wiki/wiki/%5BEnglish%5D-White-Paper) is a good place to start as it outlines the vision. For the more technical minded, a protocol description can be found in the [yellow paper](http://gavwood.com/Paper.pdf) by Gavin Wood.
@@ -34,6 +34,6 @@ https://bintray.com/ethereum/maven/org.ethereum/view
For building ethereumj-core or ethereumj-studio look in their own individual README
-# License
+# License
This software is released under the MIT license, read it [here](LICENSE)
diff --git a/TODO.md b/TODO.md
index cd00bdae..cd5ab5be 100644
--- a/TODO.md
+++ b/TODO.md
@@ -4,26 +4,26 @@
----------------
- [ ] **GUI screen** a screen that will hold table with full state representation
-- [ ] **SerpentCompiler** compile create(gas, mem_start, import("examples/mul2.se"))
+- [ ] **SerpentCompiler** compile create(gas, mem_start, import("examples/mul2.se"))
https://github.com/ethereum/wiki/wiki/Serpent
- [ ] **SerpentCompiler** compile return(array) correct
- [ ] **ProgramPlayDialog** support internal calls
-- [ ] **Performance:** BigInteger math change for constant arrays implementation
+- [ ] **Performance:** BigInteger math change for constant arrays implementation
economy for memory allocation
-- [ ] **Command Line:** add the headless run option
-- [ ] **SerpentCompiler** Serpent new syntax:
-(@> @< @/ @%) - unsigned operations
- > < / % - default are all signed operations
-+= -= *= /= %= @/= @%= - short form operations
+- [ ] **Command Line:** add the headless run option
+- [ ] **SerpentCompiler** Serpent new syntax:
+(@> @< @/ @%) - unsigned operations
+ > < / % - default are all signed operations
++= -= *= /= %= @/= @%= - short form operations
share - code section
-
-- [ ] **LLL_to_ASM compiler** list style language to EVM assembly compiler:
+
+- [ ] **LLL_to_ASM compiler** list style language to EVM assembly compiler:
- [ ] **Use home-directory** Create .ethereumj in home-directory for blockchain, state & details database. Make configurable in system.properties so developer can choose user.dir without the creation of .ethereumj directory.
-##### UnitTest:
+##### UnitTest:
----------------
-- [ ] **VM complex:** CREATE testing
+- [ ] **VM complex:** CREATE testing
- [ ] **VM complex:** SUICIDE testing
- [ ] **SerpentCompiler** compile return(array) correct
- [ ] **WorldManager** apply transactions
@@ -36,14 +36,14 @@ share - code section
- [X] ** Block Queue ** separate net layer and block processing layer, net layer should continue get
blocks in time the vm layer process them (not stuck for it)
- [X] **Build:** extract core module and studio application
-- [x] **VM execution:** support CALL op
-- [x] **VM execution:** support CALL op with in/out data
+- [x] **VM execution:** support CALL op
+- [x] **VM execution:** support CALL op with in/out data
- [x] **VM execution:** support CREATE op
- [x] **SerpentCompiler** compile create(gas, mem_start, mem_size)
- [x] **VM complex:** CALL testing for in arrays
- [x] **VM complex:** CALL testing for out result
-- [x] **State management** trie for storage hash calculation
+- [x] **State management** trie for storage hash calculation
and update hash into AccountState
- [x] **VM execution:** SUICIDE op adjust
- [x] **Testing by JSON files:** follow cpp client performs test case by getting json file contains the test describe
diff --git a/ethereumj-core/README.md b/ethereumj-core/README.md
index ef0389e5..0619e048 100644
--- a/ethereumj-core/README.md
+++ b/ethereumj-core/README.md
@@ -1,7 +1,7 @@
The core library API for Ethereum project can be included
-into any other Java/Scala project by simple maven
-script include:
+into any other Java/Scala project by simple maven
+script include:
```
@@ -13,20 +13,20 @@ script include:
```
-EthereumJ release repository can be found here:
+EthereumJ release repository can be found here:
* https://bintray.com/ethereum/maven/org.ethereum/view
The showcase for ethereumj-core usage can be found in [ethereumj-studio](../ethereumj-studio)
-
+
###### :small_blue_diamond: Build instructions (maven)
- 1. build_1: [no test run] , [released to local repository] : ~> ` mvn clean install -Dmaven.test.skip=true `
- 2. build_2: [include test run] , [released to local repository] : ~> ` mvn clean install `
-
+ 1. build_1: [no test run] , [released to local repository] : ~> ` mvn clean install -Dmaven.test.skip=true `
+ 2. build_2: [include test run] , [released to local repository] : ~> ` mvn clean install `
+
###### :small_blue_diamond: release instructions (ant) (!) credential required
1. ` mvn install ` - which release the lib to a local repositroy
2. after the release - ` ant -f bintray-publish-version.xml `
-
-
-
+
+
+
diff --git a/ethereumj-core/pom.xml b/ethereumj-core/pom.xml
index 24d2875b..f8f558a7 100644
--- a/ethereumj-core/pom.xml
+++ b/ethereumj-core/pom.xml
@@ -446,5 +446,5 @@
-
+
diff --git a/ethereumj-core/src/main/java/org/ethereum/config/SystemProperties.java b/ethereumj-core/src/main/java/org/ethereum/config/SystemProperties.java
index e4eb86bc..96552024 100644
--- a/ethereumj-core/src/main/java/org/ethereum/config/SystemProperties.java
+++ b/ethereumj-core/src/main/java/org/ethereum/config/SystemProperties.java
@@ -13,7 +13,7 @@ import org.springframework.stereotype.Component;
/**
* Utility class to retrieve property values from the system.properties files
*
- * @author Roman Mandeleil
+ * @author Roman Mandeleil
* Created on: 22/05/2014 19:22
*/
public class SystemProperties {
@@ -46,7 +46,7 @@ public class SystemProperties {
private static Boolean DEFAULT_VM_TRACE = false;
private static String DEFAULT_VM_TRACE_DIR = "dmp";
private static int DEFAULT_PEER_LISTEN_PORT = 30303;
-
+
/* Testing */
private static Boolean DEFAULT_VMTEST_LOAD_LOCAL = false;
@@ -281,17 +281,17 @@ public class SystemProperties {
logger.info("Key: " + key + ", Value: " + value);
}
}
-
+
/*
- *
+ *
* Testing
- *
+ *
*/
public boolean vmTestLoadLocal() {
if (prop.isEmpty() || !prop.containsKey("GitHubTests.VMTest.loadLocal")) return DEFAULT_VMTEST_LOAD_LOCAL;
return Boolean.parseBoolean(prop.getProperty("GitHubTests.VMTest.loadLocal"));
}
-
+
public static void main(String args[]) {
SystemProperties systemProperties = new SystemProperties();
systemProperties.print();
diff --git a/ethereumj-core/src/main/java/org/ethereum/core/AccountState.java b/ethereumj-core/src/main/java/org/ethereum/core/AccountState.java
index 3b62e9bb..aa822a91 100644
--- a/ethereumj-core/src/main/java/org/ethereum/core/AccountState.java
+++ b/ethereumj-core/src/main/java/org/ethereum/core/AccountState.java
@@ -12,32 +12,32 @@ import static org.ethereum.crypto.HashUtil.EMPTY_TRIE_HASH;
public class AccountState {
private byte[] rlpEncoded;
-
+
/* A value equal to the number of transactions sent
- * from this address, or, in the case of contract accounts,
+ * from this address, or, in the case of contract accounts,
* the number of contract-creations made by this account */
private BigInteger nonce;
-
+
/* A scalar value equal to the number of Wei owned by this address */
private BigInteger balance;
-
- /* A 256-bit hash of the root node of a trie structure
- * that encodes the storage contents of the contract,
- * itself a simple mapping between byte arrays of size 32.
- * The hash is formally denoted σ[a] s .
- *
- * Since I typically wish to refer not to the trie’s root hash
+
+ /* A 256-bit hash of the root node of a trie structure
+ * that encodes the storage contents of the contract,
+ * itself a simple mapping between byte arrays of size 32.
+ * The hash is formally denoted σ[a] s .
+ *
+ * Since I typically wish to refer not to the trie’s root hash
* but to the underlying set of key/value pairs stored within,
- * I define a convenient equivalence TRIE (σ[a] s ) ≡ σ[a] s .
- * It shall be understood that σ[a] s is not a ‘physical’ member
+ * I define a convenient equivalence TRIE (σ[a] s ) ≡ σ[a] s .
+ * It shall be understood that σ[a] s is not a ‘physical’ member
* of the account and does not contribute to its later serialisation */
private byte[] stateRoot = EMPTY_TRIE_HASH;
-
- /* The hash of the EVM code of this contract—this is the code
- * that gets executed should this address receive a message call;
- * it is immutable and thus, unlike all other fields, cannot be changed
- * after construction. All such code fragments are contained in
- * the state database under their corresponding hashes for later
+
+ /* The hash of the EVM code of this contract—this is the code
+ * that gets executed should this address receive a message call;
+ * it is immutable and thus, unlike all other fields, cannot be changed
+ * after construction. All such code fragments are contained in
+ * the state database under their corresponding hashes for later
* retrieval */
private byte[] codeHash = EMPTY_DATA_HASH;
@@ -53,7 +53,7 @@ public class AccountState {
this.nonce = nonce;
this.balance = balance;
}
-
+
public AccountState(byte[] rlpData) {
this.rlpEncoded = rlpData;
@@ -115,7 +115,7 @@ public class AccountState {
this.balance = balance.subtract(value);
setDirty(true);
}
-
+
public byte[] getEncoded() {
if(rlpEncoded == null) {
byte[] nonce = RLP.encodeBigInteger(this.nonce);
diff --git a/ethereumj-core/src/main/java/org/ethereum/core/Block.java b/ethereumj-core/src/main/java/org/ethereum/core/Block.java
index ef8ee2f3..8805a49b 100644
--- a/ethereumj-core/src/main/java/org/ethereum/core/Block.java
+++ b/ethereumj-core/src/main/java/org/ethereum/core/Block.java
@@ -16,10 +16,10 @@ import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
/**
- * The block in Ethereum is the collection of relevant pieces of information
+ * The block in Ethereum is the collection of relevant pieces of information
* (known as the blockheader), H, together with information corresponding to
- * the comprised transactions, R, and a set of other blockheaders U that are known
- * to have a parent equal to the present block’s parent’s parent
+ * the comprised transactions, R, and a set of other blockheaders U that are known
+ * to have a parent equal to the present block’s parent’s parent
* (such blocks are known as uncles).
*
* www.ethereumJ.com
@@ -30,7 +30,7 @@ import java.util.concurrent.CopyOnWriteArrayList;
public class Block {
private static final Logger logger = LoggerFactory.getLogger("block");
-
+
public static BigInteger BLOCK_REWARD = BigInteger.valueOf(1500000000000000000L);
public static BigInteger UNCLE_REWARD = BLOCK_REWARD.multiply(
BigInteger.valueOf(15)).divide(BigInteger.valueOf(16));
@@ -38,28 +38,28 @@ public class Block {
.divide(BigInteger.valueOf(32));
private BlockHeader header;
-
+
/* Transactions */
private List transactionsList = new CopyOnWriteArrayList<>();
-
+
/* Uncles */
private List uncleList = new CopyOnWriteArrayList<>();
- /* Private */
-
+ /* Private */
+
private byte[] rlpEncoded;
private boolean parsed = false;
-
+
private Trie txsState;
-
+
/* Constructors */
-
+
public Block(byte[] rawData) {
logger.debug("new from [" + Hex.toHexString(rawData) + "]");
this.rlpEncoded = rawData;
this.parsed = false;
}
-
+
public Block(byte[] parentHash, byte[] unclesHash, byte[] coinbase, byte[] logsBloom,
byte[] difficulty, long number, long gasLimit,
long gasUsed, long timestamp, byte[] extraData, byte[] nonce,
@@ -85,11 +85,11 @@ public class Block {
RLPList params = RLP.decode2(rlpEncoded);
RLPList block = (RLPList) params.get(0);
-
+
// Parse Header
RLPList header = (RLPList) block.get(0);
this.header = new BlockHeader(header);
-
+
// Parse Transactions
RLPList txTransactions = (RLPList) block.get(1);
this.parseTxs(this.header.getTxTrieRoot(), txTransactions);
@@ -131,7 +131,7 @@ public class Block {
return FastByteComparisons.compareTo(result, 0, 32, target, 0, 32) < 0;
}
-
+
public byte[] getParentHash() {
if (!parsed) parseRLP();
return this.header.getParentHash();
@@ -151,7 +151,7 @@ public class Block {
if (!parsed) parseRLP();
return this.header.getStateRoot();
}
-
+
public void setStateRoot(byte[] stateRoot) {
if (!parsed) parseRLP();
this.header.setStateRoot(stateRoot);
@@ -180,12 +180,12 @@ public class Block {
}
return calcDifficulty;
}
-
+
public long getTimestamp() {
if (!parsed) parseRLP();
return this.header.getTimestamp();
}
-
+
public long getNumber() {
if (!parsed) parseRLP();
return this.header.getNumber();
@@ -210,7 +210,7 @@ public class Block {
if (!parsed) parseRLP();
return this.header.getNonce();
}
-
+
public void setNonce(byte[] nonce) {
this.header.setNonce(nonce);
rlpEncoded = null;
@@ -228,7 +228,7 @@ public class Block {
private StringBuffer toStringBuff = new StringBuffer();
// [parent_hash, uncles_hash, coinbase, state_root, tx_trie_root,
- // difficulty, number, minGasPrice, gasLimit, gasUsed, timestamp,
+ // difficulty, number, minGasPrice, gasLimit, gasUsed, timestamp,
// extradata, nonce]
@Override
@@ -260,7 +260,7 @@ public class Block {
toStringBuff.append("BlockData [");
toStringBuff.append("hash=" + ByteUtil.toHexString(this.getHash())).append("");
toStringBuff.append(header.toFlatString());
-
+
for (Transaction tx : getTransactionsList()) {
toStringBuff.append("\n");
toStringBuff.append(tx.toString());
@@ -318,7 +318,7 @@ public class Block {
this.getHeader().setUnclesHash( SHA3Helper.sha3( getUnclesEncoded() ));
rlpEncoded = null;
}
-
+
public byte[] getEncoded() {
if(rlpEncoded == null) {
byte[] header = this.header.getEncoded();
@@ -328,7 +328,7 @@ public class Block {
}
return rlpEncoded;
}
-
+
public byte[] getEncodedWithoutNonce() {
if (!parsed) parseRLP();
byte[] header = this.header.getEncodedWithoutNonce();
diff --git a/ethereumj-core/src/main/java/org/ethereum/core/BlockHeader.java b/ethereumj-core/src/main/java/org/ethereum/core/BlockHeader.java
index 45d9433c..bed731e0 100644
--- a/ethereumj-core/src/main/java/org/ethereum/core/BlockHeader.java
+++ b/ethereumj-core/src/main/java/org/ethereum/core/BlockHeader.java
@@ -11,23 +11,23 @@ import static org.ethereum.crypto.HashUtil.EMPTY_TRIE_HASH;
import static org.ethereum.util.ByteUtil.toHexString;
/**
- * Block header is a value object containing
- * the basic information of a block
+ * Block header is a value object containing
+ * the basic information of a block
*/
public class BlockHeader {
-
+
/* The SHA3 256-bit hash of the parent block, in its entirety */
private byte[] parentHash;
/* The SHA3 256-bit hash of the uncles list portion of this block */
private byte[] unclesHash;
- /* The 160-bit address to which all fees collected from the
+ /* The 160-bit address to which all fees collected from the
* successful mining of this block be transferred; formally */
private byte[] coinbase;
- /* The SHA3 256-bit hash of the root node of the state trie,
+ /* The SHA3 256-bit hash of the root node of the state trie,
* after all transactions are executed and finalisations applied */
private byte[] stateRoot;
- /* The SHA3 256-bit hash of the root node of the trie structure
+ /* The SHA3 256-bit hash of the root node of the trie structure
* populated with each transaction in the transaction
* list portion, the trie is populate by [key, val] --> [rlp(index), rlp(tx_reciepe)]
* of the block */
@@ -41,33 +41,33 @@ public class BlockHeader {
/*todo: comment it when you know what the fuck it is*/
private byte[] logsBloom;
/* A scalar value corresponding to the difficulty level of this block.
- * This can be calculated from the previous block’s difficulty level
+ * This can be calculated from the previous block’s difficulty level
* and the timestamp */
private byte[] difficulty;
- /* A scalar value equal to the reasonable output of Unix's time()
+ /* A scalar value equal to the reasonable output of Unix's time()
* at this block's inception */
- private long timestamp;
- /* A scalar value equal to the number of ancestor blocks.
+ private long timestamp;
+ /* A scalar value equal to the number of ancestor blocks.
* The genesis block has a number of zero */
private long number;
/* A scalar value equal to the current limit of gas expenditure per block */
private long gasLimit;
/* A scalar value equal to the total gas used in transactions in this block */
private long gasUsed;
- /* An arbitrary byte array containing data relevant to this block.
+ /* An arbitrary byte array containing data relevant to this block.
* With the exception of the genesis block, this must be 32 bytes or fewer */
private byte[] extraData;
- /* A 256-bit hash which proves that a sufficient amount
+ /* A 256-bit hash which proves that a sufficient amount
* of computation has been carried out on this block */
private byte[] nonce;
-
+
public BlockHeader(RLPList rlpHeader) {
this.parentHash = rlpHeader.get(0).getRLPData();
this.unclesHash = rlpHeader.get(1).getRLPData();
this.coinbase = rlpHeader.get(2).getRLPData();
this.stateRoot = rlpHeader.get(3).getRLPData();
-
+
this.txTrieRoot = rlpHeader.get(4).getRLPData();
if(this.txTrieRoot == null)
this.txTrieRoot = EMPTY_TRIE_HASH;
@@ -78,23 +78,23 @@ public class BlockHeader {
this.logsBloom = rlpHeader.get(6).getRLPData();
this.difficulty = rlpHeader.get(7).getRLPData();
-
+
byte[] nrBytes = rlpHeader.get(8).getRLPData();
byte[] glBytes = rlpHeader.get(9).getRLPData();
byte[] guBytes = rlpHeader.get(10).getRLPData();
byte[] tsBytes = rlpHeader.get(11).getRLPData();
-
+
this.number = nrBytes == null ? 0 : (new BigInteger(1, nrBytes)).longValue();
this.gasLimit = glBytes == null ? 0 : (new BigInteger(1, glBytes)).longValue();
this.gasUsed = guBytes == null ? 0 : (new BigInteger(1, guBytes)).longValue();
this.timestamp = tsBytes == null ? 0 : (new BigInteger(1, tsBytes)).longValue();
-
+
this.extraData = rlpHeader.get(12).getRLPData();
this.nonce = rlpHeader.get(13).getRLPData();
}
-
+
public BlockHeader(byte[] parentHash, byte[] unclesHash, byte[] coinbase,
byte[] logsBloom, byte[] difficulty, long number,
long gasLimit, long gasUsed, long timestamp,
@@ -112,10 +112,10 @@ public class BlockHeader {
this.nonce = nonce;
this.stateRoot = HashUtil.EMPTY_TRIE_HASH;
}
-
+
/**
- * Calculate Difficulty
+ * Calculate Difficulty
* See Yellow Paper: http://www.gavwood.com/Paper.pdf - page 5, 4.3.4 (24)
* @return byte array value of the difficulty
*/
@@ -217,15 +217,15 @@ public class BlockHeader {
public void setNonce(byte[] nonce) {
this.nonce = nonce;
}
-
+
public byte[] getEncoded() {
return this.getEncoded(true); // with nonce
}
-
+
public byte[] getEncodedWithoutNonce() {
return this.getEncoded(false);
}
-
+
public byte[] getEncoded(boolean withNonce) {
byte[] parentHash = RLP.encodeElement(this.parentHash);
@@ -262,7 +262,7 @@ public class BlockHeader {
private StringBuffer toStringBuff = new StringBuffer();
-
+
public String toString() {
toStringBuff.setLength(0);
@@ -281,7 +281,7 @@ public class BlockHeader {
toStringBuff.append(" nonce=" + toHexString(nonce)).append("\n");
return toStringBuff.toString();
}
-
+
public String toFlatString() {
toStringBuff.append(" parentHash=" + toHexString(parentHash)).append("");
toStringBuff.append(" unclesHash=" + toHexString(unclesHash)).append("");
diff --git a/ethereumj-core/src/main/java/org/ethereum/core/BlockchainImpl.java b/ethereumj-core/src/main/java/org/ethereum/core/BlockchainImpl.java
index 756ccb33..b7aa6149 100644
--- a/ethereumj-core/src/main/java/org/ethereum/core/BlockchainImpl.java
+++ b/ethereumj-core/src/main/java/org/ethereum/core/BlockchainImpl.java
@@ -29,14 +29,14 @@ import static org.ethereum.config.SystemProperties.CONFIG;
import static org.ethereum.core.Denomination.SZABO;
/**
- * The Ethereum blockchain is in many ways similar to the Bitcoin blockchain,
- * although it does have some differences.
- *
- * The main difference between Ethereum and Bitcoin with regard to the blockchain architecture
- * is that, unlike Bitcoin, Ethereum blocks contain a copy of both the transaction list
- * and the most recent state. Aside from that, two other values, the block number and
- * the difficulty, are also stored in the block.
- *
+ * The Ethereum blockchain is in many ways similar to the Bitcoin blockchain,
+ * although it does have some differences.
+ *
+ * The main difference between Ethereum and Bitcoin with regard to the blockchain architecture
+ * is that, unlike Bitcoin, Ethereum blocks contain a copy of both the transaction list
+ * and the most recent state. Aside from that, two other values, the block number and
+ * the difficulty, are also stored in the block.
+ *
* The block validation algorithm in Ethereum is as follows:
*
*
Check if the previous block referenced exists and is valid.
Check that the block number, difficulty, transaction root, uncle root and gas limit (various low-level Ethereum-specific concepts) are valid.
*
Check that the proof of work on the block is valid.
*
Let S[0] be the STATE_ROOT of the previous block.
- *
Let TX be the block's transaction list, with n transactions.
- * For all in in 0...n-1, set S[i+1] = APPLY(S[i],TX[i]).
- * If any applications returns an error, or if the total gas consumed in the block
+ *
Let TX be the block's transaction list, with n transactions.
+ * For all in in 0...n-1, set S[i+1] = APPLY(S[i],TX[i]).
+ * If any applications returns an error, or if the total gas consumed in the block
* up until this point exceeds the GASLIMIT, return an error.
*
Let S_FINAL be S[n], but adding the block reward paid to the miner.
*
Check if S_FINAL is the same as the STATE_ROOT. If it is, the block is valid; otherwise, it is not valid.
@@ -66,7 +66,7 @@ public class BlockchainImpl implements Blockchain {
private static final Logger logger = LoggerFactory.getLogger("blockchain");
private static final Logger stateLogger = LoggerFactory.getLogger("state");
-
+
// to avoid using minGasPrice=0 from Genesis for the wallet
private static final long INITIAL_MIN_GAS_PRICE = 10 * SZABO.longValue();
@@ -107,7 +107,7 @@ public class BlockchainImpl implements Blockchain {
public byte[] getBestBlockHash() {
return getBestBlock().getHash();
}
-
+
@Override
public long getSize() {
return bestBlock.getNumber() + 1;
@@ -313,7 +313,7 @@ public class BlockchainImpl implements Blockchain {
logger.warn("Invalid block with nr: {}", block.getNumber());
}
}
-
+
private List applyBlock(Block block) {
int i = 1;
@@ -363,15 +363,15 @@ public class BlockchainImpl implements Blockchain {
/**
* Add reward to block- and every uncle coinbase
* assuming the entire block is valid.
- *
+ *
* @param block object containing the header and uncles
*/
private void addReward(Block block) {
// Add standard block reward
BigInteger totalBlockReward = Block.BLOCK_REWARD;
-
- // Add extra rewards based on number of uncles
+
+ // Add extra rewards based on number of uncles
if(block.getUncleList().size() > 0) {
for (BlockHeader uncle : block.getUncleList()) {
track.addBalance(uncle.getCoinbase(), Block.UNCLE_REWARD);
@@ -381,7 +381,7 @@ public class BlockchainImpl implements Blockchain {
}
track.addBalance(block.getCoinbase(), totalBlockReward);
}
-
+
@Override
public void storeBlock(Block block, List receipts) {
@@ -408,8 +408,8 @@ public class BlockchainImpl implements Blockchain {
logger.debug("block added to the blockChain: index: [{}]", block.getNumber());
if (block.getNumber() % 100 == 0)
logger.info("*** Last block added [ #{} ]", block.getNumber());
- }
-
+ }
+
public boolean hasParentOnTheChain(Block block){
return getParent(block.getHeader()) != null;
diff --git a/ethereumj-core/src/main/java/org/ethereum/core/Denomination.java b/ethereumj-core/src/main/java/org/ethereum/core/Denomination.java
index 988eadc7..184b55ee 100644
--- a/ethereumj-core/src/main/java/org/ethereum/core/Denomination.java
+++ b/ethereumj-core/src/main/java/org/ethereum/core/Denomination.java
@@ -12,10 +12,10 @@ public enum Denomination {
FINNY(newBigInt(15)),
ETHER(newBigInt(18)),
EINSTEIN(newBigInt(21)),
- DOUGLAS(newBigInt(42));
-
+ DOUGLAS(newBigInt(42));
+
private BigInteger amount;
-
+
private Denomination(BigInteger value) {
this.amount = value;
}
@@ -23,7 +23,7 @@ public enum Denomination {
public BigInteger value() {
return amount;
}
-
+
public long longValue() {
return value().longValue();
}
@@ -31,7 +31,7 @@ public enum Denomination {
private static BigInteger newBigInt(int value) {
return BigInteger.valueOf(10).pow(value);
}
-
+
public static String toFriendlyString(BigInteger value) {
if(value.compareTo(DOUGLAS.value()) == 1 || value.compareTo(DOUGLAS.value()) == 0) {
return Float.toString(value.divide(DOUGLAS.value()).floatValue()) + " DOUGLAS";
diff --git a/ethereumj-core/src/main/java/org/ethereum/core/Genesis.java b/ethereumj-core/src/main/java/org/ethereum/core/Genesis.java
index 9b81c956..df505e41 100644
--- a/ethereumj-core/src/main/java/org/ethereum/core/Genesis.java
+++ b/ethereumj-core/src/main/java/org/ethereum/core/Genesis.java
@@ -10,26 +10,26 @@ import org.ethereum.trie.TrieImpl;
import org.spongycastle.util.encoders.Hex;
/**
- * The genesis block is the first block in the chain and has fixed values according to
+ * The genesis block is the first block in the chain and has fixed values according to
* the protocol specification. The genesis block is 13 items, and is specified thus:
- *
+ *
* ( zerohash_256 , SHA3 RLP () , zerohash_160 , stateRoot, 0, 2^22 , 0, 0, 1000000, 0, 0, 0, SHA3 (42) , (), () )
- *
- * - Where zerohash_256 refers to the parent hash, a 256-bit hash which is all zeroes;
- * - zerohash_160 refers to the coinbase address, a 160-bit hash which is all zeroes;
- * - 2^22 refers to the difficulty;
- * - 0 refers to the timestamp (the Unix epoch);
- * - the transaction trie root and extradata are both 0, being equivalent to the empty byte array.
- * - The sequences of both uncles and transactions are empty and represented by ().
- * - SHA3 (42) refers to the SHA3 hash of a byte array of length one whose first and only byte is of value 42.
+ *
+ * - Where zerohash_256 refers to the parent hash, a 256-bit hash which is all zeroes;
+ * - zerohash_160 refers to the coinbase address, a 160-bit hash which is all zeroes;
+ * - 2^22 refers to the difficulty;
+ * - 0 refers to the timestamp (the Unix epoch);
+ * - the transaction trie root and extradata are both 0, being equivalent to the empty byte array.
+ * - The sequences of both uncles and transactions are empty and represented by ().
+ * - SHA3 (42) refers to the SHA3 hash of a byte array of length one whose first and only byte is of value 42.
* - SHA3 RLP () value refers to the hash of the uncle lists in RLP, both empty lists.
- *
+ *
* See Yellow Paper: http://www.gavwood.com/Paper.pdf (Appendix I. Genesis Block)
*/
public class Genesis extends Block {
public final static BigInteger PREMINE_AMOUNT = BigInteger.valueOf(2).pow(200);
-
+
private static String[] premine = new String[] {
"51ba59315b3a95761d0863b05ccc7a7f54703d99",
"e6716f9544a56c530d868e4bfbacb172315bdead", // # (J)
@@ -56,14 +56,14 @@ public class Genesis extends Block {
public static long TIMESTAMP = 0;
public static byte[] EXTRA_DATA = new byte[0];
public static byte[] NONCE = sha3(new byte[]{42});
-
+
private static Block instance;
-
+
private Genesis() {
super(PARENT_HASH, UNCLES_HASH, COINBASE, LOG_BLOOM, DIFFICULTY,
NUMBER, GAS_LIMIT, GAS_USED, TIMESTAMP,
EXTRA_DATA, NONCE, null, null);
-
+
Trie state = new TrieImpl(null);
// The proof-of-concept series include a development pre-mine, making the state root hash
// some value stateRoot. The latest documentation should be consulted for the value of the state root.
@@ -74,14 +74,14 @@ public class Genesis extends Block {
setStateRoot(state.getRootHash());
}
-
+
public static Block getInstance() {
if (instance == null) {
instance = new Genesis();
}
return instance;
}
-
+
public final static String[] getPremine() {
return premine;
}
diff --git a/ethereumj-core/src/main/java/org/ethereum/core/Transaction.java b/ethereumj-core/src/main/java/org/ethereum/core/Transaction.java
index 61d428e0..d57cbc32 100644
--- a/ethereumj-core/src/main/java/org/ethereum/core/Transaction.java
+++ b/ethereumj-core/src/main/java/org/ethereum/core/Transaction.java
@@ -16,17 +16,17 @@ import static org.ethereum.util.ByteUtil.EMPTY_BYTE_ARRAY;
import static org.ethereum.util.ByteUtil.ZERO_BYTE_ARRAY;
/**
- * A transaction (formally, T) is a single cryptographically
- * signed instruction sent by an actor external to Ethereum.
- * An external actor can be a person (via a mobile device or desktop computer)
- * or could be from a piece of automated software running on a server.
- * There are two types of transactions: those which result in message calls
+ * A transaction (formally, T) is a single cryptographically
+ * signed instruction sent by an actor external to Ethereum.
+ * An external actor can be a person (via a mobile device or desktop computer)
+ * or could be from a piece of automated software running on a server.
+ * There are two types of transactions: those which result in message calls
* and those which result in the creation of new contracts.
*/
public class Transaction {
private static final Logger logger = LoggerFactory.getLogger(Transaction.class);
-
+
/* SHA3 hash of the RLP encoded transaction */
private byte[] hash;
@@ -64,7 +64,7 @@ public class Transaction {
/* Tx in encoded form */
private byte[] rlpEncoded;
private byte[] rlpRaw;
- /* Indicates if this transaction has been parsed
+ /* Indicates if this transaction has been parsed
* from the RLP-encoded data */
private boolean parsed = false;
@@ -295,7 +295,7 @@ public class Transaction {
byte[] data = RLP.encodeElement(this.data);
byte[] v, r, s;
-
+
if(signature != null) {
v = RLP.encodeByte( signature.v );
r = RLP.encodeElement(BigIntegers.asUnsignedByteArray(signature.r));
diff --git a/ethereumj-core/src/main/java/org/ethereum/core/TransactionReceipt.java b/ethereumj-core/src/main/java/org/ethereum/core/TransactionReceipt.java
index 7ae3648a..a88f58f2 100644
--- a/ethereumj-core/src/main/java/org/ethereum/core/TransactionReceipt.java
+++ b/ethereumj-core/src/main/java/org/ethereum/core/TransactionReceipt.java
@@ -13,9 +13,9 @@ import java.util.List;
import static org.ethereum.util.ByteUtil.EMPTY_BYTE_ARRAY;
/**
- * The transaction receipt is a tuple of three items
- * comprising the transaction, together with the post-transaction state,
- * and the cumulative gas used in the block containing the transaction receipt
+ * The transaction receipt is a tuple of three items
+ * comprising the transaction, together with the post-transaction state,
+ * and the cumulative gas used in the block containing the transaction receipt
* as of immediately after the transaction has happened,
*
*
diff --git a/ethereumj-core/src/main/java/org/ethereum/core/Wallet.java b/ethereumj-core/src/main/java/org/ethereum/core/Wallet.java
index b1d09eee..8381a8e8 100644
--- a/ethereumj-core/src/main/java/org/ethereum/core/Wallet.java
+++ b/ethereumj-core/src/main/java/org/ethereum/core/Wallet.java
@@ -40,7 +40,7 @@ public class Wallet {
// TODO: a) the values I need to keep for address state is balance & nonce & ECKey
// TODO: b) keep it to be easy accessed by the toAddress()
// private HashMap rows = new HashMap<>();
-
+
// This map of transaction designed
// to approve the tx by external trusted peer
private Map walletTransactions = new ConcurrentHashMap<>();
@@ -141,13 +141,13 @@ public class Wallet {
return walletTransaction;
}
-
+
public void addTransactions(List transactions) {
for (Transaction transaction : transactions) {
this.addTransaction(transaction);
}
}
-
+
public void removeTransactions(List transactions) {
for (Transaction tx : transactions) {
if (logger.isDebugEnabled())
@@ -182,7 +182,7 @@ public class Wallet {
Account receiver = rows.get(Hex.toHexString(receiveAddress));
if (receiver != null) {
receiver.addPendingTransaction(transaction);
-
+
logger.info("Pending transaction added to " +
"\n account: [{}], " +
"\n tx: [{}]",
@@ -221,7 +221,7 @@ public class Wallet {
900099909
-
+
*/
String dir = System.getProperty("user.dir");
diff --git a/ethereumj-core/src/main/java/org/ethereum/crypto/ECKey.java b/ethereumj-core/src/main/java/org/ethereum/crypto/ECKey.java
index c5707baf..43937be9 100644
--- a/ethereumj-core/src/main/java/org/ethereum/crypto/ECKey.java
+++ b/ethereumj-core/src/main/java/org/ethereum/crypto/ECKey.java
@@ -50,7 +50,7 @@ import org.spongycastle.util.encoders.Hex;
* Creating a new ECKey with the empty constructor will generate a new random keypair. Other static methods can be used
* when you already have the public or private parts. If you create a key with only the public part, you can check
* signatures but not create them.
- *
+ *
*
The ECDSA algorithm supports key recovery in which a signature plus a couple of discriminator bits can
* be reversed to find the public key used to calculate it. This can be convenient when you have a message and a
* signature and want to find out who signed it, rather than requiring the user to provide the expected identity.
@@ -70,7 +70,7 @@ import org.spongycastle.util.encoders.Hex;
*/
public class ECKey implements Serializable {
private static final Logger logger = LoggerFactory.getLogger(ECKey.class);
-
+
/** The parameters of the secp256k1 curve that Ethereum uses. */
public static final ECDomainParameters CURVE;
@@ -90,7 +90,7 @@ public class ECKey implements Serializable {
HALF_CURVE_ORDER = params.getN().shiftRight(1);
secureRandom = new SecureRandom();
}
-
+
// The two parts of the key. If "priv" is set, "pub" can always be calculated. If "pub" is set but not "priv", we
// can only verify signatures not make them.
// TODO: Redesign this class to use consistent internals and more efficient serialization.
@@ -129,7 +129,7 @@ public class ECKey implements Serializable {
throw new IllegalArgumentException("Public key may not be null");
this.pub = pub;
}
-
+
/**
* Utility for compressing an elliptic curve point. Returns the same point if it's already compressed.
* See the ECKey class docs for a discussion of point compression.
@@ -145,7 +145,7 @@ public class ECKey implements Serializable {
public static ECPoint decompressPoint(ECPoint compressed) {
return CURVE.getCurve().decodePoint(compressed.getEncoded(false));
}
-
+
/**
* Creates an ECKey given the private key only. The public key is calculated from it (this is slow). Note that
* the resulting public key is compressed.
@@ -197,7 +197,7 @@ public class ECKey implements Serializable {
public static ECKey fromPublicOnly(byte[] pub) {
return new ECKey(null, CURVE.getCurve().decodePoint(pub));
}
-
+
/**
* Returns a copy of this key, but with the public point represented in uncompressed form. Normally you would
* never need this: it's for specialised scenarios or when backwards compatibility in encoded form is necessary.
@@ -224,7 +224,7 @@ public class ECKey implements Serializable {
public boolean hasPrivKey() {
return priv != null;
}
-
+
/**
* Returns public key bytes from the given private key. To convert a byte array into a BigInteger, use
* new BigInteger(1, bytes);
@@ -293,7 +293,7 @@ public class ECKey implements Serializable {
}
return b.toString();
}
-
+
/**
* Groups the two components that make up a signature, and provides a way to encode to Base64 form, which is
* how ECDSA signatures are represented when embedded in other data structures in the Ethereum protocol. The raw
@@ -311,11 +311,11 @@ public class ECKey implements Serializable {
this.r = r;
this.s = s;
}
-
+
private static ECDSASignature fromComponents(byte[] r, byte[] s) {
return new ECDSASignature(new BigInteger(1, r), new BigInteger(1, s));
}
-
+
public static ECDSASignature fromComponents(byte[] r, byte[] s, byte v) {
ECDSASignature signature = fromComponents(r, s);
signature.v = v;
@@ -341,7 +341,7 @@ public class ECKey implements Serializable {
return this;
}
}
-
+
public String toBase64() {
byte[] sigData = new byte[65]; // 1 header + 32 bytes for R + 32 bytes for S
sigData[0] = v;
@@ -349,7 +349,7 @@ public class ECKey implements Serializable {
System.arraycopy(bigIntegerToBytes(this.s, 32), 0, sigData, 33, 32);
return new String(Base64.encode(sigData), Charset.forName("UTF-8"));
}
-
+
@Override
public boolean equals(Object o) {
if (this == o) return true;
@@ -370,11 +370,11 @@ public class ECKey implements Serializable {
return result;
}
}
-
+
/**
- * Signs the given hash and returns the R and S components as BigIntegers
- * and put them in ECDSASignature
- *
+ * Signs the given hash and returns the R and S components as BigIntegers
+ * and put them in ECDSASignature
+ *
* @param input to sign
* @return ECDSASignature signature that contains the R and S components
*/
@@ -389,7 +389,7 @@ public class ECKey implements Serializable {
BigInteger[] components = signer.generateSignature(input);
return new ECDSASignature(components[0], components[1]).toCanonicalised();
}
-
+
/**
* Takes the sha3 hash (32 bytes) of data and returns the ECDSA signature
*
@@ -413,12 +413,12 @@ public class ECKey implements Serializable {
sig.v = (byte) (recId + 27 + (isCompressed() ? 4 : 0));
return sig;
}
-
+
/**
* Given a piece of text and a message signature encoded in base64, returns an ECKey
* containing the public key that was used to sign it. This can then be compared to the expected public key to
* determine if the signature was correct.
- *
+ *
* @param messageHash a piece of human readable text that was signed
* @param signatureBase64 The Ethereum-format message signature in base64
* @throws SignatureException If the public key could not be recovered or if there was a signature format error.
@@ -453,10 +453,10 @@ public class ECKey implements Serializable {
throw new SignatureException("Could not recover public key from signature");
return key;
}
-
+
/**
*
Verifies the given ECDSA signature against the message bytes using the public key bytes.
- *
+ *
*
When using native ECDSA verification, data must be 32 bytes, and no element may be
* larger than 520 bytes.
*
@@ -471,7 +471,7 @@ public class ECKey implements Serializable {
try {
return signer.verifySignature(data, signature.r, signature.s);
} catch (NullPointerException npe) {
- // Bouncy Castle contains a bug that can cause NPEs given specially crafted signatures.
+ // Bouncy Castle contains a bug that can cause NPEs given specially crafted signatures.
// Those signatures are inherently invalid/attack sigs so we just fail them here rather than crash the thread.
logger.error("Caught NPE inside bouncy castle", npe);
return false;
@@ -637,7 +637,7 @@ public class ECKey implements Serializable {
byte[] bits = getPubKey();
return (bits[0] & 0xFF) | ((bits[1] & 0xFF) << 8) | ((bits[2] & 0xFF) << 16) | ((bits[3] & 0xFF) << 24);
}
-
+
@SuppressWarnings("serial")
public static class MissingPrivateKeyException extends RuntimeException {
}
diff --git a/ethereumj-core/src/main/java/org/ethereum/crypto/HashUtil.java b/ethereumj-core/src/main/java/org/ethereum/crypto/HashUtil.java
index 5fa34da6..f0e6657c 100644
--- a/ethereumj-core/src/main/java/org/ethereum/crypto/HashUtil.java
+++ b/ethereumj-core/src/main/java/org/ethereum/crypto/HashUtil.java
@@ -18,14 +18,14 @@ import org.ethereum.util.LRUMap;
public class HashUtil {
- private static final int MAX_ENTRIES = 100; // Should contain most commonly hashed values
+ private static final int MAX_ENTRIES = 100; // Should contain most commonly hashed values
private static LRUMap sha3Cache = new LRUMap<>(0, MAX_ENTRIES);
public static final byte[] EMPTY_DATA_HASH = sha3(EMPTY_BYTE_ARRAY);
public static final byte[] EMPTY_LIST_HASH = sha3(RLP.encodeList());
public static final byte[] EMPTY_TRIE_HASH = sha3(RLP.encodeElement(EMPTY_BYTE_ARRAY));
private static final MessageDigest sha256digest;
-
+
static {
try {
sha256digest = MessageDigest.getInstance("SHA-256");
@@ -33,7 +33,7 @@ public class HashUtil {
throw new RuntimeException(e); // Can't happen.
}
}
-
+
public static byte[] sha256(byte[] input) {
return sha256digest.digest(input);
}
@@ -47,7 +47,7 @@ public class HashUtil {
sha3Cache.put(inputByteArray, result);
return result;
}
-
+
public static byte[] ripemd160(byte[] message) {
Digest digest = new RIPEMD160Digest();
if (message != null) {
@@ -83,7 +83,7 @@ public class HashUtil {
return newAddress;
}
-
+
/**
* @see #doubleDigest(byte[], int, int)
*/
diff --git a/ethereumj-core/src/main/java/org/ethereum/crypto/SHA3Helper.java b/ethereumj-core/src/main/java/org/ethereum/crypto/SHA3Helper.java
index 5f63cdaa..c7992e3a 100644
--- a/ethereumj-core/src/main/java/org/ethereum/crypto/SHA3Helper.java
+++ b/ethereumj-core/src/main/java/org/ethereum/crypto/SHA3Helper.java
@@ -6,9 +6,9 @@ import org.spongycastle.crypto.digests.SHA3Digest;
import org.spongycastle.util.encoders.Hex;
public class SHA3Helper {
-
+
private static int DEFAULT_SIZE = 256;
-
+
public static String sha3String(String message) {
return sha3String(message, new SHA3Digest(DEFAULT_SIZE), true);
}
@@ -75,23 +75,23 @@ public class SHA3Helper {
digest.doFinal(hash, 0);
return hash;
}
-
+
public enum Size {
-
+
S224(224),
S256(256),
S384(384),
S512(512);
-
+
int bits = 0;
-
+
Size(int bits) {
this.bits = bits;
}
-
+
public int getValue() {
return this.bits;
}
}
-
+
}
diff --git a/ethereumj-core/src/main/java/org/ethereum/db/ByteArrayWrapper.java b/ethereumj-core/src/main/java/org/ethereum/db/ByteArrayWrapper.java
index f7ca4930..f9d38b5b 100644
--- a/ethereumj-core/src/main/java/org/ethereum/db/ByteArrayWrapper.java
+++ b/ethereumj-core/src/main/java/org/ethereum/db/ByteArrayWrapper.java
@@ -24,7 +24,7 @@ public class ByteArrayWrapper implements Comparable {
return false;
byte[] otherData = ((ByteArrayWrapper) other).getData();
return FastByteComparisons.compareTo(
- data, 0, data.length,
+ data, 0, data.length,
otherData, 0, otherData.length) == 0;
}
@@ -36,10 +36,10 @@ public class ByteArrayWrapper implements Comparable {
@Override
public int compareTo(ByteArrayWrapper o) {
return FastByteComparisons.compareTo(
- data, 0, data.length,
+ data, 0, data.length,
o.getData(), 0, o.getData().length);
}
-
+
public byte[] getData() {
return data;
}
diff --git a/ethereumj-core/src/main/java/org/ethereum/db/ContractDetails.java b/ethereumj-core/src/main/java/org/ethereum/db/ContractDetails.java
index 882345f0..f0194438 100644
--- a/ethereumj-core/src/main/java/org/ethereum/db/ContractDetails.java
+++ b/ethereumj-core/src/main/java/org/ethereum/db/ContractDetails.java
@@ -32,7 +32,7 @@ public class ContractDetails {
public ContractDetails() {
}
-
+
public ContractDetails(byte[] rlpCode) {
decode(rlpCode);
}
diff --git a/ethereumj-core/src/main/java/org/ethereum/db/Database.java b/ethereumj-core/src/main/java/org/ethereum/db/Database.java
index dde409ca..5d6a7fbc 100644
--- a/ethereumj-core/src/main/java/org/ethereum/db/Database.java
+++ b/ethereumj-core/src/main/java/org/ethereum/db/Database.java
@@ -4,26 +4,26 @@ package org.ethereum.db;
* Ethereum generic database interface
*/
public interface Database {
-
- /**
+
+ /**
* Get value from database
- *
+ *
* @param key for which to retrieve the value
* @return the value for the given key
*/
public byte[] get(byte[] key);
-
+
/**
* Insert value into database
- *
+ *
* @param key for the given value
* @param value to insert
*/
- public void put(byte[] key, byte[] value);
-
+ public void put(byte[] key, byte[] value);
+
/**
* Delete key/value pair from database
- *
+ *
* @param key for which to delete the value
*/
public void delete(byte[] key);
diff --git a/ethereumj-core/src/main/java/org/ethereum/db/DatabaseImpl.java b/ethereumj-core/src/main/java/org/ethereum/db/DatabaseImpl.java
index 7320ad47..74663e45 100644
--- a/ethereumj-core/src/main/java/org/ethereum/db/DatabaseImpl.java
+++ b/ethereumj-core/src/main/java/org/ethereum/db/DatabaseImpl.java
@@ -19,18 +19,18 @@ import org.spongycastle.util.encoders.Hex;
/**
* Generic interface for Ethereum database
- *
+ *
* LevelDB key/value pair DB implementation will be used.
* Choice must be made between:
* Pure Java: https://github.com/dain/leveldb
* JNI binding: https://github.com/fusesource/leveldbjni
*/
public class DatabaseImpl implements Database {
-
+
private static final Logger logger = LoggerFactory.getLogger("db");
private DB db;
private String name;
-
+
public DatabaseImpl(String name) {
// Initialize Database
this.name = name;
@@ -69,9 +69,9 @@ public class DatabaseImpl implements Database {
} catch (IOException ioe) {
logger.error(ioe.getMessage(), ioe);
throw new RuntimeException("Can't initialize database");
- }
+ }
}
-
+
public void destroyDB(File fileLocation) {
logger.debug("Destroying existing database");
Options options = new Options();
@@ -81,12 +81,12 @@ public class DatabaseImpl implements Database {
logger.error(e.getMessage(), e);
}
}
-
+
@Override
public byte[] get(byte[] key) {
return db.get(key);
}
-
+
@Override
public void put(byte[] key, byte[] value) {
@@ -96,7 +96,7 @@ public class DatabaseImpl implements Database {
Hex.toHexString(value));
db.put(key, value);
}
-
+
@Override
public void delete(byte[] key) {
if(logger.isDebugEnabled())
@@ -104,11 +104,11 @@ public class DatabaseImpl implements Database {
db.delete(key);
}
-
+
public DBIterator iterator() {
return db.iterator();
}
-
+
public DB getDb() {
return this.db;
}
diff --git a/ethereumj-core/src/main/java/org/ethereum/facade/Repository.java b/ethereumj-core/src/main/java/org/ethereum/facade/Repository.java
index bc5d2392..1ecfce92 100644
--- a/ethereumj-core/src/main/java/org/ethereum/facade/Repository.java
+++ b/ethereumj-core/src/main/java/org/ethereum/facade/Repository.java
@@ -21,7 +21,7 @@ public interface Repository {
/**
* Create a new account in the database
- *
+ *
* @param addr of the contract
* @return newly created account state
*/
@@ -34,65 +34,65 @@ public interface Repository {
* false otherwise
*/
public boolean isExist(byte[] addr);
-
+
/**
* Retrieve an account
- *
+ *
* @param addr of the account
* @return account state as stored in the database
*/
public AccountState getAccountState(byte[] addr);
-
+
/**
* Deletes the account
- *
+ *
* @param addr of the account
*/
public void delete(byte[] addr);
-
+
/**
* Increase the account nonce of the given account by one
- *
+ *
* @param addr of the account
* @return new value of the nonce
*/
public BigInteger increaseNonce(byte[] addr);
-
+
/**
* Get current nonce of a given account
- *
+ *
* @param addr of the account
* @return value of the nonce
*/
public BigInteger getNonce(byte[] addr);
-
+
/**
* Retrieve contract details for a given account from the database
- *
+ *
* @param addr of the account
- * @return new contract details
+ * @return new contract details
*/
public ContractDetails getContractDetails(byte[] addr);
-
+
/**
* Store code associated with an account
- *
+ *
* @param addr for the account
* @param code that will be associated with this account
*/
public void saveCode(byte[] addr, byte[] code);
-
+
/**
* Retrieve the code associated with an account
- *
+ *
* @param addr of the account
* @return code in byte-array format
*/
public byte[] getCode(byte[] addr);
-
+
/**
* Put a value in storage of an account at a given key
- *
+ *
* @param addr of the account
* @param key of the data to store
* @param value is the data to store
@@ -102,34 +102,34 @@ public interface Repository {
/**
* Retrieve storage value from an account for a given key
- *
+ *
* @param addr of the account
* @param key associated with this value
* @return data in the form of a DataWord
*/
public DataWord getStorageValue(byte[] addr, DataWord key);
-
+
/**
* Retrieve balance of an account
- *
+ *
* @param addr of the account
* @return balance of the account as a BigInteger value
*/
public BigInteger getBalance(byte[] addr);
-
+
/**
* Add value to the balance of an account
- *
+ *
* @param addr of the account
* @param value to be added
* @return new balance of the account
*/
public BigInteger addBalance(byte[] addr, BigInteger value);
-
+
/**
* Returns an iterator over the accounts in this database in proper sequence
- *
+ *
* @return an iterator over the accounts in this database in proper sequence
*/
public DBIterator getAccountsIterator();
@@ -137,12 +137,12 @@ public interface Repository {
/**
* Dump the full state of the current repository into a file with JSON format
- * It contains all the contracts/account, their attributes and
- *
+ * It contains all the contracts/account, their attributes and
+ *
* @param block of the current state
* @param gasUsed the amount of gas used in the block until that point
* @param txNumber is the number of the transaction for which the dump has to be made
- * @param txHash is the hash of the given transaction.
+ * @param txHash is the hash of the given transaction.
* If null, the block state post coinbase reward is dumped.
*/
public void dumpState(Block block, long gasUsed, int txNumber, byte[] txHash);
@@ -158,13 +158,13 @@ public interface Repository {
/**
- * Store all the temporary changes made
+ * Store all the temporary changes made
* to the repository in the actual database
*/
public void commit();
-
+
/**
- * Undo all the changes made so far
+ * Undo all the changes made so far
* to a snapshot of the repository
*/
public void rollback();
@@ -175,13 +175,13 @@ public interface Repository {
* @param root - new root
*/
public void syncToRoot(byte[] root);
-
+
/**
* Check to see if the current repository has an open connection to the database
* @return true if connection to database is open
*/
public boolean isClosed();
-
+
/**
* Close the database
*/
diff --git a/ethereumj-core/src/main/java/org/ethereum/json/EtherObjectMapper.java b/ethereumj-core/src/main/java/org/ethereum/json/EtherObjectMapper.java
index f3f553cd..fe778700 100644
--- a/ethereumj-core/src/main/java/org/ethereum/json/EtherObjectMapper.java
+++ b/ethereumj-core/src/main/java/org/ethereum/json/EtherObjectMapper.java
@@ -11,9 +11,9 @@ import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
/**
- * An extended {@link com.fasterxml.jackson.databind.ObjectMapper ObjectMapper} class to
+ * An extended {@link com.fasterxml.jackson.databind.ObjectMapper ObjectMapper} class to
* customize ethereum state dumps.
- *
+ *
* @author Alon Muroch
*
*/
@@ -21,7 +21,7 @@ public class EtherObjectMapper extends ObjectMapper {
@Override
public String writeValueAsString(Object value)
- throws JsonProcessingException {
+ throws JsonProcessingException {
// alas, we have to pull the recycler directly here...
SegmentedStringWriter sw = new SegmentedStringWriter(_jsonFactory._getBufferRecycler());
try {
@@ -29,7 +29,7 @@ public class EtherObjectMapper extends ObjectMapper {
// set ethereum custom pretty printer
EtherPrettyPrinter pp = new EtherPrettyPrinter();
ge.setPrettyPrinter(pp);
-
+
_configAndWriteValue(ge, value);
} catch (JsonProcessingException e) { // to support [JACKSON-758]
throw e;
@@ -38,11 +38,11 @@ public class EtherObjectMapper extends ObjectMapper {
}
return sw.getAndClear();
}
-
+
/**
- * An extended {@link com.fasterxml.jackson.core.util.DefaultPrettyPrinter} class to customize
+ * An extended {@link com.fasterxml.jackson.core.util.DefaultPrettyPrinter} class to customize
* an ethereum {@link com.fasterxml.jackson.core.PrettyPrinter Pretty Printer} Generator
- *
+ *
* @author Alon Muroch
*
*/
@@ -51,7 +51,7 @@ public class EtherObjectMapper extends ObjectMapper {
public EtherPrettyPrinter() {
super();
}
-
+
@Override
public void writeObjectFieldValueSeparator(JsonGenerator jg)
throws IOException, JsonGenerationException {
diff --git a/ethereumj-core/src/main/java/org/ethereum/json/JSONHelper.java b/ethereumj-core/src/main/java/org/ethereum/json/JSONHelper.java
index cb2b4d6c..2973033c 100644
--- a/ethereumj-core/src/main/java/org/ethereum/json/JSONHelper.java
+++ b/ethereumj-core/src/main/java/org/ethereum/json/JSONHelper.java
@@ -16,26 +16,26 @@ import java.math.BigInteger;
import java.util.*;
/**
- * JSON Helper class to format data into ObjectNodes
+ * JSON Helper class to format data into ObjectNodes
* to match PyEthereum blockstate output
- *
+ *
* Dump format:
* {
- * "address":
- * {
- * "nonce": "n1",
- * "balance": "b1",
- * "stateRoot": "s1",
- * "codeHash": "c1",
- * "code": "c2",
- * "storage":
- * {
- * "key1": "value1",
- * "key2": "value2"
+ * "address":
+ * {
+ * "nonce": "n1",
+ * "balance": "b1",
+ * "stateRoot": "s1",
+ * "codeHash": "c1",
+ * "code": "c2",
+ * "storage":
+ * {
+ * "key1": "value1",
+ * "key2": "value2"
* }
* }
* }
- *
+ *
* www.ethereumJ.com
*
* @author: Roman Mandeleil
@@ -43,14 +43,14 @@ import java.util.*;
*/
public class JSONHelper {
- public static void dumpState(ObjectNode statesNode, String address, AccountState state, ContractDetails details) {
+ public static void dumpState(ObjectNode statesNode, String address, AccountState state, ContractDetails details) {
List storageKeys = new ArrayList<>(details.getStorage().keySet());
Collections.sort((List) storageKeys);
ObjectNode account = statesNode.objectNode();
ObjectNode storage = statesNode.objectNode();
-
+
for (DataWord key : storageKeys) {
storage.put("0x" + Hex.toHexString(key.getData()),
"0x" + Hex.toHexString(details.getStorage().get(key).getNoLeadZeroesData()));
@@ -61,14 +61,14 @@ public class JSONHelper {
account.put("nonce", state.getNonce() == null ? "0" : state.getNonce().toString());
account.put("storage", storage);
account.put("storage_root", state.getStateRoot() == null ? "" : Hex.toHexString(state.getStateRoot()));
-
+
statesNode.put(address, account);
}
-
+
public static void dumpBlock(ObjectNode blockNode, Block block,
long gasUsed, byte[] state, List keys,
Repository repository) {
-
+
blockNode.put("coinbase", Hex.toHexString(block.getCoinbase()));
blockNode.put("difficulty", new BigInteger(1, block.calcDifficulty()).toString());
blockNode.put("extra_data", "0x");
@@ -76,25 +76,25 @@ public class JSONHelper {
blockNode.put("nonce", "0x" + Hex.toHexString(block.getNonce()));
blockNode.put("number", String.valueOf(block.getNumber()));
blockNode.put("prevhash", "0x" + Hex.toHexString(block.getParentHash()));
-
+
ObjectNode statesNode = blockNode.objectNode();
for (ByteArrayWrapper key : keys) {
byte[] keyBytes = key.getData();
AccountState accountState = repository.getAccountState(keyBytes);
ContractDetails details = repository.getContractDetails(keyBytes);
JSONHelper.dumpState(statesNode, Hex.toHexString(keyBytes), accountState, details);
- }
+ }
blockNode.put("state", statesNode);
-
+
blockNode.put("state_root", Hex.toHexString(state));
blockNode.put("timestamp", String.valueOf(block.getTimestamp()));
-
+
ArrayNode transactionsNode = blockNode.arrayNode();
blockNode.put("transactions", transactionsNode);
-
+
blockNode.put("tx_list_root", ByteUtil.toHexString(block.getTxTrieRoot()));
blockNode.put("uncles_hash", "0x" + Hex.toHexString(block.getUnclesHash()));
-
+
// JSONHelper.dumpTransactions(blockNode,
// stateRoot, codeHash, code, storage);
}
diff --git a/ethereumj-core/src/main/java/org/ethereum/jsontestsuite/JSONReader.java b/ethereumj-core/src/main/java/org/ethereum/jsontestsuite/JSONReader.java
index adf33582..a7013592 100644
--- a/ethereumj-core/src/main/java/org/ethereum/jsontestsuite/JSONReader.java
+++ b/ethereumj-core/src/main/java/org/ethereum/jsontestsuite/JSONReader.java
@@ -20,7 +20,7 @@ public class JSONReader {
json = getFromUrl("https://raw.githubusercontent.com/ethereum/tests/develop/" + filename);
return json == "" ? json = getFromLocal(filename) : json;
}
-
+
public static String getFromLocal(String filename) {
System.out.println("Loading local file: " + filename);
try {
@@ -36,7 +36,7 @@ public class JSONReader {
}
return "";
}
-
+
public static String getFromUrl(String urlToRead) {
URL url;
HttpURLConnection conn;
diff --git a/ethereumj-core/src/main/java/org/ethereum/jsontestsuite/Logs.java b/ethereumj-core/src/main/java/org/ethereum/jsontestsuite/Logs.java
index e06e82a4..8e1e3d42 100644
--- a/ethereumj-core/src/main/java/org/ethereum/jsontestsuite/Logs.java
+++ b/ethereumj-core/src/main/java/org/ethereum/jsontestsuite/Logs.java
@@ -15,7 +15,7 @@ import org.spongycastle.util.encoders.Hex;
public class Logs {
List logs = new ArrayList<>();
-
+
public Logs(JSONArray jLogs) {
for (int i = 0; i < jLogs.size(); ++i){
diff --git a/ethereumj-core/src/main/java/org/ethereum/jsontestsuite/TestCase.java b/ethereumj-core/src/main/java/org/ethereum/jsontestsuite/TestCase.java
index 92a2c17d..14651bb8 100644
--- a/ethereumj-core/src/main/java/org/ethereum/jsontestsuite/TestCase.java
+++ b/ethereumj-core/src/main/java/org/ethereum/jsontestsuite/TestCase.java
@@ -23,7 +23,7 @@ public class TestCase {
// "env": { ... },
private Env env;
-
+
//
private Logs logs;
@@ -64,7 +64,7 @@ public class TestCase {
JSONArray callCreates = new JSONArray();
if(testCaseJSONObj.containsKey("callcreates"))
callCreates = (JSONArray)testCaseJSONObj.get("callcreates");
-
+
JSONArray logsJSON = new JSONArray();
if(testCaseJSONObj.containsKey("logs"))
logsJSON = (JSONArray)testCaseJSONObj.get("logs");
@@ -74,7 +74,7 @@ public class TestCase {
if(testCaseJSONObj.containsKey("gas"))
gasString = testCaseJSONObj.get("gas").toString();
this.gas = ByteUtil.bigIntegerToBytes(new BigInteger(gasString));
-
+
String outString = null;
if(testCaseJSONObj.containsKey("out"))
outString = testCaseJSONObj.get("out").toString();
@@ -122,7 +122,7 @@ public class TestCase {
public Exec getExec() {
return exec;
}
-
+
public Logs getLogs() {
return logs;
}
diff --git a/ethereumj-core/src/main/java/org/ethereum/jsontestsuite/TestRunner.java b/ethereumj-core/src/main/java/org/ethereum/jsontestsuite/TestRunner.java
index e9d8d136..2d8f493c 100644
--- a/ethereumj-core/src/main/java/org/ethereum/jsontestsuite/TestRunner.java
+++ b/ethereumj-core/src/main/java/org/ethereum/jsontestsuite/TestRunner.java
@@ -33,7 +33,7 @@ public class TestRunner {
private ProgramTrace trace = null;
public List runTestSuite(TestSuite testSuite) {
-
+
Iterator testIterator = testSuite.iterator();
List resultCollector = new ArrayList<>();
diff --git a/ethereumj-core/src/main/java/org/ethereum/manager/WorldManager.java b/ethereumj-core/src/main/java/org/ethereum/manager/WorldManager.java
index 5c5e0e30..031d89dd 100644
--- a/ethereumj-core/src/main/java/org/ethereum/manager/WorldManager.java
+++ b/ethereumj-core/src/main/java/org/ethereum/manager/WorldManager.java
@@ -25,8 +25,8 @@ import static org.ethereum.config.SystemProperties.CONFIG;
/**
* WorldManager is a singleton containing references to different parts of the system.
- *
- * @author Roman Mandeleil
+ *
+ * @author Roman Mandeleil
* Created on: 01/06/2014 10:44
*/
@Component
@@ -57,12 +57,12 @@ public class WorldManager {
@Autowired
private AdminInfo adminInfo;
-
+
private final Set pendingTransactions = Collections.synchronizedSet(new HashSet());
@Autowired
private EthereumListener listener;
-
+
@PostConstruct
public void init() {
byte[] cowAddr = HashUtil.sha3("cow".getBytes());
@@ -72,7 +72,7 @@ public class WorldManager {
byte[] cbAddr = HashUtil.sha3(secret.getBytes());
wallet.importKey(cbAddr);
}
-
+
public void addListener(EthereumListener listener) {
logger.info("Ethereum listener added");
((EthereumListenerWrapper)this.listener).addListener(listener);
@@ -115,7 +115,7 @@ public class WorldManager {
public EthereumListener getListener() {
return listener;
}
-
+
public void setWallet(Wallet wallet) {
this.wallet = wallet;
}
@@ -123,11 +123,11 @@ public class WorldManager {
public Repository getRepository() {
return repository;
}
-
+
public Blockchain getBlockchain() {
return blockchain;
}
-
+
public Wallet getWallet() {
return wallet;
}
diff --git a/ethereumj-core/src/main/java/org/ethereum/mine/Miner.java b/ethereumj-core/src/main/java/org/ethereum/mine/Miner.java
index 7bd327b7..d340bdbf 100644
--- a/ethereumj-core/src/main/java/org/ethereum/mine/Miner.java
+++ b/ethereumj-core/src/main/java/org/ethereum/mine/Miner.java
@@ -14,18 +14,18 @@ import java.math.BigInteger;
/**
* The Miner performs the proof-of-work needed for a valid block
- *
+ *
* The mining proof-of-work (PoW) exists as a cryptographically secure nonce
- * that proves beyond reasonable doubt that a particular amount of computation
- * has been expended in the determination of some token value n.
- * It is utilised to enforce the blockchain security by giving meaning
- * and credence to the notion of difficulty (and, by extension, total difficulty).
- *
- * However, since mining new blocks comes with an attached reward,
- * the proof-of-work not only functions as a method of securing confidence
- * that the blockchain will remain canonical into the future, but also as
+ * that proves beyond reasonable doubt that a particular amount of computation
+ * has been expended in the determination of some token value n.
+ * It is utilised to enforce the blockchain security by giving meaning
+ * and credence to the notion of difficulty (and, by extension, total difficulty).
+ *
+ * However, since mining new blocks comes with an attached reward,
+ * the proof-of-work not only functions as a method of securing confidence
+ * that the blockchain will remain canonical into the future, but also as
* a wealth distribution mechanism.
- *
+ *
* See Yellow Paper: http://www.gavwood.com/Paper.pdf (chapter 11.5 Mining Proof-of-Work)
*/
public class Miner {
@@ -36,13 +36,13 @@ public class Miner {
/**
* Adds a nonce to given block which complies with the given difficulty
- *
- * For the PoC series, we use a simplified proof-of-work.
- * This is not ASIC resistant and is meant merely as a placeholder.
- * It utilizes the bare SHA3 hash function to secure the block chain by requiring
- * the SHA3 hash of the concatenation of the nonce and the header’s SHA3 hash to be
+ *
+ * For the PoC series, we use a simplified proof-of-work.
+ * This is not ASIC resistant and is meant merely as a placeholder.
+ * It utilizes the bare SHA3 hash function to secure the block chain by requiring
+ * the SHA3 hash of the concatenation of the nonce and the header’s SHA3 hash to be
* sufficiently low. It is formally defined as PoW:
- *
+ *
* PoW(H, n) ≡ BE(SHA3(SHA3(RLP(H!n)) ◦ n))
*
* where:
@@ -54,7 +54,7 @@ public class Miner {
* o is the series concatenation operator;
* BE(X) evaluates to the value equal to X when interpreted as a
* big-endian-encoded integer.
- *
+ *
* @param newBlock without a valid nonce
* @param difficulty - the mining difficulty
* @return true if valid nonce has been added to the block
@@ -76,7 +76,7 @@ public class Miner {
byte[] testNonce = new byte[32];
byte[] concat;
-
+
while(ByteUtil.increment(testNonce) && !stop) {
if (testNonce[31] == 0 && testNonce[30] == 0){
diff --git a/ethereumj-core/src/main/java/org/ethereum/net/BlockQueue.java b/ethereumj-core/src/main/java/org/ethereum/net/BlockQueue.java
index f053265a..b7ff4fae 100644
--- a/ethereumj-core/src/main/java/org/ethereum/net/BlockQueue.java
+++ b/ethereumj-core/src/main/java/org/ethereum/net/BlockQueue.java
@@ -18,8 +18,8 @@ import java.util.concurrent.ConcurrentLinkedQueue;
* The processing queue for blocks to be validated and added to the blockchain.
* This class also maintains the list of hashes from the peer with the heaviest sub-tree.
* Based on these hashes, blocks are added to the queue.
- *
- * @author Roman Mandeleil
+ *
+ * @author Roman Mandeleil
* Created on: 27/07/2014 11:28
*/
@Component
@@ -27,13 +27,13 @@ public class BlockQueue {
private static final Logger logger = LoggerFactory.getLogger("blockqueue");
- /** The list of hashes of the heaviest chain on the network,
+ /** The list of hashes of the heaviest chain on the network,
* for which this client doesn't have the blocks yet */
private Deque blockHashQueue = new ArrayDeque<>();
-
+
/** Queue with blocks to be validated and added to the blockchain */
private Queue blockReceivedQueue = new ConcurrentLinkedQueue<>();
-
+
/** Highest known total difficulty, representing the heaviest chain on the network */
private BigInteger highestTotalDifficulty;
@@ -59,7 +59,7 @@ public class BlockQueue {
private void nudgeQueue() {
if (blockReceivedQueue.isEmpty())
return;
-
+
logger.info("BlockQueue size: {}", blockReceivedQueue.size());
while(!blockReceivedQueue.isEmpty()){
Block block = blockReceivedQueue.poll();
@@ -74,10 +74,10 @@ public class BlockQueue {
* Add a list of blocks to the processing queue.
* The list is validated by making sure the first block in the received list of blocks
* is the next expected block number of the queue.
- *
+ *
* The queue is configured to contain a maximum number of blocks to avoid memory issues
* If the list exceeds that, the rest of the received blocks in the list are discarded.
- *
+ *
* @param blockList - the blocks received from a peer to be added to the queue
*/
public void addBlocks(List blockList) {
@@ -104,13 +104,13 @@ public class BlockQueue {
blockReceivedQueue.size(),
lastBlock.getNumber());
}
-
+
/**
- * Returns the last block in the queue. If the queue is empty,
+ * Returns the last block in the queue. If the queue is empty,
* this will return the last block added to the blockchain.
- *
+ *
* @return The last known block this client on the network
- * and will never return null as there is
+ * and will never return null as there is
* always the Genesis block at the start of the chain.
*/
public Block getLastBlock() {
@@ -122,7 +122,7 @@ public class BlockQueue {
/**
* Reset the queue of hashes of blocks to be retrieved
* and add the best hash to the top of the queue
- *
+ *
* @param hash - the best hash
*/
public void setBestHash(byte[] hash) {
@@ -131,9 +131,9 @@ public class BlockQueue {
}
/**
- * Returns the last added hash to the queue representing
+ * Returns the last added hash to the queue representing
* the latest known block on the network
- *
+ *
* @return The best hash on the network known to the client
*/
public byte[] getBestHash() {
@@ -158,10 +158,10 @@ public class BlockQueue {
public void addNewBlockHash(byte[] hash){
blockHashQueue.addFirst(hash);
}
-
+
/**
* Return a list of hashes from blocks that still need to be downloaded.
- *
+ *
* @return A list of hashes for which blocks need to be retrieved.
*/
public List getHashes() {
@@ -195,7 +195,7 @@ public class BlockQueue {
return 0;
}
}
-
+
public BigInteger getHighestTotalDifficulty() {
return highestTotalDifficulty;
}
@@ -206,7 +206,7 @@ public class BlockQueue {
/**
* Returns the current number of blocks in the queue
- *
+ *
* @return the current number of blocks in the queue
*/
public int size() {
@@ -223,7 +223,7 @@ public class BlockQueue {
}
/**
- * Cancel and purge the timer-thread that
+ * Cancel and purge the timer-thread that
* processes the blocks in the queue
*/
public void close() {
diff --git a/ethereumj-core/src/main/java/org/ethereum/net/MessageRoundtrip.java b/ethereumj-core/src/main/java/org/ethereum/net/MessageRoundtrip.java
index 840a5efc..30ba0f5f 100644
--- a/ethereumj-core/src/main/java/org/ethereum/net/MessageRoundtrip.java
+++ b/ethereumj-core/src/main/java/org/ethereum/net/MessageRoundtrip.java
@@ -7,7 +7,7 @@ import org.ethereum.net.message.Message;
* been offered This class also contains the last time a message was offered and
* is updated when an answer has been received to it can be removed from the
* queue.
- *
+ *
* @author Roman Mandeleil
*/
public class MessageRoundtrip {
diff --git a/ethereumj-core/src/main/java/org/ethereum/net/client/Capability.java b/ethereumj-core/src/main/java/org/ethereum/net/client/Capability.java
index 8037f597..63c44833 100644
--- a/ethereumj-core/src/main/java/org/ethereum/net/client/Capability.java
+++ b/ethereumj-core/src/main/java/org/ethereum/net/client/Capability.java
@@ -8,7 +8,7 @@ public class Capability implements Comparable {
public final static String P2P = "p2p";
public final static String ETH = "eth";
public final static String SHH = "shh";
-
+
private String name;
private byte version;
@@ -16,7 +16,7 @@ public class Capability implements Comparable {
this.name = name;
this.version = version;
}
-
+
public String getName() {
return name;
}
@@ -24,7 +24,7 @@ public class Capability implements Comparable {
public byte getVersion() {
return version;
}
-
+
@Override
public boolean equals(Object obj) {
if (this == obj) return true;
@@ -41,7 +41,7 @@ public class Capability implements Comparable {
public int compareTo(Capability o) {
return this.name.compareTo(o.name);
}
-
+
public String toString() {
return name + ":" + version;
}
diff --git a/ethereumj-core/src/main/java/org/ethereum/net/client/PeerClient.java b/ethereumj-core/src/main/java/org/ethereum/net/client/PeerClient.java
index 7820b52b..664a7be5 100644
--- a/ethereumj-core/src/main/java/org/ethereum/net/client/PeerClient.java
+++ b/ethereumj-core/src/main/java/org/ethereum/net/client/PeerClient.java
@@ -50,12 +50,12 @@ public class PeerClient {
Bootstrap b = new Bootstrap();
b.group(workerGroup);
b.channel(NioSocketChannel.class);
-
+
b.option(ChannelOption.SO_KEEPALIVE, true);
b.option(ChannelOption.MESSAGE_SIZE_ESTIMATOR, DefaultMessageSizeEstimator.DEFAULT);
b.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, CONFIG.peerConnectionTimeout());
b.remoteAddress(host, port);
-
+
b.handler(ethereumChannelInitializer);
// Start the client.
diff --git a/ethereumj-core/src/main/java/org/ethereum/net/eth/BlockHashesMessage.java b/ethereumj-core/src/main/java/org/ethereum/net/eth/BlockHashesMessage.java
index e1838136..719fb3da 100644
--- a/ethereumj-core/src/main/java/org/ethereum/net/eth/BlockHashesMessage.java
+++ b/ethereumj-core/src/main/java/org/ethereum/net/eth/BlockHashesMessage.java
@@ -76,7 +76,7 @@ public class BlockHashesMessage extends EthMessage {
@Override
public String toString() {
if (!parsed) parse();
-
+
StringBuffer sb = Utils.getHashlistShort(this.blockHashes);
return "[" + this.getCommand().name() + sb.toString() + "] (" + this.blockHashes.size() + ")";
}
diff --git a/ethereumj-core/src/main/java/org/ethereum/net/eth/EthMessage.java b/ethereumj-core/src/main/java/org/ethereum/net/eth/EthMessage.java
index 070011eb..9bad0f09 100644
--- a/ethereumj-core/src/main/java/org/ethereum/net/eth/EthMessage.java
+++ b/ethereumj-core/src/main/java/org/ethereum/net/eth/EthMessage.java
@@ -4,7 +4,7 @@ import org.ethereum.net.eth.EthMessageCodes;
import org.ethereum.net.message.Message;
public abstract class EthMessage extends Message {
-
+
public EthMessage() {}
public EthMessage(byte[] encoded) {
diff --git a/ethereumj-core/src/main/java/org/ethereum/net/eth/EthMessageCodes.java b/ethereumj-core/src/main/java/org/ethereum/net/eth/EthMessageCodes.java
index e84b718e..286f5349 100644
--- a/ethereumj-core/src/main/java/org/ethereum/net/eth/EthMessageCodes.java
+++ b/ethereumj-core/src/main/java/org/ethereum/net/eth/EthMessageCodes.java
@@ -7,7 +7,7 @@ import java.util.Map;
* A list of commands for the Ethereum network protocol.
*
* The codes for these commands are the first byte in every packet.
- *
+ *
* @see
* https://github.com/ethereum/wiki/wiki/Ethereum-Wire-Protocol
*/
@@ -56,8 +56,8 @@ public enum EthMessageCodes {
/**
* [+0x07 [blockHeader, transactionList, uncleList], totalDifficulty]
- * Specify a single block that the peer should know about. The composite item
- * in the list (following the message ID) is a block in the format described
+ * Specify a single block that the peer should know about. The composite item
+ * in the list (following the message ID) is a block in the format described
* in the main Ethereum specification. */
NEW_BLOCK(0x07),
diff --git a/ethereumj-core/src/main/java/org/ethereum/net/eth/GetBlockHashesMessage.java b/ethereumj-core/src/main/java/org/ethereum/net/eth/GetBlockHashesMessage.java
index 7eae53a1..0c2f6b6b 100644
--- a/ethereumj-core/src/main/java/org/ethereum/net/eth/GetBlockHashesMessage.java
+++ b/ethereumj-core/src/main/java/org/ethereum/net/eth/GetBlockHashesMessage.java
@@ -9,15 +9,15 @@ import org.spongycastle.util.encoders.Hex;
/**
* Wrapper around an Ethereum GetBlockHashes message on the network
- *
+ *
* @see org.ethereum.net.eth.EthMessageCodes#GET_BLOCK_HASHES
*/
public class GetBlockHashesMessage extends EthMessage {
/** The newest block hash from which to start sending older hashes */
private byte[] bestHash;
-
- /** The maximum number of blocks to return.
+
+ /** The maximum number of blocks to return.
* Note: the peer could return fewer. */
private int maxBlocks;
@@ -80,8 +80,8 @@ public class GetBlockHashesMessage extends EthMessage {
@Override
public String toString() {
if (!parsed) parse();
- return "[" + this.getCommand().name() +
- " bestHash=" + Hex.toHexString(bestHash) +
+ return "[" + this.getCommand().name() +
+ " bestHash=" + Hex.toHexString(bestHash) +
" maxBlocks=" + maxBlocks + "]";
}
}
\ No newline at end of file
diff --git a/ethereumj-core/src/main/java/org/ethereum/net/eth/GetBlocksMessage.java b/ethereumj-core/src/main/java/org/ethereum/net/eth/GetBlocksMessage.java
index c2920773..8db2431b 100644
--- a/ethereumj-core/src/main/java/org/ethereum/net/eth/GetBlocksMessage.java
+++ b/ethereumj-core/src/main/java/org/ethereum/net/eth/GetBlocksMessage.java
@@ -12,7 +12,7 @@ import static org.ethereum.net.eth.EthMessageCodes.GET_BLOCKS;
/**
* Wrapper around an Ethereum GetBlocks message on the network
- *
+ *
* @see org.ethereum.net.eth.EthMessageCodes#GET_BLOCKS
*/
public class GetBlocksMessage extends EthMessage {
diff --git a/ethereumj-core/src/main/java/org/ethereum/net/eth/GetTransactionsMessage.java b/ethereumj-core/src/main/java/org/ethereum/net/eth/GetTransactionsMessage.java
index 0079b3c3..c4eff242 100644
--- a/ethereumj-core/src/main/java/org/ethereum/net/eth/GetTransactionsMessage.java
+++ b/ethereumj-core/src/main/java/org/ethereum/net/eth/GetTransactionsMessage.java
@@ -6,12 +6,12 @@ import org.spongycastle.util.encoders.Hex;
/**
* Wrapper around an Ethereum GetTransactions message on the network
- *
+ *
* @see org.ethereum.net.eth.EthMessageCodes#GET_TRANSACTIONS
*/
public class GetTransactionsMessage extends EthMessage {
- /** GetTransactions message is always a the same single command payload */
+ /** GetTransactions message is always a the same single command payload */
private final static byte[] FIXED_PAYLOAD = Hex.decode("C116");
public byte[] getEncoded() {
diff --git a/ethereumj-core/src/main/java/org/ethereum/net/eth/NewBlockMessage.java b/ethereumj-core/src/main/java/org/ethereum/net/eth/NewBlockMessage.java
index f5d7e83d..4389b9cb 100644
--- a/ethereumj-core/src/main/java/org/ethereum/net/eth/NewBlockMessage.java
+++ b/ethereumj-core/src/main/java/org/ethereum/net/eth/NewBlockMessage.java
@@ -7,7 +7,7 @@ import org.spongycastle.util.encoders.Hex;
/**
* Wrapper around an Ethereum Blocks message on the network
- *
+ *
* @see org.ethereum.net.eth.EthMessageCodes#NEW_BLOCK
*/
public class NewBlockMessage extends EthMessage {
@@ -48,7 +48,7 @@ public class NewBlockMessage extends EthMessage {
if (!parsed) parse();
return block;
}
-
+
public byte[] getDifficulty(){
if (!parsed) parse();
return difficulty;
diff --git a/ethereumj-core/src/main/java/org/ethereum/net/eth/StatusMessage.java b/ethereumj-core/src/main/java/org/ethereum/net/eth/StatusMessage.java
index 5dba278c..ef6efc85 100644
--- a/ethereumj-core/src/main/java/org/ethereum/net/eth/StatusMessage.java
+++ b/ethereumj-core/src/main/java/org/ethereum/net/eth/StatusMessage.java
@@ -9,8 +9,8 @@ import org.spongycastle.util.encoders.Hex;
import static org.ethereum.net.eth.EthMessageCodes.STATUS;
/**
- * Wrapper around an Ethereum Status message on the network
- *
+ * Wrapper around an Ethereum Status message on the network
+ *
* @see org.ethereum.net.eth.EthMessageCodes#STATUS
*/
public class StatusMessage extends EthMessage {
diff --git a/ethereumj-core/src/main/java/org/ethereum/net/eth/TransactionsMessage.java b/ethereumj-core/src/main/java/org/ethereum/net/eth/TransactionsMessage.java
index 8d00e3e2..953cec13 100644
--- a/ethereumj-core/src/main/java/org/ethereum/net/eth/TransactionsMessage.java
+++ b/ethereumj-core/src/main/java/org/ethereum/net/eth/TransactionsMessage.java
@@ -13,12 +13,12 @@ import java.util.List;
import java.util.Set;
/**
- * Wrapper around an Ethereum Transactions message on the network
- *
+ * Wrapper around an Ethereum Transactions message on the network
+ *
* @see org.ethereum.net.eth.EthMessageCodes#TRANSACTIONS
*/
public class TransactionsMessage extends EthMessage {
-
+
private Set transactions;
public TransactionsMessage(byte[] encoded) {
@@ -36,7 +36,7 @@ public class TransactionsMessage extends EthMessage {
this.transactions = transactionList;
parsed = true;
}
-
+
private void parse() {
RLPList paramsList = (RLPList) RLP.decode2(encoded).get(0);
@@ -48,7 +48,7 @@ public class TransactionsMessage extends EthMessage {
}
parsed = true;
}
-
+
private void encode() {
List encodedElements = new ArrayList<>();
encodedElements.add(RLP.encodeByte(TRANSACTIONS.asByte()));
@@ -58,7 +58,7 @@ public class TransactionsMessage extends EthMessage {
.toArray(new byte[encodedElements.size()][]);
this.encoded = RLP.encodeList(encodedElementArray);
}
-
+
@Override
public byte[] getEncoded() {
if (encoded == null) encode();
@@ -80,7 +80,7 @@ public class TransactionsMessage extends EthMessage {
public Class> getAnswerMessage() {
return null;
}
-
+
public String toString() {
if(!parsed) parse();
StringBuffer sb = new StringBuffer();
diff --git a/ethereumj-core/src/main/java/org/ethereum/net/message/Message.java b/ethereumj-core/src/main/java/org/ethereum/net/message/Message.java
index 1ac0f4da..27ff07ce 100644
--- a/ethereumj-core/src/main/java/org/ethereum/net/message/Message.java
+++ b/ethereumj-core/src/main/java/org/ethereum/net/message/Message.java
@@ -2,7 +2,7 @@ package org.ethereum.net.message;
/**
* Abstract message class for all messages on the Ethereum network
- *
+ *
* @author Roman Mandeleil
* Created on: 06/04/14 14:58
*/
@@ -18,19 +18,19 @@ public abstract class Message {
this.encoded = encoded;
parsed = false;
}
-
+
/**
* Gets the RLP encoded byte array of this message
- *
+ *
* @return RLP encoded byte array representation of this message
*/
public abstract byte[] getEncoded();
-
+
public abstract Class> getAnswerMessage();
-
+
/**
* Returns the message in String format
- *
+ *
* @return A string with all attributes of the message
*/
public abstract String toString();
diff --git a/ethereumj-core/src/main/java/org/ethereum/net/message/ReasonCode.java b/ethereumj-core/src/main/java/org/ethereum/net/message/ReasonCode.java
index 80bdfd98..05cbc32c 100644
--- a/ethereumj-core/src/main/java/org/ethereum/net/message/ReasonCode.java
+++ b/ethereumj-core/src/main/java/org/ethereum/net/message/ReasonCode.java
@@ -4,61 +4,61 @@ import java.util.HashMap;
import java.util.Map;
/**
- * Reason is an optional integer specifying one
- * of a number of reasons for disconnect
+ * Reason is an optional integer specifying one
+ * of a number of reasons for disconnect
*/
public enum ReasonCode {
/** [0x00] Disconnect request by other peer */
REQUESTED(0x00),
-
+
/** [0x01] */
TCP_ERROR(0x01),
-
+
/** [0x02] Packets can not be parsed */
BAD_PROTOCOL(0x02),
-
+
/** [0x03] This peer is too slow or delivers unreliable data */
USELESS_PEER(0x03),
-
+
/** [0x04] Already too many connections with other peers */
TOO_MANY_PEERS(0x04),
-
+
/** [0x05] Already have a running connection with this peer */
ALREADY_CONNECTED(0x05),
-
+
/** [0x06] Version of the p2p protocol is not the same as ours */
INCOMPATIBLE_PROTOCOL(0x06),
-
+
/** [0x07] Peer identifies itself with the wrong networkId */
INCOMPATIBLE_NETWORK(0x07),
-
+
/** [0x08] Peer quit voluntarily */
PEER_QUITING(0x08),
-
+
/** [0xFF] Reason not specified */
UNKNOWN(0xFF);
private int reason;
-
+
private static final Map intToTypeMap = new HashMap<>();
static {
for (ReasonCode type : ReasonCode.values()) {
intToTypeMap.put(type.reason, type);
}
}
-
+
private ReasonCode(int reason) {
this.reason = reason;
}
-
+
public static ReasonCode fromInt(int i) {
ReasonCode type = intToTypeMap.get(Integer.valueOf(i));
- if (type == null)
+ if (type == null)
return ReasonCode.UNKNOWN;
return type;
}
-
+
public byte asByte() {
return (byte) reason;
}
diff --git a/ethereumj-core/src/main/java/org/ethereum/net/message/StaticMessages.java b/ethereumj-core/src/main/java/org/ethereum/net/message/StaticMessages.java
index 1c29524c..0cffa5a2 100644
--- a/ethereumj-core/src/main/java/org/ethereum/net/message/StaticMessages.java
+++ b/ethereumj-core/src/main/java/org/ethereum/net/message/StaticMessages.java
@@ -19,14 +19,14 @@ import org.spongycastle.util.encoders.Hex;
/**
* This class contains static values of messages on the network. These message
* will always be the same and therefore don't need to be created each time.
- *
+ *
* @author Roman Mandeleil
* Created on: 13/04/14 20:19
*/
public class StaticMessages {
public static final String PEER_ID = Hex.toHexString(HashUtil.randomPeerId());
-
+
public final static PingMessage PING_MESSAGE = new PingMessage();
public final static PongMessage PONG_MESSAGE = new PongMessage();
public final static HelloMessage HELLO_MESSAGE = generateHelloMessage();
@@ -43,7 +43,7 @@ public class StaticMessages {
new Capability(Capability.SHH, ShhHandler.VERSION));
int listenPort = SystemProperties.CONFIG.listenPort();
- return new HelloMessage(p2pVersion, helloAnnouncement,
+ return new HelloMessage(p2pVersion, helloAnnouncement,
capabilities, listenPort, PEER_ID);
}
diff --git a/ethereumj-core/src/main/java/org/ethereum/net/p2p/GetPeersMessage.java b/ethereumj-core/src/main/java/org/ethereum/net/p2p/GetPeersMessage.java
index fcfdcd06..b93020b2 100644
--- a/ethereumj-core/src/main/java/org/ethereum/net/p2p/GetPeersMessage.java
+++ b/ethereumj-core/src/main/java/org/ethereum/net/p2p/GetPeersMessage.java
@@ -4,7 +4,7 @@ import org.spongycastle.util.encoders.Hex;
/**
* Wrapper around an Ethereum GetPeers message on the network
- *
+ *
* @see org.ethereum.net.p2p.P2pMessageCodes#GET_PEERS
*/
public class GetPeersMessage extends P2pMessage {
diff --git a/ethereumj-core/src/main/java/org/ethereum/net/p2p/HelloMessage.java b/ethereumj-core/src/main/java/org/ethereum/net/p2p/HelloMessage.java
index ea68263b..c78e6a7b 100644
--- a/ethereumj-core/src/main/java/org/ethereum/net/p2p/HelloMessage.java
+++ b/ethereumj-core/src/main/java/org/ethereum/net/p2p/HelloMessage.java
@@ -15,7 +15,7 @@ import java.util.List;
/**
* Wrapper around an Ethereum HelloMessage on the network
- *
+ *
* @see org.ethereum.net.p2p.P2pMessageCodes#HELLO
*/
public class HelloMessage extends P2pMessage {
@@ -24,7 +24,7 @@ public class HelloMessage extends P2pMessage {
private byte p2pVersion;
/** The underlying client. A user-readable string. */
private String clientId;
- /** A peer-network capability code, readable ASCII and 3 letters.
+ /** A peer-network capability code, readable ASCII and 3 letters.
* Currently only "eth", "shh" and "bzz" are known. */
private List capabilities;
/** The port on which the peer is listening for an incoming connection */
@@ -64,10 +64,10 @@ public class HelloMessage extends P2pMessage {
RLPElement capId = ((RLPList)capabilityList.get(i)).get(0);
RLPElement capVersion = ((RLPList)capabilityList.get(i)).get(1);
-
+
String name = new String(capId.getRLPData());
byte version = capVersion.getRLPData() == null ? 0 : capVersion.getRLPData()[0];
-
+
Capability cap = new Capability(name, version);
this.capabilities.add(cap);
}
diff --git a/ethereumj-core/src/main/java/org/ethereum/net/p2p/P2pHandler.java b/ethereumj-core/src/main/java/org/ethereum/net/p2p/P2pHandler.java
index e37b3c65..cc5c435e 100644
--- a/ethereumj-core/src/main/java/org/ethereum/net/p2p/P2pHandler.java
+++ b/ethereumj-core/src/main/java/org/ethereum/net/p2p/P2pHandler.java
@@ -32,7 +32,7 @@ import org.springframework.stereotype.Component;
/**
* Process the basic protocol messages between every peer on the network.
- *
+ *
* Peers can send/receive
*
*
HELLO : Announce themselves to the network
@@ -48,7 +48,7 @@ import org.springframework.stereotype.Component;
public class P2pHandler extends SimpleChannelInboundHandler {
public final static byte VERSION = 2;
-
+
private final static Logger logger = LoggerFactory.getLogger("net");
private final Timer timer = new Timer("MessageTimer");
@@ -69,7 +69,7 @@ public class P2pHandler extends SimpleChannelInboundHandler {
this.peerDiscoveryMode = false;
}
-
+
public P2pHandler(MessageQueue msgQueue, boolean peerDiscoveryMode) {
this.msgQueue = msgQueue;
this.peerDiscoveryMode = peerDiscoveryMode;
@@ -167,7 +167,7 @@ public class P2pHandler extends SimpleChannelInboundHandler {
ctx.close();
killTimers();
}
-
+
private void processPeers(ChannelHandlerContext ctx, PeersMessage peersMessage) {
worldManager.getPeerDiscovery().addPeers(peersMessage.getPeers());
}
@@ -264,7 +264,7 @@ public class P2pHandler extends SimpleChannelInboundHandler {
if (capability.getName().equals(Capability.ETH)) {
EthMessageCodes.setOffset(offset);
offset += EthMessageCodes.values().length;
- }
+ }
if (capability.getName().equals(Capability.SHH)) {
ShhMessageCodes.setOffset(offset);
@@ -295,7 +295,7 @@ public class P2pHandler extends SimpleChannelInboundHandler {
}, 500, 25000);
*/
}
-
+
public void killTimers(){
timer.cancel();
timer.purge();
diff --git a/ethereumj-core/src/main/java/org/ethereum/net/p2p/Peer.java b/ethereumj-core/src/main/java/org/ethereum/net/p2p/Peer.java
index e181e2d2..45c15daa 100644
--- a/ethereumj-core/src/main/java/org/ethereum/net/p2p/Peer.java
+++ b/ethereumj-core/src/main/java/org/ethereum/net/p2p/Peer.java
@@ -57,7 +57,7 @@ public class Peer {
@Override
public String toString() {
- return "[ip=" + getAddress().getHostAddress() +
+ return "[ip=" + getAddress().getHostAddress() +
" port=" + getPort()
+ " peerId=" + getPeerId() + "]";
}
diff --git a/ethereumj-core/src/main/java/org/ethereum/net/p2p/PeersMessage.java b/ethereumj-core/src/main/java/org/ethereum/net/p2p/PeersMessage.java
index d525f4c0..eacc6b84 100644
--- a/ethereumj-core/src/main/java/org/ethereum/net/p2p/PeersMessage.java
+++ b/ethereumj-core/src/main/java/org/ethereum/net/p2p/PeersMessage.java
@@ -16,7 +16,7 @@ import org.spongycastle.util.encoders.Hex;
/**
* Wrapper around an Ethereum Peers message on the network
- *
+ *
* @see org.ethereum.net.p2p.P2pMessageCodes#PEERS
*/
public class PeersMessage extends P2pMessage {
diff --git a/ethereumj-core/src/main/java/org/ethereum/net/p2p/PingMessage.java b/ethereumj-core/src/main/java/org/ethereum/net/p2p/PingMessage.java
index c66a8e9c..3252a1d3 100644
--- a/ethereumj-core/src/main/java/org/ethereum/net/p2p/PingMessage.java
+++ b/ethereumj-core/src/main/java/org/ethereum/net/p2p/PingMessage.java
@@ -4,7 +4,7 @@ import org.spongycastle.util.encoders.Hex;
/**
* Wrapper around an Ethereum Ping message on the network
- *
+ *
* @see org.ethereum.net.p2p.P2pMessageCodes#PING
*/
public class PingMessage extends P2pMessage {
diff --git a/ethereumj-core/src/main/java/org/ethereum/net/p2p/PongMessage.java b/ethereumj-core/src/main/java/org/ethereum/net/p2p/PongMessage.java
index a93d4c06..5b50ea8d 100644
--- a/ethereumj-core/src/main/java/org/ethereum/net/p2p/PongMessage.java
+++ b/ethereumj-core/src/main/java/org/ethereum/net/p2p/PongMessage.java
@@ -5,7 +5,7 @@ import org.spongycastle.util.encoders.Hex;
/**
* Wrapper around an Ethereum Pong message on the network
- *
+ *
* @see org.ethereum.net.p2p.P2pMessageCodes#PONG
*/
public class PongMessage extends P2pMessage {
diff --git a/ethereumj-core/src/main/java/org/ethereum/net/peerdiscovery/DiscoveryChannel.java b/ethereumj-core/src/main/java/org/ethereum/net/peerdiscovery/DiscoveryChannel.java
index b69b05a0..03aaec99 100644
--- a/ethereumj-core/src/main/java/org/ethereum/net/peerdiscovery/DiscoveryChannel.java
+++ b/ethereumj-core/src/main/java/org/ethereum/net/peerdiscovery/DiscoveryChannel.java
@@ -72,7 +72,7 @@ public class DiscoveryChannel {
Bootstrap b = new Bootstrap();
b.group(workerGroup);
b.channel(NioSocketChannel.class);
-
+
b.option(ChannelOption.SO_KEEPALIVE, true);
b.option(ChannelOption.MESSAGE_SIZE_ESTIMATOR, DefaultMessageSizeEstimator.DEFAULT);
b.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, CONFIG.peerConnectionTimeout());
diff --git a/ethereumj-core/src/main/java/org/ethereum/net/peerdiscovery/PeerDiscovery.java b/ethereumj-core/src/main/java/org/ethereum/net/peerdiscovery/PeerDiscovery.java
index 20c033a6..0b07ab52 100644
--- a/ethereumj-core/src/main/java/org/ethereum/net/peerdiscovery/PeerDiscovery.java
+++ b/ethereumj-core/src/main/java/org/ethereum/net/peerdiscovery/PeerDiscovery.java
@@ -25,7 +25,7 @@ public class PeerDiscovery {
private static final Logger logger = LoggerFactory.getLogger("peerdiscovery");
private final Set peers = Collections.synchronizedSet(new HashSet());
-
+
private PeerMonitorThread monitor;
private ThreadFactory threadFactory;
private ThreadPoolExecutor executorPool;
@@ -77,11 +77,11 @@ public class PeerDiscovery {
public boolean isStarted() {
return started.get();
}
-
+
public Set getPeers() {
return peers;
}
-
+
/**
* Update list of known peers with new peers
* This method checks for duplicate peer id's and addresses
diff --git a/ethereumj-core/src/main/java/org/ethereum/net/peerdiscovery/RejectionLogger.java b/ethereumj-core/src/main/java/org/ethereum/net/peerdiscovery/RejectionLogger.java
index 521b7442..93406db5 100644
--- a/ethereumj-core/src/main/java/org/ethereum/net/peerdiscovery/RejectionLogger.java
+++ b/ethereumj-core/src/main/java/org/ethereum/net/peerdiscovery/RejectionLogger.java
@@ -9,8 +9,8 @@ import java.util.concurrent.ThreadPoolExecutor;
/**
* A handler to log rejected threads when execution is blocked because the
* thread bounds and queue capacities are reached
- *
- * @author Roman Mandeleil
+ *
+ * @author Roman Mandeleil
* Created on: 22/05/2014 10:31
*/
public class RejectionLogger implements RejectedExecutionHandler {
diff --git a/ethereumj-core/src/main/java/org/ethereum/net/peerdiscovery/WorkerThread.java b/ethereumj-core/src/main/java/org/ethereum/net/peerdiscovery/WorkerThread.java
index 68cd1ae4..7a59cf8f 100644
--- a/ethereumj-core/src/main/java/org/ethereum/net/peerdiscovery/WorkerThread.java
+++ b/ethereumj-core/src/main/java/org/ethereum/net/peerdiscovery/WorkerThread.java
@@ -11,7 +11,7 @@ import org.springframework.stereotype.Component;
import java.util.concurrent.ThreadPoolExecutor;
/**
- * @author Roman Mandeleil
+ * @author Roman Mandeleil
* Created on: 22/05/2014 09:26
*/
@Component
diff --git a/ethereumj-core/src/main/java/org/ethereum/net/server/PeerServer.java b/ethereumj-core/src/main/java/org/ethereum/net/server/PeerServer.java
index 68f6b326..49f98a62 100644
--- a/ethereumj-core/src/main/java/org/ethereum/net/server/PeerServer.java
+++ b/ethereumj-core/src/main/java/org/ethereum/net/server/PeerServer.java
@@ -57,7 +57,7 @@ public class PeerServer {
b.group(bossGroup, workerGroup);
b.channel(NioServerSocketChannel.class);
-
+
b.option(ChannelOption.SO_KEEPALIVE, true);
b.option(ChannelOption.MESSAGE_SIZE_ESTIMATOR, DefaultMessageSizeEstimator.DEFAULT);
b.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, CONFIG.peerConnectionTimeout());
diff --git a/ethereumj-core/src/main/java/org/ethereum/net/shh/ShhHandler.java b/ethereumj-core/src/main/java/org/ethereum/net/shh/ShhHandler.java
index c1bd7509..7ee6925f 100644
--- a/ethereumj-core/src/main/java/org/ethereum/net/shh/ShhHandler.java
+++ b/ethereumj-core/src/main/java/org/ethereum/net/shh/ShhHandler.java
@@ -12,7 +12,7 @@ import org.springframework.stereotype.Component;
/**
* Process the messages between peers with 'shh' capability on the network.
- *
+ *
* Peers with 'shh' capability can send/receive:
*
*
@@ -63,7 +63,7 @@ public class ShhHandler extends SimpleChannelInboundHandler {
break;
}
}
-
+
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
logger.error(cause.getCause().toString());
diff --git a/ethereumj-core/src/main/java/org/ethereum/net/shh/ShhMessageCodes.java b/ethereumj-core/src/main/java/org/ethereum/net/shh/ShhMessageCodes.java
index 6e583a00..817bb1e0 100644
--- a/ethereumj-core/src/main/java/org/ethereum/net/shh/ShhMessageCodes.java
+++ b/ethereumj-core/src/main/java/org/ethereum/net/shh/ShhMessageCodes.java
@@ -7,7 +7,7 @@ import java.util.Map;
* A list of commands for the Whisper network protocol.
*
* The codes for these commands are the first byte in every packet.
- *
+ *
* @see
* https://github.com/ethereum/wiki/wiki/Wire-Protocol
*/
diff --git a/ethereumj-core/src/main/java/org/ethereum/net/wire/MessageDecoder.java b/ethereumj-core/src/main/java/org/ethereum/net/wire/MessageDecoder.java
index 7b95f4b9..510e84d1 100644
--- a/ethereumj-core/src/main/java/org/ethereum/net/wire/MessageDecoder.java
+++ b/ethereumj-core/src/main/java/org/ethereum/net/wire/MessageDecoder.java
@@ -39,7 +39,7 @@ public class MessageDecoder extends ByteToMessageDecoder {
byte[] encoded = new byte[in.readInt()];
in.readBytes(encoded);
-
+
if (loggerWire.isDebugEnabled())
loggerWire.debug("Encoded: [{}]", Hex.toHexString(encoded));
@@ -54,7 +54,7 @@ public class MessageDecoder extends ByteToMessageDecoder {
out.add(msg);
in.markReaderIndex();
}
-
+
private boolean isValidEthereumPacket(ByteBuf in) {
// Ethereum message is at least 8 bytes
if (in.readableBytes() < 8)
diff --git a/ethereumj-core/src/main/java/org/ethereum/net/wire/MessageEncoder.java b/ethereumj-core/src/main/java/org/ethereum/net/wire/MessageEncoder.java
index fd6befaf..8cb3fa28 100644
--- a/ethereumj-core/src/main/java/org/ethereum/net/wire/MessageEncoder.java
+++ b/ethereumj-core/src/main/java/org/ethereum/net/wire/MessageEncoder.java
@@ -39,10 +39,10 @@ public class MessageEncoder extends MessageToByteEncoder {
loggerNet.info("To: \t{} \tSend: \t{}", ctx.channel().remoteAddress(), msg);
byte[] encoded = msg.getEncoded();
-
+
if (loggerWire.isDebugEnabled())
loggerWire.debug("Encoded: [{}]", Hex.toHexString(encoded));
-
+
out.capacity(encoded.length + 8);
out.writeBytes(StaticMessages.SYNC_TOKEN);
out.writeBytes(ByteUtil.calcPacketLength(encoded));
diff --git a/ethereumj-core/src/main/java/org/ethereum/serpent/SerpentCompiler.java b/ethereumj-core/src/main/java/org/ethereum/serpent/SerpentCompiler.java
index de1a1382..1f2ff17a 100644
--- a/ethereumj-core/src/main/java/org/ethereum/serpent/SerpentCompiler.java
+++ b/ethereumj-core/src/main/java/org/ethereum/serpent/SerpentCompiler.java
@@ -124,7 +124,7 @@ public class SerpentCompiler {
// encode ref for 5 bytes
for (int i = 0; i < lexaList.size(); ++i) {
-
+
String lexa = lexaList.get(i);
if (!lexa.contains("REF_")) continue;
lexaList.add(i + 1, lexa);
diff --git a/ethereumj-core/src/main/java/org/ethereum/trie/Cache.java b/ethereumj-core/src/main/java/org/ethereum/trie/Cache.java
index d3db0e1b..a8409552 100644
--- a/ethereumj-core/src/main/java/org/ethereum/trie/Cache.java
+++ b/ethereumj-core/src/main/java/org/ethereum/trie/Cache.java
@@ -15,7 +15,7 @@ import org.iq80.leveldb.WriteBatch;
* Created on: 20/05/2014 10:44
*/
public class Cache {
-
+
private Map nodes = new ConcurrentHashMap<>();
private DB db;
private boolean isDirty;
@@ -26,8 +26,8 @@ public class Cache {
/**
* Put the node in the cache if RLP encoded value is longer than 32 bytes
- *
- * @param o the Node which could be a pair-, multi-item Node or single Value
+ *
+ * @param o the Node which could be a pair-, multi-item Node or single Value
* @return sha3 hash of RLP encoded node if length > 32 otherwise return node itself
*/
public Object put(Object o) {
diff --git a/ethereumj-core/src/main/java/org/ethereum/trie/Node.java b/ethereumj-core/src/main/java/org/ethereum/trie/Node.java
index f0318ef9..670a6458 100644
--- a/ethereumj-core/src/main/java/org/ethereum/trie/Node.java
+++ b/ethereumj-core/src/main/java/org/ethereum/trie/Node.java
@@ -3,40 +3,40 @@ package org.ethereum.trie;
import org.ethereum.util.Value;
-/**
+/**
* A Node in a Merkle Patricia Tree is one of the following:
- *
+ *
* - NULL (represented as the empty string)
* - A two-item array [ key, value ] (1 key for 2-item array)
* - A 17-item array [ v0 ... v15, vt ] (16 keys for 17-item array)
- *
- * The idea is that in the event that there is a long path of nodes
- * each with only one element, we shortcut the descent by setting up
- * a [ key, value ] node, where the key gives the hexadecimal path
- * to descend, in the compact encoding described above, and the value
+ *
+ * The idea is that in the event that there is a long path of nodes
+ * each with only one element, we shortcut the descent by setting up
+ * a [ key, value ] node, where the key gives the hexadecimal path
+ * to descend, in the compact encoding described above, and the value
* is just the hash of the node like in the standard radix tree.
- *
+ *
* R
* / \
* / \
* N N
* / \ / \
* L L L L
- * *
- * Also, we add another conceptual change: internal nodes can no longer
- * have values, only leaves with no children of their own can; however,
- * since to be fully generic we want the key/value store to be able to
- * store keys like 'dog' and 'doge' at the same time, we simply add
- * a terminator symbol (16) to the alphabet so there is never a value
- * "en-route" to another value.
- *
+ * *
+ * Also, we add another conceptual change: internal nodes can no longer
+ * have values, only leaves with no children of their own can; however,
+ * since to be fully generic we want the key/value store to be able to
+ * store keys like 'dog' and 'doge' at the same time, we simply add
+ * a terminator symbol (16) to the alphabet so there is never a value
+ * "en-route" to another value.
+ *
* Where a node is referenced inside a node, what is included is:
- *
+ *
* H(rlp.encode(x)) where H(x) = sha3(x) if len(x) >= 32 else x
- *
- * Note that when updating a trie, you will need to store the key/value pair (sha3(x), x)
+ *
+ * Note that when updating a trie, you will need to store the key/value pair (sha3(x), x)
* in a persistent lookup table when you create a node with length >= 32,
- * but if the node is shorter than that then you do not need to store anything
+ * but if the node is shorter than that then you do not need to store anything
* when length < 32 for the obvious reason that the function f(x) = x is reversible.
*
* www.ethereumJ.com
@@ -52,7 +52,7 @@ public class Node {
public Node(Value val) {
this(val, false);
}
-
+
public Node(Value val, boolean dirty) {
this.value = val;
this.dirty = dirty;
@@ -65,11 +65,11 @@ public class Node {
public boolean isDirty() {
return dirty;
}
-
+
public void setDirty(boolean ditry) {
this.dirty = ditry;
}
-
+
public Value getValue() {
return value;
}
diff --git a/ethereumj-core/src/main/java/org/ethereum/trie/Trie.java b/ethereumj-core/src/main/java/org/ethereum/trie/Trie.java
index c0382911..5e1ed68f 100644
--- a/ethereumj-core/src/main/java/org/ethereum/trie/Trie.java
+++ b/ethereumj-core/src/main/java/org/ethereum/trie/Trie.java
@@ -1,14 +1,14 @@
package org.ethereum.trie;
/**
- * Trie interface for the main data structure in Ethereum
+ * Trie interface for the main data structure in Ethereum
* which is used to store both the account state and storage of each account.
*/
public interface Trie {
-
+
/**
* Gets a value from the trie for a given key
- *
+ *
* @param key - any length byte array
* @return an rlp encoded byte array of the stored object
*/
@@ -16,43 +16,43 @@ public interface Trie {
/**
* Insert or update a value in the trie for a specified key
- *
+ *
* @param key - any length byte array
* @param value rlp encoded byte array of the object to store
*/
public void update(byte[] key, byte[] value);
-
+
/**
* Deletes a key/value from the trie for a given key
- *
+ *
* @param key - any length byte array
*/
public void delete(byte[] key);
-
+
/**
* Returns a SHA-3 hash from the top node of the trie
- *
- * @return 32-byte SHA-3 hash representing the entire contents of the trie.
+ *
+ * @return 32-byte SHA-3 hash representing the entire contents of the trie.
*/
public byte[] getRootHash();
-
+
/**
* Set the top node of the trie
- *
+ *
* @param root - 32-byte SHA-3 hash of the root node
*/
public void setRoot(byte[] root);
-
+
/**
* Commit all the changes until now
*/
public void sync();
-
+
/**
* Discard all the changes until now
*/
public void undo();
-
+
public String getTrieDump();
public boolean validate();
diff --git a/ethereumj-core/src/main/java/org/ethereum/trie/TrieImpl.java b/ethereumj-core/src/main/java/org/ethereum/trie/TrieImpl.java
index ed1d0082..8aed929d 100644
--- a/ethereumj-core/src/main/java/org/ethereum/trie/TrieImpl.java
+++ b/ethereumj-core/src/main/java/org/ethereum/trie/TrieImpl.java
@@ -19,19 +19,19 @@ import org.slf4j.LoggerFactory;
import org.spongycastle.util.encoders.Hex;
/**
- * The modified Merkle Patricia tree (trie) provides a persistent data structure
- * to map between arbitrary-length binary data (byte arrays). It is defined in terms of
- * a mutable data structure to map between 256-bit binary fragments and arbitrary-length
- * binary data, typically implemented as a database. The core of the trie, and its sole
- * requirement in terms of the protocol specification is to provide a single value that
- * identifies a given set of key-value pairs, which may either a 32 byte sequence or
- * the empty byte sequence. It is left as an implementation consideration to store and
- * maintain the structure of the trie in a manner the allows effective and efficient
+ * The modified Merkle Patricia tree (trie) provides a persistent data structure
+ * to map between arbitrary-length binary data (byte arrays). It is defined in terms of
+ * a mutable data structure to map between 256-bit binary fragments and arbitrary-length
+ * binary data, typically implemented as a database. The core of the trie, and its sole
+ * requirement in terms of the protocol specification is to provide a single value that
+ * identifies a given set of key-value pairs, which may either a 32 byte sequence or
+ * the empty byte sequence. It is left as an implementation consideration to store and
+ * maintain the structure of the trie in a manner the allows effective and efficient
* realisation of the protocol.
*
- * The trie implements a caching mechanism and will use cached values if they are present.
- * If a node is not present in the cache it will try to fetch it from the database and
- * store the cached value.
+ * The trie implements a caching mechanism and will use cached values if they are present.
+ * If a node is not present in the cache it will try to fetch it from the database and
+ * store the cached value.
*
* Note: the data isn't persisted unless `sync` is explicitly called.
*
@@ -63,7 +63,7 @@ public class TrieImpl implements Trie {
public TrieIterator getIterator() {
return new TrieIterator(this);
}
-
+
public void setCache(Cache cache) {
this.cache = cache;
}
@@ -101,14 +101,14 @@ public class TrieImpl implements Trie {
@Override
public byte[] get(byte[] key) {
- if (logger.isDebugEnabled())
+ if (logger.isDebugEnabled())
logger.debug("Retrieving key {}", Hex.toHexString(key));
byte[] k = binToNibbles(key);
Value c = new Value(this.get(this.root, k));
return (c == null)? null : c.asBytes();
}
-
+
/**
* Insert key/value pair into trie
*
@@ -140,7 +140,7 @@ public class TrieImpl implements Trie {
public void delete(String key) {
this.update(key.getBytes(), "".getBytes());
}
-
+
@Override
public void delete(byte[] key) {
delete(new String(key));
@@ -149,7 +149,7 @@ public class TrieImpl implements Trie {
logger.debug("New root-hash: {}", Hex.toHexString(this.getRootHash()));
}
}
-
+
@Override
public byte[] getRootHash() {
if (root == null
diff --git a/ethereumj-core/src/main/java/org/ethereum/trie/TrieIterator.java b/ethereumj-core/src/main/java/org/ethereum/trie/TrieIterator.java
index c4fb1486..fc9c51b1 100644
--- a/ethereumj-core/src/main/java/org/ethereum/trie/TrieIterator.java
+++ b/ethereumj-core/src/main/java/org/ethereum/trie/TrieIterator.java
@@ -11,7 +11,7 @@ import static org.ethereum.util.CompactEncoder.unpackToNibbles;
* Created on: 20/05/2014 10:44
*/
public class TrieIterator {
-
+
private TrieImpl trie;
private String key;
private String value;
@@ -73,9 +73,9 @@ public class TrieIterator {
public int purge() {
List shas = this.collect();
-
+
for (byte[] sha : shas) {
- this.trie.getCache().delete(sha);
+ this.trie.getCache().delete(sha);
}
return this.values.size();
}
diff --git a/ethereumj-core/src/main/java/org/ethereum/util/ByteUtil.java b/ethereumj-core/src/main/java/org/ethereum/util/ByteUtil.java
index 39038e9e..42852511 100644
--- a/ethereumj-core/src/main/java/org/ethereum/util/ByteUtil.java
+++ b/ethereumj-core/src/main/java/org/ethereum/util/ByteUtil.java
@@ -24,7 +24,7 @@ public class ByteUtil {
}
/**
- * The regular {@link java.math.BigInteger#toByteArray()} method isn't quite what we often need:
+ * The regular {@link java.math.BigInteger#toByteArray()} method isn't quite what we often need:
* it appends a leading zero to indicate that the number is positive and may need padding.
*
* @param b the integer to format into a byte array
@@ -39,23 +39,23 @@ public class ByteUtil {
int start = (biBytes.length == numBytes + 1) ? 1 : 0;
int length = Math.min(biBytes.length, numBytes);
System.arraycopy(biBytes, start, bytes, numBytes - length, length);
- return bytes;
+ return bytes;
}
/**
* Omitting sign indication byte.
*
- * Instead of {@link org.spongycastle.util.BigIntegers#asUnsignedByteArray(BigInteger)}
+ * Instead of {@link org.spongycastle.util.BigIntegers#asUnsignedByteArray(BigInteger)}
* we use this custom method to avoid an empty array in case of BigInteger.ZERO
*
* @param value - any big integer number. A null-value will return null
- * @return A byte array without a leading zero byte if present in the signed encoding.
+ * @return A byte array without a leading zero byte if present in the signed encoding.
* BigInteger.ZERO will return an array with length 1 and byte-value 0.
*/
public static byte[] bigIntegerToBytes(BigInteger value) {
if (value == null)
return null;
-
+
byte[] data = value.toByteArray();
if (data.length != 1 && data[0] == 0) {
@@ -66,10 +66,10 @@ public class ByteUtil {
return data;
}
- /**
+ /**
* Returns the amount of nibbles that match each other from 0 ...
* amount will never be larger than smallest input
- *
+ *
* @param a - first input
* @param b - second input
* @return Number of bytes that match
@@ -84,22 +84,22 @@ public class ByteUtil {
}
return i;
}
-
+
/**
* Converts a long value into a byte array.
- *
+ *
* @param val - long value to convert
* @return byte[] of length 8, representing the long value
*/
public static byte[] longToBytes(long val) {
return ByteBuffer.allocate(8).putLong(val).array();
}
-
+
/**
* Convert a byte-array into a hex String.
- * Works similar to {@link Hex#toHexString}
+ * Works similar to {@link Hex#toHexString}
* but allows for null
- *
+ *
* @param data - byte-array to convert to a hex-string
* @return hex representation of the data.
* Returns an empty String if the input is null
@@ -109,7 +109,7 @@ public class ByteUtil {
public static String toHexString(byte[] data) {
return data == null ? "" : Hex.toHexString(data);
}
-
+
/**
* Calculate packet length
* @param msg byte[]
@@ -124,14 +124,14 @@ public class ByteUtil {
(byte)((msgLen ) & 0xFF)};
return len;
}
-
+
/**
* Cast hex encoded value from byte[] to int
- *
+ *
* Limited to Integer.MAX_VALUE: 2^32-1 (4 bytes)
- *
+ *
* @param b array contains the values
- * @return unsigned positive int value.
+ * @return unsigned positive int value.
*/
public static int byteArrayToInt(byte[] b) {
if (b == null || b.length == 0)
@@ -153,10 +153,10 @@ public class ByteUtil {
return new BigInteger(1, b).longValue();
}
-
+
/**
* Turn nibbles to a pretty looking output string
- *
+ *
* Example. [ 1, 2, 3, 4, 5 ] becomes '\x11\x23\x45'
*
* @param nibbles - getting byte of data [ 04 ] and turning
@@ -171,7 +171,7 @@ public class ByteUtil {
}
return buffer.toString();
}
-
+
public static String oneByteToHexString(byte value) {
String retVal = Integer.toString(value & 0xFF, 16);
if (retVal.length() == 1) retVal = "0" + retVal;
@@ -197,7 +197,7 @@ public class ByteUtil {
if (bytes == 0) ++bytes;
return bytes;
}
-
+
/**
* @param arg - not more that 32 bits
* @return - bytes of the value pad with complete to 32 zeroes
@@ -215,7 +215,7 @@ public class ByteUtil {
else
data = arg.toString().trim().getBytes();
-
+
if (data.length > 32)
throw new RuntimeException("values can't be more than 32 byte");
@@ -304,9 +304,9 @@ public class ByteUtil {
/**
* Utility function to copy a byte array into a new byte array with given size.
- * If the src length is smaller than the given size, the result will be left-padded
+ * If the src length is smaller than the given size, the result will be left-padded
* with zeros.
- *
+ *
* @param value - a BigInteger with a maximum value of 2^256-1
* @return Byte array of given size with a copy of the src
*/
diff --git a/ethereumj-core/src/main/java/org/ethereum/util/CompactEncoder.java b/ethereumj-core/src/main/java/org/ethereum/util/CompactEncoder.java
index 47d75906..5db93a90 100644
--- a/ethereumj-core/src/main/java/org/ethereum/util/CompactEncoder.java
+++ b/ethereumj-core/src/main/java/org/ethereum/util/CompactEncoder.java
@@ -12,29 +12,29 @@ import java.nio.ByteBuffer;
import java.util.HashMap;
import java.util.Map;
-/**
+/**
* Compact encoding of hex sequence with optional terminator
- *
- * The traditional compact way of encoding a hex string is to convert it into binary
- * - that is, a string like 0f1248 would become three bytes 15, 18, 72. However,
- * this approach has one slight problem: what if the length of the hex string is odd?
- * In that case, there is no way to distinguish between, say, 0f1248 and f1248.
- *
- * Additionally, our application in the Merkle Patricia tree requires the additional feature
- * that a hex string can also have a special "terminator symbol" at the end (denoted by the 'T').
- * A terminator symbol can occur only once, and only at the end.
- *
- * An alternative way of thinking about this to not think of there being a terminator symbol,
- * but instead treat bit specifying the existence of the terminator symbol as a bit specifying
+ *
+ * The traditional compact way of encoding a hex string is to convert it into binary
+ * - that is, a string like 0f1248 would become three bytes 15, 18, 72. However,
+ * this approach has one slight problem: what if the length of the hex string is odd?
+ * In that case, there is no way to distinguish between, say, 0f1248 and f1248.
+ *
+ * Additionally, our application in the Merkle Patricia tree requires the additional feature
+ * that a hex string can also have a special "terminator symbol" at the end (denoted by the 'T').
+ * A terminator symbol can occur only once, and only at the end.
+ *
+ * An alternative way of thinking about this to not think of there being a terminator symbol,
+ * but instead treat bit specifying the existence of the terminator symbol as a bit specifying
* that the given node encodes a final node, where the value is an actual value, rather than
* the hash of yet another node.
- *
- * To solve both of these issues, we force the first nibble of the final byte-stream to encode
- * two flags, specifying oddness of length (ignoring the 'T' symbol) and terminator status;
- * these are placed, respectively, into the two lowest significant bits of the first nibble.
+ *
+ * To solve both of these issues, we force the first nibble of the final byte-stream to encode
+ * two flags, specifying oddness of length (ignoring the 'T' symbol) and terminator status;
+ * these are placed, respectively, into the two lowest significant bits of the first nibble.
* In the case of an even-length hex string, we must introduce a second nibble (of value zero)
- * to ensure the hex-string is even in length and thus is representable by a whole number of bytes.
- *
+ * to ensure the hex-string is even in length and thus is representable by a whole number of bytes.
+ *
* Examples:
* > [ 1, 2, 3, 4, 5 ]
* '\x11\x23\x45'
@@ -77,7 +77,7 @@ public class CompactEncoder {
*/
public static byte[] packNibbles(byte[] nibbles) {
int terminator = 0;
-
+
if (nibbles[nibbles.length-1] == TERMINATOR) {
terminator = 1;
nibbles = copyOf(nibbles, nibbles.length-1);
@@ -100,9 +100,9 @@ public class CompactEncoder {
/**
* Unpack a binary string to its nibbles equivalent
- *
+ *
* @param str of binary data
- * @return array of nibbles in byte-format
+ * @return array of nibbles in byte-format
*/
public static byte[] unpackToNibbles(byte[] str) {
byte[] base = binToNibbles(str);
@@ -122,7 +122,7 @@ public class CompactEncoder {
* Transforms a binary array to hexadecimal format + terminator
*
* @param str byte[]
- * @return array with each individual nibble adding a terminator at the end
+ * @return array with each individual nibble adding a terminator at the end
*/
public static byte[] binToNibbles(byte[] str) {
byte[] hexEncoded = encode(str);
diff --git a/ethereumj-core/src/main/java/org/ethereum/util/DecodeResult.java b/ethereumj-core/src/main/java/org/ethereum/util/DecodeResult.java
index 43c59cb6..7bfc4170 100644
--- a/ethereumj-core/src/main/java/org/ethereum/util/DecodeResult.java
+++ b/ethereumj-core/src/main/java/org/ethereum/util/DecodeResult.java
@@ -9,23 +9,23 @@ public class DecodeResult implements Serializable {
private int pos;
private Object decoded;
-
+
public DecodeResult(int pos, Object decoded) {
this.pos = pos;
this.decoded = decoded;
}
-
+
public int getPos() {
return pos;
}
public Object getDecoded() {
return decoded;
}
-
+
public String toString() {
return asString(this.decoded);
}
-
+
private String asString(Object decoded) {
if(decoded instanceof String) {
return (String) decoded;
@@ -37,7 +37,7 @@ public class DecodeResult implements Serializable {
result += asString(item);
}
return result;
- }
+ }
throw new RuntimeException("Not a valid type. Should not occur");
}
}
diff --git a/ethereumj-core/src/main/java/org/ethereum/util/FastByteComparisons.java b/ethereumj-core/src/main/java/org/ethereum/util/FastByteComparisons.java
index d3de4c95..f52c43d3 100644
--- a/ethereumj-core/src/main/java/org/ethereum/util/FastByteComparisons.java
+++ b/ethereumj-core/src/main/java/org/ethereum/util/FastByteComparisons.java
@@ -72,7 +72,7 @@ public abstract class FastByteComparisons {
private static class LexicographicalComparerHolder {
static final String UNSAFE_COMPARER_NAME =
LexicographicalComparerHolder.class.getName() + "$UnsafeComparer";
-
+
static final Comparer BEST_COMPARER = getBestComparer();
/**
* Returns the Unsafe-using Comparer, or falls back to the pure-Java
@@ -91,7 +91,7 @@ public abstract class FastByteComparisons {
return lexicographicalComparerJavaImpl();
}
}
-
+
private enum PureJavaComparer implements Comparer {
INSTANCE;
@@ -116,7 +116,7 @@ public abstract class FastByteComparisons {
return length1 - length2;
}
}
-
+
@SuppressWarnings("unused") // used via reflection
private enum UnsafeComparer implements Comparer {
INSTANCE;
diff --git a/ethereumj-core/src/main/java/org/ethereum/util/LRUMap.java b/ethereumj-core/src/main/java/org/ethereum/util/LRUMap.java
index 8f4148b1..54b1f91f 100644
--- a/ethereumj-core/src/main/java/org/ethereum/util/LRUMap.java
+++ b/ethereumj-core/src/main/java/org/ethereum/util/LRUMap.java
@@ -10,7 +10,7 @@ public class LRUMap extends ConcurrentHashMap {
private static final long serialVersionUID = 1L;
protected final int maxEntries;
-
+
public LRUMap(int initialEntries, int maxEntries) {
super(initialEntries, 0.8f, 3);
this.maxEntries = maxEntries;
diff --git a/ethereumj-core/src/main/java/org/ethereum/util/RLP.java b/ethereumj-core/src/main/java/org/ethereum/util/RLP.java
index 0d09f5ac..d09a91eb 100644
--- a/ethereumj-core/src/main/java/org/ethereum/util/RLP.java
+++ b/ethereumj-core/src/main/java/org/ethereum/util/RLP.java
@@ -19,8 +19,8 @@ import org.ethereum.util.RLPList;
import org.spongycastle.util.encoders.Hex;
/**
- * Recursive Length Prefix (RLP) encoding.
- *
+ * Recursive Length Prefix (RLP) encoding.
+ *
* The purpose of RLP is to encode arbitrarily nested arrays of binary data, and
* RLP is the main encoding method used to serialize objects in Ethereum. The
* only purpose of RLP is to encode structure; encoding specific atomic data
@@ -30,18 +30,18 @@ import org.spongycastle.util.encoders.Hex;
* canonical forms are to either use [[k1,v1],[k2,v2]...] with keys in
* lexicographic order or to use the higher-level Patricia Tree encoding as
* Ethereum does.
- *
+ *
* The RLP encoding function takes in an item. An item is defined as follows:
- *
+ *
* - A string (ie. byte array) is an item - A list of items is an item
- *
+ *
* For example, an empty string is an item, as is the string containing the word
* "cat", a list containing any number of strings, as well as more complex data
* structures like ["cat",["puppy","cow"],"horse",[[]],"pig",[""],"sheep"]. Note
* that in the context of the rest of this article, "string" will be used as a
* synonym for "a certain number of bytes of binary data"; no special encodings
* are used and no knowledge about the content of the strings is implied.
- *
+ *
* See: https://github.com/ethereum/wiki/wiki/%5BEnglish%5D-RLP
*
* www.ethereumJ.com
@@ -57,16 +57,16 @@ public class RLP {
/**
* Reason for threshold according to Vitalik Buterin:
* - 56 bytes maximizes the benefit of both options
- * - if we went with 60 then we would have only had 4 slots for long strings
+ * - if we went with 60 then we would have only had 4 slots for long strings
* so RLP would not have been able to store objects above 4gb
* - if we went with 48 then RLP would be fine for 2^128 space, but that's way too much
* - so 56 and 2^64 space seems like the right place to put the cutoff
* - also, that's where Bitcoin's varint does the cutof
**/
private static int SIZE_THRESHOLD = 56;
-
+
/** RLP encoding rules are defined as follows: */
-
+
/*
* For a single byte whose value is in the [0x00, 0x7f] range, that byte is
* its own RLP encoding.
@@ -110,12 +110,12 @@ public class RLP {
* range of the first byte is thus [0xf8, 0xff].
*/
private static int OFFSET_LONG_LIST = 0xf7;
-
-
+
+
/* ******************************************************
* DECODING *
* ******************************************************/
-
+
private static byte decodeOneByteItem(byte[] data, int index) {
// null item
if ((data[index] & 0xFF) == OFFSET_SHORT_ITEM) {
@@ -183,7 +183,7 @@ public class RLP {
}
return value;
}
-
+
private static String decodeStringItem(byte[] data, int index) {
String value = null;
@@ -281,7 +281,7 @@ public class RLP {
value = valueBytes;
return value;
}
-
+
private static int nextItemLength(byte[] data, int index) {
if (index >= data.length)
@@ -517,7 +517,7 @@ public class RLP {
}
return length;
}
-
+
private static int calcLengthRaw(int lengthOfLength, byte[] msgData, int index) {
byte pow = (byte) (lengthOfLength - 1);
int length = 0;
@@ -527,7 +527,7 @@ public class RLP {
}
return length;
}
-
+
public static byte getCommandCode(byte[] data) {
byte command = 0;
int index = getFirstListElement(data, 0);
@@ -535,7 +535,7 @@ public class RLP {
command = ((int) (command & 0xFF) == OFFSET_SHORT_ITEM) ? 0 : command;
return command;
}
-
+
/**
* Parse wire byte[] message into RLP elements
*
@@ -671,11 +671,11 @@ public class RLP {
throw new RuntimeException("RLP wrong encoding", e);
}
}
-
+
/**
* Reads any RLP encoded byte-array and returns all objects as byte-array or list of byte-arrays
- *
- * @param data RLP encoded byte-array
+ *
+ * @param data RLP encoded byte-array
* @param pos position in the array to start reading
* @return DecodeResult encapsulates the decoded items as a single Object and the final read position
*/
@@ -709,7 +709,7 @@ public class RLP {
throw new RuntimeException("Only byte values between 0x00 and 0xFF are supported, but got: " + prefix);
}
}
-
+
private static DecodeResult decodeList(byte[] data, int pos, int prevPos, int len) {
List