Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
hive-ruby
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
hive-ruby
Commits
b6c8f93e
Unverified
Commit
b6c8f93e
authored
6 years ago
by
Anthony Martin
Committed by
GitHub
6 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #12 from steemit/6-recover-requested-blocks
6 recover requested blocks
parents
58c66e46
421e4cb3
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
lib/steem/api.rb
+0
-21
0 additions, 21 deletions
lib/steem/api.rb
lib/steem/rpc/base_client.rb
+13
-0
13 additions, 0 deletions
lib/steem/rpc/base_client.rb
lib/steem/rpc/http_client.rb
+17
-1
17 additions, 1 deletion
lib/steem/rpc/http_client.rb
lib/steem/stream.rb
+12
-4
12 additions, 4 deletions
lib/steem/stream.rb
with
42 additions
and
26 deletions
lib/steem/api.rb
+
0
−
21
View file @
b6c8f93e
...
...
@@ -149,19 +149,6 @@ module Steem
@@signatures
[
url
][
rpc_method_name
]
||=
Api
::
jsonrpc
(
url
).
get_signature
(
method:
rpc_method_name
).
result
end
# @private
def
raise_error_response
(
rpc_method_name
,
rpc_args
,
response
)
raise
UnknownError
,
"
#{
rpc_method_name
}
:
#{
response
}
"
if
response
.
error
.
nil?
error
=
response
.
error
if
error
.
message
==
'Invalid Request'
raise
Steem
::
ArgumentError
,
"Unexpected arguments:
#{
rpc_args
.
inspect
}
. Expected:
#{
rpc_method_name
}
(
#{
args_keys_to_s
(
rpc_method_name
)
}
)"
end
BaseError
.
build_error
(
error
,
rpc_method_name
)
end
# @private
def
respond_to_missing?
(
m
,
include_private
=
false
)
methods
.
nil?
?
false
:
methods
.
include?
(
m
.
to_sym
)
...
...
@@ -203,14 +190,6 @@ module Steem
response
=
rpc_client
.
rpc_execute
(
@api_name
,
m
,
rpc_args
)
if
defined?
(
response
.
error
)
&&
!!
response
.
error
if
!!
response
.
error
.
message
raise_error_response
rpc_method_name
,
rpc_args
,
response
else
raise
Steem
::
ArgumentError
,
response
.
error
.
inspect
end
end
if
!!
block
case
response
when
Hashie
::
Mash
then
yield
response
.
result
,
response
.
error
,
response
.
id
...
...
This diff is collapsed.
Click to expand it.
lib/steem/rpc/base_client.rb
+
13
−
0
View file @
b6c8f93e
...
...
@@ -161,6 +161,19 @@ module Steem
sleep
@backoff
end
# @private
def
raise_error_response
(
rpc_method_name
,
rpc_args
,
response
)
raise
UnknownError
,
"
#{
rpc_method_name
}
:
#{
response
}
"
if
response
.
error
.
nil?
error
=
response
.
error
if
error
.
message
==
'Invalid Request'
raise
Steem
::
ArgumentError
,
"Unexpected arguments:
#{
rpc_args
.
inspect
}
. Expected:
#{
rpc_method_name
}
(
#{
args_keys_to_s
(
rpc_method_name
)
}
)"
end
BaseError
.
build_error
(
error
,
rpc_method_name
)
end
end
end
end
This diff is collapsed.
Click to expand it.
lib/steem/rpc/http_client.rb
+
17
−
1
View file @
b6c8f93e
...
...
@@ -17,7 +17,7 @@ module Steem
#
# @private
TIMEOUT_ERRORS
=
[
Net
::
OpenTimeout
,
JSON
::
ParserError
,
Net
::
ReadTimeout
,
Errno
::
EBADF
,
IOError
,
Errno
::
ENETDOWN
]
Errno
::
EBADF
,
IOError
,
Errno
::
ENETDOWN
,
Steem
::
RemoteDatabaseLockError
]
# @private
POST_HEADERS
=
{
...
...
@@ -108,6 +108,22 @@ module Steem
else
;
response
end
[
response
].
flatten
.
each_with_index
do
|
r
,
i
|
if
defined?
(
r
.
error
)
&&
!!
r
.
error
if
!!
r
.
error
.
message
begin
rpc_method_name
=
"
#{
api_name
}
.
#{
api_method
}
"
rpc_args
=
[
request_object
].
flatten
[
i
]
raise_error_response
rpc_method_name
,
rpc_args
,
r
rescue
*
TIMEOUT_ERRORS
=>
e
throw
retry_timeout
(
:tota_cera_pila
,
e
)
end
else
raise
Steem
::
ArgumentError
,
r
.
error
.
inspect
end
end
end
yield_response
response
,
&
block
when
'504'
# Gateway Timeout
throw
retry_timeout
(
:tota_cera_pila
,
response
.
body
)
...
...
This diff is collapsed.
Click to expand it.
lib/steem/stream.rb
+
12
−
4
View file @
b6c8f93e
...
...
@@ -91,6 +91,14 @@ module Steem
# @option options [Integer] :until_block_num Ends the stream at the given block number. Default: nil.
def
transactions
(
options
=
{},
&
block
)
blocks
(
options
)
do
|
block
,
block_num
|
if
block
.
nil?
warn
"Batch missing block_num:
#{
block_num
}
, retrying ..."
block
=
block_api
.
get_block
(
block_num:
block_num
)
do
|
result
|
result
.
block
end
end
block
.
transactions
.
each_with_index
do
|
transaction
,
index
|
trx_id
=
block
.
transaction_ids
[
index
]
...
...
@@ -332,9 +340,8 @@ module Steem
end
response
=
account_history_api
.
get_ops_in_block
(
*
get_ops_in_block_options
)
result
=
response
.
result
if
res
ult
.
nil?
if
res
ponse
.
nil?
||
(
result
=
response
.
result
)
.
nil?
if
retries
<
MAX_RETRY_COUNT
warn
"Retrying get_ops_in_block on block
#{
block_num
}
"
unless
@no_warn
retries
=
retries
+
1
...
...
@@ -360,7 +367,8 @@ module Steem
retries
=
retries
+
1
redo
else
raise
TooManyRetriesError
,
"unable to find virtual operations for block:
#{
block_num
}
"
warn
"unable to find virtual operations for block:
#{
block_num
}
"
# raise TooManyRetriesError, "unable to find virtual operations for block: #{block_num}"
end
end
...
...
@@ -374,4 +382,4 @@ module Steem
end
end
end
end
\ No newline at end of file
end
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