/**
   * FermatEventHandler interface implementation
   *
   * <p>Plugin is started? The event is the expected event?
   */
  @Override
  public void handleEvent(FermatEvent fermatEvent) throws FermatException {

    if (this.cryptoBrokerActorConnectionPluginRoot.getStatus() == ServiceStatus.STARTED) {

      if (fermatEvent instanceof CryptoBrokerConnectionRequestUpdatesEvent) {

        actorConnectionEventActions.handleCryptoBrokerUpdateEvent();

      } else {
        EventType eventExpected = EventType.CRYPTO_BROKER_CONNECTION_REQUEST_UPDATES;
        String context =
            "Event received: "
                + fermatEvent.getEventType().toString()
                + " - "
                + fermatEvent.getEventType().getCode()
                + "\n"
                + "Event expected: "
                + eventExpected.toString()
                + " - "
                + eventExpected.getCode();
        throw new UnexpectedEventException(context);
      }
    } else {
      throw new CryptoBrokerActorConnectionNotStartedException("Plugin is not started.", "");
    }
  }
  @Override
  public void handleEvent(FermatEvent fermatEvent) throws FermatException {
    String context =
        "Event Type: " + fermatEvent.getEventType() + "Event Source: " + fermatEvent.getSource();

    if (assetDistributionRecorderService.getStatus() != ServiceStatus.STARTED) {
      throw new TransactionServiceNotStartedException();
    }

    if (!(fermatEvent instanceof ReceivedNewTransactionStatusNotificationEvent)) {
      // You're using the wrong handler..
      throw new CantSaveEventException(
          null,
          context,
          "The event received event is not an instance of ReceivedNewTransactionStatusNotificationEvent, use the right handler.");
    }

    ReceivedNewTransactionStatusNotificationEvent metadataNotificationEvent =
        (ReceivedNewTransactionStatusNotificationEvent) fermatEvent;

    try {
      assetDistributionRecorderService.receivedTransactionStatusNotificationrEvent(
          metadataNotificationEvent);
    } catch (Exception exception) {
      throw new CantSaveEventException(
          exception,
          "Handling the ReceivedNewTransactionStatusNotificationEvent",
          "Unexpected exception");
    }
  }
  /** FermatEventHandler interface implementation */
  @Override
  public void handleEvent(FermatEvent fermatEvent) throws FermatException {
    if (!eventRecorderService.getStatus().equals(ServiceStatus.STARTED))
      throw new TransactionServiceNotStartedException(
          TransactionServiceNotStartedException.DEFAULT_MESSAGE,
          null,
          null,
          "Events can't be handled if the service is not started");

    if (fermatEvent instanceof IncomingCryptoOnCryptoNetworkWaitingTransferenceExtraUserEvent)
      eventRecorderService.saveEvent(fermatEvent);
    else
      throw new CantSaveEventException(
          CantSaveEventException.DEFAULT_MESSAGE,
          null,
          "Event: " + fermatEvent.getEventType().toString(),
          "This should have been IncomingCryptoOnCryptoNetworkWaitingTransferenceExtraUserEvent");
  }