Documentation ¶
Overview ¶
Copyright (c) 2018 The asimov developers Use of this source code is governed by an ISC license that can be found in the LICENSE file.
Index ¶
- func DisableLog()
- func UseLogger()
- type AsimovRpcService
- type NodeServer
- func (s *NodeServer) AddBytesReceived(bytesReceived uint64)
- func (s *NodeServer) AddBytesSent(bytesSent uint64)
- func (s *NodeServer) AddPeer(sp *serverPeer)
- func (s *NodeServer) AddRebroadcastInventory(iv *protos.InvVect, data interface{})
- func (s *NodeServer) AnnounceNewSignature(sig *asiutil.BlockSign)
- func (s *NodeServer) AnnounceNewTransactions(txns []*mining.TxDesc)
- func (s *NodeServer) BanPeer(sp *serverPeer)
- func (s *NodeServer) BroadcastMessage(msg protos.Message, exclPeers ...*serverPeer)
- func (s *NodeServer) ConnectedCount() int32
- func (s *NodeServer) NetTotals() (uint64, uint64)
- func (s *NodeServer) OutboundGroupCount(key string) int
- func (s *NodeServer) RelayInventory(invVect *protos.InvVect, data interface{})
- func (s *NodeServer) RemoveRebroadcastInventory(iv *protos.InvVect)
- func (s *NodeServer) ScheduleShutdown(duration time.Duration)
- func (s *NodeServer) Start()
- func (s *NodeServer) Stop()
- func (s *NodeServer) TransactionConfirmed(tx *asiutil.Tx)
- func (s *NodeServer) UpdatePeerHeights(latestBlkHash *common.Hash, latestHeight int32, updateSource *peer.Peer)
- func (s *NodeServer) WaitForShutdown()
- type PublicRpcAPI
- func (s *PublicRpcAPI) AddNode(_addr string, _subCmd rpcjson.AddNodeSubCmd) (interface{}, error)
- func (s *PublicRpcAPI) CalculateContractAddress(inputs []rpcjson.TransactionInput, outputs []rpcjson.TransactionOutput) (interface{}, error)
- func (s *PublicRpcAPI) Call(callerAddress string, contractAddress string, data string, name string, ...) (interface{}, error)
- func (s *PublicRpcAPI) CallReadOnlyFunction(callerAddress string, contractAddress string, data string, name string, ...) (interface{}, error)
- func (s *PublicRpcAPI) CreateRawTransaction(inputs []rpcjson.TransactionInput, outputs []rpcjson.TransactionOutput, ...) (interface{}, error)
- func (s *PublicRpcAPI) CurrentPeers() []string
- func (s *PublicRpcAPI) DecodeRawTransaction(hexTx string) (interface{}, error)
- func (s *PublicRpcAPI) DecodeScript(hexScript string) (interface{}, error)
- func (s *PublicRpcAPI) EstimateGas(caller string, contractAddress string, amount int64, asset string, data string, ...) (interface{}, error)
- func (s *PublicRpcAPI) GetAssetInfoList(assets []string) (interface{}, error)
- func (s *PublicRpcAPI) GetBalance(address string) ([]rpcjson.GetBalanceResult, error)
- func (s *PublicRpcAPI) GetBalances(addresses []string) (interface{}, error)
- func (s *PublicRpcAPI) GetBestBlock() (*rpcjson.GetBestBlockResult, error)
- func (s *PublicRpcAPI) GetBlock(blockHash string, verbose bool, verboseTx bool) (interface{}, error)
- func (s *PublicRpcAPI) GetBlockChainInfo() (interface{}, error)
- func (s *PublicRpcAPI) GetBlockHash(blockHeight int32) (string, error)
- func (s *PublicRpcAPI) GetBlockHeader(blockHash string, verbose bool) (interface{}, error)
- func (s *PublicRpcAPI) GetBlockHeight(blockHash string) (int32, error)
- func (s *PublicRpcAPI) GetBlockListByHeight(offset int32, count int32) (interface{}, error)
- func (s *PublicRpcAPI) GetBlockTemplate(privkey string, round uint32, slotIndex uint16) (interface{}, error)
- func (s *PublicRpcAPI) GetConsensusMiningInfo() (interface{}, error)
- func (s *PublicRpcAPI) GetContractAddressesByAssets(assets []string) (interface{}, error)
- func (s *PublicRpcAPI) GetContractExecuteError(txid string) (interface{}, error)
- func (s *PublicRpcAPI) GetContractTemplate(contractAddress string) (interface{}, error)
- func (s *PublicRpcAPI) GetContractTemplateInfoByKey(key string) (interface{}, error)
- func (s *PublicRpcAPI) GetContractTemplateInfoByName(category uint16, templateName string) (interface{}, error)
- func (s *PublicRpcAPI) GetContractTemplateList(approved bool, category uint16, pageNo int, pageSize int) (interface{}, error)
- func (s *PublicRpcAPI) GetContractTemplateName(contractAddress string) (interface{}, error)
- func (s *PublicRpcAPI) GetCurrentNet() (common.AsimovNet, error)
- func (s *PublicRpcAPI) GetFeeList() (interface{}, error)
- func (s *PublicRpcAPI) GetGenesisContract(contractAddr common.Address) (interface{}, error)
- func (s *PublicRpcAPI) GetGenesisContractByHeight(height int32, contractAddr common.Address) (interface{}, error)
- func (s *PublicRpcAPI) GetMempoolTransactions(txIds []string) (interface{}, error)
- func (s *PublicRpcAPI) GetMergeUtxoStatus(address string, mergeCount int32) ([]rpcjson.GetMergeUtxoResult, error)
- func (s *PublicRpcAPI) GetNetTotals() (interface{}, error)
- func (s *PublicRpcAPI) GetRawTransaction(txId string, verbose bool, vinExtra bool) (interface{}, error)
- func (s *PublicRpcAPI) GetRoundInfo(round uint32) (interface{}, error)
- func (s *PublicRpcAPI) GetSignUpStatus(address string) (interface{}, error)
- func (s *PublicRpcAPI) GetTransactionReceipt(txId string) (interface{}, error)
- func (s *PublicRpcAPI) GetTransactionsByAddresses(addresses []string, numToSkip uint32, numRequested uint32) (interface{}, error)
- func (s *PublicRpcAPI) GetUtxoByAddress(addresses []string, asset string) (interface{}, error)
- func (s *PublicRpcAPI) GetUtxoInPage(address string, asset string, from, count int32) (interface{}, error)
- func (s *PublicRpcAPI) GetVirtualTransactions(blkHashStr string, verbose bool, vinExtra bool) (interface{}, error)
- func (s *PublicRpcAPI) RunTransaction(hexTx string, utxos []*rpcjson.ListUnspentResult) (interface{}, error)
- func (s *PublicRpcAPI) SearchRawTransactions(address string, verbose bool, skip int, count int, vinExtra bool, reverse bool, ...) (interface{}, error)
- func (s *PublicRpcAPI) SendRawTransaction(hexTx string) (interface{}, error)
- func (s *PublicRpcAPI) SignBlock(blockHash string, privkey string) (interface{}, error)
- func (s *PublicRpcAPI) Test(callerAddress string, byteCode string, argStr string, ...) (interface{}, error)
- func (s *PublicRpcAPI) UpTime() (int64, error)
- func (s *PublicRpcAPI) ValidateAddress(address string) (bool, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DisableLog ¶
func DisableLog()
DisableLog disables all library log output. Logging output is disabled by default until either UseLogger or SetLogWriter are called.
Types ¶
type AsimovRpcService ¶
type AsimovRpcService struct {
// contains filtered or unexported fields
}
func NewAsimovRpcService ¶
func NewAsimovRpcService(ctx *node.ServiceContext, stack *node.Node, config *rpcserverConfig) (*AsimovRpcService, error)
func (*AsimovRpcService) APIs ¶
func (s *AsimovRpcService) APIs() []rpc.API
APIs return the collection of RPC services the asimov package offers. NOTE, some of these services probably need to be moved to somewhere else.
func (*AsimovRpcService) Start ¶
func (s *AsimovRpcService) Start() error
func (*AsimovRpcService) Stop ¶
func (s *AsimovRpcService) Stop() error
type NodeServer ¶
type NodeServer struct {
// contains filtered or unexported fields
}
NodeServer provides an asimov Server for handling communications to and from asimov peers.
func NewServer ¶
func NewServer(db database.Transactor, stateDB database.Database, agentBlacklist, agentWhitelist []string, chainParams *chaincfg.Params, interrupt <-chan struct{}, shutdownRequestChannel chan struct{}) (*NodeServer, error)
newServer returns a new btcd NodeServer configured to listen on addr for the flow network type specified by chainParams. Use start to begin accepting connections from peers.
func (*NodeServer) AddBytesReceived ¶
func (s *NodeServer) AddBytesReceived(bytesReceived uint64)
AddBytesReceived adds the passed number of bytes to the total bytes received counter for the NodeServer. It is safe for concurrent access.
func (*NodeServer) AddBytesSent ¶
func (s *NodeServer) AddBytesSent(bytesSent uint64)
AddBytesSent adds the passed number of bytes to the total bytes sent counter for the NodeServer. It is safe for concurrent access.
func (*NodeServer) AddPeer ¶
func (s *NodeServer) AddPeer(sp *serverPeer)
AddPeer adds a new peer that has already been connected to the NodeServer.
func (*NodeServer) AddRebroadcastInventory ¶
func (s *NodeServer) AddRebroadcastInventory(iv *protos.InvVect, data interface{})
AddRebroadcastInventory adds 'iv' to the list of inventories to be rebroadcasted at random intervals until they show up in a block.
func (*NodeServer) AnnounceNewSignature ¶
func (s *NodeServer) AnnounceNewSignature(sig *asiutil.BlockSign)
func (*NodeServer) AnnounceNewTransactions ¶
func (s *NodeServer) AnnounceNewTransactions(txns []*mining.TxDesc)
AnnounceNewTransactions generates and relays inventory vectors and notifies both websocket and getblocktemplate long poll clients of the passed transactions. This function should be called whenever new transactions are added to the mempool.
func (*NodeServer) BanPeer ¶
func (s *NodeServer) BanPeer(sp *serverPeer)
BanPeer bans a peer that has already been connected to the NodeServer by ip.
func (*NodeServer) BroadcastMessage ¶
func (s *NodeServer) BroadcastMessage(msg protos.Message, exclPeers ...*serverPeer)
BroadcastMessage sends msg to all peers currently connected to the NodeServer except those in the passed peers to exclude.
func (*NodeServer) ConnectedCount ¶
func (s *NodeServer) ConnectedCount() int32
ConnectedCount returns the number of currently connected peers.
func (*NodeServer) NetTotals ¶
func (s *NodeServer) NetTotals() (uint64, uint64)
NetTotals returns the sum of all bytes received and sent across the network for all peers. It is safe for concurrent access.
func (*NodeServer) OutboundGroupCount ¶
func (s *NodeServer) OutboundGroupCount(key string) int
OutboundGroupCount returns the number of peers connected to the given outbound group key.
func (*NodeServer) RelayInventory ¶
func (s *NodeServer) RelayInventory(invVect *protos.InvVect, data interface{})
RelayInventory relays the passed inventory vector to all connected peers that are not already known to have it.
func (*NodeServer) RemoveRebroadcastInventory ¶
func (s *NodeServer) RemoveRebroadcastInventory(iv *protos.InvVect)
RemoveRebroadcastInventory removes 'iv' from the list of items to be rebroadcasted if present.
func (*NodeServer) ScheduleShutdown ¶
func (s *NodeServer) ScheduleShutdown(duration time.Duration)
ScheduleShutdown schedules a NodeServer shutdown after the specified duration. It also dynamically adjusts how often to warn the NodeServer is going down based on remaining duration.
func (*NodeServer) Start ¶
func (s *NodeServer) Start()
Start begins accepting connections from peers.
func (*NodeServer) Stop ¶
func (s *NodeServer) Stop()
Stop gracefully shuts down the NodeServer by stopping and disconnecting all peers and the main listener.
func (*NodeServer) TransactionConfirmed ¶
func (s *NodeServer) TransactionConfirmed(tx *asiutil.Tx)
Transaction has one confirmation on the main chain. Now we can mark it as no longer needing rebroadcasting.
func (*NodeServer) UpdatePeerHeights ¶
func (s *NodeServer) UpdatePeerHeights(latestBlkHash *common.Hash, latestHeight int32, updateSource *peer.Peer)
UpdatePeerHeights updates the heights of all peers who have have announced the latest connected main chain block, or a recognized orphan. These height updates allow us to dynamically refresh peer heights, ensuring sync peer selection has access to the latest block heights for each peer.
func (*NodeServer) WaitForShutdown ¶
func (s *NodeServer) WaitForShutdown()
WaitForShutdown blocks until the main listener and peer handlers are stopped.
type PublicRpcAPI ¶
type PublicRpcAPI struct {
// contains filtered or unexported fields
}
func NewPublicRpcAPI ¶
func NewPublicRpcAPI(stack *node.Node, config *rpcserverConfig) *PublicRpcAPI
NewPublicWeb3API creates a new Web3Service instance
func (*PublicRpcAPI) AddNode ¶
func (s *PublicRpcAPI) AddNode(_addr string, _subCmd rpcjson.AddNodeSubCmd) (interface{}, error)
func (*PublicRpcAPI) CalculateContractAddress ¶
func (s *PublicRpcAPI) CalculateContractAddress(inputs []rpcjson.TransactionInput, outputs []rpcjson.TransactionOutput) (interface{}, error)
Calculate a contract address before deploying the contract on chain. Note the calculation is part of logic implemented in the `CreateRawTransaction` function. As a result, `CreateRawTransaction` is directly called instead of composing the similar code again.
func (*PublicRpcAPI) Call ¶
func (s *PublicRpcAPI) Call(callerAddress string, contractAddress string, data string, name string, abiStr string, amount int64, asset string) (interface{}, error)
This function is provided to internal IDE tool. IT IS NOT MEANT FOR PUBLIC USE. The function provides a way to call a contract function in a state preserving manner. A contract function can be called and returns the execution result without affecting the block state. In order to prevent the execution to end in OUT OF GAS, the gas set to call the contract function is 1000000000.
func (*PublicRpcAPI) CallReadOnlyFunction ¶
func (s *PublicRpcAPI) CallReadOnlyFunction(callerAddress string, contractAddress string, data string, name string, abi string) (interface{}, error)
Call a readonly function (view, pure in solidity) in a contract and return the execution result of the contract function
func (*PublicRpcAPI) CreateRawTransaction ¶
func (s *PublicRpcAPI) CreateRawTransaction(inputs []rpcjson.TransactionInput, outputs []rpcjson.TransactionOutput, lockTime *int64, gasLimit *int32) (interface{}, error)
func (*PublicRpcAPI) CurrentPeers ¶
func (s *PublicRpcAPI) CurrentPeers() []string
func (*PublicRpcAPI) DecodeRawTransaction ¶
func (s *PublicRpcAPI) DecodeRawTransaction(hexTx string) (interface{}, error)
func (*PublicRpcAPI) DecodeScript ¶
func (s *PublicRpcAPI) DecodeScript(hexScript string) (interface{}, error)
func (*PublicRpcAPI) EstimateGas ¶
func (s *PublicRpcAPI) EstimateGas(caller string, contractAddress string, amount int64, asset string, data string, callType string, voteValue int64) (interface{}, error)
This function is provided only for INTERNAL USE. By running this function, the caller can estimate gas cost of a specific contract call. Note the estimated gas cost is augmented by 120% in order to prevent OUT OF GAS error in real execution.
func (*PublicRpcAPI) GetAssetInfoList ¶
func (s *PublicRpcAPI) GetAssetInfoList(assets []string) (interface{}, error)
Get detail information of given assets.
func (*PublicRpcAPI) GetBalance ¶
func (s *PublicRpcAPI) GetBalance(address string) ([]rpcjson.GetBalanceResult, error)
Get balance of an address. The result contains a list of {asset, value} which the address owns.
func (*PublicRpcAPI) GetBalances ¶
func (s *PublicRpcAPI) GetBalances(addresses []string) (interface{}, error)
Get balance for each address in the array.
func (*PublicRpcAPI) GetBestBlock ¶
func (s *PublicRpcAPI) GetBestBlock() (*rpcjson.GetBestBlockResult, error)
func (*PublicRpcAPI) GetBlock ¶
func (s *PublicRpcAPI) GetBlock(blockHash string, verbose bool, verboseTx bool) (interface{}, error)
func (*PublicRpcAPI) GetBlockChainInfo ¶
func (s *PublicRpcAPI) GetBlockChainInfo() (interface{}, error)
func (*PublicRpcAPI) GetBlockHash ¶
func (s *PublicRpcAPI) GetBlockHash(blockHeight int32) (string, error)
func (*PublicRpcAPI) GetBlockHeader ¶
func (s *PublicRpcAPI) GetBlockHeader(blockHash string, verbose bool) (interface{}, error)
func (*PublicRpcAPI) GetBlockHeight ¶
func (s *PublicRpcAPI) GetBlockHeight(blockHash string) (int32, error)
func (*PublicRpcAPI) GetBlockListByHeight ¶
func (s *PublicRpcAPI) GetBlockListByHeight(offset int32, count int32) (interface{}, error)
func (*PublicRpcAPI) GetBlockTemplate ¶
func (s *PublicRpcAPI) GetBlockTemplate(privkey string, round uint32, slotIndex uint16) (interface{}, error)
func (*PublicRpcAPI) GetConsensusMiningInfo ¶
func (s *PublicRpcAPI) GetConsensusMiningInfo() (interface{}, error)
Get detail mining information of consensus
func (*PublicRpcAPI) GetContractAddressesByAssets ¶
func (s *PublicRpcAPI) GetContractAddressesByAssets(assets []string) (interface{}, error)
Get the contract addresses which issued the given assets
func (*PublicRpcAPI) GetContractExecuteError ¶
func (s *PublicRpcAPI) GetContractExecuteError(txid string) (interface{}, error)
func (*PublicRpcAPI) GetContractTemplate ¶
func (s *PublicRpcAPI) GetContractTemplate(contractAddress string) (interface{}, error)
Get information of the template based on which the given address (contract) is deployed.
func (*PublicRpcAPI) GetContractTemplateInfoByKey ¶
func (s *PublicRpcAPI) GetContractTemplateInfoByKey(key string) (interface{}, error)
Get template information by key The key is the the transaction id in which the template is submitted
func (*PublicRpcAPI) GetContractTemplateInfoByName ¶
func (s *PublicRpcAPI) GetContractTemplateInfoByName(category uint16, templateName string) (interface{}, error)
Get template information by category and template name
func (*PublicRpcAPI) GetContractTemplateList ¶
func (s *PublicRpcAPI) GetContractTemplateList(approved bool, category uint16, pageNo int, pageSize int) (interface{}, error)
Get a list of template information. The result contains a page from pageNo to pageNo+pageSize of given category.
func (*PublicRpcAPI) GetContractTemplateName ¶
func (s *PublicRpcAPI) GetContractTemplateName(contractAddress string) (interface{}, error)
Get name of the template based on which the given address (contract) is deployed.
func (*PublicRpcAPI) GetCurrentNet ¶
func (s *PublicRpcAPI) GetCurrentNet() (common.AsimovNet, error)
func (*PublicRpcAPI) GetFeeList ¶
func (s *PublicRpcAPI) GetFeeList() (interface{}, error)
Get the list of assets which can be used as transaction fees on Asimov blockchain By default, only Asim can be used as transaction fee. The validator committee can choose to add new asset to the list as needed.
func (*PublicRpcAPI) GetGenesisContract ¶
func (s *PublicRpcAPI) GetGenesisContract(contractAddr common.Address) (interface{}, error)
Get system contract ABI information on latest block height.
func (*PublicRpcAPI) GetGenesisContractByHeight ¶
func (s *PublicRpcAPI) GetGenesisContractByHeight(height int32, contractAddr common.Address) (interface{}, error)
Get system contract ABI information on a given block height. Note the term system contract and genesis contract are interchangeable in this context.
func (*PublicRpcAPI) GetMempoolTransactions ¶
func (s *PublicRpcAPI) GetMempoolTransactions(txIds []string) (interface{}, error)
func (*PublicRpcAPI) GetMergeUtxoStatus ¶
func (s *PublicRpcAPI) GetMergeUtxoStatus(address string, mergeCount int32) ([]rpcjson.GetMergeUtxoResult, error)
Get UTXO merge status of a given address Note UTXO merge is a feature provided by Asimov blockchain If there are too many UTXOs of a given address, they will be auto merged by the system in order to save space and prevent dust attack This feature is DISABLED for now
func (*PublicRpcAPI) GetNetTotals ¶
func (s *PublicRpcAPI) GetNetTotals() (interface{}, error)
func (*PublicRpcAPI) GetRawTransaction ¶
func (s *PublicRpcAPI) GetRawTransaction(txId string, verbose bool, vinExtra bool) (interface{}, error)
func (*PublicRpcAPI) GetRoundInfo ¶
func (s *PublicRpcAPI) GetRoundInfo(round uint32) (interface{}, error)
Get block information in detail of a given round in Satoshi+ consensus
func (*PublicRpcAPI) GetSignUpStatus ¶
func (s *PublicRpcAPI) GetSignUpStatus(address string) (interface{}, error)
Get the sign-up status in Satoshi+ consensus of a given address
func (*PublicRpcAPI) GetTransactionReceipt ¶
func (s *PublicRpcAPI) GetTransactionReceipt(txId string) (interface{}, error)
func (*PublicRpcAPI) GetTransactionsByAddresses ¶
func (s *PublicRpcAPI) GetTransactionsByAddresses(addresses []string, numToSkip uint32, numRequested uint32) (interface{}, error)
func (*PublicRpcAPI) GetUtxoByAddress ¶
func (s *PublicRpcAPI) GetUtxoByAddress(addresses []string, asset string) (interface{}, error)
Get list of UTXO of a given asset for all address in the array. If asset is not specified, all assets will be fetched.
func (*PublicRpcAPI) GetUtxoInPage ¶
func (s *PublicRpcAPI) GetUtxoInPage(address string, asset string, from, count int32) (interface{}, error)
Get UTXO of a given asset for an address. If asset is not specified, all assets will be fetched. The qualified UTXO is sorted and the page [from, from+count] will be retrieved.
func (*PublicRpcAPI) GetVirtualTransactions ¶
func (s *PublicRpcAPI) GetVirtualTransactions(blkHashStr string, verbose bool, vinExtra bool) (interface{}, error)
Get virtual transactions of a block in detail In Asimov, all asset operations occur in VM is converted to Virtual transactions and send back to blockchain Virtual transaction is one of key designs in Asimov blockchain, for more knowledge please refer to the technical white paper
func (*PublicRpcAPI) RunTransaction ¶
func (s *PublicRpcAPI) RunTransaction(hexTx string, utxos []*rpcjson.ListUnspentResult) (interface{}, error)
This function is provided only for INTERNAL USE. This function provides a way to run a transaction in a state preserving manner. Which is especially useful to estimate gas cost at blockchain level instead of VM level (compared to `EstimateGas`)
func (*PublicRpcAPI) SearchRawTransactions ¶
func (s *PublicRpcAPI) SearchRawTransactions(address string, verbose bool, skip int, count int, vinExtra bool, reverse bool, filterAddress []string) (interface{}, error)
Address string Verbose *int `jsonrpcdefault:"1"` Skip *int `jsonrpcdefault:"0"` Count *int `jsonrpcdefault:"100"` VinExtra *int `jsonrpcdefault:"0"` Reverse *bool `jsonrpcdefault:"false"` FilterAddrs *[]string
func (*PublicRpcAPI) SendRawTransaction ¶
func (s *PublicRpcAPI) SendRawTransaction(hexTx string) (interface{}, error)
func (*PublicRpcAPI) SignBlock ¶
func (s *PublicRpcAPI) SignBlock(blockHash string, privkey string) (interface{}, error)
func (*PublicRpcAPI) Test ¶
func (s *PublicRpcAPI) Test(callerAddress string, byteCode string, argStr string, callDatas []rpcjson.TestCallData, abiStr string) (interface{}, error)
This function is provided to internal IDE tool. IT IS NOT MEANT FOR PUBLIC USE. This function provides a way to execute a series of operations (submit template, deploy contract instance, call a contract) in a state preserving manner. The operations will be executed in order and without affecting the block state. In order to prevent the execution to end in OUT OF GAS, the gas set to call the contract function is 1000000000.
func (*PublicRpcAPI) UpTime ¶
func (s *PublicRpcAPI) UpTime() (int64, error)
func (*PublicRpcAPI) ValidateAddress ¶
func (s *PublicRpcAPI) ValidateAddress(address string) (bool, error)
Check whether the provided string format address is a valid Asimov 21-byte address