Enable remote node mempool archiver

This commit is contained in:
Rucknium 2022-12-20 21:10:20 +00:00
parent 566e661e61
commit f0bd624811

View file

@ -1,4 +1,14 @@
script.args <- commandArgs(trailingOnly = TRUE)
stopifnot(length(script.args) <= 1)
if (length(script.args) == 1) {
url.rpc <- script.args
} else {
url.rpc <- "http://127.0.0.1:18081"
}
# Modified from TownforgeR::tf_rpc_curl function
xmr.rpc <- function(
url.rpc = "http://127.0.0.1:18081/json_rpc",
@ -61,7 +71,7 @@ tx.pool <- c()
# Check that node is responding
while(length(tx.pool) == 0) {
tx.pool <- xmr.rpc("http://127.0.0.1:18081/get_transaction_pool")$transactions
tx.pool <- xmr.rpc(paste0(url.rpc, "/get_transaction_pool"))$transactions
if (length(tx.pool) > 0 && tx.pool[[1]]$receive_time == 0) {
error("Transaction receive_time is missing. Possible solution: remove '--restricted-rpc' monerod flag.")
@ -78,9 +88,9 @@ while (TRUE) {
compute.time <- system.time({
tx.pool <- xmr.rpc("http://127.0.0.1:18081/get_transaction_pool", keep.trying.rpc = TRUE)$transactions
tx.pool <- xmr.rpc(paste0(url.rpc, "/get_transaction_pool"), keep.trying.rpc = TRUE)$transactions
block.header <- xmr.rpc(url.rpc = "http://127.0.0.1:18081/json_rpc", method = "get_last_block_header")$result$block_header
block.header <- xmr.rpc(paste0(url.rpc, "/json_rpc"), method = "get_last_block_header")$result$block_header
block_receive_time <- round(Sys.time())
# One second time resolution