introduce PeerUID type

This commit is contained in:
Matthias Radestock committed 2015-05-14 12:35:01 +01:00
1 parent ace56da7b3
commit c7dd48d769
4 files changed
+14 -6

No files matched your search

+11 -3
View File
@@ -3,13 +3,21 @@ package router
import (
"fmt"
"sort"
"strconv"
)
type PeerUID uint64
func ParsePeerUID(s string) (PeerUID, error) {
uid, err := strconv.ParseUint(s, 10, 64)
return PeerUID(uid), err
}
type Peer struct {
Name PeerName
NameByte []byte
NickName string
UID uint64
UID PeerUID
version uint64
localRefCount uint64 // maintained by Peers
connections map[PeerName]Connection
@@ -17,9 +25,9 @@ type Peer struct {
type ConnectionSet map[Connection]struct{}
func NewPeer(name PeerName, nickName string, uid uint64, version uint64) *Peer {
func NewPeer(name PeerName, nickName string, uid PeerUID, version uint64) *Peer {
if uid == 0 {
uid = randUint64()
uid = PeerUID(randUint64())
}
return &Peer{
Name: name,