Skip to content

Commit 9da1fb8

Browse files
committed
Update batteries to new Tuple-mapping API
1 parent b3302d4 commit 9da1fb8

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

src/main/java/org/ldk/batteries/ChannelManagerConstructor.java

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public static class InvalidSerializedDataException extends Exception {}
3636
* After doing so (and syncing the blockchain on the channel manager as well), you should call chain_sync_completed()
3737
* and then continue to normal application operation.
3838
*/
39-
public final TwoTuple<ChannelMonitor, byte[]>[] channel_monitors;
39+
public final TwoTuple_BlockHashChannelMonitorZ[] channel_monitors;
4040
/**
4141
* A PeerManager which is constructed to pass messages and handle connections to peers.
4242
*/
@@ -65,23 +65,24 @@ public ChannelManagerConstructor(byte[] channel_manager_serialized, byte[][] cha
6565
BroadcasterInterface tx_broadcaster, Logger logger) throws InvalidSerializedDataException {
6666
final IgnoringMessageHandler no_custom_messages = IgnoringMessageHandler.of();
6767
final ChannelMonitor[] monitors = new ChannelMonitor[channel_monitors_serialized.length];
68-
this.channel_monitors = new TwoTuple[monitors.length];
68+
this.channel_monitors = new TwoTuple_BlockHashChannelMonitorZ[monitors.length];
6969
for (int i = 0; i < monitors.length; i++) {
70-
Result_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ res = UtilMethods.BlockHashChannelMonitorZ_read(channel_monitors_serialized[i], keys_interface);
70+
Result_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ res = UtilMethods.C2Tuple_BlockHashChannelMonitorZ_read(channel_monitors_serialized[i], keys_interface);
7171
if (res instanceof Result_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ.Result_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_Err) {
7272
throw new InvalidSerializedDataException();
7373
}
74-
monitors[i] = ((Result_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ.Result_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_OK) res).res.b;
75-
this.channel_monitors[i] = new TwoTuple<>(monitors[i], ((Result_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ.Result_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_OK)res).res.a);
74+
byte[] block_hash = ((Result_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ.Result_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_OK)res).res.get_a();
75+
monitors[i] = ((Result_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ.Result_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_OK) res).res.get_b();
76+
this.channel_monitors[i] = TwoTuple_BlockHashChannelMonitorZ.of(block_hash, monitors[i]);
7677
}
7778
Result_C2Tuple_BlockHashChannelManagerZDecodeErrorZ res =
78-
UtilMethods.BlockHashChannelManagerZ_read(channel_manager_serialized, keys_interface, fee_estimator, chain_monitor.as_Watch(), tx_broadcaster,
79+
UtilMethods.C2Tuple_BlockHashChannelManagerZ_read(channel_manager_serialized, keys_interface, fee_estimator, chain_monitor.as_Watch(), tx_broadcaster,
7980
logger, UserConfig.with_default(), monitors);
8081
if (res instanceof Result_C2Tuple_BlockHashChannelManagerZDecodeErrorZ.Result_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_Err) {
8182
throw new InvalidSerializedDataException();
8283
}
83-
this.channel_manager = ((Result_C2Tuple_BlockHashChannelManagerZDecodeErrorZ.Result_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_OK)res).res.b;
84-
this.channel_manager_latest_block_hash = ((Result_C2Tuple_BlockHashChannelManagerZDecodeErrorZ.Result_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_OK)res).res.a;
84+
this.channel_manager = ((Result_C2Tuple_BlockHashChannelManagerZDecodeErrorZ.Result_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_OK)res).res.get_b();
85+
this.channel_manager_latest_block_hash = ((Result_C2Tuple_BlockHashChannelManagerZDecodeErrorZ.Result_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_OK)res).res.get_a();
8586
this.chain_monitor = chain_monitor;
8687
this.router = router;
8788
this.logger = logger;
@@ -115,7 +116,7 @@ public ChannelManagerConstructor(Network network, UserConfig config, byte[] curr
115116
@Nullable NetGraphMsgHandler router,
116117
BroadcasterInterface tx_broadcaster, Logger logger) {
117118
final IgnoringMessageHandler no_custom_messages = IgnoringMessageHandler.of();
118-
channel_monitors = new TwoTuple[0];
119+
channel_monitors = new TwoTuple_BlockHashChannelMonitorZ[0];
119120
channel_manager_latest_block_hash = null;
120121
this.chain_monitor = chain_monitor;
121122
this.router = router;
@@ -160,8 +161,8 @@ public interface EventHandler {
160161
*/
161162
public void chain_sync_completed(EventHandler event_handler) {
162163
if (background_processor != null) { return; }
163-
for (TwoTuple<ChannelMonitor, byte[]> monitor: channel_monitors) {
164-
this.chain_monitor.as_Watch().watch_channel(monitor.a.get_funding_txo().a, monitor.a);
164+
for (TwoTuple_BlockHashChannelMonitorZ monitor: channel_monitors) {
165+
this.chain_monitor.as_Watch().watch_channel(monitor.get_b().get_funding_txo().get_a(), monitor.get_b());
165166
}
166167
background_processor = BackgroundProcessor.start(org.ldk.structs.ChannelManagerPersister.new_impl(channel_manager -> {
167168
event_handler.persist_manager(channel_manager.write());

0 commit comments

Comments
 (0)