Skip to content

Commit

Permalink
Merge pull request #2 from victor-tucci/Flash-implementation
Browse files Browse the repository at this point in the history
Flash implementation and remove unused sock connection
  • Loading branch information
victor-tucci authored Feb 25, 2023
2 parents 45e5644 + 38f53cd commit d646ba4
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 18 deletions.
10 changes: 8 additions & 2 deletions src/lws/src/rest_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -713,15 +713,21 @@ 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.fee == "5")
{
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}));
json message = {
{"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"},
Expand Down
4 changes: 3 additions & 1 deletion src/lws/src/rpc/light_wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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_FIELD(fee)
);
}
void rpc::write_bytes(wire::json_writer& dest, const submit_raw_tx_response self)
{
Expand Down
1 change: 1 addition & 0 deletions src/lws/src/rpc/light_wallet.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ namespace rpc
{
submit_raw_tx_request() = delete;
std::string tx;
std::string fee;
};
void read_bytes(wire::json_reader&, submit_raw_tx_request&);

Expand Down
13 changes: 3 additions & 10 deletions src/lws/src/scanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<crypto::hash> blk_ids;
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -868,7 +861,7 @@ namespace lws
// client = MONERO_UNWRAP(ctx.connect());

// expect<rpc::client> synced = sync(disk.clone(), std::move(client));
sync(disk.clone(), connection);
sync(disk.clone());
// if (!synced)
// {
// if (!synced.matches(std::errc::timed_out))
Expand Down
4 changes: 2 additions & 2 deletions src/lws/src/scanner.h
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
5 changes: 2 additions & 3 deletions src/lws/src/server_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d646ba4

Please sign in to comment.