package mesh

import (
	"fmt"
	"time"
)

type PeerInfo struct {
	ID        string              `json:"id"`
	Protocols map[string][]string `json:"protocols"`
}

type peerInfoProtocol struct {
	PeerID      string    `json:"peer_id"`
	Name        string    `json:"name"`
	Address     string    `json:"address"`
	LastUpdated time.Time `json:"last_updated,omitempty"`
	Pinned      bool      `json:"pinned,omitempty"`
}

// TODO maybe a better or just faster hash function?
func (p *peerInfoProtocol) Hash() string {
	return fmt.Sprintf("%s/%s/%s", p.PeerID, p.Name, p.Address)
}

package mesh

import (
	"fmt"
	"time"
)

type PeerInfo struct {
	ID        string
	Protocols map[string][]string
}

type peerInfoProtocol struct {
	PeerID      string
	Name        string
	Address     string
	LastUpdated time.Time
	Pinned      bool
}

// TODO maybe a better or just faster hash function?
func (p *peerInfoProtocol) Hash() string {
	return fmt.Sprintf("%s/%s/%s", p.PeerID, p.Name, p.Address)
}

--- 
+++ 
@@ -6,16 +6,16 @@
 )
 
 type PeerInfo struct {
-	ID        string
-	Protocols map[string][]string
+	ID        string              `json:"id"`
+	Protocols map[string][]string `json:"protocols"`
 }
 
 type peerInfoProtocol struct {
-	PeerID      string
-	Name        string
-	Address     string
-	LastUpdated time.Time
-	Pinned      bool
+	PeerID      string    `json:"peer_id"`
+	Name        string    `json:"name"`
+	Address     string    `json:"address"`
+	LastUpdated time.Time `json:"last_updated,omitempty"`
+	Pinned      bool      `json:"pinned,omitempty"`
 }
 
 // TODO maybe a better or just faster hash function?
Add peer info json attrs
