| @@ -0,0 +1,31 @@ | |||
| package com.jd.blockchain.ledger.core; | |||
| import com.jd.blockchain.ledger.AccountHeader; | |||
| import com.jd.blockchain.utils.Bytes; | |||
| public interface AccountQuery<T> extends MerkleProvable { | |||
| AccountHeader[] getHeaders(int fromIndex, int count); | |||
| /** | |||
| * 返回总数; | |||
| * | |||
| * @return | |||
| */ | |||
| long getTotal(); | |||
| boolean contains(Bytes address); | |||
| /** | |||
| * 返回账户实例; | |||
| * | |||
| * @param address Base58 格式的账户地址; | |||
| * @return 账户实例,如果不存在则返回 null; | |||
| */ | |||
| T getAccount(String address); | |||
| T getAccount(Bytes address); | |||
| T getAccount(Bytes address, long version); | |||
| } | |||
| @@ -1,29 +1,5 @@ | |||
| package com.jd.blockchain.ledger.core; | |||
| import com.jd.blockchain.crypto.HashDigest; | |||
| import com.jd.blockchain.ledger.AccountHeader; | |||
| import com.jd.blockchain.ledger.MerkleProof; | |||
| import com.jd.blockchain.utils.Bytes; | |||
| public interface ContractAccountQuery { | |||
| AccountHeader[] getAccounts(int fromIndex, int count); | |||
| HashDigest getRootHash(); | |||
| /** | |||
| * 返回合约总数; | |||
| * | |||
| * @return | |||
| */ | |||
| long getTotalCount(); | |||
| MerkleProof getProof(Bytes address); | |||
| boolean contains(Bytes address); | |||
| ContractAccount getContract(Bytes address); | |||
| ContractAccount getContract(Bytes address, long version); | |||
| public interface ContractAccountQuery extends AccountQuery<ContractAccount> { | |||
| } | |||
| @@ -11,7 +11,7 @@ import com.jd.blockchain.storage.service.VersioningKVStorage; | |||
| import com.jd.blockchain.utils.Bytes; | |||
| import com.jd.blockchain.utils.Transactional; | |||
| public class ContractAccountSet implements MerkleProvable, Transactional, ContractAccountQuery { | |||
| public class ContractAccountSet implements Transactional, ContractAccountQuery { | |||
| private AccountSet accountSet; | |||
| @@ -27,8 +27,8 @@ public class ContractAccountSet implements MerkleProvable, Transactional, Contra | |||
| } | |||
| @Override | |||
| public AccountHeader[] getAccounts(int fromIndex, int count) { | |||
| return accountSet.getAccounts(fromIndex,count); | |||
| public AccountHeader[] getHeaders(int fromIndex, int count) { | |||
| return accountSet.getAccounts(fromIndex, count); | |||
| } | |||
| public boolean isReadonly() { | |||
| @@ -38,7 +38,7 @@ public class ContractAccountSet implements MerkleProvable, Transactional, Contra | |||
| void setReadonly() { | |||
| accountSet.setReadonly(); | |||
| } | |||
| @Override | |||
| public HashDigest getRootHash() { | |||
| return accountSet.getRootHash(); | |||
| @@ -50,7 +50,7 @@ public class ContractAccountSet implements MerkleProvable, Transactional, Contra | |||
| * @return | |||
| */ | |||
| @Override | |||
| public long getTotalCount() { | |||
| public long getTotal() { | |||
| return accountSet.getTotalCount(); | |||
| } | |||
| @@ -65,13 +65,18 @@ public class ContractAccountSet implements MerkleProvable, Transactional, Contra | |||
| } | |||
| @Override | |||
| public ContractAccount getContract(Bytes address) { | |||
| public ContractAccount getAccount(Bytes address) { | |||
| BaseAccount accBase = accountSet.getAccount(address); | |||
| return new ContractAccount(accBase); | |||
| } | |||
| @Override | |||
| public ContractAccount getContract(Bytes address, long version) { | |||
| public ContractAccount getAccount(String address) { | |||
| return getAccount(Bytes.fromBase58(address)); | |||
| } | |||
| @Override | |||
| public ContractAccount getAccount(Bytes address, long version) { | |||
| BaseAccount accBase = accountSet.getAccount(address, version); | |||
| return new ContractAccount(accBase); | |||
| } | |||
| @@ -79,14 +84,10 @@ public class ContractAccountSet implements MerkleProvable, Transactional, Contra | |||
| /** | |||
| * 部署一项新的合约链码; | |||
| * | |||
| * @param address | |||
| * 合约账户地址; | |||
| * @param pubKey | |||
| * 合约账户公钥; | |||
| * @param addressSignature | |||
| * 地址签名;合约账户的私钥对地址的签名; | |||
| * @param chaincode | |||
| * 链码内容; | |||
| * @param address 合约账户地址; | |||
| * @param pubKey 合约账户公钥; | |||
| * @param addressSignature 地址签名;合约账户的私钥对地址的签名; | |||
| * @param chaincode 链码内容; | |||
| * @return 合约账户; | |||
| */ | |||
| public ContractAccount deploy(Bytes address, PubKey pubKey, DigitalSignature addressSignature, byte[] chaincode) { | |||
| @@ -100,12 +101,9 @@ public class ContractAccountSet implements MerkleProvable, Transactional, Contra | |||
| /** | |||
| * 更新指定账户的链码; | |||
| * | |||
| * @param address | |||
| * 合约账户地址; | |||
| * @param chaincode | |||
| * 链码内容; | |||
| * @param version | |||
| * 链码版本; | |||
| * @param address 合约账户地址; | |||
| * @param chaincode 链码内容; | |||
| * @param version 链码版本; | |||
| * @return 返回链码的新版本号; | |||
| */ | |||
| public long update(Bytes address, byte[] chaincode, long version) { | |||
| @@ -1,32 +1,5 @@ | |||
| package com.jd.blockchain.ledger.core; | |||
| import com.jd.blockchain.crypto.HashDigest; | |||
| import com.jd.blockchain.ledger.AccountHeader; | |||
| import com.jd.blockchain.ledger.MerkleProof; | |||
| import com.jd.blockchain.utils.Bytes; | |||
| public interface DataAccountQuery { | |||
| AccountHeader[] getAccounts(int fromIndex, int count); | |||
| HashDigest getRootHash(); | |||
| long getTotalCount(); | |||
| /** | |||
| * 返回账户的存在性证明; | |||
| */ | |||
| MerkleProof getProof(Bytes address); | |||
| /** | |||
| * 返回数据账户; <br> | |||
| * 如果不存在,则返回 null; | |||
| * | |||
| * @param address | |||
| * @return | |||
| */ | |||
| DataAccount getDataAccount(Bytes address); | |||
| DataAccount getDataAccount(Bytes address, long version); | |||
| public interface DataAccountQuery extends AccountQuery<DataAccount> { | |||
| } | |||
| @@ -11,7 +11,7 @@ import com.jd.blockchain.storage.service.VersioningKVStorage; | |||
| import com.jd.blockchain.utils.Bytes; | |||
| import com.jd.blockchain.utils.Transactional; | |||
| public class DataAccountSet implements MerkleProvable, Transactional, DataAccountQuery { | |||
| public class DataAccountSet implements Transactional, DataAccountQuery { | |||
| private AccountSet accountSet; | |||
| @@ -27,7 +27,7 @@ public class DataAccountSet implements MerkleProvable, Transactional, DataAccoun | |||
| } | |||
| @Override | |||
| public AccountHeader[] getAccounts(int fromIndex, int count) { | |||
| public AccountHeader[] getHeaders(int fromIndex, int count) { | |||
| return accountSet.getAccounts(fromIndex, count); | |||
| } | |||
| @@ -38,17 +38,22 @@ public class DataAccountSet implements MerkleProvable, Transactional, DataAccoun | |||
| void setReadonly() { | |||
| accountSet.setReadonly(); | |||
| } | |||
| @Override | |||
| public HashDigest getRootHash() { | |||
| return accountSet.getRootHash(); | |||
| } | |||
| @Override | |||
| public long getTotalCount() { | |||
| public long getTotal() { | |||
| return accountSet.getTotalCount(); | |||
| } | |||
| @Override | |||
| public boolean contains(Bytes address) { | |||
| return accountSet.contains(address); | |||
| } | |||
| /** | |||
| * 返回账户的存在性证明; | |||
| */ | |||
| @@ -63,6 +68,11 @@ public class DataAccountSet implements MerkleProvable, Transactional, DataAccoun | |||
| return new DataAccount(accBase); | |||
| } | |||
| @Override | |||
| public DataAccount getAccount(String address) { | |||
| return getAccount(Bytes.fromBase58(address)); | |||
| } | |||
| /** | |||
| * 返回数据账户; <br> | |||
| * 如果不存在,则返回 null; | |||
| @@ -71,7 +81,7 @@ public class DataAccountSet implements MerkleProvable, Transactional, DataAccoun | |||
| * @return | |||
| */ | |||
| @Override | |||
| public DataAccount getDataAccount(Bytes address) { | |||
| public DataAccount getAccount(Bytes address) { | |||
| BaseAccount accBase = accountSet.getAccount(address); | |||
| if (accBase == null) { | |||
| return null; | |||
| @@ -80,7 +90,7 @@ public class DataAccountSet implements MerkleProvable, Transactional, DataAccoun | |||
| } | |||
| @Override | |||
| public DataAccount getDataAccount(Bytes address, long version) { | |||
| public DataAccount getAccount(Bytes address, long version) { | |||
| BaseAccount accBase = accountSet.getAccount(address, version); | |||
| return new DataAccount(accBase); | |||
| } | |||
| @@ -0,0 +1,52 @@ | |||
| package com.jd.blockchain.ledger.core; | |||
| import com.jd.blockchain.crypto.HashDigest; | |||
| import com.jd.blockchain.ledger.AccountHeader; | |||
| import com.jd.blockchain.ledger.MerkleProof; | |||
| import com.jd.blockchain.utils.Bytes; | |||
| public class EmptyAccountSet<T> implements AccountQuery<T> { | |||
| private static final AccountHeader[] EMPTY = {}; | |||
| @Override | |||
| public HashDigest getRootHash() { | |||
| return null; | |||
| } | |||
| @Override | |||
| public MerkleProof getProof(Bytes key) { | |||
| return null; | |||
| } | |||
| @Override | |||
| public AccountHeader[] getHeaders(int fromIndex, int count) { | |||
| return EMPTY; | |||
| } | |||
| @Override | |||
| public long getTotal() { | |||
| return 0; | |||
| } | |||
| @Override | |||
| public boolean contains(Bytes address) { | |||
| return false; | |||
| } | |||
| @Override | |||
| public T getAccount(String address) { | |||
| return null; | |||
| } | |||
| @Override | |||
| public T getAccount(Bytes address) { | |||
| return null; | |||
| } | |||
| @Override | |||
| public T getAccount(Bytes address, long version) { | |||
| return null; | |||
| } | |||
| } | |||
| @@ -1,7 +1,6 @@ | |||
| package com.jd.blockchain.ledger.core; | |||
| import com.jd.blockchain.crypto.HashDigest; | |||
| import com.jd.blockchain.ledger.AccountHeader; | |||
| import com.jd.blockchain.ledger.LedgerAdminSettings; | |||
| import com.jd.blockchain.ledger.MerkleProof; | |||
| import com.jd.blockchain.ledger.ParticipantDataQuery; | |||
| @@ -90,120 +89,17 @@ public class EmptyLedgerDataset implements LedgerDataQuery { | |||
| } | |||
| private static class EmptyUserAccountSet implements UserAccountQuery{ | |||
| private static class EmptyUserAccountSet extends EmptyAccountSet<UserAccount> implements UserAccountQuery{ | |||
| @Override | |||
| public AccountHeader[] getAccounts(int fromIndex, int count) { | |||
| return null; | |||
| } | |||
| @Override | |||
| public long getTotalCount() { | |||
| return 0; | |||
| } | |||
| @Override | |||
| public HashDigest getRootHash() { | |||
| return null; | |||
| } | |||
| @Override | |||
| public MerkleProof getProof(Bytes key) { | |||
| return null; | |||
| } | |||
| @Override | |||
| public UserAccount getUser(String address) { | |||
| return null; | |||
| } | |||
| @Override | |||
| public UserAccount getUser(Bytes address) { | |||
| return null; | |||
| } | |||
| @Override | |||
| public boolean contains(Bytes address) { | |||
| return false; | |||
| } | |||
| @Override | |||
| public UserAccount getUser(Bytes address, long version) { | |||
| return null; | |||
| } | |||
| } | |||
| private static class EmptyDataAccountSet implements DataAccountQuery{ | |||
| @Override | |||
| public AccountHeader[] getAccounts(int fromIndex, int count) { | |||
| return null; | |||
| } | |||
| @Override | |||
| public HashDigest getRootHash() { | |||
| return null; | |||
| } | |||
| @Override | |||
| public long getTotalCount() { | |||
| return 0; | |||
| } | |||
| @Override | |||
| public MerkleProof getProof(Bytes address) { | |||
| return null; | |||
| } | |||
| private static class EmptyDataAccountSet extends EmptyAccountSet<DataAccount> implements DataAccountQuery{ | |||
| @Override | |||
| public DataAccount getDataAccount(Bytes address) { | |||
| return null; | |||
| } | |||
| @Override | |||
| public DataAccount getDataAccount(Bytes address, long version) { | |||
| return null; | |||
| } | |||
| } | |||
| private static class EmptyContractAccountSet extends EmptyAccountSet<ContractAccount> implements ContractAccountQuery{ | |||
| } | |||
| private static class EmptyContractAccountSet implements ContractAccountQuery{ | |||
| @Override | |||
| public AccountHeader[] getAccounts(int fromIndex, int count) { | |||
| return null; | |||
| } | |||
| @Override | |||
| public HashDigest getRootHash() { | |||
| return null; | |||
| } | |||
| @Override | |||
| public long getTotalCount() { | |||
| return 0; | |||
| } | |||
| @Override | |||
| public MerkleProof getProof(Bytes address) { | |||
| return null; | |||
| } | |||
| @Override | |||
| public boolean contains(Bytes address) { | |||
| return false; | |||
| } | |||
| @Override | |||
| public ContractAccount getContract(Bytes address) { | |||
| return null; | |||
| } | |||
| @Override | |||
| public ContractAccount getContract(Bytes address, long version) { | |||
| return null; | |||
| } | |||
| } | |||
| } | |||
| @@ -272,12 +272,12 @@ public class LedgerInitializer { | |||
| } | |||
| @Override | |||
| public LedgerDataQuery getDataSet(LedgerBlock block) { | |||
| public LedgerDataQuery getLedgerData(LedgerBlock block) { | |||
| return dataset; | |||
| } | |||
| @Override | |||
| public TransactionSet getTransactionSet(LedgerBlock block) { | |||
| public TransactionQuery getTransactionSet(LedgerBlock block) { | |||
| return null; | |||
| } | |||
| @@ -54,16 +54,30 @@ public interface LedgerQuery { | |||
| LedgerAdminInfo getAdminInfo(); | |||
| LedgerAdminInfo getAdminInfo(LedgerBlock block); | |||
| LedgerAdminSettings getAdminSettings(); | |||
| LedgerAdminSettings getAdminSettings(LedgerBlock block); | |||
| LedgerBlock getBlock(HashDigest hash); | |||
| LedgerDataQuery getDataSet(LedgerBlock block); | |||
| /** | |||
| * 返回指定 | |||
| * @param block | |||
| * @return | |||
| */ | |||
| LedgerDataQuery getLedgerData(LedgerBlock block); | |||
| /** | |||
| * 返回最新区块对应的账本数据; | |||
| * | |||
| * @return | |||
| */ | |||
| default LedgerDataQuery getLedgerData() { | |||
| return getLedgerData(getLatestBlock()); | |||
| } | |||
| TransactionSet getTransactionSet(LedgerBlock block); | |||
| TransactionQuery getTransactionSet(LedgerBlock block); | |||
| UserAccountQuery getUserAccountSet(LedgerBlock block); | |||
| @@ -71,11 +85,7 @@ public interface LedgerQuery { | |||
| ContractAccountQuery getContractAccountSet(LedgerBlock block); | |||
| default LedgerDataQuery getDataSet() { | |||
| return getDataSet(getLatestBlock()); | |||
| } | |||
| default TransactionSet getTransactionSet() { | |||
| default TransactionQuery getTransactionSet() { | |||
| return getTransactionSet(getLatestBlock()); | |||
| } | |||
| @@ -90,7 +100,7 @@ public interface LedgerQuery { | |||
| default ContractAccountQuery getContractAccountset() { | |||
| return getContractAccountSet(getLatestBlock()); | |||
| } | |||
| /** | |||
| * 重新检索最新区块,同时更新缓存; | |||
| * | |||
| @@ -111,7 +121,5 @@ public interface LedgerQuery { | |||
| * @return | |||
| */ | |||
| HashDigest retrieveLatestBlockHash(); | |||
| } | |||
| @@ -93,7 +93,7 @@ public class LedgerQueryService implements BlockchainQueryService { | |||
| public long getTransactionCount(HashDigest ledgerHash, long height) { | |||
| checkLedgerHash(ledgerHash); | |||
| LedgerBlock block = ledger.getBlock(height); | |||
| TransactionSet txset = ledger.getTransactionSet(block); | |||
| TransactionQuery txset = ledger.getTransactionSet(block); | |||
| return txset.getTotalCount(); | |||
| } | |||
| @@ -101,7 +101,7 @@ public class LedgerQueryService implements BlockchainQueryService { | |||
| public long getTransactionCount(HashDigest ledgerHash, HashDigest blockHash) { | |||
| checkLedgerHash(ledgerHash); | |||
| LedgerBlock block = ledger.getBlock(blockHash); | |||
| TransactionSet txset = ledger.getTransactionSet(block); | |||
| TransactionQuery txset = ledger.getTransactionSet(block); | |||
| return txset.getTotalCount(); | |||
| } | |||
| @@ -109,7 +109,7 @@ public class LedgerQueryService implements BlockchainQueryService { | |||
| public long getTransactionTotalCount(HashDigest ledgerHash) { | |||
| checkLedgerHash(ledgerHash); | |||
| LedgerBlock block = ledger.getLatestBlock(); | |||
| TransactionSet txset = ledger.getTransactionSet(block); | |||
| TransactionQuery txset = ledger.getTransactionSet(block); | |||
| return txset.getTotalCount(); | |||
| } | |||
| @@ -118,7 +118,7 @@ public class LedgerQueryService implements BlockchainQueryService { | |||
| checkLedgerHash(ledgerHash); | |||
| LedgerBlock block = ledger.getBlock(height); | |||
| DataAccountQuery dataAccountSet = ledger.getDataAccountSet(block); | |||
| return dataAccountSet.getTotalCount(); | |||
| return dataAccountSet.getTotal(); | |||
| } | |||
| @Override | |||
| @@ -126,7 +126,7 @@ public class LedgerQueryService implements BlockchainQueryService { | |||
| checkLedgerHash(ledgerHash); | |||
| LedgerBlock block = ledger.getBlock(blockHash); | |||
| DataAccountQuery dataAccountSet = ledger.getDataAccountSet(block); | |||
| return dataAccountSet.getTotalCount(); | |||
| return dataAccountSet.getTotal(); | |||
| } | |||
| @Override | |||
| @@ -134,7 +134,7 @@ public class LedgerQueryService implements BlockchainQueryService { | |||
| checkLedgerHash(ledgerHash); | |||
| LedgerBlock block = ledger.getLatestBlock(); | |||
| DataAccountQuery dataAccountSet = ledger.getDataAccountSet(block); | |||
| return dataAccountSet.getTotalCount(); | |||
| return dataAccountSet.getTotal(); | |||
| } | |||
| @Override | |||
| @@ -142,7 +142,7 @@ public class LedgerQueryService implements BlockchainQueryService { | |||
| checkLedgerHash(ledgerHash); | |||
| LedgerBlock block = ledger.getBlock(height); | |||
| UserAccountQuery userAccountSet = ledger.getUserAccountSet(block); | |||
| return userAccountSet.getTotalCount(); | |||
| return userAccountSet.getTotal(); | |||
| } | |||
| @Override | |||
| @@ -150,7 +150,7 @@ public class LedgerQueryService implements BlockchainQueryService { | |||
| checkLedgerHash(ledgerHash); | |||
| LedgerBlock block = ledger.getBlock(blockHash); | |||
| UserAccountQuery userAccountSet = ledger.getUserAccountSet(block); | |||
| return userAccountSet.getTotalCount(); | |||
| return userAccountSet.getTotal(); | |||
| } | |||
| @Override | |||
| @@ -158,7 +158,7 @@ public class LedgerQueryService implements BlockchainQueryService { | |||
| checkLedgerHash(ledgerHash); | |||
| LedgerBlock block = ledger.getLatestBlock(); | |||
| UserAccountQuery userAccountSet = ledger.getUserAccountSet(block); | |||
| return userAccountSet.getTotalCount(); | |||
| return userAccountSet.getTotal(); | |||
| } | |||
| @Override | |||
| @@ -166,7 +166,7 @@ public class LedgerQueryService implements BlockchainQueryService { | |||
| checkLedgerHash(ledgerHash); | |||
| LedgerBlock block = ledger.getBlock(height); | |||
| ContractAccountQuery contractAccountSet = ledger.getContractAccountSet(block); | |||
| return contractAccountSet.getTotalCount(); | |||
| return contractAccountSet.getTotal(); | |||
| } | |||
| @Override | |||
| @@ -174,7 +174,7 @@ public class LedgerQueryService implements BlockchainQueryService { | |||
| checkLedgerHash(ledgerHash); | |||
| LedgerBlock block = ledger.getBlock(blockHash); | |||
| ContractAccountQuery contractAccountSet = ledger.getContractAccountSet(block); | |||
| return contractAccountSet.getTotalCount(); | |||
| return contractAccountSet.getTotal(); | |||
| } | |||
| @Override | |||
| @@ -182,14 +182,14 @@ public class LedgerQueryService implements BlockchainQueryService { | |||
| checkLedgerHash(ledgerHash); | |||
| LedgerBlock block = ledger.getLatestBlock(); | |||
| ContractAccountQuery contractAccountSet = ledger.getContractAccountSet(block); | |||
| return contractAccountSet.getTotalCount(); | |||
| return contractAccountSet.getTotal(); | |||
| } | |||
| @Override | |||
| public LedgerTransaction[] getTransactions(HashDigest ledgerHash, long height, int fromIndex, int count) { | |||
| checkLedgerHash(ledgerHash); | |||
| LedgerBlock ledgerBlock = ledger.getBlock(height); | |||
| TransactionSet transactionSet = ledger.getTransactionSet(ledgerBlock); | |||
| TransactionQuery transactionSet = ledger.getTransactionSet(ledgerBlock); | |||
| int lastHeightTxTotalNums = 0; | |||
| if (height > 0) { | |||
| @@ -219,7 +219,7 @@ public class LedgerQueryService implements BlockchainQueryService { | |||
| checkLedgerHash(ledgerHash); | |||
| LedgerBlock ledgerBlock = ledger.getBlock(blockHash); | |||
| long height = ledgerBlock.getHeight(); | |||
| TransactionSet transactionSet = ledger.getTransactionSet(ledgerBlock); | |||
| TransactionQuery transactionSet = ledger.getTransactionSet(ledgerBlock); | |||
| int lastHeightTxTotalNums = 0; | |||
| if (height > 0) { | |||
| @@ -248,7 +248,7 @@ public class LedgerQueryService implements BlockchainQueryService { | |||
| public LedgerTransaction getTransactionByContentHash(HashDigest ledgerHash, HashDigest contentHash) { | |||
| checkLedgerHash(ledgerHash); | |||
| LedgerBlock block = ledger.getLatestBlock(); | |||
| TransactionSet txset = ledger.getTransactionSet(block); | |||
| TransactionQuery txset = ledger.getTransactionSet(block); | |||
| return txset.get(contentHash); | |||
| } | |||
| @@ -256,8 +256,8 @@ public class LedgerQueryService implements BlockchainQueryService { | |||
| public TransactionState getTransactionStateByContentHash(HashDigest ledgerHash, HashDigest contentHash) { | |||
| checkLedgerHash(ledgerHash); | |||
| LedgerBlock block = ledger.getLatestBlock(); | |||
| TransactionSet txset = ledger.getTransactionSet(block); | |||
| return txset.getTxState(contentHash); | |||
| TransactionQuery txset = ledger.getTransactionSet(block); | |||
| return txset.getState(contentHash); | |||
| } | |||
| @Override | |||
| @@ -265,7 +265,7 @@ public class LedgerQueryService implements BlockchainQueryService { | |||
| checkLedgerHash(ledgerHash); | |||
| LedgerBlock block = ledger.getLatestBlock(); | |||
| UserAccountQuery userAccountSet = ledger.getUserAccountSet(block); | |||
| return userAccountSet.getUser(address); | |||
| return userAccountSet.getAccount(address); | |||
| } | |||
| @@ -274,7 +274,7 @@ public class LedgerQueryService implements BlockchainQueryService { | |||
| checkLedgerHash(ledgerHash); | |||
| LedgerBlock block = ledger.getLatestBlock(); | |||
| DataAccountQuery dataAccountSet = ledger.getDataAccountSet(block); | |||
| return dataAccountSet.getDataAccount(Bytes.fromBase58(address)); | |||
| return dataAccountSet.getAccount(Bytes.fromBase58(address)); | |||
| } | |||
| @Override | |||
| @@ -285,7 +285,7 @@ public class LedgerQueryService implements BlockchainQueryService { | |||
| checkLedgerHash(ledgerHash); | |||
| LedgerBlock block = ledger.getLatestBlock(); | |||
| DataAccountQuery dataAccountSet = ledger.getDataAccountSet(block); | |||
| DataAccount dataAccount = dataAccountSet.getDataAccount(Bytes.fromBase58(address)); | |||
| DataAccount dataAccount = dataAccountSet.getAccount(Bytes.fromBase58(address)); | |||
| KVDataEntry[] entries = new KVDataEntry[keys.length]; | |||
| long ver; | |||
| @@ -333,7 +333,7 @@ public class LedgerQueryService implements BlockchainQueryService { | |||
| checkLedgerHash(ledgerHash); | |||
| LedgerBlock block = ledger.getLatestBlock(); | |||
| DataAccountQuery dataAccountSet = ledger.getDataAccountSet(block); | |||
| DataAccount dataAccount = dataAccountSet.getDataAccount(Bytes.fromBase58(address)); | |||
| DataAccount dataAccount = dataAccountSet.getAccount(Bytes.fromBase58(address)); | |||
| KVDataEntry[] entries = new KVDataEntry[keys.length]; | |||
| long ver = -1; | |||
| @@ -363,7 +363,7 @@ public class LedgerQueryService implements BlockchainQueryService { | |||
| checkLedgerHash(ledgerHash); | |||
| LedgerBlock block = ledger.getLatestBlock(); | |||
| DataAccountQuery dataAccountSet = ledger.getDataAccountSet(block); | |||
| DataAccount dataAccount = dataAccountSet.getDataAccount(Bytes.fromBase58(address)); | |||
| DataAccount dataAccount = dataAccountSet.getAccount(Bytes.fromBase58(address)); | |||
| int pages[] = QueryUtil.calFromIndexAndCount(fromIndex, count, (int) dataAccount.getDataEntriesTotalCount()); | |||
| return dataAccount.getDataEntries(pages[0], pages[1]); | |||
| @@ -374,7 +374,7 @@ public class LedgerQueryService implements BlockchainQueryService { | |||
| checkLedgerHash(ledgerHash); | |||
| LedgerBlock block = ledger.getLatestBlock(); | |||
| DataAccountQuery dataAccountSet = ledger.getDataAccountSet(block); | |||
| DataAccount dataAccount = dataAccountSet.getDataAccount(Bytes.fromBase58(address)); | |||
| DataAccount dataAccount = dataAccountSet.getAccount(Bytes.fromBase58(address)); | |||
| return dataAccount.getDataEntriesTotalCount(); | |||
| } | |||
| @@ -384,7 +384,7 @@ public class LedgerQueryService implements BlockchainQueryService { | |||
| checkLedgerHash(ledgerHash); | |||
| LedgerBlock block = ledger.getLatestBlock(); | |||
| ContractAccountQuery contractAccountSet = ledger.getContractAccountSet(block); | |||
| return contractAccountSet.getContract(Bytes.fromBase58(address)); | |||
| return contractAccountSet.getAccount(Bytes.fromBase58(address)); | |||
| } | |||
| @Override | |||
| @@ -392,8 +392,8 @@ public class LedgerQueryService implements BlockchainQueryService { | |||
| checkLedgerHash(ledgerHash); | |||
| LedgerBlock block = ledger.getLatestBlock(); | |||
| UserAccountQuery userAccountSet = ledger.getUserAccountSet(block); | |||
| int pages[] = QueryUtil.calFromIndexAndCount(fromIndex, count, (int) userAccountSet.getTotalCount()); | |||
| return userAccountSet.getAccounts(pages[0], pages[1]); | |||
| int pages[] = QueryUtil.calFromIndexAndCount(fromIndex, count, (int) userAccountSet.getTotal()); | |||
| return userAccountSet.getHeaders(pages[0], pages[1]); | |||
| } | |||
| @Override | |||
| @@ -401,8 +401,8 @@ public class LedgerQueryService implements BlockchainQueryService { | |||
| checkLedgerHash(ledgerHash); | |||
| LedgerBlock block = ledger.getLatestBlock(); | |||
| DataAccountQuery dataAccountSet = ledger.getDataAccountSet(block); | |||
| int pages[] = QueryUtil.calFromIndexAndCount(fromIndex, count, (int) dataAccountSet.getTotalCount()); | |||
| return dataAccountSet.getAccounts(pages[0], pages[1]); | |||
| int pages[] = QueryUtil.calFromIndexAndCount(fromIndex, count, (int) dataAccountSet.getTotal()); | |||
| return dataAccountSet.getHeaders(pages[0], pages[1]); | |||
| } | |||
| @Override | |||
| @@ -410,8 +410,8 @@ public class LedgerQueryService implements BlockchainQueryService { | |||
| checkLedgerHash(ledgerHash); | |||
| LedgerBlock block = ledger.getLatestBlock(); | |||
| ContractAccountQuery contractAccountSet = ledger.getContractAccountSet(block); | |||
| int pages[] = QueryUtil.calFromIndexAndCount(fromIndex, count, (int) contractAccountSet.getTotalCount()); | |||
| return contractAccountSet.getAccounts(pages[0], pages[1]); | |||
| int pages[] = QueryUtil.calFromIndexAndCount(fromIndex, count, (int) contractAccountSet.getTotal()); | |||
| return contractAccountSet.getHeaders(pages[0], pages[1]); | |||
| } | |||
| } | |||
| @@ -118,7 +118,7 @@ class LedgerRepositoryImpl implements LedgerRepository { | |||
| private LedgerState retrieveLatestState() { | |||
| LedgerBlock latestBlock = innerGetBlock(innerGetLatestBlockHeight()); | |||
| LedgerDataset ledgerDataset = innerGetLedgerDataset(latestBlock); | |||
| TransactionSet txSet = loadTransactionSet(latestBlock.getTransactionSetHash(), | |||
| TransactionQuery txSet = loadTransactionSet(latestBlock.getTransactionSetHash(), | |||
| ledgerDataset.getAdminDataset().getSettings().getCryptoSetting(), keyPrefix, exPolicyStorage, | |||
| versioningStorage, true); | |||
| this.latestState = new LedgerState(latestBlock, ledgerDataset, txSet); | |||
| @@ -253,7 +253,7 @@ class LedgerRepositoryImpl implements LedgerRepository { | |||
| } | |||
| @Override | |||
| public TransactionSet getTransactionSet(LedgerBlock block) { | |||
| public TransactionQuery getTransactionSet(LedgerBlock block) { | |||
| long height = getLatestBlockHeight(); | |||
| if (height == block.getHeight()) { | |||
| // 从缓存中返回最新区块的数据集; | |||
| @@ -354,7 +354,7 @@ class LedgerRepositoryImpl implements LedgerRepository { | |||
| } | |||
| @Override | |||
| public LedgerDataset getDataSet(LedgerBlock block) { | |||
| public LedgerDataset getLedgerData(LedgerBlock block) { | |||
| long height = getLatestBlockHeight(); | |||
| if (height == block.getHeight()) { | |||
| return latestState.getLedgerDataset(); | |||
| @@ -579,11 +579,11 @@ class LedgerRepositoryImpl implements LedgerRepository { | |||
| private final LedgerBlock block; | |||
| private final TransactionSet transactionSet; | |||
| private final TransactionQuery transactionSet; | |||
| private final LedgerDataset ledgerDataset; | |||
| public LedgerState(LedgerBlock block, LedgerDataset ledgerDataset, TransactionSet transactionSet) { | |||
| public LedgerState(LedgerBlock block, LedgerDataset ledgerDataset, TransactionQuery transactionSet) { | |||
| this.block = block; | |||
| this.ledgerDataset = ledgerDataset; | |||
| this.transactionSet = transactionSet; | |||
| @@ -610,7 +610,7 @@ class LedgerRepositoryImpl implements LedgerRepository { | |||
| return ledgerDataset.getUserAccountSet(); | |||
| } | |||
| public TransactionSet getTransactionSet() { | |||
| public TransactionQuery getTransactionSet() { | |||
| return transactionSet; | |||
| } | |||
| @@ -24,7 +24,7 @@ public interface LedgerTransactionContext { | |||
| * | |||
| * @return | |||
| */ | |||
| TransactionSet getTransactionSet(); | |||
| TransactionQuery getTransactionSet(); | |||
| /** | |||
| * 交易请求; | |||
| @@ -79,7 +79,7 @@ public class TransactionBatchProcessor implements TransactionBatchProcess { | |||
| this.handlesRegisteration = handlesRegisteration; | |||
| LedgerBlock ledgerBlock = ledgerRepo.getLatestBlock(); | |||
| LedgerDataQuery ledgerDataQuery = ledgerRepo.getDataSet(ledgerBlock); | |||
| LedgerDataQuery ledgerDataQuery = ledgerRepo.getLedgerData(ledgerBlock); | |||
| LedgerAdminDataQuery previousAdminDataset = ledgerDataQuery.getAdminDataset(); | |||
| this.securityManager = new LedgerSecurityManagerImpl(previousAdminDataset.getAdminInfo().getRolePrivileges(), | |||
| previousAdminDataset.getAdminInfo().getAuthorizations(), previousAdminDataset.getParticipantDataset(), | |||
| @@ -93,7 +93,7 @@ public class TransactionBatchProcessor implements TransactionBatchProcess { | |||
| OperationHandleRegisteration handlesRegisteration) { | |||
| LedgerBlock ledgerBlock = ledgerRepo.getLatestBlock(); | |||
| LedgerEditor newBlockEditor = ledgerRepo.createNextBlock(); | |||
| LedgerDataQuery previousBlockDataset = ledgerRepo.getDataSet(ledgerBlock); | |||
| LedgerDataQuery previousBlockDataset = ledgerRepo.getLedgerData(ledgerBlock); | |||
| LedgerAdminDataQuery previousAdminDataset = previousBlockDataset.getAdminDataset(); | |||
| LedgerSecurityManager securityManager = new LedgerSecurityManagerImpl( | |||
| @@ -0,0 +1,24 @@ | |||
| package com.jd.blockchain.ledger.core; | |||
| import com.jd.blockchain.crypto.HashDigest; | |||
| import com.jd.blockchain.ledger.LedgerTransaction; | |||
| import com.jd.blockchain.ledger.TransactionState; | |||
| public interface TransactionQuery extends MerkleProvable { | |||
| LedgerTransaction[] getTxs(int fromIndex, int count); | |||
| byte[][] getValuesByIndex(int fromIndex, int count); | |||
| long getTotalCount(); | |||
| /** | |||
| * @param txContentHash | |||
| * Base58 编码的交易内容的哈希; | |||
| * @return | |||
| */ | |||
| LedgerTransaction get(HashDigest txContentHash); | |||
| TransactionState getState(HashDigest txContentHash); | |||
| } | |||
| @@ -13,7 +13,7 @@ import com.jd.blockchain.storage.service.VersioningKVStorage; | |||
| import com.jd.blockchain.utils.Bytes; | |||
| import com.jd.blockchain.utils.Transactional; | |||
| public class TransactionSet implements Transactional, MerkleProvable { | |||
| public class TransactionSet implements Transactional, TransactionQuery { | |||
| static { | |||
| DataContractRegistry.register(LedgerTransaction.class); | |||
| @@ -25,6 +25,7 @@ public class TransactionSet implements Transactional, MerkleProvable { | |||
| private MerkleDataSet txSet; | |||
| @Override | |||
| public LedgerTransaction[] getTxs(int fromIndex, int count) { | |||
| if (count > LedgerConsts.MAX_LIST_COUNT) { | |||
| throw new IllegalArgumentException("Count exceed the upper limit[" + LedgerConsts.MAX_LIST_COUNT + "]!"); | |||
| @@ -38,6 +39,7 @@ public class TransactionSet implements Transactional, MerkleProvable { | |||
| return ledgerTransactions; | |||
| } | |||
| @Override | |||
| public byte[][] getValuesByIndex(int fromIndex, int count) { | |||
| byte[][] values = new byte[count][]; | |||
| for (int i = 0; i < count; i++) { | |||
| @@ -57,6 +59,7 @@ public class TransactionSet implements Transactional, MerkleProvable { | |||
| return txSet.getProof(key); | |||
| } | |||
| @Override | |||
| public long getTotalCount() { | |||
| // 每写入一个交易,同时写入交易内容Hash与交易结果的索引,因此交易记录数为集合总记录数除以 2; | |||
| return txSet.getDataCount() / 2; | |||
| @@ -113,10 +116,10 @@ public class TransactionSet implements Transactional, MerkleProvable { | |||
| } | |||
| /** | |||
| * @param txContentHash | |||
| * Base58 编码的交易内容的哈希; | |||
| * @param txContentHash Base58 编码的交易内容的哈希; | |||
| * @return | |||
| */ | |||
| @Override | |||
| public LedgerTransaction get(HashDigest txContentHash) { | |||
| // transaction has only one version; | |||
| Bytes key = new Bytes(txContentHash.toBytes()); | |||
| @@ -129,7 +132,8 @@ public class TransactionSet implements Transactional, MerkleProvable { | |||
| return tx; | |||
| } | |||
| public TransactionState getTxState(HashDigest txContentHash) { | |||
| @Override | |||
| public TransactionState getState(HashDigest txContentHash) { | |||
| Bytes resultKey = encodeTxStateKey(txContentHash); | |||
| // transaction has only one version; | |||
| byte[] bytes = txSet.getValue(resultKey, 0); | |||
| @@ -154,7 +158,7 @@ public class TransactionSet implements Transactional, MerkleProvable { | |||
| public boolean isReadonly() { | |||
| return txSet.isReadonly(); | |||
| } | |||
| void setReadonly() { | |||
| txSet.setReadonly(); | |||
| } | |||
| @@ -1,31 +1,5 @@ | |||
| package com.jd.blockchain.ledger.core; | |||
| import com.jd.blockchain.crypto.HashDigest; | |||
| import com.jd.blockchain.ledger.AccountHeader; | |||
| import com.jd.blockchain.ledger.MerkleProof; | |||
| import com.jd.blockchain.utils.Bytes; | |||
| public interface UserAccountQuery { | |||
| AccountHeader[] getAccounts(int fromIndex, int count); | |||
| /** | |||
| * 返回用户总数; | |||
| * | |||
| * @return | |||
| */ | |||
| long getTotalCount(); | |||
| HashDigest getRootHash(); | |||
| MerkleProof getProof(Bytes key); | |||
| UserAccount getUser(String address); | |||
| UserAccount getUser(Bytes address); | |||
| boolean contains(Bytes address); | |||
| UserAccount getUser(Bytes address, long version); | |||
| public interface UserAccountQuery extends AccountQuery<UserAccount> { | |||
| } | |||
| @@ -15,7 +15,7 @@ import com.jd.blockchain.utils.Transactional; | |||
| * @author huanghaiquan | |||
| * | |||
| */ | |||
| public class UserAccountSet implements Transactional, MerkleProvable, UserAccountQuery { | |||
| public class UserAccountSet implements Transactional, UserAccountQuery { | |||
| private AccountSet accountSet; | |||
| @@ -32,7 +32,7 @@ public class UserAccountSet implements Transactional, MerkleProvable, UserAccoun | |||
| } | |||
| @Override | |||
| public AccountHeader[] getAccounts(int fromIndex, int count) { | |||
| public AccountHeader[] getHeaders(int fromIndex, int count) { | |||
| return accountSet.getAccounts(fromIndex,count); | |||
| } | |||
| @@ -42,7 +42,7 @@ public class UserAccountSet implements Transactional, MerkleProvable, UserAccoun | |||
| * @return | |||
| */ | |||
| @Override | |||
| public long getTotalCount() { | |||
| public long getTotal() { | |||
| return accountSet.getTotalCount(); | |||
| } | |||
| @@ -65,12 +65,12 @@ public class UserAccountSet implements Transactional, MerkleProvable, UserAccoun | |||
| } | |||
| @Override | |||
| public UserAccount getUser(String address) { | |||
| return getUser(Bytes.fromBase58(address)); | |||
| public UserAccount getAccount(String address) { | |||
| return getAccount(Bytes.fromBase58(address)); | |||
| } | |||
| @Override | |||
| public UserAccount getUser(Bytes address) { | |||
| public UserAccount getAccount(Bytes address) { | |||
| BaseAccount baseAccount = accountSet.getAccount(address); | |||
| return new UserAccount(baseAccount); | |||
| } | |||
| @@ -81,7 +81,7 @@ public class UserAccountSet implements Transactional, MerkleProvable, UserAccoun | |||
| } | |||
| @Override | |||
| public UserAccount getUser(Bytes address, long version) { | |||
| public UserAccount getAccount(Bytes address, long version) { | |||
| BaseAccount baseAccount = accountSet.getAccount(address, version); | |||
| return new UserAccount(baseAccount); | |||
| } | |||
| @@ -57,7 +57,7 @@ public abstract class AbtractContractEventSendOperationHandle implements Operati | |||
| ContractLedgerContext ledgerContext = new ContractLedgerContext(queryService, opHandleContext); | |||
| // 先检查合约引擎是否已经加载合约;如果未加载,再从账本中读取合约代码并装载到引擎中执行; | |||
| ContractAccount contract = contractSet.getContract(contractOP.getContractAddress()); | |||
| ContractAccount contract = contractSet.getAccount(contractOP.getContractAddress()); | |||
| if (contract == null) { | |||
| throw new LedgerException(String.format("Contract was not registered! --[ContractAddress=%s]", | |||
| contractOP.getContractAddress())); | |||
| @@ -30,7 +30,7 @@ public class DataAccountKVSetOperationHandle extends AbstractLedgerOperationHand | |||
| securityPolicy.checkEndpointPermission(LedgerPermission.WRITE_DATA_ACCOUNT, MultiIDsPolicy.AT_LEAST_ONE); | |||
| // 操作账本; | |||
| DataAccount account = newBlockDataset.getDataAccountSet().getDataAccount(kvWriteOp.getAccountAddress()); | |||
| DataAccount account = newBlockDataset.getDataAccountSet().getAccount(kvWriteOp.getAccountAddress()); | |||
| if (account == null) { | |||
| throw new DataAccountDoesNotExistException("DataAccount doesn't exist!"); | |||
| } | |||
| @@ -106,7 +106,7 @@ public class ContractInvokingTest { | |||
| deploy(ledgerRepo, ledgerManager, opReg, ledgerHash, contractKey); | |||
| // 创建新区块的交易处理器; | |||
| LedgerBlock preBlock = ledgerRepo.getLatestBlock(); | |||
| LedgerDataQuery previousBlockDataset = ledgerRepo.getDataSet(preBlock); | |||
| LedgerDataQuery previousBlockDataset = ledgerRepo.getLedgerData(preBlock); | |||
| // 加载合约 | |||
| LedgerEditor newBlockEditor = ledgerRepo.createNextBlock(); | |||
| @@ -181,7 +181,7 @@ public class ContractInvokingTest { | |||
| // 创建新区块的交易处理器; | |||
| LedgerBlock preBlock = ledgerRepo.getLatestBlock(); | |||
| LedgerDataQuery previousBlockDataset = ledgerRepo.getDataSet(preBlock); | |||
| LedgerDataQuery previousBlockDataset = ledgerRepo.getLedgerData(preBlock); | |||
| // 加载合约 | |||
| LedgerEditor newBlockEditor = ledgerRepo.createNextBlock(); | |||
| @@ -218,7 +218,7 @@ public class ContractInvokingTest { | |||
| TransactionBatchResultHandle txResultHandle = txbatchProcessor.prepare(); | |||
| txResultHandle.commit(); | |||
| BytesValue latestValue = ledgerRepo.getDataAccountSet().getDataAccount(kpDataAccount.getAddress()).getBytes(key, | |||
| BytesValue latestValue = ledgerRepo.getDataAccountSet().getAccount(kpDataAccount.getAddress()).getBytes(key, | |||
| -1); | |||
| System.out.printf("latest value=[%s] %s \r\n", latestValue.getType(), latestValue.getValue().toUTF8String()); | |||
| @@ -278,9 +278,9 @@ public class ContractInvokingTest { | |||
| } | |||
| }); | |||
| // 预期数据都能够正常写入; | |||
| KVDataEntry kv1 = ledgerRepo.getDataAccountSet().getDataAccount(kpDataAccount.getAddress()).getDataEntry("K1", | |||
| KVDataEntry kv1 = ledgerRepo.getDataAccountSet().getAccount(kpDataAccount.getAddress()).getDataEntry("K1", | |||
| 0); | |||
| KVDataEntry kv2 = ledgerRepo.getDataAccountSet().getDataAccount(kpDataAccount.getAddress()).getDataEntry("K2", | |||
| KVDataEntry kv2 = ledgerRepo.getDataAccountSet().getAccount(kpDataAccount.getAddress()).getDataEntry("K2", | |||
| 0); | |||
| assertEquals(0, kv1.getVersion()); | |||
| assertEquals(0, kv2.getVersion()); | |||
| @@ -299,8 +299,8 @@ public class ContractInvokingTest { | |||
| } | |||
| }); | |||
| // 预期数据都能够正常写入; | |||
| kv1 = ledgerRepo.getDataAccountSet().getDataAccount(kpDataAccount.getAddress()).getDataEntry("K1", 1); | |||
| kv2 = ledgerRepo.getDataAccountSet().getDataAccount(kpDataAccount.getAddress()).getDataEntry("K2", 1); | |||
| kv1 = ledgerRepo.getDataAccountSet().getAccount(kpDataAccount.getAddress()).getDataEntry("K1", 1); | |||
| kv2 = ledgerRepo.getDataAccountSet().getAccount(kpDataAccount.getAddress()).getDataEntry("K2", 1); | |||
| assertEquals(1, kv1.getVersion()); | |||
| assertEquals(1, kv2.getVersion()); | |||
| assertEquals("V1-1", kv1.getValue()); | |||
| @@ -318,10 +318,10 @@ public class ContractInvokingTest { | |||
| } | |||
| }); | |||
| // 预期数据都能够正常写入; | |||
| kv1 = ledgerRepo.getDataAccountSet().getDataAccount(kpDataAccount.getAddress()).getDataEntry("K1", 1); | |||
| kv1 = ledgerRepo.getDataAccountSet().getAccount(kpDataAccount.getAddress()).getDataEntry("K1", 1); | |||
| assertEquals(1, kv1.getVersion()); | |||
| assertEquals("V1-1", kv1.getValue()); | |||
| kv1 = ledgerRepo.getDataAccountSet().getDataAccount(kpDataAccount.getAddress()).getDataEntry("K1", 2); | |||
| kv1 = ledgerRepo.getDataAccountSet().getAccount(kpDataAccount.getAddress()).getDataEntry("K1", 2); | |||
| assertEquals(-1, kv1.getVersion()); | |||
| assertEquals(null, kv1.getValue()); | |||
| @@ -330,7 +330,7 @@ public class ContractInvokingTest { | |||
| private LedgerBlock buildBlock(LedgerRepository ledgerRepo, LedgerService ledgerService, | |||
| OperationHandleRegisteration opReg, TxDefinitor txDefinitor) { | |||
| LedgerBlock preBlock = ledgerRepo.getLatestBlock(); | |||
| LedgerDataQuery previousBlockDataset = ledgerRepo.getDataSet(preBlock); | |||
| LedgerDataQuery previousBlockDataset = ledgerRepo.getLedgerData(preBlock); | |||
| LedgerEditor newBlockEditor = ledgerRepo.createNextBlock(); | |||
| TransactionBatchProcessor txbatchProcessor = new TransactionBatchProcessor(getSecurityManager(), newBlockEditor, | |||
| ledgerRepo, opReg); | |||
| @@ -363,7 +363,7 @@ public class ContractInvokingTest { | |||
| private void registerDataAccount(LedgerRepository ledgerRepo, LedgerManager ledgerManager, | |||
| DefaultOperationHandleRegisteration opReg, HashDigest ledgerHash, BlockchainKeypair kpDataAccount) { | |||
| LedgerBlock preBlock = ledgerRepo.getLatestBlock(); | |||
| LedgerDataQuery previousBlockDataset = ledgerRepo.getDataSet(preBlock); | |||
| LedgerDataQuery previousBlockDataset = ledgerRepo.getLedgerData(preBlock); | |||
| // 加载合约 | |||
| LedgerEditor newBlockEditor = ledgerRepo.createNextBlock(); | |||
| @@ -393,7 +393,7 @@ public class ContractInvokingTest { | |||
| DefaultOperationHandleRegisteration opReg, HashDigest ledgerHash, BlockchainKeypair contractKey) { | |||
| // 创建新区块的交易处理器; | |||
| LedgerBlock preBlock = ledgerRepo.getLatestBlock(); | |||
| LedgerDataQuery previousBlockDataset = ledgerRepo.getDataSet(preBlock); | |||
| LedgerDataQuery previousBlockDataset = ledgerRepo.getLedgerData(preBlock); | |||
| // 加载合约 | |||
| LedgerEditor newBlockEditor = ledgerRepo.createNextBlock(); | |||
| @@ -84,8 +84,8 @@ public class TransactionBatchProcessorTest { | |||
| LedgerRepository ledgerRepo = ledgerManager.register(ledgerHash, STORAGE); | |||
| // 验证参与方账户的存在; | |||
| LedgerDataQuery previousBlockDataset = ledgerRepo.getDataSet(ledgerRepo.getLatestBlock()); | |||
| UserAccount user0 = previousBlockDataset.getUserAccountSet().getUser(parti0.getAddress()); | |||
| LedgerDataQuery previousBlockDataset = ledgerRepo.getLedgerData(ledgerRepo.getLatestBlock()); | |||
| UserAccount user0 = previousBlockDataset.getUserAccountSet().getAccount(parti0.getAddress()); | |||
| assertNotNull(user0); | |||
| boolean partiRegistered = previousBlockDataset.getUserAccountSet().contains(parti0.getAddress()); | |||
| assertTrue(partiRegistered); | |||
| @@ -144,8 +144,8 @@ public class TransactionBatchProcessorTest { | |||
| LedgerRepository ledgerRepo = ledgerManager.register(ledgerHash, STORAGE); | |||
| // 验证参与方账户的存在; | |||
| LedgerDataQuery previousBlockDataset = ledgerRepo.getDataSet(ledgerRepo.getLatestBlock()); | |||
| UserAccount user0 = previousBlockDataset.getUserAccountSet().getUser(parti0.getAddress()); | |||
| LedgerDataQuery previousBlockDataset = ledgerRepo.getLedgerData(ledgerRepo.getLatestBlock()); | |||
| UserAccount user0 = previousBlockDataset.getUserAccountSet().getAccount(parti0.getAddress()); | |||
| assertNotNull(user0); | |||
| boolean partiRegistered = previousBlockDataset.getUserAccountSet().contains(parti0.getAddress()); | |||
| assertTrue(partiRegistered); | |||
| @@ -183,7 +183,7 @@ public class TransactionBatchProcessorTest { | |||
| assertEquals(newBlock.getHash(), latestBlock.getHash()); | |||
| assertEquals(1, newBlock.getHeight()); | |||
| LedgerDataQuery ledgerDS = ledgerRepo.getDataSet(latestBlock); | |||
| LedgerDataQuery ledgerDS = ledgerRepo.getLedgerData(latestBlock); | |||
| boolean existUser1 = ledgerDS.getUserAccountSet().contains(userKeypair1.getAddress()); | |||
| boolean existUser2 = ledgerDS.getUserAccountSet().contains(userKeypair2.getAddress()); | |||
| assertTrue(existUser1); | |||
| @@ -202,8 +202,8 @@ public class TransactionBatchProcessorTest { | |||
| LedgerRepository ledgerRepo = ledgerManager.register(ledgerHash, STORAGE); | |||
| // 验证参与方账户的存在; | |||
| LedgerDataQuery previousBlockDataset = ledgerRepo.getDataSet(ledgerRepo.getLatestBlock()); | |||
| UserAccount user0 = previousBlockDataset.getUserAccountSet().getUser(parti0.getAddress()); | |||
| LedgerDataQuery previousBlockDataset = ledgerRepo.getLedgerData(ledgerRepo.getLatestBlock()); | |||
| UserAccount user0 = previousBlockDataset.getUserAccountSet().getAccount(parti0.getAddress()); | |||
| assertNotNull(user0); | |||
| boolean partiRegistered = previousBlockDataset.getUserAccountSet().contains(parti0.getAddress()); | |||
| assertTrue(partiRegistered); | |||
| @@ -261,7 +261,7 @@ public class TransactionBatchProcessorTest { | |||
| assertNotNull(tx3); | |||
| assertEquals(TransactionState.SUCCESS, tx3.getExecutionState()); | |||
| LedgerDataQuery ledgerDS = ledgerRepo.getDataSet(latestBlock); | |||
| LedgerDataQuery ledgerDS = ledgerRepo.getLedgerData(latestBlock); | |||
| boolean existUser1 = ledgerDS.getUserAccountSet().contains(userKeypair1.getAddress()); | |||
| boolean existUser2 = ledgerDS.getUserAccountSet().contains(userKeypair2.getAddress()); | |||
| boolean existUser3 = ledgerDS.getUserAccountSet().contains(userKeypair3.getAddress()); | |||
| @@ -282,8 +282,8 @@ public class TransactionBatchProcessorTest { | |||
| LedgerRepository ledgerRepo = ledgerManager.register(ledgerHash, STORAGE); | |||
| // 验证参与方账户的存在; | |||
| LedgerDataQuery previousBlockDataset = ledgerRepo.getDataSet(ledgerRepo.getLatestBlock()); | |||
| UserAccount user0 = previousBlockDataset.getUserAccountSet().getUser(parti0.getAddress()); | |||
| LedgerDataQuery previousBlockDataset = ledgerRepo.getLedgerData(ledgerRepo.getLatestBlock()); | |||
| UserAccount user0 = previousBlockDataset.getUserAccountSet().getAccount(parti0.getAddress()); | |||
| assertNotNull(user0); | |||
| boolean partiRegistered = previousBlockDataset.getUserAccountSet().contains(parti0.getAddress()); | |||
| assertTrue(partiRegistered); | |||
| @@ -305,7 +305,7 @@ public class TransactionBatchProcessorTest { | |||
| newBlockEditor.commit(); | |||
| assertEquals(TransactionState.SUCCESS, txResp1.getExecutionState()); | |||
| DataAccount dataAccount = ledgerRepo.getDataAccountSet().getDataAccount(dataAccountKeypair.getAddress()); | |||
| DataAccount dataAccount = ledgerRepo.getDataAccountSet().getAccount(dataAccountKeypair.getAddress()); | |||
| assertNotNull(dataAccount); | |||
| // 正确写入 KV 数据; | |||
| @@ -321,7 +321,7 @@ public class TransactionBatchProcessorTest { | |||
| "K1", "V-1-2", 0, ledgerHash, parti0, parti0); | |||
| newBlockEditor = ledgerRepo.createNextBlock(); | |||
| previousBlockDataset = ledgerRepo.getDataSet(ledgerRepo.getLatestBlock()); | |||
| previousBlockDataset = ledgerRepo.getLedgerData(ledgerRepo.getLatestBlock()); | |||
| txbatchProcessor = new TransactionBatchProcessor(securityManager, newBlockEditor, ledgerRepo, opReg); | |||
| txbatchProcessor.schedule(txreq1); | |||
| @@ -332,13 +332,13 @@ public class TransactionBatchProcessorTest { | |||
| newBlock = newBlockEditor.prepare(); | |||
| newBlockEditor.commit(); | |||
| BytesValue v1_0 = ledgerRepo.getDataAccountSet().getDataAccount(dataAccountKeypair.getAddress()).getBytes("K1", | |||
| BytesValue v1_0 = ledgerRepo.getDataAccountSet().getAccount(dataAccountKeypair.getAddress()).getBytes("K1", | |||
| 0); | |||
| BytesValue v1_1 = ledgerRepo.getDataAccountSet().getDataAccount(dataAccountKeypair.getAddress()).getBytes("K1", | |||
| BytesValue v1_1 = ledgerRepo.getDataAccountSet().getAccount(dataAccountKeypair.getAddress()).getBytes("K1", | |||
| 1); | |||
| BytesValue v2 = ledgerRepo.getDataAccountSet().getDataAccount(dataAccountKeypair.getAddress()).getBytes("K2", | |||
| BytesValue v2 = ledgerRepo.getDataAccountSet().getAccount(dataAccountKeypair.getAddress()).getBytes("K2", | |||
| 0); | |||
| BytesValue v3 = ledgerRepo.getDataAccountSet().getDataAccount(dataAccountKeypair.getAddress()).getBytes("K3", | |||
| BytesValue v3 = ledgerRepo.getDataAccountSet().getAccount(dataAccountKeypair.getAddress()).getBytes("K3", | |||
| 0); | |||
| assertNotNull(v1_0); | |||
| @@ -360,7 +360,7 @@ public class TransactionBatchProcessorTest { | |||
| "K1", "V-1-3", 0, ledgerHash, parti0, parti0); | |||
| newBlockEditor = ledgerRepo.createNextBlock(); | |||
| previousBlockDataset = ledgerRepo.getDataSet(ledgerRepo.getLatestBlock()); | |||
| previousBlockDataset = ledgerRepo.getLedgerData(ledgerRepo.getLatestBlock()); | |||
| txbatchProcessor = new TransactionBatchProcessor(securityManager, newBlockEditor, ledgerRepo, opReg); | |||
| txbatchProcessor.schedule(txreq5); | |||
| @@ -376,15 +376,15 @@ public class TransactionBatchProcessorTest { | |||
| newBlock = newBlockEditor.prepare(); | |||
| newBlockEditor.commit(); | |||
| BytesValue v1 = ledgerRepo.getDataAccountSet().getDataAccount(dataAccountKeypair.getAddress()).getBytes("K1"); | |||
| v3 = ledgerRepo.getDataAccountSet().getDataAccount(dataAccountKeypair.getAddress()).getBytes("K3"); | |||
| BytesValue v1 = ledgerRepo.getDataAccountSet().getAccount(dataAccountKeypair.getAddress()).getBytes("K1"); | |||
| v3 = ledgerRepo.getDataAccountSet().getAccount(dataAccountKeypair.getAddress()).getBytes("K3"); | |||
| // k1 的版本仍然为1,没有更新; | |||
| long k1_version = ledgerRepo.getDataAccountSet().getDataAccount(dataAccountKeypair.getAddress()) | |||
| long k1_version = ledgerRepo.getDataAccountSet().getAccount(dataAccountKeypair.getAddress()) | |||
| .getDataVersion("K1"); | |||
| assertEquals(1, k1_version); | |||
| long k3_version = ledgerRepo.getDataAccountSet().getDataAccount(dataAccountKeypair.getAddress()) | |||
| long k3_version = ledgerRepo.getDataAccountSet().getAccount(dataAccountKeypair.getAddress()) | |||
| .getDataVersion("K3"); | |||
| assertEquals(1, k3_version); | |||
| @@ -17,6 +17,7 @@ import com.jd.blockchain.binaryproto.DataContractRegistry; | |||
| import com.jd.blockchain.crypto.HashDigest; | |||
| import com.jd.blockchain.ledger.DataAccountKVSetOperation.KVWriteEntry; | |||
| import com.jd.blockchain.ledger.core.LedgerTransactionData; | |||
| import com.jd.blockchain.ledger.core.TransactionQuery; | |||
| import com.jd.blockchain.ledger.core.TransactionSet; | |||
| import com.jd.blockchain.ledger.core.TransactionStagedSnapshot; | |||
| import com.jd.blockchain.storage.service.utils.MemoryKVStorage; | |||
| @@ -103,7 +104,7 @@ public class TransactionSetTest { | |||
| assertEquals(5, tx.getTransactionContent().getOperations().length); | |||
| // Reload ; | |||
| TransactionSet reloadTxset = new TransactionSet(txsetRootHash, defCryptoSetting, keyPrefix, testStorage, | |||
| TransactionQuery reloadTxset = new TransactionSet(txsetRootHash, defCryptoSetting, keyPrefix, testStorage, | |||
| testStorage, true); | |||
| assertEquals(1, reloadTxset.getTotalCount()); | |||
| @@ -5,12 +5,7 @@ import java.lang.annotation.Retention; | |||
| import java.lang.annotation.RetentionPolicy; | |||
| import java.lang.annotation.Target; | |||
| /** | |||
| * HTTP 服务方法; | |||
| * | |||
| * @author haiq | |||
| * | |||
| */ | |||
| @Target({ ElementType.METHOD }) | |||
| @Retention(RetentionPolicy.RUNTIME) | |||
| public @interface EventHandle { | |||
| @@ -20,7 +20,7 @@ import com.jd.blockchain.ledger.core.DataAccountQuery; | |||
| import com.jd.blockchain.ledger.core.LedgerQuery; | |||
| import com.jd.blockchain.ledger.core.LedgerService; | |||
| import com.jd.blockchain.ledger.core.ParticipantCertData; | |||
| import com.jd.blockchain.ledger.core.TransactionSet; | |||
| import com.jd.blockchain.ledger.core.TransactionQuery; | |||
| import com.jd.blockchain.ledger.core.UserAccountQuery; | |||
| import com.jd.blockchain.transaction.BlockchainQueryService; | |||
| import com.jd.blockchain.utils.Bytes; | |||
| @@ -116,7 +116,7 @@ public class LedgerQueryController implements BlockchainQueryService { | |||
| @PathVariable(name = "blockHeight") long blockHeight) { | |||
| LedgerQuery ledger = ledgerService.getLedger(ledgerHash); | |||
| LedgerBlock block = ledger.getBlock(blockHeight); | |||
| TransactionSet txSet = ledger.getTransactionSet(block); | |||
| TransactionQuery txSet = ledger.getTransactionSet(block); | |||
| return txSet.getTotalCount(); | |||
| } | |||
| @@ -126,7 +126,7 @@ public class LedgerQueryController implements BlockchainQueryService { | |||
| @PathVariable(name = "blockHash") HashDigest blockHash) { | |||
| LedgerQuery ledger = ledgerService.getLedger(ledgerHash); | |||
| LedgerBlock block = ledger.getBlock(blockHash); | |||
| TransactionSet txSet = ledger.getTransactionSet(block); | |||
| TransactionQuery txSet = ledger.getTransactionSet(block); | |||
| return txSet.getTotalCount(); | |||
| } | |||
| @@ -135,7 +135,7 @@ public class LedgerQueryController implements BlockchainQueryService { | |||
| public long getTransactionTotalCount(@PathVariable(name = "ledgerHash") HashDigest ledgerHash) { | |||
| LedgerQuery ledger = ledgerService.getLedger(ledgerHash); | |||
| LedgerBlock block = ledger.getLatestBlock(); | |||
| TransactionSet txSet = ledger.getTransactionSet(block); | |||
| TransactionQuery txSet = ledger.getTransactionSet(block); | |||
| return txSet.getTotalCount(); | |||
| } | |||
| @@ -146,7 +146,7 @@ public class LedgerQueryController implements BlockchainQueryService { | |||
| LedgerQuery ledger = ledgerService.getLedger(ledgerHash); | |||
| LedgerBlock block = ledger.getBlock(height); | |||
| DataAccountQuery dataAccountSet = ledger.getDataAccountSet(block); | |||
| return dataAccountSet.getTotalCount(); | |||
| return dataAccountSet.getTotal(); | |||
| } | |||
| @RequestMapping(method = RequestMethod.GET, path = "ledgers/{ledgerHash}/blocks/hash/{blockHash}/accounts/count") | |||
| @@ -156,7 +156,7 @@ public class LedgerQueryController implements BlockchainQueryService { | |||
| LedgerQuery ledger = ledgerService.getLedger(ledgerHash); | |||
| LedgerBlock block = ledger.getBlock(blockHash); | |||
| DataAccountQuery dataAccountSet = ledger.getDataAccountSet(block); | |||
| return dataAccountSet.getTotalCount(); | |||
| return dataAccountSet.getTotal(); | |||
| } | |||
| @RequestMapping(method = RequestMethod.GET, path = "ledgers/{ledgerHash}/accounts/count") | |||
| @@ -165,7 +165,7 @@ public class LedgerQueryController implements BlockchainQueryService { | |||
| LedgerQuery ledger = ledgerService.getLedger(ledgerHash); | |||
| LedgerBlock block = ledger.getLatestBlock(); | |||
| DataAccountQuery dataAccountSet = ledger.getDataAccountSet(block); | |||
| return dataAccountSet.getTotalCount(); | |||
| return dataAccountSet.getTotal(); | |||
| } | |||
| @RequestMapping(method = RequestMethod.GET, path = "ledgers/{ledgerHash}/blocks/height/{blockHeight}/users/count") | |||
| @@ -175,7 +175,7 @@ public class LedgerQueryController implements BlockchainQueryService { | |||
| LedgerQuery ledger = ledgerService.getLedger(ledgerHash); | |||
| LedgerBlock block = ledger.getBlock(height); | |||
| UserAccountQuery userAccountSet = ledger.getUserAccountSet(block); | |||
| return userAccountSet.getTotalCount(); | |||
| return userAccountSet.getTotal(); | |||
| } | |||
| @RequestMapping(method = RequestMethod.GET, path = "ledgers/{ledgerHash}/blocks/hash/{blockHash}/users/count") | |||
| @@ -185,7 +185,7 @@ public class LedgerQueryController implements BlockchainQueryService { | |||
| LedgerQuery ledger = ledgerService.getLedger(ledgerHash); | |||
| LedgerBlock block = ledger.getBlock(blockHash); | |||
| UserAccountQuery userAccountSet = ledger.getUserAccountSet(block); | |||
| return userAccountSet.getTotalCount(); | |||
| return userAccountSet.getTotal(); | |||
| } | |||
| @RequestMapping(method = RequestMethod.GET, path = "ledgers/{ledgerHash}/users/count") | |||
| @@ -194,7 +194,7 @@ public class LedgerQueryController implements BlockchainQueryService { | |||
| LedgerQuery ledger = ledgerService.getLedger(ledgerHash); | |||
| LedgerBlock block = ledger.getLatestBlock(); | |||
| UserAccountQuery userAccountSet = ledger.getUserAccountSet(block); | |||
| return userAccountSet.getTotalCount(); | |||
| return userAccountSet.getTotal(); | |||
| } | |||
| @RequestMapping(method = RequestMethod.GET, path = "ledgers/{ledgerHash}/blocks/height/{blockHeight}/contracts/count") | |||
| @@ -204,7 +204,7 @@ public class LedgerQueryController implements BlockchainQueryService { | |||
| LedgerQuery ledger = ledgerService.getLedger(ledgerHash); | |||
| LedgerBlock block = ledger.getBlock(height); | |||
| ContractAccountQuery contractAccountSet = ledger.getContractAccountSet(block); | |||
| return contractAccountSet.getTotalCount(); | |||
| return contractAccountSet.getTotal(); | |||
| } | |||
| @RequestMapping(method = RequestMethod.GET, path = "ledgers/{ledgerHash}/blocks/hash/{blockHash}/contracts/count") | |||
| @@ -214,7 +214,7 @@ public class LedgerQueryController implements BlockchainQueryService { | |||
| LedgerQuery ledger = ledgerService.getLedger(ledgerHash); | |||
| LedgerBlock block = ledger.getBlock(blockHash); | |||
| ContractAccountQuery contractAccountSet = ledger.getContractAccountSet(block); | |||
| return contractAccountSet.getTotalCount(); | |||
| return contractAccountSet.getTotal(); | |||
| } | |||
| @RequestMapping(method = RequestMethod.GET, path = "ledgers/{ledgerHash}/contracts/count") | |||
| @@ -223,7 +223,7 @@ public class LedgerQueryController implements BlockchainQueryService { | |||
| LedgerQuery ledger = ledgerService.getLedger(ledgerHash); | |||
| LedgerBlock block = ledger.getLatestBlock(); | |||
| ContractAccountQuery contractAccountSet = ledger.getContractAccountSet(block); | |||
| return contractAccountSet.getTotalCount(); | |||
| return contractAccountSet.getTotal(); | |||
| } | |||
| @RequestMapping(method = RequestMethod.GET, path = "ledgers/{ledgerHash}/blocks/height/{blockHeight}/txs") | |||
| @@ -235,7 +235,7 @@ public class LedgerQueryController implements BlockchainQueryService { | |||
| LedgerQuery ledger = ledgerService.getLedger(ledgerHash); | |||
| LedgerBlock ledgerBlock = ledger.getBlock(blockHeight); | |||
| TransactionSet transactionSet = ledger.getTransactionSet(ledgerBlock); | |||
| TransactionQuery transactionSet = ledger.getTransactionSet(ledgerBlock); | |||
| int lastHeightTxTotalNums = 0; | |||
| if (blockHeight > 0) { | |||
| @@ -269,7 +269,7 @@ public class LedgerQueryController implements BlockchainQueryService { | |||
| LedgerQuery ledger = ledgerService.getLedger(ledgerHash); | |||
| LedgerBlock ledgerBlock = ledger.getBlock(blockHash); | |||
| long height = ledgerBlock.getHeight(); | |||
| TransactionSet transactionSet = ledger.getTransactionSet(ledgerBlock); | |||
| TransactionQuery transactionSet = ledger.getTransactionSet(ledgerBlock); | |||
| int lastHeightTxTotalNums = 0; | |||
| if (height > 0) { | |||
| @@ -300,7 +300,7 @@ public class LedgerQueryController implements BlockchainQueryService { | |||
| @PathVariable(name = "contentHash") HashDigest contentHash) { | |||
| LedgerQuery ledger = ledgerService.getLedger(ledgerHash); | |||
| LedgerBlock block = ledger.getLatestBlock(); | |||
| TransactionSet txset = ledger.getTransactionSet(block); | |||
| TransactionQuery txset = ledger.getTransactionSet(block); | |||
| return txset.get(contentHash); | |||
| } | |||
| @@ -310,8 +310,8 @@ public class LedgerQueryController implements BlockchainQueryService { | |||
| @PathVariable(name = "contentHash") HashDigest contentHash) { | |||
| LedgerQuery ledger = ledgerService.getLedger(ledgerHash); | |||
| LedgerBlock block = ledger.getLatestBlock(); | |||
| TransactionSet txset = ledger.getTransactionSet(block); | |||
| return txset.getTxState(contentHash); | |||
| TransactionQuery txset = ledger.getTransactionSet(block); | |||
| return txset.getState(contentHash); | |||
| } | |||
| @RequestMapping(method = RequestMethod.GET, path = "ledgers/{ledgerHash}/users/address/{address}") | |||
| @@ -321,7 +321,7 @@ public class LedgerQueryController implements BlockchainQueryService { | |||
| LedgerQuery ledger = ledgerService.getLedger(ledgerHash); | |||
| LedgerBlock block = ledger.getLatestBlock(); | |||
| UserAccountQuery userAccountSet = ledger.getUserAccountSet(block); | |||
| return userAccountSet.getUser(address); | |||
| return userAccountSet.getAccount(address); | |||
| } | |||
| @RequestMapping(method = RequestMethod.GET, path = "ledgers/{ledgerHash}/accounts/address/{address}") | |||
| @@ -331,7 +331,7 @@ public class LedgerQueryController implements BlockchainQueryService { | |||
| LedgerQuery ledger = ledgerService.getLedger(ledgerHash); | |||
| LedgerBlock block = ledger.getLatestBlock(); | |||
| DataAccountQuery dataAccountSet = ledger.getDataAccountSet(block); | |||
| return dataAccountSet.getDataAccount(Bytes.fromBase58(address)); | |||
| return dataAccountSet.getAccount(Bytes.fromBase58(address)); | |||
| } | |||
| @RequestMapping(method = { RequestMethod.GET, | |||
| @@ -345,7 +345,7 @@ public class LedgerQueryController implements BlockchainQueryService { | |||
| LedgerQuery ledger = ledgerService.getLedger(ledgerHash); | |||
| LedgerBlock block = ledger.getLatestBlock(); | |||
| DataAccountQuery dataAccountSet = ledger.getDataAccountSet(block); | |||
| DataAccount dataAccount = dataAccountSet.getDataAccount(Bytes.fromBase58(address)); | |||
| DataAccount dataAccount = dataAccountSet.getAccount(Bytes.fromBase58(address)); | |||
| KVDataEntry[] entries = new KVDataEntry[keys.length]; | |||
| long ver; | |||
| @@ -394,7 +394,7 @@ public class LedgerQueryController implements BlockchainQueryService { | |||
| LedgerQuery ledger = ledgerService.getLedger(ledgerHash); | |||
| LedgerBlock block = ledger.getLatestBlock(); | |||
| DataAccountQuery dataAccountSet = ledger.getDataAccountSet(block); | |||
| DataAccount dataAccount = dataAccountSet.getDataAccount(Bytes.fromBase58(address)); | |||
| DataAccount dataAccount = dataAccountSet.getAccount(Bytes.fromBase58(address)); | |||
| KVDataEntry[] entries = new KVDataEntry[keys.length]; | |||
| long ver = -1; | |||
| @@ -429,7 +429,7 @@ public class LedgerQueryController implements BlockchainQueryService { | |||
| LedgerQuery ledger = ledgerService.getLedger(ledgerHash); | |||
| LedgerBlock block = ledger.getLatestBlock(); | |||
| DataAccountQuery dataAccountSet = ledger.getDataAccountSet(block); | |||
| DataAccount dataAccount = dataAccountSet.getDataAccount(Bytes.fromBase58(address)); | |||
| DataAccount dataAccount = dataAccountSet.getAccount(Bytes.fromBase58(address)); | |||
| int pages[] = QueryUtil.calFromIndexAndCount(fromIndex, count, (int) dataAccount.getDataEntriesTotalCount()); | |||
| return dataAccount.getDataEntries(pages[0], pages[1]); | |||
| @@ -443,7 +443,7 @@ public class LedgerQueryController implements BlockchainQueryService { | |||
| LedgerQuery ledger = ledgerService.getLedger(ledgerHash); | |||
| LedgerBlock block = ledger.getLatestBlock(); | |||
| DataAccountQuery dataAccountSet = ledger.getDataAccountSet(block); | |||
| DataAccount dataAccount = dataAccountSet.getDataAccount(Bytes.fromBase58(address)); | |||
| DataAccount dataAccount = dataAccountSet.getAccount(Bytes.fromBase58(address)); | |||
| return dataAccount.getDataEntriesTotalCount(); | |||
| } | |||
| @@ -455,7 +455,7 @@ public class LedgerQueryController implements BlockchainQueryService { | |||
| LedgerQuery ledger = ledgerService.getLedger(ledgerHash); | |||
| LedgerBlock block = ledger.getLatestBlock(); | |||
| ContractAccountQuery contractAccountSet = ledger.getContractAccountSet(block); | |||
| return contractAccountSet.getContract(Bytes.fromBase58(address)); | |||
| return contractAccountSet.getAccount(Bytes.fromBase58(address)); | |||
| } | |||
| /** | |||
| @@ -474,8 +474,8 @@ public class LedgerQueryController implements BlockchainQueryService { | |||
| LedgerQuery ledger = ledgerService.getLedger(ledgerHash); | |||
| LedgerBlock block = ledger.getLatestBlock(); | |||
| UserAccountQuery userAccountSet = ledger.getUserAccountSet(block); | |||
| int pages[] = QueryUtil.calFromIndexAndCount(fromIndex, count, (int) userAccountSet.getTotalCount()); | |||
| return userAccountSet.getAccounts(pages[0], pages[1]); | |||
| int pages[] = QueryUtil.calFromIndexAndCount(fromIndex, count, (int) userAccountSet.getTotal()); | |||
| return userAccountSet.getHeaders(pages[0], pages[1]); | |||
| } | |||
| /** | |||
| @@ -494,8 +494,8 @@ public class LedgerQueryController implements BlockchainQueryService { | |||
| LedgerQuery ledger = ledgerService.getLedger(ledgerHash); | |||
| LedgerBlock block = ledger.getLatestBlock(); | |||
| DataAccountQuery dataAccountSet = ledger.getDataAccountSet(block); | |||
| int pages[] = QueryUtil.calFromIndexAndCount(fromIndex, count, (int) dataAccountSet.getTotalCount()); | |||
| return dataAccountSet.getAccounts(pages[0], pages[1]); | |||
| int pages[] = QueryUtil.calFromIndexAndCount(fromIndex, count, (int) dataAccountSet.getTotal()); | |||
| return dataAccountSet.getHeaders(pages[0], pages[1]); | |||
| } | |||
| @RequestMapping(method = RequestMethod.GET, path = "ledgers/{ledgerHash}/contracts") | |||
| @@ -506,8 +506,8 @@ public class LedgerQueryController implements BlockchainQueryService { | |||
| LedgerQuery ledger = ledgerService.getLedger(ledgerHash); | |||
| LedgerBlock block = ledger.getLatestBlock(); | |||
| ContractAccountQuery contractAccountSet = ledger.getContractAccountSet(block); | |||
| int pages[] = QueryUtil.calFromIndexAndCount(fromIndex, count, (int) contractAccountSet.getTotalCount()); | |||
| return contractAccountSet.getAccounts(pages[0], pages[1]); | |||
| int pages[] = QueryUtil.calFromIndexAndCount(fromIndex, count, (int) contractAccountSet.getTotal()); | |||
| return contractAccountSet.getHeaders(pages[0], pages[1]); | |||
| } | |||
| } | |||
| @@ -336,21 +336,21 @@ public class IntegrationTest { | |||
| // getDataAccountCount according to blockhash | |||
| for (int i = 0; i < ledgerHeight + 1; i++) { | |||
| LedgerBlock expectBlock = ledgerOfNode0.getBlock(i); | |||
| long expectDataCount = ledgerOfNode0.getDataAccountSet(expectBlock).getTotalCount(); | |||
| long expectDataCount = ledgerOfNode0.getDataAccountSet(expectBlock).getTotal(); | |||
| long actualDataCount = blockchainService.getDataAccountCount(ledgerHash, expectBlock.getHash()); | |||
| } | |||
| // getUserCount according to blockhash | |||
| for (int i = 0; i < ledgerHeight + 1; i++) { | |||
| LedgerBlock expectBlock = ledgerOfNode0.getBlock(i); | |||
| long expectUserCount = ledgerOfNode0.getUserAccountSet(expectBlock).getTotalCount(); | |||
| long expectUserCount = ledgerOfNode0.getUserAccountSet(expectBlock).getTotal(); | |||
| long actualUserCount = blockchainService.getUserCount(ledgerHash, expectBlock.getHash()); | |||
| } | |||
| // getContractCount according to blockhash | |||
| for (int i = 0; i < ledgerHeight + 1; i++) { | |||
| LedgerBlock expectBlock = ledgerOfNode0.getBlock(i); | |||
| long expectContractCount = ledgerOfNode0.getContractAccountSet(expectBlock).getTotalCount(); | |||
| long expectContractCount = ledgerOfNode0.getContractAccountSet(expectBlock).getTotal(); | |||
| long actualContractCount = blockchainService.getContractCount(ledgerHash, expectBlock.getHash()); | |||
| } | |||
| @@ -372,9 +372,9 @@ public class IntegrationTest { | |||
| // expect block acount total | |||
| LedgerBlock ledgerBlock = ledgerOfNode0.getBlock(i); | |||
| expectTransactionTotal = ledgerOfNode0.getTransactionSet(ledgerBlock).getTotalCount(); | |||
| expectUserTotal = ledgerOfNode0.getUserAccountSet(ledgerBlock).getTotalCount(); | |||
| expectDataTotal = ledgerOfNode0.getDataAccountSet(ledgerBlock).getTotalCount(); | |||
| expectContractTotal = ledgerOfNode0.getContractAccountSet(ledgerBlock).getTotalCount(); | |||
| expectUserTotal = ledgerOfNode0.getUserAccountSet(ledgerBlock).getTotal(); | |||
| expectDataTotal = ledgerOfNode0.getDataAccountSet(ledgerBlock).getTotal(); | |||
| expectContractTotal = ledgerOfNode0.getContractAccountSet(ledgerBlock).getTotal(); | |||
| } | |||
| // getTransactionTotalCount | |||
| @@ -579,7 +579,7 @@ public class IntegrationTest { | |||
| Node node0 = context.getNode(0); | |||
| LedgerQuery ledgerOfNode0 = node0.getLedgerManager().getLedger(ledgerHash); | |||
| LedgerBlock block = ledgerOfNode0.getBlock(txResp.getBlockHeight()); | |||
| byte[] contractCodeInDb = ledgerOfNode0.getContractAccountSet(block).getContract(contractDeployKey.getAddress()) | |||
| byte[] contractCodeInDb = ledgerOfNode0.getContractAccountSet(block).getAccount(contractDeployKey.getAddress()) | |||
| .getChainCode(); | |||
| txContentHash = ptx.getHash(); | |||
| @@ -659,9 +659,9 @@ public class IntegrationTest { | |||
| LedgerQuery ledgerOfNode0 = node0.getLedgerManager().getLedger(ledgerHash); | |||
| LedgerBlock block = ledgerOfNode0.getBlock(txResp.getBlockHeight()); | |||
| BytesValue val1InDb = ledgerOfNode0.getDataAccountSet(block).getDataAccount(contractDataKey.getAddress()) | |||
| BytesValue val1InDb = ledgerOfNode0.getDataAccountSet(block).getAccount(contractDataKey.getAddress()) | |||
| .getBytes("A"); | |||
| BytesValue val2InDb = ledgerOfNode0.getDataAccountSet(block).getDataAccount(contractDataKey.getAddress()) | |||
| BytesValue val2InDb = ledgerOfNode0.getDataAccountSet(block).getAccount(contractDataKey.getAddress()) | |||
| .getBytes(KEY_TOTAL); | |||
| } | |||
| @@ -117,19 +117,19 @@ public class LedgerInitializeTest { | |||
| PubKey pubKey0 = KeyGenUtils.decodePubKey(PUB_KEYS[0]); | |||
| Bytes address0 = AddressEncoding.generateAddress(pubKey0); | |||
| UserAccount user0_0 = userset0.getUser(address0); | |||
| UserAccount user0_0 = userset0.getAccount(address0); | |||
| PubKey pubKey1 = KeyGenUtils.decodePubKey(PUB_KEYS[1]); | |||
| Bytes address1 = AddressEncoding.generateAddress(pubKey1); | |||
| UserAccount user1_0 = userset0.getUser(address1); | |||
| UserAccount user1_0 = userset0.getAccount(address1); | |||
| PubKey pubKey2 = KeyGenUtils.decodePubKey(PUB_KEYS[2]); | |||
| Bytes address2 = AddressEncoding.generateAddress(pubKey2); | |||
| UserAccount user2_0 = userset0.getUser(address2); | |||
| UserAccount user2_0 = userset0.getAccount(address2); | |||
| PubKey pubKey3 = KeyGenUtils.decodePubKey(PUB_KEYS[3]); | |||
| Bytes address3 = AddressEncoding.generateAddress(pubKey3); | |||
| UserAccount user3_0 = userset0.getUser(address3); | |||
| UserAccount user3_0 = userset0.getAccount(address3); | |||
| } | |||
| public static LedgerInitProperties loadInitSetting() { | |||
| @@ -305,19 +305,19 @@ public class LedgerInitializeWebTest { | |||
| PubKey pubKey0 = KeyGenUtils.decodePubKey(PUB_KEYS[0]); | |||
| Bytes address0 = AddressEncoding.generateAddress(pubKey0); | |||
| UserAccount user0_0 = userset0.getUser(address0); | |||
| UserAccount user0_0 = userset0.getAccount(address0); | |||
| PubKey pubKey1 = KeyGenUtils.decodePubKey(PUB_KEYS[1]); | |||
| Bytes address1 = AddressEncoding.generateAddress(pubKey1); | |||
| UserAccount user1_0 = userset0.getUser(address1); | |||
| UserAccount user1_0 = userset0.getAccount(address1); | |||
| PubKey pubKey2 = KeyGenUtils.decodePubKey(PUB_KEYS[2]); | |||
| Bytes address2 = AddressEncoding.generateAddress(pubKey2); | |||
| UserAccount user2_0 = userset0.getUser(address2); | |||
| UserAccount user2_0 = userset0.getAccount(address2); | |||
| PubKey pubKey3 = KeyGenUtils.decodePubKey(PUB_KEYS[3]); | |||
| Bytes address3 = AddressEncoding.generateAddress(pubKey3); | |||
| UserAccount user3_0 = userset0.getUser(address3); | |||
| UserAccount user3_0 = userset0.getAccount(address3); | |||
| } | |||
| public static LedgerInitProperties loadInitSetting_1() { | |||
| @@ -282,7 +282,7 @@ public class LedgerPerformanceTest { | |||
| ConsoleUtils.info("\r\n\r\n================= 准备测试交易 [执行合约] ================="); | |||
| LedgerBlock latestBlock = ledger.getLatestBlock(); | |||
| LedgerDataQuery previousDataSet = ledger.getDataSet(latestBlock); | |||
| LedgerDataQuery previousDataSet = ledger.getLedgerData(latestBlock); | |||
| LedgerEditor newEditor = ledger.createNextBlock(); | |||
| TransactionBatchProcessor txProc = new TransactionBatchProcessor(DEFAULT_SECURITY_MANAGER, newEditor, | |||
| ledger, opHandler); | |||
| @@ -315,7 +315,7 @@ public class LedgerPerformanceTest { | |||
| long batchStartTs = System.currentTimeMillis(); | |||
| for (int i = 0; i < batchCount; i++) { | |||
| LedgerBlock latestBlock = ledger.getLatestBlock(); | |||
| LedgerDataQuery previousDataSet = ledger.getDataSet(latestBlock); | |||
| LedgerDataQuery previousDataSet = ledger.getLedgerData(latestBlock); | |||
| if (statistic) { | |||
| ConsoleUtils.info("------ 开始执行交易, 即将生成区块[高度:%s] ------", (latestBlock.getHeight() + 1)); | |||
| } | |||
| @@ -240,7 +240,7 @@ public class IntegrationBase { | |||
| if (keyPairType == KeyPairType.DATAACCOUNT) { | |||
| assertNotNull(ledgerRepository.getDataAccountSet(ledgerRepository.getLatestBlock()) | |||
| .getDataAccount(keyPair.getAddress())); | |||
| .getAccount(keyPair.getAddress())); | |||
| } | |||
| System.out.printf("validKeyPair end %s \r\n", index); | |||
| } | |||
| @@ -264,7 +264,7 @@ public class IntegrationBase { | |||
| if (keyPairType == KeyPairType.DATAACCOUNT) { | |||
| assertNotNull(ledgerRepository.getDataAccountSet(ledgerRepository.getLatestBlock()) | |||
| .getDataAccount(keyPair.getAddress())); | |||
| .getAccount(keyPair.getAddress())); | |||
| } | |||
| countDownLatch.countDown(); | |||
| } | |||
| @@ -527,7 +527,7 @@ public class IntegrationBase { | |||
| LedgerBlock block = ledgerRepository.getBlock(txResp.getBlockHeight()); | |||
| byte[] contractCodeInDb = ledgerRepository.getContractAccountSet(block) | |||
| .getContract(contractDeployKey.getAddress()).getChainCode(); | |||
| .getAccount(contractDeployKey.getAddress()).getChainCode(); | |||
| assertArrayEquals(contractCode, contractCodeInDb); | |||
| // execute the contract; | |||
| @@ -153,7 +153,7 @@ public class IntegrationTest4Bftsmart { | |||
| long participantCount = ledgerRepository.getAdminInfo(ledgerRepository.retrieveLatestBlock()).getParticipantCount(); | |||
| long userCount = ledgerRepository.getUserAccountSet(ledgerRepository.retrieveLatestBlock()).getTotalCount(); | |||
| long userCount = ledgerRepository.getUserAccountSet(ledgerRepository.retrieveLatestBlock()).getTotal(); | |||
| System.out.printf("before add participant: participantCount = %d, userCount = %d\r\n", (int)participantCount, (int)userCount); | |||
| @@ -164,7 +164,7 @@ public class IntegrationTest4Bftsmart { | |||
| participantCount = ledgerRepository.getAdminInfo(ledgerRepository.retrieveLatestBlock()).getParticipantCount(); | |||
| userCount = ledgerRepository.getUserAccountSet(ledgerRepository.retrieveLatestBlock()).getTotalCount(); | |||
| userCount = ledgerRepository.getUserAccountSet(ledgerRepository.retrieveLatestBlock()).getTotal(); | |||
| System.out.printf("after add participant: participantCount = %d, userCount = %d\r\n", (int)participantCount, (int)userCount); | |||
| @@ -149,7 +149,7 @@ public class IntegrationTest4MQ { | |||
| long participantCount = ledgerRepository.getAdminInfo(ledgerRepository.retrieveLatestBlock()).getParticipantCount(); | |||
| long userCount = ledgerRepository.getUserAccountSet(ledgerRepository.retrieveLatestBlock()).getTotalCount(); | |||
| long userCount = ledgerRepository.getUserAccountSet(ledgerRepository.retrieveLatestBlock()).getTotal(); | |||
| System.out.printf("before add participant: participantCount = %d, userCount = %d\r\n", (int)participantCount, (int)userCount); | |||
| @@ -160,7 +160,7 @@ public class IntegrationTest4MQ { | |||
| participantCount = ledgerRepository.getAdminInfo(ledgerRepository.retrieveLatestBlock()).getParticipantCount(); | |||
| userCount = ledgerRepository.getUserAccountSet(ledgerRepository.retrieveLatestBlock()).getTotalCount(); | |||
| userCount = ledgerRepository.getUserAccountSet(ledgerRepository.retrieveLatestBlock()).getTotal(); | |||
| System.out.printf("after add participant: participantCount = %d, userCount = %d\r\n", (int)participantCount, (int)userCount); | |||
| @@ -214,21 +214,21 @@ public class IntegrationTestAll4Redis { | |||
| assertEquals(ledgerRepository.retrieveLatestBlockHeight(), txResp.getBlockHeight()); | |||
| assertEquals("Value_A_0", ledgerRepository.getDataAccountSet(ledgerRepository.retrieveLatestBlock()) | |||
| .getDataAccount(dataKey.getAddress()).getBytes("A").getValue().toUTF8String()); | |||
| .getAccount(dataKey.getAddress()).getBytes("A").getValue().toUTF8String()); | |||
| assertEquals("Value_B_0", ledgerRepository.getDataAccountSet(ledgerRepository.retrieveLatestBlock()) | |||
| .getDataAccount(dataKey.getAddress()).getBytes("B").getValue().toUTF8String()); | |||
| .getAccount(dataKey.getAddress()).getBytes("B").getValue().toUTF8String()); | |||
| assertEquals("Value_C_0", ledgerRepository.getDataAccountSet(ledgerRepository.retrieveLatestBlock()) | |||
| .getDataAccount(dataKey.getAddress()).getBytes("C").getValue().toUTF8String()); | |||
| .getAccount(dataKey.getAddress()).getBytes("C").getValue().toUTF8String()); | |||
| assertEquals("Value_D_0", ledgerRepository.getDataAccountSet(ledgerRepository.retrieveLatestBlock()) | |||
| .getDataAccount(dataKey.getAddress()).getBytes("D").getValue().toUTF8String()); | |||
| .getAccount(dataKey.getAddress()).getBytes("D").getValue().toUTF8String()); | |||
| assertEquals(0, ledgerRepository.getDataAccountSet(ledgerRepository.retrieveLatestBlock()) | |||
| .getDataAccount(dataKey.getAddress()).getDataVersion("A")); | |||
| .getAccount(dataKey.getAddress()).getDataVersion("A")); | |||
| assertEquals(0, ledgerRepository.getDataAccountSet(ledgerRepository.retrieveLatestBlock()) | |||
| .getDataAccount(dataKey.getAddress()).getDataVersion("B")); | |||
| .getAccount(dataKey.getAddress()).getDataVersion("B")); | |||
| assertEquals(0, ledgerRepository.getDataAccountSet(ledgerRepository.retrieveLatestBlock()) | |||
| .getDataAccount(dataKey.getAddress()).getDataVersion("C")); | |||
| .getAccount(dataKey.getAddress()).getDataVersion("C")); | |||
| assertEquals(0, ledgerRepository.getDataAccountSet(ledgerRepository.retrieveLatestBlock()) | |||
| .getDataAccount(dataKey.getAddress()).getDataVersion("D")); | |||
| .getAccount(dataKey.getAddress()).getDataVersion("D")); | |||
| return; | |||
| } | |||
| @@ -321,7 +321,7 @@ public class IntegrationTestAll4Redis { | |||
| assertEquals(txResp.getContentHash(), transactionHash); | |||
| assertEquals(txResp.getBlockHash(), ledgerRepository.getLatestBlockHash()); | |||
| assertNotNull(ledgerRepository.getDataAccountSet(ledgerRepository.getLatestBlock()) | |||
| .getDataAccount(dataAccount.getAddress())); | |||
| .getAccount(dataAccount.getAddress())); | |||
| return dataAccount; | |||
| } | |||
| @@ -383,7 +383,7 @@ public class IntegrationTestAll4Redis { | |||
| txTpl.dataAccounts().register(contractDataKey.getIdentity()); | |||
| // dataAccountSet.getDataAccount(dataAddress) | |||
| DataAccount dataAccount = ledgerRepository.getDataAccountSet(ledgerRepository.getLatestBlock()) | |||
| .getDataAccount(contractDataKey.getAddress()); | |||
| .getAccount(contractDataKey.getAddress()); | |||
| DataAccountKVSetOperation kvsetOP = txTpl.dataAccount(contractDataKey.getAddress()) | |||
| .setText("A", "Value_A_0", -1).setText("B", "Value_B_0", -1) | |||
| @@ -407,7 +407,7 @@ public class IntegrationTestAll4Redis { | |||
| LedgerBlock block = ledgerRepository.getBlock(txResp.getBlockHeight()); | |||
| byte[] contractCodeInDb = ledgerRepository.getContractAccountSet(block) | |||
| .getContract(contractDeployKey.getAddress()).getChainCode(); | |||
| .getAccount(contractDeployKey.getAddress()).getChainCode(); | |||
| assertArrayEquals(contractCode, contractCodeInDb); | |||
| txContentHash = ptx.getHash(); | |||
| @@ -449,9 +449,9 @@ public class IntegrationTestAll4Redis { | |||
| AsymmetricKeypair key = Crypto.getSignatureFunction("ED25519").generateKeypair(); | |||
| PubKey pubKey = key.getPubKey(); | |||
| Bytes dataAddress = AddressEncoding.generateAddress(pubKey); | |||
| assertEquals(dataAddress, dataAccountSet.getDataAccount(dataAddress).getAddress()); | |||
| assertEquals(dataAddress, dataAccountSet.getAccount(dataAddress).getAddress()); | |||
| assertEquals("hello", | |||
| dataAccountSet.getDataAccount(dataAddress).getBytes(KEY_TOTAL, -1).getValue().toUTF8String()); | |||
| dataAccountSet.getAccount(dataAddress).getBytes(KEY_TOTAL, -1).getValue().toUTF8String()); | |||
| // 验证userAccount,从合约内部赋值,然后外部验证;内部定义动态key,外部不便于得到,临时屏蔽; | |||
| // UserAccountSet userAccountSet = | |||
| @@ -478,9 +478,9 @@ public class IntegrationTestAll4Redis { | |||
| // 验证结果; | |||
| LedgerBlock block = ledgerRepository.getBlock(txResp.getBlockHeight()); | |||
| BytesValue val1InDb = ledgerRepository.getDataAccountSet(block).getDataAccount(contractDataKey.getAddress()) | |||
| BytesValue val1InDb = ledgerRepository.getDataAccountSet(block).getAccount(contractDataKey.getAddress()) | |||
| .getBytes("A"); | |||
| BytesValue val2InDb = ledgerRepository.getDataAccountSet(block).getDataAccount(contractDataKey.getAddress()) | |||
| BytesValue val2InDb = ledgerRepository.getDataAccountSet(block).getAccount(contractDataKey.getAddress()) | |||
| .getBytes(KEY_TOTAL); | |||
| assertEquals("Value_A_0", val1InDb.getValue().toUTF8String()); | |||
| assertEquals("total value,dataAccount", val2InDb.getValue().toUTF8String()); | |||
| @@ -151,22 +151,22 @@ public class LedgerInitializeTest { | |||
| PubKey pubKey0 = KeyGenUtils.decodePubKey(PUB_KEYS[0]); | |||
| Bytes address0 = AddressEncoding.generateAddress(pubKey0); | |||
| UserAccount user0_0 = userset0.getUser(address0); | |||
| UserAccount user0_0 = userset0.getAccount(address0); | |||
| assertNotNull(user0_0); | |||
| PubKey pubKey1 = KeyGenUtils.decodePubKey(PUB_KEYS[1]); | |||
| Bytes address1 = AddressEncoding.generateAddress(pubKey1); | |||
| UserAccount user1_0 = userset0.getUser(address1); | |||
| UserAccount user1_0 = userset0.getAccount(address1); | |||
| assertNotNull(user1_0); | |||
| PubKey pubKey2 = KeyGenUtils.decodePubKey(PUB_KEYS[2]); | |||
| Bytes address2 = AddressEncoding.generateAddress(pubKey2); | |||
| UserAccount user2_0 = userset0.getUser(address2); | |||
| UserAccount user2_0 = userset0.getAccount(address2); | |||
| assertNotNull(user2_0); | |||
| PubKey pubKey3 = KeyGenUtils.decodePubKey(PUB_KEYS[3]); | |||
| Bytes address3 = AddressEncoding.generateAddress(pubKey3); | |||
| UserAccount user3_0 = userset0.getUser(address3); | |||
| UserAccount user3_0 = userset0.getAccount(address3); | |||
| assertNotNull(user3_0); | |||
| } | |||
| @@ -158,24 +158,24 @@ public class LedgerInitializeWeb4Nodes { | |||
| PubKey pubKey0 = KeyGenUtils.decodePubKey(PUB_KEYS[0]); | |||
| Bytes address0 = AddressEncoding.generateAddress(pubKey0); | |||
| System.out.printf("localNodeAddress0 = %s \r\n", address0.toBase58()); | |||
| UserAccount user0_0 = userset0.getUser(address0); | |||
| UserAccount user0_0 = userset0.getAccount(address0); | |||
| assertNotNull(user0_0); | |||
| PubKey pubKey1 = KeyGenUtils.decodePubKey(PUB_KEYS[1]); | |||
| Bytes address1 = AddressEncoding.generateAddress(pubKey1); | |||
| UserAccount user1_0 = userset0.getUser(address1); | |||
| UserAccount user1_0 = userset0.getAccount(address1); | |||
| assertNotNull(user1_0); | |||
| System.out.printf("localNodeAddress1 = %s \r\n", address1.toBase58()); | |||
| PubKey pubKey2 = KeyGenUtils.decodePubKey(PUB_KEYS[2]); | |||
| Bytes address2 = AddressEncoding.generateAddress(pubKey2); | |||
| UserAccount user2_0 = userset0.getUser(address2); | |||
| UserAccount user2_0 = userset0.getAccount(address2); | |||
| assertNotNull(user2_0); | |||
| System.out.printf("localNodeAddress2 = %s \r\n", address2.toBase58()); | |||
| PubKey pubKey3 = KeyGenUtils.decodePubKey(PUB_KEYS[3]); | |||
| Bytes address3 = AddressEncoding.generateAddress(pubKey3); | |||
| UserAccount user3_0 = userset0.getUser(address3); | |||
| UserAccount user3_0 = userset0.getAccount(address3); | |||
| assertNotNull(user3_0); | |||
| System.out.printf("localNodeAddress3 = %s \r\n", address3.toBase58()); | |||
| @@ -77,7 +77,7 @@ public class LedgerBlockGeneratingTest { | |||
| LedgerBlock latestBlock = ledger.getLatestBlock(); | |||
| assertEquals(height + i, latestBlock.getHeight()); | |||
| LedgerDataQuery previousDataSet = ledger.getDataSet(latestBlock); | |||
| LedgerDataQuery previousDataSet = ledger.getLedgerData(latestBlock); | |||
| ConsoleUtils.info("------ 开始执行交易, 即将生成区块[%s] ------", (latestBlock.getHeight() + 1)); | |||
| long startTs = System.currentTimeMillis(); | |||
| @@ -127,7 +127,8 @@ public class RolesAuthorizationTest { | |||
| new TransactionDefiner() { | |||
| @Override | |||
| public void define(TransactionBuilder txBuilder) { | |||
| txBuilder.security().roles().configure("NORMAL").enable(LedgerPermission.REGISTER_DATA_ACCOUNT) | |||
| txBuilder.security().roles().configure("NORMAL") | |||
| .enable(LedgerPermission.REGISTER_DATA_ACCOUNT) | |||
| .disable(LedgerPermission.REGISTER_USER) | |||
| .enable(TransactionPermission.CONTRACT_OPERATION); | |||
| @@ -215,9 +216,9 @@ public class RolesAuthorizationTest { | |||
| private void assertPredefineData(HashDigest ledgerHash, MemoryKVStorage storage) { | |||
| LedgerManager ledgerManager = new LedgerManager(); | |||
| LedgerRepository ledger = ledgerManager.register(ledgerHash, storage); | |||
| UserAccount newUser = ledger.getUserAccountSet().getUser(NEW_USER.getAddress()); | |||
| UserAccount newUser = ledger.getUserAccountSet().getAccount(NEW_USER.getAddress()); | |||
| assertNotNull(newUser); | |||
| DataAccount dataAccount = ledger.getDataAccountSet().getDataAccount(DATA_ACCOUNT_ID.getAddress()); | |||
| DataAccount dataAccount = ledger.getDataAccountSet().getAccount(DATA_ACCOUNT_ID.getAddress()); | |||
| assertNotNull(dataAccount); | |||
| UserRoles userRoles = ledger.getAdminSettings().getAuthorizations().getUserRoles(NEW_USER.getAddress()); | |||
| @@ -440,7 +440,7 @@ public class MockerNodeContext implements BlockchainQueryService { | |||
| public OperationResult[] txProcess(TransactionRequest txRequest) { | |||
| LedgerEditor newEditor = ledgerRepository.createNextBlock(); | |||
| LedgerBlock latestBlock = ledgerRepository.getLatestBlock(); | |||
| LedgerDataQuery previousDataSet = ledgerRepository.getDataSet(latestBlock); | |||
| LedgerDataQuery previousDataSet = ledgerRepository.getLedgerData(latestBlock); | |||
| TransactionBatchProcessor txProc = new TransactionBatchProcessor(getSecurityManager(), newEditor, | |||
| ledgerRepository, opHandler); | |||
| TransactionResponse txResp = txProc.schedule(txRequest); | |||