Improve protocol & leveldb debugging

This commit is contained in:
Jakob Borg
2014-07-23 11:54:15 +02:00
parent 08ce9b09ec
commit c714a12ad7
4 changed files with 30 additions and 10 deletions

View File

@@ -31,6 +31,15 @@ func NodeIDFromString(s string) (NodeID, error) {
return n, err
}
func NodeIDFromBytes(bs []byte) NodeID {
var n NodeID
if len(bs) != len(n) {
panic("incorrect length of byte slice representing node ID")
}
copy(n[:], bs)
return n
}
// String returns the canonical string representation of the node ID
func (n NodeID) String() string {
id := base32.StdEncoding.EncodeToString(n[:])