client

package
v0.0.0-...-e766b56 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2023 License: BSD-3-Clause Imports: 20 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = fmt.Errorf("not found")

Functions

func FeedUpdateReference

func FeedUpdateReference(owner common.Address, topic Topic, index uint64) ([]byte, error)

func OwnerFromKey

func OwnerFromKey(key *ecdsa.PrivateKey) (common.Address, error)

func PayloadStripTime

func PayloadStripTime(payload []byte) []byte

func PayloadWithTime

func PayloadWithTime(payload []byte, t time.Time) []byte

func RawDataFromSocResp

func RawDataFromSocResp(resp []byte) []byte

Types

type BatchID

type BatchID string // hex encoded [32]byte

type BuyStampResponse

type BuyStampResponse struct {
	BatchID BatchID `json:"batchID"`
}

type Client

type Client interface {
	// Stamps fetches purchased stamp batches via /stamps endpoint.
	Stamps(
		ctx context.Context,
	) (StampsResponse, error)

	// BuyStamp buys a new postage stamp batch.
	BuyStamp(
		ctx context.Context,
		amount *big.Int,
		depth uint8,
		immutable bool,
	) (BuyStampResponse, error)

	// UploadBytes arbitrary bytes data via /bytes endpoint.
	UploadBytes(
		ctx context.Context,
		data []byte,
		batchID BatchID,
	) (UploadResponse, error)

	// DownloadBytes bytes data via /bytes endpoint.
	DownloadBytes(
		ctx context.Context,
		addr swarm.Address,
	) (io.ReadCloser, error)

	// DownloadChunk downloads Chunk via /chunks endpoint.
	DownloadChunk(
		ctx context.Context,
		addr swarm.Address,
	) (io.ReadCloser, error)

	// UploadSoc uploads Single Owner Chunk data via /soc endpoint.
	UploadSoc(
		ctx context.Context,
		owner common.Address,
		id SocID,
		data []byte,
		signature SocSignature,
		batchID BatchID,
	) (UploadSocResponse, error)

	// FeedIndexLatest returns the most recent feed's index from /feeds/owner/topic.
	FeedIndexLatest(
		ctx context.Context,
		owner common.Address,
		topic Topic,
	) (FeedIndexResponse, error)
}

Client is interface for communicating with Bee node API.

func NewClient

func NewClient(cfg Config) Client

type Config

type Config struct {
	NodeURL string
}

type FeedIndexResponse

type FeedIndexResponse struct {
	Reference swarm.Address `json:"reference"`
	Current   uint64        // passed via header
	Next      uint64        // passed via header
}

type SocID

type SocID = soc.ID

func FeedID

func FeedID(topic Topic, index uint64) (SocID, error)

type SocSignature

type SocSignature []byte // [65]bytes (swarm.SocSignatureSize)

func SignSocData

func SignSocData(
	id SocID,
	payload []byte,
	privKey *ecdsa.PrivateKey,
) ([]byte, SocSignature, error)

type Stamp

type Stamp struct {
	BatchID       BatchID        `json:"batchID"`
	Utilization   uint32         `json:"utilization"`
	Usable        bool           `json:"usable"`
	Label         string         `json:"label"`
	Depth         uint8          `json:"depth"`
	Amount        *bigint.BigInt `json:"amount"`
	BucketDepth   uint8          `json:"bucketDepth"`
	BlockNumber   uint64         `json:"blockNumber"`
	ImmutableFlag bool           `json:"immutableFlag"`
	Exists        bool           `json:"exists"`
	BatchTTL      int64          `json:"batchTTL"`
	Expired       bool           `json:"expired"`
}

type StampsResponse

type StampsResponse struct {
	Stamps []Stamp `json:"stamps"`
}

type Topic

type Topic []byte

type UploadResponse

type UploadResponse struct {
	Reference swarm.Address `json:"reference"`
}

type UploadSocResponse

type UploadSocResponse struct {
	Reference swarm.Address `json:"reference"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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