HelixNetwork / pendulum

Pendulum is a distributed messaging protocol that enables globally available tamper proof timestamps :hourglass_flowing_sand:
https://dev.hlx.ai
Other
10 stars 6 forks source link

Restart of TransactionValidator #114

Closed spangin closed 5 years ago

spangin commented 5 years ago

TransactionValidator has a problem after shutdown() is called. https://github.com/HelixNetwork/helix-1.0/blob/dev/src/main/java/net/helix/hlx/TransactionValidator.java (IOTA has the same problem)

There are two ways to use TransactionValidator:

  1. TransactionValidator can be run only once.
  2. TransactionValidator can be restarted (IOTA uses it in the corresponding test).

There is a small problem at the 1st way: If shutdown() is called, variable shuttingDown=true and TransactionValidator doesn't work anymore. But init() can be called and a new thread is created and started every time init is called. Quick fix is a condition has to be added to init(): a validation thread can be created and started if shuttingDown=false.

There is a big problem at the 2nd way: If shutdown() is called, variable shuttingDown=true and TransactionValidator doesn't work anymore. Quick fix is: a line "shuttingDown.set(false);" has to be added to init().

The best solution is to set states for TransactionValidator to know what actions are available for the thread.

oracle58 commented 5 years ago

I think this has been resolved. @spangin, can you reference the pr/commit in which it was fixed, thanks.