diff --git a/pkg/network/message.go b/pkg/network/message.go index 250508dc4..e8cefc255 100644 --- a/pkg/network/message.go +++ b/pkg/network/message.go @@ -167,9 +167,6 @@ func (m *Message) unmarshalPayload(r io.Reader) error { return err } - fmt.Printf("incomming payload: %d bytes\n", len(pbuf)) - fmt.Println(pbuf) - if uint32(n) != m.Length { return fmt.Errorf("expected to have read exactly %d bytes got %d", m.Length, n) } diff --git a/pkg/network/payload/addr.go b/pkg/network/payload/addr.go index b3cee7745..08ecd61fa 100644 --- a/pkg/network/payload/addr.go +++ b/pkg/network/payload/addr.go @@ -28,7 +28,7 @@ func (p *AddrWithTime) UnmarshalBinary(b []byte) error { p.Timestamp = binary.LittleEndian.Uint32(b[0:4]) p.Services = binary.LittleEndian.Uint64(b[4:12]) binary.Read(bytes.NewReader(b[12:28]), binary.BigEndian, &p.Addr.IP) - p.Addr.Port = binary.LittleEndian.Uint16(b[28:30]) + p.Addr.Port = binary.BigEndian.Uint16(b[28:30]) return nil } diff --git a/pkg/network/payload/inventory.go b/pkg/network/payload/inventory.go index 1ad887e15..ca508b4bb 100644 --- a/pkg/network/payload/inventory.go +++ b/pkg/network/payload/inventory.go @@ -3,7 +3,6 @@ package payload import ( "bytes" "encoding/binary" - "fmt" . "github.com/anthdm/neo-go/pkg/util" ) @@ -48,8 +47,6 @@ func (p *Inventory) UnmarshalBinary(b []byte) error { // TODO: what byte is [1:2] ? // We have 1 byte for the type which is uint8 and 32 for the hash. // There is 1 byte left over. - fmt.Println(b[0:1]) - fmt.Println(b[1:2]) binary.Read(bytes.NewReader(b), binary.LittleEndian, &p.Type) p.Hash.UnmarshalBinary(b[2:len(b)]) return nil diff --git a/pkg/network/server.go b/pkg/network/server.go index 5eebfd26f..c9e3adaae 100644 --- a/pkg/network/server.go +++ b/pkg/network/server.go @@ -171,10 +171,7 @@ func (s *Server) loop() { // TODO: unregister peers on error. // processMessage processes the received message from a remote node. func (s *Server) processMessage(msg *Message, peer *Peer) error { - rpcLogger.Printf("IN :: %s", msg.commandType()) - if msg.Length > 0 { - rpcLogger.Printf("IN :: %+v", msg.Payload) - } + rpcLogger.Printf("IN :: %s :: %+v", msg.commandType(), msg.Payload) switch msg.commandType() { case cmdVersion: @@ -228,6 +225,9 @@ func (s *Server) handleVersionCmd(v *payload.Version, peer *Peer) error { } func (s *Server) handleAddrCmd(addrList *payload.AddressList, peer *Peer) error { + for _, addr := range addrList.Addrs { + fmt.Println(addr) + } return nil } diff --git a/pkg/network/tcp.go b/pkg/network/tcp.go index c530c3cff..408be9b06 100644 --- a/pkg/network/tcp.go +++ b/pkg/network/tcp.go @@ -52,8 +52,8 @@ func handleConnection(s *Server, conn net.Conn, initiated bool) { // Read from the connection and decode it into an RPCMessage and // tell the server there is message available for proccesing. - msg := &Message{} for { + msg := &Message{} if err := msg.decode(conn); err != nil { // remote connection probably closed. if err == io.EOF {