rpchttp

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2019 License: Apache-2.0 Imports: 34 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ASSETPREFIX = "STC"
)
View Source
const (
	LocalHost = "127.0.0.1"
)
View Source
const (
	RANDBYTELEN = 4
)

Variables

View Source
var (
	STCRpcInvalidHash        = responsePacking("invalid hash")
	STCRpcInvalidBlock       = responsePacking("invalid block")
	STCRpcInvalidTransaction = responsePacking("invalid transaction")
	STCRpcInvalidParameter   = responsePacking("invalid parameter")

	STCRpcUnknownBlock       = responsePacking("unknown block")
	STCRpcUnknownTransaction = responsePacking("unknown transaction")

	STCRpcNil           = responsePacking(nil)
	STCRpcUnsupported   = responsePacking("Unsupported")
	STCRpcInternalError = responsePacking("internal error")
	STCRpcIOError       = responsePacking("internal IO error")
	STCRpcAPIError      = responsePacking("internal API error")
	STCRpcSuccess       = responsePacking(true)
	STCRpcFailed        = responsePacking(false)

	// error code for wallet
	STCRpcWalletAlreadyExists = responsePacking("wallet already exist")
	STCRpcWalletNotExists     = responsePacking("wallet doesn't exist")

	STCRpc = responsePacking
)

Functions

func AddFileIPFS

func AddFileIPFS(filepath string, useCluster bool) (string, error)

func Call

func Call(address string, method string, id interface{}, params []interface{}) ([]byte, error)

Call sends RPC request to server

func GetFileIPFS

func GetFileIPFS(ref, outPath string) error

func Handle

func Handle(w http.ResponseWriter, r *http.Request)

this is the funciton that should be called in order to answer an rpc call should be registered like "http.HandleFunc("/", httpjsonrpc.Handle)"

func HandleFunc

func HandleFunc(pattern string, handler func([]interface{}) map[string]interface{})

a function to register functions to be called for specific rpc calls

func NewRegTx

func NewRegTx(rand string, index int, admin, issuer *Account) *transaction.Transaction

func RegistDbftService

func RegistDbftService(d *dbft.DbftService)

func RegistRpcNode

func RegistRpcNode(n Noder)

func SetDefaultFunc

func SetDefaultFunc(def func(http.ResponseWriter, *http.Request))

a function to be called if the request is not a HTTP JSON RPC call

func SignTx

func SignTx(admin *Account, tx *transaction.Transaction)

func StartRPCServer

func StartRPCServer()

func VerifyAndSendTx

func VerifyAndSendTx(txn *tx.Transaction) ErrCode

Types

type AmountMap

type AmountMap struct {
	Key   Uint256
	Value Fixed64
}

type BalanceTxInputInfo

type BalanceTxInputInfo struct {
	AssetID     string
	Value       string
	ProgramHash string
}

type BlockHead

type BlockHead struct {
	Version          uint32
	PrevBlockHash    string
	TransactionsRoot string
	Timestamp        uint32
	Height           uint32
	ConsensusData    uint64
	NextBookKeeper   string
	Program          ProgramInfo

	Hash string
}

type BlockInfo

type BlockInfo struct {
	Hash         string
	BlockData    *BlockHead
	Transactions []*Transactions
}

type BookKeepingInfo

type BookKeepingInfo struct {
	Nonce uint64
}

implement PayloadInfo define BookKeepingInfo

type BookkeeperInfo

type BookkeeperInfo struct {
	PubKey     string
	Action     string
	Issuer     IssuerInfo
	Controller string
}

type ConsensusInfo

type ConsensusInfo struct {
}

type DataFileInfo

type DataFileInfo struct {
	IPFSPath string
	Filename string
	Note     string
	Issuer   IssuerInfo
}

type DeployCodeInfo

type DeployCodeInfo struct {
	Code        *FunctionCodeInfo
	Name        string
	Version     string
	Author      string
	Email       string
	Description string
	Language    int
	ProgramHash string
}

type FunctionCodeInfo

type FunctionCodeInfo struct {
	Code           string
	ParameterTypes []int
	ReturnType     int
	CodeHash       string
}

implement PayloadInfo define DeployCodeInfo

type IssuerInfo

type IssuerInfo struct {
	X, Y string
}

type LockAssetInfo

type LockAssetInfo struct {
	Address    string
	AssetID    string
	Amount     string
	LockHeight uint32
}

type NodeInfo

type NodeInfo struct {
	State    uint   // node status
	Port     uint16 // The nodes's port
	ID       uint64 // The nodes's id
	Time     int64
	Version  uint32 // The network protocol the node used
	Services uint64 // The services the node supplied
	Relay    bool   // The relay capability of the node (merge into capbility flag)
	Height   uint64 // The node latest block height
	TxnCnt   uint64 // The transactions be transmit by this node
	RxTxnCnt uint64 // The transaction received by this node
}

type PayloadInfo

type PayloadInfo interface{}

func TransPayloadToHex

func TransPayloadToHex(p Payload) PayloadInfo

type PrivacyPayloadInfo

type PrivacyPayloadInfo struct {
	PayloadType uint8
	Payload     string
	EncryptType uint8
	EncryptAttr string
}

type ProgramInfo

type ProgramInfo struct {
	Code      string
	Parameter string
}

type RecordInfo

type RecordInfo struct {
	RecordType string
	RecordData string
}

type RegisterAssetInfo

type RegisterAssetInfo struct {
	Asset      *asset.Asset
	Amount     string
	Issuer     IssuerInfo
	Controller string
}

implement PayloadInfo define RegisterAssetInfo

type ServeMux

type ServeMux struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

multiplexer that keeps track of every function to be called on specific rpc call

type Transactions

type Transactions struct {
	TxType         tx.TransactionType
	PayloadVersion byte
	Payload        PayloadInfo
	Attributes     []TxAttributeInfo
	UTXOInputs     []UTXOTxInputInfo
	BalanceInputs  []BalanceTxInputInfo
	Outputs        []TxoutputInfo
	Programs       []ProgramInfo

	AssetOutputs      []TxoutputMap
	AssetInputAmount  []AmountMap
	AssetOutputAmount []AmountMap

	Hash string
}

func TransArryByteToHexString

func TransArryByteToHexString(ptx *tx.Transaction) *Transactions

type TxAttributeInfo

type TxAttributeInfo struct {
	Usage tx.TransactionAttributeUsage
	Data  string
}

type TxInfo

type TxInfo struct {
	Hash string
	Hex  string
	Tx   *Transactions
}

type TxoutInfo

type TxoutInfo struct {
	High  uint32
	Low   uint32
	Txout tx.TxOutput
}

type TxoutputInfo

type TxoutputInfo struct {
	AssetID     string
	Value       string
	ProgramHash string
}

type TxoutputMap

type TxoutputMap struct {
	Key   Uint256
	Txout []TxoutputInfo
}

type UTXOTxInputInfo

type UTXOTxInputInfo struct {
	ReferTxID          string
	ReferTxOutputIndex uint16
}

Jump to

Keyboard shortcuts

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