bolt

package
v0.0.0-...-67d7764 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2018 License: MIT Imports: 7 Imported by: 1

Documentation

Overview

package bolt implements operations using Bolt as the underlying database

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

type DB struct {
	DB *bolt.DB
}

DB is a wrapper with reference to underlying Bolt database and implements BlockstackDB operations

func New

func New(path string) (*DB, error)

New attempts to create a new Bolt database instance given path.

func (*DB) Get

func (db *DB) Get(bucket, key []byte) (result []byte, err error)

Get attempts to return value at given key. If an error occurs, it is returned and the result will be an empty byte slice.

func (*DB) GetNames

func (db *DB) GetNames() (map[string]map[string]bool, error)

GetNames returns the set of all names at current day

func (*DB) GetNamesAt

func (db *DB) GetNamesAt(t time.Time) (result map[string]map[string]bool, err error)

GetNamesAt returns set of names across all namespaces at a given day. The time parameter is used as the key, rounded to start of day in UTC format, and converted to Unix epoch time. The result is map[NamespaceName][SetOfNames], using a boolean map for the name set since Go does not have builtin sets. The set of names are stored as gzip compressed bytes, and are uncompressed when retrieved from database.

func (*DB) Put

func (db *DB) Put(bucket, key, value []byte) error

Put attempts to insert the given key value pair under the provided bucket name. The bucket is created if it doesn't exist.

func (*DB) PutNames

func (db *DB) PutNames(names map[string]map[string]bool) error

PutNames inserts the set of names for each namespace into the database where the key is the current date rounded to start of day.

func (*DB) PutNamesAt

func (db *DB) PutNamesAt(names map[string]map[string]bool, t time.Time) error

PutNamesAt attempts to insert the set of names for each namespace into the database using the given time as key, rounded to start of day in UTC and converted to Unix epoch time. The set of names are stored as gzip compressed bytes, and are uncompressed when retrieved from database.

func (*DB) Shutdown

func (db *DB) Shutdown() error

Shutdown closes the database and returns an error if any occur.

Jump to

Keyboard shortcuts

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