X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=ts%2Fstructs%2FLockableScore.mts;h=7582f892420e5bb529a662c87bb67722d7445124;hb=9d652fa3984c75323634bbe004bd7cac4906f950;hp=583de5cf87adc24c32c4fc80f28b641a4f44cc8a;hpb=bf08029c1ad5244b59902eada723b634dcade62d;p=ldk-java diff --git a/ts/structs/LockableScore.mts b/ts/structs/LockableScore.mts index 583de5cf..7582f892 100644 --- a/ts/structs/LockableScore.mts +++ b/ts/structs/LockableScore.mts @@ -280,11 +280,13 @@ import { MultiThreadedLockableScore } from '../structs/MultiThreadedLockableScor import CommonBase from './CommonBase.mjs'; import * as bindings from '../bindings.mjs' -import * as InternalUtils from '../InternalUtils.mjs' +/** An implementation of LockableScore */ export interface LockableScoreInterface { + /**Returns the locked scorer. + */ lock(): Score; } @@ -292,6 +294,16 @@ class LDKLockableScoreHolder { held: LockableScore; } +/** + * A scorer that is accessed under a lock. + * + * Needed so that calls to [`Score::channel_penalty_msat`] in [`find_route`] can be made while + * having shared ownership of a scorer but without requiring internal locking in [`Score`] + * implementations. Internal locking would be detrimental to route finding performance and could + * result in [`Score::channel_penalty_msat`] returning a different value for the same channel. + * + * [`find_route`]: crate::routing::router::find_route + */ export class LockableScore extends CommonBase { /* @internal */ public bindings_instance?: bindings.LDKLockableScore; @@ -302,7 +314,8 @@ export class LockableScore extends CommonBase { this.bindings_instance = null; } - static new_impl(arg: LockableScoreInterface): LockableScore { + /** Creates a new instance of LockableScore from a given implementation */ + public static new_impl(arg: LockableScoreInterface): LockableScore { const impl_holder: LDKLockableScoreHolder = new LDKLockableScoreHolder(); let structImplementation = { lock (): number { @@ -318,6 +331,10 @@ export class LockableScore extends CommonBase { impl_holder.held.bindings_instance = structImplementation; return impl_holder.held; } + + /** + * Returns the locked scorer. + */ public lock(): Score { const ret: number = bindings.LockableScore_lock(this.ptr); const ret_hu_conv: Score = new Score(null, ret);