interfacev2

package
v0.0.0-...-425d0f2 Latest Latest
Warning

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

Go to latest
Published: Feb 29, 2024 License: MIT Imports: 3 Imported by: 20

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action interface {

	// the action type number
	Kind() uint16

	// assembling datas
	Serialize() ([]byte, error)
	Parse([]byte, uint32) (uint32, error)
	Size() uint32

	// Addresses that need to verify signatures
	RequestSignAddresses() []fields.Address

	// change chain state
	WriteinChainState(ChainStateOperation) error
	RecoverChainState(ChainStateOperation) error

	// help func
	SetBelongTransaction(Transaction)
	Describe() map[string]interface{} // json api

	// burning fees
	IsBurning90PersentTxFees() bool // Whether to destroy 90% of the transaction cost of this transaction
}

type Block

type Block interface {

	// origin
	OriginMark() string // "", "sync", "discover", "mining"
	SetOriginMark(string)

	// delete cache data
	Fresh()

	// the block type number
	Version() uint8

	// assembling datas
	Serialize() ([]byte, error)
	Parse([]byte, uint32) (uint32, error)
	Size() uint32

	SerializeHead() ([]byte, error)
	ParseHead([]byte, uint32) (uint32, error)

	SerializeBody() ([]byte, error)
	ParseBody([]byte, uint32) (uint32, error)

	SerializeMeta() ([]byte, error)
	ParseMeta([]byte, uint32) (uint32, error)

	SerializeTransactions(SerializeTransactionsIterator) ([]byte, error)
	ParseTransactions([]byte, uint32) (uint32, error)

	SerializeExcludeTransactions() ([]byte, error)
	ParseExcludeTransactions([]byte, uint32) (uint32, error)

	// change chain state
	WriteinChainState(ChainStateOperation) error
	RecoverChainState(ChainStateOperation) error

	// hash
	Hash() fields.Hash
	HashFresh() fields.Hash

	// change struct data
	AddTransaction(Transaction)
	SetTransactions([]Transaction)
	SetMrklRoot(fields.Hash)
	SetNonce(uint32)
	SetNonceByte(nonce []byte)

	// verify signatures
	VerifyNeedSigns() (bool, error)

	GetTransactions() []Transaction
	GetHeight() uint64
	GetDifficulty() uint32
	GetWitnessStage() uint16
	GetNonce() uint32
	GetNonceByte() []byte
	GetPrevHash() fields.Hash
	GetTimestamp() uint64
	GetTransactionCount() uint32
	GetMrklRoot() fields.Hash

	// customer trs count
	GetCustomerTransactionCount() uint32
}

type BlockStore

type BlockStore interface {

	// close
	Close()

	// save
	SaveBlockUniteTransactions(Block) error
	// cancel
	CancelUniteTransactions(Block) error

	// block
	ReadLastBlockHeight() (uint64, error)

	ReadBlockHeadBytesByHeight(uint64) ([]byte, error)
	ReadBlockHeadBytesByHash(fields.Hash) ([]byte, error)
	ReadBlockBytesLengthByHeight(uint64, uint32) (fields.Hash, []byte, error)
	ReadBlockBytesByHeight(uint64) (fields.Hash, []byte, error)
	ReadBlockBytesLengthByHash(fields.Hash, uint32) ([]byte, error)
	ReadBlockBytesByHash(fields.Hash) ([]byte, error)
	ReadBlockHashByHeight(uint64) (fields.Hash, error)

	// tx
	ReadTransactionBytesByHash(fields.Hash) (uint64, []byte, error)
	TransactionIsExist(fields.Hash) (bool, error)

	// diamond
	SaveDiamond(*stores.DiamondSmelt) error
	ReadDiamond(fields.DiamondName) (*stores.DiamondSmelt, error)
	ReadDiamondByNumber(uint32) (*stores.DiamondSmelt, error)
	ReadDiamondNameByNumber(uint32) (fields.DiamondName, error)

	// delete
	DeleteTransactionByHash(fields.Hash) error

	// btc move log
	GetBTCMoveLogTotalPage() (int, error)                        // Number of data pages, 100 pieces of data per page
	GetBTCMoveLogPageData(int) ([]*stores.SatoshiGenesis, error) // Get data page
	SaveBTCMoveLogPageData(int, []*stores.SatoshiGenesis) error  // Save data page

}

type ChainState

type ChainState interface {
	ChainStateOperation

	Fork() (ChainState, error)
	Close()   // close
	Destory() // Destruction, including deletion of all document stores

}

type ChainStateOperation

type ChainStateOperation interface {
	// Database upgrade mode
	IsDatabaseVersionRebuildMode() bool
	SetDatabaseVersionRebuildMode(bool)

	// status
	IsInTxPool() bool // No in the trading pool
	SetInTxPool(bool)

	// status
	GetPendingBlockHeight() uint64
	SetPendingBlockHeight(uint64)
	GetPendingBlockHash() fields.Hash
	SetPendingBlockHash(fields.Hash)

	GetPendingSubmitStoreDiamond() (*stores.DiamondSmelt, error)
	SetPendingSubmitStoreDiamond(*stores.DiamondSmelt) error

	// status
	SetLastestBlockHeadAndMeta(Block) error
	ReadLastestBlockHeadAndMeta() (Block, error)
	SetLastestDiamond(*stores.DiamondSmelt) error
	ReadLastestDiamond() (*stores.DiamondSmelt, error)

	UpdateSetTotalSupply(totalobj *stores.TotalSupply) error
	ReadTotalSupply() (*stores.TotalSupply, error)

	// store
	BlockStore() BlockStore
	SetBlockStore(BlockStore) error

	// tx hash
	ContainTxHash(fields.Hash, fields.BlockHeight) error // Write include transaction hash
	RemoveTxHash(fields.Hash) error                      // Remove transaction
	CheckTxHash(fields.Hash) (bool, error)               // Check whether the transaction has been linked

	Balance(fields.Address) (*stores.Balance, error)
	//Satoshi(fields.Address) *stores.Satoshi
	Lockbls(fields.LockblsId) (*stores.Lockbls, error)
	Channel(fields.ChannelId) (*stores.Channel, error)
	Diamond(fields.DiamondName) (*stores.Diamond, error)
	DiamondSystemLending(fields.DiamondSyslendId) (*stores.DiamondSystemLending, error)
	BitcoinSystemLending(fields.BitcoinSyslendId) (*stores.BitcoinSystemLending, error)
	UserLending(fields.UserLendingId) (*stores.UserLending, error)
	Chaswap(fields.HashHalfChecker) (*stores.Chaswap, error)

	BalanceSet(fields.Address, *stores.Balance) error
	BalanceDel(fields.Address) error

	LockblsCreate(fields.LockblsId, *stores.Lockbls) error // Create linear lock
	LockblsUpdate(fields.LockblsId, *stores.Lockbls) error // Update: release (take out any available quota)
	LockblsDelete(fields.LockblsId) error                  // Automatically delete after release

	ChannelCreate(fields.ChannelId, *stores.Channel) error
	ChannelUpdate(fields.ChannelId, *stores.Channel) error
	ChannelDelete(fields.ChannelId) error

	DiamondSet(fields.DiamondName, *stores.Diamond) error
	DiamondDel(fields.DiamondName) error

	DiamondLendingCreate(fields.DiamondSyslendId, *stores.DiamondSystemLending) error
	DiamondLendingUpdate(fields.DiamondSyslendId, *stores.DiamondSystemLending) error
	DiamondLendingDelete(fields.DiamondSyslendId) error

	BitcoinLendingCreate(fields.BitcoinSyslendId, *stores.BitcoinSystemLending) error
	BitcoinLendingUpdate(fields.BitcoinSyslendId, *stores.BitcoinSystemLending) error
	BitcoinLendingDelete(fields.BitcoinSyslendId) error

	UserLendingCreate(fields.UserLendingId, *stores.UserLending) error
	UserLendingUpdate(fields.UserLendingId, *stores.UserLending) error
	UserLendingDelete(fields.UserLendingId) error

	ChaswapCreate(fields.HashHalfChecker, *stores.Chaswap) error
	ChaswapUpdate(fields.HashHalfChecker, *stores.Chaswap) error
	ChaswapDelete(fields.HashHalfChecker) error

	// movebtc
	SaveMoveBTCBelongTxHash(trsno uint32, txhash []byte) error
	ReadMoveBTCTxHashByNumber(trsno uint32) ([]byte, error)
	LoadValidatedSatoshiGenesis(int64) (*stores.SatoshiGenesis, bool) // Get verified BTC transfer logs  获取已验证的BTC转移日志 & 是否需要验证 whether verification is required

}

type Field

type Field interface {

	// assembling datas
	Serialize() ([]byte, error)
	Parse([]byte, uint32) (uint32, error)
	Size() uint32
}

type HacashNode

type HacashNode interface {
	Launch(inicnffilepath string) error

	StartMining()
	StopMining()
}

type SerializeTransactionsIterator

type SerializeTransactionsIterator interface {
	Init(uint32)
	FinishOneTrs(uint32, Transaction, []byte)
}

type StoreItem

type StoreItem interface {

	// assembling datas
	Serialize() ([]byte, error)
	Parse([]byte, uint32) (uint32, error)
	Size() uint32
}

type Transaction

type Transaction interface {
	ClearHash() // Clear hash cache

	Copy() Transaction

	// the transaction type number
	Type() uint8

	// assembling datas
	Serialize() ([]byte, error)
	Parse([]byte, uint32) (uint32, error)
	Size() uint32

	// hash data
	Hash() fields.Hash        // Hash without service charge
	HashWithFee() fields.Hash // inclued fee amount

	// Addresses that need to verify signatures
	RequestSignAddresses(appends []fields.Address, dropfeeaddr bool) ([]fields.Address, error)

	// sign
	CleanSigns()
	GetSigns() []fields.Sign // Return all signature data
	SetSigns([]fields.Sign)  // Set signature data
	// fill signatures
	FillTargetSign(signacc *account.Account) error           // Designated account signature
	FillNeedSigns(map[string][]byte, []fields.Address) error // All signatures
	// verify signatures
	VerifyAllNeedSigns() (bool, error)
	VerifyTargetSigns(reqaddr []fields.Address) (bool, error)

	// change chain state
	WriteinChainState(ChainStateOperation) error
	RecoverChainState(ChainStateOperation) error

	// fee
	FeePurity() uint32 // fee purity

	// get something
	GetAddress() fields.Address
	SetAddress(fields.Address)
	// Transaction costs actually received by miners
	// If some transactions receive less handling charges than they originally paid, the rest will be destroyed
	GetFeeOfMinerRealReceived() *fields.Amount
	GetFee() *fields.Amount
	SetFee(*fields.Amount)
	GetActions() []Action
	GetTimestamp() uint64
	GetMessage() fields.TrimString16
	SetMessage(fields.TrimString16)
}

Jump to

Keyboard shortcuts

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