public static void Run(string[] args) { Console.WriteLine("Connecting to node"); var networkParams = NetworkParameters.ProdNet(); using (var blockStore = new MemoryBlockStore(networkParams)) { var chain = new BlockChain(networkParams, blockStore); var peer = new Peer(networkParams, new PeerAddress(IPAddress.Loopback), chain); peer.Connect(); new Thread(() => peer.Run(CancellationToken.None)).Start(); var blockHash = new Sha256Hash(args[0]); var future = peer.BeginGetBlock(blockHash, null, null); Console.WriteLine("Waiting for node to send us the requested block: " + blockHash); var block = peer.EndGetBlock(future); Console.WriteLine(block); peer.Disconnect(); } }
public static void Run(string[] args) { Console.WriteLine("Connecting to node"); var @params = NetworkParameters.ProdNet(); using (var blockStore = new MemoryBlockStore(@params)) { var chain = new BlockChain(@params, blockStore); var peer = new Peer(@params, new PeerAddress(IPAddress.Loopback), chain); peer.Connect(); new Thread(peer.Run).Start(); var blockHash = new Sha256Hash(args[0]); var future = peer.BeginGetBlock(blockHash, null, null); Console.WriteLine("Waiting for node to send us the requested block: " + blockHash); var block = peer.EndGetBlock(future); Console.WriteLine(block); peer.Disconnect(); } }