From 7bc00331b5ee2e832f942974cbd1c44a1712ae0b Mon Sep 17 00:00:00 2001 From: Rucknium Date: Mon, 15 Apr 2024 12:46:16 +0000 Subject: [PATCH] Fix problems from R CMD check --- NAMESPACE | 1 + R/ping.R | 13 +++++++------ man/ping.peers.Rd | 2 ++ 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/NAMESPACE b/NAMESPACE index d75f824..c71bda5 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1 +1,2 @@ exportPattern("^[[:alpha:]]+") +importFrom("utils", "read.csv") diff --git a/R/ping.R b/R/ping.R index 08beca7..c75ce6f 100644 --- a/R/ping.R +++ b/R/ping.R @@ -12,7 +12,9 @@ #' @export #' #' @examples +#' \dontrun{ #' ping.peers() +#' } ping.peers <- function(bitmonero.dir = "~/.bitmonero", output.file = "/monero_peer_pings.csv", sleep = 10, ping.count = 5) { bitmonero.dir <- path.expand(bitmonero.dir) @@ -52,13 +54,14 @@ ping.peers <- function(bitmonero.dir = "~/.bitmonero", output.file = "/monero_pe old.ip.ports <- "" } - tail.file <- readr::read_lines(log.file, skip = lines.already.read) + n.lines.file <- length(tail.file) + lines.already.read + ip.lines <- grep("Received NOTIFY_NEW_TRANSACTIONS", tail.file, fixed = TRUE) if (length(ip.lines) == 0) { - Sys.sleep(sleep.time) + Sys.sleep(sleep) cat(base::date(), " Peers pinged: 0\n", sep = "") next } @@ -72,13 +75,12 @@ ping.peers <- function(bitmonero.dir = "~/.bitmonero", output.file = "/monero_pe x } - peers <- get.peer.ip.port.direction(tail.file[ip.lines]) peers <- unique(peers) peers <- peers[! paste0(peers$ip, ":", peers$port) %in% old.ip.ports, , drop = FALSE] if (nrow(peers) == 0) { - Sys.sleep(sleep.time) + Sys.sleep(sleep) cat(base::date(), " Peers pinged: 0\n", sep = "") next } @@ -98,7 +100,6 @@ ping.peers <- function(bitmonero.dir = "~/.bitmonero", output.file = "/monero_pe paste(ip, port, direction, paste(pings, collapse = ","), sep = ",") } - if (nrow(peers) * ping.count > 5) { n.workers <- min(c(floor(nrow(peers) * ping.count / 5), parallelly::availableCores()*4)) @@ -127,7 +128,7 @@ ping.peers <- function(bitmonero.dir = "~/.bitmonero", output.file = "/monero_pe lines.already.read <- n.lines.file - Sys.sleep(sleep.time) + Sys.sleep(sleep) cat(base::date(), " Peers pinged: ", length(ping.data), "\n", sep = "") diff --git a/man/ping.peers.Rd b/man/ping.peers.Rd index bf48689..aa67cb3 100644 --- a/man/ping.peers.Rd +++ b/man/ping.peers.Rd @@ -27,5 +27,7 @@ No return value. Executes in a loop until interrupted. Ping peer nodes for latency measurement } \examples{ +\dontrun{ ping.peers() } +}