-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* switch back to OpenSSL 1.1.1 * update INSTALL.md * fix changes to INSTALL.md
- Loading branch information
1 parent
f14c552
commit 6c95aaa
Showing
15 changed files
with
602 additions
and
337 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,13 +8,13 @@ default: all | |
# multiple subcommands and uses the library. | ||
# The library can be loaded in utop for interactive testing. | ||
all: | ||
CPLUS_INCLUDE_PATH=${CPLUS_INCLUDE_PATH}:/usr/local/opt/[email protected]/include LIBRARY_PATH=${LIBRARY_PATH}:/usr/local/opt/[email protected]/lib dune build @install | ||
dune build @install | ||
@test -L bin || ln -s _build/install/default/bin . | ||
|
||
# Build only scilla-checker and scilla-runner | ||
slim: | ||
CPLUS_INCLUDE_PATH=${CPLUS_INCLUDE_PATH}:/usr/local/opt/[email protected]/include LIBRARY_PATH=${LIBRARY_PATH}:/usr/local/opt/[email protected]/lib dune build src/runners/scilla_runner.exe | ||
CPLUS_INCLUDE_PATH=${CPLUS_INCLUDE_PATH}:/usr/local/opt/[email protected]/include LIBRARY_PATH=${LIBRARY_PATH}:/usr/local/opt/[email protected]/lib dune build src/runners/scilla_checker.exe | ||
dune build src/runners/scilla_runner.exe | ||
dune build src/runners/scilla_checker.exe | ||
@test -L bin || mkdir bin; ln -s _build/default/src/runners/*.exe bin/ | ||
|
||
# Launch utop such that it finds the libraroes. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,79 +1,103 @@ | ||
/* | ||
* Copyright (c) 2018 Zilliqa | ||
* This source code is being disclosed to you solely for the purpose of your | ||
* participation in testing Zilliqa. You may view, compile and run the code for | ||
* that purpose and pursuant to the protocols and algorithms that are programmed | ||
* into, and intended by, the code. You may not do anything else with the code | ||
* without express permission from Zilliqa Research Pte. Ltd., including | ||
* modifying or publishing the code (or any part of it), and developing or | ||
* forming another public or private blockchain network. This source code is | ||
* provided 'as is' and no warranties are given as to title or non-infringement, | ||
* merchantability or fitness for purpose and, to the extent permitted by law, | ||
* all liability for your use of the code is disclaimed. Some programs in this | ||
* code are governed by the GNU General Public License v3.0 (available at | ||
* https://www.gnu.org/licenses/gpl-3.0.en.html) ('GPLv3'). The programs that | ||
* are governed by GPLv3.0 are those programs that are located in the folders | ||
* src/depends and tests/depends and which include a reference to GPLv3 in their | ||
* program files. | ||
* Copyright (C) 2019 Zilliqa | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#include "DataConversion.h" | ||
|
||
using namespace std; | ||
|
||
const vector<unsigned char> DataConversion::HexStrToUint8Vec( | ||
const string& hex_input) { | ||
vector<uint8_t> out; | ||
boost::algorithm::unhex(hex_input.begin(), hex_input.end(), | ||
back_inserter(out)); | ||
return out; | ||
bool DataConversion::HexStrToUint8Vec(const string& hex_input, bytes& out) { | ||
try { | ||
out.clear(); | ||
boost::algorithm::unhex(hex_input.begin(), hex_input.end(), | ||
back_inserter(out)); | ||
} catch (exception& e) { | ||
LOG_GENERAL(WARNING, "Failed HexStrToUint8Vec conversion"); | ||
return false; | ||
} | ||
return true; | ||
} | ||
|
||
const array<unsigned char, 32> DataConversion::HexStrToStdArray( | ||
const string& hex_input) { | ||
array<unsigned char, 32> d = {0}; | ||
vector<unsigned char> v = HexStrToUint8Vec(hex_input); | ||
copy(v.begin(), v.begin() + min((int)v.size(), 32), d.begin()); | ||
return d; | ||
bool DataConversion::HexStrToStdArray(const string& hex_input, | ||
array<uint8_t, 32>& d) { | ||
d = {0}; | ||
bytes v; | ||
if (HexStrToUint8Vec(hex_input, v)) { | ||
copy(v.begin(), v.begin() + min((int)v.size(), 32), d.begin()); | ||
return true; | ||
} | ||
LOG_GENERAL(WARNING, "Failed HexStrToStdArray conversion"); | ||
return false; | ||
} | ||
|
||
const array<unsigned char, 64> DataConversion::HexStrToStdArray64( | ||
const string& hex_input) { | ||
array<unsigned char, 64> d = {0}; | ||
vector<unsigned char> v = HexStrToUint8Vec(hex_input); | ||
copy(v.begin(), v.begin() + min((int)v.size(), 64), d.begin()); | ||
return d; | ||
bool DataConversion::HexStrToStdArray64(const string& hex_input, | ||
array<uint8_t, 64>& d) { | ||
d = {0}; | ||
bytes v; | ||
if (HexStrToUint8Vec(hex_input, v)) { | ||
copy(v.begin(), v.begin() + min((int)v.size(), 64), d.begin()); | ||
return true; | ||
} | ||
LOG_GENERAL(WARNING, "Failed HexStrToStdArray conversion"); | ||
return false; | ||
} | ||
|
||
const string DataConversion::Uint8VecToHexStr( | ||
const vector<unsigned char>& hex_vec) { | ||
string str; | ||
boost::algorithm::hex(hex_vec.begin(), hex_vec.end(), back_inserter(str)); | ||
return str; | ||
bool DataConversion::Uint8VecToHexStr(const bytes& hex_vec, string& str) { | ||
try { | ||
str = ""; | ||
boost::algorithm::hex(hex_vec.begin(), hex_vec.end(), back_inserter(str)); | ||
} catch (exception& e) { | ||
LOG_GENERAL(WARNING, "Failed Uint8VecToHexStr conversion"); | ||
return false; | ||
} | ||
return true; | ||
} | ||
|
||
const string DataConversion::Uint8VecToHexStr( | ||
const vector<unsigned char>& hex_vec, unsigned int offset, | ||
unsigned int len) { | ||
string str; | ||
boost::algorithm::hex(hex_vec.begin() + offset, | ||
hex_vec.begin() + offset + len, back_inserter(str)); | ||
return str; | ||
bool DataConversion::Uint8VecToHexStr(const bytes& hex_vec, unsigned int offset, | ||
unsigned int len, string& str) { | ||
try { | ||
str = ""; | ||
boost::algorithm::hex(hex_vec.begin() + offset, | ||
hex_vec.begin() + offset + len, back_inserter(str)); | ||
} catch (exception& e) { | ||
LOG_GENERAL(WARNING, "Failed Uint8VecToHexStr conversion"); | ||
return false; | ||
} | ||
return true; | ||
} | ||
|
||
string DataConversion::SerializableToHexStr(const Serializable& input) { | ||
vector<unsigned char> tmp; | ||
bool DataConversion::SerializableToHexStr(const Serializable& input, | ||
string& str) { | ||
bytes tmp; | ||
input.Serialize(tmp, 0); | ||
string str; | ||
boost::algorithm::hex(tmp.begin(), tmp.end(), back_inserter(str)); | ||
return str; | ||
try { | ||
str = ""; | ||
boost::algorithm::hex(tmp.begin(), tmp.end(), back_inserter(str)); | ||
} catch (exception& e) { | ||
LOG_GENERAL(WARNING, "Failed SerializableToHexStr conversion"); | ||
return false; | ||
} | ||
return true; | ||
} | ||
|
||
uint16_t DataConversion::charArrTo16Bits(const vector<unsigned char>& hex_arr) { | ||
uint16_t DataConversion::charArrTo16Bits(const bytes& hex_arr) { | ||
if (hex_arr.size() == 0) { | ||
return 0; | ||
} | ||
uint32_t lsb = hex_arr.size() - 1; | ||
|
||
return (hex_arr.at(lsb - 1) << 8) | hex_arr.at(lsb); | ||
} | ||
} |
Oops, something went wrong.