-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #343 from permaweb/VinceJuliano/boot-loader-342
Vince juliano/boot loader 342
- Loading branch information
Showing
8 changed files
with
248 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
-- This is for aop6 Boot Loader | ||
-- See: https://github.com/permaweb/aos/issues/342 | ||
-- For the Process as the first Message, if On-Boot | ||
-- has the value 'data' then evaluate the data | ||
-- if it is a tx id, then download and evaluate the tx | ||
|
||
local drive = { _version = "0.0.1" } | ||
|
||
function drive.getData(txId) | ||
local file = io.open('/data/' .. txId) | ||
if not file then | ||
return nil, "File not found!" | ||
end | ||
local contents = file:read( | ||
file:seek('end') | ||
) | ||
file:close() | ||
return contents | ||
end | ||
|
||
return function (ao) | ||
local eval = require(".eval")(ao) | ||
return function (msg) | ||
if msg.Tags['On-Boot'] == nil then | ||
return | ||
end | ||
if msg.Tags['On-Boot'] == 'Data' then | ||
eval(msg) | ||
else | ||
local loadedVal = drive.getData(msg.Tags['On-Boot']) | ||
eval({ Data = loadedVal }) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters