hive-nectar 0.0.10__py3-none-any.whl → 0.1.0__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.
- {hive_nectar-0.0.10.dist-info → hive_nectar-0.1.0.dist-info}/METADATA +10 -11
- hive_nectar-0.1.0.dist-info/RECORD +88 -0
- nectar/__init__.py +1 -4
- nectar/account.py +791 -685
- nectar/amount.py +82 -21
- nectar/asset.py +1 -2
- nectar/block.py +34 -22
- nectar/blockchain.py +111 -143
- nectar/blockchaininstance.py +396 -247
- nectar/blockchainobject.py +33 -5
- nectar/cli.py +1058 -1349
- nectar/comment.py +317 -182
- nectar/community.py +39 -43
- nectar/constants.py +1 -14
- nectar/discussions.py +793 -139
- nectar/hive.py +137 -77
- nectar/hivesigner.py +106 -68
- nectar/imageuploader.py +33 -23
- nectar/instance.py +31 -79
- nectar/market.py +128 -264
- nectar/memo.py +40 -13
- nectar/message.py +23 -10
- nectar/nodelist.py +118 -82
- nectar/price.py +80 -61
- nectar/profile.py +6 -3
- nectar/rc.py +45 -25
- nectar/snapshot.py +285 -163
- nectar/storage.py +16 -5
- nectar/transactionbuilder.py +132 -41
- nectar/utils.py +37 -17
- nectar/version.py +1 -1
- nectar/vote.py +171 -30
- nectar/wallet.py +26 -19
- nectar/witness.py +153 -54
- nectarapi/graphenerpc.py +147 -133
- nectarapi/noderpc.py +12 -6
- nectarapi/rpcutils.py +12 -6
- nectarapi/version.py +1 -1
- nectarbase/ledgertransactions.py +24 -1
- nectarbase/objects.py +17 -6
- nectarbase/operations.py +160 -90
- nectarbase/signedtransactions.py +38 -2
- nectarbase/version.py +1 -1
- nectargraphenebase/account.py +295 -17
- nectargraphenebase/chains.py +0 -135
- nectargraphenebase/ecdsasig.py +152 -176
- nectargraphenebase/types.py +18 -4
- nectargraphenebase/unsignedtransactions.py +1 -1
- nectargraphenebase/version.py +1 -1
- hive_nectar-0.0.10.dist-info/RECORD +0 -91
- nectar/blurt.py +0 -562
- nectar/conveyor.py +0 -308
- nectar/steem.py +0 -581
- {hive_nectar-0.0.10.dist-info → hive_nectar-0.1.0.dist-info}/WHEEL +0 -0
- {hive_nectar-0.0.10.dist-info → hive_nectar-0.1.0.dist-info}/entry_points.txt +0 -0
- {hive_nectar-0.0.10.dist-info → hive_nectar-0.1.0.dist-info}/licenses/LICENSE.txt +0 -0
nectar/rc.py
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
# -*- coding: utf-8 -*-
|
|
2
|
-
from binascii import hexlify
|
|
3
2
|
|
|
4
3
|
from nectar.constants import (
|
|
5
4
|
EXEC_FOLLOW_CUSTOM_OP_SCALE,
|
|
@@ -15,17 +14,29 @@ from .instance import shared_blockchain_instance
|
|
|
15
14
|
|
|
16
15
|
class RC(object):
|
|
17
16
|
def __init__(self, blockchain_instance=None, **kwargs):
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
17
|
+
"""
|
|
18
|
+
Initialize the RC helper with a blockchain instance.
|
|
19
|
+
|
|
20
|
+
If `blockchain_instance` is provided it will be used for RC lookups and broadcasts;
|
|
21
|
+
otherwise the module-wide shared_blockchain_instance() is used. Extra keyword
|
|
22
|
+
arguments are accepted for compatibility but ignored.
|
|
23
|
+
"""
|
|
23
24
|
self.blockchain = blockchain_instance or shared_blockchain_instance()
|
|
24
25
|
|
|
25
26
|
def get_tx_size(self, op):
|
|
26
|
-
"""
|
|
27
|
+
"""
|
|
28
|
+
Estimate the serialized size (in bytes) of a signed transaction containing the given operation.
|
|
29
|
+
|
|
30
|
+
This constructs a dummy Signed_Transaction using fixed reference fields and a hard-coded private key, signs it on the "HIVE" chain, and returns the length of the resulting serialized transaction in bytes. The value is an estimate useful for RC sizing and does not represent a real broadcastable transaction.
|
|
31
|
+
|
|
32
|
+
Parameters:
|
|
33
|
+
op: Operation or dict-like operation payload to include in the transaction.
|
|
34
|
+
|
|
35
|
+
Returns:
|
|
36
|
+
int: Number of bytes in the serialized, signed transaction.
|
|
37
|
+
"""
|
|
27
38
|
ops = [Operation(op)]
|
|
28
|
-
prefix = "
|
|
39
|
+
prefix = "HIVE"
|
|
29
40
|
wif = "5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3"
|
|
30
41
|
ref_block_num = 34294
|
|
31
42
|
ref_block_prefix = 3707022213
|
|
@@ -37,8 +48,7 @@ class RC(object):
|
|
|
37
48
|
operations=ops,
|
|
38
49
|
)
|
|
39
50
|
tx = tx.sign([wif], chain=prefix)
|
|
40
|
-
|
|
41
|
-
tx_size = len(txWire)
|
|
51
|
+
tx_size = len(bytes(tx))
|
|
42
52
|
return tx_size
|
|
43
53
|
|
|
44
54
|
def get_resource_count(
|
|
@@ -49,7 +59,24 @@ class RC(object):
|
|
|
49
59
|
new_account_op_count=0,
|
|
50
60
|
market_op_count=0,
|
|
51
61
|
):
|
|
52
|
-
"""
|
|
62
|
+
"""
|
|
63
|
+
Build and return a resource_count mapping for RC cost calculation.
|
|
64
|
+
|
|
65
|
+
Parameters:
|
|
66
|
+
tx_size (int): Transaction size in bytes; used for history bytes and for market bytes when applicable.
|
|
67
|
+
execution_time_count (int): Execution time units for the operation.
|
|
68
|
+
state_bytes_count (int, optional): Additional state bytes contributed by the operation (default 0).
|
|
69
|
+
new_account_op_count (int, optional): Number of new-account operations included (default 0).
|
|
70
|
+
market_op_count (int, optional): If > 0, marks the transaction as a market operation and sets market bytes to tx_size (default 0).
|
|
71
|
+
|
|
72
|
+
Returns:
|
|
73
|
+
dict: A dictionary containing keys used by the RC pricing engine, including:
|
|
74
|
+
- resource_history_bytes
|
|
75
|
+
- resource_state_bytes
|
|
76
|
+
- resource_new_accounts
|
|
77
|
+
- resource_execution_time
|
|
78
|
+
- resource_market_bytes (only present if market_op_count > 0)
|
|
79
|
+
"""
|
|
53
80
|
resource_count = {"resource_history_bytes": tx_size}
|
|
54
81
|
resource_count["resource_state_bytes"] = state_object_size_info[
|
|
55
82
|
"transaction_object_base_size"
|
|
@@ -136,23 +163,16 @@ class RC(object):
|
|
|
136
163
|
return self.blockchain.get_rc_cost(resource_count)
|
|
137
164
|
|
|
138
165
|
def transfer_dict(self, transfer_dict):
|
|
139
|
-
"""
|
|
140
|
-
|
|
141
|
-
Example for calculating RC costs
|
|
142
|
-
|
|
143
|
-
.. code-block:: python
|
|
166
|
+
"""
|
|
167
|
+
Calculate Resource Credit (RC) cost for a transfer operation represented as a dict.
|
|
144
168
|
|
|
145
|
-
|
|
146
|
-
from nectar.amount import Amount
|
|
147
|
-
transfer_dict = {
|
|
148
|
-
"from": "foo", "to": "baar",
|
|
149
|
-
"amount": Amount("111.110 STEEM"),
|
|
150
|
-
"memo": "Fooo"
|
|
151
|
-
}
|
|
169
|
+
The input dict must contain the fields required by a Transfer operation (for example: "from", "to", "amount", "memo"). This function builds a Transfer operation, estimates the signed transaction size, marks the operation as a market operation (market_op_count=1), and returns the RC cost computed by the blockchain instance.
|
|
152
170
|
|
|
153
|
-
|
|
154
|
-
|
|
171
|
+
Parameters:
|
|
172
|
+
transfer_dict (dict): Fields for a Transfer operation compatible with operations.Transfer.
|
|
155
173
|
|
|
174
|
+
Returns:
|
|
175
|
+
dict: RC cost structure as returned by the blockchain's get_rc_cost.
|
|
156
176
|
"""
|
|
157
177
|
market_op_count = 1
|
|
158
178
|
op = operations.Transfer(**transfer_dict)
|