Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
clive
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
hive
clive
Commits
48493602
Commit
48493602
authored
1 year ago
by
Krzysztof Mochocki
Committed by
Mateusz Żebrak
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
UpdateNodeData returns dynamic global properties
parent
eeec79ed
No related branches found
No related tags found
3 merge requests
!186
V1.27.5.0 release
,
!174
RELEASE: 1
,
!102
Redesign header
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
clive/__private/core/commands/update_node_data.py
+10
-7
10 additions, 7 deletions
clive/__private/core/commands/update_node_data.py
with
10 additions
and
7 deletions
clive/__private/core/commands/update_node_data.py
+
10
−
7
View file @
48493602
...
@@ -5,10 +5,11 @@ from datetime import datetime, timedelta, timezone
...
@@ -5,10 +5,11 @@ from datetime import datetime, timedelta, timezone
from
math
import
ceil
from
math
import
ceil
from
typing
import
TYPE_CHECKING
,
Final
,
cast
from
typing
import
TYPE_CHECKING
,
Final
,
cast
from
clive.__private.core.commands.abc.command
import
Command
from
clive.__private.core.commands.abc.command
_with_result
import
Command
WithResult
from
clive.__private.core.iwax
import
calculate_current_manabar_value
,
calculate_manabar_full_regeneration_time
from
clive.__private.core.iwax
import
calculate_current_manabar_value
,
calculate_manabar_full_regeneration_time
from
clive.exceptions
import
CommunicationError
from
clive.exceptions
import
CommunicationError
from
clive.models
import
Asset
from
clive.models
import
Asset
from
schemas.database_api.response_schemas
import
GetDynamicGlobalProperties
if
TYPE_CHECKING
:
if
TYPE_CHECKING
:
from
types
import
TracebackType
from
types
import
TracebackType
...
@@ -18,10 +19,9 @@ if TYPE_CHECKING:
...
@@ -18,10 +19,9 @@ if TYPE_CHECKING:
from
clive.__private.storage.mock_database
import
Account
from
clive.__private.storage.mock_database
import
Account
from
schemas.__private.hive_fields_custom_schemas
import
Manabar
from
schemas.__private.hive_fields_custom_schemas
import
Manabar
from
schemas.database_api.fundaments_of_reponses
import
AccountItemFundament
from
schemas.database_api.fundaments_of_reponses
import
AccountItemFundament
from
schemas.database_api.response_schemas
import
GetDynamicGlobalProperties
from
schemas.rc_api.fundaments_of_responses
import
RcAccount
from
schemas.rc_api.fundaments_of_responses
import
RcAccount
GDPO
T
=
GetDynamicGlobalProperties
[
Asset
.
Hive
,
Asset
.
Hbd
,
Asset
.
Vests
]
DynamicGlobalProperties
T
=
GetDynamicGlobalProperties
[
Asset
.
Hive
,
Asset
.
Hbd
,
Asset
.
Vests
]
class
SuppressNotExistingApi
:
class
SuppressNotExistingApi
:
...
@@ -39,7 +39,7 @@ class SuppressNotExistingApi:
...
@@ -39,7 +39,7 @@ class SuppressNotExistingApi:
@dataclass
@dataclass
class
UpdateNodeData
(
Command
):
class
UpdateNodeData
(
Command
WithResult
[
DynamicGlobalPropertiesT
]
):
accounts
:
list
[
Account
]
accounts
:
list
[
Account
]
node
:
Node
node
:
Node
...
@@ -56,6 +56,7 @@ class UpdateNodeData(Command):
...
@@ -56,6 +56,7 @@ class UpdateNodeData(Command):
api_accounts
=
self
.
__harvest_data_from_api
()
api_accounts
=
self
.
__harvest_data_from_api
()
gdpo
=
self
.
node
.
api
.
database_api
.
get_dynamic_global_properties
()
gdpo
=
self
.
node
.
api
.
database_api
.
get_dynamic_global_properties
()
self
.
_result
=
gdpo
for
account
,
info
in
api_accounts
.
items
():
for
account
,
info
in
api_accounts
.
items
():
account
.
data
.
reputation
=
info
.
reputation
account
.
data
.
reputation
=
info
.
reputation
...
@@ -189,7 +190,7 @@ class UpdateNodeData(Command):
...
@@ -189,7 +190,7 @@ class UpdateNodeData(Command):
def
__calculate_hive_power
(
def
__calculate_hive_power
(
self
,
self
,
gdpo
:
GDPO
T
,
gdpo
:
DynamicGlobalProperties
T
,
account
:
AccountItemFundament
[
Asset
.
Hive
,
Asset
.
Hbd
,
Asset
.
Vests
],
account
:
AccountItemFundament
[
Asset
.
Hive
,
Asset
.
Hbd
,
Asset
.
Vests
],
)
->
int
:
)
->
int
:
account_vesting_shares
=
(
account_vesting_shares
=
(
...
@@ -205,7 +206,9 @@ class UpdateNodeData(Command):
...
@@ -205,7 +206,9 @@ class UpdateNodeData(Command):
),
),
)
)
def
__update_manabar
(
self
,
gdpo
:
GDPOT
,
max_mana
:
int
,
manabar
:
Manabar
,
dest
:
mock_database
.
Manabar
)
->
None
:
def
__update_manabar
(
self
,
gdpo
:
DynamicGlobalPropertiesT
,
max_mana
:
int
,
manabar
:
Manabar
,
dest
:
mock_database
.
Manabar
)
->
None
:
power_from_api
=
int
(
manabar
.
current_mana
)
power_from_api
=
int
(
manabar
.
current_mana
)
last_update
=
int
(
manabar
.
last_update_time
)
last_update
=
int
(
manabar
.
last_update_time
)
dest
.
max_value
=
int
(
self
.
__vests_to_hive
(
max_mana
,
gdpo
).
amount
)
dest
.
max_value
=
int
(
self
.
__vests_to_hive
(
max_mana
,
gdpo
).
amount
)
...
@@ -231,7 +234,7 @@ class UpdateNodeData(Command):
...
@@ -231,7 +234,7 @@ class UpdateNodeData(Command):
-
gdpo
.
time
-
gdpo
.
time
)
)
def
__vests_to_hive
(
self
,
amount
:
int
|
Asset
.
Vests
,
gdpo
:
GDPO
T
)
->
Asset
.
Hive
:
def
__vests_to_hive
(
self
,
amount
:
int
|
Asset
.
Vests
,
gdpo
:
DynamicGlobalProperties
T
)
->
Asset
.
Hive
:
if
isinstance
(
amount
,
Asset
.
Vests
):
if
isinstance
(
amount
,
Asset
.
Vests
):
amount
=
int
(
amount
.
amount
)
amount
=
int
(
amount
.
amount
)
return
Asset
.
Hive
(
return
Asset
.
Hive
(
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment