private Transaction GetTransactionFromBlock(ApplicationEngine engine, byte[] blockIndexOrHash, int txIndex)
        {
            UInt256 hash;

            if (blockIndexOrHash.Length < UInt256.Length)
            {
                hash = GetBlockHash(engine.Snapshot, (uint)new BigInteger(blockIndexOrHash));
            }
            else if (blockIndexOrHash.Length == UInt256.Length)
            {
                hash = new UInt256(blockIndexOrHash);
            }
            else
            {
                throw new ArgumentException(null, nameof(blockIndexOrHash));
            }
            if (hash is null)
            {
                return(null);
            }
            TrimmedBlock block = GetTrimmedBlock(engine.Snapshot, hash);

            if (block is null || !IsTraceableBlock(engine.Snapshot, block.Index, engine.ProtocolSettings.MaxTraceableBlocks))
            {
                return(null);
            }
            if (txIndex < 0 || txIndex >= block.Hashes.Length)
            {
                throw new ArgumentOutOfRangeException(nameof(txIndex));
            }
            return(GetTransaction(engine.Snapshot, block.Hashes[txIndex]));
        }
        private TrimmedBlock GetBlock(ApplicationEngine engine, byte[] indexOrHash)
        {
            UInt256 hash;

            if (indexOrHash.Length < UInt256.Length)
            {
                hash = GetBlockHash(engine.Snapshot, (uint)new BigInteger(indexOrHash));
            }
            else if (indexOrHash.Length == UInt256.Length)
            {
                hash = new UInt256(indexOrHash);
            }
            else
            {
                throw new ArgumentException(null, nameof(indexOrHash));
            }
            if (hash is null)
            {
                return(null);
            }
            TrimmedBlock block = GetTrimmedBlock(engine.Snapshot, hash);

            if (block is null || !IsTraceableBlock(engine.Snapshot, block.Index, engine.ProtocolSettings.MaxTraceableBlocks))
            {
                return(null);
            }
            return(block);
        }
        /// <summary>
        /// Gets a block with the specified hash.
        /// </summary>
        /// <param name="snapshot">The snapshot used to read data.</param>
        /// <param name="hash">The hash of the block.</param>
        /// <returns>The block with the specified hash.</returns>
        public Block GetBlock(DataCache snapshot, UInt256 hash)
        {
            TrimmedBlock state = GetTrimmedBlock(snapshot, hash);

            if (state is null)
            {
                return(null);
            }
            return(new Block
            {
                Header = state.Header,
                Transactions = state.Hashes.Select(p => GetTransaction(snapshot, p)).ToArray()
            });
        }