Skip to content

Commit 8584b70

Browse files
committed
Use DNS for localnet.
1 parent a63980b commit 8584b70

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

Diff for: cmd/harmony/main.go

+2-5
Original file line numberDiff line numberDiff line change
@@ -759,11 +759,8 @@ func setupConsensusAndNode(hc harmonyconfig.HarmonyConfig, nodeConfig *nodeconfi
759759
}
760760

761761
// Syncing provider is provided by following rules:
762-
// 1. If starting with a localnet or offline, use local sync peers.
763-
// 2. If specified with --dns=false, use legacy syncing which is syncing through self-
764-
// discover peers.
765-
// 3. Else, use the dns for syncing.
766-
if hc.Network.NetworkType == nodeconfig.Localnet || hc.General.IsOffline {
762+
// If starting with offline, use local sync peers.
763+
if hc.General.IsOffline {
767764
epochConfig := shard.Schedule.InstanceForEpoch(ethCommon.Big0)
768765
selfPort := hc.P2P.Port
769766
currentNode.SyncingPeerProvider = node.NewLocalSyncingPeerProvider(

Diff for: internal/configs/node/network.go

+12-2
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ const (
3333
pangaeaDNSZone = "os.hmny.io"
3434
partnerDNSZone = "ps.hmny.io"
3535
stressnetDNSZone = "stn.hmny.io"
36+
localnetDNSZone = "127.0.0.1"
3637
)
3738

3839
const (
@@ -169,13 +170,22 @@ func GetDefaultDNSZone(networkType NetworkType) string {
169170
return partnerDNSZone
170171
case Stressnet:
171172
return stressnetDNSZone
173+
case Localnet:
174+
return localnetDNSZone
172175
}
173176
return ""
174177
}
175178

176179
// GetDefaultDNSPort get the default DNS port for the given network type
177-
func GetDefaultDNSPort(NetworkType) int {
178-
return DefaultDNSPort
180+
func GetDefaultDNSPort(n NetworkType) int {
181+
switch n {
182+
case Localnet:
183+
// port could be found in ./tmp_log/log-.../bootnode.log
184+
// looks like `bootnode BN_MA=/ip4/127.0.0.1/tcp/19876/p2p/Qmc1V6W7BwX8Ugb42Ti8RnXF1rY5PF7nnZ6bKBryCgi6cv`
185+
return 19876
186+
default:
187+
return DefaultDNSPort
188+
}
179189
}
180190

181191
// GetRPCHTTPPortFromBase return the rpc HTTP port from base port

0 commit comments

Comments
 (0)