db

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2018 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RepairRocksDB

func RepairRocksDB(name string) error

RepairRocksDB calls RocksDb db repair function

Types

type RocksDB

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

RocksDB handle

func NewRocksDB

func NewRocksDB(path string, parser bchain.BlockChainParser, metrics *common.Metrics) (d *RocksDB, err error)

NewRocksDB opens an internal handle to RocksDB environment. Close needs to be called to release it.

func (*RocksDB) Close

func (d *RocksDB) Close() error

Close releases the RocksDB environment opened in NewRocksDB.

func (*RocksDB) ComputeInternalStateColumnStats

func (d *RocksDB) ComputeInternalStateColumnStats(stopCompute chan os.Signal) error

ComputeInternalStateColumnStats computes stats of all db columns and sets them to internal state can be very slow operation

func (*RocksDB) ConnectBlock

func (d *RocksDB) ConnectBlock(block *bchain.Block) error

ConnectBlock indexes addresses in the block and stores them in db

func (*RocksDB) DatabaseSizeOnDisk

func (d *RocksDB) DatabaseSizeOnDisk() int64

DatabaseSizeOnDisk returns size of the database in bytes

func (*RocksDB) DeleteTx

func (d *RocksDB) DeleteTx(txid string) error

DeleteTx removes transactions from db

func (*RocksDB) DisconnectBlock

func (d *RocksDB) DisconnectBlock(block *bchain.Block) error

DisconnectBlock removes addresses in the block from the db

func (*RocksDB) DisconnectBlockRange

func (d *RocksDB) DisconnectBlockRange(lower uint32, higher uint32) error

DisconnectBlockRange removes all data belonging to blocks in range lower-higher it finds the data in blockaddresses column if available, otherwise by doing quite slow full scan of addresses column

func (*RocksDB) GetBestBlock

func (d *RocksDB) GetBestBlock() (uint32, string, error)

GetBestBlock returns the block hash of the block with highest height in the db

func (*RocksDB) GetBlockHash

func (d *RocksDB) GetBlockHash(height uint32) (string, error)

GetBlockHash returns block hash at given height or empty string if not found

func (*RocksDB) GetTransactions

func (d *RocksDB) GetTransactions(address string, lower uint32, higher uint32, fn func(txid string, vout uint32, isOutput bool) error) (err error)

GetTransactions finds all input/output transactions for address Transaction are passed to callback function.

func (*RocksDB) GetTx

func (d *RocksDB) GetTx(txid string) (*bchain.Tx, uint32, error)

GetTx returns transaction stored in db and height of the block containing it

func (*RocksDB) LoadInternalState

func (d *RocksDB) LoadInternalState(rpcCoin string) (*common.InternalState, error)

LoadInternalState loads from db internal state or initializes a new one if not yet stored

func (*RocksDB) PutTx

func (d *RocksDB) PutTx(tx *bchain.Tx, height uint32, blockTime int64) error

PutTx stores transactions in db

func (*RocksDB) Reopen

func (d *RocksDB) Reopen() error

Reopen reopens the database It closes and reopens db, nobody can access the database during the operation!

func (*RocksDB) SetInternalState

func (d *RocksDB) SetInternalState(is *common.InternalState)

SetInternalState sets the InternalState to be used by db to collect internal state

func (*RocksDB) StoreInternalState

func (d *RocksDB) StoreInternalState(is *common.InternalState) error

StoreInternalState stores the internal state to db

type SyncWorker

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

SyncWorker is handle to SyncWorker

func NewSyncWorker

func NewSyncWorker(db *RocksDB, chain bchain.BlockChain, syncWorkers, syncChunk int, minStartHeight int, dryRun bool, chanOsSignal chan os.Signal, metrics *common.Metrics, is *common.InternalState) (*SyncWorker, error)

NewSyncWorker creates new SyncWorker and returns its handle

func (*SyncWorker) ConnectBlocksParallel

func (w *SyncWorker) ConnectBlocksParallel(lower, higher uint32) error

ConnectBlocksParallel uses parallel goroutines to get data from blockchain daemon

func (*SyncWorker) DisconnectBlocks

func (w *SyncWorker) DisconnectBlocks(lower uint32, higher uint32, hashes []string) error

DisconnectBlocks removes all data belonging to blocks in range lower-higher, using block data from blockchain, if they are available, otherwise doing full scan

func (*SyncWorker) ResyncIndex

func (w *SyncWorker) ResyncIndex(onNewBlock bchain.OnNewBlockFunc) error

ResyncIndex synchronizes index to the top of the blockchain onNewBlock is called when new block is connected, but not in initial parallel sync

type TxCache

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

TxCache is handle to TxCacheServer

func NewTxCache

func NewTxCache(db *RocksDB, chain bchain.BlockChain, metrics *common.Metrics, enabled bool) (*TxCache, error)

NewTxCache creates new TxCache interface and returns its handle

func (*TxCache) GetTransaction

func (c *TxCache) GetTransaction(txid string, bestheight uint32) (*bchain.Tx, uint32, error)

GetTransaction returns transaction either from RocksDB or if not present from blockchain it the transaction is confirmed, it is stored in the RocksDB

Jump to

Keyboard shortcuts

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