diff options
author | Jimmy Hu <jimmy.hu@dexon.org> | 2018-08-30 17:21:58 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-30 17:21:58 +0800 |
commit | 96554a3bc14030e5d0dfc9dc1ee6bcdd9a133fa8 (patch) | |
tree | 418e2c43acf4f9c13289eaccf66f94ef46c9356b /core/types/block.go | |
parent | a4e0da981a3dfc8817d39be65cb5b24938b0761a (diff) | |
download | tangerine-consensus-96554a3bc14030e5d0dfc9dc1ee6bcdd9a133fa8.tar tangerine-consensus-96554a3bc14030e5d0dfc9dc1ee6bcdd9a133fa8.tar.gz tangerine-consensus-96554a3bc14030e5d0dfc9dc1ee6bcdd9a133fa8.tar.bz2 tangerine-consensus-96554a3bc14030e5d0dfc9dc1ee6bcdd9a133fa8.tar.lz tangerine-consensus-96554a3bc14030e5d0dfc9dc1ee6bcdd9a133fa8.tar.xz tangerine-consensus-96554a3bc14030e5d0dfc9dc1ee6bcdd9a133fa8.tar.zst tangerine-consensus-96554a3bc14030e5d0dfc9dc1ee6bcdd9a133fa8.zip |
core: Add PreparePayloads to Application and Remove blockConverter interface. (#84)
Diffstat (limited to 'core/types/block.go')
-rw-r--r-- | core/types/block.go | 29 |
1 files changed, 6 insertions, 23 deletions
diff --git a/core/types/block.go b/core/types/block.go index 1a55121..f13d868 100644 --- a/core/types/block.go +++ b/core/types/block.go @@ -70,6 +70,7 @@ type Block struct { Height uint64 `json:"height"` Timestamps map[ValidatorID]time.Time `json:"timestamps"` Acks map[common.Hash]struct{} `json:"acks"` + Payloads [][]byte `json:"payloads"` Signature crypto.Signature `json:"signature"` CRSSignature crypto.Signature `json:"crs_signature"` @@ -77,29 +78,6 @@ type Block struct { Notary Notary `json:"notary"` } -// Block implements BlockConverter interface. -func (b *Block) Block() *Block { - return b -} - -// Payloads impelmemnts BlockConverter interface. -func (b *Block) Payloads() [][]byte { - return [][]byte{} -} - -// SetBlock implments BlockConverter interface. -func (b *Block) SetBlock(block *Block) { - *b = *block -} - -// BlockConverter interface define the interface for extracting block -// information from an existing object. -type BlockConverter interface { - Block() *Block - Payloads() [][]byte - SetBlock(block *Block) -} - func (b *Block) String() string { return fmt.Sprintf("Block(%v)", b.Hash.String()[:6]) } @@ -130,6 +108,11 @@ 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) + } return } |