Skip to content

metastore API

Ezra Weller edited this page Nov 10, 2019 · 7 revisions

Version: Pre-alpha

Squad's metastore package is a p2p storage system built using Holochain.

API

webSocketConnection(uri)

Create a new websocket connection to the metastore.

Inputs: uri (string, websocket url to connect to)

Outputs: squad.connection (the new websocket connection)

on(message, f)

Set callback to be run when the websocket connection returns a particular message.

Inputs:

  • message: string (output to look for from the websocket connection)
  • f: function (runs when the message is received)

Example:

metastore.on('open', () => {
  console.log("TESTING METASTORE API...")
})

createDefinition(definition)

Create a new definition metadata entry in the shared metastore.

Inputs: definition

Outputs: Holochain address (the address of the new definition in the metastore)

getDefinition(address)

Get a definition from the metastore using its Holochain address.

Inputs: Holochain address

Outputs: definition

getAddress

(TBD -- change this to getDefinitionAddress)

getCatalogAddresses(catalog_type, catalog_name)

Get the Holochain addresses of the definitions in a specific catalog.

Inputs:

  • catalog_type: string (definition-type the catalog stores -- "Game", "Component," etc.)
  • catalog_name: string (name of the catalog -- base catalogs are "[catalog_type]-Catalog")

Outputs: List of addresses

getAllDefinitionsOfType(catalog_type)

Get all definitions of a certain type from the base catalog for that type.

Inputs: catalog_type (string, definition-type the catalog stores -- "Game", "Component," etc.)

Outputs: List of definitions

getDefinitionsFromCatalog

Get definitions from a specific catalog.

Inputs:

  • catalog_type: string (definition-type the catalog stores -- "Game", "Component," etc.)
  • catalog_name: string (name of the catalog -- base catalogs are "[catalog_type]-Catalog")

Outputs: List of definitions

close()

Close the websocket connection.

networking

A networking shim allowing the metastore to share data peer-to-peer.

networking.createNode(url)

Create an IPFS node.

Inputs: url (the URL the IPFS node repo will be associated to)

Outputs: A new IPFS object

networking.shareDefinitions(node, TOPIC, typeArray, shareFunction)

Subscribe to the IPFS node and periodically share metadata to it.

Inputs:

  • node: IPFS object
  • TOPIC: string (topic to share and retrieve IPFS data through)
  • typeArray: array of strings (the metadata types to be shared and retrieved -- definition types: "Format", "Game", etc.)
  • shareFunction: function (to plug data into when retrieved, generally a submitDefinition function)