Files
consensus/engine/tracker/tracker.go
T
zeekay 4aac78700d Refactor: remove dead code, add thread safety, improve test coverage
- 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
2025-12-13 07:42:01 +00:00

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
}