Ejemplo n.º 1
0
        public void TestUInt32Length()
        {
            var value = new UInt32ColumnValue();

            foreach (uint i in new[] { uint.MinValue, 1U, 2U, Any.UInt32, 65521U, uint.MaxValue - 1, uint.MaxValue })
            {
                TestLengthForStruct(value, i, 4);
            }
        }
Ejemplo n.º 2
0
        public void TestUInt32ValueAsObject()
        {
            var value = new UInt32ColumnValue();

            foreach (uint i in new[] { uint.MinValue, 1U, 2U, Any.UInt32, 65521U, uint.MaxValue - 1, uint.MaxValue })
            {
                TestValueAsObjectForStruct(value, i);
            }
        }
Ejemplo n.º 3
0
        private IEnumerable <UnspentTx> ReadUnspentTransactionsInner()
        {
            using (SetSessionContext())
            {
                Api.JetSetCurrentIndex(this.jetSession, this.unspentTxTableId, "IX_TxHash");

                if (Api.TryMoveFirst(this.jetSession, this.unspentTxTableId))
                {
                    do
                    {
                        var txHashColumn = new BytesColumnValue {
                            Columnid = this.txHashColumnId
                        };
                        var blockIndexColumn = new Int32ColumnValue {
                            Columnid = this.blockIndexColumnId
                        };
                        var txIndexColumn = new Int32ColumnValue {
                            Columnid = this.txIndexColumnId
                        };
                        var txVersionColumn = new UInt32ColumnValue {
                            Columnid = this.txVersionColumnId
                        };
                        var isCoinbaseColumn = new BoolColumnValue {
                            Columnid = this.isCoinbaseColumnId
                        };
                        var outputStatesColumn = new BytesColumnValue {
                            Columnid = this.outputStatesColumnId
                        };
                        var txOutputBytesColumn = new BytesColumnValue {
                            Columnid = this.txOutputBytesColumnId
                        };
                        Api.RetrieveColumns(this.jetSession, this.unspentTxTableId, txHashColumn, blockIndexColumn, txIndexColumn, txVersionColumn, isCoinbaseColumn, outputStatesColumn, txOutputBytesColumn);

                        var txHash       = DbEncoder.DecodeUInt256(txHashColumn.Value);
                        var blockIndex   = blockIndexColumn.Value.Value;
                        var txIndex      = txIndexColumn.Value.Value;
                        var txVersion    = txVersionColumn.Value.Value;
                        var isCoinbase   = isCoinbaseColumn.Value.Value;
                        var outputStates = DataDecoder.DecodeOutputStates(outputStatesColumn.Value);

                        yield return(new UnspentTx(txHash, blockIndex, txIndex, txVersion, isCoinbase, outputStates));
                    }while (Api.TryMoveNext(this.jetSession, this.unspentTxTableId));
                }
            }
        }
Ejemplo n.º 4
0
        public bool TryGetUnspentTx(UInt256 txHash, out UnspentTx unspentTx)
        {
            CheckTransaction();

            using (SetSessionContext())
            {
                Api.JetSetCurrentIndex(this.jetSession, this.unspentTxTableId, "IX_TxHash");
                Api.MakeKey(this.jetSession, this.unspentTxTableId, DbEncoder.EncodeUInt256(txHash), MakeKeyGrbit.NewKey);
                if (Api.TrySeek(this.jetSession, this.unspentTxTableId, SeekGrbit.SeekEQ))
                {
                    var blockIndexColumn = new Int32ColumnValue {
                        Columnid = this.blockIndexColumnId
                    };
                    var txIndexColumn = new Int32ColumnValue {
                        Columnid = this.txIndexColumnId
                    };
                    var txVersionColumn = new UInt32ColumnValue {
                        Columnid = this.txVersionColumnId
                    };
                    var isCoinbaseColumn = new BoolColumnValue {
                        Columnid = this.isCoinbaseColumnId
                    };
                    var outputStatesColumn = new BytesColumnValue {
                        Columnid = this.outputStatesColumnId
                    };
                    var txOutputBytesColumn = new BytesColumnValue {
                        Columnid = this.txOutputBytesColumnId
                    };
                    Api.RetrieveColumns(this.jetSession, this.unspentTxTableId, blockIndexColumn, txIndexColumn, txVersionColumn, isCoinbaseColumn, outputStatesColumn, txOutputBytesColumn);

                    var blockIndex   = blockIndexColumn.Value.Value;
                    var txIndex      = txIndexColumn.Value.Value;
                    var txVersion    = txVersionColumn.Value.Value;
                    var isCoinbase   = isCoinbaseColumn.Value.Value;
                    var outputStates = DataDecoder.DecodeOutputStates(outputStatesColumn.Value);

                    unspentTx = new UnspentTx(txHash, blockIndex, txIndex, txVersion, isCoinbase, outputStates);
                    return(true);
                }

                unspentTx = default(UnspentTx);
                return(false);
            }
        }
Ejemplo n.º 5
0
        private IEnumerable<UnspentTx> ReadUnspentTransactionsInner()
        {
            using (SetSessionContext())
            {
                Api.JetSetCurrentIndex(this.jetSession, this.unspentTxTableId, "IX_TxHash");

                if (Api.TryMoveFirst(this.jetSession, this.unspentTxTableId))
                {
                    do
                    {
                        var txHashColumn = new BytesColumnValue { Columnid = this.txHashColumnId };
                        var blockIndexColumn = new Int32ColumnValue { Columnid = this.blockIndexColumnId };
                        var txIndexColumn = new Int32ColumnValue { Columnid = this.txIndexColumnId };
                        var txVersionColumn = new UInt32ColumnValue { Columnid = this.txVersionColumnId };
                        var isCoinbaseColumn = new BoolColumnValue { Columnid = this.isCoinbaseColumnId };
                        var outputStatesColumn = new BytesColumnValue { Columnid = this.outputStatesColumnId };
                        var txOutputBytesColumn = new BytesColumnValue { Columnid = this.txOutputBytesColumnId };
                        Api.RetrieveColumns(this.jetSession, this.unspentTxTableId, txHashColumn, blockIndexColumn, txIndexColumn, txVersionColumn, isCoinbaseColumn, outputStatesColumn, txOutputBytesColumn);

                        var txHash = DbEncoder.DecodeUInt256(txHashColumn.Value);
                        var blockIndex = blockIndexColumn.Value.Value;
                        var txIndex = txIndexColumn.Value.Value;
                        var txVersion = txVersionColumn.Value.Value;
                        var isCoinbase = isCoinbaseColumn.Value.Value;
                        var outputStates = DataDecoder.DecodeOutputStates(outputStatesColumn.Value);

                        yield return new UnspentTx(txHash, blockIndex, txIndex, txVersion, isCoinbase, outputStates);
                    }
                    while (Api.TryMoveNext(this.jetSession, this.unspentTxTableId));
                }
            }
        }
Ejemplo n.º 6
0
        public bool TryGetUnspentTx(UInt256 txHash, out UnspentTx unspentTx)
        {
            CheckTransaction();

            using (SetSessionContext())
            {
                Api.JetSetCurrentIndex(this.jetSession, this.unspentTxTableId, "IX_TxHash");
                Api.MakeKey(this.jetSession, this.unspentTxTableId, DbEncoder.EncodeUInt256(txHash), MakeKeyGrbit.NewKey);
                if (Api.TrySeek(this.jetSession, this.unspentTxTableId, SeekGrbit.SeekEQ))
                {
                    var blockIndexColumn = new Int32ColumnValue { Columnid = this.blockIndexColumnId };
                    var txIndexColumn = new Int32ColumnValue { Columnid = this.txIndexColumnId };
                    var txVersionColumn = new UInt32ColumnValue { Columnid = this.txVersionColumnId };
                    var isCoinbaseColumn = new BoolColumnValue { Columnid = this.isCoinbaseColumnId };
                    var outputStatesColumn = new BytesColumnValue { Columnid = this.outputStatesColumnId };
                    var txOutputBytesColumn = new BytesColumnValue { Columnid = this.txOutputBytesColumnId };
                    Api.RetrieveColumns(this.jetSession, this.unspentTxTableId, blockIndexColumn, txIndexColumn, txVersionColumn, isCoinbaseColumn, outputStatesColumn, txOutputBytesColumn);

                    var blockIndex = blockIndexColumn.Value.Value;
                    var txIndex = txIndexColumn.Value.Value;
                    var txVersion = txVersionColumn.Value.Value;
                    var isCoinbase = isCoinbaseColumn.Value.Value;
                    var outputStates = DataDecoder.DecodeOutputStates(outputStatesColumn.Value);

                    unspentTx = new UnspentTx(txHash, blockIndex, txIndex, txVersion, isCoinbase, outputStates);
                    return true;
                }

                unspentTx = default(UnspentTx);
                return false;
            }
        }