mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 02:42:27 +00:00
fix unit test
This commit is contained in:
parent
7e4db6e904
commit
3aba8f4c26
3 changed files with 14 additions and 7 deletions
|
|
@ -903,7 +903,7 @@ func (c *Posv) Finalize(chain consensus.ChainReader, header *types.Header, state
|
|||
}
|
||||
|
||||
if c.HookReward != nil && number%rCheckpoint == 0 {
|
||||
if !c.EnableCache && c.BlockSigners.Len() >= 2700 {
|
||||
if !c.EnableCache && uint64(c.BlockSigners.Len()) >= (rCheckpoint*3) {
|
||||
fmt.Println("EnableCache true c.BlockSigners.Len()", c.BlockSigners.Len())
|
||||
c.EnableCache = true
|
||||
}
|
||||
|
|
|
|||
|
|
@ -350,7 +350,7 @@ func GetRewardForCheckpoint(c *posv.Posv, chain consensus.ChainReader, blockSign
|
|||
} else {
|
||||
var wg sync.WaitGroup
|
||||
squeue := make(chan []common.Address, 1)
|
||||
wg.Add(900)
|
||||
wg.Add(int(rCheckpoint))
|
||||
|
||||
for i := startBlockNumber; i <= endBlockNumber; i++ {
|
||||
go func(i uint64) {
|
||||
|
|
@ -484,15 +484,22 @@ func GetRewardBalancesRate(c *posv.Posv, foudationWalletAddr common.Address, mas
|
|||
vote.Masternode = masterAddr
|
||||
vote.Voter = voteAddr
|
||||
|
||||
if vCap, ok := c.Votes.Get(vote); ok {
|
||||
voterCap = vCap.(*big.Int)
|
||||
if c != nil {
|
||||
if vCap, ok := c.Votes.Get(vote); ok {
|
||||
voterCap = vCap.(*big.Int)
|
||||
} else {
|
||||
voterCap, err = validator.GetVoterCap(opts, masterAddr, voteAddr)
|
||||
if err != nil {
|
||||
log.Crit("Fail to get vote capacity", "error", err)
|
||||
}
|
||||
fmt.Println("Add to Votes cache", vote.Masternode.String(), vote.Voter.String(), voterCap.String())
|
||||
c.Votes.Add(vote, voterCap)
|
||||
}
|
||||
} else {
|
||||
voterCap, err = validator.GetVoterCap(opts, masterAddr, voteAddr)
|
||||
if err != nil {
|
||||
log.Crit("Fail to get vote capacity", "error", err)
|
||||
}
|
||||
fmt.Println("Add to Votes cache", vote.Masternode.String(), vote.Voter.String(), voterCap.String())
|
||||
c.Votes.Add(vote, voterCap)
|
||||
}
|
||||
|
||||
totalCap.Add(totalCap, voterCap)
|
||||
|
|
|
|||
|
|
@ -144,7 +144,7 @@ func TestRewardBalance(t *testing.T) {
|
|||
|
||||
foundationAddr := common.HexToAddress(common.FoudationAddr)
|
||||
totalReward := new(big.Int).SetInt64(15 * 1000)
|
||||
rewards, err := contracts.GetRewardBalancesRate(foundationAddr, acc3Addr, totalReward, baseValidator)
|
||||
rewards, err := contracts.GetRewardBalancesRate(nil, foundationAddr, acc3Addr, totalReward, baseValidator)
|
||||
if err != nil {
|
||||
t.Error("Fail to get reward balances rate.", err)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue