feat: ensure format consistency and add badges to README

This commit is contained in:
Marvin 2018-02-13 01:13:17 +01:00
commit d6121571a2
7 changed files with 28 additions and 14 deletions

9
.editorconfig Normal file
View file

@ -0,0 +1,9 @@
root = true
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
indent_style = space
indent_size = 2

View file

@ -0,0 +1,8 @@
# nanocurrency-js
[![Build Status](https://travis-ci.org/marvinroger/nanocurrency-js.svg?branch=master)](https://travis-ci.org/marvinroger/nanocurrency-js)
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
---
A toolkit for the Nano cryptocurrency.

View file

@ -1,6 +1,6 @@
{
"name": "nanocurrency",
"description": "Toolkit for the Nano cryptocurrency",
"description": "A toolkit for the Nano cryptocurrency.",
"version": "0.0.0-development",
"author": {
"name": "Marvin ROGER",

View file

@ -10,8 +10,7 @@ const uint64_t WORK_THRESHOLD = 0xffffffc000000000;
void hex_to_bytes(const std::string& hex, uint8_t* bytes) {
int byte_index = 0;
for (unsigned int i = 0; i < hex.length(); i += 2)
{
for (unsigned int i = 0; i < hex.length(); i += 2) {
std::string byte_string = hex.substr(i, 2);
uint8_t byte = (uint8_t) strtol(byte_string.c_str(), NULL, 16);
bytes[byte_index++] = byte;
@ -42,8 +41,7 @@ uint64_t generate_work(uint8_t* block_hash, uint8_t worker_number, uint8_t worke
return work;
}
uint64_t swap_uint64(uint64_t val)
{
uint64_t swap_uint64(uint64_t val) {
val = ((val << 8) & 0xFF00FF00FF00FF00ULL ) | ((val >> 8) & 0x00FF00FF00FF00FFULL );
val = ((val << 16) & 0xFFFF0000FFFF0000ULL ) | ((val >> 16) & 0x0000FFFF0000FFFFULL );
return (val << 32) | (val >> 32);
@ -51,8 +49,7 @@ uint64_t swap_uint64(uint64_t val)
extern "C" {
EMSCRIPTEN_KEEPALIVE
char* emscripten_generate_work(char* block_hash_hex, uint8_t worker_number, uint8_t worker_count)
{
char* emscripten_generate_work(char* block_hash_hex, uint8_t worker_number, uint8_t worker_count) {
std::string block_hash_hex_string(block_hash_hex);
uint8_t block_hash_bytes[32];
hex_to_bytes(block_hash_hex_string, block_hash_bytes);