mirror of
https://github.com/Rucknium/xmrpeers.git
synced 2024-12-22 11:39:23 +00:00
Fix problems from R CMD check
This commit is contained in:
parent
c357201f5b
commit
7bc00331b5
3 changed files with 10 additions and 6 deletions
|
@ -1 +1,2 @@
|
||||||
exportPattern("^[[:alpha:]]+")
|
exportPattern("^[[:alpha:]]+")
|
||||||
|
importFrom("utils", "read.csv")
|
||||||
|
|
13
R/ping.R
13
R/ping.R
|
@ -12,7 +12,9 @@
|
||||||
#' @export
|
#' @export
|
||||||
#'
|
#'
|
||||||
#' @examples
|
#' @examples
|
||||||
|
#' \dontrun{
|
||||||
#' ping.peers()
|
#' ping.peers()
|
||||||
|
#' }
|
||||||
ping.peers <- function(bitmonero.dir = "~/.bitmonero", output.file = "/monero_peer_pings.csv", sleep = 10, ping.count = 5) {
|
ping.peers <- function(bitmonero.dir = "~/.bitmonero", output.file = "/monero_peer_pings.csv", sleep = 10, ping.count = 5) {
|
||||||
|
|
||||||
bitmonero.dir <- path.expand(bitmonero.dir)
|
bitmonero.dir <- path.expand(bitmonero.dir)
|
||||||
|
@ -52,13 +54,14 @@ ping.peers <- function(bitmonero.dir = "~/.bitmonero", output.file = "/monero_pe
|
||||||
old.ip.ports <- ""
|
old.ip.ports <- ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
tail.file <- readr::read_lines(log.file, skip = lines.already.read)
|
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)
|
ip.lines <- grep("Received NOTIFY_NEW_TRANSACTIONS", tail.file, fixed = TRUE)
|
||||||
|
|
||||||
if (length(ip.lines) == 0) {
|
if (length(ip.lines) == 0) {
|
||||||
Sys.sleep(sleep.time)
|
Sys.sleep(sleep)
|
||||||
cat(base::date(), " Peers pinged: 0\n", sep = "")
|
cat(base::date(), " Peers pinged: 0\n", sep = "")
|
||||||
next
|
next
|
||||||
}
|
}
|
||||||
|
@ -72,13 +75,12 @@ ping.peers <- function(bitmonero.dir = "~/.bitmonero", output.file = "/monero_pe
|
||||||
x
|
x
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
peers <- get.peer.ip.port.direction(tail.file[ip.lines])
|
peers <- get.peer.ip.port.direction(tail.file[ip.lines])
|
||||||
peers <- unique(peers)
|
peers <- unique(peers)
|
||||||
peers <- peers[! paste0(peers$ip, ":", peers$port) %in% old.ip.ports, , drop = FALSE]
|
peers <- peers[! paste0(peers$ip, ":", peers$port) %in% old.ip.ports, , drop = FALSE]
|
||||||
|
|
||||||
if (nrow(peers) == 0) {
|
if (nrow(peers) == 0) {
|
||||||
Sys.sleep(sleep.time)
|
Sys.sleep(sleep)
|
||||||
cat(base::date(), " Peers pinged: 0\n", sep = "")
|
cat(base::date(), " Peers pinged: 0\n", sep = "")
|
||||||
next
|
next
|
||||||
}
|
}
|
||||||
|
@ -98,7 +100,6 @@ ping.peers <- function(bitmonero.dir = "~/.bitmonero", output.file = "/monero_pe
|
||||||
paste(ip, port, direction, paste(pings, collapse = ","), sep = ",")
|
paste(ip, port, direction, paste(pings, collapse = ","), sep = ",")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (nrow(peers) * ping.count > 5) {
|
if (nrow(peers) * ping.count > 5) {
|
||||||
|
|
||||||
n.workers <- min(c(floor(nrow(peers) * ping.count / 5), parallelly::availableCores()*4))
|
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
|
lines.already.read <- n.lines.file
|
||||||
|
|
||||||
Sys.sleep(sleep.time)
|
Sys.sleep(sleep)
|
||||||
|
|
||||||
cat(base::date(), " Peers pinged: ", length(ping.data), "\n", sep = "")
|
cat(base::date(), " Peers pinged: ", length(ping.data), "\n", sep = "")
|
||||||
|
|
||||||
|
|
|
@ -27,5 +27,7 @@ No return value. Executes in a loop until interrupted.
|
||||||
Ping peer nodes for latency measurement
|
Ping peer nodes for latency measurement
|
||||||
}
|
}
|
||||||
\examples{
|
\examples{
|
||||||
|
\dontrun{
|
||||||
ping.peers()
|
ping.peers()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue