oxen-io/oxen-storage-server

Loki Daemon Callbacks for Blockchain activity

Doy-lee opened this issue · 2 comments

The daemon has the ability to execute arbitrary commands upon receiving a block, reorganising and or the block rate changes by launching lokid with these flags which could make interop between the two more robust.

  --block-notify arg                    Run a program for each new block, '%s' 
                                        will be replaced by the block hash
  --reorg-notify arg                    Run a program for each reorg, '%s' will
                                        be replaced by the split height, '%h' 
                                        will be replaced by the new blockchain 
                                        height, and '%n' will be replaced by 
                                        the number of new blocks in the new 
                                        chain
  --block-rate-notify arg               Run a program when the block rate 
                                        undergoes large fluctuations. This 
                                        might be a sign of large amounts of 
                                        hash rate going on and off the Loki 
                                        network, and thus be of potential 
                                        interest in predicting attacks. %t will
                                        be replaced by the number of minutes 
                                        for the observation window, %b by the 
                                        number of blocks observed within that 
                                        window, and %e by the number of blocks 
                                        that was expected in that window. It is
                                        suggested that this notification is 
                                        used to automatically increase the 
                                        number of confirmations required before
                                        a payment is acted upon.

Might need to plan ahead to figure out how to make this usable for the storage server so figured I'd drop this pre-emptively.

These flags are a bit awkward to use. We could change lokid to make http request to the storage server notifying of a new block instead.

SS now does this by subscribing to block notifications via its persistent oxenmq connection to oxend (as part of #416). (Albeit not as described above, but a similar idea).