bsadapter

package module
v0.0.0-...-198d7db Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2024 License: MIT Imports: 5 Imported by: 9

README

bsadapter

The bsadapter package/module is a small piece of glue code to connect the github.com/ipfs/go-blockstore package, and packages implementing its interfaces, forward into the go-ipld-prime/storage interfaces.

Why structured like this?

See ../README_adapters.md for details about why adapter code is needed, why this is in a module, why it's here, etc.

Which of dsadapter vs bsadapter vs bsrvadapter should I use?

In short: you should prefer direct implementations of the storage APIs over any of these adapters, if one is available with the features you need.

Otherwise, if that's not an option (yet) for some reason, use whichever adapter gets you most directly connected to the code you need.

See ../README_adapters.md for more details and discussion.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Adapter

type Adapter struct {
	Wrapped blockstore.Blockstore
}

Adapter implements go-ipld-prime/storage.ReadableStorage and go-ipld-prime/storage.WritableStorage backed by a go-ipfs-blockstore.Blockstore.

The go-ipfs-blockstore.Blockstore may internally have other configuration. We don't interfere with that here; such configuration should be handled when creating the go-ipfs-blockstore value.

Note that this system will only work for certain structures of keys -- this is because the blockstore API works on the level of CIDs. As long as your key string is the binary form of a CID, it will work correctly. Other keys are not possible to support with this adapter.

Contexts given to this system are checked for errors at the beginning of an operation, but otherwise have no effect, because the Blockstore API doesn't accept context parameters.

func (*Adapter) Get

func (a *Adapter) Get(ctx context.Context, key string) ([]byte, error)

Get implements go-ipld-prime/storage.ReadableStorage.Get.

func (*Adapter) Has

func (a *Adapter) Has(ctx context.Context, key string) (bool, error)

Has implements go-ipld-prime/storage.Storage.Has.

func (*Adapter) Put

func (a *Adapter) Put(ctx context.Context, key string, content []byte) error

Put implements go-ipld-prime/storage.WritableStorage.Put.

Jump to

Keyboard shortcuts

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