Use uint64_t for chainID

This commit is contained in:
pscott
2021-08-26 13:02:07 +02:00
parent 832c7de51e
commit b2172e4627
8 changed files with 54 additions and 36 deletions

View File

@@ -60,7 +60,7 @@ typedef enum chain_kind_e {
typedef struct chain_config_s {
char coinName[10]; // ticker
uint32_t chainId;
uint64_t chainId;
chain_kind_t kind;
} chain_config_t;

View File

@@ -54,19 +54,17 @@ int local_strchr(char *string, char ch) {
return -1;
}
uint32_t u32_from_BE(uint8_t *in, uint8_t size) {
switch (size) {
case 0:
return 0;
case 1:
return in[0];
case 2:
return (in[0] << 8) | in[1];
case 3:
return (in[0] << 16) | (in[1] << 8) | in[2];
default:
return (in[0] << 24) | (in[1] << 16) | (in[2] << 8) | in[3];
uint64_t u64_from_BE(uint8_t *in, uint8_t size) {
uint8_t i = 0;
uint64_t res = 0;
while (i < size && i < sizeof(res)) {
res <<= 8;
res |= in[i];
i++;
}
return res;
}
bool uint256_to_decimal(const uint8_t *value, size_t value_len, char *out, size_t out_len) {

View File

@@ -28,7 +28,7 @@ void convertUint256BE(uint8_t* data, uint32_t length, uint256_t* target);
int local_strchr(char* string, char ch);
uint32_t u32_from_BE(uint8_t* in, uint8_t size);
uint64_t u64_from_BE(uint8_t* in, uint8_t size);
bool uint256_to_decimal(const uint8_t* value, size_t value_len, char* out, size_t out_len);