Skip to content

Commit

Permalink
Msvcwjb (Chia-Network#25)
Browse files Browse the repository at this point in the history
* make things easier on msvc. replace VLA and fix gulrak header issue

* removed global nominmax
  • Loading branch information
wjblanke authored May 9, 2020
1 parent e0795c3 commit 9c2cd50
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def cpp_flag(compiler):
class BuildExt(build_ext):
"""A custom build extension for adding compiler-specific options."""
c_opts = {
'msvc': ['/EHsc','/std:c++17','/D','NOMINMAX','/O2'],
'msvc': ['/EHsc','/std:c++17','/O2'],
'unix': [],
}
l_opts = {
Expand Down
12 changes: 8 additions & 4 deletions src/cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,15 @@ int main(int argc, char *argv[]) {
}
memo = Strip0x(memo);
id = Strip0x(id);
uint8_t memo_bytes[memo.size() / 2];
uint8_t *memo_bytes = new uint8_t(memo.size() / 2);
uint8_t id_bytes[32];

HexToBytes(memo, memo_bytes);
HexToBytes(id, id_bytes);

DiskPlotter plotter = DiskPlotter();
plotter.CreatePlotDisk(tempdir, tempdir, finaldir, filename, k, memo_bytes, memo.size() / 2, id_bytes, 32);
delete(memo_bytes);
} else if (operation == "prove") {
if (argc < 3) {
HelpAndQuit(options);
Expand All @@ -124,10 +125,11 @@ int main(int argc, char *argv[]) {
vector<LargeBits> qualities = prover.GetQualitiesForChallenge(challenge_bytes);
for (uint32_t i = 0; i < qualities.size(); i++) {
k = prover.GetSize() / 2;
uint8_t proof_data[8 * k];
uint8_t *proof_data = new uint8_t(8 * k);
LargeBits proof = prover.GetFullProof(challenge_bytes, i);
proof.ToBytes(proof_data);
cout << "Proof: 0x" << Util::HexStr(proof_data, k * 8) << endl;
delete proof_data;
}
if (qualities.empty()) {
cout << "No proofs found." << endl;
Expand Down Expand Up @@ -159,7 +161,7 @@ int main(int argc, char *argv[]) {
<< static_cast<int>(k) << endl << endl;
uint8_t id_bytes[32];
uint8_t challenge_bytes[32];
uint8_t proof_bytes[proof.size() / 2];
uint8_t *proof_bytes = new uint8_t(proof.size() / 2);
HexToBytes(id, id_bytes);
HexToBytes(challenge, challenge_bytes);
HexToBytes(proof, proof_bytes);
Expand All @@ -171,6 +173,7 @@ int main(int argc, char *argv[]) {
cout << "Proof verification failed." << endl;
exit(1);
}
delete proof_bytes;
} else if (operation == "check") {
uint32_t iterations = 1000;
if (argc == 3) {
Expand All @@ -195,7 +198,7 @@ int main(int argc, char *argv[]) {
vector<LargeBits> qualities = prover.GetQualitiesForChallenge(hash.data());
for (uint32_t i = 0; i < qualities.size(); i++) {
LargeBits proof = prover.GetFullProof(hash.data(), i);
uint8_t proof_data[proof.GetSize() / 8];
uint8_t *proof_data = new uint8_t(proof.GetSize() / 8);
proof.ToBytes(proof_data);
cout << "i: " << num << std::endl;
cout << "chalenge: 0x" << Util::HexStr(hash.data(), 256 / 8) << endl;
Expand All @@ -209,6 +212,7 @@ int main(int argc, char *argv[]) {
cout << "Proof verification failed." << endl;
exit(1);
}
delete proof_data;
}
}
std::cout << "Total success: " << success << "/" << iterations << ", " <<
Expand Down
4 changes: 4 additions & 0 deletions src/plotter_disk.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
#include <string>
#include <utility>

// Gulrak filesystem brings in Windows headers that cause some issues with std
#define _HAS_STD_BYTE 0
#define NOMINMAX

#include "../lib/include/filesystem.hh"
namespace fs = ghc::filesystem;
#include "util.hpp"
Expand Down

0 comments on commit 9c2cd50

Please sign in to comment.