Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
in Blockchain by (4.1k points)

I created a simple "blockchain" on Java.

Blockchain class is an ArrayList<> of Blocks. The blocks are made by: hashcode, previous hashcode and nonse counter. When a block is created, it is added to the blockchain but, until the algorithm (SHA256) is resolved, it is not possible to allocate others. If the hashcode is unique, it is added successfully or the block is removed.

What I would like to do now is to share the blockchain on a network, so the SHA256 algorithm will not be resolved by the local machine, but by a user on the network (for exaple, bitcoin mining).

So my question is: how can I share the same object on different machines in a network?

You can download the code from Git:

Blockchain code

1 Answer

0 votes
by (14.4k points)
edited by

A Node generally keeps a list of nodes it is connected to and further notifies them for changes. Also once they start communicating, users should note the differences in the chain (for example if chain on one node is different from chain on another node but both are valid). For bitcoin, the longer node is considered valid.

You can refer to this link for simple javascript implementation of a blockchain using websockets:

A simple python implementation:

On Java:

Want to be an expert in Blockchain? Don't waste your time thinking. Enroll in Blockchain Certification now.

Browse Categories