Java| block chain development and communication group: 613121183
Interested can also add ha, provided a lot of block chain information, there will be information to share
The basic concept of a block chain is simple: a distributed database that stores an ever-growing list,list containing many sequential records. In general, however, when we talk about block chains, we also talk about the problem of using block chains, which can easily be confused. This is the case for a block-chain project like the popular Bitcoin and the Etheric square. The term "block chain" is often closely linked to concepts like trading, smart contracts, and cryptographic currencies.
This makes it much more difficult to understand the block chain, especially if you want to understand the source code. I will use the 200 line JS implementation of the super simple block chain to help you understand it, I gave this code named Naivechain. Block Structure
The first logical step is to determine the block structure. To ensure that things are as simple as possible, we only select the most necessary parts: index (subscript), timestamp (timestamp), data (data), hash (hash value), and previous hash (pre-hashing).
This block must be able to find the hash value of the previous block in order to ensure the integrity of the entire chain.
1 2 3 4 5 6 7 8 9 |
Class Block {constructor (index, Previoushash, timestamp, data, hash) {this. index = index; this. Previoushash = Previoushash. ToString (); this. timestamp = timestamp; this. data = data; this. hash = hash. ToString (); } } |
Block Hash
In order to save the full data, you must hash the block. SHA-256 will encrypt the contents of the block, recording this value should have nothing to do with "digging", because there is no need to solve the problem of work proof.
1 2 3 |
var Calculatehash = (Index, Previoushash, |