-
Notifications
You must be signed in to change notification settings - Fork 142
/
snapshot_info.go
52 lines (41 loc) · 1.07 KB
/
snapshot_info.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
package sm_snapshots
import (
"fmt"
"github.com/iotaledger/wasp/packages/state"
"github.com/iotaledger/wasp/packages/trie"
)
type snapshotInfoImpl struct {
index uint32
commitment *state.L1Commitment
}
var _ SnapshotInfo = &snapshotInfoImpl{}
func NewSnapshotInfo(index uint32, commitment *state.L1Commitment) SnapshotInfo {
return &snapshotInfoImpl{
index: index,
commitment: commitment,
}
}
func (si *snapshotInfoImpl) StateIndex() uint32 {
return si.index
}
func (si *snapshotInfoImpl) Commitment() *state.L1Commitment {
return si.commitment
}
func (si *snapshotInfoImpl) TrieRoot() trie.Hash {
return si.Commitment().TrieRoot()
}
func (si *snapshotInfoImpl) BlockHash() state.BlockHash {
return si.Commitment().BlockHash()
}
func (si *snapshotInfoImpl) String() string {
return fmt.Sprintf("%v %s", si.StateIndex(), si.Commitment())
}
func (si *snapshotInfoImpl) Equals(other SnapshotInfo) bool {
if si == nil {
return other == nil
}
if si.StateIndex() != other.StateIndex() {
return false
}
return si.Commitment().Equals(other.Commitment())
}