NewPersistedClock create a new persisted Lamport clock
(root billy.Filesystem, filePath string)
| 20 | |
| 21 | // NewPersistedClock create a new persisted Lamport clock |
| 22 | func NewPersistedClock(root billy.Filesystem, filePath string) (*PersistedClock, error) { |
| 23 | clock := &PersistedClock{ |
| 24 | MemClock: NewMemClock(), |
| 25 | root: root, |
| 26 | filePath: filePath, |
| 27 | } |
| 28 | |
| 29 | err := clock.Write() |
| 30 | if err != nil { |
| 31 | return nil, err |
| 32 | } |
| 33 | |
| 34 | return clock, nil |
| 35 | } |
| 36 | |
| 37 | // LoadPersistedClock load a persisted Lamport clock from a file |
| 38 | func LoadPersistedClock(root billy.Filesystem, filePath string) (*PersistedClock, error) { |