Skip to contents

Moves the node's active chain to a previous block, effectively rolling back the blockchain state. This is a powerful operation typically used for testing or recovery. The node must be paused with mc_pause(conn, "incoming,mining") before calling.

Usage

mc_set_last_block(conn, hash_or_height)

Arguments

conn

A connection object created by mc_connect.

hash_or_height

Either a block hash (character string) or a block height (integer) to rewind to.

Value

Character string. The hash of the last block after the rewind.

See also

mc_pause, mc_resume, mc_get_block to inspect blocks.

Other node control: mc_pause(), mc_resume()

Examples

if (FALSE) { # \dontrun{
# Pause the node first
mc_pause(conn, "incoming,mining")
# Rewind to block height 100
last_hash <- mc_set_last_block(conn, 100)
# Resume after rewind
mc_resume(conn, "incoming,mining")
} # }