Skip to content

Commit

Permalink
Merge pull request #77 from brave-intl/extern-flags
Browse files Browse the repository at this point in the history
make production/verbose extern
  • Loading branch information
bridiver authored Sep 4, 2018
2 parents 1dfae89 + 0db0a3c commit 81f53c4
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 12 deletions.
7 changes: 5 additions & 2 deletions include/bat/ledger/ledger.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@

namespace ledger {

extern bool is_production;
extern bool is_verbose;

LEDGER_EXPORT struct VisitData {
VisitData();
VisitData(const std::string& _tld,
Expand Down Expand Up @@ -87,13 +90,13 @@ class LEDGER_EXPORT Ledger {
uint32_t tab_id,
const std::string& url,
const std::map<std::string, std::string>& parts,
const std::string& first_party_url,
const std::string& first_party_url,
const std::string& referrer,
const VisitData& visit_data) = 0;

virtual void OnPostData(
const std::string& url,
const std::string& first_party_url,
const std::string& first_party_url,
const std::string& referrer,
const std::string& post_data,
const VisitData& visit_data) = 0;
Expand Down
3 changes: 3 additions & 0 deletions src/bat/ledger/ledger.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@

namespace ledger {

bool is_production = true;
bool is_verbose = true;

VisitData::VisitData():
tab_id(-1) {}

Expand Down
2 changes: 1 addition & 1 deletion src/bat_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -867,7 +867,7 @@ void BatClient::recoverWallet(const std::string& passPhrase) {
newSeed.resize(32);
size_t written = 0;
int result = bip39_mnemonic_to_bytes(nullptr, passPhrase.c_str(), &newSeed.front(), newSeed.size(), &written);
if (braveledger_ledger::g_isVerbose) {
if (ledger::is_verbose) {
LOG(ERROR) << "!!!recoverWallet result == " << result << "!!!result size == " << written;
}
if (0 != result || 0 == written) {
Expand Down
11 changes: 6 additions & 5 deletions src/bat_helper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <openssl/hkdf.h>
#include <openssl/sha.h>

#include "bat/ledger/ledger.h"
#include "rapidjson_bat_helper.h"
#include "static_values.h"
#include "tweetnacl.h"
Expand Down Expand Up @@ -709,7 +710,7 @@ namespace braveledger_bat_helper {
d.HasMember("closing_balance") && d["closing_balance"].IsDouble() &&
d.HasMember("grants") && d["grants"].IsDouble() &&
d.HasMember("earning_from_ads") && d["earning_from_ads"].IsDouble() &&
d.HasMember("auto_contribute") && d["auto_contribute"].IsDouble() &&
d.HasMember("auto_contribute") && d["auto_contribute"].IsDouble() &&
d.HasMember("recurring_donation") && d["recurring_donation"].IsDouble() &&
d.HasMember("one_time_donation") && d["one_time_donation"].IsDouble());
}
Expand Down Expand Up @@ -844,7 +845,7 @@ namespace braveledger_bat_helper {

writer.String("allow_non_verified");
writer.Bool(data.allow_non_verified_);

writer.String("pubs_load_timestamp");
writer.Uint64(data.pubs_load_timestamp_);

Expand Down Expand Up @@ -1866,21 +1867,21 @@ namespace braveledger_bat_helper {
std::string url;
switch (server) {
case SERVER_TYPES::BALANCE:
if (braveledger_ledger::g_isProduction) {
if (ledger::is_production) {
url = BALANCE_PRODUCTION_SERVER;
} else {
url = BALANCE_STAGING_SERVER;
}
break;
case SERVER_TYPES::PUBLISHER:
if (braveledger_ledger::g_isProduction) {
if (ledger::is_production) {
url = PUBLISHER_PRODUCTION_SERVER;
} else {
url = PUBLISHER_STAGING_SERVER;
}
break;
default:
if (braveledger_ledger::g_isProduction) {
if (ledger::is_production) {
url = LEDGER_PRODUCTION_SERVER;
} else {
url = LEDGER_STAGING_SERVER;
Expand Down
3 changes: 0 additions & 3 deletions src/static_values.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,6 @@

namespace braveledger_ledger {

// TODO NZ we need to define this variabled via flags that we set in the client that is using this lib
static const bool g_isProduction = true;
static const bool g_isVerbose = true;
static const uint8_t g_hkdfSalt[] = {126, 244, 99, 158, 51, 68, 253, 80, 133, 183, 51, 180, 77,
62, 74, 252, 62, 106, 96, 125, 241, 110, 134, 87, 190, 208,
158, 84, 125, 69, 246, 207, 162, 247, 107, 172, 37, 34, 53,
Expand Down
4 changes: 3 additions & 1 deletion src/url_request_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

#include "url_request_handler.h"

#include "bat/ledger/ledger.h"

namespace bat_ledger {

URLRequestHandler::URLRequestHandler() {}
Expand All @@ -25,7 +27,7 @@ void URLRequestHandler::OnURLRequestResponse(uint64_t request_id,
return;
}

if (braveledger_ledger::g_isVerbose) {
if (ledger::is_verbose) {
LOG(ERROR) << "[ RESPONSE ]";
LOG(ERROR) << "> url: " << url;
LOG(ERROR) << "> response: " << response;
Expand Down

0 comments on commit 81f53c4

Please sign in to comment.