syntax = "proto3";

package blossomsub.pb;

option go_package = "source.quilibrium.com/quilibrium/monorepo/go-libp2p-blossomsub/pb";

message RPC {
	repeated SubOpts subscriptions = 1;
	repeated Message publish = 2;

	message SubOpts {
		bool subscribe = 1; // subscribe or unsubcribe
		bytes bitmask = 2;
	}

	ControlMessage control = 3;
}

message Message {
	bytes from = 1;
	bytes data = 2;
	bytes seqno = 3;
	bytes bitmask = 4;
	bytes signature = 5;
	bytes key = 6;
}

message ControlMessage {
	repeated ControlIHave ihave = 1;
	repeated ControlIWant iwant = 2;
	repeated ControlGraft graft = 3;
	repeated ControlPrune prune = 4;
}

message ControlIHave {
	bytes bitmask = 1;
	// implementors from other languages should use bytes here - go protobuf emits invalid utf8 strings
	repeated string messageIDs = 2;
}

message ControlIWant {
	// implementors from other languages should use bytes here - go protobuf emits invalid utf8 strings
	repeated string messageIDs = 1;
}

message ControlGraft {
	bytes bitmask = 1;
}

message ControlPrune {
	bytes bitmask = 1;
	repeated PeerInfo peers = 2;
	uint64 backoff = 3;
}

message PeerInfo {
	optional bytes peerID = 1;
	optional bytes signedPeerRecord = 2;
}