Exemple #1
0
        public bool TryRemoveTransaction(UInt256 txHash)
        {
            CheckWriteTransaction();

            UnconfirmedTx unconfirmedTx;

            if (unconfirmedTxes.Value.TryGetValue(txHash, out unconfirmedTx) &&
                unconfirmedTxes.TryModify(x => x.Remove(txHash)))
            {
                // update index of txes spending each input's prev tx
                for (var inputIndex = 0; inputIndex < unconfirmedTx.Transaction.Inputs.Length; inputIndex++)
                {
                    var input = unconfirmedTx.Transaction.Inputs[inputIndex];

                    unconfirmedTxesByPrevTxOutputKey.Modify(_ => { });
                    ImmutableDictionary <UInt256, UnconfirmedTx> .Builder unconfirmedTxes;
                    if (unconfirmedTxesByPrevTxOutputKey.Value.TryGetValue(input.PrevTxOutputKey, out unconfirmedTxes))
                    {
                        // ensure a copy of the builder is modified or underlying storage will see uncomitted state
                        unconfirmedTxes = unconfirmedTxes.ToImmutable().ToBuilder();
                    }
                    else
                    {
                        unconfirmedTxes = ImmutableDictionary.CreateBuilder <UInt256, UnconfirmedTx>();
                    }

                    unconfirmedTxes.Remove(unconfirmedTx.Hash);
                    if (unconfirmedTxes.Count > 0)
                    {
                        unconfirmedTxesByPrevTxOutputKey.Value[input.PrevTxOutputKey] = unconfirmedTxes;
                    }
                    else
                    {
                        unconfirmedTxesByPrevTxOutputKey.Value.Remove(input.PrevTxOutputKey);
                    }
                }

                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemple #2
0
 public bool TryRemoveBlockUnmintedTxes(UInt256 blockHash)
 {
     CheckWriteTransaction();
     return(blockUnmintedTxes.TryModify(x => x.Remove(blockHash)));
 }
Exemple #3
0
 public bool TryRemoveBlockSpentTxes(int blockIndex)
 {
     CheckWriteTransaction();
     return(blockSpentTxes.TryModify(x => x.Remove(blockIndex)));
 }
Exemple #4
0
 public bool TryRemoveUnspentTxOutput(TxOutputKey txOutputKey)
 {
     CheckWriteTransaction();
     return(unspentTxOutputs.TryModify(x => x.Remove(txOutputKey)));
 }
Exemple #5
0
 public bool TryRemoveUnspentTx(UInt256 txHash)
 {
     CheckWriteTransaction();
     return(unspentTransactions.TryModify(x => x.Remove(txHash)));
 }
Exemple #6
0
 public bool TryRemoveHeader(UInt256 blockHash)
 {
     CheckWriteTransaction();
     return(headers.TryModify(x => x.Remove(blockHash)));
 }