Exemple #1
0
        public void BlockVerify(Block block)
        {
            lock (Chain)
            {
                Chain.Add(block);
            }

            lock (TransactionPool)
            {
                var ids = block.Transactions.Select(x => x.Id).ToArray();
                TransactionPool.RemoveTxs(ids);
            }

            lock (Utxos)
            {
                var inEntries = block.Transactions.SelectMany(x => x.Inputs);
                Utxos.RemoveAll(x =>
                                inEntries.Any(inEntry =>
                                              inEntry.OutputIndex == x.OutIndex &&
                                              inEntry.TransactionId.Equals(x.TransactionId)));
                var utxos =
                    block.Transactions
                    .Select(x => (x.Outputs, x.Id))
                    .SelectMany(x => ToTxO(x.Outputs, x.Id));

                Utxos.AddRange(utxos);
            }

            //if(Chain.Count % 100 == 0) Difficulty.CalculateNextDifficulty()

            Applied?.Invoke();
        }
Exemple #2
0
        private async Task ApplyInternal(bool reset = true)
        {
            try
            {
                using (MessageView.ShowLoad("Применение изменений..."))
                {
                    Repository.SaveScenario(_clonedScenario);
                    StatisticsManager.ReRegister(_clonedScenario);
                    await _clonedScenario.Initialize();

                    _clonedScenario.AfterInitilize();
                }

                IsModified = false;

                if (reset)
                {
                    if (await SetScenario(_clonedScenario))
                    {
                        Applied?.Invoke();
                    }
                }
                else
                {
                    _originalSenario = _clonedScenario; //crutch
                    Applied?.Invoke();
                }
            }
            catch (Exception e)
            {
                Log.Error($"Ошибка инициализации сценария [{_clonedScenario.Name}]", e);
            }
        }
Exemple #3
0
        public void Apply(BehavioursComponent behaviours)
        {
            behaviours.Apply(Behaviour, behaviours.gameObject);
            IsApplied = true;

            Applied?.Invoke(this);
        }
Exemple #4
0
        public void Apply()
        {
            if (IsApplied)
                return;

            IsApplied = true;
            OnApplied();
            Applied?.Invoke(this);
        }
Exemple #5
0
        protected override void OnApply(PageApplyEventArgs e)
        {
            if (e.ApplyBehavior == ApplyKind.Apply)
            {
                Applied?.Invoke();
            }

            base.OnApply(e);
        }
Exemple #6
0
 private void ApplyInternal()
 {
     _originalTrigger.Stop();
     _repository.SaveTrigger(_clonedTrigger);
     _clonedTrigger.Initialize();
     _clonedTrigger.AfterInitialize();
     SetTrigger(
         _clonedTrigger,
         () => {
         Applied?.Invoke();
         IsModified = false;
     });
 }
Exemple #7
0
        void LockedChainApply(List <Block> newChain)
        {
            var localTxs           = Chain.SelectMany(x => x.Transactions);
            var remoteTxs          = newChain.SelectMany(x => x.Transactions);
            var txNotIncludeRemote =
                localTxs.Where(tx => !remoteTxs.Any(x => x.Id.Equals(tx.Id))).ToArray();

            lock (TransactionPool)
            {
                var txIds = TransactionPool.GetPool().Select(x => x.Id)
                            .Where(x => remoteTxs.Any(tx => x.Equals(tx.Id))).ToArray();
                TransactionPool.RemoveTxs(txIds);
                TransactionPool.AddTxs(txNotIncludeRemote);
            }

            lock (Chain)
            {
                Chain.Clear();
                Chain.AddRange(newChain);
            }

            UpdateUtxos();
            Applied?.Invoke();
        }
Exemple #8
0
 private void ApplyInternal(bool reset = true)
 {
     try
     {
         Repository.SaveScenario(_clonedScenario);
         StatisticsManager.ReRegister(_clonedScenario);
         _clonedScenario.InitializeAsync();
         _clonedScenario.AfterInitilize();
         IsModified = false;
         if (reset)
         {
             SetScenario(_clonedScenario, Applied);
         }
         else
         {
             _originalSenario = _clonedScenario; //crutch
             Applied?.Invoke();
         }
     }
     catch (Exception e)
     {
         Log.ErrorFormat(e, "Ошибка инициализации сценария {0}", _clonedScenario.Name);
     }
 }
Exemple #9
0
 private void OnApply()
 {
     Applied?.Invoke(this, new SettingsEventArgs(this));
 }
 protected virtual void OnApplied()
 {
     Applied?.Invoke(this, EventArgs.Empty);
 }
Exemple #11
0
 private void OnApplied() => Applied?.Invoke(this, EventArgs.Empty);
        protected override void OnApply(PageApplyEventArgs e)
        {
            base.OnApply(e);

            Applied?.Invoke(this, EventArgs.Empty);
        }
Exemple #13
0
 protected virtual void OnApplied(EventArgs e)
 {
     Applied?.Invoke(this, e);
 }