浏览代码

p2p: print Cap as name/version

Felix Lange 10 年之前
父节点
当前提交
4bef3ce284
共有 1 个文件被更改,包括 6 次插入0 次删除
  1. 6 0
      p2p/protocol.go

+ 6 - 0
p2p/protocol.go

@@ -1,5 +1,7 @@
 package p2p
 
+import "fmt"
+
 // Protocol represents a P2P subprotocol implementation.
 type Protocol struct {
 	// Name should contain the official protocol name,
@@ -37,6 +39,10 @@ func (cap Cap) RlpData() interface{} {
 	return []interface{}{cap.Name, cap.Version}
 }
 
+func (cap Cap) String() string {
+	return fmt.Sprintf("%s/%d", cap.Name, cap.Version)
+}
+
 type capsByName []Cap
 
 func (cs capsByName) Len() int           { return len(cs) }