|
|
|
@ -26,7 +26,6 @@ import org.hyperledger.besu.ethereum.eth.messages.snap.GetTrieNodesMessage; |
|
|
|
|
import org.hyperledger.besu.ethereum.eth.messages.snap.SnapV1; |
|
|
|
|
import org.hyperledger.besu.ethereum.eth.messages.snap.StorageRangeMessage; |
|
|
|
|
import org.hyperledger.besu.ethereum.eth.messages.snap.TrieNodesMessage; |
|
|
|
|
import org.hyperledger.besu.ethereum.eth.sync.DefaultSynchronizer; |
|
|
|
|
import org.hyperledger.besu.ethereum.eth.sync.snapsync.SnapSyncConfiguration; |
|
|
|
|
import org.hyperledger.besu.ethereum.p2p.rlpx.wire.MessageData; |
|
|
|
|
import org.hyperledger.besu.ethereum.proof.WorldStateProofProvider; |
|
|
|
@ -49,7 +48,6 @@ import java.util.NavigableMap; |
|
|
|
|
import java.util.Optional; |
|
|
|
|
import java.util.concurrent.atomic.AtomicBoolean; |
|
|
|
|
import java.util.concurrent.atomic.AtomicInteger; |
|
|
|
|
import java.util.concurrent.atomic.AtomicLong; |
|
|
|
|
import java.util.function.Function; |
|
|
|
|
import java.util.function.Predicate; |
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
@ -84,7 +82,6 @@ class SnapServer implements BesuEvents.InitialSyncCompletionListener { |
|
|
|
|
static final Hash HASH_LAST = Hash.wrap(Bytes32.leftPad(Bytes.fromHexString("FF"), (byte) 0xFF)); |
|
|
|
|
|
|
|
|
|
private final AtomicBoolean isStarted = new AtomicBoolean(false); |
|
|
|
|
private final AtomicLong listenerId = new AtomicLong(); |
|
|
|
|
private final EthMessages snapMessages; |
|
|
|
|
|
|
|
|
|
private final WorldStateStorageCoordinator worldStateStorageCoordinator; |
|
|
|
@ -111,14 +108,9 @@ class SnapServer implements BesuEvents.InitialSyncCompletionListener { |
|
|
|
|
this.protocolContext = Optional.of(protocolContext); |
|
|
|
|
registerResponseConstructors(); |
|
|
|
|
|
|
|
|
|
// subscribe to initial sync completed events to start/stop snap server:
|
|
|
|
|
this.protocolContext |
|
|
|
|
.flatMap(ProtocolContext::getSynchronizer) |
|
|
|
|
.filter(z -> z instanceof DefaultSynchronizer) |
|
|
|
|
.map(DefaultSynchronizer.class::cast) |
|
|
|
|
.ifPresentOrElse( |
|
|
|
|
z -> this.listenerId.set(z.subscribeInitialSync(this)), |
|
|
|
|
() -> LOGGER.warn("SnapServer created without reference to sync status")); |
|
|
|
|
// subscribe to initial sync completed events to start/stop snap server,
|
|
|
|
|
// not saving the listenerId since we never need to unsubscribe.
|
|
|
|
|
protocolContext.getSynchronizer().subscribeInitialSync(this); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|