encode PeerID using IDB58

This is to fix error of "Invalid UTF-8 in peerID field".

Signed-off-by: Leo Chen <leo@harmony.one>
pull/351/head^2
Leo Chen 6 years ago
parent fe06318d04
commit 8b7766de6f
  1. 6
      cmd/client/wallet/main.go
  2. 2
      internal/beaconchain/rpc/server.go

@ -296,7 +296,11 @@ func CreateWalletNode() *node.Node {
response := bcClient.GetLeaders()
for _, leader := range response.Leaders {
shardIDLeaderMap[leader.ShardId] = p2p.Peer{IP: leader.Ip, Port: leader.Port, PeerID: peer.ID(leader.PeerID)}
peerID, err := peer.IDB58Decode(leader.PeerID)
if err != nil {
panic(err)
}
shardIDLeaderMap[leader.ShardId] = p2p.Peer{IP: leader.Ip, Port: leader.Port, PeerID: peerID}
}
// dummy host for wallet

@ -23,7 +23,7 @@ func (s *Server) FetchLeaders(ctx context.Context, request *proto.FetchLeadersRe
leaders := []*proto.FetchLeadersResponse_Leader{}
for shardID, leader := range s.shardLeaderMap() {
leaders = append(leaders, &proto.FetchLeadersResponse_Leader{Ip: leader.IP, Port: leader.Port, ShardId: uint32(shardID), PeerID: string(leader.PeerID)})
leaders = append(leaders, &proto.FetchLeadersResponse_Leader{Ip: leader.IP, Port: leader.Port, ShardId: uint32(shardID), PeerID: leader.PeerID.Pretty()})
}
log.Println(leaders)
return &proto.FetchLeadersResponse{Leaders: leaders}, nil

Loading…
Cancel
Save