From 70788a40e6bfd4221be27e557e46703e0ce96cb3 Mon Sep 17 00:00:00 2001 From: Yusef Napora Date: Thu, 26 Jan 2017 15:04:36 -0500 Subject: [PATCH 1/2] add `mcclient manifest lookup ` cmd --- src/client/api/RestClient.js | 6 ++++++ src/client/cli/commands/manifest/lookup.js | 21 +++++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 src/client/cli/commands/manifest/lookup.js diff --git a/src/client/api/RestClient.js b/src/client/api/RestClient.js index 01e696d..95d77f0 100644 --- a/src/client/api/RestClient.js +++ b/src/client/api/RestClient.js @@ -357,6 +357,12 @@ class RestClient { .then(parseBoolResponse) } + listManifestsForEntity (entityId: string): Promise> { + return this.getRequest(`dir/listmf/${entityId}`) + .then(r => new NDJsonResponse(r)) + .then(r => r.values()) + } + shutdown (): Promise { return this.postRequest('shutdown', '', false) .then(() => true) diff --git a/src/client/cli/commands/manifest/lookup.js b/src/client/cli/commands/manifest/lookup.js new file mode 100644 index 0000000..cf6b013 --- /dev/null +++ b/src/client/cli/commands/manifest/lookup.js @@ -0,0 +1,21 @@ +// @flow + +const RestClient = require('../../../api/RestClient') +const { subcommand, printJSON } = require('../../util') + +module.exports = { + command: 'lookup ', + builder: { + entityId: { + type: 'string', + description: 'An "entity" identifier that can be used to verify a public identity. ' + + 'e.g: "blockstack:mediachainlabs.id" or "keybase:yusef"' + } + }, + description: `Query the directory for the manifests belonging to \`entityId\`.\n`, + handler: subcommand((opts: {client: RestClient, entityId: string}) => { + const {client, entityId} = opts + return client.listManifestsForEntity(entityId) + .then(m => printJSON(m)) + }) +} From 5fffde73fcad476039117527a1b271ffee281099 Mon Sep 17 00:00:00 2001 From: Yusef Napora Date: Thu, 26 Jan 2017 15:22:27 -0500 Subject: [PATCH 2/2] update protobufs --- src/protobuf/dir.proto | 13 +++++++++++++ src/protobuf/index.js | 16 ++++++++++++++-- src/protobuf/node.proto | 8 ++++++++ src/protobuf/types.js | 17 ++++++++++++++++- 4 files changed, 51 insertions(+), 3 deletions(-) diff --git a/src/protobuf/dir.proto b/src/protobuf/dir.proto index 3867e66..e24132f 100644 --- a/src/protobuf/dir.proto +++ b/src/protobuf/dir.proto @@ -1,6 +1,8 @@ syntax = "proto3"; package proto; +import "manifest.proto"; + message PeerInfo { string id = 1; // peer id repeated bytes addr = 2; // peer multiaddrs @@ -15,6 +17,7 @@ message PublisherInfo { message RegisterPeer { PeerInfo info = 1; PublisherInfo publisher = 2; // optional (v1.4) + repeated Manifest manifest = 3; // optional (v1.5) } // /mediachain/dir/lookup @@ -41,3 +44,13 @@ message ListNamespacesRequest {} message ListNamespacesResponse { repeated string namespaces = 1; } + +// /mediachain/dir/listmf +message ListManifestRequest { + string entity = 1; +} + +message ListManifestResponse { + repeated Manifest manifest = 1; +} + diff --git a/src/protobuf/index.js b/src/protobuf/index.js index 01bf7e3..e00ddc2 100644 --- a/src/protobuf/index.js +++ b/src/protobuf/index.js @@ -13,6 +13,10 @@ import type { LookupPeerResponseMsg, ListPeersRequestMsg, ListPeersResponseMsg, + ListManifestRequestMsg, + ListManifestResponseMsg, + ManifestRequestMsg, + ManifestResponseMsg, PingMsg, PongMsg, NodeInfoRequestMsg, @@ -53,11 +57,15 @@ type AllProtos = { LookupPeerRequest: ProtoCodec, LookupPeerResponse: ProtoCodec, ListPeersRequest: ProtoCodec, - ListPeersResponse: ProtoCodec + ListPeersResponse: ProtoCodec, + ListManifestRequest: ProtoCodec, + ListManifestResponse: ProtoCodec }, node: { Ping: ProtoCodec, Pong: ProtoCodec, + ManifestRequest: ProtoCodec, + ManifestResponse: ProtoCodec, NodeInfoRequest: ProtoCodec, NodeInfo: ProtoCodec, QueryRequest: ProtoCodec, @@ -120,11 +128,15 @@ function loadProtos (): AllProtos { LookupPeerRequest: pb.LookupPeerRequest, LookupPeerResponse: pb.LookupPeerResponse, ListPeersRequest: pb.ListPeersRequest, - ListPeersResponse: pb.ListPeersResponse + ListPeersResponse: pb.ListPeersResponse, + ListManifestRequest: pb.ListManifestRequest, + ListManifestResponse: pb.ListManifestResponse }, node: { Ping: pb.Ping, Pong: pb.Pong, + ManifestRequest: pb.ManifestRequest, + ManifestResponse: pb.ManifestResponse, NodeInfoRequest: pb.NodeInfoRequest, NodeInfo: pb.NodeInfo, QueryRequest: pb.QueryRequest, diff --git a/src/protobuf/node.proto b/src/protobuf/node.proto index 264afad..470f6f3 100644 --- a/src/protobuf/node.proto +++ b/src/protobuf/node.proto @@ -2,6 +2,7 @@ syntax = "proto3"; package proto; import "stmt.proto"; +import "manifest.proto"; // end of result stream marker message StreamEnd {} @@ -20,6 +21,13 @@ message NodeInfo { string info = 3; } +// /mediachain/node/manifest +message ManifestRequest {} + +message ManifestResponse { + repeated Manifest manifest = 1; +} + // /mediachain/node/ping message Ping {} message Pong {} diff --git a/src/protobuf/types.js b/src/protobuf/types.js index 84733a4..a2492d2 100644 --- a/src/protobuf/types.js +++ b/src/protobuf/types.js @@ -14,7 +14,8 @@ export type PublisherInfoMsg = { export type RegisterPeerMsg = { info: PeerInfoMsg, - publisher?: PublisherInfoMsg + publisher?: PublisherInfoMsg, + manifest?: Array } export type LookupPeerRequestMsg = { @@ -33,8 +34,22 @@ export type ListPeersResponseMsg = { peers: Array } +export type ListManifestRequestMsg = { + entity: string +} + +export type ListManifestResponseMsg = { + manifest: Array +} + // node.proto +export type ManifestRequestMsg = {} + +export type ManifestResponseMsg = { + manifest: Array +} + export type PingMsg = { } export type PongMsg = { }