From 28d507f0433a82c551d3f80b0bdb0b93fb9ad89c Mon Sep 17 00:00:00 2001 From: Jonathan Bennett Date: Sun, 21 Dec 2025 14:25:12 -0600 Subject: [PATCH] Broadcast root hash for an empty chain --- src/modules/Native/StoreForwardPlusPlus.cpp | 22 +++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/modules/Native/StoreForwardPlusPlus.cpp b/src/modules/Native/StoreForwardPlusPlus.cpp index 03a0bf5e7..100807520 100644 --- a/src/modules/Native/StoreForwardPlusPlus.cpp +++ b/src/modules/Native/StoreForwardPlusPlus.cpp @@ -186,7 +186,25 @@ int32_t StoreForwardPlusPlusModule::runOnce() link_object chain_end = getChainEndLinkObject(root_hash_bytes, 32); if (chain_end.rx_time == 0) { + // TODO: we want to do the announce anyway, even if we have no message on the chain yet LOG_WARN("Store and Forward++ database lookup returned null"); + + // first attempt at a chain-only announce with no messages + meshtastic_StoreForwardPlusPlus storeforward = meshtastic_StoreForwardPlusPlus_init_zero; + storeforward.sfpp_message_type = meshtastic_StoreForwardPlusPlus_SFPP_message_type_CANON_ANNOUNCE; + storeforward.root_hash.size = 32; + memcpy(storeforward.root_hash.bytes, root_hash_bytes, 32); + + storeforward.encapsulated_rxtime = 0; + // storeforward. + meshtastic_MeshPacket *p = allocDataProtobuf(storeforward); + p->to = NODENUM_BROADCAST; + p->decoded.want_response = false; + p->priority = meshtastic_MeshPacket_Priority_BACKGROUND; + p->channel = 0; + LOG_INFO("Send packet to mesh"); + service->sendToMesh(p, RX_SRC_LOCAL, true); + return 60 * 60 * 1000; } @@ -287,6 +305,10 @@ bool StoreForwardPlusPlusModule::handleReceivedProtobuf(const meshtastic_MeshPac addRootToMappings(router->p_encrypted->channel, t->root_hash.bytes); LOG_WARN("Adding root hash to mappings"); } + if (t->encapsulated_rxtime == 0) { + LOG_WARN("No encapsulated time, conclude the chain is empty"); + return true; + } // get tip of chain for this channel link_object chain_end = getChainEndLinkObject(t->root_hash.bytes, t->root_hash.size);