Skip to content

Commit 22f5b91

Browse files
authored
Make platformvm implement block.HeightIndexedChainVM (#1746)
1 parent 3a0b763 commit 22f5b91

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

vms/platformvm/vm.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ import (
5454

5555
var (
5656
_ block.ChainVM = (*VM)(nil)
57+
_ block.HeightIndexedChainVM = (*VM)(nil)
5758
_ secp256k1fx.VM = (*VM)(nil)
5859
_ validators.State = (*VM)(nil)
5960
_ validators.SubnetConnector = (*VM)(nil)
@@ -88,6 +89,9 @@ type VM struct {
8889

8990
txBuilder txbuilder.Builder
9091
manager blockexecutor.Manager
92+
93+
// TODO: Remove after v1.11.x is activated
94+
pruned utils.Atomic[bool]
9195
}
9296

9397
// Initialize this blockchain.
@@ -222,6 +226,8 @@ func (vm *VM) Initialize(
222226
zap.Error(err),
223227
)
224228
}
229+
230+
vm.pruned.Set(true)
225231
}()
226232

227233
return nil
@@ -467,3 +473,15 @@ func (vm *VM) Clock() *mockable.Clock {
467473
func (vm *VM) Logger() logging.Logger {
468474
return vm.ctx.Log
469475
}
476+
477+
func (vm *VM) VerifyHeightIndex(_ context.Context) error {
478+
if vm.pruned.Get() {
479+
return nil
480+
}
481+
482+
return block.ErrIndexIncomplete
483+
}
484+
485+
func (vm *VM) GetBlockIDAtHeight(_ context.Context, height uint64) (ids.ID, error) {
486+
return vm.state.GetBlockIDAtHeight(height)
487+
}

0 commit comments

Comments
 (0)