Rename delegate_signature->witness_signature #147

- changed secret hash of block headers from 224 to 160 to save 16 bytes
per header which will add up to 1 MB per day in savings.
This commit is contained in:
Daniel Larimer 2015-07-09 18:11:52 -04:00
parent a799f064d4
commit 49937daeb8
8 changed files with 11 additions and 10 deletions

View file

@ -90,7 +90,7 @@ vector<witness_id_type> database::get_near_witness_schedule()const
return result;
}
void database::update_witness_schedule(signed_block next_block)
void database::update_witness_schedule(const signed_block& next_block)
{
const global_property_object& gpo = get_global_properties();
const witness_schedule_object& wso = get(witness_schedule_id_type());
@ -109,6 +109,7 @@ void database::update_witness_schedule(signed_block next_block)
witness_id_type wit;
const dynamic_global_property_object& dpo = get_dynamic_global_properties();
assert( dpo.random.data_size() == witness_scheduler_rng::seed_length );
assert( witness_scheduler_rng::seed_length == wso.rng_seed.size() );

View file

@ -122,7 +122,7 @@
// counter used to determine bits of entropy
// must be less than or equal to secret_hash_type::data_length()
#define GRAPHENE_RNG_SEED_LENGTH (224 / 8)
#define GRAPHENE_RNG_SEED_LENGTH (160 / 8)
/**
* every second, the fraction of burned core asset which cycles is

View file

@ -422,7 +422,7 @@ namespace graphene { namespace chain {
void update_withdraw_permissions();
//////////////////// db_witness_schedule.cpp ////////////////////
void update_witness_schedule(signed_block next_block); /// no-op except for scheduling blocks
void update_witness_schedule(const signed_block& next_block); /// no-op except for scheduling blocks
///Steps performed only at maintenance intervals
///@{

View file

@ -42,7 +42,7 @@ namespace graphene { namespace chain {
void sign( const fc::ecc::private_key& signer );
bool validate_signee( const fc::ecc::public_key& expected_signee )const;
signature_type delegate_signature;
signature_type witness_signature;
};
struct signed_block : public signed_block_header
@ -55,5 +55,5 @@ namespace graphene { namespace chain {
FC_REFLECT( graphene::chain::block_header, (previous)(timestamp)(witness)
(next_secret_hash)(previous_secret)(transaction_merkle_root)(extensions) )
FC_REFLECT_DERIVED( graphene::chain::signed_block_header, (graphene::chain::block_header), (delegate_signature) )
FC_REFLECT_DERIVED( graphene::chain::signed_block_header, (graphene::chain::block_header), (witness_signature) )
FC_REFLECT_DERIVED( graphene::chain::signed_block, (graphene::chain::signed_block_header), (transactions) )

View file

@ -220,7 +220,7 @@ namespace graphene { namespace chain {
typedef fc::sha256 digest_type;
typedef fc::ecc::compact_signature signature_type;
typedef safe<int64_t> share_type;
typedef fc::sha224 secret_hash_type;
typedef fc::ripemd160 secret_hash_type;
typedef uint16_t weight_type;
/**

View file

@ -56,7 +56,7 @@ class witness_schedule_object : public abstract_object<witness_schedule_object>
witness_scheduler scheduler;
uint32_t last_scheduling_block;
uint64_t slots_since_genesis = 0;
fc::array< char, GRAPHENE_RNG_SEED_LENGTH > rng_seed;
fc::array< char, sizeof(secret_hash_type) > rng_seed;
};
} }

View file

@ -38,7 +38,7 @@ class nullary_rng
* The sha256_ctr_rng generates bits using SHA256 in counter (CTR)
* mode.
*/
template< class HashClass, int SeedLength=32 >
template< class HashClass, int SeedLength=sizeof(secret_hash_type) >
class hash_ctr_rng
{
public:

View file

@ -42,12 +42,12 @@ namespace graphene { namespace chain {
fc::ecc::public_key signed_block_header::signee()const
{
return fc::ecc::public_key( delegate_signature, digest(), true/*enforce canonical*/ );
return fc::ecc::public_key( witness_signature, digest(), true/*enforce canonical*/ );
}
void signed_block_header::sign( const fc::ecc::private_key& signer )
{
delegate_signature = signer.sign_compact( digest() );
witness_signature = signer.sign_compact( digest() );
}
bool signed_block_header::validate_signee( const fc::ecc::public_key& expected_signee )const