2019-01-11 06:15:34 +03:00
// Copyright (c) 2018-2019 Zano Project
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
# include "scratchpad_helper.h"
# include "currency_format_utils.h"
namespace currency
{
bool scratchpad_keeper : : update ( const std : : vector < crypto : : hash > & seed , uint64_t height )
{
2019-01-11 23:46:29 +03:00
return crypto : : generate_scratchpad ( seed , m_scratchpad , get_scratchpad_size_for_height ( height ) ) ;
2019-01-11 06:15:34 +03:00
}
crypto : : hash scratchpad_keeper : : get_pow_hash ( const blobdata & bd , uint64_t height )
{
2019-01-11 23:46:29 +03:00
CHECK_AND_ASSERT_THROW_MES ( get_scratchpad_size_for_height ( height ) = = this - > size ( ) , " Fatal error on hash calculation: scratchpad_size= " < < m_scratchpad . size ( ) < < " at height= " < < height ) ;
2019-01-11 06:15:34 +03:00
crypto : : hash res_hash = null_hash ;
bool res = get_wild_keccak2 ( bd , res_hash , m_scratchpad ) ;
CHECK_AND_ASSERT_THROW_MES ( res , " Fatal error on hash calculation: scratchpad_size= " < < m_scratchpad . size ( ) ) ;
return res_hash ;
}
2019-01-11 23:46:29 +03:00
crypto : : hash scratchpad_keeper : : get_pow_hash ( const block & b )
{
blobdata bl = get_block_hashing_blob ( b ) ;
return get_pow_hash ( bl , get_block_height ( b ) ) ;
}
2019-01-11 06:15:34 +03:00
uint64_t scratchpad_keeper : : size ( )
{
return m_scratchpad . size ( ) ;
}
}