Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
H
hivemind
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
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
hivemind
Commits
e21a4a43
Commit
e21a4a43
authored
5 years ago
by
Dariusz Kędzierski
Committed by
Gandalf
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Specialized endpoints support
parent
fd06621e
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
README.md
+2
-2
2 additions, 2 deletions
README.md
docker-compose.yml
+1
-1
1 addition, 1 deletion
docker-compose.yml
hive/conf.py
+3
-2
3 additions, 2 deletions
hive/conf.py
hive/steem/client.py
+27
-11
27 additions, 11 deletions
hive/steem/client.py
with
33 additions
and
16 deletions
README.md
+
2
−
2
View file @
e21a4a43
...
...
@@ -63,7 +63,7 @@ Hivemind is deployed as a Docker container.
Here is an example command that will initialize the DB schema and start the syncing process:
```
docker run -d --name hivemind --env DATABASE_URL=postgresql://user:pass@hostname:5432/databasename --env STEEMD_URL=https://yoursteemnode --env SYNC_SERVICE=1 -p 8080:8080 steemit/hivemind:latest
docker run -d --name hivemind --env DATABASE_URL=postgresql://user:pass@hostname:5432/databasename --env STEEMD_URL=
'{"default":"
https://yoursteemnode
"}'
--env SYNC_SERVICE=1 -p 8080:8080 steemit/hivemind:latest
```
Be sure to set
`DATABASE_URL`
to point to your postgres database and
`STEEMD_URL`
to point to your steemd node to sync from.
...
...
@@ -84,7 +84,7 @@ docker logs -f hivemind
|
`LOG_LEVEL`
|
`--log-level`
| INFO |
|
`HTTP_SERVER_PORT`
|
`--http-server-port`
| 8080 |
|
`DATABASE_URL`
|
`--database-url`
| postgresql://user:pass@localhost:5432/hive |
|
`STEEMD_URL`
|
`--steemd-url`
| https://
api.
steem
it.com
|
|
`STEEMD_URL`
|
`--steemd-url`
|
'{"default":"
https://
your
steem
node"}'
|
|
`MAX_BATCH`
|
`--max-batch`
| 50 |
|
`MAX_WORKERS`
|
`--max-workers`
| 4 |
|
`TRAIL_BLOCKS`
|
`--trail-blocks`
| 2 |
...
...
This diff is collapsed.
Click to expand it.
docker-compose.yml
+
1
−
1
View file @
e21a4a43
...
...
@@ -16,7 +16,7 @@ services:
environment
:
DATABASE_URL
:
postgresql://testuser:testuserpass@db:5432/testdb
LOG_LEVEL
:
INFO
STEEMD_URL
:
https://api.steemit.com
STEEMD_URL
:
'
{"default"
:
"
https://api.steemit.com
"}'
links
:
-
db:db
ports
:
...
...
This diff is collapsed.
Click to expand it.
hive/conf.py
+
3
−
2
View file @
e21a4a43
...
...
@@ -32,7 +32,7 @@ class Conf():
# common
add
(
'
--database-url
'
,
env_var
=
'
DATABASE_URL
'
,
required
=
False
,
help
=
'
database connection url
'
,
default
=
''
)
add
(
'
--steemd-url
'
,
env_var
=
'
STEEMD_URL
'
,
required
=
False
,
help
=
'
steemd/jussi endpoint
'
,
default
=
'
https://api.steemit.com
'
)
add
(
'
--steemd-url
'
,
env_var
=
'
STEEMD_URL
'
,
required
=
False
,
help
=
'
steemd/jussi endpoint
'
,
default
=
'
{
"
default
"
:
"
https://api.steemit.com
"
}
'
)
add
(
'
--muted-accounts-url
'
,
env_var
=
'
MUTED_ACCOUNTS_URL
'
,
required
=
False
,
help
=
'
url to flat list of muted accounts
'
,
default
=
''
)
# server
...
...
@@ -85,8 +85,9 @@ class Conf():
def
steem
(
self
):
"""
Get a SteemClient instance, lazily initialized
"""
if
not
self
.
_steem
:
from
json
import
loads
self
.
_steem
=
SteemClient
(
url
=
self
.
get
(
'
steemd_url
'
),
url
=
loads
(
self
.
get
(
'
steemd_url
'
)
)
,
max_batch
=
self
.
get
(
'
max_batch
'
),
max_workers
=
self
.
get
(
'
max_workers
'
))
return
self
.
_steem
...
...
This diff is collapsed.
Click to expand it.
hive/steem/client.py
+
27
−
11
View file @
e21a4a43
...
...
@@ -10,15 +10,19 @@ from hive.steem.block.stream import BlockStream
class
SteemClient
:
"""
Handles upstream calls to jussi/steemd, with batching and retrying.
"""
def
__init__
(
self
,
url
=
'
https://api.steemit.com
'
,
max_batch
=
50
,
max_workers
=
1
):
assert
url
,
'
steem-API endpoint undefined
'
# dangerous default value of url but it should be fine since we are not writting to it
def
__init__
(
self
,
url
=
{
"
default
"
:
'
https://api.steemit.com
'
},
max_batch
=
50
,
max_workers
=
1
):
assert
url
,
'
steem-API endpoints undefined
'
assert
"
default
"
in
url
,
"
Url should have default endpoint defined
"
assert
max_batch
>
0
and
max_batch
<=
5000
assert
max_workers
>
0
and
max_workers
<=
64
self
.
_max_batch
=
max_batch
self
.
_max_workers
=
max_workers
self
.
_client
=
HttpClient
(
nodes
=
[
url
])
self
.
_client
=
dict
()
for
endpoint
,
endpoint_url
in
url
.
items
():
print
(
"
Endpoint {} will be routed to node {}
"
.
format
(
endpoint
,
endpoint_url
))
self
.
_client
[
endpoint
]
=
HttpClient
(
nodes
=
[
endpoint_url
])
def
get_accounts
(
self
,
accounts
):
"""
Fetch multiple accounts by name.
"""
...
...
@@ -135,7 +139,11 @@ class SteemClient:
def
__exec
(
self
,
method
,
params
=
None
):
"""
Perform a single steemd call.
"""
start
=
perf
()
result
=
self
.
_client
.
exec
(
method
,
params
)
result
=
None
if
method
in
self
.
_client
:
result
=
self
.
_client
[
method
].
exec
(
method
,
params
)
else
:
result
=
self
.
_client
[
"
default
"
].
exec
(
method
,
params
)
items
=
len
(
params
[
0
])
if
method
==
'
get_accounts
'
else
1
Stats
.
log_steem
(
method
,
perf
()
-
start
,
items
)
return
result
...
...
@@ -145,12 +153,20 @@ class SteemClient:
start
=
perf
()
result
=
[]
for
part
in
self
.
_client
.
exec_multi
(
method
,
params
,
max_workers
=
self
.
_max_workers
,
batch_size
=
self
.
_max_batch
):
result
.
extend
(
part
)
if
method
in
self
.
_client
:
for
part
in
self
.
_client
[
method
].
exec_multi
(
method
,
params
,
max_workers
=
self
.
_max_workers
,
batch_size
=
self
.
_max_batch
):
result
.
extend
(
part
)
else
:
for
part
in
self
.
_client
[
"
default
"
].
exec_multi
(
method
,
params
,
max_workers
=
self
.
_max_workers
,
batch_size
=
self
.
_max_batch
):
result
.
extend
(
part
)
Stats
.
log_steem
(
method
,
perf
()
-
start
,
len
(
params
))
return
result
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