rpc

package
v0.0.0-...-e4e12f0 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2022 License: LGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HandleFunc

type HandleFunc func(msg *p2p.Msg, write func(interface{})) error

HandleFunc to handle received messages from peer.

type RPC

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

RPC defines the common pattern that peer interacts with each other.

func New

func New(peer *p2p.Peer, rw p2p.MsgReadWriter) *RPC

New create a new RPC instance.

func (*RPC) Call

func (r *RPC) Call(ctx context.Context, msgCode uint64, arg interface{}, result interface{}) error

Call send a call to the peer and wait for result.

func (*RPC) Done

func (r *RPC) Done() <-chan struct{}

Done returns a channel to indicates whether peer disconnected.

func (*RPC) Notify

func (r *RPC) Notify(ctx context.Context, msgCode uint64, arg interface{}) error

Notify notifies a message to the peer.

func (*RPC) Serve

func (r *RPC) Serve(handleFunc HandleFunc, maxMsgSize uint32) error

Serve handles peer's IO loop, and dispatches calls and results.

Jump to

Keyboard shortcuts

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