Browse Source

Modified comment;

tags/1.0.0
huanghaiquan 5 years ago
parent
commit
a6b0bebfda
1 changed files with 11 additions and 9 deletions
  1. +11
    -9
      source/ledger/ledger-core/src/main/java/com/jd/blockchain/ledger/core/impl/LedgerTransactionalEditor.java

+ 11
- 9
source/ledger/ledger-core/src/main/java/com/jd/blockchain/ledger/core/impl/LedgerTransactionalEditor.java View File

@@ -60,7 +60,7 @@ public class LedgerTransactionalEditor implements LedgerEditor {
} }


public static LedgerTransactionalEditor createEditor(LedgerSetting ledgerSetting, LedgerBlock previousBlock, public static LedgerTransactionalEditor createEditor(LedgerSetting ledgerSetting, LedgerBlock previousBlock,
String ledgerKeyPrefix, ExPolicyKVStorage ledgerExStorage, VersioningKVStorage ledgerVerStorage) {
String ledgerKeyPrefix, ExPolicyKVStorage ledgerExStorage, VersioningKVStorage ledgerVerStorage) {
// new block; // new block;
LedgerBlockData currBlock = new LedgerBlockData(previousBlock.getHeight() + 1, previousBlock.getLedgerHash(), LedgerBlockData currBlock = new LedgerBlockData(previousBlock.getHeight() + 1, previousBlock.getLedgerHash(),
previousBlock.getHash()); previousBlock.getHash());
@@ -123,13 +123,14 @@ public class LedgerTransactionalEditor implements LedgerEditor {
// load the starting point of the new transaction; // load the starting point of the new transaction;
StagedSnapshot previousSnapshot = stagedSnapshots.peek(); StagedSnapshot previousSnapshot = stagedSnapshots.peek();
if (previousSnapshot instanceof GenesisSnapshot) { if (previousSnapshot instanceof GenesisSnapshot) {
// Genesis;
// 准备生成创世区块;
GenesisSnapshot snpht = (GenesisSnapshot) previousSnapshot; GenesisSnapshot snpht = (GenesisSnapshot) previousSnapshot;
txDataset = LedgerRepositoryImpl.newDataSet(snpht.initSetting, ledgerKeyPrefix, txBuffStorage, txDataset = LedgerRepositoryImpl.newDataSet(snpht.initSetting, ledgerKeyPrefix, txBuffStorage,
txBuffStorage); txBuffStorage);
txset = LedgerRepositoryImpl.newTransactionSet(txDataset.getAdminAccount().getSetting(), txset = LedgerRepositoryImpl.newTransactionSet(txDataset.getAdminAccount().getSetting(),
ledgerKeyPrefix, txBuffStorage, txBuffStorage); ledgerKeyPrefix, txBuffStorage, txBuffStorage);
} else { } else {
// 新的区块;
// TxSnapshot; reload dataset and txset; // TxSnapshot; reload dataset and txset;
TxSnapshot snpht = (TxSnapshot) previousSnapshot; TxSnapshot snpht = (TxSnapshot) previousSnapshot;
// load dataset; // load dataset;
@@ -182,8 +183,7 @@ public class LedgerTransactionalEditor implements LedgerEditor {


// compute block hash; // compute block hash;
byte[] blockBodyBytes = BinaryProtocol.encode(newlyBlock, BlockBody.class); byte[] blockBodyBytes = BinaryProtocol.encode(newlyBlock, BlockBody.class);
HashDigest blockHash = Crypto.getHashFunction(cryptoSetting.getHashAlgorithm())
.hash(blockBodyBytes);
HashDigest blockHash = Crypto.getHashFunction(cryptoSetting.getHashAlgorithm()).hash(blockBodyBytes);
newlyBlock.setHash(blockHash); newlyBlock.setHash(blockHash);
if (newlyBlock.getLedgerHash() == null) { if (newlyBlock.getLedgerHash() == null) {
// init GenesisBlock's ledger hash; // init GenesisBlock's ledger hash;
@@ -251,13 +251,13 @@ public class LedgerTransactionalEditor implements LedgerEditor {


private void checkState() { private void checkState() {
if (prepared) { if (prepared) {
throw new IllegalStateException("LedgerEditor had been prepared!");
throw new IllegalStateException("LedgerEditor has been prepared!");
} }
if (committed) { if (committed) {
throw new IllegalStateException("LedgerEditor had been committed!");
throw new IllegalStateException("LedgerEditor has been committed!");
} }
if (canceled) { if (canceled) {
throw new IllegalStateException("LedgerEditor had been canceled!");
throw new IllegalStateException("LedgerEditor has been canceled!");
} }
} }


@@ -366,7 +366,8 @@ public class LedgerTransactionalEditor implements LedgerEditor {
// LedgerTransactionData tx = new LedgerTransactionData(blockHeight, txRequest, // LedgerTransactionData tx = new LedgerTransactionData(blockHeight, txRequest,
// txResult, txDataSnapshot); // txResult, txDataSnapshot);


LedgerTransactionData tx = new LedgerTransactionData(blockHeight, txRequest, txResult, null, operationResultArray(operationResults));
LedgerTransactionData tx = new LedgerTransactionData(blockHeight, txRequest, txResult, null,
operationResultArray(operationResults));
this.txset.add(tx); this.txset.add(tx);
// this.txset.commit(); // this.txset.commit();


@@ -397,7 +398,8 @@ public class LedgerTransactionalEditor implements LedgerEditor {
// TransactionStagedSnapshot txDataSnapshot = takeSnapshot(); // TransactionStagedSnapshot txDataSnapshot = takeSnapshot();
// LedgerTransactionData tx = new LedgerTransactionData(blockHeight, txRequest, // LedgerTransactionData tx = new LedgerTransactionData(blockHeight, txRequest,
// txResult, txDataSnapshot); // txResult, txDataSnapshot);
LedgerTransactionData tx = new LedgerTransactionData(blockHeight, txRequest, txResult, null, operationResultArray(operationResults));
LedgerTransactionData tx = new LedgerTransactionData(blockHeight, txRequest, txResult, null,
operationResultArray(operationResults));
this.txset.add(tx); this.txset.add(tx);
// this.txset.commit(); // this.txset.commit();




Loading…
Cancel
Save