refactor RecoveryState

draft that compiles and passes make check

Signed-off-by: Loic Dachary <loic@dachary.org>