generated from flashbots/go-template
-
Notifications
You must be signed in to change notification settings - Fork 116
/
common.go
54 lines (44 loc) · 1.55 KB
/
common.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
54
// Package common provides things used by various other components
package common
import (
"errors"
"fmt"
"time"
"github.com/flashbots/go-utils/cli"
)
var (
ErrServerAlreadyRunning = errors.New("server already running")
SecondsPerSlot = uint64(cli.GetEnvInt("SEC_PER_SLOT", 12))
DurationPerSlot = time.Duration(SecondsPerSlot) * time.Second
SlotsPerEpoch = uint64(cli.GetEnvInt("SLOTS_PER_EPOCH", 32))
DurationPerEpoch = DurationPerSlot * time.Duration(SlotsPerEpoch)
)
func SlotToEpoch(slot uint64) uint64 {
return slot / SlotsPerEpoch
}
// HTTPServerTimeouts are various timeouts for requests to the mev-boost HTTP server
type HTTPServerTimeouts struct {
Read time.Duration // Timeout for body reads. None if 0.
ReadHeader time.Duration // Timeout for header reads. None if 0.
Write time.Duration // Timeout for writes. None if 0.
Idle time.Duration // Timeout to disconnect idle client connections. None if 0.
}
// BuilderStatus configures how builder blocks are processed.
type BuilderStatus struct {
IsHighPrio bool
IsBlacklisted bool
IsOptimistic bool
}
// Profile captures performance metrics for the block submission handler. Each
// field corresponds to the number of microseconds in each stage. The `Total`
// field is the number of microseconds taken for entire flow.
type Profile struct {
Decode uint64
Prechecks uint64
Simulation uint64
RedisUpdate uint64
Total uint64
}
func (p *Profile) String() string {
return fmt.Sprintf("%v,%v,%v,%v,%v", p.Decode, p.Prechecks, p.Simulation, p.RedisUpdate, p.Total)
}