简体   繁体   中英

reading data stored into blockchain

I've implemented a simple blockchain in java using arraylist contain object (block class).

    public static ArrayList<Block> blockchain = new ArrayList<Block>();

... and block class containing the transaction which I need to store into blockchain.

  public Block(transaction data,String previousHash ) {

    this.data = data;

    this.previousHash = previousHash;

    this.timeStamp = new Date().getTime();


              this.hash = calculateHash(); 
}

transaction class contains the data: hash of medical record title of file medical record .....

    public transaction(String title,String date,String pointer,int version,int nbdoctor,int nbsdoctor ,byte[] patient 
        ,String hashdata , ArrayList<byte []> permission , ArrayList<byte []> spermission ,byte[] newdoctorkey , byte[] newsdoctorkey ,
        byte[] removedoctor ,byte[] sremovedoctor) 

but I don't know the way to read from this blockchain . I want to get the data into transaction object according to the title field. I want a quick method to access to the data into blockchain (into array list).

Thank you.

The answer to this question is simple and straightforward. To read data which is stored in blocks within blockchains, you need a 'block explorer.'

Now depending on the type of blockchain you are vested in, you should chose relevant block explorers. For a bitcoin blockhain, you need a bitcoin explorer; and similarly for an ethereum blockchain, you need an Ethereum explorer.

You seem to have trouble understanding the block concept. A block always contains multiple transactions in a blockchain. These transactions are structured as a Merkle tree to improve read/write performance. If you only place a single transaction inside a block, there is no point in using a block. At that point you might as well use a simple hash chain, where each transaction contains a reference to its predecessor.

For more, refer to: https://en.wikipedia.org/wiki/Blockchain

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM