dataquery

package
v1.4.3 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2024 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// ProtocolID represents the response protocol version
	ProtocolID = "/ffg/dataquery_response/1.0.0"

	// DataQueryResponseTransferProtocolID is a protocol to handle sending data query responses to a querying node.
	// this protocol will be mostly used by verifiers to act as a proxy so node's which cant be dialed back by the
	// file hoster can pull the data query response from the verifiers.
	DataQueryResponseTransferProtocolID = "/ffg/dataquery_response_transfer/1.0.0"
)

Variables

This section is empty.

Functions

func VerifyDataFromPeer

func VerifyDataFromPeer(data []byte, signature []byte, peerID peer.ID, pubKeyData []byte) error

VerifyDataFromPeer given a pubkey and signature + data returns the verification result.

Types

type Interface

type Interface interface {
	PutQueryHistory(key string, val messages.DataQueryRequest, localTimestamp int64) error
	GetQueryHistory(key string) (messages.DataQueryRequest, bool)
	PutQueryResponse(key string, val messages.DataQueryResponse)
	GetQueryResponse(key string) ([]messages.DataQueryResponse, bool)
	SendDataQueryResponse(ctx context.Context, peerID peer.ID, payload *messages.DataQueryResponseProto) error
	RequestDataQueryResponseTransfer(ctx context.Context, peerID peer.ID, request *messages.DataQueryResponseTransferProto) error
	PurgeQueryHistory() error
}

Interface represents a data quertier.

type Protocol

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

Protocol wraps the data query protocols and handlers

func New

func New(h host.Host) (*Protocol, error)

New creates a data query protocol.

func (*Protocol) GetQueryHistory

func (d *Protocol) GetQueryHistory(key string) (messages.DataQueryRequest, bool)

GetQueryHistory gets a val from history.

func (*Protocol) GetQueryResponse

func (d *Protocol) GetQueryResponse(key string) ([]messages.DataQueryResponse, bool)

GetQueryResponse gets a val from responses

func (*Protocol) PurgeQueryHistory added in v1.1.18

func (d *Protocol) PurgeQueryHistory() error

PurgeQueryHistory purges/deletes all queries that are more than some minutes old.

func (*Protocol) PutQueryHistory

func (d *Protocol) PutQueryHistory(key string, val messages.DataQueryRequest, localTimestamp int64) error

PutQueryHistory puts the query history. localTimestamp is the machine's timestamp which will be used to purge old queries automatically after they are expired.

func (*Protocol) PutQueryResponse

func (d *Protocol) PutQueryResponse(key string, val messages.DataQueryResponse)

PutQueryResponse put into responses.

func (*Protocol) RequestDataQueryResponseTransfer

func (d *Protocol) RequestDataQueryResponseTransfer(ctx context.Context, peerID peer.ID, request *messages.DataQueryResponseTransferProto) error

RequestDataQueryResponseTransfer requests a data query response transfer from a peer, mostly a verifier.

func (*Protocol) SendDataQueryResponse

func (d *Protocol) SendDataQueryResponse(ctx context.Context, peerID peer.ID, payload *messages.DataQueryResponseProto) error

SendDataQueryResponse sends back the response to initiator

Jump to

Keyboard shortcuts

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