diff options
author | Jimmy Hu <jimmy.hu@dexon.org> | 2018-08-08 11:28:57 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-08 11:28:57 +0800 |
commit | a418ea95c0f5afb50cbb78aedecc68373353d06e (patch) | |
tree | 79bee8ef152f58c0b3bbcbe38d4dd537050b72aa /core/types | |
parent | 3a929b656b6bd5846849fd98dc29ff761db97ed3 (diff) | |
download | dexon-consensus-a418ea95c0f5afb50cbb78aedecc68373353d06e.tar dexon-consensus-a418ea95c0f5afb50cbb78aedecc68373353d06e.tar.gz dexon-consensus-a418ea95c0f5afb50cbb78aedecc68373353d06e.tar.bz2 dexon-consensus-a418ea95c0f5afb50cbb78aedecc68373353d06e.tar.lz dexon-consensus-a418ea95c0f5afb50cbb78aedecc68373353d06e.tar.xz dexon-consensus-a418ea95c0f5afb50cbb78aedecc68373353d06e.tar.zst dexon-consensus-a418ea95c0f5afb50cbb78aedecc68373353d06e.zip |
crypto: Add crypto module. (#34)
Diffstat (limited to 'core/types')
-rw-r--r-- | core/types/block.go | 36 |
1 files changed, 28 insertions, 8 deletions
diff --git a/core/types/block.go b/core/types/block.go index 56b456c..8a27ab0 100644 --- a/core/types/block.go +++ b/core/types/block.go @@ -23,6 +23,7 @@ import ( "time" "github.com/dexon-foundation/dexon-consensus-core/common" + "github.com/dexon-foundation/dexon-consensus-core/crypto" ) // Status represents the block process state. @@ -36,16 +37,35 @@ const ( BlockStatusFinal ) +// CompactionChainAck represents the acking to the compaction chain. +type CompactionChainAck struct { + AckingBlockHash common.Hash `json:"acking_block_hash"` + // Signature is the signature of the hash value of + // Block.ConsensusInfoParentHash and Block.ConsensusInfo. + ConsensusSignature crypto.Signature `json:"consensus_signature"` +} + +// ConsensusInfo represents the consensus information on the compaction chain. +type ConsensusInfo struct { + Timestamp time.Time `json:"timestamp"` + Height uint64 `json:"height"` +} + // Block represents a single event broadcasted on the network. type Block struct { - ProposerID ValidatorID `json:"proposer_id"` - ParentHash common.Hash `json:"parent_hash"` - Hash common.Hash `json:"hash"` - Height uint64 `json:"height"` - Timestamps map[ValidatorID]time.Time `json:"timestamps"` - Acks map[common.Hash]struct{} `json:"acks"` - ConsensusTime time.Time `json:"consensus_time"` - ConsensusHeight uint64 `json:"consensus_height"` + ProposerID ValidatorID `json:"proposer_id"` + ParentHash common.Hash `json:"parent_hash"` + Hash common.Hash `json:"hash"` + Height uint64 `json:"height"` + Timestamps map[ValidatorID]time.Time `json:"timestamps"` + Acks map[common.Hash]struct{} `json:"acks"` + CompactionChainAck CompactionChainAck `json:"compaction_chain_ack"` + + ConsensusInfo ConsensusInfo `json:"consensus_info"` + // ConsensusInfoParentHash is the hash value of Block.ConsensusInfoParentHash + // and Block.ConsensusInfo, where Block is the previous block on + // the compaction chain. + ConsensusInfoParentHash common.Hash `json:"consensus_info_parent_hash"` Ackeds map[common.Hash]struct{} `json:"-"` AckedValidators map[ValidatorID]struct{} `json:"-"` |