Skip to content

Commit

Permalink
wasi: remove unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
colindickson committed Jan 11, 2024
1 parent 0bc7042 commit 84fc7f6
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 42 deletions.
Binary file modified wasm/bench/substreams_wasi_go/main.wasm
Binary file not shown.
42 changes: 0 additions & 42 deletions wasm/wasi/module.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
package wasi

import (
"bufio"
"bytes"
"context"
"encoding/base64"
"encoding/json"
"fmt"
"io"
"log"
Expand All @@ -31,7 +28,6 @@ type Module struct {
userModule wazero.CompiledModule
hostModules []wazero.CompiledModule
send io.ReadWriter
receive io.ReadWriter
}

func init() {
Expand All @@ -52,15 +48,13 @@ func newModule(ctx context.Context, wasmCode []byte, wasmCodeType string, regist
wazConfig := wazero.NewModuleConfig()

s := bytes.NewBuffer(nil)
r := bytes.NewBuffer(nil)

return &Module{
wazModuleConfig: wazConfig,
wazRuntime: runtime,
userModule: mod,
hostModules: hostModules,
send: s,
receive: r,
}, nil
}

Expand Down Expand Up @@ -121,42 +115,6 @@ type message struct {
payload []byte
}

func (m *Module) receiveMessage(context.Context) error {
s := bufio.NewScanner(m.receive)
for {

// Repeated calls to Scan yield the token sequence found in the input.
for s.Scan() {
encoded := s.Text()
decoded, err := base64.StdEncoding.DecodeString(encoded)
if err != nil {
return fmt.Errorf("decoding input: %w", err)
}
msg := &message{}
err = json.Unmarshal(decoded, msg)
if err != nil {
return fmt.Errorf("unmarshalling message: %w", err)
}
switch msg.call {
case "Println":
fmt.Println("printing...", string(msg.payload))
_, err := m.send.Write([]byte("\n"))
if err != nil {
return fmt.Errorf("writing ok: %w", err)
}
default:
panic(fmt.Errorf("unknown call: %q", msg.call))
}

}
if err := s.Err(); err != nil {
return fmt.Errorf("reading input: %w", err)
}

}
return nil
}

func (m *Module) instantiateModule(ctx context.Context) error {
m.Lock()
defer m.Unlock()
Expand Down

0 comments on commit 84fc7f6

Please sign in to comment.