Skip to content

Commit d160682

Browse files
committed
Use DNS for localnet.
1 parent 8245c99 commit d160682

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
@@ -758,11 +758,8 @@ func setupConsensusAndNode(hc harmonyconfig.HarmonyConfig, nodeConfig *nodeconfi
758758
}
759759

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