Merge branch 'wrap-queries-in-connection-class'

This commit is contained in:
vrde 2016-10-17 14:15:27 +02:00
commit 425d6714ac
No known key found for this signature in database
GPG Key ID: 6581C7C39B3D397D

View File

@ -138,11 +138,11 @@ class Bigchain(object):
# There is no other node to assign to # There is no other node to assign to
new_assignee = self.me new_assignee = self.me
response = r.table('backlog')\ response = self.connection.run(
.get(transaction['id'])\ r.table('backlog')
.update({'assignee': new_assignee, .get(transaction['id'])
'assignment_timestamp': time()}, .update({'assignee': new_assignee, 'assignment_timestamp': time()},
durability=durability).run(self.conn) durability=durability))
return response return response
def get_stale_transactions(self): def get_stale_transactions(self):
@ -152,9 +152,9 @@ class Bigchain(object):
backlog after some amount of time specified in the configuration backlog after some amount of time specified in the configuration
""" """
return r.table('backlog')\ return self.connection.run(
.filter(lambda tx: time() - tx['assignment_timestamp'] > r.table('backlog')
self.backlog_reassign_delay).run(self.conn) .filter(lambda tx: time() - tx['assignment_timestamp'] > self.backlog_reassign_delay))
def validate_transaction(self, transaction): def validate_transaction(self, transaction):
"""Validate a transaction. """Validate a transaction.