Skip to content

lukeburns/autoisolate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

autoisolate

script-addressed autobase executed with isolated vm.

for building composable autobase-protocols

usage

const toUppercaseAddress = 'hyp1pqdnvkw95qufp9czn8540f2lazdecn2cht475n08zaz6fkpatq2tshqltq2'

const base = new Autobase(opts)
const isolate = new Autoisolate(toUppercaseAddress, { 
  autobase: base,
  isolate: new Isolate()
})

await isolate.ready()
await base.append('hello world')
const node = await base.view.get(0)

console.log(node.value.toString()) // HELLO WORLD

where toUppercaseAddress is the the key used to lookup the apply function for an autobase from the DHT

const script = dedent`
  function apply (batch) {
    return batch.map(({ value }) => Buffer.from(Buffer.toString(value).toUpperCase()))
  }
`
const toUppercaseAddress = Autoisolate.encodeScript(script)
const { value } = await dht.immutableGet(toUppercaseAddress)
console.log(script === value.toString()) // true

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published