package
0.4.33
Repository: https://github.com/p9c/pod.git
Documentation: pkg.go.dev

# README

walletdb

[Build Status] (https://travis-ci.org/btcsuite/btcwallet)

Package walletdb provides a namespaced database interface for btcwallet.

A wallet essentially consists of a multitude of stored data such as private and public keys, key derivation bits, pay-to-script-hash scripts, and various metadata. One of the issues with many wallets is they are tightly integrated. Designing a wallet with loosely coupled components that provide specific functionality is ideal, however it presents a challenge in regards to data storage since each component needs to store its own data without knowing the internals of other components or breaking atomicity.

This package solves this issue by providing a namespaced database interface that is intended to be used by the main wallet daemon. This allows the potential for any backend database type with a suitable driver. Each component, which will typically be a package, can then implement various functionality such as address management, voting pools, and colored coin metadata in their own namespace without having to worry about conflicts with other packages even though they are sharing the same database that is managed by the wallet.

A suite of tests is provided to ensure proper functionality. See test_coverage.txt for the gocov coverage report. Alternatively, if you are running a POSIX OS, you can run the cov_report.sh script for a real-time report. Package walletdb is licensed under the copyfree ISC license.

This interfaces provided by this package were heavily inspired by the excellent boltdb project at https://github.com/boltdb/bolt by Ben B. Johnson.

Feature Overview

  • Key/value store
  • Namespace support
    • Allows multiple packages to have their own area in the database without worrying about conflicts
  • Read-only and read-write transactions with both manual and managed modes
  • Nested buckets
  • Supports registration of backend databases
  • Comprehensive test coverage

Documentation

[GoDoc] (http://godoc.org/github.com/p9c/pod/walletmain/walletdb)

Full go doc style documentation for the project can be viewed online without installing this package by using the GoDoc site here: http://godoc.org/github.com/p9c/pod/walletmain/walletdb

You can also view the documentation locally once the package is installed with the godoc tool by running godoc -http=":6060" and pointing your browser to http://localhost:6060/pkg/github.com/p9c/pod/walletmain/walletdb

Installation

$ go get github.com/p9c/pod/walletmain/walletdb

Examples

License

Package walletdb is licensed under the copyfree ISC License.

# Packages

Package bdb implements an instance of walletdb that uses boltdb for the backing datastore.
Package walletdbtest provides exported tests that can be imported and consumed by walletdb driver tests to help ensure that drivers confirm to the database driver interface correctly.

# Functions

BucketIsEmpty returns whether the bucket is empty, that is, whether there are no key/value pairs or nested buckets.
No description provided by the author
Create intializes and opens a database for the specified type.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Open opens an existing database for the specified type.
RegisterDriver adds a backend database driver to available interfaces.
SupportedDrivers returns a slice of strings that represent the database drivers that have been registered and are therefore supported.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Update opens a database read/write transaction and executes the function f with the transaction passed as a parameter.
View opens a database read transaction and executes the function f with the transaction passed as a parameter.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Variables

ErrBucketExists is returned when creating a bucket that already exists.
ErrBucketNameRequired is returned when creating a bucket with a blank name.
ErrBucketNotFound is returned when trying to access a bucket that has not been created yet.
ErrDbAlreadyOpen is returned when open is called on a database that is already open.
ErrDbDoesNotExist is returned when open is called for a database that does not exist.
ErrDbExists is returned when create is called for a database that already exists.
ErrDbNotOpen is returned when a database instance is accessed before it is opened or after it is closed.
ErrDbTypeRegistered is returned when two different database drivers attempt to register with the name database type.
ErrDbUnknownType is returned when there is no driver registered for the specified database type.
ErrIncompatibleValue is returned when trying create or delete a bucket on an existing non-bucket key or when trying to create or delete a non-bucket key on an existing bucket key.
ErrInvalid is returned if the specified database is not valid.
ErrKeyRequired is returned when inserting a zero-length key.
ErrKeyTooLarge is returned when inserting a key that is larger than MaxKeySize.
ErrTxClosed is returned when attempting to commit or rollback a transaction that has already had one of those operations performed.
ErrTxNotWritable is returned when an operation that requires write access to the database is attempted against a read-only transaction.
ErrValueTooLarge is returned when inserting a value that is larger than MaxValueSize.

# Structs

Driver defines a structure for backend drivers to use when they registered themselves as a backend which implements the Db interface.

# Interfaces

DB represents an ACID database.
ReadBucket represents a bucket (a hierarchical structure within the database) that is only allowed to perform read operations.
ReadCursor represents a bucket cursor that can be positioned at the start or end of the bucket's key/value pairs and iterate over pairs in the bucket.
ReadTx represents a database transaction that can only be used for reads.
ReadWriteBucket represents a bucket (a hierarchical structure within the database) that is allowed to perform both read and write operations.
ReadWriteCursor represents a bucket cursor that can be positioned at the start or end of the bucket's key/value pairs and iterate over pairs in the bucket.
ReadWriteTx represents a database transaction that can be used for both reads and writes.