Skip to content

Commit

Permalink
Merge branch 'main' into CNS-942-remove-stake-entry-index-usage
Browse files Browse the repository at this point in the history
  • Loading branch information
oren-lava authored Apr 14, 2024
2 parents 5c982f0 + 13cecd9 commit 2f369a1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
4 changes: 2 additions & 2 deletions protocol/lavasession/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ import (

const (
MaxConsecutiveConnectionAttempts = 5
TimeoutForEstablishingAConnection = 1 * time.Second
MaxSessionsAllowedPerProvider = 1000 // Max number of sessions allowed per provider
TimeoutForEstablishingAConnection = 1500 * time.Millisecond // 1.5 seconds
MaxSessionsAllowedPerProvider = 1000 // Max number of sessions allowed per provider
MaxAllowedBlockListedSessionPerProvider = 3
MaximumNumberOfFailuresAllowedPerConsumerSession = 3
RelayNumberIncrement = 1
Expand Down
14 changes: 10 additions & 4 deletions protocol/rpcconsumer/rpcconsumer_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (

const (
MaxRelayRetries = 6
SendRelayAttempts = 3
numberOfTimesToCheckCurrentlyUsedIsEmpty = 3
)

Expand Down Expand Up @@ -329,10 +330,15 @@ func (rpccs *RPCConsumerServer) ProcessRelaySend(ctx context.Context, directiveH
ctx, cancel := context.WithCancel(ctx)
defer cancel()
relayProcessor := NewRelayProcessor(ctx, lavasession.NewUsedProviders(directiveHeaders), rpccs.requiredResponses, chainMessage, rpccs.consumerConsistency, dappID, consumerIp)
err := rpccs.sendRelayToProvider(ctx, chainMessage, relayRequestData, dappID, consumerIp, relayProcessor)
if err != nil && relayProcessor.usedProviders.CurrentlyUsed() == 0 {
// we failed to send a batch of relays, if there are no active sends we can terminate
return relayProcessor, err
var err error
// try sending a relay 3 times. if failed return the error
for retryFirstRelayAttempt := 0; retryFirstRelayAttempt < SendRelayAttempts; retryFirstRelayAttempt++ {
err = rpccs.sendRelayToProvider(ctx, chainMessage, relayRequestData, dappID, consumerIp, relayProcessor)
// check if we had an error. if we did, try again.
if err == nil {
break
}
utils.LavaFormatWarning("Failed retryFirstRelayAttempt, will retry.", err, utils.LogAttr("attempt", retryFirstRelayAttempt))
}
// a channel to be notified processing was done, true means we have results and can return
gotResults := make(chan bool)
Expand Down

0 comments on commit 2f369a1

Please sign in to comment.