aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-02-10 23:41:36 +0800
committerobscuren <geffobscura@gmail.com>2014-02-10 23:41:36 +0800
commit42123b439683725b71bbec8ee9ec7443a1af1214 (patch)
tree60bc4aa5eef89aff227f243a32b07667dcf8c37a
parent0ae6a3882523c7134a68f64e90fd8cc70f3c0807 (diff)
downloadgo-tangerine-42123b439683725b71bbec8ee9ec7443a1af1214.tar
go-tangerine-42123b439683725b71bbec8ee9ec7443a1af1214.tar.gz
go-tangerine-42123b439683725b71bbec8ee9ec7443a1af1214.tar.bz2
go-tangerine-42123b439683725b71bbec8ee9ec7443a1af1214.tar.lz
go-tangerine-42123b439683725b71bbec8ee9ec7443a1af1214.tar.xz
go-tangerine-42123b439683725b71bbec8ee9ec7443a1af1214.tar.zst
go-tangerine-42123b439683725b71bbec8ee9ec7443a1af1214.zip
Fixed peer handling
-rw-r--r--peer.go15
1 files changed, 8 insertions, 7 deletions
diff --git a/peer.go b/peer.go
index c592f275f..6ec3c7ee7 100644
--- a/peer.go
+++ b/peer.go
@@ -319,7 +319,8 @@ func (p *Peer) HandleInbound() {
peers := make([]string, data.Length())
// Parse each possible peer
for i := 0; i < data.Length(); i++ {
- peers[i] = unpackAddr(data.Get(i).Get(0), data.Get(i).Get(1).AsUint())
+ value := ethutil.NewValue(data.Get(i).AsRaw())
+ peers[i] = unpackAddr(value.Get(0), value.Get(1).Uint())
}
// Connect to the list of peers
@@ -380,17 +381,17 @@ func packAddr(address, port string) ([]interface{}, uint16) {
b, _ := strconv.Atoi(addr[1])
c, _ := strconv.Atoi(addr[2])
d, _ := strconv.Atoi(addr[3])
- host := []interface{}{byte(a), byte(b), byte(c), byte(d)}
+ host := []interface{}{int32(a), int32(b), int32(c), int32(d)}
prt, _ := strconv.Atoi(port)
return host, uint16(prt)
}
-func unpackAddr(value *ethutil.RlpValue, p uint64) string {
- a := strconv.Itoa(int(value.Get(0).AsUint()))
- b := strconv.Itoa(int(value.Get(1).AsUint()))
- c := strconv.Itoa(int(value.Get(2).AsUint()))
- d := strconv.Itoa(int(value.Get(3).AsUint()))
+func unpackAddr(value *ethutil.Value, p uint64) string {
+ a := strconv.Itoa(int(value.Get(0).Uint()))
+ b := strconv.Itoa(int(value.Get(1).Uint()))
+ c := strconv.Itoa(int(value.Get(2).Uint()))
+ d := strconv.Itoa(int(value.Get(3).Uint()))
host := strings.Join([]string{a, b, c, d}, ".")
port := strconv.Itoa(int(p))