File tree Expand file tree Collapse file tree 3 files changed +7
-7
lines changed Expand file tree Collapse file tree 3 files changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -45,7 +45,7 @@ public class Blockchain {
45
45
*
46
46
* @param address wallet address
47
47
*/
48
- public Blockchain (String address ) {
48
+ public Blockchain (String address , String type ) {
49
49
if (dbExists ()) {
50
50
logger .info ("blockchain already exists." );
51
51
System .exit (0 );
@@ -89,7 +89,7 @@ public Blockchain(String address) {
89
89
.toByteArray ();
90
90
blockDB .put (LAST_HASH , lastHash );
91
91
// put message to consensus 2018/1/2
92
- if (Tron . getPeer (). getType () .equals (Peer .PEER_SERVER )) {
92
+ if (type .equals (Peer .PEER_SERVER )) {
93
93
String value = ByteArray .toHexString (genesisBlock .toByteArray ());
94
94
Message message = new Message (value , Type .BLOCK );
95
95
Client .putMessage1 (message ); // consensus: put message GenesisBlock
Original file line number Diff line number Diff line change @@ -86,12 +86,12 @@ private void initBlockchian() {
86
86
//blockchain = new Blockchain(ByteArray.toHexString(wallet.getAddress()));
87
87
if (this .type .equals (Peer .PEER_SERVER )){
88
88
blockchain = new Blockchain (ByteArray .toHexString (wallet
89
- .getAddress ()));
89
+ .getAddress ()), this . type );
90
90
}
91
91
if (this .type .equals (Peer .PEER_NORMAL )){
92
92
//System.out.println("BlockChain loadding ...");
93
93
blockchain = new Blockchain (ByteArray .toHexString (wallet
94
- .getAddress ()));
94
+ .getAddress ()), this . type );
95
95
Client .loadBlock (this );
96
96
}
97
97
}
Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ public class BlockchainTest {
26
26
@ Test
27
27
public void testBlockchain () {
28
28
Blockchain blockchain = new Blockchain
29
- ("0304f784e4e7bae517bcab94c3e0c9214fb4ac7ff9d7d5a937d1f40031f87b85" );
29
+ ("0304f784e4e7bae517bcab94c3e0c9214fb4ac7ff9d7d5a937d1f40031f87b85" , "server" );
30
30
31
31
logger .info ("test blockchain: lashHash = {}, currentHash = {}" ,
32
32
ByteArray .toHexString (blockchain .getLastHash ()), ByteArray
@@ -56,7 +56,7 @@ public void testBlockchainNew() {
56
56
57
57
@ Test
58
58
public void testIterator () {
59
- Blockchain blockchain = new Blockchain ("" );
59
+ Blockchain blockchain = new Blockchain ("" , "server" );
60
60
Block info = null ;
61
61
BlockchainIterator bi = new BlockchainIterator (blockchain );
62
62
while (bi .hasNext ()) {
@@ -88,7 +88,7 @@ public void testDBExists() {
88
88
@ Test
89
89
public void testFindUTXO () {
90
90
Blockchain blockchain = new Blockchain
91
- ("fd0f3c8ab4877f0fd96cd156b0ad42ea7aa82c31" );
91
+ ("fd0f3c8ab4877f0fd96cd156b0ad42ea7aa82c31" , "server" );
92
92
Wallet wallet = new Wallet ();
93
93
wallet .init ();
94
94
Transaction transaction = TransactionUtils .newTransaction (wallet ,
You can’t perform that action at this time.
0 commit comments