db

package
v1.8.22-0...-74acde4 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2019 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Overview

Package db implements a mock store that keeps all chunk data in LevelDB database.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GlobalStore

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

GlobalStore contains the LevelDB database that is storing chunk data for all swarm nodes. Closing the GlobalStore with Close method is required to release resources used by the database.

func NewGlobalStore

func NewGlobalStore(path string) (s *GlobalStore, err error)

NewGlobalStore creates a new instance of GlobalStore.

func (*GlobalStore) Close

func (s *GlobalStore) Close() error

Close releases the resources used by the underlying LevelDB.

func (*GlobalStore) Delete

func (s *GlobalStore) Delete(addr common.Address, key []byte) error

Delete removes the chunk reference to node with address addr.

func (*GlobalStore) Export

func (s *GlobalStore) Export(w io.Writer) (n int, err error)

Export writes to a writer a tar archive with all chunk data from the store. It returns the number fo chunks exported and an error.

func (*GlobalStore) Get

func (s *GlobalStore) Get(addr common.Address, key []byte) (data []byte, err error)

Get returns chunk data if the chunk with key exists for node on address addr.

func (*GlobalStore) HasKey

func (s *GlobalStore) HasKey(addr common.Address, key []byte) bool

HasKey returns whether a node with addr contains the key.

func (*GlobalStore) Import

func (s *GlobalStore) Import(r io.Reader) (n int, err error)

Import reads tar archive from a reader that contains exported chunk data. It returns the number of chunks imported and an error.

func (*GlobalStore) KeyNodes

func (s *GlobalStore) KeyNodes(key []byte, startAddr *common.Address, limit int) (nodes mock.Nodes, err error)

KeyNodes returns a paginated list of nodes that contain a particular key.

func (*GlobalStore) Keys

func (s *GlobalStore) Keys(startKey []byte, limit int) (keys mock.Keys, err error)

Keys returns a paginated list of keys on all nodes.

func (*GlobalStore) NewNodeStore

func (s *GlobalStore) NewNodeStore(addr common.Address) *mock.NodeStore

NewNodeStore returns a new instance of NodeStore that retrieves and stores chunk data only for a node with address addr.

func (*GlobalStore) NodeKeys

func (s *GlobalStore) NodeKeys(addr common.Address, startKey []byte, limit int) (keys mock.Keys, err error)

NodeKeys returns a paginated list of keys on a node with provided address.

func (*GlobalStore) Nodes

func (s *GlobalStore) Nodes(startAddr *common.Address, limit int) (nodes mock.Nodes, err error)

Nodes returns a paginated list of all known nodes.

func (*GlobalStore) Put

func (s *GlobalStore) Put(addr common.Address, key []byte, data []byte) error

Put saves the chunk data for node with address addr.

Jump to

Keyboard shortcuts

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