mirror of
https://github.com/luxfi/consensus.git
synced 2026-09-24 00:26:58 +00:00
- Remove unused packages: engine/dag/{getter,bootstrap,vertex/vertexmock},
engine/pq/{bootstrap,block}, core/{tracker,verify}
- Add sync.RWMutex to protocol/wave for thread-safe map access
- Increase engine/dag test coverage from 11.7% to 98.3%
- Add comprehensive tests for DAG consensus, vertex, and engine
- All 27 packages pass tests, 16 at 100% coverage
50 lines
958 B
Go
50 lines
958 B
Go
package tracker
|
|
|
|
import (
|
|
"github.com/luxfi/ids"
|
|
)
|
|
|
|
// Tracker tracks consensus state
|
|
type Tracker interface {
|
|
// IsBootstrapped checks if bootstrapped
|
|
IsBootstrapped() bool
|
|
|
|
// Bootstrapped marks as bootstrapped
|
|
Bootstrapped(ids.ID)
|
|
|
|
// OnBootstrapCompleted called when bootstrap completes
|
|
OnBootstrapCompleted() chan ids.ID
|
|
}
|
|
|
|
// tracker implementation
|
|
type tracker struct {
|
|
bootstrapped bool
|
|
completed chan ids.ID
|
|
}
|
|
|
|
// NewTracker creates a new tracker
|
|
func NewTracker() Tracker {
|
|
return &tracker{
|
|
completed: make(chan ids.ID, 1),
|
|
}
|
|
}
|
|
|
|
// IsBootstrapped checks if bootstrapped
|
|
func (t *tracker) IsBootstrapped() bool {
|
|
return t.bootstrapped
|
|
}
|
|
|
|
// Bootstrapped marks as bootstrapped
|
|
func (t *tracker) Bootstrapped(chainID ids.ID) {
|
|
t.bootstrapped = true
|
|
select {
|
|
case t.completed <- chainID:
|
|
default:
|
|
}
|
|
}
|
|
|
|
// OnBootstrapCompleted returns completion channel
|
|
func (t *tracker) OnBootstrapCompleted() chan ids.ID {
|
|
return t.completed
|
|
}
|