2019-08-26 08:02:26 +00:00
|
|
|
package retrieval
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/ipfs/go-cid"
|
2019-08-26 13:45:36 +00:00
|
|
|
cbor "github.com/ipfs/go-ipld-cbor"
|
2019-08-26 08:02:26 +00:00
|
|
|
|
|
|
|
"github.com/filecoin-project/go-lotus/chain/types"
|
|
|
|
)
|
|
|
|
|
2019-08-26 13:45:36 +00:00
|
|
|
const ProtocolID = "/fil/retrieval/-1.0.0" // TODO: spec
|
|
|
|
const QueryProtocolID = "/fil/retrieval/qry/-1.0.0" // TODO: spec
|
|
|
|
|
2019-08-26 18:23:11 +00:00
|
|
|
type QueryResponseStatus int
|
2019-08-26 09:08:39 +00:00
|
|
|
|
2019-08-26 08:02:26 +00:00
|
|
|
const (
|
2019-08-26 18:23:11 +00:00
|
|
|
Available QueryResponseStatus = iota
|
2019-08-26 08:02:26 +00:00
|
|
|
Unavailable
|
|
|
|
)
|
|
|
|
|
2019-08-27 18:45:21 +00:00
|
|
|
const (
|
|
|
|
Accepted = iota
|
|
|
|
Error
|
|
|
|
Rejected
|
2019-08-29 15:43:45 +00:00
|
|
|
Unsealing
|
2019-08-27 18:45:21 +00:00
|
|
|
)
|
|
|
|
|
2019-08-26 13:45:36 +00:00
|
|
|
func init() {
|
2019-08-29 18:55:20 +00:00
|
|
|
cbor.RegisterCborType(RetParams{})
|
2019-08-26 13:45:36 +00:00
|
|
|
|
2019-08-26 18:23:11 +00:00
|
|
|
cbor.RegisterCborType(Query{})
|
|
|
|
cbor.RegisterCborType(QueryResponse{})
|
2019-08-27 18:45:21 +00:00
|
|
|
cbor.RegisterCborType(Unixfs0Offer{})
|
|
|
|
|
2019-08-29 18:55:20 +00:00
|
|
|
cbor.RegisterCborType(DealProposal{})
|
2019-08-27 18:45:21 +00:00
|
|
|
cbor.RegisterCborType(DealResponse{})
|
2019-08-29 11:31:25 +00:00
|
|
|
cbor.RegisterCborType(Block{})
|
2019-08-26 13:45:36 +00:00
|
|
|
}
|
|
|
|
|
2019-08-26 18:23:11 +00:00
|
|
|
type Query struct {
|
2019-08-26 08:02:26 +00:00
|
|
|
Piece cid.Cid
|
2019-08-26 18:23:11 +00:00
|
|
|
// TODO: payment
|
2019-08-26 08:02:26 +00:00
|
|
|
}
|
|
|
|
|
2019-08-26 18:23:11 +00:00
|
|
|
type QueryResponse struct {
|
|
|
|
Status QueryResponseStatus
|
2019-08-26 08:02:26 +00:00
|
|
|
|
2019-08-26 13:45:36 +00:00
|
|
|
Size uint64 // TODO: spec
|
|
|
|
// TODO: unseal price (+spec)
|
2019-08-26 18:23:11 +00:00
|
|
|
// TODO: sectors to unseal
|
2019-08-26 13:45:36 +00:00
|
|
|
// TODO: address to send money for the deal?
|
|
|
|
MinPrice types.BigInt
|
2019-08-26 08:02:26 +00:00
|
|
|
}
|
2019-08-26 18:23:11 +00:00
|
|
|
|
2019-08-29 18:55:20 +00:00
|
|
|
type Unixfs0Offer struct {
|
2019-08-26 18:23:11 +00:00
|
|
|
Offset uint64
|
|
|
|
Size uint64
|
|
|
|
}
|
|
|
|
|
2019-08-29 15:43:45 +00:00
|
|
|
type RetParams struct {
|
2019-08-26 18:23:11 +00:00
|
|
|
Unixfs0 *Unixfs0Offer
|
|
|
|
}
|
|
|
|
|
2019-08-29 15:43:45 +00:00
|
|
|
type DealProposal struct {
|
|
|
|
Ref cid.Cid
|
|
|
|
Params RetParams
|
|
|
|
// TODO: payment
|
|
|
|
}
|
|
|
|
|
2019-08-26 18:23:11 +00:00
|
|
|
type DealResponse struct {
|
2019-08-29 15:43:45 +00:00
|
|
|
Status int
|
2019-08-27 18:45:21 +00:00
|
|
|
Message string
|
2019-08-26 18:23:11 +00:00
|
|
|
}
|
2019-08-29 11:31:25 +00:00
|
|
|
|
|
|
|
type Block struct { // TODO: put in spec
|
|
|
|
Prefix []byte // TODO: fix cid.Prefix marshaling somehow
|
|
|
|
Data []byte
|
|
|
|
}
|