HB
HB
handles interactions with a Hyperbeam node.
- Instantiate
- path
- fetch
- text
- json
- send
- spawn
- schedule
- compute
- messages
- Legacynet AOS
- Mainnet AOS
- Devices
Instantiate
import { HB } from "wao"
const hb = await new HB({ url: "http://localhost:10000" }).init(jwk)
path
Create a path to request.
const device = "meta"
const path = "info"
const json = true
const params = {}
const path = hb.path(device, path, json, params)
// /~meta@1.0/info/serialize~json@1.0
fetch
Request without a signature.
const result = await hb.fetch(url, json)
text
Request a text response without a signature.
const result = await hb.text(device, path)
json
Request a json response without a signature.
const result = await hb.json(device, path)
send
Send a request with a signed http message. data
will be set to http body with auto-generated content-digest
and inline-body-key
in the header.
const result = await hb.send({ ...headers })
spawn
Spawn a process.
const { pid } = await hb.spawn({ ...tags })
schedule
Equivalent to sending a message.
const { slot } = await hb.schedule({ tags, data, pid, action })
compute
Equivalent to getting a result.
const res = await hb.compute({ pid, slot })
const { Messages, Spawns, Assignments, Output } = res
messages
Get messages on a process. You can get next messages by message.next
.
const msgs = await hb.messages({ pid, from, to })
for(const item of msgs.edges){
const { cursor: slot, node: { assignment, message } } = item
}
if(msgs.next) const msgs2 = await msg.next()
pid
: a process idfrom
|to
: the slot numbers. Messages are marked by integer on HB, not by txid.0
is theType=Process
message that spawed the process.to
is inclusive. Both are optional.
Legacynet AOS
spawnLegacy
Spawn Legacynet AOS.
const { pid } = await hb.spawnLegacy({ tags, data })
scheduleLegacy
Schedule a legacynet aos message.
const res = await hb.scheduleLegacy({ tags, data, pid, action })
const { Messages, Spawns, Assignments, Output } = res
computeLegacy
Compute legacynet AOS state.
const res = await hb.computeLegacy({ pid, slot })
const { Messages, Spawns, Assignments, Output } = res
dryrun
dryrun
is only for legacynet AOS. Mainnet AOS disabled this feature for a performance reason.
const res = await hb.dryrun({ tags, data, pid, action })
const { Messages, Spawns, Assignments, Output } = res
Mainnet AOS
Mainnet AOS processes have dedicated API.
spawnAOS
const { pid } = await hb.spawnAOS()
messageAOS
messageAOS
= schedule
+ computeAOS
.
const result = await hb.messageAOS({ pid, action, tags, data })
computeAOS
const result = await hb.computeAOS({ pid, slot })
Devices
Each device has its own API based on the paths.
meta
const info = await hb.meta.info()
const address = await hb.meta.info({ key: "address" })
await hb.meta.info({ method: "POST", configA: "valA" }) // update node config
const build = await hb.meta.build()
hyperbuddy
const metrics = await hb.hyperbuddy.metrics()
More devices will be added soon.