mirror of
https://github.com/QuilibriumNetwork/ceremonyclient.git
synced 2026-02-22 02:47:26 +08:00
* v2.1.0 [omit consensus and adjacent] - this commit will be amended with the full release after the file copy is complete * 2.1.0 main node rollup
32 lines
517 B
Go
32 lines
517 B
Go
package hypergraph
|
|
|
|
import (
|
|
"sync/atomic"
|
|
"time"
|
|
)
|
|
|
|
type SyncController struct {
|
|
isSyncing atomic.Bool
|
|
SyncStatus map[string]*SyncInfo
|
|
}
|
|
|
|
func (s *SyncController) TryEstablishSyncSession() bool {
|
|
return !s.isSyncing.Swap(true)
|
|
}
|
|
|
|
func (s *SyncController) EndSyncSession() {
|
|
s.isSyncing.Store(false)
|
|
}
|
|
|
|
type SyncInfo struct {
|
|
Unreachable bool
|
|
LastSynced time.Time
|
|
}
|
|
|
|
func NewSyncController() *SyncController {
|
|
return &SyncController{
|
|
isSyncing: atomic.Bool{},
|
|
SyncStatus: map[string]*SyncInfo{},
|
|
}
|
|
}
|