diff --git a/tinman/constants.py b/tinman/constants.py new file mode 100644 index 0000000..b5ce547 --- /dev/null +++ b/tinman/constants.py @@ -0,0 +1,37 @@ +# This Python file uses the following encoding: utf-8 + + +MAINNET_PREFIX = "STM" +TESTNET_PREFIX = "TST" +PUB_KEY_LEN = 53 +MAINNET_DISABLED_WITNESS_KEY = "STM1111111111111111111111111111111114T1Anm" +TESTNET_DISABLED_WITNESS_KEY = "TST1111111111111111111111111111111114T1Anm" + + +""" +Whitelist of exceptions from transaction source (Mainnet)." +""" + +TRANSACTION_SOURCE_RETRYABLE_ERRORS = [ + "Unable to acquire database lock", + "Internal Error", + "Server error", + "Upstream response error" +] + +MAX_RETRY = 30 + +DATABASE_API_SINGLE_QUERY_LIMIT = 1000 + +ACTIONS_MAJOR_VERSION_SUPPORTED = 0 +ACTIONS_MINOR_VERSION_SUPPORTED = 2 + + +SNAPSHOT_MAJOR_VERSION_SUPPORTED = 0 +SNAPSHOT_MINOR_VERSION_SUPPORTED = 2 +STEEM_GENESIS_TIMESTAMP = 1451606400 +STEEM_BLOCK_INTERVAL = 3 +NUM_BLOCKS_TO_CLEAR_WITNESS_ROUND = 21 +TRANSACTION_WITNESS_SETUP_PAD = 100 +STEEM_MAX_AUTHORITY_MEMBERSHIP = 10 +DENOM = 10**12 # we need stupidly high precision because VESTS \ No newline at end of file diff --git a/tinman/gatling.py b/tinman/gatling.py index d36e7be..db9b908 100755 --- a/tinman/gatling.py +++ b/tinman/gatling.py @@ -9,15 +9,8 @@ from . import prockey from . import util -# Whitelist of exceptions from transaction source (Mainnet). -TRANSACTION_SOURCE_RETRYABLE_ERRORS = [ - "Unable to acquire database lock", - "Internal Error", - "Server error", - "Upstream response error" -] +from tinman.constants import MAX_RETRY, TRANSACTION_SOURCE_RETRYABLE_ERRORS -MAX_RETRY = 30 def str2bool(str_arg): """ diff --git a/tinman/prefixsub.py b/tinman/prefixsub.py index 37e8c29..93255a4 100644 --- a/tinman/prefixsub.py +++ b/tinman/prefixsub.py @@ -7,11 +7,9 @@ import sys import math -MAINNET_PREFIX = "STM" -TESTNET_PREFIX = "TST" -PUB_KEY_LEN = 53 -MAINNET_DISABLED_WITNESS_KEY = "STM1111111111111111111111111111111114T1Anm" -TESTNET_DISABLED_WITNESS_KEY = "TST1111111111111111111111111111111114T1Anm" +from tinman.constants import MAINNET_PREFIX, TESTNET_PREFIX, PUB_KEY_LEN, MAINNET_DISABLED_WITNESS_KEY,\ + TESTNET_DISABLED_WITNESS_KEY + def transform_prefix(object): if isinstance(object, list): @@ -37,6 +35,7 @@ def transform_prefix(object): else: return object + def main(argv): parser = argparse.ArgumentParser(prog=argv[0], description="Substitute prefix") parser.add_argument("-i", "--input-file", default="-", dest="input_file", metavar="FILE", help="File to read actions from") @@ -75,5 +74,6 @@ def main(argv): if args.output_file != "-": output_file.close() + if __name__ == "__main__": main(sys.argv) diff --git a/tinman/simple_steem_client b/tinman/simple_steem_client new file mode 160000 index 0000000..1fb4ef5 --- /dev/null +++ b/tinman/simple_steem_client @@ -0,0 +1 @@ +Subproject commit 1fb4ef5a53cff992a2f3de2b88d2129678194971 diff --git a/tinman/snapshot.py b/tinman/snapshot.py index f630fb2..b039fad 100755 --- a/tinman/snapshot.py +++ b/tinman/snapshot.py @@ -11,17 +11,8 @@ from simple_steem_client.client import SteemRemoteBackend, SteemInterface, SteemRPCException from . import __version__ +from tinman.constants import DATABASE_API_SINGLE_QUERY_LIMIT, MAX_RETRY, TRANSACTION_SOURCE_RETRYABLE_ERRORS -DATABASE_API_SINGLE_QUERY_LIMIT = 1000 -MAX_RETRY = 30 - -# Whitelist of exceptions from transaction source (Mainnet). -TRANSACTION_SOURCE_RETRYABLE_ERRORS = [ - "Unable to acquire database lock", - "Internal Error", - "Server error", - "Upstream response error" -] def list_all_accounts(steemd): """ Generator function providing set of accounts existing in the Main Steem net """ diff --git a/tinman/submit.py b/tinman/submit.py index 3db4eea..255a444 100755 --- a/tinman/submit.py +++ b/tinman/submit.py @@ -14,11 +14,9 @@ import sys import time import traceback - from . import util +from tinman.constants import ACTIONS_MAJOR_VERSION_SUPPORTED, ACTIONS_MINOR_VERSION_SUPPORTED -ACTIONS_MAJOR_VERSION_SUPPORTED = 0 -ACTIONS_MINOR_VERSION_SUPPORTED = 2 class TransactionSigner(object): def __init__(self, sign_transaction_exe=None, chain_id=None): @@ -37,6 +35,7 @@ def sign_transaction(self, tx, wif): line = self.proc.stdout.readline().decode("utf-8") return json.loads(line) + class CachedDgpo(object): def __init__(self, timefunc=time.time, refresh_interval=1.0, steemd=None): self.timefunc = timefunc @@ -111,6 +110,7 @@ def generate_blocks(steemd, args, cached_dgpo=None, now=None, produce_realtime=F ) return + def main(argv): parser = argparse.ArgumentParser(prog=argv[0], description="Submit transactions to Steem") diff --git a/tinman/txgen.py b/tinman/txgen.py index 860c96d..73f58db 100755 --- a/tinman/txgen.py +++ b/tinman/txgen.py @@ -21,15 +21,10 @@ from . import __version__ from . import prockey from . import util +from tinman.constants import SNAPSHOT_MAJOR_VERSION_SUPPORTED, SNAPSHOT_MINOR_VERSION_SUPPORTED, STEEM_GENESIS_TIMESTAMP, \ + STEEM_BLOCK_INTERVAL, NUM_BLOCKS_TO_CLEAR_WITNESS_ROUND, TRANSACTION_WITNESS_SETUP_PAD, \ + STEEM_MAX_AUTHORITY_MEMBERSHIP, DENOM -SNAPSHOT_MAJOR_VERSION_SUPPORTED = 0 -SNAPSHOT_MINOR_VERSION_SUPPORTED = 2 -STEEM_GENESIS_TIMESTAMP = 1451606400 -STEEM_BLOCK_INTERVAL = 3 -NUM_BLOCKS_TO_CLEAR_WITNESS_ROUND = 21 -TRANSACTION_WITNESS_SETUP_PAD = 100 -STEEM_MAX_AUTHORITY_MEMBERSHIP = 10 -DENOM = 10**12 # we need stupidly high precision because VESTS def create_system_accounts(conf, keydb, name): desc = conf["accounts"][name] @@ -53,6 +48,7 @@ def create_system_accounts(conf, keydb, name): return + def vote_accounts(conf, keydb, elector, elected): er_desc = conf["accounts"][elector] ed_desc = conf["accounts"][elected]