1- type GraphSyncExtensions {String:nullable Any}
1+ ################################################################################
2+ ### GraphSync messaging protocol version 2 ###
3+ ################################################################################
4+
5+ # UUID bytes
26type GraphSyncRequestID bytes
7+
38type GraphSyncPriority int
49
10+ # Extensions as a name:data map where the data is any arbitrary, valid Node
11+ type GraphSyncExtensions { String : nullable Any }
12+
513type GraphSyncLinkAction enum {
614 # Present means the linked block was present on this machine, and is included
715 # in this message
@@ -18,6 +26,9 @@ type GraphSyncLinkAction enum {
1826 # TODO: | DuplicateDAGSkipped ("s")
1927} representation string
2028
29+ # Metadata for each "link" in the DAG being communicated, each block gets one of
30+ # these and missing blocks also get one, with an explanation as per
31+ # GraphSyncLinkAction
2132type GraphSyncMetadatum struct {
2233 link Link
2334 action GraphSyncLinkAction
@@ -57,38 +68,47 @@ type GraphSyncRequestType enum {
5768 | Cancel ("c")
5869 # Update means the extensions contain an update about this request
5970 | Update ("u")
60- # Restart means restart this request from the begging, respecting the any DoNotSendCids/DoNotSendBlocks contained
61- # in the extensions -- essentially a cancel followed by a new
71+ # Restart means restart this request from the begging, respecting the any
72+ # DoNotSendCids/DoNotSendBlocks contained in the extensions--essentially a
73+ # cancel followed by a new
6274 # TODO: | Restart ("r")
6375} representation string
6476
6577type GraphSyncRequest struct {
66- id GraphSyncRequestID # unique id set on the requester side
67- requestType GraphSyncRequestType # the request type
68- priority GraphSyncPriority # the priority (normalized). default to 1
69- root nullable Link # a CID for the root node in the query
70- selector nullable Any # see https://github.com/ipld/specs/blob/master/selectors/selectors.md
71- extensions GraphSyncExtensions # side channel information
72- } representation tuple
78+ id GraphSyncRequestID (rename "id") # unique id set on the requester side
79+ requestType GraphSyncRequestType (rename "type") # the request type
80+ priority optional GraphSyncPriority (rename "pri") # the priority (normalized). default to 1
81+ root optional Link (rename "root") # a CID for the root node in the query
82+ selector optional Any (rename "sel") # see https://github.com/ipld/specs/blob/master/selectors/selectors.md
83+ extensions optional GraphSyncExtensions (rename "ext") # side channel information
84+ } representation map
7385
7486type GraphSyncResponse struct {
75- id GraphSyncRequestID # the request id we are responding to
76- status GraphSyncResponseStatusCode # a status code.
77- metadata GraphSyncMetadata # metadata about response
78- extensions GraphSyncExtensions # side channel information
79- } representation tuple
87+ id GraphSyncRequestID (rename "reqid") # the request id we are responding to
88+ status GraphSyncResponseStatusCode (rename "stat") # a status code.
89+ metadata optional GraphSyncMetadata (rename "meta") # metadata about response
90+ extensions optional GraphSyncExtensions (rename "ext") # side channel information
91+ } representation map
8092
93+ # Block data and CID prefix that can be used to reconstruct the entire CID from
94+ # the hash of the bytes
8195type GraphSyncBlock struct {
8296 prefix Bytes # CID prefix (cid version, multicodec and multihash prefix (type + length)
8397 data Bytes
8498} representation tuple
8599
100+ # We expect each message to contain at least one of the fields, typically either
101+ # just requests, or responses and possibly blocks with it
86102type GraphSyncMessage struct {
87103 requests optional [GraphSyncRequest] (rename "req")
88104 responses optional [GraphSyncResponse] (rename "rsp")
89105 blocks optional [GraphSyncBlock] (rename "blk")
90106} representation map
91107
108+ # Parent keyed union to hold the message, the root of the structure that can be
109+ # used to version the messaging format outside of the protocol and makes the
110+ # data itself more self-descriptive (i.e. `{"gs2":...` will appear at the front
111+ # of every msg)
92112type GraphSyncMessageRoot union {
93113 | GraphSyncMessage "gs2"
94114} representation keyed
0 commit comments