public HelloMessage(Node node, long timestamp, BlockCapsule.BlockId genesis_block, BlockCapsule.BlockId solid_block, BlockCapsule.BlockId head_block) { Endpoint from = new Endpoint(); from.NodeId = ByteString.CopyFrom(node.Id); from.Port = node.Port; from.Address = ByteString.CopyFrom(Encoding.UTF8.GetBytes(node.Host)); Protocol.HelloMessage.Types.BlockId genesis = new Protocol.HelloMessage.Types.BlockId(); genesis.Hash = ByteString.CopyFrom(genesis_block.Hash); genesis.Number = genesis_block.Num; Protocol.HelloMessage.Types.BlockId solid = new Protocol.HelloMessage.Types.BlockId(); solid.Hash = ByteString.CopyFrom(solid_block.Hash); solid.Number = solid_block.Num; Protocol.HelloMessage.Types.BlockId head = new Protocol.HelloMessage.Types.BlockId(); head.Hash = ByteString.CopyFrom(head_block.Hash); head.Number = head_block.Num; this.message = new Protocol.HelloMessage(); this.message.From = from; this.message.Version = (int)Args.Instance.Node.P2P.Version; this.message.Timestamp = timestamp; this.message.GenesisBlockId = genesis; this.message.SolidBlockId = solid; this.message.HeadBlockId = head; this.type = (byte)MessageTypes.MsgType.P2P_HELLO; this.data = this.message.ToByteArray(); }
public HelloMessage(byte type, byte[] raw_data) : base(type, raw_data) { this.message = Protocol.HelloMessage.Parser.ParseFrom(raw_data); }