Skip to content

Commit

Permalink
Merge pull request #53 from richardschneider/core-api-52
Browse files Browse the repository at this point in the history
feat(BitswapApi): add LedgerAsync
  • Loading branch information
richardschneider authored Jun 16, 2019
2 parents 912c604 + 6d74937 commit e5e44d3
Show file tree
Hide file tree
Showing 10 changed files with 210 additions and 16 deletions.
1 change: 0 additions & 1 deletion .nuget/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@
<packages>
<package id="coveralls.net" version="0.6.0" />
<package id="OpenCover" version="4.6.519" />
<package id="msdn.4.5.2" version="0.1.0-alpha-1611021200" />
</packages>
7 changes: 4 additions & 3 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ environment:
install:
- dotnet --version
- choco install gitversion.portable -y
- nuget update -self
- choco install docfx -y
- npm install gh-pages -g

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

after_build:
- cmd: appveyor PushArtifact "src\bin\%CONFIGURATION%\Ipfs.Http.Client.%GitVersion_MajorMinorPatch%.nupkg"

# Build documentation in doc\_site
- docfx doc\docfx.json --logLevel Warning
# v2.43 is requiring VS 2019!!!
- cmd: choco install docfx -y --version 2.42 --force
- docfx doc\docfx.json --logLevel Warning --warningsAsErrors
- 7z a -tzip docs.zip doc\_site
- appveyor PushArtifact docs.zip
- if defined git_token gh-pages -d doc\_site -m "new docs %GitVersion_FullSemVer%"
Expand Down
3 changes: 3 additions & 0 deletions doc/api/.manifest
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"Ipfs.Http.IpfsClient.ApiUri": "Ipfs.Http.IpfsClient.yml",
"Ipfs.Http.IpfsClient.Bitswap": "Ipfs.Http.IpfsClient.yml",
"Ipfs.Http.IpfsClient.Block": "Ipfs.Http.IpfsClient.yml",
"Ipfs.Http.IpfsClient.BlockRepository": "Ipfs.Http.IpfsClient.yml",
"Ipfs.Http.IpfsClient.Bootstrap": "Ipfs.Http.IpfsClient.yml",
"Ipfs.Http.IpfsClient.Config": "Ipfs.Http.IpfsClient.yml",
"Ipfs.Http.IpfsClient.Dag": "Ipfs.Http.IpfsClient.yml",
Expand All @@ -47,8 +48,10 @@
"Ipfs.Http.IpfsClient.PubSub": "Ipfs.Http.IpfsClient.yml",
"Ipfs.Http.IpfsClient.ResolveAsync(System.String,System.Boolean,System.Threading.CancellationToken)": "Ipfs.Http.IpfsClient.yml",
"Ipfs.Http.IpfsClient.ShutdownAsync": "Ipfs.Http.IpfsClient.yml",
"Ipfs.Http.IpfsClient.Stats": "Ipfs.Http.IpfsClient.yml",
"Ipfs.Http.IpfsClient.Swarm": "Ipfs.Http.IpfsClient.yml",
"Ipfs.Http.IpfsClient.TrustedPeers": "Ipfs.Http.IpfsClient.yml",
"Ipfs.Http.IpfsClient.Upload2Async(System.String,System.Threading.CancellationToken,System.IO.Stream,System.String,System.String[])": "Ipfs.Http.IpfsClient.yml",
"Ipfs.Http.IpfsClient.UploadAsync(System.String,System.Threading.CancellationToken,System.Byte[],System.String[])": "Ipfs.Http.IpfsClient.yml",
"Ipfs.Http.IpfsClient.UploadAsync(System.String,System.Threading.CancellationToken,System.IO.Stream,System.String,System.String[])": "Ipfs.Http.IpfsClient.yml",
"Ipfs.Http.IpfsClient.UserAgent": "Ipfs.Http.IpfsClient.yml",
Expand Down
14 changes: 8 additions & 6 deletions doc/docfx.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,18 @@
]
}
],
"xrefService": [
"https://xref.docs.microsoft.com/query?uid={uid}"
],
"xref": [
"../packages/msdn.4.5.2.0.1.0-alpha-1611021200/content/msdn.4.5.2.zip",
"https://richardschneider.github.io/net-ipfs-core/xrefmap.yml"
"https://richardschneider.github.io/net-ipfs-core/xrefmap.yml"
],
"globalMetadata" : {
"globalMetadata": {
"_appTitle": "IPFS HTP Client documentation",
"_appFooter": "Generated by DocFX",
"_appFaviconPath": "images/ipfs-favicon.ico",
"_appLogoPath": "images/ipfs-logo.svg"
},
"_appFaviconPath": "images/ipfs-favicon.ico",
"_appLogoPath": "images/ipfs-cs-logo-48x48.png"
},
"dest": "_site",
"globalMetadataFiles": [],
"fileMetadataFiles": [],
Expand Down
Binary file added doc/images/ipfs-cs-logo-48x48.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/images/ipfs-cs-logo-64x64.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
167 changes: 167 additions & 0 deletions doc/images/ipfs-cs-logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions src/CoreApi/BitswapApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,19 @@ internal BitswapApi(IpfsClient ipfs)
{
await ipfs.DoCommandAsync("bitswap/unwant", cancel, id);
}

public async Task<BitswapLedger> LedgerAsync(Peer peer, CancellationToken cancel = default(CancellationToken))
{
var json = await ipfs.DoCommandAsync("bitswap/ledger", cancel, peer.Id.ToString());
var o = JObject.Parse(json);
return new BitswapLedger
{
Peer = (string)o["Peer"],
DataReceived = (ulong)o["Sent"],
DataSent = (ulong)o["Recv"],
BlocksExchanged = (ulong)o["Exchanged"]
};
}
}

}
12 changes: 6 additions & 6 deletions src/IpfsHttpClient.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
<RootNamespace>Ipfs.Http</RootNamespace>
<DocumentationFile>bin\$(Configuration)\$(TargetFramework)\$(AssemblyName).xml</DocumentationFile>
<DebugType>full</DebugType>

<TreatWarningsAsErrors>true</TreatWarningsAsErrors>

<!-- developer build is always 0.42 -->
<AssemblyVersion>0.42</AssemblyVersion>
<Version>0.42</Version>
Expand All @@ -18,17 +19,16 @@
<Description> Provides .Net client access to the InterPlanetary File System.</Description>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<PackageReleaseNotes>https://github.com/richardschneider/net-ipfs-http-client/releases</PackageReleaseNotes>
<Copyright>© 2015-2018 Richard Schneider</Copyright>
<Copyright>© 2015-2019 Richard Schneider</Copyright>
<PackageTags>ipfs peer-to-peer distributed file-system</PackageTags>
<IncludeSymbols>True</IncludeSymbols>
<PackageLicenseUrl>https://github.com/richardschneider/net-ipfs-http-client/blob/master/LICENSE</PackageLicenseUrl>
<PackageProjectUrl>https://github.com/richardschneider/net-ipfs-http-client</PackageProjectUrl>
<PackageIconUrl>https://github.com/ipfs/logo/blob/master/platform-icons/osx-menu-bar.png</PackageIconUrl>
<PackageIconUrl>https://raw.githubusercontent.com/richardschneider/net-ipfs-core/master/doc/images/ipfs-cs-logo-64x64.png</PackageIconUrl>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Ipfs.Core" Version="0.51.1" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.1" />
<PackageReference Include="Ipfs.Core" Version="0.52.1" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
<PackageReference Include="System.Net.Http" Version="4.3.3" Condition="'$(TargetFramework)' == 'netstandard14'" />
<PackageReference Include="System.Net.Http" Version="4.3.3" Condition="'$(TargetFramework)' == 'net45'" />
</ItemGroup>
Expand Down
9 changes: 9 additions & 0 deletions test/CoreApi/BitswapApiTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,14 @@ public async Task Unwant()
break;
}
}

[TestMethod]
public async Task Ledger()
{
var peer = new Peer { Id = "QmSoLMeWqB7YGVLJN3pNLQpmmEk35v6wYtsMGLzSr5QBU3" };
var ledger = await ipfs.Bitswap.LedgerAsync(peer);
Assert.IsNotNull(ledger);
Assert.AreEqual(peer.Id, ledger.Peer.Id);
}
}
}

0 comments on commit e5e44d3

Please sign in to comment.