store

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2021 License: MIT Imports: 20 Imported by: 4

Documentation

Index

Constants

View Source
const DefaultFeeRate common.Fixed64 = 1e8

Variables

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

	// 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")
	BKTConsensus       = []byte("consensus")

	//ReturnSideChainDepositCoin
	BKTReturnSideChainDepositCoin = []byte("retschdepositcoin")
)
View Source
var BKTChangeCustomIDFee = []byte("CF")
View Source
var BKTLastCustomIDFee = []byte("CH")
View Source
var BKTReceivedCustomID = []byte("RC")
View Source
var BKTReservedCustomID = []byte("RS")

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 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)
}

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 *types.Transaction, batch *leveldb.Batch) error
	BatchDeleteRetSideChainDepositCoinTx(tx *types.Transaction, batch *leveldb.Batch) error

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

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

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

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
	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 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