Compare commits

..

3 Commits

Author SHA1 Message Date
Ori Newman
d80144ef15 Increase the route capacity of InvTransaction messages. (#1603) (#1637)
Co-authored-by: stasatdaglabs <39559713+stasatdaglabs@users.noreply.github.com>
2021-03-30 13:39:45 +03:00
Ori Newman
11bd3a7e3f Update to version 0.9.2 2021-03-30 12:45:48 +03:00
Svarog
e457503aea Update go-deploy workflow to upload all executables (#1604) 2021-03-14 13:47:54 +02:00
3 changed files with 41 additions and 4 deletions

View File

@@ -238,7 +238,7 @@ func (m *Manager) registerTransactionRelayFlow(router *routerpkg.Router, isStopp
outgoingRoute := router.OutgoingRoute()
return []*flow{
m.registerFlow("HandleRelayedTransactions", router,
m.registerFlowWithCapacity("HandleRelayedTransactions", 10_000, router,
[]appmessage.MessageCommand{appmessage.CmdInvTransaction, appmessage.CmdTx, appmessage.CmdTransactionNotFound}, isStopping, errChan,
func(incomingRoute *routerpkg.Route, peer *peerpkg.Peer) error {
return transactionrelay.HandleRelayedTransactions(m.context, incomingRoute, outgoingRoute)
@@ -274,6 +274,24 @@ func (m *Manager) registerFlow(name string, router *routerpkg.Router, messageTyp
panic(err)
}
return m.registerFlowForRoute(route, name, isStopping, errChan, initializeFunc)
}
func (m *Manager) registerFlowWithCapacity(name string, capacity int, router *routerpkg.Router,
messageTypes []appmessage.MessageCommand, isStopping *uint32,
errChan chan error, initializeFunc flowInitializeFunc) *flow {
route, err := router.AddIncomingRouteWithCapacity(capacity, messageTypes)
if err != nil {
panic(err)
}
return m.registerFlowForRoute(route, name, isStopping, errChan, initializeFunc)
}
func (m *Manager) registerFlowForRoute(route *routerpkg.Route, name string, isStopping *uint32,
errChan chan error, initializeFunc flowInitializeFunc) *flow {
return &flow{
name: name,
executeFunc: func(peer *peerpkg.Peer) {

View File

@@ -35,13 +35,32 @@ func NewRouter() *Router {
// be routed to the given `route`
func (r *Router) AddIncomingRoute(messageTypes []appmessage.MessageCommand) (*Route, error) {
route := NewRoute()
err := r.initializeIncomingRoute(route, messageTypes)
if err != nil {
return nil, err
}
return route, nil
}
// AddIncomingRouteWithCapacity registers the messages of types `messageTypes` to
// be routed to the given `route` with a capacity of `capacity`
func (r *Router) AddIncomingRouteWithCapacity(capacity int, messageTypes []appmessage.MessageCommand) (*Route, error) {
route := newRouteWithCapacity(capacity)
err := r.initializeIncomingRoute(route, messageTypes)
if err != nil {
return nil, err
}
return route, nil
}
func (r *Router) initializeIncomingRoute(route *Route, messageTypes []appmessage.MessageCommand) error {
for _, messageType := range messageTypes {
if r.doesIncomingRouteExist(messageType) {
return nil, errors.Errorf("a route for '%s' already exists", messageType)
return errors.Errorf("a route for '%s' already exists", messageType)
}
r.setIncomingRoute(messageType, route)
}
return route, nil
return nil
}
// RemoveRoute unregisters the messages of types `messageTypes` from

View File

@@ -11,7 +11,7 @@ const validCharacters = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrs
const (
appMajor uint = 0
appMinor uint = 9
appPatch uint = 1
appPatch uint = 2
)
// appBuild is defined as a variable so it can be overridden during the build