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