Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
beem
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
beem
Commits
be3dffbd
Commit
be3dffbd
authored
8 years ago
by
Fabian Schuh
Browse files
Options
Downloads
Patches
Plain Diff
[asset] caching
parent
8f8b0cde
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bitshares/asset.py
+10
-1
10 additions, 1 deletion
bitshares/asset.py
with
10 additions
and
1 deletion
bitshares/asset.py
+
10
−
1
View file @
be3dffbd
...
@@ -3,6 +3,9 @@ from .exceptions import AssetDoesNotExistsException
...
@@ -3,6 +3,9 @@ from .exceptions import AssetDoesNotExistsException
class
Asset
(
dict
):
class
Asset
(
dict
):
assets_cache
=
dict
()
def
__init__
(
def
__init__
(
self
,
self
,
asset
,
asset
,
...
@@ -21,7 +24,10 @@ class Asset(dict):
...
@@ -21,7 +24,10 @@ class Asset(dict):
super
(
Asset
,
self
).
__init__
(
asset
)
super
(
Asset
,
self
).
__init__
(
asset
)
self
.
cached
=
True
self
.
cached
=
True
if
not
lazy
and
not
self
.
cached
:
if
self
.
asset
in
Asset
.
assets_cache
:
super
(
Asset
,
self
).
__init__
(
Asset
.
assets_cache
[
self
.
asset
])
self
.
cached
=
True
elif
not
lazy
and
not
self
.
cached
:
self
.
refresh
()
self
.
refresh
()
def
refresh
(
self
):
def
refresh
(
self
):
...
@@ -33,6 +39,9 @@ class Asset(dict):
...
@@ -33,6 +39,9 @@ class Asset(dict):
self
[
"
bitasset_data
"
]
=
self
.
bitshares
.
rpc
.
get_object
(
asset
[
"
bitasset_data_id
"
])
self
[
"
bitasset_data
"
]
=
self
.
bitshares
.
rpc
.
get_object
(
asset
[
"
bitasset_data_id
"
])
self
.
cached
=
True
self
.
cached
=
True
# store in cache
Asset
.
assets_cache
[
asset
[
"
symbol
"
]]
=
asset
@property
@property
def
is_bitasset
(
self
):
def
is_bitasset
(
self
):
return
(
"
bitasset_data_id
"
in
self
)
return
(
"
bitasset_data_id
"
in
self
)
...
...
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