Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
TATAUFO committed Feb 16, 2020
1 parent 195d6c2 commit d198260
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ func (n *Node) SetLocalPort(port uint64) {
n.localPort = port
}

// AddPeer add peer to local node peers
func (n *Node) AddPeer(p *peer.Peer) error {
peerBytes, err := json.Marshal(p)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions peer/peer.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func New(ip string, port uint64, nodeKey string) (*Peer, error) {
return &Peer{IP: ip, Port: port, NodeKey: nodeKey}, nil
}

// Key return key of peer
// ID return key of peer
func (p *Peer) ID() common.Hash {
hash := sha256.New()
hash.Reset()
Expand Down Expand Up @@ -99,9 +99,9 @@ func (p Peer) Url() string {
return fmt.Sprintf("ws://%s:%d/%s", p.IP, p.Port, p.NodeKey)
}

// Address is UserID@IP:port/nodeKey
func (p Peer) Address() string {
// todo : address without p.UserID or not verified

return fmt.Sprintf("%s@%s:%d/%s", common.Hash2String(p.UserID), p.IP, p.Port, p.NodeKey)
}

Expand Down

0 comments on commit d198260

Please sign in to comment.