@@ -47,39 +47,40 @@ class Schema10To11 {
4747
4848 // Delete any existing custom entries for the fulcrum server
4949 await (m.database.delete (electrumServers)..where (
50- (e ) =>
50+ (t ) =>
5151 electrumServers.url.equals (fulcrumUrl) |
5252 electrumServers.url.equals (fulcrumUrlWithoutProtocol),
5353 ))
5454 .go ();
5555
56- // Get all Bitcoin mainnet servers and update their priority
57- final serversToUpdate =
56+ // Get all Bitcoin mainnet servers to update their priority
57+ final btcMainnetServers =
5858 await (m.database.select (electrumServers)..where (
59- (e ) =>
59+ (t ) =>
6060 electrumServers.isTestnet.equals (0 ) &
6161 electrumServers.isLiquid.equals (0 ),
6262 ))
6363 .get ();
6464
65- for (final server in serversToUpdate) {
66- final url = server.read ('url' ) as String ;
67- final isTestnet = server.read ('is_testnet' ) as bool ;
68- final isLiquid = server.read ('is_liquid' ) as bool ;
69- final priority = server.read ('priority' ) as int ;
70- final isCustom = server.read ('is_custom' ) as bool ;
65+ // Update each server's priority by incrementing it
66+ for (final server in btcMainnetServers) {
67+ final serverUrl = server.data['url' ] as String ;
68+ final serverIsTestnet = server.data['is_testnet' ] as int ;
69+ final serverIsLiquid = server.data['is_liquid' ] as int ;
70+ final serverPriority = server.data['priority' ] as int ;
71+ final serverIsCustom = server.data['is_custom' ] as int ;
7172
72- await m.database
73- . into ( electrumServers)
74- . insertOnConflictUpdate (
75- RawValuesInsertable ({
76- 'url' : Constant (url ),
77- 'is_testnet' : Constant (isTestnet ),
78- 'is_liquid' : Constant (isLiquid ),
79- 'priority' : Constant (priority + 1 ),
80- 'is_custom' : Constant (isCustom ),
81- }),
82- );
73+ await ( m.database. update (
74+ electrumServers,
75+ ).. where ((t) => electrumServers.url. equals (serverUrl))). write (
76+ RawValuesInsertable ({
77+ 'url' : Constant < String >(serverUrl ),
78+ 'is_testnet' : Constant < int >(serverIsTestnet ),
79+ 'is_liquid' : Constant < int >(serverIsLiquid ),
80+ 'priority' : Constant < int >(serverPriority + 1 ),
81+ 'is_custom' : Constant < int >(serverIsCustom ),
82+ }),
83+ );
8384 }
8485
8586 await m.database
@@ -131,10 +132,10 @@ class Schema10To11 {
131132 .into (mempoolServers)
132133 .insert (
133134 RawValuesInsertable ({
134- 'url' : Constant (server['url' ]),
135- 'is_testnet' : Constant (server['isTestnet' ]),
136- 'is_liquid' : Constant (server['isLiquid' ]),
137- 'is_custom' : Constant (server['isCustom' ]),
135+ 'url' : Constant (server['url' ] as String ),
136+ 'is_testnet' : Constant (server['isTestnet' ] as bool ),
137+ 'is_liquid' : Constant (server['isLiquid' ] as bool ),
138+ 'is_custom' : Constant (server['isCustom' ] as bool ),
138139 }),
139140 mode: InsertMode .insertOrReplace,
140141 );
0 commit comments