Basic consensus implementation (#45)

Consensus for user connections, user inputs, contract outputs and time.
This commit is contained in:
Asanka Indrajith
2019-10-26 11:46:32 -04:00
committed by GitHub
parent b4b9132d18
commit d6acee4e09
28 changed files with 1464 additions and 487 deletions

View File

@@ -1,6 +1,7 @@
#include <string>
#include <sodium.h>
#include <sstream>
#include <chrono>
#include <rapidjson/document.h>
namespace util
@@ -52,6 +53,16 @@ int hex2bin(unsigned char *decodedbuf, size_t decodedbuf_len, std::string_view h
return 0;
}
/**
* Returns current time in UNIX epoch milliseconds.
*/
int64_t get_epoch_milliseconds()
{
return std::chrono::duration_cast<std::chrono::milliseconds>(
std::chrono::system_clock::now().time_since_epoch())
.count();
}
/**
* Compare two version strings in the format of "1.12.3".
* v1 < v2 -> returns -1