use of com.jd.blockchain.ledger.merkletree.MerkleTree in project jdchain-core by blockchain-jd-com.
the class MerkleHashTrieTest method buildMerkleRootHash.
private HashDigest buildMerkleRootHash(VersioningKVData<String, byte[]>[] datas) {
MerkleTree merkleTree = newMerkleTree_with_committed(datas);
HashDigest rootHash = merkleTree.getRootHash();
return rootHash;
}
use of com.jd.blockchain.ledger.merkletree.MerkleTree in project jdchain-core by blockchain-jd-com.
the class MerkleHashTrieTest method testSpecialUseCase_1.
@Test
public void testSpecialUseCase_1() {
CryptoSetting cryptoSetting = createCryptoSetting();
MemoryKVStorage storage = new MemoryKVStorage();
MerkleHashTrie merkleTree = new MerkleHashTrie(cryptoSetting, KEY_PREFIX, storage);
byte[] key = Base58Utils.decode("j5sXmpcomtM2QMUNWeQWsF8bNFFnyeXoCjVAekEeLSscgY");
byte[] value = BytesUtils.toBytes("Special Use-Case VALUE");
long version = 0;
merkleTree.setData(key, version, value);
KVEntry mkdata = merkleTree.getData(key);
assertNotNull(mkdata);
merkleTree.commit();
mkdata = merkleTree.getData(key);
assertNotNull(mkdata);
MerkleTree merkleTreeReload = new MerkleHashTrie(merkleTree.getRootHash(), cryptoSetting, KEY_PREFIX, storage, false);
mkdata = merkleTreeReload.getData(key);
assertNotNull(mkdata);
}
use of com.jd.blockchain.ledger.merkletree.MerkleTree in project jdchain-core by blockchain-jd-com.
the class MerkleHashSortTreeTest method testSpecialUseCase_1.
@Test
public void testSpecialUseCase_1() {
TreeOptions treeOptions = createTreeOptions();
MemoryKVStorage storage = new MemoryKVStorage();
MerkleHashSortTree merkleTree = new MerkleHashSortTree(treeOptions, KEY_PREFIX, storage);
byte[] key = Base58Utils.decode("j5sXmpcomtM2QMUNWeQWsF8bNFFnyeXoCjVAekEeLSscgY");
byte[] value = BytesUtils.toBytes("Special Use-Case VALUE");
long version = 0;
merkleTree.setData(key, version, value);
KVEntry mkdata = merkleTree.getData(key);
assertNotNull(mkdata);
merkleTree.commit();
mkdata = merkleTree.getData(key);
assertNotNull(mkdata);
MerkleTree merkleTreeReload = new MerkleHashSortTree(merkleTree.getRootHash(), treeOptions, KEY_PREFIX, storage);
mkdata = merkleTreeReload.getData(key);
assertNotNull(mkdata);
}
use of com.jd.blockchain.ledger.merkletree.MerkleTree in project jdchain-core by blockchain-jd-com.
the class MerkleHashSortTreeTest method buildMerkleRootHash.
private HashDigest buildMerkleRootHash(VersioningKVData<String, byte[]>[] datas) {
MerkleTree merkleTree = newMerkleTree_with_committed(datas);
HashDigest rootHash = merkleTree.getRootHash();
return rootHash;
}
Aggregations