Commit 1b885c1d authored by 陈涛's avatar 陈涛

修改pubkey的bug

parent 02e8d249
...@@ -5,6 +5,7 @@ from motor.core import AgnosticCollection ...@@ -5,6 +5,7 @@ from motor.core import AgnosticCollection
import dependencies import dependencies
from exception.api import APIError from exception.api import APIError
from exception.db import ExistDataError, NotFundError from exception.db import ExistDataError, NotFundError
from exception.http import RequestInvalidParamsError
from model import BaseResponse, Response, PageResponse, Page from model import BaseResponse, Response, PageResponse, Page
from fastapi import APIRouter, Depends from fastapi import APIRouter, Depends
...@@ -28,6 +29,10 @@ async def subscribe( ...@@ -28,6 +29,10 @@ async def subscribe(
fund_collect: AgnosticCollection = Depends(dependencies.get_fund_collect), fund_collect: AgnosticCollection = Depends(dependencies.get_fund_collect),
beacon_service: BeaconChaService = Depends(BeaconChaService), beacon_service: BeaconChaService = Depends(BeaconChaService),
): ):
try:
int(bind_node.pub_key)
except Exception as e:
raise RequestInvalidParamsError()
node_detail = await beacon_service.get_validator(index_or_pubkey=bind_node.pub_key) node_detail = await beacon_service.get_validator(index_or_pubkey=bind_node.pub_key)
db_data = BaseNode(**bind_node.dict(), index=node_detail.validator_index) db_data = BaseNode(**bind_node.dict(), index=node_detail.validator_index)
# 限制staking基金才可绑定节点 # 限制staking基金才可绑定节点
...@@ -71,6 +76,10 @@ async def get_node_info( ...@@ -71,6 +76,10 @@ async def get_node_info(
beacon_service: BeaconChaService = Depends(BeaconChaService), beacon_service: BeaconChaService = Depends(BeaconChaService),
fund_collect: AgnosticCollection = Depends(dependencies.get_fund_collect) fund_collect: AgnosticCollection = Depends(dependencies.get_fund_collect)
): ):
try:
int(pub_key)
except Exception as e:
raise RequestInvalidParamsError()
query = {'id': fund_id, 'user_id': user.id, 'fund_type': FundType.staking, f"nodes.{pub_key}": {"$exists": True}} 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) fund = await fund_collect.find_one(query)
assert fund, NotFundError('未绑定该节点') assert fund, NotFundError('未绑定该节点')
...@@ -90,6 +99,10 @@ async def get_node_deposit( ...@@ -90,6 +99,10 @@ async def get_node_deposit(
beacon_service: BeaconChaService = Depends(BeaconChaService), beacon_service: BeaconChaService = Depends(BeaconChaService),
fund_collect: AgnosticCollection = Depends(dependencies.get_fund_collect) fund_collect: AgnosticCollection = Depends(dependencies.get_fund_collect)
): ):
try:
int(pub_key)
except Exception as e:
raise RequestInvalidParamsError()
query = {'id': fund_id, 'user_id': user.id, 'fund_type': FundType.staking, f"nodes.{pub_key}": {"$exists": True}} 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) fund = await fund_collect.find_one(query)
assert fund, NotFundError('未绑定该节点') assert fund, NotFundError('未绑定该节点')
...@@ -110,6 +123,10 @@ async def get_node_blocks( ...@@ -110,6 +123,10 @@ async def get_node_blocks(
beacon_service: BeaconChaService = Depends(BeaconChaService), beacon_service: BeaconChaService = Depends(BeaconChaService),
fund_collect: AgnosticCollection = Depends(dependencies.get_fund_collect) fund_collect: AgnosticCollection = Depends(dependencies.get_fund_collect)
): ):
try:
int(pub_key)
except Exception as e:
raise RequestInvalidParamsError()
start = (page.page - 1) * page.page_size start = (page.page - 1) * page.page_size
query = {'id': fund_id, 'user_id': user.id, 'fund_type': FundType.staking, f"nodes.{pub_key}": {"$exists": True}} 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) fund = await fund_collect.find_one(query)
...@@ -133,6 +150,10 @@ async def get_node_income( ...@@ -133,6 +150,10 @@ async def get_node_income(
beacon_service: BeaconChaService = Depends(BeaconChaService), beacon_service: BeaconChaService = Depends(BeaconChaService),
fund_collect: AgnosticCollection = Depends(dependencies.get_fund_collect) fund_collect: AgnosticCollection = Depends(dependencies.get_fund_collect)
): ):
try:
int(pub_key)
except Exception as e:
raise RequestInvalidParamsError()
query = {'id': fund_id, 'user_id': user.id, 'fund_type': FundType.staking, f"nodes.{pub_key}": {"$exists": True}} 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) fund = await fund_collect.find_one(query)
assert fund, NotFundError('未绑定该节点') assert fund, NotFundError('未绑定该节点')
......
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