mirror of
https://github.com/stjet/banani.git
synced 2025-12-29 09:39:23 +00:00
much
get cryptography in order, hex->uint8 fix, work on wallet, work, rpc
This commit is contained in:
29
work.ts
Normal file
29
work.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import type { BlockHash } from "./rpc_types";
|
||||
import type { RPC } from "./rpc";
|
||||
|
||||
export interface WorkProvider {
|
||||
request_work(block_hash: BlockHash): Promise<string>,
|
||||
}
|
||||
|
||||
|
||||
export class RPCWorkProvider {
|
||||
readonly rpc: RPC;
|
||||
|
||||
/** Extra json to send with the rpc payload. Needed for rpc.nano.to's work_generate, unfortunately */
|
||||
extra_payload: Record<string, any> = {};
|
||||
|
||||
constructor(rpc: RPC) {
|
||||
this.rpc = rpc;
|
||||
}
|
||||
|
||||
async request_work(block_hash: BlockHash): Promise<string> {
|
||||
return (await this.rpc.call({
|
||||
action: "work_generate",
|
||||
hash: block_hash,
|
||||
...this.extra_payload,
|
||||
})).work;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user