From d4e4999055549012dc5dd374e04b6059c2854c86 Mon Sep 17 00:00:00 2001 From: Jimmy Hu Date: Thu, 16 Aug 2018 16:20:17 +0800 Subject: core: Remove notary ack. (#64) --- core/consensus.go | 47 +++++++++++++++++++++++++---------------------- 1 file changed, 25 insertions(+), 22 deletions(-) (limited to 'core/consensus.go') diff --git a/core/consensus.go b/core/consensus.go index d5ce923..3e8f87d 100644 --- a/core/consensus.go +++ b/core/consensus.go @@ -48,8 +48,8 @@ var ( "hash of block is incorrect") ErrIncorrectSignature = fmt.Errorf( "signature of block is incorrect") - ErrIncorrectCompactionChainAck = fmt.Errorf( - "compaction chain ack of block is incorrect") + ErrIncorrectNotaryAck = fmt.Errorf( + "compaction chain notary of block is incorrect") ErrGenesisBlockNotEmpty = fmt.Errorf( "genesis block should be empty") ) @@ -120,26 +120,29 @@ func (con *Consensus) sanityCheck(blockConv types.BlockConverter) (err error) { return ErrIncorrectSignature } - // Check the compaction chain info. - if ackingBlockHash := - b.CompactionChainAck.AckingBlockHash; (ackingBlockHash != common.Hash{}) { - ackingBlock, err := con.db.Get(ackingBlockHash) - if err != nil { - return err - } - hash, err := hashConsensusInfo(&ackingBlock) - if err != nil { - return err - } - pubKey, err := con.sigToPub(hash, - b.CompactionChainAck.ConsensusInfoSignature) - if err != nil { - return err - } - if !b.ProposerID.Equal(crypto.Keccak256Hash(pubKey.Bytes())) { - return ErrIncorrectCompactionChainAck + // TODO(jimmy-dexon): remove these comments before open source. + /* + // Check the notary ack. + if notaryBlockHash := + b.NotaryAck.NotaryBlockHash; (notaryBlockHash != common.Hash{}) { + notaryBlock, err := con.db.Get(notaryBlockHash) + if err != nil { + return err + } + hash, err := hashNotary(¬aryBlock) + if err != nil { + return err + } + pubKey, err := con.sigToPub(hash, + b.NotaryAck.NotarySignature) + if err != nil { + return err + } + if !b.ProposerID.Equal(crypto.Keccak256Hash(pubKey.Bytes())) { + return ErrIncorrectNotaryAck + } } - } + */ return nil } @@ -199,7 +202,7 @@ func (con *Consensus) ProcessBlock(blockConv types.BlockConverter) (err error) { if err = con.db.Update(*b); err != nil { return } - con.app.DeliverBlock(b.Hash, b.ConsensusInfo.Timestamp) + con.app.DeliverBlock(b.Hash, b.Notary.Timestamp) } } return -- cgit v1.2.3