1
using System.Collections.Generic;
2
using System.Security.Cryptography;
3
using Libplanet.Blocks;
4
using NetMQ;
5

6
namespace Libplanet.Net.Messages
7
{
8
    internal class BlockHeaderMessage : Message
9
    {
10 1
        public BlockHeaderMessage(HashDigest<SHA256> genesisHash, BlockHeader header)
11 1
        {
12 1
            GenesisHash = genesisHash;
13 1
            Header = header;
14 1
        }
15

16 1
        public BlockHeaderMessage(NetMQFrame[] frames)
17 1
        {
18 1
            GenesisHash = new HashDigest<SHA256>(frames[0].Buffer);
19 1
            Header = BlockHeader.Deserialize(frames[1].Buffer);
20 1
        }
21

22 1
        public HashDigest<SHA256> GenesisHash { get; }
23

24 1
        public BlockHeader Header { get; }
25

26 1
        protected override MessageType Type => MessageType.BlockHeaderMessage;
27

28
        protected override IEnumerable<NetMQFrame> DataFrames
29
        {
30
            get
31 1
            {
32 1
                yield return new NetMQFrame(GenesisHash.ToByteArray());
33 1
                yield return new NetMQFrame(Header.Serialize());
34 1
            }
35
        }
36
    }
37
}

Read our documentation on viewing source code .

Loading