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
|
||||
DownVote(nodeId *encoding.NodeId) error
|
||||
NodeId() *encoding.NodeId
|
||||
SelfConnectionUris() []*url.URL
|
||||
Service
|
||||
}
|
||||
|
|
|
@ -43,9 +43,15 @@ type P2PImpl struct {
|
|||
reconnectDelay structs.Map
|
||||
peers structs.Map
|
||||
peersPending structs.Map
|
||||
selfConnectionUris []*url.URL
|
||||
}
|
||||
|
||||
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{
|
||||
logger: node.Logger(),
|
||||
nodeKeyPair: node.Config().KeyPair,
|
||||
|
@ -55,11 +61,16 @@ func NewP2P(node interfaces.Node) *P2PImpl {
|
|||
reconnectDelay: structs.NewMap(),
|
||||
peers: structs.NewMap(),
|
||||
peersPending: structs.NewMap(),
|
||||
selfConnectionUris: []*url.URL{uri},
|
||||
}
|
||||
|
||||
return service
|
||||
}
|
||||
|
||||
func (p *P2PImpl) SelfConnectionUris() []*url.URL {
|
||||
return p.selfConnectionUris
|
||||
}
|
||||
|
||||
func (p *P2PImpl) Node() interfaces.Node {
|
||||
return p.node
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue