@@ -99,6 +99,8 @@ class SingleScanConnection private[client] (
9999 with ScanConnection
100100 with BackfillingScanConnection
101101 with HasUrl {
102+ import ScanRoundAggregatesDecoder .*
103+
102104 def url = config.adminApi.url
103105
104106 // cached DSO reference. Never changes.
@@ -392,76 +394,6 @@ class SingleScanConnection private[client] (
392394 }
393395 }
394396
395- private def decodeRoundTotal (
396- rt : org.lfdecentralizedtrust.splice.http.v0.definitions.RoundTotals
397- ): Either [String , ScanAggregator .RoundTotals ] = {
398- (for {
399- closedRoundEffectiveAt <- CantonTimestamp .fromInstant(rt.closedRoundEffectiveAt.toInstant)
400- appRewards <- Codec .decode(Codec .BigDecimal )(rt.appRewards)
401- validatorRewards <- Codec .decode(Codec .BigDecimal )(rt.validatorRewards)
402- changeToInitialAmountAsOfRoundZero <- Codec
403- .decode(Codec .BigDecimal )(rt.changeToInitialAmountAsOfRoundZero)
404- changeToHoldingFeesRate <- Codec .decode(Codec .BigDecimal )(rt.changeToHoldingFeesRate)
405- cumulativeAppRewards <- Codec .decode(Codec .BigDecimal )(rt.cumulativeAppRewards)
406- cumulativeValidatorRewards <- Codec
407- .decode(Codec .BigDecimal )(rt.cumulativeValidatorRewards)
408- cumulativeChangeToInitialAmountAsOfRoundZero <- Codec
409- .decode(Codec .BigDecimal )(rt.cumulativeChangeToInitialAmountAsOfRoundZero)
410- cumulativeChangeToHoldingFeesRate <- Codec
411- .decode(Codec .BigDecimal )(rt.cumulativeChangeToHoldingFeesRate)
412- totalAmuletBalance <- Codec .decode(Codec .BigDecimal )(rt.totalAmuletBalance)
413- } yield {
414- ScanAggregator .RoundTotals (
415- closedRound = rt.closedRound,
416- closedRoundEffectiveAt = closedRoundEffectiveAt,
417- appRewards = appRewards,
418- validatorRewards = validatorRewards,
419- changeToInitialAmountAsOfRoundZero = changeToInitialAmountAsOfRoundZero,
420- changeToHoldingFeesRate = changeToHoldingFeesRate,
421- cumulativeAppRewards = cumulativeAppRewards,
422- cumulativeValidatorRewards = cumulativeValidatorRewards,
423- cumulativeChangeToInitialAmountAsOfRoundZero = cumulativeChangeToInitialAmountAsOfRoundZero,
424- cumulativeChangeToHoldingFeesRate = cumulativeChangeToHoldingFeesRate,
425- totalAmuletBalance = totalAmuletBalance,
426- )
427- })
428- }
429-
430- private def decodeRoundPartyTotals (
431- rt : org.lfdecentralizedtrust.splice.http.v0.definitions.RoundPartyTotals
432- ): Either [String , ScanAggregator .RoundPartyTotals ] = {
433- (for {
434- appRewards <- Codec .decode(Codec .BigDecimal )(rt.appRewards)
435- validatorRewards <- Codec .decode(Codec .BigDecimal )(rt.validatorRewards)
436- trafficPurchasedCcSpent <- Codec .decode(Codec .BigDecimal )(rt.trafficPurchasedCcSpent)
437- cumulativeAppRewards <- Codec .decode(Codec .BigDecimal )(rt.cumulativeAppRewards)
438- cumulativeValidatorRewards <- Codec .decode(Codec .BigDecimal )(rt.cumulativeValidatorRewards)
439- cumulativeChangeToInitialAmountAsOfRoundZero <- Codec
440- .decode(Codec .BigDecimal )(rt.cumulativeChangeToInitialAmountAsOfRoundZero)
441- cumulativeChangeToHoldingFeesRate <- Codec
442- .decode(Codec .BigDecimal )(rt.cumulativeChangeToHoldingFeesRate)
443- cumulativeTrafficPurchasedCcSpent <- Codec
444- .decode(Codec .BigDecimal )(rt.cumulativeTrafficPurchasedCcSpent)
445- } yield {
446- ScanAggregator .RoundPartyTotals (
447- closedRound = rt.closedRound,
448- party = rt.party,
449- appRewards = appRewards,
450- validatorRewards = validatorRewards,
451- trafficPurchased = rt.trafficPurchased,
452- trafficPurchasedCcSpent = trafficPurchasedCcSpent,
453- trafficNumPurchases = rt.trafficNumPurchases,
454- cumulativeAppRewards = cumulativeAppRewards,
455- cumulativeValidatorRewards = cumulativeValidatorRewards,
456- cumulativeChangeToInitialAmountAsOfRoundZero = cumulativeChangeToInitialAmountAsOfRoundZero,
457- cumulativeChangeToHoldingFeesRate = cumulativeChangeToHoldingFeesRate,
458- cumulativeTrafficPurchased = rt.cumulativeTrafficPurchased,
459- cumulativeTrafficPurchasedCcSpent = cumulativeTrafficPurchasedCcSpent,
460- cumulativeTrafficNumPurchases = rt.cumulativeTrafficNumPurchases,
461- )
462- })
463- }
464-
465397 override def getMigrationSchedule ()(implicit
466398 ec : ExecutionContext ,
467399 tc : TraceContext ,
@@ -878,3 +810,63 @@ class CachedScanConnection private[client] (
878810 )
879811 )
880812}
813+
814+ object ScanRoundAggregatesDecoder {
815+ def decodeRoundTotal (
816+ rt : org.lfdecentralizedtrust.splice.http.v0.definitions.RoundTotals
817+ ): Either [String , ScanAggregator .RoundTotals ] = {
818+ (for {
819+ closedRoundEffectiveAt <- CantonTimestamp .fromInstant(rt.closedRoundEffectiveAt.toInstant)
820+ appRewards <- Codec .decode(Codec .BigDecimal )(rt.appRewards)
821+ validatorRewards <- Codec .decode(Codec .BigDecimal )(rt.validatorRewards)
822+ cumulativeAppRewards <- Codec .decode(Codec .BigDecimal )(rt.cumulativeAppRewards)
823+ cumulativeValidatorRewards <- Codec
824+ .decode(Codec .BigDecimal )(rt.cumulativeValidatorRewards)
825+ } yield {
826+ // changeToInitialAmountAsOfRoundZero, changeToHoldingFeesRate, cumulativeChangeToInitialAmountAsOfRoundZero,
827+ // cumulativeChangeToHoldingFeesRate and totalAmuletBalance are intentionally left out
828+ // since these do not match up anymore because amulet expires are attributed to the closed round at a later stage
829+ // in scan_txlog_store, at a time that can easily differ between SVs.
830+ ScanAggregator .RoundTotals (
831+ closedRound = rt.closedRound,
832+ closedRoundEffectiveAt = closedRoundEffectiveAt,
833+ appRewards = appRewards,
834+ validatorRewards = validatorRewards,
835+ cumulativeAppRewards = cumulativeAppRewards,
836+ cumulativeValidatorRewards = cumulativeValidatorRewards,
837+ )
838+ })
839+ }
840+
841+ def decodeRoundPartyTotals (
842+ rt : org.lfdecentralizedtrust.splice.http.v0.definitions.RoundPartyTotals
843+ ): Either [String , ScanAggregator .RoundPartyTotals ] = {
844+ (for {
845+ appRewards <- Codec .decode(Codec .BigDecimal )(rt.appRewards)
846+ validatorRewards <- Codec .decode(Codec .BigDecimal )(rt.validatorRewards)
847+ trafficPurchasedCcSpent <- Codec .decode(Codec .BigDecimal )(rt.trafficPurchasedCcSpent)
848+ cumulativeAppRewards <- Codec .decode(Codec .BigDecimal )(rt.cumulativeAppRewards)
849+ cumulativeValidatorRewards <- Codec .decode(Codec .BigDecimal )(rt.cumulativeValidatorRewards)
850+ cumulativeTrafficPurchasedCcSpent <- Codec
851+ .decode(Codec .BigDecimal )(rt.cumulativeTrafficPurchasedCcSpent)
852+ } yield {
853+ // cumulativeChangeToInitialAmountAsOfRoundZero and cumulativeChangeToHoldingFeesRate are intentionally left out
854+ // since these do not match up anymore because amulet expires are attributed to the closed round at a later stage
855+ // in scan_txlog_store, at a time that can easily differ between SVs.
856+ ScanAggregator .RoundPartyTotals (
857+ closedRound = rt.closedRound,
858+ party = rt.party,
859+ appRewards = appRewards,
860+ validatorRewards = validatorRewards,
861+ trafficPurchased = rt.trafficPurchased,
862+ trafficPurchasedCcSpent = trafficPurchasedCcSpent,
863+ trafficNumPurchases = rt.trafficNumPurchases,
864+ cumulativeAppRewards = cumulativeAppRewards,
865+ cumulativeValidatorRewards = cumulativeValidatorRewards,
866+ cumulativeTrafficPurchased = rt.cumulativeTrafficPurchased,
867+ cumulativeTrafficPurchasedCcSpent = cumulativeTrafficPurchasedCcSpent,
868+ cumulativeTrafficNumPurchases = rt.cumulativeTrafficNumPurchases,
869+ )
870+ })
871+ }
872+ }
0 commit comments