Skip to content

Commit

Permalink
chore: simplify _get_block parser
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenctw committed Dec 13, 2023
1 parent ec8a6ec commit 025b1f5
Showing 1 changed file with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions permissionless-arbitration/lua_node/blockchain/reader.lua
Original file line number Diff line number Diff line change
Expand Up @@ -132,21 +132,13 @@ function Reader:_get_block(block)
assert(handle)

local ret
local str = handle:read()
while str do
if str:find "Error" or str:find "error" then
local err_str = handle:read "*a"
handle:close()
error(string.format("Cast block failed:\n%s", err_str))
end

ret = str:match("timestamp (%d+)")
if ret then
break
end

str = handle:read()
local str = handle:read "*a"
if str:find "Error" or str:find "error" then
handle:close()
error(string.format("Cast block failed:\n%s", str))
end

ret = str:match("timestamp (%d+)")
handle:close()

return ret
Expand Down

0 comments on commit 025b1f5

Please sign in to comment.