Documentation ¶
Overview ¶
Package fcrserver - provides an interface to do networking.
Package fcrserver - provides an interface to do networking.
Index ¶
- Constants
- func GetMultiAddr(privKeyStr string, ip string, port uint) (string, error)
- func IsTimeoutError(err error) bool
- type FCRServer
- type FCRServerImplV1
- func (s *FCRServerImplV1) AddHandler(msgType byte, ...) FCRServer
- func (s *FCRServerImplV1) AddRequester(msgType byte, ...) FCRServer
- func (s *FCRServerImplV1) Request(multiaddrStr string, msgType byte, args ...interface{}) (*fcrmessages.FCRACKMsg, error)
- func (s *FCRServerImplV1) Shutdown()
- func (s *FCRServerImplV1) Start() error
- type FCRServerRequestReader
- type FCRServerRequestReaderImplV1
- type FCRServerRequestWriter
- type FCRServerRequestWriterImplV1
- type FCRServerResponseReader
- type FCRServerResponseReaderImplV1
- type FCRServerResponseWriter
- type FCRServerResponseWriterImplV1
Constants ¶
const ( Lowwater = 100 Highwater = 400 GracePeriod = time.Hour )
Variables ¶
This section is empty.
Functions ¶
func GetMultiAddr ¶
GetMultiAddr returns the supposed multiaddr string from given private key, ip address and port.
func IsTimeoutError ¶
IsTimeoutError checks if the given error is a timeout error
Types ¶
type FCRServer ¶
type FCRServer interface { // Start starts the server. Start() error // Shutdown stops the server. Shutdown() // AddHandler adds a handler to the server, which handles a given message type. AddHandler(msgType byte, handler func(reader FCRServerRequestReader, writer FCRServerResponseWriter, request *fcrmessages.FCRReqMsg) error) FCRServer // AddRequester adds a requester to the server, which is used to send a request for a given message type. AddRequester(msgType byte, requester func(reader FCRServerResponseReader, writer FCRServerRequestWriter, args ...interface{}) (*fcrmessages.FCRACKMsg, error)) FCRServer // Request uses a requester corresponding to the given message type to send a request to given multiaddr. Request(multiaddrStr string, msgType byte, args ...interface{}) (*fcrmessages.FCRACKMsg, error) }
FCRServer represents a server handling p2p connection.
type FCRServerImplV1 ¶
type FCRServerImplV1 struct {
// contains filtered or unexported fields
}
FCRServerImplV1 implements FCRServer, it is built on top of libp2p.
func (*FCRServerImplV1) AddHandler ¶
func (s *FCRServerImplV1) AddHandler(msgType byte, handler func(reader FCRServerRequestReader, writer FCRServerResponseWriter, request *fcrmessages.FCRReqMsg) error) FCRServer
func (*FCRServerImplV1) AddRequester ¶
func (s *FCRServerImplV1) AddRequester(msgType byte, requester func(reader FCRServerResponseReader, writer FCRServerRequestWriter, args ...interface{}) (*fcrmessages.FCRACKMsg, error)) FCRServer
func (*FCRServerImplV1) Request ¶
func (s *FCRServerImplV1) Request(multiaddrStr string, msgType byte, args ...interface{}) (*fcrmessages.FCRACKMsg, error)
func (*FCRServerImplV1) Shutdown ¶
func (s *FCRServerImplV1) Shutdown()
func (*FCRServerImplV1) Start ¶
func (s *FCRServerImplV1) Start() error
type FCRServerRequestReader ¶
type FCRServerRequestReader interface { // Read reads a message for a given timeout. // It returns the message, and error. Read(timeout time.Duration) (*fcrmessages.FCRReqMsg, error) }
FCRServerRequestReader is a reader for reading message.
type FCRServerRequestReaderImplV1 ¶
type FCRServerRequestReaderImplV1 struct {
// contains filtered or unexported fields
}
FCRServerRequestReaderImplV1 implements FCRServerRequestReader.
func (*FCRServerRequestReaderImplV1) Read ¶
func (r *FCRServerRequestReaderImplV1) Read(timeout time.Duration) (*fcrmessages.FCRReqMsg, error)
type FCRServerRequestWriter ¶
type FCRServerRequestWriter interface { // Write writes a message for a given timeout. // It returns error. Write(msg *fcrmessages.FCRReqMsg, privKey string, keyVer byte, timeout time.Duration) error }
FCRServerRequesterWriter is a writer for writer request.
type FCRServerRequestWriterImplV1 ¶
type FCRServerRequestWriterImplV1 struct {
// contains filtered or unexported fields
}
FCRServerRequestWriterImplV1 implements FCRServerRequestWriter.
func (*FCRServerRequestWriterImplV1) Write ¶
func (w *FCRServerRequestWriterImplV1) Write(msg *fcrmessages.FCRReqMsg, privKey string, keyVer byte, timeout time.Duration) error
type FCRServerResponseReader ¶
type FCRServerResponseReader interface { // Read reads a message for a given timeout. // It returns the message, and error. Read(timeout time.Duration) (*fcrmessages.FCRACKMsg, error) }
FCRServerResponseReader is a reader for reading message.
type FCRServerResponseReaderImplV1 ¶
type FCRServerResponseReaderImplV1 struct {
// contains filtered or unexported fields
}
FCRServerResponseReaderImplV1 implements FCRServerResponseReader.
func (*FCRServerResponseReaderImplV1) Read ¶
func (r *FCRServerResponseReaderImplV1) Read(timeout time.Duration) (*fcrmessages.FCRACKMsg, error)
type FCRServerResponseWriter ¶
type FCRServerResponseWriter interface { // Write writes a message for a given timeout. // It returns error. Write(msg *fcrmessages.FCRACKMsg, privKey string, keyVer byte, timeout time.Duration) error }
FCRServerResponseWriter is a writer for writer response.
type FCRServerResponseWriterImplV1 ¶
type FCRServerResponseWriterImplV1 struct {
// contains filtered or unexported fields
}
FCRServerResponseWriterImplV1 implements FCRServerResponseWriter.
func (*FCRServerResponseWriterImplV1) Write ¶
func (w *FCRServerResponseWriterImplV1) Write(msg *fcrmessages.FCRACKMsg, privKey string, keyVer byte, timeout time.Duration) error