package Ġcom . r 3 . demos . ub in 2 a . plan Ċ Ċ import Ġco . parallel universe . fib ers . Suspend able Ċ import Ġcom . r 3 . demos . ub in 2 a . ob lig ation . O bl igation Ċ import Ġcom . r 3 . demos . ub in 2 a . plan . generator . O bl igation Edge Ċ import Ġcom . r 3 . demos . ub in 2 a . plan . solver . Component Cycle Solver Ċ import Ġcom . r 3 . demos . ub in 2 a . plan . solver . Component Net ting Optim iser Ċ import Ġcom . r 3 . demos . ub in 2 a . plan . solver . Net ting Optim iser Impl Ċ import Ġnet . cord a . core . contracts . Amount Ċ import Ġnet . cord a . core . flows . Flow Logic Ċ import Ġnet . cord a . core . flows . Initi ating Flow Ċ import Ġnet . cord a . core . flows . Start able By RPC Ċ import Ġnet . cord a . core . identity . Abstract Party Ċ import Ġjava . util .* Ċ Ċ data Ġclass ĠNet ting Payment ( val Ġfrom : ĠAbstract Party , Ġval Ġto : ĠAbstract Party , Ġval Ġamount : ĠAmount < Currency >) Ġ{ ĊĊĠĠĠ Ġoverride Ġfun ĠtoString (): ĠString Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġ" Net ting Payment (" Ġ+ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" from =${ from . name OrNull () !!. organisation }, Ġ" Ġ+ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" to =${ to . name OrNull () !!. organisation }, Ġ" Ġ+ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" amount =$ amount )" ĊĠĠĠ Ġ} Ċ Ċ } Ċ Ċ @ Initi ating Flow Ċ @ Start able By RPC Ċ class ĠNew Plan Flow ( val Ġoblig ations : ĠSet < O bl igation . State >, ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġlimits : ĠMap < Abstract Party , ĠAmount < Currency >>, Ġ// ĠWould Ġusually Ġjust Ġtake Ġ' Anonymous Party '. ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġprivate Ġval Ġnet ting Mode : ĠComponent Cycle Solver , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġprivate Ġval Ġextend Components : ĠBoolean Ġ= Ġfalse Ċ ) Ġ: ĠFlow Logic < Pair < List < Net ting Payment >, ĠList < O bl igation Edge >> >() Ġ{ ĊĠĠĠ Ġ@ Suspend able ĊĠĠĠ Ġoverride Ġfun Ġcall (): ĠPair < List < Net ting Payment >, ĠList < O bl igation Edge >> Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġ(_, Ġoblig ations Map , Ġcycles ) Ġ= Ġoblig ations Graph From ( ob lig ations . toList (), Ġextend Components ) ĊĠĠĠĠĠĠĠ Ġval Ġoptim iser Ġ= ĠNet ting Optim iser Impl ( cycles , Ġoblig ations Map , Ġlimits , Ġlogger , Ġ{ Ġc , Ġo , Ġl , Ġlg Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ ĠComponent Net ting Optim iser ( c , Ġo , Ġl , Ġlg , Ġnet ting Mode ) ĊĠĠĠĠĠĠĠ Ġ}) ĊĠĠĠĠĠĠĠ Ġreturn Ġoptim iser . optim ise () ĊĠĠĠ Ġ} Ċ } Ċ