forked from TrueCloudLab/neoneo-go
consensus: use GetNextBlockValidators where appropriate
GetValidators without parameter is called upon DBFT initialization and it should receive validators for the next block (that will create it), parameterized GetValidators is used for NextConsensus calculation where we need a list for the current state of the chain.
This commit is contained in:
parent
2278cd5700
commit
7eef895061
4 changed files with 16 additions and 3 deletions
|
@ -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
|
||||
)
|
||||
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))
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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")
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue