Skip to content

Commit

Permalink
chore: fix linter errors
Browse files Browse the repository at this point in the history
  • Loading branch information
tzdybal committed Nov 18, 2024
1 parent f659060 commit 7cf6d40
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 0 deletions.
59 changes: 59 additions & 0 deletions cmd/dummy/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package main

import (
"errors"
"log"
"net"
"os"
"sync"
"time"

"google.golang.org/grpc"

grpcproxy "github.com/rollkit/go-execution/proxy/grpc"
"github.com/rollkit/go-execution/test"
pb "github.com/rollkit/go-execution/types/pb/execution"
)

const bufSize = 1024 * 1024

func main() {
dummy := test.NewDummyExecutor()
config := &grpcproxy.Config{
DefaultTimeout: 5 * time.Second,
MaxRequestSize: bufSize,
}

listenAddress := "127.0.0.1:40041"
if len(os.Args) == 2 {
listenAddress = os.Args[1]
}

listener, err := net.Listen("tcp4", listenAddress)
if err != nil {
log.Fatalf("error while creating listener: %v\n", err)
}
defer func() {
_ = listener.Close()
}()

log.Println("Starting server...")
server := grpcproxy.NewServer(dummy, config)
s := grpc.NewServer()
pb.RegisterExecutionServiceServer(s, server)

wg := sync.WaitGroup{}
wg.Add(1)

go func() {
log.Println("Serving...")
if err := s.Serve(listener); err != nil && !errors.Is(err, grpc.ErrServerStopped) {
log.Fatalf("Server exited with error: %v\n", err)
}
wg.Done()
}()
defer s.Stop()

wg.Wait()
log.Println("Server stopped")
}
1 change: 1 addition & 0 deletions test/dummy.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ func (e *DummyExecutor) GetTxs(context.Context) ([]types.Tx, error) {
return txs, nil
}

// InjectTx adds a transaction to the internal list of injected transactions in the DummyExecutor instance.
func (e *DummyExecutor) InjectTx(tx types.Tx) {
e.injectedTxs = append(e.injectedTxs, tx)
}
Expand Down

0 comments on commit 7cf6d40

Please sign in to comment.