diff options
author | Jimmy Hu <jimmy.hu@dexon.org> | 2018-11-13 15:34:22 +0800 |
---|---|---|
committer | Wei-Ning Huang <w@byzantine-lab.io> | 2019-06-12 17:27:18 +0800 |
commit | 08ec9c78c4acfc09f24ddd0f864504fc58cb07e2 (patch) | |
tree | 6f197a58383c922bc541d27e3dff36083d145036 /vendor/github.com/dexon-foundation/dexon-consensus/core/types/block.go | |
parent | aec90eae15b9ad106e3443fc5c5ab6f285e131a0 (diff) | |
download | go-tangerine-08ec9c78c4acfc09f24ddd0f864504fc58cb07e2.tar go-tangerine-08ec9c78c4acfc09f24ddd0f864504fc58cb07e2.tar.gz go-tangerine-08ec9c78c4acfc09f24ddd0f864504fc58cb07e2.tar.bz2 go-tangerine-08ec9c78c4acfc09f24ddd0f864504fc58cb07e2.tar.lz go-tangerine-08ec9c78c4acfc09f24ddd0f864504fc58cb07e2.tar.xz go-tangerine-08ec9c78c4acfc09f24ddd0f864504fc58cb07e2.tar.zst go-tangerine-08ec9c78c4acfc09f24ddd0f864504fc58cb07e2.zip |
vendor: sync to latest core (#16)
Diffstat (limited to 'vendor/github.com/dexon-foundation/dexon-consensus/core/types/block.go')
-rw-r--r-- | vendor/github.com/dexon-foundation/dexon-consensus/core/types/block.go | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/vendor/github.com/dexon-foundation/dexon-consensus/core/types/block.go b/vendor/github.com/dexon-foundation/dexon-consensus/core/types/block.go index 27416d8c9..b24e1f715 100644 --- a/vendor/github.com/dexon-foundation/dexon-consensus/core/types/block.go +++ b/vendor/github.com/dexon-foundation/dexon-consensus/core/types/block.go @@ -83,6 +83,18 @@ type FinalizationResult struct { Height uint64 `json:"height"` } +// Clone returns a deep copy of FinalizationResult +func (f FinalizationResult) Clone() FinalizationResult { + frcopy := FinalizationResult{ + ParentHash: f.ParentHash, + Timestamp: f.Timestamp, + Height: f.Height, + } + frcopy.Randomness = make([]byte, len(f.Randomness)) + copy(frcopy.Randomness, f.Randomness) + return frcopy +} + type rlpFinalizationResult struct { ParentHash common.Hash Randomness []byte @@ -223,9 +235,7 @@ func (b *Block) Clone() (bcopy *Block) { bcopy.Position.Height = b.Position.Height bcopy.Signature = b.Signature.Clone() bcopy.CRSSignature = b.CRSSignature.Clone() - bcopy.Finalization.ParentHash = b.Finalization.ParentHash - bcopy.Finalization.Timestamp = b.Finalization.Timestamp - bcopy.Finalization.Height = b.Finalization.Height + bcopy.Finalization = b.Finalization.Clone() bcopy.Witness.Height = b.Witness.Height bcopy.Witness.Data = make([]byte, len(b.Witness.Data)) copy(bcopy.Witness.Data, b.Witness.Data) @@ -235,8 +245,6 @@ func (b *Block) Clone() (bcopy *Block) { bcopy.Payload = make([]byte, len(b.Payload)) copy(bcopy.Payload, b.Payload) bcopy.PayloadHash = b.PayloadHash - bcopy.Finalization.Randomness = make([]byte, len(b.Finalization.Randomness)) - copy(bcopy.Finalization.Randomness, b.Finalization.Randomness) return } |