Posted by 咕🎨 on
2023-03-06
Words 405 and
Reading Time 1 Minutes
Viewed Times
POA共识现在存在的问题
现在以太坊POA实现
设置矿工手续费账户:
1 2 3 4 5 6 7 8 9 10 11 12
// SetCoinbase sets the coinbase of the generated block. // It can be called at most once. func (b *BlockGen) SetCoinbase(addr common.Address) { if b.gasPool != nil { if len(b.txs) > 0 { panic("coinbase must be set before adding transactions") } panic("coinbase can only be set once") } b.header.Coinbase = addr b.gasPool = new(GasPool).AddGas(b.header.GasLimit) }
自动对矿工地址设置手续费账户(clique.go):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
// Gather all the proposals that make sense voting on addresses := make([]common.Address, 0, len(c.proposals)) for address, authorize := range c.proposals { if snap.validVote(address, authorize) { addresses = append(addresses, address) } } // If there's pending proposals, cast a vote on them if len(addresses) > 0 { header.Coinbase = addresses[rand.Intn(len(addresses))] if c.proposals[header.Coinbase] { copy(header.Nonce[:], nonceAuthVote) } else { copy(header.Nonce[:], nonceDropVote) } }