forked from ethereum/go-ethereum
-
Notifications
You must be signed in to change notification settings - Fork 136
/
taiko_payload_building.go
53 lines (42 loc) 路 1.19 KB
/
taiko_payload_building.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package miner
import (
"math/big"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/params"
)
// SetFullBlock updates the full-block to the given block.
func (payload *Payload) SetFullBlock(block *types.Block, fees *big.Int) {
payload.lock.Lock()
defer payload.lock.Unlock()
go payload.afterSetFullBlock()
payload.full = block
payload.fullFees = fees
feesInEther := new(big.Float).Quo(new(big.Float).SetInt(fees), big.NewFloat(params.Ether))
log.Info("Updated payload", "id", payload.id, "number", block.NumberU64(), "hash", block.Hash(),
"txs", len(block.Transactions()), "gas", block.GasUsed(), "fees", feesInEther,
"root", block.Root())
payload.cond.Broadcast() // fire signal for notifying full block
}
func (payload *Payload) afterSetFullBlock() {
payload.lock.Lock()
defer payload.lock.Unlock()
select {
case <-payload.done:
log.Info("SetFullBlock payload.done received", "id", payload.id)
return
default:
}
select {
case _, ok := <-payload.stop:
if ok {
log.Info("SetFullBlock payload.stop received", "id", payload.id)
return
}
default:
}
select {
case payload.stop <- struct{}{}:
default:
}
}