sqlite

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2019 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

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 CreateSTXOsDB = `` /* 255-byte string literal not displayed */
View Source
const CreateStateDB = `CREATE TABLE IF NOT EXISTS State(
				Key NOT NULL PRIMARY KEY,
				Value BLOB NOT NULL
			);`
View Source
const CreateTxsDB = `` /* 303-byte string literal not displayed */
View Source
const CreateUTXOsDB = `` /* 192-byte string literal not displayed */
View Source
const (
	DriverName = "sqlite3"
)
View Source
const (
	HeightKey = "Height"
)

Variables

This section is empty.

Functions

func DisableLog

func DisableLog()

DisableLog disables all library log output. Logging output is disabled by default until either UseLogger or SetLogWriter are called.

func NewAddrs

func NewAddrs(db *sql.DB, lock *sync.RWMutex) (*addrs, error)

func NewDatabase

func NewDatabase(dataDir string) (*database, error)

func NewSTXOs

func NewSTXOs(db *sql.DB, lock *sync.RWMutex) (*stxos, error)

func NewState

func NewState(db *sql.DB, lock *sync.RWMutex) (*state, error)

func NewTxs

func NewTxs(db *sql.DB, lock *sync.RWMutex) (*txs, error)

func NewUTXOs

func NewUTXOs(db *sql.DB, lock *sync.RWMutex) (*utxos, error)

func UseLogger

func UseLogger(logger elalog.Logger)

UseLogger uses a specified Logger to output package logging info. This should be used in preference to SetLogWriter if the caller is also using elalog.

Types

type Addrs

type Addrs interface {
	// put a address to database
	Put(hash *common.Uint168, script []byte, addrType int) error

	// get a address from database
	Get(hash *common.Uint168) (*sutil.Addr, error)

	// get all addresss from database
	GetAll() ([]*sutil.Addr, error)

	// delete a address from database
	Del(hash *common.Uint168) error

	// Batch return a AddrsBatch
	Batch() AddrsBatch
}

type AddrsBatch

type AddrsBatch interface {

	// put a address to database
	Put(hash *common.Uint168, script []byte, addrType int) error

	// delete a address from database
	Del(hash *common.Uint168) error
	// contains filtered or unexported methods
}

type DataBatch

type DataBatch interface {
	Addrs() AddrsBatch
	Txs() TxsBatch
	UTXOs() UTXOsBatch
	STXOs() STXOsBatch
	RollbackHeight(height uint32) error
	// contains filtered or unexported methods
}

type DataStore

type DataStore interface {
	State() State
	Addrs() Addrs
	Txs() Txs
	UTXOs() UTXOs
	STXOs() STXOs
	Batch() DataBatch
	Clear() error
	Close() error
}

type STXOs

type STXOs interface {
	// Put save a STXO into database
	Put(stxo *sutil.STXO) error

	// get a stxo from database
	Get(op *util.OutPoint) (*sutil.STXO, error)

	// get stxos of the given address hash from database
	GetAddrAll(hash *common.Uint168) ([]*sutil.STXO, error)

	// Get all STXOs in database
	GetAll() ([]*sutil.STXO, error)

	// delete a stxo from database
	Del(outPoint *util.OutPoint) error

	// Batch return a STXOsBatch.
	Batch() STXOsBatch
}

type STXOsBatch

type STXOsBatch interface {

	// Put save a STXO into database
	Put(stxo *sutil.STXO) error

	// delete a stxo from database
	Del(outPoint *util.OutPoint) error
	// contains filtered or unexported methods
}

type State

type State interface {
	// save state height
	PutHeight(height uint32)

	// get state height
	GetHeight() uint32
}

type Txs

type Txs interface {
	// Put a new transaction to database
	Put(tx *util.Tx) error

	// Fetch a raw tx and it's metadata given a hash
	Get(txId *common.Uint256) (*util.Tx, error)

	// Fetch all transactions from database
	GetAll() ([]*util.Tx, error)

	// Fetch all transactions from the given height.
	GetAllFrom(height uint32) ([]*util.Tx, error)

	// Fetch all unconfirmed transactions.
	GetAllUnconfirmed() ([]*util.Tx, error)

	// Delete a transaction from the db
	Del(txId *common.Uint256) error

	// PutForkTxs persists the fork chain transactions into database with the
	// fork block hash and can be queried by GetForkTxs(hash).
	PutForkTxs(txs []*util.Tx, hash *common.Uint256) error

	// GetForkTxs returns all transactions within the fork block hash.
	GetForkTxs(hash *common.Uint256) ([]*util.Tx, error)

	// Batch return a TxsBatch
	Batch() TxsBatch
}

type TxsBatch

type TxsBatch interface {

	// Put a new transaction to database
	Put(tx *util.Tx) error

	// Delete a transaction from the db
	Del(txId *common.Uint256) error
	// contains filtered or unexported methods
}

type UTXOs

type UTXOs interface {
	// put a utxo to database
	Put(utxo *sutil.UTXO) error

	// get a utxo from database
	Get(op *util.OutPoint) (*sutil.UTXO, error)

	// get utxos of the given address hash from database
	GetAddrAll(hash *common.Uint168) ([]*sutil.UTXO, error)

	// Get all UTXOs in database
	GetAll() ([]*sutil.UTXO, error)

	// delete a utxo from database
	Del(outPoint *util.OutPoint) error

	// Batch return a UTXOsBatch.
	Batch() UTXOsBatch
}

type UTXOsBatch

type UTXOsBatch interface {

	// put a utxo to database
	Put(utxo *sutil.UTXO) error

	// delete a utxo from database
	Del(outPoint *util.OutPoint) error
	// contains filtered or unexported methods
}

Jump to

Keyboard shortcuts

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