syntax = "proto3";
package cometbft.p2p.v1;

option go_package = "github.com/cometbft/cometbft/api/cometbft/p2p/v1";

import "gogoproto/gogo.proto";
import "cometbft/crypto/v1/keys.proto";

// PacketPing is a request to confirm that the connection is alive.
message PacketPing {}

// PacketPong is a response to confirm that the connection is alive.
message PacketPong {}

// PacketMsg contains data for the specified channel ID. EOF means the message
// is fully received.
message PacketMsg {
  int32 channel_id = 1 [(gogoproto.customname) = "ChannelID"];
  bool  eof        = 2 [(gogoproto.customname) = "EOF"];
  bytes data       = 3;
}

// Packet is an abstract p2p message.
message Packet {
  // Sum of all possible messages.
  oneof sum {
    PacketPing packet_ping = 1;
    PacketPong packet_pong = 2;
    PacketMsg  packet_msg  = 3;
  }
}

// AuthSigMessage is sent during the authentication and contains our/remote's
// signature along with the public key.
message AuthSigMessage {
  cometbft.crypto.v1.PublicKey pub_key = 1 [(gogoproto.nullable) = false];
  bytes                        sig     = 2;
}
