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-26 13:45:36 +00:00
|
|
|
func init() {
|
2019-08-26 18:23:11 +00:00
|
|
|
cbor.RegisterCborType(Deal{})
|
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{})
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
type Unixfs0Offer struct {
|
|
|
|
Root cid.Cid
|
|
|
|
Offset uint64
|
|
|
|
Size uint64
|
|
|
|
}
|
|
|
|
|
|
|
|
type Deal struct {
|
|
|
|
Unixfs0 *Unixfs0Offer
|
|
|
|
}
|
|
|
|
|
|
|
|
type DealResponse struct {
|
2019-08-27 19:54:39 +00:00
|
|
|
Status int // TODO: make this more spec complainant
|
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
|
|
|
|
}
|