feat: store http api config in selfConnectionUris
This commit is contained in:
parent
8a91b912c0
commit
7ab602ce23
|
@ -24,5 +24,6 @@ type P2PService interface {
|
||||||
UpVote(nodeId *encoding.NodeId) error
|
UpVote(nodeId *encoding.NodeId) error
|
||||||
DownVote(nodeId *encoding.NodeId) error
|
DownVote(nodeId *encoding.NodeId) error
|
||||||
NodeId() *encoding.NodeId
|
NodeId() *encoding.NodeId
|
||||||
|
SelfConnectionUris() []*url.URL
|
||||||
Service
|
Service
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,9 +43,15 @@ type P2PImpl struct {
|
||||||
reconnectDelay structs.Map
|
reconnectDelay structs.Map
|
||||||
peers structs.Map
|
peers structs.Map
|
||||||
peersPending structs.Map
|
peersPending structs.Map
|
||||||
|
selfConnectionUris []*url.URL
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewP2P(node interfaces.Node) *P2PImpl {
|
func NewP2P(node interfaces.Node) *P2PImpl {
|
||||||
|
uri, err := url.Parse(fmt.Sprintf("wws://%s/%d", node.Config().HTTP.API.Domain, node.Config().HTTP.API.Port))
|
||||||
|
if err != nil {
|
||||||
|
node.Logger().Fatal("failed to HTTP API URL Config", zap.Error(err))
|
||||||
|
}
|
||||||
|
|
||||||
service := &P2PImpl{
|
service := &P2PImpl{
|
||||||
logger: node.Logger(),
|
logger: node.Logger(),
|
||||||
nodeKeyPair: node.Config().KeyPair,
|
nodeKeyPair: node.Config().KeyPair,
|
||||||
|
@ -55,11 +61,16 @@ func NewP2P(node interfaces.Node) *P2PImpl {
|
||||||
reconnectDelay: structs.NewMap(),
|
reconnectDelay: structs.NewMap(),
|
||||||
peers: structs.NewMap(),
|
peers: structs.NewMap(),
|
||||||
peersPending: structs.NewMap(),
|
peersPending: structs.NewMap(),
|
||||||
|
selfConnectionUris: []*url.URL{uri},
|
||||||
}
|
}
|
||||||
|
|
||||||
return service
|
return service
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (p *P2PImpl) SelfConnectionUris() []*url.URL {
|
||||||
|
return p.selfConnectionUris
|
||||||
|
}
|
||||||
|
|
||||||
func (p *P2PImpl) Node() interfaces.Node {
|
func (p *P2PImpl) Node() interfaces.Node {
|
||||||
return p.node
|
return p.node
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue