diff --git a/era/era_detail.cc b/era/era_detail.cc new file mode 100644 index 0000000..43fbc51 --- /dev/null +++ b/era/era_detail.cc @@ -0,0 +1,36 @@ +#include "era/era_detail.h" + +#include + +using namespace base; +using namespace era; + +//---------------------------------------------------------------- + +namespace { + le32 pack_hash_detail(uint32_t hash1, uint32_t hash2, uint32_t nr_probes) { + throw std::runtime_error("not implemented"); + } + + void unpack_hash_detail(le32 packed, uint32_t &hash1, uint32_t &hash2, uint32_t &nr_probes) { + throw std::runtime_error("not implemented"); + } +} + +void +era_detail_traits::unpack(disk_type const &disk, value_type &value) +{ + value.nr_bits = to_cpu(disk.nr_bits); + unpack_hash_detail(disk.hash_fns_and_probes, value.hash1, value.hash2, value.nr_probes); + value.bloom_root = to_cpu(disk.bloom_root); +} + +void +era_detail_traits::pack(value_type const &value, disk_type &disk) +{ + disk.nr_bits = to_disk(value.nr_bits); + disk.hash_fns_and_probes = pack_hash_detail(value.hash1, value.hash2, value.nr_probes); + disk.bloom_root = to_disk(value.bloom_root); +} + +//---------------------------------------------------------------- diff --git a/era/era_detail.h b/era/era_detail.h new file mode 100644 index 0000000..1b907fb --- /dev/null +++ b/era/era_detail.h @@ -0,0 +1,36 @@ +#ifndef ERA_DETAIL_H +#define ERA_DETAIL_H + +#include "base/endian_utils.h" + +//---------------------------------------------------------------- + +namespace era { + struct era_detail_disk { + base::le32 nr_bits; + base::le32 hash_fns_and_probes; + base::le64 bloom_root; + }; + + struct era_detail { + uint32_t nr_bits; + + uint32_t hash1; + uint32_t hash2; + uint32_t nr_probes; + + uint64_t bloom_root; + }; + + struct era_detail_traits { + typedef era_detail_disk disk_type; + typedef era_detail value_type; + + static void unpack(disk_type const &disk, value_type &value); + static void pack(value_type const &value, disk_type &disk); + }; +} + +//---------------------------------------------------------------- + +#endif