From 41fee1edc2db330e7371e866a78691fa80592658 Mon Sep 17 00:00:00 2001 From: techgoku Date: Mon, 16 Jan 2023 13:11:13 +0530 Subject: [PATCH 1/3] Flash Tx from client Handled --- src/lws/src/rest_server.cpp | 9 +++++++-- src/lws/src/rpc/light_wallet.cpp | 4 +++- src/lws/src/rpc/light_wallet.h | 1 + 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/lws/src/rest_server.cpp b/src/lws/src/rest_server.cpp index 85c09291dcc..60e2f68460f 100644 --- a/src/lws/src/rest_server.cpp +++ b/src/lws/src/rest_server.cpp @@ -713,7 +713,12 @@ namespace lws transaction_rpc::request daemon_req{}; daemon_req.do_not_relay = false; - daemon_req.tx_as_hex = std::move(req.tx); // Flash Transcation need to be enabled in future + daemon_req.tx_as_hex = std::move(req.tx); + if(req.flash == true){ + daemon_req.flash = true; + }else{ + daemon_req.flash =false; + }// Handles Flash Method from Client // epee::byte_slice message = rpc::client::make_message("send_raw_tx_hex", daemon_req); // MONERO_CHECK(client->send(std::move(message), std::chrono::seconds{10})); @@ -721,7 +726,7 @@ namespace lws {"jsonrpc","2.0"}, {"id","0"}, {"method","send_raw_transaction"}, - {"params",{{"tx_as_hex",daemon_req.tx_as_hex},{"do_not_relay",daemon_req.do_not_relay}}} + {"params",{{"tx_as_hex",daemon_req.tx_as_hex},{"do_not_relay",daemon_req.do_not_relay},{"flash",daemon_req.flash}}} }; // std::cout <<"message : " << message.dump() << std::endl; auto resp = cpr::Post(cpr::Url{"http://127.0.0.1:19091/json_rpc"}, diff --git a/src/lws/src/rpc/light_wallet.cpp b/src/lws/src/rpc/light_wallet.cpp index f0a7a0004d3..852ac4629c6 100644 --- a/src/lws/src/rpc/light_wallet.cpp +++ b/src/lws/src/rpc/light_wallet.cpp @@ -310,7 +310,9 @@ namespace lws void rpc::read_bytes(wire::json_reader& source, submit_raw_tx_request& self) { - wire::object(source, WIRE_FIELD(tx)); + wire::object(source, WIRE_FIELD(tx), + WIRE_OPTIONAL_FIELD(flash) + ); } void rpc::write_bytes(wire::json_writer& dest, const submit_raw_tx_response self) { diff --git a/src/lws/src/rpc/light_wallet.h b/src/lws/src/rpc/light_wallet.h index a52809de6db..392408892d8 100644 --- a/src/lws/src/rpc/light_wallet.h +++ b/src/lws/src/rpc/light_wallet.h @@ -170,6 +170,7 @@ namespace rpc { submit_raw_tx_request() = delete; std::string tx; + boost::optional flash; }; void read_bytes(wire::json_reader&, submit_raw_tx_request&); From cdd7ba1528165c39b67cd723a19313dd3fe9758b Mon Sep 17 00:00:00 2001 From: techgoku Date: Tue, 17 Jan 2023 19:04:18 +0530 Subject: [PATCH 2/3] flash method handled for client --- src/lws/src/rest_server.cpp | 5 +++-- src/lws/src/rpc/light_wallet.cpp | 2 +- src/lws/src/rpc/light_wallet.h | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/lws/src/rest_server.cpp b/src/lws/src/rest_server.cpp index 60e2f68460f..a8f57c881dc 100644 --- a/src/lws/src/rest_server.cpp +++ b/src/lws/src/rest_server.cpp @@ -713,8 +713,9 @@ namespace lws transaction_rpc::request daemon_req{}; daemon_req.do_not_relay = false; - daemon_req.tx_as_hex = std::move(req.tx); - if(req.flash == true){ + daemon_req.tx_as_hex = std::move(req.tx); + if(req.fee == "5") + { daemon_req.flash = true; }else{ daemon_req.flash =false; diff --git a/src/lws/src/rpc/light_wallet.cpp b/src/lws/src/rpc/light_wallet.cpp index 852ac4629c6..56fee2fe14a 100644 --- a/src/lws/src/rpc/light_wallet.cpp +++ b/src/lws/src/rpc/light_wallet.cpp @@ -311,7 +311,7 @@ namespace lws void rpc::read_bytes(wire::json_reader& source, submit_raw_tx_request& self) { wire::object(source, WIRE_FIELD(tx), - WIRE_OPTIONAL_FIELD(flash) + WIRE_FIELD(fee) ); } void rpc::write_bytes(wire::json_writer& dest, const submit_raw_tx_response self) diff --git a/src/lws/src/rpc/light_wallet.h b/src/lws/src/rpc/light_wallet.h index 392408892d8..8455916f2a3 100644 --- a/src/lws/src/rpc/light_wallet.h +++ b/src/lws/src/rpc/light_wallet.h @@ -170,7 +170,7 @@ namespace rpc { submit_raw_tx_request() = delete; std::string tx; - boost::optional flash; + std::string fee; }; void read_bytes(wire::json_reader&, submit_raw_tx_request&); From 38f53cde665e0d7aa9006498fe43a1dcf926854c Mon Sep 17 00:00:00 2001 From: victor-tucci Date: Sat, 25 Feb 2023 18:46:43 +0530 Subject: [PATCH 3/3] Remove unused sock file connection --- src/lws/src/scanner.cpp | 13 +++---------- src/lws/src/scanner.h | 4 ++-- src/lws/src/server_main.cpp | 5 ++--- 3 files changed, 7 insertions(+), 15 deletions(-) diff --git a/src/lws/src/scanner.cpp b/src/lws/src/scanner.cpp index 6ae68efb8da..7b8214392c2 100644 --- a/src/lws/src/scanner.cpp +++ b/src/lws/src/scanner.cpp @@ -718,17 +718,10 @@ namespace lws } }//anonymous - void scanner::sync(db::storage disk,lws::rpc::Connection connection) + void scanner::sync(db::storage disk) { try { - if(!connection.daemon_connected) - { - MERROR("Daemon not connected so stop action called"); - lws::scanner::stop(); - } - MINFO("Starting blockchain sync with daemon"); - json details; int a =0; std::vector blk_ids; @@ -807,7 +800,7 @@ namespace lws } } - void scanner::run(db::storage disk, std::size_t thread_count,lws::rpc::Connection connection) + void scanner::run(db::storage disk, std::size_t thread_count) { thread_count = std::max(std::size_t(1), thread_count); @@ -868,7 +861,7 @@ namespace lws // client = MONERO_UNWRAP(ctx.connect()); // expect synced = sync(disk.clone(), std::move(client)); - sync(disk.clone(), connection); + sync(disk.clone()); // if (!synced) // { // if (!synced.matches(std::errc::timed_out)) diff --git a/src/lws/src/scanner.h b/src/lws/src/scanner.h index 7cef687a33f..d23dfef4d24 100644 --- a/src/lws/src/scanner.h +++ b/src/lws/src/scanner.h @@ -18,10 +18,10 @@ namespace lws public: //! Use `client` to sync blockchain data, and \return client if successful. - static void sync(db::storage disk,lws::rpc::Connection connection); + static void sync(db::storage disk); //! Poll daemon until `stop()` is called, using `thread_count` threads. - static void run(db::storage disk, std::size_t thread_count,lws::rpc::Connection connection); + static void run(db::storage disk, std::size_t thread_count); //! \return True if `stop()` has never been called. static bool is_running() noexcept { return running; } diff --git a/src/lws/src/server_main.cpp b/src/lws/src/server_main.cpp index 569c10fc4d2..eae5729b93e 100644 --- a/src/lws/src/server_main.cpp +++ b/src/lws/src/server_main.cpp @@ -166,12 +166,11 @@ namespace std::signal(SIGINT, [] (int) { lws::scanner::stop(); }); fs::create_directories(prog.db_path); auto disk = lws::db::storage::open(prog.db_path.c_str(), prog.create_queue_max); - lws::rpc::Connection connection = lws::rpc::connect_daemon(); - lws::scanner::sync(disk.clone(),connection); + lws::scanner::sync(disk.clone()); lws::rest_server server{epee::to_span(prog.rest_servers), disk.clone(), std::move(prog.rest_config)}; // blocks until SIGINT - lws::scanner::run(std::move(disk), prog.scan_threads,connection); + lws::scanner::run(std::move(disk), prog.scan_threads); } } // anonymous