Ejemplo n.º 1
0
        //[Fact]
        public static void Play()
        {
            Stopwatch watch = new Stopwatch();

            watch.Start();
            System.Net.ServicePointManager.DefaultConnectionLimit = 100;
            System.Net.ServicePointManager.Expect100Continue      = false;
            var repo    = new RapidBaseTransactionRepository("http://rapidbase-test.azurewebsites.net/");
            var colored = new OpenAsset.NoSqlColoredTransactionRepository(repo);


            var result = repo
                         .Get("c3462373f1a722c66cbb1b93712df94aa7b3731f4142cd8413f10c9e872927de")
                         .GetColoredTransaction(colored);

            watch.Stop();
            //for(int i = 0 ; i < 100 ; i++)
            //{
            //	using(var node = Node.ConnectToLocal(Network.Main))
            //	{
            //		node.VersionHandshake();
            //		var chain = new ConcurrentChain(Network.Main);
            //		node.SynchronizeChain(chain);
            //	}
            //}
        }
Ejemplo n.º 2
0
        public static void Play()
        {
            var node = Node.ConnectToLocal(Network.TestNet);

            node.VersionHandshake();
            var chain = node.GetChain();
            var r     = chain.Validate(Network.TestNet, true);

            //Wallet wallet = new Wallet(new ExtKey(), Network.Main);
            //wallet.Connect(addrman: AddressManager.LoadPeerFile(@"E:\Program Files\Bitcoin\peers.dat", Network.Main));
            //while(true)
            //{
            //	Thread.Sleep(1000);
            //	Console.WriteLine(wallet.ConnectedNodes + " " + wallet.State);

            //}

            //var node = Node.ConnectToLocal(Network.Main);
            //node.VersionHandshake();
            //var chain = node.GetChain();
            //var v3 = chain.Tip
            //	.EnumerateToGenesis()
            //	.Take(1000)
            //	.Aggregate(0, (a, b) => b.Header.Version == 3 ? a+1 : a);

            //var r = (double)v3 / (double)1000;

            Stopwatch watch = new Stopwatch();

            watch.Start();
            System.Net.ServicePointManager.DefaultConnectionLimit = 100;
            System.Net.ServicePointManager.Expect100Continue      = false;
            var repo    = new QBitNinjaTransactionRepository("http://rapidbase-test.azurewebsites.net/");
            var colored = new OpenAsset.NoSqlColoredTransactionRepository(repo);


            var result = repo
                         .Get("c3462373f1a722c66cbb1b93712df94aa7b3731f4142cd8413f10c9e872927de")
                         .GetColoredTransaction(colored);

            watch.Stop();
            //for(int i = 0 ; i < 100 ; i++)
            //{
            //	using(var node = Node.ConnectToLocal(Network.Main))
            //	{
            //		node.VersionHandshake();
            //		var chain = new ConcurrentChain(Network.Main);
            //		node.SynchronizeChain(chain);
            //	}
            //}
        }
Ejemplo n.º 3
0
        public static void Play()
        {
            new Key().PubKey.WitHash.GetAddress(Network.SegNet).ToString();

            var node = Node.Connect(Network.SegNet, "qbitninja-server.cloudapp.net");

            node.VersionHandshake();

            uint256 p2wsh      = null;
            uint256 p2pwkh     = null;
            uint256 p2wshp2sh  = null;
            uint256 p2wpkhp2sh = null;

            foreach (var block in node.GetBlocks())
            {
                foreach (var tx in block.Transactions)
                {
                    if (p2wsh != null && p2pwkh != null && p2wshp2sh != null && p2wpkhp2sh != null)
                    {
                        break;
                    }
                    if (!tx.IsCoinBase && !tx.Witness.IsEmpty)
                    {
                        foreach (var input in tx.Inputs.AsIndexedInputs())
                        {
                            if (input.WitScript == WitScript.Empty)
                            {
                                continue;
                            }
                            if (input.ScriptSig == Script.Empty)
                            {
                                if (PayToWitPubKeyHashTemplate.Instance.ExtractWitScriptParameters(input.WitScript) != null)
                                {
                                    p2pwkh = tx.GetHash();
                                }
                                else
                                {
                                    p2wsh = tx.GetHash();
                                }
                            }
                            else
                            {
                                if (PayToWitPubKeyHashTemplate.Instance.ExtractWitScriptParameters(input.WitScript) != null)
                                {
                                    p2wpkhp2sh = tx.GetHash();
                                }
                                else
                                {
                                    p2wshp2sh = tx.GetHash();
                                }
                            }
                            break;
                        }
                    }
                }
            }

            var secret = new BitcoinSecret("QTrKVpsVwNUD9GayzdbUNz2NNDqiPgjd9RCprwSa4gmBFg3V2oik", Network.SegNet);

            var oo = secret.PubKey.WitHash.GetAddress(Network.SegNet);

            var key = new Key().GetBitcoinSecret(Network.SegNet);
            var aa  = key.GetAddress();

            foreach (var n in new[] { Network.Main, Network.SegNet })
            {
                for (int i = 0; i < 2; i++)
                {
                    BitcoinAddress addr = i == 0 ? (BitcoinAddress) new Key().PubKey.GetSegwitAddress(n) : new Key().ScriptPubKey.GetWitScriptAddress(n);
                    var            c    = addr.ScriptPubKey.ToString();
                }
            }


            var             networks  = Network.GetNetworks().ToArray();
            List <Conflict> conflicts = new List <Conflict>();

            for (int n = 0; n < networks.Length; n++)
            {
                for (int n2 = n + 1; n2 < networks.Length; n2++)
                {
                    var a = networks[n];
                    var b = networks[n2];
                    if (a == Network.RegTest || b == Network.RegTest)
                    {
                        continue;
                    }
                    if (a == b)
                    {
                        throw new Exception();
                    }
                    for (int i = 0; i < a.base58Prefixes.Length; i++)
                    {
                        for (int y = i + 1; y < a.base58Prefixes.Length; y++)
                        {
                            if (a.base58Prefixes[i] != null && b.base58Prefixes[y] != null)
                            {
                                var ae = Encoders.Hex.EncodeData(a.base58Prefixes[i]);
                                var be = Encoders.Hex.EncodeData(b.base58Prefixes[y]);
                                if (ae == be)
                                {
                                    continue;
                                }
                                if (ae.StartsWith(be) || be.StartsWith(ae))
                                {
                                    ConflictPart ca = new ConflictPart();
                                    ca.Network = a;
                                    ca.Type    = (Base58Type)i;
                                    ca.Value   = a.base58Prefixes[i];

                                    ConflictPart cb = new ConflictPart();
                                    cb.Network = b;
                                    cb.Type    = (Base58Type)y;
                                    cb.Value   = b.base58Prefixes[y];

                                    Conflict cc = new Conflict();
                                    cc.A = ca;
                                    cc.B = cb;
                                    conflicts.Add(cc);
                                }
                            }
                        }
                    }
                }
            }

            var rr = String.Join("\r\n", conflicts.OfType <object>().ToArray());

            Console.WriteLine();

            //ConcurrentChain chain = new ConcurrentChain(Network.Main);
            //ChainBehavior chainBehavior = new ChainBehavior(chain);
            //NodeConnectionParameters para = new NodeConnectionParameters();
            //para.TemplateBehaviors.Add(chainBehavior);

            //NodesGroup group = new NodesGroup(Network.Main, para);
            //group.Connect();
            //while(true)
            //{
            //	Thread.Sleep(1000);
            //}



            //Parallel.ForEach(Enumerable.Range(0, 10), _ =>
            //{
            //	ConcurrentChain chain = new ConcurrentChain(Network.Main);
            //	node.SynchronizeChain(chain);
            //});

            //Wallet wallet = new Wallet(new ExtKey(), Network.Main);
            //wallet.Connect(addrman: AddressManager.LoadPeerFile(@"E:\Program Files\Bitcoin\peers.dat", Network.Main));
            //while(true)
            //{
            //	Thread.Sleep(1000);
            //	Console.WriteLine(wallet.ConnectedNodes + " " + wallet.State);

            //}

            //var node = Node.ConnectToLocal(Network.Main);
            //node.VersionHandshake();
            //var chain = node.GetChain();
            //var v3 = chain.Tip
            //	.EnumerateToGenesis()
            //	.Take(1000)
            //	.Aggregate(0, (a, b) => b.Header.Version == 3 ? a+1 : a);

            //var r = (double)v3 / (double)1000;

            Stopwatch watch = new Stopwatch();

            watch.Start();
            System.Net.ServicePointManager.DefaultConnectionLimit = 100;
            System.Net.ServicePointManager.Expect100Continue      = false;
            var repo    = new QBitNinjaTransactionRepository("http://rapidbase-test.azurewebsites.net/");
            var colored = new OpenAsset.NoSqlColoredTransactionRepository(repo);


            var result = repo
                         .Get("c3462373f1a722c66cbb1b93712df94aa7b3731f4142cd8413f10c9e872927de")
                         .GetColoredTransaction(colored);

            watch.Stop();
            //for(int i = 0 ; i < 100 ; i++)
            //{
            //	using(var node = Node.ConnectToLocal(Network.Main))
            //	{
            //		node.VersionHandshake();
            //		var chain = new ConcurrentChain(Network.Main);
            //		node.SynchronizeChain(chain);
            //	}
            //}
        }
Ejemplo n.º 4
0
		public static void Play()
		{
			Transaction txxxxx = new Transaction("0100000000010213206299feb17742091c3cb2ab45faa3aa87922d3c030cafb3f798850a2722bf0000000000feffffffa12f2424b9599898a1d30f06e1ce55eba7fabfeee82ae9356f07375806632ff3010000006b483045022100fcc8cf3014248e1a0d6dcddf03e80f7e591605ad0dbace27d2c0d87274f8cd66022053fcfff64f35f22a14deb657ac57f110084fb07bb917c3b42e7d033c54c7717b012102b9e4dcc33c9cc9cb5f42b96dddb3b475b067f3e21125f79e10c853e5ca8fba31feffffff02206f9800000000001976a9144841b9874d913c430048c78a7b18baebdbea440588ac8096980000000000160014e4873ef43eac347471dd94bc899c51b395a509a502483045022100dd8250f8b5c2035d8feefae530b10862a63030590a851183cb61b3672eb4f26e022057fe7bc8593f05416c185d829b574290fb8706423451ebd0a0ae50c276b87b43012102179862f40b85fa43487500f1d6b13c864b5eb0a83999738db0f7a6b91b2ec64f00db080000");

			Script scriptCode = new Script("OP_DUP OP_HASH160 e4873ef43eac347471dd94bc899c51b395a509a5 OP_EQUALVERIFY OP_CHECKSIG");
			var rrrr = Script.SignatureHash(scriptCode, txxxxx, 0, SigHash.All, Money.Satoshis(10000000), HashVersion.Witness);

			//Console.WriteLine(total);
			new Key().PubKey.WitHash.GetAddress(Network.SegNet).ToString();

			var node = Node.Connect(Network.SegNet, "qbitninja-server.cloudapp.net");
			node.VersionHandshake();

			uint256 p2wsh = null;
			uint256 p2pwkh = null;
			uint256 p2wshp2sh = null;
			uint256 p2wpkhp2sh = null;
			foreach(var block in node.GetBlocks())
			{
				foreach(var tx in block.Transactions)
				{
					if(p2wsh != null && p2pwkh != null && p2wshp2sh != null && p2wpkhp2sh != null)
						break;
					if(!tx.IsCoinBase && tx.HasWitness)
					{
						foreach(var input in tx.Inputs.AsIndexedInputs())
						{
							if(input.WitScript == WitScript.Empty)
								continue;
							if(input.ScriptSig == Script.Empty)
							{
								if(PayToWitPubKeyHashTemplate.Instance.ExtractWitScriptParameters(input.WitScript) != null)
									p2pwkh = tx.GetHash();
								else
									p2wsh = tx.GetHash();
							}
							else
							{
								if(PayToWitPubKeyHashTemplate.Instance.ExtractWitScriptParameters(input.WitScript) != null)
									p2wpkhp2sh = tx.GetHash();
								else
									p2wshp2sh = tx.GetHash();
							}
							break;
						}
					}
				}
			}

			var secret = new BitcoinSecret("QTrKVpsVwNUD9GayzdbUNz2NNDqiPgjd9RCprwSa4gmBFg3V2oik", Network.SegNet);

			var oo = secret.PubKey.WitHash.GetAddress(Network.SegNet);

			var key = new Key().GetBitcoinSecret(Network.SegNet);
			var aa = key.GetAddress();
			foreach(var n in new[] { Network.Main, Network.SegNet })
			{
				for(int i = 0 ; i < 2 ; i++)
				{
					BitcoinAddress addr = i == 0 ? (BitcoinAddress)new Key().PubKey.GetSegwitAddress(n) : new Key().ScriptPubKey.GetWitScriptAddress(n);
					var c = addr.ScriptPubKey.ToString();
				}
			}


			var networks = Network.GetNetworks().ToArray();
			List<Conflict> conflicts = new List<Conflict>();
			for(int n = 0 ; n < networks.Length ; n++)
			{
				for(int n2 = n + 1 ; n2 < networks.Length ; n2++)
				{
					var a = networks[n];
					var b = networks[n2];
					if(a == Network.RegTest || b == Network.RegTest)
						continue;
					if(a == b)
						throw new Exception();
					for(int i = 0 ; i < a.base58Prefixes.Length ; i++)
					{
						for(int y = i + 1 ; y < a.base58Prefixes.Length ; y++)
						{
							if(a.base58Prefixes[i] != null && b.base58Prefixes[y] != null)
							{
								var ae = Encoders.Hex.EncodeData(a.base58Prefixes[i]);
								var be = Encoders.Hex.EncodeData(b.base58Prefixes[y]);
								if(ae == be)
									continue;
								if(ae.StartsWith(be) || be.StartsWith(ae))
								{
									ConflictPart ca = new ConflictPart();
									ca.Network = a;
									ca.Type = (Base58Type)i;
									ca.Value = a.base58Prefixes[i];

									ConflictPart cb = new ConflictPart();
									cb.Network = b;
									cb.Type = (Base58Type)y;
									cb.Value = b.base58Prefixes[y];

									Conflict cc = new Conflict();
									cc.A = ca;
									cc.B = cb;
									conflicts.Add(cc);
								}
							}
						}
					}
				}
			}

			var rr = String.Join("\r\n", conflicts.OfType<object>().ToArray());
			Console.WriteLine();

			//ConcurrentChain chain = new ConcurrentChain(Network.Main);
			//ChainBehavior chainBehavior = new ChainBehavior(chain);
			//NodeConnectionParameters para = new NodeConnectionParameters();
			//para.TemplateBehaviors.Add(chainBehavior);

			//NodesGroup group = new NodesGroup(Network.Main, para);
			//group.Connect();
			//while(true)
			//{
			//	Thread.Sleep(1000);
			//}



			//Parallel.ForEach(Enumerable.Range(0, 10), _ =>
			//{
			//	ConcurrentChain chain = new ConcurrentChain(Network.Main);
			//	node.SynchronizeChain(chain);
			//});

			//Wallet wallet = new Wallet(new ExtKey(), Network.Main);
			//wallet.Connect(addrman: AddressManager.LoadPeerFile(@"E:\Program Files\Bitcoin\peers.dat", Network.Main));
			//while(true)
			//{
			//	Thread.Sleep(1000);
			//	Console.WriteLine(wallet.ConnectedNodes + " " + wallet.State);

			//}

			//var node = Node.ConnectToLocal(Network.Main);
			//node.VersionHandshake();
			//var chain = node.GetChain();
			//var v3 = chain.Tip
			//	.EnumerateToGenesis()
			//	.Take(1000)
			//	.Aggregate(0, (a, b) => b.Header.Version == 3 ? a+1 : a);

			//var r = (double)v3 / (double)1000;

			Stopwatch watch = new Stopwatch();
			watch.Start();
			System.Net.ServicePointManager.DefaultConnectionLimit = 100;
			System.Net.ServicePointManager.Expect100Continue = false;
			var repo = new QBitNinjaTransactionRepository("http://rapidbase-test.azurewebsites.net/");
			var colored = new OpenAsset.NoSqlColoredTransactionRepository(repo);


			var result = repo
				.Get("c3462373f1a722c66cbb1b93712df94aa7b3731f4142cd8413f10c9e872927de")
				.GetColoredTransaction(colored);
			watch.Stop();
			//for(int i = 0 ; i < 100 ; i++)
			//{
			//	using(var node = Node.ConnectToLocal(Network.Main))
			//	{
			//		node.VersionHandshake();
			//		var chain = new ConcurrentChain(Network.Main);
			//		node.SynchronizeChain(chain);
			//	}
			//}
		}
Ejemplo n.º 5
0
		public static void Play()
		{
			for(int i = 0 ; i < 400000 ; i++)
			{
				var node = Node.Connect(Network.Main, "23.102.26.138:1273");
				node.StateChanged += (s, a) =>
				{
					if(node.State == NodeState.HandShaked)
					{
						ConcurrentChain chain = new ConcurrentChain(Network.Main);
						node.SynchronizeChain(chain);
					}
				};
				node.VersionHandshake();
				node.DisconnectAsync();
			}
			

			//Parallel.ForEach(Enumerable.Range(0, 10), _ =>
			//{
			//	ConcurrentChain chain = new ConcurrentChain(Network.Main);
			//	node.SynchronizeChain(chain);
			//});

			//Wallet wallet = new Wallet(new ExtKey(), Network.Main);
			//wallet.Connect(addrman: AddressManager.LoadPeerFile(@"E:\Program Files\Bitcoin\peers.dat", Network.Main));
			//while(true)
			//{
			//	Thread.Sleep(1000);
			//	Console.WriteLine(wallet.ConnectedNodes + " " + wallet.State);

			//}

			//var node = Node.ConnectToLocal(Network.Main);
			//node.VersionHandshake();
			//var chain = node.GetChain();
			//var v3 = chain.Tip
			//	.EnumerateToGenesis()
			//	.Take(1000)
			//	.Aggregate(0, (a, b) => b.Header.Version == 3 ? a+1 : a);

			//var r = (double)v3 / (double)1000;

			Stopwatch watch = new Stopwatch();
			watch.Start();
			System.Net.ServicePointManager.DefaultConnectionLimit = 100;
			System.Net.ServicePointManager.Expect100Continue = false;
			var repo = new QBitNinjaTransactionRepository("http://rapidbase-test.azurewebsites.net/");
			var colored = new OpenAsset.NoSqlColoredTransactionRepository(repo);


			var result = repo
				.Get("c3462373f1a722c66cbb1b93712df94aa7b3731f4142cd8413f10c9e872927de")
				.GetColoredTransaction(colored);
			watch.Stop();
			//for(int i = 0 ; i < 100 ; i++)
			//{
			//	using(var node = Node.ConnectToLocal(Network.Main))
			//	{
			//		node.VersionHandshake();
			//		var chain = new ConcurrentChain(Network.Main);
			//		node.SynchronizeChain(chain);
			//	}
			//}
		}
Ejemplo n.º 6
0
		public static void Play()
		{
			new Key().PubKey.WitHash.GetAddress(Network.SegNet).ToString();

			var node = Node.Connect(Network.SegNet, "qbitninja-server.cloudapp.net");
			node.VersionHandshake();

			uint256 p2wsh = null;
			uint256 p2pwkh = null;
			uint256 p2wshp2sh = null;
			uint256 p2wpkhp2sh = null;
			foreach(var block in node.GetBlocks())
			{
				foreach(var tx in block.Transactions)
				{
					if(p2wsh != null && p2pwkh != null && p2wshp2sh != null && p2wpkhp2sh != null)
						break;
					if(!tx.IsCoinBase && !tx.Witness.IsEmpty)
					{
						foreach(var input in tx.Inputs.AsIndexedInputs())
						{
							if(input.WitScript == WitScript.Empty)
								continue;
							if(input.ScriptSig == Script.Empty)
							{
								if(PayToWitPubKeyHashTemplate.Instance.ExtractWitScriptParameters(input.WitScript) != null)
									p2pwkh = tx.GetHash();
								else
									p2wsh = tx.GetHash();
							}
							else
							{
								if(PayToWitPubKeyHashTemplate.Instance.ExtractWitScriptParameters(input.WitScript) != null)
									p2wpkhp2sh = tx.GetHash();
								else
									p2wshp2sh = tx.GetHash();
							}
							break;
						}
					}
				}
			}

			var secret = new BitcoinSecret("QTrKVpsVwNUD9GayzdbUNz2NNDqiPgjd9RCprwSa4gmBFg3V2oik", Network.SegNet);

			var oo = secret.PubKey.WitHash.GetAddress(Network.SegNet);

			var key = new Key().GetBitcoinSecret(Network.SegNet);
			var aa = key.GetAddress();
			foreach(var n in new[]{Network.Main, Network.SegNet})
			{
				for(int i = 0; i < 2;i++)
				{
					BitcoinAddress addr = i == 0 ? (BitcoinAddress)new Key().PubKey.GetSegwitAddress(n) : new Key().ScriptPubKey.GetWitScriptAddress(n);
					var c = addr.ScriptPubKey.ToString();
				}
			}


			var networks = Network.GetNetworks().ToArray();		
			List<Conflict> conflicts = new List<Conflict>();
			for(int n = 0 ; n < networks.Length ; n++)
			{
				for(int n2 = n+1; n2 < networks.Length ; n2++)
				{
					var a = networks[n];
					var b = networks[n2];
					if(a == Network.RegTest || b == Network.RegTest)
						continue;
					if(a == b)
						throw new Exception();
					for(int i = 0 ; i < a.base58Prefixes.Length ; i++)
					{
						for(int y = i + 1 ; y < a.base58Prefixes.Length ; y++)
						{
							if(a.base58Prefixes[i] != null && b.base58Prefixes[y] != null)
							{
								var ae = Encoders.Hex.EncodeData(a.base58Prefixes[i]);
								var be = Encoders.Hex.EncodeData(b.base58Prefixes[y]);
								if(ae == be)
									continue;
								if(ae.StartsWith(be) || be.StartsWith(ae))
								{
									ConflictPart ca = new ConflictPart();
									ca.Network = a;
									ca.Type = (Base58Type)i;
									ca.Value = a.base58Prefixes[i];

									ConflictPart cb = new ConflictPart();
									cb.Network = b;
									cb.Type = (Base58Type)y;
									cb.Value = b.base58Prefixes[y];

									Conflict cc = new Conflict();
									cc.A = ca;
									cc.B = cb;
									conflicts.Add(cc);
								}
							}
						}
					}
				}
			}

			var rr = String.Join("\r\n", conflicts.OfType<object>().ToArray());
			Console.WriteLine();

			//ConcurrentChain chain = new ConcurrentChain(Network.Main);
			//ChainBehavior chainBehavior = new ChainBehavior(chain);
			//NodeConnectionParameters para = new NodeConnectionParameters();
			//para.TemplateBehaviors.Add(chainBehavior);

			//NodesGroup group = new NodesGroup(Network.Main, para);
			//group.Connect();
			//while(true)
			//{
			//	Thread.Sleep(1000);
			//}



			//Parallel.ForEach(Enumerable.Range(0, 10), _ =>
			//{
			//	ConcurrentChain chain = new ConcurrentChain(Network.Main);
			//	node.SynchronizeChain(chain);
			//});

			//Wallet wallet = new Wallet(new ExtKey(), Network.Main);
			//wallet.Connect(addrman: AddressManager.LoadPeerFile(@"E:\Program Files\Bitcoin\peers.dat", Network.Main));
			//while(true)
			//{
			//	Thread.Sleep(1000);
			//	Console.WriteLine(wallet.ConnectedNodes + " " + wallet.State);

			//}

			//var node = Node.ConnectToLocal(Network.Main);
			//node.VersionHandshake();
			//var chain = node.GetChain();
			//var v3 = chain.Tip
			//	.EnumerateToGenesis()
			//	.Take(1000)
			//	.Aggregate(0, (a, b) => b.Header.Version == 3 ? a+1 : a);

			//var r = (double)v3 / (double)1000;

			Stopwatch watch = new Stopwatch();
			watch.Start();
			System.Net.ServicePointManager.DefaultConnectionLimit = 100;
			System.Net.ServicePointManager.Expect100Continue = false;
			var repo = new QBitNinjaTransactionRepository("http://rapidbase-test.azurewebsites.net/");
			var colored = new OpenAsset.NoSqlColoredTransactionRepository(repo);


			var result = repo
				.Get("c3462373f1a722c66cbb1b93712df94aa7b3731f4142cd8413f10c9e872927de")
				.GetColoredTransaction(colored);
			watch.Stop();
			//for(int i = 0 ; i < 100 ; i++)
			//{
			//	using(var node = Node.ConnectToLocal(Network.Main))
			//	{
			//		node.VersionHandshake();
			//		var chain = new ConcurrentChain(Network.Main);
			//		node.SynchronizeChain(chain);
			//	}
			//}
		}
Ejemplo n.º 7
0
		public static void Play()
		{
			var networks = Network.GetNetworks().ToArray();		
			List<Conflict> conflicts = new List<Conflict>();
			for(int n = 0 ; n < networks.Length ; n++)
			{
				for(int n2 = n+1; n2 < networks.Length ; n2++)
				{
					var a = networks[n];
					var b = networks[n2];
					if(a == Network.RegTest || b == Network.RegTest)
						continue;
					if(a == b)
						throw new Exception();
					for(int i = 0 ; i < a.base58Prefixes.Length ; i++)
					{
						for(int y = i + 1 ; y < a.base58Prefixes.Length ; y++)
						{
							if(a.base58Prefixes[i] != null && b.base58Prefixes[y] != null)
							{
								var ae = Encoders.Hex.EncodeData(a.base58Prefixes[i]);
								var be = Encoders.Hex.EncodeData(b.base58Prefixes[y]);
								if(ae == be)
									continue;
								if(ae.StartsWith(be) || be.StartsWith(ae))
								{
									ConflictPart ca = new ConflictPart();
									ca.Network = a;
									ca.Type = (Base58Type)i;
									ca.Value = a.base58Prefixes[i];

									ConflictPart cb = new ConflictPart();
									cb.Network = b;
									cb.Type = (Base58Type)y;
									cb.Value = b.base58Prefixes[y];

									Conflict cc = new Conflict();
									cc.A = ca;
									cc.B = cb;
									conflicts.Add(cc);
								}
							}
						}
					}
				}
			}

			var rr = String.Join("\r\n", conflicts.OfType<object>().ToArray());
			Console.WriteLine();

			//ConcurrentChain chain = new ConcurrentChain(Network.Main);
			//ChainBehavior chainBehavior = new ChainBehavior(chain);
			//NodeConnectionParameters para = new NodeConnectionParameters();
			//para.TemplateBehaviors.Add(chainBehavior);

			//NodesGroup group = new NodesGroup(Network.Main, para);
			//group.Connect();
			//while(true)
			//{
			//	Thread.Sleep(1000);
			//}



			//Parallel.ForEach(Enumerable.Range(0, 10), _ =>
			//{
			//	ConcurrentChain chain = new ConcurrentChain(Network.Main);
			//	node.SynchronizeChain(chain);
			//});

			//Wallet wallet = new Wallet(new ExtKey(), Network.Main);
			//wallet.Connect(addrman: AddressManager.LoadPeerFile(@"E:\Program Files\Bitcoin\peers.dat", Network.Main));
			//while(true)
			//{
			//	Thread.Sleep(1000);
			//	Console.WriteLine(wallet.ConnectedNodes + " " + wallet.State);

			//}

			//var node = Node.ConnectToLocal(Network.Main);
			//node.VersionHandshake();
			//var chain = node.GetChain();
			//var v3 = chain.Tip
			//	.EnumerateToGenesis()
			//	.Take(1000)
			//	.Aggregate(0, (a, b) => b.Header.Version == 3 ? a+1 : a);

			//var r = (double)v3 / (double)1000;

			Stopwatch watch = new Stopwatch();
			watch.Start();
			System.Net.ServicePointManager.DefaultConnectionLimit = 100;
			System.Net.ServicePointManager.Expect100Continue = false;
			var repo = new QBitNinjaTransactionRepository("http://rapidbase-test.azurewebsites.net/");
			var colored = new OpenAsset.NoSqlColoredTransactionRepository(repo);


			var result = repo
				.Get("c3462373f1a722c66cbb1b93712df94aa7b3731f4142cd8413f10c9e872927de")
				.GetColoredTransaction(colored);
			watch.Stop();
			//for(int i = 0 ; i < 100 ; i++)
			//{
			//	using(var node = Node.ConnectToLocal(Network.Main))
			//	{
			//		node.VersionHandshake();
			//		var chain = new ConcurrentChain(Network.Main);
			//		node.SynchronizeChain(chain);
			//	}
			//}
		}