-
Notifications
You must be signed in to change notification settings - Fork 670
/
height_indexed_vm.go
35 lines (30 loc) · 1.27 KB
/
height_indexed_vm.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// Copyright (C) 2019-2022, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package block
import (
"context"
"errors"
"github.com/ava-labs/avalanchego/ids"
)
var (
ErrHeightIndexedVMNotImplemented = errors.New("vm does not implement HeightIndexedChainVM interface")
ErrIndexIncomplete = errors.New("query failed because height index is incomplete")
)
// HeightIndexedChainVM extends ChainVM to allow querying block IDs by height.
type HeightIndexedChainVM interface {
// VerifyHeightIndex should return:
// - nil if the height index is available.
// - ErrHeightIndexedVMNotImplemented if the height index is not supported.
// - ErrIndexIncomplete if the height index is not currently available.
// - Any other non-standard error that may have occurred when verifying the
// index.
VerifyHeightIndex(context.Context) error
// GetBlockIDAtHeight returns:
// - The ID of the block that was accepted with [height].
// - database.ErrNotFound if the [height] index is unknown.
//
// Note: A returned value of [database.ErrNotFound] typically means that the
// underlying VM was state synced and does not have access to the
// blockID at [height].
GetBlockIDAtHeight(ctx context.Context, height uint64) (ids.ID, error)
}