Java blockchain (#7694)
* Adding source code for the article tracked under BAEL-3232. * Incorporated the review comments on the article.
This commit is contained in:
committed by
Grzegorz Piwowarek
parent
73743acb30
commit
8c11eeb20e
@@ -3,7 +3,6 @@ package com.baeldung.blockchain;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.Date;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@@ -17,10 +16,10 @@ public class Block {
|
||||
private long timeStamp;
|
||||
private int nonce;
|
||||
|
||||
public Block(String data, String previousHash) {
|
||||
public Block(String data, String previousHash, long timeStamp) {
|
||||
this.data = data;
|
||||
this.previousHash = previousHash;
|
||||
this.timeStamp = new Date().getTime();
|
||||
this.timeStamp = timeStamp;
|
||||
this.hash = calculateBlockHash();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user