adding some hashing methods to db for debugging
This commit is contained in:
parent
bfef440968
commit
45f7819aba
5 changed files with 35 additions and 1 deletions
|
|
@ -87,6 +87,14 @@ namespace graphene { namespace db {
|
||||||
} FC_CAPTURE_AND_RETHROW()
|
} FC_CAPTURE_AND_RETHROW()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual fc::uint128 hash()const override {
|
||||||
|
fc::uint128 result;
|
||||||
|
for( const auto& ptr : _objects )
|
||||||
|
result += ptr.hash();
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
class const_iterator
|
class const_iterator
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
|
||||||
|
|
@ -90,8 +90,19 @@ namespace graphene { namespace chain {
|
||||||
|
|
||||||
const index_type& indices()const { return _indices; }
|
const index_type& indices()const { return _indices; }
|
||||||
|
|
||||||
|
virtual fc::uint128 hash()const override {
|
||||||
|
fc::uint128 result;
|
||||||
|
for( const auto& ptr : _indices )
|
||||||
|
{
|
||||||
|
result += ptr.hash();
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
index_type _indices;
|
fc::uint128 _current_hash;
|
||||||
|
index_type _indices;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -122,6 +122,7 @@ namespace graphene { namespace db {
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void inspect_all_objects(std::function<void(const object&)> inspector)const = 0;
|
virtual void inspect_all_objects(std::function<void(const object&)> inspector)const = 0;
|
||||||
|
virtual fc::uint128 hash()const = 0;
|
||||||
virtual void add_observer( const shared_ptr<index_observer>& ) = 0;
|
virtual void add_observer( const shared_ptr<index_observer>& ) = 0;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,8 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <graphene/db/object_id.hpp>
|
#include <graphene/db/object_id.hpp>
|
||||||
#include <fc/io/raw.hpp>
|
#include <fc/io/raw.hpp>
|
||||||
|
#include <fc/crypto/city.hpp>
|
||||||
|
#include <fc/uint128.hpp>
|
||||||
|
|
||||||
namespace graphene { namespace db {
|
namespace graphene { namespace db {
|
||||||
|
|
||||||
|
|
@ -67,6 +69,7 @@ namespace graphene { namespace db {
|
||||||
virtual void move_from( object& obj ) = 0;
|
virtual void move_from( object& obj ) = 0;
|
||||||
virtual variant to_variant()const = 0;
|
virtual variant to_variant()const = 0;
|
||||||
virtual vector<char> pack()const = 0;
|
virtual vector<char> pack()const = 0;
|
||||||
|
virtual fc::uint128 hash()const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -91,6 +94,10 @@ namespace graphene { namespace db {
|
||||||
}
|
}
|
||||||
virtual variant to_variant()const { return variant( static_cast<const DerivedClass&>(*this) ); }
|
virtual variant to_variant()const { return variant( static_cast<const DerivedClass&>(*this) ); }
|
||||||
virtual vector<char> pack()const { return fc::raw::pack( static_cast<const DerivedClass&>(*this) ); }
|
virtual vector<char> pack()const { return fc::raw::pack( static_cast<const DerivedClass&>(*this) ); }
|
||||||
|
virtual fc::uint128 hash()const {
|
||||||
|
auto tmp = this->pack();
|
||||||
|
return fc::city_hash_crc_128( tmp.data(), tmp.size() );
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef flat_map<uint8_t, object_id_type> annotation_map;
|
typedef flat_map<uint8_t, object_id_type> annotation_map;
|
||||||
|
|
|
||||||
|
|
@ -92,6 +92,13 @@ namespace graphene { namespace db {
|
||||||
}
|
}
|
||||||
} FC_CAPTURE_AND_RETHROW()
|
} FC_CAPTURE_AND_RETHROW()
|
||||||
}
|
}
|
||||||
|
virtual fc::uint128 hash()const override {
|
||||||
|
fc::uint128 result;
|
||||||
|
for( const auto& ptr : _objects )
|
||||||
|
result += ptr->hash();
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
class const_iterator
|
class const_iterator
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue