ldb

package
v0.0.0-...-ca6883d Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2014 License: ISC, ISC Imports: 13 Imported by: 0

Documentation

Overview

Package ldb implements an instance of btcdb backed by leveldb.

Database version number is stored in a flat file <dbname>.ver Currently a single (littlendian) integer in the file. If there is additional data to save in the future, the presence of additional data can be indicated by changing the version number, then parsing the file differently.

Index

Constants

This section is empty.

Variables

View Source
var CurrentDBVersion int32 = 1

CurrentDBVersion is the database version.

Functions

func CreateDB

func CreateDB(args ...interface{}) (btcdb.Db, error)

CreateDB creates, initializes and opens a database for use.

func OpenDB

func OpenDB(args ...interface{}) (btcdb.Db, error)

OpenDB opens an existing database for use.

Types

type LevelDb

type LevelDb struct {
	// contains filtered or unexported fields
}

LevelDb holds internal state for databse.

func (*LevelDb) Close

func (db *LevelDb) Close() error

Close cleanly shuts down database, syncing all data.

func (*LevelDb) DropAfterBlockBySha

func (db *LevelDb) DropAfterBlockBySha(sha *btcwire.ShaHash) (rerr error)

DropAfterBlockBySha will remove any blocks from the database after the given block.

func (*LevelDb) ExistsSha

func (db *LevelDb) ExistsSha(sha *btcwire.ShaHash) (bool, error)

ExistsSha looks up the given block hash returns true if it is present in the database.

func (*LevelDb) ExistsTxSha

func (db *LevelDb) ExistsTxSha(txsha *btcwire.ShaHash) (bool, error)

ExistsTxSha returns if the given tx sha exists in the database

func (*LevelDb) FetchBlockBySha

func (db *LevelDb) FetchBlockBySha(sha *btcwire.ShaHash) (blk *btcutil.Block, err error)

FetchBlockBySha - return a btcutil Block

func (*LevelDb) FetchBlockHeaderBySha

func (db *LevelDb) FetchBlockHeaderBySha(sha *btcwire.ShaHash) (bh *btcwire.BlockHeader, err error)

FetchBlockHeaderBySha - return a btcwire ShaHash

func (*LevelDb) FetchBlockHeightBySha

func (db *LevelDb) FetchBlockHeightBySha(sha *btcwire.ShaHash) (int64, error)

FetchBlockHeightBySha returns the block height for the given hash. This is part of the btcdb.Db interface implementation.

func (*LevelDb) FetchBlockShaByHeight

func (db *LevelDb) FetchBlockShaByHeight(height int64) (sha *btcwire.ShaHash, err error)

FetchBlockShaByHeight returns a block hash based on its height in the block chain.

func (*LevelDb) FetchHeightRange

func (db *LevelDb) FetchHeightRange(startHeight, endHeight int64) (rshalist []btcwire.ShaHash, err error)

FetchHeightRange looks up a range of blocks by the start and ending heights. Fetch is inclusive of the start height and exclusive of the ending height. To fetch all hashes from the start height until no more are present, use the special id `AllShas'.

func (*LevelDb) FetchTxBySha

func (db *LevelDb) FetchTxBySha(txsha *btcwire.ShaHash) ([]*btcdb.TxListReply, error)

FetchTxBySha returns some data for the given Tx Sha.

func (*LevelDb) FetchTxByShaList

func (db *LevelDb) FetchTxByShaList(txShaList []*btcwire.ShaHash) []*btcdb.TxListReply

FetchTxByShaList returns the most recent tx of the name fully spent or not

func (*LevelDb) FetchUnSpentTxByShaList

func (db *LevelDb) FetchUnSpentTxByShaList(txShaList []*btcwire.ShaHash) []*btcdb.TxListReply

FetchUnSpentTxByShaList given a array of ShaHash, look up the transactions and return them in a TxListReply array.

func (*LevelDb) InsertBlock

func (db *LevelDb) InsertBlock(block *btcutil.Block) (height int64, rerr error)

InsertBlock inserts raw block and transaction data from a block into the database. The first block inserted into the database will be treated as the genesis block. Every subsequent block insert requires the referenced parent block to already exist.

func (*LevelDb) InsertTx

func (db *LevelDb) InsertTx(txsha *btcwire.ShaHash, height int64, txoff int, txlen int, spentbuf []byte) (err error)

InsertTx inserts a tx hash and its associated data into the database.

func (*LevelDb) NewestSha

func (db *LevelDb) NewestSha() (rsha *btcwire.ShaHash, rblkid int64, err error)

NewestSha returns the hash and block height of the most recent (end) block of the block chain. It will return the zero hash, -1 for the block height, and no error (nil) if there are not any blocks in the database yet.

func (*LevelDb) RollbackClose

func (db *LevelDb) RollbackClose() error

RollbackClose this is part of the btcdb.Db interface and should discard recent changes to the db and the close the db. This currently just does a clean shutdown.

func (*LevelDb) Sync

func (db *LevelDb) Sync() error

Sync verifies that the database is coherent on disk, and no outstanding transactions are in flight.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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