Browse Source

getter/setters for state trees

pull/102/head
Ethan Buchman 9 years ago
committed by Jae Kwon
parent
commit
75fb6c184e
1 changed files with 23 additions and 0 deletions
  1. +23
    -0
      state/state.go

+ 23
- 0
state/state.go View File

@ -144,6 +144,10 @@ func (s *State) ComputeBlockStateHash(block *types.Block) error {
return nil
}
func (s *State) SetDB(db dbm.DB) {
s.DB = db
}
//-------------------------------------
// State.accounts
@ -178,6 +182,11 @@ func (s *State) GetAccounts() merkle.Tree {
return s.accounts.Copy()
}
// Set the accounts tree
func (s *State) SetAccounts(accounts merkle.Tree) {
s.accounts = accounts
}
// State.accounts
//-------------------------------------
// State.validators
@ -199,6 +208,10 @@ func (s *State) SetValidatorInfo(valInfo *ValidatorInfo) (updated bool) {
return s.validatorInfos.Set(valInfo.Address, valInfo.Copy())
}
func (s *State) GetValidatorInfos() merkle.Tree {
return s.validatorInfos.Copy()
}
func (s *State) unbondValidator(val *Validator) {
// Move validator to UnbondingValidators
val, removed := s.BondedValidators.Remove(val.Address)
@ -284,6 +297,11 @@ func (s *State) destroyValidator(val *Validator) {
}
// Set the validator infos tree
func (s *State) SetValidatorInfos(validatorInfos merkle.Tree) {
s.validatorInfos = validatorInfos
}
// State.validators
//-------------------------------------
// State.storage
@ -320,6 +338,11 @@ func (s *State) GetNames() merkle.Tree {
return s.nameReg.Copy()
}
// Set the name reg tree
func (s *State) SetNameReg(nameReg merkle.Tree) {
s.nameReg = nameReg
}
func NameRegEncoder(o interface{}, w io.Writer, n *int64, err *error) {
binary.WriteBinary(o.(*types.NameRegEntry), w, n, err)
}


Loading…
Cancel
Save