diff options
author | Wei-Ning Huang <w@dexon.org> | 2018-09-12 11:47:27 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-12 11:47:27 +0800 |
commit | 743983c82b601e200fa53d4aa8973f83ff628d29 (patch) | |
tree | 25ba7f6974233e062e8a8824ac702ac2c715f5a9 /core/types/block.go | |
parent | 0e8fda250804b9c46232287a18af05e7ccf5bf72 (diff) | |
download | dexon-consensus-743983c82b601e200fa53d4aa8973f83ff628d29.tar dexon-consensus-743983c82b601e200fa53d4aa8973f83ff628d29.tar.gz dexon-consensus-743983c82b601e200fa53d4aa8973f83ff628d29.tar.bz2 dexon-consensus-743983c82b601e200fa53d4aa8973f83ff628d29.tar.lz dexon-consensus-743983c82b601e200fa53d4aa8973f83ff628d29.tar.xz dexon-consensus-743983c82b601e200fa53d4aa8973f83ff628d29.tar.zst dexon-consensus-743983c82b601e200fa53d4aa8973f83ff628d29.zip |
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.
Diffstat (limited to 'core/types/block.go')
-rw-r--r-- | core/types/block.go | 9 |
1 files changed, 3 insertions, 6 deletions
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 } |