/**
 * # Event Transaction
 * An Event Transaction gossiped between nodes as part of events.
 *
 * ### Keywords
 * The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
 * "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this
 * document are to be interpreted as described in
 * [RFC2119](https://www.ietf.org/rfc/rfc2119) and clarified in
 * [RFC8174](https://www.ietf.org/rfc/rfc8174).
 */
syntax = "proto3";

package com.hedera.hapi.platform.event;

// SPDX-License-Identifier: Apache-2.0
import "platform/event/state_signature_transaction.proto";

option java_package = "com.hedera.hapi.platform.event.legacy";
// <<<pbj.java_package = "com.hedera.hapi.platform.event">>> This comment is special code for setting PBJ Compiler java package
option java_multiple_files = true;

/**
 * Defines the position of an EventTransaction relative to a logical "group"
 * of EventTransaction that correspond to a single set of changes to the state
 * Merkle tree.
 */
enum TransactionGroupRole {
  /**
   * The EventTransaction is the only transaction in its group.
   */
  STANDALONE = 0;

  /**
   * The EventTransaction is a child and first in its group.
   */
  FIRST_CHILD = 1;

  /**
   * The EventTransaction is a child in the middle of its group.
   */
  MIDDLE_CHILD = 2;

  /**
   * The EventTransaction is a child and last in its group.
   */
  LAST_CHILD = 3;

  /**
   * The EventTransaction is a parent and first in its group.
   */
  STARTING_PARENT = 4;

  /**
   * The EventTransaction is a parent in the middle of its group.
   */
  PARENT = 5;

  /**
   * The EventTransaction is a parent and last in its group.
   */
  ENDING_PARENT = 6;
}

/**
 * An Event Transaction gossiped between nodes as part of events.
 *
 * Each node MUST extract this transaction and process according to the type
 * of transaction encoded.<br/>
 * Both the platform and the application built on that platform MAY define event
 * transactions.<br/>
 * The encoded data MUST be a serialized protobuf message.
 */
message EventTransaction {
  oneof transaction {
      /**
       * An application transaction.
       * <p>
       * The contents of this transaction SHALL be defined by the application
       * subsystem that created the event.<br/>
       * The contents MUST be a serialized protobuf message.
       */
      bytes application_transaction = 1;
      /**
       * A state signature.
       * <p>
       * This transaction SHALL be a valid state signature for a state snapshot.
       */
      StateSignatureTransaction state_signature_transaction = 2;
  }

  /**
   * The role of this transaction in a group of transactions.
   */
  TransactionGroupRole transaction_group_role = 3;
}
