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
throughout the node's life as new blocks appear.
```json
{
"block_processed": {
"block": {
"hash": "000000000000000000034bdb3c01652a0aa8f63d32f949313d55af2509f9d245",
"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));
/* 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. */

View file

@ -582,8 +582,8 @@ void notify_balance_snapshot(struct lightningd *ld,
plugins_notify(ld->plugins, take(n));
}
static void block_processed_notification_serialize(struct json_stream *stream,
struct block *block)
static void block_added_notification_serialize(struct json_stream *stream,
struct block *block)
{
json_object_start(stream, "block");
json_add_string(stream, "hash",
@ -592,17 +592,17 @@ static void block_processed_notification_serialize(struct json_stream *stream,
json_object_end(stream);
}
REGISTER_NOTIFICATION(block_processed,
block_processed_notification_serialize);
REGISTER_NOTIFICATION(block_added,
block_added_notification_serialize);
void notify_block_processed(struct lightningd *ld,
const struct block *block)
void notify_block_added(struct lightningd *ld,
const struct block *block)
{
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 =
jsonrpc_notification_start(NULL, "block_processed");
jsonrpc_notification_start(NULL, "block_added");
serialize(n->stream, block);
jsonrpc_notification_end(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,
const struct balance_snapshot *snap);
void notify_block_processed(struct lightningd *ld,
const struct block *block);
void notify_block_added(struct lightningd *ld,
const struct block *block);
void notify_openchannel_peer_sigs(struct lightningd *ld,
const struct channel_id *cid,

View file

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

View file

@ -2925,11 +2925,11 @@ def test_commando_badrune(node_factory):
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"""
base = bitcoind.rpc.getblockchaininfo()["blocks"]
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})
ret = l1.rpc.call("blockscatched")