mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 02:42:27 +00:00
cache only blocksigners
This commit is contained in:
parent
f9ae05c5d5
commit
46c96249bf
3 changed files with 17 additions and 20 deletions
|
|
@ -226,7 +226,6 @@ type Posv struct {
|
|||
lock sync.RWMutex // Protects the signer fields
|
||||
|
||||
BlockSigners *lru.Cache
|
||||
Votes *lru.Cache
|
||||
HookReward func(chain consensus.ChainReader, state *state.StateDB, header *types.Header) (error, map[string]interface{})
|
||||
HookPenalty func(chain consensus.ChainReader, blockNumberEpoc uint64) ([]common.Address, error)
|
||||
HookValidator func(header *types.Header, signers []common.Address) ([]byte, error)
|
||||
|
|
|
|||
|
|
@ -329,14 +329,13 @@ func GetRewardForCheckpoint(c *posv.Posv, chain consensus.ChainReader, number ui
|
|||
data[blkHash] = append(data[blkHash], from)
|
||||
}
|
||||
} else {
|
||||
log.Info("Failed get from cached", "hash", header.Hash().String(), "number", i)
|
||||
log.Debug("Failed get from cached", "hash", header.Hash().String(), "number", i)
|
||||
block := chain.GetBlock(header.Hash(), i)
|
||||
txs := block.Transactions()
|
||||
receipts := core.GetBlockReceipts(c.GetDb(), header.Hash(), i)
|
||||
|
||||
var signTxs []*types.Transaction
|
||||
for _, tx := range txs {
|
||||
if tx.IsSigningTransaction() {
|
||||
var b uint
|
||||
for _, r := range receipts {
|
||||
if r.TxHash == tx.Hash() {
|
||||
|
|
@ -354,7 +353,6 @@ func GetRewardForCheckpoint(c *posv.Posv, chain consensus.ChainReader, number ui
|
|||
from := *tx.From()
|
||||
data[blkHash] = append(data[blkHash], from)
|
||||
}
|
||||
}
|
||||
c.BlockSigners.Add(header.Hash(), signTxs)
|
||||
|
||||
}
|
||||
|
|
@ -433,7 +431,7 @@ func GetCandidatesOwnerBySigner(validator *contractValidator.TomoValidator, sign
|
|||
}
|
||||
|
||||
// Calculate reward for holders.
|
||||
func CalculateRewardForHolders(c *posv.Posv, foudationWalletAddr common.Address, validator *contractValidator.TomoValidator, state *state.StateDB, signer common.Address, calcReward *big.Int) (error, map[common.Address]*big.Int) {
|
||||
func CalculateRewardForHolders(foudationWalletAddr common.Address, validator *contractValidator.TomoValidator, state *state.StateDB, signer common.Address, calcReward *big.Int) (error, map[common.Address]*big.Int) {
|
||||
rewards, err := GetRewardBalancesRate(foudationWalletAddr, signer, calcReward, validator)
|
||||
if err != nil {
|
||||
return err, nil
|
||||
|
|
|
|||
|
|
@ -324,7 +324,7 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) {
|
|||
voterResults := make(map[common.Address]interface{})
|
||||
if len(signers) > 0 {
|
||||
for signer, calcReward := range rewardSigners {
|
||||
err, rewards := contracts.CalculateRewardForHolders(c, foudationWalletAddr, validator, state, signer, calcReward)
|
||||
err, rewards := contracts.CalculateRewardForHolders(foudationWalletAddr, validator, state, signer, calcReward)
|
||||
if err != nil {
|
||||
log.Crit("Fail to calculate reward for holders.", "error", err)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue