Coverage Summary for Class: RskMessage (co.rsk.net.eth)
Class |
Class, %
|
Method, %
|
Line, %
|
RskMessage |
0%
(0/1)
|
0%
(0/7)
|
0%
(0/12)
|
1 /*
2 * This file is part of RskJ
3 * Copyright (C) 2017 RSK Labs Ltd.
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU Lesser General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19 package co.rsk.net.eth;
20
21 import co.rsk.net.messages.Message;
22 import org.ethereum.net.eth.message.EthMessage;
23 import org.ethereum.net.eth.message.EthMessageCodes;
24 import org.ethereum.util.RLP;
25
26 /**
27 * Created by ajlopez on 5/14/2016.
28 */
29 public class RskMessage extends EthMessage {
30 private Message message;
31
32 public RskMessage(Message message) {
33 this.message = message;
34 this.parsed = true;
35 }
36
37 @Override
38 public EthMessageCodes getCommand() {
39 return EthMessageCodes.RSK_MESSAGE;
40 }
41
42 public Message getMessage() {
43 return this.message;
44 }
45
46 @Override
47 public byte[] getEncoded() {
48 if (encoded == null) {
49 encode();
50 }
51
52 return encoded;
53 }
54
55 @Override
56 public Class<?> getAnswerMessage() {
57 return null;
58 }
59
60 protected void encode() {
61 byte[] msg = this.message.getEncoded();
62
63 this.encoded = RLP.encodeList(msg);
64 }
65
66
67 @Override
68 public String toString() {
69 return "[" + this.getCommand().name() +
70 " message=" + this.message +
71 "]";
72 }
73 }