Coverage Summary for Class: RepositorySnapshot (co.rsk.db)

Class
RepositorySnapshot


1 /* 2  * This file is part of RskJ 3  * Copyright (C) 2019 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.db; 20  21 import co.rsk.core.RskAddress; 22 import co.rsk.core.bc.AccountInformationProvider; 23 import co.rsk.crypto.Keccak256; 24 import org.ethereum.core.AccountState; 25 import org.ethereum.core.Repository; 26  27 import java.util.Set; 28  29 /** 30  * The readonly methods of a Repository. 31  * This interface DOES NOT represent an immutable value, since we have startTracking/commit to apply changes. 32  */ 33 public interface RepositorySnapshot extends AccountInformationProvider { 34  /** 35  * @return the storage root of this repository 36  */ 37  byte[] getRoot(); 38  39  /** 40  * @return set of all the account addresses 41  */ 42  Set<RskAddress> getAccountsKeys(); 43  44  /** 45  * This method can retrieve the code size without actually retrieving the code 46  * in some cases. 47  */ 48  int getCodeLength(RskAddress addr); 49  50  /** 51  * This method can retrieve the hash code without actually retrieving the code 52  * in some cases. 53  * This is the PRE RSKIP169 implementation, which has a bug we need to preserve 54  * before the implementation 55  * @param addr of the account 56  * @return hash of the contract code 57  */ 58  Keccak256 getCodeHashNonStandard(RskAddress addr); 59  60  /** 61  * This method can retrieve the hash code without actually retrieving the code 62  * in some cases. 63  * This is the POST RSKIP169 implementation which fixes the bug 64  * @param addr of the account 65  * @return hash of the contract code 66  */ 67  Keccak256 getCodeHashStandard(RskAddress addr); 68  69  /** 70  * @param addr - account to check 71  * @return - true if account exist, 72  * false otherwise 73  */ 74  boolean isExist(RskAddress addr); 75  76  /** 77  * Retrieve an account 78  * 79  * @param addr of the account 80  * @return account state as stored in the database 81  */ 82  AccountState getAccountState(RskAddress addr); 83  84  /** 85  * This method creates a new child repository for change tracking purposes. 86  * Changes will be applied to this repository after calling commit on the child. This means that this interface does 87  * NOT represent an immutable value. 88  */ 89  Repository startTracking(); 90 }