@@ -182,14 +182,14 @@ func (x *XDPoS_v2) SignHash(header *types.Header) (hash common.Hash) {
182182}
183183
184184// Initial V2 related parameters
185- func (x * XDPoS_v2 ) Initial (chain consensus.ChainReader , header * types.Header ) error {
185+ func (x * XDPoS_v2 ) Initial (chain consensus.ChainHeaderReader , header * types.Header ) error {
186186 x .lock .Lock ()
187187 defer x .lock .Unlock ()
188188
189189 return x .initial (chain , header )
190190}
191191
192- func (x * XDPoS_v2 ) initial (chain consensus.ChainReader , header * types.Header ) error {
192+ func (x * XDPoS_v2 ) initial (chain consensus.ChainHeaderReader , header * types.Header ) error {
193193 log .Warn ("[initial] initial v2 related parameters" )
194194
195195 if x .highestQuorumCert .ProposedBlockInfo .Hash != (common.Hash {}) { // already initialized
@@ -555,11 +555,11 @@ func (x *XDPoS_v2) Seal(chain consensus.ChainReader, block *types.Block, stop <-
555555// CalcDifficulty is the difficulty adjustment algorithm. It returns the difficulty
556556// that a new block should have based on the previous blocks in the chain and the
557557// current signer.
558- func (x * XDPoS_v2 ) CalcDifficulty (chain consensus.ChainReader , time uint64 , parent * types.Header ) * big.Int {
558+ func (x * XDPoS_v2 ) CalcDifficulty (chain consensus.ChainHeaderReader , time uint64 , parent * types.Header ) * big.Int {
559559 return x .calcDifficulty (chain , parent , x .signer )
560560}
561561
562- func (x * XDPoS_v2 ) IsAuthorisedAddress (chain consensus.ChainReader , header * types.Header , address common.Address ) bool {
562+ func (x * XDPoS_v2 ) IsAuthorisedAddress (chain consensus.ChainHeaderReader , header * types.Header , address common.Address ) bool {
563563 snap , err := x .GetSnapshot (chain , header )
564564 if err != nil {
565565 log .Error ("[IsAuthorisedAddress] Can't get snapshot with at " , "number" , header .Number , "hash" , header .Hash ().Hex (), "err" , err )
@@ -573,7 +573,7 @@ func (x *XDPoS_v2) IsAuthorisedAddress(chain consensus.ChainReader, header *type
573573 return false
574574}
575575
576- func (x * XDPoS_v2 ) GetSnapshot (chain consensus.ChainReader , header * types.Header ) (* SnapshotV2 , error ) {
576+ func (x * XDPoS_v2 ) GetSnapshot (chain consensus.ChainHeaderReader , header * types.Header ) (* SnapshotV2 , error ) {
577577 number := header .Number .Uint64 ()
578578 log .Trace ("get snapshot" , "number" , number )
579579 snap , err := x .getSnapshot (chain , number , false )
@@ -583,7 +583,7 @@ func (x *XDPoS_v2) GetSnapshot(chain consensus.ChainReader, header *types.Header
583583 return snap , nil
584584}
585585
586- func (x * XDPoS_v2 ) UpdateMasternodes (chain consensus.ChainReader , header * types.Header , ms []utils.Masternode ) error {
586+ func (x * XDPoS_v2 ) UpdateMasternodes (chain consensus.ChainHeaderReader , header * types.Header , ms []utils.Masternode ) error {
587587 number := header .Number .Uint64 ()
588588 log .Trace ("[UpdateMasternodes]" , "number" , number , "hash" , header .Hash ())
589589 if number % x .config .Epoch != x .config .Epoch - x .config .Gap {
@@ -617,7 +617,7 @@ func (x *XDPoS_v2) UpdateMasternodes(chain consensus.ChainReader, header *types.
617617
618618// VerifyUncles implements consensus.Engine, always returning an error for any
619619// uncles as this consensus mechanism doesn't permit uncles.
620- func (x * XDPoS_v2 ) VerifyUncles (chain consensus.ChainReader , block * types.Block ) error {
620+ func (x * XDPoS_v2 ) VerifyUncles (chain consensus.ChainHeaderReader , block * types.Block ) error {
621621 if len (block .Uncles ()) > 0 {
622622 return errors .New ("uncles not allowed in XDPoS_v2" )
623623 }
@@ -652,7 +652,7 @@ func (x *XDPoS_v2) VerifyHeaders(chain consensus.ChainReader, headers []*types.H
652652/*
653653Proposed Block workflow
654654*/
655- func (x * XDPoS_v2 ) ProposedBlockHandler (chain consensus.ChainReader , blockHeader * types.Header ) error {
655+ func (x * XDPoS_v2 ) ProposedBlockHandler (chain consensus.ChainHeaderReader , blockHeader * types.Header ) error {
656656 x .lock .Lock ()
657657 defer x .lock .Unlock ()
658658
@@ -695,7 +695,7 @@ func (x *XDPoS_v2) ProposedBlockHandler(chain consensus.ChainReader, blockHeader
695695*/
696696
697697// To be used by different message verification. Verify local DB block info against the received block information(i.e hash, blockNum, round)
698- func (x * XDPoS_v2 ) VerifyBlockInfo (blockChainReader consensus.ChainReader , blockInfo * types.BlockInfo , blockHeader * types.Header ) error {
698+ func (x * XDPoS_v2 ) VerifyBlockInfo (blockChainReader consensus.ChainHeaderReader , blockInfo * types.BlockInfo , blockHeader * types.Header ) error {
699699 /*
700700 1. Check if is able to get header by hash from the chain
701701 2. Check the header from step 1 matches what's in the blockInfo. This includes the block number and the round
@@ -742,7 +742,7 @@ func (x *XDPoS_v2) VerifyBlockInfo(blockChainReader consensus.ChainReader, block
742742 return nil
743743}
744744
745- func (x * XDPoS_v2 ) verifyQC (blockChainReader consensus.ChainReader , quorumCert * types.QuorumCert , parentHeader * types.Header ) error {
745+ func (x * XDPoS_v2 ) verifyQC (blockChainReader consensus.ChainHeaderReader , quorumCert * types.QuorumCert , parentHeader * types.Header ) error {
746746 if quorumCert == nil {
747747 log .Warn ("[verifyQC] QC is Nil" )
748748 return utils .ErrInvalidQC
@@ -817,7 +817,7 @@ func (x *XDPoS_v2) verifyQC(blockChainReader consensus.ChainReader, quorumCert *
817817}
818818
819819// Update local QC variables including highestQC & lockQuorumCert, as well as commit the blocks that satisfy the algorithm requirements
820- func (x * XDPoS_v2 ) processQC (blockChainReader consensus.ChainReader , incomingQuorumCert * types.QuorumCert ) error {
820+ func (x * XDPoS_v2 ) processQC (blockChainReader consensus.ChainHeaderReader , incomingQuorumCert * types.QuorumCert ) error {
821821 log .Debug ("[processQC][Before]" , "HighQC" , x .highestQuorumCert .ProposedBlockInfo .Round )
822822 // 1. Update HighestQC
823823 if incomingQuorumCert .ProposedBlockInfo .Round > x .highestQuorumCert .ProposedBlockInfo .Round {
@@ -862,7 +862,7 @@ func (x *XDPoS_v2) processQC(blockChainReader consensus.ChainReader, incomingQuo
8628623. Reset vote and timeout Pools
8638634. Send signal to miner
864864*/
865- func (x * XDPoS_v2 ) setNewRound (blockChainReader consensus.ChainReader , round types.Round ) {
865+ func (x * XDPoS_v2 ) setNewRound (blockChainReader consensus.ChainHeaderReader , round types.Round ) {
866866 log .Info ("[setNewRound] new round and reset pools and workers" , "round" , round )
867867 x .currentRound = round
868868 x .timeoutCount = 0
@@ -891,7 +891,7 @@ func (x *XDPoS_v2) getSyncInfo() *types.SyncInfo {
891891}
892892
893893// Find parent and grandparent, check round number, if so, commit grandparent(grandGrandParent of currentBlock)
894- func (x * XDPoS_v2 ) commitBlocks (blockChainReader consensus.ChainReader , proposedBlockHeader * types.Header , proposedBlockRound * types.Round , incomingQc * types.QuorumCert ) (bool , error ) {
894+ func (x * XDPoS_v2 ) commitBlocks (blockChainReader consensus.ChainHeaderReader , proposedBlockHeader * types.Header , proposedBlockRound * types.Round , incomingQc * types.QuorumCert ) (bool , error ) {
895895 // XDPoS v1.0 switch to v2.0, skip commit
896896 if big .NewInt (0 ).Sub (proposedBlockHeader .Number , big .NewInt (2 )).Cmp (x .config .V2 .SwitchBlock ) <= 0 {
897897 return false , nil
@@ -961,7 +961,7 @@ func (x *XDPoS_v2) GetMasternodesFromEpochSwitchHeader(epochSwitchHeader *types.
961961}
962962
963963// Given header, get master node from the epoch switch block of that epoch
964- func (x * XDPoS_v2 ) GetMasternodes (chain consensus.ChainReader , header * types.Header ) []common.Address {
964+ func (x * XDPoS_v2 ) GetMasternodes (chain consensus.ChainHeaderReader , header * types.Header ) []common.Address {
965965 epochSwitchInfo , err := x .getEpochSwitchInfo (chain , header , header .Hash ())
966966 if err != nil {
967967 log .Error ("[GetMasternodes] Adaptor v2 getEpochSwitchInfo has error" , "err" , err )
@@ -971,7 +971,7 @@ func (x *XDPoS_v2) GetMasternodes(chain consensus.ChainReader, header *types.Hea
971971}
972972
973973// Given header, get master node from the epoch switch block of that epoch
974- func (x * XDPoS_v2 ) GetPenalties (chain consensus.ChainReader , header * types.Header ) []common.Address {
974+ func (x * XDPoS_v2 ) GetPenalties (chain consensus.ChainHeaderReader , header * types.Header ) []common.Address {
975975 epochSwitchInfo , err := x .getEpochSwitchInfo (chain , header , header .Hash ())
976976 if err != nil {
977977 log .Error ("[GetPenalties] Adaptor v2 getEpochSwitchInfo has error" , "err" , err )
@@ -980,7 +980,7 @@ func (x *XDPoS_v2) GetPenalties(chain consensus.ChainReader, header *types.Heade
980980 return epochSwitchInfo .Penalties
981981}
982982
983- func (x * XDPoS_v2 ) GetStandbynodes (chain consensus.ChainReader , header * types.Header ) []common.Address {
983+ func (x * XDPoS_v2 ) GetStandbynodes (chain consensus.ChainHeaderReader , header * types.Header ) []common.Address {
984984 epochSwitchInfo , err := x .getEpochSwitchInfo (chain , header , header .Hash ())
985985 if err != nil {
986986 log .Error ("[GetStandbynodes] Adaptor v2 getEpochSwitchInfo has error" , "err" , err )
@@ -1030,7 +1030,7 @@ func (x *XDPoS_v2) calcMasternodes(chain consensus.ChainReader, blockNum *big.In
10301030}
10311031
10321032// Given hash, get master node from the epoch switch block of the epoch
1033- func (x * XDPoS_v2 ) GetMasternodesByHash (chain consensus.ChainReader , hash common.Hash ) []common.Address {
1033+ func (x * XDPoS_v2 ) GetMasternodesByHash (chain consensus.ChainHeaderReader , hash common.Hash ) []common.Address {
10341034 epochSwitchInfo , err := x .getEpochSwitchInfo (chain , nil , hash )
10351035 if err != nil {
10361036 log .Error ("[GetMasternodes] Adaptor v2 getEpochSwitchInfo has error, potentially bug" , "err" , err )
@@ -1040,7 +1040,7 @@ func (x *XDPoS_v2) GetMasternodesByHash(chain consensus.ChainReader, hash common
10401040}
10411041
10421042// Given hash, get master node from the epoch switch block of the previous `limit` epoch
1043- func (x * XDPoS_v2 ) GetPreviousPenaltyByHash (chain consensus.ChainReader , hash common.Hash , limit int ) []common.Address {
1043+ func (x * XDPoS_v2 ) GetPreviousPenaltyByHash (chain consensus.ChainHeaderReader , hash common.Hash , limit int ) []common.Address {
10441044 currentEpochSwitchInfo , err := x .getEpochSwitchInfo (chain , nil , hash )
10451045 if err != nil {
10461046 log .Error ("[GetPreviousPenaltyByHash] Adaptor v2 getPreviousEpochSwitchInfoByHash has error, potentially bug" , "err" , err )
@@ -1071,7 +1071,7 @@ func (x *XDPoS_v2) FindParentBlockToAssign(chain consensus.ChainReader) *types.B
10711071 return parent
10721072}
10731073
1074- func (x * XDPoS_v2 ) allowedToSend (chain consensus.ChainReader , blockHeader * types.Header , sendType string ) bool {
1074+ func (x * XDPoS_v2 ) allowedToSend (chain consensus.ChainHeaderReader , blockHeader * types.Header , sendType string ) bool {
10751075 // Don't hold the signFn for the whole signing operation
10761076 x .signLock .RLock ()
10771077 signer := x .signer
0 commit comments