fcrmessages

package
v0.0.0-...-7a4b066 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2021 License: Apache-2.0 Imports: 9 Imported by: 2

Documentation

Overview

Package fcrmessages - stores all the p2p messages.

Package fcrmessages - stores all the p2p messages.

Package fcrmessages - stores all the p2p messages.

Package fcrmessages - stores all the p2p messages.

Package fcrmessages - stores all the p2p messages.

Package fcrmessages - stores all the p2p messages.

Package fcrmessages - stores all the messages.

Package fcrmessages - stores all the messages.

Package fcrmessages - stores all the p2p messages.

Package fcrmessages - stores all the p2p messages.

Package fcrmessages - stores all the p2p messages.

Package fcrmessages - stores all the p2p messages.

Index

Constants

View Source
const (
	StandardOfferDiscoveryRequestType = byte(0)
	DHTOfferDiscoveryRequestType      = byte(1)
	OfferPublishRequestType           = byte(2)
	EstablishmentRequestType          = byte(3)
	DataRetrievalRequestType          = byte(4) // Placeholder, TBD
	PaymentProxyRequestType           = byte(5) // Placeholder, TBD
)

Variables

This section is empty.

Functions

func DecodeDHTOfferDiscoveryRequest

func DecodeDHTOfferDiscoveryRequest(fcrMsg *FCRReqMsg) (
	uint64,
	string,
	*cid.ContentID,
	uint32,
	uint32,
	string,
	string,
	error,
)

DecodeDHTOfferDiscoveryRequest is used to get the fields from FCRMessage of dhtOfferDiscoveryRequestJson It returns the nonce, nodeID, pieceCID, numDHT, maxOfferRequestedPerDHT, account address and voucher.

func DecodeDHTOfferDiscoveryResponse

func DecodeDHTOfferDiscoveryResponse(fcrMsg *FCRACKMsg) (
	uint64,
	map[string]FCRACKMsg,
	string,
	error,
)

DecodeDHTOfferDiscoveryResponse is used to get the fields from FCRMessage of dhtOfferDiscoveryResponseJson. It returns nonce, a map of contacted nodes -> contacted messages, refund account address and voucher.

func DecodeDataRetrievalRequest

func DecodeDataRetrievalRequest(fcrMsg *FCRReqMsg) (
	uint64,
	string,
	*cidoffer.SubCIDOffer,
	string,
	string,
	error,
)

DecodeDataRetrievalRequest is used to get the fields from FCRMessage of dataRetrievalRequest. It returns the nonce, offer, account address and voucher.

func DecodeDataRetrievalResponse

func DecodeDataRetrievalResponse(fcrMsg *FCRACKMsg) (
	uint64,
	string,
	[]byte,
	error,
)

DecodeDataRetrievalResponse is used to get the fields from FCRMessage of dataRetrievalResponseJson. It returns the nonce, tag, and file data and error.

func DecodeEstablishmentRequest

func DecodeEstablishmentRequest(fcrMsg *FCRReqMsg) (
	uint64,
	string,
	string,
	error,
)

DecodeEstablishmentRequest is used to get the fields from FCRMessage of establishmentRequestJson It returns the nonce and challenge string in this establishment request.

func DecodeEstablishmentResponse

func DecodeEstablishmentResponse(fcrMsg *FCRACKMsg) (
	uint64,
	string,
	error,
)

DecodeEstablishmentResponse is used to get the fields from FCRMessage of establishmentResponseJson It returns the nonce and challenge string in this establishment request.

func DecodeOfferPublishRequest

func DecodeOfferPublishRequest(fcrMsg *FCRReqMsg) (
	uint64,
	string,
	*cidoffer.CIDOffer,
	error,
)

DecodeOfferPublishRequest is used to get the fields from FCRMessage of offerPublishRequestJson. It returns the nonce, nodeID and the offer.

func DecodeStandardOfferDiscoveryRequest

func DecodeStandardOfferDiscoveryRequest(fcrMsg *FCRReqMsg) (
	uint64,
	string,
	*cid.ContentID,
	uint32,
	string,
	string,
	error,
)

DecodeStandardOfferDiscoveryRequest is used to get the fields from FCRMessage of standardOfferDiscoveryRequestJson. It returns the nonce, nodeID, pieceCID, maxOfferRequested, account address and voucher.

func DecodeStandardOfferDiscoveryResponse

func DecodeStandardOfferDiscoveryResponse(fcrMsg *FCRACKMsg) (
	uint64,
	[]cidoffer.SubCIDOffer,
	string,
	error,
)

DecodeStandardOfferDiscoveryResponse is used to get the fields from FCRMessage of standardOfferDiscoveryResponseJson. It returns nonce, a list of offers, refund account address and voucher.

Types

type FCRACKMsg

type FCRACKMsg struct {
	// contains filtered or unexported fields
}

FCRACKMsg is the response used in communication between filecoin retrieval entities.

func CreateFCRACKErrorMsg

func CreateFCRACKErrorMsg(nonce uint64, err error) *FCRACKMsg

CreateFCRACKErrorMsg is used to create an unsigned error message

func CreateFCRACKMsg

func CreateFCRACKMsg(nonce uint64, msgBody []byte) *FCRACKMsg

CreateFCRACKMsg is used to create an unsigned ack message

func EncodeDHTOfferDiscoveryResponse

func EncodeDHTOfferDiscoveryResponse(
	nonce uint64,
	contacted map[string]*FCRACKMsg,
	refundVoucher string,
) (*FCRACKMsg, error)

EncodeDHTOfferDiscoveryResponse is used to get the FCRMessage of dhtOfferDiscoveryResponseJson.

func EncodeDataRetrievalResponse

func EncodeDataRetrievalResponse(
	nonce uint64,
	tag string,
	data []byte,
) (*FCRACKMsg, error)

EncodeDataRetrievalResponse is used to get the FCRMessage of dataRetrievalResponseJson.

func EncodeEstablishmentResponse

func EncodeEstablishmentResponse(
	nonce uint64,
	challenge string,
) (*FCRACKMsg, error)

EncodeEstablishmentResponse is used to get the FCRMessage of establishmentResponseJson

func EncodeStandardOfferDiscoveryResponse

func EncodeStandardOfferDiscoveryResponse(
	nonce uint64,
	offers []cidoffer.SubCIDOffer,
	refundVoucher string,
) (*FCRACKMsg, error)

EncodeStandardOfferDiscoveryResponse is used to get the FCRMessage of standardOfferDiscoveryResponseJson.

func (*FCRACKMsg) ACK

func (fcrMsg *FCRACKMsg) ACK() bool

Type is used to get the message type of the message.

func (*FCRACKMsg) Body

func (fcrMsg *FCRACKMsg) Body() []byte

Body is used to get the message body.

func (*FCRACKMsg) Error

func (fcrMsg *FCRACKMsg) Error() string

Error is used to get the error.

func (*FCRACKMsg) FromBytes

func (fcrMsg *FCRACKMsg) FromBytes(data []byte) error

FCRMsgFromBytes converts a bytes to FCRMessage

func (*FCRACKMsg) Nonce

func (fcrMsg *FCRACKMsg) Nonce() uint64

Nonce is used to get the nonce of the message.

func (*FCRACKMsg) Sign

func (fcrMsg *FCRACKMsg) Sign(privKey string, keyVer byte) error

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

func (*FCRACKMsg) Signature

func (fcrMsg *FCRACKMsg) Signature() string

Signature is used to get the signature.

func (*FCRACKMsg) ToBytes

func (fcrMsg *FCRACKMsg) ToBytes() ([]byte, error)

FCRMsgToBytes converts a FCRMessage to bytes

func (*FCRACKMsg) Verify

func (fcrMsg *FCRACKMsg) Verify(pubKey string, keyVer byte) error

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

type FCRReqMsg

type FCRReqMsg struct {
	// contains filtered or unexported fields
}

FCRReqMsg is the request used in communication between filecoin retrieval entities.

func CreateFCRReqMsg

func CreateFCRReqMsg(msgType byte, nonce uint64, msgBody []byte) *FCRReqMsg

CreateFCRReqMsg is used to create an unsigned message

func EncodeDHTOfferDiscoveryRequest

func EncodeDHTOfferDiscoveryRequest(
	nonce uint64,
	NodeID string,
	pieceCID *cid.ContentID,
	numDHT uint32,
	maxOfferRequestedPerDHT uint32,
	accountAddr string,
	voucher string,
) (*FCRReqMsg, error)

EncodeDHTOfferDiscoveryRequest is used to get the FCRMessage of dhtOfferDiscoveryRequestJson

func EncodeDataRetrievalRequest

func EncodeDataRetrievalRequest(
	nonce uint64,
	senderID string,
	offer *cidoffer.SubCIDOffer,
	accountAddr string,
	voucher string,
) (*FCRReqMsg, error)

EncodeDataRetrievalRequest is used to get the FCRMessage of dataRetrievalRequest.

func EncodeEstablishmentRequest

func EncodeEstablishmentRequest(
	nonce uint64,
	nodeID string,
	challenge string,
) (*FCRReqMsg, error)

EncodeEstablishmentRequest is used to get the FCRMessage of establishmentRequestJson

func EncodeOfferPublishRequest

func EncodeOfferPublishRequest(
	nonce uint64,
	nodeID string,
	offer *cidoffer.CIDOffer,
) (*FCRReqMsg, error)

EncodeOfferPublishRequest is used to get the FCRMessage of offerPublishRequestJson.

func EncodeStandardOfferDiscoveryRequest

func EncodeStandardOfferDiscoveryRequest(
	nonce uint64,
	NodeID string,
	pieceCID *cid.ContentID,
	maxOfferRequested uint32,
	accountAddr string,
	voucher string,
) (*FCRReqMsg, error)

EncodeStandardOfferDiscoveryRequest is used to get the FCRMessage of standardOfferDiscoveryRequestJson.

func (*FCRReqMsg) Body

func (fcrMsg *FCRReqMsg) Body() []byte

Body is used to get the message body.

func (*FCRReqMsg) FromBytes

func (fcrMsg *FCRReqMsg) FromBytes(data []byte) error

FCRMsgFromBytes converts a bytes to FCRMessage

func (*FCRReqMsg) Nonce

func (fcrMsg *FCRReqMsg) Nonce() uint64

Nonce is used to get the nonce of the message.

func (*FCRReqMsg) Sign

func (fcrMsg *FCRReqMsg) Sign(privKey string, keyVer byte) error

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

func (*FCRReqMsg) Signature

func (fcrMsg *FCRReqMsg) Signature() string

Signature is used to get the signature.

func (*FCRReqMsg) ToBytes

func (fcrMsg *FCRReqMsg) ToBytes() ([]byte, error)

FCRMsgToBytes converts a FCRMessage to bytes

func (*FCRReqMsg) Type

func (fcrMsg *FCRReqMsg) Type() byte

Type is used to get the message type of the message.

func (*FCRReqMsg) Verify

func (fcrMsg *FCRReqMsg) Verify(pubKey string, keyVer byte) error

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

func (*FCRReqMsg) VerifyByID

func (fcrMsg *FCRReqMsg) VerifyByID(id string) error

VerifyByID is used to verify the offer with a given id (hashed public key).

Jump to

Keyboard shortcuts

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