-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathepochinfo.go
59 lines (47 loc) · 1.22 KB
/
epochinfo.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
55
56
57
58
59
package iss
import (
lsp "github.com/filecoin-project/mir/pkg/iss/leaderselectionpolicy"
"github.com/filecoin-project/mir/pkg/orderers/common"
trantorpbtypes "github.com/filecoin-project/mir/pkg/pb/trantorpb/types"
tt "github.com/filecoin-project/mir/pkg/trantor/types"
)
// epochInfo holds epoch-specific information that becomes irrelevant on advancing to the next epoch.
type epochInfo struct {
// Epoch number.
nr tt.EpochNr
// First sequence number belonging to this epoch.
firstSN tt.SeqNr
// This epoch's membership.
Membership *trantorpbtypes.Membership
// Orderers' segments associated with the epoch.
Segments []*common.Segment
// Leader selection policy.
leaderPolicy lsp.LeaderSelectionPolicy
}
func newEpochInfo(
nr tt.EpochNr,
firstSN tt.SeqNr,
membership *trantorpbtypes.Membership,
leaderPolicy lsp.LeaderSelectionPolicy,
) epochInfo {
ei := epochInfo{
nr: nr,
firstSN: firstSN,
Membership: membership,
leaderPolicy: leaderPolicy,
}
return ei
}
func (e *epochInfo) Nr() tt.EpochNr {
return e.nr
}
func (e *epochInfo) FirstSN() tt.SeqNr {
return e.firstSN
}
func (e *epochInfo) Len() int {
l := 0
for _, segment := range e.Segments {
l += segment.Len()
}
return l
}