Research Article
Research on a Shared Bicycle Deposit Management System Based on Blockchain Technology
Algorithm 3
Hash each transaction, build Merkle tree, and compute the Merkle root.
(1) | READ: Transactions | (2) | For all transactions | (3) | hash[i]=create Hash(transaction[i]) | (4) | For all hashes in each level | (5) | if number of hashes = even then | (6) | Hash[i]=create Hash(hash[i]+hash[i]) | (7) | else | (8) | if! Last Hash then | (9) | hash[i]=create Hash(hash[i]+hash[i+1]) | (10) | else | (11) | hash[i]=create Hash(hash[i]+hash[i]) | (12) | end if | (13) | if level=last then | (14) | rootvalue=hash[i] | (15) | end if | (16) | end if |
|