-
Notifications
You must be signed in to change notification settings - Fork 0
/
storage_transfer.go
62 lines (54 loc) · 1.67 KB
/
storage_transfer.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
package boostly
import (
"github.com/google/uuid"
"github.com/ipfs/go-cid"
)
const (
FilStorageTransferProtocol_1_0_0 = "/fil/storage/transfer/1.0.0"
)
// HttpRequest has parameters for an HTTP transfer
type HttpRequest struct {
// URL can be
// - an http URL:
// "https://example.com/path"
// - a libp2p URL:
// "libp2p:///ip4/104.131.131.82/tcp/4001/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ"
// Must include a Peer ID
URL string
// Headers are the HTTP headers that are sent as part of the request,
// eg "Authorization"
Headers map[string]string
}
// TransportDealInfo has parameters for a transfer to be executed
type TransportDealInfo struct {
OutputFile string
DealUuid uuid.UUID
DealSize int64
}
// TransportEvent is fired as a transfer progresses
type TransportEvent struct {
NBytesReceived int64
Error error
}
// TransferStatus describes the status of a transfer (started, completed etc)
type TransferStatus string
const (
// TransferStatusStarted is set when the transfer starts
TransferStatusStarted TransferStatus = "TransferStatusStarted"
// TransferStatusRestarted is set when the transfer restarts after previously starting
TransferStatusRestarted TransferStatus = "TransferStatusRestarted"
TransferStatusOngoing TransferStatus = "TransferStatusOngoing"
TransferStatusCompleted TransferStatus = "TransferStatusCompleted"
TransferStatusFailed TransferStatus = "TransferStatusFailed"
)
// TransferState describes a transfer's current state
type TransferState struct {
ID string
LocalAddr string
RemoteAddr string
Status TransferStatus
Sent uint64
Received uint64
Message string
PayloadCid cid.Cid
}