-
Notifications
You must be signed in to change notification settings - Fork 189
/
Copy pathpersister.go
30 lines (25 loc) · 1.3 KB
/
persister.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
package hotstuff
// Persister is responsible for persisting minimal critical safety and liveness data for HotStuff:
// specifically [hotstuff.LivenessData] and [hotstuff.SafetyData].
type Persister interface {
PersisterReader
// PutSafetyData persists the last safety data.
// This method blocks until `safetyData` was successfully persisted.
// During normal operations, no errors are expected.
PutSafetyData(safetyData *SafetyData) error
// PutLivenessData persists the last liveness data.
// This method blocks until `safetyData` was successfully persisted.
// During normal operations, no errors are expected.
PutLivenessData(livenessData *LivenessData) error
}
// PersisterReader exposes only the read-only parts of the Persister component.
// This is used to read information about the HotStuff instance's current state from other components.
// CAUTION: the write functions are hidden here, because it is NOT SAFE to use them outside the Hotstuff state machine.
type PersisterReader interface {
// GetSafetyData will retrieve last persisted safety data.
// During normal operations, no errors are expected.
GetSafetyData() (*SafetyData, error)
// GetLivenessData will retrieve last persisted liveness data.
// During normal operations, no errors are expected.
GetLivenessData() (*LivenessData, error)
}