Skip to content

Commit

Permalink
Hack channel loader to support both string and hash_t keys
Browse files Browse the repository at this point in the history
Due to an error in not adpating the dump writer correctly, it is possible
that dump files exist in an unsupported format (with keys written as
hash_t). We need to temporarily support loading both formats.
  • Loading branch information
Gavin Norman authored and nemanja-boric-sociomantic committed Jul 10, 2018
1 parent 95283de commit b2a9f41
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/dhtnode/storage/DumpManager.d
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,17 @@ public class DumpManager
ref ulong out_of_range, ref ulong invalid, ref ulong too_big,
ref ulong empty )
{
if ( !Hash.isHash(key) )
// TODO: this support for reading hash_t keys from the dump file is a
// hack to work around an error. It can be removed in the next release
// (or the dump format adapted fully to write keys as hash_t.)
char[hash_t.sizeof * 2] key_str;
if ( key.length == hash_t.sizeof )
{
auto hash_key = *(cast(hash_t*)key.ptr);
Hash.toHexString(hash_key, key_str);
key = key_str;
}
else if ( !Hash.isHash(key) )
{
log.error("Encountered invalid non-hexadecimal key in channel '{}': "
"{} -- ignored", storage.id, key);
Expand Down

0 comments on commit b2a9f41

Please sign in to comment.