Skip to content

Commit

Permalink
vfs: small refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
colindickson committed Jan 11, 2024
1 parent 8efef17 commit 06351b7
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions wasm/wasi/fs/virtual.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,9 @@ func (v *VirtualFile) Stat() (fs.FileInfo, error) {
}

func (v *VirtualFile) Write(bytes []byte) (sent int, err error) {
if strings.HasSuffix(v.name, "sys/substreams/output") { //special function
/// get call from context
call := wasm.FromContext(v.ctx)
call.SetReturnValue(bytes)
if strings.HasSuffix(v.name, "sys/substreams/output") {
//special function
v.setOutput(bytes)
return len(bytes), nil
}

Expand All @@ -64,6 +63,12 @@ func (v *VirtualFile) Write(bytes []byte) (sent int, err error) {
return len(bytes), nil
}

func (v *VirtualFile) setOutput(bytes []byte) {
// get call from context
call := wasm.FromContext(v.ctx)
call.SetReturnValue(bytes)
}

func (v *VirtualFile) Read(bytes []byte) (sent int, err error) {
data := v.Remaining
if !v.Loaded {
Expand Down

0 comments on commit 06351b7

Please sign in to comment.