Example #1
0
        // this method is thread safe
        // it should be called periodically by a behaviour
        // that is in charge of keeping the chin in sync
        public void SaveToDisk(bool force = false)
        {
            saveLock.Lock(() => force || this.ChainIndex.Tip.Height > savedHeight, () =>
            {
                using (var file = File.OpenWrite(this.Context.Config.File("headers.dat")))
                {
                    this.ChainIndex.WriteTo(file);
                }

                this.savedHeight = this.ChainIndex.Tip.Height;
            });
        }