-
Notifications
You must be signed in to change notification settings - Fork 146
Expand file tree
/
Copy pathinterfaces.go
More file actions
89 lines (76 loc) · 3.13 KB
/
interfaces.go
File metadata and controls
89 lines (76 loc) · 3.13 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
// Copyright 2021 ChainSafe Systems (ON)
// SPDX-License-Identifier: LGPL-3.0-only
package sync
import (
"encoding/json"
"sync"
"github.com/ChainSafe/gossamer/dot/network"
"github.com/ChainSafe/gossamer/dot/peerset"
"github.com/ChainSafe/gossamer/dot/state"
"github.com/ChainSafe/gossamer/dot/types"
"github.com/ChainSafe/gossamer/lib/common"
rtstorage "github.com/ChainSafe/gossamer/lib/runtime/storage"
"github.com/libp2p/go-libp2p-core/peer"
)
// BlockState is the interface for the block state
type BlockState interface {
BestBlockHeader() (*types.Header, error)
BestBlockNumber() (number uint, err error)
CompareAndSetBlockData(bd *types.BlockData) error
HasBlockBody(hash common.Hash) (bool, error)
GetBlockBody(common.Hash) (*types.Body, error)
GetHeader(common.Hash) (*types.Header, error)
HasHeader(hash common.Hash) (bool, error)
Range(startHash, endHash common.Hash) (hashes []common.Hash, err error)
SubChain(start, end common.Hash) ([]common.Hash, error)
GetReceipt(common.Hash) ([]byte, error)
GetMessageQueue(common.Hash) ([]byte, error)
GetJustification(common.Hash) ([]byte, error)
SetJustification(hash common.Hash, data []byte) error
AddBlockToBlockTree(block *types.Block) error
GetHashByNumber(blockNumber uint) (common.Hash, error)
GetBlockByHash(common.Hash) (*types.Block, error)
GetRuntime(blockHash common.Hash) (runtime state.Runtime, err error)
StoreRuntime(blockHash common.Hash, runtime state.Runtime)
GetHighestFinalisedHeader() (*types.Header, error)
GetFinalisedNotifierChannel() chan *types.FinalisationInfo
GetHeaderByNumber(num uint) (*types.Header, error)
GetAllBlocksAtNumber(num uint) ([]common.Hash, error)
IsDescendantOf(parent, child common.Hash) (bool, error)
}
// StorageState is the interface for the storage state
type StorageState interface {
TrieState(root *common.Hash) (*rtstorage.TrieState, error)
sync.Locker
}
// TransactionState is the interface for transaction queue methods
type TransactionState interface {
RemoveExtrinsic(ext types.Extrinsic)
}
// BabeVerifier deals with BABE block verification
type BabeVerifier interface {
VerifyBlock(header *types.Header) error
}
// FinalityGadget implements justification verification functionality
type FinalityGadget interface {
VerifyBlockJustification(common.Hash, []byte) ([]byte, error)
}
// BlockImportHandler is the interface for the handler of newly imported blocks
type BlockImportHandler interface {
HandleBlockImport(block *types.Block, state *rtstorage.TrieState, announce bool) error
}
// Network is the interface for the network
type Network interface {
// DoBlockRequest sends a request to the given peer.
// If a response is received within a certain time period,
// it is returned, otherwise an error is returned.
DoBlockRequest(to peer.ID, req *network.BlockRequestMessage) (*network.BlockResponseMessage, error)
// Peers returns a list of currently connected peers
Peers() []common.PeerInfo
// ReportPeer reports peer based on the peer behaviour.
ReportPeer(change peerset.ReputationChange, p peer.ID)
}
// Telemetry is the telemetry client to send telemetry messages.
type Telemetry interface {
SendMessage(msg json.Marshaler)
}