hive-nectar 0.1.1__py3-none-any.whl → 0.1.3__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.1.1.dist-info → hive_nectar-0.1.3.dist-info}/METADATA +1 -2
- {hive_nectar-0.1.1.dist-info → hive_nectar-0.1.3.dist-info}/RECORD +22 -21
- nectar/account.py +86 -35
- nectar/block.py +3 -3
- nectar/blockchain.py +2 -2
- nectar/blockchaininstance.py +11 -1
- nectar/cli.py +292 -266
- nectar/comment.py +19 -16
- nectar/haf.py +380 -0
- nectar/hivesigner.py +9 -0
- nectar/market.py +2 -4
- nectar/memo.py +2 -2
- nectar/nodelist.py +0 -24
- nectar/utils.py +60 -37
- nectar/version.py +1 -1
- nectarapi/version.py +1 -1
- nectarbase/version.py +1 -1
- nectargraphenebase/account.py +1 -2
- nectargraphenebase/version.py +1 -1
- {hive_nectar-0.1.1.dist-info → hive_nectar-0.1.3.dist-info}/WHEEL +0 -0
- {hive_nectar-0.1.1.dist-info → hive_nectar-0.1.3.dist-info}/entry_points.txt +0 -0
- {hive_nectar-0.1.1.dist-info → hive_nectar-0.1.3.dist-info}/licenses/LICENSE.txt +0 -0
nectar/cli.py
CHANGED
|
@@ -14,7 +14,6 @@ import time
|
|
|
14
14
|
from datetime import datetime, timedelta, timezone
|
|
15
15
|
|
|
16
16
|
import click
|
|
17
|
-
from click_shell import shell
|
|
18
17
|
from prettytable import PrettyTable
|
|
19
18
|
|
|
20
19
|
from nectar import exceptions
|
|
@@ -256,11 +255,7 @@ def export_trx(tx, export):
|
|
|
256
255
|
json.dump(tx, f)
|
|
257
256
|
|
|
258
257
|
|
|
259
|
-
@
|
|
260
|
-
prompt="hive-nectar> ",
|
|
261
|
-
intro="Starting hive-nectar... (use help to list all commands)",
|
|
262
|
-
chain=True,
|
|
263
|
-
)
|
|
258
|
+
@click.group(chain=True)
|
|
264
259
|
# @click.group(chain=True)
|
|
265
260
|
@click.option(
|
|
266
261
|
"--node", "-n", default="", help="URL for public Hive API (e.g. https://api.hive.blog)"
|
|
@@ -593,23 +588,30 @@ def updatenodes(show, test, only_https, only_wss):
|
|
|
593
588
|
t = PrettyTable(["node", "Version", "score"])
|
|
594
589
|
t.align = "l"
|
|
595
590
|
nodelist = NodeList()
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
591
|
+
try:
|
|
592
|
+
nodelist.update_nodes(blockchain_instance=hv)
|
|
593
|
+
# Flags are mutually exclusive; at least one transport must be enabled
|
|
594
|
+
if only_https and only_wss:
|
|
595
|
+
raise click.UsageError("Use at most one of --only-https or --only-wss.")
|
|
596
|
+
nodes = nodelist.get_hive_nodes(wss=not only_https, https=not only_wss)
|
|
597
|
+
if not nodes:
|
|
598
|
+
raise RuntimeError("No nodes matched the selected filters.")
|
|
599
|
+
if hv.config["default_chain"] != "hive":
|
|
600
|
+
hv.config["default_chain"] = "hive"
|
|
601
|
+
if show or test:
|
|
602
|
+
sorted_nodes = sorted(nodelist, key=lambda node: node["score"], reverse=True)
|
|
603
|
+
for node in sorted_nodes:
|
|
604
|
+
if node["url"] in nodes:
|
|
605
|
+
score = float("{0:.1f}".format(node["score"]))
|
|
606
|
+
t.add_row([node["url"], node["version"], score])
|
|
607
|
+
print(t)
|
|
608
|
+
if not test:
|
|
609
|
+
hv.set_default_nodes(nodes)
|
|
610
|
+
hv.rpc.nodes.set_node_urls(nodes)
|
|
611
|
+
hv.rpc.rpcconnect()
|
|
612
|
+
except Exception:
|
|
613
|
+
log.exception("Failed to update nodes")
|
|
614
|
+
raise
|
|
613
615
|
|
|
614
616
|
|
|
615
617
|
@cli.command()
|
|
@@ -2032,13 +2034,21 @@ def allow(foreign_account, permission, account, weight, threshold, export):
|
|
|
2032
2034
|
"--permission", "-p", default="posting", help='The permission to grant (defaults to "posting")'
|
|
2033
2035
|
)
|
|
2034
2036
|
@click.option("--account", "-a", help="The account to disallow action for")
|
|
2037
|
+
@click.option(
|
|
2038
|
+
"--weight",
|
|
2039
|
+
"-w",
|
|
2040
|
+
type=int,
|
|
2041
|
+
help="The weight to use instead of the (full) threshold. "
|
|
2042
|
+
"If the weight is smaller than the threshold, "
|
|
2043
|
+
"additional signatures are required",
|
|
2044
|
+
)
|
|
2035
2045
|
@click.option(
|
|
2036
2046
|
"--threshold",
|
|
2037
2047
|
"-t",
|
|
2038
2048
|
help="The permission's threshold that needs to be reached by signatures to be able to interact",
|
|
2039
2049
|
)
|
|
2040
2050
|
@click.option("--export", "-e", help="When set, transaction is stored in a file")
|
|
2041
|
-
def disallow(foreign_account, permission, account, threshold, export):
|
|
2051
|
+
def disallow(foreign_account, permission, account, weight, threshold, export):
|
|
2042
2052
|
"""Remove allowance an account/key to interact with your account"""
|
|
2043
2053
|
hv = shared_blockchain_instance()
|
|
2044
2054
|
if hv.rpc is not None:
|
|
@@ -2058,7 +2068,7 @@ def disallow(foreign_account, permission, account, threshold, export):
|
|
|
2058
2068
|
|
|
2059
2069
|
pwd = click.prompt("Password for Key Derivation", confirmation_prompt=True)
|
|
2060
2070
|
foreign_account = [format(PasswordKey(account, pwd, permission).get_public(), hv.prefix)]
|
|
2061
|
-
tx = acc.disallow(foreign_account, permission=permission, threshold=threshold)
|
|
2071
|
+
tx = acc.disallow(foreign_account, permission=permission, weight=weight, threshold=threshold)
|
|
2062
2072
|
if hv.unsigned and hv.nobroadcast and hv.hivesigner is not None:
|
|
2063
2073
|
tx = hv.hivesigner.url_from_tx(tx)
|
|
2064
2074
|
export_trx(tx, export)
|
|
@@ -2364,7 +2374,7 @@ def setprofile(variable, value, account, pair, export):
|
|
|
2364
2374
|
@click.option("--account", "-a", help="delprofile as this user")
|
|
2365
2375
|
@click.option("--export", "-e", help="When set, transaction is stored in a file")
|
|
2366
2376
|
def delprofile(variable, account, export):
|
|
2367
|
-
"""Delete a variable in an account
|
|
2377
|
+
"""Delete a variable in an account's profile"""
|
|
2368
2378
|
hv = shared_blockchain_instance()
|
|
2369
2379
|
if hv.rpc is not None:
|
|
2370
2380
|
hv.rpc.rpcconnect()
|
|
@@ -4402,255 +4412,271 @@ def curation(
|
|
|
4402
4412
|
hv = shared_blockchain_instance()
|
|
4403
4413
|
if hv.rpc is not None:
|
|
4404
4414
|
hv.rpc.rpcconnect()
|
|
4405
|
-
|
|
4406
|
-
|
|
4407
|
-
authorperm
|
|
4408
|
-
|
|
4409
|
-
|
|
4410
|
-
|
|
4411
|
-
show_all_voter = False
|
|
4412
|
-
if authorperm == "all" or authorperm.isdigit():
|
|
4413
|
-
if not account:
|
|
4414
|
-
account = hv.config["default_account"]
|
|
4415
|
-
# Using built-in timezone support
|
|
4416
|
-
limit_time = datetime.now(timezone.utc) - timedelta(days=7)
|
|
4417
|
-
votes = AccountVotes(account, start=limit_time, blockchain_instance=hv)
|
|
4418
|
-
authorperm_list = [vote.authorperm for vote in votes]
|
|
4419
|
-
if authorperm.isdigit():
|
|
4420
|
-
if len(authorperm_list) < int(authorperm):
|
|
4421
|
-
raise ValueError("Authorperm id must be lower than %d" % (len(authorperm_list) + 1))
|
|
4422
|
-
authorperm_list = [authorperm_list[int(authorperm) - 1]]
|
|
4423
|
-
all_posts = False
|
|
4415
|
+
try:
|
|
4416
|
+
HP_symbol = "HP"
|
|
4417
|
+
if authorperm is None:
|
|
4418
|
+
authorperm = "all"
|
|
4419
|
+
if account is None and authorperm != "all":
|
|
4420
|
+
show_all_voter = True
|
|
4424
4421
|
else:
|
|
4425
|
-
|
|
4426
|
-
|
|
4427
|
-
|
|
4428
|
-
|
|
4429
|
-
|
|
4430
|
-
|
|
4431
|
-
|
|
4432
|
-
|
|
4433
|
-
|
|
4434
|
-
|
|
4435
|
-
|
|
4436
|
-
|
|
4437
|
-
|
|
4438
|
-
|
|
4439
|
-
|
|
4440
|
-
|
|
4441
|
-
|
|
4442
|
-
elif (all_posts) and title:
|
|
4443
|
-
t = PrettyTable(
|
|
4444
|
-
[
|
|
4445
|
-
"Author",
|
|
4446
|
-
"permlink",
|
|
4447
|
-
"Voting time",
|
|
4448
|
-
"Vote",
|
|
4449
|
-
"Early vote loss",
|
|
4450
|
-
"Curation",
|
|
4451
|
-
"Performance",
|
|
4452
|
-
]
|
|
4453
|
-
)
|
|
4454
|
-
t.align = "l"
|
|
4455
|
-
elif all_posts:
|
|
4456
|
-
t = PrettyTable(
|
|
4457
|
-
["Author", "Voting time", "Vote", "Early vote loss", "Curation", "Performance"]
|
|
4458
|
-
)
|
|
4459
|
-
t.align = "l"
|
|
4460
|
-
elif (export) and permlink:
|
|
4461
|
-
t = PrettyTable(
|
|
4462
|
-
[
|
|
4463
|
-
"Author",
|
|
4464
|
-
"permlink",
|
|
4465
|
-
"Voter",
|
|
4466
|
-
"Voting time",
|
|
4467
|
-
"Vote",
|
|
4468
|
-
"Early vote loss",
|
|
4469
|
-
"Curation",
|
|
4470
|
-
"Performance",
|
|
4471
|
-
]
|
|
4472
|
-
)
|
|
4473
|
-
t.align = "l"
|
|
4474
|
-
elif (export) and title:
|
|
4475
|
-
t = PrettyTable(
|
|
4476
|
-
[
|
|
4477
|
-
"Author",
|
|
4478
|
-
"permlink",
|
|
4479
|
-
"Voter",
|
|
4480
|
-
"Voting time",
|
|
4481
|
-
"Vote",
|
|
4482
|
-
"Early vote loss",
|
|
4483
|
-
"Curation",
|
|
4484
|
-
"Performance",
|
|
4485
|
-
]
|
|
4486
|
-
)
|
|
4487
|
-
t.align = "l"
|
|
4488
|
-
elif export:
|
|
4489
|
-
t = PrettyTable(
|
|
4490
|
-
["Author", "Voter", "Voting time", "Vote", "Early vote loss", "Curation", "Performance"]
|
|
4491
|
-
)
|
|
4492
|
-
t.align = "l"
|
|
4493
|
-
else:
|
|
4494
|
-
t = PrettyTable(
|
|
4495
|
-
["Voter", "Voting time", "Vote", "Early vote loss", "Curation", "Performance"]
|
|
4496
|
-
)
|
|
4497
|
-
t.align = "l"
|
|
4498
|
-
index = 0
|
|
4499
|
-
for authorperm in authorperm_list:
|
|
4500
|
-
index += 1
|
|
4501
|
-
comment = Comment(authorperm, blockchain_instance=hv)
|
|
4502
|
-
if payout is not None and comment.is_pending():
|
|
4503
|
-
payout = float(payout)
|
|
4504
|
-
elif payout is not None:
|
|
4505
|
-
payout = None
|
|
4506
|
-
curation_rewards_HBD = comment.get_curation_rewards(
|
|
4507
|
-
pending_payout_hbd=True, pending_payout_value=payout
|
|
4508
|
-
)
|
|
4509
|
-
curation_rewards_HP = comment.get_curation_rewards(
|
|
4510
|
-
pending_payout_hbd=False, pending_payout_value=payout
|
|
4511
|
-
)
|
|
4512
|
-
rows = []
|
|
4513
|
-
sum_curation = [0, 0, 0, 0]
|
|
4514
|
-
max_curation = [0, 0, 0, 0, 0, 0]
|
|
4515
|
-
highest_vote = [0, 0, 0, 0, 0, 0]
|
|
4516
|
-
for vote in comment.get_votes():
|
|
4517
|
-
vote_time = vote["time"]
|
|
4518
|
-
|
|
4519
|
-
vote_HBD = hv.rshares_to_token_backed_dollar(int(vote["rshares"]))
|
|
4520
|
-
curation_HBD = curation_rewards_HBD["active_votes"][vote["voter"]]
|
|
4521
|
-
curation_HP = curation_rewards_HP["active_votes"][vote["voter"]]
|
|
4522
|
-
if vote_HBD > 0:
|
|
4523
|
-
penalty = (comment.get_curation_penalty(vote_time=vote_time)) * vote_HBD
|
|
4524
|
-
performance = float(curation_HBD) / vote_HBD * 100
|
|
4525
|
-
else:
|
|
4526
|
-
performance = 0
|
|
4527
|
-
penalty = 0
|
|
4528
|
-
vote_befor_min = ((vote_time) - comment["created"]).total_seconds() / 60
|
|
4529
|
-
sum_curation[0] += vote_HBD
|
|
4530
|
-
sum_curation[1] += penalty
|
|
4531
|
-
sum_curation[2] += float(curation_HP)
|
|
4532
|
-
sum_curation[3] += float(curation_HBD)
|
|
4533
|
-
row = [
|
|
4534
|
-
vote["voter"],
|
|
4535
|
-
vote_befor_min,
|
|
4536
|
-
vote_HBD,
|
|
4537
|
-
penalty,
|
|
4538
|
-
float(curation_HP),
|
|
4539
|
-
performance,
|
|
4540
|
-
]
|
|
4541
|
-
|
|
4542
|
-
rows.append(row)
|
|
4543
|
-
sortedList = sorted(rows, key=lambda row: (row[1]), reverse=False)
|
|
4544
|
-
new_row = []
|
|
4545
|
-
new_row2 = []
|
|
4546
|
-
voter = []
|
|
4547
|
-
voter2 = []
|
|
4548
|
-
if (all_posts or export) and permlink:
|
|
4549
|
-
if length:
|
|
4550
|
-
new_row = [comment.author, comment.permlink[: int(length)]]
|
|
4551
|
-
else:
|
|
4552
|
-
new_row = [comment.author, comment.permlink]
|
|
4553
|
-
new_row2 = ["", ""]
|
|
4554
|
-
elif (all_posts or export) and title:
|
|
4555
|
-
if length:
|
|
4556
|
-
new_row = [comment.author, comment.title[: int(length)]]
|
|
4557
|
-
else:
|
|
4558
|
-
new_row = [comment.author, comment.title]
|
|
4559
|
-
new_row2 = ["", ""]
|
|
4560
|
-
elif all_posts or export:
|
|
4561
|
-
new_row = [comment.author]
|
|
4562
|
-
new_row2 = [""]
|
|
4563
|
-
if not all_posts:
|
|
4564
|
-
voter = [""]
|
|
4565
|
-
voter2 = [""]
|
|
4566
|
-
found_voter = False
|
|
4567
|
-
for row in sortedList:
|
|
4568
|
-
if limit is not None and row[1] > float(limit):
|
|
4569
|
-
continue
|
|
4570
|
-
if min_vote is not None and float(row[2]) < float(min_vote):
|
|
4571
|
-
continue
|
|
4572
|
-
if max_vote is not None and float(row[2]) > float(max_vote):
|
|
4573
|
-
continue
|
|
4574
|
-
if min_performance is not None and float(row[5]) < float(min_performance):
|
|
4575
|
-
continue
|
|
4576
|
-
if max_performance is not None and float(row[5]) > float(max_performance):
|
|
4577
|
-
continue
|
|
4578
|
-
if row[-1] > max_curation[-1]:
|
|
4579
|
-
max_curation = row
|
|
4580
|
-
if row[2] > highest_vote[2]:
|
|
4581
|
-
highest_vote = row
|
|
4582
|
-
if show_all_voter or account == row[0]:
|
|
4583
|
-
if not all_posts:
|
|
4584
|
-
voter = [row[0]]
|
|
4585
|
-
if all_posts:
|
|
4586
|
-
new_row[0] = "%d. %s" % (index, comment.author)
|
|
4587
|
-
if not found_voter:
|
|
4588
|
-
found_voter = True
|
|
4589
|
-
t.add_row(
|
|
4590
|
-
new_row
|
|
4591
|
-
+ voter
|
|
4592
|
-
+ [
|
|
4593
|
-
"%.1f min" % row[1],
|
|
4594
|
-
"%.3f %s" % (float(row[2]), hv.backed_token_symbol),
|
|
4595
|
-
"%.3f %s" % (float(row[3]), hv.backed_token_symbol),
|
|
4596
|
-
"%.3f %s" % (row[4], HP_symbol),
|
|
4597
|
-
"%.1f %%" % (row[5]),
|
|
4598
|
-
]
|
|
4599
|
-
)
|
|
4600
|
-
if len(authorperm_list) == 1:
|
|
4601
|
-
new_row = new_row2
|
|
4602
|
-
if not short and found_voter:
|
|
4603
|
-
t.add_row(new_row2 + voter2 + ["", "", "", "", ""])
|
|
4604
|
-
if sum_curation[0] > 0:
|
|
4605
|
-
curation_sum_percentage = sum_curation[3] / sum_curation[0] * 100
|
|
4422
|
+
show_all_voter = False
|
|
4423
|
+
if authorperm == "all" or authorperm.isdigit():
|
|
4424
|
+
if not account:
|
|
4425
|
+
account = hv.config["default_account"]
|
|
4426
|
+
# Using built-in timezone support
|
|
4427
|
+
# Respect CLI --days (help already documents max=7)
|
|
4428
|
+
_days = min(float(days), 7.0)
|
|
4429
|
+
limit_time = datetime.now(timezone.utc) - timedelta(days=_days)
|
|
4430
|
+
votes = AccountVotes(account, start=limit_time, blockchain_instance=hv)
|
|
4431
|
+
authorperm_list = [vote.authorperm for vote in votes]
|
|
4432
|
+
if authorperm.isdigit():
|
|
4433
|
+
if len(authorperm_list) < int(authorperm):
|
|
4434
|
+
raise ValueError(
|
|
4435
|
+
"Authorperm id must be lower than %d" % (len(authorperm_list) + 1)
|
|
4436
|
+
)
|
|
4437
|
+
authorperm_list = [authorperm_list[int(authorperm) - 1]]
|
|
4438
|
+
all_posts = False
|
|
4606
4439
|
else:
|
|
4607
|
-
|
|
4608
|
-
|
|
4609
|
-
|
|
4610
|
-
|
|
4611
|
-
|
|
4612
|
-
|
|
4613
|
-
|
|
4614
|
-
"
|
|
4615
|
-
"
|
|
4616
|
-
"
|
|
4617
|
-
"
|
|
4618
|
-
"
|
|
4440
|
+
all_posts = True
|
|
4441
|
+
else:
|
|
4442
|
+
authorperm_list = [authorperm]
|
|
4443
|
+
all_posts = False
|
|
4444
|
+
if (all_posts) and permlink:
|
|
4445
|
+
t = PrettyTable(
|
|
4446
|
+
[
|
|
4447
|
+
"Author",
|
|
4448
|
+
"permlink",
|
|
4449
|
+
"Voting time",
|
|
4450
|
+
"Vote",
|
|
4451
|
+
"Early vote loss",
|
|
4452
|
+
"Curation",
|
|
4453
|
+
"Performance",
|
|
4619
4454
|
]
|
|
4620
4455
|
)
|
|
4621
|
-
|
|
4622
|
-
|
|
4623
|
-
|
|
4624
|
-
|
|
4625
|
-
"
|
|
4626
|
-
"
|
|
4627
|
-
"
|
|
4628
|
-
"
|
|
4629
|
-
"
|
|
4456
|
+
t.align = "l"
|
|
4457
|
+
elif (all_posts) and title:
|
|
4458
|
+
t = PrettyTable(
|
|
4459
|
+
[
|
|
4460
|
+
"Author",
|
|
4461
|
+
"permlink",
|
|
4462
|
+
"Voting time",
|
|
4463
|
+
"Vote",
|
|
4464
|
+
"Early vote loss",
|
|
4465
|
+
"Curation",
|
|
4466
|
+
"Performance",
|
|
4630
4467
|
]
|
|
4631
4468
|
)
|
|
4632
|
-
|
|
4633
|
-
|
|
4634
|
-
|
|
4635
|
-
|
|
4636
|
-
|
|
4637
|
-
|
|
4638
|
-
|
|
4639
|
-
|
|
4640
|
-
|
|
4469
|
+
t.align = "l"
|
|
4470
|
+
elif all_posts:
|
|
4471
|
+
t = PrettyTable(
|
|
4472
|
+
["Author", "Voting time", "Vote", "Early vote loss", "Curation", "Performance"]
|
|
4473
|
+
)
|
|
4474
|
+
t.align = "l"
|
|
4475
|
+
elif (export) and permlink:
|
|
4476
|
+
t = PrettyTable(
|
|
4477
|
+
[
|
|
4478
|
+
"Author",
|
|
4479
|
+
"permlink",
|
|
4480
|
+
"Voter",
|
|
4481
|
+
"Voting time",
|
|
4482
|
+
"Vote",
|
|
4483
|
+
"Early vote loss",
|
|
4484
|
+
"Curation",
|
|
4485
|
+
"Performance",
|
|
4641
4486
|
]
|
|
4642
4487
|
)
|
|
4643
|
-
|
|
4644
|
-
|
|
4645
|
-
|
|
4646
|
-
|
|
4488
|
+
t.align = "l"
|
|
4489
|
+
elif (export) and title:
|
|
4490
|
+
t = PrettyTable(
|
|
4491
|
+
[
|
|
4492
|
+
"Author",
|
|
4493
|
+
"permlink",
|
|
4494
|
+
"Voter",
|
|
4495
|
+
"Voting time",
|
|
4496
|
+
"Vote",
|
|
4497
|
+
"Early vote loss",
|
|
4498
|
+
"Curation",
|
|
4499
|
+
"Performance",
|
|
4500
|
+
]
|
|
4501
|
+
)
|
|
4502
|
+
t.align = "l"
|
|
4503
|
+
elif export:
|
|
4504
|
+
t = PrettyTable(
|
|
4505
|
+
[
|
|
4506
|
+
"Author",
|
|
4507
|
+
"Voter",
|
|
4508
|
+
"Voting time",
|
|
4509
|
+
"Vote",
|
|
4510
|
+
"Early vote loss",
|
|
4511
|
+
"Curation",
|
|
4512
|
+
"Performance",
|
|
4513
|
+
]
|
|
4514
|
+
)
|
|
4515
|
+
t.align = "l"
|
|
4516
|
+
else:
|
|
4517
|
+
t = PrettyTable(
|
|
4518
|
+
["Voter", "Voting time", "Vote", "Early vote loss", "Curation", "Performance"]
|
|
4519
|
+
)
|
|
4520
|
+
t.align = "l"
|
|
4521
|
+
index = 0
|
|
4522
|
+
for authorperm in authorperm_list:
|
|
4523
|
+
index += 1
|
|
4524
|
+
comment = Comment(authorperm, blockchain_instance=hv)
|
|
4525
|
+
if payout is not None and comment.is_pending():
|
|
4526
|
+
payout = float(payout)
|
|
4527
|
+
elif payout is not None:
|
|
4528
|
+
payout = None
|
|
4529
|
+
curation_rewards_HBD = comment.get_curation_rewards(
|
|
4530
|
+
pending_payout_hbd=True, pending_payout_value=payout
|
|
4531
|
+
)
|
|
4532
|
+
curation_rewards_HP = comment.get_curation_rewards(
|
|
4533
|
+
pending_payout_hbd=False, pending_payout_value=payout
|
|
4534
|
+
)
|
|
4535
|
+
rows = []
|
|
4536
|
+
sum_curation = [0, 0, 0, 0]
|
|
4537
|
+
max_curation = [0, 0, 0, 0, 0, 0]
|
|
4538
|
+
highest_vote = [0, 0, 0, 0, 0, 0]
|
|
4539
|
+
for vote in comment.get_votes():
|
|
4540
|
+
vote_time = vote["time"]
|
|
4541
|
+
|
|
4542
|
+
vote_HBD = hv.rshares_to_token_backed_dollar(int(vote["rshares"]))
|
|
4543
|
+
curation_HBD = curation_rewards_HBD["active_votes"][vote["voter"]]
|
|
4544
|
+
curation_HP = curation_rewards_HP["active_votes"][vote["voter"]]
|
|
4545
|
+
if vote_HBD > 0:
|
|
4546
|
+
penalty = (comment.get_curation_penalty(vote_time=vote_time)) * vote_HBD
|
|
4547
|
+
performance = float(curation_HBD) / vote_HBD * 100
|
|
4548
|
+
else:
|
|
4549
|
+
performance = 0
|
|
4550
|
+
penalty = 0
|
|
4551
|
+
vote_befor_min = ((vote_time) - comment["created"]).total_seconds() / 60
|
|
4552
|
+
sum_curation[0] += vote_HBD
|
|
4553
|
+
sum_curation[1] += penalty
|
|
4554
|
+
sum_curation[2] += float(curation_HP)
|
|
4555
|
+
sum_curation[3] += float(curation_HBD)
|
|
4556
|
+
row = [
|
|
4557
|
+
vote["voter"],
|
|
4558
|
+
vote_befor_min,
|
|
4559
|
+
vote_HBD,
|
|
4560
|
+
penalty,
|
|
4561
|
+
float(curation_HP),
|
|
4562
|
+
performance,
|
|
4563
|
+
]
|
|
4564
|
+
|
|
4565
|
+
rows.append(row)
|
|
4566
|
+
sortedList = sorted(rows, key=lambda row: (row[1]), reverse=False)
|
|
4567
|
+
new_row = []
|
|
4568
|
+
new_row2 = []
|
|
4569
|
+
voter = []
|
|
4570
|
+
voter2 = []
|
|
4571
|
+
if (all_posts or export) and permlink:
|
|
4572
|
+
if length:
|
|
4573
|
+
new_row = [comment.author, comment.permlink[: int(length)]]
|
|
4574
|
+
else:
|
|
4575
|
+
new_row = [comment.author, comment.permlink]
|
|
4576
|
+
new_row2 = ["", ""]
|
|
4577
|
+
elif (all_posts or export) and title:
|
|
4578
|
+
if length:
|
|
4579
|
+
new_row = [comment.author, comment.title[: int(length)]]
|
|
4580
|
+
else:
|
|
4581
|
+
new_row = [comment.author, comment.title]
|
|
4582
|
+
new_row2 = ["", ""]
|
|
4583
|
+
elif all_posts or export:
|
|
4584
|
+
new_row = [comment.author]
|
|
4585
|
+
new_row2 = [""]
|
|
4586
|
+
if not all_posts:
|
|
4587
|
+
voter = [""]
|
|
4588
|
+
voter2 = [""]
|
|
4589
|
+
found_voter = False
|
|
4590
|
+
for row in sortedList:
|
|
4591
|
+
if limit is not None and row[1] > float(limit):
|
|
4592
|
+
continue
|
|
4593
|
+
if min_vote is not None and float(row[2]) < float(min_vote):
|
|
4594
|
+
continue
|
|
4595
|
+
if max_vote is not None and float(row[2]) > float(max_vote):
|
|
4596
|
+
continue
|
|
4597
|
+
if min_performance is not None and float(row[5]) < float(min_performance):
|
|
4598
|
+
continue
|
|
4599
|
+
if max_performance is not None and float(row[5]) > float(max_performance):
|
|
4600
|
+
continue
|
|
4601
|
+
if row[-1] > max_curation[-1]:
|
|
4602
|
+
max_curation = row
|
|
4603
|
+
if row[2] > highest_vote[2]:
|
|
4604
|
+
highest_vote = row
|
|
4605
|
+
if show_all_voter or account == row[0]:
|
|
4606
|
+
if not all_posts:
|
|
4607
|
+
voter = [row[0]]
|
|
4608
|
+
if all_posts:
|
|
4609
|
+
new_row[0] = "%d. %s" % (index, comment.author)
|
|
4610
|
+
if not found_voter:
|
|
4611
|
+
found_voter = True
|
|
4612
|
+
t.add_row(
|
|
4613
|
+
new_row
|
|
4614
|
+
+ voter
|
|
4615
|
+
+ [
|
|
4616
|
+
"%.1f min" % row[1],
|
|
4617
|
+
"%.3f %s" % (float(row[2]), hv.backed_token_symbol),
|
|
4618
|
+
"%.3f %s" % (float(row[3]), hv.backed_token_symbol),
|
|
4619
|
+
"%.3f %s" % (row[4], HP_symbol),
|
|
4620
|
+
"%.1f %%" % (row[5]),
|
|
4621
|
+
]
|
|
4622
|
+
)
|
|
4623
|
+
if len(authorperm_list) == 1:
|
|
4624
|
+
new_row = new_row2
|
|
4625
|
+
if not short and found_voter:
|
|
4626
|
+
t.add_row(new_row2 + voter2 + ["", "", "", "", ""])
|
|
4627
|
+
if sum_curation[0] > 0:
|
|
4628
|
+
curation_sum_percentage = sum_curation[3] / sum_curation[0] * 100
|
|
4629
|
+
else:
|
|
4630
|
+
curation_sum_percentage = 0
|
|
4631
|
+
sum_line = new_row2 + voter2
|
|
4632
|
+
sum_line[-1] = "High. vote"
|
|
4633
|
+
|
|
4634
|
+
t.add_row(
|
|
4635
|
+
sum_line
|
|
4636
|
+
+ [
|
|
4637
|
+
"%.1f min" % highest_vote[1],
|
|
4638
|
+
"%.3f %s" % (float(highest_vote[2]), hv.backed_token_symbol),
|
|
4639
|
+
"%.3f %s" % (float(highest_vote[3]), hv.backed_token_symbol),
|
|
4640
|
+
"%.3f %s" % (highest_vote[4], HP_symbol),
|
|
4641
|
+
"%.1f %%" % (highest_vote[5]),
|
|
4642
|
+
]
|
|
4643
|
+
)
|
|
4644
|
+
sum_line[-1] = "High. Cur."
|
|
4645
|
+
t.add_row(
|
|
4646
|
+
sum_line
|
|
4647
|
+
+ [
|
|
4648
|
+
"%.1f min" % max_curation[1],
|
|
4649
|
+
"%.3f %s" % (float(max_curation[2]), hv.backed_token_symbol),
|
|
4650
|
+
"%.3f %s" % (float(max_curation[3]), hv.backed_token_symbol),
|
|
4651
|
+
"%.3f %s" % (max_curation[4], HP_symbol),
|
|
4652
|
+
"%.1f %%" % (max_curation[5]),
|
|
4653
|
+
]
|
|
4654
|
+
)
|
|
4655
|
+
sum_line[-1] = "Sum"
|
|
4656
|
+
t.add_row(
|
|
4657
|
+
sum_line
|
|
4658
|
+
+ [
|
|
4659
|
+
"-",
|
|
4660
|
+
"%.3f %s" % (sum_curation[0], hv.backed_token_symbol),
|
|
4661
|
+
"%.3f %s" % (sum_curation[1], hv.backed_token_symbol),
|
|
4662
|
+
"%.3f %s" % (sum_curation[2], HP_symbol),
|
|
4663
|
+
"%.2f %%" % curation_sum_percentage,
|
|
4664
|
+
]
|
|
4665
|
+
)
|
|
4666
|
+
if all_posts or export:
|
|
4667
|
+
t.add_row(new_row2 + voter2 + ["-", "-", "-", "-", "-"])
|
|
4668
|
+
if not (all_posts or export):
|
|
4669
|
+
print("curation for %s" % (authorperm))
|
|
4670
|
+
print(t)
|
|
4671
|
+
if export:
|
|
4672
|
+
with open(export, "w") as w:
|
|
4673
|
+
w.write(str(t.get_html_string()))
|
|
4674
|
+
elif all_posts:
|
|
4675
|
+
print("curation for @%s" % account)
|
|
4647
4676
|
print(t)
|
|
4648
|
-
|
|
4649
|
-
|
|
4650
|
-
|
|
4651
|
-
elif all_posts:
|
|
4652
|
-
print("curation for @%s" % account)
|
|
4653
|
-
print(t)
|
|
4677
|
+
except Exception as e:
|
|
4678
|
+
print(str(e))
|
|
4679
|
+
raise e
|
|
4654
4680
|
|
|
4655
4681
|
|
|
4656
4682
|
@cli.command()
|