diff options
author | Mission Liao <mission.liao@dexon.org> | 2018-09-21 17:28:25 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-21 17:28:25 +0800 |
commit | 9d99c27b7261f8228cc0a5a496be6ac50e03abf2 (patch) | |
tree | 71e10b4f1ca6aa155c7521c7e8083ba72be4428c /core/consensus.go | |
parent | fb4b47fa61db81f4d6b8264d7508aa43509a60a3 (diff) | |
download | dexon-consensus-9d99c27b7261f8228cc0a5a496be6ac50e03abf2.tar dexon-consensus-9d99c27b7261f8228cc0a5a496be6ac50e03abf2.tar.gz dexon-consensus-9d99c27b7261f8228cc0a5a496be6ac50e03abf2.tar.bz2 dexon-consensus-9d99c27b7261f8228cc0a5a496be6ac50e03abf2.tar.lz dexon-consensus-9d99c27b7261f8228cc0a5a496be6ac50e03abf2.tar.xz dexon-consensus-9d99c27b7261f8228cc0a5a496be6ac50e03abf2.tar.zst dexon-consensus-9d99c27b7261f8228cc0a5a496be6ac50e03abf2.zip |
core: add shard (#127)
A shard is basically DEXON v1 components,
except the strongly acked part, including:
- maintaining lattice structure
- total ordering
- generate consensus timestamp
Diffstat (limited to 'core/consensus.go')
-rw-r--r-- | core/consensus.go | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/core/consensus.go b/core/consensus.go index 33a3d7f..7700296 100644 --- a/core/consensus.go +++ b/core/consensus.go @@ -104,7 +104,7 @@ func (recv *consensusReceiver) ConfirmBlock(hash common.Hash) { log.Println(ErrUnknownBlockConfirmed, hash) return } - if err := recv.consensus.ProcessBlock(block); err != nil { + if err := recv.consensus.processBlock(block); err != nil { log.Println(err) return } @@ -273,7 +273,7 @@ BALoop: // RunLegacy starts running Legacy DEXON Consensus. func (con *Consensus) RunLegacy() { - go con.processMsg(con.network.ReceiveChan(), con.ProcessBlock) + go con.processMsg(con.network.ReceiveChan(), con.processBlock) go con.processWitnessData() chainID := uint32(0) @@ -299,7 +299,7 @@ func (con *Consensus) RunLegacy() { if err := con.PrepareGenesisBlock(genesisBlock, time.Now().UTC()); err != nil { log.Println(err) } - if err := con.ProcessBlock(genesisBlock); err != nil { + if err := con.processBlock(genesisBlock); err != nil { log.Println(err) } con.network.BroadcastBlock(genesisBlock) @@ -317,10 +317,10 @@ ProposingBlockLoop: ChainID: chainID, }, } - if err := con.PrepareBlock(block, time.Now().UTC()); err != nil { + if err := con.prepareBlock(block, time.Now().UTC()); err != nil { log.Println(err) } - if err := con.ProcessBlock(block); err != nil { + if err := con.processBlock(block); err != nil { log.Println(err) } con.network.BroadcastBlock(block) @@ -368,7 +368,7 @@ func (con *Consensus) proposeBlock(chainID uint32) *types.Block { Height: con.rbModule.nextHeight(chainID), }, } - if err := con.PrepareBlock(block, time.Now().UTC()); err != nil { + if err := con.prepareBlock(block, time.Now().UTC()); err != nil { log.Println(err) return nil } @@ -464,8 +464,8 @@ func (con *Consensus) PreProcessBlock(b *types.Block) (err error) { return } -// ProcessBlock is the entry point to submit one block to a Consensus instance. -func (con *Consensus) ProcessBlock(block *types.Block) (err error) { +// processBlock is the entry point to submit one block to a Consensus instance. +func (con *Consensus) processBlock(block *types.Block) (err error) { if err := con.sanityCheck(block); err != nil { return err } @@ -538,7 +538,7 @@ func (con *Consensus) checkPrepareBlock( } // PrepareBlock would setup header fields of block based on its ProposerID. -func (con *Consensus) PrepareBlock(b *types.Block, +func (con *Consensus) prepareBlock(b *types.Block, proposeTime time.Time) (err error) { if err = con.checkPrepareBlock(b, proposeTime); err != nil { return |