-
Notifications
You must be signed in to change notification settings - Fork 5
/
interface.go
45 lines (39 loc) · 1.3 KB
/
interface.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
package p2p
import (
"fmt"
"github.com/libsv/go-p2p/chaincfg/chainhash"
"github.com/libsv/go-p2p/wire"
)
var ErrPeerNetworkMismatch = fmt.Errorf("peer network mismatch")
type PeerManagerI interface {
AnnounceTransaction(txHash *chainhash.Hash, peers []PeerI) []PeerI
RequestTransaction(txHash *chainhash.Hash) PeerI
AnnounceBlock(blockHash *chainhash.Hash, peers []PeerI) []PeerI
RequestBlock(blockHash *chainhash.Hash) PeerI
AddPeer(peer PeerI) error
GetPeers() []PeerI
Shutdown()
}
type PeerI interface {
Connected() bool
WriteMsg(msg wire.Message) error
String() string
AnnounceTransaction(txHash *chainhash.Hash)
RequestTransaction(txHash *chainhash.Hash)
AnnounceBlock(blockHash *chainhash.Hash)
RequestBlock(blockHash *chainhash.Hash)
Network() wire.BitcoinNet
IsHealthy() bool
IsUnhealthyCh() <-chan struct{}
Shutdown()
Restart()
}
type PeerHandlerI interface {
HandleTransactionsGet(msgs []*wire.InvVect, peer PeerI) ([][]byte, error)
HandleTransactionSent(msg *wire.MsgTx, peer PeerI) error
HandleTransactionAnnouncement(msg *wire.InvVect, peer PeerI) error
HandleTransactionRejection(rejMsg *wire.MsgReject, peer PeerI) error
HandleTransaction(msg *wire.MsgTx, peer PeerI) error
HandleBlockAnnouncement(msg *wire.InvVect, peer PeerI) error
HandleBlock(msg wire.Message, peer PeerI) error
}