Skip to content

Commit

Permalink
add backlog count (#806)
Browse files Browse the repository at this point in the history
  • Loading branch information
rhsimplex committed Nov 14, 2016
1 parent 32a2475 commit c8553ab
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
11 changes: 11 additions & 0 deletions bigchaindb/db/backends/rethinkdb.py
Expand Up @@ -293,6 +293,17 @@ def count_blocks(self):
r.table('bigchain', read_mode=self.read_mode)
.count())

def count_backlog(self):
"""Count the number of transactions in the backlog table.
Returns:
The number of transactions in the backlog.
"""

return self.connection.run(
r.table('backlog', read_mode=self.read_mode)
.count())

def write_vote(self, vote):
"""Write a vote to the votes table.
Expand Down
9 changes: 9 additions & 0 deletions tests/db/test_bigchain_api.py
Expand Up @@ -592,6 +592,15 @@ def test_non_create_input_not_found(self, b, user_vk):
with pytest.raises(TransactionDoesNotExist) as excinfo:
tx.validate(Bigchain())

def test_count_backlog(self, b, user_vk):
from bigchaindb.models import Transaction

for _ in range(4):
tx = Transaction.create([b.me], [user_vk]).sign([b.me_private])
b.write_transaction(tx)

assert b.backend.count_backlog() == 4


class TestTransactionValidation(object):
def test_create_operation_with_inputs(self, b, user_vk, create_tx):
Expand Down

0 comments on commit c8553ab

Please sign in to comment.