Update auto-generated bindings to 0.0.103
[ldk-java] / ts / structs / Score.ts
1
2             
3 import CommonBase from './CommonBase';
4 import * as bindings from '../bindings' // TODO: figure out location
5
6
7
8             export class Score extends CommonBase {
9
10                 bindings_instance?: bindings.LDKScore;
11
12                 constructor(ptr?: number, arg?: bindings.LDKScore) {
13                     if (Number.isFinite(ptr)) {
14                                         super(ptr);
15                                         this.bindings_instance = null;
16                                     } else {
17                                         // TODO: private constructor instantiation
18                                         super(bindings.LDKScore_new(arg));
19                                         this.ptrs_to.push(arg);
20                                         
21                                     }
22                 }
23
24                 protected finalize() {
25                     if (this.ptr != 0) {
26                         bindings.Score_free(this.ptr);
27                     }
28                     super.finalize();
29                 }
30
31                 static new_impl(arg: ScoreInterface): Score {
32                     const impl_holder: LDKScoreHolder = new LDKScoreHolder();
33                     let structImplementation = <bindings.LDKScore>{
34                         // todo: in-line interface filling
35                         channel_penalty_msat (short_channel_id: number, source: number, target: number): number {
36                                                         const source_hu_conv: NodeId = new NodeId(null, source);
37                                                         const target_hu_conv: NodeId = new NodeId(null, target);
38                                                         number ret = arg.channel_penalty_msat(short_channel_id, source_hu_conv, target_hu_conv);
39                                 return ret;
40                                                 },
41
42                                                 payment_path_failed (path: number[], short_channel_id: number): void {
43                                                         RouteHop[] path_conv_10_arr = new RouteHop[path.length];
44                                 for (int k = 0; k < path.length; k++) {
45                                         number path_conv_10 = path[k];
46                                         const path_conv_10_hu_conv: RouteHop = new RouteHop(null, path_conv_10);
47                                         path_conv_10_hu_conv.ptrs_to.add(this);
48                                         path_conv_10_arr[k] = path_conv_10_hu_conv;
49                                 }
50                                                         arg.payment_path_failed(path_conv_10_arr, short_channel_id);
51                                                 },
52
53                                                 write (): Uint8Array {
54                                                         Uint8Array ret = arg.write();
55                                 return ret;
56                                                 },
57
58                                                 
59                     };
60                     impl_holder.held = new Score (null, structImplementation);
61                 }
62             }
63
64             export interface ScoreInterface {
65                 channel_penalty_msat(short_channel_id: number, source: NodeId, target: NodeId): number;
66                                 payment_path_failed(path: RouteHop[], short_channel_id: number): void;
67                                 write(): Uint8Array;
68                                 
69             }
70
71             class LDKScoreHolder {
72                 held: Score;
73             }
74         public number channel_penalty_msat(number short_channel_id, NodeId source, NodeId target) {
75                 number ret = bindings.Score_channel_penalty_msat(this.ptr, short_channel_id, source == null ? 0 : source.ptr & ~1, target == null ? 0 : target.ptr & ~1);
76                 this.ptrs_to.add(source);
77                 this.ptrs_to.add(target);
78                 return ret;
79         }
80
81         public void payment_path_failed(RouteHop[] path, number short_channel_id) {
82                 bindings.Score_payment_path_failed(this.ptr, path != null ? Arrays.stream(path).map(path_conv_10 -> path_conv_10 == null ? 0 : path_conv_10.ptr & ~1).toArray(number[]::new) : null, short_channel_id);
83         }
84
85         public Uint8Array write() {
86                 Uint8Array ret = bindings.Score_write(this.ptr);
87                 return ret;
88         }
89
90 }