diff --git a/cmd/tmsp/cli.go b/cmd/tmsp_cli/tmsp_cli.go similarity index 95% rename from cmd/tmsp/cli.go rename to cmd/tmsp_cli/tmsp_cli.go index e8fb7a19f..d90dd10b7 100644 --- a/cmd/tmsp/cli.go +++ b/cmd/tmsp_cli/tmsp_cli.go @@ -241,27 +241,27 @@ func makeRequest(conn net.Conn, req types.Request) (types.Response, error) { var err error // Write desired request - wire.WriteBinary(req, conn, &n, &err) + wire.WriteBinaryLengthPrefixed(req, conn, &n, &err) if err != nil { return nil, err } // Write flush request - wire.WriteBinary(types.RequestFlush{}, conn, &n, &err) + wire.WriteBinaryLengthPrefixed(types.RequestFlush{}, conn, &n, &err) if err != nil { return nil, err } // Read desired response var res types.Response - wire.ReadBinaryPtr(&res, conn, 0, &n, &err) + wire.ReadBinaryPtrLengthPrefixed(&res, conn, 0, &n, &err) if err != nil { return nil, err } // Read flush response var resFlush types.ResponseFlush - wire.ReadBinaryPtr(&resFlush, conn, 0, &n, &err) + wire.ReadBinaryPtrLengthPrefixed(&resFlush, conn, 0, &n, &err) if err != nil { return nil, err } diff --git a/example/golang/dummy_test.go b/example/golang/dummy_test.go index d8b5b0f64..8e93d7d3c 100644 --- a/example/golang/dummy_test.go +++ b/example/golang/dummy_test.go @@ -35,6 +35,7 @@ func TestStream(t *testing.T) { var n int var err error var res types.Response + wire.ReadVarint(conn, &n, &err) // ignore wire.ReadBinaryPtr(&res, conn, 0, &n, &err) if err != nil { Exit(err.Error()) @@ -71,7 +72,7 @@ func TestStream(t *testing.T) { var n int var err error var req types.Request = types.RequestAppendTx{TxBytes: []byte("test")} - wire.WriteBinary(req, conn, &n, &err) + wire.WriteBinaryLengthPrefixed(req, conn, &n, &err) if err != nil { t.Fatal(err.Error()) } @@ -79,7 +80,7 @@ func TestStream(t *testing.T) { // Sometimes send flush messages if counter%123 == 0 { t.Log("flush") - wire.WriteBinary(types.RequestFlush{}, conn, &n, &err) + wire.WriteBinaryLengthPrefixed(types.RequestFlush{}, conn, &n, &err) if err != nil { t.Fatal(err.Error()) } @@ -88,7 +89,7 @@ func TestStream(t *testing.T) { // Send final flush message var n int - wire.WriteBinary(types.RequestFlush{}, conn, &n, &err) + wire.WriteBinaryLengthPrefixed(types.RequestFlush{}, conn, &n, &err) if err != nil { t.Fatal(err.Error()) } diff --git a/server/server.go b/server/server.go index e5945c81c..a9caae953 100644 --- a/server/server.go +++ b/server/server.go @@ -85,7 +85,7 @@ func handleRequests(appC types.AppContext, closeConn chan error, conn net.Conn, var n int var err error var req types.Request - wire.ReadBinaryPtr(&req, bufReader, 0, &n, &err) + wire.ReadBinaryPtrLengthPrefixed(&req, bufReader, 0, &n, &err) if err != nil { if err == io.EOF { closeConn <- fmt.Errorf("Connection closed by client") @@ -146,7 +146,7 @@ func handleResponses(closeConn chan error, responses <-chan types.Response, conn var res = <-responses var n int var err error - wire.WriteBinary(res, bufWriter, &n, &err) + wire.WriteBinaryLengthPrefixed(res, bufWriter, &n, &err) if err != nil { closeConn <- fmt.Errorf("Error in handleResponses: %v", err.Error()) return