Documentation
¶
Overview ¶
Package ldb implements an instance of rdddb 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 ¶
- Variables
- func CreateDB(args ...interface{}) (rdddb.Db, error)
- func OpenDB(args ...interface{}) (rdddb.Db, error)
- type LevelDb
- func (db *LevelDb) Close() error
- func (db *LevelDb) DropAfterBlockBySha(sha *rddwire.ShaHash) (rerr error)
- func (db *LevelDb) ExistsSha(sha *rddwire.ShaHash) (bool, error)
- func (db *LevelDb) ExistsTxSha(txsha *rddwire.ShaHash) (bool, error)
- func (db *LevelDb) FetchBlockBySha(sha *rddwire.ShaHash) (blk *rddutil.Block, err error)
- func (db *LevelDb) FetchBlockHeaderBySha(sha *rddwire.ShaHash) (bh *rddwire.BlockHeader, err error)
- func (db *LevelDb) FetchBlockHeightBySha(sha *rddwire.ShaHash) (int64, error)
- func (db *LevelDb) FetchBlockShaByHeight(height int64) (sha *rddwire.ShaHash, err error)
- func (db *LevelDb) FetchHeightRange(startHeight, endHeight int64) (rshalist []rddwire.ShaHash, err error)
- func (db *LevelDb) FetchTxBySha(txsha *rddwire.ShaHash) ([]*rdddb.TxListReply, error)
- func (db *LevelDb) FetchTxByShaList(txShaList []*rddwire.ShaHash) []*rdddb.TxListReply
- func (db *LevelDb) FetchUnSpentTxByShaList(txShaList []*rddwire.ShaHash) []*rdddb.TxListReply
- func (db *LevelDb) InsertBlock(block *rddutil.Block) (height int64, rerr error)
- func (db *LevelDb) InsertTx(txsha *rddwire.ShaHash, height int64, txoff int, txlen int, spentbuf []byte) (err error)
- func (db *LevelDb) NewestSha() (rsha *rddwire.ShaHash, rblkid int64, err error)
- func (db *LevelDb) RollbackClose() error
- func (db *LevelDb) Sync() error
Constants ¶
This section is empty.
Variables ¶
var CurrentDBVersion int32 = 1
CurrentDBVersion is the database version.
Functions ¶
Types ¶
type LevelDb ¶
type LevelDb struct {
// contains filtered or unexported fields
}
LevelDb holds internal state for databse.
func (*LevelDb) DropAfterBlockBySha ¶
DropAfterBlockBySha will remove any blocks from the database after the given block.
func (*LevelDb) ExistsSha ¶
ExistsSha looks up the given block hash returns true if it is present in the database.
func (*LevelDb) ExistsTxSha ¶
ExistsTxSha returns if the given tx sha exists in the database
func (*LevelDb) FetchBlockBySha ¶
FetchBlockBySha - return a rddutil Block
func (*LevelDb) FetchBlockHeaderBySha ¶
FetchBlockHeaderBySha - return a rddwire ShaHash
func (*LevelDb) FetchBlockHeightBySha ¶
FetchBlockHeightBySha returns the block height for the given hash. This is part of the rdddb.Db interface implementation.
func (*LevelDb) FetchBlockShaByHeight ¶
FetchBlockShaByHeight returns a block hash based on its height in the block chain.
func (*LevelDb) FetchHeightRange ¶
func (db *LevelDb) FetchHeightRange(startHeight, endHeight int64) (rshalist []rddwire.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 ¶
FetchTxBySha returns some data for the given Tx Sha.
func (*LevelDb) FetchTxByShaList ¶
func (db *LevelDb) FetchTxByShaList(txShaList []*rddwire.ShaHash) []*rdddb.TxListReply
FetchTxByShaList returns the most recent tx of the name fully spent or not
func (*LevelDb) FetchUnSpentTxByShaList ¶
func (db *LevelDb) FetchUnSpentTxByShaList(txShaList []*rddwire.ShaHash) []*rdddb.TxListReply
FetchUnSpentTxByShaList given a array of ShaHash, look up the transactions and return them in a TxListReply array.
func (*LevelDb) InsertBlock ¶
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 *rddwire.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 ¶
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 ¶
RollbackClose this is part of the rdddb.Db interface and should discard recent changes to the db and the close the db. This currently just does a clean shutdown.