-
Notifications
You must be signed in to change notification settings - Fork 17
/
message.go
55 lines (49 loc) · 1.38 KB
/
message.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
package datatransfer
import (
"io"
"github.com/ipfs/go-cid"
"github.com/ipld/go-ipld-prime/datamodel"
"github.com/libp2p/go-libp2p/core/protocol"
)
var (
// ProtocolDataTransfer1_2 is the protocol identifier for the latest
// version of data-transfer (supports do-not-send-first-blocks extension)
ProtocolDataTransfer1_2 protocol.ID = "/fil/datatransfer/1.2.0"
)
// Message is a message for the data transfer protocol
// (either request or response) that can serialize to a protobuf
type Message interface {
IsRequest() bool
IsRestart() bool
IsNew() bool
IsUpdate() bool
IsPaused() bool
IsCancel() bool
TransferID() TransferID
ToNet(w io.Writer) error
ToIPLD() datamodel.Node
MessageForProtocol(targetProtocol protocol.ID) (newMsg Message, err error)
}
// Request is a response message for the data transfer protocol
type Request interface {
Message
IsPull() bool
IsVoucher() bool
VoucherType() TypeIdentifier
Voucher() (datamodel.Node, error)
TypedVoucher() (TypedVoucher, error)
BaseCid() cid.Cid
Selector() (datamodel.Node, error)
IsRestartExistingChannelRequest() bool
RestartChannelId() (ChannelID, error)
}
// Response is a response message for the data transfer protocol
type Response interface {
Message
IsValidationResult() bool
IsComplete() bool
Accepted() bool
VoucherResultType() TypeIdentifier
VoucherResult() (datamodel.Node, error)
EmptyVoucherResult() bool
}