Only open contract storage for operations that need it

pull/12/head
Bernhard Mueller 7 years ago
parent 1b56bacc91
commit 1d64166351
  1. 54
      myth

54
myth

@ -64,8 +64,6 @@ try:
except KeyError: except KeyError:
db_dir = None db_dir = None
contract_storage = get_persistent_storage(db_dir)
args = parser.parse_args() args = parser.parse_args()
if (args.v): if (args.v):
@ -155,34 +153,36 @@ elif (args.trace):
else: else:
print(str(i['pc']) + " " + i['op'] + ";\tSTACK: " + i['stack']) print(str(i['pc']) + " " + i['op'] + ";\tSTACK: " + i['stack'])
elif (args.search): else:
contract_storage = get_persistent_storage(db_dir)
if (args.search):
try: try:
contract_storage.search(args.search, searchCallback) contract_storage.search(args.search, searchCallback)
except SyntaxError: except SyntaxError:
exitWithError("Syntax error in search expression.") exitWithError("Syntax error in search expression.")
elif (args.xrefs): elif (args.xrefs):
try: try:
contract_hash = util.safe_decode(args.xrefs) contract_hash = util.safe_decode(args.xrefs)
except binascii.Error: except binascii.Error:
exitWithError("Invalid contract hash.") exitWithError("Invalid contract hash.")
try: try:
contract = contract_storage.get_contract_by_hash(contract_hash) contract = contract_storage.get_contract_by_hash(contract_hash)
print("\n".join(contract.get_xrefs())) print("\n".join(contract.get_xrefs()))
except KeyError: except KeyError:
exitWithError("Contract not found in the database.") exitWithError("Contract not found in the database.")
elif (args.init_db):
if args.ipc:
contract_storage.initialize(args.rpchost, args.rpcport, args.sync_all, args.ipc)
else:
contract_storage.initialize(args.rpchost, args.rpcport, args.sync_all, args.ipc)
elif (args.hash): elif (args.init_db):
print("0x" + utils.sha3(args.hash)[:4].hex()) if args.ipc:
contract_storage.initialize(args.rpchost, args.rpcport, args.sync_all, args.ipc)
else:
contract_storage.initialize(args.rpchost, args.rpcport, args.sync_all, args.ipc)
else: elif (args.hash):
parser.print_help() print("0x" + utils.sha3(args.hash)[:4].hex())
else:
parser.print_help()

Loading…
Cancel
Save