[ Web Proxy ]
URL:
Viewing: https://raw.githubusercontent.com/Xenland/BitShares/master/src/difficulty.cpp [Back]  [Original]

#include 
#include 
#include 

namespace bts 
{
  const fc::bigint& max224()
  {
     static fc::bigint m = [](){ 
        char data[224/8+1];
        memset( data, 0xff, sizeof(data) );
        data[0] = 0;
        return fc::bigint(data,sizeof(data));
     }();
     return m;
  }

  uint64_t difficulty( const fc::sha224& hash_value )
  {
      if( hash_value == fc::sha224() ) return uint64_t(-1); // div by 0

      auto dif = max224() / fc::bigint( (char*)&hash_value, sizeof(hash_value) );
// TODO... restore this     dif >>= 24;
      int64_t tmp = dif.to_int64();
      // possible if hash_value starts with 1
      if( tmp < 0 ) tmp = 0;
      return tmp;
  }


} // bts

Web Proxy Viewer  |  New URL  |  Original Page