Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable Retrieving IPLD Object Stats #56

Merged
merged 4 commits into from
Mar 31, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions doc/PROTO.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,12 @@
- [DagRequest](#pb.DagRequest)
- [DagRequest.LinksEntry](#pb.DagRequest.LinksEntry)
- [DagResponse](#pb.DagResponse)
- [DagResponse.NodeStatsEntry](#pb.DagResponse.NodeStatsEntry)
- [ExtrasRequest](#pb.ExtrasRequest)
- [GetPeersResponse](#pb.GetPeersResponse)
- [IPLDLink](#pb.IPLDLink)
- [IPLDNode](#pb.IPLDNode)
- [IPLDStat](#pb.IPLDStat)
- [KeystoreRequest](#pb.KeystoreRequest)
- [KeystoreResponse](#pb.KeystoreResponse)
- [P2PLsInfo](#pb.P2PLsInfo)
Expand Down Expand Up @@ -659,6 +661,23 @@ Used in response to a Dag or DagStream RPC
| hashes | [string](#string) | repeated | returns the hashes of newly generated IPLD objects sent by: DAG_PUT, DAG_NEW_NODE, DAG_ADD_LINKS, DAG_GET_LINKS |
| rawData | [bytes](#bytes) | | the actual data contained by the IPLD object sent by: DAG_GET |
| links | [IPLDLink](#pb.IPLDLink) | repeated | the links contained within an IPLD node object sent by: DAG_GET_LINKS |
| nodeStats | [DagResponse.NodeStatsEntry](#pb.DagResponse.NodeStatsEntry) | repeated | maps ipld cids to a ipld.NodeStat object equivalent sent by: DAG_STAT |






<a name="pb.DagResponse.NodeStatsEntry"></a>

### DagResponse.NodeStatsEntry



| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| key | [string](#string) | | |
| value | [IPLDStat](#pb.IPLDStat) | | |



Expand Down Expand Up @@ -729,6 +748,26 @@ An IPFS MerkleDAG Node



<a name="pb.IPLDStat"></a>

### IPLDStat
IPLDStat is statistics about an individual dag node
it is a protocol buffer wrapper around ipld.NodeStat


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| numLinks | [int64](#int64) | | number of links in link table |
| blockSize | [int64](#int64) | | size of the raw, encoded data |
| linkSize | [int64](#int64) | | size of the links segment |
| cumulativeSize | [int64](#int64) | | cumulative size of object and its references |
| dataSize | [int64](#int64) | | size of the data segment |






<a name="pb.KeystoreRequest"></a>

### KeystoreRequest
Expand Down Expand Up @@ -943,6 +982,7 @@ DAGREQTYPE indicates the particular DagAPI request being performed
| DAG_NEW_NODE | 2 | DAG_NEW_NODE is used to create a new IPLD node object |
| DAG_ADD_LINKS | 3 | DAG_ADD_LINKS is used to add links to an IPLD node object |
| DAG_GET_LINKS | 4 | DAG_GET_LINKS is used to retrieve all links contained in an IPLD node object |
| DAG_STAT | 5 | DAG_STAT is used to retrieve ipld.NodeStats information |



Expand Down
710 changes: 602 additions & 108 deletions go/node.pb.go

Large diffs are not rendered by default.

285 changes: 283 additions & 2 deletions js/node_pb.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ goog.exportSymbol('proto.pb.ExtrasRequest', null, global);
goog.exportSymbol('proto.pb.GetPeersResponse', null, global);
goog.exportSymbol('proto.pb.IPLDLink', null, global);
goog.exportSymbol('proto.pb.IPLDNode', null, global);
goog.exportSymbol('proto.pb.IPLDStat', null, global);
goog.exportSymbol('proto.pb.KSREQTYPE', null, global);
goog.exportSymbol('proto.pb.KeystoreRequest', null, global);
goog.exportSymbol('proto.pb.KeystoreResponse', null, global);
Expand Down Expand Up @@ -3055,7 +3056,8 @@ proto.pb.DagResponse.toObject = function(includeInstance, msg) {
hashesList: jspb.Message.getRepeatedField(msg, 2),
rawdata: msg.getRawdata_asB64(),
linksList: jspb.Message.toObjectList(msg.getLinksList(),
proto.pb.IPLDLink.toObject, includeInstance)
proto.pb.IPLDLink.toObject, includeInstance),
nodestatsMap: (f = msg.getNodestatsMap()) ? f.toObject(includeInstance, proto.pb.IPLDStat.toObject) : []
};

if (includeInstance) {
Expand Down Expand Up @@ -3109,6 +3111,12 @@ proto.pb.DagResponse.deserializeBinaryFromReader = function(msg, reader) {
reader.readMessage(value,proto.pb.IPLDLink.deserializeBinaryFromReader);
msg.addLinks(value);
break;
case 5:
var value = msg.getNodestatsMap();
reader.readMessage(value, function(message, reader) {
jspb.Map.deserializeBinary(message, reader, jspb.BinaryReader.prototype.readString, jspb.BinaryReader.prototype.readMessage, proto.pb.IPLDStat.deserializeBinaryFromReader, "");
});
break;
default:
reader.skipField();
break;
Expand Down Expand Up @@ -3167,6 +3175,10 @@ proto.pb.DagResponse.serializeBinaryToWriter = function(message, writer) {
proto.pb.IPLDLink.serializeBinaryToWriter
);
}
f = message.getNodestatsMap(true);
if (f && f.getLength() > 0) {
f.serializeBinary(5, writer, jspb.BinaryWriter.prototype.writeString, jspb.BinaryWriter.prototype.writeMessage, proto.pb.IPLDStat.serializeBinaryToWriter);
}
};


Expand Down Expand Up @@ -3284,6 +3296,274 @@ proto.pb.DagResponse.prototype.clearLinksList = function() {
};


/**
* map<string, IPLDStat> nodeStats = 5;
* @param {boolean=} opt_noLazyCreate Do not create the map if
* empty, instead returning `undefined`
* @return {!jspb.Map<string,!proto.pb.IPLDStat>}
*/
proto.pb.DagResponse.prototype.getNodestatsMap = function(opt_noLazyCreate) {
return /** @type {!jspb.Map<string,!proto.pb.IPLDStat>} */ (
jspb.Message.getMapField(this, 5, opt_noLazyCreate,
proto.pb.IPLDStat));
};


proto.pb.DagResponse.prototype.clearNodestatsMap = function() {
this.getNodestatsMap().clear();
};



/**
* Generated by JsPbCodeGenerator.
* @param {Array=} opt_data Optional initial data array, typically from a
* server response, or constructed directly in Javascript. The array is used
* in place and becomes part of the constructed object. It is not cloned.
* If no data is provided, the constructed object will be empty, but still
* valid.
* @extends {jspb.Message}
* @constructor
*/
proto.pb.IPLDStat = function(opt_data) {
jspb.Message.initialize(this, opt_data, 0, -1, null, null);
};
goog.inherits(proto.pb.IPLDStat, jspb.Message);
if (goog.DEBUG && !COMPILED) {
proto.pb.IPLDStat.displayName = 'proto.pb.IPLDStat';
}


if (jspb.Message.GENERATE_TO_OBJECT) {
/**
* Creates an object representation of this proto suitable for use in Soy templates.
* Field names that are reserved in JavaScript and will be renamed to pb_name.
* To access a reserved field use, foo.pb_<name>, eg, foo.pb_default.
* For the list of reserved names please see:
* com.google.apps.jspb.JsClassTemplate.JS_RESERVED_WORDS.
* @param {boolean=} opt_includeInstance Whether to include the JSPB instance
* for transitional soy proto support: http://goto/soy-param-migration
* @return {!Object}
*/
proto.pb.IPLDStat.prototype.toObject = function(opt_includeInstance) {
return proto.pb.IPLDStat.toObject(opt_includeInstance, this);
};


/**
* Static version of the {@see toObject} method.
* @param {boolean|undefined} includeInstance Whether to include the JSPB
* instance for transitional soy proto support:
* http://goto/soy-param-migration
* @param {!proto.pb.IPLDStat} msg The msg instance to transform.
* @return {!Object}
* @suppress {unusedLocalVariables} f is only used for nested messages
*/
proto.pb.IPLDStat.toObject = function(includeInstance, msg) {
var f, obj = {
numlinks: jspb.Message.getFieldWithDefault(msg, 1, 0),
blocksize: jspb.Message.getFieldWithDefault(msg, 2, 0),
linksize: jspb.Message.getFieldWithDefault(msg, 3, 0),
cumulativesize: jspb.Message.getFieldWithDefault(msg, 4, 0),
datasize: jspb.Message.getFieldWithDefault(msg, 5, 0)
};

if (includeInstance) {
obj.$jspbMessageInstance = msg;
}
return obj;
};
}


/**
* Deserializes binary data (in protobuf wire format).
* @param {jspb.ByteSource} bytes The bytes to deserialize.
* @return {!proto.pb.IPLDStat}
*/
proto.pb.IPLDStat.deserializeBinary = function(bytes) {
var reader = new jspb.BinaryReader(bytes);
var msg = new proto.pb.IPLDStat;
return proto.pb.IPLDStat.deserializeBinaryFromReader(msg, reader);
};


/**
* Deserializes binary data (in protobuf wire format) from the
* given reader into the given message object.
* @param {!proto.pb.IPLDStat} msg The message object to deserialize into.
* @param {!jspb.BinaryReader} reader The BinaryReader to use.
* @return {!proto.pb.IPLDStat}
*/
proto.pb.IPLDStat.deserializeBinaryFromReader = function(msg, reader) {
while (reader.nextField()) {
if (reader.isEndGroup()) {
break;
}
var field = reader.getFieldNumber();
switch (field) {
case 1:
var value = /** @type {number} */ (reader.readInt64());
msg.setNumlinks(value);
break;
case 2:
var value = /** @type {number} */ (reader.readInt64());
msg.setBlocksize(value);
break;
case 3:
var value = /** @type {number} */ (reader.readInt64());
msg.setLinksize(value);
break;
case 4:
var value = /** @type {number} */ (reader.readInt64());
msg.setCumulativesize(value);
break;
case 5:
var value = /** @type {number} */ (reader.readInt64());
msg.setDatasize(value);
break;
default:
reader.skipField();
break;
}
}
return msg;
};


/**
* Serializes the message to binary data (in protobuf wire format).
* @return {!Uint8Array}
*/
proto.pb.IPLDStat.prototype.serializeBinary = function() {
var writer = new jspb.BinaryWriter();
proto.pb.IPLDStat.serializeBinaryToWriter(this, writer);
return writer.getResultBuffer();
};


/**
* Serializes the given message to binary data (in protobuf wire
* format), writing to the given BinaryWriter.
* @param {!proto.pb.IPLDStat} message
* @param {!jspb.BinaryWriter} writer
* @suppress {unusedLocalVariables} f is only used for nested messages
*/
proto.pb.IPLDStat.serializeBinaryToWriter = function(message, writer) {
var f = undefined;
f = message.getNumlinks();
if (f !== 0) {
writer.writeInt64(
1,
f
);
}
f = message.getBlocksize();
if (f !== 0) {
writer.writeInt64(
2,
f
);
}
f = message.getLinksize();
if (f !== 0) {
writer.writeInt64(
3,
f
);
}
f = message.getCumulativesize();
if (f !== 0) {
writer.writeInt64(
4,
f
);
}
f = message.getDatasize();
if (f !== 0) {
writer.writeInt64(
5,
f
);
}
};


/**
* optional int64 numLinks = 1;
* @return {number}
*/
proto.pb.IPLDStat.prototype.getNumlinks = function() {
return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 1, 0));
};


/** @param {number} value */
proto.pb.IPLDStat.prototype.setNumlinks = function(value) {
jspb.Message.setProto3IntField(this, 1, value);
};


/**
* optional int64 blockSize = 2;
* @return {number}
*/
proto.pb.IPLDStat.prototype.getBlocksize = function() {
return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 2, 0));
};


/** @param {number} value */
proto.pb.IPLDStat.prototype.setBlocksize = function(value) {
jspb.Message.setProto3IntField(this, 2, value);
};


/**
* optional int64 linkSize = 3;
* @return {number}
*/
proto.pb.IPLDStat.prototype.getLinksize = function() {
return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 3, 0));
};


/** @param {number} value */
proto.pb.IPLDStat.prototype.setLinksize = function(value) {
jspb.Message.setProto3IntField(this, 3, value);
};


/**
* optional int64 cumulativeSize = 4;
* @return {number}
*/
proto.pb.IPLDStat.prototype.getCumulativesize = function() {
return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 4, 0));
};


/** @param {number} value */
proto.pb.IPLDStat.prototype.setCumulativesize = function(value) {
jspb.Message.setProto3IntField(this, 4, value);
};


/**
* optional int64 dataSize = 5;
* @return {number}
*/
proto.pb.IPLDStat.prototype.getDatasize = function() {
return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 5, 0));
};


/** @param {number} value */
proto.pb.IPLDStat.prototype.setDatasize = function(value) {
jspb.Message.setProto3IntField(this, 5, value);
};



/**
* Generated by JsPbCodeGenerator.
Expand Down Expand Up @@ -4616,7 +4896,8 @@ proto.pb.DAGREQTYPE = {
DAG_GET: 1,
DAG_NEW_NODE: 2,
DAG_ADD_LINKS: 3,
DAG_GET_LINKS: 4
DAG_GET_LINKS: 4,
DAG_STAT: 5
};

/**
Expand Down
Loading