From 5fb04b699bc2ffdd048cd9e7257201e2454a14f1 Mon Sep 17 00:00:00 2001 From: Chris Pacia Date: Thu, 10 Nov 2016 17:50:17 -0500 Subject: [PATCH 1/2] Add cmd line flag to disable audit log --- market/audit.py | 5 ++++- market/network.py | 4 ++-- market/protocol.py | 4 ++-- openbazaard.py | 8 +++++--- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/market/audit.py b/market/audit.py index e8a0bd83..f535910e 100644 --- a/market/audit.py +++ b/market/audit.py @@ -8,8 +8,9 @@ class Audit(object): A class for handling audit information """ - def __init__(self, db): + def __init__(self, db, enabled=True): self.db = db + self.enabled = enabled self.log = Logger(system=self) @@ -23,6 +24,8 @@ def __init__(self, db): } def record(self, guid, action_id, contract_hash=None): + if self.enabled is not True: + return self.log.info("Recording Audit Event [%s]" % action_id) if action_id in self.action_ids: diff --git a/market/network.py b/market/network.py index 9662c5a4..bdb2d148 100644 --- a/market/network.py +++ b/market/network.py @@ -35,7 +35,7 @@ class Server(object): - def __init__(self, kserver, signing_key, database): + def __init__(self, kserver, signing_key, database, audit=True): """ A high level class for sending direct, market messages to other nodes. A node will need one of these to participate in buying and selling. @@ -46,7 +46,7 @@ def __init__(self, kserver, signing_key, database): self.router = kserver.protocol.router self.db = database self.log = Logger(system=self) - self.protocol = MarketProtocol(kserver.node, self.router, signing_key, database) + self.protocol = MarketProtocol(kserver.node, self.router, signing_key, database, audit) task.LoopingCall(self.update_listings).start(3600, now=True) def querySeed(self, list_seed_pubkey): diff --git a/market/protocol.py b/market/protocol.py index c0e891f6..d23a8792 100644 --- a/market/protocol.py +++ b/market/protocol.py @@ -29,12 +29,12 @@ class MarketProtocol(RPCProtocol): implements(MessageProcessor) - def __init__(self, node, router, signing_key, database): + def __init__(self, node, router, signing_key, database, audit=True): self.router = router self.node = node RPCProtocol.__init__(self, node, router) self.log = Logger(system=self) - self.audit = Audit(db=database) + self.audit = Audit(db=database, enabled=audit) self.multiplexer = None self.db = database self.signing_key = signing_key diff --git a/openbazaard.py b/openbazaard.py index af70e9b8..2b400029 100644 --- a/openbazaard.py +++ b/openbazaard.py @@ -45,6 +45,7 @@ def run(*args): RESTPORT = args[4] WSPORT = args[5] HEARTBEATPORT = args[6] + AUDIT = args[7] def start_server(keys, first_startup=False): # logging @@ -109,7 +110,7 @@ def on_bootstrap_complete(resp): protocol.register_processor(kserver.protocol) # market - mserver = network.Server(kserver, keys.signing_key, db) + mserver = network.Server(kserver, keys.signing_key, db, AUDIT) mserver.protocol.connect_multiplexer(protocol) protocol.register_processor(mserver.protocol) @@ -247,6 +248,7 @@ def start(self): parser.add_argument('-r', '--restapiport', help="set the rest api port", default=18469) parser.add_argument('-w', '--websocketport', help="set the websocket api port", default=18466) parser.add_argument('-b', '--heartbeatport', help="set the heartbeat port", default=18470) + parser.add_argument('-u', '--disableaudit', action='store_true', help="disable event logging") parser.add_argument('--pidfile', help="name of the pid file", default="openbazaard.pid") args = parser.parse_args(sys.argv[2:]) @@ -262,11 +264,11 @@ def start(self): self.daemon.pidfile = "/tmp/" + args.pidfile self.daemon.start(args.testnet, args.loglevel, port, args.allowip, int(args.restapiport), int(args.websocketport), - int(args.heartbeatport), time.time()) + int(args.heartbeatport), time.time(), args.disableaudit) else: run(args.testnet, args.loglevel, port, args.allowip, int(args.restapiport), int(args.websocketport), - int(args.heartbeatport), time.time()) + int(args.heartbeatport), time.time(), args.disableaudit) def stop(self): # pylint: disable=W0612 From 87c7189cc72d6a1e61e2eb28cedfcd253d1dba0b Mon Sep 17 00:00:00 2001 From: Chris Pacia Date: Thu, 10 Nov 2016 18:50:10 -0500 Subject: [PATCH 2/2] Fix pylint error --- market/contracts.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/market/contracts.py b/market/contracts.py index 207ad470..6ee51363 100644 --- a/market/contracts.py +++ b/market/contracts.py @@ -949,8 +949,8 @@ def payment_received(self): if self.db.sales.get_status(order_id) == 0: self.db.sales.update_status(order_id, 1) self.db.sales.status_changed(order_id, 1) - self.notification_listener.notify(unhexlify(buyer_guid), handle, "new order", order_id, - title, image_hash) + self.notification_listener.notify(unhexlify(buyer_guid), handle, "new order", + order_id, title, image_hash) notification = SMTPNotification(self.db) notification.send("[OpenBazaar] Payment for Order Received",