Coverage Summary for Class: BlockHeaderNotification (co.rsk.rpc.modules.eth.subscribe)

Class Class, % Method, % Line, %
BlockHeaderNotification 0% (0/1) 0% (0/15) 0% (0/29)


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.rpc.modules.eth.subscribe; 20  21 import org.ethereum.core.Block; 22 import org.ethereum.rpc.TypeConverter; 23  24 /** 25  * The block header DTO for JSON serialization purposes. 26  */ 27 public class BlockHeaderNotification implements EthSubscriptionNotificationDTO { 28  private final String difficulty; 29  private final String extraData; 30  private final String gasLimit; 31  private final String gasUsed; 32  private final String logsBloom; 33  private final String miner; 34  private final String number; 35  private final String parentHash; 36  private final String receiptsRoot; 37  private final String sha3Uncles; 38  private final String stateRoot; 39  private final String timestamp; 40  private final String transactionsRoot; 41  private final String hash; 42  43  public BlockHeaderNotification(Block block) { 44  difficulty = TypeConverter.toQuantityJsonHex(block.getDifficulty().getBytes()); 45  extraData = TypeConverter.toUnformattedJsonHex(block.getExtraData()); 46  gasLimit = TypeConverter.toJsonHex(block.getGasLimit()); 47  gasUsed = TypeConverter.toQuantityJsonHex(block.getGasUsed()); 48  logsBloom = TypeConverter.toJsonHex(block.getLogBloom()); 49  miner = TypeConverter.toJsonHex(block.getCoinbase().getBytes()); 50  number = TypeConverter.toQuantityJsonHex(block.getNumber()); 51  parentHash = block.getParentHashJsonString(); 52  receiptsRoot = TypeConverter.toJsonHex(block.getReceiptsRoot()); 53  sha3Uncles = TypeConverter.toJsonHex(block.getUnclesHash()); 54  stateRoot = TypeConverter.toJsonHex(block.getStateRoot()); 55  timestamp = TypeConverter.toQuantityJsonHex(block.getTimestamp()); 56  transactionsRoot = TypeConverter.toJsonHex(block.getTxTrieRoot()); 57  hash = block.getHashJsonString(); 58  } 59  60  public String getDifficulty() { 61  return difficulty; 62  } 63  64  public String getExtraData() { 65  return extraData; 66  } 67  68  public String getGasLimit() { 69  return gasLimit; 70  } 71  72  public String getGasUsed() { 73  return gasUsed; 74  } 75  76  public String getLogsBloom() { 77  return logsBloom; 78  } 79  80  public String getMiner() { 81  return miner; 82  } 83  84  public String getNumber() { 85  return number; 86  } 87  88  public String getParentHash() { 89  return parentHash; 90  } 91  92  public String getReceiptsRoot() { 93  return receiptsRoot; 94  } 95  96  public String getSha3Uncles() { 97  return sha3Uncles; 98  } 99  100  public String getStateRoot() { 101  return stateRoot; 102  } 103  104  public String getTimestamp() { 105  return timestamp; 106  } 107  108  public String getTransactionsRoot() { 109  return transactionsRoot; 110  } 111  112  public String getHash() { 113  return hash; 114  } 115 }