// DO NOT EDIT.
// swift-format-ignore-file
//
// Generated by the Swift generator plugin for the protocol buffer compiler.
// Source: cosmos/slashing/v1beta1/slashing.proto
//
// For information on using the generated types, please see the documentation:
//   https://github.com/apple/swift-protobuf/

import Foundation
import SwiftProtobuf

// If the compiler emits an error on this type, it is because this file
// was generated by a version of the `protoc` Swift plug-in that is
// incompatible with the version of SwiftProtobuf to which you are linking.
// Please ensure that you are building against the same version of the API
// that was used to generate this file.
fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck {
  struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {}
  typealias Version = _2
}

/// ValidatorSigningInfo defines a validator's signing info for monitoring their
/// liveness activity.
struct Cosmos_Slashing_V1beta1_ValidatorSigningInfo {
  // SwiftProtobuf.Message conformance is added in an extension below. See the
  // `Message` and `Message+*Additions` files in the SwiftProtobuf library for
  // methods supported on all messages.

  var address: String = String()

  /// Height at which validator was first a candidate OR was unjailed
  var startHeight: Int64 = 0

  /// Index which is incremented each time the validator was a bonded
  /// in a block and may have signed a precommit or not. This in conjunction with the
  /// `SignedBlocksWindow` param determines the index in the `MissedBlocksBitArray`.
  var indexOffset: Int64 = 0

  /// Timestamp until which the validator is jailed due to liveness downtime.
  var jailedUntil: SwiftProtobuf.Google_Protobuf_Timestamp {
    get {return _jailedUntil ?? SwiftProtobuf.Google_Protobuf_Timestamp()}
    set {_jailedUntil = newValue}
  }
  /// Returns true if `jailedUntil` has been explicitly set.
  var hasJailedUntil: Bool {return self._jailedUntil != nil}
  /// Clears the value of `jailedUntil`. Subsequent reads from it will return its default value.
  mutating func clearJailedUntil() {self._jailedUntil = nil}

  /// Whether or not a validator has been tombstoned (killed out of validator set). It is set
  /// once the validator commits an equivocation or for any other configured misbehiavor.
  var tombstoned: Bool = false

  /// A counter kept to avoid unnecessary array reads.
  /// Note that `Sum(MissedBlocksBitArray)` always equals `MissedBlocksCounter`.
  var missedBlocksCounter: Int64 = 0

  var unknownFields = SwiftProtobuf.UnknownStorage()

  init() {}

  fileprivate var _jailedUntil: SwiftProtobuf.Google_Protobuf_Timestamp? = nil
}

/// Params represents the parameters used for by the slashing module.
struct Cosmos_Slashing_V1beta1_Params {
  // SwiftProtobuf.Message conformance is added in an extension below. See the
  // `Message` and `Message+*Additions` files in the SwiftProtobuf library for
  // methods supported on all messages.

  var signedBlocksWindow: Int64 = 0

  var minSignedPerWindow: Data = Data()

  var downtimeJailDuration: SwiftProtobuf.Google_Protobuf_Duration {
    get {return _downtimeJailDuration ?? SwiftProtobuf.Google_Protobuf_Duration()}
    set {_downtimeJailDuration = newValue}
  }
  /// Returns true if `downtimeJailDuration` has been explicitly set.
  var hasDowntimeJailDuration: Bool {return self._downtimeJailDuration != nil}
  /// Clears the value of `downtimeJailDuration`. Subsequent reads from it will return its default value.
  mutating func clearDowntimeJailDuration() {self._downtimeJailDuration = nil}

  var slashFractionDoubleSign: Data = Data()

  var slashFractionDowntime: Data = Data()

  var unknownFields = SwiftProtobuf.UnknownStorage()

  init() {}

  fileprivate var _downtimeJailDuration: SwiftProtobuf.Google_Protobuf_Duration? = nil
}

#if swift(>=5.5) && canImport(_Concurrency)
extension Cosmos_Slashing_V1beta1_ValidatorSigningInfo: @unchecked Sendable {}
extension Cosmos_Slashing_V1beta1_Params: @unchecked Sendable {}
#endif  // swift(>=5.5) && canImport(_Concurrency)

// MARK: - Code below here is support for the SwiftProtobuf runtime.

fileprivate let _protobuf_package = "cosmos.slashing.v1beta1"

extension Cosmos_Slashing_V1beta1_ValidatorSigningInfo: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
  static let protoMessageName: String = _protobuf_package + ".ValidatorSigningInfo"
  static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
    1: .same(proto: "address"),
    2: .standard(proto: "start_height"),
    3: .standard(proto: "index_offset"),
    4: .standard(proto: "jailed_until"),
    5: .same(proto: "tombstoned"),
    6: .standard(proto: "missed_blocks_counter"),
  ]

  mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
    while let fieldNumber = try decoder.nextFieldNumber() {
      // The use of inline closures is to circumvent an issue where the compiler
      // allocates stack space for every case branch when no optimizations are
      // enabled. https://github.com/apple/swift-protobuf/issues/1034
      switch fieldNumber {
      case 1: try { try decoder.decodeSingularStringField(value: &self.address) }()
      case 2: try { try decoder.decodeSingularInt64Field(value: &self.startHeight) }()
      case 3: try { try decoder.decodeSingularInt64Field(value: &self.indexOffset) }()
      case 4: try { try decoder.decodeSingularMessageField(value: &self._jailedUntil) }()
      case 5: try { try decoder.decodeSingularBoolField(value: &self.tombstoned) }()
      case 6: try { try decoder.decodeSingularInt64Field(value: &self.missedBlocksCounter) }()
      default: break
      }
    }
  }

  func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
    // The use of inline closures is to circumvent an issue where the compiler
    // allocates stack space for every if/case branch local when no optimizations
    // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and
    // https://github.com/apple/swift-protobuf/issues/1182
    if !self.address.isEmpty {
      try visitor.visitSingularStringField(value: self.address, fieldNumber: 1)
    }
    if self.startHeight != 0 {
      try visitor.visitSingularInt64Field(value: self.startHeight, fieldNumber: 2)
    }
    if self.indexOffset != 0 {
      try visitor.visitSingularInt64Field(value: self.indexOffset, fieldNumber: 3)
    }
    try { if let v = self._jailedUntil {
      try visitor.visitSingularMessageField(value: v, fieldNumber: 4)
    } }()
    if self.tombstoned != false {
      try visitor.visitSingularBoolField(value: self.tombstoned, fieldNumber: 5)
    }
    if self.missedBlocksCounter != 0 {
      try visitor.visitSingularInt64Field(value: self.missedBlocksCounter, fieldNumber: 6)
    }
    try unknownFields.traverse(visitor: &visitor)
  }

  static func ==(lhs: Cosmos_Slashing_V1beta1_ValidatorSigningInfo, rhs: Cosmos_Slashing_V1beta1_ValidatorSigningInfo) -> Bool {
    if lhs.address != rhs.address {return false}
    if lhs.startHeight != rhs.startHeight {return false}
    if lhs.indexOffset != rhs.indexOffset {return false}
    if lhs._jailedUntil != rhs._jailedUntil {return false}
    if lhs.tombstoned != rhs.tombstoned {return false}
    if lhs.missedBlocksCounter != rhs.missedBlocksCounter {return false}
    if lhs.unknownFields != rhs.unknownFields {return false}
    return true
  }
}

extension Cosmos_Slashing_V1beta1_Params: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
  static let protoMessageName: String = _protobuf_package + ".Params"
  static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
    1: .standard(proto: "signed_blocks_window"),
    2: .standard(proto: "min_signed_per_window"),
    3: .standard(proto: "downtime_jail_duration"),
    4: .standard(proto: "slash_fraction_double_sign"),
    5: .standard(proto: "slash_fraction_downtime"),
  ]

  mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
    while let fieldNumber = try decoder.nextFieldNumber() {
      // The use of inline closures is to circumvent an issue where the compiler
      // allocates stack space for every case branch when no optimizations are
      // enabled. https://github.com/apple/swift-protobuf/issues/1034
      switch fieldNumber {
      case 1: try { try decoder.decodeSingularInt64Field(value: &self.signedBlocksWindow) }()
      case 2: try { try decoder.decodeSingularBytesField(value: &self.minSignedPerWindow) }()
      case 3: try { try decoder.decodeSingularMessageField(value: &self._downtimeJailDuration) }()
      case 4: try { try decoder.decodeSingularBytesField(value: &self.slashFractionDoubleSign) }()
      case 5: try { try decoder.decodeSingularBytesField(value: &self.slashFractionDowntime) }()
      default: break
      }
    }
  }

  func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
    // The use of inline closures is to circumvent an issue where the compiler
    // allocates stack space for every if/case branch local when no optimizations
    // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and
    // https://github.com/apple/swift-protobuf/issues/1182
    if self.signedBlocksWindow != 0 {
      try visitor.visitSingularInt64Field(value: self.signedBlocksWindow, fieldNumber: 1)
    }
    if !self.minSignedPerWindow.isEmpty {
      try visitor.visitSingularBytesField(value: self.minSignedPerWindow, fieldNumber: 2)
    }
    try { if let v = self._downtimeJailDuration {
      try visitor.visitSingularMessageField(value: v, fieldNumber: 3)
    } }()
    if !self.slashFractionDoubleSign.isEmpty {
      try visitor.visitSingularBytesField(value: self.slashFractionDoubleSign, fieldNumber: 4)
    }
    if !self.slashFractionDowntime.isEmpty {
      try visitor.visitSingularBytesField(value: self.slashFractionDowntime, fieldNumber: 5)
    }
    try unknownFields.traverse(visitor: &visitor)
  }

  static func ==(lhs: Cosmos_Slashing_V1beta1_Params, rhs: Cosmos_Slashing_V1beta1_Params) -> Bool {
    if lhs.signedBlocksWindow != rhs.signedBlocksWindow {return false}
    if lhs.minSignedPerWindow != rhs.minSignedPerWindow {return false}
    if lhs._downtimeJailDuration != rhs._downtimeJailDuration {return false}
    if lhs.slashFractionDoubleSign != rhs.slashFractionDoubleSign {return false}
    if lhs.slashFractionDowntime != rhs.slashFractionDowntime {return false}
    if lhs.unknownFields != rhs.unknownFields {return false}
    return true
  }
}
