mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-24 15:44:32 +00:00
add GetVoterCap func
This commit is contained in:
parent
8a456132e5
commit
b10d8170c7
1 changed files with 14 additions and 0 deletions
|
|
@ -105,4 +105,18 @@ func GetVoters(statedb *state.StateDB, candidate common.Address) []common.Addres
|
|||
elapsed := time.Since(start)
|
||||
fmt.Printf("Execution time: %s\n", elapsed)
|
||||
return rets
|
||||
}
|
||||
|
||||
func GetVoterCap(state *state.StateDB, candidate, voter common.Address) *big.Int {
|
||||
//validatorsState[_candidate].voters[_voter]
|
||||
start := time.Now()
|
||||
fmt.Printf("--------GetVoterCap---------\n")
|
||||
slot := slotValidatorMapping["validatorsState"]
|
||||
locValidatorsState := getLocMappingAtKey(candidate.Hash(), slot)
|
||||
locCandidateVoters := locValidatorsState.Add(locValidatorsState, new(big.Int).SetUint64(uint64(3)))
|
||||
locVoters := getLocMappingAtKey(voter.Hash(), locCandidateVoters.Uint64())
|
||||
ret := state.GetState(common.HexToAddress(common.MasternodeVotingSMC), common.BigToHash(locVoters))
|
||||
elapsed := time.Since(start)
|
||||
fmt.Printf("Execution time: %s\n", elapsed)
|
||||
return ret.Big()
|
||||
}
|
||||
Loading…
Reference in a new issue