Skip to content

Commit

Permalink
[sync] fix a panic issue found in stream tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JackyWYX authored and Leo Chen committed May 4, 2021
1 parent 6a0b932 commit d8b5d16
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions node/node_syncing.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,15 @@ func (node *Node) createStateSync() *legacysync.StateSync {
// Thus for compatibility, we are doing the arithmetics here, and not to change the
// protocol itself. This is just the temporary hack and will not be a concern after
// state sync.
syncPort := node.downloaderServer.Port
mutatedPort := strconv.Itoa(syncPort + legacysync.SyncingPortDifference)
var mySyncPort int
if node.downloaderServer != nil {
mySyncPort = node.downloaderServer.Port
} else {
// If local sync server is not started, the port field in protocol is actually not
// functional, simply set it to default value.
mySyncPort = nodeconfig.DefaultDNSPort
}
mutatedPort := strconv.Itoa(mySyncPort + legacysync.SyncingPortDifference)
return legacysync.CreateStateSync(node.SelfPeer.IP, mutatedPort,
node.GetSyncID(), node.NodeConfig.Role() == nodeconfig.ExplorerNode)
}
Expand Down

0 comments on commit d8b5d16

Please sign in to comment.