mirror of
https://github.com/bigchaindb/bigchaindb.git
synced 2024-10-13 13:34:05 +00:00
Wrap queries with connection object
This commit is contained in:
parent
01da32d351
commit
3c45de70d0
@ -121,7 +121,9 @@ def get_txids_filtered(conn, asset_id, operation=None):
|
|||||||
{'$match': match},
|
{'$match': match},
|
||||||
{'$project': {'block.transactions.id': True}}
|
{'$project': {'block.transactions.id': True}}
|
||||||
]
|
]
|
||||||
cursor = conn.db['bigchain'].aggregate(pipeline)
|
cursor = conn.run(
|
||||||
|
conn.collection('bigchain')
|
||||||
|
.aggregate(pipeline))
|
||||||
return (elem['block']['transactions']['id'] for elem in cursor)
|
return (elem['block']['transactions']['id'] for elem in cursor)
|
||||||
|
|
||||||
|
|
||||||
@ -281,18 +283,20 @@ def get_last_voted_block(conn, node_pubkey):
|
|||||||
|
|
||||||
@register_query(MongoDBConnection)
|
@register_query(MongoDBConnection)
|
||||||
def get_unvoted_blocks(conn, node_pubkey):
|
def get_unvoted_blocks(conn, node_pubkey):
|
||||||
return conn.db['bigchain'].aggregate([
|
return conn.run(
|
||||||
{'$lookup': {
|
conn.collection('bigchain')
|
||||||
'from': 'votes',
|
.aggregate([
|
||||||
'localField': 'id',
|
{'$lookup': {
|
||||||
'foreignField': 'vote.voting_for_block',
|
'from': 'votes',
|
||||||
'as': 'votes'
|
'localField': 'id',
|
||||||
}},
|
'foreignField': 'vote.voting_for_block',
|
||||||
{'$match': {
|
'as': 'votes'
|
||||||
'votes.node_pubkey': {'$ne': node_pubkey},
|
}},
|
||||||
'block.transactions.operation': {'$ne': 'GENESIS'}
|
{'$match': {
|
||||||
}},
|
'votes.node_pubkey': {'$ne': node_pubkey},
|
||||||
{'$project': {
|
'block.transactions.operation': {'$ne': 'GENESIS'}
|
||||||
'votes': False, '_id': False
|
}},
|
||||||
}}
|
{'$project': {
|
||||||
])
|
'votes': False, '_id': False
|
||||||
|
}}
|
||||||
|
]))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user