Skip to content

Commit

Permalink
Fix another bug
Browse files Browse the repository at this point in the history
  • Loading branch information
shleikes committed Jan 14, 2025
1 parent 1e85a9f commit fc67e26
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion protocol/lavasession/single_consumer_session.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func (scs *SingleConsumerSession) SetUsageForSession(cuNeededForSession uint64,
scs.RelayNum += RelayNumberIncrement // increase relayNum
if scs.RelayNum > 1 {
// we only set reputation for sessions with more than one successful relays, this guarantees data within the epoch exists
scs.QoSManager.SetLastReputationQoSReportRaw(scs.epoch, scs.SessionId, reputationReport)
scs.QoSManager.SetLastReputationQoSReport(scs.epoch, scs.SessionId, reputationReport)
scs.QoSManager.SetLastReputationQoSReportRaw(scs.epoch, scs.SessionId, rawReputationReport)
}
scs.usedProviders = usedProviders
Expand Down
9 changes: 9 additions & 0 deletions protocol/qos/qos_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,15 @@ func (qosManager *QoSManager) SetLastReputationQoSReportRaw(epoch uint64, sessio
return doneChan
}

func (qosManager *QoSManager) SetLastReputationQoSReport(epoch uint64, sessionId int64, report *pairingtypes.QualityOfServiceReport) DoneChan {
qosMutatorBase, doneChan := qosManager.createQoSMutatorBase(epoch, sessionId)
qosManager.mutatorsQueue <- &QoSMutatorSetReputation{
QoSMutatorBase: *qosMutatorBase,
report: report,
}
return doneChan
}

func (qosManager *QoSManager) getQoSReport(epoch uint64, sessionId int64) *QoSReport {
qosManager.lock.RLock()
defer qosManager.lock.RUnlock()
Expand Down
18 changes: 18 additions & 0 deletions protocol/qos/qos_mutator_set_reputation.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package qos

import (
pairingtypes "github.com/lavanet/lava/v4/x/pairing/types"
)

// Mutator to set usage for a session
type QoSMutatorSetReputation struct {
QoSMutatorBase
report *pairingtypes.QualityOfServiceReport
}

func (qoSMutatorSetReputation *QoSMutatorSetReputation) Mutate(report *QoSReport) {
defer func() {
qoSMutatorSetReputation.doneChan <- struct{}{}
}()
report.lastReputationQoSReport = qoSMutatorSetReputation.report
}

0 comments on commit fc67e26

Please sign in to comment.