|
|
|
@ -246,11 +246,11 @@ func WriteValidatorStats( |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// ReadValidatorList retrieves staking validator by its address
|
|
|
|
|
// Return only active validators if activeOnly==true, otherwise, return all validators
|
|
|
|
|
func ReadValidatorList(db DatabaseReader, activeOnly bool) ([]common.Address, error) { |
|
|
|
|
// Return only elected validators if electedOnly==true, otherwise, return all validators
|
|
|
|
|
func ReadValidatorList(db DatabaseReader, electedOnly bool) ([]common.Address, error) { |
|
|
|
|
key := validatorListKey |
|
|
|
|
if activeOnly { |
|
|
|
|
key = activeValidatorListKey |
|
|
|
|
if electedOnly { |
|
|
|
|
key = electedValidatorListKey |
|
|
|
|
} |
|
|
|
|
data, err := db.Get(key) |
|
|
|
|
if err != nil || len(data) == 0 { |
|
|
|
@ -265,11 +265,11 @@ func ReadValidatorList(db DatabaseReader, activeOnly bool) ([]common.Address, er |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// WriteValidatorList stores staking validator's information by its address
|
|
|
|
|
// Writes only for active validators if activeOnly==true, otherwise, writes for all validators
|
|
|
|
|
func WriteValidatorList(db DatabaseWriter, addrs []common.Address, activeOnly bool) error { |
|
|
|
|
// Writes only for elected validators if electedOnly==true, otherwise, writes for all validators
|
|
|
|
|
func WriteValidatorList(db DatabaseWriter, addrs []common.Address, electedOnly bool) error { |
|
|
|
|
key := validatorListKey |
|
|
|
|
if activeOnly { |
|
|
|
|
key = activeValidatorListKey |
|
|
|
|
if electedOnly { |
|
|
|
|
key = electedValidatorListKey |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bytes, err := rlp.EncodeToBytes(addrs) |
|
|
|
|