syntax = "proto3";

package p2p.v1;
import "google/protobuf/timestamp.proto";

enum P2PMsgType {
  P2P_MSG_TYPE_INVALID = 0;
  P2P_MSG_TYPE_PING = 1;
  P2P_MSG_TYPE_PONG = 2;
}

// shared between all p2p package
message MessageHeader {
  // client protocol version
  string client_version = 1;
  // client type
  int32  client_type = 2;
  // allows requesters to use request data when processing a response
  string id = 3;
  // package create time.
  google.protobuf.Timestamp create_time = 4;
  // id of node that created the message (not the peer that may have sent it). =base58(multihash(nodePubKey))
  string node_id = 5;

  bool gossip = 6;

  // Authoring node Secp256k1 public key (32bytes) - protobufs serielized
  bytes node_pubkey = 7;
  // signature of full message data.
  bytes sign = 8;
}
// HandShake used for check info when peer connect
message HandShakeRequest {
  MessageHeader header = 1;
  string message = 2;
}

message HandShakeResponse {
  MessageHeader header = 1;
  string message = 2;
}

// PingRequest used for peer keep alive.
message PingRequest {
  MessageHeader header = 1;
  string message = 2;
}

message PongResponse {
  MessageHeader header = 1;
  string message = 2;
}

// Disconnect used for disconnect a peer and give a reason.
message DisconnectRequest {
  MessageHeader header = 1;
  string reason = 2;
}

message MessageRequest {
  MessageHeader header = 1;
  int32 message_type = 2;
  bytes message_data = 3;
}

message MessageResponse {
  MessageHeader header = 1;
  int32 message_type = 2;
  bytes message_data = 3;
}
