Navigation | Overlay |
---|---|
t Navigate files | h Toggle hits |
y Change url to tip of branch | m Toggle misses |
b / v Jump to prev/next hit line | p Toggle partial |
z / x Jump to prev/next missed or partial line | 1..9 Toggle flags |
shift + o Open current page in GitHub | a Toggle all on |
/ or ? Show keyboard shortcuts dialog | c Toggle context lines or commits |
1 |
using System.Collections.Generic; |
|
2 |
using System.Linq; |
|
3 |
using System.Security.Cryptography; |
|
4 |
using Libplanet.Blockchain; |
|
5 |
using NetMQ; |
|
6 |
|
|
7 |
namespace Libplanet.Net.Messages |
|
8 |
{
|
|
9 |
internal class GetRecentStates : Message |
|
10 |
{
|
|
11 | 1 |
public GetRecentStates( |
12 | 1 |
BlockLocator baseLocator, |
13 | 1 |
HashDigest<SHA256> target, |
14 | 1 |
long offset) |
15 | 1 |
{
|
16 | 1 |
BaseLocator = baseLocator; |
17 | 1 |
TargetBlockHash = target; |
18 | 1 |
Offset = offset; |
19 | 1 |
}
|
20 |
|
|
21 |
public GetRecentStates(NetMQFrame[] frames) |
|
22 | 1 |
: this( |
23 | 1 |
new BlockLocator(frames.Skip(2).Select(f => new HashDigest<SHA256>(f.Buffer))), |
24 | 1 |
new HashDigest<SHA256>(frames[1].Buffer), |
25 | 1 |
frames[0].ConvertToInt64() |
26 | 1 |
)
|
27 | 1 |
{
|
28 | 1 |
}
|
29 |
|
|
30 | 1 |
public BlockLocator BaseLocator { get; } |
31 |
|
|
32 | 1 |
public HashDigest<SHA256> TargetBlockHash { get; } |
33 |
|
|
34 | 1 |
public long Offset { get; } |
35 |
|
|
36 | 1 |
protected override MessageType Type => MessageType.GetRecentStates; |
37 |
|
|
38 |
protected override IEnumerable<NetMQFrame> DataFrames |
|
39 |
{
|
|
40 |
get
|
|
41 | 1 |
{
|
42 | 1 |
yield return new NetMQFrame(NetworkOrderBitsConverter.GetBytes(Offset)); |
43 | 1 |
yield return new NetMQFrame(TargetBlockHash.ToByteArray()); |
44 | 1 |
foreach (HashDigest<SHA256> hash in BaseLocator) |
45 | 1 |
{
|
46 | 1 |
yield return new NetMQFrame(hash.ToByteArray()); |
47 | 1 |
}
|
48 | 1 |
}
|
49 |
}
|
|
50 |
}
|
|
51 |
}
|
Read our documentation on viewing source code .