Skip to content

Commit

Permalink
temporarily disable checkpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
heropan committed Jul 17, 2020
1 parent bf66eae commit b18eaea
Show file tree
Hide file tree
Showing 4 changed files with 111 additions and 85 deletions.
1 change: 1 addition & 0 deletions SDK/Ethereum/EthereumEWM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,7 @@ namespace Elastos {
clientTransferEventHandler
};

// TODO: set to correct time to replace ETHEREUM_TIMESTAMP_UNKNOWN
return ewmCreateWithPublicKey((BREthereumNetwork) network, key, ETHEREUM_TIMESTAMP_UNKNOWN,
(BREthereumMode) mode, brClient, storagePath.data());
}
Expand Down
189 changes: 107 additions & 82 deletions SDK/Implement/EthSidechainSubWallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
namespace Elastos {
namespace ElaWallet {

const std::string CALLBACK_IS_NULL_PROMPT = "callback is null";

EthSidechainSubWallet::~EthSidechainSubWallet() {
}

Expand Down Expand Up @@ -82,7 +84,9 @@ namespace Elastos {
}

void EthSidechainSubWallet::getGasPrice(BREthereumWallet wid, int rid) {
ArgInfo("{}", GetFunName());
nlohmann::json j;
j["Rid"] = rid;
ArgInfo("{} {}", GetFunName(), j.dump(4));
}

void EthSidechainSubWallet::getGasEstimate(BREthereumWallet wid,
Expand All @@ -92,38 +96,42 @@ namespace Elastos {
const std::string &amount,
const std::string &data,
int rid) {
ArgInfo("{}", GetFunName());
ArgInfo("from: {}", from);
ArgInfo("to: {}", to);
ArgInfo("amount: {}", amount);
ArgInfo("data: {}", data);
ArgInfo("rid: {}", rid);
nlohmann::json j;
j["From"] = from;
j["To"] = to;
j["Amount"] = amount;
j["Data"] = data;
j["Rid"] = rid;
ArgInfo("{} {}", GetFunName(), j.dump(4));
}

void EthSidechainSubWallet::getBalance(BREthereumWallet wid, const std::string &address, int rid) {
ArgInfo("{}", GetFunName());
ArgInfo("address: {}", address);
ArgInfo("rid: {}", rid);
nlohmann::json j;
j["Address"] = address;
j["Rid"] = rid;
ArgInfo("{} {}", GetFunName(), j.dump(4));
}

void EthSidechainSubWallet::submitTransaction(BREthereumWallet wid,
BREthereumTransfer tid,
const std::string &rawTransaction,
int rid) {
ArgInfo("{}", GetFunName());
ArgInfo("rawTx: {}", rawTransaction);
ArgInfo("rid: {}", rid);
nlohmann::json j;
j["RawTx"] = rawTransaction;
j["Rid"] = rid;
ArgInfo("{} {}", GetFunName(), j.dump(4));
}

void EthSidechainSubWallet::getTransactions(const std::string &address,
uint64_t begBlockNumber,
uint64_t endBlockNumber,
int rid) {
ArgInfo("{}", GetFunName());
ArgInfo("address: {}", address);
ArgInfo("begBlockNumber: {}", begBlockNumber);
ArgInfo("endBlockNumber: {}", endBlockNumber);
ArgInfo("rid: {}", rid);
nlohmann::json j;
j["Address"] = address;
j["BegBlockNumber"] = begBlockNumber;
j["EndBlockNumber"] = endBlockNumber;
j["Rid"] = rid;
ArgInfo("{} {}", GetFunName(), j.dump(4));
}

void EthSidechainSubWallet::getLogs(const std::string &contract,
Expand All @@ -132,120 +140,135 @@ namespace Elastos {
uint64_t begBlockNumber,
uint64_t endBlockNumber,
int rid) {
ArgInfo("{}", GetFunName());
ArgInfo("contract: {}", contract);
ArgInfo("address: {}", address);
ArgInfo("event: {}", event);
ArgInfo("begBlockNumber: {}", begBlockNumber);
ArgInfo("endBlockNumber: {}", endBlockNumber);
nlohmann::json j;
j["Contract"] = contract;
j["Address"] = address;
j["Event"] = event;
j["BegBlockNumber"] = begBlockNumber;
j["EndBlockNumber"] = endBlockNumber;
j["Rid"] = rid;
ArgInfo("{} {}", GetFunName(), j.dump(4));
}

void EthSidechainSubWallet::getBlocks(const std::string &address,
int interests,
uint64_t blockNumberStart,
uint64_t blockNumberStop,
int rid) {
ArgInfo("{}", GetFunName());
ArgInfo("address: {}", address);
ArgInfo("interests: {}", interests);
ArgInfo("blockNumberStart: {}", blockNumberStart);
ArgInfo("blockNumberStop: {}", blockNumberStop);
ArgInfo("rid: {}", rid);
nlohmann::json j;
j["Address"] = address;
j["Interests"] = interests;
j["BlockNumberStart"] = blockNumberStart;
j["BlockNumberStop"] = blockNumberStop;
j["Rid"] = rid;
ArgInfo("{} {}", GetFunName(), j.dump(4));
}

void EthSidechainSubWallet::getTokens(int rid) {
ArgInfo("{}", GetFunName());
ArgInfo("rid: {}", rid);
nlohmann::json j;
j["Rid"] = rid;
ArgInfo("{} {}", GetFunName(), j.dump(4));
}

void EthSidechainSubWallet::getBlockNumber(int rid) {
ArgInfo("{}", GetFunName());
ArgInfo("rid: {}", rid);
nlohmann::json j;
j["Rid"] = rid;
ArgInfo("{} {}", GetFunName(), j.dump(4));
}

void EthSidechainSubWallet::getNonce(const std::string &address, int rid) {
ArgInfo("{}", GetFunName());
ArgInfo("address: {}", address);
ArgInfo("rid: {}", rid);
nlohmann::json j;
j["Address"] = address;
j["Rid"] = rid;
ArgInfo("{} {}", GetFunName(), j.dump(4));
}

void EthSidechainSubWallet::handleEWMEvent(EthereumEWM::EWMEvent event, EthereumEWM::Status status,
const std::string &errorDescription) {
nlohmann::json eJson;
eJson["Type"] = "EWMEvent";
eJson["Event"] = EthereumEWM::EWMEvent2String(event);
eJson["Status"] = EthereumEWM::Status2String(status);
eJson["ErrorDescription"] = errorDescription;
ArgInfo("{} {}", GetFunName(), eJson.dump(4));

ArgInfo("{}", GetFunName());
boost::mutex::scoped_lock scoped_lock(lock);
if (_callback != nullptr) {
nlohmann::json eJson;
eJson["Type"] = "EWMEvent";
eJson["Event"] = EthereumEWM::EWMEvent2String(event);
eJson["Status"] = EthereumEWM::Status2String(status);
eJson["ErrorDescription"] = errorDescription;
ArgInfo("e: {}", eJson.dump(4));
_callback->OnETHSCEventHandled(eJson);
} else {
Log::info(CALLBACK_IS_NULL_PROMPT);
}
}

void EthSidechainSubWallet::handlePeerEvent(EthereumEWM::PeerEvent event, EthereumEWM::Status status,
const std::string &errorDescription) {
ArgInfo("{}", GetFunName());
nlohmann::json eJson;
eJson["Type"] = "PeerEvent";
eJson["Event"] = EthereumEWM::PeerEvent2String(event);
eJson["Status"] = EthereumEWM::Status2String(status);
eJson["ErrorDescription"] = errorDescription;
ArgInfo("{} {}", GetFunName(), eJson.dump(4));

boost::mutex::scoped_lock scoped_lock(lock);
if (_callback != nullptr) {
nlohmann::json eJson;
eJson["Type"] = "PeerEvent";
eJson["Event"] = EthereumEWM::PeerEvent2String(event);
eJson["Status"] = EthereumEWM::Status2String(status);
eJson["ErrorDescription"] = errorDescription;
ArgInfo("e: {}", eJson.dump(4));
_callback->OnETHSCEventHandled(eJson);
} else {
Log::info(CALLBACK_IS_NULL_PROMPT);
}
}

void EthSidechainSubWallet::handleWalletEvent(const EthereumWalletPtr &wallet,
EthereumEWM::WalletEvent event,
EthereumEWM::Status status,
const std::string &errorDescription) {
ArgInfo("{}", GetFunName());
nlohmann::json eJson;
eJson["Type"] = "WalletEvent";
eJson["Event"] = EthereumEWM::WalletEvent2String(event);
eJson["Status"] = EthereumEWM::Status2String(status);
eJson["ErrorDescription"] = errorDescription;
eJson["WalletSymbol"] = wallet->getSymbol();
ArgInfo("{} {}", GetFunName(), eJson.dump(4));

boost::mutex::scoped_lock scoped_lock(lock);
if (_callback != nullptr) {
nlohmann::json eJson;
eJson["Type"] = "WalletEvent";
eJson["Event"] = EthereumEWM::WalletEvent2String(event);
eJson["Status"] = EthereumEWM::Status2String(status);
eJson["ErrorDescription"] = errorDescription;
eJson["WalletSymbol"] = wallet->getSymbol();
ArgInfo("e: {}", eJson.dump(4));
_callback->OnETHSCEventHandled(eJson);
} else {
Log::info(CALLBACK_IS_NULL_PROMPT);
}
}

void EthSidechainSubWallet::handleTokenEvent(const EthereumTokenPtr &token, EthereumEWM::TokenEvent event) {
ArgInfo("{}", GetFunName());
nlohmann::json eJson;
eJson["Type"] = "TokenEvent";
eJson["Event"] = EthereumEWM::TokenEvent2String(event);
eJson["WalletSymbol"] = token->getSymbol();
ArgInfo("{} {}", GetFunName(), eJson.dump(4));

boost::mutex::scoped_lock scoped_lock(lock);
if (_callback != nullptr) {
nlohmann::json eJson;
eJson["Type"] = "TokenEvent";
eJson["Event"] = EthereumEWM::TokenEvent2String(event);
eJson["WalletSymbol"] = token->getSymbol();
ArgInfo("e: {}", eJson.dump(4));
_callback->OnETHSCEventHandled(eJson);
} else {
Log::info(CALLBACK_IS_NULL_PROMPT);
}
}

void EthSidechainSubWallet::handleBlockEvent(const EthereumBlockPtr &block,
EthereumEWM::BlockEvent event,
EthereumEWM::Status status,
const std::string &errorDescription) {
ArgInfo("{}", GetFunName());
nlohmann::json eJson;
eJson["Type"] = "BlockEvent";
eJson["Event"] = EthereumEWM::BlockEvent2String(event);
eJson["Status"] = EthereumEWM::Status2String(status);
eJson["ErrorDescription"] = errorDescription;
eJson["BlockNumber"] = block->getBlockNumber();
ArgInfo("{} {}", GetFunName(), eJson.dump(4));

boost::mutex::scoped_lock scoped_lock(lock);
if (_callback != nullptr) {
nlohmann::json eJson;
eJson["Type"] = "BlockEvent";
eJson["Event"] = EthereumEWM::BlockEvent2String(event);
eJson["Status"] = EthereumEWM::Status2String(status);
eJson["ErrorDescription"] = errorDescription;
eJson["BlockNumber"] = block->getBlockNumber();
ArgInfo("e: {}", eJson.dump(4));
_callback->OnETHSCEventHandled(eJson);
} else {
Log::info(CALLBACK_IS_NULL_PROMPT);
}
}

Expand All @@ -254,18 +277,20 @@ namespace Elastos {
EthereumEWM::TransactionEvent event,
EthereumEWM::Status status,
const std::string &errorDescription) {
ArgInfo("{}", GetFunName());
nlohmann::json eJson;
eJson["Type"] = "TransferEvent";
eJson["Event"] = EthereumEWM::TransactionEvent2String(event);
eJson["Status"] = EthereumEWM::Status2String(status);
eJson["ErrorDescription"] = errorDescription;
eJson["WalletSymbol"] = wallet->getSymbol();
eJson["TxHash"] = transaction->getIdentifier();
ArgInfo("{} {}", GetFunName(), eJson.dump(4));

boost::mutex::scoped_lock scoped_lock(lock);
if (_callback != nullptr) {
nlohmann::json eJson;
eJson["Type"] = "TransferEvent";
eJson["Event"] = EthereumEWM::TransactionEvent2String(event);
eJson["Status"] = EthereumEWM::Status2String(status);
eJson["ErrorDescription"] = errorDescription;
eJson["WalletSymbol"] = wallet->getSymbol();
eJson["TxHash"] = transaction->getIdentifier();
ArgInfo("e: {}", eJson.dump(4));
_callback->OnETHSCEventHandled(eJson);
} else {
Log::info(CALLBACK_IS_NULL_PROMPT);
}
}

Expand Down
4 changes: 2 additions & 2 deletions ThirdParty/breadwallet-core/ethereum/bcs/BREthereumBCSSync.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,9 @@ syncRangeReport (BREthereumBCSSyncRange range,

assert (range->head > range->tail);

eth_log ("BCS", "Sync: %s: (T:C:R:D) = ( %d : %4" PRIu64 " : {%7" PRIu64 ", %7" PRIu64 "} : %2d ) *** %s%p -> %p",
eth_log ("BCS", "Sync: %s: (T:C:R:D) = ( %d : %4" PRIu64 ": %8llu : {%7" PRIu64 ", %7" PRIu64 "} : %2d ) *** %s%p -> %p",
action,
range->type, range->count, range->tail, range->head, depth,
range->type, range->count, range->step, range->tail, range->head, depth,
spaces, range, range->parent);
}

Expand Down
2 changes: 1 addition & 1 deletion ThirdParty/breadwallet-core/ethereum/ewm/BREthereumEWM.c
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ ewmCreate (BREthereumNetwork network,
}

// If we have no blocks; then add a checkpoint
if (0 == BRSetCount(blocks)) {
if (0 && 0 == BRSetCount(blocks)) {
const BREthereumBlockCheckpoint *checkpoint = blockCheckpointLookupByTimestamp (network, accountTimestamp);
BREthereumBlock block = blockCreate (blockCheckpointCreatePartialBlockHeader (checkpoint));
blockSetTotalDifficulty (block, checkpoint->u.td);
Expand Down

0 comments on commit b18eaea

Please sign in to comment.