package Ġorg . know ledger . ledger . adapters . pools Ċ Ċ import Ġcom . github . m ichael bull . result . binding Ċ import Ġcom . github . m ichael bull . result . combine Ċ import Ġorg . know ledger . collections . to Mutable Sort edList From Pre Sorted Ċ import Ġorg . know ledger . ledger . adapters . Ledger Storage Adapter Ċ import Ġorg . know ledger . ledger . chain . Persistence Context Ċ import Ġorg . know ledger . ledger . chain . solver . Storage State Ċ import Ġorg . know ledger . ledger . crypto . Hash Ċ import Ġorg . know ledger . ledger . database . Storage Element Ċ import Ġorg . know ledger . ledger . database . Storage Type Ċ import Ġorg . know ledger . ledger . database . results . Data Failure Ċ import Ġorg . know ledger . ledger . results . Outcome Ċ import Ġorg . know ledger . ledger . results . ok Ċ import Ġorg . know ledger . ledger . storage . Adapter Ids Ċ import Ġorg . know ledger . ledger . storage . Mutable Block Pool Ċ import Ġorg . know ledger . ledger . storage . results . Load Failure Ċ Ċ internal Ġclass ĠBlock Pool Storage Adapter Ġ: ĠLed ger Storage Adapter < Mutable Block Pool > Ġ{ ĊĠĠĠ Ġoverride Ġval Ġid : ĠString Ġget () Ġ= Ġ" Block Pool " ĊĊĠĠĠ Ġoverride Ġval Ġproperties : ĠMap < String , ĠStorage Type > ĊĠĠĠĠĠĠĠ Ġget () Ġ= Ġmap Of ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" chain Id " Ġto ĠStorage Type . LINK , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" blocks " Ġto ĠStorage Type . LIST , ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠ Ġoverride Ġfun Ġstore ( ĊĠĠĠĠĠĠĠ Ġelement : ĠMutable Block Pool , Ġstate : ĠStorage State , ĊĠĠĠ Ġ): ĠOut come < Unit , ĠData Failure > Ġ= ĊĠĠĠĠĠĠĠ Ġwith ( state ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġpush New Linked (" chain Id ", Ġelement . chain Id , ĠAdapter Ids . Chain Id ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġpush New LinkedList (" blocks ", Ġelement . mutable Blocks , ĠAdapter Ids . Block ) ĊĠĠĠĠĠĠĠ Ġ}. ok () ĊĊĠĠĠ Ġoverride Ġfun Ġload ( ĊĠĠĠĠĠĠĠ Ġledger Hash : ĠHash , Ġelement : ĠStorage Element , Ġcontext : ĠPersistence Context , ĊĠĠĠ Ġ): ĠOut come < Mutable Block Pool , ĠLoad Failure > Ġ= ĊĠĠĠĠĠĠĠ Ġwith ( element ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġblock Elem Ġ= Ġget Mutable Element List (" blocks ") ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġchain Elem Ġ= Ġget Linked (" chain Id ") ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġblock Adapter Ġ= Ġcontext . block Storage Adapter ĊĠĠĠĠĠĠĠĠĠĠĠ Ġbinding Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġblocks Ġ= Ġblock Elem . map Ġ{ Ġblock Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġblock Adapter . load ( ledger Hash , Ġblock , Ġcontext ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ}. combine (). bind () ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġchain Id Ġ= Ġcontext . chain Id Storage Adapter . load ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġledger Hash , Ġchain Elem , Ġcontext , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ). bind () ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġcontext . block Pool Factory . create ( chain Id , Ġblocks . to Mutable Sort edList From Pre Sorted ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ} Ċ Ċ }