One thing I heard interviewing some users is that it's very common to sequence RPCs with periodic tip hash checks and restart if a new block comes in.
Something that might be helpful would be if Core could support a few different things in RPCs:
- a tip hash argument that causes failure if the passed_tip != actual_tip
- a hash argument that causes failure if the passed_tip \not \in header_chain
another thing that might help these types of users could be node leases whereby:
- the node is given a lease which expires e.g. N seconds after the lease is granted/no message has been sent by the leasor, and the node will not process new messages until the lease is free or let go
Optionally, we could allow a distinct non expiring lease.
One might use such an API like (made up RPCs)
finished = false
while not finished:
try:
h <- getbestblockhash
b <- getwalletbalance h
a <- getnewaddress h
send b a
finished = true
or
L <- get_lease
b <- getwalletbalance h
a <- getnewaddress h
send b a
clear_lease L
Leasing might be better than just a blockhash argument because you can guarantee e.g. repeated calls to mempool operations are consistent. This could be problematic e.g. if a txn is in the mempool and you're trying to coordinate wallet software to detect txns paying you so that you might fee bump them with CPFP, it might disappear while your flow of txns is occuring.