/
rollapp_packets_list_filter.go
55 lines (48 loc) · 1.42 KB
/
rollapp_packets_list_filter.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
package types
import commontypes "github.com/dymensionxyz/dymension/v3/x/common/types"
type RollappPacketListFilter struct {
Prefixes []Prefix
}
type Prefix struct {
Start []byte
End []byte
}
func PendingByRollappIDByMaxHeight(
rollappID string,
maxProofHeight uint64,
) RollappPacketListFilter {
status := commontypes.Status_PENDING
return RollappPacketListFilter{
Prefixes: []Prefix{
{
Start: commontypes.RollappPacketByStatusByRollappIDByProofHeightPrefix(rollappID, status, 0),
End: commontypes.RollappPacketByStatusByRollappIDByProofHeightPrefix(rollappID, status, maxProofHeight+1), // inclusive end
},
},
}
}
func ByRollappIDByStatus(rollappID string, status ...commontypes.Status) RollappPacketListFilter {
prefixes := make([]Prefix, len(status))
for i, s := range status {
prefixes[i] = Prefix{Start: commontypes.RollappPacketByStatusByRollappIDPrefix(s, rollappID)}
}
return RollappPacketListFilter{
Prefixes: prefixes,
}
}
func ByRollappID(rollappID string) RollappPacketListFilter {
return ByRollappIDByStatus(rollappID,
commontypes.Status_PENDING,
commontypes.Status_FINALIZED,
commontypes.Status_REVERTED,
)
}
func ByStatus(status ...commontypes.Status) RollappPacketListFilter {
prefixes := make([]Prefix, len(status))
for i, s := range status {
prefixes[i] = Prefix{Start: commontypes.RollappPacketByStatusPrefix(s)}
}
return RollappPacketListFilter{
Prefixes: prefixes,
}
}