mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-19 21:31:37 +00:00
hotfix etherbase/coinbase
Send tx sign for block number to smart contract blockSigner.
This commit is contained in:
parent
571c41f891
commit
a41658640f
3 changed files with 19 additions and 8 deletions
|
|
@ -60,17 +60,26 @@ type rewardLog struct {
|
|||
var TxSignMu sync.RWMutex
|
||||
|
||||
// Send tx sign for block number to smart contract blockSigner.
|
||||
func CreateTransactionSign(chainConfig *params.ChainConfig, pool *core.TxPool, manager *accounts.Manager, block *types.Block, chainDb ethdb.Database) error {
|
||||
func CreateTransactionSign(chainConfig *params.ChainConfig, pool *core.TxPool, manager *accounts.Manager, block *types.Block, chainDb ethdb.Database, eb common.Address) error {
|
||||
TxSignMu.Lock()
|
||||
defer TxSignMu.Unlock()
|
||||
if chainConfig.XDPoS != nil {
|
||||
// Find active account.
|
||||
account := accounts.Account{}
|
||||
var wallet accounts.Wallet
|
||||
etherbaseAccount := accounts.Account{
|
||||
Address: eb,
|
||||
URL: accounts.URL{},
|
||||
}
|
||||
if wallets := manager.Wallets(); len(wallets) > 0 {
|
||||
wallet = wallets[0]
|
||||
if accts := wallets[0].Accounts(); len(accts) > 0 {
|
||||
account = accts[0]
|
||||
if w, err := manager.Find(etherbaseAccount); err == nil && w != nil {
|
||||
wallet = w
|
||||
account = etherbaseAccount
|
||||
} else {
|
||||
wallet = wallets[0]
|
||||
if accts := wallets[0].Accounts(); len(accts) > 0 {
|
||||
account = accts[0]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -224,7 +224,7 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) {
|
|||
return nil
|
||||
}
|
||||
if block.NumberU64()%common.MergeSignRange == 0 || !eth.chainConfig.IsTIP2019(block.Number()) {
|
||||
if err := contracts.CreateTransactionSign(chainConfig, eth.txPool, eth.accountManager, block, chainDb); err != nil {
|
||||
if err := contracts.CreateTransactionSign(chainConfig, eth.txPool, eth.accountManager, block, chainDb, eb); err != nil {
|
||||
return fmt.Errorf("Fail to create tx sign for importing block: %v", err)
|
||||
}
|
||||
}
|
||||
|
|
@ -472,12 +472,14 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) {
|
|||
sort.Slice(candidates, func(i, j int) bool {
|
||||
return candidates[i].Stake.Cmp(candidates[j].Stake) >= 0
|
||||
})
|
||||
candidates = candidates[:150]
|
||||
if len(candidates) > 150 {
|
||||
candidates = candidates[:150]
|
||||
}
|
||||
result := []common.Address{}
|
||||
for _, candidate := range candidates {
|
||||
result = append(result, candidate.Address)
|
||||
}
|
||||
return result[:150], nil
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// Hook calculates reward for masternodes
|
||||
|
|
|
|||
|
|
@ -413,7 +413,7 @@ func (self *worker) wait() {
|
|||
}
|
||||
// Send tx sign to smart contract blockSigners.
|
||||
if block.NumberU64()%common.MergeSignRange == 0 || !self.config.IsTIP2019(block.Number()) {
|
||||
if err := contracts.CreateTransactionSign(self.config, self.eth.TxPool(), self.eth.AccountManager(), block, self.chainDb); err != nil {
|
||||
if err := contracts.CreateTransactionSign(self.config, self.eth.TxPool(), self.eth.AccountManager(), block, self.chainDb, self.coinbase); err != nil {
|
||||
log.Error("Fail to create tx sign for signer", "error", "err")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue