hashgraph / hedera-hcs-sxc-java

The HCS SXC (SDK eXtension Components) is a set of pre-built components that aim to provide additional functionality over and above the java SDK for HCS to make it easier and quicker to develop applications. This repository is only intended for demo purposes and not production applications.
Apache License 2.0
18 stars 8 forks source link

hcs-lib: provide interfaces to enable persistence consistency check and database sync #215

Open zoperado opened 4 years ago

zoperado commented 4 years ago

Detailed Description If an app-net user disconnects from message queue or messages are not delivered for whatever reason then he doesn't know if he is out of sync. When he starts receiving messages again then there is a gap in his record stream while everyone else is in sync. This problem is more evident if two message queues listen to same topic, each of which queue has its own subscribers, and one queue is down while the other is up and delivering messages. The proposed solution is to create persistence interfaces that scan stored records and returns the gaps in sequence numbers: findGaps()->[s0, ... ,sN] where s is a sequence number for which we have not received a message. We should be able to broadcast a request getMessage(seqNo) to the network and a designated user-role can then automatically relay the message associated with the sequence number.

Actual Behavior In settlements, we may see a settlement net amount whose credit lines don't add up because we failed to receive credit line messages but managed to receive the settlement message.

Expected Behavior No gaps in records.

Environment:

Additional Context Add any other context about the problem here. Attach any logs here, if applicable.

zoperado commented 4 years ago

See #284 and topicGetInfo returns current sequence number. Use topicGetInfo to indicate somewhere whether appclient is in sync. A user may be in doubt whether things are in sync. If we have a small heartbeat, let's say topicGetInfo every 10 seconds or so then: if the lastSeqNo from Mirror isAlotLessThan SeqNo from topicGetInfo then the user can know if things are out of sync