mirror of
https://github.com/stakwork/sphinx-key.git
synced 2025-12-17 07:14:23 +01:00
core: remove unneeded clones, allocate output buffer once at setup, and reuse same memory block
This commit is contained in:
@@ -87,6 +87,7 @@ pub fn make_event_loop(
|
|||||||
|
|
||||||
// signing loop
|
// signing loop
|
||||||
let dummy_peer = PubKey([0; 33]);
|
let dummy_peer = PubKey([0; 33]);
|
||||||
|
let mut out_buffer: Vec<u8> = Vec::with_capacity(600);
|
||||||
while let Ok(event) = rx.recv() {
|
while let Ok(event) = rx.recv() {
|
||||||
match event {
|
match event {
|
||||||
Event::Connected => {
|
Event::Connected => {
|
||||||
@@ -101,16 +102,18 @@ pub fn make_event_loop(
|
|||||||
//led_tx.send(Status::ConnectingToMqtt).unwrap();
|
//led_tx.send(Status::ConnectingToMqtt).unwrap();
|
||||||
log::info!("GOT A Event::Disconnected msg!");
|
log::info!("GOT A Event::Disconnected msg!");
|
||||||
}
|
}
|
||||||
Event::VlsMessage(ref msg_bytes) => {
|
Event::VlsMessage(msg_bytes) => {
|
||||||
//led_tx.send(Status::Signing).unwrap();
|
//led_tx.send(Status::Signing).unwrap();
|
||||||
|
out_buffer.clear();
|
||||||
let _ret = match sphinx_signer::root::handle(
|
let _ret = match sphinx_signer::root::handle(
|
||||||
&root_handler,
|
&root_handler,
|
||||||
msg_bytes.clone(),
|
msg_bytes,
|
||||||
dummy_peer.clone(),
|
dummy_peer.clone(),
|
||||||
do_log,
|
do_log,
|
||||||
|
&mut out_buffer,
|
||||||
) {
|
) {
|
||||||
Ok(b) => {
|
Ok(()) => {
|
||||||
mqtt.publish(topics::VLS_RETURN, QOS, false, &b)
|
mqtt.publish(topics::VLS_RETURN, QOS, false, &out_buffer)
|
||||||
.expect("could not publish VLS response");
|
.expect("could not publish VLS response");
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user