@@ -10,9 +10,11 @@ import com.jd.blockchain.storage.service.ExPolicyKVStorage; | |||
import com.jd.blockchain.storage.service.VersioningKVStorage; | |||
import com.jd.blockchain.utils.Bytes; | |||
import com.jd.blockchain.utils.Transactional; | |||
import org.slf4j.Logger; | |||
import org.slf4j.LoggerFactory; | |||
public class DataAccountSet implements Transactional, DataAccountQuery { | |||
private Logger logger = LoggerFactory.getLogger(DataAccountSet.class); | |||
private MerkleAccountSet accountSet; | |||
public DataAccountSet(CryptoSetting cryptoSetting, String prefix, ExPolicyKVStorage exStorage, | |||
@@ -77,7 +79,7 @@ public class DataAccountSet implements Transactional, DataAccountQuery { | |||
/** | |||
* 返回数据账户; <br> | |||
* 如果不存在,则返回 null; | |||
* | |||
* | |||
* @param address | |||
* @return | |||
*/ | |||
@@ -110,4 +112,4 @@ public class DataAccountSet implements Transactional, DataAccountQuery { | |||
public void cancel() { | |||
accountSet.cancel(); | |||
} | |||
} | |||
} |
@@ -23,9 +23,11 @@ import com.jd.blockchain.storage.service.VersioningKVStorage; | |||
import com.jd.blockchain.storage.service.utils.BufferedKVStorage; | |||
import com.jd.blockchain.utils.Bytes; | |||
import com.jd.blockchain.utils.codec.Base58Utils; | |||
import org.slf4j.Logger; | |||
import org.slf4j.LoggerFactory; | |||
public class LedgerTransactionalEditor implements LedgerEditor { | |||
private Logger logger = LoggerFactory.getLogger(LedgerTransactionalEditor.class); | |||
private static final boolean PARALLEL_DB_WRITE; | |||
static { | |||
@@ -103,7 +105,7 @@ public class LedgerTransactionalEditor implements LedgerEditor { | |||
/** | |||
* 创建账本新区块的编辑器; | |||
* | |||
* | |||
* @param ledgerHash 账本哈希; | |||
* @param ledgerSetting 账本设置; | |||
* @param previousBlock 前置区块; | |||
@@ -138,7 +140,7 @@ public class LedgerTransactionalEditor implements LedgerEditor { | |||
/** | |||
* 创建创世区块的编辑器; | |||
* | |||
* | |||
* @param initSetting | |||
* @param ledgerKeyPrefix | |||
* @param ledgerExStorage | |||
@@ -195,7 +197,7 @@ public class LedgerTransactionalEditor implements LedgerEditor { | |||
/** | |||
* 检查当前账本是否是指定交易请求的账本; | |||
* | |||
* | |||
* @param txRequest | |||
* @return | |||
*/ | |||
@@ -301,7 +303,7 @@ public class LedgerTransactionalEditor implements LedgerEditor { | |||
currentBlock.setTransactionSetHash(previousTxSnapshot.getTransactionSetHash()); | |||
// TODO: 根据所有交易的时间戳的平均值来生成区块的时间戳; | |||
// long timestamp = | |||
// long timestamp = | |||
// currentBlock.setTimestamp(timestamp); | |||
// compute block hash; | |||
@@ -394,7 +396,7 @@ public class LedgerTransactionalEditor implements LedgerEditor { | |||
/** | |||
* 用于暂存交易上下文数据的快照对象; | |||
* | |||
* | |||
* @author huanghaiquan | |||
* | |||
*/ | |||
@@ -404,7 +406,7 @@ public class LedgerTransactionalEditor implements LedgerEditor { | |||
/** | |||
* 创世区块的快照对象; | |||
* | |||
* | |||
* @author huanghaiquan | |||
* | |||
*/ | |||
@@ -419,7 +421,7 @@ public class LedgerTransactionalEditor implements LedgerEditor { | |||
/** | |||
* 交易执行完毕后的快照对象; | |||
* | |||
* | |||
* @author huanghaiquan | |||
* | |||
*/ | |||
@@ -464,12 +466,12 @@ public class LedgerTransactionalEditor implements LedgerEditor { | |||
/** | |||
* 交易的上下文; | |||
* | |||
* | |||
* @author huanghaiquan | |||
* | |||
*/ | |||
private static class LedgerTransactionContextImpl implements LedgerTransactionContext { | |||
private Logger logger = LoggerFactory.getLogger(LedgerTransactionContextImpl.class); | |||
private LedgerTransactionalEditor blockEditor; | |||
private TransactionRequest txRequest; | |||
@@ -522,21 +524,27 @@ public class LedgerTransactionalEditor implements LedgerEditor { | |||
checkTxState(); | |||
// capture snapshot | |||
logger.debug("before dataset.commit(),[contentHash={}]",this.getTransactionRequest().getTransactionContent().getHash()); | |||
this.dataset.commit(); | |||
logger.debug("after dataset.commit(),[contentHash={}]",this.getTransactionRequest().getTransactionContent().getHash()); | |||
TransactionStagedSnapshot txDataSnapshot = takeDataSnapshot(); | |||
LedgerTransactionData tx; | |||
try { | |||
tx = new LedgerTransactionData(blockEditor.getBlockHeight(), txRequest, txResult, txDataSnapshot, | |||
operationResultArray(operationResults)); | |||
logger.debug("before txSet.add(),[contentHash={}]",tx.getTransactionContent().getHash()); | |||
this.txset.add(tx); | |||
logger.debug("after txSet.add(),[contentHash={}]",tx.getTransactionContent().getHash()); | |||
this.txset.commit(); | |||
logger.debug("after txset.commit(),[contentHash={}]",this.getTransactionRequest().getTransactionContent().getHash()); | |||
} catch (Exception e) { | |||
throw new TransactionRollbackException(e.getMessage(), e); | |||
} | |||
try { | |||
this.storage.flush(); | |||
logger.debug("after storage.flush(),[contentHash={}]",this.getTransactionRequest().getTransactionContent().getHash()); | |||
} catch (Exception e) { | |||
throw new BlockRollbackException(e.getMessage(), e); | |||
} | |||
@@ -631,4 +639,4 @@ public class LedgerTransactionalEditor implements LedgerEditor { | |||
} | |||
} | |||
} | |||
} |
@@ -13,9 +13,11 @@ import com.jd.blockchain.storage.service.VersioningKVStorage; | |||
import com.jd.blockchain.utils.Bytes; | |||
import com.jd.blockchain.utils.DataEntry; | |||
import com.jd.blockchain.utils.Transactional; | |||
import org.slf4j.Logger; | |||
import org.slf4j.LoggerFactory; | |||
public class MerkleAccountSet implements Transactional, MerkleProvable, AccountQuery<CompositeAccount> { | |||
private Logger logger = LoggerFactory.getLogger(MerkleAccountSet.class); | |||
static { | |||
DataContractRegistry.register(MerkleSnapshot.class); | |||
DataContractRegistry.register(BlockchainIdentity.class); | |||
@@ -31,7 +33,7 @@ public class MerkleAccountSet implements Transactional, MerkleProvable, AccountQ | |||
/** | |||
* The cache of latest version accounts, including accounts getting by querying | |||
* and by new regiestering ; | |||
* | |||
* | |||
*/ | |||
// TODO:未考虑大数据量时,由于缺少过期策略,会导致内存溢出的问题; | |||
private Map<Bytes, InnerMerkleAccount> latestAccountsCache = new HashMap<>(); | |||
@@ -97,7 +99,7 @@ public class MerkleAccountSet implements Transactional, MerkleProvable, AccountQ | |||
/** | |||
* 返回账户的总数量; | |||
* | |||
* | |||
* @return | |||
*/ | |||
public long getTotal() { | |||
@@ -111,7 +113,7 @@ public class MerkleAccountSet implements Transactional, MerkleProvable, AccountQ | |||
/** | |||
* 返回最新版本的 Account; | |||
* | |||
* | |||
* @param address | |||
* @return | |||
*/ | |||
@@ -122,10 +124,10 @@ public class MerkleAccountSet implements Transactional, MerkleProvable, AccountQ | |||
/** | |||
* 账户是否存在;<br> | |||
* | |||
* | |||
* 如果指定的账户已经注册(通过 {@link #register(String, PubKey)} 方法),但尚未提交(通过 | |||
* {@link #commit()} 方法),此方法对该账户仍然返回 false; | |||
* | |||
* | |||
* @param address | |||
* @return | |||
*/ | |||
@@ -145,7 +147,7 @@ public class MerkleAccountSet implements Transactional, MerkleProvable, AccountQ | |||
* 如果账户不存在,则返回 -1;<br> | |||
* 如果账户已经注册(通过 {@link #register(String, PubKey)} 方法),但尚未提交(通过 {@link #commit()} | |||
* 方法),则返回 -1; <br> | |||
* | |||
* | |||
* @param address | |||
* @return | |||
*/ | |||
@@ -161,9 +163,9 @@ public class MerkleAccountSet implements Transactional, MerkleProvable, AccountQ | |||
/** | |||
* 返回指定版本的 Account; | |||
* | |||
* | |||
* 只有最新版本的账户才能可写的,其它都是只读; | |||
* | |||
* | |||
* @param address 账户地址; | |||
* @param version 账户版本;如果指定为 -1,则返回最新版本; | |||
* @return | |||
@@ -200,7 +202,7 @@ public class MerkleAccountSet implements Transactional, MerkleProvable, AccountQ | |||
// Now, be sure that "acc == null", so get account from storage; | |||
// Set readonly for the old version account; | |||
boolean readonly = (version > -1 && version < latestVersion) || isReadonly(); | |||
long qVersion = version == -1 ? latestVersion : version; | |||
// load account from storage; | |||
acc = loadAccount(address, readonly, qVersion); | |||
@@ -221,11 +223,11 @@ public class MerkleAccountSet implements Transactional, MerkleProvable, AccountQ | |||
/** | |||
* 注册一个新账户; <br> | |||
* | |||
* | |||
* 如果账户已经存在,则会引发 {@link LedgerException} 异常; <br> | |||
* | |||
* | |||
* 如果指定的地址和公钥不匹配,则会引发 {@link LedgerException} 异常; | |||
* | |||
* | |||
* @param address 区块链地址; | |||
* @param pubKey 公钥; | |||
* @return 注册成功的账户对象; | |||
@@ -248,7 +250,11 @@ public class MerkleAccountSet implements Transactional, MerkleProvable, AccountQ | |||
// 相同的账户已经存在; | |||
throw new LedgerException("The registering account already exist!"); | |||
} | |||
logger.debug("before merkleDataset.getVersion...[address={}]",address); | |||
long version = merkleDataset.getVersion(address); | |||
logger.debug("after merkleDataset.getVersion...[address={}]",address); | |||
if (version >= 0) { | |||
throw new LedgerException("The registering account already exist!", TransactionState.ACCOUNT_REGISTER_CONFLICT); | |||
} | |||
@@ -278,7 +284,7 @@ public class MerkleAccountSet implements Transactional, MerkleProvable, AccountQ | |||
/** | |||
* 加载指定版本的账户; | |||
* | |||
* | |||
* @param address 账户地址; | |||
* @param readonly 是否只读; | |||
* @param version 账户的版本;大于等于 0 ; | |||
@@ -307,7 +313,7 @@ public class MerkleAccountSet implements Transactional, MerkleProvable, AccountQ | |||
/** | |||
* 保存账户的根哈希,返回账户的新版本; | |||
* | |||
* | |||
* @param account | |||
* @return | |||
*/ | |||
@@ -361,7 +367,7 @@ public class MerkleAccountSet implements Transactional, MerkleProvable, AccountQ | |||
/** | |||
* 内部实现的账户,监听和同步账户数据的变更; | |||
* | |||
* | |||
* @author huanghaiquan | |||
* | |||
*/ | |||
@@ -402,4 +408,4 @@ public class MerkleAccountSet implements Transactional, MerkleProvable, AccountQ | |||
} | |||
} | |||
} |
@@ -17,17 +17,19 @@ import com.jd.blockchain.utils.DataIterator; | |||
import com.jd.blockchain.utils.Dataset; | |||
import com.jd.blockchain.utils.Transactional; | |||
import com.jd.blockchain.utils.io.BytesUtils; | |||
import org.slf4j.Logger; | |||
import org.slf4j.LoggerFactory; | |||
/** | |||
* 对新的数据项按顺序递增进行编号的 Merkle 数据集; <br> | |||
* | |||
* | |||
* 注:此实现不是线程安全的; | |||
* | |||
* | |||
* @author huanghaiquan | |||
* | |||
*/ | |||
public class MerkleDataSet implements Transactional, MerkleProvable, Dataset<Bytes, byte[]> { | |||
private Logger logger = LoggerFactory.getLogger(MerkleDataSet.class); | |||
/** | |||
* 4 MB MaxSize of value; | |||
*/ | |||
@@ -58,7 +60,7 @@ public class MerkleDataSet implements Transactional, MerkleProvable, Dataset<Byt | |||
/* | |||
* (non-Javadoc) | |||
* | |||
* | |||
* @see com.jd.blockchain.ledger.core.MerkleProvable#getRootHash() | |||
*/ | |||
@Override | |||
@@ -68,7 +70,7 @@ public class MerkleDataSet implements Transactional, MerkleProvable, Dataset<Byt | |||
/** | |||
* 创建一个新的 MerkleDataSet; | |||
* | |||
* | |||
* @param setting 密码设置; | |||
* @param exPolicyStorage 默克尔树的存储; | |||
* @param versioningStorage 数据的存储; | |||
@@ -80,7 +82,7 @@ public class MerkleDataSet implements Transactional, MerkleProvable, Dataset<Byt | |||
/** | |||
* 创建一个新的 MerkleDataSet; | |||
* | |||
* | |||
* @param setting 密码设置; | |||
* @param exPolicyStorage 默克尔树的存储; | |||
* @param versioningStorage 数据的存储; | |||
@@ -111,7 +113,7 @@ public class MerkleDataSet implements Transactional, MerkleProvable, Dataset<Byt | |||
/** | |||
* 从指定的 Merkle 根构建的 MerkleDataSet; | |||
* | |||
* | |||
* @param dataStorage | |||
* @param defaultMerkleHashAlgorithm | |||
* @param verifyMerkleHashOnLoad | |||
@@ -125,7 +127,7 @@ public class MerkleDataSet implements Transactional, MerkleProvable, Dataset<Byt | |||
/** | |||
* 从指定的 Merkle 根构建的 MerkleDataSet; | |||
* | |||
* | |||
* @param dataStorage | |||
* @param defaultMerkleHashAlgorithm | |||
* @param verifyMerkleHashOnLoad | |||
@@ -169,7 +171,7 @@ public class MerkleDataSet implements Transactional, MerkleProvable, Dataset<Byt | |||
/** | |||
* 返回理论上允许的最大数据索引; | |||
* | |||
* | |||
* @return | |||
*/ | |||
public long getMaxIndex() { | |||
@@ -229,7 +231,7 @@ public class MerkleDataSet implements Transactional, MerkleProvable, Dataset<Byt | |||
/** | |||
* get the data at the specific index; | |||
* | |||
* | |||
* @param fromIndex | |||
* @return | |||
*/ | |||
@@ -241,7 +243,7 @@ public class MerkleDataSet implements Transactional, MerkleProvable, Dataset<Byt | |||
/** | |||
* get the key at the specific index; | |||
* | |||
* | |||
* @param fromIndex | |||
* @return | |||
*/ | |||
@@ -254,14 +256,14 @@ public class MerkleDataSet implements Transactional, MerkleProvable, Dataset<Byt | |||
// /** | |||
// * Create or update the value associated the specified key if the version | |||
// * checking is passed.<br> | |||
// * | |||
// * | |||
// * The value of the key will be updated only if it's latest version equals the | |||
// * specified version argument. <br> | |||
// * If the key doesn't exist, it will be created when the version arg was -1. | |||
// * <p> | |||
// * If updating is performed, the version of the key increase by 1. <br> | |||
// * If creating is performed, the version of the key initialize by 0. <br> | |||
// * | |||
// * | |||
// * @param key The key of data; | |||
// * @param value The value of data; | |||
// * @param version The expected latest version of the key. | |||
@@ -279,14 +281,14 @@ public class MerkleDataSet implements Transactional, MerkleProvable, Dataset<Byt | |||
/** | |||
* Create or update the value associated the specified key if the version | |||
* checking is passed.<br> | |||
* | |||
* | |||
* The value of the key will be updated only if it's latest version equals the | |||
* specified version argument. <br> | |||
* If the key doesn't exist, it will be created when the version arg was -1. | |||
* <p> | |||
* If updating is performed, the version of the key increase by 1. <br> | |||
* If creating is performed, the version of the key initialize by 0. <br> | |||
* | |||
* | |||
* @param key The key of data; | |||
* @param value The value of data; | |||
* @param version The expected latest version of the key. | |||
@@ -342,7 +344,9 @@ public class MerkleDataSet implements Transactional, MerkleProvable, Dataset<Byt | |||
} | |||
// update merkle tree; | |||
logger.debug("before merkleTree.setData(...),key={}",key); | |||
merkleTree.setData(sn, key, newVersion, value); | |||
logger.debug("after merkleTree.setData(...),key={}",key); | |||
// TODO: 未在当前实例的层面,实现对输入键-值的缓冲,而直接写入了存储,而 MerkleTree 在未调用 commit | |||
// 之前是缓冲的,这使得在存储层面的数据会不一致,而未来需要优化; | |||
@@ -359,7 +363,7 @@ public class MerkleDataSet implements Transactional, MerkleProvable, Dataset<Byt | |||
/** | |||
* 返回指定 key 对应的序号,如果不存在,则返回 -1; | |||
* | |||
* | |||
* @param key | |||
* @return | |||
*/ | |||
@@ -378,7 +382,7 @@ public class MerkleDataSet implements Transactional, MerkleProvable, Dataset<Byt | |||
/** | |||
* 返回默克尔树中记录的指定键的版本,在由默克尔树表示的数据集的快照中,这是指定键的最新版本,<br> | |||
* 但该版本有可能小于实际存储的最新版本(由于后续追加的新修改被之后生成的快照维护); | |||
* | |||
* | |||
* @param key | |||
* @return 返回指定的键的版本;如果不存在,则返回 -1; | |||
*/ | |||
@@ -396,10 +400,10 @@ public class MerkleDataSet implements Transactional, MerkleProvable, Dataset<Byt | |||
// /** | |||
// * Return the specified version's value;<br> | |||
// * | |||
// * | |||
// * If the key with the specified version doesn't exist, then return null;<br> | |||
// * If the version is specified to -1, then return the latest version's value; | |||
// * | |||
// * | |||
// * @param key | |||
// * @param version | |||
// */ | |||
@@ -410,10 +414,10 @@ public class MerkleDataSet implements Transactional, MerkleProvable, Dataset<Byt | |||
/** | |||
* Return the specified version's value;<br> | |||
* | |||
* | |||
* If the key with the specified version doesn't exist, then return null;<br> | |||
* If the version is specified to -1, then return the latest version's value; | |||
* | |||
* | |||
* @param key | |||
* @param version | |||
*/ | |||
@@ -432,7 +436,7 @@ public class MerkleDataSet implements Transactional, MerkleProvable, Dataset<Byt | |||
// /** | |||
// * Return the latest version's value; | |||
// * | |||
// * | |||
// * @param key | |||
// * @return return null if not exist; | |||
// */ | |||
@@ -443,7 +447,7 @@ public class MerkleDataSet implements Transactional, MerkleProvable, Dataset<Byt | |||
/** | |||
* Return the latest version's value; | |||
* | |||
* | |||
* @param key | |||
* @return return null if not exist; | |||
*/ | |||
@@ -460,7 +464,7 @@ public class MerkleDataSet implements Transactional, MerkleProvable, Dataset<Byt | |||
// /** | |||
// * Return the latest version entry associated the specified key; If the key | |||
// * doesn't exist, then return -1; | |||
// * | |||
// * | |||
// * @param key | |||
// * @return | |||
// */ | |||
@@ -472,7 +476,7 @@ public class MerkleDataSet implements Transactional, MerkleProvable, Dataset<Byt | |||
/** | |||
* Return the latest version entry associated the specified key; If the key | |||
* doesn't exist, then return -1; | |||
* | |||
* | |||
* @param key | |||
* @return | |||
*/ | |||
@@ -487,7 +491,7 @@ public class MerkleDataSet implements Transactional, MerkleProvable, Dataset<Byt | |||
// } | |||
/** | |||
* | |||
* | |||
* @param key | |||
* @return Null if the key doesn't exist! | |||
*/ | |||
@@ -565,7 +569,7 @@ public class MerkleDataSet implements Transactional, MerkleProvable, Dataset<Byt | |||
/* | |||
* (non-Javadoc) | |||
* | |||
* | |||
* @see com.jd.blockchain.ledger.core.MerkleProvable#getProof(java.lang.String) | |||
*/ | |||
@Override | |||
@@ -579,7 +583,7 @@ public class MerkleDataSet implements Transactional, MerkleProvable, Dataset<Byt | |||
/** | |||
* A wrapper for {@link DataEntry} and {@link MerkleProof}; | |||
* | |||
* | |||
* @author huanghaiquan | |||
* | |||
*/ | |||
@@ -737,4 +741,4 @@ public class MerkleDataSet implements Transactional, MerkleProvable, Dataset<Byt | |||
} | |||
} | |||
} |
@@ -84,14 +84,14 @@ public class TransactionBatchProcessor implements TransactionBatchProcess { | |||
public TransactionBatchProcessor(LedgerRepository ledgerRepo, OperationHandleRegisteration handlesRegisteration) { | |||
this.ledger = ledgerRepo; | |||
this.handlesRegisteration = handlesRegisteration; | |||
LedgerBlock ledgerBlock = ledgerRepo.getLatestBlock(); | |||
LedgerDataQuery ledgerDataQuery = ledgerRepo.getLedgerData(ledgerBlock); | |||
LedgerAdminDataQuery previousAdminDataset = ledgerDataQuery.getAdminDataset(); | |||
this.securityManager = new LedgerSecurityManagerImpl(previousAdminDataset.getAdminInfo().getRolePrivileges(), | |||
previousAdminDataset.getAdminInfo().getAuthorizations(), previousAdminDataset.getParticipantDataset(), | |||
ledgerDataQuery.getUserAccountSet()); | |||
this.newBlockEditor = ledgerRepo.createNextBlock(); | |||
} | |||
@@ -115,7 +115,7 @@ public class TransactionBatchProcessor implements TransactionBatchProcess { | |||
/* | |||
* (non-Javadoc) | |||
* | |||
* | |||
* @see | |||
* com.jd.blockchain.ledger.core.impl.TransactionBatchProcess#schedule(com.jd. | |||
* blockchain.ledger.TransactionRequest) | |||
@@ -151,6 +151,8 @@ public class TransactionBatchProcessor implements TransactionBatchProcess { | |||
LedgerTransactionContext txCtx = newBlockEditor.newTransaction(request); | |||
// 处理交易; | |||
LOGGER.debug("before handleTx...after checkRequest()... --[BlockHeight={}][RequestHash={}][TxHash={}]", | |||
newBlockEditor.getBlockHeight(), request.getHash(), request.getTransactionContent().getHash()); | |||
resp = handleTx(reqExt, txCtx); | |||
LOGGER.debug("Complete handling transaction. --[BlockHeight={}][RequestHash={}][TxHash={}]", | |||
@@ -262,9 +264,9 @@ public class TransactionBatchProcessor implements TransactionBatchProcess { | |||
/** | |||
* 处理交易;<br> | |||
* | |||
* | |||
* 此方法会处理所有的异常,以不同结果的 {@link TransactionResponse} 返回; | |||
* | |||
* | |||
* @param request | |||
* @param txCtx | |||
* @return | |||
@@ -299,7 +301,11 @@ public class TransactionBatchProcessor implements TransactionBatchProcess { | |||
// 提交交易(事务); | |||
result = TransactionState.SUCCESS; | |||
LOGGER.debug("before commit(). --[BlockHeight={}][RequestHash={}][TxHash={}]", | |||
newBlockEditor.getBlockHeight(), request.getHash(), request.getTransactionContent().getHash()); | |||
txCtx.commit(result, operationResults); | |||
LOGGER.debug("after commit(). --[BlockHeight={}][RequestHash={}][TxHash={}]", | |||
newBlockEditor.getBlockHeight(), request.getHash(), request.getTransactionContent().getHash()); | |||
} catch (TransactionRollbackException e) { | |||
result = TransactionState.IGNORED_BY_TX_FULL_ROLLBACK; | |||
txCtx.rollback(); | |||
@@ -372,7 +378,7 @@ public class TransactionBatchProcessor implements TransactionBatchProcess { | |||
/** | |||
* 直接丢弃交易; | |||
* | |||
* | |||
* @param request | |||
* @param txState | |||
* @return 丢弃交易的回复;只包含原始请求中的交易内容哈希和交易被丢弃的原因,而不包含区块信息; | |||
@@ -390,7 +396,7 @@ public class TransactionBatchProcessor implements TransactionBatchProcess { | |||
/* | |||
* (non-Javadoc) | |||
* | |||
* | |||
* @see com.jd.blockchain.ledger.core.impl.TransactionBatchProcess#prepare() | |||
*/ | |||
@Override | |||
@@ -405,7 +411,7 @@ public class TransactionBatchProcessor implements TransactionBatchProcess { | |||
/* | |||
* (non-Javadoc) | |||
* | |||
* | |||
* @see | |||
* com.jd.blockchain.ledger.core.impl.TransactionBatchProcess#cancel(com.jd. | |||
* blockchain.ledger.ExecutionState) | |||
@@ -12,9 +12,11 @@ import com.jd.blockchain.storage.service.ExPolicyKVStorage; | |||
import com.jd.blockchain.storage.service.VersioningKVStorage; | |||
import com.jd.blockchain.utils.Bytes; | |||
import com.jd.blockchain.utils.Transactional; | |||
import org.slf4j.Logger; | |||
import org.slf4j.LoggerFactory; | |||
public class TransactionSet implements Transactional, TransactionQuery { | |||
private Logger logger = LoggerFactory.getLogger(TransactionSet.class); | |||
static { | |||
DataContractRegistry.register(LedgerTransaction.class); | |||
} | |||
@@ -67,7 +69,7 @@ public class TransactionSet implements Transactional, TransactionQuery { | |||
/** | |||
* Create a new TransactionSet which can be added transaction; | |||
* | |||
* | |||
* @param setting | |||
* @param merkleTreeStorage | |||
* @param dataStorage | |||
@@ -80,7 +82,7 @@ public class TransactionSet implements Transactional, TransactionQuery { | |||
/** | |||
* Create TransactionSet which is readonly to the history transactions; | |||
* | |||
* | |||
* @param setting | |||
* @param merkleTreeStorage | |||
* @param dataStorage | |||
@@ -12,16 +12,18 @@ import com.jd.blockchain.ledger.core.OperationHandleContext; | |||
import com.jd.blockchain.ledger.core.SecurityContext; | |||
import com.jd.blockchain.ledger.core.SecurityPolicy; | |||
import com.jd.blockchain.ledger.core.TransactionRequestExtension; | |||
import org.slf4j.Logger; | |||
import org.slf4j.LoggerFactory; | |||
/** | |||
* 执行直接账本操作的处理类; | |||
* | |||
* | |||
* @author huanghaiquan | |||
* | |||
* @param <T> | |||
*/ | |||
public abstract class AbstractLedgerOperationHandle<T extends Operation> implements OperationHandle { | |||
private Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
static { | |||
DataContractRegistry.register(BytesValue.class); | |||
} | |||
@@ -52,8 +54,11 @@ public abstract class AbstractLedgerOperationHandle<T extends Operation> impleme | |||
// 操作账本; | |||
@SuppressWarnings("unchecked") | |||
T concretedOp = (T) op; | |||
logger.debug("before doProcess()... --[RequestHash={}][TxHash={}]", | |||
requestContext.getHash(), requestContext.getTransactionContent().getHash()); | |||
doProcess(concretedOp, newBlockDataset, requestContext, ledger, handleContext); | |||
logger.debug("after doProcess()... --[RequestHash={}][TxHash={}]", | |||
requestContext.getHash(), requestContext.getTransactionContent().getHash()); | |||
// 账本操作没有返回值; | |||
return null; | |||
} | |||
@@ -10,9 +10,11 @@ import com.jd.blockchain.ledger.core.OperationHandleContext; | |||
import com.jd.blockchain.ledger.core.SecurityContext; | |||
import com.jd.blockchain.ledger.core.SecurityPolicy; | |||
import com.jd.blockchain.ledger.core.TransactionRequestExtension; | |||
import org.slf4j.Logger; | |||
import org.slf4j.LoggerFactory; | |||
public class DataAccountRegisterOperationHandle extends AbstractLedgerOperationHandle<DataAccountRegisterOperation> { | |||
private Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
public DataAccountRegisterOperationHandle() { | |||
super(DataAccountRegisterOperation.class); | |||
} | |||
@@ -29,7 +31,9 @@ public class DataAccountRegisterOperationHandle extends AbstractLedgerOperationH | |||
// 操作账本; | |||
DataAccountRegisterOperation dataAccountRegOp = (DataAccountRegisterOperation) op; | |||
BlockchainIdentity bid = dataAccountRegOp.getAccountID(); | |||
logger.debug("before register.[dataAddress={}]",bid.getAddress()); | |||
newBlockDataset.getDataAccountSet().register(bid.getAddress(), bid.getPubKey(), null); | |||
logger.debug("after register.[dataAddress={}]",bid.getAddress()); | |||
} | |||
} |
@@ -41,6 +41,7 @@ public class RolesConfigureOperationHandle extends AbstractLedgerOperationHandle | |||
rp.disable(rpcfg.getDisableLedgerPermissions()); | |||
rp.disable(rpcfg.getDisableTransactionPermissions()); | |||
rpSettings.updateRolePrivilege(rp); | |||
} | |||
} | |||
} | |||
@@ -14,6 +14,8 @@ import com.jd.blockchain.service.TransactionEngine; | |||
import com.jd.blockchain.utils.codec.Base58Utils; | |||
import com.jd.blockchain.utils.concurrent.AsyncFuture; | |||
import com.jd.blockchain.utils.concurrent.CompletableAsyncFuture; | |||
import org.slf4j.Logger; | |||
import org.slf4j.LoggerFactory; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.stereotype.Component; | |||
@@ -37,7 +39,7 @@ import java.util.concurrent.locks.ReentrantLock; | |||
*/ | |||
@Component | |||
public class ConsensusMessageDispatcher implements MessageHandle { | |||
private Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
@Autowired | |||
private TransactionEngine txEngine; | |||
@@ -119,7 +121,9 @@ public class ConsensusMessageDispatcher implements MessageHandle { | |||
if (!realmProcessor.getCurrBatchId().equalsIgnoreCase(batchId)) { | |||
throw new IllegalArgumentException("BatchId is not begin!"); | |||
} | |||
logger.debug("before realmProcessor.commit(),[batchId={}]",batchId); | |||
realmProcessor.commit(); | |||
logger.debug("after realmProcessor.commit(),[batchId={}]",batchId); | |||
// realmProcessorMap.remove(realmName); | |||
} | |||