Skip to content

Commit

Permalink
Fix bootstrap node population
Browse files Browse the repository at this point in the history
  • Loading branch information
meyer9 committed May 31, 2019
1 parent 3de2a84 commit fc6c89f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
5 changes: 5 additions & 0 deletions beacon/app/networkfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ func GenerateConfigFromChainConfig(chainConfig ChainConfig) (*Config, error) {
c.GenesisTime = chainConfig.GenesisTime

c.DiscoveryOptions = p2p.NewDiscoveryOptions()

fmt.Println(chainConfig.BootstrapPeers)

c.DiscoveryOptions.PeerAddresses = make([]peerstore.PeerInfo, len(chainConfig.BootstrapPeers))

networkConfig, found := config.NetworkIDs[chainConfig.NetworkID]
Expand All @@ -101,6 +104,8 @@ func GenerateConfigFromChainConfig(chainConfig ChainConfig) (*Config, error) {
c.DiscoveryOptions.PeerAddresses[i] = *peerInfo
}

fmt.Println(c.DiscoveryOptions.PeerAddresses)

return &c, nil
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/beacon/synapsebeacon.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func main() {

appConfig.ListeningAddress = *listen
appConfig.RPCAddress = *rpcConnect
appConfig.DiscoveryOptions.PeerAddresses = initialPeers
appConfig.DiscoveryOptions.PeerAddresses = append(appConfig.DiscoveryOptions.PeerAddresses, initialPeers...)
appConfig.DataDirectory = *datadir

appConfig.Resync = *resync
Expand Down
16 changes: 9 additions & 7 deletions p2p/discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package p2p

import (
"context"
"fmt"
"time"

protocol "github.com/libp2p/go-libp2p-protocol"
Expand All @@ -13,7 +14,6 @@ import (
ps "github.com/libp2p/go-libp2p-peerstore"
mdns "github.com/libp2p/go-libp2p/p2p/discovery"
"github.com/phoreproject/synapse/pb"
logger "github.com/sirupsen/logrus"
)

// MDNSOptions are options for the MDNS discovery mechanism.
Expand Down Expand Up @@ -86,14 +86,16 @@ const mDNSTag = "_phore-discovery._udp"
//
// TODO: add other discovery protocols such as DHT, etc.
func (d Discovery) StartDiscovery() error {
if d.options.MDNS.Enabled {
err := d.discoverFromMDNS()
if err != nil {
logger.Error(err)
}
}
fmt.Println("starting discovery")
// if d.options.MDNS.Enabled {
// err := d.discoverFromMDNS()
// if err != nil {
// logger.Error(err)
// }
// }

for _, pinfo := range d.options.PeerAddresses {
fmt.Println(pinfo)
d.HandlePeerFound(pinfo)
}

Expand Down

0 comments on commit fc6c89f

Please sign in to comment.