mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-11-26 19:42:23 +00:00
core: implement (*Blockchain).GetStandByCommitee()
This commit is contained in:
parent
05c24d9401
commit
27169d140f
4 changed files with 22 additions and 5 deletions
|
@ -119,7 +119,7 @@ type Blockchain struct {
|
|||
// cache for block verification keys.
|
||||
keyCache map[util.Uint160]map[string]*keys.PublicKey
|
||||
|
||||
sbValidators keys.PublicKeys
|
||||
sbCommittee keys.PublicKeys
|
||||
|
||||
log *zap.Logger
|
||||
|
||||
|
@ -156,7 +156,7 @@ func NewBlockchain(s storage.Store, cfg config.ProtocolConfiguration, log *zap.L
|
|||
cfg.MemPoolSize = defaultMemPoolSize
|
||||
log.Info("mempool size is not set or wrong, setting default value", zap.Int("MemPoolSize", cfg.MemPoolSize))
|
||||
}
|
||||
validators, err := validatorsFromConfig(cfg)
|
||||
committee, err := committeeFromConfig(cfg)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -169,7 +169,7 @@ func NewBlockchain(s storage.Store, cfg config.ProtocolConfiguration, log *zap.L
|
|||
runToExitCh: make(chan struct{}),
|
||||
memPool: mempool.NewMemPool(cfg.MemPoolSize),
|
||||
keyCache: make(map[util.Uint160]map[string]*keys.PublicKey),
|
||||
sbValidators: validators,
|
||||
sbCommittee: committee,
|
||||
log: log,
|
||||
events: make(chan bcEvent),
|
||||
subCh: make(chan interface{}),
|
||||
|
@ -1393,7 +1393,12 @@ func (bc *Blockchain) PoolTx(t *transaction.Transaction) error {
|
|||
|
||||
//GetStandByValidators returns validators from the configuration.
|
||||
func (bc *Blockchain) GetStandByValidators() keys.PublicKeys {
|
||||
return bc.sbValidators.Copy()
|
||||
return bc.sbCommittee[:bc.config.ValidatorsCount].Copy()
|
||||
}
|
||||
|
||||
// GetStandByCommittee returns standby commitee from the configuration.
|
||||
func (bc *Blockchain) GetStandByCommittee() keys.PublicKeys {
|
||||
return bc.sbCommittee.Copy()
|
||||
}
|
||||
|
||||
// GetValidators returns current validators.
|
||||
|
|
|
@ -42,6 +42,7 @@ type Blockchainer interface {
|
|||
GetNEP5TransferLog(util.Uint160) *state.NEP5TransferLog
|
||||
GetNEP5Balances(util.Uint160) *state.NEP5Balances
|
||||
GetValidators() ([]*keys.PublicKey, error)
|
||||
GetStandByCommittee() keys.PublicKeys
|
||||
GetStandByValidators() keys.PublicKeys
|
||||
GetScriptHashesForVerifying(*transaction.Transaction) ([]util.Uint160, error)
|
||||
GetStateRoot(height uint32) (*state.MPTRootState, error)
|
||||
|
|
|
@ -95,10 +95,18 @@ func deployNativeContracts(magic netmode.Magic) *transaction.Transaction {
|
|||
}
|
||||
|
||||
func validatorsFromConfig(cfg config.ProtocolConfiguration) ([]*keys.PublicKey, error) {
|
||||
vs, err := committeeFromConfig(cfg)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return vs[:cfg.ValidatorsCount], nil
|
||||
}
|
||||
|
||||
func committeeFromConfig(cfg config.ProtocolConfiguration) ([]*keys.PublicKey, error) {
|
||||
if len(cfg.StandbyCommittee) < cfg.ValidatorsCount {
|
||||
return nil, errors.New("validators count can be less than the size of StandbyCommittee")
|
||||
}
|
||||
validators := make([]*keys.PublicKey, cfg.ValidatorsCount)
|
||||
validators := make([]*keys.PublicKey, len(cfg.StandbyCommittee))
|
||||
for i := range validators {
|
||||
pubKey, err := keys.NewPublicKeyFromString(cfg.StandbyCommittee[i])
|
||||
if err != nil {
|
||||
|
|
|
@ -103,6 +103,9 @@ func (chain testChain) GetNEP5Balances(util.Uint160) *state.NEP5Balances {
|
|||
func (chain testChain) GetValidators() ([]*keys.PublicKey, error) {
|
||||
panic("TODO")
|
||||
}
|
||||
func (chain testChain) GetStandByCommittee() keys.PublicKeys {
|
||||
panic("TODO")
|
||||
}
|
||||
func (chain testChain) GetStandByValidators() keys.PublicKeys {
|
||||
panic("TODO")
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue