aboutsummaryrefslogtreecommitdiffstats
path: root/core/types/block.go
diff options
context:
space:
mode:
authorMission Liao <mission.liao@dexon.org>2018-10-11 19:33:25 +0800
committerGitHub <noreply@github.com>2018-10-11 19:33:25 +0800
commit490fa1e9ce2b661e4c8b612bd53f20123346353b (patch)
tree2ef4a4fabb1e21d46ef3e47538dadfeecdf2cf4d /core/types/block.go
parentf3e9eb613c7e8dec6b8c6b1b0a20ddbec4e91a9c (diff)
downloaddexon-consensus-490fa1e9ce2b661e4c8b612bd53f20123346353b.tar
dexon-consensus-490fa1e9ce2b661e4c8b612bd53f20123346353b.tar.gz
dexon-consensus-490fa1e9ce2b661e4c8b612bd53f20123346353b.tar.bz2
dexon-consensus-490fa1e9ce2b661e4c8b612bd53f20123346353b.tar.lz
dexon-consensus-490fa1e9ce2b661e4c8b612bd53f20123346353b.tar.xz
dexon-consensus-490fa1e9ce2b661e4c8b612bd53f20123346353b.tar.zst
dexon-consensus-490fa1e9ce2b661e4c8b612bd53f20123346353b.zip
core: change interface (#193)
* Extract types.FinalizationResult * Change interface: - Application.BlockConfirmed returns whole block. - Application.BlockDelivered returns partial result.
Diffstat (limited to 'core/types/block.go')
-rw-r--r--core/types/block.go37
1 files changed, 21 insertions, 16 deletions
diff --git a/core/types/block.go b/core/types/block.go
index fc69481..5996acf 100644
--- a/core/types/block.go
+++ b/core/types/block.go
@@ -39,6 +39,13 @@ var (
}
)
+// FinalizationResult represents the result of DEXON consensus algorithm.
+type FinalizationResult struct {
+ Randomness []byte `json:"randomness"`
+ Timestamp time.Time `json:"timestamp"`
+ Height uint64 `json:"height"`
+}
+
// Witness represents the consensus information on the compaction chain.
type Witness struct {
Timestamp time.Time `json:"timestamp"`
@@ -61,18 +68,16 @@ func NewBlock() (b *Block) {
// 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:"timestamps"`
- Acks common.SortedHashes `json:"acks"`
- Payload []byte `json:"payload"`
- Randomness []byte `json:"randomness"`
- ConsensusTimestamp time.Time `json:"consensus_timestamp"`
- ConsensusHeight uint64 `json:"consensus_height"`
- Witness Witness `json:"witness"`
- 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:"timestamps"`
+ Acks common.SortedHashes `json:"acks"`
+ Payload []byte `json:"payload"`
+ Witness Witness `json:"witness"`
+ Finalization FinalizationResult `json:"finalization"`
+ Signature crypto.Signature `json:"signature"`
CRSSignature crypto.Signature `json:"crs_signature"`
}
@@ -92,8 +97,8 @@ func (b *Block) Clone() (bcopy *Block) {
bcopy.Position.Height = b.Position.Height
bcopy.Signature = b.Signature.Clone()
bcopy.CRSSignature = b.CRSSignature.Clone()
- bcopy.ConsensusTimestamp = b.ConsensusTimestamp
- bcopy.ConsensusHeight = b.ConsensusHeight
+ bcopy.Finalization.Timestamp = b.Finalization.Timestamp
+ bcopy.Finalization.Height = b.Finalization.Height
bcopy.Witness.Timestamp = b.Witness.Timestamp
bcopy.Witness.Height = b.Witness.Height
bcopy.Witness.Data = make([]byte, len(b.Witness.Data))
@@ -103,8 +108,8 @@ func (b *Block) Clone() (bcopy *Block) {
copy(bcopy.Acks, b.Acks)
bcopy.Payload = make([]byte, len(b.Payload))
copy(bcopy.Payload, b.Payload)
- bcopy.Randomness = make([]byte, len(b.Randomness))
- copy(bcopy.Randomness, b.Randomness)
+ bcopy.Finalization.Randomness = make([]byte, len(b.Finalization.Randomness))
+ copy(bcopy.Finalization.Randomness, b.Finalization.Randomness)
return
}