+110
-4
lines changedFilter options
+110
-4
lines changed Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
1
+
using System;
2
+
using System.Collections.Generic;
3
+
using System.Text;
4
+
5
+
namespace Ipfs.CoreApi
6
+
{
7
+
/// <summary>
8
+
/// Statistics on the <see cref="IBitswapApi">bitswap</see> blocks exchanged with another <see cref="Peer"/>.
9
+
/// </summary>
10
+
/// <seealso cref="IBitswapApi.LedgerAsync"/>
11
+
public class BitswapLedger
12
+
{
13
+
/// <summary>
14
+
/// The <see cref="Peer"/> that pertains to this ledger.
15
+
/// </summary>
16
+
/// <value>
17
+
/// The peer that is being monitored.
18
+
/// </value>
19
+
public Peer Peer;
20
+
21
+
/// <summary>
22
+
/// The number of blocks sent by the <see cref="Peer"/> to us.
23
+
/// </summary>
24
+
/// <value>
25
+
/// The number of blocks.
26
+
/// </value>
27
+
public ulong BlocksReceived;
28
+
29
+
/// <summary>
30
+
/// The number of blocks sent by us to the <see cref="Peer"/>.
31
+
/// </summary>
32
+
/// <value>
33
+
/// The number of blocks.
34
+
/// </value>
35
+
public ulong BlocksSent;
36
+
37
+
/// <summary>
38
+
/// The number of bytes sent by the <see cref="Peer"/> to us.
39
+
/// </summary>
40
+
/// <value>
41
+
/// The number of bytes.
42
+
/// </value>
43
+
public ulong DataReceived;
44
+
45
+
46
+
/// <summary>
47
+
/// The number of bytes sent by us to the <see cref="Peer"/>
48
+
/// </summary>
49
+
/// <value>
50
+
/// The number of bytes.
51
+
/// </value>
52
+
public ulong DataSent;
53
+
54
+
}
55
+
}
Original file line number Diff line number Diff line change
@@ -11,9 +11,19 @@ namespace Ipfs.CoreApi
11
11
/// send blocks to other peers in the network.
12
12
/// </summary>
13
13
/// <remarks>
14
-
/// Bitswap has two primary jobs (1) Attempt to acquire blocks from the network that
15
-
/// have been requested by the client and (2) Judiciously(though strategically)
16
-
/// send blocks in its possession to other peers who want them.
14
+
/// Bitswap has two primary jobs
15
+
/// <list type="bullet">
16
+
/// <item>
17
+
/// <description>
18
+
/// Attempt to acquire blocks from the network that have been requested by the client
19
+
/// </description>
20
+
/// </item>
21
+
/// <item>
22
+
/// <description>
23
+
/// Judiciously (though strategically) send blocks in its possession to other peers who want them
24
+
/// </description>
25
+
/// </item>
26
+
/// </list>
17
27
/// </remarks>
18
28
/// <seealso href="https://github.com/ipfs/specs/tree/master/bitswap">Bitswap spec</seealso>
19
29
public interface IBitswapApi
@@ -68,6 +78,22 @@ public interface IBitswapApi
68
78
/// Any outstanding <see cref="GetAsync(Cid, CancellationToken)"/> for the
69
79
/// <paramref name="id"/> are cancelled.
70
80
/// </remarks>
71
-
Task UnwantAsync(Cid id, CancellationToken cancel = default(CancellationToken));
81
+
Task UnwantAsync(Cid id, CancellationToken cancel = default(CancellationToken));
82
+
83
+
/// <summary>
84
+
/// Gets information on the blocks exchanged with a specific <see cref="Peer"/>.
85
+
/// </summary>
86
+
/// <param name="peer">
87
+
/// The peer to get information on. If the peer is unknown, then a ledger
88
+
/// with zeros is returned.
89
+
/// </param>
90
+
/// <param name="cancel">
91
+
/// Is used to stop the task. When cancelled, the <see cref="TaskCanceledException"/> is raised.
92
+
/// </param>
93
+
/// <returns>
94
+
/// A task that represents the asynchronous operation. The task's value
95
+
/// contains the <see cref="BitswapLedger"/> for the <paramref name="peer"/>.
96
+
/// </returns>
97
+
Task<BitswapLedger> LedgerAsync(Peer peer, CancellationToken cancel = default(CancellationToken));
72
98
}
73
99
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
1
+
using System;
2
+
using System.Linq;
3
+
using System.Text;
4
+
using Microsoft.VisualStudio.TestTools.UnitTesting;
5
+
6
+
namespace Ipfs.CoreApi
7
+
{
8
+
[TestClass]
9
+
public class BitswapLedgerTest
10
+
{
11
+
[TestMethod]
12
+
public void Defaults()
13
+
{
14
+
var ledger = new BitswapLedger();
15
+
16
+
Assert.IsNull(ledger.Peer);
17
+
Assert.AreEqual(0ul, ledger.BlocksReceived);
18
+
Assert.AreEqual(0ul, ledger.BlocksSent);
19
+
Assert.AreEqual(0ul, ledger.DataReceived);
20
+
Assert.AreEqual(0ul, ledger.DataSent);
21
+
}
22
+
23
+
24
+
}
25
+
}
You can’t perform that action at this time.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4