diff --git a/ProjectPlugins/CodexPlugin/CodexAccess.cs b/ProjectPlugins/CodexPlugin/CodexAccess.cs index 8e0ac40..f9d7772 100644 --- a/ProjectPlugins/CodexPlugin/CodexAccess.cs +++ b/ProjectPlugins/CodexPlugin/CodexAccess.cs @@ -44,6 +44,11 @@ namespace CodexPlugin return result; } + public CodexDebugBlockExchangeResponse GetDebugBlockExchange() + { + return Http().HttpGetJson("debug/blockexchange"); + } + public CodexDebugThresholdBreaches GetDebugThresholdBreaches() { return Http().HttpGetJson("debug/loop"); diff --git a/ProjectPlugins/CodexPlugin/CodexApiTypes.cs b/ProjectPlugins/CodexPlugin/CodexApiTypes.cs index 127f437..3fbc1a2 100644 --- a/ProjectPlugins/CodexPlugin/CodexApiTypes.cs +++ b/ProjectPlugins/CodexPlugin/CodexApiTypes.cs @@ -122,4 +122,46 @@ namespace CodexPlugin public string state { get; set; } = string.Empty; public string error { get; set; } = string.Empty; } + + public class CodexDebugBlockExchangeResponse + { + public CodexDebugBlockExchangeResponsePeer[] peers { get; set; } = Array.Empty(); + 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(); + public CodexDebugBlockExchangeResponsePeerWant[] wants { get; set; } = Array.Empty(); + 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; } + } } diff --git a/ProjectPlugins/CodexPlugin/CodexContainerRecipe.cs b/ProjectPlugins/CodexPlugin/CodexContainerRecipe.cs index ebef993..cf72fb6 100644 --- a/ProjectPlugins/CodexPlugin/CodexContainerRecipe.cs +++ b/ProjectPlugins/CodexPlugin/CodexContainerRecipe.cs @@ -7,7 +7,8 @@ namespace CodexPlugin { 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 DiscoveryPortTag = "discovery-port"; diff --git a/ProjectPlugins/CodexPlugin/CodexNode.cs b/ProjectPlugins/CodexPlugin/CodexNode.cs index f4ff802..4a5940d 100644 --- a/ProjectPlugins/CodexPlugin/CodexNode.cs +++ b/ProjectPlugins/CodexPlugin/CodexNode.cs @@ -13,6 +13,7 @@ namespace CodexPlugin string GetName(); CodexDebugResponse GetDebugInfo(); CodexDebugPeerResponse GetDebugPeer(string peerId); + CodexDebugBlockExchangeResponse GetDebugBlockExchange(); ContentId UploadFile(TrackedFile file); TrackedFile? DownloadContent(ContentId contentId, string fileLabel = ""); void ConnectToPeer(ICodexNode node); @@ -81,6 +82,11 @@ namespace CodexPlugin return CodexAccess.GetDebugPeer(peerId); } + public CodexDebugBlockExchangeResponse GetDebugBlockExchange() + { + return CodexAccess.GetDebugBlockExchange(); + } + public ContentId UploadFile(TrackedFile file) { using var fileStream = File.OpenRead(file.Filename); diff --git a/ProjectPlugins/CodexPlugin/CodexStartupConfig.cs b/ProjectPlugins/CodexPlugin/CodexStartupConfig.cs index 4b651df..971dd2c 100644 --- a/ProjectPlugins/CodexPlugin/CodexStartupConfig.cs +++ b/ProjectPlugins/CodexPlugin/CodexStartupConfig.cs @@ -46,6 +46,10 @@ namespace CodexPlugin "noise", "bufferstream", "mplexcoder", + "secure", + "chronosstream", + "connection", + "connmanager", "websock", "ws-session" };