encointer/encointer-wallet-flutter

Getter: Header not found in database after changing the network

clangenb opened this issue · 0 comments

After changing the network, we immediately fetch the newest data from the blockchain. However, it sometimes store.chain.latestHeader does still have the value from the previous network, leading to the following exception observed in the integration tests:

[VERBOSE-2:dart_vm_initializer.cc(41)] Unhandled Exception: Exception: {code: 1, message: Error while calling into the runtime: Api called for an unknown Block: Header was not found in the database: 0x1884547e12437a45e5a9e644ce5913d985b3936273462ddf419ca167f6a5fcee}
#0      SubstrateDartApi.rpc (package:encointer_wallet/service/substrate_api/core/dart_api.dart:71:33)
<asynchronous suspension>
#1      EncointerDartApi.getReputations (package:encointer_wallet/service/substrate_api/encointer/encointer_dart_api.dart:58:25)
<asynchronous suspension>
#2      EncointerApi.getReputations (package:encointer_wallet/service/substrate_api/encointer/encointer_api.dart:585:25)
<asynchronous suspension>

The solution to this is that we get the bestHead from the chain in the connectNode function before doing anything else.