-
Notifications
You must be signed in to change notification settings - Fork 672
/
state_syncable_vm.go
44 lines (36 loc) · 1.54 KB
/
state_syncable_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
36
37
38
39
40
41
42
43
44
// Copyright (C) 2019-2022, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package block
import (
"errors"
)
var ErrStateSyncableVMNotImplemented = errors.New("vm does not implement StateSyncableVM interface")
// StateSyncableVM contains the functionality to allow VMs to sync to a given
// state, rather then boostrapping from genesis.
type StateSyncableVM interface {
// StateSyncEnabled indicates whether the state sync is enabled for this VM.
// If StateSyncableVM is not implemented, as it may happen with a wrapper
// VM, StateSyncEnabled should return false, nil
StateSyncEnabled() (bool, error)
// GetOngoingSyncStateSummary returns an in-progress state summary if it
// exists.
//
// The engine can then ask the network if the ongoing summary is still
// supported, thus helping the VM decide whether to continue an in-progress
// sync or start over.
//
// Returns database.ErrNotFound if there is no in-progress sync.
GetOngoingSyncStateSummary() (StateSummary, error)
// GetLastStateSummary returns the latest state summary.
//
// Returns database.ErrNotFound if no summary is available.
GetLastStateSummary() (StateSummary, error)
// ParseStateSummary parses a state summary out of [summaryBytes].
ParseStateSummary(summaryBytes []byte) (StateSummary, error)
// GetStateSummary retrieves the state summary that was generated at height
// [summaryHeight].
//
// Returns database.ErrNotFound if no summary is available at
// [summaryHeight].
GetStateSummary(summaryHeight uint64) (StateSummary, error)
}