bee

package
v0.3.8 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2020 License: BSD-3-Clause Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MaxChunkSize represents max chunk size in bytes
	MaxChunkSize = 4096
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Addresses added in v0.2.3

type Addresses struct {
	Overlay  swarm.Address
	Underlay []string
}

Addresses represents node's addresses

type AddressesStreamMsg added in v0.2.3

type AddressesStreamMsg struct {
	Addresses Addresses
	Index     int
	Error     error
}

AddressesStreamMsg represents message sent over the AddressStream channel

type Balance added in v0.2.20

type Balance struct {
	Balance int
	Peer    string
}

Balance represents node's balance with peer

type Balances added in v0.2.20

type Balances struct {
	Balances []Balance
}

Balances represents Balances's response

type BalancesStreamMsg added in v0.2.20

type BalancesStreamMsg struct {
	Balances Balances
	Index    int
	Error    error
}

BalancesStreamMsg represents message sent over the BalancesStream channel

type Bin added in v0.2.2

type Bin struct {
	Connected         int
	ConnectedPeers    []swarm.Address
	DisconnectedPeers []swarm.Address
	Population        int
}

Bin represents Kademlia bin

type Chunk

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

Chunk represents Bee chunk

func NewChunk

func NewChunk(data []byte) (Chunk, error)

NewChunk returns new chunk

func NewRandomChunk

func NewRandomChunk(r *rand.Rand) (Chunk, error)

NewRandomChunk returns new pseudorandom chunk

func (*Chunk) Address

func (c *Chunk) Address() swarm.Address

Address returns chunk's address

func (*Chunk) ClosestNode

func (c *Chunk) ClosestNode(nodes []swarm.Address) (closest swarm.Address, err error)

ClosestNode returns chunk's closest node of a given set of nodes

func (*Chunk) Data

func (c *Chunk) Data() []byte

Data returns chunk's data

func (*Chunk) SetAddress added in v0.2.17

func (c *Chunk) SetAddress() error

SetAddress calculates the address of a chunk and assign's it to address field

func (*Chunk) Size

func (c *Chunk) Size() int

Size returns chunk size

func (*Chunk) Span added in v0.2.7

func (c *Chunk) Span() int

Span returns chunk span

type Cluster

type Cluster struct {
	Nodes []Node
	// contains filtered or unexported fields
}

Cluster represents cluster of Bee nodes

func NewCluster

func NewCluster(o ClusterOptions) (c Cluster, err error)

NewCluster returns new cluster

func (*Cluster) AddNodes added in v0.2.12

func (c *Cluster) AddNodes(count int) (err error)

AddNodes adds new nodes to the cluster

func (*Cluster) Addresses added in v0.2.3

func (c *Cluster) Addresses(ctx context.Context) (addrs []Addresses, err error)

Addresses returns ordered list of addresses of all nodes in the cluster

func (*Cluster) AddressesStream added in v0.2.3

func (c *Cluster) AddressesStream(ctx context.Context) <-chan AddressesStreamMsg

AddressesStream returns stream of addresses of all nodes in the cluster

func (*Cluster) Balances added in v0.2.20

func (c *Cluster) Balances(ctx context.Context) (balances map[string]map[string]int, err error)

Balances returns balances of all nodes in the cluster

func (*Cluster) BalancesStream added in v0.2.20

func (c *Cluster) BalancesStream(ctx context.Context) <-chan BalancesStreamMsg

BalancesStream returns stream of balances of all nodes in the cluster

func (*Cluster) GlobalReplicationFactor added in v0.2.12

func (c *Cluster) GlobalReplicationFactor(ctx context.Context, a swarm.Address) (int, error)

GlobalReplicationFactor returns the total number of nodes that contain given chunk

func (*Cluster) HasChunkStream added in v0.2.12

func (c *Cluster) HasChunkStream(ctx context.Context, a swarm.Address) <-chan HasChunkStreamMsg

HasChunkStream returns stream of HasChunk requests for all nodes in the cluster

func (*Cluster) Overlays

func (c *Cluster) Overlays(ctx context.Context) (overlays []swarm.Address, err error)

Overlays returns ordered list of overlay addresses of all nodes in the cluster

func (*Cluster) OverlaysStream added in v0.2.3

func (c *Cluster) OverlaysStream(ctx context.Context) <-chan OverlaysStreamMsg

OverlaysStream returns stream of overlay addresses of all nodes in the cluster TODO: add semaphore

func (*Cluster) Peers added in v0.2.3

func (c *Cluster) Peers(ctx context.Context) (peers [][]swarm.Address, err error)

Peers returns ordered list of peers of all nodes in the cluster

func (*Cluster) PeersStream added in v0.2.3

func (c *Cluster) PeersStream(ctx context.Context) <-chan PeersStreamMsg

PeersStream returns stream of peers of all nodes in the cluster

func (*Cluster) RemoveNodes added in v0.2.12

func (c *Cluster) RemoveNodes(count int) (err error)

RemoveNodes removes nodes from the cluster

func (*Cluster) Settlements added in v0.3.0

func (c *Cluster) Settlements(ctx context.Context) (settlements map[string]map[string]SentReceived, err error)

Settlements returns settlements of all nodes in the cluster

func (*Cluster) SettlementsStream added in v0.3.0

func (c *Cluster) SettlementsStream(ctx context.Context) <-chan SettlementsStreamMsg

SettlementsStream returns stream of settlements of all nodes in the cluster

func (*Cluster) Size

func (c *Cluster) Size() int

Size returns size of the cluster

func (*Cluster) Topologies added in v0.2.3

func (c *Cluster) Topologies(ctx context.Context) (topologies []Topology, err error)

Topologies returns ordered list of Kademlia topology of all nodes in the cluster

func (*Cluster) TopologyStream added in v0.2.3

func (c *Cluster) TopologyStream(ctx context.Context) <-chan TopologyStreamMsg

TopologyStream returns stream of peers of all nodes in the cluster

type ClusterOptions

type ClusterOptions struct {
	APIScheme               string
	APIHostnamePattern      string
	APIDomain               string
	APIInsecureTLS          bool
	DebugAPIScheme          string
	DebugAPIHostnamePattern string
	DebugAPIDomain          string
	DisableNamespace        bool
	DebugAPIInsecureTLS     bool
	Namespace               string
	Size                    int
}

ClusterOptions represents Bee cluster options

type File added in v0.2.11

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

File represents Bee file

func NewBufferFile added in v0.2.18

func NewBufferFile(name string, buffer *bytes.Buffer) File

NewBufferFile returns new file with specified buffer

func NewRandomFile added in v0.2.11

func NewRandomFile(r *rand.Rand, name string, size int64) File

NewRandomFile returns new pseudorandom file

func (*File) Address added in v0.2.11

func (f *File) Address() swarm.Address

Address returns file's address

func (*File) CalculateHash added in v0.2.18

func (f *File) CalculateHash() error

CalculateHash calculates hash from dataReader. It replaces dataReader with another that will contain the data.

func (*File) ClosestNode added in v0.2.11

func (f *File) ClosestNode(nodes []swarm.Address) (closest swarm.Address, err error)

ClosestNode returns file's closest node of a given set of nodes

func (*File) DataReader added in v0.2.12

func (f *File) DataReader() io.Reader

DataReader returns file's data reader

func (*File) Hash added in v0.2.12

func (f *File) Hash() []byte

Hash returns file's hash

func (*File) Name added in v0.2.11

func (f *File) Name() string

Name returns file's name

func (*File) Size added in v0.2.11

func (f *File) Size() int64

Size returns file size

type HasChunkStreamMsg added in v0.2.12

type HasChunkStreamMsg struct {
	Found bool
	Index int
	Error error
}

HasChunkStreamMsg represents message sent over the HasChunkStream channel

type Node

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

Node represents Bee node

func NewNode

func NewNode(opts NodeOptions) Node

NewNode returns new node

func (*Node) Addresses added in v0.2.3

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

Addresses returns node's addresses

func (*Node) Balance added in v0.2.20

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

Balance returns node's balance with a given peer

func (*Node) Balances added in v0.2.20

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

Balances returns node's balances

func (*Node) CreateTag added in v0.3.7

func (n *Node) CreateTag(ctx context.Context) (resp api.TagResponse, err error)

CreateTag creates tag on the node

func (*Node) DownloadBytes added in v0.2.10

func (n *Node) DownloadBytes(ctx context.Context, a swarm.Address) (data []byte, err error)

DownloadBytes downloads chunk from the node

func (*Node) DownloadChunk added in v0.2.2

func (n *Node) DownloadChunk(ctx context.Context, a swarm.Address, targets string) (data []byte, err error)

DownloadChunk downloads chunk from the node

func (*Node) DownloadFile added in v0.2.11

func (n *Node) DownloadFile(ctx context.Context, a swarm.Address) (size int64, hash []byte, err error)

DownloadFile downloads chunk from the node and returns it's size and hash

func (*Node) DownloadManifestFile added in v0.2.18

func (n *Node) DownloadManifestFile(ctx context.Context, a swarm.Address, path string) (size int64, hash []byte, err error)

DownloadManifestFile downloads manifest file from the node and returns it's size and hash

func (*Node) GetTag added in v0.3.7

func (n *Node) GetTag(ctx context.Context, tagUID uint32) (resp api.TagResponse, err error)

GetTag retrieves tag from node

func (*Node) HasChunk

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

HasChunk returns true/false if node has a chunk

func (*Node) Overlay

func (n *Node) Overlay(ctx context.Context) (swarm.Address, error)

Overlay returns node's overlay address

func (*Node) Peers

func (n *Node) Peers(ctx context.Context) (peers []swarm.Address, err error)

Peers returns addresses of node's peers

func (*Node) PinChunk added in v0.2.12

func (n *Node) PinChunk(ctx context.Context, a swarm.Address) (bool, error)

PinChunk returns true/false if chunk pinning is successful

func (*Node) Ping

func (n *Node) Ping(ctx context.Context, node swarm.Address) (rtt string, err error)

Ping pings other node

func (*Node) PingStream added in v0.2.4

func (n *Node) PingStream(ctx context.Context, nodes []swarm.Address) <-chan PingStreamMsg

PingStream returns stream of ping results for given nodes

func (*Node) PinnedChunk added in v0.2.12

func (n *Node) PinnedChunk(ctx context.Context, a swarm.Address) (PinnedChunk, error)

PinnedChunk returns pinned chunk

func (*Node) PinnedChunks added in v0.2.12

func (n *Node) PinnedChunks(ctx context.Context) (PinnedChunks, error)

PinnedChunks returns pinned chunks

func (*Node) RemoveChunk added in v0.2.17

func (n *Node) RemoveChunk(ctx context.Context, c *Chunk) (err error)

RemoveChunk removes the given chunk from the node's local store

func (*Node) Settlement added in v0.3.0

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

Settlement returns node's settlement with a given peer

func (*Node) Settlements added in v0.3.0

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

Settlements returns node's settlements

func (*Node) Topology added in v0.2.2

func (n *Node) Topology(ctx context.Context) (topology Topology, err error)

Topology returns Kademlia topology

func (*Node) Underlay added in v0.2.3

func (n *Node) Underlay(ctx context.Context) ([]string, error)

Underlay returns node's underlay addresses

func (*Node) UnpinChunk added in v0.2.12

func (n *Node) UnpinChunk(ctx context.Context, a swarm.Address) (bool, error)

UnpinChunk returns true/false if chunk unpinning is successful

func (*Node) UploadBytes added in v0.2.10

func (n *Node) UploadBytes(ctx context.Context, b []byte, o api.UploadOptions) (swarm.Address, error)

UploadBytes uploads bytes to the node

func (*Node) UploadChunk

func (n *Node) UploadChunk(ctx context.Context, c *Chunk, o api.UploadOptions) (err error)

UploadChunk uploads chunk to the node

func (*Node) UploadCollection added in v0.2.18

func (n *Node) UploadCollection(ctx context.Context, f *File) (err error)

UploadCollection uploads TAR collection bytes to the node

func (*Node) UploadFile added in v0.2.11

func (n *Node) UploadFile(ctx context.Context, f *File, pin bool) (err error)

UploadFile uploads file to the node

func (*Node) UploadFileWithTag added in v0.3.7

func (n *Node) UploadFileWithTag(ctx context.Context, f *File, pin bool, tagUID uint32) (err error)

UploadFileWithTag uploads file with tag to the node

type NodeOptions

type NodeOptions struct {
	APIURL              *url.URL
	APIInsecureTLS      bool
	DebugAPIURL         *url.URL
	DebugAPIInsecureTLS bool
}

NodeOptions represents Bee node options

type OverlaysStreamMsg added in v0.2.3

type OverlaysStreamMsg struct {
	Address swarm.Address
	Index   int
	Error   error
}

OverlaysStreamMsg represents message sent over the OverlaysStream channel

type PeersStreamMsg added in v0.2.3

type PeersStreamMsg struct {
	Peers []swarm.Address
	Index int
	Error error
}

PeersStreamMsg represents message sent over the PeersStream channel

type PingStreamMsg added in v0.2.4

type PingStreamMsg struct {
	Node  swarm.Address
	RTT   string
	Index int
	Error error
}

PingStreamMsg represents message sent over the PingStream channel

type PinnedChunk added in v0.2.12

type PinnedChunk struct {
	Address    swarm.Address
	PinCounter int
}

PinnedChunk represents pinned chunk

type PinnedChunks added in v0.2.12

type PinnedChunks struct {
	Chunks []PinnedChunk
}

PinnedChunks represents pinned chunks

type SentReceived added in v0.3.0

type SentReceived struct {
	Received int
	Sent     int
}

SentReceived object

type Settlement added in v0.3.0

type Settlement struct {
	Peer     string
	Received int
	Sent     int
}

Settlement represents node's settlement with peer

type Settlements added in v0.3.0

type Settlements struct {
	Settlements   []Settlement
	TotalReceived int
	TotalSent     int
}

Settlements represents Settlements's response

type SettlementsStreamMsg added in v0.3.0

type SettlementsStreamMsg struct {
	Settlements Settlements
	Index       int
	Error       error
}

SettlementsStreamMsg represents message sent over the SettlementsStream channel

type Topology added in v0.2.2

type Topology struct {
	Overlay        swarm.Address
	Connected      int
	Population     int
	NnLowWatermark int
	Depth          int
	Bins           map[string]Bin
}

Topology represents Kademlia topology

type TopologyStreamMsg added in v0.2.3

type TopologyStreamMsg struct {
	Topology Topology
	Index    int
	Error    error
}

TopologyStreamMsg represents message sent over the TopologyStream channel

Jump to

Keyboard shortcuts

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