hive-nectar 0.0.7__py3-none-any.whl → 0.0.9b0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of hive-nectar might be problematic. Click here for more details.

nectar/nodelist.py CHANGED
@@ -243,7 +243,12 @@ class NodeList(list):
243
243
  cnt += 1
244
244
  try:
245
245
  account = Account("nectarflower", blockchain_instance=steem)
246
- metadata = json.loads(account["posting_json_metadata"])
246
+ # Metadata is stored in the account's json_metadata field (not posting_json_metadata)
247
+ raw_meta = account.get("json_metadata") or ""
248
+ try:
249
+ metadata = json.loads(raw_meta) if raw_meta else None
250
+ except Exception:
251
+ metadata = None
247
252
  except Exception as e:
248
253
  log.warning(f"Error fetching metadata (attempt {cnt}): {str(e)}")
249
254
  steem.rpc.next()
@@ -257,10 +262,30 @@ class NodeList(list):
257
262
  report = metadata.get("report", [])
258
263
  failing_nodes = metadata.get("failing_nodes", {})
259
264
  parameter = metadata.get("parameter", {})
260
- benchmarks = parameter.get("benchmarks", {})
261
-
262
- # Convert benchmarks dict to list of benchmark names
263
- benchmark_names = list(benchmarks.keys())
265
+ benchmarks = parameter.get("benchmarks")
266
+
267
+ # Determine benchmark names. If not explicitly provided in metadata parameters, derive them
268
+ # by inspecting the keys of the report entries and filtering out the non-benchmark fields.
269
+ if benchmarks and isinstance(benchmarks, dict):
270
+ benchmark_names: list[str] = list(benchmarks.keys())
271
+ else:
272
+ benchmark_names = []
273
+ # Common non-benchmark keys present in every report entry
274
+ _skip_keys = {
275
+ "node",
276
+ "version",
277
+ "hive",
278
+ "weighted_score",
279
+ "tests_completed",
280
+ }
281
+ # Collect benchmark names dynamically from the report section
282
+ for _entry in report:
283
+ if isinstance(_entry, dict):
284
+ for _k in _entry.keys():
285
+ if _k not in _skip_keys and _k not in benchmark_names:
286
+ benchmark_names.append(_k)
287
+ # Sort for deterministic ordering
288
+ benchmark_names.sort()
264
289
 
265
290
  if weights is None:
266
291
  weights_dict = {}
@@ -294,6 +319,7 @@ class NodeList(list):
294
319
 
295
320
  for node in self:
296
321
  new_node = node.copy()
322
+ node_was_updated = False
297
323
 
298
324
  # Check against report data
299
325
  for report_node in report:
@@ -319,17 +345,67 @@ class NodeList(list):
319
345
  weighted_score = score * weights_dict.get(benchmark, 0)
320
346
  scores.append(weighted_score)
321
347
 
322
- sum_score = sum(scores)
323
- new_node["score"] = sum_score
348
+ # Prefer the pre-computed weighted_score from the metadata if present; fall back to
349
+ # the locally calculated score otherwise.
350
+ if "weighted_score" in report_node and isinstance(report_node["weighted_score"], (int, float)):
351
+ new_node["score"] = report_node["weighted_score"]
352
+ else:
353
+ sum_score = sum(scores)
354
+ new_node["score"] = sum_score
355
+ node_was_updated = True
324
356
  break
325
357
 
326
358
  # Check if node is in failing nodes list
327
359
  if node["url"] in failing_nodes:
328
360
  failing_count += 1
329
361
  new_node["score"] = -1
362
+ elif not node_was_updated:
363
+ # If node wasn't part of the metadata report, reset its score so it
364
+ # doesn't overshadow the authoritative ordering
365
+ new_node["score"] = 0
330
366
 
331
367
  new_nodes.append(new_node)
332
368
 
369
+ # ------------------------------------------------------------
370
+ # Ensure that all nodes present in the metadata are included
371
+ # in the final list, even if they were not part of the default
372
+ # hard-coded set.
373
+ # ------------------------------------------------------------
374
+ existing_urls: set[str] = {n["url"] for n in new_nodes}
375
+
376
+ # Add nodes found in the report section
377
+ for report_node in report:
378
+ url = report_node.get("node")
379
+ if not url or url in existing_urls:
380
+ continue
381
+ new_entry = {
382
+ "url": url,
383
+ "version": report_node.get("version", "0.0.0"),
384
+ "type": "appbase",
385
+ "owner": report_node.get("owner", "unknown"),
386
+ "hive": report_node.get("hive", True),
387
+ "score": report_node.get("weighted_score", 0),
388
+ }
389
+ new_nodes.append(new_entry)
390
+ existing_urls.add(url)
391
+
392
+ # Add nodes listed as failing but missing
393
+ for url in failing_nodes.keys():
394
+ if url in existing_urls:
395
+ continue
396
+ new_nodes.append(
397
+ {
398
+ "url": url,
399
+ "version": "unknown",
400
+ "type": "appbase",
401
+ "owner": "unknown",
402
+ "hive": True,
403
+ "score": -1,
404
+ }
405
+ )
406
+ existing_urls.add(url)
407
+
408
+ # Re-initialise internal list
333
409
  super(NodeList, self).__init__(new_nodes)
334
410
 
335
411
  def get_nodes(
nectar/storage.py CHANGED
@@ -1,15 +1,14 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  import logging
3
3
 
4
+ from nectarstorage import SqliteConfigurationStore, SqliteEncryptedKeyStore
5
+
4
6
  from .nodelist import NodeList
5
7
 
6
8
  log = logging.getLogger(__name__)
7
9
  log.setLevel(logging.DEBUG)
8
10
  log.addHandler(logging.StreamHandler())
9
- from nectarstorage import (
10
- SqliteConfigurationStore,
11
- SqliteEncryptedKeyStore,
12
- )
11
+
13
12
 
14
13
  timeformat = "%Y%m%d-%H%M%S"
15
14
 
nectar/utils.py CHANGED
@@ -136,7 +136,7 @@ def derive_permlink(
136
136
  author (for replies).
137
137
 
138
138
  """
139
- suffix = "-" + formatTime(datetime.now(timezone.utc)) + "z"
139
+ suffix = "-" + formatTime(datetime.now(timezone.utc)).lower()
140
140
  if parent_permlink and parent_author:
141
141
  prefix = "re-" + sanitize_permlink(parent_author) + "-"
142
142
  if with_suffix:
nectar/version.py CHANGED
@@ -1,3 +1,3 @@
1
1
  """THIS FILE IS GENERATED FROM nectar PYPROJECT.TOML."""
2
2
 
3
- version = "0.0.7"
3
+ version = "0.0.9b"
nectarapi/__init__.py CHANGED
@@ -3,6 +3,7 @@
3
3
  from .version import version as __version__
4
4
 
5
5
  __all__ = [
6
+ "__version__",
6
7
  "noderpc",
7
8
  "exceptions",
8
9
  "rpcutils",
nectarapi/version.py CHANGED
@@ -1,3 +1,3 @@
1
1
  """THIS FILE IS GENERATED FROM nectar PYPROJECT.TOML."""
2
2
 
3
- version = "0.0.7"
3
+ version = "0.0.9b"
nectarbase/__init__.py CHANGED
@@ -3,6 +3,7 @@
3
3
  from .version import version as __version__
4
4
 
5
5
  __all__ = [
6
+ "__version__",
6
7
  "memo",
7
8
  "objects",
8
9
  "objecttypes",
nectarbase/version.py CHANGED
@@ -1,3 +1,3 @@
1
1
  """THIS FILE IS GENERATED FROM nectar PYPROJECT.TOML."""
2
2
 
3
- version = "0.0.7"
3
+ version = "0.0.9b"
@@ -10,6 +10,7 @@ from .version import version as __version__
10
10
  # from . import dictionary as BrainKeyDictionary
11
11
 
12
12
  __all__ = [
13
+ "__version__",
13
14
  "account",
14
15
  "aes",
15
16
  "base58",
@@ -1,4 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
+ from collections import OrderedDict
3
+
2
4
  from .objects import GrapheneObject, isArgsThisClass
3
5
  from .types import (
4
6
  Set,
@@ -1,3 +1,3 @@
1
1
  """THIS FILE IS GENERATED FROM nectar PYPROJECT.TOML."""
2
2
 
3
- version = "0.0.7"
3
+ version = "0.0.9b"
nectarstorage/__init__.py CHANGED
@@ -15,7 +15,27 @@ from .base import (
15
15
  )
16
16
  from .sqlite import SQLiteCommon, SQLiteFile
17
17
 
18
- __all__ = ["interfaces", "masterpassword", "base", "sqlite", "ram"]
18
+ __all__ = [
19
+ # submodules
20
+ "interfaces",
21
+ "masterpassword",
22
+ "base",
23
+ "sqlite",
24
+ "ram",
25
+ # store classes re-exported for convenience
26
+ "InRamConfigurationStore",
27
+ "InRamEncryptedKeyStore",
28
+ "InRamEncryptedTokenStore",
29
+ "InRamPlainKeyStore",
30
+ "InRamPlainTokenStore",
31
+ "SqliteConfigurationStore",
32
+ "SqliteEncryptedKeyStore",
33
+ "SqliteEncryptedTokenStore",
34
+ "SqlitePlainKeyStore",
35
+ "SqlitePlainTokenStore",
36
+ "SQLiteCommon",
37
+ "SQLiteFile",
38
+ ]
19
39
 
20
40
 
21
41
  def get_default_config_store(*args, **kwargs):
nectarstorage/sqlite.py CHANGED
@@ -5,7 +5,7 @@ import os
5
5
  import shutil
6
6
  import sqlite3
7
7
  import time
8
- from datetime import datetime
8
+ from datetime import datetime, timezone
9
9
 
10
10
  from appdirs import user_data_dir
11
11