mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 18:32:23 +00:00
get state on chain at HookReward
This commit is contained in:
parent
4455673db4
commit
34179cae22
2 changed files with 8 additions and 4 deletions
|
|
@ -224,7 +224,7 @@ type Posv struct {
|
|||
signFn clique.SignerFn // Signer function to authorize hashes with
|
||||
lock sync.RWMutex // Protects the signer fields
|
||||
|
||||
HookReward func(state *state.StateDB, chain consensus.ChainReader, header *types.Header) (error, map[string]interface{})
|
||||
HookReward func(chain consensus.ChainReader, 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)
|
||||
HookVerifyMNs func(header *types.Header, signers []common.Address) error
|
||||
|
|
@ -850,7 +850,7 @@ func (c *Posv) Finalize(chain consensus.ChainReader, header *types.Header, state
|
|||
rCheckpoint := chain.Config().Posv.RewardCheckpoint
|
||||
|
||||
if c.HookReward != nil && number%rCheckpoint == 0 {
|
||||
err, rewards := c.HookReward(state, chain, header)
|
||||
err, rewards := c.HookReward(chain, header)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ import (
|
|||
"github.com/ethereum/go-ethereum/contracts"
|
||||
"github.com/ethereum/go-ethereum/core"
|
||||
"github.com/ethereum/go-ethereum/core/bloombits"
|
||||
"github.com/ethereum/go-ethereum/core/state"
|
||||
//"github.com/ethereum/go-ethereum/core/state"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/ethereum/go-ethereum/core/vm"
|
||||
"github.com/ethereum/go-ethereum/eth/downloader"
|
||||
|
|
@ -285,7 +285,11 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) {
|
|||
}
|
||||
|
||||
// Hook calculates reward for masternodes
|
||||
c.HookReward = func(state *state.StateDB, chain consensus.ChainReader, header *types.Header) (error, map[string]interface{}) {
|
||||
c.HookReward = func(chain consensus.ChainReader, header *types.Header) (error, map[string]interface{}) {
|
||||
state, err := eth.blockchain.State()
|
||||
if state == nil || err != nil {
|
||||
log.Crit("Can't get state", "block number", header.Number.Uint64(), "err", err)
|
||||
}
|
||||
number := header.Number.Uint64()
|
||||
rCheckpoint := chain.Config().Posv.RewardCheckpoint
|
||||
foundationWalletAddr := chain.Config().Posv.FoudationWalletAddr
|
||||
|
|
|
|||
Loading…
Reference in a new issue