Skip to content

Commit

Permalink
[cmd] more opt on logic and added comments
Browse files Browse the repository at this point in the history
  • Loading branch information
JackyWYX authored and Leo Chen committed Aug 14, 2020
1 parent 9740cfd commit 7a6fd23
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions cmd/harmony/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -552,15 +552,18 @@ func setupConsensusAndNode(hc harmonyConfig, nodeConfig *nodeconfig.ConfigType)
currentNode.BroadcastInvalidTx = defaultBroadcastInvalidTx
}

if hc.Network.LegacySyncing {
if hc.Network.NetworkType == nodeconfig.Localnet {
epochConfig := shard.Schedule.InstanceForEpoch(ethCommon.Big0)
selfPort := hc.P2P.Port
currentNode.SyncingPeerProvider = node.NewLocalSyncingPeerProvider(
6000, uint16(selfPort), epochConfig.NumShards(), uint32(epochConfig.NumNodesPerShard()))
} else {
currentNode.SyncingPeerProvider = node.NewLegacySyncingPeerProvider(currentNode)
}
// Syncing provider is provided by following rules:
// 1. If starting with a localnet, use local sync peers.
// 2. If specified with --dns=false, use legacy syncing which is syncing through self-
// discover peers.
// 3. Else, use the dns for syncing.
if hc.Network.NetworkType == nodeconfig.Localnet {
epochConfig := shard.Schedule.InstanceForEpoch(ethCommon.Big0)
selfPort := hc.P2P.Port
currentNode.SyncingPeerProvider = node.NewLocalSyncingPeerProvider(
6000, uint16(selfPort), epochConfig.NumShards(), uint32(epochConfig.NumNodesPerShard()))
} else if hc.Network.LegacySyncing {
currentNode.SyncingPeerProvider = node.NewLegacySyncingPeerProvider(currentNode)
} else {
currentNode.SyncingPeerProvider = node.NewDNSSyncingPeerProvider(hc.Network.DNSZone, syncing.GetSyncingPort(strconv.Itoa(hc.Network.DNSPort)))
}
Expand Down

0 comments on commit 7a6fd23

Please sign in to comment.