Created
February 17, 2016 17:22
-
-
Save bitcartel/96769cf2017e401d2015 to your computer and use it in GitHub Desktop.
explorer patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
now = time.time() - EPOCH1970 | |
mempool = abe.store.get_rawmempool(chain) | |
print "RawMemPool = {}".format(mempool) | |
recenttx = abe.store.list_transactions(chain, 30) # we only want 'send' category, not 'receive' or 'move' | |
print "JSON-RPC Recent Tx = {}".format(recenttx) | |
sorted_mempool = sorted(mempool.items()[:10], key=lambda tup: tup[1]['time'], reverse=True) | |
print "1. Length of sorted mempool = {}".format(len(sorted_mempool)) | |
if len(sorted_mempool) < 10: | |
recenttx = filter(lambda x: x['category'] == 'send' and x['confirmations']>-1, recenttx) | |
# recenttx = [tx for tx in recenttx if tx['category']=='send'] | |
sorted_recenttx = sorted(recenttx, key=lambda tx: tx['time'], reverse=True) | |
existing_txids = [txid for (txid, value) in sorted_mempool] | |
for tx in sorted_recenttx: | |
if len(sorted_mempool) == 10: | |
break | |
if tx['txid'] not in existing_txids: | |
existing_txids.append(tx['txid']) | |
sorted_mempool.append((tx['txid'], tx)) | |
print "2. Length of sorted mempool = {}".format(len(sorted_mempool)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment