mirror of
https://github.com/ipfs/kubo.git
synced 2026-02-25 04:17:44 +08:00
this is a major refactor of the entire codebase it changes the monolithic peer.Peer into using a peer.ID and a peer.Peerstore. Other changes: - removed handshake3. - testutil vastly simplified peer - secio bugfix + debugging logs - testutil: RandKeyPair - backpressure bugfix: w.o.w. - peer: added hex enc/dec - peer: added a PeerInfo struct PeerInfo is a small struct used to pass around a peer with a set of addresses and keys. This is not meant to be a complete view of the system, but rather to model updates to the peerstore. It is used by things like the routing system. - updated peer/queue + peerset - latency metrics - testutil: use crand for PeerID gen RandPeerID generates random "valid" peer IDs. it does not NEED to generate keys because it is as if we lost the key right away. fine to read some randomness and hash it. to generate proper keys and an ID, use: sk, pk, _ := testutil.RandKeyPair() id, _ := peer.IDFromPublicKey(pk) Also added RandPeerIDFatal helper - removed old spipe - updated seccat - core: cleanup initIdentity - removed old getFromPeerList
79 lines
1.9 KiB
Protocol Buffer
79 lines
1.9 KiB
Protocol Buffer
package dht.pb;
|
|
|
|
//run `protoc --go_out=. *.proto` to generate
|
|
|
|
message Message {
|
|
enum MessageType {
|
|
PUT_VALUE = 0;
|
|
GET_VALUE = 1;
|
|
ADD_PROVIDER = 2;
|
|
GET_PROVIDERS = 3;
|
|
FIND_NODE = 4;
|
|
PING = 5;
|
|
}
|
|
|
|
enum ConnectionType {
|
|
// sender does not have a connection to peer, and no extra information (default)
|
|
NOT_CONNECTED = 0;
|
|
|
|
// sender has a live connection to peer
|
|
CONNECTED = 1;
|
|
|
|
// sender recently connected to peer
|
|
CAN_CONNECT = 2;
|
|
|
|
// sender recently tried to connect to peer repeatedly but failed to connect
|
|
// ("try" here is loose, but this should signal "made strong effort, failed")
|
|
CANNOT_CONNECT = 3;
|
|
}
|
|
|
|
message Peer {
|
|
// ID of a given peer.
|
|
optional string id = 1;
|
|
|
|
// multiaddrs for a given peer
|
|
repeated bytes addrs = 2;
|
|
|
|
// used to signal the sender's connection capabilities to the peer
|
|
optional ConnectionType connection = 3;
|
|
}
|
|
|
|
// defines what type of message it is.
|
|
optional MessageType type = 1;
|
|
|
|
// defines what coral cluster level this query/response belongs to.
|
|
optional int32 clusterLevelRaw = 10;
|
|
|
|
// Used to specify the key associated with this message.
|
|
// PUT_VALUE, GET_VALUE, ADD_PROVIDER, GET_PROVIDERS
|
|
optional string key = 2;
|
|
|
|
// Used to return a value
|
|
// PUT_VALUE, GET_VALUE
|
|
optional Record record = 3;
|
|
|
|
// Used to return peers closer to a key in a query
|
|
// GET_VALUE, GET_PROVIDERS, FIND_NODE
|
|
repeated Peer closerPeers = 8;
|
|
|
|
// Used to return Providers
|
|
// GET_VALUE, ADD_PROVIDER, GET_PROVIDERS
|
|
repeated Peer providerPeers = 9;
|
|
}
|
|
|
|
// Record represents a dht record that contains a value
|
|
// for a key value pair
|
|
message Record {
|
|
// The key that references this record
|
|
optional string key = 1;
|
|
|
|
// The actual value this record is storing
|
|
optional bytes value = 2;
|
|
|
|
// hash of the authors public key
|
|
optional string author = 3;
|
|
|
|
// A PKI signature for the key+value+author
|
|
optional bytes signature = 4;
|
|
}
|