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
f8f73509
Commit
f8f73509
authored
Apr 03, 2023
by
陈涛
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改pubkey的bug
parent
1b885c1d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
47 deletions
+47
-47
node.py
api/node.py
+47
-47
No files found.
api/node.py
View file @
f8f73509
...
...
@@ -31,23 +31,23 @@ async def subscribe(
):
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基金才可绑定节点
except
Exception
as
e
:
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基金才可绑定节点
query
=
{
'id'
:
bind_node
.
fund_id
,
'user_id'
:
user
.
id
,
'fund_type'
:
FundType
.
staking
,
f
"nodes.{bind_node.pub_key}"
:
{
'$exists'
:
False
}}
query
=
{
'id'
:
bind_node
.
fund_id
,
'user_id'
:
user
.
id
,
'fund_type'
:
FundType
.
staking
,
f
"nodes.{bind_node.pub_key}"
:
{
'$exists'
:
False
}}
update
=
{
"$set"
:
{
f
"nodes.{bind_node.pub_key}"
:
db_data
.
dict
()}}
res
=
await
fund_collect
.
update_one
(
query
,
update
)
if
res
.
raw_result
[
'nModified'
]
==
0
:
raise
ExistDataError
(
message
=
'节点已存在'
)
return
BaseResponse
(
data
=
'绑定成功'
)
update
=
{
"$set"
:
{
f
"nodes.{bind_node.pub_key}"
:
db_data
.
dict
()}}
res
=
await
fund_collect
.
update_one
(
query
,
update
)
if
res
.
raw_result
[
'nModified'
]
==
0
:
raise
ExistDataError
(
message
=
'节点已存在'
)
return
BaseResponse
(
data
=
'绑定成功'
)
@
router
.
delete
(
'/'
,
response_model
=
BaseResponse
,
summary
=
'解绑节点'
,
description
=
'解绑节点'
)
...
...
@@ -78,14 +78,14 @@ async def get_node_info(
):
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
(
'未绑定该节点'
)
validator_detail
=
await
beacon_service
.
get_validator
(
pub_key
)
response
=
Response
[
Validator
](
data
=
validator_detail
)
return
response
except
Exception
as
e
:
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_detail
=
await
beacon_service
.
get_validator
(
pub_key
)
response
=
Response
[
Validator
](
data
=
validator_detail
)
return
response
@
router
.
get
(
...
...
@@ -101,14 +101,14 @@ async def get_node_deposit(
):
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
(
'未绑定该节点'
)
validator_deposit_list
=
await
beacon_service
.
get_validator_deposit
(
pub_key
)
response
=
Response
[
List
[
ValidatorDeposit
]](
data
=
validator_deposit_list
)
return
response
except
Exception
as
e
:
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
)
return
response
@
router
.
get
(
...
...
@@ -125,18 +125,18 @@ async def get_node_blocks(
):
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
)
assert
fund
,
NotFundError
(
'未绑定该节点'
)
validator_blocks
=
await
beacon_service
.
get_validator_blocks
(
index
=
fund
[
"nodes"
][
pub_key
][
"index"
],
start
=
start
,
length
=
page
.
page_size
)
return
PageResponse
[
ValidatorBlock
](
data
=
validator_blocks
.
data
,
**
page
.
dict
(),
total
=
validator_blocks
.
total
)
except
Exception
as
e
:
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
)
assert
fund
,
NotFundError
(
'未绑定该节点'
)
validator_blocks
=
await
beacon_service
.
get_validator_blocks
(
index
=
fund
[
"nodes"
][
pub_key
][
"index"
],
start
=
start
,
length
=
page
.
page_size
)
return
PageResponse
[
ValidatorBlock
](
data
=
validator_blocks
.
data
,
**
page
.
dict
(),
total
=
validator_blocks
.
total
)
@
router
.
get
(
...
...
@@ -152,15 +152,15 @@ async def get_node_income(
):
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
(
'未绑定该节点'
)
validator_income_list
=
await
beacon_service
.
get_validator_income
(
index_or_pubkey
=
pub_key
)
assert
validator_income_list
,
NotFundError
()
response
=
Response
[
ValidatorIncome
](
data
=
validator_income_list
[
0
])
return
response
except
Exception
as
e
:
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
()
response
=
Response
[
ValidatorIncome
](
data
=
validator_income_list
[
0
])
return
response
@
router
.
get
(
"/epoch/{epoch}/"
,
response_model
=
Response
[
Epoch
],
summary
=
"查询epoch"
,
description
=
""
)
...
...
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