1. Block is the base unit of the block chain
A block chain consists of several blocks, which are the base units of the blockchain.
2. The basic attributes of chunks in a block chain
Description of the chunk 6 attribute-index The index value of the chunk, the unique key in the blockchain
Description of the Block 6 attribute-timestamp chunk timestamp, used to differentiate the generation time of a chunk
Description of Block 6 properties The hash value of the-hash chunk is the hash value calculated for the whole chunk
Description of Block 6 properties-previous hash value of a chunk before hash
Description of the Block 6 attribute-data The data storage portion of the blockchain, for example bitcoin is used to store transaction data
Description of Block 6 properties-nonce (Mining principle, Bitcoin difficulty example) The Nonce value is calculated by forming a valid hash.
3, block chain block code implementation
Package cn.wenwuyi.blockchain.pojo;/** * Class Name: Block.java * Description: Block entity class * Time: March 12, 2018 PM 7:03:50 * @author Cn.wenwuyi * @ve Rsion 1.0 */public Class Block {/** * index */private int index; /** * The hash value of the previous chunk */private String Previoushash; /** * Time stamp */private long timestamp; /** * data, transaction data, etc. */private String data; /** * Hash value */private String hash; /** * nonce value (difficulty factor) */private long nonce; Public block () {} public block (int index, string previoushash, long timestamp, string data, String Hash,long nonce) {this.index = index; This.previoushash = Previoushash; This.timestamp = timestamp; This.data = data; This.hash = hash; This.nonce = nonce; } public int GetIndex () {return index; } public void Setindex (int index) {this.index = index; } public String Getprevioushash () {return previoushash; } public void SEtprevioushash (String previoushash) {this.previoushash = Previoushash; } public Long Gettimestamp () {return timestamp; } public void Settimestamp (long timestamp) {this.timestamp = timestamp; } public String GetData () {return data; } public void SetData (String data) {this.data = data; } public String Gethash () {return hash; } public void Sethash (String hash) {This.hash = hash; } public Long Getnonce () {return nonce; } public void Setnonce (long nonce) {this.nonce = nonce; }}
Java implements chunks in blockchain, block implementation