Coverage Summary for Class: BlockHeaderContract (co.rsk.pcc.blockheader)

Class Class, % Method, % Line, %
BlockHeaderContract 0% (0/1) 0% (0/3) 0% (0/14)


1 /* 2  * This file is part of RskJ 3  * Copyright (C) 2019 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  20 package co.rsk.pcc.blockheader; 21  22 import co.rsk.core.RskAddress; 23 import co.rsk.pcc.NativeContract; 24 import co.rsk.pcc.NativeMethod; 25 import org.ethereum.config.blockchain.upgrades.ActivationConfig; 26  27 import java.util.Arrays; 28 import java.util.List; 29 import java.util.Optional; 30  31 /** 32  * Precompiled contract that provides access to Block Header fields (coinbase, minimum gas price, block hash, merged 33  * mining tags, bitcoin header, gas limit, gas used, RSK difficulty and coinbase for uncles). 34  * 35  * @author Diego Masini 36  */ 37 public class BlockHeaderContract extends NativeContract { 38  // See: REMASC Maturity 39  private static final short MAX_DEPTH = 4000; 40  41  private final BlockAccessor blockAccessor; 42  43  public BlockHeaderContract(ActivationConfig activationConfig, RskAddress contractAddress) { 44  super(activationConfig, contractAddress); 45  this.blockAccessor = new BlockAccessor(MAX_DEPTH); 46  } 47  48  @Override 49  public List<NativeMethod> getMethods() { 50  return Arrays.asList( 51  new GetCoinbaseAddress(getExecutionEnvironment(), this.blockAccessor), 52  new GetBlockHash(getExecutionEnvironment(), this.blockAccessor), 53  new GetMergedMiningTags(getExecutionEnvironment(), this.blockAccessor), 54  new GetMinimumGasPrice(getExecutionEnvironment(), this.blockAccessor), 55  new GetGasLimit(getExecutionEnvironment(), this.blockAccessor), 56  new GetGasUsed(getExecutionEnvironment(), this.blockAccessor), 57  new GetDifficulty(getExecutionEnvironment(), this.blockAccessor), 58  new GetBitcoinHeader(getExecutionEnvironment(), this.blockAccessor), 59  new GetUncleCoinbaseAddress(getExecutionEnvironment(), this.blockAccessor) 60  ); 61  } 62  63  @Override 64  public Optional<NativeMethod> getDefaultMethod() { 65  return Optional.empty(); 66  } 67 } 68  69