Fix spacing

This commit is contained in:
John Jones 2019-07-23 17:32:29 -05:00
parent ea9128257c
commit 55e2abe7d5

View file

@ -38,36 +38,33 @@ namespace fc
hash160::hash160() { memset( _hash, 0, sizeof(_hash) ); }
hash160::hash160( const string& hex_str ) {
fc::from_hex( hex_str, (char*)_hash, sizeof(_hash) );
fc::from_hex( hex_str, (char*)_hash, sizeof(_hash) );
}
string hash160::str()const {
return fc::to_hex( (char*)_hash, sizeof(_hash) );
return fc::to_hex( (char*)_hash, sizeof(_hash) );
}
hash160::operator string()const { return str(); }
char* hash160::data()const { return (char*)&_hash[0]; }
class hash160::encoder::impl {
public:
impl()
{
}
public:
impl() { }
};
hash160::encoder::~encoder() {}
hash160::encoder::encoder() {}
hash160 hash160::hash( const char* d, uint32_t dlen ) {
encoder e;
e.write(d,dlen);
return e.result();
encoder e;
e.write(d,dlen);
return e.result();
}
hash160 hash160::hash( const string& s ) {
return hash( s.c_str(), s.size() );
return hash( s.c_str(), s.size() );
}
void hash160::encoder::write( const char* d, uint32_t dlen )
@ -93,45 +90,52 @@ hash160 hash160::encoder::result() {
}
hash160 operator << ( const hash160& h1, uint32_t i ) {
hash160 result;
fc::detail::shift_l( h1.data(), result.data(), result.data_size(), i );
return result;
hash160 result;
fc::detail::shift_l( h1.data(), result.data(), result.data_size(), i );
return result;
}
hash160 operator ^ ( const hash160& h1, const hash160& h2 ) {
hash160 result;
result._hash[0] = h1._hash[0].value() ^ h2._hash[0].value();
result._hash[1] = h1._hash[1].value() ^ h2._hash[1].value();
result._hash[2] = h1._hash[2].value() ^ h2._hash[2].value();
result._hash[3] = h1._hash[3].value() ^ h2._hash[3].value();
result._hash[4] = h1._hash[4].value() ^ h2._hash[4].value();
return result;
hash160 result;
result._hash[0] = h1._hash[0].value() ^ h2._hash[0].value();
result._hash[1] = h1._hash[1].value() ^ h2._hash[1].value();
result._hash[2] = h1._hash[2].value() ^ h2._hash[2].value();
result._hash[3] = h1._hash[3].value() ^ h2._hash[3].value();
result._hash[4] = h1._hash[4].value() ^ h2._hash[4].value();
return result;
}
bool operator >= ( const hash160& h1, const hash160& h2 ) {
return memcmp( h1._hash, h2._hash, sizeof(h1._hash) ) >= 0;
return memcmp( h1._hash, h2._hash, sizeof(h1._hash) ) >= 0;
}
bool operator > ( const hash160& h1, const hash160& h2 ) {
return memcmp( h1._hash, h2._hash, sizeof(h1._hash) ) > 0;
return memcmp( h1._hash, h2._hash, sizeof(h1._hash) ) > 0;
}
bool operator < ( const hash160& h1, const hash160& h2 ) {
return memcmp( h1._hash, h2._hash, sizeof(h1._hash) ) < 0;
return memcmp( h1._hash, h2._hash, sizeof(h1._hash) ) < 0;
}
bool operator != ( const hash160& h1, const hash160& h2 ) {
return memcmp( h1._hash, h2._hash, sizeof(h1._hash) ) != 0;
return memcmp( h1._hash, h2._hash, sizeof(h1._hash) ) != 0;
}
bool operator == ( const hash160& h1, const hash160& h2 ) {
return memcmp( h1._hash, h2._hash, sizeof(h1._hash) ) == 0;
return memcmp( h1._hash, h2._hash, sizeof(h1._hash) ) == 0;
}
void to_variant( const hash160& bi, variant& v, uint32_t max_depth )
{
to_variant( std::vector<char>( (const char*)&bi, ((const char*)&bi) + sizeof(bi) ), v, max_depth );
}
void from_variant( const variant& v, hash160& bi, uint32_t max_depth )
{
std::vector<char> ve = v.as< std::vector<char> >( max_depth );
memset( &bi, char(0), sizeof(bi) );
if( ve.size() )
memcpy( &bi, ve.data(), std::min<size_t>(ve.size(),sizeof(bi)) );
}
void to_variant( const hash160& bi, variant& v, uint32_t max_depth )
{
to_variant( std::vector<char>( (const char*)&bi, ((const char*)&bi) + sizeof(bi) ), v, max_depth );
}
void from_variant( const variant& v, hash160& bi, uint32_t max_depth )
{
std::vector<char> ve = v.as< std::vector<char> >( max_depth );
memset( &bi, char(0), sizeof(bi) );
if( ve.size() )
memcpy( &bi, ve.data(), std::min<size_t>(ve.size(),sizeof(bi)) );
}
} // fc