<commit_before>﻿using NBitcoin;
using NBitcoin.DataEncoders;
using NBitcoin.Protocol;
using NBitcoin.RPC;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Threading.Tasks;

namespace NBitcoin.Altcoins
{
	// Reference: https://github.com/qtumproject/qtum/blob/f925e854a84165f8302aa2772cc90faf8a98cb61/src/chainparams.cpp
	public class Qtum : NetworkSetBase
	{
		public static Qtum Instance { get; } = new Qtum();

		public override string CryptoCode => "QTUM";

		private Qtum()
		{

		}
		public class QtumConsensusFactory : ConsensusFactory
		{
			private QtumConsensusFactory()
			{
			}
			public static QtumConsensusFactory Instance { get; } = new QtumConsensusFactory();

			public override BlockHeader CreateBlockHeader()
			{
				return new QtumBlockHeader();
			}
			public override Block CreateBlock()
			{
				return new QtumBlock(new QtumBlockHeader());
			}
		}

#pragma warning disable CS0618 // Type or member is obsolete
		public class AuxPow : IBitcoinSerializable
		{
			uint256 hashStateRoot = uint256.Zero;

			public uint256 HashStateRoot
			{
				get
				{
					return hashStateRoot;
				}
				set
				{
					hashStateRoot = value;
				}
			}

			uint256 hashUtxoRoot = uint256.Zero;

			public uint256 HashUtxoRoot
			{
				get
				{
					return hashUtxoRoot;
				}
				set
				{
					hashUtxoRoot = value;
				}
			}

			OutPoint prevoutStake = OutPoint.Zero;

			public OutPoint PrevoutStake
			{
				get
				{
					return prevoutStake;
				}
				set
				{
					prevoutStake = value;
				}
			}

			Script blockSignature = Script.Empty;

			public Script BlockSignature
			{
				get
				{
					return blockSignature;
				}
				set
				{
					blockSignature = value;
				}
			}

			public void ReadWrite(BitcoinStream stream)
			{
				stream.ReadWrite(ref hashStateRoot);
				stream.ReadWrite(ref hashUtxoRoot);
				stream.ReadWrite(ref prevoutStake);
				stream.ReadWrite(ref blockSignature);
			}
		}

		public class QtumBlock : Block
		{
			public QtumBlock(QtumBlockHeader header) : base(header)
			{

			}

			public override ConsensusFactory GetConsensusFactory()<commit_msg>Fix blockheader parse logic for QTUM<commit_after>﻿using NBitcoin;
using NBitcoin.DataEncoders;
using NBitcoin.Protocol;
using NBitcoin.RPC;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Threading.Tasks;

namespace NBitcoin.Altcoins
{
	// Reference: https://github.com/qtumproject/qtum/blob/f925e854a84165f8302aa2772cc90faf8a98cb61/src/chainparams.cpp
	public class Qtum : NetworkSetBase
	{
		public static Qtum Instance { get; } = new Qtum();

		public override string CryptoCode => "QTUM";

		private Qtum()
		{

		}
		public class QtumConsensusFactory : ConsensusFactory
		{
			private QtumConsensusFactory()
			{
			}
			public static QtumConsensusFactory Instance { get; } = new QtumConsensusFactory();

			public override BlockHeader CreateBlockHeader()
			{
				return new QtumBlockHeader();
			}
			public override Block CreateBlock()
			{
				return new QtumBlock(new QtumBlockHeader());
			}
		}

#pragma warning disable CS0618 // Type or member is obsolete
		public class AuxPow : IBitcoinSerializable
		{
			uint256 hashStateRoot = uint256.Zero;

			public uint256 HashStateRoot
			{
				get
				{
					return hashStateRoot;
				}
				set
				{
					hashStateRoot = value;
				}
			}

			uint256 hashUtxoRoot = uint256.Zero;

			public uint256 HashUtxoRoot
			{
				get
				{
					return hashUtxoRoot;
				}
				set
				{
					hashUtxoRoot = value;
				}
			}

			OutPoint prevoutStake = OutPoint.Zero;

			public OutPoint PrevoutStake
			{
				get
				{
					return prevoutStake;
				}
				set
				{
					prevoutStake = value;
				}
			}

			byte[] blockSignature = null;

			public byte[] BlockSignature
			{
				get
				{
					return blockSignature;
				}
				set
				{
					blockSignature = value;
				}
			}

			public void ReadWrite(BitcoinStream stream)
			{
				stream.ReadWrite(ref hashStateRoot);
				stream.ReadWrite(ref hashUtxoRoot);
				stream.ReadWrite(ref prevoutStake);
				stream.ReadWriteAsVarString(ref blockSignature);
			}
		}

		public class QtumBlock : Block
		{
			public QtumBlock(QtumBlockHeader header) : base(header)
			{

			}

			public override ConsensusFactory GetConsensusFactory()
{'fraction_non_alphanumeric': 0.07993586807146129, 'fraction_numerical': 0.021988089784699953, 'mean_word_length': 2.902591599642538, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 2, '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': '4088068', 'n_tokens_mistral': 1904, 'n_tokens_neox': 1414, 'n_words': 314}