Skip to content

Running the example

Running the example

Running just an instance doesn't fully show you how the program behave, it needs at least 2 peers to connect to each other, that's why there are already multiple configuration files configured differently to let you connect two instances together.

You can run one instance by setting MithrilShards.Example.Node as the startup project and run the launchSettings profile "node1" .

Then open a shell at the MithrilShards.Example.Node project path and run the command below

1
dotnet run --no-build --settings forge-settings2.json

This would cause you to have a debuggable instance running with the configuration defined in forge-settings.json file and another run running on the forge-settings2.json configuration.

Alternatively you can run both instances, without a debugger (but you can attach later the process to Visual Studio) by running on two different shells:

1
2
dotnet run --no-build --settings forge-settings.json
dotnet run --no-build --settings forge-settings2.json

The program running forge-settings.json contains the most verbose log level and you'll have the best experience if you install (or use a docker image) of Seq configured on the port specified in your configuration file (e.g. localhost:5341).
See SerilogShard for more details.

Here an example of the configuration file (forge-settings.json)

 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
{
   "ForgeConnectivity": {
      "ForceShutdownAfter": 300,
      "MaxInboundConnections": 25,
      "AllowLoopbackConnection": false,
      "Listeners": [
         {
            "IsWhitelistingEndpoint": true,
            "Endpoint": "0.0.0.0:45051"
         },
         {
            "IsWhitelistingEndpoint": true,
            "Endpoint": "127.0.0.1:45052",
            "PublicEndpoint": "98.0.0.1:45011"
         }
      ]
   },
   "Example": {
      "MaxTimeAdjustment": 4200,
      "Connections": [
         {
            "Endpoint": "127.0.0.1:45061",
            "AdditionalInformation": "I'm cool!"
         }
      ]
   },
   "StatisticsCollector": {
      "ContinuousConsoleDisplay": false,
      "ContinuousConsoleDisplayRate": 5
   },
   "DevController": {
      "Enabled": true
   },
   "WebApi": {
      "EndPoint": "127.0.0.1:45020",
      "Enabled": true,
      "Https": false
   },

   "Serilog": {
      "Using": [ "Serilog.Sinks.Console", "Serilog.Sinks.Seq" ],
      "Enrich": [ "FromLogContext", "WithMachineName", "WithThreadId" ],
      "WriteTo": [
         {
            "Name": "Console",
            "Args": {
               "IncludeScopes": true,
               "theme": "Serilog.Sinks.SystemConsole.Themes.AnsiConsoleTheme::Code, Serilog.Sinks.Console"
            }
         },
         {
            "Name": "Seq",
            "Args": { "serverUrl": "http://localhost:5341" }
         }
      ],
      "MinimumLevel": {
         "Default": "Debug",
         "Override": {
            "Bedrock.Framework": "Warning",
            "Microsoft": "Warning",
            "System": "Warning"
         }
      }
   }
}

Some Screenshots

Here a screenshot that shows the content of the shell when running the node with settings = forge-settings.json

image-20210331175542234

You can access the Swagger UI by opening the address https://127.0.0.1:45020/docs/index.html
image-20210331180535114

Here you can manipulate quotes using the Web API, or even manually attempt to connect to other peers using PeerManagement Connect action in the DEV area.

If you installed Seq, you can access the logs in a better way like shown here:
image-20210331180409700


Last update: 2021-04-08