Browse Source

Provide a way to extract a serialised integer

master
Con Kolivas 11 years ago
parent
commit
4f60dc1b8a
  1. 12
      src/libckpool.c
  2. 1
      src/libckpool.h

12
src/libckpool.c

@ -1255,6 +1255,18 @@ int ser_number(uchar *s, int32_t val)
return len; return len;
} }
int get_sernumber(uchar *s)
{
int32_t val = 0;
int len;
len = s[0];
if (unlikely(len < 1 || len > 4))
return 0;
memcpy(&val, &s[1], len);
return le32toh(val);
}
/* For testing a le encoded 256 byte hash against a target */ /* For testing a le encoded 256 byte hash against a target */
bool fulltest(const uchar *hash, const uchar *target) bool fulltest(const uchar *hash, const uchar *target)
{ {

1
src/libckpool.h

@ -344,6 +344,7 @@ void b58tobin(char *b58bin, const char *b58);
void address_to_pubkeytxn(char *pkh, const char *addr); void address_to_pubkeytxn(char *pkh, const char *addr);
int ser_number(uchar *s, int32_t val); int ser_number(uchar *s, int32_t val);
int get_sernumber(uchar *s);
bool fulltest(const uchar *hash, const uchar *target); bool fulltest(const uchar *hash, const uchar *target);
void copy_tv(tv_t *dest, const tv_t *src); void copy_tv(tv_t *dest, const tv_t *src);

Loading…
Cancel
Save