multistore

package module
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2021 License: Apache-2.0, MIT Imports: 22 Imported by: 17

README

go-fil-markets

CircleCI codecov GoDoc

This repository provides a mechanism for constructing multiple, isolated, IPFS storage instances (blockstore, filestore, DAGService) on top of a single go-datastore instance.

Background reading

You may want to familiarize yourself with various IPFS storage layer components:

Installation

go get "github.com/chenjianmei111/go-multistore"`

Usage

Initialize multistore:

var ds datastore.Batching
multiDs, err := multistore.NewMultiDstore(ds)

Create new store:

next := multiDs.Next()
store, err := multiDs.Get(store)

// store will have a blockstore, filestore, and DAGService

List existing store indexes:

indexes := multiDs.List()

Delete a store (will delete all data in isolated store without touching the rest of the datastore):

var index int
err := multiDs.Delete(index)

Shutdown (make sure everything is closed):

multiDs.Close()

Contributing

Issues and PRs are welcome! Please first read the background reading and CONTRIBUTING guide, and look over the current code. PRs against master require approval of at least two maintainers.

Day-to-day discussion takes place in the #fil-components channel of the Filecoin project chat. Usage or design questions are welcome.

Project-level documentation

The chenjianmei111 has a community repo with more detail about our resources and policies, such as the Code of Conduct.

License

This repository is dual-licensed under Apache 2.0 and MIT terms.

Copyright 2020. Protocol Labs, Inc.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MultiStore

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

MultiStore is a wrapper around a datastore that provides multiple isolated instances of IPFS storage components -> BlockStore, FileStore, DAGService, etc

func NewMultiDstore

func NewMultiDstore(ds datastore.Batching) (*MultiStore, error)

NewMultiDstore returns a new instance of a MultiStore for the given datastore instance

func (*MultiStore) Close

func (mds *MultiStore) Close() error

Close closes all open datastores

func (*MultiStore) Delete

func (mds *MultiStore) Delete(i StoreID) error

Delete deletes the store with the given id, including all of its data

func (*MultiStore) Get

func (mds *MultiStore) Get(i StoreID) (*Store, error)

Get returns the store for the given ID

func (*MultiStore) List

func (mds *MultiStore) List() StoreIDList

List returns a list of all known store IDs

func (*MultiStore) MultiReadBlockstore

func (mds *MultiStore) MultiReadBlockstore() blockstore.Blockstore

MultiReadBlockstore returns a single Blockstore that will try to read from all of the blockstores tracked by this multistore

func (*MultiStore) Next

func (mds *MultiStore) Next() StoreID

Next returns the next available StoreID

type Store

type Store struct {
	Fstore *filestore.Filestore

	Bstore blockstore.Blockstore

	DAG    ipld.DAGService
	Loader ipldprime.Loader
	Storer ipldprime.Storer
	// contains filtered or unexported fields
}

Store is a single store instance returned by the MultiStore. it gives public access to the blockstore, filestore, dag service, and an ipld-prime loader/storer

func (*Store) Close

func (s *Store) Close() error

Close closes down the blockservice used by the DAG Service for this store

type StoreID

type StoreID uint64

StoreID identifies a unique instance of a store

type StoreIDList

type StoreIDList []StoreID

StoreIDList is just a list of StoreID that implements sort.Interface

func (StoreIDList) Len

func (s StoreIDList) Len() int

func (StoreIDList) Less

func (s StoreIDList) Less(i, j int) bool

func (StoreIDList) Swap

func (s StoreIDList) Swap(i, j int)

Jump to

Keyboard shortcuts

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