Fix imports
This commit is contained in:
parent
4ef4721820
commit
9299ba5fa6
@ -2,12 +2,12 @@ package client
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/filecoin-project/go-lotus/api"
|
"github.com/filecoin-project/go-lotus/api"
|
||||||
"github.com/filecoin-project/go-lotus/lib"
|
"github.com/filecoin-project/go-lotus/lib/jsonrpc"
|
||||||
)
|
)
|
||||||
|
|
||||||
// NewRPC creates a new http jsonrpc client.
|
// NewRPC creates a new http jsonrpc client.
|
||||||
func NewRPC(addr string) api.API {
|
func NewRPC(addr string) api.API {
|
||||||
var res api.Struct
|
var res api.Struct
|
||||||
lib.NewClient(addr, "Filecoin", &res.Internal)
|
jsonrpc.NewClient(addr, "Filecoin", &res.Internal)
|
||||||
return &res
|
return &res
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,6 @@ import (
|
|||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
tf "github.com/filecoin-project/go-filecoin/testhelpers/testflags"
|
|
||||||
"github.com/filecoin-project/go-lotus/lib/bls-signatures"
|
"github.com/filecoin-project/go-lotus/lib/bls-signatures"
|
||||||
"github.com/filecoin-project/go-lotus/lib/crypto"
|
"github.com/filecoin-project/go-lotus/lib/crypto"
|
||||||
)
|
)
|
||||||
@ -23,8 +22,6 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestRandomIDAddress(t *testing.T) {
|
func TestRandomIDAddress(t *testing.T) {
|
||||||
tf.UnitTest(t)
|
|
||||||
|
|
||||||
assert := assert.New(t)
|
assert := assert.New(t)
|
||||||
|
|
||||||
addr, err := NewIDAddress(uint64(rand.Int()))
|
addr, err := NewIDAddress(uint64(rand.Int()))
|
||||||
@ -41,8 +38,6 @@ func TestRandomIDAddress(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestVectorsIDAddress(t *testing.T) {
|
func TestVectorsIDAddress(t *testing.T) {
|
||||||
tf.UnitTest(t)
|
|
||||||
|
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
input uint64
|
input uint64
|
||||||
expected string
|
expected string
|
||||||
@ -91,8 +86,6 @@ func TestVectorsIDAddress(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestSecp256k1Address(t *testing.T) {
|
func TestSecp256k1Address(t *testing.T) {
|
||||||
tf.UnitTest(t)
|
|
||||||
|
|
||||||
assert := assert.New(t)
|
assert := assert.New(t)
|
||||||
|
|
||||||
sk, err := crypto.GenerateKey()
|
sk, err := crypto.GenerateKey()
|
||||||
@ -112,8 +105,6 @@ func TestSecp256k1Address(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestVectorSecp256k1Address(t *testing.T) {
|
func TestVectorSecp256k1Address(t *testing.T) {
|
||||||
tf.UnitTest(t)
|
|
||||||
|
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
input []byte
|
input []byte
|
||||||
expected string
|
expected string
|
||||||
@ -189,8 +180,6 @@ func TestVectorSecp256k1Address(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestRandomActorAddress(t *testing.T) {
|
func TestRandomActorAddress(t *testing.T) {
|
||||||
tf.UnitTest(t)
|
|
||||||
|
|
||||||
assert := assert.New(t)
|
assert := assert.New(t)
|
||||||
|
|
||||||
actorMsg := make([]byte, 20)
|
actorMsg := make([]byte, 20)
|
||||||
@ -210,8 +199,6 @@ func TestRandomActorAddress(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestVectorActorAddress(t *testing.T) {
|
func TestVectorActorAddress(t *testing.T) {
|
||||||
tf.UnitTest(t)
|
|
||||||
|
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
input []byte
|
input []byte
|
||||||
expected string
|
expected string
|
||||||
@ -265,8 +252,6 @@ func TestVectorActorAddress(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestRandomBLSAddress(t *testing.T) {
|
func TestRandomBLSAddress(t *testing.T) {
|
||||||
tf.UnitTest(t)
|
|
||||||
|
|
||||||
assert := assert.New(t)
|
assert := assert.New(t)
|
||||||
|
|
||||||
pk := bls.PrivateKeyPublicKey(bls.PrivateKeyGenerate())
|
pk := bls.PrivateKeyPublicKey(bls.PrivateKeyGenerate())
|
||||||
@ -285,8 +270,6 @@ func TestRandomBLSAddress(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestVectorBLSAddress(t *testing.T) {
|
func TestVectorBLSAddress(t *testing.T) {
|
||||||
tf.UnitTest(t)
|
|
||||||
|
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
input []byte
|
input []byte
|
||||||
expected string
|
expected string
|
||||||
@ -350,8 +333,6 @@ func TestVectorBLSAddress(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestInvalidStringAddresses(t *testing.T) {
|
func TestInvalidStringAddresses(t *testing.T) {
|
||||||
tf.UnitTest(t)
|
|
||||||
|
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
input string
|
input string
|
||||||
expetErr error
|
expetErr error
|
||||||
@ -378,8 +359,6 @@ func TestInvalidStringAddresses(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestInvalidByteAddresses(t *testing.T) {
|
func TestInvalidByteAddresses(t *testing.T) {
|
||||||
tf.UnitTest(t)
|
|
||||||
|
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
input []byte
|
input []byte
|
||||||
expetErr error
|
expetErr error
|
||||||
@ -414,8 +393,6 @@ func TestInvalidByteAddresses(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestChecksum(t *testing.T) {
|
func TestChecksum(t *testing.T) {
|
||||||
tf.UnitTest(t)
|
|
||||||
|
|
||||||
assert := assert.New(t)
|
assert := assert.New(t)
|
||||||
|
|
||||||
data := []byte("helloworld")
|
data := []byte("helloworld")
|
||||||
@ -430,8 +407,6 @@ func TestChecksum(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestAddressFormat(t *testing.T) {
|
func TestAddressFormat(t *testing.T) {
|
||||||
tf.UnitTest(t)
|
|
||||||
|
|
||||||
assert := assert.New(t)
|
assert := assert.New(t)
|
||||||
require := require.New(t)
|
require := require.New(t)
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ import (
|
|||||||
"bufio"
|
"bufio"
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/filecoin-project/go-lotus/lib"
|
"github.com/filecoin-project/go-lotus/lib/cborrpc"
|
||||||
"github.com/libp2p/go-libp2p-core/protocol"
|
"github.com/libp2p/go-libp2p-core/protocol"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"sync"
|
"sync"
|
||||||
@ -14,7 +14,6 @@ import (
|
|||||||
cbor "github.com/ipfs/go-ipld-cbor"
|
cbor "github.com/ipfs/go-ipld-cbor"
|
||||||
inet "github.com/libp2p/go-libp2p-core/network"
|
inet "github.com/libp2p/go-libp2p-core/network"
|
||||||
"github.com/libp2p/go-libp2p-peer"
|
"github.com/libp2p/go-libp2p-peer"
|
||||||
//"github.com/libp2p/go-libp2p-protocol"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type NewStreamFunc func(context.Context, peer.ID, ...protocol.ID) (inet.Stream, error)
|
type NewStreamFunc func(context.Context, peer.ID, ...protocol.ID) (inet.Stream, error)
|
||||||
@ -80,7 +79,7 @@ func (bss *BlockSyncService) HandleStream(s inet.Stream) {
|
|||||||
log.Error("handling block sync request")
|
log.Error("handling block sync request")
|
||||||
|
|
||||||
var req BlockSyncRequest
|
var req BlockSyncRequest
|
||||||
if err := lib.ReadCborRPC(bufio.NewReader(s), &req); err != nil {
|
if err := cborrpc.ReadCborRPC(bufio.NewReader(s), &req); err != nil {
|
||||||
log.Errorf("failed to read block sync request: %s", err)
|
log.Errorf("failed to read block sync request: %s", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -92,7 +91,7 @@ func (bss *BlockSyncService) HandleStream(s inet.Stream) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := lib.WriteCborRPC(s, resp); err != nil {
|
if err := cborrpc.WriteCborRPC(s, resp); err != nil {
|
||||||
log.Error("failed to write back response for handle stream: ", err)
|
log.Error("failed to write back response for handle stream: ", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -326,12 +325,12 @@ func (bs *BlockSync) sendRequestToPeer(ctx context.Context, p peer.ID, req *Bloc
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := lib.WriteCborRPC(s, req); err != nil {
|
if err := cborrpc.WriteCborRPC(s, req); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
var res BlockSyncResponse
|
var res BlockSyncResponse
|
||||||
if err := lib.ReadCborRPC(bufio.NewReader(s), &res); err != nil {
|
if err := cborrpc.ReadCborRPC(bufio.NewReader(s), &res); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
package daemon
|
package daemon
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/filecoin-project/go-lotus/lib"
|
"github.com/filecoin-project/go-lotus/lib/jsonrpc"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/filecoin-project/go-lotus/api"
|
"github.com/filecoin-project/go-lotus/api"
|
||||||
)
|
)
|
||||||
|
|
||||||
func serveRPC(api api.API) error {
|
func serveRPC(api api.API) error {
|
||||||
rpcServer := lib.NewServer()
|
rpcServer := jsonrpc.NewServer()
|
||||||
rpcServer.Register("Filecoin", api)
|
rpcServer.Register("Filecoin", api)
|
||||||
http.Handle("/rpc/v0", rpcServer)
|
http.Handle("/rpc/v0", rpcServer)
|
||||||
return http.ListenAndServe(":1234", http.DefaultServeMux)
|
return http.ListenAndServe(":1234", http.DefaultServeMux)
|
||||||
|
@ -6,7 +6,6 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/filecoin-project/go-lotus/lib"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"reflect"
|
"reflect"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
@ -38,10 +37,10 @@ func (r *result) UnmarshalJSON(raw []byte) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type clientResponse struct {
|
type clientResponse struct {
|
||||||
Jsonrpc string `json:"jsonrpc"`
|
Jsonrpc string `json:"jsonrpc"`
|
||||||
Result result `json:"result"`
|
Result result `json:"result"`
|
||||||
ID int64 `json:"id"`
|
ID int64 `json:"id"`
|
||||||
Error *lib.respError `json:"error,omitempty"`
|
Error *respError `json:"error,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// ClientCloser is used to close Client from further use
|
// ClientCloser is used to close Client from further use
|
||||||
@ -73,7 +72,7 @@ func NewClient(addr string, namespace string, handler interface{}) ClientCloser
|
|||||||
panic("handler field not a func")
|
panic("handler field not a func")
|
||||||
}
|
}
|
||||||
|
|
||||||
valOut, errOut, nout := lib.processFuncOut(ftyp)
|
valOut, errOut, nout := processFuncOut(ftyp)
|
||||||
|
|
||||||
processResponse := func(resp clientResponse, code int) []reflect.Value {
|
processResponse := func(resp clientResponse, code int) []reflect.Value {
|
||||||
out := make([]reflect.Value, nout)
|
out := make([]reflect.Value, nout)
|
||||||
@ -112,14 +111,14 @@ func NewClient(addr string, namespace string, handler interface{}) ClientCloser
|
|||||||
|
|
||||||
fn := reflect.MakeFunc(ftyp, func(args []reflect.Value) (results []reflect.Value) {
|
fn := reflect.MakeFunc(ftyp, func(args []reflect.Value) (results []reflect.Value) {
|
||||||
id := atomic.AddInt64(&idCtr, 1)
|
id := atomic.AddInt64(&idCtr, 1)
|
||||||
params := make([]lib.param, len(args)-hasCtx)
|
params := make([]param, len(args)-hasCtx)
|
||||||
for i, arg := range args[hasCtx:] {
|
for i, arg := range args[hasCtx:] {
|
||||||
params[i] = lib.param{
|
params[i] = param{
|
||||||
v: arg,
|
v: arg,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
req := lib.request{
|
req := request{
|
||||||
Jsonrpc: "2.0",
|
Jsonrpc: "2.0",
|
||||||
ID: &id,
|
ID: &id,
|
||||||
Method: namespace + "." + f.Name,
|
Method: namespace + "." + f.Name,
|
||||||
|
@ -4,7 +4,6 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/filecoin-project/go-lotus/lib"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"reflect"
|
"reflect"
|
||||||
)
|
)
|
||||||
@ -176,7 +175,7 @@ func (s *RPCServer) Register(namespace string, r interface{}) {
|
|||||||
|
|
||||||
funcType := method.Func.Type()
|
funcType := method.Func.Type()
|
||||||
hasCtx := 0
|
hasCtx := 0
|
||||||
if funcType.NumIn() >= 2 && funcType.In(1) == lib.contextType {
|
if funcType.NumIn() >= 2 && funcType.In(1) == contextType {
|
||||||
hasCtx = 1
|
hasCtx = 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -213,7 +212,7 @@ func processFuncOut(funcType reflect.Type) (valOut int, errOut int, n int) {
|
|||||||
switch n {
|
switch n {
|
||||||
case 0:
|
case 0:
|
||||||
case 1:
|
case 1:
|
||||||
if funcType.Out(0) == lib.errorType {
|
if funcType.Out(0) == errorType {
|
||||||
errOut = 0
|
errOut = 0
|
||||||
} else {
|
} else {
|
||||||
valOut = 0
|
valOut = 0
|
||||||
@ -221,7 +220,7 @@ func processFuncOut(funcType reflect.Type) (valOut int, errOut int, n int) {
|
|||||||
case 2:
|
case 2:
|
||||||
valOut = 0
|
valOut = 0
|
||||||
errOut = 1
|
errOut = 1
|
||||||
if funcType.Out(1) != lib.errorType {
|
if funcType.Out(1) != errorType {
|
||||||
panic("expected error as second return value")
|
panic("expected error as second return value")
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
@ -3,7 +3,6 @@ package jsonrpc
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"github.com/filecoin-project/go-lotus/lib"
|
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
"strconv"
|
"strconv"
|
||||||
"sync"
|
"sync"
|
||||||
@ -57,7 +56,7 @@ func TestRPC(t *testing.T) {
|
|||||||
|
|
||||||
serverHandler := &SimpleServerHandler{}
|
serverHandler := &SimpleServerHandler{}
|
||||||
|
|
||||||
rpcServer := lib.NewServer()
|
rpcServer := NewServer()
|
||||||
rpcServer.Register("SimpleServerHandler", serverHandler)
|
rpcServer.Register("SimpleServerHandler", serverHandler)
|
||||||
|
|
||||||
// httptest stuff
|
// httptest stuff
|
||||||
@ -71,7 +70,7 @@ func TestRPC(t *testing.T) {
|
|||||||
AddGet func(int) int
|
AddGet func(int) int
|
||||||
StringMatch func(t TestType, i2 int64) (out TestOut, err error)
|
StringMatch func(t TestType, i2 int64) (out TestOut, err error)
|
||||||
}
|
}
|
||||||
closer := lib.NewClient(testServ.URL, "SimpleServerHandler", &client)
|
closer := NewClient(testServ.URL, "SimpleServerHandler", &client)
|
||||||
defer closer()
|
defer closer()
|
||||||
|
|
||||||
// Add(int) error
|
// Add(int) error
|
||||||
@ -131,7 +130,7 @@ func TestRPC(t *testing.T) {
|
|||||||
var noret struct {
|
var noret struct {
|
||||||
Add func(int)
|
Add func(int)
|
||||||
}
|
}
|
||||||
closer = lib.NewClient(testServ.URL, "SimpleServerHandler", &noret)
|
closer = NewClient(testServ.URL, "SimpleServerHandler", &noret)
|
||||||
|
|
||||||
// this one should actually work
|
// this one should actually work
|
||||||
noret.Add(4)
|
noret.Add(4)
|
||||||
@ -143,7 +142,7 @@ func TestRPC(t *testing.T) {
|
|||||||
var noparam struct {
|
var noparam struct {
|
||||||
Add func()
|
Add func()
|
||||||
}
|
}
|
||||||
closer = lib.NewClient(testServ.URL, "SimpleServerHandler", &noparam)
|
closer = NewClient(testServ.URL, "SimpleServerHandler", &noparam)
|
||||||
|
|
||||||
// shouldn't panic
|
// shouldn't panic
|
||||||
noparam.Add()
|
noparam.Add()
|
||||||
@ -152,7 +151,7 @@ func TestRPC(t *testing.T) {
|
|||||||
var erronly struct {
|
var erronly struct {
|
||||||
AddGet func() (int, error)
|
AddGet func() (int, error)
|
||||||
}
|
}
|
||||||
closer = lib.NewClient(testServ.URL, "SimpleServerHandler", &erronly)
|
closer = NewClient(testServ.URL, "SimpleServerHandler", &erronly)
|
||||||
|
|
||||||
_, err = erronly.AddGet()
|
_, err = erronly.AddGet()
|
||||||
if err == nil || err.Error() != "RPC error (-32602): wrong param count" {
|
if err == nil || err.Error() != "RPC error (-32602): wrong param count" {
|
||||||
@ -163,7 +162,7 @@ func TestRPC(t *testing.T) {
|
|||||||
var wrongtype struct {
|
var wrongtype struct {
|
||||||
Add func(string) error
|
Add func(string) error
|
||||||
}
|
}
|
||||||
closer = lib.NewClient(testServ.URL, "SimpleServerHandler", &wrongtype)
|
closer = NewClient(testServ.URL, "SimpleServerHandler", &wrongtype)
|
||||||
|
|
||||||
err = wrongtype.Add("not an int")
|
err = wrongtype.Add("not an int")
|
||||||
if err == nil || err.Error() != "RPC error (-32700): json: cannot unmarshal string into Go value of type int" {
|
if err == nil || err.Error() != "RPC error (-32700): json: cannot unmarshal string into Go value of type int" {
|
||||||
@ -174,7 +173,7 @@ func TestRPC(t *testing.T) {
|
|||||||
var notfound struct {
|
var notfound struct {
|
||||||
NotThere func(string) error
|
NotThere func(string) error
|
||||||
}
|
}
|
||||||
closer = lib.NewClient(testServ.URL, "SimpleServerHandler", ¬found)
|
closer = NewClient(testServ.URL, "SimpleServerHandler", ¬found)
|
||||||
|
|
||||||
err = notfound.NotThere("hello?")
|
err = notfound.NotThere("hello?")
|
||||||
if err == nil || err.Error() != "RPC error (-32601): method 'SimpleServerHandler.NotThere' not found" {
|
if err == nil || err.Error() != "RPC error (-32601): method 'SimpleServerHandler.NotThere' not found" {
|
||||||
@ -208,7 +207,7 @@ func TestCtx(t *testing.T) {
|
|||||||
|
|
||||||
serverHandler := &CtxHandler{}
|
serverHandler := &CtxHandler{}
|
||||||
|
|
||||||
rpcServer := lib.NewServer()
|
rpcServer := NewServer()
|
||||||
rpcServer.Register("CtxHandler", serverHandler)
|
rpcServer.Register("CtxHandler", serverHandler)
|
||||||
|
|
||||||
// httptest stuff
|
// httptest stuff
|
||||||
@ -220,7 +219,7 @@ func TestCtx(t *testing.T) {
|
|||||||
var client struct {
|
var client struct {
|
||||||
Test func(ctx context.Context)
|
Test func(ctx context.Context)
|
||||||
}
|
}
|
||||||
closer := lib.NewClient(testServ.URL, "CtxHandler", &client)
|
closer := NewClient(testServ.URL, "CtxHandler", &client)
|
||||||
|
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), 100*time.Millisecond)
|
ctx, cancel := context.WithTimeout(context.Background(), 100*time.Millisecond)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
@ -240,7 +239,7 @@ func TestCtx(t *testing.T) {
|
|||||||
var noCtxClient struct {
|
var noCtxClient struct {
|
||||||
Test func()
|
Test func()
|
||||||
}
|
}
|
||||||
closer = lib.NewClient(testServ.URL, "CtxHandler", &noCtxClient)
|
closer = NewClient(testServ.URL, "CtxHandler", &noCtxClient)
|
||||||
|
|
||||||
noCtxClient.Test()
|
noCtxClient.Test()
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/filecoin-project/go-lotus/chain"
|
"github.com/filecoin-project/go-lotus/chain"
|
||||||
"github.com/filecoin-project/go-lotus/lib"
|
"github.com/filecoin-project/go-lotus/lib/cborrpc"
|
||||||
|
|
||||||
"github.com/libp2p/go-libp2p-core/host"
|
"github.com/libp2p/go-libp2p-core/host"
|
||||||
|
|
||||||
@ -46,7 +46,7 @@ func (hs *Service) HandleStream(s inet.Stream) {
|
|||||||
defer s.Close()
|
defer s.Close()
|
||||||
|
|
||||||
var hmsg Message
|
var hmsg Message
|
||||||
if err := lib.ReadCborRPC(s, &hmsg); err != nil {
|
if err := cborrpc.ReadCborRPC(s, &hmsg); err != nil {
|
||||||
log.Infow("failed to read hello message", "error", err)
|
log.Infow("failed to read hello message", "error", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -91,7 +91,7 @@ func (hs *Service) SayHello(ctx context.Context, pid peer.ID) error {
|
|||||||
fmt.Println("SENDING HELLO MESSAGE: ", hts.Cids())
|
fmt.Println("SENDING HELLO MESSAGE: ", hts.Cids())
|
||||||
fmt.Println("hello message genesis: ", gen.Cid())
|
fmt.Println("hello message genesis: ", gen.Cid())
|
||||||
|
|
||||||
if err := lib.WriteCborRPC(s, hmsg); err != nil {
|
if err := cborrpc.WriteCborRPC(s, hmsg); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user