Setup call to debug blockexchange endpoint.

This commit is contained in:
benbierens 2023-10-09 12:33:35 +02:00
parent b0610393af
commit f08986f6c0
No known key found for this signature in database
GPG Key ID: FE44815D96D0A1AA
5 changed files with 59 additions and 1 deletions

View File

@ -44,6 +44,11 @@ namespace CodexPlugin
return result; return result;
} }
public CodexDebugBlockExchangeResponse GetDebugBlockExchange()
{
return Http().HttpGetJson<CodexDebugBlockExchangeResponse>("debug/blockexchange");
}
public CodexDebugThresholdBreaches GetDebugThresholdBreaches() public CodexDebugThresholdBreaches GetDebugThresholdBreaches()
{ {
return Http().HttpGetJson<CodexDebugThresholdBreaches>("debug/loop"); return Http().HttpGetJson<CodexDebugThresholdBreaches>("debug/loop");

View File

@ -122,4 +122,46 @@ namespace CodexPlugin
public string state { get; set; } = string.Empty; public string state { get; set; } = string.Empty;
public string error { get; set; } = string.Empty; public string error { get; set; } = string.Empty;
} }
public class CodexDebugBlockExchangeResponse
{
public CodexDebugBlockExchangeResponsePeer[] peers { get; set; } = Array.Empty<CodexDebugBlockExchangeResponsePeer>();
public int taskQueue { get; set; }
public int pendingBlocks { get; set; }
public override string ToString()
{
if (peers.Length == 0 && taskQueue == 0 && pendingBlocks == 0) return "all-empty";
return $"taskqueue: {taskQueue} pendingblocks: {pendingBlocks} peers: {string.Join(",", peers.Select(p => p.ToString()))}";
}
}
public class CodexDebugBlockExchangeResponsePeer
{
public CodexDebugBlockExchangeResponsePeerHasBlock[] hasBlocks { get; set; } = Array.Empty<CodexDebugBlockExchangeResponsePeerHasBlock>();
public CodexDebugBlockExchangeResponsePeerWant[] wants { get; set; } = Array.Empty<CodexDebugBlockExchangeResponsePeerWant>();
public int exchanged { get; set; }
public override string ToString()
{
return $"(blocks:{hasBlocks.Length} wants:{wants.Length})";
}
}
public class CodexDebugBlockExchangeResponsePeerHasBlock
{
public string cid { get; set; } = string.Empty;
public bool have { get; set; }
public string price { get; set; } = string.Empty;
}
public class CodexDebugBlockExchangeResponsePeerWant
{
public string block { get; set; } = string.Empty;
public int priority { get; set; }
public bool cancel { get; set; }
public string wantType { get; set; } = string.Empty;
public bool sendDontHave { get; set; }
}
} }

View File

@ -7,7 +7,8 @@ namespace CodexPlugin
{ {
private readonly MarketplaceStarter marketplaceStarter = new MarketplaceStarter(); private readonly MarketplaceStarter marketplaceStarter = new MarketplaceStarter();
private const string DefaultDockerImage = "codexstorage/nim-codex:latest-dist-tests"; //private const string DefaultDockerImage = "codexstorage/nim-codex:latest-dist-tests";
private const string DefaultDockerImage = "codexstorage/nim-codex:sha-1875e6b-dist-tests";
public const string MetricsPortTag = "metrics_port"; public const string MetricsPortTag = "metrics_port";
public const string DiscoveryPortTag = "discovery-port"; public const string DiscoveryPortTag = "discovery-port";

View File

@ -13,6 +13,7 @@ namespace CodexPlugin
string GetName(); string GetName();
CodexDebugResponse GetDebugInfo(); CodexDebugResponse GetDebugInfo();
CodexDebugPeerResponse GetDebugPeer(string peerId); CodexDebugPeerResponse GetDebugPeer(string peerId);
CodexDebugBlockExchangeResponse GetDebugBlockExchange();
ContentId UploadFile(TrackedFile file); ContentId UploadFile(TrackedFile file);
TrackedFile? DownloadContent(ContentId contentId, string fileLabel = ""); TrackedFile? DownloadContent(ContentId contentId, string fileLabel = "");
void ConnectToPeer(ICodexNode node); void ConnectToPeer(ICodexNode node);
@ -81,6 +82,11 @@ namespace CodexPlugin
return CodexAccess.GetDebugPeer(peerId); return CodexAccess.GetDebugPeer(peerId);
} }
public CodexDebugBlockExchangeResponse GetDebugBlockExchange()
{
return CodexAccess.GetDebugBlockExchange();
}
public ContentId UploadFile(TrackedFile file) public ContentId UploadFile(TrackedFile file)
{ {
using var fileStream = File.OpenRead(file.Filename); using var fileStream = File.OpenRead(file.Filename);

View File

@ -46,6 +46,10 @@ namespace CodexPlugin
"noise", "noise",
"bufferstream", "bufferstream",
"mplexcoder", "mplexcoder",
"secure",
"chronosstream",
"connection",
"connmanager",
"websock", "websock",
"ws-session" "ws-session"
}; };