-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathpeerchannels_notify.go
37 lines (30 loc) · 1.06 KB
/
peerchannels_notify.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
package payd
import (
"context"
"github.com/gorilla/websocket"
"github.com/libsv/go-spvchannels"
)
// The types of message handlers.
const (
PeerChannelHandlerTypeProof PeerChannelHandlerType = "proof"
)
// PeerChannelHandlerType the type of function which a peer channels message should map to.
type PeerChannelHandlerType string
// PeerChannelsNotifyService for interfacing with peer channel notifications.
type PeerChannelsNotifyService interface {
RegisterHandler(ht PeerChannelHandlerType, hdlr PeerChannelsMessageHandler) PeerChannelsNotifyService
Subscribe(ctx context.Context, args *PeerChannel) error
}
// PeerChannelsMessageHandler for handling peer channel messages.
type PeerChannelsMessageHandler interface {
HandlePeerChannelsMessage(ctx context.Context, msgs spvchannels.MessagesReply) (bool, error)
}
// PeerChannelSubscription for subscribing to channel notifications.
type PeerChannelSubscription struct {
Host string
Path string
ChannelID string
Token string
ChannelType PeerChannelHandlerType
Conn *websocket.Conn
}