BlackHole Function Documentation
Info
Blackhole is the layer that converts transactions into graphs. Some of the actions performed by this library are not applied immediately.
UpdateElement, MoveElement, DeleteElement and SetElement require calling the Commit method to be applied.
1. Create
Description: This function creates a new graph and returns its graphID.
Arguments:
- None
Returns:
graphID
(string): The ID of the created graph
Example:
let graphID = BlackHole.Create();
2. NewGraph
Description: This function creates a new graph from a given graphID.
Arguments:
graphID
(string): The ID of the graph to create
Returns:
- undefined
Example:
BlackHole.NewGraph("some-graph-id");
3. LoadGraph
Description: This function loads a graph from the blockchain and returns it as a JSON object.
Arguments:
graphID
(string): The ID of the graph to load
Returns:
loadedGraph
(object): The loaded graph as a JSON object
Example:
let graph = BlackHole.LoadGraph("some-graph-id");
4. GetElement
Description: This function returns an element of a graph as a JSON object.
Arguments:
graphID
(string): The ID of the graphelementID
(string): The ID of the element to retrieve
Returns:
element
(object): The element as a JSON object
Example:
let element = BlackHole.GetElement("some-graph-id", "some-element-id");
6. UpdateElement
Description: This function updates a property of an element in a graph.
Arguments:
graphID
(string): The ID of the graphelementID
(string): The ID of the element to updateproperty
(string): The property to updatevalue
(string|int): The new value of the property
Returns:
boolean
: true if the update succeeded, else false
Example:
let success = BlackHole.UpdateElement("some-graph-id", "some-element-id", "property-name", "new-value");
7. MoveElement
Description: This function moves an element in a graph relative to another reference element.
Arguments:
graphID
(string): The ID of the graphelementID
(string): The ID of the element to movedirection
(string): The direction to move (in, before, after)referenceNodeID
(string): The ID of the reference element
Returns:
boolean
: true if the move succeeded, else false
Example:
let success = BlackHole.MoveElement("some-graph-id", "some-element-id", "before", "reference-node-id");
8. DeleteElement
Description: This function deletes an element from a graph.
Arguments:
graphID
(string): The ID of the graphelementID
(string): The ID of the element to delete
Returns:
boolean
: true if the deletion succeeded, else false
Example:
let success = BlackHole.DeleteElement("some-graph-id", "some-element-id");
9. SetElement
Description: This function updates several properties of an element in a graph.
Arguments:
graphID
(string): The ID of the graphelementID
(string): The ID of the element to updateproperties
(object): An object containing the properties and their new values
Returns:
boolean
: true if the update succeeded, else false
Example:
let success = BlackHole.SetElement("some-graph-id", "some-element-id", {
"property1": "new-value1",
"property2": 42
});
10. Commit
Description: This function sends the pending actions to the blockchain.
Arguments:
- None
Returns:
txIDs
(array): The IDs of the sent transactions
Example:
let txIDs = BlackHole.Commit();