findPath
@twine-protocol/twine-core v0.1.0 • Docs
twine-js / @twine-protocol/twine-core / findPath
Function: findPath()
findPath(
start
,target
,resolver
):Promise
<Path
|null
>
Find a path between two pulses
This function is a convenience function that uses the crawl
function to find a path between two pulses. It will return a path if one is found, or null if no path is found.
Parameters
Parameter
Type
Description
Returns
Promise
<Path
| null
>
A path if one is found, or null if no path is found
Example
import { findPath } from '@twine-protocol/twine-core'
import { HttpStore } from '@twine-protocol/twine-http-store'
const resolver = new HttpStore('https://someapi.io')
const start = { chain: 'chaincid', pulse: 'startpulsecid' }
const target = { chain: 'chaincid', pulse: 'targetpulsecid' }
const path = await findPath(start, target, resolver)
if (path) {
console.log('Path found:', path)
} else {
console.log('No path found')
}
Defined in
Last updated