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.Numerics; |
|
3 |
using System.Security.Cryptography; |
|
4 |
using NetMQ; |
|
5 |
|
|
6 |
namespace Libplanet.Net.Messages |
|
7 |
{
|
|
8 |
internal class ChainStatus : Message |
|
9 |
{
|
|
10 | 1 |
public ChainStatus( |
11 | 1 |
HashDigest<SHA256> genesisHash, |
12 | 1 |
long tipIndex, |
13 | 1 |
BigInteger totalDifficulty) |
14 | 1 |
{
|
15 | 1 |
GenesisHash = genesisHash; |
16 | 1 |
TipIndex = tipIndex; |
17 | 1 |
TotalDifficulty = totalDifficulty; |
18 | 1 |
}
|
19 |
|
|
20 | 1 |
public ChainStatus(NetMQFrame[] body) |
21 | 1 |
{
|
22 | 1 |
GenesisHash = new HashDigest<SHA256>(body[0].Buffer); |
23 | 1 |
TipIndex = body[1].ConvertToInt64(); |
24 | 1 |
TotalDifficulty = new BigInteger(body[2].ToByteArray()); |
25 | 1 |
}
|
26 |
|
|
27 | 1 |
public HashDigest<SHA256> GenesisHash { get; } |
28 |
|
|
29 | 1 |
public long TipIndex { get; } |
30 |
|
|
31 | 1 |
public BigInteger TotalDifficulty { get; } |
32 |
|
|
33 | 1 |
protected override MessageType Type => MessageType.ChainStatus; |
34 |
|
|
35 |
protected override IEnumerable<NetMQFrame> DataFrames |
|
36 |
{
|
|
37 |
get
|
|
38 | 1 |
{
|
39 | 1 |
yield return new NetMQFrame(GenesisHash.ToByteArray()); |
40 | 1 |
yield return new NetMQFrame( |
41 | 1 |
NetworkOrderBitsConverter.GetBytes(TipIndex)); |
42 | 1 |
yield return new NetMQFrame(TotalDifficulty.ToByteArray()); |
43 | 1 |
}
|
44 |
}
|
|
45 |
}
|
|
46 |
}
|
Read our documentation on viewing source code .