Skip to content

Commit e5e44d3

Browse files
Merge pull request #53 from richardschneider/core-api-52
feat(BitswapApi): add LedgerAsync
2 parents 912c604 + 6d74937 commit e5e44d3

File tree

10 files changed

+210
-16
lines changed

10 files changed

+210
-16
lines changed

.nuget/packages.config

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,4 @@
22
<packages>
33
<package id="coveralls.net" version="0.6.0" />
44
<package id="OpenCover" version="4.6.519" />
5-
<package id="msdn.4.5.2" version="0.1.0-alpha-1611021200" />
65
</packages>

appveyor.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ environment:
3232
install:
3333
- dotnet --version
3434
- choco install gitversion.portable -y
35-
- nuget update -self
36-
- choco install docfx -y
3735
- npm install gh-pages -g
3836

3937
# - nuget install secure-file -ExcludeVersion
@@ -56,8 +54,11 @@ build_script:
5654

5755
after_build:
5856
- cmd: appveyor PushArtifact "src\bin\%CONFIGURATION%\Ipfs.Http.Client.%GitVersion_MajorMinorPatch%.nupkg"
57+
5958
# Build documentation in doc\_site
60-
- docfx doc\docfx.json --logLevel Warning
59+
# v2.43 is requiring VS 2019!!!
60+
- cmd: choco install docfx -y --version 2.42 --force
61+
- docfx doc\docfx.json --logLevel Warning --warningsAsErrors
6162
- 7z a -tzip docs.zip doc\_site
6263
- appveyor PushArtifact docs.zip
6364
- if defined git_token gh-pages -d doc\_site -m "new docs %GitVersion_FullSemVer%"

doc/api/.manifest

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"Ipfs.Http.IpfsClient.ApiUri": "Ipfs.Http.IpfsClient.yml",
2727
"Ipfs.Http.IpfsClient.Bitswap": "Ipfs.Http.IpfsClient.yml",
2828
"Ipfs.Http.IpfsClient.Block": "Ipfs.Http.IpfsClient.yml",
29+
"Ipfs.Http.IpfsClient.BlockRepository": "Ipfs.Http.IpfsClient.yml",
2930
"Ipfs.Http.IpfsClient.Bootstrap": "Ipfs.Http.IpfsClient.yml",
3031
"Ipfs.Http.IpfsClient.Config": "Ipfs.Http.IpfsClient.yml",
3132
"Ipfs.Http.IpfsClient.Dag": "Ipfs.Http.IpfsClient.yml",
@@ -47,8 +48,10 @@
4748
"Ipfs.Http.IpfsClient.PubSub": "Ipfs.Http.IpfsClient.yml",
4849
"Ipfs.Http.IpfsClient.ResolveAsync(System.String,System.Boolean,System.Threading.CancellationToken)": "Ipfs.Http.IpfsClient.yml",
4950
"Ipfs.Http.IpfsClient.ShutdownAsync": "Ipfs.Http.IpfsClient.yml",
51+
"Ipfs.Http.IpfsClient.Stats": "Ipfs.Http.IpfsClient.yml",
5052
"Ipfs.Http.IpfsClient.Swarm": "Ipfs.Http.IpfsClient.yml",
5153
"Ipfs.Http.IpfsClient.TrustedPeers": "Ipfs.Http.IpfsClient.yml",
54+
"Ipfs.Http.IpfsClient.Upload2Async(System.String,System.Threading.CancellationToken,System.IO.Stream,System.String,System.String[])": "Ipfs.Http.IpfsClient.yml",
5255
"Ipfs.Http.IpfsClient.UploadAsync(System.String,System.Threading.CancellationToken,System.Byte[],System.String[])": "Ipfs.Http.IpfsClient.yml",
5356
"Ipfs.Http.IpfsClient.UploadAsync(System.String,System.Threading.CancellationToken,System.IO.Stream,System.String,System.String[])": "Ipfs.Http.IpfsClient.yml",
5457
"Ipfs.Http.IpfsClient.UserAgent": "Ipfs.Http.IpfsClient.yml",

doc/docfx.json

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,16 +64,18 @@
6464
]
6565
}
6666
],
67+
"xrefService": [
68+
"https://xref.docs.microsoft.com/query?uid={uid}"
69+
],
6770
"xref": [
68-
"../packages/msdn.4.5.2.0.1.0-alpha-1611021200/content/msdn.4.5.2.zip",
69-
"https://richardschneider.github.io/net-ipfs-core/xrefmap.yml"
71+
"https://richardschneider.github.io/net-ipfs-core/xrefmap.yml"
7072
],
71-
"globalMetadata" : {
73+
"globalMetadata": {
7274
"_appTitle": "IPFS HTP Client documentation",
7375
"_appFooter": "Generated by DocFX",
74-
"_appFaviconPath": "images/ipfs-favicon.ico",
75-
"_appLogoPath": "images/ipfs-logo.svg"
76-
},
76+
"_appFaviconPath": "images/ipfs-favicon.ico",
77+
"_appLogoPath": "images/ipfs-cs-logo-48x48.png"
78+
},
7779
"dest": "_site",
7880
"globalMetadataFiles": [],
7981
"fileMetadataFiles": [],

doc/images/ipfs-cs-logo-48x48.png

2.23 KB
Loading

doc/images/ipfs-cs-logo-64x64.png

3.44 KB
Loading

doc/images/ipfs-cs-logo.svg

Lines changed: 167 additions & 0 deletions
Loading

src/CoreApi/BitswapApi.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,19 @@ internal BitswapApi(IpfsClient ipfs)
4646
{
4747
await ipfs.DoCommandAsync("bitswap/unwant", cancel, id);
4848
}
49+
50+
public async Task<BitswapLedger> LedgerAsync(Peer peer, CancellationToken cancel = default(CancellationToken))
51+
{
52+
var json = await ipfs.DoCommandAsync("bitswap/ledger", cancel, peer.Id.ToString());
53+
var o = JObject.Parse(json);
54+
return new BitswapLedger
55+
{
56+
Peer = (string)o["Peer"],
57+
DataReceived = (ulong)o["Sent"],
58+
DataSent = (ulong)o["Recv"],
59+
BlocksExchanged = (ulong)o["Exchanged"]
60+
};
61+
}
4962
}
5063

5164
}

src/IpfsHttpClient.csproj

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
<RootNamespace>Ipfs.Http</RootNamespace>
77
<DocumentationFile>bin\$(Configuration)\$(TargetFramework)\$(AssemblyName).xml</DocumentationFile>
88
<DebugType>full</DebugType>
9-
9+
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
10+
1011
<!-- developer build is always 0.42 -->
1112
<AssemblyVersion>0.42</AssemblyVersion>
1213
<Version>0.42</Version>
@@ -18,17 +19,16 @@
1819
<Description> Provides .Net client access to the InterPlanetary File System.</Description>
1920
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
2021
<PackageReleaseNotes>https://github.com/richardschneider/net-ipfs-http-client/releases</PackageReleaseNotes>
21-
<Copyright>© 2015-2018 Richard Schneider</Copyright>
22+
<Copyright>© 2015-2019 Richard Schneider</Copyright>
2223
<PackageTags>ipfs peer-to-peer distributed file-system</PackageTags>
2324
<IncludeSymbols>True</IncludeSymbols>
24-
<PackageLicenseUrl>https://github.com/richardschneider/net-ipfs-http-client/blob/master/LICENSE</PackageLicenseUrl>
2525
<PackageProjectUrl>https://github.com/richardschneider/net-ipfs-http-client</PackageProjectUrl>
26-
<PackageIconUrl>https://github.com/ipfs/logo/blob/master/platform-icons/osx-menu-bar.png</PackageIconUrl>
26+
<PackageIconUrl>https://raw.githubusercontent.com/richardschneider/net-ipfs-core/master/doc/images/ipfs-cs-logo-64x64.png</PackageIconUrl>
2727
</PropertyGroup>
2828

2929
<ItemGroup>
30-
<PackageReference Include="Ipfs.Core" Version="0.51.1" />
31-
<PackageReference Include="Newtonsoft.Json" Version="12.0.1" />
30+
<PackageReference Include="Ipfs.Core" Version="0.52.1" />
31+
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
3232
<PackageReference Include="System.Net.Http" Version="4.3.3" Condition="'$(TargetFramework)' == 'netstandard14'" />
3333
<PackageReference Include="System.Net.Http" Version="4.3.3" Condition="'$(TargetFramework)' == 'net45'" />
3434
</ItemGroup>

test/CoreApi/BitswapApiTest.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,5 +63,14 @@ public async Task Unwant()
6363
break;
6464
}
6565
}
66+
67+
[TestMethod]
68+
public async Task Ledger()
69+
{
70+
var peer = new Peer { Id = "QmSoLMeWqB7YGVLJN3pNLQpmmEk35v6wYtsMGLzSr5QBU3" };
71+
var ledger = await ipfs.Bitswap.LedgerAsync(peer);
72+
Assert.IsNotNull(ledger);
73+
Assert.AreEqual(peer.Id, ledger.Peer.Id);
74+
}
6675
}
6776
}

0 commit comments

Comments
 (0)