Skip to content

Commit

Permalink
Allow creating the Trie Log Layer objects outside of its package (#4096)
Browse files Browse the repository at this point in the history
* Allow creating Trie Log Layer objects outside of its package

Signed-off-by: Jiri Peinlich <jiri.peinlich@gmail.com>

* Make access public so that I can use the class outside of besu

Signed-off-by: Jiri Peinlich <jiri.peinlich@gmail.com>
  • Loading branch information
gezero authored Jul 21, 2022
1 parent 8eb22bb commit 1dd7357
Showing 1 changed file with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,11 @@ void addStorageChange(
.put(slotHash, new BonsaiValue<>(oldValue, newValue));
}

static TrieLogLayer fromBytes(final byte[] bytes) {
public static TrieLogLayer fromBytes(final byte[] bytes) {
return readFrom(new BytesValueRLPInput(Bytes.wrap(bytes), false));
}

static TrieLogLayer readFrom(final RLPInput input) {
public static TrieLogLayer readFrom(final RLPInput input) {
final TrieLogLayer newLayer = new TrieLogLayer();

input.enterList();
Expand Down Expand Up @@ -161,7 +161,7 @@ static TrieLogLayer readFrom(final RLPInput input) {
return newLayer;
}

void writeTo(final RLPOutput output) {
public void writeTo(final RLPOutput output) {
freeze();

final Set<Address> addresses = new TreeSet<>();
Expand Down Expand Up @@ -212,23 +212,23 @@ void writeTo(final RLPOutput output) {
output.endList(); // container
}

Stream<Map.Entry<Address, BonsaiValue<StateTrieAccountValue>>> streamAccountChanges() {
public Stream<Map.Entry<Address, BonsaiValue<StateTrieAccountValue>>> streamAccountChanges() {
return accounts.entrySet().stream();
}

Stream<Map.Entry<Address, BonsaiValue<Bytes>>> streamCodeChanges() {
public Stream<Map.Entry<Address, BonsaiValue<Bytes>>> streamCodeChanges() {
return code.entrySet().stream();
}

Stream<Map.Entry<Address, Map<Hash, BonsaiValue<UInt256>>>> streamStorageChanges() {
public Stream<Map.Entry<Address, Map<Hash, BonsaiValue<UInt256>>>> streamStorageChanges() {
return storage.entrySet().stream();
}

boolean hasStorageChanges(final Address address) {
public boolean hasStorageChanges(final Address address) {
return storage.containsKey(address);
}

Stream<Map.Entry<Hash, BonsaiValue<UInt256>>> streamStorageChanges(final Address address) {
public Stream<Map.Entry<Hash, BonsaiValue<UInt256>>> streamStorageChanges(final Address address) {
return storage.getOrDefault(address, Map.of()).entrySet().stream();
}

Expand Down

0 comments on commit 1dd7357

Please sign in to comment.