Esempio n. 1
0
        public static bool Load(this IConsensusContext context, Store store)
        {
            byte[] data = store.Get(CN_Context, new byte[0]);

            if (data is null || data.Length == 0)
            {
                return(false);
            }

            using (MemoryStream ms = new MemoryStream(data, false))
                using (BinaryReader reader = new BinaryReader(ms))
                {
                    try
                    {
                        context.Deserialize(reader);
                    }
                    catch
                    {
                        return(false);
                    }
                    return(true);
                }
        }