graph

package
v0.0.0-...-cafecf9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 16, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckProfitable

func CheckProfitable(edges []Offer) bool

func CurrencyAmountAndIssuer

func CurrencyAmountAndIssuer(takerPays interface{}) (string, float64, string)

func DropToPriceInUSD

func DropToPriceInUSD(drop int) (usd float64)

func DropToXrp

func DropToXrp(drop float64) (xrp float64)

func GetCycle

func GetCycle(asset string, predecessors map[string]string) []string

Types

type Graph

type Graph struct {
	Graph         map[string]map[string]*OrderBook
	AccountRoots  map[string]map[int]*Offer
	Issuers       map[string]bool
	Clients       map[string]bool
	AccountLedger map[string][]string
	Lock          sync.RWMutex
}

Graph : Data structure for graph of offers

func (*Graph) CreateSimpleGraph

func (graph *Graph) CreateSimpleGraph() SimplerGraph

CreateSimpleGraph : function for creating a SimpleGraph

func (*Graph) GetProfitableOffers

func (graph *Graph) GetProfitableOffers() ([]Offer, []string)

func (*Graph) ParseTransaction

func (graph *Graph) ParseTransaction(tx data.Transaction) (newOffers []Offer)

func (*Graph) PaymentTransactionParse

func (graph *Graph) PaymentTransactionParse(tx data.Transaction) (newOffers []Offer)

func (*Graph) SortGraphWithTxs

func (graph *Graph) SortGraphWithTxs()

SortGraphWithTxs : function for creating a new graph with offers sorted by rates

type Offer

type Offer struct {
	//Indexing
	XrpTx          data.Transaction
	TxHash         string
	Account        string
	SequenceNumber int

	//Actual transaction data
	Rate           float64
	Quantity       float64
	CreatorWillPay string
	CreatorWillGet string
	Issuer         string
}

Offer : Data structure for an offer

func (Offer) ToString

func (offer Offer) ToString() string

type OrderBook

type OrderBook struct {
	List    []*Offer
	Pay     string
	WillGet string
}

type SimplerGraph

type SimplerGraph struct {
	Graph      map[string]map[string]float64
	Currencies []string
	Lock       sync.Mutex
}

SimplerGraph : Data structure for graph of best offers (nxn grid, -log(edge))

func (SimplerGraph) BellmanFord

func (graph SimplerGraph) BellmanFord() (string, map[string]string)

BellmanFord : Run Bellman-Ford Algorithm on the Simpler Graph with the best rates

type TxList

type TxList struct {
	List []*Offer
}

TxList : Data structure for list of offers

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL