rpcbus

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2019 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GetLastBlock method = iota
	GetMempoolTxs
	GetMempoolTxsBySize
	SendMempoolTx
	VerifyCandidateBlock
	CreateWallet
	CreateFromSeed
	LoadWallet
	SendBidTx
	SendStakeTx
	SendStandardTx
	GetBalance
	GetUnconfirmedBalance
	GetAddress
	GetTxHistory
	GetLastCertificate
	GetCandidate
	GetRoundResults
	AutomateConsensusTxs
	GetSyncProgress
	IsWalletLoaded
)

Variables

View Source
var (
	// ErrRequestTimeout is returned when request timeout-ed
	ErrRequestTimeout = errors.New("timeout-ed request")

	// ErrMethodExists is returned when method is already registered
	ErrMethodExists = errors.New("method exists already")

	// ErrMethodNotExists is returned when calling an unregistered method
	ErrMethodNotExists = errors.New("method not registered")

	// ErrInvalidRequestChan is returned method is bound to nil chan
	ErrInvalidRequestChan = errors.New("invalid request channel")
)

Functions

func MarshalConsensusTxRequest

func MarshalConsensusTxRequest(buf *bytes.Buffer, amount, lockTime uint64) error

Types

type RPCBus

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

RPCBus is a request–response mechanism for internal communication between node components/subsystems. Under the hood this is long-polling method based on "chan chan" technique.

func New

func New() *RPCBus

func (*RPCBus) Call

func (bus *RPCBus) Call(m method, req Request, timeOut time.Duration) (bytes.Buffer, error)

Call runs a long-polling technique to request from the method Consumer to run the corresponding procedure and return a result or timeout

func (*RPCBus) Close

func (bus *RPCBus) Close()

Close all open channels

func (*RPCBus) Register

func (bus *RPCBus) Register(m method, req chan<- Request) error

Register registers a method and binds it to a handler channel. methodName must be unique per node instance. if not, returns err

type Request

type Request struct {
	Params   bytes.Buffer
	RespChan chan Response
}

func NewRequest

func NewRequest(p bytes.Buffer) Request

NewRequest builds a new request with params

type Response

type Response struct {
	Resp bytes.Buffer
	Err  error
}

Jump to

Keyboard shortcuts

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