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
455b09ef
Commit
455b09ef
authored
Mar 31, 2023
by
陈涛
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改nodes相关接口
parent
a3dd11ac
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
18 deletions
+8
-18
node.py
api/node.py
+7
-17
dependencies.py
dependencies.py
+1
-1
No files found.
api/node.py
View file @
455b09ef
...
...
@@ -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
()
...
...
dependencies.py
View file @
455b09ef
...
...
@@ -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
)
...
...
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