rpc

package
v0.0.7-dev Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2019 License: ISC Imports: 50 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrRPCUnimplemented is an error returned to RPC clients when the
	// provided command is recognized, but not implemented.
	ErrRPCUnimplemented = &btcjson.RPCError{
		Code:    btcjson.ErrRPCUnimplemented,
		Message: "Command unimplemented",
	}

	// ErrRPCNoWallet is an error returned to RPC clients when the provided
	// command is recognized as a wallet command.
	ErrRPCNoWallet = &btcjson.RPCError{
		Code:    btcjson.ErrRPCNoWallet,
		Message: "This implementation does not implement wallet commands",
	}
)

Errors

View Source
var ErrClientQuit = errors.New("client quit")

ErrClientQuit describes the error where a client send is not processed due to the client having already been disconnected or dropped.

Functions

This section is empty.

Types

type Server

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

Server provides a concurrent safe RPC server to a chain server.

func NewRPCServer

func NewRPCServer(
	startupTime int64,
	p2pServer *p2p.Server,
	db database.DB,
	blockTemplateGenerator *mining.BlkTmplGenerator,
	cpuminer *cpuminer.CPUMiner,

) (*Server, error)

NewRPCServer returns a new instance of the rpcServer struct.

func (*Server) NotifyNewTransactions

func (s *Server) NotifyNewTransactions(txns []*mempool.TxDesc)

NotifyNewTransactions notifies both websocket and getBlockTemplate long poll clients of the passed transactions. This function should be called whenever new transactions are added to the mempool.

func (*Server) RequestedProcessShutdown

func (s *Server) RequestedProcessShutdown() <-chan struct{}

RequestedProcessShutdown returns a channel that is sent to when an authorized RPC client requests the process to shutdown. If the request can not be read immediately, it is dropped.

func (*Server) Start

func (s *Server) Start()

Start is used by server.go to start the rpc listener.

func (*Server) Stop

func (s *Server) Stop() error

Stop is used by server.go to stop the rpc listener.

func (*Server) WebsocketHandler

func (s *Server) WebsocketHandler(conn *websocket.Conn, remoteAddr string,
	authenticated bool, isAdmin bool)

WebsocketHandler handles a new websocket client by creating a new wsClient, starting it, and blocking until the connection closes. Since it blocks, it must be run in a separate goroutine. It should be invoked from the websocket server handler which runs each new connection in a new goroutine thereby satisfying the requirement.

Jump to

Keyboard shortcuts

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