diff --git a/beem/account.py b/beem/account.py index 578cc9257c2479444b05df4aa5943257c1b4a9af..4b54b85ac54ee98c783d218be93fdc2f01e8260e 100644 --- a/beem/account.py +++ b/beem/account.py @@ -21,6 +21,7 @@ from beem.amount import Amount from beembase import operations from beemgraphenebase.account import PrivateKey, PublicKey from beemgraphenebase.py23 import bytes_types, integer_types, string_types, text_type +from beem.constants import STEEM_VOTE_REGENERATION_SECONDS log = logging.getLogger(__name__) @@ -285,7 +286,7 @@ class Account(BlockchainObject): if with_regeneration: utc = pytz.timezone('UTC') diff_in_seconds = (utc.localize(datetime.utcnow()) - (self["last_vote_time"])).total_seconds() - regenerated_vp = diff_in_seconds * 10000 / 86400 / 5 / 100 + regenerated_vp = diff_in_seconds * 10000 / STEEM_VOTE_REGENERATION_SECONDS / 100 else: regenerated_vp = 0 total_vp = (self["voting_power"] / 100 + regenerated_vp) @@ -334,7 +335,7 @@ class Account(BlockchainObject): missing_vp = voting_power_goal - self.get_voting_power() if missing_vp < 0: return 0 - recharge_seconds = missing_vp * 100 * 5 * 86400 / 10000 + recharge_seconds = missing_vp * 100 * STEEM_VOTE_REGENERATION_SECONDS / 10000 return timedelta(seconds=recharge_seconds) def get_recharge_time(self, voting_power_goal=100): diff --git a/beem/comment.py b/beem/comment.py index cd3b570b07ed1e2de469bb588a981319649cb308..7ec2507a75de8d38f5545681acb68332a56f910a 100644 --- a/beem/comment.py +++ b/beem/comment.py @@ -19,6 +19,7 @@ from .blockchainobject import BlockchainObject from .exceptions import ContentDoesNotExistsException, VotingInvalidOnArchivedPost from beembase import operations from beemgraphenebase.py23 import py23_bytes, bytes_types, integer_types, string_types, text_type +from beem.constants import STEEM_REVERSE_AUCTION_WINDOW_SECONDS, STEEM_100_PERCENT, STEEM_1_PERCENT log = logging.getLogger(__name__) @@ -291,7 +292,7 @@ class Comment(BlockchainObject): elapsed_seconds = (vote_time - self["created"]).total_seconds() else: raise ValueError("vote_time must be a string or a datetime") - reward = (elapsed_seconds / 1800) + reward = (elapsed_seconds / STEEM_REVERSE_AUCTION_WINDOW_SECONDS) if reward > 1: reward = 1.0 return 1.0 - reward @@ -537,16 +538,6 @@ class Comment(BlockchainObject): else: [post_author, post_permlink] = resolve_authorperm(identifier) - steem_conf = self.steem.get_config() - if 'STEEMIT_100_PERCENT' in steem_conf: - STEEM_100_PERCENT = steem_conf['STEEMIT_100_PERCENT'] - STEEM_1_PERCENT = steem_conf['STEEMIT_1_PERCENT'] - elif 'STEEM_100_PERCENT' in steem_conf: - STEEM_100_PERCENT = steem_conf['STEEM_100_PERCENT'] - STEEM_1_PERCENT = steem_conf['STEEM_1_PERCENT'] - else: - STEEM_100_PERCENT = 10000 - STEEM_1_PERCENT = (STEEM_100_PERCENT / 100) vote_weight = int(weight * STEEM_1_PERCENT) if vote_weight > STEEM_100_PERCENT: vote_weight = STEEM_100_PERCENT diff --git a/beem/constants.py b/beem/constants.py new file mode 100644 index 0000000000000000000000000000000000000000..d51c0186b525205233d4b0640773d71d31ac8c1d --- /dev/null +++ b/beem/constants.py @@ -0,0 +1,13 @@ +# This Python file uses the following encoding: utf-8 +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function +from __future__ import unicode_literals + + +STEEM_100_PERCENT = 10000 +STEEM_1_PERCENT = 100 +STEEM_1_TENTH_PERCENT = 10 +STEEM_REVERSE_AUCTION_WINDOW_SECONDS = 1800 +STEEM_VOTE_REGENERATION_SECONDS = 432000 +STEEM_ROOT_POST_PARENT = '' diff --git a/beem/steem.py b/beem/steem.py index 881a37a83ad7df80e3501d91c769b77dc01c3155..8f6fe4e3724092fe1a08297e0d15fccc142ebdb0 100644 --- a/beem/steem.py +++ b/beem/steem.py @@ -28,6 +28,7 @@ from .exceptions import ( from .wallet import Wallet from .transactionbuilder import TransactionBuilder from .utils import formatTime, resolve_authorperm, derive_permlink, remove_from_dict +from beem.constants import STEEM_VOTE_REGENERATION_SECONDS log = logging.getLogger(__name__) @@ -491,7 +492,7 @@ class Steem(object): # get props global_properties = self.get_dynamic_global_properties() vote_power_reserve_rate = global_properties['vote_power_reserve_rate'] - max_vote_denom = vote_power_reserve_rate * (5 * 60 * 60 * 24) + max_vote_denom = vote_power_reserve_rate * STEEM_VOTE_REGENERATION_SECONDS return max_vote_denom def _calc_resulting_vote(self, voting_power=10000, vote_pct=10000): diff --git a/examples/benchmark_nodes2.py b/examples/benchmark_nodes2.py index 0417a7c5bb77df1d01237c8b3ae471eef62ff377..0e28887971e70c9b403d74d1fe7637d08effbc4d 100644 --- a/examples/benchmark_nodes2.py +++ b/examples/benchmark_nodes2.py @@ -16,7 +16,7 @@ from beem.steem import Steem from beem.utils import parse_time, formatTimedelta, get_node_list, construct_authorperm, resolve_authorperm, resolve_authorpermvoter, construct_authorpermvoter from beem.comment import Comment from beem.vote import Vote -from beemgrapheneapi.rpcutils import NumRetriesReached +from beemapi.exceptions import NumRetriesReached FUTURES_MODULE = None if not FUTURES_MODULE: try: @@ -33,6 +33,7 @@ def benchmark_node(node, how_many_minutes=10, how_many_seconds=30): block_count = 0 history_count = 0 access_time = 0 + follow_time = 0 blockchain_version = u'0.0.0' sucessfull = False error_msg = None @@ -92,7 +93,11 @@ def benchmark_node(node, how_many_minutes=10, how_many_seconds=30): Account(author, steem_instance=stm) stop = timer() account_time = stop - start - access_time = (vote_time + comment_time + account_time) / 3.0 + start = timer() + account.get_followers() + stop = timer() + follow_time = stop - start + access_time = (vote_time + comment_time + account_time + follow_time) / 4.0 sucessfull = True except NumRetriesReached: error_msg = 'NumRetriesReached' @@ -103,7 +108,7 @@ def benchmark_node(node, how_many_minutes=10, how_many_seconds=30): error_msg = str(e) return {'sucessfull': sucessfull, 'node': node, 'error': error_msg, 'total_duration': timer() - start_total, 'block_count': block_count, - 'history_count': history_count, 'access_time': access_time, + 'history_count': history_count, 'access_time': access_time, 'follow_time': follow_time, 'version': blockchain_version}