-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added basetuple with arguments up to 39 in again
added reconenctivity on json rpc disconnect
- Loading branch information
1 parent
0ad0b79
commit 08f3985
Showing
6 changed files
with
7,116 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
using Serilog; | ||
using Substrate.NetApi; | ||
using Substrate.NetApi.Model.Extrinsics; | ||
|
||
internal class Program | ||
{ | ||
private static async Task Main(string[] args) | ||
{ | ||
// Configure Serilog for logging | ||
Log.Logger = new LoggerConfiguration() | ||
.WriteTo.Console() | ||
.MinimumLevel.Debug() | ||
.CreateLogger(); | ||
|
||
// Set up a cancellation token for graceful shutdown | ||
CancellationTokenSource cts = new CancellationTokenSource(); | ||
|
||
await MainAsync(cts.Token); | ||
|
||
// Keep the application alive to continue monitoring the connection | ||
Console.WriteLine("Press any key to exit..."); | ||
Console.ReadKey(); | ||
|
||
// Cleanup logging resources | ||
await Log.CloseAndFlushAsync(); | ||
} | ||
|
||
private static async Task MainAsync(CancellationToken token) | ||
{ | ||
// Create the client | ||
string substrateNodeUrl = "wss://rpc-parachain.bajun.network"; | ||
var client = new SubstrateClient(new Uri(substrateNodeUrl), ChargeTransactionPayment.Default()); | ||
|
||
while (!token.IsCancellationRequested) | ||
{ | ||
// Ensure the client is connected | ||
if (!client.IsConnected) | ||
{ | ||
Log.Information("Attempting to connect to the client..."); | ||
await client.ConnectAsync( | ||
useMetaData: true, | ||
standardSubstrate: true, | ||
maxRetryAttempts: 5, | ||
delayRetryMilliseconds: 5000, | ||
token: token | ||
); | ||
Log.Information("Client connected successfully."); | ||
} | ||
|
||
var currentBlocknumber = await client.State.GetStorageAsync(Utils.HexToByteArray("0x26aa394eea5630e07c48ae0c9558cef702a5c1b19ab7a04f536c519aca4983ac"), (string)null, token); | ||
Log.Information("MainAsync running... block: {blocknumber}", currentBlocknumber.ToString()); | ||
|
||
// Wait before next call | ||
await Task.Delay(12000); | ||
} | ||
|
||
// Gracefully shut down | ||
await client.CloseAsync(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Serilog.Sinks.Console" Version="6.0.0" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Substrate.NetApi\Substrate.NetApi.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
Oops, something went wrong.