Documentation
¶
Index ¶
- type Action
- type Backend
- type Block
- type BlockChain
- type BlockHeadMetaRead
- type BlockStore
- type BlockStoreRead
- type ChainEngine
- type ChainState
- type ChainStateImmutable
- type ChainStateOperation
- type ChainStateOperationRead
- type Field
- type ImmutableStatus
- type LatestStatus
- type Miner
- type P2PManager
- type P2PMsgCommunicator
- type P2PMsgDataHandler
- type P2PMsgPeer
- type PendingStatus
- type PowDevice
- type PowServer
- type PowWorker
- type PowWorkerMiningStuffItem
- type Transaction
- type TxPool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Action ¶
type Action interface { // base super Field // the action type number Kind() uint16 // Addresses that need to verify signatures RequestSignAddresses() []fields.Address // change chain state WriteInChainState(ChainStateOperation) error // help func SetBelongTrs(Transaction) Describe() map[string]interface{} // json api // burning fees IsBurning90PersentTxFees() bool // Whether to destroy 90% of the transaction cost of this transaction }
type Backend ¶
type Backend interface { BlockChain() BlockChain AllPeersDescribe() string }
type Block ¶
type Block interface { // base super Field // origin OriginMark() string // "", "sync", "discover", "mining" SetOriginMark(string) // copy CopyHeadMetaForMining() Block CopyForMining() Block // delete cache data Fresh() // the block type number Version() uint8 SerializeHead() ([]byte, error) ParseHead([]byte, uint32) (uint32, error) SerializeBody() ([]byte, error) ParseBody([]byte, uint32) (uint32, error) SerializeMeta() ([]byte, error) ParseMeta([]byte, uint32) (uint32, error) ParseTransactions([]byte, uint32) (uint32, error) SerializeExcludeTransactions() ([]byte, error) ParseExcludeTransactions([]byte, uint32) (uint32, error) // change chain state WriteInChainState(ChainStateOperation) error // hash Hash() fields.Hash HashFresh() fields.Hash // change struct data AddTrs(Transaction) SetTrsList([]Transaction) SetMrklRoot(fields.Hash) SetNonce(uint32) SetNonceByte(nonce []byte) // verify signatures VerifyNeedSigns() (bool, error) GetTrsList() []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 BlockChain ¶
type BlockChain interface { Start() error GetChainEngineKernel() ChainEngine SetChainEngineKernel(ChainEngine) ValidateTransactionForTxPool(Transaction) error ValidateDiamondCreateAction(Action) error CreateNextBlockByValidateTxs([]Transaction) (Block, []Transaction, uint32, error) }
type BlockHeadMetaRead ¶
type BlockHeadMetaRead interface { Hash() fields.Hash Version() uint8 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 SerializeExcludeTransactions() ([]byte, error) ParseExcludeTransactions([]byte, uint32) (uint32, error) }
type BlockStore ¶
type BlockStore interface { BlockStoreRead // close Close() // save SaveBlock(Block) error // Set the block hash that the block height points to UpdateSetBlockHashReferToHeight(uint64, fields.Hash) error // diamond SaveDiamond(*stores.DiamondSmelt) error // Set the diamond name pointed by the diamond number UpdateSetDiamondNameReferToNumber(uint32, fields.DiamondName) error // btc move log RunDownLoadBTCMoveLog() SaveBTCMoveLogPageData(int, []*stores.SatoshiGenesis) error // Save data page LoadValidatedSatoshiGenesis(int64) (*stores.SatoshiGenesis, bool) // Get verified BTC transfer logs 获取已验证的BTC转移日志 & 是否需要验证 whether verification is required }
type BlockStoreRead ¶
type BlockStoreRead interface { // read ReadBlockBytesByHash(fields.Hash) ([]byte, error) ReadBlockBytesByHeight(uint64) (fields.Hash, []byte, error) ReadBlockHashByHeight(uint64) (fields.Hash, error) ReadDiamond(fields.DiamondName) (*stores.DiamondSmelt, error) ReadDiamondByNumber(uint32) (*stores.DiamondSmelt, error) ReadDiamondNameByNumber(uint32) (fields.DiamondName, error) GetBTCMoveLogTotalPage() (int, error) // Number of data pages, 100 pieces of data per page GetBTCMoveLogPageData(int) ([]*stores.SatoshiGenesis, error) // Get data page }
type ChainEngine ¶
type ChainEngine interface { Start() error Close() error ChainStateIinitializeCall(func(ChainStateOperation)) InsertBlock(Block, string) error StateRead() ChainStateOperationRead // Read-only status CurrentState() ChainState // Latest status LatestBlock() (BlockHeadMetaRead, BlockHeadMetaRead, error) // Latest blocks (confirmed and immature) LatestDiamond() (*stores.DiamondSmelt, error) // Latest block diamonds SubscribeValidatedBlockOnInsert(chan Block) SubscribeDiamondOnCreate(chan *stores.DiamondSmelt) }
type ChainState ¶
type ChainState interface { ChainStateOperation // Get parent status GetParent() ChainState // Get all child States GetChilds() map[uint64]ChainState // Start a sub state ForkNextBlock(uint64, fields.Hash, Block) (ChainState, error) ForkSubChild() (ChainState, error) TraversalCopy(ChainState) error //GetReferBlock() (uint64, fields.Hash) SearchBaseStateByBlockHash(fields.Hash) (ChainState, error) // Destruction Destory() // Destroy, including deleting all sub States, caches, status data, etc // Judgment type IsImmutable() bool // Save on disk ImmutableWriteToDisk() (ChainStateImmutable, error) GetTotalNonEmptyAccountStatistics() []int64 }
type ChainStateImmutable ¶
type ChainStateImmutable interface { ChainState // Traversing immature block hash SeekImmatureBlockHashs() ([]fields.Hash, error) Close() // Close file handle, etc }
Immutable, non fallback lock status data
type ChainStateOperation ¶
type ChainStateOperation interface { ChainStateOperationRead // Database upgrade mode SetDatabaseVersionRebuildMode(bool) // status SetInTxPool(bool) GetPending() PendingStatus SetPending(PendingStatus) error LatestStatusRead() (LatestStatus, error) LatestStatusSet(LatestStatus) error UpdateSetTotalSupply(totalobj *stores.TotalSupply) error // store BlockStore() BlockStore // tx hash ContainTxHash(fields.Hash, fields.BlockHeight) error // Write include transaction hash RemoveTxHash(fields.Hash) error // Remove transaction 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 }
type ChainStateOperationRead ¶
type ChainStateOperationRead interface { // Database upgrade mode IsDatabaseVersionRebuildMode() bool // status IsInTxPool() bool // No in the trading pool //GetPending() (PendingStatus) GetPendingBlockHeight() uint64 GetPendingBlockHash() fields.Hash //LatestStatusRead() (LatestStatus, error) //ReadLastestBlockHeadMetaForRead() (BlockHeadMetaRead, error) ReadLastestDiamond() (*stores.DiamondSmelt, error) ReadTotalSupply() (*stores.TotalSupply, error) // store BlockStoreRead() BlockStoreRead // tx hash CheckTxHash(fields.Hash) (bool, error) // Check whether the transaction has been linked ReadTxBelongHeightByHash(fields.Hash) (fields.BlockHeight, error) // Check the block ID of the exchange ReadTransactionBytesByHash(fields.Hash) (fields.BlockHeight, []byte, error) // Read transaction content // query Balance(fields.Address) (*stores.Balance, error) 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) // movebtc ReadMoveBTCTxHashByTrsNo(trsno uint32) ([]byte, error) }
type ImmutableStatus ¶
type LatestStatus ¶
type LatestStatus interface { Field SetLastestDiamond(*stores.DiamondSmelt) ReadLastestDiamond() *stores.DiamondSmelt }
type Miner ¶
type Miner interface { Start() // StartMining() // StopMining() // SetBlockChain(BlockChain) SetTxPool(TxPool) SetPowServer(PowServer) SubmitTx(Transaction) }
type P2PManager ¶
type P2PMsgCommunicator ¶
type P2PMsgCommunicator interface { PeerLen() int GetAllPeers() []P2PMsgPeer FindAnyOnePeerBetterBePublic() P2PMsgPeer BroadcastDataMessageToUnawarePeers(ty uint16, msgbody []byte, KnowledgeKind string, KnowledgeKey string) }
type P2PMsgDataHandler ¶
type P2PMsgDataHandler interface { OnConnected(P2PMsgCommunicator, P2PMsgPeer) OnMsgData(mc P2PMsgCommunicator, p P2PMsgPeer, msgty uint16, msgbody []byte) OnDisconnected(P2PMsgPeer) }
type P2PMsgPeer ¶
type PendingStatus ¶
type PendingStatus interface { Field GetPendingBlockHead() BlockHeadMetaRead GetPendingBlockHeight() uint64 GetPendingBlockHash() fields.Hash GetWaitingSubmitDiamond() *stores.DiamondSmelt SetWaitingSubmitDiamond(*stores.DiamondSmelt) ClearWaitingSubmitDiamond() }
type PowDevice ¶
type PowDevice interface { Init() error // initialization CloseUploadHashrate() // Turn off force statistics GetSuperveneWide() int // Concurrent number // Perform a mining operation DoMining(blockHeight uint64, reporthashrate bool, stopmark *byte, tarhashvalue []byte, blockheadmeta [][]byte) (bool, int, []byte, []byte) }
Equipment end
type PowWorker ¶
type PowWorker interface { InitStart() error // initialization CloseUploadHashrate() // Turn off force statistics SetPowDevice(device PowDevice) // Set mining equipment end Excavate(miningStuffCh chan PowWorkerMiningStuffItem, resultCh chan PowWorkerMiningStuffItem) DoNextMining(nextheight uint64) // to do next StopAllMining() // stop all }
Executive end
type PowWorkerMiningStuffItem ¶
type PowWorkerMiningStuffItem interface { // Set or obtain whether mining is successful SetMiningSuccessed(bool) GetMiningSuccessed() bool // Copy and set mining nonce CopyForMiningByRandomSetCoinbaseNonce() PowWorkerMiningStuffItem GetHeadMetaBlock() Block GetCoinbaseNonce() []byte GetHeadNonce() []byte SetHeadNonce(nonce []byte) }
Mining feeding unit
type Transaction ¶
type Transaction interface { // base super Field Clone() Transaction // the transaction type number Type() uint8 // 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 // fee FeePurity() uint64 // 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) GetActionList() []Action GetTimestamp() uint64 GetMessage() fields.TrimString16 SetMessage(fields.TrimString16) }
type TxPool ¶
type TxPool interface { SetBlockChain(BlockChain) // Check whether the transaction already exists CheckTxExistByHash(fields.Hash) (Transaction, bool) CheckTxExist(Transaction) (Transaction, bool) // Add transaction AddTx(Transaction) error // Query a transaction from the trading pool // FindTxByHash(fields.Hash) (Transaction, bool) // Obtain all transactions, and sort them according to the service fee purity from high to low CopyTxsOrderByFeePurity(targetblockheight uint64, maxcount uint32, maxsize uint32) []Transaction // Filter and clear transactions RemoveTxs([]Transaction) RemoveTxsOnNextBlockArrive([]Transaction) SetAutomaticallyCleanInvalidTransactions(bool) // Add transaction success event subscription SubscribeOnAddTxSuccess(chan Transaction) PauseEventSubscribe() // Pause event subscription RenewalEventSubscribe() // Reopen event subscription GetDiamondCreateTxs(int) []Transaction }
Click to show internal directories.
Click to hide internal directories.