From 3ae595ffca9b4a1faab221b8fdd967739d0139e2 Mon Sep 17 00:00:00 2001 From: Eugene Shevchenko Date: Wed, 17 Oct 2018 14:33:24 +0300 Subject: [PATCH] Adds filter to empty VM hook in RootVmHook. --- .../src/main/java/org/ethereum/vm/hook/RootVmHook.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/ethereumj-core/src/main/java/org/ethereum/vm/hook/RootVmHook.java b/ethereumj-core/src/main/java/org/ethereum/vm/hook/RootVmHook.java index 1022b48c0c..ad38093d65 100644 --- a/ethereumj-core/src/main/java/org/ethereum/vm/hook/RootVmHook.java +++ b/ethereumj-core/src/main/java/org/ethereum/vm/hook/RootVmHook.java @@ -25,6 +25,7 @@ import org.springframework.context.annotation.Primary; import org.springframework.stereotype.Component; +import java.util.Arrays; import java.util.Optional; import java.util.function.Consumer; @@ -46,6 +47,8 @@ public RootVmHook(Optional hooks) { private void proxySafeToAll(Consumer action) { for (VMHook hook : hooks) { + if (hook.isEmpty()) continue; + try { action.accept(hook); } catch (Throwable t) { @@ -71,6 +74,10 @@ public void stopPlay(Program program) { @Override public boolean isEmpty() { - return hooks.length == 0; + return hooks.length == 0 || emptyHooksCount() == hooks.length; + } + + private long emptyHooksCount() { + return Arrays.stream(hooks).filter(VMHook::isEmpty).count(); } }