+ if (use_chan_manager_constructor) {
+ byte[][] monitors = {orig.monitors.values().stream().iterator().next().write()};
+ byte[] serialized = orig.chan_manager.write();
+ try {
+ this.constructor = new ChannelManagerConstructor(serialized, monitors, this.keys_interface,
+ this.fee_estimator, this.chain_monitor, this.filter, this.tx_broadcaster, this.logger);
+ constructor.chain_sync_completed(new ChannelManagerConstructor.ChannelManagerPersister() {
+ @Override public void handle_events(Event[] events) {
+ synchronized (pending_manager_events) {
+ pending_manager_events.addAll(Arrays.asList(events));
+ pending_manager_events.notifyAll();
+ }
+ }
+ @Override public void persist_manager(byte[] channel_manager_bytes) { }
+ });
+ this.chan_manager = constructor.channel_manager;
+ must_free_objs.add(new WeakReference<>(this.chan_manager));
+ // If we are using a ChannelManagerConstructor, we may have pending events waiting on the old peer
+ // which have been removed from the ChannelManager but which we still need to handle.
+ this.pending_manager_events.addAll(orig.pending_manager_events);
+ if (!this.pending_manager_events.isEmpty()) {
+ // However, this implies cross_reload_ref_pollution
+ cross_reload_ref_pollution = true;
+ }
+ } catch (ChannelManagerConstructor.InvalidSerializedDataException e) {
+ assert false;
+ }
+ } else {
+ ChannelMonitor[] monitors = new ChannelMonitor[1];