-
Notifications
You must be signed in to change notification settings - Fork 210
/
fetcher.go
80 lines (64 loc) · 2.16 KB
/
fetcher.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
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
package system
import (
"context"
"github.com/spacemeshos/go-spacemesh/common/types"
"github.com/spacemeshos/go-spacemesh/p2p"
)
//go:generate mockgen -typed -package=mocks -destination=./mocks/fetcher.go -source=./fetcher.go
// Fetcher is a general interface that defines a component capable of fetching data from remote peers.
type Fetcher interface {
AtxFetcher
BlockFetcher
PoetProofFetcher
BallotFetcher
ActiveSetFetcher
ProposalFetcher
TxFetcher
PeerTracker
}
// BlockFetcher defines an interface for fetching blocks from remote peers.
type BlockFetcher interface {
GetBlocks(context.Context, []types.BlockID) error
}
type GetAtxOpts struct {
LimitingOff bool
}
type GetAtxOpt func(*GetAtxOpts)
func WithoutLimiting() GetAtxOpt {
return func(opts *GetAtxOpts) {
opts.LimitingOff = true
}
}
// AtxFetcher defines an interface for fetching ATXs from remote peers.
type AtxFetcher interface {
GetAtxs(context.Context, []types.ATXID, ...GetAtxOpt) error
}
// TxFetcher defines an interface for fetching transactions from remote peers.
type TxFetcher interface {
GetBlockTxs(context.Context, []types.TransactionID) error
GetProposalTxs(context.Context, []types.TransactionID) error
}
// PoetProofFetcher defines an interface for fetching PoET proofs from remote peers.
type PoetProofFetcher interface {
GetPoetProof(context.Context, types.Hash32) error
}
// BallotFetcher defines an interface for fetching Ballot from remote peers.
type BallotFetcher interface {
GetBallots(context.Context, []types.BallotID) error
}
// ProposalFetcher defines an interface for fetching Proposal from remote peers.
type ProposalFetcher interface {
GetProposals(context.Context, []types.ProposalID) error
}
// ActiveSetFetcher defines an interface downloading active set.
type ActiveSetFetcher interface {
GetActiveSet(context.Context, types.Hash32) error
}
// MalfeasanceProofFetcher defines an interface for fetching malfeasance proofs.
type MalfeasanceProofFetcher interface {
GetMalfeasanceProofs(context.Context, []types.NodeID) error
}
// PeerTracker defines an interface to track peer hashes.
type PeerTracker interface {
RegisterPeerHashes(peer p2p.Peer, hashes []types.Hash32)
}