Skip to content

Commit

Permalink
Merge pull request #1096 from tronprotocol/add_message
Browse files Browse the repository at this point in the history
Add message
  • Loading branch information
zhaohong authored Jun 24, 2018
2 parents c50e14f + 6e3099d commit 07236ce
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/main/java/org/tron/core/capsule/BlockCapsule.java
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ public BlockCapsule(long number, Sha256Hash hash, long when, ByteString witnessA
initTxs();
}


public BlockCapsule(long timestamp, ByteString parentHash, long number,
List<Transaction> transactionList) {
// blockheader raw
Expand Down Expand Up @@ -248,6 +249,15 @@ 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())).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());
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/tron/core/capsule/utils/BlockUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 07236ce

Please sign in to comment.