forked from ethereum-optimism/optimism
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcluster.go
More file actions
57 lines (41 loc) · 1.32 KB
/
cluster.go
File metadata and controls
57 lines (41 loc) · 1.32 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
package stack
import (
"log/slog"
"github.com/ethereum-optimism/optimism/op-supervisor/supervisor/backend/depset"
)
// ClusterID identifies a Cluster by name, is type-safe, and can be value-copied and used as map key.
type ClusterID genericID
var _ GenericID = (*ClusterID)(nil)
const ClusterKind Kind = "Cluster"
func (id ClusterID) String() string {
return genericID(id).string(ClusterKind)
}
func (id ClusterID) Kind() Kind {
return ClusterKind
}
func (id ClusterID) LogValue() slog.Value {
return slog.StringValue(id.String())
}
func (id ClusterID) MarshalText() ([]byte, error) {
return genericID(id).marshalText(ClusterKind)
}
func (id *ClusterID) UnmarshalText(data []byte) error {
return (*genericID)(id).unmarshalText(ClusterKind, data)
}
func SortClusterIDs(ids []ClusterID) []ClusterID {
return copyAndSortCmp(ids)
}
func SortClusters(elems []Cluster) []Cluster {
return copyAndSort(elems, lessElemOrdered[ClusterID, Cluster])
}
var _ ClusterMatcher = ClusterID("")
func (id ClusterID) Match(elems []Cluster) []Cluster {
return findByID(id, elems)
}
// Cluster represents a set of chains that interop with each other.
// This may include L1 chains (although potentially not two-way interop due to consensus-layer limitations).
type Cluster interface {
Common
ID() ClusterID
DependencySet() depset.DependencySet
}