chainstatev3

package
v0.0.0-...-03c569e Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2024 License: MIT Imports: 15 Imported by: 1

Documentation

Index

Constants

View Source
const (
	KeySuffixType_statuskv = "statuskv"

	KeySuffixType_totalsupply = "totalsupply"

	KeySuffixType_balance = "balance"
	KeySuffixType_diamond = "diamond"
	KeySuffixType_channel = "channel"
	KeySuffixType_movebtc = "movebtc"
	KeySuffixType_lockbls = "lockbls"
	KeySuffixType_dmdlend = "dmdlend"
	KeySuffixType_btclend = "btclend"
	KeySuffixType_usrlend = "usrlend"
	KeySuffixType_chaswap = "chaswap"
	KeySuffixType_txhxchk = "txhxchk"
)
View Source
const (
	LastStatusKeyImmutableBlockHash = "immutable_block_hash"
	LastStatusKeyImmatureBlockHashs = "immature_block_hashs"
)

Variables

This section is empty.

Functions

func Test_print_all_address_balance

func Test_print_all_address_balance(ldb *leveldb.DB)

Types

type ChainState

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

func NewChainStateImmutable

func NewChainStateImmutable(cnf *ChainStateConfig) (*ChainState, error)

func (*ChainState) Balance

func (cs *ChainState) Balance(addr fields.Address) (*stores.Balance, error)

func (*ChainState) BalanceDel

func (cs *ChainState) BalanceDel(addr fields.Address) error

func (*ChainState) BalanceSet

func (cs *ChainState) BalanceSet(addr fields.Address, balance *stores.Balance) error

func (*ChainState) BitcoinLendingCreate

func (cs *ChainState) BitcoinLendingCreate(lendid fields.BitcoinSyslendId, stoitem *stores.BitcoinSystemLending) error

Create diamond lending

func (*ChainState) BitcoinLendingDelete

func (cs *ChainState) BitcoinLendingDelete(lendid fields.BitcoinSyslendId) error

delete

func (*ChainState) BitcoinLendingUpdate

func (cs *ChainState) BitcoinLendingUpdate(lendid fields.BitcoinSyslendId, stoitem *stores.BitcoinSystemLending) error

to update

func (*ChainState) BitcoinSystemLending

func (cs *ChainState) BitcoinSystemLending(lendid fields.BitcoinSyslendId) (*stores.BitcoinSystemLending, error)

Diamondlending query

func (ChainState) BlockStore

func (s ChainState) BlockStore() interfaces.BlockStore

func (ChainState) BlockStoreRead

func (s ChainState) BlockStoreRead() interfaces.BlockStoreRead

func (*ChainState) Channel

func (cs *ChainState) Channel(channelid fields.ChannelId) (*stores.Channel, error)

func (*ChainState) ChannelCreate

func (cs *ChainState) ChannelCreate(channel_id fields.ChannelId, channel *stores.Channel) error

func (*ChainState) ChannelDelete

func (cs *ChainState) ChannelDelete(channel_id fields.ChannelId) error

func (*ChainState) ChannelUpdate

func (cs *ChainState) ChannelUpdate(channel_id fields.ChannelId, channel *stores.Channel) error

func (*ChainState) Chaswap

func (cs *ChainState) Chaswap(chaswap_id fields.HashHalfChecker) (*stores.Chaswap, error)

func (*ChainState) ChaswapCreate

func (cs *ChainState) ChaswapCreate(chaswap_id fields.HashHalfChecker, chaswap *stores.Chaswap) error

func (*ChainState) ChaswapDelete

func (cs *ChainState) ChaswapDelete(chaswap_id fields.HashHalfChecker) error

func (*ChainState) ChaswapUpdate

func (cs *ChainState) ChaswapUpdate(chaswap_id fields.HashHalfChecker, chaswap *stores.Chaswap) error

func (*ChainState) CheckTxHash

func (cs *ChainState) CheckTxHash(txhx fields.Hash) (bool, error)

Check whether the transaction is linked

func (*ChainState) Close

func (s *ChainState) Close()

Close file handle, etc

func (*ChainState) ContainTxHash

func (cs *ChainState) ContainTxHash(txhx fields.Hash, blkhei fields.BlockHeight) error

Write include transaction hash

func (*ChainState) Destory

func (s *ChainState) Destory()

Destroy, including deleting all sub States, caches, status data, etc

func (*ChainState) Diamond

func (cs *ChainState) Diamond(diamond fields.DiamondName) (*stores.Diamond, error)

func (*ChainState) DiamondDel

func (cs *ChainState) DiamondDel(diamond_name fields.DiamondName) error

func (*ChainState) DiamondLendingCreate

func (cs *ChainState) DiamondLendingCreate(dmdid fields.DiamondSyslendId, stoitem *stores.DiamondSystemLending) error

func (*ChainState) DiamondLendingDelete

func (cs *ChainState) DiamondLendingDelete(dmdid fields.DiamondSyslendId) error

func (*ChainState) DiamondLendingUpdate

func (cs *ChainState) DiamondLendingUpdate(dmdid fields.DiamondSyslendId, stoitem *stores.DiamondSystemLending) error

func (*ChainState) DiamondSet

func (cs *ChainState) DiamondSet(diamond_name fields.DiamondName, diamond *stores.Diamond) error

func (*ChainState) DiamondSystemLending

func (cs *ChainState) DiamondSystemLending(dmdid fields.DiamondSyslendId) (*stores.DiamondSystemLending, error)

func (*ChainState) ForkNextBlock

func (s *ChainState) ForkNextBlock(hei uint64, hx fields.Hash, blockhead interfaces.Block) (interfaces.ChainState, error)

func (*ChainState) ForkNextBlockObj

func (s *ChainState) ForkNextBlockObj(hei uint64, hx fields.Hash, blockhead interfaces.Block) (*ChainState, error)

func (*ChainState) ForkSubChild

func (s *ChainState) ForkSubChild() (interfaces.ChainState, error)

func (*ChainState) ForkSubChildObj

func (s *ChainState) ForkSubChildObj() (*ChainState, error)

func (*ChainState) GetChildObjs

func (s *ChainState) GetChildObjs() map[uint64]*ChainState

Get all child States

func (*ChainState) GetChilds

func (s *ChainState) GetChilds() map[uint64]interfaces.ChainState

func (ChainState) GetParent

func (s ChainState) GetParent() interfaces.ChainState

func (ChainState) GetParentObj

func (s ChainState) GetParentObj() *ChainState

Get parent status

func (*ChainState) GetPending

func (cs *ChainState) GetPending() interfaces.PendingStatus

func (*ChainState) GetPendingBlockHash

func (cs *ChainState) GetPendingBlockHash() fields.Hash

func (*ChainState) GetPendingBlockHeight

func (cs *ChainState) GetPendingBlockHeight() uint64

func (*ChainState) GetTotalNonEmptyAccountStatistics

func (s *ChainState) GetTotalNonEmptyAccountStatistics() []int64

func (*ChainState) ImmutableStatusRead

func (cs *ChainState) ImmutableStatusRead() (interfaces.ImmutableStatus, error)

func (*ChainState) ImmutableStatusSet

func (cs *ChainState) ImmutableStatusSet(status interfaces.ImmutableStatus) error

func (*ChainState) ImmutableWriteToDisk

func (s *ChainState) ImmutableWriteToDisk() (interfaces.ChainStateImmutable, error)

Save on disk

func (*ChainState) ImmutableWriteToDiskObj

func (s *ChainState) ImmutableWriteToDiskObj() (*ChainState, error)

Save on disk

func (*ChainState) IsDatabaseVersionRebuildMode

func (s *ChainState) IsDatabaseVersionRebuildMode() bool

func (ChainState) IsImmutable

func (s ChainState) IsImmutable() bool

func (*ChainState) IsInTxPool

func (s *ChainState) IsInTxPool() bool

func (*ChainState) LatestStatusRead

func (cs *ChainState) LatestStatusRead() (interfaces.LatestStatus, error)

func (*ChainState) LatestStatusSet

func (cs *ChainState) LatestStatusSet(status interfaces.LatestStatus) error

func (*ChainState) Lockbls

func (cs *ChainState) Lockbls(lkid fields.LockblsId) (*stores.Lockbls, error)

func (*ChainState) LockblsCreate

func (cs *ChainState) LockblsCreate(lkid fields.LockblsId, stoitem *stores.Lockbls) error

func (*ChainState) LockblsDelete

func (cs *ChainState) LockblsDelete(lkid fields.LockblsId) error

func (*ChainState) LockblsUpdate

func (cs *ChainState) LockblsUpdate(lkid fields.LockblsId, stoitem *stores.Lockbls) error

func (*ChainState) ReadLastestBlockHeadMetaForRead

func (cs *ChainState) ReadLastestBlockHeadMetaForRead() (interfaces.BlockHeadMetaRead, error)

func (*ChainState) ReadLastestDiamond

func (cs *ChainState) ReadLastestDiamond() (*stores.DiamondSmelt, error)

func (*ChainState) ReadMoveBTCTxHashByTrsNo

func (cs *ChainState) ReadMoveBTCTxHashByTrsNo(trsno uint32) ([]byte, error)

block data store

func (*ChainState) ReadTotalSupply

func (cs *ChainState) ReadTotalSupply() (*stores.TotalSupply, error)

func (*ChainState) ReadTransactionBytesByHash

func (cs *ChainState) ReadTransactionBytesByHash(txhx fields.Hash) (fields.BlockHeight, []byte, error)

Read transaction content

func (*ChainState) ReadTxBelongHeightByHash

func (cs *ChainState) ReadTxBelongHeightByHash(txhx fields.Hash) (fields.BlockHeight, error)

Check the height of the block to which the exchange belongs

func (*ChainState) RemoveChild

func (s *ChainState) RemoveChild(child *ChainState)

Get all child States

func (*ChainState) RemoveTxHash

func (cs *ChainState) RemoveTxHash(txhx fields.Hash) error

Remove transaction

func (*ChainState) SaveMoveBTCBelongTxHash

func (cs *ChainState) SaveMoveBTCBelongTxHash(trsno uint32, txhash []byte) error

block data store

func (*ChainState) SearchBaseStateByBlockHash

func (s *ChainState) SearchBaseStateByBlockHash(hx fields.Hash) (interfaces.ChainState, error)

func (*ChainState) SearchBaseStateByBlockHashObj

func (s *ChainState) SearchBaseStateByBlockHashObj(hx fields.Hash) (*ChainState, error)

Query the specified status tree location

func (*ChainState) SeekImmatureBlockHashs

func (s *ChainState) SeekImmatureBlockHashs() ([]fields.Hash, error)

Traversing immature block hash

func (*ChainState) SetBlockStoreObj

func (s *ChainState) SetBlockStoreObj(store *blockstorev3.BlockStore)

func (*ChainState) SetDatabaseVersionRebuildMode

func (s *ChainState) SetDatabaseVersionRebuildMode(set bool)

func (*ChainState) SetInTxPool

func (s *ChainState) SetInTxPool(stat bool)

func (*ChainState) SetPending

func (cs *ChainState) SetPending(pd interfaces.PendingStatus) error

func (*ChainState) StatusRead

func (cs *ChainState) StatusRead(name string) ([]byte, error)

func (*ChainState) StatusSet

func (cs *ChainState) StatusSet(name string, value []byte) error

func (*ChainState) TraversalCopy

func (s *ChainState) TraversalCopy(src interfaces.ChainState) error

func (*ChainState) TraversalCopyByObj

func (s *ChainState) TraversalCopyByObj(src *ChainState) error

func (*ChainState) UpdateSetTotalSupply

func (cs *ChainState) UpdateSetTotalSupply(totalobj *stores.TotalSupply) error

func (*ChainState) UserLending

func (cs *ChainState) UserLending(lendid fields.UserLendingId) (*stores.UserLending, error)

Diamondlending query

func (*ChainState) UserLendingCreate

func (cs *ChainState) UserLendingCreate(lendid fields.UserLendingId, stoitem *stores.UserLending) error

Create diamond lending

func (*ChainState) UserLendingDelete

func (cs *ChainState) UserLendingDelete(lendid fields.UserLendingId) error

delete

func (*ChainState) UserLendingUpdate

func (cs *ChainState) UserLendingUpdate(lendid fields.UserLendingId, stoitem *stores.UserLending) error

to update

type ChainStateConfig

type ChainStateConfig struct {
	Datadir string

	BTCMoveCheckEnable  bool
	BTCMoveCheckLogsURL string

	// Database rebuild mode
	DatabaseVersionRebuildMode bool
}

func NewChainStateConfig

func NewChainStateConfig(cnffile *sys.Inicnf) *ChainStateConfig

func NewEmptyChainStateConfig

func NewEmptyChainStateConfig() *ChainStateConfig

type ImmutableStatus

type ImmutableStatus struct {

	// Mature block
	ImmutableBlockHeadMetaIsExist fields.Bool
	ImmutableBlockHeadMeta        interfaces.BlockHeadMetaRead

	// Latest block header
	LatestBlockHashIsExist fields.Bool
	LatestBlockHash        fields.Hash

	// Immature block hash
	ImmatureBlockHashCount fields.VarUint2
	ImmatureBlockHashs     []fields.Hash
}

func NewInitialImmutableStatus

func NewInitialImmutableStatus() *ImmutableStatus

func (*ImmutableStatus) GetImmatureBlockHashList

func (p *ImmutableStatus) GetImmatureBlockHashList() []fields.Hash

func (*ImmutableStatus) GetImmutableBlockHeadMeta

func (p *ImmutableStatus) GetImmutableBlockHeadMeta() interfaces.BlockHeadMetaRead

func (*ImmutableStatus) GetLatestBlockHash

func (p *ImmutableStatus) GetLatestBlockHash() fields.Hash

func (*ImmutableStatus) Parse

func (p *ImmutableStatus) Parse(buf []byte, seek uint32) (uint32, error)

func (*ImmutableStatus) Serialize

func (p *ImmutableStatus) Serialize() ([]byte, error)

func (*ImmutableStatus) SetImmatureBlockHashList

func (p *ImmutableStatus) SetImmatureBlockHashList(list []fields.Hash)

func (*ImmutableStatus) SetImmutableBlockHeadMeta

func (p *ImmutableStatus) SetImmutableBlockHeadMeta(head interfaces.BlockHeadMetaRead)

func (*ImmutableStatus) SetLatestBlockHash

func (p *ImmutableStatus) SetLatestBlockHash(hx fields.Hash)

func (*ImmutableStatus) Size

func (p *ImmutableStatus) Size() uint32

type LatestStatus

type LatestStatus struct {
	// Latest block diamond
	LatestDiamondIsExist fields.Bool
	LatestDiamond        *stores.DiamondSmelt
}

func NewInitialLatestStatus

func NewInitialLatestStatus() *LatestStatus

func (*LatestStatus) Parse

func (p *LatestStatus) Parse(buf []byte, seek uint32) (uint32, error)

func (*LatestStatus) ReadLastestDiamond

func (p *LatestStatus) ReadLastestDiamond() *stores.DiamondSmelt

func (*LatestStatus) Serialize

func (p *LatestStatus) Serialize() ([]byte, error)

func (*LatestStatus) SetLastestDiamond

func (p *LatestStatus) SetLastestDiamond(diamond *stores.DiamondSmelt)

func (*LatestStatus) Size

func (p *LatestStatus) Size() uint32

type MemoryStorageItem

type MemoryStorageItem struct {
	IsDelete bool   // Tag deleted
	Value    []byte // data
}

func NewDeleteMarkItem

func NewDeleteMarkItem() *MemoryStorageItem

func NewStorageItem

func NewStorageItem(value []byte) *MemoryStorageItem

type PendingStatus

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

func NewPendingStatus

func NewPendingStatus(hei uint64, hx fields.Hash, blockhead interfaces.BlockHeadMetaRead) *PendingStatus

func (*PendingStatus) ClearWaitingSubmitDiamond

func (p *PendingStatus) ClearWaitingSubmitDiamond()

func (*PendingStatus) GetPendingBlockHash

func (p *PendingStatus) GetPendingBlockHash() fields.Hash

func (*PendingStatus) GetPendingBlockHead

func (p *PendingStatus) GetPendingBlockHead() interfaces.BlockHeadMetaRead

func (*PendingStatus) GetPendingBlockHeight

func (p *PendingStatus) GetPendingBlockHeight() uint64

func (*PendingStatus) GetWaitingSubmitDiamond

func (p *PendingStatus) GetWaitingSubmitDiamond() *stores.DiamondSmelt

func (*PendingStatus) Parse

func (p *PendingStatus) Parse(buf []byte, seek uint32) (uint32, error)

func (*PendingStatus) Serialize

func (p *PendingStatus) Serialize() ([]byte, error)

func (*PendingStatus) SetWaitingSubmitDiamond

func (p *PendingStatus) SetWaitingSubmitDiamond(diamond *stores.DiamondSmelt)

func (*PendingStatus) Size

func (p *PendingStatus) Size() uint32

Jump to

Keyboard shortcuts

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