store

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2023 License: MIT Imports: 23 Imported by: 4

Documentation

Index

Constants

View Source
const (
	DefaultConfirmations uint32         = 6
	DefaultFeeRate       common.Fixed64 = 1e8
)

Variables

View Source
var (
	// addresses
	BKTAddrs = []byte("addrs")

	// transaction types
	BKTTxTypes = []byte("txtypes")

	// headers
	BKTHeaders  = []byte("headers")
	BKTIndexes  = []byte("indexes")
	BKTChainTip = []byte("chaintip")

	// ops
	BKTOps = []byte("ops")

	// que
	BKTQue    = []byte("que")
	BKTQueIdx = []byte("qindex")

	// transactions
	BKTTxs       = []byte("transactions")
	BKTHeightTxs = []byte("heighttxs")
	BKTForkTxs   = []byte("forktxs")

	// arbiters
	BKTArbiters          = []byte("arbiters")
	BKTArbPosition       = []byte("arbptn")
	BKTArbPositions      = []byte("arbpts")
	BKTArbitersData      = []byte("arbdata")
	BKTTransactionHeight = []byte("txheight")

	// revert to pow
	BKTRevertPosition  = []byte("revertp")
	BKTRevertPositions = []byte("revertps")

	//ReturnSideChainDepositCoin
	BKTReturnSideChainDepositCoin = []byte("retschdepositcoin")

	BKTReservedCustomID     = []byte("rscid")
	BKTReceivedCustomID     = []byte("rccid")
	BKTChangeCustomIDFee    = []byte("ccidf")
	BKTCustomIDFeePositions = []byte("cidfps")
)

Functions

func NewAddrs

func NewAddrs(db *leveldb.DB) (*addrs, error)

func NewArbiters added in v0.0.5

func NewArbiters(db *leveldb.DB, originArbiters [][]byte, arbitersCount int) *arbiters

func NewCustomID added in v0.0.7

func NewCustomID(db *leveldb.DB, GenesisBlockAddress string) *customID

func NewDataStore

func NewDataStore(dataDir string, originArbiters [][]byte, arbitersCount int, GenesisBlockAddress string) (*dataStore, error)

//this spv GenesisBlockAddress

GenesisBlockAddress    string

func NewHeaderStore

func NewHeaderStore(dataDir string, newHeader func() util.BlockHeader) (*headers, error)

func NewOps

func NewOps(db *leveldb.DB) *ops

func NewQue

func NewQue(db *leveldb.DB) *que

func NewTxTypes added in v0.1.0

func NewTxTypes(db *leveldb.DB) (*txTypes, error)

func NewTxs

func NewTxs(db *leveldb.DB) *txs

Types

type Addrs

type Addrs interface {
	database.DB
	GetFilter() *sdk.AddrFilter
	Put(addr *common.Uint168) error
	GetAll() []*common.Uint168
}

type Arbiters added in v0.0.5

type Arbiters interface {
	database.DB
	Put(height uint32, crcArbiters [][]byte, normalArbiters [][]byte) error
	BatchPut(height uint32, crcArbiters [][]byte, normalArbiters [][]byte, batch *leveldb.Batch) error
	Get() (crcArbiters [][]byte, normalArbiters [][]byte, err error)
	GetNext() (workingHeight uint32, crcArbiters [][]byte, normalArbiters [][]byte, err error)
	GetByHeight(height uint32) (crcArbiters [][]byte, normalArbiters [][]byte, err error)
	BatchPutRevertTransaction(batch *leveldb.Batch, workingHeight uint32, mode byte) error
	GetConsensusAlgorithmByHeight(height uint32) (byte, error)
	GetRevertInfo() []RevertInfo
}

type CustomID added in v0.0.7

type CustomID interface {
	database.DB
	PutControversialReservedCustomIDs(
		reservedCustomIDs []string, proposalHash common.Uint256) error
	BatchPutControversialReservedCustomIDs(reservedCustomIDs []string,
		proposalHash common.Uint256, batch *leveldb.Batch) error
	BatchDeleteControversialReservedCustomIDs(
		proposalHash common.Uint256, batch *leveldb.Batch)

	PutControversialReceivedCustomIDs(reservedCustomIDs []string,
		did common.Uint168, proposalHash common.Uint256) error
	BatchPutControversialReceivedCustomIDs(receivedCustomIDs []string,
		did common.Uint168, proposalHash common.Uint256, batch *leveldb.Batch) error
	BatchDeleteControversialReceivedCustomIDs(
		proposalHash common.Uint256, batch *leveldb.Batch)

	BatchPutRetSideChainDepositCoinTx(tx it.Transaction, batch *leveldb.Batch) error
	BatchDeleteRetSideChainDepositCoinTx(tx it.Transaction, batch *leveldb.Batch) error

	PutControversialChangeCustomIDFee(rate common.Fixed64,
		proposalHash common.Uint256, workingHeight uint32) error

	BatchPutControversialChangeCustomIDFee(rate common.Fixed64,
		proposalHash common.Uint256, workingHeight uint32, batch *leveldb.Batch) error
	BatchDeleteControversialChangeCustomIDFee(
		proposalHash common.Uint256, batch *leveldb.Batch)

	PutCustomIDProposalResults(results []payload.ProposalResult, height uint32) error
	BatchPutCustomIDProposalResults(results []payload.ProposalResult, height uint32, batch *leveldb.Batch) error

	GetReservedCustomIDs(height uint32, info []RevertInfo) (map[string]struct{}, error)
	GetReceivedCustomIDs(height uint32, info []RevertInfo) (map[string]common.Uint168, error)
	GetCustomIDFeeRate(height uint32) (common.Fixed64, error)
	//Is this RetSideChainDepositCoin tx exist
	HaveRetSideChainDepositCoinTx(txHash common.Uint256) bool
}

type CustomIDInfo added in v0.1.0

type CustomIDInfo struct {
	DID    common.Uint168
	Height uint32
}

type DataBatch

type DataBatch interface {
	Txs() TxsBatch
	Ops() OpsBatch
	Que() QueBatch
	GetNakedBatch() *leveldb.Batch
	// Delete all transactions, ops, queued items on
	// the given height.
	DelAll(height uint32) error
	// contains filtered or unexported methods
}

type DataStore

type DataStore interface {
	database.DB
	Addrs() Addrs
	TxTypes() TxTypes
	Txs() Txs
	Ops() Ops
	Que() Que
	Arbiters() Arbiters
	CID() CustomID
	Batch() DataBatch
}

type HeaderStore

type HeaderStore interface {
	database.Headers
	GetByHeight(height uint32) (header *util.Header, err error)
}

type Ops

type Ops interface {
	database.DB
	Put(*util.OutPoint, common.Uint168) error
	HaveOp(*util.OutPoint) *common.Uint168
	GetAll() ([]*util.OutPoint, error)
	Batch() OpsBatch
}

type OpsBatch

type OpsBatch interface {
	Put(*util.OutPoint, common.Uint168) error
	Del(*util.OutPoint) error
	// contains filtered or unexported methods
}

type Que

type Que interface {
	database.DB

	// Put a queue item to database
	Put(item *QueItem) error

	// Get all items in queue
	GetAll() ([]*QueItem, error)

	// Delete confirmed item in queue
	Del(notifyId, txHash *common.Uint256) error

	// Batch returns a queue batch instance.
	Batch() QueBatch
}

type QueBatch

type QueBatch interface {

	// Put a queue item to database
	Put(item *QueItem) error

	// Delete confirmed item in queue
	Del(notifyId, txHash *common.Uint256) error

	// Delete all items on the given height.
	DelAll(height uint32) error
	// contains filtered or unexported methods
}

type QueItem

type QueItem struct {
	NotifyId   common.Uint256
	TxId       common.Uint256
	Height     uint32
	LastNotify time.Time
}

type RevertInfo added in v0.1.0

type RevertInfo struct {
	WorkingHeight uint32
	Mode          byte
}

type TxTypes added in v0.1.0

type TxTypes interface {
	database.DB
	GetFilter() *sdk.TxTypesFilter
	Put(txType uint8) error
	GetAll() []uint8
}

type Txs

type Txs interface {
	database.DB
	Put(tx *util.Tx) error
	Get(txId *common.Uint256) (*util.Tx, error)
	GetAll() ([]*util.Tx, error)
	GetIds(height uint32) ([]*common.Uint256, error)
	PutForkTxs(txs []*util.Tx, hash *common.Uint256) error
	GetForkTxs(hash *common.Uint256) ([]*util.Tx, error)
	Del(txId *common.Uint256) error
	Batch() TxsBatch
}

type TxsBatch

type TxsBatch interface {
	Put(tx *util.Tx) error
	Del(txId *common.Uint256) error
	DelAll(height uint32) error
	// contains filtered or unexported methods
}

Jump to

Keyboard shortcuts

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