Commit 455b09ef authored by 陈涛's avatar 陈涛

修改nodes相关接口

parent a3dd11ac
......@@ -90,11 +90,8 @@ async def get_node_deposit(
beacon_service: BeaconChaService = Depends(BeaconChaService),
fund_collect: AgnosticCollection = Depends(dependencies.get_fund_collect)
):
fund = await fund_collect.find_one({
"id": fund_id,
"user_id": user.id,
"nodes": {"$elemMatch": {"pub_key": pub_key}}
})
query = {'id': fund_id, 'user_id': user.id, 'fund_type': FundType.staking, f"nodes.{pub_key}": {"$exists": True}}
fund = await fund_collect.find_one(query)
assert fund, NotFundError('未绑定该节点')
validator_deposit_list = await beacon_service.get_validator_deposit(pub_key)
response = Response[List[ValidatorDeposit]](data=validator_deposit_list)
......@@ -114,15 +111,11 @@ async def get_node_blocks(
fund_collect: AgnosticCollection = Depends(dependencies.get_fund_collect)
):
start = (page.page - 1) * page.page_size
fund = await fund_collect.find_one({
"id": fund_id,
"user_id": user.id,
"nodes": {"$elemMatch": {"pub_key": pub_key}}
})
query = {'id': fund_id, 'user_id': user.id, 'fund_type': FundType.staking, f"nodes.{pub_key}": {"$exists": True}}
fund = await fund_collect.find_one(query)
assert fund, NotFundError('未绑定该节点')
node = next(filter(lambda x: x["pub_key"] == pub_key, fund["nodes"]))
validator_blocks = await beacon_service.get_validator_blocks(
index=node["index"],
index=fund["nodes"][pub_key]["index"],
start=start,
length=page.page_size
)
......@@ -140,11 +133,8 @@ async def get_node_income(
beacon_service: BeaconChaService = Depends(BeaconChaService),
fund_collect: AgnosticCollection = Depends(dependencies.get_fund_collect)
):
fund = await fund_collect.find_one({
"id": fund_id,
"user_id": user.id,
"nodes": {"$elemMatch": {"pub_key": pub_key}}
})
query = {'id': fund_id, 'user_id': user.id, 'fund_type': FundType.staking, f"nodes.{pub_key}": {"$exists": True}}
fund = await fund_collect.find_one(query)
assert fund, NotFundError('未绑定该节点')
validator_income_list = await beacon_service.get_validator_income(index_or_pubkey=pub_key)
assert validator_income_list, NotFundError()
......
......@@ -14,7 +14,7 @@ from tools.jwt_tools import User
def get_current_user(credentials: HTTPAuthorizationCredentials = Security(jwt_tools.security)) -> User:
if settings.env == 'LOCAL':
return User(id='local_test', email='local_test@qq.com')
return User(id='659092a5-df9e-43fd-b51d-79d4c7ff09ad', email='local_test@qq.com')
return jwt_tools.get_current_user(credentials)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment