diff options
author | Jimmy Hu <jimmy.hu@dexon.org> | 2019-02-27 10:41:01 +0800 |
---|---|---|
committer | Wei-Ning Huang <w@byzantine-lab.io> | 2019-06-12 17:27:22 +0800 |
commit | 2b2396b6bce0f21b515ac2d38556f6dca08b1770 (patch) | |
tree | 60d6c93689b54534ecc88bd1491bd82fa372b541 /vendor/github.com/dexon-foundation/dexon-consensus/core/types/block.go | |
parent | edb1273cb08d56df41b30b1f2f2e113f9b4296e4 (diff) | |
download | go-tangerine-2b2396b6bce0f21b515ac2d38556f6dca08b1770.tar go-tangerine-2b2396b6bce0f21b515ac2d38556f6dca08b1770.tar.gz go-tangerine-2b2396b6bce0f21b515ac2d38556f6dca08b1770.tar.bz2 go-tangerine-2b2396b6bce0f21b515ac2d38556f6dca08b1770.tar.lz go-tangerine-2b2396b6bce0f21b515ac2d38556f6dca08b1770.tar.xz go-tangerine-2b2396b6bce0f21b515ac2d38556f6dca08b1770.tar.zst go-tangerine-2b2396b6bce0f21b515ac2d38556f6dca08b1770.zip |
core: sync to latest core (#214)
* vendor: sync to latest core
* fix for single chain
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 | 36 |
1 files changed, 10 insertions, 26 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 a2b697ce0..2b23e96e3 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 @@ -23,7 +23,6 @@ import ( "bytes" "fmt" "io" - "sort" "time" "github.com/dexon-foundation/dexon/rlp" @@ -125,17 +124,16 @@ type Witness struct { // Block represents a single event broadcasted on the network. type Block struct { - ProposerID NodeID `json:"proposer_id"` - ParentHash common.Hash `json:"parent_hash"` - Hash common.Hash `json:"hash"` - Position Position `json:"position"` - Timestamp time.Time `json:"timestamp"` - Acks common.SortedHashes `json:"acks"` - Payload []byte `json:"payload"` - PayloadHash common.Hash `json:"payload_hash"` - Witness Witness `json:"witness"` - Finalization FinalizationResult `json:"finalization"` - Signature crypto.Signature `json:"signature"` + ProposerID NodeID `json:"proposer_id"` + ParentHash common.Hash `json:"parent_hash"` + Hash common.Hash `json:"hash"` + Position Position `json:"position"` + Timestamp time.Time `json:"timestamp"` + Payload []byte `json:"payload"` + PayloadHash common.Hash `json:"payload_hash"` + Witness Witness `json:"witness"` + Finalization FinalizationResult `json:"finalization"` + Signature crypto.Signature `json:"signature"` CRSSignature crypto.Signature `json:"crs_signature"` } @@ -146,7 +144,6 @@ type rlpBlock struct { Hash common.Hash Position Position Timestamp *rlpTimestamp - Acks common.SortedHashes Payload []byte PayloadHash common.Hash Witness *Witness @@ -164,7 +161,6 @@ func (b *Block) EncodeRLP(w io.Writer) error { Hash: b.Hash, Position: b.Position, Timestamp: &rlpTimestamp{b.Timestamp}, - Acks: b.Acks, Payload: b.Payload, PayloadHash: b.PayloadHash, Witness: &b.Witness, @@ -185,7 +181,6 @@ func (b *Block) DecodeRLP(s *rlp.Stream) error { Hash: dec.Hash, Position: dec.Position, Timestamp: dec.Timestamp.Time, - Acks: dec.Acks, Payload: dec.Payload, PayloadHash: dec.PayloadHash, Witness: *dec.Witness, @@ -208,7 +203,6 @@ func (b *Block) Clone() (bcopy *Block) { bcopy.ParentHash = b.ParentHash bcopy.Hash = b.Hash bcopy.Position.Round = b.Position.Round - bcopy.Position.ChainID = b.Position.ChainID bcopy.Position.Height = b.Position.Height bcopy.Signature = b.Signature.Clone() bcopy.CRSSignature = b.CRSSignature.Clone() @@ -217,8 +211,6 @@ func (b *Block) Clone() (bcopy *Block) { bcopy.Witness.Data = make([]byte, len(b.Witness.Data)) copy(bcopy.Witness.Data, b.Witness.Data) bcopy.Timestamp = b.Timestamp - bcopy.Acks = make(common.SortedHashes, len(b.Acks)) - copy(bcopy.Acks, b.Acks) bcopy.Payload = make([]byte, len(b.Payload)) copy(bcopy.Payload, b.Payload) bcopy.PayloadHash = b.PayloadHash @@ -240,14 +232,6 @@ func (b *Block) IsEmpty() bool { return b.ProposerID.Hash == common.Hash{} } -// IsAcking checks if a block acking another by it's hash. -func (b *Block) IsAcking(hash common.Hash) bool { - idx := sort.Search(len(b.Acks), func(i int) bool { - return bytes.Compare(b.Acks[i][:], hash[:]) >= 0 - }) - return !(idx == len(b.Acks) || b.Acks[idx] != hash) -} - // ByHash is the helper type for sorting slice of blocks by hash. type ByHash []*Block |