Java implementation of block in blockchain, block implementation

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.