Interface: JobsProgram
Jobs program interface
Methods
all()
all(filters?, checkRuns?): Promise<Job[]>;Fetch all job accounts
Parameters
| Parameter | Type |
|---|---|
filters? | { market?: Address; node?: Address; project?: Address; state?: JobState; } |
filters.market? | Address |
filters.node? | Address |
filters.project? | Address |
filters.state? | JobState |
checkRuns? | boolean |
Returns
get()
get(addr, checkRun?): Promise<Job>;Fetch a job account by address
Parameters
| Parameter | Type |
|---|---|
addr | Address |
checkRun? | boolean |
Returns
market()
market(addr): Promise<Market>;Fetch a market account by address
Parameters
| Parameter | Type |
|---|---|
addr | Address |
Returns
markets()
markets(): Promise<Market[]>;Fetch all market accounts
Returns
monitor()
monitor(): Promise<[AsyncIterable<SimpleMonitorEvent, any, any>, () => void]>;Monitor program account updates using async iterators. Automatically merges run account data into job account updates. Returns a tuple of [eventStream, stopFunction].
Returns
Promise<[AsyncIterable<SimpleMonitorEvent, any, any>, () => void]>
Example
const [eventStream, stop] = await jobsProgram.monitor();
for await (const event of eventStream) {
if (event.type === MonitorEventType.JOB) {
console.log('Job updated:', event.data.address);
} else if (event.type === MonitorEventType.MARKET) {
console.log('Market updated:', event.data.address);
}
}monitorDetailed()
monitorDetailed(): Promise<[AsyncIterable<MonitorEvent, any, any>, () => void]>;Monitor program account updates with detailed events for each account type. Provides separate events for job, market, and run accounts. Returns a tuple of [eventStream, stopFunction].
Returns
Promise<[AsyncIterable<MonitorEvent, any, any>, () => void]>
Example
const [eventStream, stop] = await jobsProgram.monitorDetailed();
for await (const event of eventStream) {
switch (event.type) {
case MonitorEventType.JOB:
console.log('Job updated:', event.data.address);
break;
case MonitorEventType.MARKET:
console.log('Market updated:', event.data.address);
break;
case MonitorEventType.RUN:
console.log('Run updated:', event.data.address);
break;
}
}multiple()
multiple(addresses, checkRuns?): Promise<Job[]>;Fetch multiple job accounts by address
Parameters
| Parameter | Type |
|---|---|
addresses | Address[] |
checkRuns? | boolean |
Returns
post()
post(params): Promise<
| AssignInstruction<Address, string, string, string, string, string, string, string, string, string, string, string, string, string, []>
| ListInstruction<Address, string, string, string, string, string, string, string, string, string, string, string, string, []>>;Post a new job to the marketplace (can list or assign based on params)
Parameters
| Parameter | Type |
|---|---|
params | | AssignParams | ListParams |
Returns
Promise< | AssignInstruction<Address, string, string, string, string, string, string, string, string, string, string, string, string, string, []> | ListInstruction<Address, string, string, string, string, string, string, string, string, string, string, string, string, []>>
run()
run(addr): Promise<Run>;Fetch a run account by address
Parameters
| Parameter | Type |
|---|---|
addr | Address |
Returns
runs()
runs(filters?): Promise<Run[]>;Fetch all run accounts
Parameters
| Parameter | Type |
|---|---|
filters? | { job?: Address; node?: Address; } |
filters.job? | Address |
filters.node? | Address |
Returns
Properties
| Property | Type | Description |
|---|---|---|
assign | Assign | Assign a job directly to a host node |
close | Close | Close a market |
closeMarket | Close | Close a market (synonym for close) |
complete | Complete | Post the result for a JobAccount to finish it and get paid. |
createMarket | Open | Create a new market (synonym for open) |
delist | Delist | Delist a job from the marketplace |
end | End | Stop a running job |
extend | Extend | Extend an existing job's timeout |
finish | Finish | Complete a job that has been stopped. |
list | List | List a new job to the marketplace |
open | Open | Create a new market |
quit | Quit | Quit a JobAccount that you have started. |
stop | Stop | Exit the node queue |
work | Work | Enters the MarketAccount queue, or create a RunAccount. |