multistore

package module
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2022 License: Apache-2.0, MIT Imports: 21 Imported by: 6

README

go-multistore

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/myelnet/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()

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(ctx context.Context, 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(ctx context.Context, i StoreID) error

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

func (*MultiStore) Get

func (mds *MultiStore) Get(ctx context.Context, 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 {
	Bstore blockstore.Blockstore

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

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

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