Skip to content

Commit

Permalink
Improve loading of peers.json (#207)
Browse files Browse the repository at this point in the history
  • Loading branch information
xandronus authored Aug 26, 2020
1 parent 47dbd11 commit ea12be0
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/Blockcore/P2P/PeerAddressManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,25 @@ public PeerAddressManager(IDateTimeProvider dateTimeProvider, DataFolder peerFil
/// <inheritdoc />
public void LoadPeers()
{
List<PeerAddress> loadedPeers = this.fileStorage.LoadByFileName(PeerFileName);
List<PeerAddress> loadedPeers;

try
{
loadedPeers = this.fileStorage.LoadByFileName(PeerFileName);
}
catch (Exception e)
{
this.logger.LogError("Error loading peers JSON, defaulting to empty list: {0}", e);

loadedPeers = new List<PeerAddress>();
}

if (loadedPeers == null)
loadedPeers = new List<PeerAddress>();

// If the loaded peers is still empty at this point, we rely on the discovery loop to find new peers to connect to.
// The discovery loop will only not run if -connect is used or if there are un-attempted peers left, so as long as
// there are seed nodes & DNS seeds available we should get something to connect to relatively rapidly.

this.logger.LogDebug("{0} peers were loaded.", loadedPeers.Count);

Expand Down

0 comments on commit ea12be0

Please sign in to comment.