Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update with explorer and some bugfixes #45

Merged
merged 18 commits into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@ jobs:
$asset_path = "./$build_folder/src/Release/$release_name.zip"
mkdir "$release_name"
cp *.exe "$release_name/"
echo "::set-output name=sha256::${sha256}"
echo "::set-output name=release_name::${release_name}.zip"
echo "::set-output name=asset_path::${asset_path}"
echo "::set-output name=krb_ver::${krb_ver}"
echo "::set-output name=artifact_path::$build_folder/src/Release/$release_name"
echo "sha256=${sha256}" >> $env:GITHUB_OUTPUT
echo "release_name=${release_name}.zip" >> $env:GITHUB_OUTPUT
echo "asset_path=${asset_path}" >> $env:GITHUB_OUTPUT
echo "krb_ver=${krb_ver}" >> $env:GITHUB_OUTPUT
echo "artifact_path=$build_folder/src/Release/$release_name" >> $env:GITHUB_OUTPUT

- name: Upload To GH Artifacts
uses: actions/upload-artifact@v1.0.0
uses: actions/upload-artifact@v3
with:
name: ${{ steps.build.outputs.release_name }}
path: ${{ steps.build.outputs.artifact_path }}
Expand Down Expand Up @@ -133,20 +133,20 @@ jobs:
for f in src/*; do [[ -x $f && -f $f ]] && exeFiles+=( "$f" ); done
strip "${exeFiles[@]}"
cp "${exeFiles[@]}" "$release_name/"
echo "::set-output name=release_name::${release_name}"
echo "::set-output name=artifact_path::$build_folder/$release_name"
echo "release_name=${release_name}" >> $GITHUB_OUTPUT
echo "artifact_path=$build_folder/$release_name" >> $GITHUB_OUTPUT

- name: Upload To GH Artifacts
uses: actions/upload-artifact@v1.0.0
uses: actions/upload-artifact@v3
with:
name: ${{ steps.build.outputs.release_name }}
path: ${{ steps.build.outputs.artifact_path }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

build-ubuntu18:
name: Ubuntu 18.04
runs-on: ubuntu-18.04
build-ubuntu22:
name: Ubuntu 22.04
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@master
with:
Expand All @@ -160,7 +160,7 @@ jobs:
sudo apt install -y libboost-all-dev libssl-dev
build_folder="build/release"
krb_ver=${GITHUB_SHA::7}
release_name="Karbo-cli-ubuntu18.04-${krb_ver}"
release_name="Karbo-cli-ubuntu22.04-${krb_ver}"
mkdir -p "$build_folder"
cd "$build_folder"
cmake -D ARCH=default -D CMAKE_BUILD_TYPE=Release -D CMAKE_POSITION_INDEPENDENT_CODE:BOOL=true ../..
Expand All @@ -170,11 +170,11 @@ jobs:
for f in src/*; do [[ -x $f && -f $f ]] && exeFiles+=( "$f" ); done
strip "${exeFiles[@]}"
cp "${exeFiles[@]}" "$release_name/"
echo "::set-output name=release_name::${release_name}"
echo "::set-output name=artifact_path::$build_folder/$release_name"
echo "release_name=${release_name}" >> $GITHUB_OUTPUT
echo "artifact_path=$build_folder/$release_name" >> $GITHUB_OUTPUT

- name: Upload To GH Artifacts
uses: actions/upload-artifact@v1.0.0
uses: actions/upload-artifact@v3
with:
name: ${{ steps.build.outputs.release_name }}
path: ${{ steps.build.outputs.artifact_path }}
Expand Down
40 changes: 20 additions & 20 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ jobs:
Compress-Archive -Path *.exe -DestinationPath "$release_name.zip"
$sha256 = (Get-FileHash "$release_name.zip").Hash
$asset_path = "./$build_folder/src/Release/$release_name.zip"
echo "::set-output name=sha256::${sha256}"
echo "::set-output name=release_name::${release_name}.zip"
echo "::set-output name=asset_path::${asset_path}"
echo "::set-output name=krb_ver::${krb_ver}"
echo "sha256=${sha256}" >> $env:GITHUB_OUTPUT
echo "release_name=${release_name}.zip" >> $env:GITHUB_OUTPUT
echo "asset_path=${asset_path}" >> $env:GITHUB_OUTPUT
echo "krb_ver=${krb_ver}" >> $env:GITHUB_OUTPUT

- name: Create Release
uses: softprops/[email protected]
Expand Down Expand Up @@ -89,10 +89,10 @@ jobs:
zip -r "$release_name".zip "$release_name"
sha256=$(shasum -a 256 "$release_name".zip | awk '{print toupper($1)}')
asset_path="./$build_folder$release_name.zip"
echo "::set-output name=sha256::${sha256}"
echo "::set-output name=release_name::${release_name}.zip"
echo "::set-output name=asset_path::${asset_path}"
echo "::set-output name=krb_ver::${krb_ver}"
echo "sha256=${sha256}" >> $GITHUB_OUTPUT
echo "release_name=${release_name}.zip" >> $GITHUB_OUTPUT
echo "asset_path=${asset_path}" >> $GITHUB_OUTPUT
echo "krb_ver=${krb_ver}" >> $GITHUB_OUTPUT

- name: Create Release
uses: softprops/[email protected]
Expand All @@ -105,9 +105,9 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

build-ubuntu18:
name: Ubuntu 18.04
runs-on: ubuntu-18.04
build-ubuntu22:
name: Ubuntu 22.04
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@master
with:
Expand All @@ -121,7 +121,7 @@ jobs:
sudo apt install -y libboost-all-dev libssl-dev
build_folder="build/release"
krb_ver=$(echo "$GITHUB_REF" | sed 's|refs/tags/||')
release_name="Karbo-cli-ubuntu18.04-${krb_ver}"
release_name="Karbo-cli-ubuntu22.04-${krb_ver}"
mkdir -p "$build_folder"
cd "$build_folder"
cmake -D ARCH=default -D CMAKE_BUILD_TYPE=Release -D CMAKE_POSITION_INDEPENDENT_CODE:BOOL=true ../..
Expand All @@ -135,10 +135,10 @@ jobs:
cd ..
sha256=$(shasum -a 256 "$release_name".tar.gz | awk '{print toupper($1)}')
asset_path="./$build_folder/$release_name.tar.gz"
echo "::set-output name=sha256::${sha256}"
echo "::set-output name=release_name::${release_name}.tar.gz"
echo "::set-output name=asset_path::${asset_path}"
echo "::set-output name=krb_ver::${krb_ver}"
echo "sha256=${sha256}" >> $GITHUB_OUTPUT
echo "release_name=${release_name}.tar.gz" >> $GITHUB_OUTPUT
echo "asset_path=${asset_path}" >> $GITHUB_OUTPUT
echo "krb_ver=${krb_ver}" >> $GITHUB_OUTPUT

- name: Create Release
uses: softprops/[email protected]
Expand Down Expand Up @@ -181,10 +181,10 @@ jobs:
cd ..
sha256=$(shasum -a 256 "$release_name".tar.gz | awk '{print toupper($1)}')
asset_path="./$build_folder/$release_name.tar.gz"
echo "::set-output name=sha256::${sha256}"
echo "::set-output name=release_name::${release_name}.tar.gz"
echo "::set-output name=asset_path::${asset_path}"
echo "::set-output name=krb_ver::${krb_ver}"
echo "sha256=${sha256}" >> $GITHUB_OUTPUT
echo "release_name=${release_name}.tar.gz" >> $GITHUB_OUTPUT
echo "asset_path=${asset_path}" >> $GITHUB_OUTPUT
echo "krb_ver=${krb_ver}" >> $GITHUB_OUTPUT

- name: Create Release
uses: softprops/[email protected]
Expand Down
3 changes: 1 addition & 2 deletions external/linenoise/linenoise.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1683,8 +1683,7 @@ inline bool enableRawMode(int fd) {
}

GetConsoleMode(hIn, &consolemodeIn);
DWORD consolemodeInWithRaw = consolemodeIn & ~ENABLE_PROCESSED_INPUT;
SetConsoleMode(hIn, consolemodeInWithRaw);
SetConsoleMode(hIn, consolemodeIn & ~ENABLE_PROCESSED_INPUT);

rawmode = true;
#endif
Expand Down
5 changes: 0 additions & 5 deletions src/AddressGenerator/vanitygen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,11 +246,6 @@ int main(int argc, char** argv) {

System::Dispatcher dispatcher;

#ifdef _WIN32
std::string consoletitle = std::string(CryptoNote::CRYPTONOTE_NAME) + " address generator v. " + std::string(PROJECT_VERSION_LONG);
SetConsoleTitleA(consoletitle.c_str());
#endif

std::string coinName(CryptoNote::CRYPTONOTE_NAME);
std::cout << InformationMsg(coinName + " address generator v. " + std::string(PROJECT_VERSION)) << std::endl;

Expand Down
4 changes: 2 additions & 2 deletions src/Common/ConsoleHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ bool AsyncConsoleReader::waitInput() {
#else
while (!m_stop.load(std::memory_order_relaxed))
{
int retval = ::WaitForSingleObject(::GetStdHandle(STD_INPUT_HANDLE), 100);
DWORD retval = ::WaitForSingleObject(::GetStdHandle(STD_INPUT_HANDLE), 100);
switch (retval)
{
case WAIT_FAILED:
Expand Down Expand Up @@ -188,7 +188,7 @@ void ConsoleHandler::unpause() {
void ConsoleHandler::wait() {

try {
if (m_thread.joinable()) {
if (m_thread.joinable() && m_thread.get_id() != std::this_thread::get_id()) {
m_thread.join();
}
} catch (std::exception& e) {
Expand Down
75 changes: 37 additions & 38 deletions src/Common/FormatTools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,8 @@ std::string formatAmount(uint64_t amount)
{
std::string s = std::to_string(amount);
if (s.size() < numberOfDecimalPlaces + 1)
{
s.insert(0, numberOfDecimalPlaces + 1 - s.size(), '0');
{
s.insert(0, numberOfDecimalPlaces + 1 - s.size(), '0');
}
s.insert(s.size() - numberOfDecimalPlaces, ".");
return s;
Expand All @@ -174,9 +174,8 @@ std::string formatAmount(int64_t amount)
{
std::string s = formatAmount(static_cast<uint64_t>(std::abs(amount)));

if (amount < 0)
{
s.insert(0, "-");
if (amount < 0) {
s.insert(0, "-");
}

return s;
Expand Down Expand Up @@ -224,39 +223,39 @@ std::string unixTimeToDate(const uint64_t timestamp)
}

bool parseAmount(const std::string& str, uint64_t& amount) {
std::string strAmount = str;
boost::algorithm::trim(strAmount);

size_t pointIndex = strAmount.find_first_of('.');
size_t fractionSize;
if (std::string::npos != pointIndex) {
fractionSize = strAmount.size() - pointIndex - 1;
while (numberOfDecimalPlaces < fractionSize && '0' == strAmount.back()) {
strAmount.erase(strAmount.size() - 1, 1);
--fractionSize;
}
if (numberOfDecimalPlaces < fractionSize) {
return false;
}
strAmount.erase(pointIndex, 1);
}
else {
fractionSize = 0;
}

if (strAmount.empty()) {
return false;
}

if (!std::all_of(strAmount.begin(), strAmount.end(), ::isdigit)) {
return false;
}

if (fractionSize < numberOfDecimalPlaces) {
strAmount.append(numberOfDecimalPlaces - fractionSize, '0');
}

return Common::fromString(strAmount, amount);
std::string strAmount = str;
boost::algorithm::trim(strAmount);

size_t pointIndex = strAmount.find_first_of('.');
size_t fractionSize;
if (std::string::npos != pointIndex) {
fractionSize = strAmount.size() - pointIndex - 1;
while (numberOfDecimalPlaces < fractionSize && '0' == strAmount.back()) {
strAmount.erase(strAmount.size() - 1, 1);
--fractionSize;
}
if (numberOfDecimalPlaces < fractionSize) {
return false;
}
strAmount.erase(pointIndex, 1);
}
else {
fractionSize = 0;
}

if (strAmount.empty()) {
return false;
}

if (!std::all_of(strAmount.begin(), strAmount.end(), ::isdigit)) {
return false;
}

if (fractionSize < numberOfDecimalPlaces) {
strAmount.append(numberOfDecimalPlaces - fractionSize, '0');
}

return Common::fromString(strAmount, amount);
}

} // namespace Common
6 changes: 3 additions & 3 deletions src/Common/FormatTools.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ namespace Common
const uint64_t target_height);

std::string formatAmountWithTicker(const uint64_t amount);

std::string formatAmount(uint64_t amount);

std::string formatAmount(int64_t amount);
std::string formatAmount(uint64_t amount);

std::string formatAmount(int64_t amount);

std::string formatAmountBasic(const uint64_t amount);

Expand Down
1 change: 1 addition & 0 deletions src/Common/Math.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#pragma once

#include <algorithm>
#include <limits>
#include <vector>
#include "StringTools.h"

Expand Down
3 changes: 3 additions & 0 deletions src/CryptoNoteCore/Core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,9 @@ void Core::getTransactions(const std::vector<Crypto::Hash>& transactionHashes, s
assert(segment != nullptr);

std::vector<Crypto::Hash> leftTransactions = transactionHashes;
if (leftTransactions.empty()) {
return;
}

// find in main chain
do {
Expand Down
2 changes: 2 additions & 0 deletions src/CryptoNoteCore/UpgradeDetector.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
#include "CryptoNoteConfig.h"
#include <Logging/LoggerRef.h>

#undef ERROR

namespace CryptoNote {
class UpgradeDetectorBase {
public:
Expand Down
8 changes: 3 additions & 5 deletions src/CryptoNoteProtocol/CryptoNoteProtocolHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ int CryptoNoteProtocolHandler::handle_notify_new_transactions(int command, NOTIF
if (!post_notify<NOTIFY_NEW_TRANSACTIONS>(*m_p2p, arg, dandelion_peer)) {
arg.stem = false;
logger(Logging::DEBUGGING) << "Failed to relay transactions to Dandelion peer "
<< dandelion_peer.m_connection_id << ", remove from stempool and broadcast as fluff:";
<< dandelion_peer.m_remote_ip << ", remove from stempool and broadcast as fluff:";
for (const auto& h : txHashes) {
m_stemPool.removeTransaction(h);
logger(Logging::DEBUGGING) << h;
Expand Down Expand Up @@ -1123,9 +1123,7 @@ void CryptoNoteProtocolHandler::relayTransactions(const std::vector<BinaryArray>
if (!m_stemPool.hasTransaction(transactionHash)) {
logger(Logging::DEBUGGING) << "Adding relayed transaction " << transactionHash << " to stempool";
BinaryArray txblob = *tx_blob_it;
m_dispatcher.remoteSpawn([this, transactionHash, txblob] {
m_stemPool.addTransaction(transactionHash, txblob);
});
m_stemPool.addTransaction(transactionHash, txblob);
txHashes.push_back(transactionHash);
}
}
Expand All @@ -1138,7 +1136,7 @@ void CryptoNoteProtocolHandler::relayTransactions(const std::vector<BinaryArray>
if (dandelion_peer.m_state == CryptoNoteConnectionContext::state_normal || dandelion_peer.m_state == CryptoNoteConnectionContext::state_synchronizing) {
if (!post_notify<NOTIFY_NEW_TRANSACTIONS>(*m_p2p, r, dandelion_peer)) {
logger(Logging::WARNING, Logging::BRIGHT_YELLOW) << "Failed to relay transactions to Dandelion peer "
<< dandelion_peer.m_connection_id << ", broadcasting in dandelion fluff mode";
<< dandelion_peer.m_remote_ip << ", broadcasting in dandelion fluff mode";
r.stem = false;
for (const auto& h : txHashes) {
m_stemPool.removeTransaction(h);
Expand Down
Loading
Loading