2013-11-19 15:54:31 +05:30
|
|
|
#ifndef ERA_DETAIL_H
|
|
|
|
#define ERA_DETAIL_H
|
|
|
|
|
|
|
|
#include "base/endian_utils.h"
|
2014-01-15 05:29:12 +05:30
|
|
|
#include "persistent-data/transaction_manager.h"
|
2013-11-19 15:54:31 +05:30
|
|
|
|
|
|
|
//----------------------------------------------------------------
|
|
|
|
|
|
|
|
namespace era {
|
|
|
|
struct era_detail_disk {
|
|
|
|
base::le32 nr_bits;
|
2014-01-30 03:07:25 +05:30
|
|
|
base::le64 writeset_root;
|
2013-11-19 16:18:39 +05:30
|
|
|
} __attribute__ ((packed));
|
2013-11-19 15:54:31 +05:30
|
|
|
|
|
|
|
struct era_detail {
|
2014-06-26 20:05:48 +05:30
|
|
|
era_detail()
|
|
|
|
: nr_bits(0),
|
|
|
|
writeset_root(0) {
|
|
|
|
}
|
|
|
|
|
2013-11-19 15:54:31 +05:30
|
|
|
uint32_t nr_bits;
|
2014-01-30 03:07:25 +05:30
|
|
|
uint64_t writeset_root;
|
2013-11-19 15:54:31 +05:30
|
|
|
};
|
|
|
|
|
2014-01-15 05:29:12 +05:30
|
|
|
struct era_detail_ref_counter {
|
2014-08-07 20:13:01 +05:30
|
|
|
era_detail_ref_counter(persistent_data::transaction_manager::ptr tm)
|
|
|
|
: tm_(tm) {
|
2014-01-23 06:16:03 +05:30
|
|
|
}
|
2014-01-15 05:29:12 +05:30
|
|
|
|
2014-08-07 20:13:01 +05:30
|
|
|
void inc(era_detail const &d) {
|
|
|
|
tm_->get_sm()->inc(d.writeset_root);
|
2014-01-23 06:16:03 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
void dec(persistent_data::block_address b) {
|
2014-08-07 20:13:01 +05:30
|
|
|
// I don't think we ever do this in the tools
|
|
|
|
throw std::runtime_error("not implemented");
|
2014-01-23 06:16:03 +05:30
|
|
|
}
|
2014-08-07 20:13:01 +05:30
|
|
|
|
|
|
|
private:
|
|
|
|
persistent_data::transaction_manager::ptr tm_;
|
2014-01-15 05:29:12 +05:30
|
|
|
};
|
|
|
|
|
2013-11-19 15:54:31 +05:30
|
|
|
struct era_detail_traits {
|
|
|
|
typedef era_detail_disk disk_type;
|
|
|
|
typedef era_detail value_type;
|
2014-01-15 05:29:12 +05:30
|
|
|
typedef era_detail_ref_counter ref_counter;
|
2013-11-19 15:54:31 +05:30
|
|
|
|
|
|
|
static void unpack(disk_type const &disk, value_type &value);
|
|
|
|
static void pack(value_type const &value, disk_type &disk);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------
|
|
|
|
|
|
|
|
#endif
|