cidoffer

package
v0.0.0-...-12ab560 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 29, 2021 License: Apache-2.0 Imports: 10 Imported by: 5

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

View Source
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) GetCIDs

func (c *CIDOffer) GetCIDs() []cid.ContentID

GetCIDs returns the cids of this offer.

func (*CIDOffer) GetExpiry

func (c *CIDOffer) GetExpiry() int64

GetExpiry returns the expiry of this offer.

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) GetPrice

func (c *CIDOffer) GetPrice() uint64

GetPrice returns the price of this offer.

func (*CIDOffer) GetProviderID

func (c *CIDOffer) GetProviderID() *nodeid.NodeID

GetProviderID returns the provider ID of this offer.

func (*CIDOffer) GetQoS

func (c *CIDOffer) GetQoS() uint64

GetQoS returns the quality of service of this offer.

func (*CIDOffer) GetSignature

func (c *CIDOffer) GetSignature() string

GetSignature returns the signature of this offer.

func (*CIDOffer) HasExpired

func (c *CIDOffer) HasExpired() bool

HasExpired returns true if the offer expiry date is in the past.

func (CIDOffer) MarshalJSON

func (c CIDOffer) MarshalJSON() ([]byte, error)

MarshalJSON is used to marshal offer into bytes.

func (CIDOffer) MarshalToSign

func (c CIDOffer) MarshalToSign() ([]byte, error)

MarshalJSON is used to marshal offer into bytes.

func (*CIDOffer) SetSignature

func (c *CIDOffer) SetSignature(s string)

SetSignature sets the signature of this offer.

func (*CIDOffer) Sign

func (c *CIDOffer) Sign(privKey *fcrcrypto.KeyPair, keyVer *fcrcrypto.KeyVersion) error

Sign is used to sign the offer with a given private key and a key version.

func (*CIDOffer) UnmarshalJSON

func (c *CIDOffer) UnmarshalJSON(p []byte) error

UnmarshalJSON is used to unmarshal bytes into offer.

func (*CIDOffer) Verify

func (c *CIDOffer) Verify(pubKey *fcrcrypto.KeyPair) error

Verify is used to verify the offer with a given public key.

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL