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
1b885c1d
Commit
1b885c1d
authored
Mar 31, 2023
by
陈涛
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改pubkey的bug
parent
02e8d249
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
0 deletions
+21
-0
node.py
api/node.py
+21
-0
No files found.
api/node.py
View file @
1b885c1d
...
...
@@ -5,6 +5,7 @@ from motor.core import AgnosticCollection
import
dependencies
from
exception.api
import
APIError
from
exception.db
import
ExistDataError
,
NotFundError
from
exception.http
import
RequestInvalidParamsError
from
model
import
BaseResponse
,
Response
,
PageResponse
,
Page
from
fastapi
import
APIRouter
,
Depends
...
...
@@ -28,6 +29,10 @@ async def subscribe(
fund_collect
:
AgnosticCollection
=
Depends
(
dependencies
.
get_fund_collect
),
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
)
db_data
=
BaseNode
(
**
bind_node
.
dict
(),
index
=
node_detail
.
validator_index
)
# 限制staking基金才可绑定节点
...
...
@@ -71,6 +76,10 @@ async def get_node_info(
beacon_service
:
BeaconChaService
=
Depends
(
BeaconChaService
),
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
}}
fund
=
await
fund_collect
.
find_one
(
query
)
assert
fund
,
NotFundError
(
'未绑定该节点'
)
...
...
@@ -90,6 +99,10 @@ async def get_node_deposit(
beacon_service
:
BeaconChaService
=
Depends
(
BeaconChaService
),
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
}}
fund
=
await
fund_collect
.
find_one
(
query
)
assert
fund
,
NotFundError
(
'未绑定该节点'
)
...
...
@@ -110,6 +123,10 @@ async def get_node_blocks(
beacon_service
:
BeaconChaService
=
Depends
(
BeaconChaService
),
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
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
)
...
...
@@ -133,6 +150,10 @@ async def get_node_income(
beacon_service
:
BeaconChaService
=
Depends
(
BeaconChaService
),
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
}}
fund
=
await
fund_collect
.
find_one
(
query
)
assert
fund
,
NotFundError
(
'未绑定该节点'
)
...
...
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