db

package
v0.0.0-...-c638c98 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2018 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrBlockNotFound = errors.New("Block not found.")
)
View Source
var (
	ErrBuffToSmall = errors.New("Buffer too small for requested opperation.")
)

Functions

func EachBlock

func EachBlock(d Driver, f func(b *block.Block) bool) error

EachBlock iterates through all blocks the driver has access to. if "f" returns false, it will stop iterating

func EachTransaction

func EachTransaction(d Driver, f func(t *block.Transaction) bool) error

EachTransaction iterates through all transactions in all blocks

func RegisterDriver

func RegisterDriver(name string, df DriverFactory)

Types

type Driver

type Driver interface {
	StreamBlocks(ctx context.Context) (<-chan *block.Block, <-chan error)
	Write(b *block.Block) error
}

A Driver provides an interface to read and write blocks to/from persistance.

func Open

func Open(kind string, backing io.ReadWriteSeeker) Driver

type DriverFactory

type DriverFactory func(io.ReadWriteSeeker) Driver

type NonCachedDriver

type NonCachedDriver struct {
	sync.Mutex
	// contains filtered or unexported fields
}

NonCachedDriver impliments the Driver interface with a single local file. As the name implies, this is a simple driver that does no caching.

func NewNonCachedDriver

func NewNonCachedDriver(rws io.ReadWriteSeeker) *NonCachedDriver

func (*NonCachedDriver) GetBlockByContentHash

func (n *NonCachedDriver) GetBlockByContentHash(hash []byte) (*block.Block, error)

func (*NonCachedDriver) SeekAndStream

func (n *NonCachedDriver) SeekAndStream(start time.Time, ctx context.Context) (<-chan *block.Block, <-chan error)

func (*NonCachedDriver) SeekAndStreamUntil

func (n *NonCachedDriver) SeekAndStreamUntil(t time.Time, until time.Time, ctx context.Context) (<-chan *block.Block, <-chan error)

func (*NonCachedDriver) StreamBlocks

func (n *NonCachedDriver) StreamBlocks(ctx context.Context) (<-chan *block.Block, <-chan error)

func (*NonCachedDriver) Write

func (n *NonCachedDriver) Write(b *block.Block) error

func (*NonCachedDriver) WriteMulti

func (n *NonCachedDriver) WriteMulti(b []*block.Block) error

Jump to

Keyboard shortcuts

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