Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
H
hive-js
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
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
hive-js
Commits
0450d881
Commit
0450d881
authored
5 years ago
by
Jason Salyers
Browse files
Options
Downloads
Patches
Plain Diff
[JES] Move some options to the config file
parent
2fe84706
No related branches found
No related tags found
2 merge requests
!2
Fail Over Capability
,
!1
Automatic Fail Over
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
config.json
+6
-4
6 additions, 4 deletions
config.json
package.json
+9
-3
9 additions, 3 deletions
package.json
src/api/index.js
+7
-7
7 additions, 7 deletions
src/api/index.js
src/config.js
+1
-1
1 addition, 1 deletion
src/config.js
with
23 additions
and
15 deletions
config.json
+
6
−
4
View file @
0450d881
{
{
"transport"
:
"http"
,
"transport"
:
"http"
,
"websocket"
:
"wss://
gtg.steem.house
:8090"
,
"websocket"
:
"wss://
api.hive.blog
:8090"
,
"uri"
:
"https://a
pi.steemit.com
"
,
"uri"
:
"https://a
nyx.io
"
,
"url"
:
""
,
"url"
:
"
https://anyx.io
"
,
"dev_uri"
:
"https://api.steemitdev.com"
,
"dev_uri"
:
"https://api.steemitdev.com"
,
"stage_uri"
:
"https://api.steemitstage.com"
,
"stage_uri"
:
"https://api.steemitstage.com"
,
"address_prefix"
:
"STM"
,
"address_prefix"
:
"STM"
,
"chain_id"
:
"0000000000000000000000000000000000000000000000000000000000000000"
"chain_id"
:
"0000000000000000000000000000000000000000000000000000000000000000"
,
"alternateAPIEndpoints"
:
[
"https://api.hive.blog"
,
"https://anyx.io"
],
"failoverThreshold"
:
3
}
}
This diff is collapsed.
Click to expand it.
package.json
+
9
−
3
View file @
0450d881
{
{
"name"
:
"
@steemit/steem-js
"
,
"name"
:
"
hive-js-dev
"
,
"version"
:
"0.
7.11
"
,
"version"
:
"0.
0.3
"
,
"description"
:
"Steem.js the JavaScript API for Steem blockchain"
,
"description"
:
"Steem.js the JavaScript API for Steem blockchain"
,
"main"
:
"lib/index.js"
,
"main"
:
"lib/index.js"
,
"scripts"
:
{
"scripts"
:
{
...
@@ -76,5 +76,11 @@
...
@@ -76,5 +76,11 @@
"James Calfee (https://github.com/jcalfee)"
,
"James Calfee (https://github.com/jcalfee)"
,
"Nilesh Suthar (https://github.com/nil1511)"
,
"Nilesh Suthar (https://github.com/nil1511)"
,
"Pedro Tacla Yamada (https://github.com/yamadapc)"
"Pedro Tacla Yamada (https://github.com/yamadapc)"
]
],
"directories"
:
{
"doc"
:
"doc"
,
"example"
:
"examples"
,
"lib"
:
"lib"
,
"test"
:
"test"
}
}
}
This diff is collapsed.
Click to expand it.
src/api/index.js
+
7
−
7
View file @
0450d881
...
@@ -20,8 +20,6 @@ import {
...
@@ -20,8 +20,6 @@ import {
sign
as
signRequest
sign
as
signRequest
}
from
'
@steemit/rpc-auth
'
;
}
from
'
@steemit/rpc-auth
'
;
const
suggestedApiNodes
=
[
'
https://api.hive.blog
'
,
'
https://anyx.io
'
];
class
Steem
extends
EventEmitter
{
class
Steem
extends
EventEmitter
{
constructor
(
options
=
{})
{
constructor
(
options
=
{})
{
super
(
options
);
super
(
options
);
...
@@ -30,7 +28,6 @@ class Steem extends EventEmitter {
...
@@ -30,7 +28,6 @@ class Steem extends EventEmitter {
this
.
options
=
options
;
this
.
options
=
options
;
this
.
seqNo
=
0
;
// used for rpc calls
this
.
seqNo
=
0
;
// used for rpc calls
this
.
errorCount
=
0
;
this
.
errorCount
=
0
;
this
.
errorThreshold
=
3
;
this
.
apiIndex
=
0
;
this
.
apiIndex
=
0
;
methods
.
forEach
(
method
=>
{
methods
.
forEach
(
method
=>
{
const
methodName
=
method
.
method_name
||
camelCase
(
method
.
method
);
const
methodName
=
method
.
method_name
||
camelCase
(
method
.
method
);
...
@@ -57,6 +54,9 @@ class Steem extends EventEmitter {
...
@@ -57,6 +54,9 @@ class Steem extends EventEmitter {
});
});
this
.
callAsync
=
Promise
.
promisify
(
this
.
call
);
this
.
callAsync
=
Promise
.
promisify
(
this
.
call
);
this
.
signedCallAsync
=
Promise
.
promisify
(
this
.
signedCall
);
this
.
signedCallAsync
=
Promise
.
promisify
(
this
.
signedCall
);
console
.
log
(
"
Alternate endpoitns:
"
,
this
.
options
.
alternateAPIEndpoints
);
console
.
log
(
"
Error Failover Threshold:
"
,
this
.
options
.
failoverThreshold
);
}
}
_setTransport
(
options
)
{
_setTransport
(
options
)
{
...
@@ -368,17 +368,17 @@ class Steem extends EventEmitter {
...
@@ -368,17 +368,17 @@ class Steem extends EventEmitter {
console
.
log
(
"
but we're being instructed to ignore this error. cherrio good chap, back to it
"
);
console
.
log
(
"
but we're being instructed to ignore this error. cherrio good chap, back to it
"
);
return
;
return
;
}
}
if
(
this
.
errorCount
>=
this
.
erro
rThreshold
)
if
(
this
.
errorCount
>=
this
.
options
.
failove
rThreshold
)
{
{
this
.
errorCount
=
0
;
this
.
errorCount
=
0
;
this
.
apiIndex
++
;
this
.
apiIndex
++
;
if
(
this
.
apiIndex
>=
suggestedApiNode
s
.
length
)
if
(
this
.
apiIndex
>=
this
.
options
.
alternateAPIEndpoint
s
.
length
)
{
{
this
.
apiIndex
=
0
;
this
.
apiIndex
=
0
;
}
}
let
nextEndpoint
=
suggestedApiNode
s
[
this
.
apiIndex
];
let
nextEndpoint
=
this
.
options
.
alternateAPIEndpoint
s
[
this
.
apiIndex
];
this
.
setOptions
({
url
:
nextEndpoint
});
this
.
setOptions
({
url
:
nextEndpoint
});
console
.
log
(
"
switch to another api endpoint after too many failures. new endpoint is:
"
+
nextEndpoint
);
console
.
log
(
"
switch
ing
to another api endpoint after too many failures. new endpoint is:
"
+
nextEndpoint
);
}
}
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
src/config.js
+
1
−
1
View file @
0450d881
import
each
from
'
lodash/each
'
;
import
each
from
'
lodash/each
'
;
const
defaultConfig
=
require
(
'
.
.
/config.json
'
);
const
defaultConfig
=
require
(
'
./config.json
'
);
class
Config
{
class
Config
{
constructor
(
c
)
{
constructor
(
c
)
{
...
...
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