Merge branch 'master' of github.com:cryptonomex/graphene
This commit is contained in:
commit
7614beb338
4 changed files with 38 additions and 7 deletions
|
|
@ -68,8 +68,14 @@ void block_database::flush()
|
|||
_block_num_to_pos.flush();
|
||||
}
|
||||
|
||||
void block_database::store( const block_id_type& id, const signed_block& b )
|
||||
void block_database::store( const block_id_type& _id, const signed_block& b )
|
||||
{
|
||||
block_id_type id = _id;
|
||||
if( id == block_id_type() )
|
||||
{
|
||||
id = b.id();
|
||||
elog( "id argument of block_database::store() was not initialized for block ${id}", ("id", id) );
|
||||
}
|
||||
auto num = block_header::num_from_id(id);
|
||||
_block_num_to_pos.seekp( sizeof( index_entry ) * num );
|
||||
index_entry e;
|
||||
|
|
@ -103,6 +109,9 @@ void block_database::remove( const block_id_type& id )
|
|||
|
||||
bool block_database::contains( const block_id_type& id )const
|
||||
{
|
||||
if( id == block_id_type() )
|
||||
return false;
|
||||
|
||||
index_entry e;
|
||||
auto index_pos = sizeof(e)*block_header::num_from_id(id);
|
||||
_block_num_to_pos.seekg( 0, _block_num_to_pos.end );
|
||||
|
|
@ -116,6 +125,7 @@ bool block_database::contains( const block_id_type& id )const
|
|||
|
||||
block_id_type block_database::fetch_block_id( uint32_t block_num )const
|
||||
{
|
||||
assert( block_num != 0 );
|
||||
index_entry e;
|
||||
auto index_pos = sizeof(e)*block_num;
|
||||
_block_num_to_pos.seekg( 0, _block_num_to_pos.end );
|
||||
|
|
@ -125,6 +135,7 @@ block_id_type block_database::fetch_block_id( uint32_t block_num )const
|
|||
_block_num_to_pos.seekg( index_pos );
|
||||
_block_num_to_pos.read( (char*)&e, sizeof(e) );
|
||||
|
||||
FC_ASSERT( e.block_id != block_id_type(), "Empty block_id in block_database (maybe corrupt on disk?)" );
|
||||
return e.block_id;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -143,22 +143,30 @@ void fork_database::set_max_size( uint32_t s )
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
bool fork_database::is_known_block(const block_id_type& id)const
|
||||
{
|
||||
auto& index = _index.get<block_id>();
|
||||
auto itr = index.find(id);
|
||||
return itr != index.end();
|
||||
if( itr != index.end() )
|
||||
return true;
|
||||
auto& unlinked_index = _unlinked_index.get<block_id>();
|
||||
auto unlinked_itr = unlinked_index.find(id);
|
||||
return unlinked_itr != unlinked_index.end();
|
||||
}
|
||||
|
||||
item_ptr fork_database::fetch_block(const block_id_type& id)const
|
||||
{
|
||||
auto itr = _index.get<block_id>().find(id);
|
||||
if( itr != _index.get<block_id>().end() )
|
||||
auto& index = _index.get<block_id>();
|
||||
auto itr = index.find(id);
|
||||
if( itr != index.end() )
|
||||
return *itr;
|
||||
auto& unlinked_index = _unlinked_index.get<block_id>();
|
||||
auto unlinked_itr = unlinked_index.find(id);
|
||||
if( unlinked_itr != unlinked_index.end() )
|
||||
return *unlinked_itr;
|
||||
return item_ptr();
|
||||
}
|
||||
|
||||
vector<item_ptr> fork_database::fetch_block_by_number(uint32_t num)const
|
||||
{
|
||||
vector<item_ptr> result;
|
||||
|
|
|
|||
|
|
@ -356,6 +356,12 @@ class wallet_api
|
|||
*/
|
||||
string get_wallet_filename() const;
|
||||
|
||||
/**
|
||||
* Get the WIF private key corresponding to a public key. The
|
||||
* private key must already be in the wallet.
|
||||
*/
|
||||
string get_private_key( public_key_type pubkey )const;
|
||||
|
||||
/**
|
||||
* @ingroup Transaction Builder API
|
||||
*/
|
||||
|
|
@ -1301,6 +1307,7 @@ FC_API( graphene::wallet::wallet_api,
|
|||
(get_global_properties)
|
||||
(get_dynamic_global_properties)
|
||||
(get_object)
|
||||
(get_private_key)
|
||||
(load_wallet_file)
|
||||
(normalize_brain_key)
|
||||
(get_limit_orders)
|
||||
|
|
|
|||
|
|
@ -2800,6 +2800,11 @@ string wallet_api::get_key_label( public_key_type key )const
|
|||
return string();
|
||||
}
|
||||
|
||||
string wallet_api::get_private_key( public_key_type pubkey )const
|
||||
{
|
||||
return key_to_wif( my->get_private_key( pubkey ) );
|
||||
}
|
||||
|
||||
public_key_type wallet_api::get_public_key( string label )const
|
||||
{
|
||||
try { return fc::variant(label).as<public_key_type>(); } catch ( ... ){}
|
||||
|
|
|
|||
Loading…
Reference in a new issue