<commit_before>﻿using BitSharp.Common;
using BitSharp.Data;
using BitSharp.Storage;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BitSharp.Blockchain
{
    public class Utxo : IDisposable
    {
        private readonly IUtxoStorage utxoStorage;

        internal Utxo(IUtxoStorage utxoStorage)
        {
            this.utxoStorage = utxoStorage;
        }

        public void Dispose()
        {
            this.utxoStorage.Dispose();
        }

        internal IUtxoStorage Storage
        {
            get { return this.utxoStorage; }
        }

        public UInt256 BlockHash
        {
            get { return this.utxoStorage.BlockHash; }
        }

        public int Count
        {
            get { return this.utxoStorage.Count; }
        }

        public bool CanSpend(TxOutputKey prevTxOutput)
        {
            if (prevTxOutput == null)
                throw new ArgumentNullException("prevTxOutput");

            UnspentTx prevTx;
            if (this.utxoStorage.TryGetValue(prevTxOutput.TxHash, out prevTx))
            {
                var prevTxOutputIndex = (int)prevTxOutput.TxOutputIndex;
                if (prevTxOutputIndex < 0 || prevTxOutputIndex >= prevTx.OutputStates.Length)
                    return false;

                return prevTx.OutputStates[prevTxOutputIndex] == OutputState.Unspent;
            }
            else
            {
                return false;
            }
        }

        public void DisposeDelete()
        {
            this.utxoStorage.DisposeDelete();
        }

        public static Utxo CreateForGenesisBlock(UInt256 blockHash)
        {
            return new Utxo(new GenesisUtxoStorage(blockHash));
        }
    }
}<commit_msg>ensure unchecked exception won't happen, false should always be returned<commit_after>﻿using BitSharp.Common;
using BitSharp.Data;
using BitSharp.Storage;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BitSharp.Blockchain
{
    public class Utxo : IDisposable
    {
        private readonly IUtxoStorage utxoStorage;

        internal Utxo(IUtxoStorage utxoStorage)
        {
            this.utxoStorage = utxoStorage;
        }

        public void Dispose()
        {
            this.utxoStorage.Dispose();
        }

        internal IUtxoStorage Storage
        {
            get { return this.utxoStorage; }
        }

        public UInt256 BlockHash
        {
            get { return this.utxoStorage.BlockHash; }
        }

        public int Count
        {
            get { return this.utxoStorage.Count; }
        }

        public bool CanSpend(TxOutputKey prevTxOutput)
        {
            if (prevTxOutput == null)
                throw new ArgumentNullException("prevTxOutput");

            UnspentTx prevTx;
            if (this.utxoStorage.TryGetValue(prevTxOutput.TxHash, out prevTx))
            {
                var prevTxOutputIndex = unchecked((int)prevTxOutput.TxOutputIndex);
                if (prevTxOutputIndex < 0 || prevTxOutputIndex >= prevTx.OutputStates.Length)
                    return false;

                return prevTx.OutputStates[prevTxOutputIndex] == OutputState.Unspent;
            }
            else
            {
                return false;
            }
        }

        public void DisposeDelete()
        {
            this.utxoStorage.DisposeDelete();
        }

        public static Utxo CreateForGenesisBlock(UInt256 blockHash)
        {
            return new Utxo(new GenesisUtxoStorage(blockHash));
        }
    }
}
{'fraction_non_alphanumeric': 0.0726775956284153, 'fraction_numerical': 0.003825136612021858, 'mean_word_length': 1.7280178837555886, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4197690', 'n_tokens_mistral': 1044, 'n_tokens_neox': 985, 'n_words': 205}