Esempio n. 1
0
        public override void ConsumeTransactionFeature(CommitItems commitItems, Commit commit, Transaction transaction, FeatureAccount featureAccount, FeatureData featureData)
        {
            var targetData = featureData as TransactionTarget;

            for (var i = 0; i < targetData.Targets.Count; i++)
            {
                var targetTransactionId = targetData.Targets[i];
                var targetedCount       = targetData._targetedTransactionsCount[i];

                var info = GetTransactionTargetInfo(targetTransactionId);
                if (info == null)
                {
                    info = new TransactionTargetInfo(targetTransactionId, transaction, targetedCount);
                    lock (this)
                        _transactionTargets[targetTransactionId] = info;

                    _transactionTargetsStorage.Storage.AddEntry(targetTransactionId, info.ToByteArray());
                }
                else
                {
                    info.UpdateLastTransaction(transaction, targetedCount);
                    commit.DirtyIds.Add(targetTransactionId);
                }
            }
        }
Esempio n. 2
0
        internal TransactionTargetInfo GetTransactionTargetInfo(long transactionId)
        {
            lock (this)
            {
                if (_transactionTargets.TryGetValue(transactionId, out var transactionTarget))
                {
                    return(transactionTarget);
                }
            }

            var data = _transactionTargetsStorage.Storage.GetBlockData(transactionId);

            if (data == null)
            {
                return(null);
            }

            var target = new TransactionTargetInfo(data);

            lock (this)
            {
                if (_transactionTargets.TryGetValue(transactionId, out var transactionTarget))
                {
                    return(transactionTarget);
                }

                _transactionTargets[transactionId] = target;
            }
            return(target);
        }