Search in sources :

Example 1 with Cancellable

use of tech.pegasys.teku.infrastructure.async.Cancellable in project teku by ConsenSys.

the class Eth2PeerManager method setUpPeriodicTasksForPeer.

private void setUpPeriodicTasksForPeer(Eth2Peer peer) {
    Cancellable periodicStatusUpdateTask = periodicallyUpdatePeerStatus(peer);
    Cancellable periodicPingTask = periodicallyPingPeer(peer);
    peer.subscribeDisconnect((reason, locallyInitiated) -> {
        periodicStatusUpdateTask.cancel();
        periodicPingTask.cancel();
    });
}
Also used : Cancellable(tech.pegasys.teku.infrastructure.async.Cancellable)

Example 2 with Cancellable

use of tech.pegasys.teku.infrastructure.async.Cancellable in project teku by ConsenSys.

the class DiscV5Service method doStop.

@Override
protected SafeFuture<?> doStop() {
    final Cancellable refreshTask = this.bootnodeRefreshTask;
    this.bootnodeRefreshTask = null;
    if (refreshTask != null) {
        refreshTask.cancel();
    }
    discoverySystem.stop();
    return SafeFuture.completedFuture(null);
}
Also used : Cancellable(tech.pegasys.teku.infrastructure.async.Cancellable)

Example 3 with Cancellable

use of tech.pegasys.teku.infrastructure.async.Cancellable in project teku by ConsenSys.

the class Eth1StatusLogger method fail.

synchronized void fail() {
    if (activeReporter.isEmpty()) {
        final UInt64 outageStartInSeconds = timeProvider.getTimeInSeconds();
        final Cancellable reporter = asyncRunner.runWithFixedDelay(() -> reportOutage(outageStartInSeconds), LOG_INTERVAL, error -> LOG.error("Failed to check Eth1 status", error));
        activeReporter = Optional.of(reporter);
    }
}
Also used : Cancellable(tech.pegasys.teku.infrastructure.async.Cancellable) UInt64(tech.pegasys.teku.infrastructure.unsigned.UInt64)

Example 4 with Cancellable

use of tech.pegasys.teku.infrastructure.async.Cancellable in project teku by ConsenSys.

the class ConnectionManager method doStop.

@Override
protected SafeFuture<?> doStop() {
    network.unsubscribeConnect(peerConnectedSubscriptionId);
    final Cancellable peerSearchTask = this.periodicPeerSearch;
    if (peerSearchTask != null) {
        peerSearchTask.cancel();
    }
    return SafeFuture.COMPLETE;
}
Also used : Cancellable(tech.pegasys.teku.infrastructure.async.Cancellable)

Aggregations

Cancellable (tech.pegasys.teku.infrastructure.async.Cancellable)4 UInt64 (tech.pegasys.teku.infrastructure.unsigned.UInt64)1