"fmt"
"net"
- "github.com/tendermint/go-crypto"
-
- cfg "github.com/vapor/config"
- "github.com/vapor/consensus"
- "github.com/vapor/errors"
- "github.com/vapor/version"
+ cfg "github.com/bytom/vapor/config"
+ "github.com/bytom/vapor/consensus"
+ "github.com/bytom/vapor/errors"
+ "github.com/bytom/vapor/p2p/signlib"
+ "github.com/bytom/vapor/version"
)
const maxNodeInfoSize = 10240 // 10Kb
//NodeInfo peer node info
type NodeInfo struct {
- PubKey crypto.PubKeyEd25519 `json:"pub_key"`
- Moniker string `json:"moniker"`
- Network string `json:"network"`
+ PubKey string `json:"pub_key"`
+ Moniker string `json:"moniker"`
+ Network string `json:"network"`
//NetworkID used to isolate subnets with same network name
NetworkID uint64 `json:"network_id"`
RemoteAddr string `json:"remote_addr"`
Other []string `json:"other"`
}
-func NewNodeInfo(config *cfg.Config, pubkey crypto.PubKeyEd25519, listenAddr string, netID uint64) *NodeInfo {
+func NewNodeInfo(config *cfg.Config, pubkey signlib.PubKey, listenAddr string, netID uint64) *NodeInfo {
return &NodeInfo{
- PubKey: pubkey,
+ PubKey: pubkey.String(),
Moniker: config.Moniker,
Network: config.ChainID,
NetworkID: netID,
return nil
}
+func (info NodeInfo) DoFilter(ip string, pubKey string) error {
+ if info.PubKey == pubKey {
+ return ErrConnectSelf
+ }
+
+ return nil
+}
+
//listenHost peer listener ip address
func (info NodeInfo) listenHost() string {
host, _, _ := net.SplitHostPort(info.ListenAddr)
}
//remoteAddrHost peer external ip address
-func (info NodeInfo) remoteAddrHost() string {
+func (info NodeInfo) RemoteAddrHost() string {
host, _, _ := net.SplitHostPort(info.RemoteAddr)
return host
}