Nxt Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

Latest Nxt Client 1.11.3 - NEW RELEASE: Ardor 2.0.1e TestNet IS LAUNCHED!

Pages: [1]

Author Topic: I have a database list of nxt addressses, how do I monitor them for activity?  (Read 244 times)

box1413

  • Hero Member
  • *****
  • Offline Offline
  • Posts: 596
    • View Profile
  • Karma: +96/-4

I'm trying to code this up in php within my cms. I have a collection of nxt address I want to monitor. If there is any activity on any of these addresses, I want it to fire a php script.

What is the best way to implement some type of polling to monitor when there is activity? I was thinking of running cron every minute, but wouldn't it just be better if I monitored the nxt blocks and check if any of the addresses matches one I have stored?

Looking for advice on how to get this done.

box1413

  • Hero Member
  • *****
  • Offline Offline
  • Posts: 596
    • View Profile
  • Karma: +96/-4

This might be the answer to what I'm looking for:

http://nxtwiki.org/wiki/Exchange_Integration

I'm guessing I have to run cron on a php script that checks the following JSON transactions:

  http://localhost:6876/nxt?requestType=getBlockchainTransactions&account=NXT-XK4R-7VJU-6EQG-7R335&type=0&subtype=0&executedOnly=true

But if I had 2000 addresses to check. Wouldn't that be a bunch of queries at once?

Another approach I wanted to take was have cron run and just check each block as it happens and if one of the blocks contains a transactions matching one of my addresses it will execute a php.

websioux

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 282
  • Great changes grow bottom up
    • View Profile
    • Scriba.io the Blockchain Scribe
  • Karma: +58/-1

If you have that many to check or more, yes, you'd better check the transactions when they appear on your node. But remember blockchain reorgs do occur and in that case you should detect it, and check if it has a consequence for your treatment or not.

Otherwise, it's probably not going to take that much to check the transactions of 1000 address, I'd bet for something between 1 and 10 sec.

Since you will have to keep a log of your treatment anyway, the best is perhaps to do both: try to treat blocks as they come, and once in a while cross check the transactions of each of your adresses in case a reorg made you miss something or treat something that you should not have.

It is only graved in stone after 720 blocks, before that, surprises can happen, although statistically it seems very rare to miss a transaction or treat one that is not going to be included, it looks like there are scenario where this can happen. So you must adapt your treatment strategy for that. It depends on the purpose of your treatment. If you can wait, it is always easier, if you want to be synchronous with the blockchain info, then it is harder because there are multiple possibilities at the present time. It also depends on the risk you take.
Secret Miner <= communicate with style | NotBot <= timestamp digital docs

ScripterRon

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 452
    • View Profile
  • Karma: +72/-2

One possibility is to use the EventWait API.  You can be notified when blocks are pushed and popped.  For a rollback, you will get a block popped event for the old block followed by a block pushed event for the new block.
NXT-XM86-4ZNA-65L5-CDWUE
Pages: [1]