Skip to content

Commit

Permalink
Support testnet mempool visualization
Browse files Browse the repository at this point in the history
  • Loading branch information
romanz committed Aug 14, 2018
1 parent 0f02dfd commit 2e6554c
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions tools/mempool.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env python3
import argparse
import binascii
import json
import os
Expand All @@ -8,7 +9,7 @@
import matplotlib.pyplot as plt

class Daemon:
def __init__(self, port=8332, cookie_dir='~/.bitcoin'):
def __init__(self, port, cookie_dir):
self.sock = socket.create_connection(('localhost', port))
self.fd = self.sock.makefile()
path = os.path.join(os.path.expanduser(cookie_dir), '.cookie')
Expand Down Expand Up @@ -45,7 +46,15 @@ def request(self, method, params_list):


def main():
d = Daemon()
parser = argparse.ArgumentParser()
parser.add_argument('--testnet', action='store_true')
args = parser.parse_args()

if args.testnet:
d = Daemon(port=18332, cookie_dir='~/.bitcoin/testnet3')
else:
d = Daemon(port=8332, cookie_dir='~/.bitcoin')

txids, = d.request('getrawmempool', [[False]])
txids = list(map(lambda a: [a], txids))

Expand Down

0 comments on commit 2e6554c

Please sign in to comment.