Capture all broadcast messages coming from chia_farmer
service.
You need to create Websocket connection before subscribing websocket messages.
const {getDaemon} = require("chia-agent");
const {on_message_from_farmer} = require("chia-agent/api/ws");
const daemon = getDaemon(); // This is the websocket connection handler
await daemon.connect(); // connect to local daemon using config file.
// Capture all messages from `chia_farmer`
const unsubscribe = await on_message_from_farmer(daemon, (event) => {
console.log(e.data);
// Close connection if you don't need it anymore.
if(...){
unsubscribe(); // stop listening to this ws message.
}
});
...
Capture broadcast message of command get_connections
from chia_farmer
service.
const {getDaemon} = require("chia-agent");
const {on_get_connections} = require("chia-agent/api/ws/farmer");
const daemon = getDaemon();
await daemon.connect();
const unsubscribe = await on_get_connections(daemon, (event) => {
// Format of `event` object is described below.
...
});
...
unsubscribe(); // Stop subscribing messages
{
origin: "chia_farmer";
command: "get_connections";
ack: boolean;
data: /*See below*/;
request_id: string;
destination: "wallet_ui";
}
{
connections: TConnectionGeneral[];
}
For content of TConnectionGeneral
,
see https://github.com/Chia-Mine/chia-agent/blob/main/src/api/types.ts
Capture broadcast message of command new_farming_info
from chia_farmer
service.
const {getDaemon} = require("chia-agent");
const {on_new_farming_info} = require("chia-agent/api/ws");
const daemon = getDaemon();
await daemon.connect();
const unsubscribe = await on_new_farming_info(daemon, (event) => {
// Format of `event` object is described below.
...
});
...
unsubscribe(); // Stop subscribing messages
{
origin: "chia_farmer";
command: "new_farming_info";
ack: boolean;
data: /*See below*/;
request_id: string;
destination: "wallet_ui";
}
{
farming_info: {
challenge_hash: bytes32;
signage_point: bytes32;
passed_filter: uint32;
proofs: uint32;
total_plots: uint32;
timestamp: uint64;
node_id: bytes32;
lookup_time: uint64;
}
}
Capture broadcast message of command new_signage_point
from chia_farmer
service.
const {getDaemon} = require("chia-agent");
const {on_new_signage_point} = require("chia-agent/api/ws");
const daemon = getDaemon();
await daemon.connect();
const unsubscribe = await on_new_signage_point(daemon, (event) => {
// Format of `event` object is described below.
...
});
...
unsubscribe(); // Stop subscribing messages
{
origin: "chia_farmer";
command: "new_signage_point";
ack: boolean;
data: /*See below*/;
request_id: string;
destination: "wallet_ui";
}
{
proofs: ProofOfSpace[];
signage_point: NewSignagePoint;
missing_signage_points: Optional<[uint64, uint32]>;
}
For content of ProofOfSpace
,
see https://github.com/Chia-Mine/chia-agent/blob/main/src/api/chia_rs/chia-protocol/proof_of_space.ts
For content of NewSignagePoint
see https://github.com/Chia-Mine/chia-agent/blob/main/src/api/chia/protocols/farmer_protocol.ts
Capture broadcast message of command on_harvester_update
from chia_farmer
service.
const {getDaemon} = require("chia-agent");
const {on_harvester_update} = require("chia-agent/api/ws");
const daemon = getDaemon();
await daemon.connect();
const unsubscribe = await on_harvester_update(daemon, (event) => {
// Format of `event` object is described below.
...
});
...
unsubscribe(); // Stop subscribing messages
{
origin: "chia_farmer";
command: "harvester_update";
ack: boolean;
data: /*See below*/;
request_id: string;
destination: "wallet_ui";
}
{
connection: {
node_id: bytes32;
host: str;
port: int;
};
plots: int;
failed_to_open_filenames: int;
no_key_filenames: int;
duplicates: int;
total_plot_size: int;
syncing: {
initial: bool;
plot_files_processed: uint32;
plot_files_total: uint32;
} | None;
last_sync_time: Optional<float>;
}
For content of Plot
,
see https://github.com/Chia-Mine/chia-agent/blob/main/src/api/chia/protocols/harvester_protocol.ts
Capture broadcast message of command on_harvester_removed
from chia_farmer
service.
const {getDaemon} = require("chia-agent");
const {on_harvester_removed} = require("chia-agent/api/ws");
const daemon = getDaemon();
await daemon.connect();
const unsubscribe = await on_harvester_removed(daemon, (event) => {
// Format of `event` object is described below.
...
});
...
unsubscribe(); // Stop subscribing messages
{
origin: "chia_farmer";
command: "harvester_removed";
ack: boolean;
data: /*See below*/;
request_id: string;
destination: "wallet_ui";
}
{
node_id: bytes32;
}
Capture broadcast message of command on_proof
from chia_farmer
service.
const {getDaemon} = require("chia-agent");
const {on_proof} = require("chia-agent/api/ws");
const daemon = getDaemon();
await daemon.connect();
const unsubscribe = await on_proof(daemon, (event) => {
// Format of `event` object is described below.
...
});
...
unsubscribe(); // Stop subscribing messages
{
origin: "chia_farmer";
command: "proof";
ack: boolean;
data: /*See below*/;
request_id: string;
destination: "wallet_ui";
}
{
proof: DeclareProofOfSpace;
passed_filter: bool;
}
For content of DeclareProofOfSpace
,
see https://github.com/Chia-Mine/chia-agent/blob/main/src/api/chia/protocols/farmer_protocol.ts
Capture broadcast message of command on_submitted_partial
from chia_farmer
service.
const {getDaemon} = require("chia-agent");
const {on_submitted_partial} = require("chia-agent/api/ws");
const daemon = getDaemon();
await daemon.connect();
const unsubscribe = await on_submitted_partial(daemon, (event) => {
// Format of `event` object is described below.
...
});
...
unsubscribe(); // Stop subscribing messages
{
origin: "chia_farmer";
command: "submitted_partial";
ack: boolean;
data: /*See below*/;
request_id: string;
destination: "wallet_ui" | "metrics";
}
{
launcher_id: str;
pool_url: str;
current_difficulty: uint64;
points_acknowledged_since_start: uint64;
points_acknowledged_24h: Array<[float, uint64]>; // [(time.time(), new_difficulty)]
}
Capture broadcast message of command on_failed_partial
from chia_farmer
service.
const {getDaemon} = require("chia-agent");
const {on_failed_partial} = require("chia-agent/api/ws");
const daemon = getDaemon();
await daemon.connect();
const unsubscribe = await on_failed_partial(daemon, (event) => {
// Format of `event` object is described below.
...
});
...
unsubscribe(); // Stop subscribing messages
{
origin: "chia_farmer";
command: "failed_partial";
ack: boolean;
data: /*See below*/;
request_id: string;
destination: "wallet_ui";
}
{
p2_singleton_puzzle_hash: str;
}
Capture broadcast message of command on_add_connection
from chia_farmer
service.
const {getDaemon} = require("chia-agent");
const {on_add_connection} = require("chia-agent/api/ws");
const daemon = getDaemon();
await daemon.connect();
const unsubscribe = await on_add_connection(daemon, (event) => {
// Format of `event` object is described below.
...
});
...
unsubscribe(); // Stop subscribing messages
{
origin: "chia_farmer";
command: "on_add_connection";
ack: boolean;
data: /*See below*/;
request_id: string;
destination: "metrics";
}
{}
Capture broadcast message of command on_close_connection
from chia_farmer
service.
const {getDaemon} = require("chia-agent");
const {on_close_connection} = require("chia-agent/api/ws");
const daemon = getDaemon();
await daemon.connect();
const unsubscribe = await on_close_connection(daemon, (event) => {
// Format of `event` object is described below.
...
});
...
unsubscribe(); // Stop subscribing messages
{
origin: "chia_farmer";
command: "on_close_connection";
ack: boolean;
data: /*See below*/;
request_id: string;
destination: "metrics";
}
{}