Documentation ¶
Overview ¶
Package cidoffer - provides functionality like create, verify, sign and get details for CIDOffer and SubCIDOffer structures.
CIDOffer represents an offer from a Storage Provider, explaining on what conditions the client can retrieve a set of uniquely identified files from Filecoin blockchain network. SubCIDOffer represents an offer from a Storage Provider, just like CIDOffer, but for a single file and includes a merkle proof
Index ¶
- Constants
- type CIDOffer
- func (c *CIDOffer) GenerateSubCIDOffer(cid *cid.ContentID) (*SubCIDOffer, error)
- func (c *CIDOffer) GetCIDs() []cid.ContentID
- func (c *CIDOffer) GetExpiry() int64
- func (c *CIDOffer) GetMessageDigest() (sum256 [CIDOfferDigestSize]byte)
- func (c *CIDOffer) GetPrice() uint64
- func (c *CIDOffer) GetProviderID() *nodeid.NodeID
- func (c *CIDOffer) GetQoS() uint64
- func (c *CIDOffer) GetSignature() string
- func (c *CIDOffer) HasExpired() bool
- func (c CIDOffer) MarshalJSON() ([]byte, error)
- func (c CIDOffer) MarshalToSign() ([]byte, error)
- func (c *CIDOffer) SetSignature(s string)
- func (c *CIDOffer) Sign(privKey *fcrcrypto.KeyPair, keyVer *fcrcrypto.KeyVersion) error
- func (c *CIDOffer) UnmarshalJSON(p []byte) error
- func (c *CIDOffer) Verify(pubKey *fcrcrypto.KeyPair) error
- type SubCIDOffer
- func (c *SubCIDOffer) GetExpiry() int64
- func (c *SubCIDOffer) GetMerkleProof() *fcrmerkletree.FCRMerkleProof
- func (c *SubCIDOffer) GetMerkleRoot() string
- func (c *SubCIDOffer) GetPrice() uint64
- func (c *SubCIDOffer) GetProviderID() *nodeid.NodeID
- func (c *SubCIDOffer) GetQoS() uint64
- func (c *SubCIDOffer) GetSignature() string
- func (c *SubCIDOffer) GetSubCID() *cid.ContentID
- func (c *SubCIDOffer) HasExpired() bool
- func (c SubCIDOffer) MarshalJSON() ([]byte, error)
- func (c *SubCIDOffer) MarshalToSign() ([]byte, error)
- func (c *SubCIDOffer) UnmarshalJSON(p []byte) error
- func (c *SubCIDOffer) Verify(pubKey *fcrcrypto.KeyPair) error
- func (c *SubCIDOffer) VerifyMerkleProof() error
Constants ¶
const CIDOfferDigestSize = sha512.Size256
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CIDOffer ¶
type CIDOffer struct {
// contains filtered or unexported fields
}
CIDOffer represents a CID Offer. That is, an offer to deliver content for Piece CID(s) at a certain price.
func NewCIDOffer ¶
func NewCIDOffer(providerID *nodeid.NodeID, cids []cid.ContentID, price uint64, expiry int64, qos uint64) (*CIDOffer, error)
NewCidOffer creates an unsigned CID Offer.
func (*CIDOffer) GenerateSubCIDOffer ¶
func (c *CIDOffer) GenerateSubCIDOffer(cid *cid.ContentID) (*SubCIDOffer, error)
GenerateSubCIDOffer is used to generate a sub cid offer with proof for a given cid.
func (*CIDOffer) GetMessageDigest ¶
func (c *CIDOffer) GetMessageDigest() (sum256 [CIDOfferDigestSize]byte)
GetMessageDigest calculate the message digest of this CID Group Offer. Note that the methodology used here should not be externally visible. The message digest should only be used within the gateway.
func (*CIDOffer) GetProviderID ¶
GetProviderID returns the provider ID of this offer.
func (*CIDOffer) GetSignature ¶
GetSignature returns the signature of this offer.
func (*CIDOffer) HasExpired ¶
HasExpired returns true if the offer expiry date is in the past.
func (CIDOffer) MarshalJSON ¶
MarshalJSON is used to marshal offer into bytes.
func (CIDOffer) MarshalToSign ¶
MarshalJSON is used to marshal offer into bytes.
func (*CIDOffer) SetSignature ¶
SetSignature sets the signature of this offer.
func (*CIDOffer) UnmarshalJSON ¶
UnmarshalJSON is used to unmarshal bytes into offer.
type SubCIDOffer ¶
type SubCIDOffer struct {
// contains filtered or unexported fields
}
SubCIDOffer represents a sub CID Offer. That is, part of a CID offer. It contains one sub cid and a merkle proof showing that this sub cid is part of the cid array in the original cid offer.
func NewSubCIDOffer ¶
func NewSubCIDOffer(providerID *nodeid.NodeID, subCID *cid.ContentID, merkleRoot string, merkleProof *fcrmerkletree.FCRMerkleProof, price uint64, expiry int64, qos uint64, signature string) *SubCIDOffer
NewSubCIDOffer creates a sub CID Offer.
func (*SubCIDOffer) GetExpiry ¶
func (c *SubCIDOffer) GetExpiry() int64
GetExpiry returns the expiry of this offer.
func (*SubCIDOffer) GetMerkleProof ¶
func (c *SubCIDOffer) GetMerkleProof() *fcrmerkletree.FCRMerkleProof
GetMerkleProof returns the merkle proof of this offer.
func (*SubCIDOffer) GetMerkleRoot ¶
func (c *SubCIDOffer) GetMerkleRoot() string
GetMerkleRoot returns the merkle root of this offer.
func (*SubCIDOffer) GetPrice ¶
func (c *SubCIDOffer) GetPrice() uint64
GetPrice returns the price of this offer.
func (*SubCIDOffer) GetProviderID ¶
func (c *SubCIDOffer) GetProviderID() *nodeid.NodeID
GetProviderID returns the provider ID of this offer.
func (*SubCIDOffer) GetQoS ¶
func (c *SubCIDOffer) GetQoS() uint64
GetQoS returns the quality of service of this offer.
func (*SubCIDOffer) GetSignature ¶
func (c *SubCIDOffer) GetSignature() string
GetSignature returns the signature of this offer.
func (*SubCIDOffer) GetSubCID ¶
func (c *SubCIDOffer) GetSubCID() *cid.ContentID
GetSubCID returns the sub cid of this offer.
func (*SubCIDOffer) HasExpired ¶
func (c *SubCIDOffer) HasExpired() bool
HasExpired returns true if the offer expiry date is in the past.
func (SubCIDOffer) MarshalJSON ¶
func (c SubCIDOffer) MarshalJSON() ([]byte, error)
MarshalJSON is used to marshal offer into bytes.
func (*SubCIDOffer) MarshalToSign ¶
func (c *SubCIDOffer) MarshalToSign() ([]byte, error)
func (*SubCIDOffer) UnmarshalJSON ¶
func (c *SubCIDOffer) UnmarshalJSON(p []byte) error
UnmarshalJSON is used to unmarshal bytes into offer.
func (*SubCIDOffer) Verify ¶
func (c *SubCIDOffer) Verify(pubKey *fcrcrypto.KeyPair) error
Verify is used to verify the offer with a given public key.
func (*SubCIDOffer) VerifyMerkleProof ¶
func (c *SubCIDOffer) VerifyMerkleProof() error
VerifyMerkleProof is used to verify the sub cid is part of the merkle trie