Make ZMQ Pub events a single object instead of array

This commit is contained in:
Lee *!* Clagett 2023-07-06 09:58:44 -04:00
parent e6a37fd114
commit 935acaacc5

View file

@ -247,16 +247,15 @@ namespace lws
} }
} }
struct zmq_index struct zmq_index_single
{ {
const std::uint64_t index; const std::uint64_t index;
const boost::string_ref pattern; const db::webhook_tx_confirmation& event;
const epee::span<const db::webhook_tx_confirmation> data;
}; };
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<const db::webhook_tx_confirmation> events) void send_via_zmq(rpc::client& client, const epee::span<const db::webhook_tx_confirmation> events)
@ -278,7 +277,10 @@ namespace lws
{ {
// make sure the event is queued to zmq in order. // make sure the event is queued to zmq in order.
const boost::unique_lock<boost::mutex> guard{ordering.sync}; const boost::unique_lock<boost::mutex> guard{ordering.sync};
const zmq_index index{ordering.current++, "handle-payment-webhook", events};
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"); MINFO("Sending ZMQ/RMQ PUB topics json-full-hooks and msgpack-full-hooks");
expect<void> result = success(); expect<void> result = success();
if (!(result = client.publish<wire::json>("json-full-hooks:", index))) if (!(result = client.publish<wire::json>("json-full-hooks:", index)))
@ -287,6 +289,7 @@ namespace lws
MERROR("Failed to serialize+send msgpack-full-hooks: " << result.error().message()); MERROR("Failed to serialize+send msgpack-full-hooks: " << result.error().message());
} }
} }
}
struct by_height struct by_height
{ {