quicnetwork

package
v0.0.0-...-5a6e01e Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2023 License: GPL-3.0 Imports: 40 Imported by: 0

Documentation

Overview

Package quicnetwork provides the quic based network.

Index

Constants

View Source
const QuicEncoderHintHeader string = "X-MITUM-ENCODER-HINT"
View Source
const (
	SendSealFromConnInfoHeader string = "X-MITUM-FROM-CONNINFO"
)

Variables

View Source
var (
	HTTPClientPoolGet = func() *http.Client {
		return httpClientPool.Get().(*http.Client)
	}
	HTTPClientPoolPut = func(c *http.Client) {
		c.Transport = nil
		c.CheckRedirect = nil
		c.Jar = nil
		c.Timeout = 0

		httpClientPool.Put(c)
	}

	RoundTripperPoolGet = func() *http3.RoundTripper {
		return roundTripperPool.Get().(*http3.RoundTripper)
	}
	RoundTripperPoolPut = func(r *http3.RoundTripper) {

		r.DisableCompression = false
		r.TLSClientConfig = nil
		r.QuicConfig = nil
		r.Dial = nil
		r.MaxResponseHeaderBytes = 0

		roundTripperPool.Put(r)
	}
)
View Source
var (
	DefaultPort                         = "54321"
	QuicHandlerPathGetStagedOperations  = "/operations"
	QuicHandlerPathSendSeal             = "/seal"
	QuicHandlerPathGetProposal          = "/proposal"
	QuicHandlerPathGetProposalPattern   = "/proposal" + "/{hash:.*}"
	QuicHandlerPathGetBlockdataMaps     = "/blockdatamaps"
	QuicHandlerPathGetBlockdata         = "/blockdata"
	QuicHandlerPathGetBlockdataPattern  = QuicHandlerPathGetBlockdata + "/{path:.*}"
	QuicHandlerPathPingHandoverPattern  = "/handover"
	QuicHandlerPathStartHandoverPattern = QuicHandlerPathPingHandoverPattern + "/start"
	QuicHandlerPathEndHandoverPattern   = QuicHandlerPathPingHandoverPattern + "/end"
	QuicHandlerPathNodeInfo             = "/"
)
View Source
var (
	BadRequestError   = util.NewError("bad request")
	NotSupportedErorr = util.NewError("not supported")
)
View Source
var LimitRequestByHeights = 20 // max number of reqeust heights

Functions

func CloneConfig

func CloneConfig(c *quic.Config) *quic.Config

func EncoderFromHeader

func EncoderFromHeader(header http.Header, encs *encoder.Encoders, enc encoder.Encoder) (encoder.Encoder, error)

func RateLimitStoreFromURI

func RateLimitStoreFromURI(s string) (limiter.Store, error)

Types

type Channel

type Channel struct {
	*logging.Logging
	// contains filtered or unexported fields
}

func NewChannel

func NewChannel(
	connInfo network.ConnInfo,
	bufsize uint,
	quicConfig *quic.Config,
	encs *encoder.Encoders,
	enc encoder.Encoder,
) (*Channel, error)

func (*Channel) Blockdata

func (ch *Channel) Blockdata(ctx context.Context, item block.BlockdataMapItem) (io.ReadCloser, error)

func (*Channel) BlockdataMaps

func (ch *Channel) BlockdataMaps(ctx context.Context, heights []base.Height) ([]block.BlockdataMap, error)

func (*Channel) ConnInfo

func (ch *Channel) ConnInfo() network.ConnInfo

func (*Channel) EndHandover

func (ch *Channel) EndHandover(ctx context.Context, sl network.EndHandoverSeal) (bool, error)

func (*Channel) Initialize

func (*Channel) Initialize() error

func (*Channel) NodeInfo

func (ch *Channel) NodeInfo(ctx context.Context) (network.NodeInfo, error)

func (*Channel) PingHandover

func (ch *Channel) PingHandover(ctx context.Context, sl network.PingHandoverSeal) (bool, error)

func (*Channel) Proposal

func (ch *Channel) Proposal(ctx context.Context, h valuehash.Hash) (base.Proposal, error)

func (*Channel) SendSeal

func (ch *Channel) SendSeal(ctx context.Context, ci network.ConnInfo, sl seal.Seal) error

func (*Channel) SetLogging

func (ch *Channel) SetLogging(l *logging.Logging) *logging.Logging

func (*Channel) StagedOperations

func (ch *Channel) StagedOperations(ctx context.Context, hs []valuehash.Hash) ([]operation.Operation, error)

func (*Channel) StartHandover

func (ch *Channel) StartHandover(ctx context.Context, sl network.StartHandoverSeal) (bool, error)

type HashesArgs

type HashesArgs struct {
	Hashes []valuehash.Hash
}

func NewHashesArgs

func NewHashesArgs(hashes []valuehash.Hash) HashesArgs

func (HashesArgs) Sort

func (ha HashesArgs) Sort()

func (HashesArgs) String

func (ha HashesArgs) String() string

func (*HashesArgs) UnmarshalBSON

func (ha *HashesArgs) UnmarshalBSON(b []byte) error

func (*HashesArgs) UnmarshalJSON

func (ha *HashesArgs) UnmarshalJSON(b []byte) error

type HashesArgsUnpackerJSON

type HashesArgsUnpackerJSON struct {
	Hashes []valuehash.Bytes
}

type HeightsArgs

type HeightsArgs struct {
	Heights []base.Height
}

func NewHeightsArgs

func NewHeightsArgs(heights []base.Height) HeightsArgs

func (HeightsArgs) Sort

func (ha HeightsArgs) Sort()

func (HeightsArgs) String

func (ha HeightsArgs) String() string

type PrimitiveQuicServer

type PrimitiveQuicServer struct {
	*logging.Logging
	*util.ContextDaemon
	// contains filtered or unexported fields
}

func NewPrimitiveQuicServer

func NewPrimitiveQuicServer(
	bind string,
	certs []tls.Certificate,
	httpLog *logging.Logging,
) (*PrimitiveQuicServer, error)

func (*PrimitiveQuicServer) Handler

func (qs *PrimitiveQuicServer) Handler(prefix string) *mux.Route

func (*PrimitiveQuicServer) SetHandler

func (qs *PrimitiveQuicServer) SetHandler(prefix string, handler http.Handler) *mux.Route

func (*PrimitiveQuicServer) SetHandlerFunc

func (qs *PrimitiveQuicServer) SetHandlerFunc(prefix string, f network.HTTPHandlerFunc) *mux.Route

func (*PrimitiveQuicServer) SetLogging

func (qs *PrimitiveQuicServer) SetLogging(l *logging.Logging) *logging.Logging

func (*PrimitiveQuicServer) StoppedChan

func (qs *PrimitiveQuicServer) StoppedChan() <-chan struct{}

type QuicClient

type QuicClient struct {
	*logging.Logging
	// contains filtered or unexported fields
}

func NewQuicClient

func NewQuicClient(insecure bool, quicConfig *quic.Config) (*QuicClient, error)

func (*QuicClient) Get

func (cl *QuicClient) Get(
	ctx context.Context, timeout time.Duration,
	url string, b []byte, headers http.Header,
) (*QuicResponse, error)

func (*QuicClient) Request

func (cl *QuicClient) Request(
	ctx context.Context,
	timeout time.Duration,
	url string,
	method string,
	b []byte,
	headers http.Header,
) (*http.Response, func() error, error)

func (*QuicClient) Send

func (cl *QuicClient) Send(
	ctx context.Context, timeout time.Duration,
	url string, b []byte, headers http.Header,
) (*QuicResponse, error)

type QuicResponse

type QuicResponse struct {
	sync.Mutex
	*http.Response
	// contains filtered or unexported fields
}

func NewQuicResponse

func NewQuicResponse(response *http.Response, closeFunc func() error) *QuicResponse

func (*QuicResponse) Body

func (qr *QuicResponse) Body() io.ReadCloser

func (*QuicResponse) Bytes

func (qr *QuicResponse) Bytes() ([]byte, error)

func (*QuicResponse) Close

func (qr *QuicResponse) Close() error

func (*QuicResponse) Error

func (qr *QuicResponse) Error() error

func (*QuicResponse) OK

func (qr *QuicResponse) OK() bool

type Server

type Server struct {
	*logging.Logging
	*PrimitiveQuicServer
	// contains filtered or unexported fields
}

func NewServer

func NewServer(
	prim *PrimitiveQuicServer,
	encs *encoder.Encoders, enc encoder.Encoder,
	ca cache.Cache,
	connInfo network.ConnInfo,
	passthroughs func(context.Context, network.PassthroughedSeal, func(seal.Seal, network.Channel)) error,
) (*Server, error)

func (*Server) Encoder

func (sv *Server) Encoder() encoder.Encoder

func (*Server) Encoders

func (sv *Server) Encoders() *encoder.Encoders

func (*Server) Initialize

func (*Server) Initialize() error

func (*Server) NodeInfoHandler

func (sv *Server) NodeInfoHandler() network.NodeInfoHandler

func (*Server) SetBlockdataHandler

func (sv *Server) SetBlockdataHandler(fn network.BlockdataHandler)

func (*Server) SetBlockdataMapsHandler

func (sv *Server) SetBlockdataMapsHandler(fn network.BlockdataMapsHandler)

func (*Server) SetEndHandoverHandler

func (sv *Server) SetEndHandoverHandler(fn network.EndHandoverHandler)

func (*Server) SetGetProposalHandler

func (sv *Server) SetGetProposalHandler(fn network.GetProposalHandler)

func (*Server) SetGetStagedOperationsHandler

func (sv *Server) SetGetStagedOperationsHandler(fn network.GetStagedOperationsHandler)

func (*Server) SetLogging

func (sv *Server) SetLogging(l *logging.Logging) *logging.Logging

func (*Server) SetNewSealHandler

func (sv *Server) SetNewSealHandler(fn network.NewSealHandler)

func (*Server) SetNodeInfoHandler

func (sv *Server) SetNodeInfoHandler(fn network.NodeInfoHandler)

func (*Server) SetPingHandoverHandler

func (sv *Server) SetPingHandoverHandler(fn network.PingHandoverHandler)

func (*Server) SetStartHandoverHandler

func (sv *Server) SetStartHandoverHandler(fn network.StartHandoverHandler)

func (*Server) Start

func (sv *Server) Start() error

Jump to

Keyboard shortcuts

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