Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
PyFund
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
陈涛
PyFund
Commits
201d1562
Commit
201d1562
authored
Mar 28, 2023
by
陈涛
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
node查询接口增加鉴权
parent
73a781ba
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
13 deletions
+40
-13
node.py
api/node.py
+40
-13
No files found.
api/node.py
View file @
201d1562
...
...
@@ -61,25 +61,43 @@ async def unsubscribe(
return
BaseResponse
(
data
=
'解绑成功'
)
@
router
.
get
(
"/validator/{index_or_pubkey}/"
,
response_model
=
Response
[
Validator
],
summary
=
"查询节点详情"
,
description
=
""
)
async
def
node_get_validator
(
index_or_pubkey
:
Union
[
int
,
str
],
beacon_service
:
BeaconChaService
=
Depends
(
BeaconChaService
)
@
router
.
get
(
"/info/{pub_key}/"
,
response_model
=
Response
[
Validator
],
summary
=
"查询节点详情"
,
description
=
""
)
async
def
get_node_info
(
fund_id
:
str
,
pub_key
:
str
,
user
:
User
=
Depends
(
dependencies
.
get_current_user
),
beacon_service
:
BeaconChaService
=
Depends
(
BeaconChaService
),
fund_collect
:
AgnosticCollection
=
Depends
(
dependencies
.
get_fund_collect
)
):
validator_detail
=
await
beacon_service
.
get_validator
(
index_or_pubkey
)
fund
=
await
fund_collect
.
find_one
({
"id"
:
fund_id
,
"user_id"
:
user
.
id
,
"nodes"
:
{
"$elemMatch"
:
{
"pub_key"
:
pub_key
}}
})
assert
fund
,
NotFundError
()
validator_detail
=
await
beacon_service
.
get_validator
(
pub_key
)
response
=
Response
[
Validator
](
data
=
validator_detail
)
return
response
@
router
.
get
(
"/
validator/deposit/{index_or_pub
key}/"
,
"/
deposit/{pub_
key}/"
,
response_model
=
Response
[
List
[
ValidatorDeposit
]],
summary
=
"查询节点充值记录"
,
description
=
""
)
async
def
node_get_validator_deposit
(
index_or_pubkey
:
Union
[
int
,
str
],
beacon_service
:
BeaconChaService
=
Depends
(
BeaconChaService
)
async
def
get_node_deposit
(
fund_id
:
str
,
pub_key
:
str
,
user
:
User
=
Depends
(
dependencies
.
get_current_user
),
beacon_service
:
BeaconChaService
=
Depends
(
BeaconChaService
),
fund_collect
:
AgnosticCollection
=
Depends
(
dependencies
.
get_fund_collect
)
):
validator_deposit
=
await
beacon_service
.
get_validator_deposit
(
index_or_pubkey
)
fund
=
await
fund_collect
.
find_one
({
"id"
:
fund_id
,
"user_id"
:
user
.
id
,
"nodes"
:
{
"$elemMatch"
:
{
"pub_key"
:
pub_key
}}
})
assert
fund
,
NotFundError
()
validator_deposit
=
await
beacon_service
.
get_validator_deposit
(
pub_key
)
response
=
Response
[
List
[
ValidatorDeposit
]](
data
=
validator_deposit
)
return
response
...
...
@@ -118,14 +136,23 @@ async def node_get_validator_deposit(
@
router
.
get
(
"/validator/income/{
index_or_pub
key}/"
,
"/validator/income/{
pub_
key}/"
,
response_model
=
Response
[
ValidatorIncome
],
summary
=
"查询节点收益"
,
description
=
""
)
async
def
node_get_validator_deposit
(
index_or_pubkey
:
Union
[
int
,
str
],
fund_id
:
str
,
pub_key
:
str
,
user
:
User
=
Depends
(
dependencies
.
get_current_user
),
beacon_service
:
BeaconChaService
=
Depends
(
BeaconChaService
),
fund_collect
:
AgnosticCollection
=
Depends
(
dependencies
.
get_fund_collect
)
):
validator_income
=
await
beacon_service
.
get_validator_income
(
indexOrPubkey
=
index_or_pubkey
)
fund
=
await
fund_collect
.
find_one
({
"id"
:
fund_id
,
"user_id"
:
user
.
id
,
"nodes"
:
{
"$elemMatch"
:
{
"pub_key"
:
pub_key
}}
})
assert
fund
,
NotFundError
()
validator_income
=
await
beacon_service
.
get_validator_income
(
indexOrPubkey
=
pub_key
)
assert
validator_income
,
"没有查到收益"
response
=
Response
[
ValidatorIncome
](
data
=
validator_income
[
0
])
return
response
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment