-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathProgram.cs
77 lines (63 loc) · 2.71 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
// // Copyright (c) 2016-2024 Knuth Project developers.
// // Distributed under the MIT software license, see the accompanying
// // file COPYING or http://www.opensource.org/licenses/mit-license.php.
// using System;
// using System.Threading.Tasks;
// using Knuth;
// using Serilog;
// namespace console
// {
// public class Program
// {
// private static bool running_;
// static async Task DoSomething(Node node) {
// var result = await node.LaunchAsync();
// if (result != ErrorCode.Success) {
// Log.Error($"Node::LaunchAsync failed; error code: {result}");
// return;
// }
// node.SubscribeBlockNotifications(OnBlockArrived);
// Log.Information("Synchronizing local copy of the blockchain...");
// running_ = true;
// while (running_) {
// var lastHeight = await node.Chain.GetLastHeightAsync();
// if (node.Chain.IsStale) {
// Log.Information("Chain is doing IBD");
// }
// Log.Information("Current height in local copy: " + lastHeight.Result);
// await Task.Delay(5000);
// // return;
// }
// }
// static async Task Main(string[] args) {
// // string configFile = "node.cfg";
// string configFile = "/home/fernando/dev/kth/cs-api/tests/bch/config/invalid.cfg";
// var log = new LoggerConfiguration()
// .MinimumLevel.Debug()
// .WriteTo.ColoredConsole(outputTemplate: "{Timestamp:HH:mm} [{Level}] {Message}{NewLine}{Exception}")
// .CreateLogger();
// Log.Logger = log;
// try {
// Console.CancelKeyPress += OnSigInterrupt;
// Log.Information("Initializing...");
// using (var node = new Knuth.Node(configFile)) {
// await DoSomething(node);
// Log.Information("Shutting down node...");
// }
// } catch (Exception ex) {
// Log.Error(ex,"Error detected");
// }
// Log.CloseAndFlush();
// Log.Information("Node shutdown OK!");
// }
// private static bool OnBlockArrived(ErrorCode errorCode, UInt64 u, BlockList incoming, BlockList outgoing) {
// Log.Information("Block received!");
// return true;
// }
// private static void OnSigInterrupt(object sender, ConsoleCancelEventArgs args) {
// Log.Information("Stop signal detected.");
// args.Cancel = true;
// running_ = false;
// }
// }
// }