chore(wallet) increase the all-time fetching sample count
Also: - extend maximum expected DB entries to fetch - fix test TestBalanceHistoryGetWithoutOverlappingFetch passing because of all-time stride side effect Closes status-desktop #9624
This commit is contained in:
parent
30f167e63d
commit
226fa7d696
|
@ -33,7 +33,7 @@ var averageBlockDurationForChain = map[uint64]time.Duration{
|
||||||
const (
|
const (
|
||||||
twiceADayStride time.Duration = time.Duration(12) * time.Hour
|
twiceADayStride time.Duration = time.Duration(12) * time.Hour
|
||||||
weekStride = 14 * twiceADayStride
|
weekStride = 14 * twiceADayStride
|
||||||
fourMonthsStride = 4 /*months*/ * 4 * weekStride
|
monthsStride = 1 /*months*/ * 4 * weekStride
|
||||||
)
|
)
|
||||||
|
|
||||||
// bitsetFilters used to fetch relevant data points in one batch and to increase cache hit
|
// bitsetFilters used to fetch relevant data points in one batch and to increase cache hit
|
||||||
|
@ -74,7 +74,7 @@ var timeIntervalToStrideDuration = map[TimeInterval]time.Duration{
|
||||||
BalanceHistory1Month: twiceADayStride,
|
BalanceHistory1Month: twiceADayStride,
|
||||||
BalanceHistory6Months: weekStride,
|
BalanceHistory6Months: weekStride,
|
||||||
BalanceHistory1Year: weekStride,
|
BalanceHistory1Year: weekStride,
|
||||||
BalanceHistoryAllTime: fourMonthsStride,
|
BalanceHistoryAllTime: monthsStride,
|
||||||
}
|
}
|
||||||
|
|
||||||
func strideBlockCount(timeInterval TimeInterval, chainID uint64) int {
|
func strideBlockCount(timeInterval TimeInterval, chainID uint64) int {
|
||||||
|
@ -244,7 +244,7 @@ func (b *Balance) get(ctx context.Context, chainID uint64, currency string, addr
|
||||||
startTimestamp = endTimestamp - int64(timeIntervalDuration[timeInterval].Seconds())
|
startTimestamp = endTimestamp - int64(timeIntervalDuration[timeInterval].Seconds())
|
||||||
fetchTimestamp = startTimestamp - int64(timeIntervalToStrideDuration[timeInterval].Seconds())
|
fetchTimestamp = startTimestamp - int64(timeIntervalToStrideDuration[timeInterval].Seconds())
|
||||||
}
|
}
|
||||||
cached, _, err := b.db.filter(&assetIdentity{chainID, address, currency}, nil, &balanceFilter{fetchTimestamp, endTimestamp, expandFlag(timeIntervalToBitsetFilter[timeInterval])}, 200, asc)
|
cached, _, err := b.db.filter(&assetIdentity{chainID, address, currency}, nil, &balanceFilter{fetchTimestamp, endTimestamp, expandFlag(timeIntervalToBitsetFilter[timeInterval])}, 800, asc)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -273,16 +273,18 @@ func TestBalanceHistoryGetWithoutOverlappingFetch(t *testing.T) {
|
||||||
currentTimestamp := dataSource.TimeNow()
|
currentTimestamp := dataSource.TimeNow()
|
||||||
getUntilTimestamp := currentTimestamp - int64((400 /*days*/ * 24 * time.Hour).Seconds())
|
getUntilTimestamp := currentTimestamp - int64((400 /*days*/ * 24 * time.Hour).Seconds())
|
||||||
|
|
||||||
fetchInterval := testInput.interval + 3
|
getInterval := testInput.interval + 3
|
||||||
if fetchInterval > BalanceHistoryAllTime {
|
if getInterval > BalanceHistoryAllTime {
|
||||||
fetchInterval = BalanceHistory7Days + BalanceHistoryAllTime - testInput.interval
|
getInterval = BalanceHistory7Days + BalanceHistoryAllTime - testInput.interval
|
||||||
}
|
}
|
||||||
err := bh.update(context.Background(), dataSource, common.Address{7}, fetchInterval)
|
err := bh.update(context.Background(), dataSource, common.Address{7}, testInput.interval)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
balanceData, err := bh.get(context.Background(), dataSource.ChainID(), dataSource.Currency(), common.Address{7}, getUntilTimestamp, testInput.interval)
|
balanceData, err := bh.get(context.Background(), dataSource.ChainID(), dataSource.Currency(), common.Address{7}, getUntilTimestamp, getInterval)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
if testInput.interval != BalanceHistoryAllTime {
|
||||||
require.Equal(t, 0, len(balanceData))
|
require.Equal(t, 0, len(balanceData))
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -688,7 +690,7 @@ func TestBlockStrideHaveCommonDivisor(t *testing.T) {
|
||||||
|
|
||||||
func TestBlockStrideMatchesBitsetFilter(t *testing.T) {
|
func TestBlockStrideMatchesBitsetFilter(t *testing.T) {
|
||||||
filterToStrideEquivalence := map[bitsetFilter]time.Duration{
|
filterToStrideEquivalence := map[bitsetFilter]time.Duration{
|
||||||
filterAllTime: fourMonthsStride,
|
filterAllTime: monthsStride,
|
||||||
filterWeekly: weekStride,
|
filterWeekly: weekStride,
|
||||||
filterTwiceADay: twiceADayStride,
|
filterTwiceADay: twiceADayStride,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue