Skip to content

Changed project framework versions and cleaned code. #4

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

Merged
Merged
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
8 changes: 2 additions & 6 deletions IpfsHttpClient.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26730.16
# Visual Studio Version 17
VisualStudioVersion = 17.1.32421.90
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{6B9AA9C7-5E90-4D10-9DDE-A2AA5FE3ECA6}"
ProjectSection(SolutionItems) = preProject
Expand All @@ -11,8 +11,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
README.md = README.md
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Documentation", "doc\Documentation.csproj", "{F3A32EA9-0B2F-46A3-B47A-33B4C04BD423}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IpfsHttpClient", "src\IpfsHttpClient.csproj", "{F3C81C57-C283-4E07-B765-DEABCFB22136}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IpfsHttpClientTests", "test\IpfsHttpClientTests.csproj", "{B459FBC7-4A28-4170-AD83-7348A403407F}"
Expand All @@ -23,8 +21,6 @@ Global
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{F3A32EA9-0B2F-46A3-B47A-33B4C04BD423}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F3A32EA9-0B2F-46A3-B47A-33B4C04BD423}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F3C81C57-C283-4E07-B765-DEABCFB22136}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F3C81C57-C283-4E07-B765-DEABCFB22136}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F3C81C57-C283-4E07-B765-DEABCFB22136}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down
9 changes: 2 additions & 7 deletions src/Block.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.IO;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;

namespace Ipfs.Http
{
Expand Down Expand Up @@ -48,7 +43,7 @@ public long Size
size = value;
}
}

}

}
10 changes: 2 additions & 8 deletions src/CoreApi/BitswapApi.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
using Newtonsoft.Json;
using Ipfs.CoreApi;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Ipfs.CoreApi;
using System.IO;

namespace Ipfs.Http
{

class BitswapApi : IBitswapApi
{
IpfsClient ipfs;
Expand All @@ -33,7 +27,7 @@ internal BitswapApi(IpfsClient ipfs)
var keys = (JArray)(JObject.Parse(json)["Keys"]);
// https://github.com/ipfs/go-ipfs/issues/5077
return keys
.Select(k =>
.Select(k =>
{
if (k.Type == JTokenType.String)
return Cid.Decode(k.ToString());
Expand Down
11 changes: 3 additions & 8 deletions src/CoreApi/BlockApi.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
using Newtonsoft.Json;
using Ipfs.CoreApi;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Net.Http;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Ipfs.CoreApi;
using System.IO;

namespace Ipfs.Http
{

class BlockApi : IBlockApi
{
IpfsClient ipfs;
Expand Down Expand Up @@ -41,7 +36,7 @@ public async Task<Cid> PutAsync(
CancellationToken cancel = default(CancellationToken))
{
var options = new List<string>();
if (multiHash != MultiHash.DefaultAlgorithmName ||
if (multiHash != MultiHash.DefaultAlgorithmName ||
contentType != Cid.DefaultContentType ||
encoding != MultiBase.DefaultAlgorithmName)
{
Expand Down
10 changes: 1 addition & 9 deletions src/CoreApi/BlockRepositoryApi.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,10 @@
using Newtonsoft.Json;
using Ipfs.CoreApi;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Ipfs.CoreApi;
using System.IO;

namespace Ipfs.Http
{

class BlockRepositoryApi : IBlockRepositoryApi
{
IpfsClient ipfs;
Expand Down
8 changes: 1 addition & 7 deletions src/CoreApi/BootstrapApi.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
using Newtonsoft.Json;
using Ipfs.CoreApi;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Ipfs.CoreApi;
using System.IO;

namespace Ipfs.Http
{

class BootstrapApi : IBootstrapApi
{
IpfsClient ipfs;
Expand Down
8 changes: 2 additions & 6 deletions src/CoreApi/ConfigApi.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
using Newtonsoft.Json;
using Ipfs.CoreApi;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Ipfs.CoreApi;

namespace Ipfs.Http
{

class ConfigApi : IConfigApi
{
IpfsClient ipfs;
Expand Down
20 changes: 7 additions & 13 deletions src/CoreApi/DagApi.cs
Original file line number Diff line number Diff line change
@@ -1,29 +1,23 @@
using Common.Logging;
using Ipfs.CoreApi;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Ipfs.CoreApi;
using System.Globalization;

namespace Ipfs.Http
{

class DagApi : IDagApi
{
IpfsClient ipfs;
private IpfsClient ipfs;

internal DagApi(IpfsClient ipfs)
{
this.ipfs = ipfs;
}


public async Task<Cid> PutAsync(
JObject data,
string contentType = "dag-cbor",
Expand All @@ -49,11 +43,11 @@ public async Task<Cid> PutAsync(
}

public async Task<Cid> PutAsync(
object data,
object data,
string contentType = "dag-cbor",
string multiHash = MultiHash.DefaultAlgorithmName,
string encoding = MultiBase.DefaultAlgorithmName,
bool pin = true,
bool pin = true,
CancellationToken cancel = default(CancellationToken))
{
using (var ms = new MemoryStream(
Expand Down Expand Up @@ -83,7 +77,7 @@ public async Task<Cid> PutAsync(
}

public async Task<JObject> GetAsync(
Cid id,
Cid id,
CancellationToken cancel = default(CancellationToken))
{
var json = await ipfs.DoCommandAsync("dag/get", cancel, id);
Expand All @@ -92,7 +86,7 @@ public async Task<JObject> GetAsync(


public async Task<JToken> GetAsync(
string path,
string path,
CancellationToken cancel = default(CancellationToken))
{
var json = await ipfs.DoCommandAsync("dag/get", cancel, path);
Expand Down
17 changes: 6 additions & 11 deletions src/CoreApi/DhtApi.cs
Original file line number Diff line number Diff line change
@@ -1,23 +1,18 @@
using Common.Logging;
using Newtonsoft.Json;
using Ipfs.CoreApi;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Ipfs.CoreApi;

namespace Ipfs.Http
{

class DhtApi : IDhtApi
{
static ILog log = LogManager.GetLogger<DhtApi>();

IpfsClient ipfs;
private static ILog log = LogManager.GetLogger<DhtApi>();
private IpfsClient ipfs;

internal DhtApi(IpfsClient ipfs)
{
Expand Down Expand Up @@ -57,7 +52,7 @@ internal DhtApi(IpfsClient ipfs)
}

IEnumerable<Peer> ProviderFromStream(Stream stream, int limit = int.MaxValue)
{
{
using (var sr = new StreamReader(stream))
{
var n = 0;
Expand Down Expand Up @@ -91,8 +86,8 @@ IEnumerable<Peer> ProviderFromStream(Stream stream, int limit = int.MaxValue)
}
}
}
}
}
}
}
}

}
12 changes: 2 additions & 10 deletions src/CoreApi/DnsApi.cs
Original file line number Diff line number Diff line change
@@ -1,21 +1,13 @@
using Newtonsoft.Json;
using Ipfs.CoreApi;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Ipfs.CoreApi;
using System.IO;

namespace Ipfs.Http
{

class DnsApi : IDnsApi
{
IpfsClient ipfs;
private IpfsClient ipfs;

internal DnsApi(IpfsClient ipfs)
{
Expand Down
12 changes: 5 additions & 7 deletions src/CoreApi/FileSystemApi.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Common.Logging;
using Ipfs.CoreApi;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
Expand All @@ -8,17 +9,14 @@
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Ipfs.CoreApi;

namespace Ipfs.Http
{

class FileSystemApi : IFileSystemApi
{
static ILog log = LogManager.GetLogger<FileSystemApi>();

IpfsClient ipfs;
Lazy<DagNode> emptyFolder;
private static ILog log = LogManager.GetLogger<FileSystemApi>();
private IpfsClient ipfs;
private Lazy<DagNode> emptyFolder;

internal FileSystemApi(IpfsClient ipfs)
{
Expand Down Expand Up @@ -209,7 +207,7 @@ internal FileSystemApi(IpfsClient ipfs)

if (length == 0)
length = int.MaxValue; // go-ipfs only accepts int lengths
return ipfs.DownloadAsync("cat", cancel, path,
return ipfs.DownloadAsync("cat", cancel, path,
$"offset={offset}",
$"length={length}");
}
Expand Down
12 changes: 4 additions & 8 deletions src/CoreApi/GenericApi.cs
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
using Newtonsoft.Json;
using Ipfs.CoreApi;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.IO;
using System.Net;
using System.Threading.Tasks;
using System.Threading;
using Ipfs.CoreApi;
using Newtonsoft.Json.Linq;
using System.Threading.Tasks;

namespace Ipfs.Http
{
public partial class IpfsClient : IGenericApi
{
const double TicksPerNanosecond = (double)TimeSpan.TicksPerMillisecond * 0.000001;
private const double TicksPerNanosecond = (double)TimeSpan.TicksPerMillisecond * 0.000001;

/// <inheritdoc />
public Task<Peer> IdAsync(MultiHash peer = null, CancellationToken cancel = default(CancellationToken))
Expand Down
14 changes: 5 additions & 9 deletions src/CoreApi/KeyApi.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
using Common.Logging;
using Newtonsoft.Json;
using Ipfs.CoreApi;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Ipfs.CoreApi;

namespace Ipfs.Http
{
class KeyApi : IKeyApi
class KeyApi : IKeyApi
{
/// <summary>
/// Information about a local key.
Expand Down Expand Up @@ -41,9 +37,9 @@ internal KeyApi(IpfsClient ipfs)

public async Task<IKey> CreateAsync(string name, string keyType, int size, CancellationToken cancel = default(CancellationToken))
{
return await ipfs.DoCommandAsync<KeyInfo>("key/gen", cancel,
name,
$"type={keyType}",
return await ipfs.DoCommandAsync<KeyInfo>("key/gen", cancel,
name,
$"type={keyType}",
$"size={size}");
}

Expand Down
Loading