diff --git a/pkg/consensus/consensus.go b/pkg/consensus/consensus.go index 7fee372c9..be9545cff 100644 --- a/pkg/consensus/consensus.go +++ b/pkg/consensus/consensus.go @@ -446,12 +446,16 @@ func (s *service) getVerifiedTx() []block.Transaction { return res } -func (s *service) getValidators(_ ...block.Transaction) []crypto.PublicKey { +func (s *service) getValidators(txes ...block.Transaction) []crypto.PublicKey { var ( pKeys []*keys.PublicKey err error ) - pKeys, err = s.Chain.GetValidators() + if txes == nil { + pKeys, err = s.Chain.GetNextBlockValidators() + } else { + pKeys, err = s.Chain.GetValidators() + } if err != nil { s.log.Error("error while trying to get validators", zap.Error(err)) } diff --git a/pkg/core/blockchain.go b/pkg/core/blockchain.go index 7446799de..a8646e571 100644 --- a/pkg/core/blockchain.go +++ b/pkg/core/blockchain.go @@ -1240,11 +1240,16 @@ func (bc *Blockchain) GetStandByValidators() keys.PublicKeys { return bc.sbValidators.Copy() } -// GetValidators returns next block validators. +// GetValidators returns current validators. func (bc *Blockchain) GetValidators() ([]*keys.PublicKey, error) { return bc.contracts.NEO.GetValidatorsInternal(bc, bc.dao) } +// GetNextBlockValidators returns next block validators. +func (bc *Blockchain) GetNextBlockValidators() ([]*keys.PublicKey, error) { + return bc.contracts.NEO.GetNextBlockValidatorsInternal(bc, bc.dao) +} + // GetEnrollments returns all registered validators. func (bc *Blockchain) GetEnrollments() ([]state.Validator, error) { return bc.contracts.NEO.GetRegisteredValidators(bc.dao) diff --git a/pkg/core/blockchainer/blockchainer.go b/pkg/core/blockchainer/blockchainer.go index ce723614b..9dcac9e33 100644 --- a/pkg/core/blockchainer/blockchainer.go +++ b/pkg/core/blockchainer/blockchainer.go @@ -36,6 +36,7 @@ type Blockchainer interface { HasTransaction(util.Uint256) bool GetAccountState(util.Uint160) *state.Account GetAppExecResult(util.Uint256) (*state.AppExecResult, error) + GetNextBlockValidators() ([]*keys.PublicKey, error) GetNEP5TransferLog(util.Uint160) *state.NEP5TransferLog GetNEP5Balances(util.Uint160) *state.NEP5Balances GetValidators() ([]*keys.PublicKey, error) diff --git a/pkg/network/helper_test.go b/pkg/network/helper_test.go index cc7dbcb7c..6004c44a4 100644 --- a/pkg/network/helper_test.go +++ b/pkg/network/helper_test.go @@ -77,6 +77,9 @@ func (chain testChain) GetHeader(hash util.Uint256) (*block.Header, error) { func (chain testChain) GetAccountState(util.Uint160) *state.Account { panic("TODO") } +func (chain testChain) GetNextBlockValidators() ([]*keys.PublicKey, error) { + panic("TODO") +} func (chain testChain) GetNEP5TransferLog(util.Uint160) *state.NEP5TransferLog { panic("TODO") }