From 935acaacc5ec4e8ea0da25c533679368e80eea1e Mon Sep 17 00:00:00 2001 From: Lee *!* Clagett Date: Thu, 6 Jul 2023 09:58:44 -0400 Subject: [PATCH] Make ZMQ Pub events a single object instead of array --- src/scanner.cpp | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/scanner.cpp b/src/scanner.cpp index 8bbae18..adc2fa1 100644 --- a/src/scanner.cpp +++ b/src/scanner.cpp @@ -247,16 +247,15 @@ namespace lws } } - struct zmq_index + struct zmq_index_single { const std::uint64_t index; - const boost::string_ref pattern; - const epee::span data; + const db::webhook_tx_confirmation& event; }; - void write_bytes(wire::writer& dest, const zmq_index& self) + void write_bytes(wire::writer& dest, const zmq_index_single& self) { - wire::object(dest, WIRE_FIELD(index), WIRE_FIELD(pattern), WIRE_FIELD(data)); + wire::object(dest, WIRE_FIELD(index), WIRE_FIELD(event)); } void send_via_zmq(rpc::client& client, const epee::span events) @@ -278,13 +277,17 @@ namespace lws { // make sure the event is queued to zmq in order. const boost::unique_lock guard{ordering.sync}; - const zmq_index index{ordering.current++, "handle-payment-webhook", events}; - MINFO("Sending ZMQ/RMQ PUB topics json-full-hooks and msgpack-full-hooks"); - expect result = success(); - if (!(result = client.publish("json-full-hooks:", index))) - MERROR("Failed to serialize+send json-full-hooks: " << result.error().message()); - if (!(result = client.publish("msgpack-full-hooks:", index))) - MERROR("Failed to serialize+send msgpack-full-hooks: " << result.error().message()); + + for (const auto& event : events) + { + const zmq_index_single index{ordering.current++, event}; + MINFO("Sending ZMQ/RMQ PUB topics json-full-hooks and msgpack-full-hooks"); + expect result = success(); + if (!(result = client.publish("json-full-hooks:", index))) + MERROR("Failed to serialize+send json-full-hooks: " << result.error().message()); + if (!(result = client.publish("msgpack-full-hooks:", index))) + MERROR("Failed to serialize+send msgpack-full-hooks: " << result.error().message()); + } } }