protected override void FillWalletElectionsHistoryEntry(IWalletElectionsHistory walletElectionsHistory, SynthesizedBlock.SynthesizedElectionResult electionResult, AccountId electedAccountId)
 {
     if (walletElectionsHistory is INeuraliumWalletElectionsHistory neuraliumWalletElectionsHistory && electionResult is NeuraliumSynthesizedBlock.NeuraliumSynthesizedElectionResult neuraliumSynthesizedElectionResult)
     {
         neuraliumWalletElectionsHistory.Bounty = neuraliumSynthesizedElectionResult.ElectedGains[electedAccountId].bountyShare;
         neuraliumWalletElectionsHistory.Tips   = neuraliumSynthesizedElectionResult.ElectedGains[electedAccountId].tips;
     }
 }
        public override IWalletElectionsHistory InsertElectionsHistoryEntry(SynthesizedBlock.SynthesizedElectionResult electionResult, AccountId electedAccountId)
        {
            this.EnsureWalletLoaded();
            IWalletElectionsHistory historyEntry = base.InsertElectionsHistoryEntry(electionResult, electedAccountId);

            // now let's add a neuralium timeline entry
            if (historyEntry is INeuraliumWalletElectionsHistory neuraliumWalletElectionsHistory && electionResult is NeuraliumSynthesizedBlock.NeuraliumSynthesizedElectionResult neuraliumSynthesizedElectionResult)
            {
                IWalletAccount account = this.WalletFileInfo.WalletBase.Accounts.Values.SingleOrDefault(a => a.GetAccountId() == electedAccountId);

                if (account == null)
                {
                    throw new ApplicationException("Invalid account");
                }

                if (this.WalletFileInfo.Accounts[account.AccountUuid] is INeuraliumAccountFileInfo neuraliumAccountFileInfo)
                {
                    NeuraliumWalletTimeline          neuraliumWalletTimeline         = new NeuraliumWalletTimeline();
                    INeuraliumWalletTimelineFileInfo neuraliumWalletTimelineFileInfo = neuraliumAccountFileInfo.WalletTimelineFileInfo;

                    neuraliumWalletTimeline.Timestamp = neuraliumSynthesizedElectionResult.Timestamp;
                    neuraliumWalletTimeline.Amount    = neuraliumSynthesizedElectionResult.ElectedGains[electedAccountId].bountyShare;
                    neuraliumWalletTimeline.Tips      = neuraliumSynthesizedElectionResult.ElectedGains[electedAccountId].tips;

                    neuraliumWalletTimeline.RecipientAccountId = electedAccountId;
                    neuraliumWalletTimeline.Direction          = NeuraliumWalletTimeline.MoneratyTransactionTypes.Credit;
                    neuraliumWalletTimeline.CreditType         = NeuraliumWalletTimeline.CreditTypes.Election;

                    neuraliumWalletTimeline.Total = this.GetAccountBalance(electedAccountId, false).Total + neuraliumWalletTimeline.Amount + neuraliumWalletTimeline.Tips;

                    neuraliumWalletTimelineFileInfo.InsertTimelineEntry(neuraliumWalletTimeline);
                }
            }

            return(historyEntry);
        }