Files
zeekay ede37547f6 refactor(platformvm): consolidate block code, drop atomic_block, add v0 lift
- Drop atomic_block.go + legacy *_block_test.go (consolidated)
- Add block/v0/ subdir + lift_v0.go for old version handling
- Copyright header: 'Lux Industries, Inc.' → 'Lux Industries Inc' (no comma)
- block_adapter.go: new adapter layer
2026-06-01 15:22:27 -07:00

49 lines
1.3 KiB
Go

// Copyright (C) 2019-2025, Lux Industries Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package validators
import (
"context"
"sync"
validators "github.com/luxfi/validators"
"github.com/luxfi/ids"
)
// NewLockedState creates a new locked validator state
func NewLockedState(lock sync.Locker, state validators.State) validators.State {
return &lockedState{
lock: lock,
State: state,
}
}
type lockedState struct {
lock sync.Locker
validators.State
}
func (ls *lockedState) GetCurrentHeight(ctx context.Context) (uint64, error) {
ls.lock.Lock()
defer ls.lock.Unlock()
return ls.State.GetCurrentHeight(ctx)
}
func (ls *lockedState) GetValidatorSet(ctx context.Context, height uint64, chainID ids.ID) (map[ids.NodeID]*validators.GetValidatorOutput, error) {
ls.lock.Lock()
defer ls.lock.Unlock()
return ls.State.GetValidatorSet(ctx, height, chainID)
}
func (ls *lockedState) GetCurrentValidators(ctx context.Context, height uint64, chainID ids.ID) (map[ids.NodeID]*validators.GetValidatorOutput, error) {
ls.lock.Lock()
defer ls.lock.Unlock()
if state, ok := ls.State.(interface {
GetCurrentValidators(context.Context, uint64, ids.ID) (map[ids.NodeID]*validators.GetValidatorOutput, error)
}); ok {
return state.GetCurrentValidators(ctx, height, chainID)
}
return ls.State.GetValidatorSet(ctx, height, chainID)
}