From 743983c82b601e200fa53d4aa8973f83ff628d29 Mon Sep 17 00:00:00 2001 From: Wei-Ning Huang Date: Wed, 12 Sep 2018 11:47:27 +0800 Subject: core: types: use []byte for block Payload type (#101) Change payload type to []byte instead of [][]byte to make it more generic. The user of the consensus core should marshal the payload into a byte slice by themselves. --- core/types/block.go | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'core/types/block.go') diff --git a/core/types/block.go b/core/types/block.go index 3585a97..06712b1 100644 --- a/core/types/block.go +++ b/core/types/block.go @@ -63,7 +63,7 @@ type Block struct { Position Position `json:"position"` Timestamp time.Time `json:"timestamps"` Acks map[common.Hash]struct{} `json:"acks"` - Payloads [][]byte `json:"payloads"` + Payload []byte `json:"payload"` Signature crypto.Signature `json:"signature"` CRSSignature crypto.Signature `json:"crs_signature"` @@ -96,11 +96,8 @@ func (b *Block) Clone() (bcopy *Block) { for k, v := range b.Acks { bcopy.Acks[k] = v } - bcopy.Payloads = make([][]byte, len(b.Payloads)) - for k, v := range b.Payloads { - bcopy.Payloads[k] = make([]byte, len(v)) - copy(bcopy.Payloads[k], v) - } + bcopy.Payload = make([]byte, len(b.Payload)) + copy(bcopy.Payload, b.Payload) return } -- cgit v1.2.3