[era] era_detail

This commit is contained in:
Joe Thornber 2013-11-19 10:24:31 +00:00
parent 983a5e84e6
commit 804108fb73
2 changed files with 72 additions and 0 deletions

36
era/era_detail.cc Normal file
View File

@ -0,0 +1,36 @@
#include "era/era_detail.h"
#include <stdexcept>
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<uint32_t>(disk.nr_bits);
unpack_hash_detail(disk.hash_fns_and_probes, value.hash1, value.hash2, value.nr_probes);
value.bloom_root = to_cpu<uint64_t>(disk.bloom_root);
}
void
era_detail_traits::pack(value_type const &value, disk_type &disk)
{
disk.nr_bits = to_disk<le32>(value.nr_bits);
disk.hash_fns_and_probes = pack_hash_detail(value.hash1, value.hash2, value.nr_probes);
disk.bloom_root = to_disk<le64>(value.bloom_root);
}
//----------------------------------------------------------------

36
era/era_detail.h Normal file
View File

@ -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