@@ -473,40 +473,6 @@ public synchronized Client setMirrorNetwork(List<String> network) throws Interru
473473 return this ;
474474 }
475475
476- /**
477- * Trigger an immediate address book update.
478- * This will fetch the address book even if periodic updates are disabled.
479- */
480- public synchronized Client updateNetworkFromAddressBook () {
481- try {
482- var fileId = FileId .getAddressBookFileIdFor (this .shard , this .realm );
483-
484- logger .debug ("Fetching address book from file {}" , fileId );
485- System .out .println ("Fetching address book from file " + fileId );
486-
487- // Execute synchronously - no async complexity
488- var addressBook = new AddressBookQuery ()
489- .setFileId (fileId )
490- .execute (this ); // ← Synchronous!
491-
492- logger .debug ("Received address book with {} nodes" , addressBook .nodeAddresses .size ());
493- System .out .println ("address book size: " + addressBook .nodeAddresses .size ());
494-
495- // Update the network
496- this .setNetworkFromAddressBook (addressBook );
497-
498- logger .info ("Address book update completed successfully" );
499- System .out .println ("Address book update completed successfully" );
500-
501- } catch (TimeoutException e ) {
502- logger .warn ("Failed to fetch address book: {}" , e .getMessage ());
503- } catch (Exception e ) {
504- logger .warn ("Failed to update address book" , e );
505- }
506-
507- return this ;
508- }
509-
510476 private synchronized void scheduleNetworkUpdate (@ Nullable Duration delay ) {
511477 if (delay == null ) {
512478 networkUpdateFuture = null ;
@@ -1445,26 +1411,33 @@ public synchronized Client setNetworkUpdatePeriod(Duration networkUpdatePeriod)
14451411 *
14461412 * @return {@code this}
14471413 */
1448- // public synchronized Client updateNetworkFromAddressBook() {
1449- //// scheduleNetworkUpdate(Duration.ZERO);
1450- // updateNetworkFromAddressBook2();
1451- //
1452- // if (networkUpdateFuture != null) {
1453- // try {
1454- // networkUpdateFuture.get(30, TimeUnit.SECONDS);
1455- // logger.debug("Address book update completed successfully");
1456- // } catch (TimeoutException e) {
1457- // logger.warn("Address book update timed out after 30 seconds", e);
1458- // } catch (InterruptedException e) {
1459- // Thread.currentThread().interrupt();
1460- // logger.warn("Address book update was interrupted", e);
1461- // } catch (ExecutionException e) {
1462- // logger.warn("Address book update failed", e);
1463- // }
1464- // }
1465- //
1466- // return this;
1467- // }
1414+ public synchronized Client updateNetworkFromAddressBook () {
1415+ try {
1416+ var fileId = FileId .getAddressBookFileIdFor (this .shard , this .realm );
1417+
1418+ logger .debug ("Fetching address book from file {}" , fileId );
1419+ System .out .println ("Fetching address book from file " + fileId );
1420+
1421+ // Execute synchronously - no async complexity
1422+ var addressBook = new AddressBookQuery ().setFileId (fileId ).execute (this ); // ← Synchronous!
1423+
1424+ logger .debug ("Received address book with {} nodes" , addressBook .nodeAddresses .size ());
1425+ System .out .println ("address book size: " + addressBook .nodeAddresses .size ());
1426+
1427+ // Update the network
1428+ this .setNetworkFromAddressBook (addressBook );
1429+
1430+ logger .info ("Address book update completed successfully" );
1431+ System .out .println ("Address book update completed successfully" );
1432+
1433+ } catch (TimeoutException e ) {
1434+ logger .warn ("Failed to fetch address book: {}" , e .getMessage ());
1435+ } catch (Exception e ) {
1436+ logger .warn ("Failed to update address book" , e );
1437+ }
1438+
1439+ return this ;
1440+ }
14681441
14691442 public Logger getLogger () {
14701443 return this .logger ;
0 commit comments