Skip to content

Commit f00d66c

Browse files
committed
Zawy min difficulty added and webwalelt fix
1 parent f04e559 commit f00d66c

File tree

3 files changed

+143
-199
lines changed

3 files changed

+143
-199
lines changed

extensions/walletd-spent-transfers-tracking-mode.json

Lines changed: 139 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -517,10 +517,127 @@
517517
]
518518
},
519519

520+
{
521+
"path": "/tests/UnitTests/TestWalletService.cpp",
522+
"changes": [
523+
{
524+
"action": "add_above",
525+
"marker": "virtual void deleteAddress(const std::string& address) override { }",
526+
"parameters": {
527+
"text": [
528+
" virtual std::vector<CryptoNote::TransactionDetails> getTransactionsDetails(const std::vector<Crypto::Hash>& txHashes) const override { return {}; }",
529+
" virtual std::vector<Crypto::PublicKey> extractKeyOutputKeys(uint64_t amount, const std::vector<uint32_t>& absolute_offsets) const override { return {}; }"
530+
]
531+
}
532+
}
533+
]
534+
},
535+
{
536+
"path": "/include/IWallet.h",
537+
"changes": [
538+
{
539+
"action": "add_below",
540+
"marker": "#include \"CryptoNote.h\"",
541+
"parameters": {
542+
"text": [
543+
"#include \"BlockchainExplorerData.h\""
544+
]
545+
}
546+
},
547+
{
548+
"action": "add_below",
549+
"marker": "virtual std::vector<TransactionsInBlockInfo> getTransactions(uint32_t blockIndex, size_t count) const = 0;",
550+
"parameters": {
551+
"text": [
552+
"virtual std::vector<CryptoNote::TransactionDetails> getTransactionsDetails(const std::vector<Crypto::Hash>& txHashes) const = 0;",
553+
"virtual std::vector<Crypto::PublicKey> extractKeyOutputKeys(uint64_t amount, const std::vector<uint32_t>& absolute_offsets) const = 0;"
554+
]
555+
}
556+
}
557+
]
558+
},
559+
{
560+
"path": "/src/Wallet/WalletGreen.h",
561+
"changes": [
562+
{
563+
"action": "add_below",
564+
"marker": "virtual std::vector<TransactionsInBlockInfo> getTransactions(uint32_t blockIndex, size_t count) const override;",
565+
"parameters": {
566+
"text": [
567+
"virtual std::vector<CryptoNote::TransactionDetails> getTransactionsDetails(const std::vector<Crypto::Hash>& txHashes) const override;",
568+
"virtual std::vector<Crypto::PublicKey> extractKeyOutputKeys(uint64_t amount, const std::vector<uint32_t>& absolute_offsets) const override;"
569+
]
570+
}
571+
}
572+
]
573+
},
574+
520575

521576
{
522577
"path": "/src/Wallet/WalletGreen.cpp",
523578
"changes": [
579+
{
580+
"action": "add_above",
581+
"marker": "std::vector<TransactionsInBlockInfo> WalletGreen::getTransactions(const Crypto::Hash& blockHash, size_t count) const {",
582+
"parameters": {
583+
"text": [
584+
"std::vector<CryptoNote::TransactionDetails> WalletGreen::getTransactionsDetails(const std::vector<Crypto::Hash>& txHashes) const {",
585+
" std::vector<TransactionDetails> txs;",
586+
" System::Event requestFinished(m_dispatcher);",
587+
" std::error_code getTxsError;",
588+
"",
589+
" throwIfStopped();",
590+
"",
591+
" m_logger(DEBUGGING) << \"Requesting transactions details\";",
592+
" System::RemoteContext<void> getTransactionsContext(m_dispatcher, [this, txHashes, &txs, &requestFinished, &getTxsError] () mutable {",
593+
" m_node.getTransactions(txHashes, txs, [&requestFinished, &getTxsError, this] (std::error_code ec) mutable {",
594+
" getTxsError = ec;",
595+
" m_dispatcher.remoteSpawn(std::bind(asyncRequestCompletion, std::ref(requestFinished)));",
596+
" });",
597+
" });",
598+
" getTransactionsContext.get();",
599+
" requestFinished.wait();",
600+
"",
601+
" if (getTxsError) {",
602+
" m_logger(ERROR, BRIGHT_RED) << \"Failed to get transactions: \" << getTxsError << \", \" << getTxsError.message();",
603+
" throw std::system_error(getTxsError);",
604+
" }",
605+
"",
606+
" m_logger(DEBUGGING) << \"Transactions details received\";",
607+
"",
608+
" return txs;",
609+
"}",
610+
"",
611+
"std::vector<Crypto::PublicKey> WalletGreen::extractKeyOutputKeys(uint64_t amount, const std::vector<uint32_t>& absolute_offsets) const {",
612+
" std::vector<Crypto::PublicKey> mixin_outputs;",
613+
" System::Event requestFinished(m_dispatcher);",
614+
" std::error_code extractKeysError;",
615+
"",
616+
" throwIfStopped();",
617+
"",
618+
" m_logger(DEBUGGING) << \"Requesting transactions details\";",
619+
" System::RemoteContext<void> getTransactionsContext(m_dispatcher, [this, amount, absolute_offsets, &mixin_outputs, &requestFinished, &extractKeysError] () mutable {",
620+
" m_node.extractKeyOutputKeys(amount, absolute_offsets, mixin_outputs, [&requestFinished, &extractKeysError, this] (std::error_code ec) mutable {",
621+
" extractKeysError = ec;",
622+
" m_dispatcher.remoteSpawn(std::bind(asyncRequestCompletion, std::ref(requestFinished)));",
623+
" });",
624+
" });",
625+
" getTransactionsContext.get();",
626+
" requestFinished.wait();",
627+
"",
628+
" if (extractKeysError) {",
629+
" m_logger(ERROR, BRIGHT_RED) << \"Failed to get key output keys: \" << extractKeysError << \", \" << extractKeysError.message();",
630+
" throw std::system_error(extractKeysError);",
631+
" }",
632+
"",
633+
" m_logger(DEBUGGING) << \"Key output keys received\";",
634+
"",
635+
" return mixin_outputs;",
636+
"}",
637+
""
638+
]
639+
}
640+
},
524641
{
525642
"action": "replace",
526643
"marker": "assert(it->second.amount != 0);",
@@ -657,7 +774,7 @@
657774
"marker": "std::vector<PaymentService::TransactionsInBlockRpcInfo> convertTransactionsInBlockInfoToTransactionsInBlockRpcInfo(",
658775
"parameters": {
659776
"text": [
660-
"std::vector<PaymentService::TransactionsInBlockRpcInfo> convertTransactionsInBlockInfoToTransactionsInBlockRpcInfo(CryptoNote::INode& node, const std::unordered_set<std::string> addresses,"
777+
"std::vector<PaymentService::TransactionsInBlockRpcInfo> convertTransactionsInBlockInfoToTransactionsInBlockRpcInfo(CryptoNote::IWallet& wallet, const std::unordered_set<std::string> addresses,"
661778
]
662779
}
663780
},
@@ -666,7 +783,7 @@
666783
"marker": "PaymentService::TransactionRpcInfo convertTransactionWithTransfersToTransactionRpcInfo(",
667784
"parameters": {
668785
"text": [
669-
"PaymentService::TransactionRpcInfo convertTransactionWithTransfersToTransactionRpcInfo(CryptoNote::INode& node, const std::unordered_set<std::string> addresses,"
786+
"PaymentService::TransactionRpcInfo convertTransactionWithTransfersToTransactionRpcInfo(CryptoNote::IWallet& wallet, const std::unordered_set<std::string> addresses,"
670787
]
671788
}
672789
},
@@ -684,7 +801,7 @@
684801
"marker": "return convertTransactionsInBlockInfoToTransactionsInBlockRpcInfo(filteredTransactions);",
685802
"parameters": {
686803
"text": [
687-
" return convertTransactionsInBlockInfoToTransactionsInBlockRpcInfo(node, filter.addresses, filteredTransactions);"
804+
" return convertTransactionsInBlockInfoToTransactionsInBlockRpcInfo(wallet, filter.addresses, filteredTransactions);"
688805
]
689806
}
690807
},
@@ -693,18 +810,7 @@
693810
"marker": "PaymentService::TransactionRpcInfo transactionInfo = convertTransactionWithTransfersToTransactionRpcInfo(transactionWithTransfers);",
694811
"parameters": {
695812
"text": [
696-
" PaymentService::TransactionRpcInfo transactionInfo = convertTransactionWithTransfersToTransactionRpcInfo(node, addresses, transactionWithTransfers, known_outputs_keys);"
697-
]
698-
}
699-
},
700-
701-
702-
{
703-
"action": "add_below",
704-
"marker": "std::vector<PaymentService::TransactionsInBlockRpcInfo> rpcBlocks;",
705-
"parameters": {
706-
"text": [
707-
" std::cout << \"here\" << std::endl;"
813+
" PaymentService::TransactionRpcInfo transactionInfo = convertTransactionWithTransfersToTransactionRpcInfo(wallet, addresses, transactionWithTransfers, known_outputs_keys);"
708814
]
709815
}
710816
},
@@ -731,7 +837,7 @@
731837
"text": [
732838
" std::vector<Crypto::PublicKey> known_outputs_keys;",
733839
" std::unordered_set<std::string> addresses = {};",
734-
" transaction = convertTransactionWithTransfersToTransactionRpcInfo(node, addresses, transactionWithTransfers, known_outputs_keys);"
840+
" transaction = convertTransactionWithTransfersToTransactionRpcInfo(wallet, addresses, transactionWithTransfers, known_outputs_keys);"
735841
]
736842
}
737843
},
@@ -743,15 +849,7 @@
743849
" std::vector<Crypto::Hash> tx_ids;",
744850
" tx_ids.push_back(transactionWithTransfers.transaction.hash);",
745851
"",
746-
" std::vector<CryptoNote::TransactionDetails> txs;",
747-
748-
" CryptoNote::NodeRequest request(",
749-
" [&](const CryptoNote::INode::Callback& cb) { return node.getTransactions(tx_ids, txs, cb); });",
750-
" std::error_code ec = request.performBlocking();",
751-
" if (ec) {",
752-
"// logger(Logging::ERROR) << \"Can't get transactions by hash: \" << ec.message();",
753-
" throw std::system_error(ec);",
754-
" }",
852+
" std::vector<CryptoNote::TransactionDetails> txs = wallet.getTransactionsDetails(tx_ids);",
755853
" CryptoNote::TransactionDetails transaction = txs.front();"
756854
]
757855
}
@@ -787,7 +885,6 @@
787885
" if (transfer.amount > 0) {",
788886
" std::unordered_set<std::string>::const_iterator got = addresses.find (transfer.address);",
789887
" if (got != addresses.end()) {",
790-
"// if (!transfer.address.empty()) {",
791888
" // Populate known_outputs_keys",
792889
" known_outputs_keys.push_back(transaction.extra.publicKey);",
793890
" for (const CryptoNote::TransactionInputDetails& txinput : transaction.inputs) {",
@@ -815,19 +912,9 @@
815912
" = CryptoNote::relativeOutputOffsetsToAbsolute(txin.input.outputIndexes);",
816913
"",
817914
" // get public keys of outputs used in the mixins that match to the offests",
818-
" std::vector<Crypto::PublicKey> mixin_outputs;",
819-
"",
820-
"",
821-
" CryptoNote::NodeRequest request(",
822-
" [&](const CryptoNote::INode::Callback& cb) { return node.extractKeyOutputKeys(txin.input.amount, absolute_offsets, mixin_outputs, cb); });",
823-
" std::error_code ec = request.performBlocking();",
824-
" if (ec) {",
825-
" // logger(Logging::ERROR) << \"Can't get mixins key images: \" << ec.message();",
826-
" throw std::system_error(ec);",
827-
" }",
915+
" std::vector<Crypto::PublicKey> mixin_outputs = wallet.extractKeyOutputKeys(txin.input.amount, absolute_offsets);",
828916
" if (mixin_outputs.empty())",
829917
" {",
830-
"// logger(Logging::ERROR) << \"Mixins key images not found\" << endl;",
831918
" continue;",
832919
" }",
833920
"",
@@ -843,7 +930,6 @@
843930
" Crypto::PublicKey output_publicKey = mixin_outputs.at(count);",
844931
" // check here for known keys",
845932
" if (!(std::find(known_outputs_keys.begin(), known_outputs_keys.end(), output_publicKey) != known_outputs_keys.end())) {",
846-
"// TODO: this slow is down for some reason",
847933
" ++count;",
848934
" continue;",
849935
" }",
@@ -917,6 +1003,16 @@
9171003
"description": "Adding extractKeyOutputKeys to INode",
9181004
"path": "/src/InProcessNode/InProcessNode.cpp",
9191005
"changes": [
1006+
{
1007+
"action": "add_above",
1008+
"marker": "#include <future>",
1009+
"parameters": {
1010+
"text": [
1011+
"//remove",
1012+
"#include <iostream>"
1013+
]
1014+
}
1015+
},
9201016
{
9211017
"action": "add_above",
9221018
"marker": "void InProcessNode::getTransactions(const std::vector<Crypto::Hash>& transactionHashes,",
@@ -1179,8 +1275,6 @@
11791275
}
11801276
]
11811277
},
1182-
1183-
11841278
{
11851279
"description": "Adding extractKeyOutputKeys to INode",
11861280
"path": "/tests/UnitTests/ICoreStub.h",
@@ -1271,7 +1365,7 @@
12711365

12721366

12731367
{
1274-
"description": "Adding extractKeyOutputKeys to INode. ",
1368+
"description": "Adding extractKeyOutputKeys to INode",
12751369
"path": "/src/CryptoNoteCore/IBlockchainCache.h",
12761370
"changes": [
12771371
{
@@ -1287,7 +1381,7 @@
12871381
]
12881382
},
12891383
{
1290-
"description": "Adding extractKeyOutputKeys to INode. ",
1384+
"description": "Adding extractKeyOutputKeys to INode",
12911385
"path": "/src/CryptoNoteCore/BlockchainCache.h",
12921386
"changes": [
12931387
{
@@ -1303,7 +1397,7 @@
13031397
]
13041398
},
13051399
{
1306-
"description": "Adding extractKeyOutputKeys to INode. ",
1400+
"description": "Adding extractKeyOutputKeys to INode",
13071401
"path": "/src/CryptoNoteCore/DatabaseBlockchainCache.h",
13081402
"changes": [
13091403
{
@@ -1322,7 +1416,7 @@
13221416
]
13231417
},
13241418
{
1325-
"description": "Adding extractKeyOutputKeys to INode. ",
1419+
"description": "Adding extractKeyOutputKeys to INode",
13261420
"path": "/src/CryptoNoteCore/BlockchainCache.cpp",
13271421
"changes": [
13281422
{
@@ -1359,7 +1453,7 @@
13591453
]
13601454
},
13611455
{
1362-
"description": "Adding extractKeyOutputKeys to INode. ",
1456+
"description": "Adding extractKeyOutputKeys to INode",
13631457
"path": "/src/CryptoNoteCore/DatabaseBlockchainCache.cpp",
13641458
"changes": [
13651459
{

extensions/zawy-difficulty-algorithm.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,10 @@
212212

213213
" uint64_t nextDiffZ = low / timeSpan;",
214214
"",
215+
" if (nextDiffZ <= 100) {",
216+
" nextDiffZ = 100;",
217+
" }",
218+
"",
215219
" return nextDiffZ;",
216220
" }",
217221
""

0 commit comments

Comments
 (0)