public StateStore buildStateStore(BranchId branchId) { return new StateStore(getDbSource(branchId + "/state")); }
public BlockStore buildBlockStore(BranchId branchId) { return new BlockStore(getDbSource(branchId + "/blocks")); }
@Test public void buildPeerStore() { Peer peer = Peer.valueOf("ynode://75bff16c@127.0.0.1:32918"); PeerStore store = builder.buildPeerStore(); store.put(peer.getPeerId(), peer); assert store.contains(peer.getPeerId()); assert store.get(peer.getPeerId()).equals(peer); } }
private void loadTransaction() { // load recent 1000 block // Start Block and End Block Long bestBlock = metaStore.getBestBlock(); Long loadStart = bestBlock > 1000 ? bestBlock - 1000 : 0; for (long i = loadStart; i <= bestBlock; i++) { // recent block load and update Cache BlockHusk block = blockStore.getBlockByIndex(i); transactionStore.updateCache(block.getBody()); // set Last Best Block if (i == bestBlock) { this.prevBlock = block; } } }
public MetaStore buildMetaStore(BranchId branchId) { MetaStore store = new MetaStore(getDbSource(branchId + "/meta")); store.put(BlockchainMetaInfo.BRANCH.toString(), branchId.toString()); return store; }
public TransactionStore buildTxStore(BranchId branchId) { return new TransactionStore(getDbSource(branchId + "/txs")); }
public PeerStore buildPeerStore() { return new PeerStore(getDbSource("peers")); }
public TransactionReceiptStore buildTransactionReciptStore(BranchId branchId) { return new TransactionReceiptStore(getDbSource(branchId + "/txreceipt")); }
/** * Gets transaction by hash. * * @param hash the hash * @return the transaction by hash */ TransactionHusk getTxByHash(Sha3Hash hash) { return transactionStore.get(hash); }
/** * Gets block by hash. * * @param hash the hash * @return the block by hash */ public BlockHusk getBlockByHash(Sha3Hash hash) { return blockStore.get(hash); }
Collection<TransactionHusk> getRecentTxs() { return transactionStore.getRecentTxs(); }
long countOfTxs() { return transactionStore.countOfTxs(); }
private void putBalance(String key, BigDecimal value) { JsonObject storeValue = new JsonObject(); storeValue.addProperty("balance", value); store.put(key, storeValue); }
@Override public V get(K key) { return stateStore.get(key); }
@Override public boolean contains(K key) { return stateStore.contains(key); }
@Override public synchronized int count() { return peerStore.size(); }
public BlockHusk getBlockByIndex(long idx) { return blockStore.getBlockByIndex(idx); }
public long size() { return blockStore.getBlockchainTransactionSize(); }
private boolean isBranchExist(String branchId) { return state.get(branchId) != null; }