routing

package
v1.1.0-1 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2022 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildSimpleTable

func BuildSimpleTable(bvns []string) []protocol.Route

func RouteEnvelopes

func RouteEnvelopes(routeAccount func(*url.URL) (string, error), envs ...*protocol.Envelope) (string, error)

Types

type MessageRouter

type MessageRouter struct {
	Router
}

MessageRouter routes messages using a Router.

func (MessageRouter) Route

func (r MessageRouter) Route(msg message.Message) (multiaddr.Multiaddr, error)

Route routes a message.

type ResponseSubmit

type ResponseSubmit struct {
	Code         uint32
	Data         []byte
	Log          string
	Info         string
	Codespace    string
	MempoolError string
}

ResponseSubmit is the response from a call to Submit.

type RouteTree

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

func NewRouteTree

func NewRouteTree(table *protocol.RoutingTable) (*RouteTree, error)

func (*RouteTree) Route

func (r *RouteTree) Route(u *url.URL) (string, error)

func (*RouteTree) RouteNr

func (r *RouteTree) RouteNr(n uint64) (string, error)

type Router

type Router interface {
	RouteAccount(*url.URL) (string, error)
	Route(...*protocol.Envelope) (string, error)
	RequestAPIv2(ctx context.Context, partitionId, method string, params, result interface{}) error
	Submit(ctx context.Context, partition string, tx *protocol.Envelope, pretend, async bool) (*ResponseSubmit, error)
}

Router defines a basic interface for routing and sending transactions.

TODO Route and Send should probably be handled separately.

type RouterInstance

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

RouterInstance sends transactions to remote nodes via RPC calls.

func NewRouter

func NewRouter(eventBus *events.Bus, cm connections.ConnectionManager, logger log.Logger) *RouterInstance

func NewStaticRouter

func NewStaticRouter(table *protocol.RoutingTable, cm connections.ConnectionManager, logger log.Logger) (*RouterInstance, error)

NewStaticRouter returns a router that uses a static routing table

func (*RouterInstance) RequestAPIv2

func (r *RouterInstance) RequestAPIv2(ctx context.Context, partitionId, method string, params, result interface{}) error

func (*RouterInstance) Route

func (r *RouterInstance) Route(envs ...*protocol.Envelope) (string, error)

Route routes the account using modulo routing.

func (*RouterInstance) RouteAccount

func (r *RouterInstance) RouteAccount(account *url.URL) (string, error)

func (*RouterInstance) Submit

func (r *RouterInstance) Submit(ctx context.Context, partitionId string, tx *protocol.Envelope, pretend, async bool) (*ResponseSubmit, error)

Submit submits the transaction to the specified partition. If the partition matches this network's ID, the transaction is broadcasted via the local client. Otherwise the transaction is broadcasted via an RPC client.

Jump to

Keyboard shortcuts

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