-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implementing path finding without Horizon
- Loading branch information
1 parent
d5c856e
commit f1230cf
Showing
20 changed files
with
512 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export * from "./account"; | ||
export * from "./account_data"; | ||
export * from "./offer"; | ||
export * from "./trustline"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import BigNumber from "bignumber.js"; | ||
import { Column, Entity, JoinColumn, ManyToOne, PrimaryColumn } from "typeorm"; | ||
import { AccountID, AssetID } from "../../model"; | ||
import { AssetFactory } from "../../model/factories"; | ||
import { BigNumberTransformer } from "../../util/orm"; | ||
import { Account } from "./"; | ||
|
||
@Entity("trustlines") | ||
/* tslint:disable */ | ||
export class TrustLine { | ||
@PrimaryColumn({ name: "accountid" }) | ||
@ManyToOne(type => Account, account => account.trustLines) | ||
@JoinColumn({ name: "accountid" }) | ||
account: Account; | ||
|
||
@PrimaryColumn() | ||
issuer: AccountID; | ||
|
||
@PrimaryColumn({ name: "assetcode" }) | ||
assetCode: string; | ||
|
||
@Column({ name: "assettype" }) | ||
assetType: number; | ||
|
||
@Column({ name: "tlimit", type: "bigint", transformer: BigNumberTransformer }) | ||
limit: BigNumber; | ||
|
||
@Column({ type: "bigint", transformer: BigNumberTransformer }) | ||
balance: BigNumber; | ||
|
||
@Column() | ||
flags: number; | ||
|
||
@Column({ name: "lastmodified" }) | ||
lastModified: number; | ||
|
||
@Column({ type: "bigint", name: "buyingliabilities", transformer: BigNumberTransformer }) | ||
buyingLiabilities: BigNumber; | ||
|
||
@Column({ type: "bigint", name: "sellingliabilities", transformer: BigNumberTransformer }) | ||
sellingLiabilities: BigNumber; | ||
|
||
public get asset(): AssetID { | ||
return AssetFactory.fromTrustline(this.assetType, this.assetCode, this.issuer).toString(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { BigNumber } from "bignumber.js"; | ||
import { AssetID } from "../../model"; | ||
import { Offer } from "../../orm/entities/offer"; | ||
import { OffersGraph } from "./offers_graph"; | ||
import { load as loadOrderBook } from "./orderbook"; | ||
import { PathFinder } from "./path_finder"; | ||
|
||
const offersGraph = new OffersGraph(); | ||
|
||
export * from "./offers_listener"; | ||
|
||
export function buildOffersGraph(offers: Offer[]): void { | ||
offersGraph.build(offers); | ||
} | ||
|
||
export function updateOffersGraph(selling: AssetID, buying: AssetID, offers: Offer[]): void { | ||
offersGraph.update(selling, buying, offers); | ||
} | ||
|
||
export function findPaymentPaths(sourceAssets: AssetID[], destAsset: AssetID, destAmount: BigNumber) { | ||
const pathFinder = new PathFinder(offersGraph); | ||
return pathFinder.findPaths(sourceAssets, destAsset, destAmount); | ||
} | ||
|
||
export const orderBook = { load: loadOrderBook }; |
Oops, something went wrong.