func newPeer(version int, p *p2p.Peer, rw p2p.MsgReadWriter) *peer { id := p.ID() return &peer{ Peer: p, rw: rw, version: version, id: fmt.Sprintf("%x", id[:8]), knownTxs: set.New(), knownBlocks: set.New(), } }
func newPeerInfo(peer *p2p.Peer) *PeerInfo { var caps []string for _, cap := range peer.Caps() { caps = append(caps, cap.String()) } return &PeerInfo{ ID: peer.ID().String(), Name: peer.Name(), Caps: strings.Join(caps, ", "), RemoteAddress: peer.RemoteAddr().String(), LocalAddress: peer.LocalAddr().String(), } }
func newPeer(protv, netid int, genesis, recentHash common.Hash, td *big.Int, p *p2p.Peer, rw p2p.MsgReadWriter) *peer { id := p.ID() return &peer{ Peer: p, rw: rw, genesis: genesis, ourHash: recentHash, ourTd: td, protv: protv, netid: netid, id: fmt.Sprintf("%x", id[:8]), txHashes: set.New(), blockHashes: set.New(), } }
func NewPeer(peer *p2p.Peer) *Peer { var caps []string for _, cap := range peer.Caps() { caps = append(caps, fmt.Sprintf("%s/%d", cap.Name, cap.Version)) } return &Peer{ ref: peer, Ip: fmt.Sprintf("%v", peer.RemoteAddr()), Version: fmt.Sprintf("%v", peer.ID()), Caps: fmt.Sprintf("%v", caps), } }