hive-nectar 0.0.11__py3-none-any.whl → 0.1.1__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.

Files changed (56) hide show
  1. {hive_nectar-0.0.11.dist-info → hive_nectar-0.1.1.dist-info}/METADATA +12 -11
  2. hive_nectar-0.1.1.dist-info/RECORD +88 -0
  3. nectar/__init__.py +1 -4
  4. nectar/account.py +791 -685
  5. nectar/amount.py +82 -21
  6. nectar/asset.py +1 -2
  7. nectar/block.py +49 -23
  8. nectar/blockchain.py +111 -143
  9. nectar/blockchaininstance.py +396 -247
  10. nectar/blockchainobject.py +33 -5
  11. nectar/cli.py +1058 -1349
  12. nectar/comment.py +313 -181
  13. nectar/community.py +39 -43
  14. nectar/constants.py +1 -14
  15. nectar/discussions.py +793 -139
  16. nectar/hive.py +137 -77
  17. nectar/hivesigner.py +106 -68
  18. nectar/imageuploader.py +33 -23
  19. nectar/instance.py +31 -79
  20. nectar/market.py +128 -264
  21. nectar/memo.py +40 -13
  22. nectar/message.py +23 -10
  23. nectar/nodelist.py +115 -81
  24. nectar/price.py +80 -61
  25. nectar/profile.py +6 -3
  26. nectar/rc.py +45 -25
  27. nectar/snapshot.py +285 -163
  28. nectar/storage.py +16 -5
  29. nectar/transactionbuilder.py +132 -41
  30. nectar/utils.py +37 -17
  31. nectar/version.py +1 -1
  32. nectar/vote.py +171 -30
  33. nectar/wallet.py +26 -19
  34. nectar/witness.py +153 -54
  35. nectarapi/graphenerpc.py +147 -133
  36. nectarapi/noderpc.py +12 -6
  37. nectarapi/rpcutils.py +12 -6
  38. nectarapi/version.py +1 -1
  39. nectarbase/ledgertransactions.py +24 -1
  40. nectarbase/objects.py +17 -6
  41. nectarbase/operations.py +160 -90
  42. nectarbase/signedtransactions.py +38 -2
  43. nectarbase/version.py +1 -1
  44. nectargraphenebase/account.py +295 -17
  45. nectargraphenebase/chains.py +0 -135
  46. nectargraphenebase/ecdsasig.py +152 -176
  47. nectargraphenebase/types.py +18 -4
  48. nectargraphenebase/unsignedtransactions.py +1 -1
  49. nectargraphenebase/version.py +1 -1
  50. hive_nectar-0.0.11.dist-info/RECORD +0 -91
  51. nectar/blurt.py +0 -562
  52. nectar/conveyor.py +0 -308
  53. nectar/steem.py +0 -581
  54. {hive_nectar-0.0.11.dist-info → hive_nectar-0.1.1.dist-info}/WHEEL +0 -0
  55. {hive_nectar-0.0.11.dist-info → hive_nectar-0.1.1.dist-info}/entry_points.txt +0 -0
  56. {hive_nectar-0.0.11.dist-info → hive_nectar-0.1.1.dist-info}/licenses/LICENSE.txt +0 -0
nectar/discussions.py CHANGED
@@ -1,5 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  import logging
3
+ import warnings
3
4
 
4
5
  from .comment import Comment
5
6
  from .instance import shared_blockchain_instance
@@ -28,7 +29,7 @@ class Query(dict):
28
29
  .. testcode::
29
30
 
30
31
  from nectar.discussions import Query
31
- query = Query(limit=10, tag="steemit")
32
+ query = Query(limit=10, tag="hive")
32
33
 
33
34
  """
34
35
 
@@ -37,9 +38,9 @@ class Query(dict):
37
38
  limit=0,
38
39
  tag="",
39
40
  truncate_body=0,
40
- filter_tags=[],
41
- select_authors=[],
42
- select_tags=[],
41
+ filter_tags=None,
42
+ select_authors=None,
43
+ select_tags=None,
43
44
  start_author=None,
44
45
  start_permlink=None,
45
46
  start_tag=None,
@@ -49,12 +50,33 @@ class Query(dict):
49
50
  before_date=None,
50
51
  author=None,
51
52
  ):
53
+ """
54
+ Initialize a Query mapping for discussion fetches.
55
+
56
+ Creates a dict-like Query object containing normalized discussion query parameters used by the Discussions fetchers. List-valued parameters default to empty lists when None. Values are stored as keys on self (e.g. self["limit"], self["tag"], etc.).
57
+
58
+ Parameters:
59
+ limit (int): Maximum number of items requested (0 means no explicit client-side limit).
60
+ tag (str): Topic tag or account (used by feed/blog where appropriate).
61
+ truncate_body (int): Number of characters to truncate post bodies to (0 = no truncate).
62
+ filter_tags (list|None): Tags to exclude; defaults to [].
63
+ select_authors (list|None): Authors to include; defaults to [].
64
+ select_tags (list|None): Tags to include; defaults to [].
65
+ start_author (str|None): Author name used as a pagination starting point.
66
+ start_permlink (str|None): Permlink used as a pagination starting point.
67
+ start_tag (str|None): Tag used as a pagination starting point for tag-based queries.
68
+ parent_author (str|None): Parent post author (used for comment/replies queries).
69
+ parent_permlink (str|None): Parent post permlink (used for comment/replies queries).
70
+ start_parent_author (str|None): Parent author used for pagination in replies queries.
71
+ before_date (str|None): ISO 8601 datetime string to fetch items before this timestamp.
72
+ author (str|None): Author name for author-scoped queries.
73
+ """
52
74
  self["limit"] = limit
53
75
  self["truncate_body"] = truncate_body
54
76
  self["tag"] = tag
55
- self["filter_tags"] = filter_tags
56
- self["select_authors"] = select_authors
57
- self["select_tags"] = select_tags
77
+ self["filter_tags"] = filter_tags or []
78
+ self["select_authors"] = select_authors or []
79
+ self["select_tags"] = select_tags or []
58
80
  self["start_author"] = start_author
59
81
  self["start_permlink"] = start_permlink
60
82
  self["start_tag"] = start_tag
@@ -68,38 +90,82 @@ class Query(dict):
68
90
  class Discussions(object):
69
91
  """Get Discussions
70
92
 
71
- :param Steem blockchain_instance: Steem instance
93
+ :param Hive blockchain_instance: Hive instance
72
94
 
73
95
  """
74
96
 
75
97
  def __init__(self, lazy=False, use_appbase=False, blockchain_instance=None, **kwargs):
76
- if blockchain_instance is None:
77
- if kwargs.get("steem_instance"):
78
- blockchain_instance = kwargs["steem_instance"]
79
- elif kwargs.get("hive_instance"):
80
- blockchain_instance = kwargs["hive_instance"]
81
- self.blockchain = blockchain_instance or shared_blockchain_instance()
82
- self.lazy = lazy
83
- self.use_appbase = use_appbase
98
+ # Handle legacy parameters
99
+ """
100
+ Initialize the Discussions orchestrator.
84
101
 
85
- def get_discussions(self, discussion_type, discussion_query, limit=1000, raw_data=False):
86
- """Get Discussions
102
+ Parameters:
103
+ lazy (bool): If True, wrap fetched items in lazy-loading Comment objects.
104
+ use_appbase (bool): If True, prefer appbase/condenser-style endpoints when available.
87
105
 
88
- :param str discussion_type: Defines the used discussion query
89
- :param Query discussion_query: Defines the parameter for
90
- searching posts
91
- :param bool raw_data: returns list of comments when False, default is False
106
+ Notes:
107
+ - Accepts a blockchain instance via `blockchain_instance`. For backward compatibility this initializer also accepts the deprecated keyword arguments `steem_instance` and `hive_instance`; if one of those is provided it will be used when `blockchain_instance` is not set. Using the deprecated keys emits a DeprecationWarning.
108
+ - If both deprecated legacy instance keys are provided simultaneously, a ValueError is raised.
109
+ - The resolved blockchain instance is stored on self.blockchain (falls back to shared_blockchain_instance() when none provided). The flags `self.lazy` and `self.use_appbase` are set from the corresponding parameters.
110
+ """
111
+ legacy_keys = {"steem_instance", "hive_instance"}
112
+ legacy_instance = None
113
+ for key in legacy_keys:
114
+ if key in kwargs:
115
+ if legacy_instance is not None:
116
+ raise ValueError(
117
+ f"Cannot specify both {key} and another legacy instance parameter"
118
+ )
119
+ legacy_instance = kwargs.pop(key)
120
+ warnings.warn(
121
+ f"Parameter '{key}' is deprecated. Use 'blockchain_instance' instead.",
122
+ DeprecationWarning,
123
+ stacklevel=2,
124
+ )
92
125
 
93
- .. testcode::
126
+ # Prefer explicit blockchain_instance, then legacy
127
+ if blockchain_instance is None and legacy_instance is not None:
128
+ blockchain_instance = legacy_instance
94
129
 
95
- from nectar.discussions import Query, Discussions
96
- query = Query(limit=51, tag="steemit")
97
- discussions = Discussions()
98
- count = 0
99
- for d in discussions.get_discussions("tags", query, limit=200):
100
- print(("%d. " % (count + 1)) + str(d))
101
- count += 1
130
+ self.blockchain = blockchain_instance or shared_blockchain_instance()
131
+ self.lazy = lazy
132
+ self.use_appbase = use_appbase
102
133
 
134
+ def get_discussions(self, discussion_type, discussion_query, limit=1000, raw_data=False):
135
+ """
136
+ Yield discussions of a given type according to a Query, handling pagination.
137
+
138
+ This generator fetches discussions in pages from the appropriate per-type helper
139
+ and yields individual discussion entries until `limit` items have been yielded
140
+ or no more results are available.
141
+
142
+ Parameters:
143
+ discussion_type (str): One of:
144
+ "trending", "author_before_date", "payout", "post_payout", "created",
145
+ "active", "cashout", "votes", "children", "hot", "feed", "blog",
146
+ "comments", "promoted", "replies", "tags".
147
+ Determines which backend/query helper is used.
148
+ discussion_query (Query): Query-like mapping with parameters used by the
149
+ underlying helpers (e.g., limit, tag, start_author, start_permlink,
150
+ before_date). If `discussion_query["limit"]` is 0, it will be set to
151
+ 100 when `limit >= 100`, otherwise set to the provided `limit`.
152
+ If `before_date` is falsy, it will be set to "1970-01-01T00:00:00".
153
+ limit (int): Maximum number of discussion items to yield (default 1000).
154
+ raw_data (bool): If True, helpers are requested to return raw dict data;
155
+ if False, helpers may return wrapped Comment objects when supported.
156
+
157
+ Yields:
158
+ Individual discussion items as returned by the selected helper:
159
+ - For post/comment helpers: dicts when `raw_data=True`, or Comment objects
160
+ when `raw_data=False` and wrapping is supported.
161
+ - For "tags": tag dictionaries.
162
+
163
+ Behavior and notes:
164
+ - This function mutates `discussion_query` for pagination (start_* fields)
165
+ and may update `discussion_query["limit"]` and `before_date` as described.
166
+ - Pagination is driven by start markers (author/permlink/tag/parent_author)
167
+ and the function avoids yielding duplicate entries across pages.
168
+ - Raises ValueError if `discussion_type` is not one of the supported values.
103
169
  """
104
170
  if limit >= 100 and discussion_query["limit"] == 0:
105
171
  discussion_query["limit"] = 100
@@ -303,13 +369,13 @@ class Discussions_by_trending(list):
303
369
 
304
370
  :param Query discussion_query: Defines the parameter for
305
371
  searching posts
306
- :param Steem blockchain_instance: Steem instance
372
+ :param Hive blockchain_instance: Hive instance
307
373
  :param bool raw_data: returns list of comments when False, default is False
308
374
 
309
375
  .. testcode::
310
376
 
311
377
  from nectar.discussions import Query, Discussions_by_trending
312
- q = Query(limit=10, tag="steem")
378
+ q = Query(limit=10, tag="hive")
313
379
  for h in Discussions_by_trending(q):
314
380
  print(h)
315
381
 
@@ -324,11 +390,49 @@ class Discussions_by_trending(list):
324
390
  blockchain_instance=None,
325
391
  **kwargs,
326
392
  ):
327
- if blockchain_instance is None:
328
- if kwargs.get("steem_instance"):
329
- blockchain_instance = kwargs["steem_instance"]
330
- elif kwargs.get("hive_instance"):
331
- blockchain_instance = kwargs["hive_instance"]
393
+ # Handle legacy parameters
394
+ """
395
+ Initialize a Discussions_by_trending iterator that fetches trending discussions and stores results (raw or wrapped).
396
+
397
+ Builds a reduced query from discussion_query, prefers a provided blockchain_instance (or a legacy instance passed via the deprecated kwargs "steem_instance" or "hive_instance"), configures RPC node selection based on appbase usage, and tries a bridge API call first with fallbacks to appbase or legacy RPC endpoints. Results are stored by calling the superclass initializer with either raw post dicts or Comment-wrapped objects.
398
+
399
+ Parameters:
400
+ discussion_query (dict): Full query dict; only a subset keys are used here (e.g., "tag", "limit", "start_author", "start_permlink").
401
+ lazy (bool): If False, Comment objects are fully initialized; if True, they are created for lazy loading.
402
+ use_appbase (bool): Prefer appbase/tag endpoints when falling back from the bridge API.
403
+ raw_data (bool): If True, store raw post dicts; otherwise wrap posts in Comment objects.
404
+
405
+ Side effects:
406
+ - Sets self.blockchain to the resolved blockchain instance.
407
+ - Calls self.blockchain.rpc.set_next_node_on_empty_reply(...) to influence RPC node selection.
408
+ - Calls RPC methods to fetch posts and initializes the superclass with the fetched items.
409
+
410
+ Raises:
411
+ ValueError: If more than one legacy instance key is provided in kwargs.
412
+
413
+ Notes:
414
+ - Passing "steem_instance" or "hive_instance" in kwargs is supported for backwards compatibility but emits a DeprecationWarning and is mapped to blockchain_instance.
415
+ - No return value; the instance is populated via the superclass initializer.
416
+ """
417
+ legacy_keys = {"steem_instance", "hive_instance"}
418
+ legacy_instance = None
419
+ for key in legacy_keys:
420
+ if key in kwargs:
421
+ if legacy_instance is not None:
422
+ raise ValueError(
423
+ f"Cannot specify both {key} and another legacy instance parameter"
424
+ )
425
+ legacy_instance = kwargs.pop(key)
426
+ warnings.warn(
427
+ f"Parameter '{key}' is deprecated. Use 'blockchain_instance' instead.",
428
+ DeprecationWarning,
429
+ stacklevel=2,
430
+ )
431
+
432
+ # Prefer explicit blockchain_instance, then legacy
433
+ if blockchain_instance is None and legacy_instance is not None:
434
+ blockchain_instance = legacy_instance
435
+
332
436
  self.blockchain = blockchain_instance or shared_blockchain_instance()
333
437
  reduced_query = {}
334
438
  for key in [
@@ -394,7 +498,7 @@ class Discussions_by_author_before_date(list):
394
498
  :param int limit: Defines the limit of discussions
395
499
  :param bool use_appbase: use condenser call when set to False, default is False
396
500
  :param bool raw_data: returns list of comments when False, default is False
397
- :param Steem blockchain_instance: Steem instance
501
+ :param Hive blockchain_instance: Hive instance
398
502
 
399
503
  .. testcode::
400
504
 
@@ -416,11 +520,45 @@ class Discussions_by_author_before_date(list):
416
520
  blockchain_instance=None,
417
521
  **kwargs,
418
522
  ):
419
- if blockchain_instance is None:
420
- if kwargs.get("steem_instance"):
421
- blockchain_instance = kwargs["steem_instance"]
422
- elif kwargs.get("hive_instance"):
423
- blockchain_instance = kwargs["hive_instance"]
523
+ # Handle legacy parameters
524
+ """
525
+ Initialize a Discussions_by_author_before_date container of posts by a specific author before a given date.
526
+
527
+ Creates an ordered list of posts (either raw dicts or wrapped Comment objects) for the specified author published before `before_date`. Attempts to fetch via the bridge API and falls back to appbase/legacy RPC methods when necessary.
528
+
529
+ Parameters:
530
+ author (str): Account name whose posts to retrieve.
531
+ start_permlink (str): Permlink to start pagination from (exclusive); empty means start from newest.
532
+ before_date (str): ISO-8601 timestamp; only posts with `created` < this value are returned. Default is "1970-01-01T00:00:00" (no date filtering).
533
+ limit (int): Maximum number of posts to fetch from each RPC call (may be used for pagination by the caller).
534
+ lazy (bool): When False, posts are wrapped into Comment objects; when True, wrapping is deferred (passed to Comment).
535
+ use_appbase (bool): Prefer appbase/tag APIs when falling back from the bridge API.
536
+ raw_data (bool): If True, store raw post dicts; if False, store Comment-wrapped objects.
537
+ blockchain_instance: (omitted — treated as the blockchain service/client).
538
+
539
+ Notes:
540
+ - Legacy kwargs "steem_instance" and "hive_instance" are accepted but deprecated; specifying more than one legacy instance raises ValueError. A DeprecationWarning is emitted when either is used.
541
+ - The instance records the resolved blockchain client on self.blockchain and adjusts RPC next-node behavior based on `use_appbase`.
542
+ """
543
+ legacy_keys = {"steem_instance", "hive_instance"}
544
+ legacy_instance = None
545
+ for key in legacy_keys:
546
+ if key in kwargs:
547
+ if legacy_instance is not None:
548
+ raise ValueError(
549
+ f"Cannot specify both {key} and another legacy instance parameter"
550
+ )
551
+ legacy_instance = kwargs.pop(key)
552
+ warnings.warn(
553
+ f"Parameter '{key}' is deprecated. Use 'blockchain_instance' instead.",
554
+ DeprecationWarning,
555
+ stacklevel=2,
556
+ )
557
+
558
+ # Prefer explicit blockchain_instance, then legacy
559
+ if blockchain_instance is None and legacy_instance is not None:
560
+ blockchain_instance = legacy_instance
561
+
424
562
  self.blockchain = blockchain_instance or shared_blockchain_instance()
425
563
  self.blockchain.rpc.set_next_node_on_empty_reply(
426
564
  self.blockchain.rpc.get_use_appbase() and use_appbase
@@ -477,7 +615,7 @@ class Comment_discussions_by_payout(list):
477
615
  searching posts
478
616
  :param bool use_appbase: use condenser call when set to False, default is False
479
617
  :param bool raw_data: returns list of comments when False, default is False
480
- :param Steem blockchain_instance: Steem instance
618
+ :param Hive blockchain_instance: Hive instance
481
619
 
482
620
  .. testcode::
483
621
 
@@ -497,11 +635,48 @@ class Comment_discussions_by_payout(list):
497
635
  blockchain_instance=None,
498
636
  **kwargs,
499
637
  ):
500
- if blockchain_instance is None:
501
- if kwargs.get("steem_instance"):
502
- blockchain_instance = kwargs["steem_instance"]
503
- elif kwargs.get("hive_instance"):
504
- blockchain_instance = kwargs["hive_instance"]
638
+ # Handle legacy parameters
639
+ """
640
+ Initialize a Comment_discussions_by_payout iterator that fetches comment discussions sorted by payout.
641
+
642
+ This constructor:
643
+ - Accepts a discussion_query (dict) and reduces it to the supported keys: "tag", "limit", "filter_tags", "select_authors", "select_tags", "truncate_body", "start_author", "start_permlink".
644
+ - Handles legacy keyword arguments "steem_instance" and "hive_instance": if present, the provided legacy instance is used as the blockchain instance and a DeprecationWarning is emitted; specifying more than one legacy key raises ValueError. An explicit blockchain_instance argument takes precedence over any legacy instance.
645
+ - Configures the blockchain RPC node selection based on the blockchain instance's get_use_appbase() and the use_appbase flag.
646
+ - Attempts to fetch posts via the bridge API (get_ranked_posts with sort "payout_comments"); on failure it falls back to the appbase "tags" path or the legacy get_comment_discussions_by_payout RPC. If the RPC returns None, it is treated as an empty list.
647
+ - If raw_data is True, the underlying list is initialized with the raw post dicts; otherwise each post is wrapped in a Comment object (created with the lazy flag and the resolved blockchain instance) before initializing the superclass.
648
+
649
+ Parameters:
650
+ discussion_query (dict): Query parameters; expected keys include "tag", "limit", "start_author", "start_permlink", and related filters.
651
+ lazy (bool): If True, Comment wrappers are created in lazy mode (defer loading of full data).
652
+ use_appbase (bool): Prefer appbase/tag-based endpoints when True (affects RPC node selection and fallback behavior).
653
+ raw_data (bool): If True, return raw post dicts instead of Comment objects.
654
+ blockchain_instance: (optional) Blockchain client instance to use; if omitted a shared instance or a legacy instance (if provided via kwargs) will be used.
655
+
656
+ Side effects:
657
+ - May emit DeprecationWarning when "steem_instance" or "hive_instance" kwargs are used.
658
+ - Raises ValueError if multiple legacy instance kwargs are provided.
659
+ - Performs RPC calls (bridge and/or legacy/appbase) to fetch discussions.
660
+ """
661
+ legacy_keys = {"steem_instance", "hive_instance"}
662
+ legacy_instance = None
663
+ for key in legacy_keys:
664
+ if key in kwargs:
665
+ if legacy_instance is not None:
666
+ raise ValueError(
667
+ f"Cannot specify both {key} and another legacy instance parameter"
668
+ )
669
+ legacy_instance = kwargs.pop(key)
670
+ warnings.warn(
671
+ f"Parameter '{key}' is deprecated. Use 'blockchain_instance' instead.",
672
+ DeprecationWarning,
673
+ stacklevel=2,
674
+ )
675
+
676
+ # Prefer explicit blockchain_instance, then legacy
677
+ if blockchain_instance is None and legacy_instance is not None:
678
+ blockchain_instance = legacy_instance
679
+
505
680
  self.blockchain = blockchain_instance or shared_blockchain_instance()
506
681
  reduced_query = {}
507
682
  for key in [
@@ -561,7 +736,7 @@ class Post_discussions_by_payout(list):
561
736
  searching posts
562
737
  :param bool use_appbase: use condenser call when set to False, default is False
563
738
  :param bool raw_data: returns list of comments when False, default is False
564
- :param Steem blockchain_instance: Steem instance
739
+ :param Hive blockchain_instance: Hive instance
565
740
 
566
741
  .. testcode::
567
742
 
@@ -581,11 +756,47 @@ class Post_discussions_by_payout(list):
581
756
  blockchain_instance=None,
582
757
  **kwargs,
583
758
  ):
584
- if blockchain_instance is None:
585
- if kwargs.get("steem_instance"):
586
- blockchain_instance = kwargs["steem_instance"]
587
- elif kwargs.get("hive_instance"):
588
- blockchain_instance = kwargs["hive_instance"]
759
+ # Handle legacy parameters
760
+ """
761
+ Initialize Post_discussions_by_payout: fetches post discussions sorted by payout and populates the list (raw dicts or Comment objects).
762
+
763
+ Parameters:
764
+ discussion_query (dict): Query parameters; relevant keys: 'tag', 'limit', 'filter_tags', 'select_authors',
765
+ 'select_tags', 'truncate_body', 'start_author', 'start_permlink'. Only these keys are used from the dict.
766
+ lazy (bool): If False, wrap results immediately in Comment objects; if True, create Comment objects with lazy loading.
767
+ use_appbase (bool): When True, prefer appbase/tag-based RPC fallbacks if the bridge API is unavailable.
768
+ raw_data (bool): If True, store raw post dicts instead of wrapping them in Comment objects.
769
+
770
+ Notes and side effects:
771
+ - Accepts legacy keyword args 'steem_instance' or 'hive_instance' in kwargs; if provided, emits a DeprecationWarning and uses the given instance as the blockchain instance. Supplying more than one legacy instance parameter raises ValueError.
772
+ - The explicit 'blockchain_instance' argument overrides any legacy instance.
773
+ - Resolves and stores the blockchain instance on self.blockchain (or uses a shared instance).
774
+ - Configures the blockchain RPC's next-node behavior based on appbase usage and use_appbase.
775
+ - Attempts to fetch posts via the bridge API first, then falls back to appbase/tag endpoints, and finally to legacy RPC calls.
776
+ - Populates the instance by calling the superclass constructor with either raw post dicts or Comment-wrapped posts.
777
+
778
+ Raises:
779
+ ValueError: If more than one legacy instance parameter is provided in kwargs.
780
+ """
781
+ legacy_keys = {"steem_instance", "hive_instance"}
782
+ legacy_instance = None
783
+ for key in legacy_keys:
784
+ if key in kwargs:
785
+ if legacy_instance is not None:
786
+ raise ValueError(
787
+ f"Cannot specify both {key} and another legacy instance parameter"
788
+ )
789
+ legacy_instance = kwargs.pop(key)
790
+ warnings.warn(
791
+ f"Parameter '{key}' is deprecated. Use 'blockchain_instance' instead.",
792
+ DeprecationWarning,
793
+ stacklevel=2,
794
+ )
795
+
796
+ # Prefer explicit blockchain_instance, then legacy
797
+ if blockchain_instance is None and legacy_instance is not None:
798
+ blockchain_instance = legacy_instance
799
+
589
800
  self.blockchain = blockchain_instance or shared_blockchain_instance()
590
801
  reduced_query = {}
591
802
  for key in [
@@ -645,7 +856,7 @@ class Discussions_by_created(list):
645
856
  searching posts
646
857
  :param bool use_appbase: use condenser call when set to False, default is False
647
858
  :param bool raw_data: returns list of comments when False, default is False
648
- :param Steem blockchain_instance: Steem instance
859
+ :param Hive blockchain_instance: Hive instance
649
860
 
650
861
  .. testcode::
651
862
 
@@ -665,11 +876,49 @@ class Discussions_by_created(list):
665
876
  blockchain_instance=None,
666
877
  **kwargs,
667
878
  ):
668
- if blockchain_instance is None:
669
- if kwargs.get("steem_instance"):
670
- blockchain_instance = kwargs["steem_instance"]
671
- elif kwargs.get("hive_instance"):
672
- blockchain_instance = kwargs["hive_instance"]
879
+ # Handle legacy parameters
880
+ """
881
+ Initialize a Discussions_by_created fetcher and populate it with posts matching the query.
882
+
883
+ Builds a reduced query from `discussion_query`, resolves the blockchain instance (accepting the deprecated legacy kwargs "steem_instance" or "hive_instance" with a DeprecationWarning), configures RPC node selection, attempts to fetch posts via the bridge API and falls back to appbase/legacy RPC endpoints. The instance is initialized (as a list) with raw post dicts when `raw_data` is True or with wrapped Comment objects otherwise.
884
+
885
+ Parameters:
886
+ discussion_query (dict): Incoming query dict; keys used include "tag", "limit", "filter_tags",
887
+ "select_authors", "select_tags", "truncate_body", "start_author", and "start_permlink".
888
+ lazy (bool): If False (default), Comment wrappers are fully initialized; if True, Comment objects
889
+ are created in lazy mode.
890
+ use_appbase (bool): When True, prefer appbase/tag RPC endpoints on fallback.
891
+ raw_data (bool): When True, populate the instance with raw post dictionaries instead of Comment objects.
892
+ blockchain_instance: Omitted from param docs as a shared/blockchain client service; if None, a shared
893
+ instance is used. Legacy kwargs "steem_instance" and "hive_instance" are accepted but deprecated.
894
+
895
+ Raises:
896
+ ValueError: If more than one legacy instance parameter is provided via kwargs.
897
+ DeprecationWarning: Emitted when a legacy instance kwarg is used (not an exception).
898
+
899
+ Side effects:
900
+ - Calls `self.blockchain.rpc.set_next_node_on_empty_reply(...)`.
901
+ - Performs remote RPC calls which may raise exceptions that trigger fallback behavior.
902
+ """
903
+ legacy_keys = {"steem_instance", "hive_instance"}
904
+ legacy_instance = None
905
+ for key in legacy_keys:
906
+ if key in kwargs:
907
+ if legacy_instance is not None:
908
+ raise ValueError(
909
+ f"Cannot specify both {key} and another legacy instance parameter"
910
+ )
911
+ legacy_instance = kwargs.pop(key)
912
+ warnings.warn(
913
+ f"Parameter '{key}' is deprecated. Use 'blockchain_instance' instead.",
914
+ DeprecationWarning,
915
+ stacklevel=2,
916
+ )
917
+
918
+ # Prefer explicit blockchain_instance, then legacy
919
+ if blockchain_instance is None and legacy_instance is not None:
920
+ blockchain_instance = legacy_instance
921
+
673
922
  self.blockchain = blockchain_instance or shared_blockchain_instance()
674
923
  reduced_query = {}
675
924
  for key in [
@@ -729,7 +978,7 @@ class Discussions_by_active(list):
729
978
  searching posts
730
979
  :param bool use_appbase: use condenser call when set to False, default is False
731
980
  :param bool raw_data: returns list of comments when False, default is False
732
- :param Steem blockchain_instance: Steem() instance to use when accesing a RPC
981
+ :param Hive blockchain_instance: Hive() instance to use when accesing a RPC
733
982
 
734
983
  .. testcode::
735
984
 
@@ -749,11 +998,52 @@ class Discussions_by_active(list):
749
998
  blockchain_instance=None,
750
999
  **kwargs,
751
1000
  ):
752
- if blockchain_instance is None:
753
- if kwargs.get("steem_instance"):
754
- blockchain_instance = kwargs["steem_instance"]
755
- elif kwargs.get("hive_instance"):
756
- blockchain_instance = kwargs["hive_instance"]
1001
+ # Handle legacy parameters
1002
+ """
1003
+ Initialize Discussions_by_active: fetch discussions sorted by "active" and populate the sequence.
1004
+
1005
+ This initializer reduces the provided discussion_query to the subset of keys used by the active discussion endpoint,
1006
+ configures the blockchain RPC node selection behavior, attempts to fetch posts from the bridge API (preferred),
1007
+ and falls back to appbase/tags or legacy RPC endpoints when needed. Results are stored in the underlying sequence
1008
+ as raw dicts if raw_data is True, otherwise each post is wrapped in a Comment object with the supplied lazy flag
1009
+ and resolved blockchain instance.
1010
+
1011
+ Parameters:
1012
+ discussion_query (dict): Query parameters (may include tag, limit, filter_tags, select_authors,
1013
+ select_tags, truncate_body, start_author, start_permlink, and others).
1014
+ lazy (bool): If False (default), wrap results in Comment objects that may eagerly access data; if True, wrap
1015
+ with lazy Comment instances.
1016
+ use_appbase (bool): Prefer appbase/tags endpoints when falling back from the bridge API.
1017
+ raw_data (bool): If True, keep fetched posts as raw data dicts instead of wrapping in Comment objects.
1018
+ blockchain_instance: Optional blockchain client/instance to use; if omitted a shared instance is used.
1019
+
1020
+ Legacy behavior:
1021
+ Accepts deprecated kwargs "steem_instance" and "hive_instance". If either is provided it will be used as the
1022
+ blockchain instance and a DeprecationWarning is emitted. Providing more than one legacy instance parameter
1023
+ raises ValueError.
1024
+
1025
+ Raises:
1026
+ ValueError: If more than one legacy instance parameter is supplied (e.g., both "steem_instance" and "hive_instance").
1027
+ """
1028
+ legacy_keys = {"steem_instance", "hive_instance"}
1029
+ legacy_instance = None
1030
+ for key in legacy_keys:
1031
+ if key in kwargs:
1032
+ if legacy_instance is not None:
1033
+ raise ValueError(
1034
+ f"Cannot specify both {key} and another legacy instance parameter"
1035
+ )
1036
+ legacy_instance = kwargs.pop(key)
1037
+ warnings.warn(
1038
+ f"Parameter '{key}' is deprecated. Use 'blockchain_instance' instead.",
1039
+ DeprecationWarning,
1040
+ stacklevel=2,
1041
+ )
1042
+
1043
+ # Prefer explicit blockchain_instance, then legacy
1044
+ if blockchain_instance is None and legacy_instance is not None:
1045
+ blockchain_instance = legacy_instance
1046
+
757
1047
  self.blockchain = blockchain_instance or shared_blockchain_instance()
758
1048
  reduced_query = {}
759
1049
  for key in [
@@ -814,7 +1104,7 @@ class Discussions_by_cashout(list):
814
1104
  searching posts
815
1105
  :param bool use_appbase: use condenser call when set to False, default is False
816
1106
  :param bool raw_data: returns list of comments when False, default is False
817
- :param Steem blockchain_instance: Steem instance
1107
+ :param Hive blockchain_instance: Hive instance
818
1108
 
819
1109
  .. testcode::
820
1110
 
@@ -834,11 +1124,42 @@ class Discussions_by_cashout(list):
834
1124
  blockchain_instance=None,
835
1125
  **kwargs,
836
1126
  ):
837
- if blockchain_instance is None:
838
- if kwargs.get("steem_instance"):
839
- blockchain_instance = kwargs["steem_instance"]
840
- elif kwargs.get("hive_instance"):
841
- blockchain_instance = kwargs["hive_instance"]
1127
+ # Handle legacy parameters
1128
+ """
1129
+ Initialize Discussions_by_cashout fetcher.
1130
+
1131
+ Sets up internal blockchain instance (accepting deprecated `steem_instance`/`hive_instance` in kwargs with a DeprecationWarning; specifying more than one legacy key raises ValueError), configures RPC pagination behavior, and loads a page of discussions using the bridge API (sort "payout") with fallbacks to appbase (`get_discussions_by_cashout(..., api="tags")`) or legacy RPC. Results are stored as raw dicts when `raw_data` is True, otherwise wrapped into Comment objects created with the resolved blockchain instance and `lazy` flag.
1132
+
1133
+ Parameters:
1134
+ discussion_query: dict-like query containing keys such as "tag", "limit", "start_author", and "start_permlink". Only these keys are used from the provided query.
1135
+ lazy: bool — if False, Comment wrappers are created eagerly; if True, they are created in lazy mode.
1136
+ use_appbase: bool — when True and the RPC supports appbase, prefer appbase ("tags") fallback endpoints.
1137
+ raw_data: bool — when True, do not wrap results into Comment objects.
1138
+
1139
+ Side effects:
1140
+ - Emits DeprecationWarning when `steem_instance` or `hive_instance` is provided in kwargs.
1141
+ - May raise ValueError if multiple legacy instance kwargs are supplied.
1142
+ - Calls RPC methods which may perform network I/O.
1143
+ """
1144
+ legacy_keys = {"steem_instance", "hive_instance"}
1145
+ legacy_instance = None
1146
+ for key in legacy_keys:
1147
+ if key in kwargs:
1148
+ if legacy_instance is not None:
1149
+ raise ValueError(
1150
+ f"Cannot specify both {key} and another legacy instance parameter"
1151
+ )
1152
+ legacy_instance = kwargs.pop(key)
1153
+ warnings.warn(
1154
+ f"Parameter '{key}' is deprecated. Use 'blockchain_instance' instead.",
1155
+ DeprecationWarning,
1156
+ stacklevel=2,
1157
+ )
1158
+
1159
+ # Prefer explicit blockchain_instance, then legacy
1160
+ if blockchain_instance is None and legacy_instance is not None:
1161
+ blockchain_instance = legacy_instance
1162
+
842
1163
  self.blockchain = blockchain_instance or shared_blockchain_instance()
843
1164
  reduced_query = {}
844
1165
  for key in [
@@ -899,7 +1220,7 @@ class Discussions_by_votes(list):
899
1220
  searching posts
900
1221
  :param bool use_appbase: use condenser call when set to False, default is False
901
1222
  :param bool raw_data: returns list of comments when False, default is False
902
- :param Steem blockchain_instance: Steem instance
1223
+ :param Hive blockchain_instance: Hive instance
903
1224
 
904
1225
  .. testcode::
905
1226
 
@@ -919,11 +1240,48 @@ class Discussions_by_votes(list):
919
1240
  blockchain_instance=None,
920
1241
  **kwargs,
921
1242
  ):
922
- if blockchain_instance is None:
923
- if kwargs.get("steem_instance"):
924
- blockchain_instance = kwargs["steem_instance"]
925
- elif kwargs.get("hive_instance"):
926
- blockchain_instance = kwargs["hive_instance"]
1243
+ # Handle legacy parameters
1244
+ """
1245
+ Initialize Discussions_by_votes: fetch discussions approximating "votes" and store results.
1246
+
1247
+ This initializer prepares and executes a query for discussions ordered by votes. Because the bridge API does not provide a direct "votes" sort, it attempts a bridge query using the "trending" sort, then falls back to appbase (`get_discussions_by_votes` with api="tags") and finally to the legacy RPC method. Results are normalized to an empty list on failure. If raw_data is False, each result is wrapped in a Comment object with the resolved blockchain instance; if True, raw post dicts are kept.
1248
+
1249
+ Parameters:
1250
+ discussion_query (dict): Original query parameters; only a reduced subset is used:
1251
+ tag, limit, filter_tags, select_authors, select_tags, truncate_body,
1252
+ start_author, start_permlink, when present.
1253
+ lazy (bool): If False (default), Comment wrappers may load data immediately; if True, they remain lazy.
1254
+ use_appbase (bool): When True, prefer appbase/tagged APIs when falling back from the bridge.
1255
+ raw_data (bool): If True, keep raw post dicts instead of wrapping them in Comment objects.
1256
+ blockchain_instance: Blockchain client instance to use. If not provided, a shared instance is used.
1257
+ **kwargs: Accepts legacy parameters "steem_instance" or "hive_instance" (deprecated). If a legacy instance is supplied and blockchain_instance is not provided, it will be used. Supplying more than one legacy instance raises ValueError and emits a DeprecationWarning for each used legacy key.
1258
+
1259
+ Side effects:
1260
+ - Resolves and stores self.blockchain.
1261
+ - Calls self.blockchain.rpc.set_next_node_on_empty_reply(...) to influence RPC node selection.
1262
+
1263
+ Raises:
1264
+ ValueError: If multiple legacy instance kwargs are provided at once.
1265
+ """
1266
+ legacy_keys = {"steem_instance", "hive_instance"}
1267
+ legacy_instance = None
1268
+ for key in legacy_keys:
1269
+ if key in kwargs:
1270
+ if legacy_instance is not None:
1271
+ raise ValueError(
1272
+ f"Cannot specify both {key} and another legacy instance parameter"
1273
+ )
1274
+ legacy_instance = kwargs.pop(key)
1275
+ warnings.warn(
1276
+ f"Parameter '{key}' is deprecated. Use 'blockchain_instance' instead.",
1277
+ DeprecationWarning,
1278
+ stacklevel=2,
1279
+ )
1280
+
1281
+ # Prefer explicit blockchain_instance, then legacy
1282
+ if blockchain_instance is None and legacy_instance is not None:
1283
+ blockchain_instance = legacy_instance
1284
+
927
1285
  self.blockchain = blockchain_instance or shared_blockchain_instance()
928
1286
  reduced_query = {}
929
1287
  for key in [
@@ -984,7 +1342,7 @@ class Discussions_by_children(list):
984
1342
  searching posts
985
1343
  :param bool use_appbase: use condenser call when set to False, default is False
986
1344
  :param bool raw_data: returns list of comments when False, default is False
987
- :param Steem blockchain_instance: Steem instance
1345
+ :param Hive blockchain_instance: Hive instance
988
1346
 
989
1347
  .. testcode::
990
1348
 
@@ -1004,11 +1362,54 @@ class Discussions_by_children(list):
1004
1362
  blockchain_instance=None,
1005
1363
  **kwargs,
1006
1364
  ):
1007
- if blockchain_instance is None:
1008
- if kwargs.get("steem_instance"):
1009
- blockchain_instance = kwargs["steem_instance"]
1010
- elif kwargs.get("hive_instance"):
1011
- blockchain_instance = kwargs["hive_instance"]
1365
+ # Handle legacy parameters
1366
+ """
1367
+ Initialize a Discussions_by_children fetcher that yields child (reply) discussions for a tag/post.
1368
+
1369
+ Builds a reduced query from the provided discussion_query, prefers an explicit blockchain_instance (or a legacy
1370
+ steem_instance/hive_instance passed via kwargs), and attempts to fetch discussions via the bridge API before
1371
+ falling back to appbase or legacy RPC methods. Results are stored as raw dicts when raw_data is True or wrapped
1372
+ as Comment objects otherwise.
1373
+
1374
+ Parameters documented only when non-obvious:
1375
+ discussion_query: dict-like query containing keys such as "tag", "limit", "filter_tags",
1376
+ "select_authors", "select_tags", "truncate_body", "start_author", and "start_permlink".
1377
+ Only those keys are preserved for the reduced query used to fetch discussions.
1378
+
1379
+ Behavior and side effects:
1380
+ - If blockchain_instance is None, a shared blockchain instance is used.
1381
+ - Accepts legacy kwargs "steem_instance" or "hive_instance"; if present and blockchain_instance is not
1382
+ provided, that legacy instance is used. Using a legacy key emits a DeprecationWarning advising to use
1383
+ blockchain_instance instead.
1384
+ - Raises ValueError if more than one legacy instance key is provided.
1385
+ - Calls self.blockchain.rpc.set_next_node_on_empty_reply(...) to configure RPC node selection based on
1386
+ whether the RPC is using appbase and the use_appbase flag.
1387
+ - Primary fetch path: bridge API via get_ranked_posts with sort "trending" (bridge has no direct "children"
1388
+ sort). Falls back to get_discussions_by_children via appbase ("tags" API) or the legacy RPC call as needed.
1389
+ - Normalizes None responses to an empty list.
1390
+ - Populates the instance with raw posts when raw_data is True, or with Comment-wrapped posts when False.
1391
+
1392
+ Does not return a value.
1393
+ """
1394
+ legacy_keys = {"steem_instance", "hive_instance"}
1395
+ legacy_instance = None
1396
+ for key in legacy_keys:
1397
+ if key in kwargs:
1398
+ if legacy_instance is not None:
1399
+ raise ValueError(
1400
+ f"Cannot specify both {key} and another legacy instance parameter"
1401
+ )
1402
+ legacy_instance = kwargs.pop(key)
1403
+ warnings.warn(
1404
+ f"Parameter '{key}' is deprecated. Use 'blockchain_instance' instead.",
1405
+ DeprecationWarning,
1406
+ stacklevel=2,
1407
+ )
1408
+
1409
+ # Prefer explicit blockchain_instance, then legacy
1410
+ if blockchain_instance is None and legacy_instance is not None:
1411
+ blockchain_instance = legacy_instance
1412
+
1012
1413
  self.blockchain = blockchain_instance or shared_blockchain_instance()
1013
1414
  reduced_query = {}
1014
1415
  for key in [
@@ -1070,12 +1471,12 @@ class Discussions_by_hot(list):
1070
1471
  searching posts
1071
1472
  :param bool use_appbase: use condenser call when set to False, default is False
1072
1473
  :param bool raw_data: returns list of comments when False, default is False
1073
- :param Steem blockchain_instance: Steem instance
1474
+ :param Hive blockchain_instance: Hive instance
1074
1475
 
1075
1476
  .. testcode::
1076
1477
 
1077
1478
  from nectar.discussions import Query, Discussions_by_hot
1078
- q = Query(limit=10, tag="steem")
1479
+ q = Query(limit=10, tag="hive")
1079
1480
  for h in Discussions_by_hot(q):
1080
1481
  print(h)
1081
1482
 
@@ -1090,11 +1491,48 @@ class Discussions_by_hot(list):
1090
1491
  blockchain_instance=None,
1091
1492
  **kwargs,
1092
1493
  ):
1093
- if blockchain_instance is None:
1094
- if kwargs.get("steem_instance"):
1095
- blockchain_instance = kwargs["steem_instance"]
1096
- elif kwargs.get("hive_instance"):
1097
- blockchain_instance = kwargs["hive_instance"]
1494
+ # Handle legacy parameters
1495
+ """
1496
+ Initialize a Discussions_by_hot iterator that fetches "hot" discussions.
1497
+
1498
+ Builds a reduced query from the provided discussion_query, prefers the bridge API for fetching ranked posts
1499
+ with a fallback to appbase or legacy RPC methods, and stores results either as raw dicts or wrapped Comment objects.
1500
+
1501
+ Parameters:
1502
+ discussion_query (dict): Query parameters (e.g., tag, limit, start_author, start_permlink). Only a subset is used.
1503
+ lazy (bool): If False, Comment objects will be fully initialized; if True, they are created for lazy loading.
1504
+ use_appbase (bool): When True prefer appbase/tagged endpoints as a fallback; also affects RPC next-node selection.
1505
+ raw_data (bool): If True store and return raw post dicts; if False wrap posts in Comment objects.
1506
+ kwargs: Deprecated-only legacy parameters `steem_instance` or `hive_instance` may be provided; if present they are used
1507
+ as the blockchain instance and a DeprecationWarning is emitted.
1508
+
1509
+ Side effects:
1510
+ - Resolves and assigns self.blockchain (from blockchain_instance, legacy kwargs, or shared instance).
1511
+ - Calls self.blockchain.rpc.set_next_node_on_empty_reply(...) to influence RPC backend selection.
1512
+ - Performs RPC calls (bridge get_ranked_posts or fallback get_discussions_by_hot), which may raise RPC-related exceptions.
1513
+
1514
+ Raises:
1515
+ ValueError: If multiple legacy instance keys are provided in kwargs (e.g., both `steem_instance` and `hive_instance`).
1516
+ """
1517
+ legacy_keys = {"steem_instance", "hive_instance"}
1518
+ legacy_instance = None
1519
+ for key in legacy_keys:
1520
+ if key in kwargs:
1521
+ if legacy_instance is not None:
1522
+ raise ValueError(
1523
+ f"Cannot specify both {key} and another legacy instance parameter"
1524
+ )
1525
+ legacy_instance = kwargs.pop(key)
1526
+ warnings.warn(
1527
+ f"Parameter '{key}' is deprecated. Use 'blockchain_instance' instead.",
1528
+ DeprecationWarning,
1529
+ stacklevel=2,
1530
+ )
1531
+
1532
+ # Prefer explicit blockchain_instance, then legacy
1533
+ if blockchain_instance is None and legacy_instance is not None:
1534
+ blockchain_instance = legacy_instance
1535
+
1098
1536
  self.blockchain = blockchain_instance or shared_blockchain_instance()
1099
1537
  reduced_query = {}
1100
1538
  for key in [
@@ -1154,12 +1592,12 @@ class Discussions_by_feed(list):
1154
1592
  searching posts, tag musst be set to a username
1155
1593
  :param bool use_appbase: use condenser call when set to False, default is False
1156
1594
  :param bool raw_data: returns list of comments when False, default is False
1157
- :param Steem blockchain_instance: Steem instance
1595
+ :param Hive blockchain_instance: Hive instance
1158
1596
 
1159
1597
  .. testcode::
1160
1598
 
1161
1599
  from nectar.discussions import Query, Discussions_by_feed
1162
- q = Query(limit=10, tag="steemit")
1600
+ q = Query(limit=10, tag="hive")
1163
1601
  for h in Discussions_by_feed(q):
1164
1602
  print(h)
1165
1603
 
@@ -1174,11 +1612,60 @@ class Discussions_by_feed(list):
1174
1612
  blockchain_instance=None,
1175
1613
  **kwargs,
1176
1614
  ):
1177
- if blockchain_instance is None:
1178
- if kwargs.get("steem_instance"):
1179
- blockchain_instance = kwargs["steem_instance"]
1180
- elif kwargs.get("hive_instance"):
1181
- blockchain_instance = kwargs["hive_instance"]
1615
+ # Handle legacy parameters
1616
+ """
1617
+ Initialize a Discussions_by_feed instance that fetches a user's feed discussions.
1618
+
1619
+ Builds an internal, reduced query from discussion_query, prefers the bridge API to fetch account feed posts
1620
+ (using discussion_query["tag"] as the account), falls back to appbase or legacy RPCs on error, and stores
1621
+ results as raw dicts (if raw_data=True) or wrapped Comment objects.
1622
+
1623
+ Parameters:
1624
+ discussion_query (dict): Query parameters. Must include "tag" to specify the account; supported keys
1625
+ copied into the internal query are: "tag", "limit", "filter_tags", "select_authors",
1626
+ "select_tags", "truncate_body", "start_author", "start_permlink".
1627
+ lazy (bool): If False (default), created Comment objects are fully initialized; if True, Comment objects
1628
+ are created in lazy mode to defer loading heavy fields.
1629
+ use_appbase (bool): When True, prefer appbase/tag-based endpoints as a fallback if the bridge call fails.
1630
+ raw_data (bool): If True, the instance is populated with raw post dicts; otherwise each post is wrapped
1631
+ in a Comment object with the resolved blockchain instance.
1632
+ blockchain_instance: If provided, used for RPC calls; otherwise a shared blockchain instance is used.
1633
+ (This parameter is a blockchain client and is intentionally not documented as a conventional param.)
1634
+
1635
+ Behavior:
1636
+ - Accepts deprecated legacy kwargs "steem_instance" or "hive_instance"; if provided, they are mapped to
1637
+ the blockchain instance and a DeprecationWarning is emitted. Supplying more than one legacy instance
1638
+ parameter raises ValueError.
1639
+ - Calls blockchain.rpc.set_next_node_on_empty_reply(...) using the conjunction of the RPC's
1640
+ appbase usage and the use_appbase flag to influence node selection.
1641
+ - Attempts to fetch posts via blockchain.rpc.get_account_posts(..., api="bridge") first.
1642
+ - On any bridge error, falls back to get_discussions_by_feed(...) using appbase/tags when available,
1643
+ then to legacy RPC if necessary.
1644
+ - Ensures posts is always a list (never None) before populating the base list.
1645
+
1646
+ Raises:
1647
+ ValueError: If more than one legacy instance parameter (e.g., both "steem_instance" and "hive_instance")
1648
+ is provided in kwargs.
1649
+ """
1650
+ legacy_keys = {"steem_instance", "hive_instance"}
1651
+ legacy_instance = None
1652
+ for key in legacy_keys:
1653
+ if key in kwargs:
1654
+ if legacy_instance is not None:
1655
+ raise ValueError(
1656
+ f"Cannot specify both {key} and another legacy instance parameter"
1657
+ )
1658
+ legacy_instance = kwargs.pop(key)
1659
+ warnings.warn(
1660
+ f"Parameter '{key}' is deprecated. Use 'blockchain_instance' instead.",
1661
+ DeprecationWarning,
1662
+ stacklevel=2,
1663
+ )
1664
+
1665
+ # Prefer explicit blockchain_instance, then legacy
1666
+ if blockchain_instance is None and legacy_instance is not None:
1667
+ blockchain_instance = legacy_instance
1668
+
1182
1669
  self.blockchain = blockchain_instance or shared_blockchain_instance()
1183
1670
  reduced_query = {}
1184
1671
  for key in [
@@ -1238,7 +1725,7 @@ class Discussions_by_blog(list):
1238
1725
  searching posts, tag musst be set to a username
1239
1726
  :param bool use_appbase: use condenser call when set to False, default is False
1240
1727
  :param bool raw_data: returns list of comments when False, default is False
1241
- :param Steem blockchain_instance: Steem instance
1728
+ :param Hive blockchain_instance: Hive instance
1242
1729
 
1243
1730
  .. testcode::
1244
1731
 
@@ -1258,11 +1745,50 @@ class Discussions_by_blog(list):
1258
1745
  blockchain_instance=None,
1259
1746
  **kwargs,
1260
1747
  ):
1261
- if blockchain_instance is None:
1262
- if kwargs.get("steem_instance"):
1263
- blockchain_instance = kwargs["steem_instance"]
1264
- elif kwargs.get("hive_instance"):
1265
- blockchain_instance = kwargs["hive_instance"]
1748
+ # Handle legacy parameters
1749
+ """
1750
+ Initialize a Discussions_by_blog fetcher that retrieves a user's blog posts.
1751
+
1752
+ Builds a reduced query from discussion_query (accepts keys like "tag" (account), "limit",
1753
+ "start_author", "start_permlink", "filter_tags", "select_authors", "select_tags",
1754
+ "truncate_body"), resolves the blockchain instance to use, and attempts to fetch posts
1755
+ via the bridge API (get_account_posts) falling back to appbase/legacy RPCs (get_discussions_by_blog).
1756
+ Results are stored as raw dicts when raw_data is True, or wrapped as Comment objects when False.
1757
+
1758
+ Parameters:
1759
+ discussion_query (dict): Query parameters that may include "tag" (the account name),
1760
+ "limit", "start_author", "start_permlink", and other optional filter/select keys.
1761
+ lazy (bool): If False, Comment wrappers will be fully initialized; if True, they are lazy.
1762
+ use_appbase (bool): When True prefer appbase/tag APIs where available (affects RPC routing).
1763
+ raw_data (bool): If True, keep fetched posts as raw dicts instead of Comment instances.
1764
+ blockchain_instance: Optional blockchain client to use; if not provided, a shared instance is used.
1765
+
1766
+ Notes:
1767
+ - Legacy keyword arguments "steem_instance" and "hive_instance" are accepted via kwargs,
1768
+ will emit a DeprecationWarning and be mapped to blockchain_instance. Supplying more than
1769
+ one legacy instance parameter raises ValueError.
1770
+ - The RPC client's next-node behavior is adjusted based on appbase usage to influence
1771
+ which backend is attempted first.
1772
+ """
1773
+ legacy_keys = {"steem_instance", "hive_instance"}
1774
+ legacy_instance = None
1775
+ for key in legacy_keys:
1776
+ if key in kwargs:
1777
+ if legacy_instance is not None:
1778
+ raise ValueError(
1779
+ f"Cannot specify both {key} and another legacy instance parameter"
1780
+ )
1781
+ legacy_instance = kwargs.pop(key)
1782
+ warnings.warn(
1783
+ f"Parameter '{key}' is deprecated. Use 'blockchain_instance' instead.",
1784
+ DeprecationWarning,
1785
+ stacklevel=2,
1786
+ )
1787
+
1788
+ # Prefer explicit blockchain_instance, then legacy
1789
+ if blockchain_instance is None and legacy_instance is not None:
1790
+ blockchain_instance = legacy_instance
1791
+
1266
1792
  self.blockchain = blockchain_instance or shared_blockchain_instance()
1267
1793
  reduced_query = {}
1268
1794
  for key in [
@@ -1323,12 +1849,12 @@ class Discussions_by_comments(list):
1323
1849
  searching posts, start_author and start_permlink must be set.
1324
1850
  :param bool use_appbase: use condenser call when set to False, default is False
1325
1851
  :param bool raw_data: returns list of comments when False, default is False
1326
- :param Steem blockchain_instance: Steem instance
1852
+ :param Hive blockchain_instance: Hive instance
1327
1853
 
1328
1854
  .. testcode::
1329
1855
 
1330
1856
  from nectar.discussions import Query, Discussions_by_comments
1331
- q = Query(limit=10, start_author="steemit", start_permlink="firstpost")
1857
+ q = Query(limit=10, start_author="hiveio", start_permlink="firstpost")
1332
1858
  for h in Discussions_by_comments(q):
1333
1859
  print(h)
1334
1860
 
@@ -1343,11 +1869,20 @@ class Discussions_by_comments(list):
1343
1869
  blockchain_instance=None,
1344
1870
  **kwargs,
1345
1871
  ):
1346
- if blockchain_instance is None:
1347
- if kwargs.get("steem_instance"):
1348
- blockchain_instance = kwargs["steem_instance"]
1349
- elif kwargs.get("hive_instance"):
1350
- blockchain_instance = kwargs["hive_instance"]
1872
+ """
1873
+ Initialize Discussions_by_comments.
1874
+
1875
+ Uses the provided discussion_query (expects at minimum `start_author` and `start_permlink`, optional `limit`) to fetch a discussion thread and produce a flattened list of the root post plus replies. Attempts to use the bridge API (`get_discussion`) first and, on failure, falls back to older endpoints (`get_discussions_by_comments`). If `raw_data` is False, each post is wrapped as a Comment; otherwise raw post dicts are kept.
1876
+
1877
+ Parameters:
1878
+ discussion_query (dict): Query containing `start_author`, `start_permlink`, and optional `limit`.
1879
+ lazy (bool): If False, Comment objects are fully available; if True, they are created in lazy mode.
1880
+ use_appbase (bool): Prefers appbase/tag API paths when True (used to select RPC backend).
1881
+ raw_data (bool): When True, yields raw post dicts instead of Comment objects.
1882
+
1883
+ Side effects:
1884
+ Adjusts the blockchain RPC node selection via `set_next_node_on_empty_reply` based on the `use_appbase` flag and the RPC's appbase setting.
1885
+ """
1351
1886
  self.blockchain = blockchain_instance or shared_blockchain_instance()
1352
1887
  reduced_query = {}
1353
1888
  for key in ["start_author", "start_permlink", "limit"]:
@@ -1417,12 +1952,12 @@ class Discussions_by_promoted(list):
1417
1952
  searching posts
1418
1953
  :param bool use_appbase: use condenser call when set to False, default is False
1419
1954
  :param bool raw_data: returns list of comments when False, default is False
1420
- :param Steem blockchain_instance: Steem instance
1955
+ :param Hive blockchain_instance: Hive instance
1421
1956
 
1422
1957
  .. testcode::
1423
1958
 
1424
1959
  from nectar.discussions import Query, Discussions_by_promoted
1425
- q = Query(limit=10, tag="steem")
1960
+ q = Query(limit=10, tag="hive")
1426
1961
  for h in Discussions_by_promoted(q):
1427
1962
  print(h)
1428
1963
 
@@ -1437,11 +1972,28 @@ class Discussions_by_promoted(list):
1437
1972
  blockchain_instance=None,
1438
1973
  **kwargs,
1439
1974
  ):
1440
- if blockchain_instance is None:
1441
- if kwargs.get("steem_instance"):
1442
- blockchain_instance = kwargs["steem_instance"]
1443
- elif kwargs.get("hive_instance"):
1444
- blockchain_instance = kwargs["hive_instance"]
1975
+ """
1976
+ Initialize Discussions_by_promoted: fetch promoted discussions and populate the sequence.
1977
+
1978
+ This constructor extracts a reduced set of keys from `discussion_query` (tag, limit, filter_tags,
1979
+ select_authors, select_tags, truncate_body, start_author, start_permlink), configures the RPC
1980
+ client to switch nodes on empty replies when appbase is in use, then attempts to fetch promoted
1981
+ posts via the bridge API. On bridge failure it falls back to appbase (`get_discussions_by_promoted`
1982
+ with `api="tags"`) and then to the legacy RPC method. Results are normalized to an empty list
1983
+ if None. If `raw_data` is True the raw post dictionaries are stored; otherwise each post is wrapped
1984
+ in a `Comment` object with the provided `lazy` and resolved blockchain instance.
1985
+
1986
+ Parameters:
1987
+ discussion_query (dict): Query parameters; only the keys listed above are used.
1988
+ lazy (bool): If False, Comment wrappers are fully initialized; if True, wrappers use lazy loading.
1989
+ use_appbase (bool): Prefer appbase/tag endpoints when True (used to decide fallback behavior).
1990
+ raw_data (bool): If True, store raw post dicts instead of `Comment` instances.
1991
+ blockchain_instance: Blockchain client to use; if None the shared instance is used.
1992
+
1993
+ Side effects:
1994
+ - Calls RPC methods on the resolved blockchain instance (may contact external APIs).
1995
+ - Sets RPC behavior via `set_next_node_on_empty_reply`.
1996
+ """
1445
1997
  self.blockchain = blockchain_instance or shared_blockchain_instance()
1446
1998
  reduced_query = {}
1447
1999
  for key in [
@@ -1501,12 +2053,12 @@ class Discussions_by_replies(list):
1501
2053
  searching posts, start_parent_author, start_permlink must be set.
1502
2054
  :param bool use_appbase: use condenser call when set to False, default is False
1503
2055
  :param bool raw_data: returns list of comments when False, default is False
1504
- :param Steem blockchain_instance: Steem instance
2056
+ :param Hive blockchain_instance: Hive instance
1505
2057
 
1506
2058
  .. testcode::
1507
2059
 
1508
2060
  from nectar.discussions import Query, Discussions_by_replies
1509
- q = Query(limit=10, start_parent_author="steemit", start_permlink="firstpost")
2061
+ q = Query(limit=10, start_parent_author="hiveio", start_permlink="firstpost")
1510
2062
  for h in Discussions_by_replies(q):
1511
2063
  print(h)
1512
2064
 
@@ -1521,11 +2073,44 @@ class Discussions_by_replies(list):
1521
2073
  blockchain_instance=None,
1522
2074
  **kwargs,
1523
2075
  ):
1524
- if blockchain_instance is None:
1525
- if kwargs.get("steem_instance"):
1526
- blockchain_instance = kwargs["steem_instance"]
1527
- elif kwargs.get("hive_instance"):
1528
- blockchain_instance = kwargs["hive_instance"]
2076
+ # Handle legacy parameters
2077
+ """
2078
+ Initialize the Discussions_by_replies fetcher and populate it with replies to a specified post.
2079
+
2080
+ This constructor accepts a discussion_query that should include `start_parent_author` and `start_permlink` to identify the post whose replies are requested. It normalizes legacy kwargs `steem_instance` / `hive_instance` (emitting a DeprecationWarning and mapping to `blockchain_instance`) and will raise ValueError if multiple legacy instance keys are provided. The RPC's next-node behavior is configured according to the blockchain's appbase usage and the `use_appbase` flag.
2081
+
2082
+ Behavior:
2083
+ - Attempts the bridge API (`get_discussion`) first to obtain a discussion tree and extracts all replies (every item except the main post).
2084
+ - On any bridge/error path, falls back to `get_replies_by_last_update` (appbase `api="tags"` when appropriate), using `limit` from the query or a default of 100.
2085
+ - If `raw_data` is True, initializes the base list with raw reply dicts; otherwise wraps each reply in a Comment(lazy=..., blockchain_instance=...).
2086
+
2087
+ Parameters:
2088
+ - discussion_query (dict): Query values; `start_parent_author` and `start_permlink` are required to target a post. `limit` controls the maximum replies returned; if absent a default of 100 is used when falling back.
2089
+ - lazy (bool): Whether wrapped Comment objects should be lazy-loaded.
2090
+ - use_appbase (bool): Prefer appbase/tag API paths when True (when supported by the blockchain RPC).
2091
+ - raw_data (bool): If True, return raw reply dicts instead of Comment instances.
2092
+
2093
+ Note: `blockchain_instance` may be provided explicitly or implied via deprecated legacy kwargs; it is used to access the RPC and is not documented here as a parameter description for services/clients.
2094
+ """
2095
+ legacy_keys = {"steem_instance", "hive_instance"}
2096
+ legacy_instance = None
2097
+ for key in legacy_keys:
2098
+ if key in kwargs:
2099
+ if legacy_instance is not None:
2100
+ raise ValueError(
2101
+ f"Cannot specify both {key} and another legacy instance parameter"
2102
+ )
2103
+ legacy_instance = kwargs.pop(key)
2104
+ warnings.warn(
2105
+ f"Parameter '{key}' is deprecated. Use 'blockchain_instance' instead.",
2106
+ DeprecationWarning,
2107
+ stacklevel=2,
2108
+ )
2109
+
2110
+ # Prefer explicit blockchain_instance, then legacy
2111
+ if blockchain_instance is None and legacy_instance is not None:
2112
+ blockchain_instance = legacy_instance
2113
+
1529
2114
  self.blockchain = blockchain_instance or shared_blockchain_instance()
1530
2115
  reduced_query = {}
1531
2116
  for key in ["start_parent_author", "start_permlink", "limit"]:
@@ -1607,12 +2192,12 @@ class Replies_by_last_update(list):
1607
2192
  searching posts start_parent_author and start_permlink must be set.
1608
2193
  :param bool use_appbase: use condenser call when set to False, default is False
1609
2194
  :param bool raw_data: returns list of comments when False, default is False
1610
- :param Steem blockchain_instance: Steem instance
2195
+ :param Hive blockchain_instance: Hive instance
1611
2196
 
1612
2197
  .. testcode::
1613
2198
 
1614
2199
  from nectar.discussions import Query, Replies_by_last_update
1615
- q = Query(limit=10, start_parent_author="steemit", start_permlink="firstpost")
2200
+ q = Query(limit=10, start_parent_author="hiveio", start_permlink="firstpost")
1616
2201
  for h in Replies_by_last_update(q):
1617
2202
  print(h)
1618
2203
 
@@ -1627,11 +2212,45 @@ class Replies_by_last_update(list):
1627
2212
  blockchain_instance=None,
1628
2213
  **kwargs,
1629
2214
  ):
1630
- if blockchain_instance is None:
1631
- if kwargs.get("steem_instance"):
1632
- blockchain_instance = kwargs["steem_instance"]
1633
- elif kwargs.get("hive_instance"):
1634
- blockchain_instance = kwargs["hive_instance"]
2215
+ # Handle legacy parameters
2216
+ """
2217
+ Initialize a Replies_by_last_update iterator that loads replies to a specific post, using appbase/tags APIs when available and falling back to legacy RPC calls.
2218
+
2219
+ This constructor:
2220
+ - Accepts a discussion_query dict containing at minimum "start_author", "start_permlink", and "limit".
2221
+ - Accepts legacy kwargs "steem_instance" or "hive_instance"; if provided they are treated as deprecated aliases for `blockchain_instance` and emit a DeprecationWarning. Specifying more than one legacy key raises ValueError.
2222
+ - Chooses the blockchain instance from `blockchain_instance`, legacy parameters, or a shared instance, and configures RPC node selection based on the appbase usage.
2223
+ - Attempts to fetch replies via the appbase/tags endpoint (when available and requested) and falls back to the legacy get_replies_by_last_update RPC form if needed.
2224
+ - Normalizes missing or None responses to an empty list.
2225
+ - If raw_data is False (default), wraps each result in a Comment with the provided lazy and blockchain_instance settings; otherwise returns raw post dicts.
2226
+ - Calls the superclass initializer with the resulting list (so the object becomes an iterable/sequence of replies).
2227
+
2228
+ Parameters:
2229
+ discussion_query (dict): Query parameters; must include "start_author", "start_permlink", and "limit".
2230
+ lazy (bool): If False, Comment objects are fully initialized; if True, Comments are created with lazy-loading enabled.
2231
+ use_appbase (bool): When True, prefer appbase/tags endpoints where supported.
2232
+ raw_data (bool): If True, initialize with raw post dicts instead of Comment wrappers.
2233
+ blockchain_instance: Optional blockchain client instance; if omitted a shared instance is used. Legacy parameters `steem_instance`/`hive_instance` may be passed via kwargs but are deprecated.
2234
+ """
2235
+ legacy_keys = {"steem_instance", "hive_instance"}
2236
+ legacy_instance = None
2237
+ for key in legacy_keys:
2238
+ if key in kwargs:
2239
+ if legacy_instance is not None:
2240
+ raise ValueError(
2241
+ f"Cannot specify both {key} and another legacy instance parameter"
2242
+ )
2243
+ legacy_instance = kwargs.pop(key)
2244
+ warnings.warn(
2245
+ f"Parameter '{key}' is deprecated. Use 'blockchain_instance' instead.",
2246
+ DeprecationWarning,
2247
+ stacklevel=2,
2248
+ )
2249
+
2250
+ # Prefer explicit blockchain_instance, then legacy
2251
+ if blockchain_instance is None and legacy_instance is not None:
2252
+ blockchain_instance = legacy_instance
2253
+
1635
2254
  self.blockchain = blockchain_instance or shared_blockchain_instance()
1636
2255
  self.blockchain.rpc.set_next_node_on_empty_reply(
1637
2256
  self.blockchain.rpc.get_use_appbase() and use_appbase
@@ -1669,7 +2288,7 @@ class Trending_tags(list):
1669
2288
 
1670
2289
  :param Query discussion_query: Defines the parameter
1671
2290
  searching posts, start_tag is used if set
1672
- :param Steem blockchain_instance: Steem instance
2291
+ :param Hive blockchain_instance: Hive instance
1673
2292
 
1674
2293
  .. testcode::
1675
2294
 
@@ -1683,11 +2302,46 @@ class Trending_tags(list):
1683
2302
  def __init__(
1684
2303
  self, discussion_query, lazy=False, use_appbase=False, blockchain_instance=None, **kwargs
1685
2304
  ):
1686
- if blockchain_instance is None:
1687
- if kwargs.get("steem_instance"):
1688
- blockchain_instance = kwargs["steem_instance"]
1689
- elif kwargs.get("hive_instance"):
1690
- blockchain_instance = kwargs["hive_instance"]
2305
+ # Handle legacy parameters
2306
+ """
2307
+ Initialize a Trending_tags iterator by fetching trending tags from the blockchain RPC.
2308
+
2309
+ Fetches trending tags according to discussion_query["limit"], preferring a bridge/appbase (condenser) path when available and falling back to the legacy RPC. Resolves and stores the blockchain instance, configures RPC next-node behavior based on the use_appbase flag, and initializes the base sequence with the retrieved tag list.
2310
+
2311
+ Parameters:
2312
+ discussion_query (dict): Query parameters; only 'limit' is used (defaults to 0 if absent).
2313
+ lazy (bool): Unused by this initializer but preserved for API compatibility.
2314
+ use_appbase (bool): When True, prefer appbase/condenser endpoints when the RPC reports appbase support.
2315
+ blockchain_instance: Optional blockchain client; if not provided, a shared instance is used.
2316
+ **kwargs: May contain deprecated legacy keys 'steem_instance' or 'hive_instance'. If present, the single legacy key is accepted (mapped to blockchain_instance) and a DeprecationWarning is emitted. Supplying more than one legacy key raises ValueError.
2317
+
2318
+ Side effects:
2319
+ - Sets self.blockchain to the resolved blockchain instance.
2320
+ - Calls self.blockchain.rpc.set_next_node_on_empty_reply(...) to control backend selection.
2321
+ - Emits DeprecationWarning when a legacy instance key is used.
2322
+
2323
+ Raises:
2324
+ ValueError: If more than one legacy instance key is provided.
2325
+ """
2326
+ legacy_keys = {"steem_instance", "hive_instance"}
2327
+ legacy_instance = None
2328
+ for key in legacy_keys:
2329
+ if key in kwargs:
2330
+ if legacy_instance is not None:
2331
+ raise ValueError(
2332
+ f"Cannot specify both {key} and another legacy instance parameter"
2333
+ )
2334
+ legacy_instance = kwargs.pop(key)
2335
+ warnings.warn(
2336
+ f"Parameter '{key}' is deprecated. Use 'blockchain_instance' instead.",
2337
+ DeprecationWarning,
2338
+ stacklevel=2,
2339
+ )
2340
+
2341
+ # Prefer explicit blockchain_instance, then legacy
2342
+ if blockchain_instance is None and legacy_instance is not None:
2343
+ blockchain_instance = legacy_instance
2344
+
1691
2345
  self.blockchain = blockchain_instance or shared_blockchain_instance()
1692
2346
  self.blockchain.rpc.set_next_node_on_empty_reply(
1693
2347
  self.blockchain.rpc.get_use_appbase() and use_appbase