From 0bbec44c2a9a3cfadbded49afcefe8b5cad4f352 Mon Sep 17 00:00:00 2001 From: zhaohong Date: Sun, 24 Jun 2018 12:04:49 +0800 Subject: [PATCH] add message. --- src/main/java/org/tron/core/capsule/BlockCapsule.java | 11 +++++++++++ .../java/org/tron/core/capsule/utils/BlockUtil.java | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/tron/core/capsule/BlockCapsule.java b/src/main/java/org/tron/core/capsule/BlockCapsule.java index fab6aa433dc..f5464055eeb 100755 --- a/src/main/java/org/tron/core/capsule/BlockCapsule.java +++ b/src/main/java/org/tron/core/capsule/BlockCapsule.java @@ -140,6 +140,7 @@ public BlockCapsule(long number, Sha256Hash hash, long when, ByteString witnessA initTxs(); } + public BlockCapsule(long timestamp, ByteString parentHash, long number, List transactionList) { // blockheader raw @@ -248,6 +249,16 @@ public void setMerkleRoot() { this.block = this.block.toBuilder().setBlockHeader( this.block.getBlockHeader().toBuilder().setRawData(blockHeaderRaw)).build(); } + /* only for genisis */ + public void setWitness(String witness) { + BlockHeader.raw blockHeaderRaw = + this.block.getBlockHeader().getRawData().toBuilder().setWitnessAddress( + ByteString.copyFrom(witness.getBytes())) + .setTxTrieRoot(calcMerkleRoot().getByteString()).build(); + + this.block = this.block.toBuilder().setBlockHeader( + this.block.getBlockHeader().toBuilder().setRawData(blockHeaderRaw)).build(); + } public Sha256Hash getMerkleRoot() { return Sha256Hash.wrap(this.block.getBlockHeader().getRawData().getTxTrieRoot()); diff --git a/src/main/java/org/tron/core/capsule/utils/BlockUtil.java b/src/main/java/org/tron/core/capsule/utils/BlockUtil.java index 98a9de8a731..ea422623db0 100644 --- a/src/main/java/org/tron/core/capsule/utils/BlockUtil.java +++ b/src/main/java/org/tron/core/capsule/utils/BlockUtil.java @@ -50,7 +50,7 @@ public static BlockCapsule newGenesisBlockCapsule() { BlockCapsule blockCapsule = new BlockCapsule(timestamp, parentHash, number, transactionList); blockCapsule.setMerkleRoot(); - + blockCapsule.setWitness("A new system must allow existing systems to be linked together without requiring any central control or coordination"); blockCapsule.generatedByMyself = true; return blockCapsule;