a5ff5016c9
* port changes * Merge remote-tracking branch 'upstream/master' * Merge remote-tracking branch 'upstream/master' * Merge remote-tracking branch 'upstream/master' * files created * Merge remote-tracking branch 'upstream/master' into coyle/kad-tests * wip * Merge remote-tracking branch 'upstream/master' into coyle/kad-tests * wip * remove bkad dependencie from tests * wip * wip * wip * wip * wip * updated coyle/kademlia * wip * cleanup * ports * overlay upgraded * linter fixes * piecestore kademlia newID * add changes from kad demo * PR comments addresses * go func * force travis build * fixed merge conflicts * fixed merge conflicts * Merge branch 'coyle/kad-tests' of https://github.com/coyle/storj into coyle/kad-tests * linter issues * linting issues * fixed merge conflicts * linter is stupid
37 lines
756 B
Go
37 lines
756 B
Go
// Copyright (C) 2018 Storj Labs, Inc.
|
|
// See LICENSE for copying information.
|
|
|
|
package kademlia
|
|
|
|
import base58 "github.com/jbenet/go-base58"
|
|
|
|
// NodeID is the unique identifer of a Node in the overlay network
|
|
type NodeID string
|
|
|
|
// String transforms the nodeID to a string type
|
|
func (n *NodeID) String() string {
|
|
return string(*n)
|
|
}
|
|
|
|
// Bytes transforms the nodeID to type []byte
|
|
func (n *NodeID) Bytes() []byte {
|
|
return []byte(*n)
|
|
}
|
|
|
|
// StringToNodeID trsansforms a string to a NodeID
|
|
func StringToNodeID(s string) *NodeID {
|
|
n := NodeID(s)
|
|
return &n
|
|
}
|
|
|
|
// NewID returns a pointer to a newly intialized NodeID
|
|
func NewID() (*NodeID, error) {
|
|
b, err := newID()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
bb := NodeID(base58.Encode(b))
|
|
return &bb, nil
|
|
}
|