forked from LBRYCommunity/lbry-sdk
trending fixes
This commit is contained in:
parent
db2789990f
commit
0ba75153f3
5 changed files with 19 additions and 17 deletions
|
@ -520,7 +520,7 @@ class BlockProcessor:
|
|||
|
||||
# add the spike for trending
|
||||
self.db_op_stack.append_op(self.db.prefix_db.trending_spike.pack_spike(
|
||||
height, claim_hash, tx_num, nout, txo.amount - previous_amount, half_life=self.env.trending_half_life
|
||||
height, claim_hash, tx_num, nout, txo.amount, half_life=self.env.trending_half_life
|
||||
))
|
||||
|
||||
def _add_support(self, height: int, txo: 'Output', tx_num: int, nout: int):
|
||||
|
|
|
@ -178,9 +178,8 @@ class SearchIndex:
|
|||
}, slices=4, conflicts='proceed'
|
||||
)
|
||||
self.logger.info("updated trending scores in %ims", int((time.perf_counter() - start) * 1000))
|
||||
|
||||
whale_decay_factor = 2 * (2.0 ** (-1 / self._trending_whale_half_life))
|
||||
decay_factor = 2 * (2.0 ** (-1 / self._trending_half_life))
|
||||
whale_decay_factor = 2.0 ** ((-1 / self._trending_whale_half_life) + 1)
|
||||
decay_factor = 2.0 ** ((-1 / self._trending_half_life) + 1)
|
||||
decay_script = """
|
||||
if (ctx._source.trending_score == null) { ctx._source.trending_score = 0.0; }
|
||||
if ((-0.1 <= ctx._source.trending_score) && (ctx._source.trending_score <= 0.1)) {
|
||||
|
|
|
@ -1363,12 +1363,14 @@ class TrendingSpikePrefixRow(PrefixRow):
|
|||
struct.Struct(b'>L20sLH').pack
|
||||
]
|
||||
|
||||
def pack_spike(self, height: int, claim_hash: bytes, tx_num: int, position: int, amount: int, half_life: int,
|
||||
@classmethod
|
||||
def pack_spike(cls, height: int, claim_hash: bytes, tx_num: int, position: int, amount: int, half_life: int,
|
||||
depth: int = 0, subtract: bool = False) -> RevertablePut:
|
||||
softened_change = (((amount * 1E-8) + 1E-8) ** 0.25).real
|
||||
spike_mass = (-1.0 if subtract else 1.0) * softened_change * 2 * ((2.0 ** (-1 / half_life)) ** depth)
|
||||
# trending_spike_height = self.height + delay_trending_spike(self.amount * 1E-8)
|
||||
return RevertablePut(*self.pack_item(height, claim_hash, tx_num, position, spike_mass))
|
||||
softened_change = (((amount * 1E-8) + 1E-8) ** (1 / 4))
|
||||
spike_mass = softened_change * ((2.0 ** (-1 / half_life)) ** depth)
|
||||
if subtract:
|
||||
spike_mass = -spike_mass
|
||||
return RevertablePut(*cls.pack_item(height, claim_hash, tx_num, position, spike_mass))
|
||||
|
||||
@classmethod
|
||||
def pack_key(cls, height: int, claim_hash: bytes, tx_num: int, position: int):
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
# See the file "LICENCE" for information about the copyright
|
||||
# and warranty status of this software.
|
||||
|
||||
|
||||
import math
|
||||
import re
|
||||
import resource
|
||||
from os import environ
|
||||
|
@ -39,12 +39,13 @@ class Env:
|
|||
self.obsolete(['UTXO_MB', 'HIST_MB', 'NETWORK'])
|
||||
self.db_dir = self.required('DB_DIRECTORY')
|
||||
self.db_engine = self.default('DB_ENGINE', 'leveldb')
|
||||
self.trending_algorithms = [
|
||||
trending for trending in set(self.default('TRENDING_ALGORITHMS', 'zscore').split(' ')) if trending
|
||||
]
|
||||
self.trending_half_life = float(self.string_amount('TRENDING_HALF_LIFE', "0.9"))
|
||||
self.trending_whale_half_life = float(self.string_amount('TRENDING_WHALE_HALF_LIFE', "0.99"))
|
||||
self.trending_whale_threshold = float(self.integer('TRENDING_WHALE_THRESHOLD', 10000))
|
||||
# self.trending_algorithms = [
|
||||
# trending for trending in set(self.default('TRENDING_ALGORITHMS', 'zscore').split(' ')) if trending
|
||||
# ]
|
||||
self.trending_half_life = math.log2(0.1 ** (1 / (3 + self.integer('TRENDING_DECAY_RATE', 48)))) + 1
|
||||
self.trending_whale_half_life = math.log2(0.1 ** (1 / (3 + self.integer('TRENDING_WHALE_DECAY_RATE', 24)))) + 1
|
||||
self.trending_whale_threshold = float(self.integer('TRENDING_WHALE_THRESHOLD', 10000)) * 1E8
|
||||
|
||||
self.max_query_workers = self.integer('MAX_QUERY_WORKERS', None)
|
||||
self.individual_tag_indexes = self.boolean('INDIVIDUAL_TAG_INDEXES', True)
|
||||
self.track_metrics = self.boolean('TRACK_METRICS', False)
|
||||
|
|
|
@ -897,7 +897,7 @@ class LBRYElectrumX(SessionBase):
|
|||
'donation_address': env.donation_address,
|
||||
'daily_fee': env.daily_fee,
|
||||
'hash_function': 'sha256',
|
||||
'trending_algorithm': env.trending_algorithms[0]
|
||||
'trending_algorithm': 'variable_decay'
|
||||
})
|
||||
|
||||
async def server_features_async(self):
|
||||
|
|
Loading…
Reference in a new issue