Repository navigation
Expand file tree
/
Copy pathsync_tester.go
More file actions
76 lines (57 loc) · 1.73 KB
/
Copy pathsync_tester.go
File metadata and controls
76 lines (57 loc) · 1.73 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
package stack
import (
"log/slog"
"github.com/ethereum-optimism/optimism/op-service/apis"
"github.com/ethereum-optimism/optimism/op-service/eth"
)
// SyncTesterID identifies a syncTester by name and chainID, is type-safe, and can be value-copied and used as map key.
type SyncTesterID idWithChain
var _ IDWithChain = (*SyncTesterID)(nil)
const SyncTesterKind Kind = "SyncTester"
func NewSyncTesterID(key string, chainID eth.ChainID) SyncTesterID {
return SyncTesterID{
key: key,
chainID: chainID,
}
}
func (id SyncTesterID) String() string {
return idWithChain(id).string(SyncTesterKind)
}
func (id SyncTesterID) ChainID() eth.ChainID {
return idWithChain(id).chainID
}
func (id SyncTesterID) Kind() Kind {
return SyncTesterKind
}
func (id SyncTesterID) Key() string {
return id.key
}
func (id SyncTesterID) LogValue() slog.Value {
return slog.StringValue(id.String())
}
func (id SyncTesterID) MarshalText() ([]byte, error) {
return idWithChain(id).marshalText(SyncTesterKind)
}
func (id *SyncTesterID) UnmarshalText(data []byte) error {
return (*idWithChain)(id).unmarshalText(SyncTesterKind, data)
}
func SortSyncTesterIDs(ids []SyncTesterID) []SyncTesterID {
return copyAndSort(ids, func(a, b SyncTesterID) bool {
return lessIDWithChain(idWithChain(a), idWithChain(b))
})
}
func SortSyncTesters(elems []SyncTester) []SyncTester {
return copyAndSort(elems, func(a, b SyncTester) bool {
return lessIDWithChain(idWithChain(a.ID()), idWithChain(b.ID()))
})
}
var _ SyncTesterMatcher = SyncTesterID{}
func (id SyncTesterID) Match(elems []SyncTester) []SyncTester {
return findByID(id, elems)
}
type SyncTester interface {
Common
ID() SyncTesterID
API() apis.SyncTester
APIWithSession(sessionID string) apis.SyncTester
}