rename block_processed to block_added

This commit is contained in:
fiatjaf
2022-09-12 17:43:54 -03:00
committed by neil saitug
parent 9b33a921f0
commit 1ef8fb7ef8
6 changed files with 17 additions and 17 deletions

View File

@@ -873,14 +873,14 @@ current accounts (`account_id` matches the `account_id` emitted from
} }
``` ```
### `block_processed` ### `block_added`
Emitted after each block is received from bitcoind, either during the initial sync or Emitted after each block is received from bitcoind, either during the initial sync or
throughout the node's life as new blocks appear. throughout the node's life as new blocks appear.
```json ```json
{ {
"block_processed": { "block": {
"hash": "000000000000000000034bdb3c01652a0aa8f63d32f949313d55af2509f9d245", "hash": "000000000000000000034bdb3c01652a0aa8f63d32f949313d55af2509f9d245",
"height": 753304 "height": 753304
} }

View File

@@ -823,7 +823,7 @@ static void get_new_block(struct bitcoind *bitcoind,
add_tip(topo, new_block(topo, blk, topo->tip->height + 1)); add_tip(topo, new_block(topo, blk, topo->tip->height + 1));
/* tell plugins a new block was processed */ /* tell plugins a new block was processed */
notify_block_processed(topo->ld, topo->tip); notify_block_added(topo->ld, topo->tip);
} }
/* Try for next one. */ /* Try for next one. */

View File

@@ -582,8 +582,8 @@ void notify_balance_snapshot(struct lightningd *ld,
plugins_notify(ld->plugins, take(n)); plugins_notify(ld->plugins, take(n));
} }
static void block_processed_notification_serialize(struct json_stream *stream, static void block_added_notification_serialize(struct json_stream *stream,
struct block *block) struct block *block)
{ {
json_object_start(stream, "block"); json_object_start(stream, "block");
json_add_string(stream, "hash", json_add_string(stream, "hash",
@@ -592,17 +592,17 @@ static void block_processed_notification_serialize(struct json_stream *stream,
json_object_end(stream); json_object_end(stream);
} }
REGISTER_NOTIFICATION(block_processed, REGISTER_NOTIFICATION(block_added,
block_processed_notification_serialize); block_added_notification_serialize);
void notify_block_processed(struct lightningd *ld, void notify_block_added(struct lightningd *ld,
const struct block *block) const struct block *block)
{ {
void (*serialize)(struct json_stream *, void (*serialize)(struct json_stream *,
const struct block *block) = block_processed_notification_gen.serialize; const struct block *block) = block_added_notification_gen.serialize;
struct jsonrpc_notification *n = struct jsonrpc_notification *n =
jsonrpc_notification_start(NULL, "block_processed"); jsonrpc_notification_start(NULL, "block_added");
serialize(n->stream, block); serialize(n->stream, block);
jsonrpc_notification_end(n); jsonrpc_notification_end(n);
plugins_notify(ld->plugins, take(n)); plugins_notify(ld->plugins, take(n));

View File

@@ -87,8 +87,8 @@ void notify_coin_mvt(struct lightningd *ld,
void notify_balance_snapshot(struct lightningd *ld, void notify_balance_snapshot(struct lightningd *ld,
const struct balance_snapshot *snap); const struct balance_snapshot *snap);
void notify_block_processed(struct lightningd *ld, void notify_block_added(struct lightningd *ld,
const struct block *block); const struct block *block);
void notify_openchannel_peer_sigs(struct lightningd *ld, void notify_openchannel_peer_sigs(struct lightningd *ld,
const struct channel_id *cid, const struct channel_id *cid,

View File

@@ -8,8 +8,8 @@ plugin = Plugin()
blocks_catched = [] blocks_catched = []
@plugin.subscribe("block_processed") @plugin.subscribe("block_added")
def notify_block_processed(plugin, block, **kwargs): def notify_block_added(plugin, block, **kwargs):
global blocks_catched global blocks_catched
blocks_catched.append(block["height"]) blocks_catched.append(block["height"])

View File

@@ -2925,11 +2925,11 @@ def test_commando_badrune(node_factory):
pass pass
def test_block_processed_notifications(node_factory, bitcoind): def test_block_added_notifications(node_factory, bitcoind):
"""Test if a plugin gets notifications when a new block is found""" """Test if a plugin gets notifications when a new block is found"""
base = bitcoind.rpc.getblockchaininfo()["blocks"] base = bitcoind.rpc.getblockchaininfo()["blocks"]
plugin = [ plugin = [
os.path.join(os.getcwd(), "tests/plugins/block_processed.py"), os.path.join(os.getcwd(), "tests/plugins/block_added.py"),
] ]
l1 = node_factory.get_node(options={"plugin": plugin}) l1 = node_factory.get_node(options={"plugin": plugin})
ret = l1.rpc.call("blockscatched") ret = l1.rpc.call("blockscatched")