diff --git a/.replit b/.replit new file mode 100644 index 0000000000000000000000000000000000000000..6e7a0f4a86f59801225cfd87276c4bf162ba529a --- /dev/null +++ b/.replit @@ -0,0 +1,2 @@ +language = "python3" +run = "python beem/cli.py" diff --git a/README.rst b/README.rst index a6983b02c15205a817adddf7315af32334bfd99d..8347b2a6ecc53b2f80162ee660e2e1a96522f32e 100644 --- a/README.rst +++ b/README.rst @@ -21,6 +21,9 @@ The library name is derived from a beam machine, similar to the analogy between :target: https://anaconda.org/conda-forge/beem +.. image:: https://repl.it/badge/github/holgern/beem + :target: https://repl.it/github/holgern/beem + Current build status -------------------- diff --git a/beem/cli.py b/beem/cli.py index d7ef2099815575e978b4ddc110e2889ef6b302d7..cfe314f37007556eb9f4879269f7a3b661a91faf 100644 --- a/beem/cli.py +++ b/beem/cli.py @@ -4366,12 +4366,12 @@ def featureflags(account, signing_account): @click.option('--draws', '-d', help='Number of draws (default = 1)', default=1) @click.option('--participants', '-p', help='Number of participants or file name including participants (one participant per line), (default = 100)', default="100") @click.option('--hashtype', '-h', help='Can be md5, sha256, sha512 (default = sha256)', default="sha256") -@click.option('--seperator', '-s', help='Is used for sha256 and sha512 to seperate the draw number from the seed (default = ,)', default=",") +@click.option('--separator', '-s', help='Is used for sha256 and sha512 to seperate the draw number from the seed (default = ,)', default=",") @click.option('--account', '-a', help='The account which broadcasts the reply') @click.option('--reply', '-r', help='Parent post/comment authorperm. When set, the results will be broadcasted as reply to this authorperm.', default=None) @click.option('--without-replacement', '-w', help='When set, numbers are drawed without replacement.', is_flag=True, default=False) @click.option('--markdown', '-m', help='When set, results are returned in markdown format', is_flag=True, default=False) -def draw(block, trx_id, draws, participants, hashtype, seperator, account, reply, without_replacement, markdown): +def draw(block, trx_id, draws, participants, hashtype, separator, account, reply, without_replacement, markdown): """ Generate pseudo-random numbers based on trx id, block id and previous block id. When using --reply, the result is directly broadcasted as comment @@ -4391,12 +4391,15 @@ def draw(block, trx_id, draws, participants, hashtype, seperator, account, reply blockchain = Blockchain(blockchain_instance=stm) block = blockchain.get_current_block() data = None + for trx in block.transactions: if trx["transaction_id"] == trx_id: data = trx elif trx_id is None: trx_id = trx["transaction_id"] data = trx + if trx_id is None: + trx_id = "0" if os.path.exists(participants): with open(participants) as f: @@ -4437,11 +4440,11 @@ def draw(block, trx_id, draws, participants, hashtype, seperator, account, reply if hashtype == "md5": number = int(random.random() * len(draw_list)) elif hashtype == "sha256": - seed = hashlib.sha256((trx_id + block["block_id"] + block["previous"] + seperator +str(i + 1)).encode()).digest() + seed = hashlib.sha256((trx_id + block["block_id"] + block["previous"] + separator +str(i + 1)).encode()).digest() bigRand = int.from_bytes(seed, 'big') number = bigRand % (len(draw_list)) elif hashtype == "sha512": - seed = hashlib.sha512((trx_id + block["block_id"] + block["previous"] + seperator +str(i + 1)).encode()).digest() + seed = hashlib.sha512((trx_id + block["block_id"] + block["previous"] + separator +str(i + 1)).encode()).digest() bigRand = int.from_bytes(seed, 'big') number = bigRand % (len(draw_list)) results.append(draw_list[number]) @@ -4455,9 +4458,9 @@ def draw(block, trx_id, draws, participants, hashtype, seperator, account, reply body = "The following results can be checked with:\n" body += "```\n" if without_replacement: - body += "beempy draw -d %d -p %d -b %d -t %s -h %s -s '%s' -w\n" % (draws, participants, block["id"], trx_id, hashtype, seperator) + body += "beempy draw -d %d -p %d -b %d -t %s -h %s -s '%s' -w\n" % (draws, participants, block["id"], trx_id, hashtype, separator) else: - body += "beempy draw -d %d -p %d -b %d -t %s -h %s -s '%s'\n" % (draws, participants, block["id"], trx_id, hashtype, seperator) + body += "beempy draw -d %d -p %d -b %d -t %s -h %s -s '%s'\n" % (draws, participants, block["id"], trx_id, hashtype, separator) body += "```\n\n" body += "| key | value |\n" body += "| --- | --- |\n" diff --git a/beem/version.py b/beem/version.py index 6788b51818eec29ec0e6ba23ee56c5d0a94c6aa7..07b16fba34655a7118fbf372d2c7b1f15cf8f6ba 100644 --- a/beem/version.py +++ b/beem/version.py @@ -1,2 +1,2 @@ """THIS FILE IS GENERATED FROM beem SETUP.PY.""" -version = '0.23.11' +version = '0.23.12' diff --git a/beemapi/version.py b/beemapi/version.py index 6788b51818eec29ec0e6ba23ee56c5d0a94c6aa7..07b16fba34655a7118fbf372d2c7b1f15cf8f6ba 100644 --- a/beemapi/version.py +++ b/beemapi/version.py @@ -1,2 +1,2 @@ """THIS FILE IS GENERATED FROM beem SETUP.PY.""" -version = '0.23.11' +version = '0.23.12' diff --git a/beembase/version.py b/beembase/version.py index 6788b51818eec29ec0e6ba23ee56c5d0a94c6aa7..07b16fba34655a7118fbf372d2c7b1f15cf8f6ba 100644 --- a/beembase/version.py +++ b/beembase/version.py @@ -1,2 +1,2 @@ """THIS FILE IS GENERATED FROM beem SETUP.PY.""" -version = '0.23.11' +version = '0.23.12' diff --git a/beemgraphenebase/version.py b/beemgraphenebase/version.py index 6788b51818eec29ec0e6ba23ee56c5d0a94c6aa7..07b16fba34655a7118fbf372d2c7b1f15cf8f6ba 100644 --- a/beemgraphenebase/version.py +++ b/beemgraphenebase/version.py @@ -1,2 +1,2 @@ """THIS FILE IS GENERATED FROM beem SETUP.PY.""" -version = '0.23.11' +version = '0.23.12' diff --git a/setup.py b/setup.py index 83a7359ae192108454f1bee6d35d1bd1d9b90842..354f6dd84b0e11407db00eb03c876ea817e328a8 100755 --- a/setup.py +++ b/setup.py @@ -16,7 +16,7 @@ except LookupError: ascii = codecs.lookup('ascii') codecs.register(lambda name, enc=ascii: {True: enc}.get(name == 'mbcs')) -VERSION = '0.23.11' +VERSION = '0.23.12' tests_require = ['mock >= 2.0.0', 'pytest', 'pytest-mock', 'parameterized']