Documentation ¶
Overview ¶
Package mem implements a mock store that keeps all chunk data in memory. While it can be used for testing on smaller scales, the main purpose of this package is to provide the simplest reference implementation of a mock store.
Index ¶
- type GlobalStore
- func (s *GlobalStore) Delete(addr common.Address, key []byte) error
- func (s *GlobalStore) Export(w io.Writer) (n int, err error)
- func (s *GlobalStore) Get(addr common.Address, key []byte) (data []byte, err error)
- func (s *GlobalStore) HasKey(addr common.Address, key []byte) bool
- func (s *GlobalStore) Import(r io.Reader) (n int, err error)
- func (s *GlobalStore) NewNodeStore(addr common.Address) *mock.NodeStore
- func (s *GlobalStore) Put(addr common.Address, key []byte, data []byte) error
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 stores all chunk data and also keys and node addresses relations. It implements mock.GlobalStore interface.
func NewGlobalStore ¶
func NewGlobalStore() *GlobalStore
NewGlobalStore creates a new instance of GlobalStore.
func (*GlobalStore) Delete ¶ added in v1.0.6
func (s *GlobalStore) Delete(addr common.Address, key []byte) error
Delete removes the chunk data for 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 of chunks exported and an error.
func (*GlobalStore) Get ¶
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) 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.