Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix moved default storage dir outside the nethermind repo folder but authentication error in JSON-RPC request #7815

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using System;
using System.IO;

public class NethermindDataDirectoryProvider
{
private readonly string _defaultBasePath;

public NethermindDataDirectoryProvider()
{
// Use XDG_DATA_HOME if set, otherwise fallback to ~/.local/share
string xdgDataHome = Environment.GetEnvironmentVariable("XDG_DATA_HOME") ??
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".local", "share");

// Set the default base path for Nethermind data
_defaultBasePath = Path.Combine(xdgDataHome, "nethermind");
}

public string GetDefaultBasePath() => _defaultBasePath;

public string GetDbPath(string dbName)
{
return Path.Combine(_defaultBasePath, "db", dbName);
}

public string GetLogsPath()
{
return Path.Combine(_defaultBasePath, "logs");
}

// Add other path-related methods as needed
}
13 changes: 13 additions & 0 deletions src/Nethermind/Nethermind.Runner/Startup.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// ... in startup configuration
services.AddSingleton<NethermindDataDirectoryProvider>();

// During initialization
var pathProvider = serviceProvider.GetRequiredService<NethermindDataDirectoryProvider>();

// Use the default base path for database and logs
string dbPath = pathProvider.GetDbPath(DbNames.Storage);
string logsPath = pathProvider.GetLogsPath();


Directory.CreateDirectory(dbPath);
Directory.CreateDirectory(logsPath);