Skip to content

Commit

Permalink
fixed mac crash during wallet starting up (#399)
Browse files Browse the repository at this point in the history
  • Loading branch information
npq7721 authored Aug 27, 2024
1 parent fd73990 commit d94533d
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 15 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -351,12 +351,12 @@ jobs:
run: |
echo "building with 8 threads"
export FALLBACK_DOWNLOAD_PATH=https://pool.nowput.org/depends/
make -C depends -j8 HOST=x86_64-apple-darwin20.6.0
make -C depends -j8 HOST=x86_64-apple-darwin21.6.0
- name: Configure
run: |
./autogen.sh
./configure --prefix=`pwd`/depends/x86_64-apple-darwin20.6.0
./configure --prefix=`pwd`/depends/x86_64-apple-darwin21.6.0
- name: Build Binaries
run: |
Expand Down
3 changes: 2 additions & 1 deletion src/qt/assetsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,8 @@ void AssetsDialog::displayImage(const std::string& cid) {
ui->referenceDisplay->setToolTip(QString::fromStdString(cid));
ui->referenceDisplay->setOpenExternalLinks(false);
} else {
std::string displayUrl = "<a href=\"" + IPFS_GATEWAY_URL + cid + "\">" + cid + "</a>";
std::string ipfsGatewayUrl = gArgs.GetArg("-ipfsgateway", DEFAULT_IPFS_GATEWAY_URL);
std::string displayUrl = "<a href=\"" + ipfsGatewayUrl + cid + "\">" + cid + "</a>";
ui->referenceDisplay->setText(QString::fromStdString(displayUrl));
ui->referenceDisplay->setToolTip("");
ui->referenceDisplay->setOpenExternalLinks(true);
Expand Down
16 changes: 9 additions & 7 deletions src/qt/uploaddownload.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// Created by tri on 8/8/24.
//
// Copyright (c) 2024 The Raptoreum developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#include <qt/uploaddownload.h>

Expand Down Expand Up @@ -93,13 +93,14 @@ void graceful_disconnect(beast::ssl_stream<beast::tcp_stream>& stream) {

void download(const std::string cid, std::string& response_data) {
std::string getTarget = GET_URI + cid;
std::string ipfsServiceHost = gArgs.GetArg("-ipfsservice", DEFAULT_IPFS_SERVICE_URL);
try {
net::io_context ioc;
ssl::context ctx = setup_ssl_context();
beast::ssl_stream<beast::tcp_stream> stream = create_and_connect_ssl_stream(ioc, IPFS_SERVICE_HOST, "443", ctx);
beast::ssl_stream<beast::tcp_stream> stream = create_and_connect_ssl_stream(ioc, ipfsServiceHost, "443", ctx);

http::request<http::empty_body> req{http::verb::get, getTarget, 11};
req.set(http::field::host, IPFS_SERVICE_HOST);
req.set(http::field::host, ipfsServiceHost);
req.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING);

response_data = write_response(stream, req);
Expand All @@ -114,7 +115,8 @@ void upload(const std::string& file_path, std::string& response_data) {
try {
net::io_context ioc;
ssl::context ctx = setup_ssl_context();
beast::ssl_stream <beast::tcp_stream> stream = create_and_connect_ssl_stream(ioc, IPFS_SERVICE_HOST, "443", ctx);
std::string ipfsServiceHost = gArgs.GetArg("-ipfsservice", DEFAULT_IPFS_SERVICE_URL);
beast::ssl_stream <beast::tcp_stream> stream = create_and_connect_ssl_stream(ioc, ipfsServiceHost, "443", ctx);

// Generate a boundary for the multipart form data
std::string boundary = generate_boundary();
Expand All @@ -138,7 +140,7 @@ void upload(const std::string& file_path, std::string& response_data) {
std::string body_str = body.str();

http::request <http::string_body> req{http::verb::post, UPLOAD_URI, 11};
req.set(http::field::host, IPFS_SERVICE_HOST);
req.set(http::field::host, ipfsServiceHost);
req.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING);
req.set(http::field::content_type, "multipart/form-data; boundary=" + boundary);
req.set(http::field::content_length, std::to_string(body_str.size()));
Expand Down
10 changes: 5 additions & 5 deletions src/qt/uploaddownload.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// Created by tri on 8/8/24.
//
// Copyright (c) 2024 The Raptoreum developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#ifndef RAPTOREUM_UPLOAD_DOWNLOAD_H
#define RAPTOREUM_UPLOAD_DOWNLOAD_H
Expand All @@ -14,8 +14,8 @@

static std::string GET_URI = "/get/";
static std::string UPLOAD_URI = "/upload";
static std::string IPFS_SERVICE_HOST = gArgs.GetArg("-ipfsservice", "ipfsm.raptoreum.com");
static std::string IPFS_GATEWAY_URL = gArgs.GetArg("-ipfsgateway", "https://ipfsweb.raptoreum.com/ipfs/");
static std::string DEFAULT_IPFS_SERVICE_URL = "ipfsm.raptoreum.com";
static std::string DEFAULT_IPFS_GATEWAY_URL = "https://ipfsweb.raptoreum.com/ipfs/";

void download(const std::string cid, std::string& response_data);
void upload(const std::string& file_path, std::string& response_data);
Expand Down

0 comments on commit d94533d

Please sign in to comment.