diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 0449525ceec96e1249e88663a94bc114194d70e6..2e50b0320d8b1c1c2566018338db067dd8efdc7e 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,5 +1,11 @@ Changelog ======== +0.24.21 +------- +* Fix bug in ecda (convert mpz into int when not supported) +* add coinactivity example script +* PR #272: correct blockchain virtual op batch calls (thanks to @crokkon) + 0.24.20 ------- * New hive node has been added (https://hived.emre.sh) diff --git a/beemgraphenebase/ecdsasig.py b/beemgraphenebase/ecdsasig.py index d7deb97abed258576377b0486453fea0102623d0..42bc7805ee42a601e4c065eab2ef99a33a1ab925 100644 --- a/beemgraphenebase/ecdsasig.py +++ b/beemgraphenebase/ecdsasig.py @@ -101,7 +101,11 @@ def recover_public_key(digest, signature, i, message=None): Q_point = Q.to_affine() public_key = ec.EllipticCurvePublicNumbers(Q_point.x(), Q_point.y(), ec.SECP256K1()).public_key(default_backend()) except: - public_key = ec.EllipticCurvePublicNumbers(Q._Point__x, Q._Point__y, ec.SECP256K1()).public_key(default_backend()) + try: + public_key = ec.EllipticCurvePublicNumbers(Q._Point__x, Q._Point__y, ec.SECP256K1()).public_key(default_backend()) + except: + Q_point = Q.to_affine() + public_key = ec.EllipticCurvePublicNumbers(int(Q_point.x()), int(Q_point.y()), ec.SECP256K1()).public_key(default_backend()) public_key.verify(sigder, message, ec.ECDSA(hashes.SHA256())) return public_key else: diff --git a/examples/blockactivity.py b/examples/blockactivity.py index ebff3af241fe3c8e25af846fc46c9ff33f684374..972a98f13fdead8f3ae77f444a5e4b4e9a93fba7 100644 --- a/examples/blockactivity.py +++ b/examples/blockactivity.py @@ -57,11 +57,13 @@ def main(args=None): print(blk_inst) block_count = 0 total_ops = 0 + total_virtual_ops = 0 total_trx = 0 blocksperday = 20 * 60 * 24 - blockchain = Blockchain(blockchain_instance=blk_inst) - last_block_id = blockchain.get_current_block_num() - blocksperday + blockchain = Blockchain(blockchain_instance=blk_inst, ) + current_block_num = blockchain.get_current_block_num() + last_block_id = current_block_num - blocksperday last_block = Block(last_block_id, blockchain_instance=blk_inst) @@ -69,6 +71,12 @@ def main(args=None): start = timer() for entry in blockchain.blocks(start=last_block_id, max_batch_size=max_batch_size, threading=threading, thread_num=thread_num): + if "block" in entry: + block_time = parse_time(entry["block"]["timestamp"]) + else: + block_time = entry["timestamp"] + if block_time > stopTime: + break block_count += 1 if "block" in entry: trxs = entry["block"]["transactions"] @@ -78,20 +86,31 @@ def main(args=None): total_trx += 1 for op in tx["operations"]: total_ops += 1 - if "block" in entry: - block_time = parse_time(entry["block"]["timestamp"]) - else: - block_time = entry["timestamp"] + ops_per_day = total_ops / block_count * blocksperday if block_count % (block_debug) == 0: print("%d blocks remaining... estimated ops per day: %.1f" % (blocksperday - block_count, ops_per_day)) - if block_time > stopTime: - break + duration = timer() - start + + stopTime = last_block.time() + timedelta(seconds=60 * 60 * 24) + start = timer() + for entry in blockchain.blocks(start=last_block_id, max_batch_size=max_batch_size, threading=threading, thread_num=thread_num, only_virtual_ops=True): + block_time = entry["timestamp"] + if block_time > stopTime: + break + for tx in entry["operations"]: + for op in tx["op"]: + total_virtual_ops += 1 + + duration = timer() - start + + print("Received %.2f blocks/s." % (block_count / duration)) print("Bocks: %d, duration %.3f s" % (block_count, duration)) print("Operations per day: %d" % total_ops) print("Trx per day: %d" % total_trx) + print("Virtual Operations per day: %d" % total_virtual_ops) if __name__ == '__main__': sys.exit(main())