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
91480b21
Commit
91480b21
authored
Mar 28, 2023
by
confusion
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改node
parent
201d1562
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
73 additions
and
105 deletions
+73
-105
node.py
api/node.py
+14
-18
beacon.py
schema/beacon.py
+9
-9
beacon.py
service/beacon.py
+50
-78
No files found.
api/node.py
View file @
91480b21
...
...
@@ -27,9 +27,9 @@ async def subscribe(
fund_collect
:
AgnosticCollection
=
Depends
(
dependencies
.
get_fund_collect
),
beacon_service
:
BeaconChaService
=
Depends
(
BeaconChaService
)
):
node_detail
=
await
beacon_service
.
get_validator
(
indexOrP
ubkey
=
create_node
.
pub_key
)
assert
node_detail
,
"节点不存在,绑定失败"
db_data
=
BaseNode
(
**
create_node
.
dict
(),
index
=
node_detail
.
validator
index
)
node_detail
_list
=
await
beacon_service
.
get_validator
(
index_or_p
ubkey
=
create_node
.
pub_key
)
assert
node_detail
_list
,
"节点不存在,绑定失败"
db_data
=
BaseNode
(
**
create_node
.
dict
(),
index
=
node_detail
_list
[
0
]
.
validator_
index
)
# 限制staking基金才可绑定节点
query
=
{
'id'
:
create_node
.
fund_id
,
'user_id'
:
user
.
id
,
'fund_type'
:
FundType
.
staking
}
res
=
await
fund_collect
.
update_one
(
...
...
@@ -75,8 +75,9 @@ async def get_node_info(
"nodes"
:
{
"$elemMatch"
:
{
"pub_key"
:
pub_key
}}
})
assert
fund
,
NotFundError
()
validator_detail
=
await
beacon_service
.
get_validator
(
pub_key
)
response
=
Response
[
Validator
](
data
=
validator_detail
)
validator_detail_list
=
await
beacon_service
.
get_validator
(
pub_key
)
assert
validator_detail_list
,
NotFundError
()
response
=
Response
[
Validator
](
data
=
validator_detail_list
[
0
])
return
response
...
...
@@ -97,8 +98,8 @@ async def get_node_deposit(
"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
)
validator_deposit
_list
=
await
beacon_service
.
get_validator_deposit
(
pub_key
)
response
=
Response
[
List
[
ValidatorDeposit
]](
data
=
validator_deposit
_list
)
return
response
...
...
@@ -106,7 +107,7 @@ async def get_node_deposit(
"/validator/blocks/{index}/"
,
response_model
=
PageResponse
[
ValidatorBlock
],
summary
=
"查询节点blocks"
,
description
=
""
)
async
def
node_get_validator_deposit
(
async
def
get_node_blocks
(
fund_id
:
str
,
pub_key
:
str
,
user
:
User
=
Depends
(
dependencies
.
get_current_user
),
...
...
@@ -127,19 +128,14 @@ async def node_get_validator_deposit(
start
=
start
,
length
=
page
.
page_size
)
response
=
PageResponse
[
ValidatorBlock
](
data
=
validator_blocks
.
data
,
**
page
.
dict
(),
total
=
validator_blocks
.
total
)
return
response
return
PageResponse
[
ValidatorBlock
](
data
=
validator_blocks
.
data
,
**
page
.
dict
(),
total
=
validator_blocks
.
total
)
@
router
.
get
(
"/validator/income/{pub_key}/"
,
response_model
=
Response
[
ValidatorIncome
],
summary
=
"查询节点收益"
,
description
=
""
)
async
def
node_get_validator_deposit
(
async
def
get_node_income
(
fund_id
:
str
,
pub_key
:
str
,
user
:
User
=
Depends
(
dependencies
.
get_current_user
),
...
...
@@ -152,7 +148,7 @@ async def node_get_validator_deposit(
"nodes"
:
{
"$elemMatch"
:
{
"pub_key"
:
pub_key
}}
})
assert
fund
,
NotFundError
()
validator_income
=
await
beacon_service
.
get_validator_income
(
indexOrP
ubkey
=
pub_key
)
assert
validator_income
,
"没有查到收益"
response
=
Response
[
ValidatorIncome
](
data
=
validator_income
[
0
])
validator_income
_list
=
await
beacon_service
.
get_validator_income
(
index_or_p
ubkey
=
pub_key
)
assert
validator_income
_list
,
NotFundError
()
response
=
Response
[
ValidatorIncome
](
data
=
validator_income
_list
[
0
])
return
response
schema/beacon.py
View file @
91480b21
...
...
@@ -3,18 +3,18 @@ from pydantic import BaseModel, Field
class
Validator
(
BaseModel
):
"""质押基本信息"""
activation
eligibility
epoch
:
int
=
Field
(
None
,
title
=
"激活合格编号"
)
activationepoch
:
int
=
Field
(
None
,
title
=
"激活编号"
)
validatorindex
:
int
=
Field
(
None
,
title
=
"节点编号"
)
activation
_eligibility_
epoch
:
int
=
Field
(
None
,
title
=
"激活合格编号"
)
activation
_
epoch
:
int
=
Field
(
None
,
title
=
"激活编号"
)
validator
_
index
:
int
=
Field
(
None
,
title
=
"节点编号"
)
pubkey
:
str
=
Field
(
None
,
title
=
"pubkey"
)
balance
:
int
=
Field
(
None
,
title
=
"余额"
)
effectivebalance
:
int
=
Field
(
None
,
title
=
"实际余额"
)
exitepoch
:
int
=
Field
(
None
,
title
=
""
)
last
attestation
slot
:
int
=
Field
(
None
,
title
=
""
)
effective
_
balance
:
int
=
Field
(
None
,
title
=
"实际余额"
)
exit
_
epoch
:
int
=
Field
(
None
,
title
=
""
)
last
_attestation_
slot
:
int
=
Field
(
None
,
title
=
""
)
slashed
:
bool
=
Field
(
None
,
title
=
""
)
status
:
str
=
Field
(
None
,
title
=
""
)
withdraw
able
epoch
:
int
=
Field
(
None
,
title
=
""
)
withdrawalcredentials
:
str
=
Field
(
None
,
title
=
""
)
withdraw
_able_
epoch
:
int
=
Field
(
None
,
title
=
""
)
withdrawal
_
credentials
:
str
=
Field
(
None
,
title
=
""
)
class
ValidatorDeposit
(
BaseModel
):
...
...
@@ -54,4 +54,4 @@ class ValidatorIncome(BaseModel):
performance31d
:
float
=
Field
(
None
,
title
=
"31日收益"
)
performance365d
:
float
=
Field
(
None
,
title
=
"年收益"
)
rank7d
:
int
=
Field
(
None
,
title
=
"7日排名"
)
validatorindex
:
int
=
Field
(
None
,
title
=
"节点编号"
)
\ No newline at end of file
validator_index
:
int
=
Field
(
None
,
title
=
"节点编号"
)
\ No newline at end of file
service/beacon.py
View file @
91480b21
This diff is collapsed.
Click to expand it.
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