common

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2022 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BIT_JSONRPC   byte = 1
	BIT_WEBSOCKET byte = 2
)

Variables

View Source
var InitialAPIHandlers = map[string]APIHandler{
	"getlatestblockhash":   {Handler: getLatestBlockHash, AccessCtrl: BIT_JSONRPC},
	"getblock":             {Handler: getBlock, AccessCtrl: BIT_JSONRPC},
	"getheader":            {Handler: getHeader, AccessCtrl: BIT_JSONRPC},
	"getblockcount":        {Handler: getBlockCount, AccessCtrl: BIT_JSONRPC},
	"getlatestblockheight": {Handler: getLatestBlockHeight, AccessCtrl: BIT_JSONRPC},
	"getblocktxsbyheight":  {Handler: getBlockTxsByHeight, AccessCtrl: BIT_JSONRPC},
	"getconnectioncount":   {Handler: getConnectionCount, AccessCtrl: BIT_JSONRPC},
	"getrawmempool":        {Handler: getRawMemPool, AccessCtrl: BIT_JSONRPC},
	"gettransaction":       {Handler: getTransaction, AccessCtrl: BIT_JSONRPC},
	"sendrawtransaction":   {Handler: sendRawTransaction, AccessCtrl: BIT_JSONRPC | BIT_WEBSOCKET},
	"getwsaddr":            {Handler: getWsAddr, AccessCtrl: BIT_JSONRPC},
	"getwssaddr":           {Handler: getWssAddr, AccessCtrl: BIT_JSONRPC},
	"getversion":           {Handler: getVersion, AccessCtrl: BIT_JSONRPC},
	"getneighbor":          {Handler: getNeighbor, AccessCtrl: BIT_JSONRPC},
	"getnodestate":         {Handler: getNodeState, AccessCtrl: BIT_JSONRPC},
	"getchordringinfo":     {Handler: getChordRingInfo, AccessCtrl: BIT_JSONRPC},
	"setdebuginfo":         {Handler: setDebugInfo},
	"getbalancebyaddr":     {Handler: getBalanceByAddr, AccessCtrl: BIT_JSONRPC},
	"getbalancebyassetid":  {Handler: getBalanceByAssetID, AccessCtrl: BIT_JSONRPC},
	"getnoncebyaddr":       {Handler: getNonceByAddr, AccessCtrl: BIT_JSONRPC},
	"getid":                {Handler: getId, AccessCtrl: BIT_JSONRPC},
	"getsubscription":      {Handler: getSubscription, AccessCtrl: BIT_JSONRPC},
	"getsubscribers":       {Handler: getSubscribers, AccessCtrl: BIT_JSONRPC},
	"getsubscriberscount":  {Handler: getSubscribersCount, AccessCtrl: BIT_JSONRPC},
	"getasset":             {Handler: getAsset, AccessCtrl: BIT_JSONRPC},
	"getmyextip":           {Handler: getMyExtIP, AccessCtrl: BIT_JSONRPC},
	"findsuccessoraddr":    {Handler: findSuccessorAddr, AccessCtrl: BIT_JSONRPC},
	"findsuccessoraddrs":   {Handler: findSuccessorAddrs, AccessCtrl: BIT_JSONRPC},
	"getregistrant":        {Handler: getRegistrant, AccessCtrl: BIT_JSONRPC},
}

Functions

func GetBlockTransactions

func GetBlockTransactions(block *block.Block) interface{}

func GetHttpsCertificate

func GetHttpsCertificate(h *tls.ClientHelloInfo) (*tls.Certificate, error)

func GetWssCertificate

func GetWssCertificate(h *tls.ClientHelloInfo) (*tls.Certificate, error)

func MakeDeleteNameTransaction

func MakeDeleteNameTransaction(wallet *vault.Wallet, name string, nonce uint64, fee common.Fixed64) (*transaction.Transaction, error)

func MakeGenerateIDTransaction

func MakeGenerateIDTransaction(ctx context.Context, pubkey []byte, wallet *vault.Wallet, regFee common.Fixed64, nonce uint64, txnFee common.Fixed64, height uint32) (*transaction.Transaction, error)

func MakeIssueAssetTransaction

func MakeIssueAssetTransaction(wallet *vault.Wallet, name, symbol string, totalSupply common.Fixed64, precision uint32, nonce uint64, fee common.Fixed64) (*transaction.Transaction, error)

func MakeNanoPayTransaction

func MakeNanoPayTransaction(wallet *vault.Wallet, recipient common.Uint160, id uint64, amount common.Fixed64, txnExpiration, nanoPayExpiration uint32) (*transaction.Transaction, error)

func MakeRDCSwapTransaction

func MakeRDCSwapTransaction(wallet *vault.Wallet, receipt common.Uint160, nonce uint64, value, fee common.Fixed64) (*transaction.Transaction, error)

func MakeRegisterNameTransaction

func MakeRegisterNameTransaction(wallet *vault.Wallet, name string, nonce uint64, regFee common.Fixed64, fee common.Fixed64) (*transaction.Transaction, error)

func MakeSigChainTransaction

func MakeSigChainTransaction(wallet *vault.Wallet, sigChain []byte, nonce uint64) (*transaction.Transaction, error)

func MakeSubscribeTransaction

func MakeSubscribeTransaction(wallet *vault.Wallet, identifier string, topic string, duration uint32, meta string, nonce uint64, fee common.Fixed64) (*transaction.Transaction, error)

func MakeSwapTransaction

func MakeSwapTransaction(wallet *vault.Wallet, receipt common.Uint160, nonce uint64, value, fee common.Fixed64) (*transaction.Transaction, error)

func MakeTransferNameTransaction

func MakeTransferNameTransaction(wallet *vault.Wallet, name string, nonce uint64, fee common.Fixed64, to []byte) (*transaction.Transaction, error)

func MakeTransferRDCTransaction

func MakeTransferRDCTransaction(wallet *vault.Wallet, receipt common.Uint160, nonce uint64, value, fee common.Fixed64) (*transaction.Transaction, error)

func MakeTransferTransaction

func MakeTransferTransaction(wallet *vault.Wallet, receipt common.Uint160, nonce uint64, value, fee common.Fixed64) (*transaction.Transaction, error)

func MakeUnsubscribeTransaction

func MakeUnsubscribeTransaction(wallet *vault.Wallet, identifier string, topic string, nonce uint64, fee common.Fixed64) (*transaction.Transaction, error)

func NodeInfo

func NodeInfo(wsAddr, rpcAddr string, pubkey, id []byte) map[string]string

func RespPacking

func RespPacking(result interface{}, code errcode.ErrCode) map[string]interface{}

func ResponsePack

func ResponsePack(code errcode.ErrCode) map[string]interface{}

func VerifyAndSendTx

func VerifyAndSendTx(localNode *node.LocalNode, txn *transaction.Transaction) (errcode.ErrCode, error)

Types

type APIHandler

type APIHandler struct {
	Handler    Handler
	AccessCtrl byte
}

func (*APIHandler) IsAccessableByJsonrpc

func (ah *APIHandler) IsAccessableByJsonrpc() bool

IsAccessableByJsonrpc return true if the handler is able to be invoked by jsonrpc

func (*APIHandler) IsAccessableByWebsocket

func (ah *APIHandler) IsAccessableByWebsocket() bool

IsAccessableByWebsocket return true if the handler is able to be invoked by websocket

type Handler

type Handler func(Serverer, map[string]interface{}, context.Context) map[string]interface{}

type Serverer

type Serverer interface {
	GetNetNode() *node.LocalNode
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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