1515 * <br/><a href="https://github.com/CryptoKass/NoobChain-Tutorial-Part-2">https://github.com/CryptoKass/NoobChain-Tutorial-Part-2</a>
1616 * @author Gabriel Chandesris (2021)
1717 */
18- public class NoobChain {
18+ public class NoobChainIntegration {
1919
2020 private static List <Block > blockchain = new ArrayList <Block >();
2121 private static List <Block > blockchain2 = new ArrayList <Block >();
@@ -29,38 +29,38 @@ public static void main(String[] args) {
2929
3030 // ***** Part I
3131 Block genesisBlock = new Block ("Hi im the first block" , "0" );
32- System .out .println ("Hash for block 1 : " + genesisBlock .hash );
33- Block secondBlock = new Block ("Yo im the second block" , genesisBlock .hash );
34- System .out .println ("Hash for block 2 : " + secondBlock .hash );
35- Block thirdBlock = new Block ("Hey im the third block" , secondBlock .hash );
36- System .out .println ("Hash for block 3 : " + thirdBlock .hash );
32+ System .out .println ("Hash for block 1 : " + genesisBlock .getHash () );
33+ Block secondBlock = new Block ("Yo im the second block" , genesisBlock .getHash () );
34+ System .out .println ("Hash for block 2 : " + secondBlock .getHash () );
35+ Block thirdBlock = new Block ("Hey im the third block" , secondBlock .getHash () );
36+ System .out .println ("Hash for block 3 : " + thirdBlock .getHash () );
3737
3838
3939 // ***** Part II
4040 // Add our blocks to the blockchain List:
41- NoobChain .blockchain .add (new Block ("Hi im the first block" , "0" ));
42- NoobChain .blockchain .add (new Block ("Yo im the second block" , NoobChain .blockchain .get (NoobChain .blockchain .size ()-1 ).hash ));
43- NoobChain .blockchain .add (new Block ("Hey im the third block" , NoobChain .blockchain .get (NoobChain .blockchain .size ()-1 ).hash ));
44- String blockchainJson = new GsonBuilder ().setPrettyPrinting ().create ().toJson (NoobChain .blockchain );
41+ NoobChainIntegration .blockchain .add (new Block ("Hi im the first block" , "0" ));
42+ NoobChainIntegration .blockchain .add (new Block ("Yo im the second block" , NoobChainIntegration .blockchain .get (NoobChainIntegration .blockchain .size ()-1 ).getHash () ));
43+ NoobChainIntegration .blockchain .add (new Block ("Hey im the third block" , NoobChainIntegration .blockchain .get (NoobChainIntegration .blockchain .size ()-1 ).getHash () ));
44+ String blockchainJson = new GsonBuilder ().setPrettyPrinting ().create ().toJson (NoobChainIntegration .blockchain );
4545 System .out .println (blockchainJson );
4646
4747 // ***** Part III
4848 // Add our blocks to the blockchain List:
49- NoobChain .blockchain2 .add (new Block ("Hi im the first block" , "0" ));
49+ NoobChainIntegration .blockchain2 .add (new Block ("Hi im the first block" , "0" ));
5050 System .out .println ("Trying to Mine block 1... " );
51- NoobChain .blockchain2 .get (0 ).mineBlock (NoobChain .difficulty );
51+ NoobChainIntegration .blockchain2 .get (0 ).mineBlock (NoobChainIntegration .difficulty );
5252
53- NoobChain .blockchain2 .add (new Block ("Yo im the second block" , NoobChain .blockchain2 .get (NoobChain .blockchain2 .size ()-1 ).hash ));
53+ NoobChainIntegration .blockchain2 .add (new Block ("Yo im the second block" , NoobChainIntegration .blockchain2 .get (NoobChainIntegration .blockchain2 .size ()-1 ).getHash () ));
5454 System .out .println ("Trying to Mine block 2... " );
55- NoobChain .blockchain2 .get (1 ).mineBlock (NoobChain .difficulty );
55+ NoobChainIntegration .blockchain2 .get (1 ).mineBlock (NoobChainIntegration .difficulty );
5656
57- NoobChain .blockchain2 .add (new Block ("Hey im the third block" , NoobChain .blockchain2 .get (NoobChain .blockchain2 .size ()-1 ).hash ));
57+ NoobChainIntegration .blockchain2 .add (new Block ("Hey im the third block" , NoobChainIntegration .blockchain2 .get (NoobChainIntegration .blockchain2 .size ()-1 ).getHash () ));
5858 System .out .println ("Trying to Mine block 3... " );
59- NoobChain .blockchain2 .get (2 ).mineBlock (NoobChain .difficulty );
59+ NoobChainIntegration .blockchain2 .get (2 ).mineBlock (NoobChainIntegration .difficulty );
6060
61- System .out .println ("\n Blockchain is Valid: " + BlockChain .isChainValidV1 ( NoobChain .blockchain2 ));
61+ System .out .println ("\n Blockchain is Valid: " + BlockChain .isChainValidV1 ( NoobChainIntegration .blockchain2 ));
6262
63- String blockchain2Json = new GsonBuilder ().setPrettyPrinting ().create ().toJson (NoobChain .blockchain2 );
63+ String blockchain2Json = new GsonBuilder ().setPrettyPrinting ().create ().toJson (NoobChainIntegration .blockchain2 );
6464 System .out .println ("\n The block chain: " );
6565 System .out .println (blockchain2Json );
6666
@@ -70,21 +70,21 @@ public static void main(String[] args) {
7070 // Security.addProvider(new sun.security.provider.Sun());
7171 // XXX NOTE see https://docs.oracle.com/javase/8/docs/technotes/guides/security/SunProviders.html
7272 // Create the new wallets
73- NoobChain .walletA = new Wallet ();
74- NoobChain .walletB = new Wallet ();
73+ NoobChainIntegration .walletA = new Wallet ();
74+ NoobChainIntegration .walletB = new Wallet ();
7575 // Test public and private keys
7676 System .out .println ("Private and public keys:" );
77- System .out .println (StringUtils .getStringFromKey (NoobChain .walletA .privateKey ));
78- System .out .println (StringUtils .getStringFromKey (NoobChain .walletA .publicKey ));
77+ System .out .println (StringUtils .getStringFromKey (NoobChainIntegration .walletA .privateKey ));
78+ System .out .println (StringUtils .getStringFromKey (NoobChainIntegration .walletA .publicKey ));
7979 // Create a test transaction from WalletA to walletB
80- Transaction transaction = new Transaction (NoobChain .walletA .publicKey , NoobChain .walletB .publicKey , 5 , null );
81- transaction .generateSignature (NoobChain .walletA .privateKey );
80+ Transaction transaction = new Transaction (NoobChainIntegration .walletA .publicKey , NoobChainIntegration .walletB .publicKey , 5 , null );
81+ transaction .generateSignature (NoobChainIntegration .walletA .privateKey );
8282 // Verify the signature works and verify it from the public key
8383 System .out .println ("Is signature verified" );
8484 System .out .println (transaction .verifySignature ());
8585
8686 // ***** Part V
87- // TODO next step of tutorials !!
87+ // XXX NOTE see NoobChainFinale and NoobChainTests !!
8888 }
8989
9090 /*
0 commit comments