Skip to content

Commit 4403dad

Browse files
committed
add blockchain paramter
1 parent b626fcf commit 4403dad

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

src/main/java/org/tron/core/Blockchain.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public class Blockchain {
4545
*
4646
* @param address wallet address
4747
*/
48-
public Blockchain(String address) {
48+
public Blockchain(String address, String type) {
4949
if (dbExists()) {
5050
logger.info("blockchain already exists.");
5151
System.exit(0);
@@ -89,7 +89,7 @@ public Blockchain(String address) {
8989
.toByteArray();
9090
blockDB.put(LAST_HASH, lastHash);
9191
// put message to consensus 2018/1/2
92-
if (Tron.getPeer().getType().equals(Peer.PEER_SERVER)) {
92+
if (type.equals(Peer.PEER_SERVER)) {
9393
String value = ByteArray.toHexString(genesisBlock.toByteArray());
9494
Message message = new Message(value, Type.BLOCK);
9595
Client.putMessage1(message); // consensus: put message GenesisBlock

src/main/java/org/tron/peer/Peer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,12 @@ private void initBlockchian() {
8686
//blockchain = new Blockchain(ByteArray.toHexString(wallet.getAddress()));
8787
if (this.type.equals(Peer.PEER_SERVER)){
8888
blockchain = new Blockchain(ByteArray.toHexString(wallet
89-
.getAddress()));
89+
.getAddress()), this.type);
9090
}
9191
if (this.type.equals(Peer.PEER_NORMAL)){
9292
//System.out.println("BlockChain loadding ...");
9393
blockchain = new Blockchain(ByteArray.toHexString(wallet
94-
.getAddress()));
94+
.getAddress()), this.type);
9595
Client.loadBlock(this);
9696
}
9797
}

src/test/java/org/tron/core/BlockchainTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public class BlockchainTest {
2626
@Test
2727
public void testBlockchain() {
2828
Blockchain blockchain = new Blockchain
29-
("0304f784e4e7bae517bcab94c3e0c9214fb4ac7ff9d7d5a937d1f40031f87b85");
29+
("0304f784e4e7bae517bcab94c3e0c9214fb4ac7ff9d7d5a937d1f40031f87b85","server");
3030

3131
logger.info("test blockchain: lashHash = {}, currentHash = {}",
3232
ByteArray.toHexString(blockchain.getLastHash()), ByteArray
@@ -56,7 +56,7 @@ public void testBlockchainNew() {
5656

5757
@Test
5858
public void testIterator() {
59-
Blockchain blockchain = new Blockchain("");
59+
Blockchain blockchain = new Blockchain("","server");
6060
Block info = null;
6161
BlockchainIterator bi = new BlockchainIterator(blockchain);
6262
while (bi.hasNext()) {
@@ -88,7 +88,7 @@ public void testDBExists() {
8888
@Test
8989
public void testFindUTXO() {
9090
Blockchain blockchain = new Blockchain
91-
("fd0f3c8ab4877f0fd96cd156b0ad42ea7aa82c31");
91+
("fd0f3c8ab4877f0fd96cd156b0ad42ea7aa82c31","server");
9292
Wallet wallet = new Wallet();
9393
wallet.init();
9494
Transaction transaction = TransactionUtils.newTransaction(wallet,

0 commit comments

Comments
 (0)