Skip to content

Commit 61f98b7

Browse files
committed
A dotnet format cleanup
1 parent 94b605e commit 61f98b7

22 files changed

Lines changed: 228 additions & 228 deletions

File tree

examples/BasicUsage/Program.cs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ static void Main(string[] args)
99
{
1010
Console.WriteLine("=== Bitcoin Kernel Basic Builder Example ===\n");
1111

12-
FullChainstateExample();
13-
12+
FullChainstateExample();
13+
1414
}
1515

1616
static void FullChainstateExample()
@@ -21,18 +21,18 @@ static void FullChainstateExample()
2121
var builder = KernelLibrary.Create()
2222
.ForMainnet()
2323
.WithWorkerThreads(2)
24-
.WithDirectories("/tmp/regtest-data2", "/tmp/regtest-data/blocks2");
25-
24+
.WithDirectories("/tmp/regtest-data2", "/tmp/regtest-data/blocks2");
25+
2626
Console.WriteLine(" Configuring logging...");
2727
builder = builder.WithLogging((category, message, level) =>
2828
{
2929
if (level <= (int)BitcoinKernel.Interop.Enums.LogLevel.INFO) // Only INFO and above
3030
Console.WriteLine($" [{category}] {message}");
31-
});
32-
31+
});
32+
3333
Console.WriteLine(" Building kernel...");
34-
using var kernel = builder.Build();
35-
34+
using var kernel = builder.Build();
35+
3636
Console.WriteLine(" Kernel built successfully!");
3737
Console.WriteLine(" ✓ Chainstate initialized automatically");
3838

@@ -44,13 +44,13 @@ static void FullChainstateExample()
4444

4545
// Show new query methods
4646
Console.WriteLine($" Chain height: {kernel.GetChainHeight()}");
47-
Console.WriteLine($" Genesis hash: {Convert.ToHexString(kernel.GetGenesisBlockHash())}");
48-
47+
Console.WriteLine($" Genesis hash: {Convert.ToHexString(kernel.GetGenesisBlockHash())}");
48+
4949
if (kernel.GetChainHeight() > 0)
5050
{
5151
var tipHash = kernel.GetChainTipHash();
52-
Console.WriteLine($" Tip hash: {Convert.ToHexString(tipHash)}");
53-
52+
Console.WriteLine($" Tip hash: {Convert.ToHexString(tipHash)}");
53+
5454
var blockInfo = kernel.GetBlockInfo(0);
5555
if (blockInfo != null)
5656
{
@@ -63,12 +63,12 @@ static void FullChainstateExample()
6363
catch (Exception ex)
6464
{
6565
Console.WriteLine($" ✗ Error: {ex.Message}");
66-
}
67-
68-
66+
}
67+
68+
6969
Console.WriteLine("\nPress any key to exit...");
70-
Console.ReadKey();
71-
70+
Console.ReadKey();
71+
7272
kernel.Dispose();
7373
Console.WriteLine(" Kernel disposed.");
7474
}

examples/BlockProcessing/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ static void Main(string[] args)
6262
// Step 6: Get active chain information
6363
var activeChain = kernel.Chainstate.GetActiveChain();
6464
Console.WriteLine($" - Active chain height: {activeChain.Height}");
65-
65+
6666
var tip = activeChain.GetTip();
6767
Console.WriteLine($" - Active chain tip: {BitConverter.ToString(tip.GetBlockHash()).Replace("-", "")}");
6868
}

src/BitcoinKernel.Core/Abstractions/Block.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ internal Block(IntPtr handle)
2222
/// </summary>
2323
public static Block FromBytes(byte[] rawBlockData)
2424
{
25-
ArgumentNullException.ThrowIfNull(rawBlockData,nameof(rawBlockData));
25+
ArgumentNullException.ThrowIfNull(rawBlockData, nameof(rawBlockData));
2626
if (rawBlockData.Length == 0) throw new ArgumentException("Block data cannot be empty", nameof(rawBlockData));
2727

2828
IntPtr blockPtr = NativeMethods.BlockCreate(rawBlockData, (UIntPtr)rawBlockData.Length);
@@ -101,7 +101,7 @@ public byte[] ToBytes()
101101
public Transaction? GetTransaction(int index)
102102
{
103103
ThrowIfDisposed();
104-
104+
105105
if (index < 0 || index >= TransactionCount)
106106
return null;
107107

@@ -119,7 +119,7 @@ public byte[] ToBytes()
119119
public IEnumerable<Transaction> GetTransactions()
120120
{
121121
ThrowIfDisposed();
122-
122+
123123
int count = TransactionCount;
124124
for (int i = 0; i < count; i++)
125125
{

src/BitcoinKernel.Core/Abstractions/BlockSpentOutputs.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,15 @@ public int Count
4343
public TransactionSpentOutputs GetTransactionSpentOutputs(int transactionIndex)
4444
{
4545
ThrowIfDisposed();
46-
46+
4747
if (transactionIndex < 0 || transactionIndex >= Count)
4848
{
4949
throw new ArgumentOutOfRangeException(nameof(transactionIndex));
5050
}
5151

5252
var txSpentOutputsPtr = NativeMethods.BlockSpentOutputsGetTransactionSpentOutputsAt(
5353
_handle, (nuint)transactionIndex);
54-
54+
5555
if (txSpentOutputsPtr == IntPtr.Zero)
5656
{
5757
throw new InvalidOperationException($"Failed to get transaction spent outputs at index {transactionIndex}");
@@ -68,7 +68,7 @@ public TransactionSpentOutputs GetTransactionSpentOutputs(int transactionIndex)
6868
public IEnumerable<TransactionSpentOutputs> EnumerateTransactionSpentOutputs()
6969
{
7070
ThrowIfDisposed();
71-
71+
7272
int count = Count;
7373
for (int i = 0; i < count; i++)
7474
{

src/BitcoinKernel.Core/Abstractions/Chain.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public BlockIndex GetTip()
3535
//get chain by height
3636
IntPtr tipPtr = NativeMethods.ChainGetByHeight(_handle, Height);
3737
if (tipPtr == IntPtr.Zero)
38-
throw new KernelException("Failed to get chain tip");
38+
throw new KernelException("Failed to get chain tip");
3939

4040

4141
return new BlockIndex(tipPtr, ownsHandle: false);

src/BitcoinKernel.Core/Abstractions/TransactionSpentOutputs.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public Coin GetCoin(int index)
5858
public IEnumerable<Coin> EnumerateCoins()
5959
{
6060
ThrowIfDisposed();
61-
61+
6262
int count = Count;
6363
for (int i = 0; i < count; i++)
6464
{

src/BitcoinKernel.Core/BlockProcessing/BlockValidationResult.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,5 @@ public BlockValidationResult(bool isValid, ValidationMode mode, int? errorCode =
3636
Mode = mode;
3737
ErrorCode = errorCode;
3838
ErrorMessage = errorMessage;
39-
}
39+
}
4040
}

src/BitcoinKernel.Core/Chain/ChainParameters.cs

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -3,46 +3,46 @@
33

44
namespace BitcoinKernel.Core.Chain;
55

6-
public sealed class ChainParameters : IDisposable
6+
public sealed class ChainParameters : IDisposable
7+
{
8+
private IntPtr _handle;
9+
private bool _disposed;
10+
11+
public ChainParameters(ChainType chainType)
712
{
8-
private IntPtr _handle;
9-
private bool _disposed;
13+
_handle = NativeMethods.ChainParametersCreate(chainType);
1014

11-
public ChainParameters(ChainType chainType)
12-
{
13-
_handle = NativeMethods.ChainParametersCreate(chainType);
14-
15-
if (_handle == IntPtr.Zero)
16-
throw new InvalidOperationException($"Failed to create chain parameters for chain type: {chainType}. The native library may not be loaded correctly.");
17-
}
15+
if (_handle == IntPtr.Zero)
16+
throw new InvalidOperationException($"Failed to create chain parameters for chain type: {chainType}. The native library may not be loaded correctly.");
17+
}
1818

19-
internal IntPtr Handle
19+
internal IntPtr Handle
20+
{
21+
get
2022
{
21-
get
22-
{
23-
ThrowIfDisposed();
24-
return _handle;
25-
}
23+
ThrowIfDisposed();
24+
return _handle;
2625
}
26+
}
2727

28-
private void ThrowIfDisposed()
29-
{
30-
if (_disposed)
31-
throw new ObjectDisposedException(nameof(ChainParameters));
32-
}
28+
private void ThrowIfDisposed()
29+
{
30+
if (_disposed)
31+
throw new ObjectDisposedException(nameof(ChainParameters));
32+
}
3333

34-
public void Dispose()
34+
public void Dispose()
35+
{
36+
if (!_disposed)
3537
{
36-
if (!_disposed)
38+
if (_handle != IntPtr.Zero)
3739
{
38-
if (_handle != IntPtr.Zero)
39-
{
40-
NativeMethods.ChainParametersDestroy(_handle);
41-
_handle = IntPtr.Zero;
42-
}
43-
_disposed = true;
40+
NativeMethods.ChainParametersDestroy(_handle);
41+
_handle = IntPtr.Zero;
4442
}
43+
_disposed = true;
4544
}
45+
}
4646

47-
~ChainParameters() => Dispose();
48-
}
47+
~ChainParameters() => Dispose();
48+
}

src/BitcoinKernel.Core/Chain/ChainStateManager.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public bool ImportBlocks(string[] blockFilePaths)
105105
{
106106
if (string.IsNullOrEmpty(blockFilePaths[i]))
107107
throw new ArgumentException($"Block file path at index {i} cannot be null or empty", nameof(blockFilePaths));
108-
108+
109109
stringLengths[i] = (nuint)System.Text.Encoding.UTF8.GetByteCount(blockFilePaths[i]);
110110
}
111111

@@ -160,7 +160,7 @@ private void ThrowIfDisposed()
160160
throw new ObjectDisposedException(nameof(ChainstateManager));
161161
}
162162

163-
public void Dispose()
163+
public void Dispose()
164164
{
165165
if (!_disposed)
166166
{

0 commit comments

Comments
 (0)