httpjsonrpc

package
v0.0.0-...-bcf92e7 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2018 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AUXBLOCK_GENERATED_INTERVAL_SECONDS = 60
)

Variables

View Source
var (
	DnaRpcInvalidHash        = responsePacking("invalid hash")
	DnaRpcInvalidBlock       = responsePacking("invalid block")
	DnaRpcInvalidTransaction = responsePacking("invalid transaction")
	DnaRpcInvalidParameter   = responsePacking("invalid parameter")

	DnaRpcUnknownBlock       = responsePacking("unknown block")
	DnaRpcUnknownTransaction = responsePacking("unknown transaction")

	DnaRpcNil           = responsePacking(nil)
	DnaRpcUnsupported   = responsePacking("Unsupported")
	DnaRpcInternalError = responsePacking("internal error")
	DnaRpcIOError       = responsePacking("internal IO error")
	DnaRpcAPIError      = responsePacking("internal API error")
	DnaRpcSuccess       = responsePacking(true)
	DnaRpcFailed        = responsePacking(false)

	// error code for wallet
	DnaRpcWalletAlreadyExists = responsePacking("wallet already exist")
	DnaRpcWalletNotExists     = responsePacking("wallet doesn't exist")

	DnaRpc = responsePacking
)
View Source
var PreChainHeight uint64
View Source
var PreTime int64
View Source
var PreTransactionCount int

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 RegistPowService

func RegistPowService(p *pow.PowService)

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 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       Fixed64
	ProgramHash string
}

type BlockHead

type BlockHead struct {
	Version          uint32
	PrevBlockHash    string
	TransactionsRoot string
	Timestamp        uint32
	Bits             uint32
	Height           uint32
	Nonce            uint32

	Hash string
}

type BlockInfo

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

type CoinbaseInfo

type CoinbaseInfo struct {
	CoinbaseData string
}

type ConsensusInfo

type ConsensusInfo struct {
}

type DeployCodeInfo

type DeployCodeInfo struct {
	Code        *FunctionCodeInfo
	Name        string
	CodeVersion string
	Author      string
	Email       string
	Description string
}

type FunctionCodeInfo

type FunctionCodeInfo struct {
	Code           string
	ParameterTypes string
	ReturnTypes    string
}

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 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
	Controller string
}

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         TransactionType
	PayloadVersion byte
	Payload        PayloadInfo
	Attributes     []TxAttributeInfo
	UTXOInputs     []UTXOTxInputInfo
	BalanceInputs  []BalanceTxInputInfo
	Outputs        []TxoutputInfo
	LockTime       uint32
	Programs       []ProgramInfo

	AssetOutputs      []TxoutputMap
	AssetInputAmount  []AmountMap
	AssetOutputAmount []AmountMap
	Timestamp         uint32 `json:",omitempty"`
	Confirminations   uint32 `json:",omitempty"`
	TxSize            uint32 `json:",omitempty"`
	Hash              string
}

func TransArryByteToHexString

func TransArryByteToHexString(ptx *tx.Transaction) *Transactions

type TxAttributeInfo

type TxAttributeInfo struct {
	Usage 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
	Address string
}

type TxoutputMap

type TxoutputMap struct {
	Key   Uint256
	Txout []TxoutputInfo
}

type UTXOTxInputInfo

type UTXOTxInputInfo struct {
	ReferTxID          string
	ReferTxOutputIndex uint16
	Sequence           uint32
	Address            string
	Value              string
}

Jump to

Keyboard shortcuts

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