Coverage Summary for Class: SkeletonResponseMessage (co.rsk.net.messages)

Class Class, % Method, % Line, %
SkeletonResponseMessage 0% (0/1) 0% (0/6) 0% (0/13)


1 /* 2  * This file is part of RskJ 3  * Copyright (C) 2017 RSK Labs Ltd. 4  * (derived from ethereumJ library, Copyright (c) 2016 <ether.camp>) 5  * 6  * This program is free software: you can redistribute it and/or modify 7  * it under the terms of the GNU Lesser General Public License as published by 8  * the Free Software Foundation, either version 3 of the License, or 9  * (at your option) any later version. 10  * 11  * This program is distributed in the hope that it will be useful, 12  * but WITHOUT ANY WARRANTY; without even the implied warranty of 13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14  * GNU Lesser General Public License for more details. 15  * 16  * You should have received a copy of the GNU Lesser General Public License 17  * along with this program. If not, see <http://www.gnu.org/licenses/>. 18  */ 19 package co.rsk.net.messages; 20  21 import org.ethereum.core.BlockIdentifier; 22 import org.ethereum.util.RLP; 23  24 import java.util.List; 25  26 /** 27  * Wrapper around an RSK Skeleton message. 28  */ 29 public class SkeletonResponseMessage extends MessageWithId { 30  31  private long id; 32  private List<BlockIdentifier> blockIdentifiers; 33  34  public SkeletonResponseMessage(long id, List<BlockIdentifier> blockIdentifiers) { 35  this.id = id; 36  this.blockIdentifiers = blockIdentifiers; 37  } 38  39  @Override 40  public MessageType getMessageType() { 41  return MessageType.SKELETON_RESPONSE_MESSAGE; 42  } 43  44  @Override 45  public byte[] getEncodedMessageWithoutId() { 46  byte[][] encodedElementArray = blockIdentifiers.stream() 47  .map(BlockIdentifier::getEncoded) 48  .toArray(byte[][]::new); 49  return RLP.encodeList(RLP.encodeList(encodedElementArray)); 50  } 51  52  public long getId() { 53  return this.id; 54  } 55  56  public List<BlockIdentifier> getBlockIdentifiers() { 57  return blockIdentifiers; 58  } 59  60  @Override 61  public void accept(MessageVisitor v) { 62  v.apply(this); 63  } 64 }