lotus/retrieval/types.go

63 lines
1.1 KiB
Go
Raw Normal View History

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-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-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 AcceptedResponse struct{}
type RejectedResponse struct {
Message string
}
type ErrorResponse RejectedResponse
type DealResponse struct {
*AcceptedResponse
*RejectedResponse
*ErrorResponse
}