2019-07-26 07:17:29 +00:00
|
|
|
// Package state contains everything related to the synchronization state for MVDS.
|
|
|
|
package state
|
|
|
|
|
|
|
|
// RecordType is the type for a specific record, either `OFFER`, `REQUEST` or `MESSAGE`.
|
|
|
|
type RecordType int
|
|
|
|
|
|
|
|
const (
|
|
|
|
OFFER RecordType = iota
|
|
|
|
REQUEST
|
|
|
|
MESSAGE
|
|
|
|
)
|
|
|
|
|
|
|
|
// State is a struct used to store a records [state](https://github.com/status-im/bigbrother-specs/blob/master/data_sync/mvds.md#state).
|
|
|
|
type State struct {
|
|
|
|
Type RecordType
|
|
|
|
SendCount uint64
|
|
|
|
SendEpoch int64
|
|
|
|
// GroupID is optional, thus nullable
|
|
|
|
GroupID *GroupID
|
|
|
|
PeerID PeerID
|
|
|
|
MessageID MessageID
|
|
|
|
}
|
|
|
|
|
|
|
|
type SyncState interface {
|
|
|
|
Add(newState State) error
|
|
|
|
Remove(id MessageID, peer PeerID) error
|
2019-08-27 12:04:15 +00:00
|
|
|
All(epoch int64) ([]State, error)
|
2019-07-26 07:17:29 +00:00
|
|
|
Map(epoch int64, process func(State) State) error
|
|
|
|
}
|