Skip to content

Commit

Permalink
fix seek
Browse files Browse the repository at this point in the history
  • Loading branch information
elliotsayes committed Dec 12, 2024
1 parent 00a67cc commit e941800
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions extensions/weavedrive/client/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ function drive.getBlock(height)
if not block then
return nil, "Block Header not found!"
end
local headers = require("json").decode(block:read(block:seek("end")))
local size = block:seek("end")
block:seek("set")
local headers = require("json").decode(block:read(size))
block:close()
return headers
end
Expand All @@ -20,7 +22,9 @@ function drive.getTx(txId)
if not file then
return nil, "File not found!"
end
local contents = require("json").decode(file:read(file:seek("end")))
local size = file:seek("end")
file:seek("set")
local contents = require("json").decode(file:read(size))
file:close()
return contents
end
Expand All @@ -30,7 +34,9 @@ function drive.getData(txId)
if not file then
return nil, "File not found!"
end
local contents = file:read(file:seek("end"))
local size = file:seek("end")
file:seek("set")
local contents = file:read(size)
file:close()
return contents
end
Expand Down

0 comments on commit e941800

Please sign in to comment.