Avoids confusing the user and removes weirdness with multiple servers
sharing the same storage. Does leak the registration for the old ID but
in the unlikely event the table fills up the user can simply reset the
database.
We keep the check for an existing registration to avoid dirtying the
storage every boot unnecessarily. We also factor out the deletion of an
existing registration (which is very unlikely but technically possible)
to save some flash.
Rename NodeData to NodeRecord to provide a more specific name and match
the record term used in the comments. Also nominally allows stuff to be
associated with the nodes that's not the record, as expanding the record
is hard.
Additionally, rename the `hwid` field to `uid` as that's what's used in
the rest of the code.
All the higher level database operations need to be locked for the whole
duration of the operation, so nobody should be using the lower-level
tasks or raw read/write functions. We can also remove the locks from
them.
The database can now safely be used by multiple servers.
Must be locked for the whole operation due to the find free/add
read-modify-write.
Preserves the previous behavior of sending back an ID of 0 in case of
allocation failure, for better or worse.
There is (currently) only one storage area that is used by all servers,
so it needs to be managed by its own class shared among them.
The occupied mask is also moved as it reflects the storage contents and
so can't be stored by each server.
Put documentation with each bitmask and use the object directly. Node ID
range checks can be removed as the bitmask itself checks and we don't
expect to trip them.
Substantially cleans up the code.
The StorageManager read_block/write_block methods only return failure if
an out of bounds access is performed. Assert statically that this does
not happen.
Also remove the now-impossible failed to add node state.