Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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