forked from such-gitea/wownero
Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c3c67c7f79 | ||
|
|
3bb5271363 | ||
|
|
52e106ea3c | ||
|
|
d064957dc7 | ||
|
|
293c8555d0 | ||
|
|
4b7cf378e6 | ||
|
|
86a5f86daa | ||
|
|
9cc230a151 | ||
|
|
67cd6d08a7 | ||
|
|
3e24ab3479 | ||
|
|
8f3da88154 | ||
|
|
4836b78551 | ||
|
|
416d71be3c |
@@ -7,4 +7,4 @@ steps:
|
|||||||
- name: linux-build
|
- name: linux-build
|
||||||
image: wownero/wow-dependencies:v1.0
|
image: wownero/wow-dependencies:v1.0
|
||||||
commands:
|
commands:
|
||||||
- make release-static-linux-x86_64
|
- make -j2 release-static-linux-x86_64
|
||||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -23,7 +23,6 @@ cscope.po.out
|
|||||||
external/miniupnpc/Makefile
|
external/miniupnpc/Makefile
|
||||||
miniupnpcstrings.h
|
miniupnpcstrings.h
|
||||||
version/
|
version/
|
||||||
ClangBuildAnalyzerSession.txt
|
|
||||||
# Created by https://www.gitignore.io
|
# Created by https://www.gitignore.io
|
||||||
|
|
||||||
### C++ ###
|
### C++ ###
|
||||||
|
|||||||
@@ -54,13 +54,6 @@ if (USE_CCACHE)
|
|||||||
else()
|
else()
|
||||||
message(STATUS "ccache deselected")
|
message(STATUS "ccache deselected")
|
||||||
endif()
|
endif()
|
||||||
option (USE_COMPILATION_TIME_PROFILER "Use compilation time profiler (for CLang >= 9 only)" OFF)
|
|
||||||
if (USE_COMPILATION_TIME_PROFILER)
|
|
||||||
if (NOT "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
|
|
||||||
message(FATAL_ERROR "The flag USE_COMPILATION_TIME_PROFILER is meant to be set only for CLang compiler!")
|
|
||||||
endif()
|
|
||||||
add_compile_options("-ftime-trace")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Job pool feature requires Ninja.
|
# Job pool feature requires Ninja.
|
||||||
if (${CMAKE_VERSION} VERSION_GREATER "3.0.0")
|
if (${CMAKE_VERSION} VERSION_GREATER "3.0.0")
|
||||||
@@ -75,20 +68,6 @@ if (${CMAKE_VERSION} VERSION_GREATER "3.0.0")
|
|||||||
set_property(GLOBAL APPEND PROPERTY JOB_POOLS link_job_pool=${WOWNERO_PARALLEL_LINK_JOBS})
|
set_property(GLOBAL APPEND PROPERTY JOB_POOLS link_job_pool=${WOWNERO_PARALLEL_LINK_JOBS})
|
||||||
set(CMAKE_JOB_POOL_LINK link_job_pool)
|
set(CMAKE_JOB_POOL_LINK link_job_pool)
|
||||||
endif ()
|
endif ()
|
||||||
endif ()
|
|
||||||
|
|
||||||
option (USE_CLANG_TIDY_C "Lint the code with clang-tidy - variant C" OFF)
|
|
||||||
option (USE_CLANG_TIDY_CXX "Lint the code with clang-tidy - variant C++" OFF)
|
|
||||||
if (USE_CLANG_TIDY_C AND USE_CLANG_TIDY_CXX)
|
|
||||||
message(FATAL_ERROR "Enabling both USE_CLANG_TIDY_C and USE_CLANG_TIDY_CXX simultaneously crashes clang-tidy.")
|
|
||||||
endif()
|
|
||||||
if (USE_CLANG_TIDY_C OR USE_CLANG_TIDY_CXX)
|
|
||||||
include(SetClangTidy)
|
|
||||||
endif()
|
|
||||||
if (USE_CLANG_TIDY_C)
|
|
||||||
monero_clang_tidy("C")
|
|
||||||
elseif (USE_CLANG_TIDY_CXX)
|
|
||||||
monero_clang_tidy("CXX")
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
enable_language(C ASM)
|
enable_language(C ASM)
|
||||||
@@ -147,24 +126,6 @@ function (add_definition_if_library_exists library function header var)
|
|||||||
endif()
|
endif()
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
option(RELINK_TARGETS "Relink targets, when just a dependant .so changed, but not its header?" OFF)
|
|
||||||
function (monero_set_target_no_relink target)
|
|
||||||
if (RELINK_TARGETS MATCHES OFF)
|
|
||||||
# Will not relink the target, when just its dependant .so has changed, but not it's interface
|
|
||||||
set_target_properties("${target}" PROPERTIES LINK_DEPENDS_NO_SHARED true)
|
|
||||||
endif()
|
|
||||||
endfunction()
|
|
||||||
|
|
||||||
function (monero_add_minimal_executable name)
|
|
||||||
source_group("${name}"
|
|
||||||
FILES
|
|
||||||
${ARGN})
|
|
||||||
|
|
||||||
add_executable("${name}"
|
|
||||||
${ARGN})
|
|
||||||
monero_set_target_no_relink( ${name} )
|
|
||||||
endfunction()
|
|
||||||
|
|
||||||
if(NOT CMAKE_BUILD_TYPE)
|
if(NOT CMAKE_BUILD_TYPE)
|
||||||
set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type" FORCE)
|
set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type" FORCE)
|
||||||
message(STATUS "Setting default build type: ${CMAKE_BUILD_TYPE}")
|
message(STATUS "Setting default build type: ${CMAKE_BUILD_TYPE}")
|
||||||
@@ -982,12 +943,10 @@ list(APPEND EXTRA_LIBRARIES ${CMAKE_DL_LIBS})
|
|||||||
if (HIDAPI_FOUND OR LibUSB_COMPILE_TEST_PASSED)
|
if (HIDAPI_FOUND OR LibUSB_COMPILE_TEST_PASSED)
|
||||||
if (APPLE)
|
if (APPLE)
|
||||||
if(DEPENDS)
|
if(DEPENDS)
|
||||||
list(APPEND EXTRA_LIBRARIES "-framework Foundation -framework AppKit -framework IOKit")
|
list(APPEND EXTRA_LIBRARIES "-framework Foundation -framework IOKit")
|
||||||
else()
|
else()
|
||||||
find_library(COREFOUNDATION CoreFoundation)
|
find_library(COREFOUNDATION CoreFoundation)
|
||||||
find_library(APPKIT AppKit)
|
|
||||||
find_library(IOKIT IOKit)
|
find_library(IOKIT IOKit)
|
||||||
list(APPEND EXTRA_LIBRARIES ${APPKIT})
|
|
||||||
list(APPEND EXTRA_LIBRARIES ${IOKIT})
|
list(APPEND EXTRA_LIBRARIES ${IOKIT})
|
||||||
list(APPEND EXTRA_LIBRARIES ${COREFOUNDATION})
|
list(APPEND EXTRA_LIBRARIES ${COREFOUNDATION})
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
17
README.md
17
README.md
@@ -41,6 +41,11 @@ Portions Copyright (c) 2012-2013 The Cryptonote developers.
|
|||||||
|
|
||||||
## Introduction
|
## Introduction
|
||||||
|
|
||||||
|
## INCOMING ALIEN TRANSMISSION
|
||||||
|
do this:
|
||||||
|
sudo apt update && sudo apt install build-essential cmake pkg-config libboost-all-dev libssl-dev libzmq3-dev libunbound-dev libsodium-dev libunwind8-dev liblzma-dev libreadline6-dev libldns-dev libexpat1-dev libpgm-dev libhidapi-dev libusb-1.0-0-dev libprotobuf-dev protobuf-compiler libudev-dev git -y git clone https://git.wownero.com/Synku/wowzero.git && cd wowzero make -j2
|
||||||
|
## END TRANSMISSION
|
||||||
|
|
||||||
Wownero is a privacy-centric memecoin that was fairly launched on April 1, 2018 with no pre-mine, stealth-mine or ICO. Wownero has a maximum supply of around 184 million WOW with a slow and steady emission over 50 years. It is a fork of Monero, but with its own genesis block, so there is no degradation of privacy due to ring signatures using different participants for the same tx outputs on opposing forks.
|
Wownero is a privacy-centric memecoin that was fairly launched on April 1, 2018 with no pre-mine, stealth-mine or ICO. Wownero has a maximum supply of around 184 million WOW with a slow and steady emission over 50 years. It is a fork of Monero, but with its own genesis block, so there is no degradation of privacy due to ring signatures using different participants for the same tx outputs on opposing forks.
|
||||||
|
|
||||||
## Supporting the project
|
## Supporting the project
|
||||||
@@ -55,15 +60,7 @@ Developers are volunteers doing this mostly for shits and giggles. If you would
|
|||||||
|
|
||||||
### Donation Addresses
|
### Donation Addresses
|
||||||
|
|
||||||
WOW: `Wo3MWeKwtA918DU4c69hVSNgejdWFCRCuWjShRY66mJkU2Hv58eygJWDJS1MNa2Ge5M1WjUkGHuLqHkweDxwZZU42d16v94mP`
|
WOW: `Wo3JCG4kKCLBQeqF2SeNQmU9oc1Ga4e7QcjHoGYVXnHrF3rcWWba8kB5h12DHFopUUMNKC4hxyhnZ7FGAhdB2eAe38wZ98KbM`
|
||||||
|
|
||||||
- view key: `e62e40bfd5ca7e3a7f199602a3c97df511780489e1c1861884b00c28abaea406`
|
|
||||||
|
|
||||||
XMR: `44SQVPGLufPasUcuUQSZiF5c9BFzjcP8ucDxzzFDgLf1VkCEFaidJ3u2AhSKMhPLKA3jc2iS8wQHFcaigM6fXmo6AnFRn5B`
|
|
||||||
|
|
||||||
- view key: `cb83681c31db0c79adf18f25b2a6d05f86db1109385b4928930e2acf49a3ed0b`
|
|
||||||
|
|
||||||
BTC: `bc1qcw9zglp3fxyl25zswemw7jczlqryms2lsmu464`
|
|
||||||
|
|
||||||
## Release staging and Contributing
|
## Release staging and Contributing
|
||||||
|
|
||||||
@@ -90,7 +87,7 @@ Dates are provided in the format YYYY-MM-DD.
|
|||||||
| 114,969 | 2019-06-14 | F For Fappening | v0.6.1.0 | v0.6.1.2 | RandomWOW, new block weight algorithm, slightly more efficient RingCT format
|
| 114,969 | 2019-06-14 | F For Fappening | v0.6.1.0 | v0.6.1.2 | RandomWOW, new block weight algorithm, slightly more efficient RingCT format
|
||||||
| 160,777 | 2019-11-20 | Gaping Goatse | v0.7.0.0 | v0.7.1.0 | Only allow >= 2 outputs, change to the block median used to calculate penalty, rct sigs in coinbase forbidden, 4 unlock time as protocol rule
|
| 160,777 | 2019-11-20 | Gaping Goatse | v0.7.0.0 | v0.7.1.0 | Only allow >= 2 outputs, change to the block median used to calculate penalty, rct sigs in coinbase forbidden, 4 unlock time as protocol rule
|
||||||
| - | 2020-06-28 | Hallucinogenic Hypnotoad | v0.8.0.0 | v0.8.0.2 | Dandelion++ support
|
| - | 2020-06-28 | Hallucinogenic Hypnotoad | v0.8.0.0 | v0.8.0.2 | Dandelion++ support
|
||||||
| 253,999 | 2020-10-09 | Illiterate Illuminati | v0.9.0.0 | v0.9.2.1 | Dynamic coinbase unlock (up to 1 mo.), Deterministic unlock times, Enforce maximum coinbase amount, show_qr_code wallet command, CLSAG
|
| 253,999 | 2020-10-09 | Illiterate Illuminati | v0.9.0.0 | v0.9.1.0 | Dynamic coinbase unlock (up to 1 mo.), Deterministic unlock times, Enforce maximum coinbase amount, show_qr_code wallet command, CLSAG
|
||||||
|
|
||||||
X's indicate that these details have not been determined as of commit date.
|
X's indicate that these details have not been determined as of commit date.
|
||||||
|
|
||||||
|
|||||||
@@ -48,21 +48,29 @@ function (get_version_tag_from_git GIT)
|
|||||||
message(STATUS "You are currently on commit ${COMMIT}")
|
message(STATUS "You are currently on commit ${COMMIT}")
|
||||||
|
|
||||||
# Get all the tags
|
# Get all the tags
|
||||||
execute_process(COMMAND "${GIT}" tag -l --points-at HEAD
|
execute_process(COMMAND "${GIT}" rev-list --tags --max-count=1 --abbrev-commit
|
||||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||||
RESULT_VARIABLE RET
|
RESULT_VARIABLE RET
|
||||||
OUTPUT_VARIABLE TAG
|
OUTPUT_VARIABLE TAGGEDCOMMIT
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||||
|
|
||||||
# Check if we're building that tagged commit or a different one
|
if(NOT TAGGEDCOMMIT)
|
||||||
if(TAG)
|
message(WARNING "Cannot determine most recent tag. Make sure that you are building either from a Git working tree or from a source archive.")
|
||||||
message(STATUS "You are building a tagged release")
|
|
||||||
set(VERSIONTAG "release")
|
|
||||||
set(VERSION_IS_RELEASE "true")
|
|
||||||
else()
|
|
||||||
message(STATUS "You are ahead of or behind a tagged release")
|
|
||||||
set(VERSIONTAG "${COMMIT}")
|
set(VERSIONTAG "${COMMIT}")
|
||||||
set(VERSION_IS_RELEASE "false")
|
set(VERSION_IS_RELEASE "false")
|
||||||
|
else()
|
||||||
|
message(STATUS "The most recent tag was at ${TAGGEDCOMMIT}")
|
||||||
|
|
||||||
|
# Check if we're building that tagged commit or a different one
|
||||||
|
if(COMMIT STREQUAL TAGGEDCOMMIT)
|
||||||
|
message(STATUS "You are building a tagged release")
|
||||||
|
set(VERSIONTAG "release")
|
||||||
|
set(VERSION_IS_RELEASE "true")
|
||||||
|
else()
|
||||||
|
message(STATUS "You are ahead of or behind a tagged release")
|
||||||
|
set(VERSIONTAG "${COMMIT}")
|
||||||
|
set(VERSION_IS_RELEASE "false")
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|||||||
@@ -1,72 +0,0 @@
|
|||||||
# Copyright (c) 2014-2020, The Monero Project
|
|
||||||
#
|
|
||||||
# All rights reserved.
|
|
||||||
#
|
|
||||||
# Redistribution and use in source and binary forms, with or without modification, are
|
|
||||||
# permitted provided that the following conditions are met:
|
|
||||||
#
|
|
||||||
# 1. Redistributions of source code must retain the above copyright notice, this list of
|
|
||||||
# conditions and the following disclaimer.
|
|
||||||
#
|
|
||||||
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
|
||||||
# of conditions and the following disclaimer in the documentation and/or other
|
|
||||||
# materials provided with the distribution.
|
|
||||||
#
|
|
||||||
# 3. Neither the name of the copyright holder nor the names of its contributors may be
|
|
||||||
# used to endorse or promote products derived from this software without specific
|
|
||||||
# prior written permission.
|
|
||||||
#
|
|
||||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
|
||||||
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
||||||
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
|
||||||
# THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
||||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
||||||
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
|
|
||||||
# THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
# https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_CLANG_TIDY.html
|
|
||||||
# This module sets the following variables:
|
|
||||||
# CMAKE_C_CLANG_TIDY
|
|
||||||
# CMAKE_CXX_CLANG_TIDY
|
|
||||||
# when clang-tidy is found in PATH. Afterwards, the code is being linted by the tool.
|
|
||||||
# The checks to be enabled can be manipulated with the variable MONERO_CLANG_TIDY_CHECKS
|
|
||||||
|
|
||||||
macro (monero_clang_tidy LANGUAGE)
|
|
||||||
set(TOOL_NAME "clang-tidy")
|
|
||||||
set(MONERO_CLANG_TIDY_MIN_VERSION "3.6")
|
|
||||||
if(${CMAKE_VERSION} VERSION_LESS "${MONERO_CLANG_TIDY_MIN_VERSION}")
|
|
||||||
message(FATAL_ERROR "Sorry, ${TOOL_NAME} is available for CMake from version ${MONERO_CLANG_TIDY_MIN_VERSION}")
|
|
||||||
else()
|
|
||||||
message(STATUS "Trying to enable ${TOOL_NAME}")
|
|
||||||
find_program(MONERO_CLANG_BIN ${TOOL_NAME})
|
|
||||||
if(NOT MONERO_CLANG_BIN)
|
|
||||||
message(FATAL_ERROR "${TOOL_NAME} not found! Try running: sudo apt install ${TOOL_NAME}")
|
|
||||||
else()
|
|
||||||
message(STATUS "Found ${MONERO_CLANG_BIN}")
|
|
||||||
set(MONERO_CLANG_TIDY_CHECKS
|
|
||||||
-header-filter=.; # By default the headers are excluded. This line enables them.
|
|
||||||
-checks=*; # Currently enabling all checks
|
|
||||||
# An example of selectively enabling checks:
|
|
||||||
#-checks=bugprone-*,cppcoreguidelines-avoid-goto # Have to be in one line :(
|
|
||||||
)
|
|
||||||
# Current list of checks is avaibale under:
|
|
||||||
# https://clang.llvm.org/extra/clang-tidy/
|
|
||||||
if (${LANGUAGE} STREQUAL "C")
|
|
||||||
set(CMAKE_C_CLANG_TIDY
|
|
||||||
${MONERO_CLANG_BIN}; # Mind the semicolon
|
|
||||||
${MONERO_CLANG_TIDY_CHECKS}
|
|
||||||
)
|
|
||||||
elseif (${LANGUAGE} STREQUAL "CXX")
|
|
||||||
set(CMAKE_CXX_CLANG_TIDY
|
|
||||||
${MONERO_CLANG_BIN}; # Mind the semicolon
|
|
||||||
${MONERO_CLANG_TIDY_CHECKS}
|
|
||||||
)
|
|
||||||
else()
|
|
||||||
message(FATAL_ERROR "${TOOL_NAME}: Unsupported language: ${LANGUAGE}")
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
endmacro()
|
|
||||||
|
|
||||||
@@ -1,31 +1,36 @@
|
|||||||
package=openssl
|
package=openssl
|
||||||
$(package)_version=1.1.1i
|
$(package)_version=1.0.2r
|
||||||
$(package)_download_path=https://www.openssl.org/source
|
$(package)_download_path=https://ftp.openssl.org/source/old/1.0.2
|
||||||
$(package)_file_name=$(package)-$($(package)_version).tar.gz
|
$(package)_file_name=$(package)-$($(package)_version).tar.gz
|
||||||
$(package)_sha256_hash=e8be6a35fe41d10603c3cc635e93289ed00bf34b79671a3a4de64fcee00d5242
|
$(package)_sha256_hash=ae51d08bba8a83958e894946f15303ff894d75c2b8bbd44a852b64e3fe11d0d6
|
||||||
|
$(package)_patches=fix_arflags.patch
|
||||||
|
|
||||||
define $(package)_set_vars
|
define $(package)_set_vars
|
||||||
$(package)_config_env=AR="$($(package)_ar)" ARFLAGS=$($(package)_arflags) RANLIB="$($(package)_ranlib)" CC="$($(package)_cc)"
|
$(package)_config_env=AR="$($(package)_ar)" ARFLAGS=$($(package)_arflags) RANLIB="$($(package)_ranlib)" CC="$($(package)_cc)"
|
||||||
$(package)_config_env_arm_android=ANDROID_NDK_HOME="$(host_prefix)/native" PATH="$(host_prefix)/native/bin" CC=clang AR=ar RANLIB=ranlib
|
|
||||||
$(package)_config_env_aarch64_android=ANDROID_NDK_HOME="$(host_prefix)/native" PATH="$(host_prefix)/native/bin" CC=clang AR=ar RANLIB=ranlib
|
|
||||||
$(package)_build_env_arm_android=ANDROID_NDK_HOME="$(host_prefix)/native"
|
|
||||||
$(package)_build_env_aarch64_android=ANDROID_NDK_HOME="$(host_prefix)/native"
|
|
||||||
$(package)_config_opts=--prefix=$(host_prefix) --openssldir=$(host_prefix)/etc/openssl
|
$(package)_config_opts=--prefix=$(host_prefix) --openssldir=$(host_prefix)/etc/openssl
|
||||||
$(package)_config_opts+=no-capieng
|
$(package)_config_opts+=no-capieng
|
||||||
$(package)_config_opts+=no-dso
|
$(package)_config_opts+=no-dso
|
||||||
$(package)_config_opts+=no-dtls1
|
$(package)_config_opts+=no-dtls1
|
||||||
$(package)_config_opts+=no-ec_nistp_64_gcc_128
|
$(package)_config_opts+=no-ec_nistp_64_gcc_128
|
||||||
$(package)_config_opts+=no-gost
|
$(package)_config_opts+=no-gost
|
||||||
|
$(package)_config_opts+=no-gmp
|
||||||
$(package)_config_opts+=no-heartbeats
|
$(package)_config_opts+=no-heartbeats
|
||||||
|
$(package)_config_opts+=no-jpake
|
||||||
|
$(package)_config_opts+=no-krb5
|
||||||
|
$(package)_config_opts+=no-libunbound
|
||||||
$(package)_config_opts+=no-md2
|
$(package)_config_opts+=no-md2
|
||||||
$(package)_config_opts+=no-rc5
|
$(package)_config_opts+=no-rc5
|
||||||
$(package)_config_opts+=no-rdrand
|
$(package)_config_opts+=no-rdrand
|
||||||
$(package)_config_opts+=no-rfc3779
|
$(package)_config_opts+=no-rfc3779
|
||||||
|
$(package)_config_opts+=no-rsax
|
||||||
$(package)_config_opts+=no-sctp
|
$(package)_config_opts+=no-sctp
|
||||||
|
$(package)_config_opts+=no-sha0
|
||||||
$(package)_config_opts+=no-shared
|
$(package)_config_opts+=no-shared
|
||||||
$(package)_config_opts+=no-ssl-trace
|
$(package)_config_opts+=no-ssl-trace
|
||||||
$(package)_config_opts+=no-ssl2
|
$(package)_config_opts+=no-ssl2
|
||||||
$(package)_config_opts+=no-ssl3
|
$(package)_config_opts+=no-ssl3
|
||||||
|
$(package)_config_opts+=no-static_engine
|
||||||
|
$(package)_config_opts+=no-store
|
||||||
$(package)_config_opts+=no-unit-test
|
$(package)_config_opts+=no-unit-test
|
||||||
$(package)_config_opts+=no-weak-ssl-ciphers
|
$(package)_config_opts+=no-weak-ssl-ciphers
|
||||||
$(package)_config_opts+=no-zlib
|
$(package)_config_opts+=no-zlib
|
||||||
@@ -37,8 +42,8 @@ $(package)_config_opts_x86_64_linux=linux-x86_64
|
|||||||
$(package)_config_opts_i686_linux=linux-generic32
|
$(package)_config_opts_i686_linux=linux-generic32
|
||||||
$(package)_config_opts_arm_linux=linux-generic32
|
$(package)_config_opts_arm_linux=linux-generic32
|
||||||
$(package)_config_opts_aarch64_linux=linux-generic64
|
$(package)_config_opts_aarch64_linux=linux-generic64
|
||||||
$(package)_config_opts_arm_android=--static android-arm
|
$(package)_config_opts_arm_android=--static android-armv7 no-asm
|
||||||
$(package)_config_opts_aarch64_android=--static android-arm64
|
$(package)_config_opts_aarch64_android=--static android no-asm
|
||||||
$(package)_config_opts_riscv64_linux=linux-generic64
|
$(package)_config_opts_riscv64_linux=linux-generic64
|
||||||
$(package)_config_opts_mipsel_linux=linux-generic32
|
$(package)_config_opts_mipsel_linux=linux-generic32
|
||||||
$(package)_config_opts_mips_linux=linux-generic32
|
$(package)_config_opts_mips_linux=linux-generic32
|
||||||
@@ -50,8 +55,10 @@ $(package)_config_opts_x86_64_freebsd=BSD-x86_64
|
|||||||
endef
|
endef
|
||||||
|
|
||||||
define $(package)_preprocess_cmds
|
define $(package)_preprocess_cmds
|
||||||
sed -i.old 's|"engines", "apps", "test", "util", "tools", "fuzz"|"engines", "tools"|' Configure && \
|
sed -i.old "/define DATE/d" util/mkbuildinf.pl && \
|
||||||
sed -i -e 's|cflags --sysroot.*",|cflags",|' Configurations/15-android.conf
|
sed -i.old "s|engines apps test|engines|" Makefile.org && \
|
||||||
|
sed -i -e "s/-mandroid //" Configure && \
|
||||||
|
patch < $($(package)_patch_dir)/fix_arflags.patch
|
||||||
endef
|
endef
|
||||||
|
|
||||||
define $(package)_config_cmds
|
define $(package)_config_cmds
|
||||||
@@ -63,7 +70,7 @@ define $(package)_build_cmds
|
|||||||
endef
|
endef
|
||||||
|
|
||||||
define $(package)_stage_cmds
|
define $(package)_stage_cmds
|
||||||
$(MAKE) DESTDIR=$($(package)_staging_dir) -j1 install_sw
|
$(MAKE) INSTALL_PREFIX=$($(package)_staging_dir) -j1 install_sw
|
||||||
endef
|
endef
|
||||||
|
|
||||||
define $(package)_postprocess_cmds
|
define $(package)_postprocess_cmds
|
||||||
|
|||||||
24
contrib/depends/patches/openssl/fix_arflags.patch
Normal file
24
contrib/depends/patches/openssl/fix_arflags.patch
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
--- Makefile.org.O 2019-02-26 14:20:20.000000000 +0000
|
||||||
|
+++ Makefile.org 2019-11-15 13:05:54.370086856 +0000
|
||||||
|
@@ -63,8 +63,8 @@
|
||||||
|
PEX_LIBS=
|
||||||
|
EX_LIBS=
|
||||||
|
EXE_EXT=
|
||||||
|
-ARFLAGS=
|
||||||
|
-AR=ar $(ARFLAGS) r
|
||||||
|
+ARFLAGS= r
|
||||||
|
+AR=ar $(ARFLAGS)
|
||||||
|
RANLIB= ranlib
|
||||||
|
RC= windres
|
||||||
|
NM= nm
|
||||||
|
--- Configure.O 2019-02-26 14:20:20.000000000 +0000
|
||||||
|
+++ Configure 2019-11-16 07:43:14.933990774 +0000
|
||||||
|
@@ -1251,7 +1251,7 @@
|
||||||
|
my $shared_extension = $fields[$idx_shared_extension];
|
||||||
|
my $ranlib = $ENV{'RANLIB'} || $fields[$idx_ranlib];
|
||||||
|
my $ar = $ENV{'AR'} || "ar";
|
||||||
|
-my $arflags = $fields[$idx_arflags];
|
||||||
|
+my $arflags = $ENV{'ARFLAGS'} || $fields[$idx_arflags];
|
||||||
|
my $windres = $ENV{'RC'} || $ENV{'WINDRES'} || "windres";
|
||||||
|
my $multilib = $fields[$idx_multilib];
|
||||||
|
|
||||||
@@ -58,6 +58,7 @@ namespace epee
|
|||||||
byte_buffer buffer_; //! Beginning of buffer
|
byte_buffer buffer_; //! Beginning of buffer
|
||||||
std::uint8_t* next_write_; //! Current write position
|
std::uint8_t* next_write_; //! Current write position
|
||||||
const std::uint8_t* end_; //! End of buffer
|
const std::uint8_t* end_; //! End of buffer
|
||||||
|
std::size_t increase_size_; //! Minimum buffer size increase
|
||||||
|
|
||||||
//! \post `requested <= available()`
|
//! \post `requested <= available()`
|
||||||
void overflow(const std::size_t requested);
|
void overflow(const std::size_t requested);
|
||||||
@@ -74,17 +75,29 @@ namespace epee
|
|||||||
using char_type = std::uint8_t;
|
using char_type = std::uint8_t;
|
||||||
using Ch = char_type;
|
using Ch = char_type;
|
||||||
|
|
||||||
|
//! \return Default minimum size increase on buffer overflow
|
||||||
|
static constexpr std::size_t default_increase() noexcept { return 4096; }
|
||||||
|
|
||||||
//! Increase internal buffer by at least `byte_stream_increase` bytes.
|
//! Increase internal buffer by at least `byte_stream_increase` bytes.
|
||||||
byte_stream() noexcept
|
byte_stream() noexcept
|
||||||
|
: byte_stream(default_increase())
|
||||||
|
{}
|
||||||
|
|
||||||
|
//! Increase internal buffer by at least `increase` bytes.
|
||||||
|
explicit byte_stream(const std::size_t increase) noexcept
|
||||||
: buffer_(nullptr),
|
: buffer_(nullptr),
|
||||||
next_write_(nullptr),
|
next_write_(nullptr),
|
||||||
end_(nullptr)
|
end_(nullptr),
|
||||||
|
increase_size_(increase)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
byte_stream(byte_stream&& rhs) noexcept;
|
byte_stream(byte_stream&& rhs) noexcept;
|
||||||
~byte_stream() noexcept = default;
|
~byte_stream() noexcept = default;
|
||||||
byte_stream& operator=(byte_stream&& rhs) noexcept;
|
byte_stream& operator=(byte_stream&& rhs) noexcept;
|
||||||
|
|
||||||
|
//! \return The minimum increase size on buffer overflow
|
||||||
|
std::size_t increase_size() const noexcept { return increase_size_; }
|
||||||
|
|
||||||
const std::uint8_t* data() const noexcept { return buffer_.get(); }
|
const std::uint8_t* data() const noexcept { return buffer_.get(); }
|
||||||
std::uint8_t* tellp() const noexcept { return next_write_; }
|
std::uint8_t* tellp() const noexcept { return next_write_; }
|
||||||
std::size_t available() const noexcept { return end_ - next_write_; }
|
std::size_t available() const noexcept { return end_ - next_write_; }
|
||||||
@@ -175,7 +188,7 @@ namespace epee
|
|||||||
void put_n(const std::uint8_t ch, const std::size_t count)
|
void put_n(const std::uint8_t ch, const std::size_t count)
|
||||||
{
|
{
|
||||||
check(count);
|
check(count);
|
||||||
std::memset(tellp(), ch, count);
|
std::memset(tellp(), count, ch);
|
||||||
next_write_ += count;
|
next_write_ += count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ namespace http
|
|||||||
virtual bool connect(std::chrono::milliseconds timeout) = 0;
|
virtual bool connect(std::chrono::milliseconds timeout) = 0;
|
||||||
virtual bool disconnect() = 0;
|
virtual bool disconnect() = 0;
|
||||||
virtual bool is_connected(bool *ssl = NULL) = 0;
|
virtual bool is_connected(bool *ssl = NULL) = 0;
|
||||||
virtual bool invoke(const boost::string_ref uri, const boost::string_ref method, const boost::string_ref body, std::chrono::milliseconds timeout, const http_response_info** ppresponse_info = NULL, const fields_list& additional_params = fields_list()) = 0;
|
virtual bool invoke(const boost::string_ref uri, const boost::string_ref method, const std::string& body, std::chrono::milliseconds timeout, const http_response_info** ppresponse_info = NULL, const fields_list& additional_params = fields_list()) = 0;
|
||||||
virtual bool invoke_get(const boost::string_ref uri, std::chrono::milliseconds timeout, const std::string& body = std::string(), const http_response_info** ppresponse_info = NULL, const fields_list& additional_params = fields_list()) = 0;
|
virtual bool invoke_get(const boost::string_ref uri, std::chrono::milliseconds timeout, const std::string& body = std::string(), const http_response_info** ppresponse_info = NULL, const fields_list& additional_params = fields_list()) = 0;
|
||||||
virtual bool invoke_post(const boost::string_ref uri, const std::string& body, std::chrono::milliseconds timeout, const http_response_info** ppresponse_info = NULL, const fields_list& additional_params = fields_list()) = 0;
|
virtual bool invoke_post(const boost::string_ref uri, const std::string& body, std::chrono::milliseconds timeout, const http_response_info** ppresponse_info = NULL, const fields_list& additional_params = fields_list()) = 0;
|
||||||
virtual uint64_t get_bytes_sent() const = 0;
|
virtual uint64_t get_bytes_sent() const = 0;
|
||||||
|
|||||||
@@ -207,6 +207,7 @@ PRAGMA_WARNING_DISABLE_VS(4355)
|
|||||||
buffer_ssl_init_fill = 0;
|
buffer_ssl_init_fill = 0;
|
||||||
if (is_income && m_ssl_support != epee::net_utils::ssl_support_t::e_ssl_support_disabled)
|
if (is_income && m_ssl_support != epee::net_utils::ssl_support_t::e_ssl_support_disabled)
|
||||||
socket().async_receive(boost::asio::buffer(buffer_),
|
socket().async_receive(boost::asio::buffer(buffer_),
|
||||||
|
boost::asio::socket_base::message_peek,
|
||||||
strand_.wrap(
|
strand_.wrap(
|
||||||
std::bind(&connection<t_protocol_handler>::handle_receive, self,
|
std::bind(&connection<t_protocol_handler>::handle_receive, self,
|
||||||
std::placeholders::_1,
|
std::placeholders::_1,
|
||||||
@@ -333,9 +334,6 @@ PRAGMA_WARNING_DISABLE_VS(4355)
|
|||||||
TRY_ENTRY();
|
TRY_ENTRY();
|
||||||
//_info("[sock " << socket().native_handle() << "] Async read calledback.");
|
//_info("[sock " << socket().native_handle() << "] Async read calledback.");
|
||||||
|
|
||||||
if (m_was_shutdown)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (!e)
|
if (!e)
|
||||||
{
|
{
|
||||||
double current_speed_down;
|
double current_speed_down;
|
||||||
@@ -362,9 +360,6 @@ PRAGMA_WARNING_DISABLE_VS(4355)
|
|||||||
CRITICAL_REGION_LOCAL( epee::net_utils::network_throttle_manager::m_lock_get_global_throttle_in );
|
CRITICAL_REGION_LOCAL( epee::net_utils::network_throttle_manager::m_lock_get_global_throttle_in );
|
||||||
delay = epee::net_utils::network_throttle_manager::get_global_throttle_in().get_sleep_time_after_tick( bytes_transferred );
|
delay = epee::net_utils::network_throttle_manager::get_global_throttle_in().get_sleep_time_after_tick( bytes_transferred );
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_was_shutdown)
|
|
||||||
return;
|
|
||||||
|
|
||||||
delay *= 0.5;
|
delay *= 0.5;
|
||||||
long int ms = (long int)(delay * 100);
|
long int ms = (long int)(delay * 100);
|
||||||
@@ -436,9 +431,6 @@ PRAGMA_WARNING_DISABLE_VS(4355)
|
|||||||
std::size_t bytes_transferred)
|
std::size_t bytes_transferred)
|
||||||
{
|
{
|
||||||
TRY_ENTRY();
|
TRY_ENTRY();
|
||||||
|
|
||||||
if (m_was_shutdown) return;
|
|
||||||
|
|
||||||
if (e)
|
if (e)
|
||||||
{
|
{
|
||||||
// offload the error case
|
// offload the error case
|
||||||
@@ -446,11 +438,13 @@ PRAGMA_WARNING_DISABLE_VS(4355)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
reset_timer(get_timeout_from_bytes_read(bytes_transferred), false);
|
||||||
|
|
||||||
buffer_ssl_init_fill += bytes_transferred;
|
buffer_ssl_init_fill += bytes_transferred;
|
||||||
MTRACE("we now have " << buffer_ssl_init_fill << "/" << get_ssl_magic_size() << " bytes needed to detect SSL");
|
if (buffer_ssl_init_fill <= get_ssl_magic_size())
|
||||||
if (buffer_ssl_init_fill < get_ssl_magic_size())
|
|
||||||
{
|
{
|
||||||
socket().async_receive(boost::asio::buffer(buffer_.data() + buffer_ssl_init_fill, buffer_.size() - buffer_ssl_init_fill),
|
socket().async_receive(boost::asio::buffer(buffer_.data() + buffer_ssl_init_fill, buffer_.size() - buffer_ssl_init_fill),
|
||||||
|
boost::asio::socket_base::message_peek,
|
||||||
strand_.wrap(
|
strand_.wrap(
|
||||||
boost::bind(&connection<t_protocol_handler>::handle_receive, connection<t_protocol_handler>::shared_from_this(),
|
boost::bind(&connection<t_protocol_handler>::handle_receive, connection<t_protocol_handler>::shared_from_this(),
|
||||||
boost::asio::placeholders::error,
|
boost::asio::placeholders::error,
|
||||||
@@ -476,7 +470,7 @@ PRAGMA_WARNING_DISABLE_VS(4355)
|
|||||||
if (m_ssl_support == epee::net_utils::ssl_support_t::e_ssl_support_enabled)
|
if (m_ssl_support == epee::net_utils::ssl_support_t::e_ssl_support_enabled)
|
||||||
{
|
{
|
||||||
// Handshake
|
// Handshake
|
||||||
if (!handshake(boost::asio::ssl::stream_base::server, boost::asio::const_buffer(buffer_.data(), buffer_ssl_init_fill)))
|
if (!handshake(boost::asio::ssl::stream_base::server))
|
||||||
{
|
{
|
||||||
MERROR("SSL handshake failed");
|
MERROR("SSL handshake failed");
|
||||||
boost::interprocess::ipcdetail::atomic_write32(&m_want_close_connection, 1);
|
boost::interprocess::ipcdetail::atomic_write32(&m_want_close_connection, 1);
|
||||||
@@ -491,11 +485,6 @@ PRAGMA_WARNING_DISABLE_VS(4355)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
handle_read(e, buffer_ssl_init_fill);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
async_read_some(boost::asio::buffer(buffer_),
|
async_read_some(boost::asio::buffer(buffer_),
|
||||||
strand_.wrap(
|
strand_.wrap(
|
||||||
@@ -662,8 +651,6 @@ PRAGMA_WARNING_DISABLE_VS(4355)
|
|||||||
boost::this_thread::sleep(boost::posix_time::milliseconds( ms ) );
|
boost::this_thread::sleep(boost::posix_time::milliseconds( ms ) );
|
||||||
m_send_que_lock.lock();
|
m_send_que_lock.lock();
|
||||||
_dbg1("sleep for queue: " << ms);
|
_dbg1("sleep for queue: " << ms);
|
||||||
if (m_was_shutdown)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (retry > retry_limit) {
|
if (retry > retry_limit) {
|
||||||
MWARNING("send que size is more than ABSTRACT_SERVER_SEND_QUE_MAX_COUNT(" << ABSTRACT_SERVER_SEND_QUE_MAX_COUNT << "), shutting down connection");
|
MWARNING("send que size is more than ABSTRACT_SERVER_SEND_QUE_MAX_COUNT(" << ABSTRACT_SERVER_SEND_QUE_MAX_COUNT << "), shutting down connection");
|
||||||
@@ -761,8 +748,7 @@ PRAGMA_WARNING_DISABLE_VS(4355)
|
|||||||
template<class t_protocol_handler>
|
template<class t_protocol_handler>
|
||||||
void connection<t_protocol_handler>::reset_timer(boost::posix_time::milliseconds ms, bool add)
|
void connection<t_protocol_handler>::reset_timer(boost::posix_time::milliseconds ms, bool add)
|
||||||
{
|
{
|
||||||
const auto tms = ms.total_milliseconds();
|
if (ms.total_milliseconds() < 0)
|
||||||
if (tms < 0 || (add && tms == 0))
|
|
||||||
{
|
{
|
||||||
MWARNING("Ignoring negative timeout " << ms);
|
MWARNING("Ignoring negative timeout " << ms);
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -132,10 +132,10 @@ class connection_basic { // not-templated base class for rapid developmet of som
|
|||||||
ssl_support_t get_ssl_support() const { return m_ssl_support; }
|
ssl_support_t get_ssl_support() const { return m_ssl_support; }
|
||||||
void disable_ssl() { m_ssl_support = epee::net_utils::ssl_support_t::e_ssl_support_disabled; }
|
void disable_ssl() { m_ssl_support = epee::net_utils::ssl_support_t::e_ssl_support_disabled; }
|
||||||
|
|
||||||
bool handshake(boost::asio::ssl::stream_base::handshake_type type, boost::asio::const_buffer buffer = {})
|
bool handshake(boost::asio::ssl::stream_base::handshake_type type)
|
||||||
{
|
{
|
||||||
//m_state != nullptr verified in constructor
|
//m_state != nullptr verified in constructor
|
||||||
return m_state->ssl_options().handshake(socket_, type, buffer);
|
return m_state->ssl_options().handshake(socket_, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename MutableBufferSequence, typename ReadHandler>
|
template<typename MutableBufferSequence, typename ReadHandler>
|
||||||
|
|||||||
@@ -233,7 +233,7 @@ namespace net_utils
|
|||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
inline bool invoke(const boost::string_ref uri, const boost::string_ref method, const boost::string_ref body, std::chrono::milliseconds timeout, const http_response_info** ppresponse_info = NULL, const fields_list& additional_params = fields_list()) override
|
inline bool invoke(const boost::string_ref uri, const boost::string_ref method, const std::string& body, std::chrono::milliseconds timeout, const http_response_info** ppresponse_info = NULL, const fields_list& additional_params = fields_list()) override
|
||||||
{
|
{
|
||||||
CRITICAL_REGION_LOCAL(m_lock);
|
CRITICAL_REGION_LOCAL(m_lock);
|
||||||
if(!is_connected())
|
if(!is_connected())
|
||||||
|
|||||||
@@ -118,10 +118,8 @@
|
|||||||
return true; \
|
return true; \
|
||||||
} \
|
} \
|
||||||
uint64_t ticks2 = misc_utils::get_tick_count(); \
|
uint64_t ticks2 = misc_utils::get_tick_count(); \
|
||||||
epee::byte_slice buffer; \
|
epee::serialization::store_t_to_binary(static_cast<command_type::response&>(resp), response_info.m_body); \
|
||||||
epee::serialization::store_t_to_binary(static_cast<command_type::response&>(resp), buffer, 64 * 1024); \
|
|
||||||
uint64_t ticks3 = epee::misc_utils::get_tick_count(); \
|
uint64_t ticks3 = epee::misc_utils::get_tick_count(); \
|
||||||
response_info.m_body.assign(reinterpret_cast<const char*>(buffer.data()), buffer.size()); \
|
|
||||||
response_info.m_mime_tipe = " application/octet-stream"; \
|
response_info.m_mime_tipe = " application/octet-stream"; \
|
||||||
response_info.m_header_info.m_content_type = " application/octet-stream"; \
|
response_info.m_header_info.m_content_type = " application/octet-stream"; \
|
||||||
MDEBUG( s_pattern << "() processed with " << ticks1-ticks << "/"<< ticks2-ticks1 << "/" << ticks3-ticks2 << "ms"); \
|
MDEBUG( s_pattern << "() processed with " << ticks1-ticks << "/"<< ticks2-ticks1 << "/" << ticks3-ticks2 << "ms"); \
|
||||||
|
|||||||
@@ -31,6 +31,7 @@
|
|||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
|
#include "byte_slice.h"
|
||||||
#include "net_utils_base.h"
|
#include "net_utils_base.h"
|
||||||
#include "span.h"
|
#include "span.h"
|
||||||
|
|
||||||
@@ -38,7 +39,6 @@
|
|||||||
|
|
||||||
namespace epee
|
namespace epee
|
||||||
{
|
{
|
||||||
class byte_slice;
|
|
||||||
namespace levin
|
namespace levin
|
||||||
{
|
{
|
||||||
#pragma pack(push)
|
#pragma pack(push)
|
||||||
@@ -72,8 +72,7 @@ namespace levin
|
|||||||
|
|
||||||
|
|
||||||
#define LEVIN_DEFAULT_TIMEOUT_PRECONFIGURED 0
|
#define LEVIN_DEFAULT_TIMEOUT_PRECONFIGURED 0
|
||||||
#define LEVIN_INITIAL_MAX_PACKET_SIZE 256*1024 // 256 KiB before handshake
|
#define LEVIN_DEFAULT_MAX_PACKET_SIZE 100000000 //100MB by default
|
||||||
#define LEVIN_DEFAULT_MAX_PACKET_SIZE 100000000 //100MB by default after handshake
|
|
||||||
|
|
||||||
#define LEVIN_PACKET_REQUEST 0x00000001
|
#define LEVIN_PACKET_REQUEST 0x00000001
|
||||||
#define LEVIN_PACKET_RESPONSE 0x00000002
|
#define LEVIN_PACKET_RESPONSE 0x00000002
|
||||||
@@ -87,7 +86,7 @@ namespace levin
|
|||||||
template<class t_connection_context = net_utils::connection_context_base>
|
template<class t_connection_context = net_utils::connection_context_base>
|
||||||
struct levin_commands_handler
|
struct levin_commands_handler
|
||||||
{
|
{
|
||||||
virtual int invoke(int command, const epee::span<const uint8_t> in_buff, byte_slice& buff_out, t_connection_context& context)=0;
|
virtual int invoke(int command, const epee::span<const uint8_t> in_buff, std::string& buff_out, t_connection_context& context)=0;
|
||||||
virtual int notify(int command, const epee::span<const uint8_t> in_buff, t_connection_context& context)=0;
|
virtual int notify(int command, const epee::span<const uint8_t> in_buff, t_connection_context& context)=0;
|
||||||
virtual void callback(t_connection_context& context){};
|
virtual void callback(t_connection_context& context){};
|
||||||
|
|
||||||
|
|||||||
@@ -84,8 +84,7 @@ class async_protocol_handler_config
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
typedef t_connection_context connection_context;
|
typedef t_connection_context connection_context;
|
||||||
uint64_t m_initial_max_packet_size;
|
uint64_t m_max_packet_size;
|
||||||
uint64_t m_max_packet_size;
|
|
||||||
uint64_t m_invoke_timeout;
|
uint64_t m_invoke_timeout;
|
||||||
|
|
||||||
int invoke(int command, const epee::span<const uint8_t> in_buff, std::string& buff_out, boost::uuids::uuid connection_id);
|
int invoke(int command, const epee::span<const uint8_t> in_buff, std::string& buff_out, boost::uuids::uuid connection_id);
|
||||||
@@ -106,7 +105,7 @@ public:
|
|||||||
size_t get_in_connections_count();
|
size_t get_in_connections_count();
|
||||||
void set_handler(levin_commands_handler<t_connection_context>* handler, void (*destroy)(levin_commands_handler<t_connection_context>*) = NULL);
|
void set_handler(levin_commands_handler<t_connection_context>* handler, void (*destroy)(levin_commands_handler<t_connection_context>*) = NULL);
|
||||||
|
|
||||||
async_protocol_handler_config():m_pcommands_handler(NULL), m_pcommands_handler_destroy(NULL), m_initial_max_packet_size(LEVIN_INITIAL_MAX_PACKET_SIZE), m_max_packet_size(LEVIN_DEFAULT_MAX_PACKET_SIZE), m_invoke_timeout(LEVIN_DEFAULT_TIMEOUT_PRECONFIGURED)
|
async_protocol_handler_config():m_pcommands_handler(NULL), m_pcommands_handler_destroy(NULL), m_max_packet_size(LEVIN_DEFAULT_MAX_PACKET_SIZE), m_invoke_timeout(LEVIN_DEFAULT_TIMEOUT_PRECONFIGURED)
|
||||||
{}
|
{}
|
||||||
~async_protocol_handler_config() { set_handler(NULL, NULL); }
|
~async_protocol_handler_config() { set_handler(NULL, NULL); }
|
||||||
void del_out_connections(size_t count);
|
void del_out_connections(size_t count);
|
||||||
@@ -163,7 +162,6 @@ public:
|
|||||||
net_utils::i_service_endpoint* m_pservice_endpoint;
|
net_utils::i_service_endpoint* m_pservice_endpoint;
|
||||||
config_type& m_config;
|
config_type& m_config;
|
||||||
t_connection_context& m_connection_context;
|
t_connection_context& m_connection_context;
|
||||||
std::atomic<uint64_t> m_max_packet_size;
|
|
||||||
|
|
||||||
net_utils::buffer m_cache_in_buffer;
|
net_utils::buffer m_cache_in_buffer;
|
||||||
stream_state m_state;
|
stream_state m_state;
|
||||||
@@ -291,8 +289,7 @@ public:
|
|||||||
m_current_head(bucket_head2()),
|
m_current_head(bucket_head2()),
|
||||||
m_pservice_endpoint(psnd_hndlr),
|
m_pservice_endpoint(psnd_hndlr),
|
||||||
m_config(config),
|
m_config(config),
|
||||||
m_connection_context(conn_context),
|
m_connection_context(conn_context),
|
||||||
m_max_packet_size(config.m_initial_max_packet_size),
|
|
||||||
m_cache_in_buffer(4 * 1024),
|
m_cache_in_buffer(4 * 1024),
|
||||||
m_state(stream_state_head)
|
m_state(stream_state_head)
|
||||||
{
|
{
|
||||||
@@ -402,14 +399,13 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// these should never fail, but do runtime check for safety
|
// these should never fail, but do runtime check for safety
|
||||||
const uint64_t max_packet_size = m_max_packet_size;
|
CHECK_AND_ASSERT_MES(m_config.m_max_packet_size >= m_cache_in_buffer.size(), false, "Bad m_cache_in_buffer.size()");
|
||||||
CHECK_AND_ASSERT_MES(max_packet_size >= m_cache_in_buffer.size(), false, "Bad m_cache_in_buffer.size()");
|
CHECK_AND_ASSERT_MES(m_config.m_max_packet_size - m_cache_in_buffer.size() >= m_fragment_buffer.size(), false, "Bad m_cache_in_buffer.size() + m_fragment_buffer.size()");
|
||||||
CHECK_AND_ASSERT_MES(max_packet_size - m_cache_in_buffer.size() >= m_fragment_buffer.size(), false, "Bad m_cache_in_buffer.size() + m_fragment_buffer.size()");
|
|
||||||
|
|
||||||
// flipped to subtraction; prevent overflow since m_max_packet_size is variable and public
|
// flipped to subtraction; prevent overflow since m_max_packet_size is variable and public
|
||||||
if(cb > max_packet_size - m_cache_in_buffer.size() - m_fragment_buffer.size())
|
if(cb > m_config.m_max_packet_size - m_cache_in_buffer.size() - m_fragment_buffer.size())
|
||||||
{
|
{
|
||||||
MWARNING(m_connection_context << "Maximum packet size exceed!, m_max_packet_size = " << max_packet_size
|
MWARNING(m_connection_context << "Maximum packet size exceed!, m_max_packet_size = " << m_config.m_max_packet_size
|
||||||
<< ", packet received " << m_cache_in_buffer.size() + cb
|
<< ", packet received " << m_cache_in_buffer.size() + cb
|
||||||
<< ", connection will be closed.");
|
<< ", connection will be closed.");
|
||||||
return false;
|
return false;
|
||||||
@@ -434,7 +430,7 @@ public:
|
|||||||
//async call scenario
|
//async call scenario
|
||||||
boost::shared_ptr<invoke_response_handler_base> response_handler = m_invoke_response_handlers.front();
|
boost::shared_ptr<invoke_response_handler_base> response_handler = m_invoke_response_handlers.front();
|
||||||
response_handler->reset_timer();
|
response_handler->reset_timer();
|
||||||
MDEBUG(m_connection_context << "LEVIN_PACKET partial msg received. len=" << cb << ", current total " << m_cache_in_buffer.size() << "/" << m_current_head.m_cb << " (" << (100.0f * m_cache_in_buffer.size() / (m_current_head.m_cb ? m_current_head.m_cb : 1)) << "%)");
|
MDEBUG(m_connection_context << "LEVIN_PACKET partial msg received. len=" << cb);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -469,14 +465,6 @@ public:
|
|||||||
temp = std::move(m_fragment_buffer);
|
temp = std::move(m_fragment_buffer);
|
||||||
m_fragment_buffer.clear();
|
m_fragment_buffer.clear();
|
||||||
std::memcpy(std::addressof(m_current_head), std::addressof(temp[0]), sizeof(bucket_head2));
|
std::memcpy(std::addressof(m_current_head), std::addressof(temp[0]), sizeof(bucket_head2));
|
||||||
const size_t max_bytes = m_connection_context.get_max_bytes(m_current_head.m_command);
|
|
||||||
if(m_current_head.m_cb > std::min<size_t>(max_packet_size, max_bytes))
|
|
||||||
{
|
|
||||||
MERROR(m_connection_context << "Maximum packet size exceed!, m_max_packet_size = " << std::min<size_t>(max_packet_size, max_bytes)
|
|
||||||
<< ", packet header received " << m_current_head.m_cb << ", command " << m_current_head.m_command
|
|
||||||
<< ", connection will be closed.");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
buff_to_invoke = {reinterpret_cast<const uint8_t*>(temp.data()) + sizeof(bucket_head2), temp.size() - sizeof(bucket_head2)};
|
buff_to_invoke = {reinterpret_cast<const uint8_t*>(temp.data()) + sizeof(bucket_head2), temp.size() - sizeof(bucket_head2)};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -526,19 +514,16 @@ public:
|
|||||||
{
|
{
|
||||||
if(m_current_head.m_have_to_return_data)
|
if(m_current_head.m_have_to_return_data)
|
||||||
{
|
{
|
||||||
byte_slice return_buff;
|
std::string return_buff;
|
||||||
const uint32_t return_code = m_config.m_pcommands_handler->invoke(
|
const uint32_t return_code = m_config.m_pcommands_handler->invoke(
|
||||||
m_current_head.m_command, buff_to_invoke, return_buff, m_connection_context
|
m_current_head.m_command, buff_to_invoke, return_buff, m_connection_context
|
||||||
);
|
);
|
||||||
|
|
||||||
// peer_id remains unset if dropped
|
|
||||||
if (m_current_head.m_command == m_connection_context.handshake_command() && m_connection_context.handshake_complete())
|
|
||||||
m_max_packet_size = m_config.m_max_packet_size;
|
|
||||||
|
|
||||||
bucket_head2 head = make_header(m_current_head.m_command, return_buff.size(), LEVIN_PACKET_RESPONSE, false);
|
bucket_head2 head = make_header(m_current_head.m_command, return_buff.size(), LEVIN_PACKET_RESPONSE, false);
|
||||||
head.m_return_code = SWAP32LE(return_code);
|
head.m_return_code = SWAP32LE(return_code);
|
||||||
|
return_buff.insert(0, reinterpret_cast<const char*>(&head), sizeof(head));
|
||||||
|
|
||||||
if(!m_pservice_endpoint->do_send(byte_slice{{epee::as_byte_span(head), epee::to_span(return_buff)}}))
|
if(!m_pservice_endpoint->do_send(byte_slice{std::move(return_buff)}))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
MDEBUG(m_connection_context << "LEVIN_PACKET_SENT. [len=" << head.m_cb
|
MDEBUG(m_connection_context << "LEVIN_PACKET_SENT. [len=" << head.m_cb
|
||||||
@@ -592,11 +577,10 @@ public:
|
|||||||
m_cache_in_buffer.erase(sizeof(bucket_head2));
|
m_cache_in_buffer.erase(sizeof(bucket_head2));
|
||||||
m_state = stream_state_body;
|
m_state = stream_state_body;
|
||||||
m_oponent_protocol_ver = m_current_head.m_protocol_version;
|
m_oponent_protocol_ver = m_current_head.m_protocol_version;
|
||||||
const size_t max_bytes = m_connection_context.get_max_bytes(m_current_head.m_command);
|
if(m_current_head.m_cb > m_config.m_max_packet_size)
|
||||||
if(m_current_head.m_cb > std::min<size_t>(max_packet_size, max_bytes))
|
|
||||||
{
|
{
|
||||||
LOG_ERROR_CC(m_connection_context, "Maximum packet size exceed!, m_max_packet_size = " << std::min<size_t>(max_packet_size, max_bytes)
|
LOG_ERROR_CC(m_connection_context, "Maximum packet size exceed!, m_max_packet_size = " << m_config.m_max_packet_size
|
||||||
<< ", packet header received " << m_current_head.m_cb << ", command " << m_current_head.m_command
|
<< ", packet header received " << m_current_head.m_cb
|
||||||
<< ", connection will be closed.");
|
<< ", connection will be closed.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -650,9 +634,6 @@ public:
|
|||||||
boost::interprocess::ipcdetail::atomic_write32(&m_invoke_buf_ready, 0);
|
boost::interprocess::ipcdetail::atomic_write32(&m_invoke_buf_ready, 0);
|
||||||
CRITICAL_REGION_BEGIN(m_invoke_response_handlers_lock);
|
CRITICAL_REGION_BEGIN(m_invoke_response_handlers_lock);
|
||||||
|
|
||||||
if (command == m_connection_context.handshake_command())
|
|
||||||
m_max_packet_size = m_config.m_max_packet_size;
|
|
||||||
|
|
||||||
if(!send_message(command, in_buff, LEVIN_PACKET_REQUEST, true))
|
if(!send_message(command, in_buff, LEVIN_PACKET_REQUEST, true))
|
||||||
{
|
{
|
||||||
LOG_ERROR_CC(m_connection_context, "Failed to do_send");
|
LOG_ERROR_CC(m_connection_context, "Failed to do_send");
|
||||||
@@ -694,9 +675,6 @@ public:
|
|||||||
|
|
||||||
boost::interprocess::ipcdetail::atomic_write32(&m_invoke_buf_ready, 0);
|
boost::interprocess::ipcdetail::atomic_write32(&m_invoke_buf_ready, 0);
|
||||||
|
|
||||||
if (command == m_connection_context.handshake_command())
|
|
||||||
m_max_packet_size = m_config.m_max_packet_size;
|
|
||||||
|
|
||||||
if (!send_message(command, in_buff, LEVIN_PACKET_REQUEST, true))
|
if (!send_message(command, in_buff, LEVIN_PACKET_REQUEST, true))
|
||||||
{
|
{
|
||||||
LOG_ERROR_CC(m_connection_context, "Failed to send request");
|
LOG_ERROR_CC(m_connection_context, "Failed to send request");
|
||||||
|
|||||||
@@ -44,7 +44,6 @@
|
|||||||
#include <boost/lambda/lambda.hpp>
|
#include <boost/lambda/lambda.hpp>
|
||||||
#include <boost/interprocess/detail/atomic.hpp>
|
#include <boost/interprocess/detail/atomic.hpp>
|
||||||
#include <boost/system/error_code.hpp>
|
#include <boost/system/error_code.hpp>
|
||||||
#include <boost/utility/string_ref.hpp>
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include "net/net_utils_base.h"
|
#include "net/net_utils_base.h"
|
||||||
#include "net/net_ssl.h"
|
#include "net/net_ssl.h"
|
||||||
@@ -179,7 +178,7 @@ namespace net_utils
|
|||||||
// SSL Options
|
// SSL Options
|
||||||
if (m_ssl_options.support == epee::net_utils::ssl_support_t::e_ssl_support_enabled || m_ssl_options.support == epee::net_utils::ssl_support_t::e_ssl_support_autodetect)
|
if (m_ssl_options.support == epee::net_utils::ssl_support_t::e_ssl_support_enabled || m_ssl_options.support == epee::net_utils::ssl_support_t::e_ssl_support_autodetect)
|
||||||
{
|
{
|
||||||
if (!m_ssl_options.handshake(*m_ssl_socket, boost::asio::ssl::stream_base::client, {}, addr, timeout))
|
if (!m_ssl_options.handshake(*m_ssl_socket, boost::asio::ssl::stream_base::client, addr, timeout))
|
||||||
{
|
{
|
||||||
if (m_ssl_options.support == epee::net_utils::ssl_support_t::e_ssl_support_autodetect)
|
if (m_ssl_options.support == epee::net_utils::ssl_support_t::e_ssl_support_autodetect)
|
||||||
{
|
{
|
||||||
@@ -281,7 +280,7 @@ namespace net_utils
|
|||||||
|
|
||||||
|
|
||||||
inline
|
inline
|
||||||
bool send(const boost::string_ref buff, std::chrono::milliseconds timeout)
|
bool send(const std::string& buff, std::chrono::milliseconds timeout)
|
||||||
{
|
{
|
||||||
|
|
||||||
try
|
try
|
||||||
@@ -299,7 +298,7 @@ namespace net_utils
|
|||||||
// object is used as a callback and will update the ec variable when the
|
// object is used as a callback and will update the ec variable when the
|
||||||
// operation completes. The blocking_udp_client.cpp example shows how you
|
// operation completes. The blocking_udp_client.cpp example shows how you
|
||||||
// can use boost::bind rather than boost::lambda.
|
// can use boost::bind rather than boost::lambda.
|
||||||
async_write(buff.data(), buff.size(), ec);
|
async_write(buff.c_str(), buff.size(), ec);
|
||||||
|
|
||||||
// Block until the asynchronous operation has completed.
|
// Block until the asynchronous operation has completed.
|
||||||
while (ec == boost::asio::error::would_block)
|
while (ec == boost::asio::error::would_block)
|
||||||
|
|||||||
@@ -131,8 +131,8 @@ namespace net_utils
|
|||||||
inline
|
inline
|
||||||
bool parse_url_ipv6(const std::string url_str, http::url_content& content)
|
bool parse_url_ipv6(const std::string url_str, http::url_content& content)
|
||||||
{
|
{
|
||||||
STATIC_REGEXP_EXPR_1(rexp_match_uri, "^(([^:]*?)://)?(\\[(.*)\\](:(\\d+))?)(.*)?", boost::regex::icase | boost::regex::normal);
|
STATIC_REGEXP_EXPR_1(rexp_match_uri, "^((.*?)://)?(\\[(.*)\\](:(\\d+))?)(.*)?", boost::regex::icase | boost::regex::normal);
|
||||||
// 12 3 4 5 6 7
|
// 12 3 4 5 6 7
|
||||||
|
|
||||||
content.port = 0;
|
content.port = 0;
|
||||||
boost::smatch result;
|
boost::smatch result;
|
||||||
@@ -175,8 +175,8 @@ namespace net_utils
|
|||||||
|
|
||||||
///iframe_test.html?api_url=http://api.vk.com/api.php&api_id=3289090&api_settings=1&viewer_id=562964060&viewer_type=0&sid=0aad8d1c5713130f9ca0076f2b7b47e532877424961367d81e7fa92455f069be7e21bc3193cbd0be11895&secret=368ebbc0ef&access_token=668bc03f43981d883f73876ffff4aa8564254b359cc745dfa1b3cde7bdab2e94105d8f6d8250717569c0a7&user_id=0&group_id=0&is_app_user=1&auth_key=d2f7a895ca5ff3fdb2a2a8ae23fe679a&language=0&parent_language=0&ad_info=ElsdCQBaQlxiAQRdFUVUXiN2AVBzBx5pU1BXIgZUJlIEAWcgAUoLQg==&referrer=unknown&lc_name=9834b6a3&hash=
|
///iframe_test.html?api_url=http://api.vk.com/api.php&api_id=3289090&api_settings=1&viewer_id=562964060&viewer_type=0&sid=0aad8d1c5713130f9ca0076f2b7b47e532877424961367d81e7fa92455f069be7e21bc3193cbd0be11895&secret=368ebbc0ef&access_token=668bc03f43981d883f73876ffff4aa8564254b359cc745dfa1b3cde7bdab2e94105d8f6d8250717569c0a7&user_id=0&group_id=0&is_app_user=1&auth_key=d2f7a895ca5ff3fdb2a2a8ae23fe679a&language=0&parent_language=0&ad_info=ElsdCQBaQlxiAQRdFUVUXiN2AVBzBx5pU1BXIgZUJlIEAWcgAUoLQg==&referrer=unknown&lc_name=9834b6a3&hash=
|
||||||
//STATIC_REGEXP_EXPR_1(rexp_match_uri, "^([^?#]*)(\\?([^#]*))?(#(.*))?", boost::regex::icase | boost::regex::normal);
|
//STATIC_REGEXP_EXPR_1(rexp_match_uri, "^([^?#]*)(\\?([^#]*))?(#(.*))?", boost::regex::icase | boost::regex::normal);
|
||||||
STATIC_REGEXP_EXPR_1(rexp_match_uri, "^(([^:]*?)://)?(([^/:]*)(:(\\d+))?)(.*)?", boost::regex::icase | boost::regex::normal);
|
STATIC_REGEXP_EXPR_1(rexp_match_uri, "^((.*?)://)?(([^/:]*)(:(\\d+))?)(.*)?", boost::regex::icase | boost::regex::normal);
|
||||||
// 12 34 5 6 7
|
// 12 34 5 6 7
|
||||||
content.port = 0;
|
content.port = 0;
|
||||||
boost::smatch result;
|
boost::smatch result;
|
||||||
if(!(boost::regex_search(url_str, result, rexp_match_uri, boost::match_default) && result[0].matched))
|
if(!(boost::regex_search(url_str, result, rexp_match_uri, boost::match_default) && result[0].matched))
|
||||||
|
|||||||
@@ -132,7 +132,6 @@ namespace net_utils
|
|||||||
bool handshake(
|
bool handshake(
|
||||||
boost::asio::ssl::stream<boost::asio::ip::tcp::socket> &socket,
|
boost::asio::ssl::stream<boost::asio::ip::tcp::socket> &socket,
|
||||||
boost::asio::ssl::stream_base::handshake_type type,
|
boost::asio::ssl::stream_base::handshake_type type,
|
||||||
boost::asio::const_buffer buffer = {},
|
|
||||||
const std::string& host = {},
|
const std::string& host = {},
|
||||||
std::chrono::milliseconds timeout = std::chrono::seconds(15)) const;
|
std::chrono::milliseconds timeout = std::chrono::seconds(15)) const;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -141,6 +141,7 @@ public:
|
|||||||
|
|
||||||
rolling_median_t(rolling_median_t &&m)
|
rolling_median_t(rolling_median_t &&m)
|
||||||
{
|
{
|
||||||
|
free(data);
|
||||||
memcpy(this, &m, sizeof(rolling_median_t));
|
memcpy(this, &m, sizeof(rolling_median_t));
|
||||||
m.data = NULL;
|
m.data = NULL;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,6 @@
|
|||||||
#include <boost/utility/string_ref.hpp>
|
#include <boost/utility/string_ref.hpp>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "byte_slice.h"
|
|
||||||
#include "portable_storage_template_helper.h"
|
#include "portable_storage_template_helper.h"
|
||||||
#include "net/http_base.h"
|
#include "net/http_base.h"
|
||||||
#include "net/http_server_handlers_map2.h"
|
#include "net/http_server_handlers_map2.h"
|
||||||
@@ -75,12 +74,12 @@ namespace epee
|
|||||||
template<class t_request, class t_response, class t_transport>
|
template<class t_request, class t_response, class t_transport>
|
||||||
bool invoke_http_bin(const boost::string_ref uri, const t_request& out_struct, t_response& result_struct, t_transport& transport, std::chrono::milliseconds timeout = std::chrono::seconds(15), const boost::string_ref method = "POST")
|
bool invoke_http_bin(const boost::string_ref uri, const t_request& out_struct, t_response& result_struct, t_transport& transport, std::chrono::milliseconds timeout = std::chrono::seconds(15), const boost::string_ref method = "POST")
|
||||||
{
|
{
|
||||||
byte_slice req_param;
|
std::string req_param;
|
||||||
if(!serialization::store_t_to_binary(out_struct, req_param, 16 * 1024))
|
if(!serialization::store_t_to_binary(out_struct, req_param))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
const http::http_response_info* pri = NULL;
|
const http::http_response_info* pri = NULL;
|
||||||
if(!transport.invoke(uri, method, boost::string_ref{reinterpret_cast<const char*>(req_param.data()), req_param.size()}, timeout, std::addressof(pri)))
|
if(!transport.invoke(uri, method, req_param, timeout, std::addressof(pri)))
|
||||||
{
|
{
|
||||||
LOG_PRINT_L1("Failed to invoke http request to " << uri);
|
LOG_PRINT_L1("Failed to invoke http request to " << uri);
|
||||||
return false;
|
return false;
|
||||||
@@ -98,12 +97,7 @@ namespace epee
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const constexpr epee::serialization::portable_storage::limits_t default_http_bin_limits = {
|
return serialization::load_t_from_binary(result_struct, epee::strspan<uint8_t>(pri->m_body));
|
||||||
65536 * 3, // objects
|
|
||||||
65536 * 3, // fields
|
|
||||||
65536 * 3, // strings
|
|
||||||
};
|
|
||||||
return serialization::load_t_from_binary(result_struct, epee::strspan<uint8_t>(pri->m_body), &default_http_bin_limits);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class t_request, class t_response, class t_transport>
|
template<class t_request, class t_response, class t_transport>
|
||||||
|
|||||||
@@ -27,10 +27,8 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "portable_storage_template_helper.h"
|
#include "portable_storage_template_helper.h"
|
||||||
#include <boost/utility/string_ref.hpp>
|
|
||||||
#include <boost/utility/value_init.hpp>
|
#include <boost/utility/value_init.hpp>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include "byte_slice.h"
|
|
||||||
#include "span.h"
|
#include "span.h"
|
||||||
#include "net/levin_base.h"
|
#include "net/levin_base.h"
|
||||||
|
|
||||||
@@ -52,11 +50,6 @@ namespace
|
|||||||
snprintf(buf, sizeof(buf), "command-%u", command);
|
snprintf(buf, sizeof(buf), "command-%u", command);
|
||||||
return on_levin_traffic(context, initiator, sent, error, bytes, buf);
|
return on_levin_traffic(context, initiator, sent, error, bytes, buf);
|
||||||
}
|
}
|
||||||
static const constexpr epee::serialization::portable_storage::limits_t default_levin_limits = {
|
|
||||||
8192, // objects
|
|
||||||
16384, // fields
|
|
||||||
16384, // strings
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace epee
|
namespace epee
|
||||||
@@ -82,7 +75,7 @@ namespace epee
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
serialization::portable_storage stg_ret;
|
serialization::portable_storage stg_ret;
|
||||||
if(!stg_ret.load_from_binary(buff_to_recv, &default_levin_limits))
|
if(!stg_ret.load_from_binary(buff_to_recv))
|
||||||
{
|
{
|
||||||
LOG_ERROR("Failed to load_from_binary on command " << command);
|
LOG_ERROR("Failed to load_from_binary on command " << command);
|
||||||
return false;
|
return false;
|
||||||
@@ -117,19 +110,18 @@ namespace epee
|
|||||||
const boost::uuids::uuid &conn_id = context.m_connection_id;
|
const boost::uuids::uuid &conn_id = context.m_connection_id;
|
||||||
typename serialization::portable_storage stg;
|
typename serialization::portable_storage stg;
|
||||||
out_struct.store(stg);
|
out_struct.store(stg);
|
||||||
byte_slice buff_to_send;
|
std::string buff_to_send, buff_to_recv;
|
||||||
std::string buff_to_recv;
|
stg.store_to_binary(buff_to_send);
|
||||||
stg.store_to_binary(buff_to_send, 16 * 1024);
|
|
||||||
|
|
||||||
on_levin_traffic(context, true, true, false, buff_to_send.size(), command);
|
on_levin_traffic(context, true, true, false, buff_to_send.size(), command);
|
||||||
int res = transport.invoke(command, boost::string_ref{reinterpret_cast<const char*>(buff_to_send.data()), buff_to_send.size()}, buff_to_recv, conn_id);
|
int res = transport.invoke(command, buff_to_send, buff_to_recv, conn_id);
|
||||||
if( res <=0 )
|
if( res <=0 )
|
||||||
{
|
{
|
||||||
LOG_PRINT_L1("Failed to invoke command " << command << " return code " << res);
|
LOG_PRINT_L1("Failed to invoke command " << command << " return code " << res);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
typename serialization::portable_storage stg_ret;
|
typename serialization::portable_storage stg_ret;
|
||||||
if(!stg_ret.load_from_binary(buff_to_recv, &default_levin_limits))
|
if(!stg_ret.load_from_binary(buff_to_recv))
|
||||||
{
|
{
|
||||||
on_levin_traffic(context, true, false, true, buff_to_recv.size(), command);
|
on_levin_traffic(context, true, false, true, buff_to_recv.size(), command);
|
||||||
LOG_ERROR("Failed to load_from_binary on command " << command);
|
LOG_ERROR("Failed to load_from_binary on command " << command);
|
||||||
@@ -145,10 +137,10 @@ namespace epee
|
|||||||
const boost::uuids::uuid &conn_id = context.m_connection_id;
|
const boost::uuids::uuid &conn_id = context.m_connection_id;
|
||||||
typename serialization::portable_storage stg;
|
typename serialization::portable_storage stg;
|
||||||
const_cast<t_arg&>(out_struct).store(stg);//TODO: add true const support to searilzation
|
const_cast<t_arg&>(out_struct).store(stg);//TODO: add true const support to searilzation
|
||||||
byte_slice buff_to_send;
|
std::string buff_to_send;
|
||||||
stg.store_to_binary(buff_to_send, 16 * 1024);
|
stg.store_to_binary(buff_to_send);
|
||||||
on_levin_traffic(context, true, true, false, buff_to_send.size(), command);
|
on_levin_traffic(context, true, true, false, buff_to_send.size(), command);
|
||||||
int res = transport.invoke_async(command, epee::to_span(buff_to_send), conn_id, [cb, command](int code, const epee::span<const uint8_t> buff, typename t_transport::connection_context& context)->bool
|
int res = transport.invoke_async(command, epee::strspan<uint8_t>(buff_to_send), conn_id, [cb, command](int code, const epee::span<const uint8_t> buff, typename t_transport::connection_context& context)->bool
|
||||||
{
|
{
|
||||||
t_result result_struct = AUTO_VAL_INIT(result_struct);
|
t_result result_struct = AUTO_VAL_INIT(result_struct);
|
||||||
if( code <=0 )
|
if( code <=0 )
|
||||||
@@ -160,7 +152,7 @@ namespace epee
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
serialization::portable_storage stg_ret;
|
serialization::portable_storage stg_ret;
|
||||||
if(!stg_ret.load_from_binary(buff, &default_levin_limits))
|
if(!stg_ret.load_from_binary(buff))
|
||||||
{
|
{
|
||||||
on_levin_traffic(context, true, false, true, buff.size(), command);
|
on_levin_traffic(context, true, false, true, buff.size(), command);
|
||||||
LOG_ERROR("Failed to load_from_binary on command " << command);
|
LOG_ERROR("Failed to load_from_binary on command " << command);
|
||||||
@@ -192,11 +184,11 @@ namespace epee
|
|||||||
const boost::uuids::uuid &conn_id = context.m_connection_id;
|
const boost::uuids::uuid &conn_id = context.m_connection_id;
|
||||||
serialization::portable_storage stg;
|
serialization::portable_storage stg;
|
||||||
out_struct.store(stg);
|
out_struct.store(stg);
|
||||||
byte_slice buff_to_send;
|
std::string buff_to_send;
|
||||||
stg.store_to_binary(buff_to_send);
|
stg.store_to_binary(buff_to_send);
|
||||||
|
|
||||||
on_levin_traffic(context, true, true, false, buff_to_send.size(), command);
|
on_levin_traffic(context, true, true, false, buff_to_send.size(), command);
|
||||||
int res = transport.notify(command, epee::to_span(buff_to_send), conn_id);
|
int res = transport.notify(command, epee::strspan<uint8_t>(buff_to_send), conn_id);
|
||||||
if(res <=0 )
|
if(res <=0 )
|
||||||
{
|
{
|
||||||
MERROR("Failed to notify command " << command << " return code " << res);
|
MERROR("Failed to notify command " << command << " return code " << res);
|
||||||
@@ -207,10 +199,10 @@ namespace epee
|
|||||||
//----------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------
|
||||||
//----------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------
|
||||||
template<class t_owner, class t_in_type, class t_out_type, class t_context, class callback_t>
|
template<class t_owner, class t_in_type, class t_out_type, class t_context, class callback_t>
|
||||||
int buff_to_t_adapter(int command, const epee::span<const uint8_t> in_buff, byte_slice& buff_out, callback_t cb, t_context& context )
|
int buff_to_t_adapter(int command, const epee::span<const uint8_t> in_buff, std::string& buff_out, callback_t cb, t_context& context )
|
||||||
{
|
{
|
||||||
serialization::portable_storage strg;
|
serialization::portable_storage strg;
|
||||||
if(!strg.load_from_binary(in_buff, &default_levin_limits))
|
if(!strg.load_from_binary(in_buff))
|
||||||
{
|
{
|
||||||
on_levin_traffic(context, false, false, true, in_buff.size(), command);
|
on_levin_traffic(context, false, false, true, in_buff.size(), command);
|
||||||
LOG_ERROR("Failed to load_from_binary in command " << command);
|
LOG_ERROR("Failed to load_from_binary in command " << command);
|
||||||
@@ -230,7 +222,7 @@ namespace epee
|
|||||||
serialization::portable_storage strg_out;
|
serialization::portable_storage strg_out;
|
||||||
static_cast<t_out_type&>(out_struct).store(strg_out);
|
static_cast<t_out_type&>(out_struct).store(strg_out);
|
||||||
|
|
||||||
if(!strg_out.store_to_binary(buff_out, 32 * 1024))
|
if(!strg_out.store_to_binary(buff_out))
|
||||||
{
|
{
|
||||||
LOG_ERROR("Failed to store_to_binary in command" << command);
|
LOG_ERROR("Failed to store_to_binary in command" << command);
|
||||||
return -1;
|
return -1;
|
||||||
@@ -244,7 +236,7 @@ namespace epee
|
|||||||
int buff_to_t_adapter(t_owner* powner, int command, const epee::span<const uint8_t> in_buff, callback_t cb, t_context& context)
|
int buff_to_t_adapter(t_owner* powner, int command, const epee::span<const uint8_t> in_buff, callback_t cb, t_context& context)
|
||||||
{
|
{
|
||||||
serialization::portable_storage strg;
|
serialization::portable_storage strg;
|
||||||
if(!strg.load_from_binary(in_buff, &default_levin_limits))
|
if(!strg.load_from_binary(in_buff))
|
||||||
{
|
{
|
||||||
on_levin_traffic(context, false, false, true, in_buff.size(), command);
|
on_levin_traffic(context, false, false, true, in_buff.size(), command);
|
||||||
LOG_ERROR("Failed to load_from_binary in notify " << command);
|
LOG_ERROR("Failed to load_from_binary in notify " << command);
|
||||||
@@ -262,7 +254,7 @@ namespace epee
|
|||||||
}
|
}
|
||||||
|
|
||||||
#define CHAIN_LEVIN_INVOKE_MAP2(context_type) \
|
#define CHAIN_LEVIN_INVOKE_MAP2(context_type) \
|
||||||
int invoke(int command, const epee::span<const uint8_t> in_buff, epee::byte_slice& buff_out, context_type& context) \
|
int invoke(int command, const epee::span<const uint8_t> in_buff, std::string& buff_out, context_type& context) \
|
||||||
{ \
|
{ \
|
||||||
bool handled = false; \
|
bool handled = false; \
|
||||||
return handle_invoke_map(false, command, in_buff, buff_out, context, handled); \
|
return handle_invoke_map(false, command, in_buff, buff_out, context, handled); \
|
||||||
@@ -271,13 +263,13 @@ namespace epee
|
|||||||
#define CHAIN_LEVIN_NOTIFY_MAP2(context_type) \
|
#define CHAIN_LEVIN_NOTIFY_MAP2(context_type) \
|
||||||
int notify(int command, const epee::span<const uint8_t> in_buff, context_type& context) \
|
int notify(int command, const epee::span<const uint8_t> in_buff, context_type& context) \
|
||||||
{ \
|
{ \
|
||||||
bool handled = false; epee::byte_slice fake_str; \
|
bool handled = false; std::string fake_str;\
|
||||||
return handle_invoke_map(true, command, in_buff, fake_str, context, handled); \
|
return handle_invoke_map(true, command, in_buff, fake_str, context, handled); \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#define CHAIN_LEVIN_INVOKE_MAP() \
|
#define CHAIN_LEVIN_INVOKE_MAP() \
|
||||||
int invoke(int command, const epee::span<const uint8_t> in_buff, epee::byte_slice& buff_out, epee::net_utils::connection_context_base& context) \
|
int invoke(int command, const epee::span<const uint8_t> in_buff, std::string& buff_out, epee::net_utils::connection_context_base& context) \
|
||||||
{ \
|
{ \
|
||||||
bool handled = false; \
|
bool handled = false; \
|
||||||
return handle_invoke_map(false, command, in_buff, buff_out, context, handled); \
|
return handle_invoke_map(false, command, in_buff, buff_out, context, handled); \
|
||||||
@@ -297,7 +289,7 @@ namespace epee
|
|||||||
}
|
}
|
||||||
|
|
||||||
#define BEGIN_INVOKE_MAP2(owner_type) \
|
#define BEGIN_INVOKE_MAP2(owner_type) \
|
||||||
template <class t_context> int handle_invoke_map(bool is_notify, int command, const epee::span<const uint8_t> in_buff, epee::byte_slice& buff_out, t_context& context, bool& handled) \
|
template <class t_context> int handle_invoke_map(bool is_notify, int command, const epee::span<const uint8_t> in_buff, std::string& buff_out, t_context& context, bool& handled) \
|
||||||
{ \
|
{ \
|
||||||
try { \
|
try { \
|
||||||
typedef owner_type internal_owner_type_name;
|
typedef owner_type internal_owner_type_name;
|
||||||
|
|||||||
@@ -32,6 +32,7 @@
|
|||||||
|
|
||||||
#include "misc_language.h"
|
#include "misc_language.h"
|
||||||
#include "portable_storage_base.h"
|
#include "portable_storage_base.h"
|
||||||
|
#include "portable_storage_to_bin.h"
|
||||||
#include "portable_storage_from_bin.h"
|
#include "portable_storage_from_bin.h"
|
||||||
#include "portable_storage_to_json.h"
|
#include "portable_storage_to_json.h"
|
||||||
#include "portable_storage_from_json.h"
|
#include "portable_storage_from_json.h"
|
||||||
@@ -41,7 +42,6 @@
|
|||||||
|
|
||||||
namespace epee
|
namespace epee
|
||||||
{
|
{
|
||||||
class byte_slice;
|
|
||||||
namespace serialization
|
namespace serialization
|
||||||
{
|
{
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
@@ -54,13 +54,6 @@ namespace epee
|
|||||||
typedef epee::serialization::harray harray;
|
typedef epee::serialization::harray harray;
|
||||||
typedef storage_entry meta_entry;
|
typedef storage_entry meta_entry;
|
||||||
|
|
||||||
struct limits_t
|
|
||||||
{
|
|
||||||
size_t n_objects;
|
|
||||||
size_t n_fields;
|
|
||||||
size_t n_strings; // not counting field names
|
|
||||||
};
|
|
||||||
|
|
||||||
portable_storage(){}
|
portable_storage(){}
|
||||||
virtual ~portable_storage(){}
|
virtual ~portable_storage(){}
|
||||||
hsection open_section(const std::string& section_name, hsection hparent_section, bool create_if_notexist = false);
|
hsection open_section(const std::string& section_name, hsection hparent_section, bool create_if_notexist = false);
|
||||||
@@ -90,9 +83,9 @@ namespace epee
|
|||||||
bool delete_entry(const std::string& pentry_name, hsection hparent_section = nullptr);
|
bool delete_entry(const std::string& pentry_name, hsection hparent_section = nullptr);
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
bool store_to_binary(byte_slice& target, std::size_t initial_buffer_size = 8192);
|
bool store_to_binary(binarybuffer& target);
|
||||||
bool load_from_binary(const epee::span<const uint8_t> target, const limits_t *limits = NULL);
|
bool load_from_binary(const epee::span<const uint8_t> target);
|
||||||
bool load_from_binary(const std::string& target, const limits_t *limits = NULL) { return load_from_binary(epee::strspan<uint8_t>(target), limits); }
|
bool load_from_binary(const std::string& target) { return load_from_binary(epee::strspan<uint8_t>(target)); }
|
||||||
template<class trace_policy>
|
template<class trace_policy>
|
||||||
bool dump_as_xml(std::string& targetObj, const std::string& root_name = "");
|
bool dump_as_xml(std::string& targetObj, const std::string& root_name = "");
|
||||||
bool dump_as_json(std::string& targetObj, size_t indent = 0, bool insert_newlines = true);
|
bool dump_as_json(std::string& targetObj, size_t indent = 0, bool insert_newlines = true);
|
||||||
@@ -140,8 +133,24 @@ namespace epee
|
|||||||
{
|
{
|
||||||
return false;//TODO: don't think i ever again will use xml - ambiguous and "overtagged" format
|
return false;//TODO: don't think i ever again will use xml - ambiguous and "overtagged" format
|
||||||
}
|
}
|
||||||
|
|
||||||
inline
|
inline
|
||||||
bool portable_storage::load_from_binary(const epee::span<const uint8_t> source, const limits_t *limits)
|
bool portable_storage::store_to_binary(binarybuffer& target)
|
||||||
|
{
|
||||||
|
TRY_ENTRY();
|
||||||
|
std::stringstream ss;
|
||||||
|
storage_block_header sbh = AUTO_VAL_INIT(sbh);
|
||||||
|
sbh.m_signature_a = SWAP32LE(PORTABLE_STORAGE_SIGNATUREA);
|
||||||
|
sbh.m_signature_b = SWAP32LE(PORTABLE_STORAGE_SIGNATUREB);
|
||||||
|
sbh.m_ver = PORTABLE_STORAGE_FORMAT_VER;
|
||||||
|
ss.write((const char*)&sbh, sizeof(storage_block_header));
|
||||||
|
pack_entry_to_buff(ss, m_root);
|
||||||
|
target = ss.str();
|
||||||
|
return true;
|
||||||
|
CATCH_ENTRY("portable_storage::store_to_binary", false)
|
||||||
|
}
|
||||||
|
inline
|
||||||
|
bool portable_storage::load_from_binary(const epee::span<const uint8_t> source)
|
||||||
{
|
{
|
||||||
m_root.m_entries.clear();
|
m_root.m_entries.clear();
|
||||||
if(source.size() < sizeof(storage_block_header))
|
if(source.size() < sizeof(storage_block_header))
|
||||||
@@ -164,8 +173,6 @@ namespace epee
|
|||||||
}
|
}
|
||||||
TRY_ENTRY();
|
TRY_ENTRY();
|
||||||
throwable_buffer_reader buf_reader(source.data()+sizeof(storage_block_header), source.size()-sizeof(storage_block_header));
|
throwable_buffer_reader buf_reader(source.data()+sizeof(storage_block_header), source.size()-sizeof(storage_block_header));
|
||||||
if (limits)
|
|
||||||
buf_reader.set_limits(limits->n_objects, limits->n_fields, limits->n_strings);
|
|
||||||
buf_reader.read(m_root);
|
buf_reader.read(m_root);
|
||||||
return true;//TODO:
|
return true;//TODO:
|
||||||
CATCH_ENTRY("portable_storage::load_from_binary", false);
|
CATCH_ENTRY("portable_storage::load_from_binary", false);
|
||||||
@@ -275,7 +282,6 @@ namespace epee
|
|||||||
static_assert(std::is_rvalue_reference<entry_type&&>(), "unexpected copy of value");
|
static_assert(std::is_rvalue_reference<entry_type&&>(), "unexpected copy of value");
|
||||||
TRY_ENTRY();
|
TRY_ENTRY();
|
||||||
CHECK_AND_ASSERT(psection, nullptr);
|
CHECK_AND_ASSERT(psection, nullptr);
|
||||||
CHECK_AND_ASSERT(!pentry_name.empty(), nullptr);
|
|
||||||
auto ins_res = psection->m_entries.emplace(pentry_name, std::forward<entry_type>(entry));
|
auto ins_res = psection->m_entries.emplace(pentry_name, std::forward<entry_type>(entry));
|
||||||
return &ins_res.first->second;
|
return &ins_res.first->second;
|
||||||
CATCH_ENTRY("portable_storage::insert_new_entry_get_storage_entry", nullptr);
|
CATCH_ENTRY("portable_storage::insert_new_entry_get_storage_entry", nullptr);
|
||||||
|
|||||||
@@ -29,7 +29,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "misc_language.h"
|
#include "misc_language.h"
|
||||||
#include "misc_log_ex.h"
|
|
||||||
#include "portable_storage_base.h"
|
#include "portable_storage_base.h"
|
||||||
#include "portable_storage_bin_utils.h"
|
#include "portable_storage_bin_utils.h"
|
||||||
|
|
||||||
@@ -43,24 +42,6 @@ namespace epee
|
|||||||
{
|
{
|
||||||
namespace serialization
|
namespace serialization
|
||||||
{
|
{
|
||||||
template<typename T>
|
|
||||||
struct ps_min_bytes {
|
|
||||||
static constexpr const size_t strict = 4096; // actual low bound
|
|
||||||
};
|
|
||||||
template<> struct ps_min_bytes<uint64_t> { static constexpr const size_t strict = 8; };
|
|
||||||
template<> struct ps_min_bytes<int64_t> { static constexpr const size_t strict = 8; };
|
|
||||||
template<> struct ps_min_bytes<uint32_t> { static constexpr const size_t strict = 4; };
|
|
||||||
template<> struct ps_min_bytes<int32_t> { static constexpr const size_t strict = 4; };
|
|
||||||
template<> struct ps_min_bytes<uint16_t> { static constexpr const size_t strict = 2; };
|
|
||||||
template<> struct ps_min_bytes<int16_t> { static constexpr const size_t strict = 2; };
|
|
||||||
template<> struct ps_min_bytes<uint8_t> { static constexpr const size_t strict = 1; };
|
|
||||||
template<> struct ps_min_bytes<int8_t> { static constexpr const size_t strict = 1; };
|
|
||||||
template<> struct ps_min_bytes<double> { static constexpr const size_t strict = 8; };
|
|
||||||
template<> struct ps_min_bytes<bool> { static constexpr const size_t strict = 1; };
|
|
||||||
template<> struct ps_min_bytes<std::string> { static constexpr const size_t strict = 2; };
|
|
||||||
template<> struct ps_min_bytes<section> { static constexpr const size_t strict = 1; };
|
|
||||||
template<> struct ps_min_bytes<array_entry> { static constexpr const size_t strict = 1; };
|
|
||||||
|
|
||||||
struct throwable_buffer_reader
|
struct throwable_buffer_reader
|
||||||
{
|
{
|
||||||
throwable_buffer_reader(const void* ptr, size_t sz);
|
throwable_buffer_reader(const void* ptr, size_t sz);
|
||||||
@@ -80,9 +61,6 @@ namespace epee
|
|||||||
void read(section& sec);
|
void read(section& sec);
|
||||||
void read(std::string& str);
|
void read(std::string& str);
|
||||||
void read(array_entry &ae);
|
void read(array_entry &ae);
|
||||||
template<class t_type>
|
|
||||||
size_t min_bytes() const;
|
|
||||||
void set_limits(size_t objects, size_t fields, size_t strings);
|
|
||||||
private:
|
private:
|
||||||
struct recursuion_limitation_guard
|
struct recursuion_limitation_guard
|
||||||
{
|
{
|
||||||
@@ -103,13 +81,6 @@ namespace epee
|
|||||||
const uint8_t* m_ptr;
|
const uint8_t* m_ptr;
|
||||||
size_t m_count;
|
size_t m_count;
|
||||||
size_t m_recursion_count;
|
size_t m_recursion_count;
|
||||||
size_t m_objects;
|
|
||||||
size_t m_fields;
|
|
||||||
size_t m_strings;
|
|
||||||
|
|
||||||
size_t max_objects;
|
|
||||||
size_t max_fields;
|
|
||||||
size_t max_strings;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
inline throwable_buffer_reader::throwable_buffer_reader(const void* ptr, size_t sz)
|
inline throwable_buffer_reader::throwable_buffer_reader(const void* ptr, size_t sz)
|
||||||
@@ -121,12 +92,6 @@ namespace epee
|
|||||||
m_ptr = (uint8_t*)ptr;
|
m_ptr = (uint8_t*)ptr;
|
||||||
m_count = sz;
|
m_count = sz;
|
||||||
m_recursion_count = 0;
|
m_recursion_count = 0;
|
||||||
m_objects = 0;
|
|
||||||
m_fields = 0;
|
|
||||||
m_strings = 0;
|
|
||||||
max_objects = std::numeric_limits<size_t>::max();
|
|
||||||
max_fields = std::numeric_limits<size_t>::max();
|
|
||||||
max_strings = std::numeric_limits<size_t>::max();
|
|
||||||
}
|
}
|
||||||
inline
|
inline
|
||||||
void throwable_buffer_reader::read(void* target, size_t count)
|
void throwable_buffer_reader::read(void* target, size_t count)
|
||||||
@@ -143,7 +108,6 @@ namespace epee
|
|||||||
RECURSION_LIMITATION();
|
RECURSION_LIMITATION();
|
||||||
uint8_t name_len = 0;
|
uint8_t name_len = 0;
|
||||||
read(name_len);
|
read(name_len);
|
||||||
CHECK_AND_ASSERT_THROW_MES(name_len > 0, "Section name is missing");
|
|
||||||
sce_name.resize(name_len);
|
sce_name.resize(name_len);
|
||||||
read((void*)sce_name.data(), name_len);
|
read((void*)sce_name.data(), name_len);
|
||||||
}
|
}
|
||||||
@@ -174,18 +138,7 @@ namespace epee
|
|||||||
//for pod types
|
//for pod types
|
||||||
array_entry_t<type_name> sa;
|
array_entry_t<type_name> sa;
|
||||||
size_t size = read_varint();
|
size_t size = read_varint();
|
||||||
CHECK_AND_ASSERT_THROW_MES(size <= m_count / ps_min_bytes<type_name>::strict, "Size sanity check failed");
|
CHECK_AND_ASSERT_THROW_MES(size <= m_count, "Size sanity check failed");
|
||||||
if (std::is_same<type_name, section>())
|
|
||||||
{
|
|
||||||
CHECK_AND_ASSERT_THROW_MES(size <= max_objects - m_objects, "Too many objects");
|
|
||||||
m_objects += size;
|
|
||||||
}
|
|
||||||
else if (std::is_same<type_name, std::string>())
|
|
||||||
{
|
|
||||||
CHECK_AND_ASSERT_THROW_MES(size <= max_strings - m_strings, "Too many strings");
|
|
||||||
m_strings += size;
|
|
||||||
}
|
|
||||||
|
|
||||||
sa.reserve(size);
|
sa.reserve(size);
|
||||||
//TODO: add some optimization here later
|
//TODO: add some optimization here later
|
||||||
while(size--)
|
while(size--)
|
||||||
@@ -251,8 +204,6 @@ namespace epee
|
|||||||
inline storage_entry throwable_buffer_reader::read_se<std::string>()
|
inline storage_entry throwable_buffer_reader::read_se<std::string>()
|
||||||
{
|
{
|
||||||
RECURSION_LIMITATION();
|
RECURSION_LIMITATION();
|
||||||
CHECK_AND_ASSERT_THROW_MES(m_strings + 1 <= max_strings, "Too many strings");
|
|
||||||
m_strings += 1;
|
|
||||||
return storage_entry(read<std::string>());
|
return storage_entry(read<std::string>());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -261,8 +212,6 @@ namespace epee
|
|||||||
inline storage_entry throwable_buffer_reader::read_se<section>()
|
inline storage_entry throwable_buffer_reader::read_se<section>()
|
||||||
{
|
{
|
||||||
RECURSION_LIMITATION();
|
RECURSION_LIMITATION();
|
||||||
CHECK_AND_ASSERT_THROW_MES(m_objects < max_objects, "Too many objects");
|
|
||||||
++m_objects;
|
|
||||||
section s;//use extra variable due to vs bug, line "storage_entry se(section()); " can't be compiled in visual studio
|
section s;//use extra variable due to vs bug, line "storage_entry se(section()); " can't be compiled in visual studio
|
||||||
storage_entry se(std::move(s));
|
storage_entry se(std::move(s));
|
||||||
section& section_entry = boost::get<section>(se);
|
section& section_entry = boost::get<section>(se);
|
||||||
@@ -314,16 +263,12 @@ namespace epee
|
|||||||
RECURSION_LIMITATION();
|
RECURSION_LIMITATION();
|
||||||
sec.m_entries.clear();
|
sec.m_entries.clear();
|
||||||
size_t count = read_varint();
|
size_t count = read_varint();
|
||||||
CHECK_AND_ASSERT_THROW_MES(count <= max_fields - m_fields, "Too many object fields");
|
|
||||||
m_fields += count;
|
|
||||||
while(count--)
|
while(count--)
|
||||||
{
|
{
|
||||||
//read section name string
|
//read section name string
|
||||||
std::string sec_name;
|
std::string sec_name;
|
||||||
read_sec_name(sec_name);
|
read_sec_name(sec_name);
|
||||||
const auto insert_loc = sec.m_entries.lower_bound(sec_name);
|
sec.m_entries.emplace(std::move(sec_name), load_storage_entry());
|
||||||
CHECK_AND_ASSERT_THROW_MES(insert_loc == sec.m_entries.end() || insert_loc->first != sec_name, "duplicate key: " << sec_name);
|
|
||||||
sec.m_entries.emplace_hint(insert_loc, std::move(sec_name), load_storage_entry());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
inline
|
inline
|
||||||
@@ -344,12 +289,5 @@ namespace epee
|
|||||||
RECURSION_LIMITATION();
|
RECURSION_LIMITATION();
|
||||||
CHECK_AND_ASSERT_THROW_MES(false, "Reading array entry is not supported");
|
CHECK_AND_ASSERT_THROW_MES(false, "Reading array entry is not supported");
|
||||||
}
|
}
|
||||||
inline
|
|
||||||
void throwable_buffer_reader::set_limits(size_t objects, size_t fields, size_t strings)
|
|
||||||
{
|
|
||||||
max_objects = objects;
|
|
||||||
max_fields = fields;
|
|
||||||
max_strings = strings;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,6 @@
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "byte_slice.h"
|
|
||||||
#include "parserse_base_utils.h"
|
#include "parserse_base_utils.h"
|
||||||
#include "portable_storage.h"
|
#include "portable_storage.h"
|
||||||
#include "file_io_utils.h"
|
#include "file_io_utils.h"
|
||||||
@@ -85,10 +84,10 @@ namespace epee
|
|||||||
}
|
}
|
||||||
//-----------------------------------------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------------------------------------
|
||||||
template<class t_struct>
|
template<class t_struct>
|
||||||
bool load_t_from_binary(t_struct& out, const epee::span<const uint8_t> binary_buff, const epee::serialization::portable_storage::limits_t *limits = NULL)
|
bool load_t_from_binary(t_struct& out, const epee::span<const uint8_t> binary_buff)
|
||||||
{
|
{
|
||||||
portable_storage ps;
|
portable_storage ps;
|
||||||
bool rs = ps.load_from_binary(binary_buff, limits);
|
bool rs = ps.load_from_binary(binary_buff);
|
||||||
if(!rs)
|
if(!rs)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -112,18 +111,18 @@ namespace epee
|
|||||||
}
|
}
|
||||||
//-----------------------------------------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------------------------------------
|
||||||
template<class t_struct>
|
template<class t_struct>
|
||||||
bool store_t_to_binary(t_struct& str_in, byte_slice& binary_buff, size_t initial_buffer_size = 8192)
|
bool store_t_to_binary(t_struct& str_in, std::string& binary_buff, size_t indent = 0)
|
||||||
{
|
{
|
||||||
portable_storage ps;
|
portable_storage ps;
|
||||||
str_in.store(ps);
|
str_in.store(ps);
|
||||||
return ps.store_to_binary(binary_buff, initial_buffer_size);
|
return ps.store_to_binary(binary_buff);
|
||||||
}
|
}
|
||||||
//-----------------------------------------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------------------------------------
|
||||||
template<class t_struct>
|
template<class t_struct>
|
||||||
byte_slice store_t_to_binary(t_struct& str_in, size_t initial_buffer_size = 8192)
|
std::string store_t_to_binary(t_struct& str_in, size_t indent = 0)
|
||||||
{
|
{
|
||||||
byte_slice binary_buff;
|
std::string binary_buff;
|
||||||
store_t_to_binary(str_in, binary_buff, initial_buffer_size);
|
store_t_to_binary(str_in, binary_buff, indent);
|
||||||
return binary_buff;
|
return binary_buff;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -211,7 +211,6 @@ namespace epee
|
|||||||
for(const section_pair& se: sec.m_entries)
|
for(const section_pair& se: sec.m_entries)
|
||||||
{
|
{
|
||||||
CHECK_AND_ASSERT_THROW_MES(se.first.size() < std::numeric_limits<uint8_t>::max(), "storage_entry_name is too long: " << se.first.size() << ", val: " << se.first);
|
CHECK_AND_ASSERT_THROW_MES(se.first.size() < std::numeric_limits<uint8_t>::max(), "storage_entry_name is too long: " << se.first.size() << ", val: " << se.first);
|
||||||
CHECK_AND_ASSERT_THROW_MES(!se.first.empty(), "storage_entry_name is empty");
|
|
||||||
uint8_t len = static_cast<uint8_t>(se.first.size());
|
uint8_t len = static_cast<uint8_t>(se.first.size());
|
||||||
strm.write((const char*)&len, sizeof(len));
|
strm.write((const char*)&len, sizeof(len));
|
||||||
strm.write(se.first.data(), size_t(len));
|
strm.write(se.first.data(), size_t(len));
|
||||||
|
|||||||
@@ -29,7 +29,7 @@
|
|||||||
|
|
||||||
add_library(epee STATIC byte_slice.cpp byte_stream.cpp hex.cpp abstract_http_client.cpp http_auth.cpp mlog.cpp net_helper.cpp net_utils_base.cpp string_tools.cpp
|
add_library(epee STATIC byte_slice.cpp byte_stream.cpp hex.cpp abstract_http_client.cpp http_auth.cpp mlog.cpp net_helper.cpp net_utils_base.cpp string_tools.cpp
|
||||||
wipeable_string.cpp levin_base.cpp memwipe.c connection_basic.cpp network_throttle.cpp network_throttle-detail.cpp mlocker.cpp buffer.cpp net_ssl.cpp
|
wipeable_string.cpp levin_base.cpp memwipe.c connection_basic.cpp network_throttle.cpp network_throttle-detail.cpp mlocker.cpp buffer.cpp net_ssl.cpp
|
||||||
int-util.cpp portable_storage.cpp)
|
int-util.cpp)
|
||||||
|
|
||||||
if (USE_READLINE AND (GNU_READLINE_FOUND OR (DEPENDS AND NOT MINGW)))
|
if (USE_READLINE AND (GNU_READLINE_FOUND OR (DEPENDS AND NOT MINGW)))
|
||||||
add_library(epee_readline STATIC readline_buffer.cpp)
|
add_library(epee_readline STATIC readline_buffer.cpp)
|
||||||
|
|||||||
@@ -34,11 +34,6 @@
|
|||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
namespace
|
|
||||||
{
|
|
||||||
constexpr const std::size_t minimum_increase = 4096;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace epee
|
namespace epee
|
||||||
{
|
{
|
||||||
void byte_stream::overflow(const std::size_t requested)
|
void byte_stream::overflow(const std::size_t requested)
|
||||||
@@ -51,7 +46,7 @@ namespace epee
|
|||||||
|
|
||||||
const std::size_t len = size();
|
const std::size_t len = size();
|
||||||
const std::size_t cap = capacity();
|
const std::size_t cap = capacity();
|
||||||
const std::size_t increase = std::max(std::max(need, cap), minimum_increase);
|
const std::size_t increase = std::max(need, increase_size());
|
||||||
|
|
||||||
next_write_ = nullptr;
|
next_write_ = nullptr;
|
||||||
end_ = nullptr;
|
end_ = nullptr;
|
||||||
@@ -67,7 +62,8 @@ namespace epee
|
|||||||
byte_stream::byte_stream(byte_stream&& rhs) noexcept
|
byte_stream::byte_stream(byte_stream&& rhs) noexcept
|
||||||
: buffer_(std::move(rhs.buffer_)),
|
: buffer_(std::move(rhs.buffer_)),
|
||||||
next_write_(rhs.next_write_),
|
next_write_(rhs.next_write_),
|
||||||
end_(rhs.end_)
|
end_(rhs.end_),
|
||||||
|
increase_size_(rhs.increase_size_)
|
||||||
{
|
{
|
||||||
rhs.next_write_ = nullptr;
|
rhs.next_write_ = nullptr;
|
||||||
rhs.end_ = nullptr;
|
rhs.end_ = nullptr;
|
||||||
@@ -80,6 +76,7 @@ namespace epee
|
|||||||
buffer_ = std::move(rhs.buffer_);
|
buffer_ = std::move(rhs.buffer_);
|
||||||
next_write_ = rhs.next_write_;
|
next_write_ = rhs.next_write_;
|
||||||
end_ = rhs.end_;
|
end_ = rhs.end_;
|
||||||
|
increase_size_ = rhs.increase_size_;
|
||||||
rhs.next_write_ = nullptr;
|
rhs.next_write_ = nullptr;
|
||||||
rhs.end_ = nullptr;
|
rhs.end_ = nullptr;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -473,7 +473,6 @@ bool ssl_options_t::has_fingerprint(boost::asio::ssl::verify_context &ctx) const
|
|||||||
bool ssl_options_t::handshake(
|
bool ssl_options_t::handshake(
|
||||||
boost::asio::ssl::stream<boost::asio::ip::tcp::socket> &socket,
|
boost::asio::ssl::stream<boost::asio::ip::tcp::socket> &socket,
|
||||||
boost::asio::ssl::stream_base::handshake_type type,
|
boost::asio::ssl::stream_base::handshake_type type,
|
||||||
boost::asio::const_buffer buffer,
|
|
||||||
const std::string& host,
|
const std::string& host,
|
||||||
std::chrono::milliseconds timeout) const
|
std::chrono::milliseconds timeout) const
|
||||||
{
|
{
|
||||||
@@ -531,7 +530,7 @@ bool ssl_options_t::handshake(
|
|||||||
});
|
});
|
||||||
|
|
||||||
boost::system::error_code ec = boost::asio::error::would_block;
|
boost::system::error_code ec = boost::asio::error::would_block;
|
||||||
socket.async_handshake(type, boost::asio::buffer(buffer), boost::lambda::var(ec) = boost::lambda::_1);
|
socket.async_handshake(type, boost::lambda::var(ec) = boost::lambda::_1);
|
||||||
if (io_service.stopped())
|
if (io_service.stopped())
|
||||||
{
|
{
|
||||||
io_service.reset();
|
io_service.reset();
|
||||||
|
|||||||
@@ -6,17 +6,6 @@
|
|||||||
#include "string_tools.h"
|
#include "string_tools.h"
|
||||||
#include "net/local_ip.h"
|
#include "net/local_ip.h"
|
||||||
|
|
||||||
static inline uint32_t make_address_v4_from_v6(const boost::asio::ip::address_v6& a)
|
|
||||||
{
|
|
||||||
const auto &bytes = a.to_bytes();
|
|
||||||
uint32_t v4 = 0;
|
|
||||||
v4 = (v4 << 8) | bytes[12];
|
|
||||||
v4 = (v4 << 8) | bytes[13];
|
|
||||||
v4 = (v4 << 8) | bytes[14];
|
|
||||||
v4 = (v4 << 8) | bytes[15];
|
|
||||||
return htonl(v4);
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace epee { namespace net_utils
|
namespace epee { namespace net_utils
|
||||||
{
|
{
|
||||||
bool ipv4_network_address::equal(const ipv4_network_address& other) const noexcept
|
bool ipv4_network_address::equal(const ipv4_network_address& other) const noexcept
|
||||||
@@ -94,28 +83,8 @@ namespace epee { namespace net_utils
|
|||||||
network_address::interface const* const other_self = other.self.get();
|
network_address::interface const* const other_self = other.self.get();
|
||||||
if (self_ == other_self) return true;
|
if (self_ == other_self) return true;
|
||||||
if (!self_ || !other_self) return false;
|
if (!self_ || !other_self) return false;
|
||||||
if (typeid(*self_) == typeid(*other_self))
|
if (typeid(*self_) != typeid(*other_self)) return false;
|
||||||
return self_->is_same_host(*other_self);
|
return self_->is_same_host(*other_self);
|
||||||
const auto this_id = get_type_id();
|
|
||||||
if (this_id == ipv4_network_address::get_type_id() && other.get_type_id() == ipv6_network_address::get_type_id())
|
|
||||||
{
|
|
||||||
const boost::asio::ip::address_v6 &actual_ip = other.as<const epee::net_utils::ipv6_network_address>().ip();
|
|
||||||
if (actual_ip.is_v4_mapped())
|
|
||||||
{
|
|
||||||
const uint32_t v4ip = make_address_v4_from_v6(actual_ip);
|
|
||||||
return is_same_host(ipv4_network_address(v4ip, 0));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (this_id == ipv6_network_address::get_type_id() && other.get_type_id() == ipv4_network_address::get_type_id())
|
|
||||||
{
|
|
||||||
const boost::asio::ip::address_v6 &actual_ip = this->as<const epee::net_utils::ipv6_network_address>().ip();
|
|
||||||
if (actual_ip.is_v4_mapped())
|
|
||||||
{
|
|
||||||
const uint32_t v4ip = make_address_v4_from_v6(actual_ip);
|
|
||||||
return other.is_same_host(ipv4_network_address(v4ip, 0));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string print_connection_context(const connection_context_base& ctx)
|
std::string print_connection_context(const connection_context_base& ctx)
|
||||||
|
|||||||
@@ -1,29 +0,0 @@
|
|||||||
|
|
||||||
#include "byte_slice.h"
|
|
||||||
#include "byte_stream.h"
|
|
||||||
#include "misc_log_ex.h"
|
|
||||||
#include "span.h"
|
|
||||||
#include "storages/portable_storage.h"
|
|
||||||
#include "storages/portable_storage_to_bin.h"
|
|
||||||
|
|
||||||
namespace epee
|
|
||||||
{
|
|
||||||
namespace serialization
|
|
||||||
{
|
|
||||||
bool portable_storage::store_to_binary(byte_slice& target, const std::size_t initial_buffer_size)
|
|
||||||
{
|
|
||||||
TRY_ENTRY();
|
|
||||||
byte_stream ss;
|
|
||||||
ss.reserve(initial_buffer_size);
|
|
||||||
storage_block_header sbh{};
|
|
||||||
sbh.m_signature_a = SWAP32LE(PORTABLE_STORAGE_SIGNATUREA);
|
|
||||||
sbh.m_signature_b = SWAP32LE(PORTABLE_STORAGE_SIGNATUREB);
|
|
||||||
sbh.m_ver = PORTABLE_STORAGE_FORMAT_VER;
|
|
||||||
ss.write(epee::as_byte_span(sbh));
|
|
||||||
pack_entry_to_buff(ss, m_root);
|
|
||||||
target = epee::byte_slice{std::move(ss)};
|
|
||||||
return true;
|
|
||||||
CATCH_ENTRY("portable_storage::store_to_binary", false)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -51,7 +51,6 @@ rdln::readline_buffer::readline_buffer()
|
|||||||
|
|
||||||
void rdln::readline_buffer::start()
|
void rdln::readline_buffer::start()
|
||||||
{
|
{
|
||||||
boost::lock_guard<boost::mutex> lock(sync_mutex);
|
|
||||||
if(m_cout_buf != NULL)
|
if(m_cout_buf != NULL)
|
||||||
return;
|
return;
|
||||||
m_cout_buf = std::cout.rdbuf();
|
m_cout_buf = std::cout.rdbuf();
|
||||||
@@ -61,7 +60,6 @@ void rdln::readline_buffer::start()
|
|||||||
|
|
||||||
void rdln::readline_buffer::stop()
|
void rdln::readline_buffer::stop()
|
||||||
{
|
{
|
||||||
boost::lock_guard<boost::mutex> lock(sync_mutex);
|
|
||||||
if(m_cout_buf == NULL)
|
if(m_cout_buf == NULL)
|
||||||
return;
|
return;
|
||||||
std::cout.rdbuf(m_cout_buf);
|
std::cout.rdbuf(m_cout_buf);
|
||||||
@@ -90,9 +88,9 @@ rdln::linestatus rdln::readline_buffer::get_line(std::string& line) const
|
|||||||
|
|
||||||
void rdln::readline_buffer::set_prompt(const std::string& prompt)
|
void rdln::readline_buffer::set_prompt(const std::string& prompt)
|
||||||
{
|
{
|
||||||
boost::lock_guard<boost::mutex> lock(sync_mutex);
|
|
||||||
if(m_cout_buf == NULL)
|
if(m_cout_buf == NULL)
|
||||||
return;
|
return;
|
||||||
|
boost::lock_guard<boost::mutex> lock(sync_mutex);
|
||||||
rl_set_prompt(std::string(m_prompt_length, ' ').c_str());
|
rl_set_prompt(std::string(m_prompt_length, ' ').c_str());
|
||||||
rl_redisplay();
|
rl_redisplay();
|
||||||
rl_set_prompt(prompt.c_str());
|
rl_set_prompt(prompt.c_str());
|
||||||
@@ -115,12 +113,6 @@ const std::vector<std::string>& rdln::readline_buffer::get_completions()
|
|||||||
int rdln::readline_buffer::sync()
|
int rdln::readline_buffer::sync()
|
||||||
{
|
{
|
||||||
boost::lock_guard<boost::mutex> lock(sync_mutex);
|
boost::lock_guard<boost::mutex> lock(sync_mutex);
|
||||||
|
|
||||||
if (m_cout_buf == nullptr)
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if RL_READLINE_VERSION < 0x0700
|
#if RL_READLINE_VERSION < 0x0700
|
||||||
char lbuf[2] = {0,0};
|
char lbuf[2] = {0,0};
|
||||||
char *line = NULL;
|
char *line = NULL;
|
||||||
|
|||||||
@@ -188,7 +188,6 @@ gpg --detach-sign ${VERSION}-linux/${GH_USER}/monero-linux-*-build.assert
|
|||||||
gpg --detach-sign ${VERSION}-win/${GH_USER}/monero-win-*-build.assert
|
gpg --detach-sign ${VERSION}-win/${GH_USER}/monero-win-*-build.assert
|
||||||
gpg --detach-sign ${VERSION}-osx/${GH_USER}/monero-osx-*-build.assert
|
gpg --detach-sign ${VERSION}-osx/${GH_USER}/monero-osx-*-build.assert
|
||||||
gpg --detach-sign ${VERSION}-android/${GH_USER}/monero-android-*-build.assert
|
gpg --detach-sign ${VERSION}-android/${GH_USER}/monero-android-*-build.assert
|
||||||
gpg --detach-sign ${VERSION}-freebsd/${GH_USER}/monero-freebsd-*-build.assert
|
|
||||||
```
|
```
|
||||||
|
|
||||||
This will create a `.sig` file for each `.assert` file above (2 files for each platform).
|
This will create a `.sig` file for each `.assert` file above (2 files for each platform).
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
---
|
---
|
||||||
name: "wownero-android-0.9"
|
name: "wowzero-android-0.9"
|
||||||
enable_cache: true
|
enable_cache: true
|
||||||
suites:
|
suites:
|
||||||
- "bionic"
|
- "bionic"
|
||||||
@@ -32,8 +32,8 @@ packages:
|
|||||||
- "python3-zmq"
|
- "python3-zmq"
|
||||||
- "unzip"
|
- "unzip"
|
||||||
remotes:
|
remotes:
|
||||||
- "url": "https://git.wownero.com/wownero/wownero.git"
|
- "url": "https://git.wownero.com/synku/wowzero.git"
|
||||||
"dir": "wownero"
|
"dir": "wowzero"
|
||||||
files: []
|
files: []
|
||||||
script: |
|
script: |
|
||||||
|
|
||||||
@@ -75,7 +75,7 @@ script: |
|
|||||||
then
|
then
|
||||||
ABI=$i"eabi"
|
ABI=$i"eabi"
|
||||||
fi
|
fi
|
||||||
NDKDIR="${BUILD_DIR}/wownero/contrib/depends/$i/native/bin"
|
NDKDIR="${BUILD_DIR}/wowzero/contrib/depends/$i/native/bin"
|
||||||
for prog in ${FAKETIME_HOST_PROGS}; do
|
for prog in ${FAKETIME_HOST_PROGS}; do
|
||||||
WRAPPER=${WRAP_DIR}/${ABI}-${prog}
|
WRAPPER=${WRAP_DIR}/${ABI}-${prog}
|
||||||
echo '#!/usr/bin/env bash' > ${WRAPPER}
|
echo '#!/usr/bin/env bash' > ${WRAPPER}
|
||||||
@@ -97,7 +97,7 @@ script: |
|
|||||||
export SOURCE_DATE_EPOCH=`date -d 2000-01-01T12:00:00 +%s`
|
export SOURCE_DATE_EPOCH=`date -d 2000-01-01T12:00:00 +%s`
|
||||||
|
|
||||||
git config --global core.abbrev 9
|
git config --global core.abbrev 9
|
||||||
cd wownero
|
cd wowzero
|
||||||
# Set the version string that gets added to the tar archive name
|
# Set the version string that gets added to the tar archive name
|
||||||
version="`git describe`"
|
version="`git describe`"
|
||||||
if [[ $version == *"-"*"-"* ]]; then
|
if [[ $version == *"-"*"-"* ]]; then
|
||||||
@@ -127,7 +127,7 @@ script: |
|
|||||||
chmod 755 bin/*
|
chmod 755 bin/*
|
||||||
cp ../LICENSE bin
|
cp ../LICENSE bin
|
||||||
chmod 644 bin/LICENSE
|
chmod 644 bin/LICENSE
|
||||||
DISTNAME=wownero-${i}-${version}
|
DISTNAME=wowzero-${i}-${version}
|
||||||
mv bin ${DISTNAME}
|
mv bin ${DISTNAME}
|
||||||
find ${DISTNAME}/ | sort | tar --no-recursion --owner=0 --group=0 -c -T - | bzip2 -9 > ${OUTDIR}/${DISTNAME}.tar.bz2
|
find ${DISTNAME}/ | sort | tar --no-recursion --owner=0 --group=0 -c -T - | bzip2 -9 > ${OUTDIR}/${DISTNAME}.tar.bz2
|
||||||
cd ..
|
cd ..
|
||||||
|
|||||||
@@ -31,8 +31,8 @@ def setup():
|
|||||||
subprocess.check_call(['git', 'checkout', 'c0f77ca018cb5332bfd595e0aff0468f77542c23'])
|
subprocess.check_call(['git', 'checkout', 'c0f77ca018cb5332bfd595e0aff0468f77542c23'])
|
||||||
os.makedirs('inputs', exist_ok=True)
|
os.makedirs('inputs', exist_ok=True)
|
||||||
os.chdir('inputs')
|
os.chdir('inputs')
|
||||||
if not os.path.isdir('wownero'):
|
if not os.path.isdir('wowzero'):
|
||||||
subprocess.check_call(['git', 'clone', args.url, 'wownero'])
|
subprocess.check_call(['git', 'clone', args.url, 'wowzero'])
|
||||||
os.chdir('..')
|
os.chdir('..')
|
||||||
make_image_prog = ['bin/make-base-vm', '--suite', 'bionic', '--arch', 'amd64']
|
make_image_prog = ['bin/make-base-vm', '--suite', 'bionic', '--arch', 'amd64']
|
||||||
if args.docker:
|
if args.docker:
|
||||||
@@ -67,10 +67,10 @@ def rebuild():
|
|||||||
suffix = platforms[i][2]
|
suffix = platforms[i][2]
|
||||||
|
|
||||||
print('\nCompiling ' + args.version + ' ' + os_name)
|
print('\nCompiling ' + args.version + ' ' + os_name)
|
||||||
infile = 'inputs/wownero/contrib/gitian/gitian-' + tag_name + '.yml'
|
infile = 'inputs/wowzero/contrib/gitian/gitian-' + tag_name + '.yml'
|
||||||
subprocess.check_call(['bin/gbuild', '-j', args.jobs, '-m', args.memory, '--commit', 'wownero='+args.commit, '--url', 'wownero='+args.url, infile])
|
subprocess.check_call(['bin/gbuild', '-j', args.jobs, '-m', args.memory, '--commit', 'wowzero='+args.commit, '--url', 'wowzero='+args.url, infile])
|
||||||
subprocess.check_call(['bin/gsign', '-p', args.sign_prog, '--signer', args.signer, '--release', args.version+'-'+tag_name, '--destination', '../sigs/', infile])
|
subprocess.check_call(['bin/gsign', '-p', args.sign_prog, '--signer', args.signer, '--release', args.version+'-'+tag_name, '--destination', '../sigs/', infile])
|
||||||
subprocess.check_call('mv build/out/wownero-*.' + suffix + ' ../out/'+args.version, shell=True)
|
subprocess.check_call('mv build/out/wowzero-*.' + suffix + ' ../out/'+args.version, shell=True)
|
||||||
print('Moving var/install.log to var/install-' + tag_name + '.log')
|
print('Moving var/install.log to var/install-' + tag_name + '.log')
|
||||||
subprocess.check_call('mv var/install.log var/install-' + tag_name + '.log', shell=True)
|
subprocess.check_call('mv var/install.log var/install-' + tag_name + '.log', shell=True)
|
||||||
print('Moving var/build.log to var/build-' + tag_name + '.log')
|
print('Moving var/build.log to var/build-' + tag_name + '.log')
|
||||||
@@ -98,7 +98,7 @@ def build():
|
|||||||
subprocess.check_call(['wget', '-N', '-P', 'inputs', 'https://bitcoincore.org/cfields/osslsigncode-Backports-to-1.7.1.patch'])
|
subprocess.check_call(['wget', '-N', '-P', 'inputs', 'https://bitcoincore.org/cfields/osslsigncode-Backports-to-1.7.1.patch'])
|
||||||
subprocess.check_output(["echo 'a8c4e9cafba922f89de0df1f2152e7be286aba73f78505169bc351a7938dd911 inputs/osslsigncode-Backports-to-1.7.1.patch' | sha256sum -c"], shell=True)
|
subprocess.check_output(["echo 'a8c4e9cafba922f89de0df1f2152e7be286aba73f78505169bc351a7938dd911 inputs/osslsigncode-Backports-to-1.7.1.patch' | sha256sum -c"], shell=True)
|
||||||
subprocess.check_output(["echo 'f9a8cdb38b9c309326764ebc937cba1523a3a751a7ab05df3ecc99d18ae466c9 inputs/osslsigncode-1.7.1.tar.gz' | sha256sum -c"], shell=True)
|
subprocess.check_output(["echo 'f9a8cdb38b9c309326764ebc937cba1523a3a751a7ab05df3ecc99d18ae466c9 inputs/osslsigncode-1.7.1.tar.gz' | sha256sum -c"], shell=True)
|
||||||
subprocess.check_call(['make', '-C', 'inputs/wownero/contrib/depends', 'download', 'SOURCES_PATH=' + os.getcwd() + '/cache/common'])
|
subprocess.check_call(['make', '-C', 'inputs/wowzero/contrib/depends', 'download', 'SOURCES_PATH=' + os.getcwd() + '/cache/common'])
|
||||||
|
|
||||||
rebuild()
|
rebuild()
|
||||||
|
|
||||||
@@ -109,7 +109,7 @@ def verify():
|
|||||||
|
|
||||||
for i, v in platforms:
|
for i, v in platforms:
|
||||||
print('\nVerifying v'+args.version+' '+v[0]+'\n')
|
print('\nVerifying v'+args.version+' '+v[0]+'\n')
|
||||||
subprocess.check_call(['bin/gverify', '-v', '-d', '../sigs/', '-r', args.version+'-'+v[1], 'inputs/wownero/contrib/gitian/gitian-'+v[1]+'.yml'])
|
subprocess.check_call(['bin/gverify', '-v', '-d', '../sigs/', '-r', args.version+'-'+v[1], 'inputs/wowzero/contrib/gitian/gitian-'+v[1]+'.yml'])
|
||||||
os.chdir(workdir)
|
os.chdir(workdir)
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
@@ -118,7 +118,7 @@ def main():
|
|||||||
parser = argparse.ArgumentParser(description='Script for running full Gitian builds.', usage='%(prog)s [options] signer version')
|
parser = argparse.ArgumentParser(description='Script for running full Gitian builds.', usage='%(prog)s [options] signer version')
|
||||||
parser.add_argument('-c', '--commit', action='store_true', dest='commit', help='Indicate that the version argument is for a commit or branch')
|
parser.add_argument('-c', '--commit', action='store_true', dest='commit', help='Indicate that the version argument is for a commit or branch')
|
||||||
parser.add_argument('-p', '--pull', action='store_true', dest='pull', help='Indicate that the version argument is the number of a github repository pull request')
|
parser.add_argument('-p', '--pull', action='store_true', dest='pull', help='Indicate that the version argument is the number of a github repository pull request')
|
||||||
parser.add_argument('-u', '--url', dest='url', default='https://git.wownero.com/wownero/wownero', help='Specify the URL of the repository. Default is %(default)s')
|
parser.add_argument('-u', '--url', dest='url', default='https://git.wownero.com/synku/wowzero', help='Specify the URL of the repository. Default is %(default)s')
|
||||||
parser.add_argument('-v', '--verify', action='store_true', dest='verify', help='Verify the Gitian build')
|
parser.add_argument('-v', '--verify', action='store_true', dest='verify', help='Verify the Gitian build')
|
||||||
parser.add_argument('-b', '--build', action='store_true', dest='build', help='Do a Gitian build')
|
parser.add_argument('-b', '--build', action='store_true', dest='build', help='Do a Gitian build')
|
||||||
parser.add_argument('-B', '--buildsign', action='store_true', dest='buildsign', help='Build both signed and unsigned binaries')
|
parser.add_argument('-B', '--buildsign', action='store_true', dest='buildsign', help='Build both signed and unsigned binaries')
|
||||||
@@ -190,8 +190,8 @@ def main():
|
|||||||
if args.setup:
|
if args.setup:
|
||||||
setup()
|
setup()
|
||||||
|
|
||||||
os.makedirs('builder/inputs/wownero', exist_ok=True)
|
os.makedirs('builder/inputs/wowzero', exist_ok=True)
|
||||||
os.chdir('builder/inputs/wownero')
|
os.chdir('builder/inputs/wowzero')
|
||||||
if args.pull:
|
if args.pull:
|
||||||
subprocess.check_call(['git', 'fetch', args.url, 'refs/pull/'+args.version+'/merge'])
|
subprocess.check_call(['git', 'fetch', args.url, 'refs/pull/'+args.version+'/merge'])
|
||||||
args.commit = subprocess.check_output(['git', 'show', '-s', '--format=%H', 'FETCH_HEAD'], universal_newlines=True).strip()
|
args.commit = subprocess.check_output(['git', 'show', '-s', '--format=%H', 'FETCH_HEAD'], universal_newlines=True).strip()
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
---
|
---
|
||||||
name: "wownero-freebsd-0.9"
|
name: "wowzero-freebsd-0.9"
|
||||||
enable_cache: true
|
enable_cache: true
|
||||||
suites:
|
suites:
|
||||||
- "bionic"
|
- "bionic"
|
||||||
@@ -32,8 +32,8 @@ packages:
|
|||||||
- "libprotobuf-dev"
|
- "libprotobuf-dev"
|
||||||
- "python3-zmq"
|
- "python3-zmq"
|
||||||
remotes:
|
remotes:
|
||||||
- "url": "https://git.wownero.com/wownero/wownero.git"
|
- "url": "https://git.wownero.com/synku/wowzero.git"
|
||||||
"dir": "wownero"
|
"dir": "wowzero"
|
||||||
files: []
|
files: []
|
||||||
script: |
|
script: |
|
||||||
|
|
||||||
@@ -92,7 +92,7 @@ script: |
|
|||||||
export SOURCE_DATE_EPOCH=`date -d 2000-01-01T12:00:00 +%s`
|
export SOURCE_DATE_EPOCH=`date -d 2000-01-01T12:00:00 +%s`
|
||||||
|
|
||||||
git config --global core.abbrev 9
|
git config --global core.abbrev 9
|
||||||
cd wownero
|
cd wowzero
|
||||||
# Set the version string that gets added to the tar archive name
|
# Set the version string that gets added to the tar archive name
|
||||||
version="`git describe`"
|
version="`git describe`"
|
||||||
if [[ $version == *"-"*"-"* ]]; then
|
if [[ $version == *"-"*"-"* ]]; then
|
||||||
@@ -124,7 +124,7 @@ script: |
|
|||||||
chmod 755 bin/*
|
chmod 755 bin/*
|
||||||
cp ../LICENSE bin
|
cp ../LICENSE bin
|
||||||
chmod 644 bin/LICENSE
|
chmod 644 bin/LICENSE
|
||||||
DISTNAME=wownero-${i}-${version}
|
DISTNAME=wowzero-${i}-${version}
|
||||||
mv bin ${DISTNAME}
|
mv bin ${DISTNAME}
|
||||||
find ${DISTNAME}/ | sort | tar --no-recursion --owner=0 --group=0 -c -T - | bzip2 -9 > ${OUTDIR}/${DISTNAME}.tar.bz2
|
find ${DISTNAME}/ | sort | tar --no-recursion --owner=0 --group=0 -c -T - | bzip2 -9 > ${OUTDIR}/${DISTNAME}.tar.bz2
|
||||||
cd ..
|
cd ..
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
---
|
---
|
||||||
name: "wownero-linux-0.9"
|
name: "wowzero-linux-0.9"
|
||||||
enable_cache: true
|
enable_cache: true
|
||||||
suites:
|
suites:
|
||||||
- "bionic"
|
- "bionic"
|
||||||
@@ -43,8 +43,8 @@ packages:
|
|||||||
- "libprotobuf-dev"
|
- "libprotobuf-dev"
|
||||||
- "python3-zmq"
|
- "python3-zmq"
|
||||||
remotes:
|
remotes:
|
||||||
- "url": "https://git.wownero.com/wownero/wownero.git"
|
- "url": "https://git.wownero.com/synku/wowzero.git"
|
||||||
"dir": "wownero"
|
"dir": "wowzero"
|
||||||
files: []
|
files: []
|
||||||
script: |
|
script: |
|
||||||
|
|
||||||
@@ -120,7 +120,7 @@ script: |
|
|||||||
export SOURCE_DATE_EPOCH=`date -d 2000-01-01T12:00:00 +%s`
|
export SOURCE_DATE_EPOCH=`date -d 2000-01-01T12:00:00 +%s`
|
||||||
|
|
||||||
git config --global core.abbrev 9
|
git config --global core.abbrev 9
|
||||||
cd wownero
|
cd wowzero
|
||||||
# Set the version string that gets added to the tar archive name
|
# Set the version string that gets added to the tar archive name
|
||||||
version="`git describe`"
|
version="`git describe`"
|
||||||
if [[ $version == *"-"*"-"* ]]; then
|
if [[ $version == *"-"*"-"* ]]; then
|
||||||
@@ -169,7 +169,7 @@ script: |
|
|||||||
chmod 755 bin/*
|
chmod 755 bin/*
|
||||||
cp ../LICENSE bin
|
cp ../LICENSE bin
|
||||||
chmod 644 bin/LICENSE
|
chmod 644 bin/LICENSE
|
||||||
DISTNAME=wownero-${i}-${version}
|
DISTNAME=wowzero-${i}-${version}
|
||||||
mv bin ${DISTNAME}
|
mv bin ${DISTNAME}
|
||||||
find ${DISTNAME}/ | sort | tar --no-recursion --owner=0 --group=0 -c -T - | bzip2 -9 > ${OUTDIR}/${DISTNAME}.tar.bz2
|
find ${DISTNAME}/ | sort | tar --no-recursion --owner=0 --group=0 -c -T - | bzip2 -9 > ${OUTDIR}/${DISTNAME}.tar.bz2
|
||||||
cd ..
|
cd ..
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
---
|
---
|
||||||
name: "wownero-osx-0.9"
|
name: "wowzero-osx-0.9"
|
||||||
enable_cache: true
|
enable_cache: true
|
||||||
suites:
|
suites:
|
||||||
- "bionic"
|
- "bionic"
|
||||||
@@ -24,8 +24,8 @@ packages:
|
|||||||
- "python-dev"
|
- "python-dev"
|
||||||
- "python-setuptools"
|
- "python-setuptools"
|
||||||
remotes:
|
remotes:
|
||||||
- "url": "https://git.wownero.com/wownero/wownero.git"
|
- "url": "https://git.wownero.com/synku/wowzero.git"
|
||||||
"dir": "wownero"
|
"dir": "wowzero"
|
||||||
files:
|
files:
|
||||||
- "MacOSX10.11.sdk.tar.gz"
|
- "MacOSX10.11.sdk.tar.gz"
|
||||||
script: |
|
script: |
|
||||||
@@ -77,7 +77,7 @@ script: |
|
|||||||
export PATH=${WRAP_DIR}:${PATH}
|
export PATH=${WRAP_DIR}:${PATH}
|
||||||
|
|
||||||
git config --global core.abbrev 9
|
git config --global core.abbrev 9
|
||||||
cd wownero
|
cd wowzero
|
||||||
# Set the version string that gets added to the tar archive name
|
# Set the version string that gets added to the tar archive name
|
||||||
version="`git describe`"
|
version="`git describe`"
|
||||||
if [[ $version == *"-"*"-"* ]]; then
|
if [[ $version == *"-"*"-"* ]]; then
|
||||||
@@ -113,7 +113,7 @@ script: |
|
|||||||
chmod 755 bin/*
|
chmod 755 bin/*
|
||||||
cp ../LICENSE bin
|
cp ../LICENSE bin
|
||||||
chmod 644 bin/LICENSE
|
chmod 644 bin/LICENSE
|
||||||
DISTNAME=wownero-${i}-${version}
|
DISTNAME=wowzero-${i}-${version}
|
||||||
mv bin ${DISTNAME}
|
mv bin ${DISTNAME}
|
||||||
find ${DISTNAME}/ | sort | tar --no-recursion --owner=0 --group=0 -c -T - | bzip2 -9 > ${OUTDIR}/${DISTNAME}.tar.bz2
|
find ${DISTNAME}/ | sort | tar --no-recursion --owner=0 --group=0 -c -T - | bzip2 -9 > ${OUTDIR}/${DISTNAME}.tar.bz2
|
||||||
cd ..
|
cd ..
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
---
|
---
|
||||||
name: "wownero-win-0.9"
|
name: "wowzero-win-0.9"
|
||||||
enable_cache: true
|
enable_cache: true
|
||||||
suites:
|
suites:
|
||||||
- "bionic"
|
- "bionic"
|
||||||
@@ -36,8 +36,8 @@ alternatives:
|
|||||||
package: "x86_64-w64-mingw32-gcc"
|
package: "x86_64-w64-mingw32-gcc"
|
||||||
path: "/usr/bin/x86_64-w64-mingw32-gcc-posix"
|
path: "/usr/bin/x86_64-w64-mingw32-gcc-posix"
|
||||||
remotes:
|
remotes:
|
||||||
- "url": "https://git.wownero.com/wownero/wownero.git"
|
- "url": "https://git.wownero.com/synku/wowzero.git"
|
||||||
"dir": "wownero"
|
"dir": "wowzero"
|
||||||
files: []
|
files: []
|
||||||
script: |
|
script: |
|
||||||
WRAP_DIR=$HOME/wrapped
|
WRAP_DIR=$HOME/wrapped
|
||||||
@@ -91,7 +91,7 @@ script: |
|
|||||||
export SOURCE_DATE_EPOCH=`date -d 2000-01-01T12:00:00 +%s`
|
export SOURCE_DATE_EPOCH=`date -d 2000-01-01T12:00:00 +%s`
|
||||||
|
|
||||||
git config --global core.abbrev 9
|
git config --global core.abbrev 9
|
||||||
cd wownero
|
cd wowzero
|
||||||
# Set the version string that gets added to the tar archive name
|
# Set the version string that gets added to the tar archive name
|
||||||
version="`git describe`"
|
version="`git describe`"
|
||||||
if [[ $version == *"-"*"-"* ]]; then
|
if [[ $version == *"-"*"-"* ]]; then
|
||||||
@@ -128,7 +128,7 @@ script: |
|
|||||||
cmake .. -DCMAKE_TOOLCHAIN_FILE=${BASEPREFIX}/${i}/share/toolchain.cmake
|
cmake .. -DCMAKE_TOOLCHAIN_FILE=${BASEPREFIX}/${i}/share/toolchain.cmake
|
||||||
make ${MAKEOPTS}
|
make ${MAKEOPTS}
|
||||||
cp ../LICENSE bin
|
cp ../LICENSE bin
|
||||||
DISTNAME=wownero-${i}-${version}
|
DISTNAME=wowzero-${i}-${version}
|
||||||
mv bin ${DISTNAME}
|
mv bin ${DISTNAME}
|
||||||
find ${DISTNAME}/ | sort | zip -X@ ${OUTDIR}/${DISTNAME}.zip
|
find ${DISTNAME}/ | sort | zip -X@ ${OUTDIR}/${DISTNAME}.zip
|
||||||
cd .. && rm -rf build
|
cd .. && rm -rf build
|
||||||
|
|||||||
@@ -75,8 +75,6 @@ function (monero_add_executable name)
|
|||||||
PROPERTY
|
PROPERTY
|
||||||
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
|
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
|
||||||
enable_stack_trace("${name}")
|
enable_stack_trace("${name}")
|
||||||
|
|
||||||
monero_set_target_no_relink("${name}")
|
|
||||||
endfunction ()
|
endfunction ()
|
||||||
|
|
||||||
function (monero_add_library name)
|
function (monero_add_library name)
|
||||||
@@ -94,7 +92,6 @@ function (monero_add_library_with_deps)
|
|||||||
set(objlib obj_${MONERO_ADD_LIBRARY_NAME})
|
set(objlib obj_${MONERO_ADD_LIBRARY_NAME})
|
||||||
add_library(${objlib} OBJECT ${MONERO_ADD_LIBRARY_SOURCES})
|
add_library(${objlib} OBJECT ${MONERO_ADD_LIBRARY_SOURCES})
|
||||||
add_library("${MONERO_ADD_LIBRARY_NAME}" $<TARGET_OBJECTS:${objlib}>)
|
add_library("${MONERO_ADD_LIBRARY_NAME}" $<TARGET_OBJECTS:${objlib}>)
|
||||||
monero_set_target_no_relink("${MONERO_ADD_LIBRARY_NAME}")
|
|
||||||
if (MONERO_ADD_LIBRARY_DEPENDS)
|
if (MONERO_ADD_LIBRARY_DEPENDS)
|
||||||
add_dependencies(${objlib} ${MONERO_ADD_LIBRARY_DEPENDS})
|
add_dependencies(${objlib} ${MONERO_ADD_LIBRARY_DEPENDS})
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
@@ -1312,20 +1312,17 @@ public:
|
|||||||
* height. The number of blocks returned is variable, based on the max_size passed.
|
* height. The number of blocks returned is variable, based on the max_size passed.
|
||||||
*
|
*
|
||||||
* @param start_height the height of the first block
|
* @param start_height the height of the first block
|
||||||
* @param min_block_count the minimum number of blocks to return, if they exist
|
* @param min_count the minimum number of blocks to return, if they exist
|
||||||
* @param max_block_count the maximum number of blocks to return
|
* @param max_count the maximum number of blocks to return
|
||||||
* @param max_tx_count the maximum number of txes to return
|
|
||||||
* @param max_size the maximum size of block/transaction data to return (will be exceeded by one blocks's worth at most, if min_count is met)
|
* @param max_size the maximum size of block/transaction data to return (will be exceeded by one blocks's worth at most, if min_count is met)
|
||||||
* @param blocks the returned block/transaction data
|
* @param blocks the returned block/transaction data
|
||||||
* @param pruned whether to return full or pruned tx data
|
* @param pruned whether to return full or pruned tx data
|
||||||
* @param skip_coinbase whether to return or skip coinbase transactions (they're in blocks regardless)
|
* @param skip_coinbase whether to return or skip coinbase transactions (they're in blocks regardless)
|
||||||
* @param get_miner_tx_hash whether to calculate and return the miner (coinbase) tx hash
|
* @param get_miner_tx_hash whether to calculate and return the miner (coinbase) tx hash
|
||||||
*
|
*
|
||||||
* The call will return at least min_block_count if possible, even if this contravenes max_tx_count
|
|
||||||
*
|
|
||||||
* @return true iff the blocks and transactions were found
|
* @return true iff the blocks and transactions were found
|
||||||
*/
|
*/
|
||||||
virtual bool get_blocks_from(uint64_t start_height, size_t min_block_count, size_t max_block_count, size_t max_tx_count, size_t max_size, std::vector<std::pair<std::pair<cryptonote::blobdata, crypto::hash>, std::vector<std::pair<crypto::hash, cryptonote::blobdata>>>>& blocks, bool pruned, bool skip_coinbase, bool get_miner_tx_hash) const = 0;
|
virtual bool get_blocks_from(uint64_t start_height, size_t min_count, size_t max_count, size_t max_size, std::vector<std::pair<std::pair<cryptonote::blobdata, crypto::hash>, std::vector<std::pair<crypto::hash, cryptonote::blobdata>>>>& blocks, bool pruned, bool skip_coinbase, bool get_miner_tx_hash) const = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief fetches the prunable transaction blob with the given hash
|
* @brief fetches the prunable transaction blob with the given hash
|
||||||
|
|||||||
@@ -3001,7 +3001,7 @@ bool BlockchainLMDB::tx_exists(const crypto::hash& h) const
|
|||||||
|
|
||||||
if (! tx_found)
|
if (! tx_found)
|
||||||
{
|
{
|
||||||
LOG_PRINT_L3("transaction with hash " << epee::string_tools::pod_to_hex(h) << " not found in db");
|
LOG_PRINT_L1("transaction with hash " << epee::string_tools::pod_to_hex(h) << " not found in db");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3032,7 +3032,7 @@ bool BlockchainLMDB::tx_exists(const crypto::hash& h, uint64_t& tx_id) const
|
|||||||
bool ret = false;
|
bool ret = false;
|
||||||
if (get_result == MDB_NOTFOUND)
|
if (get_result == MDB_NOTFOUND)
|
||||||
{
|
{
|
||||||
LOG_PRINT_L3("transaction with hash " << epee::string_tools::pod_to_hex(h) << " not found in db");
|
LOG_PRINT_L1("transaction with hash " << epee::string_tools::pod_to_hex(h) << " not found in db");
|
||||||
}
|
}
|
||||||
else if (get_result)
|
else if (get_result)
|
||||||
throw0(DB_ERROR(lmdb_error("DB error attempting to fetch transaction from hash", get_result).c_str()));
|
throw0(DB_ERROR(lmdb_error("DB error attempting to fetch transaction from hash", get_result).c_str()));
|
||||||
@@ -3171,7 +3171,7 @@ bool BlockchainLMDB::get_pruned_tx_blobs_from(const crypto::hash& h, size_t coun
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BlockchainLMDB::get_blocks_from(uint64_t start_height, size_t min_block_count, size_t max_block_count, size_t max_tx_count, size_t max_size, std::vector<std::pair<std::pair<cryptonote::blobdata, crypto::hash>, std::vector<std::pair<crypto::hash, cryptonote::blobdata>>>>& blocks, bool pruned, bool skip_coinbase, bool get_miner_tx_hash) const
|
bool BlockchainLMDB::get_blocks_from(uint64_t start_height, size_t min_count, size_t max_count, size_t max_size, std::vector<std::pair<std::pair<cryptonote::blobdata, crypto::hash>, std::vector<std::pair<crypto::hash, cryptonote::blobdata>>>>& blocks, bool pruned, bool skip_coinbase, bool get_miner_tx_hash) const
|
||||||
{
|
{
|
||||||
LOG_PRINT_L3("BlockchainLMDB::" << __func__);
|
LOG_PRINT_L3("BlockchainLMDB::" << __func__);
|
||||||
check_open();
|
check_open();
|
||||||
@@ -3185,15 +3185,14 @@ bool BlockchainLMDB::get_blocks_from(uint64_t start_height, size_t min_block_cou
|
|||||||
RCURSOR(txs_prunable);
|
RCURSOR(txs_prunable);
|
||||||
}
|
}
|
||||||
|
|
||||||
blocks.reserve(std::min<size_t>(max_block_count, 10000)); // guard against very large max count if only checking bytes
|
blocks.reserve(std::min<size_t>(max_count, 10000)); // guard against very large max count if only checking bytes
|
||||||
const uint64_t blockchain_height = height();
|
const uint64_t blockchain_height = height();
|
||||||
uint64_t size = 0;
|
uint64_t size = 0;
|
||||||
size_t num_txes = 0;
|
|
||||||
MDB_val_copy<uint64_t> key(start_height);
|
MDB_val_copy<uint64_t> key(start_height);
|
||||||
MDB_val k, v, val_tx_id;
|
MDB_val k, v, val_tx_id;
|
||||||
uint64_t tx_id = ~0;
|
uint64_t tx_id = ~0;
|
||||||
MDB_cursor_op op = MDB_SET;
|
MDB_cursor_op op = MDB_SET;
|
||||||
for (uint64_t h = start_height; h < blockchain_height && blocks.size() < max_block_count && (size < max_size || blocks.size() < min_block_count); ++h)
|
for (uint64_t h = start_height; h < blockchain_height && blocks.size() < max_count && (size < max_size || blocks.size() < min_count); ++h)
|
||||||
{
|
{
|
||||||
MDB_cursor_op op = h == start_height ? MDB_SET : MDB_NEXT;
|
MDB_cursor_op op = h == start_height ? MDB_SET : MDB_NEXT;
|
||||||
int result = mdb_cursor_get(m_cur_blocks, &key, &v, op);
|
int result = mdb_cursor_get(m_cur_blocks, &key, &v, op);
|
||||||
@@ -3244,7 +3243,6 @@ bool BlockchainLMDB::get_blocks_from(uint64_t start_height, size_t min_block_cou
|
|||||||
op = MDB_NEXT;
|
op = MDB_NEXT;
|
||||||
|
|
||||||
current_block.second.reserve(b.tx_hashes.size());
|
current_block.second.reserve(b.tx_hashes.size());
|
||||||
num_txes += b.tx_hashes.size() + (skip_coinbase ? 0 : 1);
|
|
||||||
for (const auto &tx_hash: b.tx_hashes)
|
for (const auto &tx_hash: b.tx_hashes)
|
||||||
{
|
{
|
||||||
// get pruned data
|
// get pruned data
|
||||||
@@ -3264,9 +3262,6 @@ bool BlockchainLMDB::get_blocks_from(uint64_t start_height, size_t min_block_cou
|
|||||||
current_block.second.push_back(std::make_pair(tx_hash, std::move(tx_blob)));
|
current_block.second.push_back(std::make_pair(tx_hash, std::move(tx_blob)));
|
||||||
size += current_block.second.back().second.size();
|
size += current_block.second.back().second.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (blocks.size() >= min_block_count && num_txes >= max_tx_count)
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TXN_POSTFIX_RDONLY();
|
TXN_POSTFIX_RDONLY();
|
||||||
|
|||||||
@@ -257,7 +257,7 @@ public:
|
|||||||
virtual bool get_tx_blob(const crypto::hash& h, cryptonote::blobdata &tx) const;
|
virtual bool get_tx_blob(const crypto::hash& h, cryptonote::blobdata &tx) const;
|
||||||
virtual bool get_pruned_tx_blob(const crypto::hash& h, cryptonote::blobdata &tx) const;
|
virtual bool get_pruned_tx_blob(const crypto::hash& h, cryptonote::blobdata &tx) const;
|
||||||
virtual bool get_pruned_tx_blobs_from(const crypto::hash& h, size_t count, std::vector<cryptonote::blobdata> &bd) const;
|
virtual bool get_pruned_tx_blobs_from(const crypto::hash& h, size_t count, std::vector<cryptonote::blobdata> &bd) const;
|
||||||
virtual bool get_blocks_from(uint64_t start_height, size_t min_block_count, size_t max_block_count, size_t max_tx_count, size_t max_size, std::vector<std::pair<std::pair<cryptonote::blobdata, crypto::hash>, std::vector<std::pair<crypto::hash, cryptonote::blobdata>>>>& blocks, bool pruned, bool skip_coinbase, bool get_miner_tx_hash) const;
|
virtual bool get_blocks_from(uint64_t start_height, size_t min_count, size_t max_count, size_t max_size, std::vector<std::pair<std::pair<cryptonote::blobdata, crypto::hash>, std::vector<std::pair<crypto::hash, cryptonote::blobdata>>>>& blocks, bool pruned, bool skip_coinbase, bool get_miner_tx_hash) const;
|
||||||
virtual bool get_prunable_tx_blob(const crypto::hash& h, cryptonote::blobdata &tx) const;
|
virtual bool get_prunable_tx_blob(const crypto::hash& h, cryptonote::blobdata &tx) const;
|
||||||
virtual bool get_prunable_tx_hash(const crypto::hash& tx_hash, crypto::hash &prunable_hash) const;
|
virtual bool get_prunable_tx_hash(const crypto::hash& tx_hash, crypto::hash &prunable_hash) const;
|
||||||
|
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ public:
|
|||||||
virtual bool get_tx_blob(const crypto::hash& h, cryptonote::blobdata &tx) const override { return false; }
|
virtual bool get_tx_blob(const crypto::hash& h, cryptonote::blobdata &tx) const override { return false; }
|
||||||
virtual bool get_pruned_tx_blob(const crypto::hash& h, cryptonote::blobdata &tx) const override { return false; }
|
virtual bool get_pruned_tx_blob(const crypto::hash& h, cryptonote::blobdata &tx) const override { return false; }
|
||||||
virtual bool get_pruned_tx_blobs_from(const crypto::hash& h, size_t count, std::vector<cryptonote::blobdata> &bd) const override { return false; }
|
virtual bool get_pruned_tx_blobs_from(const crypto::hash& h, size_t count, std::vector<cryptonote::blobdata> &bd) const override { return false; }
|
||||||
virtual bool get_blocks_from(uint64_t start_height, size_t min_block_count, size_t max_block_count, size_t max_tx_count, size_t max_size, std::vector<std::pair<std::pair<cryptonote::blobdata, crypto::hash>, std::vector<std::pair<crypto::hash, cryptonote::blobdata>>>>& blocks, bool pruned, bool skip_coinbase, bool get_miner_tx_hash) const override { return false; }
|
virtual bool get_blocks_from(uint64_t start_height, size_t min_count, size_t max_count, size_t max_size, std::vector<std::pair<std::pair<cryptonote::blobdata, crypto::hash>, std::vector<std::pair<crypto::hash, cryptonote::blobdata>>>>& blocks, bool pruned, bool skip_coinbase, bool get_miner_tx_hash) const override { return false; }
|
||||||
virtual bool get_prunable_tx_blob(const crypto::hash& h, cryptonote::blobdata &tx) const override { return false; }
|
virtual bool get_prunable_tx_blob(const crypto::hash& h, cryptonote::blobdata &tx) const override { return false; }
|
||||||
virtual bool get_prunable_tx_hash(const crypto::hash& tx_hash, crypto::hash &prunable_hash) const override { return false; }
|
virtual bool get_prunable_tx_hash(const crypto::hash& tx_hash, crypto::hash &prunable_hash) const override { return false; }
|
||||||
virtual uint64_t get_block_height(const crypto::hash& h) const override { return 0; }
|
virtual uint64_t get_block_height(const crypto::hash& h) const override { return 0; }
|
||||||
|
|||||||
@@ -45,4 +45,4 @@ foreach(BLOB_NAME checkpoints)
|
|||||||
)
|
)
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
monero_add_library(blocks blocks.cpp ${GENERATED_SOURCES})
|
add_library(blocks STATIC blocks.cpp ${GENERATED_SOURCES})
|
||||||
|
|||||||
Binary file not shown.
@@ -200,7 +200,7 @@ namespace cryptonote
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// make RPC call to daemon
|
// make RPC call to daemon
|
||||||
// curl http://127.0.0.1:34568/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"get_block","params":{"height":278300}}' -H 'Content-Type: application/json'
|
// curl http://127.0.0.1:34568/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"get_block","params":{"height":247600}}' -H 'Content-Type: application/json'
|
||||||
// "wide_cumulative_difficulty": "0x14eb4d0131fe8",
|
// "wide_cumulative_difficulty": "0x14eb4d0131fe8",
|
||||||
ADD_CHECKPOINT2(1, "97f4ce4d7879b3bea54dcec738cd2ebb7952b4e9bb9743262310cd5fec749340", "0x2");
|
ADD_CHECKPOINT2(1, "97f4ce4d7879b3bea54dcec738cd2ebb7952b4e9bb9743262310cd5fec749340", "0x2");
|
||||||
ADD_CHECKPOINT2(6969, "aa7b66e8c461065139b55c29538a39c33ceda93e587f84d490ed573d80511c87", "0x118eef693fd"); //Hard fork to v8
|
ADD_CHECKPOINT2(6969, "aa7b66e8c461065139b55c29538a39c33ceda93e587f84d490ed573d80511c87", "0x118eef693fd"); //Hard fork to v8
|
||||||
@@ -214,8 +214,6 @@ namespace cryptonote
|
|||||||
ADD_CHECKPOINT2(253999, "755a289fe8a68e96a0f69069ba4007b676ec87dce2e47dfb9647fe5691f49883", "0x172d026ef7fe8"); //Hard fork to v16
|
ADD_CHECKPOINT2(253999, "755a289fe8a68e96a0f69069ba4007b676ec87dce2e47dfb9647fe5691f49883", "0x172d026ef7fe8"); //Hard fork to v16
|
||||||
ADD_CHECKPOINT2(254287, "b37cb55abe73965b424f8028bf71bef98d069645077ffa52f0c134907b7734e3", "0x1746622f56668"); //Hard fork to v17
|
ADD_CHECKPOINT2(254287, "b37cb55abe73965b424f8028bf71bef98d069645077ffa52f0c134907b7734e3", "0x1746622f56668"); //Hard fork to v17
|
||||||
ADD_CHECKPOINT2(256700, "389a8ab95a80e84ec74639c1078bc67b33af208ef00f53bd9609cfc40efa7059", "0x185ace3c1bd68");
|
ADD_CHECKPOINT2(256700, "389a8ab95a80e84ec74639c1078bc67b33af208ef00f53bd9609cfc40efa7059", "0x185ace3c1bd68");
|
||||||
ADD_CHECKPOINT2(271600, "9597cdbdc52ca57d7dbd8f9c0a23a73194ef2ebbcfdc75c21992672706108d43", "0x1e2d2d6a2a9e8");
|
|
||||||
ADD_CHECKPOINT2(278300, "b10dcdf7a51651f60fbcc0447409773eef1458d2c706d9a61daf467571ac19c9", "0x20a83a16d3968");
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,26 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
namespace tools
|
|
||||||
{
|
|
||||||
template<uint64_t a, uint64_t b>
|
|
||||||
struct PowerOf
|
|
||||||
{
|
|
||||||
enum Data : uint64_t
|
|
||||||
{
|
|
||||||
// a^b = a * a^(b-1)
|
|
||||||
Value = a * PowerOf<a, b - 1>::Value,
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
template<uint64_t a>
|
|
||||||
struct PowerOf<a, 0>
|
|
||||||
{
|
|
||||||
enum Data : uint64_t
|
|
||||||
{
|
|
||||||
// a^0 = 1
|
|
||||||
Value = 1,
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -871,19 +871,10 @@ std::string get_nix_version_display_string()
|
|||||||
return max_concurrency;
|
return max_concurrency;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool is_privacy_preserving_network(const std::string &address)
|
|
||||||
{
|
|
||||||
if (boost::ends_with(address, ".onion"))
|
|
||||||
return true;
|
|
||||||
if (boost::ends_with(address, ".i2p"))
|
|
||||||
return true;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool is_local_address(const std::string &address)
|
bool is_local_address(const std::string &address)
|
||||||
{
|
{
|
||||||
// always assume Tor/I2P addresses to be untrusted by default
|
// always assume Tor/I2P addresses to be untrusted by default
|
||||||
if (is_privacy_preserving_network(address))
|
if (boost::ends_with(address, ".onion") || boost::ends_with(address, ".i2p"))
|
||||||
{
|
{
|
||||||
MDEBUG("Address '" << address << "' is Tor/I2P, non local");
|
MDEBUG("Address '" << address << "' is Tor/I2P, non local");
|
||||||
return false;
|
return false;
|
||||||
@@ -1009,13 +1000,13 @@ std::string get_nix_version_display_string()
|
|||||||
for (char c: val)
|
for (char c: val)
|
||||||
{
|
{
|
||||||
if (c == '*')
|
if (c == '*')
|
||||||
newval += escape ? "*" : ".*", escape = false;
|
newval += escape ? "*" : ".*";
|
||||||
else if (c == '?')
|
else if (c == '?')
|
||||||
newval += escape ? "?" : ".", escape = false;
|
newval += escape ? "?" : ".";
|
||||||
else if (c == '\\')
|
else if (c == '\\')
|
||||||
newval += '\\', escape = !escape;
|
newval += '\\', escape = !escape;
|
||||||
else
|
else
|
||||||
newval += c, escape = false;
|
newval += c;
|
||||||
}
|
}
|
||||||
return newval;
|
return newval;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -228,7 +228,6 @@ namespace tools
|
|||||||
unsigned get_max_concurrency();
|
unsigned get_max_concurrency();
|
||||||
|
|
||||||
bool is_local_address(const std::string &address);
|
bool is_local_address(const std::string &address);
|
||||||
bool is_privacy_preserving_network(const std::string &address);
|
|
||||||
int vercmp(const char *v0, const char *v1); // returns < 0, 0, > 0, similar to strcmp, but more human friendly than lexical - does not attempt to validate
|
int vercmp(const char *v0, const char *v1); // returns < 0, 0, > 0, similar to strcmp, but more human friendly than lexical - does not attempt to validate
|
||||||
|
|
||||||
bool sha256sum(const uint8_t *data, size_t len, crypto::hash &hash);
|
bool sha256sum(const uint8_t *data, size_t len, crypto::hash &hash);
|
||||||
|
|||||||
@@ -123,17 +123,13 @@ namespace crypto {
|
|||||||
void random32_unbiased(unsigned char *bytes)
|
void random32_unbiased(unsigned char *bytes)
|
||||||
{
|
{
|
||||||
// l = 2^252 + 27742317777372353535851937790883648493.
|
// l = 2^252 + 27742317777372353535851937790883648493.
|
||||||
// l fits 15 times in 32 bytes (iow, 15 l is the highest multiple of l that fits in 32 bytes)
|
// it fits 15 in 32 bytes
|
||||||
static const unsigned char limit[32] = { 0xe3, 0x6a, 0x67, 0x72, 0x8b, 0xce, 0x13, 0x29, 0x8f, 0x30, 0x82, 0x8c, 0x0b, 0xa4, 0x10, 0x39, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0 };
|
static const unsigned char limit[32] = { 0xe3, 0x6a, 0x67, 0x72, 0x8b, 0xce, 0x13, 0x29, 0x8f, 0x30, 0x82, 0x8c, 0x0b, 0xa4, 0x10, 0x39, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0 };
|
||||||
while(1)
|
do
|
||||||
{
|
{
|
||||||
generate_random_bytes_thread_safe(32, bytes);
|
generate_random_bytes_thread_safe(32, bytes);
|
||||||
if (!less32(bytes, limit))
|
} while (!sc_isnonzero(bytes) && !less32(bytes, limit)); // should be good about 15/16 of the time
|
||||||
continue;
|
sc_reduce32(bytes);
|
||||||
sc_reduce32(bytes);
|
|
||||||
if (sc_isnonzero(bytes))
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
/* generate a random 32-byte (256-bit) integer and copy it to res */
|
/* generate a random 32-byte (256-bit) integer and copy it to res */
|
||||||
static inline void random_scalar(ec_scalar &res) {
|
static inline void random_scalar(ec_scalar &res) {
|
||||||
|
|||||||
@@ -38,7 +38,6 @@ endif()
|
|||||||
|
|
||||||
set(cryptonote_basic_sources
|
set(cryptonote_basic_sources
|
||||||
account.cpp
|
account.cpp
|
||||||
connection_context.cpp
|
|
||||||
cryptonote_basic_impl.cpp
|
cryptonote_basic_impl.cpp
|
||||||
cryptonote_format_utils.cpp
|
cryptonote_format_utils.cpp
|
||||||
difficulty.cpp
|
difficulty.cpp
|
||||||
|
|||||||
@@ -1,71 +0,0 @@
|
|||||||
// Copyright (c) 2020, The Monero Project
|
|
||||||
//
|
|
||||||
// All rights reserved.
|
|
||||||
//
|
|
||||||
// Redistribution and use in source and binary forms, with or without modification, are
|
|
||||||
// permitted provided that the following conditions are met:
|
|
||||||
//
|
|
||||||
// 1. Redistributions of source code must retain the above copyright notice, this list of
|
|
||||||
// conditions and the following disclaimer.
|
|
||||||
//
|
|
||||||
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
|
||||||
// of conditions and the following disclaimer in the documentation and/or other
|
|
||||||
// materials provided with the distribution.
|
|
||||||
//
|
|
||||||
// 3. Neither the name of the copyright holder nor the names of its contributors may be
|
|
||||||
// used to endorse or promote products derived from this software without specific
|
|
||||||
// prior written permission.
|
|
||||||
//
|
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
|
||||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
||||||
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
|
||||||
// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
||||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
||||||
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
|
|
||||||
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
#include "connection_context.h"
|
|
||||||
|
|
||||||
#include "cryptonote_protocol/cryptonote_protocol_defs.h"
|
|
||||||
#include "p2p/p2p_protocol_defs.h"
|
|
||||||
|
|
||||||
namespace cryptonote
|
|
||||||
{
|
|
||||||
std::size_t cryptonote_connection_context::get_max_bytes(const int command) noexcept
|
|
||||||
{
|
|
||||||
switch (command)
|
|
||||||
{
|
|
||||||
case nodetool::COMMAND_HANDSHAKE_T<cryptonote::CORE_SYNC_DATA>::ID:
|
|
||||||
return 65536;
|
|
||||||
case nodetool::COMMAND_TIMED_SYNC_T<cryptonote::CORE_SYNC_DATA>::ID:
|
|
||||||
return 65536;
|
|
||||||
case nodetool::COMMAND_PING::ID:
|
|
||||||
return 4096;
|
|
||||||
case nodetool::COMMAND_REQUEST_SUPPORT_FLAGS::ID:
|
|
||||||
return 4096;
|
|
||||||
case cryptonote::NOTIFY_NEW_BLOCK::ID:
|
|
||||||
return 1024 * 1024 * 128; // 128 MB (max packet is a bit less than 100 MB though)
|
|
||||||
case cryptonote::NOTIFY_NEW_TRANSACTIONS::ID:
|
|
||||||
return 1024 * 1024 * 128; // 128 MB (max packet is a bit less than 100 MB though)
|
|
||||||
case cryptonote::NOTIFY_REQUEST_GET_OBJECTS::ID:
|
|
||||||
return 1024 * 1024 * 2; // 2 MB
|
|
||||||
case cryptonote::NOTIFY_RESPONSE_GET_OBJECTS::ID:
|
|
||||||
return 1024 * 1024 * 128; // 128 MB (max packet is a bit less than 100 MB though)
|
|
||||||
case cryptonote::NOTIFY_REQUEST_CHAIN::ID:
|
|
||||||
return 512 * 1024; // 512 kB
|
|
||||||
case cryptonote::NOTIFY_RESPONSE_CHAIN_ENTRY::ID:
|
|
||||||
return 1024 * 1024 * 4; // 4 MB
|
|
||||||
case cryptonote::NOTIFY_NEW_FLUFFY_BLOCK::ID:
|
|
||||||
return 1024 * 1024 * 4; // 4 MB, but it does not includes transaction data
|
|
||||||
case cryptonote::NOTIFY_REQUEST_FLUFFY_MISSING_TX::ID:
|
|
||||||
return 1024 * 1024; // 1 MB
|
|
||||||
case cryptonote::NOTIFY_GET_TXPOOL_COMPLEMENT::ID:
|
|
||||||
return 1024 * 1024 * 4; // 4 MB
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
};
|
|
||||||
return std::numeric_limits<size_t>::max();
|
|
||||||
}
|
|
||||||
} // cryptonote
|
|
||||||
@@ -31,7 +31,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <unordered_set>
|
#include <unordered_set>
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <algorithm>
|
|
||||||
#include <boost/date_time/posix_time/posix_time.hpp>
|
#include <boost/date_time/posix_time/posix_time.hpp>
|
||||||
#include "net/net_utils_base.h"
|
#include "net/net_utils_base.h"
|
||||||
#include "copyable_atomic.h"
|
#include "copyable_atomic.h"
|
||||||
@@ -39,12 +38,12 @@
|
|||||||
|
|
||||||
namespace cryptonote
|
namespace cryptonote
|
||||||
{
|
{
|
||||||
|
|
||||||
struct cryptonote_connection_context: public epee::net_utils::connection_context_base
|
struct cryptonote_connection_context: public epee::net_utils::connection_context_base
|
||||||
{
|
{
|
||||||
cryptonote_connection_context(): m_state(state_before_handshake), m_remote_blockchain_height(0), m_last_response_height(0),
|
cryptonote_connection_context(): m_state(state_before_handshake), m_remote_blockchain_height(0), m_last_response_height(0),
|
||||||
m_last_request_time(boost::date_time::not_a_date_time), m_callback_request_count(0),
|
m_last_request_time(boost::date_time::not_a_date_time), m_callback_request_count(0),
|
||||||
m_last_known_hash(crypto::null_hash), m_pruning_seed(0), m_rpc_port(0), m_rpc_credits_per_hash(0), m_anchor(false), m_score(0),
|
m_last_known_hash(crypto::null_hash), m_pruning_seed(0), m_rpc_port(0), m_rpc_credits_per_hash(0), m_anchor(false) {}
|
||||||
m_expect_response(0), m_expect_height(0), m_num_requested(0) {}
|
|
||||||
|
|
||||||
enum state
|
enum state
|
||||||
{
|
{
|
||||||
@@ -55,12 +54,6 @@ namespace cryptonote
|
|||||||
state_normal
|
state_normal
|
||||||
};
|
};
|
||||||
|
|
||||||
static constexpr int handshake_command() noexcept { return 1001; }
|
|
||||||
bool handshake_complete() const noexcept { return m_state != state_before_handshake; }
|
|
||||||
|
|
||||||
//! \return Maximum number of bytes permissible for `command`.
|
|
||||||
static size_t get_max_bytes(int command) noexcept;
|
|
||||||
|
|
||||||
state m_state;
|
state m_state;
|
||||||
std::vector<std::pair<crypto::hash, uint64_t>> m_needed_objects;
|
std::vector<std::pair<crypto::hash, uint64_t>> m_needed_objects;
|
||||||
std::unordered_set<crypto::hash> m_requested_objects;
|
std::unordered_set<crypto::hash> m_requested_objects;
|
||||||
@@ -73,10 +66,7 @@ namespace cryptonote
|
|||||||
uint16_t m_rpc_port;
|
uint16_t m_rpc_port;
|
||||||
uint32_t m_rpc_credits_per_hash;
|
uint32_t m_rpc_credits_per_hash;
|
||||||
bool m_anchor;
|
bool m_anchor;
|
||||||
int32_t m_score;
|
//size_t m_score; TODO: add score calculations
|
||||||
int m_expect_response;
|
|
||||||
uint64_t m_expect_height;
|
|
||||||
size_t m_num_requested;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
inline std::string get_protocol_state_string(cryptonote_connection_context::state s)
|
inline std::string get_protocol_state_string(cryptonote_connection_context::state s)
|
||||||
|
|||||||
@@ -67,11 +67,11 @@
|
|||||||
#define COIN ((uint64_t)100000000000) // pow(10, 11)
|
#define COIN ((uint64_t)100000000000) // pow(10, 11)
|
||||||
|
|
||||||
#define FEE_PER_KB_OLD ((uint64_t)10000000000) // pow(10, 10)
|
#define FEE_PER_KB_OLD ((uint64_t)10000000000) // pow(10, 10)
|
||||||
#define FEE_PER_KB ((uint64_t)2000000000) // 2 * pow(10, 9)
|
#define FEE_PER_KB ((uint64_t)666666666) // 2 * pow(10, 9)
|
||||||
#define FEE_PER_BYTE ((uint64_t)300000)
|
#define FEE_PER_BYTE ((uint64_t)100000)
|
||||||
#define DYNAMIC_FEE_PER_KB_BASE_FEE ((uint64_t)2000000000) // 2 * pow(10,9)
|
#define DYNAMIC_FEE_PER_KB_BASE_FEE ((uint64_t)666666666) // 2 * pow(10,9)
|
||||||
#define DYNAMIC_FEE_PER_KB_BASE_BLOCK_REWARD ((uint64_t)10000000000000) // 10 * pow(10,12)
|
#define DYNAMIC_FEE_PER_KB_BASE_BLOCK_REWARD ((uint64_t)10000000000000) // 10 * pow(10,12)
|
||||||
#define DYNAMIC_FEE_PER_KB_BASE_FEE_V5 ((uint64_t)2000000000 * (uint64_t)CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_V2 / CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_V5)
|
#define DYNAMIC_FEE_PER_KB_BASE_FEE_V5 ((uint64_t)666666666 * (uint64_t)CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_V2 / CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_V5)
|
||||||
#define DYNAMIC_FEE_REFERENCE_TRANSACTION_WEIGHT ((uint64_t)3000)
|
#define DYNAMIC_FEE_REFERENCE_TRANSACTION_WEIGHT ((uint64_t)3000)
|
||||||
|
|
||||||
#define ORPHANED_BLOCKS_MAX_COUNT 100
|
#define ORPHANED_BLOCKS_MAX_COUNT 100
|
||||||
@@ -79,11 +79,13 @@
|
|||||||
|
|
||||||
#define DIFFICULTY_TARGET_V2 300
|
#define DIFFICULTY_TARGET_V2 300
|
||||||
#define DIFFICULTY_TARGET_V1 300
|
#define DIFFICULTY_TARGET_V1 300
|
||||||
|
#define DIFFICULTY_WINDOW_V4 77
|
||||||
#define DIFFICULTY_WINDOW_V3 144
|
#define DIFFICULTY_WINDOW_V3 144
|
||||||
#define DIFFICULTY_WINDOW_V2 60
|
#define DIFFICULTY_WINDOW_V2 60
|
||||||
#define DIFFICULTY_WINDOW 720 // blocks
|
#define DIFFICULTY_WINDOW 720 // blocks
|
||||||
#define DIFFICULTY_LAG 15 // !!!
|
#define DIFFICULTY_LAG 15 // !!!
|
||||||
#define DIFFICULTY_CUT 60 // timestamps to cut after sorting
|
#define DIFFICULTY_CUT 60 // timestamps to cut after sorting
|
||||||
|
#define DIFFICULTY_BLOCKS_COUNT_V4 DIFFICULTY_WINDOW_V4 + 1 // added +1 to make N=N
|
||||||
#define DIFFICULTY_BLOCKS_COUNT_V3 DIFFICULTY_WINDOW_V3 + 1 // added +1 to make N=N
|
#define DIFFICULTY_BLOCKS_COUNT_V3 DIFFICULTY_WINDOW_V3 + 1 // added +1 to make N=N
|
||||||
#define DIFFICULTY_BLOCKS_COUNT_V2 DIFFICULTY_WINDOW_V2 + 1 // added +1 to make N=N
|
#define DIFFICULTY_BLOCKS_COUNT_V2 DIFFICULTY_WINDOW_V2 + 1 // added +1 to make N=N
|
||||||
#define DIFFICULTY_BLOCKS_COUNT DIFFICULTY_WINDOW + DIFFICULTY_LAG
|
#define DIFFICULTY_BLOCKS_COUNT DIFFICULTY_WINDOW + DIFFICULTY_LAG
|
||||||
@@ -97,7 +99,6 @@
|
|||||||
|
|
||||||
|
|
||||||
#define BLOCKS_IDS_SYNCHRONIZING_DEFAULT_COUNT 10000 //by default, blocks ids count in synchronizing
|
#define BLOCKS_IDS_SYNCHRONIZING_DEFAULT_COUNT 10000 //by default, blocks ids count in synchronizing
|
||||||
#define BLOCKS_IDS_SYNCHRONIZING_MAX_COUNT 25000 //max blocks ids count in synchronizing
|
|
||||||
#define BLOCKS_SYNCHRONIZING_DEFAULT_COUNT_PRE_V4 100 //by default, blocks count in blocks downloading
|
#define BLOCKS_SYNCHRONIZING_DEFAULT_COUNT_PRE_V4 100 //by default, blocks count in blocks downloading
|
||||||
#define BLOCKS_SYNCHRONIZING_DEFAULT_COUNT 20 //by default, blocks count in blocks downloading
|
#define BLOCKS_SYNCHRONIZING_DEFAULT_COUNT 20 //by default, blocks count in blocks downloading
|
||||||
#define BLOCKS_SYNCHRONIZING_MAX_COUNT 2048 //must be a power of 2, greater than 128, equal to SEEDHASH_EPOCH_BLOCKS
|
#define BLOCKS_SYNCHRONIZING_MAX_COUNT 2048 //must be a power of 2, greater than 128, equal to SEEDHASH_EPOCH_BLOCKS
|
||||||
@@ -107,11 +108,11 @@
|
|||||||
|
|
||||||
|
|
||||||
#define CRYPTONOTE_DANDELIONPP_STEMS 2 // number of outgoing stem connections per epoch
|
#define CRYPTONOTE_DANDELIONPP_STEMS 2 // number of outgoing stem connections per epoch
|
||||||
#define CRYPTONOTE_DANDELIONPP_FLUFF_PROBABILITY 20 // out of 100
|
#define CRYPTONOTE_DANDELIONPP_FLUFF_PROBABILITY 10 // out of 100
|
||||||
#define CRYPTONOTE_DANDELIONPP_MIN_EPOCH 10 // minutes
|
#define CRYPTONOTE_DANDELIONPP_MIN_EPOCH 10 // minutes
|
||||||
#define CRYPTONOTE_DANDELIONPP_EPOCH_RANGE 30 // seconds
|
#define CRYPTONOTE_DANDELIONPP_EPOCH_RANGE 30 // seconds
|
||||||
#define CRYPTONOTE_DANDELIONPP_FLUSH_AVERAGE 5 // seconds average for poisson distributed fluff flush
|
#define CRYPTONOTE_DANDELIONPP_FLUSH_AVERAGE 5 // seconds average for poisson distributed fluff flush
|
||||||
#define CRYPTONOTE_DANDELIONPP_EMBARGO_AVERAGE 39 // seconds (see tx_pool.cpp for more info)
|
#define CRYPTONOTE_DANDELIONPP_EMBARGO_AVERAGE 173 // seconds (see tx_pool.cpp for more info)
|
||||||
|
|
||||||
// see src/cryptonote_protocol/levin_notify.cpp
|
// see src/cryptonote_protocol/levin_notify.cpp
|
||||||
#define CRYPTONOTE_NOISE_MIN_EPOCH 5 // minutes
|
#define CRYPTONOTE_NOISE_MIN_EPOCH 5 // minutes
|
||||||
@@ -128,8 +129,7 @@
|
|||||||
|
|
||||||
#define CRYPTONOTE_MAX_FRAGMENTS 20 // ~20 * NOISE_BYTES max payload size for covert/noise send
|
#define CRYPTONOTE_MAX_FRAGMENTS 20 // ~20 * NOISE_BYTES max payload size for covert/noise send
|
||||||
|
|
||||||
#define COMMAND_RPC_GET_BLOCKS_FAST_MAX_BLOCK_COUNT 1000
|
#define COMMAND_RPC_GET_BLOCKS_FAST_MAX_COUNT 1000
|
||||||
#define COMMAND_RPC_GET_BLOCKS_FAST_MAX_TX_COUNT 20000
|
|
||||||
|
|
||||||
#define P2P_LOCAL_WHITE_PEERLIST_LIMIT 1000
|
#define P2P_LOCAL_WHITE_PEERLIST_LIMIT 1000
|
||||||
#define P2P_LOCAL_GRAY_PEERLIST_LIMIT 5000
|
#define P2P_LOCAL_GRAY_PEERLIST_LIMIT 5000
|
||||||
@@ -138,7 +138,6 @@
|
|||||||
#define P2P_DEFAULT_HANDSHAKE_INTERVAL 60 //secondes
|
#define P2P_DEFAULT_HANDSHAKE_INTERVAL 60 //secondes
|
||||||
#define P2P_DEFAULT_PACKET_MAX_SIZE 50000000 //50000000 bytes maximum packet size
|
#define P2P_DEFAULT_PACKET_MAX_SIZE 50000000 //50000000 bytes maximum packet size
|
||||||
#define P2P_DEFAULT_PEERS_IN_HANDSHAKE 250
|
#define P2P_DEFAULT_PEERS_IN_HANDSHAKE 250
|
||||||
#define P2P_MAX_PEERS_IN_HANDSHAKE 250
|
|
||||||
#define P2P_DEFAULT_CONNECTION_TIMEOUT 5000 //5 seconds
|
#define P2P_DEFAULT_CONNECTION_TIMEOUT 5000 //5 seconds
|
||||||
#define P2P_DEFAULT_SOCKS_CONNECT_TIMEOUT 45 // seconds
|
#define P2P_DEFAULT_SOCKS_CONNECT_TIMEOUT 45 // seconds
|
||||||
#define P2P_DEFAULT_PING_CONNECTION_TIMEOUT 2000 //2 seconds
|
#define P2P_DEFAULT_PING_CONNECTION_TIMEOUT 2000 //2 seconds
|
||||||
@@ -204,8 +203,6 @@
|
|||||||
|
|
||||||
#define RPC_CREDITS_PER_HASH_SCALE ((float)(1<<24))
|
#define RPC_CREDITS_PER_HASH_SCALE ((float)(1<<24))
|
||||||
|
|
||||||
#define DNS_BLOCKLIST_LIFETIME (86400 * 8)
|
|
||||||
|
|
||||||
// New constants are intended to go here
|
// New constants are intended to go here
|
||||||
namespace config
|
namespace config
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2780,7 +2780,7 @@ bool Blockchain::find_blockchain_supplement(const std::list<crypto::hash>& qbloc
|
|||||||
// find split point between ours and foreign blockchain (or start at
|
// find split point between ours and foreign blockchain (or start at
|
||||||
// blockchain height <req_start_block>), and return up to max_count FULL
|
// blockchain height <req_start_block>), and return up to max_count FULL
|
||||||
// blocks by reference.
|
// blocks by reference.
|
||||||
bool Blockchain::find_blockchain_supplement(const uint64_t req_start_block, const std::list<crypto::hash>& qblock_ids, std::vector<std::pair<std::pair<cryptonote::blobdata, crypto::hash>, std::vector<std::pair<crypto::hash, cryptonote::blobdata> > > >& blocks, uint64_t& total_height, uint64_t& start_height, bool pruned, bool get_miner_tx_hash, size_t max_block_count, size_t max_tx_count) const
|
bool Blockchain::find_blockchain_supplement(const uint64_t req_start_block, const std::list<crypto::hash>& qblock_ids, std::vector<std::pair<std::pair<cryptonote::blobdata, crypto::hash>, std::vector<std::pair<crypto::hash, cryptonote::blobdata> > > >& blocks, uint64_t& total_height, uint64_t& start_height, bool pruned, bool get_miner_tx_hash, size_t max_count) const
|
||||||
{
|
{
|
||||||
LOG_PRINT_L3("Blockchain::" << __func__);
|
LOG_PRINT_L3("Blockchain::" << __func__);
|
||||||
CRITICAL_REGION_LOCAL(m_blockchain_lock);
|
CRITICAL_REGION_LOCAL(m_blockchain_lock);
|
||||||
@@ -2805,8 +2805,8 @@ bool Blockchain::find_blockchain_supplement(const uint64_t req_start_block, cons
|
|||||||
|
|
||||||
db_rtxn_guard rtxn_guard(m_db);
|
db_rtxn_guard rtxn_guard(m_db);
|
||||||
total_height = get_current_blockchain_height();
|
total_height = get_current_blockchain_height();
|
||||||
blocks.reserve(std::min(std::min(max_block_count, (size_t)10000), (size_t)(total_height - start_height)));
|
blocks.reserve(std::min(std::min(max_count, (size_t)10000), (size_t)(total_height - start_height)));
|
||||||
CHECK_AND_ASSERT_MES(m_db->get_blocks_from(start_height, 3, max_block_count, max_tx_count, FIND_BLOCKCHAIN_SUPPLEMENT_MAX_SIZE, blocks, pruned, true, get_miner_tx_hash),
|
CHECK_AND_ASSERT_MES(m_db->get_blocks_from(start_height, 3, max_count, FIND_BLOCKCHAIN_SUPPLEMENT_MAX_SIZE, blocks, pruned, true, get_miner_tx_hash),
|
||||||
false, "Error getting blocks");
|
false, "Error getting blocks");
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -2837,44 +2837,32 @@ void Blockchain::flush_invalid_blocks()
|
|||||||
m_invalid_blocks.clear();
|
m_invalid_blocks.clear();
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
bool Blockchain::have_block_unlocked(const crypto::hash& id, int *where) const
|
bool Blockchain::have_block(const crypto::hash& id) const
|
||||||
{
|
{
|
||||||
// WARNING: this function does not take m_blockchain_lock, and thus should only call read only
|
|
||||||
// m_db functions which do not depend on one another (ie, no getheight + gethash(height-1), as
|
|
||||||
// well as not accessing class members, even read only (ie, m_invalid_blocks). The caller must
|
|
||||||
// lock if it is otherwise needed.
|
|
||||||
LOG_PRINT_L3("Blockchain::" << __func__);
|
LOG_PRINT_L3("Blockchain::" << __func__);
|
||||||
|
CRITICAL_REGION_LOCAL(m_blockchain_lock);
|
||||||
|
|
||||||
if(m_db->block_exists(id))
|
if(m_db->block_exists(id))
|
||||||
{
|
{
|
||||||
LOG_PRINT_L2("block " << id << " found in main chain");
|
LOG_PRINT_L2("block " << id << " found in main chain");
|
||||||
if (where) *where = HAVE_BLOCK_MAIN_CHAIN;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(m_db->get_alt_block(id, NULL, NULL))
|
if(m_db->get_alt_block(id, NULL, NULL))
|
||||||
{
|
{
|
||||||
LOG_PRINT_L2("block " << id << " found in alternative chains");
|
LOG_PRINT_L2("block " << id << " found in alternative chains");
|
||||||
if (where) *where = HAVE_BLOCK_ALT_CHAIN;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(m_invalid_blocks.count(id))
|
if(m_invalid_blocks.count(id))
|
||||||
{
|
{
|
||||||
LOG_PRINT_L2("block " << id << " found in m_invalid_blocks");
|
LOG_PRINT_L2("block " << id << " found in m_invalid_blocks");
|
||||||
if (where) *where = HAVE_BLOCK_INVALID;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
bool Blockchain::have_block(const crypto::hash& id, int *where) const
|
|
||||||
{
|
|
||||||
CRITICAL_REGION_LOCAL(m_blockchain_lock);
|
|
||||||
return have_block_unlocked(id, where);
|
|
||||||
}
|
|
||||||
//------------------------------------------------------------------
|
|
||||||
bool Blockchain::handle_block_to_main_chain(const block& bl, block_verification_context& bvc, bool notify/* = true*/)
|
bool Blockchain::handle_block_to_main_chain(const block& bl, block_verification_context& bvc, bool notify/* = true*/)
|
||||||
{
|
{
|
||||||
LOG_PRINT_L3("Blockchain::" << __func__);
|
LOG_PRINT_L3("Blockchain::" << __func__);
|
||||||
@@ -3232,6 +3220,14 @@ bool Blockchain::expand_transaction_2(transaction &tx, const crypto::hash &tx_pr
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (rv.type == rct::RCTTypeCLSAG)
|
||||||
|
{
|
||||||
|
CHECK_AND_ASSERT_MES(rv.p.CLSAGs.size() == tx.vin.size(), false, "Bad CLSAGs size");
|
||||||
|
for (size_t n = 0; n < tx.vin.size(); ++n)
|
||||||
|
{
|
||||||
|
rv.p.CLSAGs[n].I = rct::ki2rct(boost::get<txin_to_key>(tx.vin[n]).k_image);
|
||||||
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CHECK_AND_ASSERT_MES(false, false, "Unsupported rct tx type: " + boost::lexical_cast<std::string>(rv.type));
|
CHECK_AND_ASSERT_MES(false, false, "Unsupported rct tx type: " + boost::lexical_cast<std::string>(rv.type));
|
||||||
@@ -3714,6 +3710,19 @@ void Blockchain::check_ring_signature(const crypto::hash &tx_prefix_hash, const
|
|||||||
result = crypto::check_ring_signature(tx_prefix_hash, key_image, p_output_keys, sig.data()) ? 1 : 0;
|
result = crypto::check_ring_signature(tx_prefix_hash, key_image, p_output_keys, sig.data()) ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//------------------------------------------------------------------
|
||||||
|
uint64_t Blockchain::get_fee_quantization_mask()
|
||||||
|
{
|
||||||
|
static uint64_t mask = 0;
|
||||||
|
if (mask == 0)
|
||||||
|
{
|
||||||
|
mask = 1;
|
||||||
|
for (size_t n = PER_KB_FEE_QUANTIZATION_DECIMALS; n < CRYPTONOTE_DISPLAY_DECIMAL_POINT; ++n)
|
||||||
|
mask *= 10;
|
||||||
|
}
|
||||||
|
return mask;
|
||||||
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
uint64_t Blockchain::get_dynamic_base_fee(uint64_t block_reward, size_t median_block_weight, uint8_t version)
|
uint64_t Blockchain::get_dynamic_base_fee(uint64_t block_reward, size_t median_block_weight, uint8_t version)
|
||||||
{
|
{
|
||||||
@@ -4819,8 +4828,6 @@ uint64_t Blockchain::prevalidate_block_hashes(uint64_t height, const std::vector
|
|||||||
|
|
||||||
CHECK_AND_ASSERT_MES(weights.empty() || weights.size() == hashes.size(), 0, "Unexpected weights size");
|
CHECK_AND_ASSERT_MES(weights.empty() || weights.size() == hashes.size(), 0, "Unexpected weights size");
|
||||||
|
|
||||||
CRITICAL_REGION_LOCAL(m_blockchain_lock);
|
|
||||||
|
|
||||||
// easy case: height >= hashes
|
// easy case: height >= hashes
|
||||||
if (height >= m_blocks_hash_of_hashes.size() * HASH_OF_HASHES_STEP)
|
if (height >= m_blocks_hash_of_hashes.size() * HASH_OF_HASHES_STEP)
|
||||||
return hashes.size();
|
return hashes.size();
|
||||||
@@ -5460,7 +5467,7 @@ void Blockchain::cancel()
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if defined(PER_BLOCK_CHECKPOINT)
|
#if defined(PER_BLOCK_CHECKPOINT)
|
||||||
static const char expected_block_hashes_hash[] = "44393af098c4738ecbe664292bc345c0acb40573562cac8bb67cea75debe9f1b";
|
static const char expected_block_hashes_hash[] = "5b78fd258ef3078654d2b15c9c2d6baab371805b94a9aa748f615995b207d045";
|
||||||
void Blockchain::load_compiled_in_block_hashes(const GetCheckpointsCallback& get_checkpoints)
|
void Blockchain::load_compiled_in_block_hashes(const GetCheckpointsCallback& get_checkpoints)
|
||||||
{
|
{
|
||||||
if (get_checkpoints == nullptr || !m_fast_sync)
|
if (get_checkpoints == nullptr || !m_fast_sync)
|
||||||
|
|||||||
@@ -51,7 +51,6 @@
|
|||||||
#include "string_tools.h"
|
#include "string_tools.h"
|
||||||
#include "rolling_median.h"
|
#include "rolling_median.h"
|
||||||
#include "cryptonote_basic/cryptonote_basic.h"
|
#include "cryptonote_basic/cryptonote_basic.h"
|
||||||
#include "common/powerof.h"
|
|
||||||
#include "common/util.h"
|
#include "common/util.h"
|
||||||
#include "cryptonote_protocol/cryptonote_protocol_defs.h"
|
#include "cryptonote_protocol/cryptonote_protocol_defs.h"
|
||||||
#include "rpc/core_rpc_server_commands_defs.h"
|
#include "rpc/core_rpc_server_commands_defs.h"
|
||||||
@@ -377,12 +376,10 @@ namespace cryptonote
|
|||||||
* for a block with the given hash
|
* for a block with the given hash
|
||||||
*
|
*
|
||||||
* @param id the hash to search for
|
* @param id the hash to search for
|
||||||
* @param where the type of block, if non NULL
|
|
||||||
*
|
*
|
||||||
* @return true if the block is known, else false
|
* @return true if the block is known, else false
|
||||||
*/
|
*/
|
||||||
bool have_block_unlocked(const crypto::hash& id, int *where = NULL) const;
|
bool have_block(const crypto::hash& id) const;
|
||||||
bool have_block(const crypto::hash& id, int *where = NULL) const;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief gets the total number of transactions on the main chain
|
* @brief gets the total number of transactions on the main chain
|
||||||
@@ -467,12 +464,11 @@ namespace cryptonote
|
|||||||
* @param total_height return-by-reference our current blockchain height
|
* @param total_height return-by-reference our current blockchain height
|
||||||
* @param start_height return-by-reference the height of the first block returned
|
* @param start_height return-by-reference the height of the first block returned
|
||||||
* @param pruned whether to return full or pruned tx blobs
|
* @param pruned whether to return full or pruned tx blobs
|
||||||
* @param max_block_count the max number of blocks to get
|
* @param max_count the max number of blocks to get
|
||||||
* @param max_tx_count the max number of txes to get (it can get overshot by the last block's number of txes minus 1)
|
|
||||||
*
|
*
|
||||||
* @return true if a block found in common or req_start_block specified, else false
|
* @return true if a block found in common or req_start_block specified, else false
|
||||||
*/
|
*/
|
||||||
bool find_blockchain_supplement(const uint64_t req_start_block, const std::list<crypto::hash>& qblock_ids, std::vector<std::pair<std::pair<cryptonote::blobdata, crypto::hash>, std::vector<std::pair<crypto::hash, cryptonote::blobdata> > > >& blocks, uint64_t& total_height, uint64_t& start_height, bool pruned, bool get_miner_tx_hash, size_t max_block_count, size_t max_tx_count) const;
|
bool find_blockchain_supplement(const uint64_t req_start_block, const std::list<crypto::hash>& qblock_ids, std::vector<std::pair<std::pair<cryptonote::blobdata, crypto::hash>, std::vector<std::pair<crypto::hash, cryptonote::blobdata> > > >& blocks, uint64_t& total_height, uint64_t& start_height, bool pruned, bool get_miner_tx_hash, size_t max_count) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief retrieves a set of blocks and their transactions, and possibly other transactions
|
* @brief retrieves a set of blocks and their transactions, and possibly other transactions
|
||||||
@@ -595,10 +591,7 @@ namespace cryptonote
|
|||||||
*
|
*
|
||||||
* @return the fee quantized mask
|
* @return the fee quantized mask
|
||||||
*/
|
*/
|
||||||
static uint64_t get_fee_quantization_mask()
|
static uint64_t get_fee_quantization_mask();
|
||||||
{
|
|
||||||
return tools::PowerOf<10, CRYPTONOTE_DISPLAY_DECIMAL_POINT - PER_KB_FEE_QUANTIZATION_DECIMALS>::Value;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief get dynamic per kB or byte fee for a given block weight
|
* @brief get dynamic per kB or byte fee for a given block weight
|
||||||
|
|||||||
@@ -1446,9 +1446,9 @@ namespace cryptonote
|
|||||||
return m_blockchain_storage.find_blockchain_supplement(qblock_ids, clip_pruned, resp);
|
return m_blockchain_storage.find_blockchain_supplement(qblock_ids, clip_pruned, resp);
|
||||||
}
|
}
|
||||||
//-----------------------------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------------------------
|
||||||
bool core::find_blockchain_supplement(const uint64_t req_start_block, const std::list<crypto::hash>& qblock_ids, std::vector<std::pair<std::pair<cryptonote::blobdata, crypto::hash>, std::vector<std::pair<crypto::hash, cryptonote::blobdata> > > >& blocks, uint64_t& total_height, uint64_t& start_height, bool pruned, bool get_miner_tx_hash, size_t max_block_count, size_t max_tx_count) const
|
bool core::find_blockchain_supplement(const uint64_t req_start_block, const std::list<crypto::hash>& qblock_ids, std::vector<std::pair<std::pair<cryptonote::blobdata, crypto::hash>, std::vector<std::pair<crypto::hash, cryptonote::blobdata> > > >& blocks, uint64_t& total_height, uint64_t& start_height, bool pruned, bool get_miner_tx_hash, size_t max_count) const
|
||||||
{
|
{
|
||||||
return m_blockchain_storage.find_blockchain_supplement(req_start_block, qblock_ids, blocks, total_height, start_height, pruned, get_miner_tx_hash, max_block_count, max_tx_count);
|
return m_blockchain_storage.find_blockchain_supplement(req_start_block, qblock_ids, blocks, total_height, start_height, pruned, get_miner_tx_hash, max_count);
|
||||||
}
|
}
|
||||||
//-----------------------------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------------------------
|
||||||
bool core::get_outs(const COMMAND_RPC_GET_OUTPUTS_BIN::request& req, COMMAND_RPC_GET_OUTPUTS_BIN::response& res) const
|
bool core::get_outs(const COMMAND_RPC_GET_OUTPUTS_BIN::request& req, COMMAND_RPC_GET_OUTPUTS_BIN::response& res) const
|
||||||
@@ -1550,11 +1550,6 @@ namespace cryptonote
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
//-----------------------------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------------------------
|
||||||
bool core::is_synchronized() const
|
|
||||||
{
|
|
||||||
return m_pprotocol != nullptr && m_pprotocol->is_synchronized();
|
|
||||||
}
|
|
||||||
//-----------------------------------------------------------------------------------------------
|
|
||||||
void core::on_synchronized()
|
void core::on_synchronized()
|
||||||
{
|
{
|
||||||
m_miner.on_synchronized();
|
m_miner.on_synchronized();
|
||||||
@@ -1665,14 +1660,9 @@ namespace cryptonote
|
|||||||
return m_mempool.get_transactions_count(include_sensitive_txes);
|
return m_mempool.get_transactions_count(include_sensitive_txes);
|
||||||
}
|
}
|
||||||
//-----------------------------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------------------------
|
||||||
bool core::have_block_unlocked(const crypto::hash& id, int *where) const
|
bool core::have_block(const crypto::hash& id) const
|
||||||
{
|
{
|
||||||
return m_blockchain_storage.have_block_unlocked(id, where);
|
return m_blockchain_storage.have_block(id);
|
||||||
}
|
|
||||||
//-----------------------------------------------------------------------------------------------
|
|
||||||
bool core::have_block(const crypto::hash& id, int *where) const
|
|
||||||
{
|
|
||||||
return m_blockchain_storage.have_block(id, where);
|
|
||||||
}
|
}
|
||||||
//-----------------------------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------------------------
|
||||||
bool core::parse_tx_from_blob(transaction& tx, crypto::hash& tx_hash, const blobdata& blob) const
|
bool core::parse_tx_from_blob(transaction& tx, crypto::hash& tx_hash, const blobdata& blob) const
|
||||||
@@ -1809,7 +1799,7 @@ namespace cryptonote
|
|||||||
m_starter_message_showed = true;
|
m_starter_message_showed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
relay_txpool_transactions(); // txpool handles periodic DB checking
|
m_txpool_auto_relayer.do_call(boost::bind(&core::relay_txpool_transactions, this));
|
||||||
m_check_updates_interval.do_call(boost::bind(&core::check_updates, this));
|
m_check_updates_interval.do_call(boost::bind(&core::check_updates, this));
|
||||||
m_check_disk_space_interval.do_call(boost::bind(&core::check_disk_space, this));
|
m_check_disk_space_interval.do_call(boost::bind(&core::check_disk_space, this));
|
||||||
m_block_rate_interval.do_call(boost::bind(&core::check_block_rate, this));
|
m_block_rate_interval.do_call(boost::bind(&core::check_block_rate, this));
|
||||||
|
|||||||
@@ -55,8 +55,6 @@
|
|||||||
PUSH_WARNINGS
|
PUSH_WARNINGS
|
||||||
DISABLE_VS_WARNINGS(4355)
|
DISABLE_VS_WARNINGS(4355)
|
||||||
|
|
||||||
enum { HAVE_BLOCK_MAIN_CHAIN, HAVE_BLOCK_ALT_CHAIN, HAVE_BLOCK_INVALID };
|
|
||||||
|
|
||||||
namespace cryptonote
|
namespace cryptonote
|
||||||
{
|
{
|
||||||
struct test_options {
|
struct test_options {
|
||||||
@@ -331,7 +329,7 @@ namespace cryptonote
|
|||||||
*
|
*
|
||||||
* @note see Blockchain::get_current_blockchain_height()
|
* @note see Blockchain::get_current_blockchain_height()
|
||||||
*/
|
*/
|
||||||
virtual uint64_t get_current_blockchain_height() const final;
|
uint64_t get_current_blockchain_height() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief get the hash and height of the most recent block
|
* @brief get the hash and height of the most recent block
|
||||||
@@ -545,8 +543,7 @@ namespace cryptonote
|
|||||||
*
|
*
|
||||||
* @note see Blockchain::have_block
|
* @note see Blockchain::have_block
|
||||||
*/
|
*/
|
||||||
bool have_block_unlocked(const crypto::hash& id, int *where = NULL) const;
|
bool have_block(const crypto::hash& id) const;
|
||||||
bool have_block(const crypto::hash& id, int *where = NULL) const;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @copydoc Blockchain::get_short_chain_history
|
* @copydoc Blockchain::get_short_chain_history
|
||||||
@@ -567,7 +564,7 @@ namespace cryptonote
|
|||||||
*
|
*
|
||||||
* @note see Blockchain::find_blockchain_supplement(const uint64_t, const std::list<crypto::hash>&, std::vector<std::pair<cryptonote::blobdata, std::vector<transaction> > >&, uint64_t&, uint64_t&, size_t) const
|
* @note see Blockchain::find_blockchain_supplement(const uint64_t, const std::list<crypto::hash>&, std::vector<std::pair<cryptonote::blobdata, std::vector<transaction> > >&, uint64_t&, uint64_t&, size_t) const
|
||||||
*/
|
*/
|
||||||
bool find_blockchain_supplement(const uint64_t req_start_block, const std::list<crypto::hash>& qblock_ids, std::vector<std::pair<std::pair<cryptonote::blobdata, crypto::hash>, std::vector<std::pair<crypto::hash, cryptonote::blobdata> > > >& blocks, uint64_t& total_height, uint64_t& start_height, bool pruned, bool get_miner_tx_hash, size_t max_block_count, size_t max_tx_count) const;
|
bool find_blockchain_supplement(const uint64_t req_start_block, const std::list<crypto::hash>& qblock_ids, std::vector<std::pair<std::pair<cryptonote::blobdata, crypto::hash>, std::vector<std::pair<crypto::hash, cryptonote::blobdata> > > >& blocks, uint64_t& total_height, uint64_t& start_height, bool pruned, bool get_miner_tx_hash, size_t max_count) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @copydoc Blockchain::get_tx_outputs_gindexs
|
* @copydoc Blockchain::get_tx_outputs_gindexs
|
||||||
@@ -640,13 +637,6 @@ namespace cryptonote
|
|||||||
*/
|
*/
|
||||||
std::string print_pool(bool short_format) const;
|
std::string print_pool(bool short_format) const;
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief gets the core synchronization status
|
|
||||||
*
|
|
||||||
* @return core synchronization status
|
|
||||||
*/
|
|
||||||
virtual bool is_synchronized() const final;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @copydoc miner::on_synchronized
|
* @copydoc miner::on_synchronized
|
||||||
*
|
*
|
||||||
@@ -673,7 +663,7 @@ namespace cryptonote
|
|||||||
*
|
*
|
||||||
* @param target_blockchain_height the target height
|
* @param target_blockchain_height the target height
|
||||||
*/
|
*/
|
||||||
uint64_t get_target_blockchain_height() const;
|
virtual uint64_t get_target_blockchain_height() const override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief returns the newest hardfork version known to the blockchain
|
* @brief returns the newest hardfork version known to the blockchain
|
||||||
@@ -1075,6 +1065,7 @@ namespace cryptonote
|
|||||||
|
|
||||||
epee::math_helper::once_a_time_seconds<60*60*12, false> m_store_blockchain_interval; //!< interval for manual storing of Blockchain, if enabled
|
epee::math_helper::once_a_time_seconds<60*60*12, false> m_store_blockchain_interval; //!< interval for manual storing of Blockchain, if enabled
|
||||||
epee::math_helper::once_a_time_seconds<60*60*2, true> m_fork_moaner; //!< interval for checking HardFork status
|
epee::math_helper::once_a_time_seconds<60*60*2, true> m_fork_moaner; //!< interval for checking HardFork status
|
||||||
|
epee::math_helper::once_a_time_seconds<60*2, false> m_txpool_auto_relayer; //!< interval for checking re-relaying txpool transactions
|
||||||
epee::math_helper::once_a_time_seconds<60*60*12, true> m_check_updates_interval; //!< interval for checking for new versions
|
epee::math_helper::once_a_time_seconds<60*60*12, true> m_check_updates_interval; //!< interval for checking for new versions
|
||||||
epee::math_helper::once_a_time_seconds<60*10, true> m_check_disk_space_interval; //!< interval for checking for disk space
|
epee::math_helper::once_a_time_seconds<60*10, true> m_check_disk_space_interval; //!< interval for checking for disk space
|
||||||
epee::math_helper::once_a_time_seconds<90, false> m_block_rate_interval; //!< interval for checking block rate
|
epee::math_helper::once_a_time_seconds<90, false> m_block_rate_interval; //!< interval for checking block rate
|
||||||
|
|||||||
@@ -39,8 +39,7 @@ namespace cryptonote
|
|||||||
virtual ~i_core_events() noexcept
|
virtual ~i_core_events() noexcept
|
||||||
{}
|
{}
|
||||||
|
|
||||||
virtual uint64_t get_current_blockchain_height() const = 0;
|
virtual uint64_t get_target_blockchain_height() const = 0;
|
||||||
virtual bool is_synchronized() const = 0;
|
|
||||||
virtual void on_transactions_relayed(epee::span<const cryptonote::blobdata> tx_blobs, relay_method tx_relay) = 0;
|
virtual void on_transactions_relayed(epee::span<const cryptonote::blobdata> tx_blobs, relay_method tx_relay) = 0;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -75,11 +75,11 @@ namespace cryptonote
|
|||||||
not ideal since a blackhole is more likely to reveal earlier nodes in
|
not ideal since a blackhole is more likely to reveal earlier nodes in
|
||||||
the chain.
|
the chain.
|
||||||
|
|
||||||
This value was calculated with k=5, ep=0.10, and hop = 175 ms. A
|
This value was calculated with k=10, ep=0.10, and hop = 175 ms. A
|
||||||
testrun from a recent Intel laptop took ~80ms to
|
testrun from a recent Intel laptop took ~80ms to
|
||||||
receive+parse+proces+send transaction. At least 50ms will be added to
|
receive+parse+proces+send transaction. At least 50ms will be added to
|
||||||
the latency if crossing an ocean. So 175ms is the fudge factor for
|
the latency if crossing an ocean. So 175ms is the fudge factor for
|
||||||
a single hop with 39s being the embargo timer. */
|
a single hop with 173s being the embargo timer. */
|
||||||
constexpr const std::chrono::seconds dandelionpp_embargo_average{CRYPTONOTE_DANDELIONPP_EMBARGO_AVERAGE};
|
constexpr const std::chrono::seconds dandelionpp_embargo_average{CRYPTONOTE_DANDELIONPP_EMBARGO_AVERAGE};
|
||||||
|
|
||||||
//TODO: constants such as these should at least be in the header,
|
//TODO: constants such as these should at least be in the header,
|
||||||
@@ -91,9 +91,6 @@ namespace cryptonote
|
|||||||
time_t const MAX_RELAY_TIME = (60 * 60 * 4); // at most that many seconds between resends
|
time_t const MAX_RELAY_TIME = (60 * 60 * 4); // at most that many seconds between resends
|
||||||
float const ACCEPT_THRESHOLD = 1.0f;
|
float const ACCEPT_THRESHOLD = 1.0f;
|
||||||
|
|
||||||
//! Max DB check interval for relayable txes
|
|
||||||
constexpr const std::chrono::minutes max_relayable_check{2};
|
|
||||||
|
|
||||||
constexpr const std::chrono::seconds forward_delay_average{CRYPTONOTE_FORWARD_DELAY_AVERAGE};
|
constexpr const std::chrono::seconds forward_delay_average{CRYPTONOTE_FORWARD_DELAY_AVERAGE};
|
||||||
|
|
||||||
// a kind of increasing backoff within min/max bounds
|
// a kind of increasing backoff within min/max bounds
|
||||||
@@ -118,21 +115,12 @@ namespace cryptonote
|
|||||||
else
|
else
|
||||||
return get_min_block_weight(version) - CRYPTONOTE_COINBASE_BLOB_RESERVED_SIZE;
|
return get_min_block_weight(version) - CRYPTONOTE_COINBASE_BLOB_RESERVED_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// external lock must be held for the comparison+set to work properly
|
|
||||||
void set_if_less(std::atomic<time_t>& next_check, const time_t candidate) noexcept
|
|
||||||
{
|
|
||||||
if (candidate < next_check.load(std::memory_order_relaxed))
|
|
||||||
next_check = candidate;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
//---------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------
|
||||||
//---------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------
|
||||||
tx_memory_pool::tx_memory_pool(Blockchain& bchs): m_blockchain(bchs), m_cookie(0), m_txpool_max_weight(DEFAULT_TXPOOL_MAX_WEIGHT), m_txpool_weight(0), m_mine_stem_txes(false), m_next_check(std::time(nullptr))
|
tx_memory_pool::tx_memory_pool(Blockchain& bchs): m_blockchain(bchs), m_cookie(0), m_txpool_max_weight(DEFAULT_TXPOOL_MAX_WEIGHT), m_txpool_weight(0), m_mine_stem_txes(false)
|
||||||
{
|
{
|
||||||
// class code expects unsigned values throughout
|
|
||||||
if (m_next_check < time_t(0))
|
|
||||||
throw std::runtime_error{"Unexpected time_t (system clock) value"};
|
|
||||||
}
|
}
|
||||||
//---------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------
|
||||||
bool tx_memory_pool::add_tx(transaction &tx, /*const crypto::hash& tx_prefix_hash,*/ const crypto::hash &id, const cryptonote::blobdata &blob, size_t tx_weight, tx_verification_context& tvc, relay_method tx_relay, bool relayed, uint8_t version)
|
bool tx_memory_pool::add_tx(transaction &tx, /*const crypto::hash& tx_prefix_hash,*/ const crypto::hash &id, const cryptonote::blobdata &blob, size_t tx_weight, tx_verification_context& tvc, relay_method tx_relay, bool relayed, uint8_t version)
|
||||||
@@ -326,10 +314,7 @@ namespace cryptonote
|
|||||||
using clock = std::chrono::system_clock;
|
using clock = std::chrono::system_clock;
|
||||||
auto last_relayed_time = std::numeric_limits<decltype(meta.last_relayed_time)>::max();
|
auto last_relayed_time = std::numeric_limits<decltype(meta.last_relayed_time)>::max();
|
||||||
if (tx_relay == relay_method::forward)
|
if (tx_relay == relay_method::forward)
|
||||||
{
|
|
||||||
last_relayed_time = clock::to_time_t(clock::now() + crypto::random_poisson_seconds{forward_delay_average}());
|
last_relayed_time = clock::to_time_t(clock::now() + crypto::random_poisson_seconds{forward_delay_average}());
|
||||||
set_if_less(m_next_check, time_t(last_relayed_time));
|
|
||||||
}
|
|
||||||
// else the `set_relayed` function will adjust the time accordingly later
|
// else the `set_relayed` function will adjust the time accordingly later
|
||||||
|
|
||||||
//update transactions container
|
//update transactions container
|
||||||
@@ -743,22 +728,16 @@ namespace cryptonote
|
|||||||
}
|
}
|
||||||
//---------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------
|
||||||
//TODO: investigate whether boolean return is appropriate
|
//TODO: investigate whether boolean return is appropriate
|
||||||
bool tx_memory_pool::get_relayable_transactions(std::vector<std::tuple<crypto::hash, cryptonote::blobdata, relay_method>> &txs)
|
bool tx_memory_pool::get_relayable_transactions(std::vector<std::tuple<crypto::hash, cryptonote::blobdata, relay_method>> &txs) const
|
||||||
{
|
{
|
||||||
using clock = std::chrono::system_clock;
|
|
||||||
|
|
||||||
const uint64_t now = time(NULL);
|
|
||||||
if (uint64_t{std::numeric_limits<time_t>::max()} < now || time_t(now) < m_next_check)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
uint64_t next_check = clock::to_time_t(clock::from_time_t(time_t(now)) + max_relayable_check);
|
|
||||||
std::vector<std::pair<crypto::hash, txpool_tx_meta_t>> change_timestamps;
|
std::vector<std::pair<crypto::hash, txpool_tx_meta_t>> change_timestamps;
|
||||||
|
const uint64_t now = time(NULL);
|
||||||
|
|
||||||
CRITICAL_REGION_LOCAL(m_transactions_lock);
|
CRITICAL_REGION_LOCAL(m_transactions_lock);
|
||||||
CRITICAL_REGION_LOCAL1(m_blockchain);
|
CRITICAL_REGION_LOCAL1(m_blockchain);
|
||||||
LockedTXN lock(m_blockchain.get_db());
|
LockedTXN lock(m_blockchain.get_db());
|
||||||
txs.reserve(m_blockchain.get_txpool_tx_count());
|
txs.reserve(m_blockchain.get_txpool_tx_count());
|
||||||
m_blockchain.for_all_txpool_txes([this, now, &txs, &change_timestamps, &next_check](const crypto::hash &txid, const txpool_tx_meta_t &meta, const cryptonote::blobdata_ref *){
|
m_blockchain.for_all_txpool_txes([this, now, &txs, &change_timestamps](const crypto::hash &txid, const txpool_tx_meta_t &meta, const cryptonote::blobdata_ref *){
|
||||||
// 0 fee transactions are never relayed
|
// 0 fee transactions are never relayed
|
||||||
if(!meta.pruned && meta.fee > 0 && !meta.do_not_relay)
|
if(!meta.pruned && meta.fee > 0 && !meta.do_not_relay)
|
||||||
{
|
{
|
||||||
@@ -768,10 +747,7 @@ namespace cryptonote
|
|||||||
case relay_method::stem:
|
case relay_method::stem:
|
||||||
case relay_method::forward:
|
case relay_method::forward:
|
||||||
if (meta.last_relayed_time > now)
|
if (meta.last_relayed_time > now)
|
||||||
{
|
|
||||||
next_check = std::min(next_check, meta.last_relayed_time);
|
|
||||||
return true; // continue to next tx
|
return true; // continue to next tx
|
||||||
}
|
|
||||||
change_timestamps.emplace_back(txid, meta);
|
change_timestamps.emplace_back(txid, meta);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -816,8 +792,6 @@ namespace cryptonote
|
|||||||
elem.second.last_relayed_time = now + get_relay_delay(now, elem.second.receive_time);
|
elem.second.last_relayed_time = now + get_relay_delay(now, elem.second.receive_time);
|
||||||
m_blockchain.update_txpool_tx(elem.first, elem.second);
|
m_blockchain.update_txpool_tx(elem.first, elem.second);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_next_check = time_t(next_check);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
//---------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------
|
||||||
@@ -825,7 +799,6 @@ namespace cryptonote
|
|||||||
{
|
{
|
||||||
crypto::random_poisson_seconds embargo_duration{dandelionpp_embargo_average};
|
crypto::random_poisson_seconds embargo_duration{dandelionpp_embargo_average};
|
||||||
const auto now = std::chrono::system_clock::now();
|
const auto now = std::chrono::system_clock::now();
|
||||||
uint64_t next_relay = uint64_t{std::numeric_limits<time_t>::max()};
|
|
||||||
|
|
||||||
CRITICAL_REGION_LOCAL(m_transactions_lock);
|
CRITICAL_REGION_LOCAL(m_transactions_lock);
|
||||||
CRITICAL_REGION_LOCAL1(m_blockchain);
|
CRITICAL_REGION_LOCAL1(m_blockchain);
|
||||||
@@ -842,10 +815,7 @@ namespace cryptonote
|
|||||||
meta.relayed = true;
|
meta.relayed = true;
|
||||||
|
|
||||||
if (meta.dandelionpp_stem)
|
if (meta.dandelionpp_stem)
|
||||||
{
|
|
||||||
meta.last_relayed_time = std::chrono::system_clock::to_time_t(now + embargo_duration());
|
meta.last_relayed_time = std::chrono::system_clock::to_time_t(now + embargo_duration());
|
||||||
next_relay = std::min(next_relay, meta.last_relayed_time);
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
meta.last_relayed_time = std::chrono::system_clock::to_time_t(now);
|
meta.last_relayed_time = std::chrono::system_clock::to_time_t(now);
|
||||||
|
|
||||||
@@ -859,7 +829,6 @@ namespace cryptonote
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
lock.commit();
|
lock.commit();
|
||||||
set_if_less(m_next_check, time_t(next_relay));
|
|
||||||
}
|
}
|
||||||
//---------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------
|
||||||
size_t tx_memory_pool::get_transactions_count(bool include_sensitive) const
|
size_t tx_memory_pool::get_transactions_count(bool include_sensitive) const
|
||||||
|
|||||||
@@ -31,7 +31,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "include_base_utils.h"
|
#include "include_base_utils.h"
|
||||||
|
|
||||||
#include <atomic>
|
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
@@ -330,14 +329,11 @@ namespace cryptonote
|
|||||||
* isn't old enough that relaying it is considered harmful
|
* isn't old enough that relaying it is considered harmful
|
||||||
* Note a transaction can be "relayable" even if do_not_relay is true
|
* Note a transaction can be "relayable" even if do_not_relay is true
|
||||||
*
|
*
|
||||||
* This function will skip all DB checks if an insufficient amount of
|
|
||||||
* time since the last call.
|
|
||||||
*
|
|
||||||
* @param txs return-by-reference the transactions and their hashes
|
* @param txs return-by-reference the transactions and their hashes
|
||||||
*
|
*
|
||||||
* @return True if DB was checked, false if DB checks skipped.
|
* @return true
|
||||||
*/
|
*/
|
||||||
bool get_relayable_transactions(std::vector<std::tuple<crypto::hash, cryptonote::blobdata, relay_method>>& txs);
|
bool get_relayable_transactions(std::vector<std::tuple<crypto::hash, cryptonote::blobdata, relay_method>>& txs) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief tell the pool that certain transactions were just relayed
|
* @brief tell the pool that certain transactions were just relayed
|
||||||
@@ -613,9 +609,6 @@ private:
|
|||||||
mutable std::unordered_map<crypto::hash, std::tuple<bool, tx_verification_context, uint64_t, crypto::hash>> m_input_cache;
|
mutable std::unordered_map<crypto::hash, std::tuple<bool, tx_verification_context, uint64_t, crypto::hash>> m_input_cache;
|
||||||
|
|
||||||
std::unordered_map<crypto::hash, transaction> m_parsed_tx_cache;
|
std::unordered_map<crypto::hash, transaction> m_parsed_tx_cache;
|
||||||
|
|
||||||
//! Next timestamp that a DB check for relayable txes is allowed
|
|
||||||
std::atomic<time_t> m_next_check;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -52,12 +52,12 @@ namespace std {
|
|||||||
namespace cryptonote
|
namespace cryptonote
|
||||||
{
|
{
|
||||||
|
|
||||||
void block_queue::add_blocks(uint64_t height, std::vector<cryptonote::block_complete_entry> bcel, const boost::uuids::uuid &connection_id, const epee::net_utils::network_address &addr, float rate, size_t size)
|
void block_queue::add_blocks(uint64_t height, std::vector<cryptonote::block_complete_entry> bcel, const boost::uuids::uuid &connection_id, float rate, size_t size)
|
||||||
{
|
{
|
||||||
boost::unique_lock<boost::recursive_mutex> lock(mutex);
|
boost::unique_lock<boost::recursive_mutex> lock(mutex);
|
||||||
std::vector<crypto::hash> hashes;
|
std::vector<crypto::hash> hashes;
|
||||||
bool has_hashes = remove_span(height, &hashes);
|
bool has_hashes = remove_span(height, &hashes);
|
||||||
blocks.insert(span(height, std::move(bcel), connection_id, addr, rate, size));
|
blocks.insert(span(height, std::move(bcel), connection_id, rate, size));
|
||||||
if (has_hashes)
|
if (has_hashes)
|
||||||
{
|
{
|
||||||
for (const crypto::hash &h: hashes)
|
for (const crypto::hash &h: hashes)
|
||||||
@@ -69,11 +69,11 @@ void block_queue::add_blocks(uint64_t height, std::vector<cryptonote::block_comp
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void block_queue::add_blocks(uint64_t height, uint64_t nblocks, const boost::uuids::uuid &connection_id, const epee::net_utils::network_address &addr, boost::posix_time::ptime time)
|
void block_queue::add_blocks(uint64_t height, uint64_t nblocks, const boost::uuids::uuid &connection_id, boost::posix_time::ptime time)
|
||||||
{
|
{
|
||||||
CHECK_AND_ASSERT_THROW_MES(nblocks > 0, "Empty span");
|
CHECK_AND_ASSERT_THROW_MES(nblocks > 0, "Empty span");
|
||||||
boost::unique_lock<boost::recursive_mutex> lock(mutex);
|
boost::unique_lock<boost::recursive_mutex> lock(mutex);
|
||||||
blocks.insert(span(height, nblocks, connection_id, addr, time));
|
blocks.insert(span(height, nblocks, connection_id, time));
|
||||||
}
|
}
|
||||||
|
|
||||||
void block_queue::flush_spans(const boost::uuids::uuid &connection_id, bool all)
|
void block_queue::flush_spans(const boost::uuids::uuid &connection_id, bool all)
|
||||||
@@ -228,7 +228,7 @@ bool block_queue::have(const crypto::hash &hash) const
|
|||||||
return have_blocks.find(hash) != have_blocks.end();
|
return have_blocks.find(hash) != have_blocks.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<uint64_t, uint64_t> block_queue::reserve_span(uint64_t first_block_height, uint64_t last_block_height, uint64_t max_blocks, const boost::uuids::uuid &connection_id, const epee::net_utils::network_address &addr, bool sync_pruned_blocks, uint32_t local_pruning_seed, uint32_t pruning_seed, uint64_t blockchain_height, const std::vector<std::pair<crypto::hash, uint64_t>> &block_hashes, boost::posix_time::ptime time)
|
std::pair<uint64_t, uint64_t> block_queue::reserve_span(uint64_t first_block_height, uint64_t last_block_height, uint64_t max_blocks, const boost::uuids::uuid &connection_id, bool sync_pruned_blocks, uint32_t local_pruning_seed, uint32_t pruning_seed, uint64_t blockchain_height, const std::vector<std::pair<crypto::hash, uint64_t>> &block_hashes, boost::posix_time::ptime time)
|
||||||
{
|
{
|
||||||
boost::unique_lock<boost::recursive_mutex> lock(mutex);
|
boost::unique_lock<boost::recursive_mutex> lock(mutex);
|
||||||
|
|
||||||
@@ -305,7 +305,7 @@ std::pair<uint64_t, uint64_t> block_queue::reserve_span(uint64_t first_block_hei
|
|||||||
return std::make_pair(0, 0);
|
return std::make_pair(0, 0);
|
||||||
}
|
}
|
||||||
MDEBUG("Reserving span " << span_start_height << " - " << (span_start_height + span_length - 1) << " for " << connection_id);
|
MDEBUG("Reserving span " << span_start_height << " - " << (span_start_height + span_length - 1) << " for " << connection_id);
|
||||||
add_blocks(span_start_height, span_length, connection_id, addr, time);
|
add_blocks(span_start_height, span_length, connection_id, time);
|
||||||
set_span_hashes(span_start_height, connection_id, hashes);
|
set_span_hashes(span_start_height, connection_id, hashes);
|
||||||
return std::make_pair(span_start_height, span_length);
|
return std::make_pair(span_start_height, span_length);
|
||||||
}
|
}
|
||||||
@@ -354,7 +354,7 @@ void block_queue::set_span_hashes(uint64_t start_height, const boost::uuids::uui
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool block_queue::get_next_span(uint64_t &height, std::vector<cryptonote::block_complete_entry> &bcel, boost::uuids::uuid &connection_id, epee::net_utils::network_address &addr, bool filled) const
|
bool block_queue::get_next_span(uint64_t &height, std::vector<cryptonote::block_complete_entry> &bcel, boost::uuids::uuid &connection_id, bool filled) const
|
||||||
{
|
{
|
||||||
boost::unique_lock<boost::recursive_mutex> lock(mutex);
|
boost::unique_lock<boost::recursive_mutex> lock(mutex);
|
||||||
if (blocks.empty())
|
if (blocks.empty())
|
||||||
@@ -367,7 +367,6 @@ bool block_queue::get_next_span(uint64_t &height, std::vector<cryptonote::block_
|
|||||||
height = i->start_block_height;
|
height = i->start_block_height;
|
||||||
bcel = i->blocks;
|
bcel = i->blocks;
|
||||||
connection_id = i->connection_id;
|
connection_id = i->connection_id;
|
||||||
addr = i->origin;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,7 +36,6 @@
|
|||||||
#include <unordered_set>
|
#include <unordered_set>
|
||||||
#include <boost/thread/recursive_mutex.hpp>
|
#include <boost/thread/recursive_mutex.hpp>
|
||||||
#include <boost/uuid/uuid.hpp>
|
#include <boost/uuid/uuid.hpp>
|
||||||
#include "net/net_utils_base.h"
|
|
||||||
|
|
||||||
#undef MONERO_DEFAULT_LOG_CATEGORY
|
#undef MONERO_DEFAULT_LOG_CATEGORY
|
||||||
#define MONERO_DEFAULT_LOG_CATEGORY "cn.block_queue"
|
#define MONERO_DEFAULT_LOG_CATEGORY "cn.block_queue"
|
||||||
@@ -58,20 +57,19 @@ namespace cryptonote
|
|||||||
float rate;
|
float rate;
|
||||||
size_t size;
|
size_t size;
|
||||||
boost::posix_time::ptime time;
|
boost::posix_time::ptime time;
|
||||||
epee::net_utils::network_address origin{};
|
|
||||||
|
|
||||||
span(uint64_t start_block_height, std::vector<cryptonote::block_complete_entry> blocks, const boost::uuids::uuid &connection_id, const epee::net_utils::network_address &addr, float rate, size_t size):
|
span(uint64_t start_block_height, std::vector<cryptonote::block_complete_entry> blocks, const boost::uuids::uuid &connection_id, float rate, size_t size):
|
||||||
start_block_height(start_block_height), blocks(std::move(blocks)), connection_id(connection_id), nblocks(this->blocks.size()), rate(rate), size(size), time(boost::date_time::min_date_time), origin(addr) {}
|
start_block_height(start_block_height), blocks(std::move(blocks)), connection_id(connection_id), nblocks(this->blocks.size()), rate(rate), size(size), time() {}
|
||||||
span(uint64_t start_block_height, uint64_t nblocks, const boost::uuids::uuid &connection_id, const epee::net_utils::network_address &addr, boost::posix_time::ptime time):
|
span(uint64_t start_block_height, uint64_t nblocks, const boost::uuids::uuid &connection_id, boost::posix_time::ptime time):
|
||||||
start_block_height(start_block_height), connection_id(connection_id), nblocks(nblocks), rate(0.0f), size(0), time(time), origin(addr) {}
|
start_block_height(start_block_height), connection_id(connection_id), nblocks(nblocks), rate(0.0f), size(0), time(time) {}
|
||||||
|
|
||||||
bool operator<(const span &s) const { return start_block_height < s.start_block_height; }
|
bool operator<(const span &s) const { return start_block_height < s.start_block_height; }
|
||||||
};
|
};
|
||||||
typedef std::set<span> block_map;
|
typedef std::set<span> block_map;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void add_blocks(uint64_t height, std::vector<cryptonote::block_complete_entry> bcel, const boost::uuids::uuid &connection_id, const epee::net_utils::network_address &addr, float rate, size_t size);
|
void add_blocks(uint64_t height, std::vector<cryptonote::block_complete_entry> bcel, const boost::uuids::uuid &connection_id, float rate, size_t size);
|
||||||
void add_blocks(uint64_t height, uint64_t nblocks, const boost::uuids::uuid &connection_id, const epee::net_utils::network_address &addr, boost::posix_time::ptime time = boost::date_time::min_date_time);
|
void add_blocks(uint64_t height, uint64_t nblocks, const boost::uuids::uuid &connection_id, boost::posix_time::ptime time = boost::date_time::min_date_time);
|
||||||
void flush_spans(const boost::uuids::uuid &connection_id, bool all = false);
|
void flush_spans(const boost::uuids::uuid &connection_id, bool all = false);
|
||||||
void flush_stale_spans(const std::set<boost::uuids::uuid> &live_connections);
|
void flush_stale_spans(const std::set<boost::uuids::uuid> &live_connections);
|
||||||
bool remove_span(uint64_t start_block_height, std::vector<crypto::hash> *hashes = NULL);
|
bool remove_span(uint64_t start_block_height, std::vector<crypto::hash> *hashes = NULL);
|
||||||
@@ -80,12 +78,12 @@ namespace cryptonote
|
|||||||
void print() const;
|
void print() const;
|
||||||
std::string get_overview(uint64_t blockchain_height) const;
|
std::string get_overview(uint64_t blockchain_height) const;
|
||||||
bool has_unpruned_height(uint64_t block_height, uint64_t blockchain_height, uint32_t pruning_seed) const;
|
bool has_unpruned_height(uint64_t block_height, uint64_t blockchain_height, uint32_t pruning_seed) const;
|
||||||
std::pair<uint64_t, uint64_t> reserve_span(uint64_t first_block_height, uint64_t last_block_height, uint64_t max_blocks, const boost::uuids::uuid &connection_id, const epee::net_utils::network_address &addr, bool sync_pruned_blocks, uint32_t local_pruning_seed, uint32_t pruning_seed, uint64_t blockchain_height, const std::vector<std::pair<crypto::hash, uint64_t>> &block_hashes, boost::posix_time::ptime time = boost::posix_time::microsec_clock::universal_time());
|
std::pair<uint64_t, uint64_t> reserve_span(uint64_t first_block_height, uint64_t last_block_height, uint64_t max_blocks, const boost::uuids::uuid &connection_id, bool sync_pruned_blocks, uint32_t local_pruning_seed, uint32_t pruning_seed, uint64_t blockchain_height, const std::vector<std::pair<crypto::hash, uint64_t>> &block_hashes, boost::posix_time::ptime time = boost::posix_time::microsec_clock::universal_time());
|
||||||
uint64_t get_next_needed_height(uint64_t blockchain_height) const;
|
uint64_t get_next_needed_height(uint64_t blockchain_height) const;
|
||||||
std::pair<uint64_t, uint64_t> get_next_span_if_scheduled(std::vector<crypto::hash> &hashes, boost::uuids::uuid &connection_id, boost::posix_time::ptime &time) const;
|
std::pair<uint64_t, uint64_t> get_next_span_if_scheduled(std::vector<crypto::hash> &hashes, boost::uuids::uuid &connection_id, boost::posix_time::ptime &time) const;
|
||||||
void reset_next_span_time(boost::posix_time::ptime t = boost::posix_time::microsec_clock::universal_time());
|
void reset_next_span_time(boost::posix_time::ptime t = boost::posix_time::microsec_clock::universal_time());
|
||||||
void set_span_hashes(uint64_t start_height, const boost::uuids::uuid &connection_id, std::vector<crypto::hash> hashes);
|
void set_span_hashes(uint64_t start_height, const boost::uuids::uuid &connection_id, std::vector<crypto::hash> hashes);
|
||||||
bool get_next_span(uint64_t &height, std::vector<cryptonote::block_complete_entry> &bcel, boost::uuids::uuid &connection_id, epee::net_utils::network_address &addr, bool filled = true) const;
|
bool get_next_span(uint64_t &height, std::vector<cryptonote::block_complete_entry> &bcel, boost::uuids::uuid &connection_id, bool filled = true) const;
|
||||||
bool has_next_span(const boost::uuids::uuid &connection_id, bool &filled, boost::posix_time::ptime &time) const;
|
bool has_next_span(const boost::uuids::uuid &connection_id, bool &filled, boost::posix_time::ptime &time) const;
|
||||||
bool has_next_span(uint64_t height, bool &filled, boost::posix_time::ptime &time, boost::uuids::uuid &connection_id) const;
|
bool has_next_span(uint64_t height, bool &filled, boost::posix_time::ptime &time, boost::uuids::uuid &connection_id) const;
|
||||||
size_t get_data_size() const;
|
size_t get_data_size() const;
|
||||||
|
|||||||
@@ -298,7 +298,6 @@ namespace cryptonote
|
|||||||
uint64_t cumulative_difficulty_top64;
|
uint64_t cumulative_difficulty_top64;
|
||||||
std::vector<crypto::hash> m_block_ids;
|
std::vector<crypto::hash> m_block_ids;
|
||||||
std::vector<uint64_t> m_block_weights;
|
std::vector<uint64_t> m_block_weights;
|
||||||
cryptonote::blobdata first_block;
|
|
||||||
|
|
||||||
BEGIN_KV_SERIALIZE_MAP()
|
BEGIN_KV_SERIALIZE_MAP()
|
||||||
KV_SERIALIZE(start_height)
|
KV_SERIALIZE(start_height)
|
||||||
@@ -310,7 +309,6 @@ namespace cryptonote
|
|||||||
KV_SERIALIZE_OPT(cumulative_difficulty_top64, (uint64_t)0)
|
KV_SERIALIZE_OPT(cumulative_difficulty_top64, (uint64_t)0)
|
||||||
KV_SERIALIZE_CONTAINER_POD_AS_BLOB(m_block_ids)
|
KV_SERIALIZE_CONTAINER_POD_AS_BLOB(m_block_ids)
|
||||||
KV_SERIALIZE_CONTAINER_POD_AS_BLOB(m_block_weights)
|
KV_SERIALIZE_CONTAINER_POD_AS_BLOB(m_block_weights)
|
||||||
KV_SERIALIZE(first_block)
|
|
||||||
END_KV_SERIALIZE_MAP()
|
END_KV_SERIALIZE_MAP()
|
||||||
};
|
};
|
||||||
typedef epee::misc_utils::struct_init<request_t> request;
|
typedef epee::misc_utils::struct_init<request_t> request;
|
||||||
|
|||||||
@@ -37,7 +37,6 @@
|
|||||||
#include <boost/program_options/variables_map.hpp>
|
#include <boost/program_options/variables_map.hpp>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "byte_slice.h"
|
|
||||||
#include "math_helper.h"
|
#include "math_helper.h"
|
||||||
#include "storages/levin_abstract_invoke2.h"
|
#include "storages/levin_abstract_invoke2.h"
|
||||||
#include "warnings.h"
|
#include "warnings.h"
|
||||||
@@ -101,11 +100,11 @@ namespace cryptonote
|
|||||||
void set_p2p_endpoint(nodetool::i_p2p_endpoint<connection_context>* p2p);
|
void set_p2p_endpoint(nodetool::i_p2p_endpoint<connection_context>* p2p);
|
||||||
//bool process_handshake_data(const blobdata& data, cryptonote_connection_context& context);
|
//bool process_handshake_data(const blobdata& data, cryptonote_connection_context& context);
|
||||||
bool process_payload_sync_data(const CORE_SYNC_DATA& hshd, cryptonote_connection_context& context, bool is_inital);
|
bool process_payload_sync_data(const CORE_SYNC_DATA& hshd, cryptonote_connection_context& context, bool is_inital);
|
||||||
bool get_payload_sync_data(epee::byte_slice& data);
|
bool get_payload_sync_data(blobdata& data);
|
||||||
bool get_payload_sync_data(CORE_SYNC_DATA& hshd);
|
bool get_payload_sync_data(CORE_SYNC_DATA& hshd);
|
||||||
bool on_callback(cryptonote_connection_context& context);
|
bool on_callback(cryptonote_connection_context& context);
|
||||||
t_core& get_core(){return m_core;}
|
t_core& get_core(){return m_core;}
|
||||||
virtual bool is_synchronized() const final { return !no_sync() && m_synchronized; }
|
bool is_synchronized(){return m_synchronized;}
|
||||||
void log_connections();
|
void log_connections();
|
||||||
std::list<connection_info> get_connections();
|
std::list<connection_info> get_connections();
|
||||||
const block_queue &get_block_queue() const { return m_block_queue; }
|
const block_queue &get_block_queue() const { return m_block_queue; }
|
||||||
@@ -117,8 +116,6 @@ namespace cryptonote
|
|||||||
std::string get_peers_overview() const;
|
std::string get_peers_overview() const;
|
||||||
std::pair<uint32_t, uint32_t> get_next_needed_pruning_stripe() const;
|
std::pair<uint32_t, uint32_t> get_next_needed_pruning_stripe() const;
|
||||||
bool needs_new_sync_connections() const;
|
bool needs_new_sync_connections() const;
|
||||||
bool is_busy_syncing();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
//----------------- commands handlers ----------------------------------------------
|
//----------------- commands handlers ----------------------------------------------
|
||||||
int handle_notify_new_block(int command, NOTIFY_NEW_BLOCK::request& arg, cryptonote_connection_context& context);
|
int handle_notify_new_block(int command, NOTIFY_NEW_BLOCK::request& arg, cryptonote_connection_context& context);
|
||||||
@@ -144,15 +141,13 @@ namespace cryptonote
|
|||||||
bool should_ask_for_pruned_data(cryptonote_connection_context& context, uint64_t first_block_height, uint64_t nblocks, bool check_block_weights) const;
|
bool should_ask_for_pruned_data(cryptonote_connection_context& context, uint64_t first_block_height, uint64_t nblocks, bool check_block_weights) const;
|
||||||
void drop_connection(cryptonote_connection_context &context, bool add_fail, bool flush_all_spans);
|
void drop_connection(cryptonote_connection_context &context, bool add_fail, bool flush_all_spans);
|
||||||
void drop_connection_with_score(cryptonote_connection_context &context, unsigned int score, bool flush_all_spans);
|
void drop_connection_with_score(cryptonote_connection_context &context, unsigned int score, bool flush_all_spans);
|
||||||
void drop_connections(const epee::net_utils::network_address address);
|
|
||||||
bool kick_idle_peers();
|
bool kick_idle_peers();
|
||||||
bool check_standby_peers();
|
bool check_standby_peers();
|
||||||
bool update_sync_search();
|
bool update_sync_search();
|
||||||
int try_add_next_blocks(cryptonote_connection_context &context);
|
int try_add_next_blocks(cryptonote_connection_context &context);
|
||||||
void notify_new_stripe(cryptonote_connection_context &context, uint32_t stripe);
|
void notify_new_stripe(cryptonote_connection_context &context, uint32_t stripe);
|
||||||
size_t skip_unneeded_hashes(cryptonote_connection_context& context, bool check_block_queue) const;
|
void skip_unneeded_hashes(cryptonote_connection_context& context, bool check_block_queue) const;
|
||||||
bool request_txpool_complement(cryptonote_connection_context &context);
|
bool request_txpool_complement(cryptonote_connection_context &context);
|
||||||
void hit_score(cryptonote_connection_context &context, int32_t score);
|
|
||||||
|
|
||||||
t_core& m_core;
|
t_core& m_core;
|
||||||
|
|
||||||
@@ -165,10 +160,9 @@ namespace cryptonote
|
|||||||
std::atomic<bool> m_ask_for_txpool_complement;
|
std::atomic<bool> m_ask_for_txpool_complement;
|
||||||
boost::mutex m_sync_lock;
|
boost::mutex m_sync_lock;
|
||||||
block_queue m_block_queue;
|
block_queue m_block_queue;
|
||||||
epee::math_helper::once_a_time_seconds<8> m_idle_peer_kicker;
|
epee::math_helper::once_a_time_seconds<30> m_idle_peer_kicker;
|
||||||
epee::math_helper::once_a_time_milliseconds<100> m_standby_checker;
|
epee::math_helper::once_a_time_milliseconds<100> m_standby_checker;
|
||||||
epee::math_helper::once_a_time_seconds<101> m_sync_search_checker;
|
epee::math_helper::once_a_time_seconds<101> m_sync_search_checker;
|
||||||
epee::math_helper::once_a_time_seconds<43> m_bad_peer_checker;
|
|
||||||
std::atomic<unsigned int> m_max_out_peers;
|
std::atomic<unsigned int> m_max_out_peers;
|
||||||
tools::PerformanceTimer m_sync_timer, m_add_timer;
|
tools::PerformanceTimer m_sync_timer, m_add_timer;
|
||||||
uint64_t m_last_add_end_time;
|
uint64_t m_last_add_end_time;
|
||||||
@@ -189,16 +183,14 @@ namespace cryptonote
|
|||||||
double get_avg_block_size();
|
double get_avg_block_size();
|
||||||
boost::circular_buffer<size_t> m_avg_buffer = boost::circular_buffer<size_t>(10);
|
boost::circular_buffer<size_t> m_avg_buffer = boost::circular_buffer<size_t>(10);
|
||||||
|
|
||||||
boost::mutex m_bad_peer_check_lock;
|
|
||||||
|
|
||||||
template<class t_parameter>
|
template<class t_parameter>
|
||||||
bool post_notify(typename t_parameter::request& arg, cryptonote_connection_context& context)
|
bool post_notify(typename t_parameter::request& arg, cryptonote_connection_context& context)
|
||||||
{
|
{
|
||||||
LOG_PRINT_L2("[" << epee::net_utils::print_connection_context_short(context) << "] post " << typeid(t_parameter).name() << " -->");
|
LOG_PRINT_L2("[" << epee::net_utils::print_connection_context_short(context) << "] post " << typeid(t_parameter).name() << " -->");
|
||||||
epee::byte_slice blob;
|
std::string blob;
|
||||||
epee::serialization::store_t_to_binary(arg, blob, 256 * 1024); // optimize for block responses
|
epee::serialization::store_t_to_binary(arg, blob);
|
||||||
//handler_response_blocks_now(blob.size()); // XXX
|
//handler_response_blocks_now(blob.size()); // XXX
|
||||||
return m_p2p->invoke_notify_to_peer(t_parameter::ID, epee::to_span(blob), context);
|
return m_p2p->invoke_notify_to_peer(t_parameter::ID, epee::strspan<uint8_t>(blob), context);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -68,12 +68,10 @@
|
|||||||
#define BLOCK_QUEUE_FORCE_DOWNLOAD_NEAR_BLOCKS 1000
|
#define BLOCK_QUEUE_FORCE_DOWNLOAD_NEAR_BLOCKS 1000
|
||||||
#define REQUEST_NEXT_SCHEDULED_SPAN_THRESHOLD_STANDBY (5 * 1000000) // microseconds
|
#define REQUEST_NEXT_SCHEDULED_SPAN_THRESHOLD_STANDBY (5 * 1000000) // microseconds
|
||||||
#define REQUEST_NEXT_SCHEDULED_SPAN_THRESHOLD (30 * 1000000) // microseconds
|
#define REQUEST_NEXT_SCHEDULED_SPAN_THRESHOLD (30 * 1000000) // microseconds
|
||||||
#define IDLE_PEER_KICK_TIME (240 * 1000000) // microseconds
|
#define IDLE_PEER_KICK_TIME (600 * 1000000) // microseconds
|
||||||
#define NON_RESPONSIVE_PEER_KICK_TIME (20 * 1000000) // microseconds
|
|
||||||
#define PASSIVE_PEER_KICK_TIME (60 * 1000000) // microseconds
|
#define PASSIVE_PEER_KICK_TIME (60 * 1000000) // microseconds
|
||||||
#define DROP_ON_SYNC_WEDGE_THRESHOLD (30 * 1000000000ull) // nanoseconds
|
#define DROP_ON_SYNC_WEDGE_THRESHOLD (30 * 1000000000ull) // nanoseconds
|
||||||
#define LAST_ACTIVITY_STALL_THRESHOLD (2.0f) // seconds
|
#define LAST_ACTIVITY_STALL_THRESHOLD (2.0f) // seconds
|
||||||
#define DROP_PEERS_ON_SCORE -2
|
|
||||||
|
|
||||||
namespace cryptonote
|
namespace cryptonote
|
||||||
{
|
{
|
||||||
@@ -137,16 +135,13 @@ namespace cryptonote
|
|||||||
CHECK_AND_ASSERT_MES_CC( context.m_callback_request_count > 0, false, "false callback fired, but context.m_callback_request_count=" << context.m_callback_request_count);
|
CHECK_AND_ASSERT_MES_CC( context.m_callback_request_count > 0, false, "false callback fired, but context.m_callback_request_count=" << context.m_callback_request_count);
|
||||||
--context.m_callback_request_count;
|
--context.m_callback_request_count;
|
||||||
|
|
||||||
if(context.m_state == cryptonote_connection_context::state_synchronizing && context.m_last_request_time == boost::posix_time::not_a_date_time)
|
if(context.m_state == cryptonote_connection_context::state_synchronizing)
|
||||||
{
|
{
|
||||||
NOTIFY_REQUEST_CHAIN::request r = {};
|
NOTIFY_REQUEST_CHAIN::request r = {};
|
||||||
context.m_needed_objects.clear();
|
context.m_needed_objects.clear();
|
||||||
context.m_expect_height = m_core.get_current_blockchain_height();
|
|
||||||
m_core.get_short_chain_history(r.block_ids);
|
m_core.get_short_chain_history(r.block_ids);
|
||||||
handler_request_blocks_history( r.block_ids ); // change the limit(?), sleep(?)
|
handler_request_blocks_history( r.block_ids ); // change the limit(?), sleep(?)
|
||||||
r.prune = m_sync_pruned_blocks;
|
r.prune = m_sync_pruned_blocks;
|
||||||
context.m_last_request_time = boost::posix_time::microsec_clock::universal_time();
|
|
||||||
context.m_expect_response = NOTIFY_RESPONSE_CHAIN_ENTRY::ID;
|
|
||||||
MLOG_P2P_MESSAGE("-->>NOTIFY_REQUEST_CHAIN: m_block_ids.size()=" << r.block_ids.size() );
|
MLOG_P2P_MESSAGE("-->>NOTIFY_REQUEST_CHAIN: m_block_ids.size()=" << r.block_ids.size() );
|
||||||
post_notify<NOTIFY_REQUEST_CHAIN>(r, context);
|
post_notify<NOTIFY_REQUEST_CHAIN>(r, context);
|
||||||
MLOG_PEER_STATE("requesting chain");
|
MLOG_PEER_STATE("requesting chain");
|
||||||
@@ -331,11 +326,6 @@ namespace cryptonote
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hshd.current_height < context.m_remote_blockchain_height)
|
|
||||||
{
|
|
||||||
MINFO(context << "Claims " << hshd.current_height << ", claimed " << context.m_remote_blockchain_height << " before");
|
|
||||||
hit_score(context, 1);
|
|
||||||
}
|
|
||||||
context.m_remote_blockchain_height = hshd.current_height;
|
context.m_remote_blockchain_height = hshd.current_height;
|
||||||
context.m_pruning_seed = hshd.pruning_seed;
|
context.m_pruning_seed = hshd.pruning_seed;
|
||||||
#ifdef CRYPTONOTE_PRUNING_DEBUG_SPOOF_SEED
|
#ifdef CRYPTONOTE_PRUNING_DEBUG_SPOOF_SEED
|
||||||
@@ -409,7 +399,6 @@ namespace cryptonote
|
|||||||
++context.m_callback_request_count;
|
++context.m_callback_request_count;
|
||||||
m_p2p->request_callback(context);
|
m_p2p->request_callback(context);
|
||||||
MLOG_PEER_STATE("requesting callback");
|
MLOG_PEER_STATE("requesting callback");
|
||||||
context.m_num_requested = 0;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------------------------------------------
|
||||||
@@ -427,7 +416,7 @@ namespace cryptonote
|
|||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------------------------------------------
|
||||||
template<class t_core>
|
template<class t_core>
|
||||||
bool t_cryptonote_protocol_handler<t_core>::get_payload_sync_data(epee::byte_slice& data)
|
bool t_cryptonote_protocol_handler<t_core>::get_payload_sync_data(blobdata& data)
|
||||||
{
|
{
|
||||||
CORE_SYNC_DATA hsd = {};
|
CORE_SYNC_DATA hsd = {};
|
||||||
get_payload_sync_data(hsd);
|
get_payload_sync_data(hsd);
|
||||||
@@ -438,10 +427,10 @@ namespace cryptonote
|
|||||||
template<class t_core>
|
template<class t_core>
|
||||||
int t_cryptonote_protocol_handler<t_core>::handle_notify_new_block(int command, NOTIFY_NEW_BLOCK::request& arg, cryptonote_connection_context& context)
|
int t_cryptonote_protocol_handler<t_core>::handle_notify_new_block(int command, NOTIFY_NEW_BLOCK::request& arg, cryptonote_connection_context& context)
|
||||||
{
|
{
|
||||||
MLOGIF_P2P_MESSAGE(crypto::hash hash; cryptonote::block b; bool ret = cryptonote::parse_and_validate_block_from_blob(arg.b.block, b, &hash);, ret, context << "Received NOTIFY_NEW_BLOCK " << hash << " (height " << arg.current_blockchain_height << ", " << arg.b.txs.size() << " txes)");
|
MLOGIF_P2P_MESSAGE(crypto::hash hash; cryptonote::block b; bool ret = cryptonote::parse_and_validate_block_from_blob(arg.b.block, b, &hash);, ret, "Received NOTIFY_NEW_BLOCK " << hash << " (height " << arg.current_blockchain_height << ", " << arg.b.txs.size() << " txes)");
|
||||||
if(context.m_state != cryptonote_connection_context::state_normal)
|
if(context.m_state != cryptonote_connection_context::state_normal)
|
||||||
return 1;
|
return 1;
|
||||||
if(!is_synchronized()) // can happen if a peer connection goes to normal but another thread still hasn't finished adding queued blocks
|
if(!is_synchronized() || m_no_sync) // can happen if a peer connection goes to normal but another thread still hasn't finished adding queued blocks
|
||||||
{
|
{
|
||||||
LOG_DEBUG_CC(context, "Received new block while syncing, ignored");
|
LOG_DEBUG_CC(context, "Received new block while syncing, ignored");
|
||||||
return 1;
|
return 1;
|
||||||
@@ -495,12 +484,9 @@ namespace cryptonote
|
|||||||
context.m_needed_objects.clear();
|
context.m_needed_objects.clear();
|
||||||
context.m_state = cryptonote_connection_context::state_synchronizing;
|
context.m_state = cryptonote_connection_context::state_synchronizing;
|
||||||
NOTIFY_REQUEST_CHAIN::request r = {};
|
NOTIFY_REQUEST_CHAIN::request r = {};
|
||||||
context.m_expect_height = m_core.get_current_blockchain_height();
|
|
||||||
m_core.get_short_chain_history(r.block_ids);
|
m_core.get_short_chain_history(r.block_ids);
|
||||||
r.prune = m_sync_pruned_blocks;
|
r.prune = m_sync_pruned_blocks;
|
||||||
handler_request_blocks_history( r.block_ids ); // change the limit(?), sleep(?)
|
handler_request_blocks_history( r.block_ids ); // change the limit(?), sleep(?)
|
||||||
context.m_last_request_time = boost::posix_time::microsec_clock::universal_time();
|
|
||||||
context.m_expect_response = NOTIFY_RESPONSE_CHAIN_ENTRY::ID;
|
|
||||||
MLOG_P2P_MESSAGE("-->>NOTIFY_REQUEST_CHAIN: m_block_ids.size()=" << r.block_ids.size() );
|
MLOG_P2P_MESSAGE("-->>NOTIFY_REQUEST_CHAIN: m_block_ids.size()=" << r.block_ids.size() );
|
||||||
post_notify<NOTIFY_REQUEST_CHAIN>(r, context);
|
post_notify<NOTIFY_REQUEST_CHAIN>(r, context);
|
||||||
MLOG_PEER_STATE("requesting chain");
|
MLOG_PEER_STATE("requesting chain");
|
||||||
@@ -512,10 +498,10 @@ namespace cryptonote
|
|||||||
template<class t_core>
|
template<class t_core>
|
||||||
int t_cryptonote_protocol_handler<t_core>::handle_notify_new_fluffy_block(int command, NOTIFY_NEW_FLUFFY_BLOCK::request& arg, cryptonote_connection_context& context)
|
int t_cryptonote_protocol_handler<t_core>::handle_notify_new_fluffy_block(int command, NOTIFY_NEW_FLUFFY_BLOCK::request& arg, cryptonote_connection_context& context)
|
||||||
{
|
{
|
||||||
MLOGIF_P2P_MESSAGE(crypto::hash hash; cryptonote::block b; bool ret = cryptonote::parse_and_validate_block_from_blob(arg.b.block, b, &hash);, ret, context << "Received NOTIFY_NEW_FLUFFY_BLOCK " << hash << " (height " << arg.current_blockchain_height << ", " << arg.b.txs.size() << " txes)");
|
MLOGIF_P2P_MESSAGE(crypto::hash hash; cryptonote::block b; bool ret = cryptonote::parse_and_validate_block_from_blob(arg.b.block, b, &hash);, ret, "Received NOTIFY_NEW_FLUFFY_BLOCK " << hash << " (height " << arg.current_blockchain_height << ", " << arg.b.txs.size() << " txes)");
|
||||||
if(context.m_state != cryptonote_connection_context::state_normal)
|
if(context.m_state != cryptonote_connection_context::state_normal)
|
||||||
return 1;
|
return 1;
|
||||||
if(!is_synchronized()) // can happen if a peer connection goes to normal but another thread still hasn't finished adding queued blocks
|
if(!is_synchronized() || m_no_sync) // can happen if a peer connection goes to normal but another thread still hasn't finished adding queued blocks
|
||||||
{
|
{
|
||||||
LOG_DEBUG_CC(context, "Received new block while syncing, ignored");
|
LOG_DEBUG_CC(context, "Received new block while syncing, ignored");
|
||||||
return 1;
|
return 1;
|
||||||
@@ -776,12 +762,9 @@ namespace cryptonote
|
|||||||
context.m_needed_objects.clear();
|
context.m_needed_objects.clear();
|
||||||
context.m_state = cryptonote_connection_context::state_synchronizing;
|
context.m_state = cryptonote_connection_context::state_synchronizing;
|
||||||
NOTIFY_REQUEST_CHAIN::request r = {};
|
NOTIFY_REQUEST_CHAIN::request r = {};
|
||||||
context.m_expect_height = m_core.get_current_blockchain_height();
|
|
||||||
m_core.get_short_chain_history(r.block_ids);
|
m_core.get_short_chain_history(r.block_ids);
|
||||||
handler_request_blocks_history( r.block_ids ); // change the limit(?), sleep(?)
|
handler_request_blocks_history( r.block_ids ); // change the limit(?), sleep(?)
|
||||||
r.prune = m_sync_pruned_blocks;
|
r.prune = m_sync_pruned_blocks;
|
||||||
context.m_last_request_time = boost::posix_time::microsec_clock::universal_time();
|
|
||||||
context.m_expect_response = NOTIFY_RESPONSE_CHAIN_ENTRY::ID;
|
|
||||||
MLOG_P2P_MESSAGE("-->>NOTIFY_REQUEST_CHAIN: m_block_ids.size()=" << r.block_ids.size() );
|
MLOG_P2P_MESSAGE("-->>NOTIFY_REQUEST_CHAIN: m_block_ids.size()=" << r.block_ids.size() );
|
||||||
post_notify<NOTIFY_REQUEST_CHAIN>(r, context);
|
post_notify<NOTIFY_REQUEST_CHAIN>(r, context);
|
||||||
MLOG_PEER_STATE("requesting chain");
|
MLOG_PEER_STATE("requesting chain");
|
||||||
@@ -946,7 +929,7 @@ namespace cryptonote
|
|||||||
// while syncing, core will lock for a long time, so we ignore
|
// while syncing, core will lock for a long time, so we ignore
|
||||||
// those txes as they aren't really needed anyway, and avoid a
|
// those txes as they aren't really needed anyway, and avoid a
|
||||||
// long block before replying
|
// long block before replying
|
||||||
if(!is_synchronized())
|
if(!is_synchronized() || m_no_sync)
|
||||||
{
|
{
|
||||||
LOG_DEBUG_CC(context, "Received new tx while syncing, ignored");
|
LOG_DEBUG_CC(context, "Received new tx while syncing, ignored");
|
||||||
return 1;
|
return 1;
|
||||||
@@ -1046,7 +1029,6 @@ namespace cryptonote
|
|||||||
drop_connection(context, false, false);
|
drop_connection(context, false, false);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
context.m_last_request_time = boost::posix_time::microsec_clock::universal_time();
|
|
||||||
MLOG_P2P_MESSAGE("-->>NOTIFY_RESPONSE_GET_OBJECTS: blocks.size()="
|
MLOG_P2P_MESSAGE("-->>NOTIFY_RESPONSE_GET_OBJECTS: blocks.size()="
|
||||||
<< rsp.blocks.size() << ", rsp.m_current_blockchain_height=" << rsp.current_blockchain_height
|
<< rsp.blocks.size() << ", rsp.m_current_blockchain_height=" << rsp.current_blockchain_height
|
||||||
<< ", missed_ids.size()=" << rsp.missed_ids.size());
|
<< ", missed_ids.size()=" << rsp.missed_ids.size());
|
||||||
@@ -1080,14 +1062,6 @@ namespace cryptonote
|
|||||||
boost::posix_time::ptime request_time = context.m_last_request_time;
|
boost::posix_time::ptime request_time = context.m_last_request_time;
|
||||||
context.m_last_request_time = boost::date_time::not_a_date_time;
|
context.m_last_request_time = boost::date_time::not_a_date_time;
|
||||||
|
|
||||||
if (context.m_expect_response != NOTIFY_RESPONSE_GET_OBJECTS::ID)
|
|
||||||
{
|
|
||||||
LOG_ERROR_CCONTEXT("Got NOTIFY_RESPONSE_GET_OBJECTS out of the blue, dropping connection");
|
|
||||||
drop_connection(context, true, false);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
context.m_expect_response = 0;
|
|
||||||
|
|
||||||
// calculate size of request
|
// calculate size of request
|
||||||
size_t size = 0;
|
size_t size = 0;
|
||||||
size_t blocks_size = 0;
|
size_t blocks_size = 0;
|
||||||
@@ -1117,13 +1091,6 @@ namespace cryptonote
|
|||||||
|
|
||||||
//epee::net_utils::network_throttle_manager::get_global_throttle_inreq().logger_handle_net("log/dr-monero/net/req-all.data", sec, get_avg_block_size());
|
//epee::net_utils::network_throttle_manager::get_global_throttle_inreq().logger_handle_net("log/dr-monero/net/req-all.data", sec, get_avg_block_size());
|
||||||
|
|
||||||
if(arg.blocks.empty())
|
|
||||||
{
|
|
||||||
LOG_ERROR_CCONTEXT("sent wrong NOTIFY_HAVE_OBJECTS: no blocks");
|
|
||||||
drop_connection(context, true, false);
|
|
||||||
++m_sync_bad_spans_downloaded;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
if(context.m_last_response_height > arg.current_blockchain_height)
|
if(context.m_last_response_height > arg.current_blockchain_height)
|
||||||
{
|
{
|
||||||
LOG_ERROR_CCONTEXT("sent wrong NOTIFY_HAVE_OBJECTS: arg.m_current_blockchain_height=" << arg.current_blockchain_height
|
LOG_ERROR_CCONTEXT("sent wrong NOTIFY_HAVE_OBJECTS: arg.m_current_blockchain_height=" << arg.current_blockchain_height
|
||||||
@@ -1133,11 +1100,6 @@ namespace cryptonote
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (arg.current_blockchain_height < context.m_remote_blockchain_height)
|
|
||||||
{
|
|
||||||
MINFO(context << "Claims " << arg.current_blockchain_height << ", claimed " << context.m_remote_blockchain_height << " before");
|
|
||||||
hit_score(context, 1);
|
|
||||||
}
|
|
||||||
context.m_remote_blockchain_height = arg.current_blockchain_height;
|
context.m_remote_blockchain_height = arg.current_blockchain_height;
|
||||||
if (context.m_remote_blockchain_height > m_core.get_target_blockchain_height())
|
if (context.m_remote_blockchain_height > m_core.get_target_blockchain_height())
|
||||||
m_core.set_target_blockchain_height(context.m_remote_blockchain_height);
|
m_core.set_target_blockchain_height(context.m_remote_blockchain_height);
|
||||||
@@ -1172,16 +1134,7 @@ namespace cryptonote
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (start_height == std::numeric_limits<uint64_t>::max())
|
if (start_height == std::numeric_limits<uint64_t>::max())
|
||||||
{
|
|
||||||
start_height = boost::get<txin_gen>(b.miner_tx.vin[0]).height;
|
start_height = boost::get<txin_gen>(b.miner_tx.vin[0]).height;
|
||||||
if (start_height > context.m_expect_height)
|
|
||||||
{
|
|
||||||
LOG_ERROR_CCONTEXT("sent block ahead of expected height, dropping connection");
|
|
||||||
drop_connection(context, false, false);
|
|
||||||
++m_sync_bad_spans_downloaded;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
auto req_it = context.m_requested_objects.find(block_hash);
|
auto req_it = context.m_requested_objects.find(block_hash);
|
||||||
if(req_it == context.m_requested_objects.end())
|
if(req_it == context.m_requested_objects.end())
|
||||||
@@ -1270,7 +1223,7 @@ namespace cryptonote
|
|||||||
const boost::posix_time::time_duration dt = now - request_time;
|
const boost::posix_time::time_duration dt = now - request_time;
|
||||||
const float rate = size * 1e6 / (dt.total_microseconds() + 1);
|
const float rate = size * 1e6 / (dt.total_microseconds() + 1);
|
||||||
MDEBUG(context << " adding span: " << arg.blocks.size() << " at height " << start_height << ", " << dt.total_microseconds()/1e6 << " seconds, " << (rate/1024) << " kB/s, size now " << (m_block_queue.get_data_size() + blocks_size) / 1048576.f << " MB");
|
MDEBUG(context << " adding span: " << arg.blocks.size() << " at height " << start_height << ", " << dt.total_microseconds()/1e6 << " seconds, " << (rate/1024) << " kB/s, size now " << (m_block_queue.get_data_size() + blocks_size) / 1048576.f << " MB");
|
||||||
m_block_queue.add_blocks(start_height, arg.blocks, context.m_connection_id, context.m_remote_address, rate, blocks_size);
|
m_block_queue.add_blocks(start_height, arg.blocks, context.m_connection_id, rate, blocks_size);
|
||||||
|
|
||||||
const crypto::hash last_block_hash = cryptonote::get_block_hash(b);
|
const crypto::hash last_block_hash = cryptonote::get_block_hash(b);
|
||||||
context.m_last_known_hash = last_block_hash;
|
context.m_last_known_hash = last_block_hash;
|
||||||
@@ -1371,8 +1324,7 @@ namespace cryptonote
|
|||||||
uint64_t start_height;
|
uint64_t start_height;
|
||||||
std::vector<cryptonote::block_complete_entry> blocks;
|
std::vector<cryptonote::block_complete_entry> blocks;
|
||||||
boost::uuids::uuid span_connection_id;
|
boost::uuids::uuid span_connection_id;
|
||||||
epee::net_utils::network_address span_origin;
|
if (!m_block_queue.get_next_span(start_height, blocks, span_connection_id))
|
||||||
if (!m_block_queue.get_next_span(start_height, blocks, span_connection_id, span_origin))
|
|
||||||
{
|
{
|
||||||
MDEBUG(context << " no next span found, going back to download");
|
MDEBUG(context << " no next span found, going back to download");
|
||||||
break;
|
break;
|
||||||
@@ -1470,7 +1422,6 @@ namespace cryptonote
|
|||||||
if (!m_core.prepare_handle_incoming_blocks(blocks, pblocks))
|
if (!m_core.prepare_handle_incoming_blocks(blocks, pblocks))
|
||||||
{
|
{
|
||||||
LOG_ERROR_CCONTEXT("Failure in prepare_handle_incoming_blocks");
|
LOG_ERROR_CCONTEXT("Failure in prepare_handle_incoming_blocks");
|
||||||
drop_connections(span_origin);
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (!pblocks.empty() && pblocks.size() != blocks.size())
|
if (!pblocks.empty() && pblocks.size() != blocks.size())
|
||||||
@@ -1510,7 +1461,6 @@ namespace cryptonote
|
|||||||
{
|
{
|
||||||
if(tvc[i].m_verifivation_failed)
|
if(tvc[i].m_verifivation_failed)
|
||||||
{
|
{
|
||||||
drop_connections(span_origin);
|
|
||||||
if (!m_p2p->for_connection(span_connection_id, [&](cryptonote_connection_context& context, nodetool::peerid_type peer_id, uint32_t f)->bool{
|
if (!m_p2p->for_connection(span_connection_id, [&](cryptonote_connection_context& context, nodetool::peerid_type peer_id, uint32_t f)->bool{
|
||||||
cryptonote::transaction tx;
|
cryptonote::transaction tx;
|
||||||
crypto::hash txid;
|
crypto::hash txid;
|
||||||
@@ -1552,7 +1502,6 @@ namespace cryptonote
|
|||||||
|
|
||||||
if(bvc.m_verifivation_failed)
|
if(bvc.m_verifivation_failed)
|
||||||
{
|
{
|
||||||
drop_connections(span_origin);
|
|
||||||
if (!m_p2p->for_connection(span_connection_id, [&](cryptonote_connection_context& context, nodetool::peerid_type peer_id, uint32_t f)->bool{
|
if (!m_p2p->for_connection(span_connection_id, [&](cryptonote_connection_context& context, nodetool::peerid_type peer_id, uint32_t f)->bool{
|
||||||
LOG_PRINT_CCONTEXT_L1("Block verification failed, dropping connection");
|
LOG_PRINT_CCONTEXT_L1("Block verification failed, dropping connection");
|
||||||
drop_connection_with_score(context, bvc.m_bad_pow ? P2P_IP_FAILS_BEFORE_BLOCK : 1, true);
|
drop_connection_with_score(context, bvc.m_bad_pow ? P2P_IP_FAILS_BEFORE_BLOCK : 1, true);
|
||||||
@@ -1572,7 +1521,6 @@ namespace cryptonote
|
|||||||
}
|
}
|
||||||
if(bvc.m_marked_as_orphaned)
|
if(bvc.m_marked_as_orphaned)
|
||||||
{
|
{
|
||||||
drop_connections(span_origin);
|
|
||||||
if (!m_p2p->for_connection(span_connection_id, [&](cryptonote_connection_context& context, nodetool::peerid_type peer_id, uint32_t f)->bool{
|
if (!m_p2p->for_connection(span_connection_id, [&](cryptonote_connection_context& context, nodetool::peerid_type peer_id, uint32_t f)->bool{
|
||||||
LOG_PRINT_CCONTEXT_L1("Block received at sync phase was marked as orphaned, dropping connection");
|
LOG_PRINT_CCONTEXT_L1("Block received at sync phase was marked as orphaned, dropping connection");
|
||||||
drop_connection(context, true, true);
|
drop_connection(context, true, true);
|
||||||
@@ -1711,46 +1659,24 @@ skip:
|
|||||||
bool t_cryptonote_protocol_handler<t_core>::kick_idle_peers()
|
bool t_cryptonote_protocol_handler<t_core>::kick_idle_peers()
|
||||||
{
|
{
|
||||||
MTRACE("Checking for idle peers...");
|
MTRACE("Checking for idle peers...");
|
||||||
std::vector<std::pair<boost::uuids::uuid, unsigned>> idle_peers;
|
|
||||||
m_p2p->for_each_connection([&](cryptonote_connection_context& context, nodetool::peerid_type peer_id, uint32_t support_flags)->bool
|
m_p2p->for_each_connection([&](cryptonote_connection_context& context, nodetool::peerid_type peer_id, uint32_t support_flags)->bool
|
||||||
{
|
{
|
||||||
if (context.m_state == cryptonote_connection_context::state_synchronizing && context.m_last_request_time != boost::date_time::not_a_date_time)
|
if (context.m_state == cryptonote_connection_context::state_synchronizing && context.m_last_request_time != boost::date_time::not_a_date_time)
|
||||||
{
|
{
|
||||||
const boost::posix_time::ptime now = boost::posix_time::microsec_clock::universal_time();
|
const boost::posix_time::ptime now = boost::posix_time::microsec_clock::universal_time();
|
||||||
const boost::posix_time::time_duration dt = now - context.m_last_request_time;
|
const boost::posix_time::time_duration dt = now - context.m_last_request_time;
|
||||||
const auto ms = dt.total_microseconds();
|
if (dt.total_microseconds() > IDLE_PEER_KICK_TIME)
|
||||||
if (ms > IDLE_PEER_KICK_TIME || (context.m_expect_response && ms > NON_RESPONSIVE_PEER_KICK_TIME))
|
|
||||||
{
|
{
|
||||||
if (context.m_score-- >= 0)
|
MINFO(context << " kicking idle peer, last update " << (dt.total_microseconds() / 1.e6) << " seconds ago");
|
||||||
{
|
LOG_PRINT_CCONTEXT_L2("requesting callback");
|
||||||
MINFO(context << " kicking idle peer, last update " << (dt.total_microseconds() / 1.e6) << " seconds ago, expecting " << (int)context.m_expect_response);
|
context.m_last_request_time = boost::date_time::not_a_date_time;
|
||||||
LOG_PRINT_CCONTEXT_L2("requesting callback");
|
context.m_state = cryptonote_connection_context::state_standby; // we'll go back to adding, then (if we can't), download
|
||||||
context.m_last_request_time = boost::date_time::not_a_date_time;
|
++context.m_callback_request_count;
|
||||||
context.m_expect_response = 0;
|
m_p2p->request_callback(context);
|
||||||
context.m_expect_height = 0;
|
|
||||||
context.m_state = cryptonote_connection_context::state_standby; // we'll go back to adding, then (if we can't), download
|
|
||||||
++context.m_callback_request_count;
|
|
||||||
m_p2p->request_callback(context);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
idle_peers.push_back(std::make_pair(context.m_connection_id, context.m_expect_response == 0 ? 1 : 5));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
for (const auto &e: idle_peers)
|
|
||||||
{
|
|
||||||
const auto &uuid = e.first;
|
|
||||||
m_p2p->for_connection(uuid, [&](cryptonote_connection_context& ctx, nodetool::peerid_type peer_id, uint32_t f)->bool{
|
|
||||||
MINFO(ctx << "dropping idle peer with negative score");
|
|
||||||
drop_connection_with_score(ctx, e.second, false);
|
|
||||||
return true;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------------------------------------------
|
||||||
@@ -1827,16 +1753,6 @@ skip:
|
|||||||
LOG_ERROR_CCONTEXT("Failed to handle NOTIFY_REQUEST_CHAIN.");
|
LOG_ERROR_CCONTEXT("Failed to handle NOTIFY_REQUEST_CHAIN.");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (r.m_block_ids.size() >= 2)
|
|
||||||
{
|
|
||||||
cryptonote::block b;
|
|
||||||
if (!m_core.get_block_by_hash(r.m_block_ids[1], b))
|
|
||||||
{
|
|
||||||
LOG_ERROR_CCONTEXT("Failed to handle NOTIFY_REQUEST_CHAIN: first block not found");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
r.first_block = cryptonote::block_to_blob(b);
|
|
||||||
}
|
|
||||||
MLOG_P2P_MESSAGE("-->>NOTIFY_RESPONSE_CHAIN_ENTRY: m_start_height=" << r.start_height << ", m_total_height=" << r.total_height << ", m_block_ids.size()=" << r.m_block_ids.size());
|
MLOG_P2P_MESSAGE("-->>NOTIFY_RESPONSE_CHAIN_ENTRY: m_start_height=" << r.start_height << ", m_total_height=" << r.total_height << ", m_block_ids.size()=" << r.m_block_ids.size());
|
||||||
post_notify<NOTIFY_RESPONSE_CHAIN_ENTRY>(r, context);
|
post_notify<NOTIFY_RESPONSE_CHAIN_ENTRY>(r, context);
|
||||||
return 1;
|
return 1;
|
||||||
@@ -1991,7 +1907,7 @@ skip:
|
|||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------------------------------------------
|
||||||
template<class t_core>
|
template<class t_core>
|
||||||
size_t t_cryptonote_protocol_handler<t_core>::skip_unneeded_hashes(cryptonote_connection_context& context, bool check_block_queue) const
|
void t_cryptonote_protocol_handler<t_core>::skip_unneeded_hashes(cryptonote_connection_context& context, bool check_block_queue) const
|
||||||
{
|
{
|
||||||
// take out blocks we already have
|
// take out blocks we already have
|
||||||
size_t skip = 0;
|
size_t skip = 0;
|
||||||
@@ -2008,7 +1924,6 @@ skip:
|
|||||||
MDEBUG(context << "skipping " << skip << "/" << context.m_needed_objects.size() << " blocks");
|
MDEBUG(context << "skipping " << skip << "/" << context.m_needed_objects.size() << " blocks");
|
||||||
context.m_needed_objects = std::vector<std::pair<crypto::hash, uint64_t>>(context.m_needed_objects.begin() + skip, context.m_needed_objects.end());
|
context.m_needed_objects = std::vector<std::pair<crypto::hash, uint64_t>>(context.m_needed_objects.begin() + skip, context.m_needed_objects.end());
|
||||||
}
|
}
|
||||||
return skip;
|
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------------------------------------------
|
||||||
template<class t_core>
|
template<class t_core>
|
||||||
@@ -2022,7 +1937,7 @@ skip:
|
|||||||
if (local_stripe == 0)
|
if (local_stripe == 0)
|
||||||
return false;
|
return false;
|
||||||
// don't request pre-bulletprooof pruned blocks, we can't reconstruct their weight (yet)
|
// don't request pre-bulletprooof pruned blocks, we can't reconstruct their weight (yet)
|
||||||
static const uint64_t bp_fork_height = m_core.get_earliest_ideal_height_for_version(HF_VERSION_SMALLER_BP + 1);
|
static const uint64_t bp_fork_height = m_core.get_earliest_ideal_height_for_version(HF_VERSION_SMALLER_BP);
|
||||||
if (first_block_height < bp_fork_height)
|
if (first_block_height < bp_fork_height)
|
||||||
return false;
|
return false;
|
||||||
// assumes the span size is less or equal to the stripe size
|
// assumes the span size is less or equal to the stripe size
|
||||||
@@ -2062,17 +1977,7 @@ skip:
|
|||||||
const size_t block_queue_size_threshold = m_block_download_max_size ? m_block_download_max_size : BLOCK_QUEUE_SIZE_THRESHOLD;
|
const size_t block_queue_size_threshold = m_block_download_max_size ? m_block_download_max_size : BLOCK_QUEUE_SIZE_THRESHOLD;
|
||||||
bool queue_proceed = nspans < BLOCK_QUEUE_NSPANS_THRESHOLD || size < block_queue_size_threshold;
|
bool queue_proceed = nspans < BLOCK_QUEUE_NSPANS_THRESHOLD || size < block_queue_size_threshold;
|
||||||
// get rid of blocks we already requested, or already have
|
// get rid of blocks we already requested, or already have
|
||||||
if (skip_unneeded_hashes(context, true) && context.m_needed_objects.empty() && context.m_num_requested == 0)
|
skip_unneeded_hashes(context, true);
|
||||||
{
|
|
||||||
if (context.m_remote_blockchain_height > m_block_queue.get_next_needed_height(bc_height))
|
|
||||||
{
|
|
||||||
MERROR(context << "Nothing we can request from this peer, and we did not request anything previously");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
MDEBUG(context << "Nothing to get from this peer, and it's not ahead of us, all done");
|
|
||||||
context.m_state = cryptonote_connection_context::state_normal;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
uint64_t next_needed_height = m_block_queue.get_next_needed_height(bc_height);
|
uint64_t next_needed_height = m_block_queue.get_next_needed_height(bc_height);
|
||||||
uint64_t next_block_height;
|
uint64_t next_block_height;
|
||||||
if (context.m_needed_objects.empty())
|
if (context.m_needed_objects.empty())
|
||||||
@@ -2208,22 +2113,12 @@ skip:
|
|||||||
context.m_last_response_height = 0;
|
context.m_last_response_height = 0;
|
||||||
goto skip;
|
goto skip;
|
||||||
}
|
}
|
||||||
if (skip_unneeded_hashes(context, false) && context.m_needed_objects.empty() && context.m_num_requested == 0)
|
skip_unneeded_hashes(context, false);
|
||||||
{
|
|
||||||
if (context.m_remote_blockchain_height > m_block_queue.get_next_needed_height(m_core.get_current_blockchain_height()))
|
|
||||||
{
|
|
||||||
MERROR(context << "Nothing we can request from this peer, and we did not request anything previously");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
MDEBUG(context << "Nothing to get from this peer, and it's not ahead of us, all done");
|
|
||||||
context.m_state = cryptonote_connection_context::state_normal;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
const uint64_t first_block_height = context.m_last_response_height - context.m_needed_objects.size() + 1;
|
const uint64_t first_block_height = context.m_last_response_height - context.m_needed_objects.size() + 1;
|
||||||
static const uint64_t bp_fork_height = m_core.get_earliest_ideal_height_for_version(HF_VERSION_SMALLER_BP);
|
static const uint64_t bp_fork_height = m_core.get_earliest_ideal_height_for_version(HF_VERSION_SMALLER_BP);
|
||||||
bool sync_pruned_blocks = m_sync_pruned_blocks && first_block_height >= bp_fork_height && m_core.get_blockchain_pruning_seed();
|
bool sync_pruned_blocks = m_sync_pruned_blocks && first_block_height >= bp_fork_height && m_core.get_blockchain_pruning_seed();
|
||||||
span = m_block_queue.reserve_span(first_block_height, context.m_last_response_height, count_limit, context.m_connection_id, context.m_remote_address, sync_pruned_blocks, m_core.get_blockchain_pruning_seed(), context.m_pruning_seed, context.m_remote_blockchain_height, context.m_needed_objects);
|
span = m_block_queue.reserve_span(first_block_height, context.m_last_response_height, count_limit, context.m_connection_id, sync_pruned_blocks, m_core.get_blockchain_pruning_seed(), context.m_pruning_seed, context.m_remote_blockchain_height, context.m_needed_objects);
|
||||||
MDEBUG(context << " span from " << first_block_height << ": " << span.first << "/" << span.second);
|
MDEBUG(context << " span from " << first_block_height << ": " << span.first << "/" << span.second);
|
||||||
if (span.second > 0)
|
if (span.second > 0)
|
||||||
{
|
{
|
||||||
@@ -2304,8 +2199,6 @@ skip:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
context.m_last_request_time = boost::posix_time::microsec_clock::universal_time();
|
context.m_last_request_time = boost::posix_time::microsec_clock::universal_time();
|
||||||
context.m_expect_height = span.first;
|
|
||||||
context.m_expect_response = NOTIFY_RESPONSE_GET_OBJECTS::ID;
|
|
||||||
MLOG_P2P_MESSAGE("-->>NOTIFY_REQUEST_GET_OBJECTS: blocks.size()=" << req.blocks.size()
|
MLOG_P2P_MESSAGE("-->>NOTIFY_REQUEST_GET_OBJECTS: blocks.size()=" << req.blocks.size()
|
||||||
<< "requested blocks count=" << count << " / " << count_limit << " from " << span.first << ", first hash " << req.blocks.front());
|
<< "requested blocks count=" << count << " / " << count_limit << " from " << span.first << ", first hash " << req.blocks.front());
|
||||||
//epee::net_utils::network_throttle_manager::get_global_throttle_inreq().logger_handle_net("log/dr-monero/net/req-all.data", sec, get_avg_block_size());
|
//epee::net_utils::network_throttle_manager::get_global_throttle_inreq().logger_handle_net("log/dr-monero/net/req-all.data", sec, get_avg_block_size());
|
||||||
@@ -2315,22 +2208,35 @@ skip:
|
|||||||
<< "/" << tools::get_pruning_stripe(span.first + span.second - 1, context.m_remote_blockchain_height, CRYPTONOTE_PRUNING_LOG_STRIPES)
|
<< "/" << tools::get_pruning_stripe(span.first + span.second - 1, context.m_remote_blockchain_height, CRYPTONOTE_PRUNING_LOG_STRIPES)
|
||||||
<< ", ours " << tools::get_pruning_stripe(m_core.get_blockchain_pruning_seed()) << ", peer stripe " << tools::get_pruning_stripe(context.m_pruning_seed));
|
<< ", ours " << tools::get_pruning_stripe(m_core.get_blockchain_pruning_seed()) << ", peer stripe " << tools::get_pruning_stripe(context.m_pruning_seed));
|
||||||
|
|
||||||
context.m_num_requested += req.blocks.size();
|
|
||||||
post_notify<NOTIFY_REQUEST_GET_OBJECTS>(req, context);
|
post_notify<NOTIFY_REQUEST_GET_OBJECTS>(req, context);
|
||||||
MLOG_PEER_STATE("requesting objects");
|
MLOG_PEER_STATE("requesting objects");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// we can do nothing, so drop this peer to make room for others unless we think we've downloaded all we need
|
// if we're still around, we might be at a point where the peer is pruned, so we could either
|
||||||
const uint64_t blockchain_height = m_core.get_current_blockchain_height();
|
// drop it to make space for other peers, or ask for a span further down the line
|
||||||
if (std::max(blockchain_height, m_block_queue.get_next_needed_height(blockchain_height)) >= m_core.get_target_blockchain_height())
|
const uint32_t next_stripe = get_next_needed_pruning_stripe().first;
|
||||||
|
const uint32_t peer_stripe = tools::get_pruning_stripe(context.m_pruning_seed);
|
||||||
|
const uint32_t local_stripe = tools::get_pruning_stripe(m_core.get_blockchain_pruning_seed());
|
||||||
|
if (!(m_sync_pruned_blocks && peer_stripe == local_stripe) && next_stripe && peer_stripe && next_stripe != peer_stripe)
|
||||||
{
|
{
|
||||||
|
// at this point, we have to either close the connection, or start getting blocks past the
|
||||||
|
// current point, or become dormant
|
||||||
|
MDEBUG(context << "this peer is pruned at seed " << epee::string_tools::to_string_hex(context.m_pruning_seed) <<
|
||||||
|
", next stripe needed is " << next_stripe);
|
||||||
|
if (!context.m_is_income)
|
||||||
|
{
|
||||||
|
if (should_drop_connection(context, next_stripe))
|
||||||
|
{
|
||||||
|
m_p2p->add_used_stripe_peer(context);
|
||||||
|
return false; // drop outgoing connections
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// we'll get back stuck waiting for the go ahead
|
||||||
context.m_state = cryptonote_connection_context::state_normal;
|
context.m_state = cryptonote_connection_context::state_normal;
|
||||||
MLOG_PEER_STATE("Nothing to do for now, switching to normal state");
|
MLOG_PEER_STATE("Nothing to do for now, switching to normal state");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
MLOG_PEER_STATE("We can download nothing from this peer, dropping");
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
skip:
|
skip:
|
||||||
@@ -2347,8 +2253,8 @@ skip:
|
|||||||
uint64_t start_height;
|
uint64_t start_height;
|
||||||
std::vector<cryptonote::block_complete_entry> blocks;
|
std::vector<cryptonote::block_complete_entry> blocks;
|
||||||
boost::uuids::uuid span_connection_id;
|
boost::uuids::uuid span_connection_id;
|
||||||
epee::net_utils::network_address span_origin;
|
bool filled = false;
|
||||||
if (m_block_queue.get_next_span(start_height, blocks, span_connection_id, span_origin, true))
|
if (m_block_queue.get_next_span(start_height, blocks, span_connection_id, filled) && filled)
|
||||||
{
|
{
|
||||||
LOG_DEBUG_CC(context, "No other thread is adding blocks, resuming");
|
LOG_DEBUG_CC(context, "No other thread is adding blocks, resuming");
|
||||||
MLOG_PEER_STATE("will try to add blocks next");
|
MLOG_PEER_STATE("will try to add blocks next");
|
||||||
@@ -2364,7 +2270,6 @@ skip:
|
|||||||
{//we have to fetch more objects ids, request blockchain entry
|
{//we have to fetch more objects ids, request blockchain entry
|
||||||
|
|
||||||
NOTIFY_REQUEST_CHAIN::request r = {};
|
NOTIFY_REQUEST_CHAIN::request r = {};
|
||||||
context.m_expect_height = m_core.get_current_blockchain_height();
|
|
||||||
m_core.get_short_chain_history(r.block_ids);
|
m_core.get_short_chain_history(r.block_ids);
|
||||||
CHECK_AND_ASSERT_MES(!r.block_ids.empty(), false, "Short chain history is empty");
|
CHECK_AND_ASSERT_MES(!r.block_ids.empty(), false, "Short chain history is empty");
|
||||||
|
|
||||||
@@ -2372,10 +2277,7 @@ skip:
|
|||||||
{
|
{
|
||||||
// we'll want to start off from where we are on that peer, which may not be added yet
|
// we'll want to start off from where we are on that peer, which may not be added yet
|
||||||
if (context.m_last_known_hash != crypto::null_hash && r.block_ids.front() != context.m_last_known_hash)
|
if (context.m_last_known_hash != crypto::null_hash && r.block_ids.front() != context.m_last_known_hash)
|
||||||
{
|
|
||||||
context.m_expect_height = std::numeric_limits<uint64_t>::max();
|
|
||||||
r.block_ids.push_front(context.m_last_known_hash);
|
r.block_ids.push_front(context.m_last_known_hash);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
handler_request_blocks_history( r.block_ids ); // change the limit(?), sleep(?)
|
handler_request_blocks_history( r.block_ids ); // change the limit(?), sleep(?)
|
||||||
@@ -2387,7 +2289,6 @@ skip:
|
|||||||
//LOG_PRINT_CCONTEXT_L1("r = " << 200);
|
//LOG_PRINT_CCONTEXT_L1("r = " << 200);
|
||||||
|
|
||||||
context.m_last_request_time = boost::posix_time::microsec_clock::universal_time();
|
context.m_last_request_time = boost::posix_time::microsec_clock::universal_time();
|
||||||
context.m_expect_response = NOTIFY_RESPONSE_CHAIN_ENTRY::ID;
|
|
||||||
MLOG_P2P_MESSAGE("-->>NOTIFY_REQUEST_CHAIN: m_block_ids.size()=" << r.block_ids.size() << ", start_from_current_chain " << start_from_current_chain);
|
MLOG_P2P_MESSAGE("-->>NOTIFY_REQUEST_CHAIN: m_block_ids.size()=" << r.block_ids.size() << ", start_from_current_chain " << start_from_current_chain);
|
||||||
post_notify<NOTIFY_REQUEST_CHAIN>(r, context);
|
post_notify<NOTIFY_REQUEST_CHAIN>(r, context);
|
||||||
MLOG_PEER_STATE("requesting chain");
|
MLOG_PEER_STATE("requesting chain");
|
||||||
@@ -2413,7 +2314,7 @@ skip:
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MINFO(context << " we've reached this peer's blockchain height (theirs " << context.m_remote_blockchain_height << ", our target " << m_core.get_target_blockchain_height());
|
MINFO(context << " we've reached this peer's blockchain height");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -2510,20 +2411,6 @@ skip:
|
|||||||
<< ", m_start_height=" << arg.start_height << ", m_total_height=" << arg.total_height);
|
<< ", m_start_height=" << arg.start_height << ", m_total_height=" << arg.total_height);
|
||||||
MLOG_PEER_STATE("received chain");
|
MLOG_PEER_STATE("received chain");
|
||||||
|
|
||||||
if (context.m_expect_response != NOTIFY_RESPONSE_CHAIN_ENTRY::ID)
|
|
||||||
{
|
|
||||||
LOG_ERROR_CCONTEXT("Got NOTIFY_RESPONSE_CHAIN_ENTRY out of the blue, dropping connection");
|
|
||||||
drop_connection(context, true, false);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
context.m_expect_response = 0;
|
|
||||||
if (arg.start_height + 1 > context.m_expect_height) // we expect an overlapping block
|
|
||||||
{
|
|
||||||
LOG_ERROR_CCONTEXT("Got NOTIFY_RESPONSE_CHAIN_ENTRY past expected height, dropping connection");
|
|
||||||
drop_connection(context, true, false);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
context.m_last_request_time = boost::date_time::not_a_date_time;
|
context.m_last_request_time = boost::date_time::not_a_date_time;
|
||||||
|
|
||||||
m_sync_download_chain_size += arg.m_block_ids.size() * sizeof(crypto::hash);
|
m_sync_download_chain_size += arg.m_block_ids.size() * sizeof(crypto::hash);
|
||||||
@@ -2548,17 +2435,12 @@ skip:
|
|||||||
}
|
}
|
||||||
MDEBUG(context << "first block hash " << arg.m_block_ids.front() << ", last " << arg.m_block_ids.back());
|
MDEBUG(context << "first block hash " << arg.m_block_ids.front() << ", last " << arg.m_block_ids.back());
|
||||||
|
|
||||||
if (arg.total_height >= CRYPTONOTE_MAX_BLOCK_NUMBER || arg.m_block_ids.size() > BLOCKS_IDS_SYNCHRONIZING_MAX_COUNT)
|
if (arg.total_height >= CRYPTONOTE_MAX_BLOCK_NUMBER || arg.m_block_ids.size() >= CRYPTONOTE_MAX_BLOCK_NUMBER)
|
||||||
{
|
{
|
||||||
LOG_ERROR_CCONTEXT("sent wrong NOTIFY_RESPONSE_CHAIN_ENTRY, with total_height=" << arg.total_height << " and block_ids=" << arg.m_block_ids.size());
|
LOG_ERROR_CCONTEXT("sent wrong NOTIFY_RESPONSE_CHAIN_ENTRY, with total_height=" << arg.total_height << " and block_ids=" << arg.m_block_ids.size());
|
||||||
drop_connection(context, false, false);
|
drop_connection(context, false, false);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (arg.total_height < context.m_remote_blockchain_height)
|
|
||||||
{
|
|
||||||
MINFO(context << "Claims " << arg.total_height << ", claimed " << context.m_remote_blockchain_height << " before");
|
|
||||||
hit_score(context, 1);
|
|
||||||
}
|
|
||||||
context.m_remote_blockchain_height = arg.total_height;
|
context.m_remote_blockchain_height = arg.total_height;
|
||||||
context.m_last_response_height = arg.start_height + arg.m_block_ids.size()-1;
|
context.m_last_response_height = arg.start_height + arg.m_block_ids.size()-1;
|
||||||
if(context.m_last_response_height > context.m_remote_blockchain_height)
|
if(context.m_last_response_height > context.m_remote_blockchain_height)
|
||||||
@@ -2571,7 +2453,7 @@ skip:
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint64_t n_use_blocks = m_core.prevalidate_block_hashes(arg.start_height, arg.m_block_ids, arg.m_block_weights);
|
uint64_t n_use_blocks = m_core.prevalidate_block_hashes(arg.start_height, arg.m_block_ids, arg.m_block_weights);
|
||||||
if (n_use_blocks == 0 || n_use_blocks + HASH_OF_HASHES_STEP <= arg.m_block_ids.size())
|
if (n_use_blocks + HASH_OF_HASHES_STEP <= arg.m_block_ids.size())
|
||||||
{
|
{
|
||||||
LOG_ERROR_CCONTEXT("Most blocks are invalid, dropping connection");
|
LOG_ERROR_CCONTEXT("Most blocks are invalid, dropping connection");
|
||||||
drop_connection(context, true, false);
|
drop_connection(context, true, false);
|
||||||
@@ -2580,75 +2462,12 @@ skip:
|
|||||||
|
|
||||||
context.m_needed_objects.clear();
|
context.m_needed_objects.clear();
|
||||||
uint64_t added = 0;
|
uint64_t added = 0;
|
||||||
std::unordered_set<crypto::hash> blocks_found;
|
|
||||||
bool first = true;
|
|
||||||
bool expect_unknown = false;
|
|
||||||
for (size_t i = 0; i < arg.m_block_ids.size(); ++i)
|
for (size_t i = 0; i < arg.m_block_ids.size(); ++i)
|
||||||
{
|
{
|
||||||
if (!blocks_found.insert(arg.m_block_ids[i]).second)
|
|
||||||
{
|
|
||||||
LOG_ERROR_CCONTEXT("Duplicate blocks in chain entry response, dropping connection");
|
|
||||||
drop_connection_with_score(context, 5, false);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
int where;
|
|
||||||
const bool have_block = m_core.have_block_unlocked(arg.m_block_ids[i], &where);
|
|
||||||
if (first)
|
|
||||||
{
|
|
||||||
if (!have_block && !m_block_queue.requested(arg.m_block_ids[i]) && !m_block_queue.have(arg.m_block_ids[i]))
|
|
||||||
{
|
|
||||||
LOG_ERROR_CCONTEXT("First block hash is unknown, dropping connection");
|
|
||||||
drop_connection_with_score(context, 5, false);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
if (!have_block)
|
|
||||||
expect_unknown = true;
|
|
||||||
}
|
|
||||||
if (!first)
|
|
||||||
{
|
|
||||||
// after the first, blocks may be known or unknown, but if they are known,
|
|
||||||
// they should be at the same height if on the main chain
|
|
||||||
if (have_block)
|
|
||||||
{
|
|
||||||
switch (where)
|
|
||||||
{
|
|
||||||
default:
|
|
||||||
case HAVE_BLOCK_INVALID:
|
|
||||||
LOG_ERROR_CCONTEXT("Block is invalid or known without known type, dropping connection");
|
|
||||||
drop_connection(context, true, false);
|
|
||||||
return 1;
|
|
||||||
case HAVE_BLOCK_MAIN_CHAIN:
|
|
||||||
if (expect_unknown)
|
|
||||||
{
|
|
||||||
LOG_ERROR_CCONTEXT("Block is on the main chain, but we did not expect a known block, dropping connection");
|
|
||||||
drop_connection_with_score(context, 5, false);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
if (m_core.get_block_id_by_height(arg.start_height + i) != arg.m_block_ids[i])
|
|
||||||
{
|
|
||||||
LOG_ERROR_CCONTEXT("Block is on the main chain, but not at the expected height, dropping connection");
|
|
||||||
drop_connection_with_score(context, 5, false);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case HAVE_BLOCK_ALT_CHAIN:
|
|
||||||
if (expect_unknown)
|
|
||||||
{
|
|
||||||
LOG_ERROR_CCONTEXT("Block is on the main chain, but we did not expect a known block, dropping connection");
|
|
||||||
drop_connection_with_score(context, 5, false);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
expect_unknown = true;
|
|
||||||
}
|
|
||||||
const uint64_t block_weight = arg.m_block_weights.empty() ? 0 : arg.m_block_weights[i];
|
const uint64_t block_weight = arg.m_block_weights.empty() ? 0 : arg.m_block_weights[i];
|
||||||
context.m_needed_objects.push_back(std::make_pair(arg.m_block_ids[i], block_weight));
|
context.m_needed_objects.push_back(std::make_pair(arg.m_block_ids[i], block_weight));
|
||||||
if (++added == n_use_blocks)
|
if (++added == n_use_blocks)
|
||||||
break;
|
break;
|
||||||
first = false;
|
|
||||||
}
|
}
|
||||||
context.m_last_response_height -= arg.m_block_ids.size() - n_use_blocks;
|
context.m_last_response_height -= arg.m_block_ids.size() - n_use_blocks;
|
||||||
|
|
||||||
@@ -2662,7 +2481,6 @@ skip:
|
|||||||
if (arg.total_height > m_core.get_target_blockchain_height())
|
if (arg.total_height > m_core.get_target_blockchain_height())
|
||||||
m_core.set_target_blockchain_height(arg.total_height);
|
m_core.set_target_blockchain_height(arg.total_height);
|
||||||
|
|
||||||
context.m_num_requested = 0;
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------------------------------------------
|
||||||
@@ -2679,7 +2497,6 @@ skip:
|
|||||||
std::vector<std::pair<epee::net_utils::zone, boost::uuids::uuid>> fullConnections, fluffyConnections;
|
std::vector<std::pair<epee::net_utils::zone, boost::uuids::uuid>> fullConnections, fluffyConnections;
|
||||||
m_p2p->for_each_connection([this, &exclude_context, &fullConnections, &fluffyConnections](connection_context& context, nodetool::peerid_type peer_id, uint32_t support_flags)
|
m_p2p->for_each_connection([this, &exclude_context, &fullConnections, &fluffyConnections](connection_context& context, nodetool::peerid_type peer_id, uint32_t support_flags)
|
||||||
{
|
{
|
||||||
// peer_id also filters out connections before handshake
|
|
||||||
if (peer_id && exclude_context.m_connection_id != context.m_connection_id && context.m_remote_address.get_zone() == epee::net_utils::zone::public_)
|
if (peer_id && exclude_context.m_connection_id != context.m_connection_id && context.m_remote_address.get_zone() == epee::net_utils::zone::public_)
|
||||||
{
|
{
|
||||||
if(m_core.fluffy_blocks_enabled() && (support_flags & P2P_SUPPORT_FLAG_FLUFFY_BLOCKS))
|
if(m_core.fluffy_blocks_enabled() && (support_flags & P2P_SUPPORT_FLAG_FLUFFY_BLOCKS))
|
||||||
@@ -2699,15 +2516,15 @@ skip:
|
|||||||
// send fluffy ones first, we want to encourage people to run that
|
// send fluffy ones first, we want to encourage people to run that
|
||||||
if (!fluffyConnections.empty())
|
if (!fluffyConnections.empty())
|
||||||
{
|
{
|
||||||
epee::byte_slice fluffyBlob;
|
std::string fluffyBlob;
|
||||||
epee::serialization::store_t_to_binary(fluffy_arg, fluffyBlob, 32 * 1024);
|
epee::serialization::store_t_to_binary(fluffy_arg, fluffyBlob);
|
||||||
m_p2p->relay_notify_to_list(NOTIFY_NEW_FLUFFY_BLOCK::ID, epee::to_span(fluffyBlob), std::move(fluffyConnections));
|
m_p2p->relay_notify_to_list(NOTIFY_NEW_FLUFFY_BLOCK::ID, epee::strspan<uint8_t>(fluffyBlob), std::move(fluffyConnections));
|
||||||
}
|
}
|
||||||
if (!fullConnections.empty())
|
if (!fullConnections.empty())
|
||||||
{
|
{
|
||||||
epee::byte_slice fullBlob;
|
std::string fullBlob;
|
||||||
epee::serialization::store_t_to_binary(arg, fullBlob, 128 * 1024);
|
epee::serialization::store_t_to_binary(arg, fullBlob);
|
||||||
m_p2p->relay_notify_to_list(NOTIFY_NEW_BLOCK::ID, epee::to_span(fullBlob), std::move(fullConnections));
|
m_p2p->relay_notify_to_list(NOTIFY_NEW_BLOCK::ID, epee::strspan<uint8_t>(fullBlob), std::move(fullConnections));
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -2740,19 +2557,6 @@ skip:
|
|||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------------------------------------------
|
||||||
template<class t_core>
|
template<class t_core>
|
||||||
void t_cryptonote_protocol_handler<t_core>::hit_score(cryptonote_connection_context &context, int32_t score)
|
|
||||||
{
|
|
||||||
if (score <= 0)
|
|
||||||
{
|
|
||||||
MERROR("Negative score hit");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
context.m_score -= score;
|
|
||||||
if (context.m_score <= DROP_PEERS_ON_SCORE)
|
|
||||||
drop_connection_with_score(context, 5, false);
|
|
||||||
}
|
|
||||||
//------------------------------------------------------------------------------------------------------------------------
|
|
||||||
template<class t_core>
|
|
||||||
std::string t_cryptonote_protocol_handler<t_core>::get_peers_overview() const
|
std::string t_cryptonote_protocol_handler<t_core>::get_peers_overview() const
|
||||||
{
|
{
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
@@ -2827,28 +2631,18 @@ skip:
|
|||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------------------------------------------
|
||||||
template<class t_core>
|
template<class t_core>
|
||||||
bool t_cryptonote_protocol_handler<t_core>::is_busy_syncing()
|
|
||||||
{
|
|
||||||
const boost::unique_lock<boost::mutex> sync{m_sync_lock, boost::try_to_lock};
|
|
||||||
return !sync.owns_lock();
|
|
||||||
}
|
|
||||||
//------------------------------------------------------------------------------------------------------------------------
|
|
||||||
template<class t_core>
|
|
||||||
void t_cryptonote_protocol_handler<t_core>::drop_connection_with_score(cryptonote_connection_context &context, unsigned score, bool flush_all_spans)
|
void t_cryptonote_protocol_handler<t_core>::drop_connection_with_score(cryptonote_connection_context &context, unsigned score, bool flush_all_spans)
|
||||||
{
|
{
|
||||||
LOG_DEBUG_CC(context, "dropping connection id " << context.m_connection_id << " (pruning seed " <<
|
LOG_DEBUG_CC(context, "dropping connection id " << context.m_connection_id << " (pruning seed " <<
|
||||||
epee::string_tools::to_string_hex(context.m_pruning_seed) <<
|
epee::string_tools::to_string_hex(context.m_pruning_seed) <<
|
||||||
"), score " << score << ", flush_all_spans " << flush_all_spans);
|
"), score " << score << ", flush_all_spans " << flush_all_spans);
|
||||||
|
|
||||||
|
if (score > 0)
|
||||||
|
m_p2p->add_host_fail(context.m_remote_address, score);
|
||||||
|
|
||||||
m_block_queue.flush_spans(context.m_connection_id, flush_all_spans);
|
m_block_queue.flush_spans(context.m_connection_id, flush_all_spans);
|
||||||
|
|
||||||
// copy since dropping the connection will invalidate the context, and thus the address
|
|
||||||
const auto remote_address = context.m_remote_address;
|
|
||||||
|
|
||||||
m_p2p->drop_connection(context);
|
m_p2p->drop_connection(context);
|
||||||
|
|
||||||
if (score > 0)
|
|
||||||
m_p2p->add_host_fail(remote_address, score);
|
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------------------------------------------
|
||||||
template<class t_core>
|
template<class t_core>
|
||||||
@@ -2858,29 +2652,6 @@ skip:
|
|||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------------------------------------------
|
||||||
template<class t_core>
|
template<class t_core>
|
||||||
void t_cryptonote_protocol_handler<t_core>::drop_connections(const epee::net_utils::network_address address)
|
|
||||||
{
|
|
||||||
MWARNING("dropping connections to " << address.str());
|
|
||||||
|
|
||||||
m_p2p->add_host_fail(address, 5);
|
|
||||||
|
|
||||||
std::vector<boost::uuids::uuid> drop;
|
|
||||||
m_p2p->for_each_connection([&](const connection_context& cntxt, nodetool::peerid_type peer_id, uint32_t support_flags) {
|
|
||||||
if (address.is_same_host(cntxt.m_remote_address))
|
|
||||||
drop.push_back(cntxt.m_connection_id);
|
|
||||||
return true;
|
|
||||||
});
|
|
||||||
for (const boost::uuids::uuid &id: drop)
|
|
||||||
{
|
|
||||||
m_block_queue.flush_spans(id, true);
|
|
||||||
m_p2p->for_connection(id, [&](cryptonote_connection_context& context, nodetool::peerid_type peer_id, uint32_t f)->bool{
|
|
||||||
drop_connection(context, true, false);
|
|
||||||
return true;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//------------------------------------------------------------------------------------------------------------------------
|
|
||||||
template<class t_core>
|
|
||||||
void t_cryptonote_protocol_handler<t_core>::on_connection_close(cryptonote_connection_context &context)
|
void t_cryptonote_protocol_handler<t_core>::on_connection_close(cryptonote_connection_context &context)
|
||||||
{
|
{
|
||||||
uint64_t target = 0;
|
uint64_t target = 0;
|
||||||
|
|||||||
@@ -40,7 +40,6 @@ namespace cryptonote
|
|||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
struct i_cryptonote_protocol
|
struct i_cryptonote_protocol
|
||||||
{
|
{
|
||||||
virtual bool is_synchronized() const = 0;
|
|
||||||
virtual bool relay_block(NOTIFY_NEW_BLOCK::request& arg, cryptonote_connection_context& exclude_context)=0;
|
virtual bool relay_block(NOTIFY_NEW_BLOCK::request& arg, cryptonote_connection_context& exclude_context)=0;
|
||||||
virtual bool relay_transactions(NOTIFY_NEW_TRANSACTIONS::request& arg, const boost::uuids::uuid& source, epee::net_utils::zone zone, relay_method tx_relay)=0;
|
virtual bool relay_transactions(NOTIFY_NEW_TRANSACTIONS::request& arg, const boost::uuids::uuid& source, epee::net_utils::zone zone, relay_method tx_relay)=0;
|
||||||
//virtual bool request_objects(NOTIFY_REQUEST_GET_OBJECTS::request& arg, cryptonote_connection_context& context)=0;
|
//virtual bool request_objects(NOTIFY_REQUEST_GET_OBJECTS::request& arg, cryptonote_connection_context& context)=0;
|
||||||
@@ -51,10 +50,6 @@ namespace cryptonote
|
|||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
struct cryptonote_protocol_stub: public i_cryptonote_protocol
|
struct cryptonote_protocol_stub: public i_cryptonote_protocol
|
||||||
{
|
{
|
||||||
virtual bool is_synchronized() const final
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
virtual bool relay_block(NOTIFY_NEW_BLOCK::request& arg, cryptonote_connection_context& exclude_context)
|
virtual bool relay_block(NOTIFY_NEW_BLOCK::request& arg, cryptonote_connection_context& exclude_context)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -36,7 +36,6 @@
|
|||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
#include "byte_slice.h"
|
|
||||||
#include "common/expect.h"
|
#include "common/expect.h"
|
||||||
#include "common/varint.h"
|
#include "common/varint.h"
|
||||||
#include "cryptonote_config.h"
|
#include "cryptonote_config.h"
|
||||||
@@ -53,7 +52,7 @@
|
|||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
int get_command_from_message(const epee::byte_slice &msg)
|
int get_command_from_message(const cryptonote::blobdata &msg)
|
||||||
{
|
{
|
||||||
return msg.size() >= sizeof(epee::levin::bucket_head2) ? SWAP32LE(((epee::levin::bucket_head2*)msg.data())->m_command) : 0;
|
return msg.size() >= sizeof(epee::levin::bucket_head2) ? SWAP32LE(((epee::levin::bucket_head2*)msg.data())->m_command) : 0;
|
||||||
}
|
}
|
||||||
@@ -106,44 +105,8 @@ namespace levin
|
|||||||
return std::chrono::steady_clock::duration{crypto::rand_range(rep(0), range.count())};
|
return std::chrono::steady_clock::duration{crypto::rand_range(rep(0), range.count())};
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t get_median_remote_height(connections& p2p)
|
//! \return Outgoing connections supporting fragments in `connections` filtered by remote blockchain height.
|
||||||
{
|
std::vector<boost::uuids::uuid> get_out_connections(connections& p2p, uint64_t min_blockchain_height)
|
||||||
std::vector<uint64_t> remote_heights;
|
|
||||||
remote_heights.reserve(connection_id_reserve_size);
|
|
||||||
p2p.foreach_connection([&remote_heights] (detail::p2p_context& context) {
|
|
||||||
if (!context.m_is_income)
|
|
||||||
{
|
|
||||||
remote_heights.emplace_back(context.m_remote_blockchain_height);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
});
|
|
||||||
|
|
||||||
if (remote_heights.empty())
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
const size_t n = remote_heights.size() / 2;
|
|
||||||
std::sort(remote_heights.begin(), remote_heights.end());
|
|
||||||
if (remote_heights.size() % 2 != 0)
|
|
||||||
{
|
|
||||||
return remote_heights[n];
|
|
||||||
}
|
|
||||||
return remote_heights[n-1];
|
|
||||||
}
|
|
||||||
|
|
||||||
uint64_t get_blockchain_height(connections& p2p, const i_core_events* core)
|
|
||||||
{
|
|
||||||
const uint64_t local_blockchain_height = core->get_current_blockchain_height();
|
|
||||||
if (core->is_synchronized())
|
|
||||||
{
|
|
||||||
return local_blockchain_height;
|
|
||||||
}
|
|
||||||
return std::max(local_blockchain_height, get_median_remote_height(p2p));
|
|
||||||
}
|
|
||||||
|
|
||||||
//! \return Outgoing connections supporting fragments in `connections` filtered by blockchain height.
|
|
||||||
std::vector<boost::uuids::uuid> get_out_connections(connections& p2p, uint64_t blockchain_height)
|
|
||||||
{
|
{
|
||||||
std::vector<boost::uuids::uuid> outs;
|
std::vector<boost::uuids::uuid> outs;
|
||||||
outs.reserve(connection_id_reserve_size);
|
outs.reserve(connection_id_reserve_size);
|
||||||
@@ -152,22 +115,16 @@ namespace levin
|
|||||||
the reserve call so a strand is not used. Investigate if there is lots
|
the reserve call so a strand is not used. Investigate if there is lots
|
||||||
of waiting in here. */
|
of waiting in here. */
|
||||||
|
|
||||||
p2p.foreach_connection([&outs, blockchain_height] (detail::p2p_context& context) {
|
p2p.foreach_connection([&outs, min_blockchain_height] (detail::p2p_context& context) {
|
||||||
if (!context.m_is_income && context.m_remote_blockchain_height >= blockchain_height)
|
if (!context.m_is_income && context.m_remote_blockchain_height >= min_blockchain_height)
|
||||||
outs.emplace_back(context.m_connection_id);
|
outs.emplace_back(context.m_connection_id);
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
MDEBUG("Found " << outs.size() << " out connections having height >= " << blockchain_height);
|
|
||||||
return outs;
|
return outs;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<boost::uuids::uuid> get_out_connections(connections& p2p, const i_core_events* core)
|
std::string make_tx_payload(std::vector<blobdata>&& txs, const bool pad, const bool fluff)
|
||||||
{
|
|
||||||
return get_out_connections(p2p, get_blockchain_height(p2p, core));
|
|
||||||
}
|
|
||||||
|
|
||||||
epee::byte_slice make_tx_payload(std::vector<blobdata>&& txs, const bool pad, const bool fluff)
|
|
||||||
{
|
{
|
||||||
NOTIFY_NEW_TRANSACTIONS::request request{};
|
NOTIFY_NEW_TRANSACTIONS::request request{};
|
||||||
request.txs = std::move(txs);
|
request.txs = std::move(txs);
|
||||||
@@ -189,7 +146,7 @@ namespace levin
|
|||||||
padding -= overhead;
|
padding -= overhead;
|
||||||
request._ = std::string(padding, ' ');
|
request._ = std::string(padding, ' ');
|
||||||
|
|
||||||
epee::byte_slice arg_buff;
|
std::string arg_buff;
|
||||||
epee::serialization::store_t_to_binary(request, arg_buff);
|
epee::serialization::store_t_to_binary(request, arg_buff);
|
||||||
|
|
||||||
// we probably lowballed the payload size a bit, so added a but too much. Fix this now.
|
// we probably lowballed the payload size a bit, so added a but too much. Fix this now.
|
||||||
@@ -201,7 +158,7 @@ namespace levin
|
|||||||
// if the size of _ moved enough, we might lose byte in size encoding, we don't care
|
// if the size of _ moved enough, we might lose byte in size encoding, we don't care
|
||||||
}
|
}
|
||||||
|
|
||||||
epee::byte_slice fullBlob;
|
std::string fullBlob;
|
||||||
if (!epee::serialization::store_t_to_binary(request, fullBlob))
|
if (!epee::serialization::store_t_to_binary(request, fullBlob))
|
||||||
throw std::runtime_error{"Failed to serialize to epee binary format"};
|
throw std::runtime_error{"Failed to serialize to epee binary format"};
|
||||||
|
|
||||||
@@ -210,12 +167,12 @@ namespace levin
|
|||||||
|
|
||||||
bool make_payload_send_txs(connections& p2p, std::vector<blobdata>&& txs, const boost::uuids::uuid& destination, const bool pad, const bool fluff)
|
bool make_payload_send_txs(connections& p2p, std::vector<blobdata>&& txs, const boost::uuids::uuid& destination, const bool pad, const bool fluff)
|
||||||
{
|
{
|
||||||
const epee::byte_slice blob = make_tx_payload(std::move(txs), pad, fluff);
|
const cryptonote::blobdata blob = make_tx_payload(std::move(txs), pad, fluff);
|
||||||
p2p.for_connection(destination, [&blob](detail::p2p_context& context) {
|
p2p.for_connection(destination, [&blob](detail::p2p_context& context) {
|
||||||
on_levin_traffic(context, true, true, false, blob.size(), get_command_from_message(blob));
|
on_levin_traffic(context, true, true, false, blob.size(), get_command_from_message(blob));
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
return p2p.notify(NOTIFY_NEW_TRANSACTIONS::ID, epee::to_span(blob), destination);
|
return p2p.notify(NOTIFY_NEW_TRANSACTIONS::ID, epee::strspan<std::uint8_t>(blob), destination);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The current design uses `asio::strand`s. The documentation isn't as clear
|
/* The current design uses `asio::strand`s. The documentation isn't as clear
|
||||||
@@ -276,7 +233,7 @@ namespace levin
|
|||||||
{
|
{
|
||||||
struct zone
|
struct zone
|
||||||
{
|
{
|
||||||
explicit zone(boost::asio::io_service& io_service, std::shared_ptr<connections> p2p, epee::byte_slice noise_in, epee::net_utils::zone zone, bool pad_txs)
|
explicit zone(boost::asio::io_service& io_service, std::shared_ptr<connections> p2p, epee::byte_slice noise_in, bool is_public, bool pad_txs)
|
||||||
: p2p(std::move(p2p)),
|
: p2p(std::move(p2p)),
|
||||||
noise(std::move(noise_in)),
|
noise(std::move(noise_in)),
|
||||||
next_epoch(io_service),
|
next_epoch(io_service),
|
||||||
@@ -284,9 +241,9 @@ namespace levin
|
|||||||
strand(io_service),
|
strand(io_service),
|
||||||
map(),
|
map(),
|
||||||
channels(),
|
channels(),
|
||||||
|
flush_time(std::chrono::steady_clock::time_point::max()),
|
||||||
connection_count(0),
|
connection_count(0),
|
||||||
flush_callbacks(0),
|
is_public(is_public),
|
||||||
nzone(zone),
|
|
||||||
pad_txs(pad_txs),
|
pad_txs(pad_txs),
|
||||||
fluffing(false)
|
fluffing(false)
|
||||||
{
|
{
|
||||||
@@ -301,9 +258,9 @@ namespace levin
|
|||||||
boost::asio::io_service::strand strand;
|
boost::asio::io_service::strand strand;
|
||||||
net::dandelionpp::connection_map map;//!< Tracks outgoing uuid's for noise channels or Dandelion++ stems
|
net::dandelionpp::connection_map map;//!< Tracks outgoing uuid's for noise channels or Dandelion++ stems
|
||||||
std::deque<noise_channel> channels; //!< Never touch after init; only update elements on `noise_channel.strand`
|
std::deque<noise_channel> channels; //!< Never touch after init; only update elements on `noise_channel.strand`
|
||||||
|
std::chrono::steady_clock::time_point flush_time; //!< Next expected Dandelion++ fluff flush
|
||||||
std::atomic<std::size_t> connection_count; //!< Only update in strand, can be read at any time
|
std::atomic<std::size_t> connection_count; //!< Only update in strand, can be read at any time
|
||||||
std::uint32_t flush_callbacks; //!< Number of active fluff flush callbacks queued
|
const bool is_public; //!< Zone is public ipv4/ipv6 connections
|
||||||
const epee::net_utils::zone nzone; //!< Zone is public ipv4/ipv6 connections, or i2p or tor
|
|
||||||
const bool pad_txs; //!< Pad txs to the next boundary for privacy
|
const bool pad_txs; //!< Pad txs to the next boundary for privacy
|
||||||
bool fluffing; //!< Zone is in Dandelion++ fluff epoch
|
bool fluffing; //!< Zone is in Dandelion++ fluff epoch
|
||||||
};
|
};
|
||||||
@@ -340,8 +297,7 @@ namespace levin
|
|||||||
if (!channel.connection.is_nil())
|
if (!channel.connection.is_nil())
|
||||||
channel.queue.push_back(std::move(message_));
|
channel.queue.push_back(std::move(message_));
|
||||||
else if (destination_ == 0 && zone_->connection_count == 0)
|
else if (destination_ == 0 && zone_->connection_count == 0)
|
||||||
MWARNING("Unable to send transaction(s) to " << epee::net_utils::zone_to_string(zone_->nzone) <<
|
MWARNING("Unable to send transaction(s) over anonymity network - no available outbound connections");
|
||||||
" - no available outbound connections");
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -349,6 +305,7 @@ namespace levin
|
|||||||
struct fluff_flush
|
struct fluff_flush
|
||||||
{
|
{
|
||||||
std::shared_ptr<detail::zone> zone_;
|
std::shared_ptr<detail::zone> zone_;
|
||||||
|
std::chrono::steady_clock::time_point flush_time_;
|
||||||
|
|
||||||
static void queue(std::shared_ptr<detail::zone> zone, const std::chrono::steady_clock::time_point flush_time)
|
static void queue(std::shared_ptr<detail::zone> zone, const std::chrono::steady_clock::time_point flush_time)
|
||||||
{
|
{
|
||||||
@@ -356,21 +313,28 @@ namespace levin
|
|||||||
assert(zone->strand.running_in_this_thread());
|
assert(zone->strand.running_in_this_thread());
|
||||||
|
|
||||||
detail::zone& this_zone = *zone;
|
detail::zone& this_zone = *zone;
|
||||||
++this_zone.flush_callbacks;
|
this_zone.flush_time = flush_time;
|
||||||
this_zone.flush_txs.expires_at(flush_time);
|
this_zone.flush_txs.expires_at(flush_time);
|
||||||
this_zone.flush_txs.async_wait(this_zone.strand.wrap(fluff_flush{std::move(zone)}));
|
this_zone.flush_txs.async_wait(this_zone.strand.wrap(fluff_flush{std::move(zone), flush_time}));
|
||||||
}
|
}
|
||||||
|
|
||||||
void operator()(const boost::system::error_code error)
|
void operator()(const boost::system::error_code error)
|
||||||
{
|
{
|
||||||
if (!zone_ || !zone_->flush_callbacks || --zone_->flush_callbacks || !zone_->p2p)
|
if (!zone_ || !zone_->p2p)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
assert(zone_->strand.running_in_this_thread());
|
assert(zone_->strand.running_in_this_thread());
|
||||||
|
|
||||||
const bool timer_error = bool(error);
|
const bool timer_error = bool(error);
|
||||||
if (timer_error && error != boost::system::errc::operation_canceled)
|
if (timer_error)
|
||||||
throw boost::system::system_error{error, "fluff_flush timer failed"};
|
{
|
||||||
|
if (error != boost::system::errc::operation_canceled)
|
||||||
|
throw boost::system::system_error{error, "fluff_flush timer failed"};
|
||||||
|
|
||||||
|
// new timer canceled this one set in future
|
||||||
|
if (zone_->flush_time < flush_time_)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const auto now = std::chrono::steady_clock::now();
|
const auto now = std::chrono::steady_clock::now();
|
||||||
auto next_flush = std::chrono::steady_clock::time_point::max();
|
auto next_flush = std::chrono::steady_clock::time_point::max();
|
||||||
@@ -406,6 +370,8 @@ namespace levin
|
|||||||
|
|
||||||
if (next_flush != std::chrono::steady_clock::time_point::max())
|
if (next_flush != std::chrono::steady_clock::time_point::max())
|
||||||
fluff_flush::queue(std::move(zone_), next_flush);
|
fluff_flush::queue(std::move(zone_), next_flush);
|
||||||
|
else
|
||||||
|
zone_->flush_time = next_flush; // signal that no timer is set
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -440,11 +406,13 @@ namespace levin
|
|||||||
|
|
||||||
MDEBUG("Queueing " << txs.size() << " transaction(s) for Dandelion++ fluffing");
|
MDEBUG("Queueing " << txs.size() << " transaction(s) for Dandelion++ fluffing");
|
||||||
|
|
||||||
zone->p2p->foreach_connection([txs, now, &zone, &source, &in_duration, &out_duration, &next_flush] (detail::p2p_context& context)
|
bool available = false;
|
||||||
|
zone->p2p->foreach_connection([txs, now, &zone, &source, &in_duration, &out_duration, &next_flush, &available] (detail::p2p_context& context)
|
||||||
{
|
{
|
||||||
// When i2p/tor, only fluff to outbound connections
|
// When i2p/tor, only fluff to outbound connections
|
||||||
if (context.handshake_complete() && source != context.m_connection_id && (zone->nzone == epee::net_utils::zone::public_ || !context.m_is_income))
|
if (source != context.m_connection_id && (zone->is_public || !context.m_is_income))
|
||||||
{
|
{
|
||||||
|
available = true;
|
||||||
if (context.fluff_txs.empty())
|
if (context.fluff_txs.empty())
|
||||||
context.flush_time = now + (context.m_is_income ? in_duration() : out_duration());
|
context.flush_time = now + (context.m_is_income ? in_duration() : out_duration());
|
||||||
|
|
||||||
@@ -456,9 +424,10 @@ namespace levin
|
|||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
if (next_flush == std::chrono::steady_clock::time_point::max())
|
if (!available)
|
||||||
MWARNING("Unable to send transaction(s), no available connections");
|
MWARNING("Unable to send transaction(s), no available connections");
|
||||||
else if (!zone->flush_callbacks || next_flush < zone->flush_txs.expires_at())
|
|
||||||
|
if (next_flush < zone->flush_time)
|
||||||
fluff_flush::queue(std::move(zone), next_flush);
|
fluff_flush::queue(std::move(zone), next_flush);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -555,7 +524,12 @@ namespace levin
|
|||||||
if (!zone_ || !core_ || txs_.empty())
|
if (!zone_ || !core_ || txs_.empty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!zone_->fluffing)
|
if (zone_->fluffing)
|
||||||
|
{
|
||||||
|
core_->on_transactions_relayed(epee::to_span(txs_), relay_method::fluff);
|
||||||
|
fluff_notify::run(std::move(zone_), epee::to_span(txs_), source_);
|
||||||
|
}
|
||||||
|
else // forward tx in stem
|
||||||
{
|
{
|
||||||
core_->on_transactions_relayed(epee::to_span(txs_), relay_method::stem);
|
core_->on_transactions_relayed(epee::to_span(txs_), relay_method::stem);
|
||||||
for (int tries = 2; 0 < tries; tries--)
|
for (int tries = 2; 0 < tries; tries--)
|
||||||
@@ -570,14 +544,11 @@ namespace levin
|
|||||||
}
|
}
|
||||||
|
|
||||||
// connection list may be outdated, try again
|
// connection list may be outdated, try again
|
||||||
update_channels::run(zone_, get_out_connections(*zone_->p2p, core_));
|
update_channels::run(zone_, get_out_connections(*zone_->p2p, core_->get_target_blockchain_height()));
|
||||||
}
|
}
|
||||||
|
|
||||||
MERROR("Unable to send transaction(s) via Dandelion++ stem");
|
MERROR("Unable to send transaction(s) via Dandelion++ stem");
|
||||||
}
|
}
|
||||||
|
|
||||||
core_->on_transactions_relayed(epee::to_span(txs_), relay_method::fluff);
|
|
||||||
fluff_notify::run(std::move(zone_), epee::to_span(txs_), source_);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -606,7 +577,7 @@ namespace levin
|
|||||||
|
|
||||||
assert(zone_->strand.running_in_this_thread());
|
assert(zone_->strand.running_in_this_thread());
|
||||||
|
|
||||||
if (zone_->nzone == epee::net_utils::zone::public_)
|
if (zone_->is_public)
|
||||||
MDEBUG("Starting new Dandelion++ epoch: " << (fluffing_ ? "fluff" : "stem"));
|
MDEBUG("Starting new Dandelion++ epoch: " << (fluffing_ ? "fluff" : "stem"));
|
||||||
|
|
||||||
zone_->map = std::move(map_);
|
zone_->map = std::move(map_);
|
||||||
@@ -674,12 +645,10 @@ namespace levin
|
|||||||
{
|
{
|
||||||
channel.active = nullptr;
|
channel.active = nullptr;
|
||||||
channel.connection = boost::uuids::nil_uuid();
|
channel.connection = boost::uuids::nil_uuid();
|
||||||
auto height = get_blockchain_height(*zone_->p2p, core_);
|
|
||||||
|
|
||||||
auto connections = get_out_connections(*zone_->p2p, height);
|
auto connections = get_out_connections(*zone_->p2p, core_->get_target_blockchain_height());
|
||||||
if (connections.empty())
|
if (connections.empty())
|
||||||
MWARNING("Unable to send transaction(s) to " << epee::net_utils::zone_to_string(zone_->nzone) <<
|
MWARNING("Lost all outbound connections to anonymity network - currently unable to send transaction(s)");
|
||||||
" - no suitable outbound connections at height " << height);
|
|
||||||
|
|
||||||
zone_->strand.post(update_channels{zone_, std::move(connections)});
|
zone_->strand.post(update_channels{zone_, std::move(connections)});
|
||||||
}
|
}
|
||||||
@@ -710,7 +679,7 @@ namespace levin
|
|||||||
|
|
||||||
const bool fluffing = crypto::rand_idx(unsigned(100)) < CRYPTONOTE_DANDELIONPP_FLUFF_PROBABILITY;
|
const bool fluffing = crypto::rand_idx(unsigned(100)) < CRYPTONOTE_DANDELIONPP_FLUFF_PROBABILITY;
|
||||||
const auto start = std::chrono::steady_clock::now();
|
const auto start = std::chrono::steady_clock::now();
|
||||||
auto connections = get_out_connections(*(zone_->p2p), core_);
|
auto connections = get_out_connections(*(zone_->p2p), core_->get_target_blockchain_height());
|
||||||
zone_->strand.dispatch(
|
zone_->strand.dispatch(
|
||||||
change_channels{zone_, net::dandelionpp::connection_map{std::move(connections), count_}, fluffing}
|
change_channels{zone_, net::dandelionpp::connection_map{std::move(connections), count_}, fluffing}
|
||||||
);
|
);
|
||||||
@@ -722,15 +691,15 @@ namespace levin
|
|||||||
};
|
};
|
||||||
} // anonymous
|
} // anonymous
|
||||||
|
|
||||||
notify::notify(boost::asio::io_service& service, std::shared_ptr<connections> p2p, epee::byte_slice noise, epee::net_utils::zone zone, const bool pad_txs, i_core_events& core)
|
notify::notify(boost::asio::io_service& service, std::shared_ptr<connections> p2p, epee::byte_slice noise, const bool is_public, const bool pad_txs, i_core_events& core)
|
||||||
: zone_(std::make_shared<detail::zone>(service, std::move(p2p), std::move(noise), zone, pad_txs))
|
: zone_(std::make_shared<detail::zone>(service, std::move(p2p), std::move(noise), is_public, pad_txs))
|
||||||
, core_(std::addressof(core))
|
, core_(std::addressof(core))
|
||||||
{
|
{
|
||||||
if (!zone_->p2p)
|
if (!zone_->p2p)
|
||||||
throw std::logic_error{"cryptonote::levin::notify cannot have nullptr p2p argument"};
|
throw std::logic_error{"cryptonote::levin::notify cannot have nullptr p2p argument"};
|
||||||
|
|
||||||
const bool noise_enabled = !zone_->noise.empty();
|
const bool noise_enabled = !zone_->noise.empty();
|
||||||
if (noise_enabled || zone == epee::net_utils::zone::public_)
|
if (noise_enabled || is_public)
|
||||||
{
|
{
|
||||||
const auto now = std::chrono::steady_clock::now();
|
const auto now = std::chrono::steady_clock::now();
|
||||||
const auto min_epoch = noise_enabled ? noise_min_epoch : dandelionpp_min_epoch;
|
const auto min_epoch = noise_enabled ? noise_min_epoch : dandelionpp_min_epoch;
|
||||||
@@ -761,7 +730,7 @@ namespace levin
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
zone_->strand.dispatch(
|
zone_->strand.dispatch(
|
||||||
update_channels{zone_, get_out_connections(*(zone_->p2p), core_)}
|
update_channels{zone_, get_out_connections(*(zone_->p2p), core_->get_target_blockchain_height())}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -824,9 +793,9 @@ namespace levin
|
|||||||
|
|
||||||
// Padding is not useful when using noise mode. Send as stem so receiver
|
// Padding is not useful when using noise mode. Send as stem so receiver
|
||||||
// forwards in Dandelion++ mode.
|
// forwards in Dandelion++ mode.
|
||||||
const epee::byte_slice payload = make_tx_payload(std::move(txs), false, false);
|
const std::string payload = make_tx_payload(std::move(txs), false, false);
|
||||||
epee::byte_slice message = epee::levin::make_fragmented_notify(
|
epee::byte_slice message = epee::levin::make_fragmented_notify(
|
||||||
zone_->noise, NOTIFY_NEW_TRANSACTIONS::ID, epee::to_span(payload)
|
zone_->noise, NOTIFY_NEW_TRANSACTIONS::ID, epee::strspan<std::uint8_t>(payload)
|
||||||
);
|
);
|
||||||
if (CRYPTONOTE_MAX_FRAGMENTS * zone_->noise.size() < message.size())
|
if (CRYPTONOTE_MAX_FRAGMENTS * zone_->noise.size() < message.size())
|
||||||
{
|
{
|
||||||
@@ -852,7 +821,7 @@ namespace levin
|
|||||||
case relay_method::stem:
|
case relay_method::stem:
|
||||||
case relay_method::forward:
|
case relay_method::forward:
|
||||||
case relay_method::local:
|
case relay_method::local:
|
||||||
if (zone_->nzone == epee::net_utils::zone::public_)
|
if (zone_->is_public)
|
||||||
{
|
{
|
||||||
// this will change a local/forward tx to stem or fluff ...
|
// this will change a local/forward tx to stem or fluff ...
|
||||||
zone_->strand.dispatch(
|
zone_->strand.dispatch(
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ namespace levin
|
|||||||
{}
|
{}
|
||||||
|
|
||||||
//! Construct an instance with available notification `zones`.
|
//! Construct an instance with available notification `zones`.
|
||||||
explicit notify(boost::asio::io_service& service, std::shared_ptr<connections> p2p, epee::byte_slice noise, epee::net_utils::zone zone, bool pad_txs, i_core_events& core);
|
explicit notify(boost::asio::io_service& service, std::shared_ptr<connections> p2p, epee::byte_slice noise, bool is_public, bool pad_txs, i_core_events& core);
|
||||||
|
|
||||||
notify(const notify&) = delete;
|
notify(const notify&) = delete;
|
||||||
notify(notify&&) = default;
|
notify(notify&&) = default;
|
||||||
|
|||||||
@@ -28,7 +28,6 @@
|
|||||||
|
|
||||||
#include "common/dns_utils.h"
|
#include "common/dns_utils.h"
|
||||||
#include "common/command_line.h"
|
#include "common/command_line.h"
|
||||||
#include "net/parse.h"
|
|
||||||
#include "daemon/command_parser_executor.h"
|
#include "daemon/command_parser_executor.h"
|
||||||
|
|
||||||
#undef MONERO_DEFAULT_LOG_CATEGORY
|
#undef MONERO_DEFAULT_LOG_CATEGORY
|
||||||
@@ -51,7 +50,7 @@ bool t_command_parser_executor::print_peer_list(const std::vector<std::string>&
|
|||||||
{
|
{
|
||||||
if (args.size() > 3)
|
if (args.size() > 3)
|
||||||
{
|
{
|
||||||
std::cout << "Invalid syntax: Too many parameters. For more details, use the help command." << std::endl;
|
std::cout << "use: print_pl [white] [gray] [<limit>] [pruned] [publicrpc]" << std::endl;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -80,7 +79,7 @@ bool t_command_parser_executor::print_peer_list(const std::vector<std::string>&
|
|||||||
}
|
}
|
||||||
else if (!epee::string_tools::get_xtype_from_string(limit, args[i]))
|
else if (!epee::string_tools::get_xtype_from_string(limit, args[i]))
|
||||||
{
|
{
|
||||||
std::cout << "Invalid syntax: Unexpected parameter: " << args[i] << ". For more details, use the help command." << std::endl;
|
std::cout << "unexpected argument: " << args[i] << std::endl;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -91,79 +90,56 @@ bool t_command_parser_executor::print_peer_list(const std::vector<std::string>&
|
|||||||
|
|
||||||
bool t_command_parser_executor::print_peer_list_stats(const std::vector<std::string>& args)
|
bool t_command_parser_executor::print_peer_list_stats(const std::vector<std::string>& args)
|
||||||
{
|
{
|
||||||
if (!args.empty()) {
|
if (!args.empty()) return false;
|
||||||
std::cout << "Invalid syntax: No parameters expected. For more details, use the help command." << std::endl;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return m_executor.print_peer_list_stats();
|
return m_executor.print_peer_list_stats();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool t_command_parser_executor::save_blockchain(const std::vector<std::string>& args)
|
bool t_command_parser_executor::save_blockchain(const std::vector<std::string>& args)
|
||||||
{
|
{
|
||||||
if (!args.empty()) {
|
if (!args.empty()) return false;
|
||||||
std::cout << "Invalid syntax: No parameters expected. For more details, use the help command." << std::endl;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return m_executor.save_blockchain();
|
return m_executor.save_blockchain();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool t_command_parser_executor::show_hash_rate(const std::vector<std::string>& args)
|
bool t_command_parser_executor::show_hash_rate(const std::vector<std::string>& args)
|
||||||
{
|
{
|
||||||
if (!args.empty()) {
|
if (!args.empty()) return false;
|
||||||
std::cout << "Invalid syntax: No parameters expected. For more details, use the help command." << std::endl;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return m_executor.show_hash_rate();
|
return m_executor.show_hash_rate();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool t_command_parser_executor::hide_hash_rate(const std::vector<std::string>& args)
|
bool t_command_parser_executor::hide_hash_rate(const std::vector<std::string>& args)
|
||||||
{
|
{
|
||||||
if (!args.empty()) {
|
if (!args.empty()) return false;
|
||||||
std::cout << "Invalid syntax: No parameters expected. For more details, use the help command." << std::endl;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return m_executor.hide_hash_rate();
|
return m_executor.hide_hash_rate();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool t_command_parser_executor::show_difficulty(const std::vector<std::string>& args)
|
bool t_command_parser_executor::show_difficulty(const std::vector<std::string>& args)
|
||||||
{
|
{
|
||||||
if (!args.empty()) {
|
if (!args.empty()) return false;
|
||||||
std::cout << "Invalid syntax: No parameters expected. For more details, use the help command." << std::endl;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return m_executor.show_difficulty();
|
return m_executor.show_difficulty();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool t_command_parser_executor::show_status(const std::vector<std::string>& args)
|
bool t_command_parser_executor::show_status(const std::vector<std::string>& args)
|
||||||
{
|
{
|
||||||
if (!args.empty()) {
|
if (!args.empty()) return false;
|
||||||
std::cout << "Invalid syntax: No parameters expected. For more details, use the help command." << std::endl;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return m_executor.show_status();
|
return m_executor.show_status();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool t_command_parser_executor::print_connections(const std::vector<std::string>& args)
|
bool t_command_parser_executor::print_connections(const std::vector<std::string>& args)
|
||||||
{
|
{
|
||||||
if (!args.empty()) {
|
if (!args.empty()) return false;
|
||||||
std::cout << "Invalid syntax: No parameters expected. For more details, use the help command." << std::endl;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return m_executor.print_connections();
|
return m_executor.print_connections();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool t_command_parser_executor::print_net_stats(const std::vector<std::string>& args)
|
bool t_command_parser_executor::print_net_stats(const std::vector<std::string>& args)
|
||||||
{
|
{
|
||||||
if (!args.empty()) {
|
if (!args.empty()) return false;
|
||||||
std::cout << "Invalid syntax: No parameters expected. For more details, use the help command." << std::endl;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return m_executor.print_net_stats();
|
return m_executor.print_net_stats();
|
||||||
}
|
}
|
||||||
@@ -172,8 +148,8 @@ bool t_command_parser_executor::print_blockchain_info(const std::vector<std::str
|
|||||||
{
|
{
|
||||||
if(!args.size())
|
if(!args.size())
|
||||||
{
|
{
|
||||||
std::cout << "Invalid syntax: At least one parameter expected. For more details, use the help command." << std::endl;
|
std::cout << "need block index parameter" << std::endl;
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
uint64_t start_index = 0;
|
uint64_t start_index = 0;
|
||||||
uint64_t end_index = 0;
|
uint64_t end_index = 0;
|
||||||
@@ -182,20 +158,20 @@ bool t_command_parser_executor::print_blockchain_info(const std::vector<std::str
|
|||||||
int64_t nblocks;
|
int64_t nblocks;
|
||||||
if(!epee::string_tools::get_xtype_from_string(nblocks, args[0]))
|
if(!epee::string_tools::get_xtype_from_string(nblocks, args[0]))
|
||||||
{
|
{
|
||||||
std::cout << "Invalid syntax: Wrong number of blocks. For more details, use the help command." << std::endl;
|
std::cout << "wrong number of blocks" << std::endl;
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
return m_executor.print_blockchain_info(nblocks, (uint64_t)-nblocks);
|
return m_executor.print_blockchain_info(nblocks, (uint64_t)-nblocks);
|
||||||
}
|
}
|
||||||
if(!epee::string_tools::get_xtype_from_string(start_index, args[0]))
|
if(!epee::string_tools::get_xtype_from_string(start_index, args[0]))
|
||||||
{
|
{
|
||||||
std::cout << "Invalid syntax: Wrong starter block index parameter. For more details, use the help command." << std::endl;
|
std::cout << "wrong starter block index parameter" << std::endl;
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
if(args.size() >1 && !epee::string_tools::get_xtype_from_string(end_index, args[1]))
|
if(args.size() >1 && !epee::string_tools::get_xtype_from_string(end_index, args[1]))
|
||||||
{
|
{
|
||||||
std::cout << "Invalid syntax: Wrong end block index parameter. For more details, use the help command." << std::endl;
|
std::cout << "wrong end block index parameter" << std::endl;
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return m_executor.print_blockchain_info(start_index, end_index);
|
return m_executor.print_blockchain_info(start_index, end_index);
|
||||||
@@ -205,7 +181,7 @@ bool t_command_parser_executor::set_log_level(const std::vector<std::string>& ar
|
|||||||
{
|
{
|
||||||
if(args.size() > 1)
|
if(args.size() > 1)
|
||||||
{
|
{
|
||||||
std::cout << "Invalid syntax: Too many parameters. For more details, use the help command." << std::endl;
|
std::cout << "use: set_log [<log_level_number_0-4> | <categories>]" << std::endl;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -219,7 +195,7 @@ bool t_command_parser_executor::set_log_level(const std::vector<std::string>& ar
|
|||||||
{
|
{
|
||||||
if(4 < l)
|
if(4 < l)
|
||||||
{
|
{
|
||||||
std::cout << "Invalid syntax: Wrong number range, use: set_log <log_level_number_0-4>. For more details, use the help command." << std::endl;
|
std::cout << "wrong number range, use: set_log <log_level_number_0-4>" << std::endl;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return m_executor.set_log_level(l);
|
return m_executor.set_log_level(l);
|
||||||
@@ -232,10 +208,7 @@ bool t_command_parser_executor::set_log_level(const std::vector<std::string>& ar
|
|||||||
|
|
||||||
bool t_command_parser_executor::print_height(const std::vector<std::string>& args)
|
bool t_command_parser_executor::print_height(const std::vector<std::string>& args)
|
||||||
{
|
{
|
||||||
if (!args.empty()) {
|
if (!args.empty()) return false;
|
||||||
std::cout << "Invalid syntax: No parameters expected. For more details, use the help command." << std::endl;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return m_executor.print_height();
|
return m_executor.print_height();
|
||||||
}
|
}
|
||||||
@@ -250,14 +223,14 @@ bool t_command_parser_executor::print_block(const std::vector<std::string>& args
|
|||||||
include_hex = true;
|
include_hex = true;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::cout << "Invalid syntax: Unexpected parameter: " << args[i] << ". For more details, use the help command." << std::endl;
|
std::cout << "unexpected argument: " << args[i] << std::endl;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (args.empty())
|
if (args.empty())
|
||||||
{
|
{
|
||||||
std::cout << "Invalid syntax: At least one parameter expected. For more details, use the help command." << std::endl;
|
std::cout << "expected: print_block (<block_hash> | <block_height>) [+hex]" << std::endl;
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string& arg = args.front();
|
const std::string& arg = args.front();
|
||||||
@@ -275,7 +248,7 @@ bool t_command_parser_executor::print_block(const std::vector<std::string>& args
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool t_command_parser_executor::print_transaction(const std::vector<std::string>& args)
|
bool t_command_parser_executor::print_transaction(const std::vector<std::string>& args)
|
||||||
@@ -294,13 +267,13 @@ bool t_command_parser_executor::print_transaction(const std::vector<std::string>
|
|||||||
include_json = true;
|
include_json = true;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::cout << "Invalid syntax: Unexpected parameter: " << args[i] << ". For more details, use the help command." << std::endl;
|
std::cout << "unexpected argument: " << args[i] << std::endl;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (args.empty())
|
if (args.empty())
|
||||||
{
|
{
|
||||||
std::cout << "Invalid syntax: At least one parameter expected. For more details, use the help command." << std::endl;
|
std::cout << "expected: print_tx <transaction_hash> [+meta] [+hex] [+json]" << std::endl;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -318,7 +291,7 @@ bool t_command_parser_executor::is_key_image_spent(const std::vector<std::string
|
|||||||
{
|
{
|
||||||
if (args.empty())
|
if (args.empty())
|
||||||
{
|
{
|
||||||
std::cout << "Invalid syntax: At least one parameter expected. For more details, use the help command." << std::endl;
|
std::cout << "expected: is_key_image_spent <key_image>" << std::endl;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -336,30 +309,21 @@ bool t_command_parser_executor::is_key_image_spent(const std::vector<std::string
|
|||||||
|
|
||||||
bool t_command_parser_executor::print_transaction_pool_long(const std::vector<std::string>& args)
|
bool t_command_parser_executor::print_transaction_pool_long(const std::vector<std::string>& args)
|
||||||
{
|
{
|
||||||
if (!args.empty()) {
|
if (!args.empty()) return false;
|
||||||
std::cout << "Invalid syntax: No parameters expected. For more details, use the help command." << std::endl;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return m_executor.print_transaction_pool_long();
|
return m_executor.print_transaction_pool_long();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool t_command_parser_executor::print_transaction_pool_short(const std::vector<std::string>& args)
|
bool t_command_parser_executor::print_transaction_pool_short(const std::vector<std::string>& args)
|
||||||
{
|
{
|
||||||
if (!args.empty()) {
|
if (!args.empty()) return false;
|
||||||
std::cout << "Invalid syntax: No parameters expected. For more details, use the help command." << std::endl;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return m_executor.print_transaction_pool_short();
|
return m_executor.print_transaction_pool_short();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool t_command_parser_executor::print_transaction_pool_stats(const std::vector<std::string>& args)
|
bool t_command_parser_executor::print_transaction_pool_stats(const std::vector<std::string>& args)
|
||||||
{
|
{
|
||||||
if (!args.empty()) {
|
if (!args.empty()) return false;
|
||||||
std::cout << "Invalid syntax: No parameters expected. For more details, use the help command." << std::endl;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return m_executor.print_transaction_pool_stats();
|
return m_executor.print_transaction_pool_stats();
|
||||||
}
|
}
|
||||||
@@ -368,7 +332,7 @@ bool t_command_parser_executor::start_mining(const std::vector<std::string>& arg
|
|||||||
{
|
{
|
||||||
if(!args.size())
|
if(!args.size())
|
||||||
{
|
{
|
||||||
std::cout << "Invalid syntax: At least one parameter expected. For more details, use the help command." << std::endl;
|
std::cout << "Please specify a wallet address to mine for: start_mining <addr> [<threads>|auto]" << std::endl;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -389,7 +353,7 @@ bool t_command_parser_executor::start_mining(const std::vector<std::string>& arg
|
|||||||
{
|
{
|
||||||
if(!cryptonote::get_account_address_from_str(info, cryptonote::STAGENET, address_str))
|
if(!cryptonote::get_account_address_from_str(info, cryptonote::STAGENET, address_str))
|
||||||
{
|
{
|
||||||
std::cout << "Invalid syntax: Target account address has wrong format. For more details, use the help command." << std::endl;
|
std::cout << "target account address has wrong format" << std::endl;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -425,10 +389,9 @@ bool t_command_parser_executor::start_mining(const std::vector<std::string>& arg
|
|||||||
bool ignore_battery = false;
|
bool ignore_battery = false;
|
||||||
if(args.size() > 4)
|
if(args.size() > 4)
|
||||||
{
|
{
|
||||||
std::cout << "Invalid syntax: Too many parameters. For more details, use the help command." << std::endl;
|
return false;
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(args.size() == 4)
|
if(args.size() == 4)
|
||||||
{
|
{
|
||||||
if(args[3] == "true" || command_line::is_yes(args[3]) || args[3] == "1")
|
if(args[3] == "true" || command_line::is_yes(args[3]) || args[3] == "1")
|
||||||
@@ -437,11 +400,10 @@ bool t_command_parser_executor::start_mining(const std::vector<std::string>& arg
|
|||||||
}
|
}
|
||||||
else if(args[3] != "false" && !command_line::is_no(args[3]) && args[3] != "0")
|
else if(args[3] != "false" && !command_line::is_no(args[3]) && args[3] != "0")
|
||||||
{
|
{
|
||||||
std::cout << "Invalid syntax: Invalid combination of parameters. For more details, use the help command." << std::endl;
|
return false;
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(args.size() >= 3)
|
if(args.size() >= 3)
|
||||||
{
|
{
|
||||||
if(args[2] == "true" || command_line::is_yes(args[2]) || args[2] == "1")
|
if(args[2] == "true" || command_line::is_yes(args[2]) || args[2] == "1")
|
||||||
@@ -450,11 +412,10 @@ bool t_command_parser_executor::start_mining(const std::vector<std::string>& arg
|
|||||||
}
|
}
|
||||||
else if(args[2] != "false" && !command_line::is_no(args[2]) && args[2] != "0")
|
else if(args[2] != "false" && !command_line::is_no(args[2]) && args[2] != "0")
|
||||||
{
|
{
|
||||||
std::cout << "Invalid syntax: Invalid combination of parameters. For more details, use the help command." << std::endl;
|
return false;
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(args.size() >= 2)
|
if(args.size() >= 2)
|
||||||
{
|
{
|
||||||
if (args[1] == "auto" || args[1] == "autodetect")
|
if (args[1] == "auto" || args[1] == "autodetect")
|
||||||
@@ -475,10 +436,7 @@ bool t_command_parser_executor::start_mining(const std::vector<std::string>& arg
|
|||||||
|
|
||||||
bool t_command_parser_executor::stop_mining(const std::vector<std::string>& args)
|
bool t_command_parser_executor::stop_mining(const std::vector<std::string>& args)
|
||||||
{
|
{
|
||||||
if (!args.empty()) {
|
if (!args.empty()) return false;
|
||||||
std::cout << "Invalid syntax: No parameters expected. For more details, use the help command." << std::endl;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return m_executor.stop_mining();
|
return m_executor.stop_mining();
|
||||||
}
|
}
|
||||||
@@ -490,31 +448,21 @@ bool t_command_parser_executor::mining_status(const std::vector<std::string>& ar
|
|||||||
|
|
||||||
bool t_command_parser_executor::stop_daemon(const std::vector<std::string>& args)
|
bool t_command_parser_executor::stop_daemon(const std::vector<std::string>& args)
|
||||||
{
|
{
|
||||||
if (!args.empty()) {
|
if (!args.empty()) return false;
|
||||||
std::cout << "Invalid syntax: No parameters expected. For more details, use the help command." << std::endl;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return m_executor.stop_daemon();
|
return m_executor.stop_daemon();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool t_command_parser_executor::print_status(const std::vector<std::string>& args)
|
bool t_command_parser_executor::print_status(const std::vector<std::string>& args)
|
||||||
{
|
{
|
||||||
if (!args.empty()) {
|
if (!args.empty()) return false;
|
||||||
std::cout << "Invalid syntax: No parameters expected. For more details, use the help command." << std::endl;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return m_executor.print_status();
|
return m_executor.print_status();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool t_command_parser_executor::set_limit(const std::vector<std::string>& args)
|
bool t_command_parser_executor::set_limit(const std::vector<std::string>& args)
|
||||||
{
|
{
|
||||||
if(args.size()>1) {
|
if(args.size()>1) return false;
|
||||||
std::cout << "Invalid syntax: Too many parameters. For more details, use the help command." << std::endl;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(args.size()==0) {
|
if(args.size()==0) {
|
||||||
return m_executor.get_limit();
|
return m_executor.get_limit();
|
||||||
}
|
}
|
||||||
@@ -523,8 +471,8 @@ bool t_command_parser_executor::set_limit(const std::vector<std::string>& args)
|
|||||||
limit = std::stoll(args[0]);
|
limit = std::stoll(args[0]);
|
||||||
}
|
}
|
||||||
catch(const std::exception& ex) {
|
catch(const std::exception& ex) {
|
||||||
std::cout << "Invalid syntax: Failed to parse limit. For more details, use the help command." << std::endl;
|
std::cout << "failed to parse argument" << std::endl;
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return m_executor.set_limit(limit, limit);
|
return m_executor.set_limit(limit, limit);
|
||||||
@@ -532,11 +480,7 @@ bool t_command_parser_executor::set_limit(const std::vector<std::string>& args)
|
|||||||
|
|
||||||
bool t_command_parser_executor::set_limit_up(const std::vector<std::string>& args)
|
bool t_command_parser_executor::set_limit_up(const std::vector<std::string>& args)
|
||||||
{
|
{
|
||||||
if(args.size()>1) {
|
if(args.size()>1) return false;
|
||||||
std::cout << "Invalid syntax: Too many parameters. For more details, use the help command." << std::endl;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(args.size()==0) {
|
if(args.size()==0) {
|
||||||
return m_executor.get_limit_up();
|
return m_executor.get_limit_up();
|
||||||
}
|
}
|
||||||
@@ -545,8 +489,8 @@ bool t_command_parser_executor::set_limit_up(const std::vector<std::string>& arg
|
|||||||
limit = std::stoll(args[0]);
|
limit = std::stoll(args[0]);
|
||||||
}
|
}
|
||||||
catch(const std::exception& ex) {
|
catch(const std::exception& ex) {
|
||||||
std::cout << "Invalid syntax: Failed to parse limit. For more details, use the help command." << std::endl;
|
std::cout << "failed to parse argument" << std::endl;
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return m_executor.set_limit(0, limit);
|
return m_executor.set_limit(0, limit);
|
||||||
@@ -554,11 +498,7 @@ bool t_command_parser_executor::set_limit_up(const std::vector<std::string>& arg
|
|||||||
|
|
||||||
bool t_command_parser_executor::set_limit_down(const std::vector<std::string>& args)
|
bool t_command_parser_executor::set_limit_down(const std::vector<std::string>& args)
|
||||||
{
|
{
|
||||||
if(args.size()>1) {
|
if(args.size()>1) return false;
|
||||||
std::cout << "Invalid syntax: Too many parameters. For more details, use the help command." << std::endl;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(args.size()==0) {
|
if(args.size()==0) {
|
||||||
return m_executor.get_limit_down();
|
return m_executor.get_limit_down();
|
||||||
}
|
}
|
||||||
@@ -567,8 +507,8 @@ bool t_command_parser_executor::set_limit_down(const std::vector<std::string>& a
|
|||||||
limit = std::stoll(args[0]);
|
limit = std::stoll(args[0]);
|
||||||
}
|
}
|
||||||
catch(const std::exception& ex) {
|
catch(const std::exception& ex) {
|
||||||
std::cout << "Invalid syntax: Failed to parse limit. For more details, use the help command." << std::endl;
|
std::cout << "failed to parse argument" << std::endl;
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return m_executor.set_limit(limit, 0);
|
return m_executor.set_limit(limit, 0);
|
||||||
@@ -585,13 +525,12 @@ bool t_command_parser_executor::out_peers(const std::vector<std::string>& args)
|
|||||||
set = true;
|
set = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
catch(const std::exception& ex) {
|
catch(const std::exception& ex) {
|
||||||
_erro("stoi exception");
|
_erro("stoi exception");
|
||||||
std::cout << "Invalid syntax: Failed to parse number. For more details, use the help command." << std::endl;
|
return false;
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return m_executor.out_peers(set, limit);
|
return m_executor.out_peers(set, limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -609,8 +548,7 @@ bool t_command_parser_executor::in_peers(const std::vector<std::string>& args)
|
|||||||
|
|
||||||
catch(const std::exception& ex) {
|
catch(const std::exception& ex) {
|
||||||
_erro("stoi exception");
|
_erro("stoi exception");
|
||||||
std::cout << "Invalid syntax: Failed to parse number." << std::endl;
|
return false;
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return m_executor.in_peers(set, limit);
|
return m_executor.in_peers(set, limit);
|
||||||
@@ -627,37 +565,27 @@ bool t_command_parser_executor::hard_fork_info(const std::vector<std::string>& a
|
|||||||
version = std::stoi(args[0]);
|
version = std::stoi(args[0]);
|
||||||
}
|
}
|
||||||
catch(const std::exception& ex) {
|
catch(const std::exception& ex) {
|
||||||
std::cout << "Invalid syntax: Failed to parse version number. For more details, use the help command." << std::endl;
|
return false;
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (version <= 0 || version > 255) {
|
|
||||||
std::cout << "Invalid syntax: Unknown version number. Must be between 0 and 255. For more details, use the help command." << std::endl;
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
if (version <= 0 || version > 255)
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
std::cout << "Invalid syntax: Too many parameters. For more details, use the help command." << std::endl;
|
return false;
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
return m_executor.hard_fork_info(version);
|
return m_executor.hard_fork_info(version);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool t_command_parser_executor::show_bans(const std::vector<std::string>& args)
|
bool t_command_parser_executor::show_bans(const std::vector<std::string>& args)
|
||||||
{
|
{
|
||||||
if (!args.empty()) {
|
if (!args.empty()) return false;
|
||||||
std::cout << "Invalid syntax: No parameters expected. For more details, use the help command." << std::endl;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return m_executor.print_bans();
|
return m_executor.print_bans();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool t_command_parser_executor::ban(const std::vector<std::string>& args)
|
bool t_command_parser_executor::ban(const std::vector<std::string>& args)
|
||||||
{
|
{
|
||||||
if (args.size() != 1 && args.size() != 2) {
|
if (args.size() != 1 && args.size() != 2) return false;
|
||||||
std::cout << "Invalid syntax: Expects one or two parameters. For more details, use the help command." << std::endl;
|
std::string ip = args[0];
|
||||||
return true;
|
|
||||||
}
|
|
||||||
time_t seconds = P2P_IP_BLOCKTIME;
|
time_t seconds = P2P_IP_BLOCKTIME;
|
||||||
if (args.size() > 1)
|
if (args.size() > 1)
|
||||||
{
|
{
|
||||||
@@ -667,89 +595,33 @@ bool t_command_parser_executor::ban(const std::vector<std::string>& args)
|
|||||||
}
|
}
|
||||||
catch (const std::exception &e)
|
catch (const std::exception &e)
|
||||||
{
|
{
|
||||||
std::cout << "Invalid syntax: Failed to parse seconds. For more details, use the help command." << std::endl;
|
return false;
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
if (seconds == 0)
|
if (seconds == 0)
|
||||||
{
|
{
|
||||||
std::cout << "Seconds must be greater than 0." << std::endl;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (boost::starts_with(args[0], "@"))
|
|
||||||
{
|
|
||||||
const std::string ban_list = args[0].substr(1);
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
const boost::filesystem::path ban_list_path(ban_list);
|
|
||||||
boost::system::error_code ec;
|
|
||||||
if (!boost::filesystem::exists(ban_list_path, ec))
|
|
||||||
{
|
|
||||||
std::cout << "Can't find ban list file " + ban_list + " - " + ec.message() << std::endl;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ret = true;
|
|
||||||
std::ifstream ifs(ban_list_path.string());
|
|
||||||
for (std::string line; std::getline(ifs, line); )
|
|
||||||
{
|
|
||||||
auto subnet = net::get_ipv4_subnet_address(line);
|
|
||||||
if (subnet)
|
|
||||||
{
|
|
||||||
ret &= m_executor.ban(subnet->str(), seconds);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
const expect<epee::net_utils::network_address> parsed_addr = net::get_network_address(line, 0);
|
|
||||||
if (parsed_addr)
|
|
||||||
{
|
|
||||||
ret &= m_executor.ban(parsed_addr->host_str(), seconds);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
std::cout << "Invalid IP address or IPv4 subnet: " << line << std::endl;
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
catch (const std::exception &e)
|
|
||||||
{
|
|
||||||
std::cout << "Error loading ban list: " << e.what() << std::endl;
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
return m_executor.ban(ip, seconds);
|
||||||
{
|
|
||||||
const std::string ip = args[0];
|
|
||||||
return m_executor.ban(ip, seconds);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool t_command_parser_executor::unban(const std::vector<std::string>& args)
|
bool t_command_parser_executor::unban(const std::vector<std::string>& args)
|
||||||
{
|
{
|
||||||
if (args.size() != 1) {
|
if (args.size() != 1) return false;
|
||||||
std::cout << "Invalid syntax: One parameter expected. For more details, use the help command." << std::endl;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string ip = args[0];
|
std::string ip = args[0];
|
||||||
return m_executor.unban(ip);
|
return m_executor.unban(ip);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool t_command_parser_executor::banned(const std::vector<std::string>& args)
|
bool t_command_parser_executor::banned(const std::vector<std::string>& args)
|
||||||
{
|
{
|
||||||
if (args.size() != 1) {
|
if (args.size() != 1) return false;
|
||||||
std::cout << "Invalid syntax: One parameter expected. For more details, use the help command." << std::endl;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
std::string address = args[0];
|
std::string address = args[0];
|
||||||
return m_executor.banned(address);
|
return m_executor.banned(address);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool t_command_parser_executor::flush_txpool(const std::vector<std::string>& args)
|
bool t_command_parser_executor::flush_txpool(const std::vector<std::string>& args)
|
||||||
{
|
{
|
||||||
if (args.size() > 1) {
|
if (args.size() > 1) return false;
|
||||||
std::cout << "Invalid syntax: Too many parameters. For more details, use the help command." << std::endl;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string txid;
|
std::string txid;
|
||||||
if (args.size() == 1)
|
if (args.size() == 1)
|
||||||
@@ -757,7 +629,7 @@ bool t_command_parser_executor::flush_txpool(const std::vector<std::string>& arg
|
|||||||
crypto::hash hash;
|
crypto::hash hash;
|
||||||
if (!parse_hash256(args[0], hash))
|
if (!parse_hash256(args[0], hash))
|
||||||
{
|
{
|
||||||
std::cout << "Invalid syntax: Failed to parse tx id. For more details, use the help command." << std::endl;
|
std::cout << "failed to parse tx id" << std::endl;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
txid = args[0];
|
txid = args[0];
|
||||||
@@ -790,7 +662,7 @@ bool t_command_parser_executor::output_histogram(const std::vector<std::string>&
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::cout << "Invalid syntax: More than two non-amount parameters. For more details, use the help command." << std::endl;
|
std::cout << "Invalid syntax: more than two non-amount parameters" << std::endl;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -801,21 +673,20 @@ bool t_command_parser_executor::print_coinbase_tx_sum(const std::vector<std::str
|
|||||||
{
|
{
|
||||||
if(!args.size())
|
if(!args.size())
|
||||||
{
|
{
|
||||||
std::cout << "Invalid syntax: At least one parameter expected. For more details, use the help command." << std::endl;
|
std::cout << "need block height parameter" << std::endl;
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t height = 0;
|
uint64_t height = 0;
|
||||||
uint64_t count = 0;
|
uint64_t count = 0;
|
||||||
if(!epee::string_tools::get_xtype_from_string(height, args[0]))
|
if(!epee::string_tools::get_xtype_from_string(height, args[0]))
|
||||||
{
|
{
|
||||||
std::cout << "Invalid syntax: Wrong starter block height parameter. For more details, use the help command." << std::endl;
|
std::cout << "wrong starter block height parameter" << std::endl;
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
if(args.size() >1 && !epee::string_tools::get_xtype_from_string(count, args[1]))
|
if(args.size() >1 && !epee::string_tools::get_xtype_from_string(count, args[1]))
|
||||||
{
|
{
|
||||||
std::cout << "wrong count parameter" << std::endl;
|
std::cout << "wrong count parameter" << std::endl;
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return m_executor.print_coinbase_tx_sum(height, count);
|
return m_executor.print_coinbase_tx_sum(height, count);
|
||||||
@@ -825,8 +696,8 @@ bool t_command_parser_executor::alt_chain_info(const std::vector<std::string>& a
|
|||||||
{
|
{
|
||||||
if(args.size() > 1)
|
if(args.size() > 1)
|
||||||
{
|
{
|
||||||
std::cout << "Invalid syntax: Too many parameters. For more details, use the help command." << std::endl;
|
std::cout << "usage: alt_chain_info [block_hash|>N|-N]" << std::endl;
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string tip;
|
std::string tip;
|
||||||
@@ -838,16 +709,16 @@ bool t_command_parser_executor::alt_chain_info(const std::vector<std::string>& a
|
|||||||
{
|
{
|
||||||
if (!epee::string_tools::get_xtype_from_string(above, args[0].c_str() + 1))
|
if (!epee::string_tools::get_xtype_from_string(above, args[0].c_str() + 1))
|
||||||
{
|
{
|
||||||
std::cout << "Invalid syntax: Invalid above parameter. For more details, use the help command." << std::endl;
|
std::cout << "invalid above parameter" << std::endl;
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (args[0].size() > 0 && args[0][0] == '-')
|
else if (args[0].size() > 0 && args[0][0] == '-')
|
||||||
{
|
{
|
||||||
if (!epee::string_tools::get_xtype_from_string(last_blocks, args[0].c_str() + 1))
|
if (!epee::string_tools::get_xtype_from_string(last_blocks, args[0].c_str() + 1))
|
||||||
{
|
{
|
||||||
std::cout << "Invalid syntax: Invalid last_blocks parameter. For more details, use the help command." << std::endl;
|
std::cout << "invalid last_blocks parameter" << std::endl;
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -863,15 +734,15 @@ bool t_command_parser_executor::print_blockchain_dynamic_stats(const std::vector
|
|||||||
{
|
{
|
||||||
if(args.size() != 1)
|
if(args.size() != 1)
|
||||||
{
|
{
|
||||||
std::cout << "Invalid syntax: One parameter expected. For more details, use the help command." << std::endl;
|
std::cout << "Exactly one parameter is needed" << std::endl;
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t nblocks = 0;
|
uint64_t nblocks = 0;
|
||||||
if(!epee::string_tools::get_xtype_from_string(nblocks, args[0]) || nblocks == 0)
|
if(!epee::string_tools::get_xtype_from_string(nblocks, args[0]) || nblocks == 0)
|
||||||
{
|
{
|
||||||
std::cout << "Invalid syntax: Wrong number of blocks. For more details, use the help command." << std::endl;
|
std::cout << "wrong number of blocks" << std::endl;
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return m_executor.print_blockchain_dynamic_stats(nblocks);
|
return m_executor.print_blockchain_dynamic_stats(nblocks);
|
||||||
@@ -879,10 +750,10 @@ bool t_command_parser_executor::print_blockchain_dynamic_stats(const std::vector
|
|||||||
|
|
||||||
bool t_command_parser_executor::update(const std::vector<std::string>& args)
|
bool t_command_parser_executor::update(const std::vector<std::string>& args)
|
||||||
{
|
{
|
||||||
if (args.size() != 1)
|
if(args.size() != 1)
|
||||||
{
|
{
|
||||||
std::cout << "Invalid syntax: One parameter expected. For more details, use the help command." << std::endl;
|
std::cout << "Exactly one parameter is needed: check, download, or update" << std::endl;
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return m_executor.update(args.front());
|
return m_executor.update(args.front());
|
||||||
@@ -890,17 +761,13 @@ bool t_command_parser_executor::update(const std::vector<std::string>& args)
|
|||||||
|
|
||||||
bool t_command_parser_executor::relay_tx(const std::vector<std::string>& args)
|
bool t_command_parser_executor::relay_tx(const std::vector<std::string>& args)
|
||||||
{
|
{
|
||||||
if (args.size() != 1)
|
if (args.size() != 1) return false;
|
||||||
{
|
|
||||||
std::cout << "Invalid syntax: One parameter expected. For more details, use the help command." << std::endl;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string txid;
|
std::string txid;
|
||||||
crypto::hash hash;
|
crypto::hash hash;
|
||||||
if (!parse_hash256(args[0], hash))
|
if (!parse_hash256(args[0], hash))
|
||||||
{
|
{
|
||||||
std::cout << "Invalid syntax: Failed to parse tx id. For more details, use the help command." << std::endl;
|
std::cout << "failed to parse tx id" << std::endl;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
txid = args[0];
|
txid = args[0];
|
||||||
@@ -909,10 +776,7 @@ bool t_command_parser_executor::relay_tx(const std::vector<std::string>& args)
|
|||||||
|
|
||||||
bool t_command_parser_executor::sync_info(const std::vector<std::string>& args)
|
bool t_command_parser_executor::sync_info(const std::vector<std::string>& args)
|
||||||
{
|
{
|
||||||
if (args.size() != 0) {
|
if (args.size() != 0) return false;
|
||||||
std::cout << "Invalid syntax: No parameters expected. For more details, use the help command." << std::endl;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return m_executor.sync_info();
|
return m_executor.sync_info();
|
||||||
}
|
}
|
||||||
@@ -921,8 +785,8 @@ bool t_command_parser_executor::pop_blocks(const std::vector<std::string>& args)
|
|||||||
{
|
{
|
||||||
if (args.size() != 1)
|
if (args.size() != 1)
|
||||||
{
|
{
|
||||||
std::cout << "Invalid syntax: One parameter expected. For more details, use the help command." << std::endl;
|
std::cout << "Exactly one parameter is needed" << std::endl;
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
@@ -930,24 +794,21 @@ bool t_command_parser_executor::pop_blocks(const std::vector<std::string>& args)
|
|||||||
uint64_t nblocks = boost::lexical_cast<uint64_t>(args[0]);
|
uint64_t nblocks = boost::lexical_cast<uint64_t>(args[0]);
|
||||||
if (nblocks < 1)
|
if (nblocks < 1)
|
||||||
{
|
{
|
||||||
std::cout << "Invalid syntax: Number of blocks must be greater than 0. For more details, use the help command." << std::endl;
|
std::cout << "number of blocks must be greater than 0" << std::endl;
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
return m_executor.pop_blocks(nblocks);
|
return m_executor.pop_blocks(nblocks);
|
||||||
}
|
}
|
||||||
catch (const boost::bad_lexical_cast&)
|
catch (const boost::bad_lexical_cast&)
|
||||||
{
|
{
|
||||||
std::cout << "Invalid syntax: Number of blocks must be a number greater than 0. For more details, use the help command." << std::endl;
|
std::cout << "number of blocks must be a number greater than 0" << std::endl;
|
||||||
}
|
}
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool t_command_parser_executor::rpc_payments(const std::vector<std::string>& args)
|
bool t_command_parser_executor::rpc_payments(const std::vector<std::string>& args)
|
||||||
{
|
{
|
||||||
if (args.size() != 0) {
|
if (args.size() != 0) return false;
|
||||||
std::cout << "Invalid syntax: No parameters expected. For more details, use the help command." << std::endl;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return m_executor.rpc_payments();
|
return m_executor.rpc_payments();
|
||||||
}
|
}
|
||||||
@@ -959,11 +820,7 @@ bool t_command_parser_executor::version(const std::vector<std::string>& args)
|
|||||||
|
|
||||||
bool t_command_parser_executor::prune_blockchain(const std::vector<std::string>& args)
|
bool t_command_parser_executor::prune_blockchain(const std::vector<std::string>& args)
|
||||||
{
|
{
|
||||||
if (args.size() > 1)
|
if (args.size() > 1) return false;
|
||||||
{
|
|
||||||
std::cout << "Invalid syntax: Too many parameters. For more details, use the help command." << std::endl;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args.empty() || args[0] != "confirm")
|
if (args.empty() || args[0] != "confirm")
|
||||||
{
|
{
|
||||||
@@ -989,8 +846,7 @@ bool t_command_parser_executor::set_bootstrap_daemon(const std::vector<std::stri
|
|||||||
const size_t args_count = args.size();
|
const size_t args_count = args.size();
|
||||||
if (args_count < 1 || args_count > 3)
|
if (args_count < 1 || args_count > 3)
|
||||||
{
|
{
|
||||||
std::cout << "Invalid syntax: Wrong number of parameters. For more details, use the help command." << std::endl;
|
return false;
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return m_executor.set_bootstrap_daemon(
|
return m_executor.set_bootstrap_daemon(
|
||||||
|
|||||||
@@ -223,8 +223,7 @@ t_command_server::t_command_server(
|
|||||||
m_command_lookup.set_handler(
|
m_command_lookup.set_handler(
|
||||||
"hard_fork_info"
|
"hard_fork_info"
|
||||||
, std::bind(&t_command_parser_executor::hard_fork_info, &m_parser, p::_1)
|
, std::bind(&t_command_parser_executor::hard_fork_info, &m_parser, p::_1)
|
||||||
, "hard_fork_info <version>"
|
, "Print the hard fork voting information."
|
||||||
, "Print the hard fork voting information. If given a version, prints whether is this version enabled."
|
|
||||||
);
|
);
|
||||||
m_command_lookup.set_handler(
|
m_command_lookup.set_handler(
|
||||||
"bans"
|
"bans"
|
||||||
@@ -234,8 +233,8 @@ t_command_server::t_command_server(
|
|||||||
m_command_lookup.set_handler(
|
m_command_lookup.set_handler(
|
||||||
"ban"
|
"ban"
|
||||||
, std::bind(&t_command_parser_executor::ban, &m_parser, p::_1)
|
, std::bind(&t_command_parser_executor::ban, &m_parser, p::_1)
|
||||||
, "ban [<IP>|@<filename>] [<seconds>]"
|
, "ban <IP> [<seconds>]"
|
||||||
, "Ban a given <IP> or list of IPs from a file for a given amount of <seconds>."
|
, "Ban a given <IP> for a given amount of <seconds>."
|
||||||
);
|
);
|
||||||
m_command_lookup.set_handler(
|
m_command_lookup.set_handler(
|
||||||
"unban"
|
"unban"
|
||||||
@@ -315,7 +314,6 @@ t_command_server::t_command_server(
|
|||||||
m_command_lookup.set_handler(
|
m_command_lookup.set_handler(
|
||||||
"prune_blockchain"
|
"prune_blockchain"
|
||||||
, std::bind(&t_command_parser_executor::prune_blockchain, &m_parser, p::_1)
|
, std::bind(&t_command_parser_executor::prune_blockchain, &m_parser, p::_1)
|
||||||
, "prune_blockchain [confirm]"
|
|
||||||
, "Prune the blockchain."
|
, "Prune the blockchain."
|
||||||
);
|
);
|
||||||
m_command_lookup.set_handler(
|
m_command_lookup.set_handler(
|
||||||
|
|||||||
@@ -66,12 +66,10 @@ uint16_t parse_public_rpc_port(const po::variables_map &vm)
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string rpc_port_str;
|
std::string rpc_port_str;
|
||||||
std::string rpc_bind_address = command_line::get_arg(vm, cryptonote::rpc_args::descriptors().rpc_bind_ip);
|
|
||||||
const auto &restricted_rpc_port = cryptonote::core_rpc_server::arg_rpc_restricted_bind_port;
|
const auto &restricted_rpc_port = cryptonote::core_rpc_server::arg_rpc_restricted_bind_port;
|
||||||
if (!command_line::is_arg_defaulted(vm, restricted_rpc_port))
|
if (!command_line::is_arg_defaulted(vm, restricted_rpc_port))
|
||||||
{
|
{
|
||||||
rpc_port_str = command_line::get_arg(vm, restricted_rpc_port);
|
rpc_port_str = command_line::get_arg(vm, restricted_rpc_port);
|
||||||
rpc_bind_address = command_line::get_arg(vm, cryptonote::rpc_args::descriptors().rpc_restricted_bind_ip);
|
|
||||||
}
|
}
|
||||||
else if (command_line::get_arg(vm, cryptonote::core_rpc_server::arg_restricted_rpc))
|
else if (command_line::get_arg(vm, cryptonote::core_rpc_server::arg_restricted_rpc))
|
||||||
{
|
{
|
||||||
@@ -88,6 +86,7 @@ uint16_t parse_public_rpc_port(const po::variables_map &vm)
|
|||||||
throw std::runtime_error("invalid RPC port " + rpc_port_str);
|
throw std::runtime_error("invalid RPC port " + rpc_port_str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const auto rpc_bind_address = command_line::get_arg(vm, cryptonote::rpc_args::descriptors().rpc_bind_ip);
|
||||||
const auto address = net::get_network_address(rpc_bind_address, rpc_port);
|
const auto address = net::get_network_address(rpc_bind_address, rpc_port);
|
||||||
if (!address) {
|
if (!address) {
|
||||||
throw std::runtime_error("failed to parse RPC bind address");
|
throw std::runtime_error("failed to parse RPC bind address");
|
||||||
|
|||||||
@@ -191,9 +191,6 @@ bool t_rpc_command_executor::print_peer_list(bool white, bool gray, size_t limit
|
|||||||
cryptonote::COMMAND_RPC_GET_PEER_LIST::response res;
|
cryptonote::COMMAND_RPC_GET_PEER_LIST::response res;
|
||||||
|
|
||||||
std::string failure_message = "Couldn't retrieve peer list";
|
std::string failure_message = "Couldn't retrieve peer list";
|
||||||
|
|
||||||
req.include_blocked = true;
|
|
||||||
|
|
||||||
if (m_is_rpc)
|
if (m_is_rpc)
|
||||||
{
|
{
|
||||||
if (!m_rpc_client->rpc_request(req, res, "/get_peer_list", failure_message.c_str()))
|
if (!m_rpc_client->rpc_request(req, res, "/get_peer_list", failure_message.c_str()))
|
||||||
@@ -240,7 +237,6 @@ bool t_rpc_command_executor::print_peer_list_stats() {
|
|||||||
std::string failure_message = "Couldn't retrieve peer list";
|
std::string failure_message = "Couldn't retrieve peer list";
|
||||||
|
|
||||||
req.public_only = false;
|
req.public_only = false;
|
||||||
req.include_blocked = true;
|
|
||||||
|
|
||||||
if (m_is_rpc)
|
if (m_is_rpc)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -146,10 +146,8 @@ namespace nodetool
|
|||||||
const command_line::arg_descriptor<std::vector<std::string> > arg_p2p_seed_node = {"seed-node", "Connect to a node to retrieve peer addresses, and disconnect"};
|
const command_line::arg_descriptor<std::vector<std::string> > arg_p2p_seed_node = {"seed-node", "Connect to a node to retrieve peer addresses, and disconnect"};
|
||||||
const command_line::arg_descriptor<std::vector<std::string> > arg_tx_proxy = {"tx-proxy", "Send local txes through proxy: <network-type>,<socks-ip:port>[,max_connections][,disable_noise] i.e. \"tor,127.0.0.1:9050,100,disable_noise\""};
|
const command_line::arg_descriptor<std::vector<std::string> > arg_tx_proxy = {"tx-proxy", "Send local txes through proxy: <network-type>,<socks-ip:port>[,max_connections][,disable_noise] i.e. \"tor,127.0.0.1:9050,100,disable_noise\""};
|
||||||
const command_line::arg_descriptor<std::vector<std::string> > arg_anonymous_inbound = {"anonymous-inbound", "<hidden-service-address>,<[bind-ip:]port>[,max_connections] i.e. \"x.onion,127.0.0.1:18083,100\""};
|
const command_line::arg_descriptor<std::vector<std::string> > arg_anonymous_inbound = {"anonymous-inbound", "<hidden-service-address>,<[bind-ip:]port>[,max_connections] i.e. \"x.onion,127.0.0.1:18083,100\""};
|
||||||
const command_line::arg_descriptor<std::string> arg_ban_list = {"ban-list", "Specify ban list file, one IP address per line"};
|
|
||||||
const command_line::arg_descriptor<bool> arg_p2p_hide_my_port = {"hide-my-port", "Do not announce yourself as peerlist candidate", false, true};
|
const command_line::arg_descriptor<bool> arg_p2p_hide_my_port = {"hide-my-port", "Do not announce yourself as peerlist candidate", false, true};
|
||||||
const command_line::arg_descriptor<bool> arg_no_sync = {"no-sync", "Don't synchronize the blockchain with other peers", false};
|
const command_line::arg_descriptor<bool> arg_no_sync = {"no-sync", "Don't synchronize the blockchain with other peers", false};
|
||||||
const command_line::arg_descriptor<bool> arg_enable_dns_blocklist = {"enable-dns-blocklist", "Apply realtime blocklist from DNS", false};
|
|
||||||
|
|
||||||
const command_line::arg_descriptor<bool> arg_no_igd = {"no-igd", "Disable UPnP port mapping"};
|
const command_line::arg_descriptor<bool> arg_no_igd = {"no-igd", "Disable UPnP port mapping"};
|
||||||
const command_line::arg_descriptor<std::string> arg_igd = {"igd", "UPnP port mapping (disabled, enabled, delayed)", "delayed"};
|
const command_line::arg_descriptor<std::string> arg_igd = {"igd", "UPnP port mapping (disabled, enabled, delayed)", "delayed"};
|
||||||
|
|||||||
@@ -139,7 +139,6 @@ namespace nodetool
|
|||||||
|
|
||||||
typedef COMMAND_HANDSHAKE_T<typename t_payload_net_handler::payload_type> COMMAND_HANDSHAKE;
|
typedef COMMAND_HANDSHAKE_T<typename t_payload_net_handler::payload_type> COMMAND_HANDSHAKE;
|
||||||
typedef COMMAND_TIMED_SYNC_T<typename t_payload_net_handler::payload_type> COMMAND_TIMED_SYNC;
|
typedef COMMAND_TIMED_SYNC_T<typename t_payload_net_handler::payload_type> COMMAND_TIMED_SYNC;
|
||||||
static_assert(p2p_connection_context::handshake_command() == COMMAND_HANDSHAKE::ID, "invalid handshake command id");
|
|
||||||
|
|
||||||
typedef epee::net_utils::boosted_tcp_server<epee::levin::async_protocol_handler<p2p_connection_context>> net_server;
|
typedef epee::net_utils::boosted_tcp_server<epee::levin::async_protocol_handler<p2p_connection_context>> net_server;
|
||||||
|
|
||||||
@@ -150,7 +149,7 @@ namespace nodetool
|
|||||||
{
|
{
|
||||||
config_t()
|
config_t()
|
||||||
: m_net_config(),
|
: m_net_config(),
|
||||||
m_peer_id(1),
|
m_peer_id(crypto::rand<uint64_t>()),
|
||||||
m_support_flags(0)
|
m_support_flags(0)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
@@ -279,7 +278,7 @@ namespace nodetool
|
|||||||
uint32_t get_max_out_public_peers() const;
|
uint32_t get_max_out_public_peers() const;
|
||||||
void change_max_in_public_peers(size_t count);
|
void change_max_in_public_peers(size_t count);
|
||||||
uint32_t get_max_in_public_peers() const;
|
uint32_t get_max_in_public_peers() const;
|
||||||
virtual bool block_host(epee::net_utils::network_address address, time_t seconds = P2P_IP_BLOCKTIME, bool add_only = false);
|
virtual bool block_host(const epee::net_utils::network_address &adress, time_t seconds = P2P_IP_BLOCKTIME);
|
||||||
virtual bool unblock_host(const epee::net_utils::network_address &address);
|
virtual bool unblock_host(const epee::net_utils::network_address &address);
|
||||||
virtual bool block_subnet(const epee::net_utils::ipv4_network_subnet &subnet, time_t seconds = P2P_IP_BLOCKTIME);
|
virtual bool block_subnet(const epee::net_utils::ipv4_network_subnet &subnet, time_t seconds = P2P_IP_BLOCKTIME);
|
||||||
virtual bool unblock_subnet(const epee::net_utils::ipv4_network_subnet &subnet);
|
virtual bool unblock_subnet(const epee::net_utils::ipv4_network_subnet &subnet);
|
||||||
@@ -358,7 +357,6 @@ namespace nodetool
|
|||||||
bool peer_sync_idle_maker();
|
bool peer_sync_idle_maker();
|
||||||
bool do_handshake_with_peer(peerid_type& pi, p2p_connection_context& context, bool just_take_peerlist = false);
|
bool do_handshake_with_peer(peerid_type& pi, p2p_connection_context& context, bool just_take_peerlist = false);
|
||||||
bool do_peer_timed_sync(const epee::net_utils::connection_context_base& context, peerid_type peer_id);
|
bool do_peer_timed_sync(const epee::net_utils::connection_context_base& context, peerid_type peer_id);
|
||||||
bool update_dns_blocklist();
|
|
||||||
|
|
||||||
bool make_new_connection_from_anchor_peerlist(const std::vector<anchor_peerlist_entry>& anchor_peerlist);
|
bool make_new_connection_from_anchor_peerlist(const std::vector<anchor_peerlist_entry>& anchor_peerlist);
|
||||||
bool make_new_connection_from_peerlist(network_zone& zone, bool use_white_list);
|
bool make_new_connection_from_peerlist(network_zone& zone, bool use_white_list);
|
||||||
@@ -463,7 +461,6 @@ namespace nodetool
|
|||||||
epee::math_helper::once_a_time_seconds<60*30, false> m_peerlist_store_interval;
|
epee::math_helper::once_a_time_seconds<60*30, false> m_peerlist_store_interval;
|
||||||
epee::math_helper::once_a_time_seconds<60> m_gray_peerlist_housekeeping_interval;
|
epee::math_helper::once_a_time_seconds<60> m_gray_peerlist_housekeeping_interval;
|
||||||
epee::math_helper::once_a_time_seconds<3600, false> m_incoming_connections_interval;
|
epee::math_helper::once_a_time_seconds<3600, false> m_incoming_connections_interval;
|
||||||
epee::math_helper::once_a_time_seconds<7000> m_dns_blocklist_interval;
|
|
||||||
|
|
||||||
std::list<epee::net_utils::network_address> m_priority_peers;
|
std::list<epee::net_utils::network_address> m_priority_peers;
|
||||||
std::vector<epee::net_utils::network_address> m_exclusive_peers;
|
std::vector<epee::net_utils::network_address> m_exclusive_peers;
|
||||||
@@ -505,8 +502,6 @@ namespace nodetool
|
|||||||
cryptonote::network_type m_nettype;
|
cryptonote::network_type m_nettype;
|
||||||
|
|
||||||
epee::net_utils::ssl_support_t m_ssl_support;
|
epee::net_utils::ssl_support_t m_ssl_support;
|
||||||
|
|
||||||
bool m_enable_dns_blocklist;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const int64_t default_limit_up = P2P_DEFAULT_LIMIT_RATE_UP; // kB/s
|
const int64_t default_limit_up = P2P_DEFAULT_LIMIT_RATE_UP; // kB/s
|
||||||
@@ -525,10 +520,8 @@ namespace nodetool
|
|||||||
extern const command_line::arg_descriptor<std::vector<std::string> > arg_p2p_seed_node;
|
extern const command_line::arg_descriptor<std::vector<std::string> > arg_p2p_seed_node;
|
||||||
extern const command_line::arg_descriptor<std::vector<std::string> > arg_tx_proxy;
|
extern const command_line::arg_descriptor<std::vector<std::string> > arg_tx_proxy;
|
||||||
extern const command_line::arg_descriptor<std::vector<std::string> > arg_anonymous_inbound;
|
extern const command_line::arg_descriptor<std::vector<std::string> > arg_anonymous_inbound;
|
||||||
extern const command_line::arg_descriptor<std::string> arg_ban_list;
|
|
||||||
extern const command_line::arg_descriptor<bool> arg_p2p_hide_my_port;
|
extern const command_line::arg_descriptor<bool> arg_p2p_hide_my_port;
|
||||||
extern const command_line::arg_descriptor<bool> arg_no_sync;
|
extern const command_line::arg_descriptor<bool> arg_no_sync;
|
||||||
extern const command_line::arg_descriptor<bool> arg_enable_dns_blocklist;
|
|
||||||
|
|
||||||
extern const command_line::arg_descriptor<bool> arg_no_igd;
|
extern const command_line::arg_descriptor<bool> arg_no_igd;
|
||||||
extern const command_line::arg_descriptor<std::string> arg_igd;
|
extern const command_line::arg_descriptor<std::string> arg_igd;
|
||||||
|
|||||||
@@ -37,7 +37,6 @@
|
|||||||
#include <boost/optional/optional.hpp>
|
#include <boost/optional/optional.hpp>
|
||||||
#include <boost/thread/thread.hpp>
|
#include <boost/thread/thread.hpp>
|
||||||
#include <boost/uuid/uuid_io.hpp>
|
#include <boost/uuid/uuid_io.hpp>
|
||||||
#include <boost/algorithm/string.hpp>
|
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
@@ -72,17 +71,6 @@
|
|||||||
|
|
||||||
#define MIN_WANTED_SEED_NODES 12
|
#define MIN_WANTED_SEED_NODES 12
|
||||||
|
|
||||||
static inline boost::asio::ip::address_v4 make_address_v4_from_v6(const boost::asio::ip::address_v6& a)
|
|
||||||
{
|
|
||||||
const auto &bytes = a.to_bytes();
|
|
||||||
uint32_t v4 = 0;
|
|
||||||
v4 = (v4 << 8) | bytes[12];
|
|
||||||
v4 = (v4 << 8) | bytes[13];
|
|
||||||
v4 = (v4 << 8) | bytes[14];
|
|
||||||
v4 = (v4 << 8) | bytes[15];
|
|
||||||
return boost::asio::ip::address_v4(v4);
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace nodetool
|
namespace nodetool
|
||||||
{
|
{
|
||||||
template<class t_payload_net_handler>
|
template<class t_payload_net_handler>
|
||||||
@@ -118,10 +106,8 @@ namespace nodetool
|
|||||||
command_line::add_arg(desc, arg_p2p_seed_node);
|
command_line::add_arg(desc, arg_p2p_seed_node);
|
||||||
command_line::add_arg(desc, arg_tx_proxy);
|
command_line::add_arg(desc, arg_tx_proxy);
|
||||||
command_line::add_arg(desc, arg_anonymous_inbound);
|
command_line::add_arg(desc, arg_anonymous_inbound);
|
||||||
command_line::add_arg(desc, arg_ban_list);
|
|
||||||
command_line::add_arg(desc, arg_p2p_hide_my_port);
|
command_line::add_arg(desc, arg_p2p_hide_my_port);
|
||||||
command_line::add_arg(desc, arg_no_sync);
|
command_line::add_arg(desc, arg_no_sync);
|
||||||
command_line::add_arg(desc, arg_enable_dns_blocklist);
|
|
||||||
command_line::add_arg(desc, arg_no_igd);
|
command_line::add_arg(desc, arg_no_igd);
|
||||||
command_line::add_arg(desc, arg_igd);
|
command_line::add_arg(desc, arg_igd);
|
||||||
command_line::add_arg(desc, arg_out_peers);
|
command_line::add_arg(desc, arg_out_peers);
|
||||||
@@ -141,9 +127,7 @@ namespace nodetool
|
|||||||
if (storage)
|
if (storage)
|
||||||
m_peerlist_storage = std::move(*storage);
|
m_peerlist_storage = std::move(*storage);
|
||||||
|
|
||||||
network_zone& public_zone = m_network_zones[epee::net_utils::zone::public_];
|
m_network_zones[epee::net_utils::zone::public_].m_config.m_support_flags = P2P_SUPPORT_FLAGS;
|
||||||
public_zone.m_config.m_support_flags = P2P_SUPPORT_FLAGS;
|
|
||||||
public_zone.m_config.m_peer_id = crypto::rand<uint64_t>();
|
|
||||||
m_first_connection_maker_call = true;
|
m_first_connection_maker_call = true;
|
||||||
|
|
||||||
CATCH_ENTRY_L0("node_server::init_config", false);
|
CATCH_ENTRY_L0("node_server::init_config", false);
|
||||||
@@ -228,7 +212,7 @@ namespace nodetool
|
|||||||
}
|
}
|
||||||
//-----------------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------------
|
||||||
template<class t_payload_net_handler>
|
template<class t_payload_net_handler>
|
||||||
bool node_server<t_payload_net_handler>::block_host(epee::net_utils::network_address addr, time_t seconds, bool add_only)
|
bool node_server<t_payload_net_handler>::block_host(const epee::net_utils::network_address &addr, time_t seconds)
|
||||||
{
|
{
|
||||||
if(!addr.is_blockable())
|
if(!addr.is_blockable())
|
||||||
return false;
|
return false;
|
||||||
@@ -241,12 +225,7 @@ namespace nodetool
|
|||||||
limit = std::numeric_limits<time_t>::max();
|
limit = std::numeric_limits<time_t>::max();
|
||||||
else
|
else
|
||||||
limit = now + seconds;
|
limit = now + seconds;
|
||||||
const std::string host_str = addr.host_str();
|
m_blocked_hosts[addr.host_str()] = limit;
|
||||||
auto it = m_blocked_hosts.find(host_str);
|
|
||||||
if (it == m_blocked_hosts.end())
|
|
||||||
m_blocked_hosts[host_str] = limit;
|
|
||||||
else if (it->second < limit || !add_only)
|
|
||||||
it->second = limit;
|
|
||||||
|
|
||||||
// drop any connection to that address. This should only have to look into
|
// drop any connection to that address. This should only have to look into
|
||||||
// the zone related to the connection, but really make sure everything is
|
// the zone related to the connection, but really make sure everything is
|
||||||
@@ -262,20 +241,13 @@ namespace nodetool
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
peerlist_entry pe{};
|
|
||||||
pe.adr = addr;
|
|
||||||
zone.second.m_peerlist.remove_from_peer_white(pe);
|
|
||||||
zone.second.m_peerlist.remove_from_peer_gray(pe);
|
|
||||||
zone.second.m_peerlist.remove_from_peer_anchor(addr);
|
|
||||||
|
|
||||||
for (const auto &c: conns)
|
for (const auto &c: conns)
|
||||||
zone.second.m_net_server.get_config_object().close(c);
|
zone.second.m_net_server.get_config_object().close(c);
|
||||||
|
|
||||||
conns.clear();
|
conns.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
MCLOG_CYAN(el::Level::Info, "global", "Host " << host_str << " blocked.");
|
MCLOG_CYAN(el::Level::Info, "global", "Host " << addr.host_str() << " blocked.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
//-----------------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------------
|
||||||
@@ -414,7 +386,7 @@ namespace nodetool
|
|||||||
m_use_ipv6 = command_line::get_arg(vm, arg_p2p_use_ipv6);
|
m_use_ipv6 = command_line::get_arg(vm, arg_p2p_use_ipv6);
|
||||||
m_require_ipv4 = !command_line::get_arg(vm, arg_p2p_ignore_ipv4);
|
m_require_ipv4 = !command_line::get_arg(vm, arg_p2p_ignore_ipv4);
|
||||||
public_zone.m_notifier = cryptonote::levin::notify{
|
public_zone.m_notifier = cryptonote::levin::notify{
|
||||||
public_zone.m_net_server.get_io_service(), public_zone.m_net_server.get_config_shared(), nullptr, epee::net_utils::zone::public_, pad_txs, m_payload_handler.get_core()
|
public_zone.m_net_server.get_io_service(), public_zone.m_net_server.get_config_shared(), nullptr, true, pad_txs, m_payload_handler.get_core()
|
||||||
};
|
};
|
||||||
|
|
||||||
if (command_line::has_arg(vm, arg_p2p_add_peer))
|
if (command_line::has_arg(vm, arg_p2p_add_peer))
|
||||||
@@ -469,50 +441,12 @@ namespace nodetool
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!command_line::is_arg_defaulted(vm, arg_ban_list))
|
|
||||||
{
|
|
||||||
const std::string ban_list = command_line::get_arg(vm, arg_ban_list);
|
|
||||||
|
|
||||||
const boost::filesystem::path ban_list_path(ban_list);
|
|
||||||
boost::system::error_code ec;
|
|
||||||
if (!boost::filesystem::exists(ban_list_path, ec))
|
|
||||||
{
|
|
||||||
throw std::runtime_error("Can't find ban list file " + ban_list + " - " + ec.message());
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string banned_ips;
|
|
||||||
if (!epee::file_io_utils::load_file_to_string(ban_list_path.string(), banned_ips))
|
|
||||||
{
|
|
||||||
throw std::runtime_error("Failed to read ban list file " + ban_list);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::istringstream iss(banned_ips);
|
|
||||||
for (std::string line; std::getline(iss, line); )
|
|
||||||
{
|
|
||||||
auto subnet = net::get_ipv4_subnet_address(line);
|
|
||||||
if (subnet)
|
|
||||||
{
|
|
||||||
block_subnet(*subnet, std::numeric_limits<time_t>::max());
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
const expect<epee::net_utils::network_address> parsed_addr = net::get_network_address(line, 0);
|
|
||||||
if (parsed_addr)
|
|
||||||
{
|
|
||||||
block_host(*parsed_addr, std::numeric_limits<time_t>::max());
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
MERROR("Invalid IP address or IPv4 subnet: " << line);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(command_line::has_arg(vm, arg_p2p_hide_my_port))
|
if(command_line::has_arg(vm, arg_p2p_hide_my_port))
|
||||||
m_hide_my_port = true;
|
m_hide_my_port = true;
|
||||||
|
|
||||||
if (command_line::has_arg(vm, arg_no_sync))
|
if (command_line::has_arg(vm, arg_no_sync))
|
||||||
m_payload_handler.set_no_sync(true);
|
m_payload_handler.set_no_sync(true);
|
||||||
|
|
||||||
m_enable_dns_blocklist = command_line::get_arg(vm, arg_enable_dns_blocklist);
|
|
||||||
|
|
||||||
if ( !set_max_out_peers(public_zone, command_line::get_arg(vm, arg_out_peers) ) )
|
if ( !set_max_out_peers(public_zone, command_line::get_arg(vm, arg_out_peers) ) )
|
||||||
return false;
|
return false;
|
||||||
else
|
else
|
||||||
@@ -565,7 +499,7 @@ namespace nodetool
|
|||||||
}
|
}
|
||||||
|
|
||||||
zone.m_notifier = cryptonote::levin::notify{
|
zone.m_notifier = cryptonote::levin::notify{
|
||||||
zone.m_net_server.get_io_service(), zone.m_net_server.get_config_shared(), std::move(this_noise), proxy.zone, pad_txs, m_payload_handler.get_core()
|
zone.m_net_server.get_io_service(), zone.m_net_server.get_config_shared(), std::move(this_noise), false, pad_txs, m_payload_handler.get_core()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1119,12 +1053,11 @@ namespace nodetool
|
|||||||
pi = context.peer_id = rsp.node_data.peer_id;
|
pi = context.peer_id = rsp.node_data.peer_id;
|
||||||
context.m_rpc_port = rsp.node_data.rpc_port;
|
context.m_rpc_port = rsp.node_data.rpc_port;
|
||||||
context.m_rpc_credits_per_hash = rsp.node_data.rpc_credits_per_hash;
|
context.m_rpc_credits_per_hash = rsp.node_data.rpc_credits_per_hash;
|
||||||
const auto azone = context.m_remote_address.get_zone();
|
network_zone& zone = m_network_zones.at(context.m_remote_address.get_zone());
|
||||||
network_zone& zone = m_network_zones.at(azone);
|
|
||||||
zone.m_peerlist.set_peer_just_seen(rsp.node_data.peer_id, context.m_remote_address, context.m_pruning_seed, context.m_rpc_port, context.m_rpc_credits_per_hash);
|
zone.m_peerlist.set_peer_just_seen(rsp.node_data.peer_id, context.m_remote_address, context.m_pruning_seed, context.m_rpc_port, context.m_rpc_credits_per_hash);
|
||||||
|
|
||||||
// move
|
// move
|
||||||
if(azone == epee::net_utils::zone::public_ && rsp.node_data.peer_id == zone.m_config.m_peer_id)
|
if(rsp.node_data.peer_id == zone.m_config.m_peer_id)
|
||||||
{
|
{
|
||||||
LOG_DEBUG_CC(context, "Connection to self detected, dropping connection");
|
LOG_DEBUG_CC(context, "Connection to self detected, dropping connection");
|
||||||
hsh_result = false;
|
hsh_result = false;
|
||||||
@@ -1181,9 +1114,8 @@ namespace nodetool
|
|||||||
if(!handle_remote_peerlist(rsp.local_peerlist_new, context))
|
if(!handle_remote_peerlist(rsp.local_peerlist_new, context))
|
||||||
{
|
{
|
||||||
LOG_WARNING_CC(context, "COMMAND_TIMED_SYNC: failed to handle_remote_peerlist(...), closing connection.");
|
LOG_WARNING_CC(context, "COMMAND_TIMED_SYNC: failed to handle_remote_peerlist(...), closing connection.");
|
||||||
const auto remote_address = context.m_remote_address;
|
|
||||||
m_network_zones.at(context.m_remote_address.get_zone()).m_net_server.get_config_object().close(context.m_connection_id );
|
m_network_zones.at(context.m_remote_address.get_zone()).m_net_server.get_config_object().close(context.m_connection_id );
|
||||||
add_host_fail(remote_address);
|
add_host_fail(context.m_remote_address);
|
||||||
}
|
}
|
||||||
if(!context.m_is_income)
|
if(!context.m_is_income)
|
||||||
m_network_zones.at(context.m_remote_address.get_zone()).m_peerlist.set_peer_just_seen(context.peer_id, context.m_remote_address, context.m_pruning_seed, context.m_rpc_port, context.m_rpc_credits_per_hash);
|
m_network_zones.at(context.m_remote_address.get_zone()).m_peerlist.set_peer_just_seen(context.peer_id, context.m_remote_address, context.m_pruning_seed, context.m_rpc_port, context.m_rpc_credits_per_hash);
|
||||||
@@ -1217,51 +1149,50 @@ namespace nodetool
|
|||||||
template<class t_payload_net_handler>
|
template<class t_payload_net_handler>
|
||||||
bool node_server<t_payload_net_handler>::is_peer_used(const peerlist_entry& peer)
|
bool node_server<t_payload_net_handler>::is_peer_used(const peerlist_entry& peer)
|
||||||
{
|
{
|
||||||
const auto zone = peer.adr.get_zone();
|
for(const auto& zone : m_network_zones)
|
||||||
const auto server = m_network_zones.find(zone);
|
if(zone.second.m_config.m_peer_id == peer.id)
|
||||||
if (server == m_network_zones.end())
|
return true;//dont make connections to ourself
|
||||||
return false;
|
|
||||||
|
|
||||||
const bool is_public = (zone == epee::net_utils::zone::public_);
|
|
||||||
if(is_public && server->second.m_config.m_peer_id == peer.id)
|
|
||||||
return true;//dont make connections to ourself
|
|
||||||
|
|
||||||
bool used = false;
|
bool used = false;
|
||||||
server->second.m_net_server.get_config_object().foreach_connection([&, is_public](const p2p_connection_context& cntxt)
|
for(auto& zone : m_network_zones)
|
||||||
{
|
{
|
||||||
if((is_public && cntxt.peer_id == peer.id) || (!cntxt.m_is_income && peer.adr == cntxt.m_remote_address))
|
zone.second.m_net_server.get_config_object().foreach_connection([&](const p2p_connection_context& cntxt)
|
||||||
{
|
{
|
||||||
used = true;
|
if(cntxt.peer_id == peer.id || (!cntxt.m_is_income && peer.adr == cntxt.m_remote_address))
|
||||||
return false;//stop enumerating
|
{
|
||||||
}
|
used = true;
|
||||||
return true;
|
return false;//stop enumerating
|
||||||
});
|
}
|
||||||
return used;
|
return true;
|
||||||
|
});
|
||||||
|
|
||||||
|
if(used)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
//-----------------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------------
|
||||||
template<class t_payload_net_handler>
|
template<class t_payload_net_handler>
|
||||||
bool node_server<t_payload_net_handler>::is_peer_used(const anchor_peerlist_entry& peer)
|
bool node_server<t_payload_net_handler>::is_peer_used(const anchor_peerlist_entry& peer)
|
||||||
{
|
{
|
||||||
const auto zone = peer.adr.get_zone();
|
for(auto& zone : m_network_zones) {
|
||||||
const auto server = m_network_zones.find(zone);
|
if(zone.second.m_config.m_peer_id == peer.id) {
|
||||||
if (server == m_network_zones.end())
|
return true;//dont make connections to ourself
|
||||||
return false;
|
|
||||||
|
|
||||||
const bool is_public = (zone == epee::net_utils::zone::public_);
|
|
||||||
if(is_public && server->second.m_config.m_peer_id == peer.id)
|
|
||||||
return true;//dont make connections to ourself
|
|
||||||
|
|
||||||
bool used = false;
|
|
||||||
server->second.m_net_server.get_config_object().foreach_connection([&, is_public](const p2p_connection_context& cntxt)
|
|
||||||
{
|
|
||||||
if((is_public && cntxt.peer_id == peer.id) || (!cntxt.m_is_income && peer.adr == cntxt.m_remote_address))
|
|
||||||
{
|
|
||||||
used = true;
|
|
||||||
return false;//stop enumerating
|
|
||||||
}
|
}
|
||||||
return true;
|
bool used = false;
|
||||||
});
|
zone.second.m_net_server.get_config_object().foreach_connection([&](const p2p_connection_context& cntxt)
|
||||||
return used;
|
{
|
||||||
|
if(cntxt.peer_id == peer.id || (!cntxt.m_is_income && peer.adr == cntxt.m_remote_address))
|
||||||
|
{
|
||||||
|
used = true;
|
||||||
|
return false;//stop enumerating
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
if (used)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
//-----------------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------------
|
||||||
template<class t_payload_net_handler>
|
template<class t_payload_net_handler>
|
||||||
@@ -1297,16 +1228,10 @@ namespace nodetool
|
|||||||
template<class t_payload_net_handler>
|
template<class t_payload_net_handler>
|
||||||
bool node_server<t_payload_net_handler>::try_to_connect_and_handshake_with_new_peer(const epee::net_utils::network_address& na, bool just_take_peerlist, uint64_t last_seen_stamp, PeerType peer_type, uint64_t first_seen_stamp)
|
bool node_server<t_payload_net_handler>::try_to_connect_and_handshake_with_new_peer(const epee::net_utils::network_address& na, bool just_take_peerlist, uint64_t last_seen_stamp, PeerType peer_type, uint64_t first_seen_stamp)
|
||||||
{
|
{
|
||||||
const auto i = m_network_zones.find(na.get_zone());
|
network_zone& zone = m_network_zones.at(na.get_zone());
|
||||||
if (i == m_network_zones.end())
|
|
||||||
return false;
|
|
||||||
network_zone& zone = i->second;
|
|
||||||
if (zone.m_connect == nullptr) // outgoing connections in zone not possible
|
if (zone.m_connect == nullptr) // outgoing connections in zone not possible
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (zone.m_our_address == na)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (zone.m_current_number_of_out_peers == zone.m_config.m_net_config.max_out_connection_count) // out peers limit
|
if (zone.m_current_number_of_out_peers == zone.m_config.m_net_config.max_out_connection_count) // out peers limit
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
@@ -1350,7 +1275,7 @@ namespace nodetool
|
|||||||
if(just_take_peerlist)
|
if(just_take_peerlist)
|
||||||
{
|
{
|
||||||
zone.m_net_server.get_config_object().close(con->m_connection_id);
|
zone.m_net_server.get_config_object().close(con->m_connection_id);
|
||||||
MDEBUG(na.str() << "CONNECTION HANDSHAKED OK AND CLOSED.");
|
LOG_DEBUG_CC(*con, "CONNECTION HANDSHAKED OK AND CLOSED.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1412,7 +1337,7 @@ namespace nodetool
|
|||||||
|
|
||||||
zone.m_net_server.get_config_object().close(con->m_connection_id);
|
zone.m_net_server.get_config_object().close(con->m_connection_id);
|
||||||
|
|
||||||
MDEBUG(na.str() << "CONNECTION HANDSHAKED OK AND CLOSED.");
|
LOG_DEBUG_CC(*con, "CONNECTION HANDSHAKED OK AND CLOSED.");
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -1503,44 +1428,17 @@ namespace nodetool
|
|||||||
const uint32_t actual_ip = na.as<const epee::net_utils::ipv4_network_address>().ip();
|
const uint32_t actual_ip = na.as<const epee::net_utils::ipv4_network_address>().ip();
|
||||||
classB.insert(actual_ip & 0x0000ffff);
|
classB.insert(actual_ip & 0x0000ffff);
|
||||||
}
|
}
|
||||||
else if (cntxt.m_remote_address.get_type_id() == epee::net_utils::ipv6_network_address::get_type_id())
|
|
||||||
{
|
|
||||||
const epee::net_utils::network_address na = cntxt.m_remote_address;
|
|
||||||
const boost::asio::ip::address_v6 &actual_ip = na.as<const epee::net_utils::ipv6_network_address>().ip();
|
|
||||||
if (actual_ip.is_v4_mapped())
|
|
||||||
{
|
|
||||||
boost::asio::ip::address_v4 v4ip = make_address_v4_from_v6(actual_ip);
|
|
||||||
uint32_t actual_ipv4;
|
|
||||||
memcpy(&actual_ipv4, v4ip.to_bytes().data(), sizeof(actual_ipv4));
|
|
||||||
classB.insert(actual_ipv4 & ntohl(0xffff0000));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
auto get_host_string = [](const epee::net_utils::network_address &address) {
|
|
||||||
if (address.get_type_id() == epee::net_utils::ipv6_network_address::get_type_id())
|
|
||||||
{
|
|
||||||
boost::asio::ip::address_v6 actual_ip = address.as<const epee::net_utils::ipv6_network_address>().ip();
|
|
||||||
if (actual_ip.is_v4_mapped())
|
|
||||||
{
|
|
||||||
boost::asio::ip::address_v4 v4ip = make_address_v4_from_v6(actual_ip);
|
|
||||||
uint32_t actual_ipv4;
|
|
||||||
memcpy(&actual_ipv4, v4ip.to_bytes().data(), sizeof(actual_ipv4));
|
|
||||||
return epee::net_utils::ipv4_network_address(actual_ipv4, 0).host_str();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return address.host_str();
|
|
||||||
};
|
|
||||||
std::unordered_set<std::string> hosts_added;
|
|
||||||
std::deque<size_t> filtered;
|
std::deque<size_t> filtered;
|
||||||
const size_t limit = use_white_list ? 20 : std::numeric_limits<size_t>::max();
|
const size_t limit = use_white_list ? 20 : std::numeric_limits<size_t>::max();
|
||||||
for (int step = 0; step < 2; ++step)
|
for (int step = 0; step < 2; ++step)
|
||||||
{
|
{
|
||||||
bool skip_duplicate_class_B = step == 0;
|
bool skip_duplicate_class_B = step == 0;
|
||||||
size_t idx = 0, skipped = 0;
|
size_t idx = 0, skipped = 0;
|
||||||
zone.m_peerlist.foreach (use_white_list, [&classB, &filtered, &idx, &skipped, skip_duplicate_class_B, limit, next_needed_pruning_stripe, &hosts_added, &get_host_string](const peerlist_entry &pe){
|
zone.m_peerlist.foreach (use_white_list, [&classB, &filtered, &idx, &skipped, skip_duplicate_class_B, limit, next_needed_pruning_stripe](const peerlist_entry &pe){
|
||||||
if (filtered.size() >= limit)
|
if (filtered.size() >= limit)
|
||||||
return false;
|
return false;
|
||||||
bool skip = false;
|
bool skip = false;
|
||||||
@@ -1550,27 +1448,6 @@ namespace nodetool
|
|||||||
uint32_t actual_ip = na.as<const epee::net_utils::ipv4_network_address>().ip();
|
uint32_t actual_ip = na.as<const epee::net_utils::ipv4_network_address>().ip();
|
||||||
skip = classB.find(actual_ip & 0x0000ffff) != classB.end();
|
skip = classB.find(actual_ip & 0x0000ffff) != classB.end();
|
||||||
}
|
}
|
||||||
else if (skip_duplicate_class_B && pe.adr.get_type_id() == epee::net_utils::ipv6_network_address::get_type_id())
|
|
||||||
{
|
|
||||||
const epee::net_utils::network_address na = pe.adr;
|
|
||||||
const boost::asio::ip::address_v6 &actual_ip = na.as<const epee::net_utils::ipv6_network_address>().ip();
|
|
||||||
if (actual_ip.is_v4_mapped())
|
|
||||||
{
|
|
||||||
boost::asio::ip::address_v4 v4ip = make_address_v4_from_v6(actual_ip);
|
|
||||||
uint32_t actual_ipv4;
|
|
||||||
memcpy(&actual_ipv4, v4ip.to_bytes().data(), sizeof(actual_ipv4));
|
|
||||||
skip = classB.find(actual_ipv4 & ntohl(0xffff0000)) != classB.end();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// consider each host once, to avoid giving undue inflence to hosts running several nodes
|
|
||||||
if (!skip)
|
|
||||||
{
|
|
||||||
const auto i = hosts_added.find(get_host_string(pe.adr));
|
|
||||||
if (i != hosts_added.end())
|
|
||||||
skip = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (skip)
|
if (skip)
|
||||||
++skipped;
|
++skipped;
|
||||||
else if (next_needed_pruning_stripe == 0 || pe.pruning_seed == 0)
|
else if (next_needed_pruning_stripe == 0 || pe.pruning_seed == 0)
|
||||||
@@ -1578,17 +1455,16 @@ namespace nodetool
|
|||||||
else if (next_needed_pruning_stripe == tools::get_pruning_stripe(pe.pruning_seed))
|
else if (next_needed_pruning_stripe == tools::get_pruning_stripe(pe.pruning_seed))
|
||||||
filtered.push_front(idx);
|
filtered.push_front(idx);
|
||||||
++idx;
|
++idx;
|
||||||
hosts_added.insert(get_host_string(pe.adr));
|
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
if (skipped == 0 || !filtered.empty())
|
if (skipped == 0 || !filtered.empty())
|
||||||
break;
|
break;
|
||||||
if (skipped)
|
if (skipped)
|
||||||
MDEBUG("Skipping " << skipped << " possible peers as they share a class B with existing peers");
|
MINFO("Skipping " << skipped << " possible peers as they share a class B with existing peers");
|
||||||
}
|
}
|
||||||
if (filtered.empty())
|
if (filtered.empty())
|
||||||
{
|
{
|
||||||
MINFO("No available peer in " << (use_white_list ? "white" : "gray") << " list filtered by " << next_needed_pruning_stripe);
|
MDEBUG("No available peer in " << (use_white_list ? "white" : "gray") << " list filtered by " << next_needed_pruning_stripe);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (use_white_list)
|
if (use_white_list)
|
||||||
@@ -1634,9 +1510,6 @@ namespace nodetool
|
|||||||
peerid_to_string(pe.id) << " " << pe.adr.str() << ", pruning seed " << epee::string_tools::to_string_hex(pe.pruning_seed) <<
|
peerid_to_string(pe.id) << " " << pe.adr.str() << ", pruning seed " << epee::string_tools::to_string_hex(pe.pruning_seed) <<
|
||||||
" (stripe " << next_needed_pruning_stripe << " needed)");
|
" (stripe " << next_needed_pruning_stripe << " needed)");
|
||||||
|
|
||||||
if(zone.m_our_address == pe.adr)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if(is_peer_used(pe)) {
|
if(is_peer_used(pe)) {
|
||||||
_note("Peer is used");
|
_note("Peer is used");
|
||||||
continue;
|
continue;
|
||||||
@@ -1944,52 +1817,6 @@ namespace nodetool
|
|||||||
m_gray_peerlist_housekeeping_interval.do_call(boost::bind(&node_server<t_payload_net_handler>::gray_peerlist_housekeeping, this));
|
m_gray_peerlist_housekeeping_interval.do_call(boost::bind(&node_server<t_payload_net_handler>::gray_peerlist_housekeeping, this));
|
||||||
m_peerlist_store_interval.do_call(boost::bind(&node_server<t_payload_net_handler>::store_config, this));
|
m_peerlist_store_interval.do_call(boost::bind(&node_server<t_payload_net_handler>::store_config, this));
|
||||||
m_incoming_connections_interval.do_call(boost::bind(&node_server<t_payload_net_handler>::check_incoming_connections, this));
|
m_incoming_connections_interval.do_call(boost::bind(&node_server<t_payload_net_handler>::check_incoming_connections, this));
|
||||||
m_dns_blocklist_interval.do_call(boost::bind(&node_server<t_payload_net_handler>::update_dns_blocklist, this));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
//-----------------------------------------------------------------------------------
|
|
||||||
template<class t_payload_net_handler>
|
|
||||||
bool node_server<t_payload_net_handler>::update_dns_blocklist()
|
|
||||||
{
|
|
||||||
if (!m_enable_dns_blocklist)
|
|
||||||
return true;
|
|
||||||
if (m_nettype != cryptonote::MAINNET)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
static const std::vector<std::string> dns_urls = {
|
|
||||||
"blocklist.moneropulse.se"
|
|
||||||
, "blocklist.moneropulse.org"
|
|
||||||
, "blocklist.moneropulse.net"
|
|
||||||
, "blocklist.moneropulse.no"
|
|
||||||
, "blocklist.moneropulse.fr"
|
|
||||||
, "blocklist.moneropulse.de"
|
|
||||||
, "blocklist.moneropulse.ch"
|
|
||||||
};
|
|
||||||
|
|
||||||
std::vector<std::string> records;
|
|
||||||
if (!tools::dns_utils::load_txt_records_from_dns(records, dns_urls))
|
|
||||||
return true;
|
|
||||||
|
|
||||||
unsigned good = 0, bad = 0;
|
|
||||||
for (const auto& record : records)
|
|
||||||
{
|
|
||||||
std::vector<std::string> ips;
|
|
||||||
boost::split(ips, record, boost::is_any_of(";"));
|
|
||||||
for (const auto &ip: ips)
|
|
||||||
{
|
|
||||||
const expect<epee::net_utils::network_address> parsed_addr = net::get_network_address(ip, 0);
|
|
||||||
if (!parsed_addr)
|
|
||||||
{
|
|
||||||
MWARNING("Invalid IP address from DNS blocklist: " << ip << " - " << parsed_addr.error());
|
|
||||||
++bad;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
block_host(*parsed_addr, DNS_BLOCKLIST_LIFETIME, true);
|
|
||||||
++good;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (good > 0)
|
|
||||||
MINFO(good << " addresses added to the blocklist");
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
//-----------------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------------
|
||||||
@@ -2091,11 +1918,6 @@ namespace nodetool
|
|||||||
template<class t_payload_net_handler>
|
template<class t_payload_net_handler>
|
||||||
bool node_server<t_payload_net_handler>::handle_remote_peerlist(const std::vector<peerlist_entry>& peerlist, const epee::net_utils::connection_context_base& context)
|
bool node_server<t_payload_net_handler>::handle_remote_peerlist(const std::vector<peerlist_entry>& peerlist, const epee::net_utils::connection_context_base& context)
|
||||||
{
|
{
|
||||||
if (peerlist.size() > P2P_MAX_PEERS_IN_HANDSHAKE)
|
|
||||||
{
|
|
||||||
MWARNING(context << "peer sent " << peerlist.size() << " peers, considered spamming");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
std::vector<peerlist_entry> peerlist_ = peerlist;
|
std::vector<peerlist_entry> peerlist_ = peerlist;
|
||||||
if(!sanitize_peerlist(peerlist_))
|
if(!sanitize_peerlist(peerlist_))
|
||||||
return false;
|
return false;
|
||||||
@@ -2112,10 +1934,7 @@ namespace nodetool
|
|||||||
|
|
||||||
LOG_DEBUG_CC(context, "REMOTE PEERLIST: remote peerlist size=" << peerlist_.size());
|
LOG_DEBUG_CC(context, "REMOTE PEERLIST: remote peerlist size=" << peerlist_.size());
|
||||||
LOG_TRACE_CC(context, "REMOTE PEERLIST: " << ENDL << print_peerlist_to_string(peerlist_));
|
LOG_TRACE_CC(context, "REMOTE PEERLIST: " << ENDL << print_peerlist_to_string(peerlist_));
|
||||||
CRITICAL_REGION_LOCAL(m_blocked_hosts_lock);
|
return m_network_zones.at(context.m_remote_address.get_zone()).m_peerlist.merge_peerlist(peerlist_, [this](const peerlist_entry &pe) { return !is_addr_recently_failed(pe.adr); });
|
||||||
return m_network_zones.at(context.m_remote_address.get_zone()).m_peerlist.merge_peerlist(peerlist_, [this](const peerlist_entry &pe) {
|
|
||||||
return !is_addr_recently_failed(pe.adr) && is_remote_host_allowed(pe.adr);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
//-----------------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------------
|
||||||
template<class t_payload_net_handler>
|
template<class t_payload_net_handler>
|
||||||
@@ -2272,7 +2091,7 @@ namespace nodetool
|
|||||||
|
|
||||||
const epee::net_utils::network_address na = context.m_remote_address;
|
const epee::net_utils::network_address na = context.m_remote_address;
|
||||||
std::string ip;
|
std::string ip;
|
||||||
uint32_t ipv4_addr = 0;
|
uint32_t ipv4_addr;
|
||||||
boost::asio::ip::address_v6 ipv6_addr;
|
boost::asio::ip::address_v6 ipv6_addr;
|
||||||
bool is_ipv4;
|
bool is_ipv4;
|
||||||
if (na.get_type_id() == epee::net_utils::ipv4_network_address::get_type_id())
|
if (na.get_type_id() == epee::net_utils::ipv4_network_address::get_type_id())
|
||||||
@@ -2435,14 +2254,12 @@ namespace nodetool
|
|||||||
template<class t_payload_net_handler>
|
template<class t_payload_net_handler>
|
||||||
int node_server<t_payload_net_handler>::handle_handshake(int command, typename COMMAND_HANDSHAKE::request& arg, typename COMMAND_HANDSHAKE::response& rsp, p2p_connection_context& context)
|
int node_server<t_payload_net_handler>::handle_handshake(int command, typename COMMAND_HANDSHAKE::request& arg, typename COMMAND_HANDSHAKE::response& rsp, p2p_connection_context& context)
|
||||||
{
|
{
|
||||||
// copy since dropping the connection will invalidate the context, and thus the address
|
|
||||||
const auto remote_address = context.m_remote_address;
|
|
||||||
|
|
||||||
if(arg.node_data.network_id != m_network_id)
|
if(arg.node_data.network_id != m_network_id)
|
||||||
{
|
{
|
||||||
|
|
||||||
LOG_INFO_CC(context, "WRONG NETWORK AGENT CONNECTED! id=" << arg.node_data.network_id);
|
LOG_INFO_CC(context, "WRONG NETWORK AGENT CONNECTED! id=" << arg.node_data.network_id);
|
||||||
drop_connection(context);
|
drop_connection(context);
|
||||||
add_host_fail(remote_address);
|
add_host_fail(context.m_remote_address);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2450,7 +2267,7 @@ namespace nodetool
|
|||||||
{
|
{
|
||||||
LOG_WARNING_CC(context, "COMMAND_HANDSHAKE came not from incoming connection");
|
LOG_WARNING_CC(context, "COMMAND_HANDSHAKE came not from incoming connection");
|
||||||
drop_connection(context);
|
drop_connection(context);
|
||||||
add_host_fail(remote_address);
|
add_host_fail(context.m_remote_address);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2461,12 +2278,11 @@ namespace nodetool
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto azone = context.m_remote_address.get_zone();
|
network_zone& zone = m_network_zones.at(context.m_remote_address.get_zone());
|
||||||
network_zone& zone = m_network_zones.at(azone);
|
|
||||||
|
|
||||||
// test only the remote end's zone, otherwise an attacker could connect to you on clearnet
|
// test only the remote end's zone, otherwise an attacker could connect to you on clearnet
|
||||||
// and pass in a tor connection's peer id, and deduce the two are the same if you reject it
|
// and pass in a tor connection's peer id, and deduce the two are the same if you reject it
|
||||||
if(azone == epee::net_utils::zone::public_ && arg.node_data.peer_id == zone.m_config.m_peer_id)
|
if(arg.node_data.peer_id == zone.m_config.m_peer_id)
|
||||||
{
|
{
|
||||||
LOG_DEBUG_CC(context, "Connection to self detected, dropping connection");
|
LOG_DEBUG_CC(context, "Connection to self detected, dropping connection");
|
||||||
drop_connection(context);
|
drop_connection(context);
|
||||||
@@ -2862,8 +2678,8 @@ namespace nodetool
|
|||||||
const uint32_t index = stripe - 1;
|
const uint32_t index = stripe - 1;
|
||||||
CRITICAL_REGION_LOCAL(m_used_stripe_peers_mutex);
|
CRITICAL_REGION_LOCAL(m_used_stripe_peers_mutex);
|
||||||
MINFO("adding stripe " << stripe << " peer: " << context.m_remote_address.str());
|
MINFO("adding stripe " << stripe << " peer: " << context.m_remote_address.str());
|
||||||
m_used_stripe_peers[index].erase(std::remove_if(m_used_stripe_peers[index].begin(), m_used_stripe_peers[index].end(),
|
std::remove_if(m_used_stripe_peers[index].begin(), m_used_stripe_peers[index].end(),
|
||||||
[&context](const epee::net_utils::network_address &na){ return context.m_remote_address == na; }), m_used_stripe_peers[index].end());
|
[&context](const epee::net_utils::network_address &na){ return context.m_remote_address == na; });
|
||||||
m_used_stripe_peers[index].push_back(context.m_remote_address);
|
m_used_stripe_peers[index].push_back(context.m_remote_address);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2876,8 +2692,8 @@ namespace nodetool
|
|||||||
const uint32_t index = stripe - 1;
|
const uint32_t index = stripe - 1;
|
||||||
CRITICAL_REGION_LOCAL(m_used_stripe_peers_mutex);
|
CRITICAL_REGION_LOCAL(m_used_stripe_peers_mutex);
|
||||||
MINFO("removing stripe " << stripe << " peer: " << context.m_remote_address.str());
|
MINFO("removing stripe " << stripe << " peer: " << context.m_remote_address.str());
|
||||||
m_used_stripe_peers[index].erase(std::remove_if(m_used_stripe_peers[index].begin(), m_used_stripe_peers[index].end(),
|
std::remove_if(m_used_stripe_peers[index].begin(), m_used_stripe_peers[index].end(),
|
||||||
[&context](const epee::net_utils::network_address &na){ return context.m_remote_address == na; }), m_used_stripe_peers[index].end());
|
[&context](const epee::net_utils::network_address &na){ return context.m_remote_address == na; });
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class t_payload_net_handler>
|
template<class t_payload_net_handler>
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ namespace nodetool
|
|||||||
virtual uint64_t get_public_connections_count()=0;
|
virtual uint64_t get_public_connections_count()=0;
|
||||||
virtual void for_each_connection(std::function<bool(t_connection_context&, peerid_type, uint32_t)> f)=0;
|
virtual void for_each_connection(std::function<bool(t_connection_context&, peerid_type, uint32_t)> f)=0;
|
||||||
virtual bool for_connection(const boost::uuids::uuid&, std::function<bool(t_connection_context&, peerid_type, uint32_t)> f)=0;
|
virtual bool for_connection(const boost::uuids::uuid&, std::function<bool(t_connection_context&, peerid_type, uint32_t)> f)=0;
|
||||||
virtual bool block_host(epee::net_utils::network_address address, time_t seconds = 0, bool add_only = false)=0;
|
virtual bool block_host(const epee::net_utils::network_address &address, time_t seconds = 0)=0;
|
||||||
virtual bool unblock_host(const epee::net_utils::network_address &address)=0;
|
virtual bool unblock_host(const epee::net_utils::network_address &address)=0;
|
||||||
virtual std::map<std::string, time_t> get_blocked_hosts()=0;
|
virtual std::map<std::string, time_t> get_blocked_hosts()=0;
|
||||||
virtual std::map<epee::net_utils::ipv4_network_subnet, time_t> get_blocked_subnets()=0;
|
virtual std::map<epee::net_utils::ipv4_network_subnet, time_t> get_blocked_subnets()=0;
|
||||||
@@ -108,7 +108,7 @@ namespace nodetool
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
virtual bool block_host(epee::net_utils::network_address address, time_t seconds, bool add_only)
|
virtual bool block_host(const epee::net_utils::network_address &address, time_t seconds)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -288,19 +288,6 @@ namespace nodetool
|
|||||||
copy_peers(peers.gray, m_peers_gray.get<by_addr>());
|
copy_peers(peers.gray, m_peers_gray.get<by_addr>());
|
||||||
copy_peers(peers.anchor, m_peers_anchor.get<by_addr>());
|
copy_peers(peers.anchor, m_peers_anchor.get<by_addr>());
|
||||||
}
|
}
|
||||||
|
|
||||||
void peerlist_manager::evict_host_from_white_peerlist(const peerlist_entry& pr)
|
|
||||||
{
|
|
||||||
peers_indexed::index<by_time>::type& sorted_index=m_peers_white.get<by_time>();
|
|
||||||
auto i = sorted_index.begin();
|
|
||||||
while (i != sorted_index.end())
|
|
||||||
{
|
|
||||||
if (i->adr.is_same_host(pr.adr))
|
|
||||||
i = sorted_index.erase(i);
|
|
||||||
else
|
|
||||||
++i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_CLASS_VERSION(nodetool::peerlist_types, nodetool::CURRENT_PEERLIST_STORAGE_ARCHIVE_VER);
|
BOOST_CLASS_VERSION(nodetool::peerlist_types, nodetool::CURRENT_PEERLIST_STORAGE_ARCHIVE_VER);
|
||||||
|
|||||||
@@ -109,7 +109,6 @@ namespace nodetool
|
|||||||
bool get_white_peer_by_index(peerlist_entry& p, size_t i);
|
bool get_white_peer_by_index(peerlist_entry& p, size_t i);
|
||||||
bool get_gray_peer_by_index(peerlist_entry& p, size_t i);
|
bool get_gray_peer_by_index(peerlist_entry& p, size_t i);
|
||||||
template<typename F> bool foreach(bool white, const F &f);
|
template<typename F> bool foreach(bool white, const F &f);
|
||||||
void evict_host_from_white_peerlist(const peerlist_entry& pr);
|
|
||||||
bool append_with_peer_white(const peerlist_entry& pr);
|
bool append_with_peer_white(const peerlist_entry& pr);
|
||||||
bool append_with_peer_gray(const peerlist_entry& pr);
|
bool append_with_peer_gray(const peerlist_entry& pr);
|
||||||
bool append_with_peer_anchor(const anchor_peerlist_entry& ple);
|
bool append_with_peer_anchor(const anchor_peerlist_entry& ple);
|
||||||
@@ -346,7 +345,6 @@ namespace nodetool
|
|||||||
if(by_addr_it_wt == m_peers_white.get<by_addr>().end())
|
if(by_addr_it_wt == m_peers_white.get<by_addr>().end())
|
||||||
{
|
{
|
||||||
//put new record into white list
|
//put new record into white list
|
||||||
evict_host_from_white_peerlist(ple);
|
|
||||||
m_peers_white.insert(ple);
|
m_peers_white.insert(ple);
|
||||||
trim_white_peerlist();
|
trim_white_peerlist();
|
||||||
}else
|
}else
|
||||||
|
|||||||
@@ -826,7 +826,7 @@ bool bulletproof_VERIFY(const std::vector<const Bulletproof*> &proofs)
|
|||||||
proof_data.reserve(proofs.size());
|
proof_data.reserve(proofs.size());
|
||||||
size_t inv_offset = 0;
|
size_t inv_offset = 0;
|
||||||
std::vector<rct::key> to_invert;
|
std::vector<rct::key> to_invert;
|
||||||
to_invert.reserve(11 * proofs.size());
|
to_invert.reserve(11 * sizeof(proofs));
|
||||||
size_t max_logM = 0;
|
size_t max_logM = 0;
|
||||||
for (const Bulletproof *p: proofs)
|
for (const Bulletproof *p: proofs)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ set(rpc_pub_headers zmq_pub.h)
|
|||||||
|
|
||||||
set(daemon_rpc_server_headers)
|
set(daemon_rpc_server_headers)
|
||||||
|
|
||||||
set(rpc_private_headers
|
set(rpc_daemon_private_headers
|
||||||
bootstrap_daemon.h
|
bootstrap_daemon.h
|
||||||
core_rpc_server.h
|
core_rpc_server.h
|
||||||
rpc_payment.h
|
rpc_payment.h
|
||||||
|
|||||||
@@ -45,12 +45,12 @@ namespace cryptonote
|
|||||||
return host + ":" + m_http_client.get_port();
|
return host + ":" + m_http_client.get_port();
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::optional<std::pair<uint64_t, uint64_t>> bootstrap_daemon::get_height()
|
boost::optional<uint64_t> bootstrap_daemon::get_height()
|
||||||
{
|
{
|
||||||
cryptonote::COMMAND_RPC_GET_INFO::request req;
|
cryptonote::COMMAND_RPC_GET_HEIGHT::request req;
|
||||||
cryptonote::COMMAND_RPC_GET_INFO::response res;
|
cryptonote::COMMAND_RPC_GET_HEIGHT::response res;
|
||||||
|
|
||||||
if (!invoke_http_json("/getinfo", req, res))
|
if (!invoke_http_json("/getheight", req, res))
|
||||||
{
|
{
|
||||||
return boost::none;
|
return boost::none;
|
||||||
}
|
}
|
||||||
@@ -60,7 +60,7 @@ namespace cryptonote
|
|||||||
return boost::none;
|
return boost::none;
|
||||||
}
|
}
|
||||||
|
|
||||||
return {{res.height, res.target_height}};
|
return res.height;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool bootstrap_daemon::handle_result(bool success, const std::string &status)
|
bool bootstrap_daemon::handle_result(bool success, const std::string &status)
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <utility>
|
|
||||||
|
|
||||||
#include <boost/optional/optional.hpp>
|
#include <boost/optional/optional.hpp>
|
||||||
#include <boost/thread/mutex.hpp>
|
#include <boost/thread/mutex.hpp>
|
||||||
@@ -28,7 +27,7 @@ namespace cryptonote
|
|||||||
bool rpc_payment_enabled);
|
bool rpc_payment_enabled);
|
||||||
|
|
||||||
std::string address() const noexcept;
|
std::string address() const noexcept;
|
||||||
boost::optional<std::pair<uint64_t, uint64_t>> get_height();
|
boost::optional<uint64_t> get_height();
|
||||||
bool handle_result(bool success, const std::string &status);
|
bool handle_result(bool success, const std::string &status);
|
||||||
|
|
||||||
template <class t_request, class t_response>
|
template <class t_request, class t_response>
|
||||||
|
|||||||
@@ -190,7 +190,6 @@ namespace cryptonote
|
|||||||
|
|
||||||
request.gray = true;
|
request.gray = true;
|
||||||
request.white = true;
|
request.white = true;
|
||||||
request.include_blocked = false;
|
|
||||||
if (!on_get_public_nodes(request, response) || response.status != CORE_RPC_STATUS_OK)
|
if (!on_get_public_nodes(request, response) || response.status != CORE_RPC_STATUS_OK)
|
||||||
{
|
{
|
||||||
return {};
|
return {};
|
||||||
@@ -265,18 +264,6 @@ namespace cryptonote
|
|||||||
if (!rpc_config)
|
if (!rpc_config)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
std::string bind_ip_str = rpc_config->bind_ip;
|
|
||||||
std::string bind_ipv6_str = rpc_config->bind_ipv6_address;
|
|
||||||
if (restricted)
|
|
||||||
{
|
|
||||||
const auto restricted_rpc_port_arg = cryptonote::core_rpc_server::arg_rpc_restricted_bind_port;
|
|
||||||
const bool has_restricted_rpc_port_arg = !command_line::is_arg_defaulted(vm, restricted_rpc_port_arg);
|
|
||||||
if (has_restricted_rpc_port_arg && port == command_line::get_arg(vm, restricted_rpc_port_arg))
|
|
||||||
{
|
|
||||||
bind_ip_str = rpc_config->restricted_bind_ip;
|
|
||||||
bind_ipv6_str = rpc_config->restricted_bind_ipv6_address;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
disable_rpc_ban = rpc_config->disable_rpc_ban;
|
disable_rpc_ban = rpc_config->disable_rpc_ban;
|
||||||
std::string address = command_line::get_arg(vm, arg_rpc_payment_address);
|
std::string address = command_line::get_arg(vm, arg_rpc_payment_address);
|
||||||
if (!address.empty() && allow_rpc_payment)
|
if (!address.empty() && allow_rpc_payment)
|
||||||
@@ -313,7 +300,7 @@ namespace cryptonote
|
|||||||
if (!m_rpc_payment)
|
if (!m_rpc_payment)
|
||||||
{
|
{
|
||||||
uint32_t bind_ip;
|
uint32_t bind_ip;
|
||||||
bool ok = epee::string_tools::get_ip_int32_from_string(bind_ip, bind_ip_str);
|
bool ok = epee::string_tools::get_ip_int32_from_string(bind_ip, rpc_config->bind_ip);
|
||||||
if (ok & !epee::net_utils::is_ip_loopback(bind_ip))
|
if (ok & !epee::net_utils::is_ip_loopback(bind_ip))
|
||||||
MWARNING("The RPC server is accessible from the outside, but no RPC payment was setup. RPC access will be free for all.");
|
MWARNING("The RPC server is accessible from the outside, but no RPC payment was setup. RPC access will be free for all.");
|
||||||
}
|
}
|
||||||
@@ -335,8 +322,8 @@ namespace cryptonote
|
|||||||
|
|
||||||
auto rng = [](size_t len, uint8_t *ptr){ return crypto::rand(len, ptr); };
|
auto rng = [](size_t len, uint8_t *ptr){ return crypto::rand(len, ptr); };
|
||||||
return epee::http_server_impl_base<core_rpc_server, connection_context>::init(
|
return epee::http_server_impl_base<core_rpc_server, connection_context>::init(
|
||||||
rng, std::move(port), std::move(bind_ip_str),
|
rng, std::move(port), std::move(rpc_config->bind_ip),
|
||||||
std::move(bind_ipv6_str), std::move(rpc_config->use_ipv6), std::move(rpc_config->require_ipv4),
|
std::move(rpc_config->bind_ipv6_address), std::move(rpc_config->use_ipv6), std::move(rpc_config->require_ipv4),
|
||||||
std::move(rpc_config->access_control_origins), std::move(http_login), std::move(rpc_config->ssl_options)
|
std::move(rpc_config->access_control_origins), std::move(http_login), std::move(rpc_config->ssl_options)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -499,9 +486,6 @@ namespace cryptonote
|
|||||||
res.database_size = round_up(res.database_size, 5ull* 1024 * 1024 * 1024);
|
res.database_size = round_up(res.database_size, 5ull* 1024 * 1024 * 1024);
|
||||||
res.update_available = restricted ? false : m_core.is_update_available();
|
res.update_available = restricted ? false : m_core.is_update_available();
|
||||||
res.version = restricted ? "" : MONERO_VERSION_FULL;
|
res.version = restricted ? "" : MONERO_VERSION_FULL;
|
||||||
res.synchronized = check_core_ready();
|
|
||||||
res.busy_syncing = m_p2p.get_payload_object().is_busy_syncing();
|
|
||||||
res.synchronized = check_core_ready();
|
|
||||||
|
|
||||||
res.status = CORE_RPC_STATUS_OK;
|
res.status = CORE_RPC_STATUS_OK;
|
||||||
return true;
|
return true;
|
||||||
@@ -566,12 +550,12 @@ namespace cryptonote
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t max_blocks = COMMAND_RPC_GET_BLOCKS_FAST_MAX_BLOCK_COUNT;
|
size_t max_blocks = COMMAND_RPC_GET_BLOCKS_FAST_MAX_COUNT;
|
||||||
if (m_rpc_payment)
|
if (m_rpc_payment)
|
||||||
{
|
{
|
||||||
max_blocks = res.credits / COST_PER_BLOCK;
|
max_blocks = res.credits / COST_PER_BLOCK;
|
||||||
if (max_blocks > COMMAND_RPC_GET_BLOCKS_FAST_MAX_BLOCK_COUNT)
|
if (max_blocks > COMMAND_RPC_GET_BLOCKS_FAST_MAX_COUNT)
|
||||||
max_blocks = COMMAND_RPC_GET_BLOCKS_FAST_MAX_BLOCK_COUNT;
|
max_blocks = COMMAND_RPC_GET_BLOCKS_FAST_MAX_COUNT;
|
||||||
if (max_blocks == 0)
|
if (max_blocks == 0)
|
||||||
{
|
{
|
||||||
res.status = CORE_RPC_STATUS_PAYMENT_REQUIRED;
|
res.status = CORE_RPC_STATUS_PAYMENT_REQUIRED;
|
||||||
@@ -580,7 +564,7 @@ namespace cryptonote
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::pair<std::pair<cryptonote::blobdata, crypto::hash>, std::vector<std::pair<crypto::hash, cryptonote::blobdata> > > > bs;
|
std::vector<std::pair<std::pair<cryptonote::blobdata, crypto::hash>, std::vector<std::pair<crypto::hash, cryptonote::blobdata> > > > bs;
|
||||||
if(!m_core.find_blockchain_supplement(req.start_height, req.block_ids, bs, res.current_height, res.start_height, req.prune, !req.no_miner_tx, max_blocks, COMMAND_RPC_GET_BLOCKS_FAST_MAX_TX_COUNT))
|
if(!m_core.find_blockchain_supplement(req.start_height, req.block_ids, bs, res.current_height, res.start_height, req.prune, !req.no_miner_tx, max_blocks))
|
||||||
{
|
{
|
||||||
res.status = "Failed";
|
res.status = "Failed";
|
||||||
add_host_fail(ctx);
|
add_host_fail(ctx);
|
||||||
@@ -1147,18 +1131,13 @@ namespace cryptonote
|
|||||||
{
|
{
|
||||||
RPC_TRACKER(send_raw_tx);
|
RPC_TRACKER(send_raw_tx);
|
||||||
|
|
||||||
{
|
|
||||||
bool ok;
|
|
||||||
use_bootstrap_daemon_if_necessary<COMMAND_RPC_SEND_RAW_TX>(invoke_http_mode::JON, "/sendrawtransaction", req, res, ok);
|
|
||||||
}
|
|
||||||
|
|
||||||
const bool restricted = m_restricted && ctx;
|
const bool restricted = m_restricted && ctx;
|
||||||
|
|
||||||
bool skip_validation = false;
|
bool skip_validation = false;
|
||||||
if (!restricted)
|
if (!restricted)
|
||||||
{
|
{
|
||||||
boost::shared_lock<boost::shared_mutex> lock(m_bootstrap_daemon_mutex);
|
boost::shared_lock<boost::shared_mutex> lock(m_bootstrap_daemon_mutex);
|
||||||
if (m_should_use_bootstrap_daemon)
|
if (m_bootstrap_daemon.get() != nullptr)
|
||||||
{
|
{
|
||||||
skip_validation = !check_core_ready();
|
skip_validation = !check_core_ready();
|
||||||
}
|
}
|
||||||
@@ -1167,10 +1146,6 @@ namespace cryptonote
|
|||||||
CHECK_CORE_READY();
|
CHECK_CORE_READY();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
CHECK_CORE_READY();
|
|
||||||
}
|
|
||||||
|
|
||||||
CHECK_PAYMENT_MIN1(req, res, COST_PER_TX_RELAY, false);
|
CHECK_PAYMENT_MIN1(req, res, COST_PER_TX_RELAY, false);
|
||||||
|
|
||||||
@@ -1385,8 +1360,6 @@ namespace cryptonote
|
|||||||
|
|
||||||
for (auto & entry : white_list)
|
for (auto & entry : white_list)
|
||||||
{
|
{
|
||||||
if (!req.include_blocked && m_p2p.is_host_blocked(entry.adr, NULL))
|
|
||||||
continue;
|
|
||||||
if (entry.adr.get_type_id() == epee::net_utils::ipv4_network_address::get_type_id())
|
if (entry.adr.get_type_id() == epee::net_utils::ipv4_network_address::get_type_id())
|
||||||
res.white_list.emplace_back(entry.id, entry.adr.as<epee::net_utils::ipv4_network_address>().ip(),
|
res.white_list.emplace_back(entry.id, entry.adr.as<epee::net_utils::ipv4_network_address>().ip(),
|
||||||
entry.adr.as<epee::net_utils::ipv4_network_address>().port(), entry.last_seen, entry.pruning_seed, entry.rpc_port, entry.rpc_credits_per_hash);
|
entry.adr.as<epee::net_utils::ipv4_network_address>().port(), entry.last_seen, entry.pruning_seed, entry.rpc_port, entry.rpc_credits_per_hash);
|
||||||
@@ -1399,8 +1372,6 @@ namespace cryptonote
|
|||||||
|
|
||||||
for (auto & entry : gray_list)
|
for (auto & entry : gray_list)
|
||||||
{
|
{
|
||||||
if (!req.include_blocked && m_p2p.is_host_blocked(entry.adr, NULL))
|
|
||||||
continue;
|
|
||||||
if (entry.adr.get_type_id() == epee::net_utils::ipv4_network_address::get_type_id())
|
if (entry.adr.get_type_id() == epee::net_utils::ipv4_network_address::get_type_id())
|
||||||
res.gray_list.emplace_back(entry.id, entry.adr.as<epee::net_utils::ipv4_network_address>().ip(),
|
res.gray_list.emplace_back(entry.id, entry.adr.as<epee::net_utils::ipv4_network_address>().ip(),
|
||||||
entry.adr.as<epee::net_utils::ipv4_network_address>().port(), entry.last_seen, entry.pruning_seed, entry.rpc_port, entry.rpc_credits_per_hash);
|
entry.adr.as<epee::net_utils::ipv4_network_address>().port(), entry.last_seen, entry.pruning_seed, entry.rpc_port, entry.rpc_credits_per_hash);
|
||||||
@@ -1419,10 +1390,8 @@ namespace cryptonote
|
|||||||
{
|
{
|
||||||
RPC_TRACKER(get_public_nodes);
|
RPC_TRACKER(get_public_nodes);
|
||||||
|
|
||||||
COMMAND_RPC_GET_PEER_LIST::request peer_list_req;
|
|
||||||
COMMAND_RPC_GET_PEER_LIST::response peer_list_res;
|
COMMAND_RPC_GET_PEER_LIST::response peer_list_res;
|
||||||
peer_list_req.include_blocked = req.include_blocked;
|
const bool success = on_get_peer_list(COMMAND_RPC_GET_PEER_LIST::request(), peer_list_res, ctx);
|
||||||
const bool success = on_get_peer_list(peer_list_req, peer_list_res, ctx);
|
|
||||||
res.status = peer_list_res.status;
|
res.status = peer_list_res.status;
|
||||||
if (!success)
|
if (!success)
|
||||||
{
|
{
|
||||||
@@ -2014,37 +1983,34 @@ namespace cryptonote
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto current_time = std::chrono::system_clock::now();
|
auto current_time = std::chrono::system_clock::now();
|
||||||
if (current_time - m_bootstrap_height_check_time > std::chrono::seconds(30)) // update every 30s
|
if (!m_p2p.get_payload_object().no_sync() &&
|
||||||
|
current_time - m_bootstrap_height_check_time > std::chrono::seconds(30)) // update every 30s
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
boost::upgrade_to_unique_lock<boost::shared_mutex> lock(upgrade_lock);
|
boost::upgrade_to_unique_lock<boost::shared_mutex> lock(upgrade_lock);
|
||||||
m_bootstrap_height_check_time = current_time;
|
m_bootstrap_height_check_time = current_time;
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::optional<std::pair<uint64_t, uint64_t>> bootstrap_daemon_height_info = m_bootstrap_daemon->get_height();
|
boost::optional<uint64_t> bootstrap_daemon_height = m_bootstrap_daemon->get_height();
|
||||||
if (!bootstrap_daemon_height_info)
|
if (!bootstrap_daemon_height)
|
||||||
{
|
{
|
||||||
MERROR("Failed to fetch bootstrap daemon height");
|
MERROR("Failed to fetch bootstrap daemon height");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const uint64_t bootstrap_daemon_height = bootstrap_daemon_height_info->first;
|
uint64_t target_height = m_core.get_target_blockchain_height();
|
||||||
const uint64_t bootstrap_daemon_target_height = bootstrap_daemon_height_info->second;
|
if (*bootstrap_daemon_height < target_height)
|
||||||
if (bootstrap_daemon_height < bootstrap_daemon_target_height)
|
|
||||||
{
|
{
|
||||||
MINFO("Bootstrap daemon is out of sync");
|
MINFO("Bootstrap daemon is out of sync");
|
||||||
return m_bootstrap_daemon->handle_result(false, {});
|
return m_bootstrap_daemon->handle_result(false, {});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!m_p2p.get_payload_object().no_sync())
|
uint64_t top_height = m_core.get_current_blockchain_height();
|
||||||
{
|
m_should_use_bootstrap_daemon = top_height + 10 < *bootstrap_daemon_height;
|
||||||
uint64_t top_height = m_core.get_current_blockchain_height();
|
MINFO((m_should_use_bootstrap_daemon ? "Using" : "Not using") << " the bootstrap daemon (our height: " << top_height << ", bootstrap daemon's height: " << *bootstrap_daemon_height << ")");
|
||||||
m_should_use_bootstrap_daemon = top_height + 10 < bootstrap_daemon_height;
|
|
||||||
MINFO((m_should_use_bootstrap_daemon ? "Using" : "Not using") << " the bootstrap daemon (our height: " << top_height << ", bootstrap daemon's height: " << bootstrap_daemon_height << ")");
|
|
||||||
|
|
||||||
if (!m_should_use_bootstrap_daemon)
|
if (!m_should_use_bootstrap_daemon)
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mode == invoke_http_mode::JON)
|
if (mode == invoke_http_mode::JON)
|
||||||
@@ -2924,7 +2890,11 @@ namespace cryptonote
|
|||||||
block_queue.foreach([&](const cryptonote::block_queue::span &span) {
|
block_queue.foreach([&](const cryptonote::block_queue::span &span) {
|
||||||
const std::string span_connection_id = epee::string_tools::pod_to_hex(span.connection_id);
|
const std::string span_connection_id = epee::string_tools::pod_to_hex(span.connection_id);
|
||||||
uint32_t speed = (uint32_t)(100.0f * block_queue.get_speed(span.connection_id) + 0.5f);
|
uint32_t speed = (uint32_t)(100.0f * block_queue.get_speed(span.connection_id) + 0.5f);
|
||||||
res.spans.push_back({span.start_block_height, span.nblocks, span_connection_id, (uint32_t)(span.rate + 0.5f), speed, span.size, span.origin.str()});
|
std::string address = "";
|
||||||
|
for (const auto &c: m_p2p.get_payload_object().get_connections())
|
||||||
|
if (c.connection_id == span_connection_id)
|
||||||
|
address = c.address;
|
||||||
|
res.spans.push_back({span.start_block_height, span.nblocks, span_connection_id, (uint32_t)(span.rate + 0.5f), speed, span.size, address});
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
res.overview = block_queue.get_overview(res.height);
|
res.overview = block_queue.get_overview(res.height);
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ namespace cryptonote
|
|||||||
// advance which version they will stop working with
|
// advance which version they will stop working with
|
||||||
// Don't go over 32767 for any of these
|
// Don't go over 32767 for any of these
|
||||||
#define CORE_RPC_VERSION_MAJOR 3
|
#define CORE_RPC_VERSION_MAJOR 3
|
||||||
#define CORE_RPC_VERSION_MINOR 5
|
#define CORE_RPC_VERSION_MINOR 2
|
||||||
#define MAKE_CORE_RPC_VERSION(major,minor) (((major)<<16)|(minor))
|
#define MAKE_CORE_RPC_VERSION(major,minor) (((major)<<16)|(minor))
|
||||||
#define CORE_RPC_VERSION MAKE_CORE_RPC_VERSION(CORE_RPC_VERSION_MAJOR, CORE_RPC_VERSION_MINOR)
|
#define CORE_RPC_VERSION MAKE_CORE_RPC_VERSION(CORE_RPC_VERSION_MAJOR, CORE_RPC_VERSION_MINOR)
|
||||||
|
|
||||||
@@ -684,9 +684,7 @@ namespace cryptonote
|
|||||||
bool was_bootstrap_ever_used;
|
bool was_bootstrap_ever_used;
|
||||||
uint64_t database_size;
|
uint64_t database_size;
|
||||||
bool update_available;
|
bool update_available;
|
||||||
bool busy_syncing;
|
|
||||||
std::string version;
|
std::string version;
|
||||||
bool synchronized;
|
|
||||||
|
|
||||||
BEGIN_KV_SERIALIZE_MAP()
|
BEGIN_KV_SERIALIZE_MAP()
|
||||||
KV_SERIALIZE_PARENT(rpc_access_response_base)
|
KV_SERIALIZE_PARENT(rpc_access_response_base)
|
||||||
@@ -725,9 +723,7 @@ namespace cryptonote
|
|||||||
KV_SERIALIZE(was_bootstrap_ever_used)
|
KV_SERIALIZE(was_bootstrap_ever_used)
|
||||||
KV_SERIALIZE(database_size)
|
KV_SERIALIZE(database_size)
|
||||||
KV_SERIALIZE(update_available)
|
KV_SERIALIZE(update_available)
|
||||||
KV_SERIALIZE(busy_syncing)
|
|
||||||
KV_SERIALIZE(version)
|
KV_SERIALIZE(version)
|
||||||
KV_SERIALIZE(synchronized)
|
|
||||||
END_KV_SERIALIZE_MAP()
|
END_KV_SERIALIZE_MAP()
|
||||||
};
|
};
|
||||||
typedef epee::misc_utils::struct_init<response_t> response;
|
typedef epee::misc_utils::struct_init<response_t> response;
|
||||||
@@ -1197,12 +1193,10 @@ namespace cryptonote
|
|||||||
struct request_t: public rpc_request_base
|
struct request_t: public rpc_request_base
|
||||||
{
|
{
|
||||||
bool public_only;
|
bool public_only;
|
||||||
bool include_blocked;
|
|
||||||
|
|
||||||
BEGIN_KV_SERIALIZE_MAP()
|
BEGIN_KV_SERIALIZE_MAP()
|
||||||
KV_SERIALIZE_PARENT(rpc_request_base)
|
KV_SERIALIZE_PARENT(rpc_request_base)
|
||||||
KV_SERIALIZE_OPT(public_only, true)
|
KV_SERIALIZE_OPT(public_only, true)
|
||||||
KV_SERIALIZE_OPT(include_blocked, false)
|
|
||||||
END_KV_SERIALIZE_MAP()
|
END_KV_SERIALIZE_MAP()
|
||||||
};
|
};
|
||||||
typedef epee::misc_utils::struct_init<request_t> request;
|
typedef epee::misc_utils::struct_init<request_t> request;
|
||||||
@@ -1248,13 +1242,11 @@ namespace cryptonote
|
|||||||
{
|
{
|
||||||
bool gray;
|
bool gray;
|
||||||
bool white;
|
bool white;
|
||||||
bool include_blocked;
|
|
||||||
|
|
||||||
BEGIN_KV_SERIALIZE_MAP()
|
BEGIN_KV_SERIALIZE_MAP()
|
||||||
KV_SERIALIZE_PARENT(rpc_request_base)
|
KV_SERIALIZE_PARENT(rpc_request_base)
|
||||||
KV_SERIALIZE_OPT(gray, false)
|
KV_SERIALIZE_OPT(gray, false)
|
||||||
KV_SERIALIZE_OPT(white, true)
|
KV_SERIALIZE_OPT(white, true)
|
||||||
KV_SERIALIZE_OPT(include_blocked, false)
|
|
||||||
END_KV_SERIALIZE_MAP()
|
END_KV_SERIALIZE_MAP()
|
||||||
};
|
};
|
||||||
typedef epee::misc_utils::struct_init<request_t> request;
|
typedef epee::misc_utils::struct_init<request_t> request;
|
||||||
|
|||||||
@@ -128,7 +128,7 @@ namespace rpc
|
|||||||
{
|
{
|
||||||
std::vector<std::pair<std::pair<blobdata, crypto::hash>, std::vector<std::pair<crypto::hash, blobdata> > > > blocks;
|
std::vector<std::pair<std::pair<blobdata, crypto::hash>, std::vector<std::pair<crypto::hash, blobdata> > > > blocks;
|
||||||
|
|
||||||
if(!m_core.find_blockchain_supplement(req.start_height, req.block_ids, blocks, res.current_height, res.start_height, req.prune, true, COMMAND_RPC_GET_BLOCKS_FAST_MAX_BLOCK_COUNT, COMMAND_RPC_GET_BLOCKS_FAST_MAX_TX_COUNT))
|
if(!m_core.find_blockchain_supplement(req.start_height, req.block_ids, blocks, res.current_height, res.start_height, req.prune, true, COMMAND_RPC_GET_BLOCKS_FAST_MAX_COUNT))
|
||||||
{
|
{
|
||||||
res.status = Message::STATUS_FAILED;
|
res.status = Message::STATUS_FAILED;
|
||||||
res.error_details = "core::find_blockchain_supplement() returned false";
|
res.error_details = "core::find_blockchain_supplement() returned false";
|
||||||
|
|||||||
@@ -91,8 +91,6 @@ namespace cryptonote
|
|||||||
rpc_args::descriptors::descriptors()
|
rpc_args::descriptors::descriptors()
|
||||||
: rpc_bind_ip({"rpc-bind-ip", rpc_args::tr("Specify IP to bind RPC server"), "127.0.0.1"})
|
: rpc_bind_ip({"rpc-bind-ip", rpc_args::tr("Specify IP to bind RPC server"), "127.0.0.1"})
|
||||||
, rpc_bind_ipv6_address({"rpc-bind-ipv6-address", rpc_args::tr("Specify IPv6 address to bind RPC server"), "::1"})
|
, rpc_bind_ipv6_address({"rpc-bind-ipv6-address", rpc_args::tr("Specify IPv6 address to bind RPC server"), "::1"})
|
||||||
, rpc_restricted_bind_ip({"rpc-restricted-bind-ip", rpc_args::tr("Specify IP to bind restricted RPC server"), "127.0.0.1"})
|
|
||||||
, rpc_restricted_bind_ipv6_address({"rpc-restricted-bind-ipv6-address", rpc_args::tr("Specify IPv6 address to bind restricted RPC server"), "::1"})
|
|
||||||
, rpc_use_ipv6({"rpc-use-ipv6", rpc_args::tr("Allow IPv6 for RPC"), false})
|
, rpc_use_ipv6({"rpc-use-ipv6", rpc_args::tr("Allow IPv6 for RPC"), false})
|
||||||
, rpc_ignore_ipv4({"rpc-ignore-ipv4", rpc_args::tr("Ignore unsuccessful IPv4 bind for RPC"), false})
|
, rpc_ignore_ipv4({"rpc-ignore-ipv4", rpc_args::tr("Ignore unsuccessful IPv4 bind for RPC"), false})
|
||||||
, rpc_login({"rpc-login", rpc_args::tr("Specify username[:password] required for RPC server"), "", true})
|
, rpc_login({"rpc-login", rpc_args::tr("Specify username[:password] required for RPC server"), "", true})
|
||||||
@@ -115,8 +113,6 @@ namespace cryptonote
|
|||||||
const descriptors arg{};
|
const descriptors arg{};
|
||||||
command_line::add_arg(desc, arg.rpc_bind_ip);
|
command_line::add_arg(desc, arg.rpc_bind_ip);
|
||||||
command_line::add_arg(desc, arg.rpc_bind_ipv6_address);
|
command_line::add_arg(desc, arg.rpc_bind_ipv6_address);
|
||||||
command_line::add_arg(desc, arg.rpc_restricted_bind_ip);
|
|
||||||
command_line::add_arg(desc, arg.rpc_restricted_bind_ipv6_address);
|
|
||||||
command_line::add_arg(desc, arg.rpc_use_ipv6);
|
command_line::add_arg(desc, arg.rpc_use_ipv6);
|
||||||
command_line::add_arg(desc, arg.rpc_ignore_ipv4);
|
command_line::add_arg(desc, arg.rpc_ignore_ipv4);
|
||||||
command_line::add_arg(desc, arg.rpc_login);
|
command_line::add_arg(desc, arg.rpc_login);
|
||||||
@@ -140,8 +136,6 @@ namespace cryptonote
|
|||||||
|
|
||||||
config.bind_ip = command_line::get_arg(vm, arg.rpc_bind_ip);
|
config.bind_ip = command_line::get_arg(vm, arg.rpc_bind_ip);
|
||||||
config.bind_ipv6_address = command_line::get_arg(vm, arg.rpc_bind_ipv6_address);
|
config.bind_ipv6_address = command_line::get_arg(vm, arg.rpc_bind_ipv6_address);
|
||||||
config.restricted_bind_ip = command_line::get_arg(vm, arg.rpc_restricted_bind_ip);
|
|
||||||
config.restricted_bind_ipv6_address = command_line::get_arg(vm, arg.rpc_restricted_bind_ipv6_address);
|
|
||||||
config.use_ipv6 = command_line::get_arg(vm, arg.rpc_use_ipv6);
|
config.use_ipv6 = command_line::get_arg(vm, arg.rpc_use_ipv6);
|
||||||
config.require_ipv4 = !command_line::get_arg(vm, arg.rpc_ignore_ipv4);
|
config.require_ipv4 = !command_line::get_arg(vm, arg.rpc_ignore_ipv4);
|
||||||
config.disable_rpc_ban = command_line::get_arg(vm, arg.disable_rpc_ban);
|
config.disable_rpc_ban = command_line::get_arg(vm, arg.disable_rpc_ban);
|
||||||
@@ -194,34 +188,6 @@ namespace cryptonote
|
|||||||
return boost::none;
|
return boost::none;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!config.restricted_bind_ip.empty())
|
|
||||||
{
|
|
||||||
// always parse IP here for error consistency
|
|
||||||
boost::system::error_code ec{};
|
|
||||||
boost::asio::ip::address::from_string(config.restricted_bind_ip, ec);
|
|
||||||
if (ec)
|
|
||||||
{
|
|
||||||
LOG_ERROR(tr("Invalid IP address given for --") << arg.rpc_restricted_bind_ip.name);
|
|
||||||
return boost::none;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!config.restricted_bind_ipv6_address.empty())
|
|
||||||
{
|
|
||||||
// allow square braces, but remove them here if present
|
|
||||||
if (config.restricted_bind_ipv6_address.find('[') != std::string::npos)
|
|
||||||
{
|
|
||||||
config.restricted_bind_ipv6_address = config.restricted_bind_ipv6_address.substr(1, config.restricted_bind_ipv6_address.size() - 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
// always parse IP here for error consistency
|
|
||||||
boost::system::error_code ec{};
|
|
||||||
boost::asio::ip::address::from_string(config.restricted_bind_ipv6_address, ec);
|
|
||||||
if (ec)
|
|
||||||
{
|
|
||||||
LOG_ERROR(tr("Invalid IP address given for --") << arg.rpc_restricted_bind_ipv6_address.name);
|
|
||||||
return boost::none;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *env_rpc_login = nullptr;
|
const char *env_rpc_login = nullptr;
|
||||||
const bool has_rpc_arg = command_line::has_arg(vm, arg.rpc_login);
|
const bool has_rpc_arg = command_line::has_arg(vm, arg.rpc_login);
|
||||||
|
|||||||
@@ -53,8 +53,6 @@ namespace cryptonote
|
|||||||
|
|
||||||
const command_line::arg_descriptor<std::string> rpc_bind_ip;
|
const command_line::arg_descriptor<std::string> rpc_bind_ip;
|
||||||
const command_line::arg_descriptor<std::string> rpc_bind_ipv6_address;
|
const command_line::arg_descriptor<std::string> rpc_bind_ipv6_address;
|
||||||
const command_line::arg_descriptor<std::string> rpc_restricted_bind_ip;
|
|
||||||
const command_line::arg_descriptor<std::string> rpc_restricted_bind_ipv6_address;
|
|
||||||
const command_line::arg_descriptor<bool> rpc_use_ipv6;
|
const command_line::arg_descriptor<bool> rpc_use_ipv6;
|
||||||
const command_line::arg_descriptor<bool> rpc_ignore_ipv4;
|
const command_line::arg_descriptor<bool> rpc_ignore_ipv4;
|
||||||
const command_line::arg_descriptor<std::string> rpc_login;
|
const command_line::arg_descriptor<std::string> rpc_login;
|
||||||
@@ -83,8 +81,6 @@ namespace cryptonote
|
|||||||
|
|
||||||
std::string bind_ip;
|
std::string bind_ip;
|
||||||
std::string bind_ipv6_address;
|
std::string bind_ipv6_address;
|
||||||
std::string restricted_bind_ip;
|
|
||||||
std::string restricted_bind_ipv6_address;
|
|
||||||
bool use_ipv6;
|
bool use_ipv6;
|
||||||
bool require_ipv4;
|
bool require_ipv4;
|
||||||
std::vector<std::string> access_control_origins;
|
std::vector<std::string> access_control_origins;
|
||||||
|
|||||||
@@ -221,7 +221,7 @@ namespace
|
|||||||
void add_subscriptions(std::array<std::size_t, N>& subs, const epee::span<const context<T>> range, context<T> const* const first)
|
void add_subscriptions(std::array<std::size_t, N>& subs, const epee::span<const context<T>> range, context<T> const* const first)
|
||||||
{
|
{
|
||||||
assert(range.size() <= N);
|
assert(range.size() <= N);
|
||||||
assert((unsigned long)(range.begin() - first) <= N - range.size());
|
assert(range.begin() - first <= N - range.size());
|
||||||
|
|
||||||
for (const auto& ctx : range)
|
for (const auto& ctx : range)
|
||||||
{
|
{
|
||||||
@@ -234,7 +234,7 @@ namespace
|
|||||||
void remove_subscriptions(std::array<std::size_t, N>& subs, const epee::span<const context<T>> range, context<T> const* const first)
|
void remove_subscriptions(std::array<std::size_t, N>& subs, const epee::span<const context<T>> range, context<T> const* const first)
|
||||||
{
|
{
|
||||||
assert(range.size() <= N);
|
assert(range.size() <= N);
|
||||||
assert((unsigned long)(range.begin() - first) <= N - range.size());
|
assert(range.begin() - first <= N - range.size());
|
||||||
|
|
||||||
for (const auto& ctx : range)
|
for (const auto& ctx : range)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -143,7 +143,6 @@ typedef cryptonote::simple_wallet sw;
|
|||||||
#define CREDITS_TARGET 50000
|
#define CREDITS_TARGET 50000
|
||||||
#define MAX_PAYMENT_DIFF 10000
|
#define MAX_PAYMENT_DIFF 10000
|
||||||
#define MIN_PAYMENT_RATE 0.01f // per hash
|
#define MIN_PAYMENT_RATE 0.01f // per hash
|
||||||
#define MAX_MNEW_ADDRESSES 1000
|
|
||||||
|
|
||||||
enum TransferType {
|
enum TransferType {
|
||||||
Transfer,
|
Transfer,
|
||||||
@@ -182,7 +181,7 @@ namespace
|
|||||||
const command_line::arg_descriptor< std::vector<std::string> > arg_command = {"command", ""};
|
const command_line::arg_descriptor< std::vector<std::string> > arg_command = {"command", ""};
|
||||||
|
|
||||||
const char* USAGE_START_MINING("start_mining [<number_of_threads>] [bg_mining] [ignore_battery]");
|
const char* USAGE_START_MINING("start_mining [<number_of_threads>] [bg_mining] [ignore_battery]");
|
||||||
const char* USAGE_SET_DAEMON("set_daemon <host>[:<port>] [trusted|untrusted|this-is-probably-a-spy-node]");
|
const char* USAGE_SET_DAEMON("set_daemon <host>[:<port>] [trusted|untrusted]");
|
||||||
const char* USAGE_SHOW_BALANCE("balance [detail]");
|
const char* USAGE_SHOW_BALANCE("balance [detail]");
|
||||||
const char* USAGE_INCOMING_TRANSFERS("incoming_transfers [available|unavailable] [verbose] [uses] [index=<N1>[,<N2>[,...]]]");
|
const char* USAGE_INCOMING_TRANSFERS("incoming_transfers [available|unavailable] [verbose] [uses] [index=<N1>[,<N2>[,...]]]");
|
||||||
const char* USAGE_PAYMENTS("payments <PID_1> [<PID_2> ... <PID_N>]");
|
const char* USAGE_PAYMENTS("payments <PID_1> [<PID_2> ... <PID_N>]");
|
||||||
@@ -204,7 +203,7 @@ namespace
|
|||||||
" account tag <tag_name> <account_index_1> [<account_index_2> ...]\n"
|
" account tag <tag_name> <account_index_1> [<account_index_2> ...]\n"
|
||||||
" account untag <account_index_1> [<account_index_2> ...]\n"
|
" account untag <account_index_1> [<account_index_2> ...]\n"
|
||||||
" account tag_description <tag_name> <description>");
|
" account tag_description <tag_name> <description>");
|
||||||
const char* USAGE_ADDRESS("address [ new <label text with white spaces allowed> | mnew <amount of new addresses> | all | <index_min> [<index_max>] | label <index> <label text with white spaces allowed> | device [<index>] | one-off <account> <subaddress>]");
|
const char* USAGE_ADDRESS("address [ new <label text with white spaces allowed> | all | <index_min> [<index_max>] | label <index> <label text with white spaces allowed> | device [<index>] | one-off <account> <subaddress>]");
|
||||||
const char* USAGE_INTEGRATED_ADDRESS("integrated_address [device] [<payment_id> | <address>]");
|
const char* USAGE_INTEGRATED_ADDRESS("integrated_address [device] [<payment_id> | <address>]");
|
||||||
const char* USAGE_ADDRESS_BOOK("address_book [(add (<address>|<integrated address>) [<description possibly with whitespaces>])|(delete <index>)]");
|
const char* USAGE_ADDRESS_BOOK("address_book [(add (<address>|<integrated address>) [<description possibly with whitespaces>])|(delete <index>)]");
|
||||||
const char* USAGE_SET_VARIABLE("set <option> [<value>]");
|
const char* USAGE_SET_VARIABLE("set <option> [<value>]");
|
||||||
@@ -2287,7 +2286,6 @@ bool simple_wallet::public_nodes(const std::vector<std::string> &args)
|
|||||||
{
|
{
|
||||||
fail_msg_writer() << tr("Error retrieving public node list: ") << e.what();
|
fail_msg_writer() << tr("Error retrieving public node list: ") << e.what();
|
||||||
}
|
}
|
||||||
message_writer(console_color_red, true) << tr("Most of these nodes are probably spies. You should not use them unless connecting via Tor or I2P");
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3224,7 +3222,7 @@ simple_wallet::simple_wallet()
|
|||||||
m_cmd_binder.set_handler("set_daemon",
|
m_cmd_binder.set_handler("set_daemon",
|
||||||
boost::bind(&simple_wallet::on_command, this, &simple_wallet::set_daemon, _1),
|
boost::bind(&simple_wallet::on_command, this, &simple_wallet::set_daemon, _1),
|
||||||
tr(USAGE_SET_DAEMON),
|
tr(USAGE_SET_DAEMON),
|
||||||
tr("Set another daemon to connect to. If it's not yours, it'll probably spy on you."));
|
tr("Set another daemon to connect to."));
|
||||||
m_cmd_binder.set_handler("save_bc",
|
m_cmd_binder.set_handler("save_bc",
|
||||||
boost::bind(&simple_wallet::on_command, this, &simple_wallet::save_bc, _1),
|
boost::bind(&simple_wallet::on_command, this, &simple_wallet::save_bc, _1),
|
||||||
tr("Save the current blockchain data."));
|
tr("Save the current blockchain data."));
|
||||||
@@ -3304,7 +3302,7 @@ simple_wallet::simple_wallet()
|
|||||||
m_cmd_binder.set_handler("address",
|
m_cmd_binder.set_handler("address",
|
||||||
boost::bind(&simple_wallet::on_command, this, &simple_wallet::print_address, _1),
|
boost::bind(&simple_wallet::on_command, this, &simple_wallet::print_address, _1),
|
||||||
tr(USAGE_ADDRESS),
|
tr(USAGE_ADDRESS),
|
||||||
tr("If no arguments are specified or <index> is specified, the wallet shows the default or specified address. If \"all\" is specified, the wallet shows all the existing addresses in the currently selected account. If \"new \" is specified, the wallet creates a new address with the provided label text (which can be empty). If \"mnew\" is specified, the wallet creates as many new addresses as specified by the argument; the default label is set for the new addresses. If \"label\" is specified, the wallet sets the label of the address specified by <index> to the provided label text. If \"one-off\" is specified, the address for the specified index is generated and displayed, and remembered by the wallet"));
|
tr("If no arguments are specified or <index> is specified, the wallet shows the default or specified address. If \"all\" is specified, the wallet shows all the existing addresses in the currently selected account. If \"new \" is specified, the wallet creates a new address with the provided label text (which can be empty). If \"label\" is specified, the wallet sets the label of the address specified by <index> to the provided label text. If \"one-off\" is specified, the address for the specified index is generated and displayed, and remembered by the wallet"));
|
||||||
m_cmd_binder.set_handler("integrated_address",
|
m_cmd_binder.set_handler("integrated_address",
|
||||||
boost::bind(&simple_wallet::on_command, this, &simple_wallet::print_integrated_address, _1),
|
boost::bind(&simple_wallet::on_command, this, &simple_wallet::print_integrated_address, _1),
|
||||||
tr(USAGE_INTEGRATED_ADDRESS),
|
tr(USAGE_INTEGRATED_ADDRESS),
|
||||||
@@ -5509,50 +5507,20 @@ bool simple_wallet::set_daemon(const std::vector<std::string>& args)
|
|||||||
} else {
|
} else {
|
||||||
daemon_url = args[0];
|
daemon_url = args[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
epee::net_utils::http::url_content parsed{};
|
|
||||||
const bool r = epee::net_utils::parse_url(daemon_url, parsed);
|
|
||||||
if (!r)
|
|
||||||
{
|
|
||||||
fail_msg_writer() << tr("Failed to parse address");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string trusted;
|
|
||||||
if (args.size() == 2)
|
|
||||||
{
|
|
||||||
if (args[1] == "trusted")
|
|
||||||
trusted = "trusted";
|
|
||||||
else if (args[1] == "untrusted")
|
|
||||||
trusted = "untrusted";
|
|
||||||
else if (args[1] == "this-is-probably-a-spy-node")
|
|
||||||
trusted = "this-is-probably-a-spy-node";
|
|
||||||
else
|
|
||||||
{
|
|
||||||
fail_msg_writer() << tr("Expected trusted, untrusted or this-is-probably-a-spy-node got ") << args[1];
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!tools::is_privacy_preserving_network(parsed.host) && !tools::is_local_address(parsed.host))
|
|
||||||
{
|
|
||||||
if (trusted == "untrusted" || trusted == "")
|
|
||||||
{
|
|
||||||
fail_msg_writer() << tr("This is not Tor/I2P address, and is not a trusted daemon.");
|
|
||||||
fail_msg_writer() << tr("Either use your own trusted node, connect via Tor or I2P, or pass this-is-probably-a-spy-node and be spied on.");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (parsed.schema != "https")
|
|
||||||
message_writer(console_color_red) << tr("Warning: connecting to a non-local daemon without SSL, passive adversaries will be able to spy on you.");
|
|
||||||
}
|
|
||||||
|
|
||||||
LOCK_IDLE_SCOPE();
|
LOCK_IDLE_SCOPE();
|
||||||
m_wallet->init(daemon_url);
|
m_wallet->init(daemon_url);
|
||||||
|
|
||||||
if (!trusted.empty())
|
if (args.size() == 2)
|
||||||
{
|
{
|
||||||
m_wallet->set_trusted_daemon(trusted == "trusted");
|
if (args[1] == "trusted")
|
||||||
|
m_wallet->set_trusted_daemon(true);
|
||||||
|
else if (args[1] == "untrusted")
|
||||||
|
m_wallet->set_trusted_daemon(false);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fail_msg_writer() << tr("Expected trusted or untrusted, got ") << args[1] << ": assuming untrusted";
|
||||||
|
m_wallet->set_trusted_daemon(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -9540,31 +9508,6 @@ bool simple_wallet::print_address(const std::vector<std::string> &args/* = std::
|
|||||||
print_address_sub(m_wallet->get_num_subaddresses(m_current_subaddress_account) - 1);
|
print_address_sub(m_wallet->get_num_subaddresses(m_current_subaddress_account) - 1);
|
||||||
m_wallet->device_show_address(m_current_subaddress_account, m_wallet->get_num_subaddresses(m_current_subaddress_account) - 1, boost::none);
|
m_wallet->device_show_address(m_current_subaddress_account, m_wallet->get_num_subaddresses(m_current_subaddress_account) - 1, boost::none);
|
||||||
}
|
}
|
||||||
else if (local_args[0] == "mnew")
|
|
||||||
{
|
|
||||||
local_args.erase(local_args.begin());
|
|
||||||
if (local_args.size() != 1)
|
|
||||||
{
|
|
||||||
fail_msg_writer() << tr("Expected exactly one argument for the amount of new addresses");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
uint32_t n;
|
|
||||||
if (!epee::string_tools::get_xtype_from_string(n, local_args[0]))
|
|
||||||
{
|
|
||||||
fail_msg_writer() << tr("failed to parse the amount of new addresses: ") << local_args[0];
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (n > MAX_MNEW_ADDRESSES)
|
|
||||||
{
|
|
||||||
fail_msg_writer() << tr("the amount of new addresses must be lower or equal to ") << MAX_MNEW_ADDRESSES;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
for (uint32_t i = 0; i < n; ++i)
|
|
||||||
{
|
|
||||||
m_wallet->add_subaddress(m_current_subaddress_account, tr("(Untitled address)"));
|
|
||||||
print_address_sub(m_wallet->get_num_subaddresses(m_current_subaddress_account) - 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (local_args[0] == "one-off")
|
else if (local_args[0] == "one-off")
|
||||||
{
|
{
|
||||||
local_args.erase(local_args.begin());
|
local_args.erase(local_args.begin());
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#define DEF_MONERO_VERSION_TAG "@VERSIONTAG@"
|
#define DEF_MONERO_VERSION_TAG "@VERSIONTAG@"
|
||||||
#define DEF_MONERO_VERSION "0.9.2.1"
|
#define DEF_MONERO_VERSION "0.9.1.0"
|
||||||
#define DEF_MONERO_RELEASE_NAME "Illiterate Illuminati"
|
#define DEF_MONERO_RELEASE_NAME "Illiterate Illuminati"
|
||||||
#define DEF_MONERO_VERSION_FULL DEF_MONERO_VERSION "-" DEF_MONERO_VERSION_TAG
|
#define DEF_MONERO_VERSION_FULL DEF_MONERO_VERSION "-" DEF_MONERO_VERSION_TAG
|
||||||
#define DEF_MONERO_VERSION_IS_RELEASE @VERSION_IS_RELEASE@
|
#define DEF_MONERO_VERSION_IS_RELEASE @VERSION_IS_RELEASE@
|
||||||
|
|||||||
@@ -212,10 +212,6 @@ void TransactionHistoryImpl::refresh()
|
|||||||
ti->m_label = pd.m_subaddr_indices.size() == 1 ? m_wallet->m_wallet->get_subaddress_label({pd.m_subaddr_account, *pd.m_subaddr_indices.begin()}) : "";
|
ti->m_label = pd.m_subaddr_indices.size() == 1 ? m_wallet->m_wallet->get_subaddress_label({pd.m_subaddr_account, *pd.m_subaddr_indices.begin()}) : "";
|
||||||
ti->m_timestamp = pd.m_timestamp;
|
ti->m_timestamp = pd.m_timestamp;
|
||||||
ti->m_confirmations = 0;
|
ti->m_confirmations = 0;
|
||||||
for (const auto &d : pd.m_dests)
|
|
||||||
{
|
|
||||||
ti->m_transfers.push_back({d.amount, d.address(m_wallet->m_wallet->nettype(), pd.m_payment_id)});
|
|
||||||
}
|
|
||||||
m_history.push_back(ti);
|
m_history.push_back(ti);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2963,8 +2963,7 @@ void wallet2::update_pool_state(std::vector<std::tuple<cryptonote::transaction,
|
|||||||
MTRACE("update_pool_state got pool");
|
MTRACE("update_pool_state got pool");
|
||||||
|
|
||||||
// remove any pending tx that's not in the pool
|
// remove any pending tx that's not in the pool
|
||||||
// TODO: set tx_propagation_timeout to CRYPTONOTE_DANDELIONPP_EMBARGO_AVERAGE * 3 / 2 after v15 hardfork
|
constexpr const std::chrono::seconds tx_propagation_timeout{CRYPTONOTE_DANDELIONPP_EMBARGO_AVERAGE * 3 / 2};
|
||||||
constexpr const std::chrono::seconds tx_propagation_timeout{500};
|
|
||||||
const auto now = std::chrono::system_clock::now();
|
const auto now = std::chrono::system_clock::now();
|
||||||
std::unordered_map<crypto::hash, wallet2::unconfirmed_transfer_details>::iterator it = m_unconfirmed_txs.begin();
|
std::unordered_map<crypto::hash, wallet2::unconfirmed_transfer_details>::iterator it = m_unconfirmed_txs.begin();
|
||||||
while (it != m_unconfirmed_txs.end())
|
while (it != m_unconfirmed_txs.end())
|
||||||
@@ -3773,7 +3772,7 @@ bool wallet2::store_keys(const std::string& keys_file_name, const epee::wipeable
|
|||||||
//----------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------
|
||||||
boost::optional<wallet2::keys_file_data> wallet2::get_keys_file_data(const epee::wipeable_string& password, bool watch_only)
|
boost::optional<wallet2::keys_file_data> wallet2::get_keys_file_data(const epee::wipeable_string& password, bool watch_only)
|
||||||
{
|
{
|
||||||
epee::byte_slice account_data;
|
std::string account_data;
|
||||||
std::string multisig_signers;
|
std::string multisig_signers;
|
||||||
std::string multisig_derivations;
|
std::string multisig_derivations;
|
||||||
cryptonote::account_base account = m_account;
|
cryptonote::account_base account = m_account;
|
||||||
@@ -3800,7 +3799,7 @@ boost::optional<wallet2::keys_file_data> wallet2::get_keys_file_data(const epee:
|
|||||||
rapidjson::Document json;
|
rapidjson::Document json;
|
||||||
json.SetObject();
|
json.SetObject();
|
||||||
rapidjson::Value value(rapidjson::kStringType);
|
rapidjson::Value value(rapidjson::kStringType);
|
||||||
value.SetString(reinterpret_cast<const char*>(account_data.data()), account_data.size());
|
value.SetString(account_data.c_str(), account_data.length());
|
||||||
json.AddMember("key_data", value, json.GetAllocator());
|
json.AddMember("key_data", value, json.GetAllocator());
|
||||||
if (!seed_language.empty())
|
if (!seed_language.empty())
|
||||||
{
|
{
|
||||||
@@ -3971,12 +3970,13 @@ boost::optional<wallet2::keys_file_data> wallet2::get_keys_file_data(const epee:
|
|||||||
rapidjson::StringBuffer buffer;
|
rapidjson::StringBuffer buffer;
|
||||||
rapidjson::Writer<rapidjson::StringBuffer> writer(buffer);
|
rapidjson::Writer<rapidjson::StringBuffer> writer(buffer);
|
||||||
json.Accept(writer);
|
json.Accept(writer);
|
||||||
|
account_data = buffer.GetString();
|
||||||
|
|
||||||
// Encrypt the entire JSON object.
|
// Encrypt the entire JSON object.
|
||||||
std::string cipher;
|
std::string cipher;
|
||||||
cipher.resize(buffer.GetSize());
|
cipher.resize(account_data.size());
|
||||||
keys_file_data.get().iv = crypto::rand<crypto::chacha_iv>();
|
keys_file_data.get().iv = crypto::rand<crypto::chacha_iv>();
|
||||||
crypto::chacha20(buffer.GetString(), buffer.GetSize(), key, keys_file_data.get().iv, &cipher[0]);
|
crypto::chacha20(account_data.data(), account_data.size(), key, keys_file_data.get().iv, &cipher[0]);
|
||||||
keys_file_data.get().account_data = cipher;
|
keys_file_data.get().account_data = cipher;
|
||||||
return keys_file_data;
|
return keys_file_data;
|
||||||
}
|
}
|
||||||
@@ -13376,20 +13376,6 @@ size_t wallet2::import_multisig(std::vector<cryptonote::blobdata> blobs)
|
|||||||
loaded = true;
|
loaded = true;
|
||||||
}
|
}
|
||||||
CHECK_AND_ASSERT_THROW_MES(loaded, "Failed to load output data");
|
CHECK_AND_ASSERT_THROW_MES(loaded, "Failed to load output data");
|
||||||
|
|
||||||
for (const auto &e: i)
|
|
||||||
{
|
|
||||||
for (const auto &lr: e.m_LR)
|
|
||||||
{
|
|
||||||
CHECK_AND_ASSERT_THROW_MES(rct::isInMainSubgroup(lr.m_L), "Multisig value is not in the main subgroup");
|
|
||||||
CHECK_AND_ASSERT_THROW_MES(rct::isInMainSubgroup(lr.m_R), "Multisig value is not in the main subgroup");
|
|
||||||
}
|
|
||||||
for (const auto &ki: e.m_partial_key_images)
|
|
||||||
{
|
|
||||||
CHECK_AND_ASSERT_THROW_MES(rct::isInMainSubgroup(rct::ki2rct(ki)), "Multisig partial key image is not in the main subgroup");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
MINFO(boost::format("%u outputs found") % boost::lexical_cast<std::string>(i.size()));
|
MINFO(boost::format("%u outputs found") % boost::lexical_cast<std::string>(i.size()));
|
||||||
info.push_back(std::move(i));
|
info.push_back(std::move(i));
|
||||||
}
|
}
|
||||||
@@ -14149,7 +14135,6 @@ std::vector<cryptonote::public_node> wallet2::get_public_nodes(bool white_only)
|
|||||||
|
|
||||||
req.white = true;
|
req.white = true;
|
||||||
req.gray = !white_only;
|
req.gray = !white_only;
|
||||||
req.include_blocked = false;
|
|
||||||
|
|
||||||
{
|
{
|
||||||
const boost::lock_guard<boost::recursive_mutex> lock{m_daemon_rpc_mutex};
|
const boost::lock_guard<boost::recursive_mutex> lock{m_daemon_rpc_mutex};
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ set(hash_targets_sources
|
|||||||
|
|
||||||
set(hash_targets_headers)
|
set(hash_targets_headers)
|
||||||
|
|
||||||
monero_add_minimal_executable(hash-target-tests
|
add_executable(hash-target-tests
|
||||||
${hash_targets_sources}
|
${hash_targets_sources}
|
||||||
${hash_targets_headers})
|
${hash_targets_headers})
|
||||||
target_link_libraries(hash-target-tests
|
target_link_libraries(hash-target-tests
|
||||||
@@ -149,7 +149,7 @@ foreach(BENCH IN LISTS MONERO_WALLET_CRYPTO_BENCH)
|
|||||||
endforeach ()
|
endforeach ()
|
||||||
|
|
||||||
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/benchmark.h.in" "${MONERO_GENERATED_HEADERS_DIR}/tests/benchmark.h")
|
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/benchmark.h.in" "${MONERO_GENERATED_HEADERS_DIR}/tests/benchmark.h")
|
||||||
monero_add_minimal_executable(monero-wallet-crypto-bench benchmark.cpp ${BENCH_OBJECTS})
|
add_executable(monero-wallet-crypto-bench benchmark.cpp ${BENCH_OBJECTS})
|
||||||
target_link_libraries(monero-wallet-crypto-bench cncrypto)
|
target_link_libraries(monero-wallet-crypto-bench cncrypto)
|
||||||
|
|
||||||
add_test(NAME wallet-crypto-bench COMMAND monero-wallet-crypto-bench)
|
add_test(NAME wallet-crypto-bench COMMAND monero-wallet-crypto-bench)
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ set(block_weight_sources
|
|||||||
|
|
||||||
set(block_weight_headers)
|
set(block_weight_headers)
|
||||||
|
|
||||||
monero_add_minimal_executable(block_weight
|
add_executable(block_weight
|
||||||
${block_weight_sources}
|
${block_weight_sources}
|
||||||
${block_weight_headers})
|
${block_weight_headers})
|
||||||
target_link_libraries(block_weight
|
target_link_libraries(block_weight
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ set(core_proxy_sources
|
|||||||
set(core_proxy_headers
|
set(core_proxy_headers
|
||||||
core_proxy.h)
|
core_proxy.h)
|
||||||
|
|
||||||
monero_add_minimal_executable(core_proxy
|
add_executable(core_proxy
|
||||||
${core_proxy_sources}
|
${core_proxy_sources}
|
||||||
${core_proxy_headers})
|
${core_proxy_headers})
|
||||||
target_link_libraries(core_proxy
|
target_link_libraries(core_proxy
|
||||||
|
|||||||
@@ -245,17 +245,12 @@ bool tests::proxy_core::init(const boost::program_options::variables_map& /*vm*/
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool tests::proxy_core::have_block_unlocked(const crypto::hash& id, int *where) {
|
bool tests::proxy_core::have_block(const crypto::hash& id) {
|
||||||
if (m_hash2blkidx.end() == m_hash2blkidx.find(id))
|
if (m_hash2blkidx.end() == m_hash2blkidx.find(id))
|
||||||
return false;
|
return false;
|
||||||
if (where) *where = HAVE_BLOCK_MAIN_CHAIN;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool tests::proxy_core::have_block(const crypto::hash& id, int *where) {
|
|
||||||
return have_block_unlocked(id, where);
|
|
||||||
}
|
|
||||||
|
|
||||||
void tests::proxy_core::build_short_history(std::list<crypto::hash> &m_history, const crypto::hash &m_start) {
|
void tests::proxy_core::build_short_history(std::list<crypto::hash> &m_history, const crypto::hash &m_start) {
|
||||||
m_history.push_front(get_block_hash(m_genesis));
|
m_history.push_front(get_block_hash(m_genesis));
|
||||||
/*std::unordered_map<crypto::hash, tests::block_index>::const_iterator cit = m_hash2blkidx.find(m_lastblk);
|
/*std::unordered_map<crypto::hash, tests::block_index>::const_iterator cit = m_hash2blkidx.find(m_lastblk);
|
||||||
|
|||||||
@@ -66,16 +66,14 @@ namespace tests
|
|||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual bool is_synchronized() const final { return true; }
|
|
||||||
void on_synchronized(){}
|
void on_synchronized(){}
|
||||||
void safesyncmode(const bool){}
|
void safesyncmode(const bool){}
|
||||||
virtual uint64_t get_current_blockchain_height() const final {return 1;}
|
uint64_t get_current_blockchain_height(){return 1;}
|
||||||
void set_target_blockchain_height(uint64_t) {}
|
void set_target_blockchain_height(uint64_t) {}
|
||||||
bool init(const boost::program_options::variables_map& vm);
|
bool init(const boost::program_options::variables_map& vm);
|
||||||
bool deinit(){return true;}
|
bool deinit(){return true;}
|
||||||
bool get_short_chain_history(std::list<crypto::hash>& ids);
|
bool get_short_chain_history(std::list<crypto::hash>& ids);
|
||||||
bool have_block(const crypto::hash& id, int *where = NULL);
|
bool have_block(const crypto::hash& id);
|
||||||
bool have_block_unlocked(const crypto::hash& id, int *where = NULL);
|
|
||||||
void get_blockchain_top(uint64_t& height, crypto::hash& top_id);
|
void get_blockchain_top(uint64_t& height, crypto::hash& top_id);
|
||||||
bool handle_incoming_tx(const cryptonote::tx_blob_entry& tx_blob, cryptonote::tx_verification_context& tvc, cryptonote::relay_method tx_relay, bool relayed);
|
bool handle_incoming_tx(const cryptonote::tx_blob_entry& tx_blob, cryptonote::tx_verification_context& tvc, cryptonote::relay_method tx_relay, bool relayed);
|
||||||
bool handle_incoming_txs(const std::vector<cryptonote::tx_blob_entry>& tx_blobs, std::vector<cryptonote::tx_verification_context>& tvc, cryptonote::relay_method tx_relay, bool relayed);
|
bool handle_incoming_txs(const std::vector<cryptonote::tx_blob_entry>& tx_blobs, std::vector<cryptonote::tx_verification_context>& tvc, cryptonote::relay_method tx_relay, bool relayed);
|
||||||
@@ -113,6 +111,5 @@ namespace tests
|
|||||||
bool prune_blockchain(uint32_t pruning_seed) const { return true; }
|
bool prune_blockchain(uint32_t pruning_seed) const { return true; }
|
||||||
bool get_txpool_complement(const std::vector<crypto::hash> &hashes, std::vector<cryptonote::blobdata> &txes) { return false; }
|
bool get_txpool_complement(const std::vector<crypto::hash> &hashes, std::vector<cryptonote::blobdata> &txes) { return false; }
|
||||||
bool get_pool_transaction_hashes(std::vector<crypto::hash>& txs, bool include_unrelayed_txes = true) const { return false; }
|
bool get_pool_transaction_hashes(std::vector<crypto::hash>& txs, bool include_unrelayed_txes = true) const { return false; }
|
||||||
crypto::hash get_block_id_by_height(uint64_t height) const { return crypto::null_hash; }
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ set(core_tests_headers
|
|||||||
rct2.h
|
rct2.h
|
||||||
wallet_tools.h)
|
wallet_tools.h)
|
||||||
|
|
||||||
monero_add_minimal_executable(core_tests
|
add_executable(core_tests
|
||||||
${core_tests_sources}
|
${core_tests_sources}
|
||||||
${core_tests_headers})
|
${core_tests_headers})
|
||||||
target_link_libraries(core_tests
|
target_link_libraries(core_tests
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user