Ejemplo n.º 1
0
        public bool TryGetUnspentTxOutput(TxOutputKey txOutputKey, out TxOutput txOutput)
        {
            CheckTransaction();

            using (SetSessionContext())
            {
                Api.JetSetCurrentIndex(this.jetSession, this.unspentTxOutputTableId, "IX_TxOutputKey");
                Api.MakeKey(this.jetSession, this.unspentTxOutputTableId, DbEncoder.EncodeTxOutputKey(txOutputKey), MakeKeyGrbit.NewKey);
                if (Api.TrySeek(this.jetSession, this.unspentTxOutputTableId, SeekGrbit.SeekEQ))
                {
                    var txOutputBytesColumn = new BytesColumnValue {
                        Columnid = this.txOutputBytesColumnId
                    };
                    Api.RetrieveColumns(this.jetSession, this.unspentTxOutputTableId, txOutputBytesColumn);

                    txOutput = DataDecoder.DecodeTxOutput(txOutputBytesColumn.Value);
                    return(true);
                }

                txOutput = default(TxOutput);
                return(false);
            }
        }
Ejemplo n.º 2
0
        private void InitWorkQueueDictionaries()
        {
            unspentTxes        = CreateWorkQueueDictionary <UInt256, UnspentTx>(MakeUnspentTxKey, x => DataDecoder.DecodeUnspentTx(x));
            unspentTxesApplier = CreateApplier <UInt256, UnspentTx>(MakeUnspentTxKey, x => DataEncoder.EncodeUnspentTx(x));
            unspentTxes.WorkQueue.LinkTo(unspentTxesApplier, new DataflowLinkOptions {
                PropagateCompletion = true
            });

            unspentTxOutputs        = CreateWorkQueueDictionary <TxOutputKey, TxOutput>(MakeUnspentTxOutputKey, x => DataDecoder.DecodeTxOutput(x));
            unspentTxOutputsApplier = CreateApplier <TxOutputKey, TxOutput>(MakeUnspentTxOutputKey, x => DataEncoder.EncodeTxOutput(x));
            unspentTxOutputs.WorkQueue.LinkTo(unspentTxOutputsApplier, new DataflowLinkOptions {
                PropagateCompletion = true
            });

            globals        = CreateWorkQueueDictionary <GlobalValue, Slice>(MakeGlobalKey, x => x);
            globalsApplier = CreateApplier <GlobalValue, Slice>(MakeGlobalKey, x => x.ToArray());
            globals.WorkQueue.LinkTo(globalsApplier, new DataflowLinkOptions {
                PropagateCompletion = true
            });

            headers        = CreateWorkQueueDictionary <UInt256, ChainedHeader>(MakeHeaderKey, x => DataDecoder.DecodeChainedHeader(x));
            headersApplier = CreateApplier <UInt256, ChainedHeader>(MakeHeaderKey, x => DataEncoder.EncodeChainedHeader(x));
            headers.WorkQueue.LinkTo(headersApplier, new DataflowLinkOptions {
                PropagateCompletion = true
            });

            spentTxes        = CreateWorkQueueDictionary <int, BlockSpentTxes>(MakeSpentTxesKey, x => DataDecoder.DecodeBlockSpentTxes(x));
            spentTxesApplier = CreateApplier <int, BlockSpentTxes>(MakeSpentTxesKey, x => DataEncoder.EncodeBlockSpentTxes(x));
            spentTxes.WorkQueue.LinkTo(spentTxesApplier, new DataflowLinkOptions {
                PropagateCompletion = true
            });

            unmintedTxes        = CreateWorkQueueDictionary <UInt256, IImmutableList <UnmintedTx> >(MakeUnmintedTxesKey, x => DataDecoder.DecodeUnmintedTxList(x));
            unmintedTxesApplier = CreateApplier <UInt256, IImmutableList <UnmintedTx> >(MakeUnmintedTxesKey, x => DataEncoder.EncodeUnmintedTxList(x));
            unmintedTxes.WorkQueue.LinkTo(unmintedTxesApplier, new DataflowLinkOptions {
                PropagateCompletion = true
            });
        }
Ejemplo n.º 3
0
        public void TestWireDecodeTransactionOut()
        {
            var actual = DataEncoder.EncodeTxOutput(DataDecoder.DecodeTxOutput(TRANSACTION_OUTPUT_1_BYTES.ToArray()));

            CollectionAssert.AreEqual(TRANSACTION_OUTPUT_1_BYTES.ToList(), actual.ToList());
        }
Ejemplo n.º 4
0
        public bool TryGetUnspentTxOutput(TxOutputKey txOutputKey, out TxOutput txOutput)
        {
            CheckTransaction();

            return(CursorTryGet(txOutputKey, out txOutput, unspentTxOutputs, MakeUnspentTxOutputKey, x => DataDecoder.DecodeTxOutput(x)));
        }