api

package
v0.17.5 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2024 License: BSD-3-Clause Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bool

func Bool(v bool) (p *bool)

Bool is a helper routine that allocates a new bool value to store v and returns a pointer to it.

func IsHTTPStatusErrorCode added in v0.8.5

func IsHTTPStatusErrorCode(err error, code int) bool

IsHTTPStatusErrorCode return whether the error is HTTPStatusError with a specific HTTP status code.

Types

type Account added in v0.16.0

type Account struct {
	Balance                  *bigint.BigInt `json:"balance"`
	ConsumedBalance          *bigint.BigInt `json:"consumedBalance"`
	GhostBalance             *bigint.BigInt `json:"ghostBalance"`
	ReservedBalance          *bigint.BigInt `json:"reservedBalance"`
	ShadowReservedBalance    *bigint.BigInt `json:"shadowReservedBalance"`
	SurplusBalance           *bigint.BigInt `json:"surplusBalance"`
	ThresholdReceived        *bigint.BigInt `json:"thresholdReceived"`
	ThresholdGiven           *bigint.BigInt `json:"thresholdGiven"`
	CurrentThresholdReceived *bigint.BigInt `json:"currentThresholdReceived"`
	CurrentThresholdGiven    *bigint.BigInt `json:"currentThresholdGiven"`
}

Account represents node's account with a given peer

type Accounting added in v0.16.0

type Accounting struct {
	Accounting map[string]Account `json:"peerData"`
}

Accounting represents node's accounts with all peers

type ActGranteesResponse added in v0.17.3

type ActGranteesResponse struct {
	Reference      swarm.Address `json:"ref"`
	HistoryAddress swarm.Address `json:"historyref"`
}

type ActService added in v0.17.3

type ActService service

func (*ActService) AddGrantees added in v0.17.3

func (a *ActService) AddGrantees(ctx context.Context, data io.Reader, o UploadOptions) (ActGranteesResponse, error)

func (*ActService) Download added in v0.17.3

func (a *ActService) Download(ctx context.Context, addr swarm.Address, opts *DownloadOptions) (resp io.ReadCloser, err error)

func (*ActService) GetGrantees added in v0.17.3

func (a *ActService) GetGrantees(ctx context.Context, addr swarm.Address) (resp io.ReadCloser, err error)

func (*ActService) PatchGrantees added in v0.17.3

func (a *ActService) PatchGrantees(ctx context.Context, data io.Reader, addr swarm.Address, haddr swarm.Address, batchID string) (ActGranteesResponse, error)

func (*ActService) Upload added in v0.17.3

func (a *ActService) Upload(ctx context.Context, name string, data io.Reader, o UploadOptions) (ActUploadResponse, error)

type ActUploadResponse added in v0.17.3

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

type Addresses added in v0.16.0

type Addresses struct {
	Ethereum     string        `json:"ethereum"`
	Overlay      swarm.Address `json:"overlay"`
	PublicKey    string        `json:"publicKey"`
	Underlay     []string      `json:"underlay"`
	PSSPublicKey string        `json:"pssPublicKey"`
}

Addresses represents node's addresses

type Balance added in v0.16.0

type Balance struct {
	Balance *bigint.BigInt `json:"balance"`
	Peer    string         `json:"peer"`
}

Balance represents node's balance with a peer

type Balances added in v0.16.0

type Balances struct {
	Balances []Balance `json:"balances"`
}

Balances represents node's balances with all peers

type Bin added in v0.16.0

type Bin struct {
	Population        int        `json:"population"`
	Connected         int        `json:"connected"`
	DisconnectedPeers []PeerInfo `json:"disconnectedPeers"`
	ConnectedPeers    []PeerInfo `json:"connectedPeers"`
}

Bin represents Kademlia bin

type BytesService added in v0.8.5

type BytesService service

BytesService represents Bee's Bytes service

func (*BytesService) Download added in v0.8.5

func (b *BytesService) Download(ctx context.Context, a swarm.Address, opts *DownloadOptions) (resp io.ReadCloser, err error)

Download downloads data from the node

func (*BytesService) Upload added in v0.8.5

Upload uploads bytes to the node

type BytesUploadResponse added in v0.8.5

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

BytesUploadResponse represents Upload's response

type CashoutStatusResponse added in v0.16.0

type CashoutStatusResponse struct {
	Peer            swarm.Address        `json:"peer"`
	Cheque          *Cheque              `json:"lastCashedCheque"`
	TransactionHash *string              `json:"transactionHash"`
	Result          *CashoutStatusResult `json:"result"`
	UncashedAmount  *bigint.BigInt       `json:"uncashedAmount"`
}

type CashoutStatusResult added in v0.16.0

type CashoutStatusResult struct {
	Recipient  string         `json:"recipient"`
	LastPayout *bigint.BigInt `json:"lastPayout"`
	Bounced    bool           `json:"bounced"`
}

type Cheque added in v0.16.0

type Cheque struct {
	Beneficiary string         `json:"beneficiary"`
	Chequebook  string         `json:"chequebook"`
	Payout      *bigint.BigInt `json:"payout"`
}

type ChequebookBalanceResponse added in v0.16.0

type ChequebookBalanceResponse struct {
	TotalBalance     *bigint.BigInt `json:"totalBalance"`
	AvailableBalance *bigint.BigInt `json:"availableBalance"`
}

type ChunksService added in v0.8.5

type ChunksService service

ChunksService represents Bee's Chunks service

func (*ChunksService) Download added in v0.8.5

func (c *ChunksService) Download(ctx context.Context, a swarm.Address, targets string, opts *DownloadOptions) (resp io.ReadCloser, err error)

Download downloads data from the node

func (*ChunksService) Upload added in v0.8.5

Upload uploads chunks to the node

type ChunksUploadResponse added in v0.8.5

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

ChunksUploadResponse represents Upload's response

type Client

type Client struct {

	// Services that API provides.
	Act         *ActService
	Bytes       *BytesService
	Chunks      *ChunksService
	Files       *FilesService
	Dirs        *DirsService
	Pinning     *PinningService
	Tags        *TagsService
	PSS         *PSSService
	SOC         *SOCService
	Stewardship *StewardshipService
	Node        *NodeService
	PingPong    *PingPongService
	Postage     *PostageService
	Stake       *StakingService
	// contains filtered or unexported fields
}

Client manages communication with the Bee API.

func NewClient

func NewClient(baseURL *url.URL, o *ClientOptions) (c *Client)

NewClient constructs a new Client.

type ClientOptions

type ClientOptions struct {
	HTTPClient *http.Client
}

ClientOptions holds optional parameters for the Client.

type DebugStore added in v0.16.0

type DebugStore map[string]int

DebugStore represents DebugStore's response

type DebugStoreService added in v0.16.0

type DebugStoreService service

DebugStoreService represents Bee's debug store service

func (*DebugStoreService) GetDebugStore added in v0.16.0

func (d *DebugStoreService) GetDebugStore(ctx context.Context) (DebugStore, error)

GetDebugStore gets db indices

type DirsService added in v0.8.5

type DirsService service

DirsService represents Bee's Dirs service

func (*DirsService) Download added in v0.8.5

func (s *DirsService) Download(ctx context.Context, a swarm.Address, path string) (resp io.ReadCloser, err error)

Download downloads data from the node

func (*DirsService) Upload added in v0.8.5

func (s *DirsService) Upload(ctx context.Context, data io.Reader, size int64, o UploadOptions) (resp DirsUploadResponse, err error)

Upload uploads TAR collection to the node

type DirsUploadResponse added in v0.8.5

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

DirsUploadResponse represents Upload's response

type DownloadOptions added in v0.14.1

type DownloadOptions struct {
	Act                    *bool
	ActHistoryAddress      *swarm.Address
	ActPublicKey           *swarm.Address
	ActTimestamp           *uint64
	Cache                  *bool
	RedundancyFallbackMode *bool
}

type FilesService added in v0.8.5

type FilesService service

FilesService represents Bee's Files service

func (*FilesService) Download added in v0.8.5

func (f *FilesService) Download(ctx context.Context, a swarm.Address, opts *DownloadOptions) (resp io.ReadCloser, err error)

Download downloads data from the node

func (*FilesService) Upload added in v0.8.5

func (f *FilesService) Upload(ctx context.Context, name string, data io.Reader, size int64, o UploadOptions) (resp FilesUploadResponse, err error)

Upload uploads files to the node

type FilesUploadResponse added in v0.8.5

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

FilesUploadResponse represents Upload's response

type HTTPStatusError added in v0.8.5

type HTTPStatusError struct {
	Code int
}

HTTPStatusError represents the error derived from the HTTP response status code.

func NewHTTPStatusError added in v0.8.5

func NewHTTPStatusError(code int) *HTTPStatusError

NewHTTPStatusError creates a new instance of HTTPStatusError based on the provided code.

func (*HTTPStatusError) Error added in v0.8.5

func (e *HTTPStatusError) Error() string

type Health added in v0.16.0

type Health struct {
	Status string `json:"status"`
}

Health represents node's health

type MetricSnapshotView added in v0.16.0

type MetricSnapshotView struct {
	LastSeenTimestamp          int64   `json:"lastSeenTimestamp"`
	SessionConnectionRetry     uint64  `json:"sessionConnectionRetry"`
	ConnectionTotalDuration    float64 `json:"connectionTotalDuration"`
	SessionConnectionDuration  float64 `json:"sessionConnectionDuration"`
	SessionConnectionDirection string  `json:"sessionConnectionDirection"`
	LatencyEWMA                int64   `json:"latencyEWMA"`
	Reachability               string  `json:"reachability"`
}

MetricSnapshotView represents snapshot of metrics counters in more human readable form.

type NodeService added in v0.16.0

type NodeService service

NodeService represents Bee's Node service

func (*NodeService) Accounting added in v0.16.0

func (n *NodeService) Accounting(ctx context.Context) (resp Accounting, err error)

Accounting returns node's accounts with all peers

func (*NodeService) Addresses added in v0.16.0

func (n *NodeService) Addresses(ctx context.Context) (resp Addresses, err error)

Addresses returns node's addresses

func (*NodeService) Balance added in v0.16.0

func (n *NodeService) Balance(ctx context.Context, a swarm.Address) (resp Balance, err error)

Balance returns node's balance with a given peer

func (*NodeService) Balances added in v0.16.0

func (n *NodeService) Balances(ctx context.Context) (resp Balances, err error)

Balances returns node's balances with all peers

func (*NodeService) Cashout added in v0.16.0

func (n *NodeService) Cashout(ctx context.Context, a swarm.Address) (resp TransactionHashResponse, err error)

func (*NodeService) CashoutStatus added in v0.16.0

func (n *NodeService) CashoutStatus(ctx context.Context, a swarm.Address) (resp CashoutStatusResponse, err error)

func (*NodeService) ChequebookBalance added in v0.16.0

func (n *NodeService) ChequebookBalance(ctx context.Context) (resp ChequebookBalanceResponse, err error)

func (*NodeService) HasChunk added in v0.16.0

func (n *NodeService) HasChunk(ctx context.Context, a swarm.Address) (bool, error)

HasChunk returns true/false if node has a chunk

func (*NodeService) Health added in v0.16.0

func (n *NodeService) Health(ctx context.Context) (resp Health, err error)

Health returns node's health

func (*NodeService) Peers added in v0.16.0

func (n *NodeService) Peers(ctx context.Context) (resp Peers, err error)

Peers returns node's peers

func (*NodeService) Readiness added in v0.16.0

func (n *NodeService) Readiness(ctx context.Context) (resp Readiness, err error)

Readiness returns node's readiness

func (*NodeService) Settlement added in v0.16.0

func (n *NodeService) Settlement(ctx context.Context, a swarm.Address) (resp Settlement, err error)

Settlement returns node's settlement with a given peer

func (*NodeService) Settlements added in v0.16.0

func (n *NodeService) Settlements(ctx context.Context) (resp Settlements, err error)

Settlements returns node's settlements with all peers

func (*NodeService) Topology added in v0.16.0

func (n *NodeService) Topology(ctx context.Context) (resp Topology, err error)

Topology returns Kademlia topology

func (*NodeService) Wallet added in v0.16.0

func (n *NodeService) Wallet(ctx context.Context) (resp Wallet, err error)

Wallet returns the wallet state

func (*NodeService) Withdraw added in v0.16.0

func (n *NodeService) Withdraw(ctx context.Context, token, addr string, amount int64) (tx common.Hash, err error)

Withdraw calls wallet withdraw endpoint

type PSSService added in v0.8.5

type PSSService service

PSSService represents Bee's PSS service

func (*PSSService) SendMessage added in v0.8.5

func (p *PSSService) SendMessage(ctx context.Context, nodeAddress swarm.Address, nodePublicKey string, topic string, prefix int, data io.Reader, batchID string) error

Sends a PSS message to a recipienct with a specific topic

type Peer added in v0.16.0

type Peer struct {
	Address swarm.Address `json:"address"`
}

Peer represents node's peer

type PeerInfo added in v0.16.0

type PeerInfo struct {
	Address swarm.Address       `json:"address"`
	Metrics *MetricSnapshotView `json:"metrics,omitempty"`
}

PeerInfo is a view of peer information exposed to a user.

type Peers added in v0.16.0

type Peers struct {
	Peers []Peer `json:"peers"`
}

Peers represents node's peers

type PingPongService

type PingPongService service

PingPongService represents Bee's PingPong service

func (*PingPongService) Ping

func (p *PingPongService) Ping(ctx context.Context, a swarm.Address) (resp Pong, err error)

Ping pings given node

type PinningService added in v0.8.5

type PinningService service

PinningService represents Bee's Pin service

func (*PinningService) GetPinnedRootHash added in v0.8.5

func (ps *PinningService) GetPinnedRootHash(ctx context.Context, ref swarm.Address) (swarm.Address, error)

GetPinnedRootHash determines if the root hash of given reference is pinned by returning its reference.

func (*PinningService) GetPins added in v0.8.5

func (ps *PinningService) GetPins(ctx context.Context) ([]swarm.Address, error)

GetPins returns all references of pinned root hashes.

func (*PinningService) PinRootHash added in v0.8.5

func (ps *PinningService) PinRootHash(ctx context.Context, ref swarm.Address) error

PinRootHash pins root hash of given reference.

func (*PinningService) UnpinRootHash added in v0.8.5

func (ps *PinningService) UnpinRootHash(ctx context.Context, ref swarm.Address) error

UnpinRootHash unpins root hash of given reference.

type Pong

type Pong struct {
	RTT string `json:"rtt"`
}

Pong represents Ping's response

type PostageService added in v0.16.0

type PostageService service

PostageService represents Bee's Postage service

func (*PostageService) CreatePostageBatch added in v0.16.0

func (p *PostageService) CreatePostageBatch(ctx context.Context, amount int64, depth uint64, label string) (batchID string, err error)

Sends a create postage request to a node that returns the batchID

func (*PostageService) DilutePostageBatch added in v0.16.0

func (p *PostageService) DilutePostageBatch(ctx context.Context, batchID string, newDepth uint64, gasPrice string) (err error)

Sends a dilute batch request to a node that returns the batchID

func (*PostageService) PostageBatches added in v0.16.0

func (p *PostageService) PostageBatches(ctx context.Context) ([]PostageStampResponse, error)

Fetches the list postage stamp batches

func (*PostageService) PostageStamp added in v0.16.0

func (p *PostageService) PostageStamp(ctx context.Context, batchID string) (PostageStampResponse, error)

func (*PostageService) ReserveState added in v0.16.0

func (p *PostageService) ReserveState(ctx context.Context) (ReserveState, error)

Returns the batchstore reservestate of the node

func (*PostageService) TopUpPostageBatch added in v0.16.0

func (p *PostageService) TopUpPostageBatch(ctx context.Context, batchID string, amount int64, gasPrice string) (err error)

Sends a topup batch request to a node that returns the batchID

type PostageStampResponse added in v0.16.0

type PostageStampResponse struct {
	BatchID       string         `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"`
}

type Readiness added in v0.16.0

type Readiness struct {
	Status string `json:"status"`
}

Readiness represents node's readiness

type ReserveState added in v0.16.0

type ReserveState struct {
	Radius        uint8 `json:"radius"`
	StorageRadius uint8 `json:"storageRadius"`
}

func (ReserveState) String added in v0.16.0

func (rs ReserveState) String() string

type SOCService added in v0.8.5

type SOCService service

PSSService represents Bee's PSS service

func (*SOCService) UploadSOC added in v0.8.5

func (p *SOCService) UploadSOC(ctx context.Context, owner, ID, signature string, data io.Reader, batchID string) (*SocResponse, error)

Sends a PSS message to a recipienct with a specific topic

type Settlement added in v0.16.0

type Settlement struct {
	Peer     string         `json:"peer"`
	Received *bigint.BigInt `json:"received"`
	Sent     *bigint.BigInt `json:"sent"`
}

Settlement represents node's settlement with a peer

type Settlements added in v0.16.0

type Settlements struct {
	Settlements   []Settlement   `json:"settlements"`
	TotalReceived *bigint.BigInt `json:"totalReceived"`
	TotalSent     *bigint.BigInt `json:"totalSent"`
}

Settlements represents node's settlements with all peers

type SocResponse added in v0.8.5

type SocResponse struct {
	Reference swarm.Address
}

type StakingService added in v0.16.0

type StakingService service

StakingService represents Bee's staking service

func (*StakingService) DepositStake added in v0.16.0

func (s *StakingService) DepositStake(ctx context.Context, amount *big.Int) (txHash string, err error)

DepositStake deposits stake

func (*StakingService) GetStakedAmount added in v0.16.0

func (s *StakingService) GetStakedAmount(ctx context.Context) (stakedAmount *big.Int, err error)

GetStakedAmount gets stake

func (*StakingService) GetWithdrawableStake added in v0.17.4

func (s *StakingService) GetWithdrawableStake(ctx context.Context) (withdrawableStake *big.Int, err error)

GetWithdrawableStake gets stake

func (*StakingService) MigrateStake added in v0.17.1

func (s *StakingService) MigrateStake(ctx context.Context) (txHash string, err error)

MigrateStake withdraws stake

type StewardshipService added in v0.8.5

type StewardshipService service

StewardshipService represents Bee's Stewardship service.

func (*StewardshipService) IsRetrievable added in v0.8.5

func (ss *StewardshipService) IsRetrievable(ctx context.Context, ref swarm.Address) (bool, error)

IsRetrievable checks whether the content on the given address is retrievable.

func (*StewardshipService) Reupload added in v0.8.5

func (ss *StewardshipService) Reupload(ctx context.Context, ref swarm.Address) error

Reupload re-uploads root hash and all of its underlying associated chunks to the network.

type TagResponse added in v0.8.5

type TagResponse struct {
	Split     uint64        `json:"split"`
	Seen      uint64        `json:"seen"`
	Stored    uint64        `json:"stored"`
	Sent      uint64        `json:"sent"`
	Synced    uint64        `json:"synced"`
	Uid       uint64        `json:"uid"`
	Address   swarm.Address `json:"address"`
	StartedAt time.Time     `json:"startedAt"`
}

type TagsService added in v0.8.5

type TagsService service

TagsService represents Bee's Tag service

func (*TagsService) CreateTag added in v0.8.5

func (p *TagsService) CreateTag(ctx context.Context) (resp TagResponse, err error)

CreateTag creates new tag

func (*TagsService) GetTag added in v0.8.5

func (p *TagsService) GetTag(ctx context.Context, tagUID uint64) (resp TagResponse, err error)

GetTag gets a new tag

func (*TagsService) WaitSync added in v0.8.5

func (p *TagsService) WaitSync(ctx context.Context, tagUID uint64) (err error)

type Topology added in v0.16.0

type Topology struct {
	BaseAddr            swarm.Address  `json:"baseAddr"`
	Population          int            `json:"population"`
	Connected           int            `json:"connected"`
	Timestamp           time.Time      `json:"timestamp"`
	NnLowWatermark      int            `json:"nnLowWatermark"`
	Depth               int            `json:"depth"`
	Bins                map[string]Bin `json:"bins"`
	LightNodes          Bin            `json:"lightNodes"`
	Reachability        string         `json:"reachability"`        // current reachability status
	NetworkAvailability string         `json:"networkAvailability"` // network availability
}

Topology represents Kademlia topology

type TransactionHashResponse added in v0.16.0

type TransactionHashResponse struct {
	TransactionHash string `json:"transactionHash"`
}

type UploadOptions added in v0.8.5

type UploadOptions struct {
	Act               bool
	Pin               bool
	Tag               uint64
	BatchID           string
	Direct            bool
	ActHistoryAddress swarm.Address
}

type Wallet added in v0.16.0

type Wallet struct {
	BZZ         *bigint.BigInt `json:"bzzBalance"`
	NativeToken *bigint.BigInt `json:"nativeTokenBalance"`
}

Jump to

Keyboard shortcuts

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