rpc

package
v0.8.8 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2017 License: GPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StartServer

func StartServer(option *Option, pmHandler pmHandler)

StartServer with Test instance as a service

Types

type Account

type Account struct {
	// contains filtered or unexported fields
}

account

func NewAccount

func NewAccount(ai AccountInterface) *Account

func (*Account) Exist

func (a *Account) Exist(addr string, reply *bool) error

Exist

func (*Account) List

func (a *Account) List(param uint8, reply *[]string) error

List accounts

func (*Account) New

func (a *Account) New(args *AccountNewArgs, reply *accounts.Address) error

NewAccount

func (*Account) Sign

func (a *Account) Sign(args *SignTxArgs, reply *string) error

type AccountInterface

type AccountInterface interface {
	NewAccount(passphrase string, accountType uint32) (accounts.Account, error)
	Accounts() ([]string, error)
	HasAddress(addr accounts.Address) bool
	Find(addr accounts.Address) *accounts.Account
	SignTx(a accounts.Account, tx *types.Transaction, pass string) (*types.Transaction, error)
}

type AccountNewArgs

type AccountNewArgs struct {
	AccountType uint32
	Passphrase  string
}

type Block

type Block struct {
	BlockHeader *types.BlockHeader `json:"header"`
	TxHashList  []crypto.Hash      `json:"txHashList"`
}

Block json rpc return block

type BroadcastReply

type BroadcastReply struct {
	ContractAddr    *string     `json:"contractAddr"`
	TransactionHash crypto.Hash `json:"transactionHash"`
}

type ContractQueryArgs

type ContractQueryArgs struct {
	ContractAddr   string
	ContractParams []string
}

type GetTxsByBlockHashArgs

type GetTxsByBlockHashArgs struct {
	BlockHash string
	TxType    uint32
}

GetTxsByBlockHashArgs get txs by block hash args

type GetTxsByBlockNumberArgs

type GetTxsByBlockNumberArgs struct {
	BlockNumber uint32
	TxType      uint32
}

GetTxsByBlockNumberArgs get txs by block number args

type HttpConn

type HttpConn struct {
	// contains filtered or unexported fields
}

func (*HttpConn) Close

func (c *HttpConn) Close() error

func (*HttpConn) Read

func (c *HttpConn) Read(p []byte) (n int, err error)

func (*HttpConn) Write

func (c *HttpConn) Write(d []byte) (n int, err error)

type IBroadcast

type IBroadcast interface {
	Relay(inv types.IInventory)
	QueryContract(tx *types.Transaction) ([]byte, error)
}

type INetWorkInfo

type INetWorkInfo interface {
	GetPeers() []*p2p.Peer
	GetLocalPeer() *p2p.Peer
}

type Ledger

type Ledger struct {
	// contains filtered or unexported fields
}

Ledger ledger rpc api

func NewLedger

func NewLedger(legderInterface LedgerInterface) *Ledger

NewLedger initialization

func (*Ledger) DeserializeTx

func (l *Ledger) DeserializeTx(hexString string, reply *types.Transaction) error

DeserializeTx deserializes transaction by transaction serialize string

func (*Ledger) GetBalance

func (l *Ledger) GetBalance(addr string, reply *state.Balance) error

GetBalance returns balance by account address

func (*Ledger) GetBlockByHash

func (l *Ledger) GetBlockByHash(blockHashBytes string, reply *Block) error

GetBlockByHash returns the block detail by hash

func (*Ledger) GetBlockByNumber

func (l *Ledger) GetBlockByNumber(number uint32, reply *Block) error

GetBlockByNumber get block by block number

func (*Ledger) GetBlockHashByNumber

func (l *Ledger) GetBlockHashByNumber(blockNumber uint32, reply *crypto.Hash) error

GetBlockHashByNumber return block hash by block number

func (*Ledger) GetLastBlockHash

func (l *Ledger) GetLastBlockHash(ignore string, reply *crypto.Hash) error

GetLastBlockHash returns the last Block hash

func (*Ledger) GetTxByHash

func (l *Ledger) GetTxByHash(txHashBytes string, reply *types.Transaction) error

GetTxByHash returns transaction by tx hash []byte

func (*Ledger) GetTxsByBlockHash

func (l *Ledger) GetTxsByBlockHash(args GetTxsByBlockHashArgs, reply *types.Transactions) error

GetTxsByBlockHash get txs by block hash

func (*Ledger) GetTxsByBlockNumber

func (l *Ledger) GetTxsByBlockNumber(args GetTxsByBlockNumberArgs, reply *types.Transactions) error

GetTxsByBlockNumber get txs by block number

func (*Ledger) GetTxsByMergeTxHash

func (l *Ledger) GetTxsByMergeTxHash(mergeTxHash string, reply *types.Transactions) error

GetTxsByMergeTxHash return cross chain transactions by merge transaction

func (*Ledger) Height

func (l *Ledger) Height(ignore string, reply *uint32) error

Height get blockchain height

type LedgerInterface

type LedgerInterface interface {
	Height() (uint32, error)
	GetBalanceNonce(addr accounts.Address) (*big.Int, uint32)
	GetTransaction(txHash crypto.Hash) (*types.Transaction, error)
	GetBlockByHash(blockHashBytes []byte) (*types.BlockHeader, error)
	GetBlockByNumber(number uint32) (*types.BlockHeader, error)
	GetBlockHashByNumber(blockNum uint32) (crypto.Hash, error)
	GetLastBlockHash() (crypto.Hash, error)
	GetTxsByBlockHash(blockHashBytes []byte, transactionType uint32) (types.Transactions, error)
	GetTxsByBlockNumber(blockNumber uint32, transactionType uint32) (types.Transactions, error)
	GetTxsByMergeTxHash(mergeTxHash crypto.Hash) (types.Transactions, error)
	GetTransactionHashList(number uint32) ([]crypto.Hash, error)
}

LedgerInterface ledger interface

type Net

type Net struct {
	// contains filtered or unexported fields
}

func NewNet

func NewNet(netServer INetWorkInfo) *Net

func (*Net) GetLocalPeer

func (n *Net) GetLocalPeer(req string, reply *string) error

func (*Net) GetPeers

func (n *Net) GetPeers(req string, reply *[]string) error

type Option

type Option struct {
	Enabled  bool
	Port     string
	User     string
	PassWord string
}

func NewDefaultOption

func NewDefaultOption() *Option

type PayLoad

type PayLoad struct {
	ContractCode   string
	ContractAddr   string
	ContractParams []string
}

type SignTxArgs

type SignTxArgs struct {
	OriginTx string
	Addr     string
	Pass     string
}

type Transaction

type Transaction struct {
	// contains filtered or unexported fields
}

func NewTransaction

func NewTransaction(pmHandler IBroadcast) *Transaction

func (*Transaction) Broadcast

func (t *Transaction) Broadcast(txHex string, reply *BroadcastReply) error

func (*Transaction) Create

func (t *Transaction) Create(args *TransactionCreateArgs, reply *string) error

func (*Transaction) Query

func (t *Transaction) Query(args *ContractQueryArgs, reply *string) error

Query contract query

type TransactionCreateArgs

type TransactionCreateArgs struct {
	FromChain string
	ToChain   string
	Recipient string
	Nonce     uint32
	Amount    int64
	Fee       int64
	TxType    uint32
	PayLoad   interface{}
}

type ViewFunc

type ViewFunc func(http.ResponseWriter, *http.Request)

ViewFunc defines view method

func BasicAuth

func BasicAuth(f ViewFunc, user, passwd string) ViewFunc

BasicAuth handles basic authtication

Jump to

Keyboard shortcuts

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