<commit_before>﻿using System.IO;
using Neo.Network;

namespace Neo
{
    public static class PeerState
    {
        private const string PeerStatePath = "peers.dat";

        public static void TryLoad()
        {
            if (!File.Exists(PeerStatePath)) return;

            using (var fileStream = new FileStream(PeerStatePath, FileMode.Open, FileAccess.Read, FileShare.Read))
            {
                LocalNode.LoadState(fileStream);
            }
        }

        public static void Save()
        {
            using (var fileStream = new FileStream(PeerStatePath, FileMode.Create, FileAccess.Write, FileShare.None))
            {
                LocalNode.SaveState(fileStream);
            }
        }
    }
}<commit_msg>Wrapped peer state loading and saving in try catch blocks so application doesn't crash on exception<commit_after>﻿using System.IO;
using Neo.Network;

namespace Neo
{
    public static class PeerState
    {
        private const string PeerStatePath = "peers.dat";

        public static void TryLoad()
        {
            if (!File.Exists(PeerStatePath)) return;

            try
            {
                using (var fileStream = new FileStream(PeerStatePath, FileMode.Open, FileAccess.Read, FileShare.Read))
                {
                    LocalNode.LoadState(fileStream);
                }
            }
            catch
            {
                // Swallow exception
                // TODO Log exception somewhere
            }
        }

        public static void Save()
        {
            try
            {
                using (var fileStream = new FileStream(PeerStatePath, FileMode.Create, FileAccess.Write, FileShare.None))
                {
                    LocalNode.SaveState(fileStream);
                }
            }
            catch
            {
                // Swallow exception
                // TODO Log exception somewhere
            }
        }
    }
}
{'fraction_non_alphanumeric': 0.07648870636550308, 'fraction_numerical': 0.0, 'mean_word_length': 1.4121287128712872, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3583983', 'n_tokens_mistral': 495, 'n_tokens_neox': 464, 'n_words': 119}