Go to the documentation of this file.
5 #ifndef UAVCAN_PROTOCOL_DYNAMIC_NODE_ID_SERVER_DISTRIBUTED_LOG_HPP_INCLUDED
6 #define UAVCAN_PROTOCOL_DYNAMIC_NODE_ID_SERVER_DISTRIBUTED_LOG_HPP_INCLUDED
16 namespace dynamic_node_id_server
45 str.appendFormatted(
"%d",
int(index));
77 out_entry.node_id =
static_cast<uint8_t>(node_id);
106 temp.node_id =
static_cast<uint8_t>(node_id);
108 return (temp == entry) ? 0 : -ErrFailure;
137 if (stored_index != 0)
163 UAVCAN_TRACE(
"dynamic_node_id_server::distributed::Log",
"Initializing empty storage");
169 UAVCAN_TRACE(
"dynamic_node_id_server::distributed::Log",
"Failed to read last index");
188 UAVCAN_TRACE(
"dynamic_node_id_server::distributed::Log",
"Failed to read entry at index %u: %d",
189 unsigned(index), result);
233 UAVCAN_TRACE(
"dynamic_node_id_server::distributed::Log",
"New entry, index %u, node ID %u, term %u",
234 unsigned(
last_index_),
unsigned(entry.node_id),
unsigned(entry.term));
246 if (((index) >=
Capacity) || (index <= 0))
251 uint32_t new_last_index = index - 1U;
263 if (new_last_index != index - 1U)
267 UAVCAN_TRACE(
"dynamic_node_id_server::distributed::Log",
"Entries removed, last index %u --> %u",
310 #endif // Include guard
int initEmptyLogStorage()
StorageType< Entry::FieldTypes::term >::Type Term
bool isOtherLogUpToDate(Index other_last_index, Term other_last_term) const
int writeEntryToStorage(Index index, const Entry &entry)
static IStorageBackend::String makeEntryKey(Index index, const char *postfix)
const Entry * getEntryAtIndex(Index index) const
int setAndGetBack(const IStorageBackend::String &key, uint32_t &inout_value)
int get(const IStorageBackend::String &key, uint32_t &out_value) const
#define UAVCAN_TRACE(...)
static IStorageBackend::String getLastIndexKey()
TraceRaftLogLastIndexRestored
int append(const Entry &entry)
static const uavcan::int16_t ErrLogic
Internal logic error.
int removeEntriesWhereIndexGreaterOrEqual(Index index)
int readEntryFromStorage(Index index, Entry &out_entry)
virtual void onEvent(TraceCode event_code, int64_t event_argument)=0
int removeEntriesWhereIndexGreater(Index index)
Log(IStorageBackend &storage, IEventTracer &tracer)
IStorageBackend & storage_
virtual String get(const String &key) const =0
Index getLastIndex() const