mirror of
https://github.com/ratspeak/microReticulum
synced 2026-11-22 23:10:38 +00:00
Fix boot loop: Identity::remember() stale timestamp causes cull crash
std::map::insert() is a no-op for existing keys, so identities loaded from persisted known_destinations kept their old timestamps. When cull_known_destinations() ran after insert, it removed the "stale" entry that was just validated — causing Identity::recall() to fail and hexhash() to assert on a null identity. Fix: use insert_or_assign() to always refresh the timestamp. Also reverts the dead-code needs_transport_headers() virtual method (the else-if at Transport.cpp:826 is unreachable because hops>=1 already catches hops==1 in the preceding if block).
This commit is contained in:
1 parent
79271a018b
commit
af9fbab780
3 files changed
+5
-5
No files matched your search
+4
-1
@@ -200,7 +200,10 @@ Can be used to load previously created and saved identities into Reticulum.
|
||||
//p _known_destinations[destination_hash] = {OS::time(), packet_hash, public_key, app_data};
|
||||
// CBA ACCUMULATES
|
||||
try {
|
||||
_known_destinations.insert({destination_hash, {OS::time(), packet_hash, public_key, app_data}});
|
||||
// Use insert_or_assign so the timestamp is always refreshed.
|
||||
// Plain insert() is a no-op for existing keys, leaving the old
|
||||
// timestamp — cull then removes the "stale" entry we just validated.
|
||||
_known_destinations.insert_or_assign(destination_hash, IdentityEntry{OS::time(), packet_hash, public_key, app_data});
|
||||
// CBA IMMEDIATE CULL
|
||||
cull_known_destinations();
|
||||
}
|
||||
|
||||
@@ -83,8 +83,6 @@ namespace RNS {
|
||||
bool _is_connected_to_shared_instance = false;
|
||||
bool _is_local_shared_instance = false;
|
||||
|
||||
public:
|
||||
virtual bool needs_transport_headers() const { return _is_connected_to_shared_instance; }
|
||||
//Bytes _hash;
|
||||
HInterface _parent_interface;
|
||||
//Transport& _owner;
|
||||
@@ -158,7 +156,6 @@ namespace RNS {
|
||||
inline void stop() { assert(_impl); return _impl->stop(); }
|
||||
inline void loop() { assert(_impl); return _impl->loop(); }
|
||||
inline const Bytes get_hash() const { assert(_impl); return _impl->get_hash(); }
|
||||
inline bool needs_transport_headers() const { assert(_impl); return _impl->needs_transport_headers(); }
|
||||
void process_announce_queue();
|
||||
|
||||
// CBA ACCUMULATES
|
||||
|
||||
+1
-1
@@ -823,7 +823,7 @@ Transport::DestinationEntry empty_destination_entry;
|
||||
// are "behind" a shared instance, we need to get that instance
|
||||
// to transport it onto the network.
|
||||
//elif Transport.destination_table[packet.destination_hash][2] == 1 and Transport.owner.is_connected_to_shared_instance:
|
||||
else if (destination_entry._hops == 1 && (_owner.is_connected_to_shared_instance() || outbound_interface.needs_transport_headers())) {
|
||||
else if (destination_entry._hops == 1 && _owner.is_connected_to_shared_instance()) {
|
||||
TRACE("Transport::outbound: Sending packet for directly connected interface to shared instance...");
|
||||
if (packet.header_type() == Type::Packet::HEADER_1) {
|
||||
// Insert packet into transport
|
||||
|
||||
Reference in new issue
Block a user