Documentation
¶
Index ¶
- Constants
- Variables
- type Addr
- type Addrs
- type AddrsDB
- type DataStore
- type HeaderCache
- type Headers
- type HeadersDB
- func (h *HeadersDB) Close()
- func (h *HeadersDB) GetHeader(hash common.Uint256) (header *db.StoreHeader, err error)
- func (h *HeadersDB) GetPrevious(header *db.StoreHeader) (*db.StoreHeader, error)
- func (h *HeadersDB) GetTip() (header *db.StoreHeader, err error)
- func (h *HeadersDB) Put(header *db.StoreHeader, newTip bool) error
- func (h *HeadersDB) Reset() error
- type Info
- type InfoDB
- type SQLiteDB
- type STXO
- type STXOs
- type STXOsDB
- func (db *STXOsDB) Delete(outPoint *OutPoint) error
- func (db *STXOsDB) FromUTXO(outPoint *OutPoint, spendTxId *Uint256, spendHeight uint32) error
- func (db *STXOsDB) Get(outPoint *OutPoint) (*STXO, error)
- func (db *STXOsDB) GetAddrAll(hash *Uint168) ([]*STXO, error)
- func (db *STXOsDB) GetAll() ([]*STXO, error)
- type SortableUTXOs
- type Txs
- type TxsDB
- func (t *TxsDB) Delete(txId *Uint256) error
- func (t *TxsDB) Get(txId *Uint256) (*db.StoreTx, error)
- func (t *TxsDB) GetAll() ([]*db.StoreTx, error)
- func (t *TxsDB) GetAllFrom(height uint32) ([]*db.StoreTx, error)
- func (t *TxsDB) Put(storeTx *db.StoreTx) error
- func (t *TxsDB) UpdateHeight(txId *Uint256, height uint32) error
- type UTXO
- type UTXOs
- type UTXOsDB
Constants ¶
View Source
const ( TypeMaster = 0 TypeSub = 1 << 1 TypeMulti = 1 << 2 TypeNotify = 1 << 3 )
View Source
const ( DriverName = "sqlite3" DBName = "./spv_wallet.db" )
View Source
const (
ChainHeightKey = "ChainHeight"
)
View Source
const CreateAddrsDB = `CREATE TABLE IF NOT EXISTS Addrs(
Hash BLOB NOT NULL PRIMARY KEY,
Script BLOB,
Type INTEGER NOT NULL
);`
View Source
const CreateInfoDB = `CREATE TABLE IF NOT EXISTS Info(
Key NOT NULL PRIMARY KEY,
Value BLOB NOT NULL
);`
View Source
const CreateSTXOsDB = `` /* 258-byte string literal not displayed */
View Source
const CreateTXNDB = `` /* 129-byte string literal not displayed */
View Source
const CreateUTXOsDB = `` /* 195-byte string literal not displayed */
Variables ¶
View Source
var ( BKTHeaders = []byte("Headers") BKTChainTip = []byte("ChainTip") KEYChainTip = []byte("ChainTip") )
Functions ¶
This section is empty.
Types ¶
type Addrs ¶
type AddrsDB ¶
type HeaderCache ¶
func (*HeaderCache) Get ¶
func (cache *HeaderCache) Get(hash common.Uint256) (*db.StoreHeader, error)
func (*HeaderCache) Set ¶
func (cache *HeaderCache) Set(header *db.StoreHeader)
type Headers ¶
type Headers interface {
// Add a new header to blockchain
Put(header *db.StoreHeader, newTip bool) error
// Get previous block of the given header
GetPrevious(header *db.StoreHeader) (*db.StoreHeader, error)
// Get full header with it's hash
GetHeader(hash common.Uint256) (*db.StoreHeader, error)
// Get the header on chain tip
GetTip() (*db.StoreHeader, error)
// Reset database, clear all data
Reset() error
// Close db
Close()
}
func NewHeadersDB ¶
type HeadersDB ¶
HeadersDB implements Headers using bolt DB
func (*HeadersDB) GetPrevious ¶
func (h *HeadersDB) GetPrevious(header *db.StoreHeader) (*db.StoreHeader, error)
Get previous block of the given header
func (*HeadersDB) GetTip ¶
func (h *HeadersDB) GetTip() (header *db.StoreHeader, err error)
Get the header on chain tip
type Info ¶
type SQLiteDB ¶
func NewSQLiteDB ¶
type STXO ¶
type STXOs ¶
type STXOs interface {
// Move a UTXO to STXO
FromUTXO(outPoint *OutPoint, spendTxId *Uint256, spendHeight uint32) error
// get a stxo from database
Get(outPoint *OutPoint) (*STXO, error)
// get stxos of the given address hash from database
GetAddrAll(hash *Uint168) ([]*STXO, error)
// Get all STXOs in database
GetAll() ([]*STXO, error)
// delete a stxo from database
Delete(outPoint *OutPoint) error
}
type STXOsDB ¶
func (*STXOsDB) GetAddrAll ¶
get stxos of the given script hash from database
type SortableUTXOs ¶
type SortableUTXOs []*UTXO
func (SortableUTXOs) Len ¶
func (utxos SortableUTXOs) Len() int
func (SortableUTXOs) Less ¶
func (utxos SortableUTXOs) Less(i, j int) bool
func (SortableUTXOs) Swap ¶
func (utxos SortableUTXOs) Swap(i, j int)
type Txs ¶
type Txs interface {
// Put a new transaction to database
Put(txn *db.StoreTx) error
// Fetch a raw tx and it's metadata given a hash
Get(txId *Uint256) (*db.StoreTx, error)
// Fetch all transactions from database
GetAll() ([]*db.StoreTx, error)
// Fetch all transactions from the given height
GetAllFrom(height uint32) ([]*db.StoreTx, error)
// Update the height of a transaction
UpdateHeight(txId *Uint256, height uint32) error
// Delete a transaction from the db
Delete(txId *Uint256) error
}
type TxsDB ¶
func (*TxsDB) GetAllFrom ¶
Fetch all transactions from the given height
func (*TxsDB) UpdateHeight ¶
Update the height of a transaction
type UTXO ¶
type UTXOs ¶
type UTXOs interface {
// put a utxo to database
Put(hash *Uint168, utxo *UTXO) error
// get a utxo from database
Get(outPoint *OutPoint) (*UTXO, error)
// get utxos of the given address hash from database
GetAddrAll(hash *Uint168) ([]*UTXO, error)
// Get all UTXOs in database
GetAll() ([]*UTXO, error)
// delete a utxo from database
Delete(outPoint *OutPoint) error
}
Click to show internal directories.
Click to hide internal directories.