diff --git a/bigchaindb/backend/mongodb/query.py b/bigchaindb/backend/mongodb/query.py index 6a241a78..1988db04 100644 --- a/bigchaindb/backend/mongodb/query.py +++ b/bigchaindb/backend/mongodb/query.py @@ -212,13 +212,6 @@ def get_block(conn, block_id): projection={'_id': False})) -@register_query(MongoDBConnection) -def has_transaction(conn, transaction_id): - return bool(conn.run( - conn.collection('bigchain') - .find_one({'block.transactions.id': transaction_id}))) - - @register_query(MongoDBConnection) def count_blocks(conn): return conn.run( diff --git a/bigchaindb/backend/query.py b/bigchaindb/backend/query.py index bdfb9e28..9aa653d7 100644 --- a/bigchaindb/backend/query.py +++ b/bigchaindb/backend/query.py @@ -211,20 +211,6 @@ def get_block(connection, block_id): raise NotImplementedError -@singledispatch -def has_transaction(connection, transaction_id): - """Check if a transaction exists in the bigchain table. - - Args: - transaction_id (str): the id of the transaction to check. - - Returns: - ``True`` if the transaction exists, ``False`` otherwise. - """ - - raise NotImplementedError - - @singledispatch def count_blocks(connection): """Count the number of blocks in the bigchain table. diff --git a/bigchaindb/backend/rethinkdb/query.py b/bigchaindb/backend/rethinkdb/query.py index 99346984..6011cc8c 100644 --- a/bigchaindb/backend/rethinkdb/query.py +++ b/bigchaindb/backend/rethinkdb/query.py @@ -158,13 +158,6 @@ def get_block(connection, block_id): return connection.run(r.table('bigchain').get(block_id)) -@register_query(RethinkDBConnection) -def has_transaction(connection, transaction_id): - return bool(connection.run( - r.table('bigchain', read_mode=READ_MODE) - .get_all(transaction_id, index='transaction_id').count())) - - @register_query(RethinkDBConnection) def count_blocks(connection): return connection.run( diff --git a/bigchaindb/core.py b/bigchaindb/core.py index a4a65482..b5465ef5 100644 --- a/bigchaindb/core.py +++ b/bigchaindb/core.py @@ -542,9 +542,6 @@ class Bigchain(object): return backend.query.write_block(self.connection, block) - def transaction_exists(self, transaction_id): - return backend.query.has_transaction(self.connection, transaction_id) - def prepare_genesis_block(self): """Prepare a genesis block.""" diff --git a/tests/backend/mongodb/test_queries.py b/tests/backend/mongodb/test_queries.py index 48089805..80e3cc91 100644 --- a/tests/backend/mongodb/test_queries.py +++ b/tests/backend/mongodb/test_queries.py @@ -248,19 +248,6 @@ def test_get_block(signed_create_tx): assert block_db == block.to_dict() -def test_has_transaction(signed_create_tx): - from bigchaindb.backend import connect, query - from bigchaindb.models import Block - conn = connect() - - # create and insert block - block = Block(transactions=[signed_create_tx]) - conn.db.bigchain.insert_one(block.to_dict()) - - assert query.has_transaction(conn, signed_create_tx.id) - assert query.has_transaction(conn, 'aaa') is False - - def test_count_blocks(signed_create_tx): from bigchaindb.backend import connect, query from bigchaindb.models import Block diff --git a/tests/backend/test_generics.py b/tests/backend/test_generics.py index 2f86d417..57a644ee 100644 --- a/tests/backend/test_generics.py +++ b/tests/backend/test_generics.py @@ -29,7 +29,6 @@ def test_schema(schema_func_name, args_qty): ('get_votes_by_block_id', 1), ('write_block', 1), ('get_block', 1), - ('has_transaction', 1), ('write_vote', 1), ('get_last_voted_block', 1), ('get_unvoted_blocks', 1), diff --git a/tests/test_core.py b/tests/test_core.py index 6bcabdc9..977db065 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -88,12 +88,3 @@ def test_has_previous_vote(monkeypatch): block = {'votes': ({'node_pubkey': 'pubkey'},)} with pytest.raises(Exception): bigchain.has_previous_vote(block) - - -@pytest.mark.parametrize('exists', (True, False)) -def test_transaction_exists(monkeypatch, exists): - from bigchaindb.core import Bigchain - monkeypatch.setattr( - 'bigchaindb.backend.query.has_transaction', lambda x, y: exists) - bigchain = Bigchain(public_key='pubkey', private_key='privkey') - assert bigchain.transaction_exists('txid') is exists