cache

package
v0.0.0-...-7abe34b Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AccumTagged

type AccumTagged struct {
	model.AccumPoolStats
	types.PoolLocation
}

type HasHash

type HasHash interface {
	// buf is optional to avoid unnecessary allocations
	Hash(buf *bytes.Buffer) [32]byte
}

type HasTime

type HasTime interface {
	Time() int
}

type KoAndLocPair

type KoAndLocPair struct {
	Loc types.PositionLocation
	Ko  *model.KnockoutSubplot
}

func (KoAndLocPair) Hash

func (k KoAndLocPair) Hash(buf *bytes.Buffer) [32]byte

func (KoAndLocPair) Time

func (k KoAndLocPair) Time() int

type MemoryCache

type MemoryCache struct {
	// contains filtered or unexported fields
}

func New

func New() *MemoryCache

func (*MemoryCache) AddPoolEvent

func (m *MemoryCache) AddPoolEvent(tx types.PoolTxEvent)

func (*MemoryCache) AddUserBalance

func (m *MemoryCache) AddUserBalance(chainId types.ChainId, user types.EthAddress, token types.EthAddress)

func (*MemoryCache) BorrowPoolHourlyCandles

func (m *MemoryCache) BorrowPoolHourlyCandles(loc types.PoolLocation, writeLock bool) (*[]model.Candle, *sync.RWMutex)

func (*MemoryCache) BorrowPoolLimits

Caller has responsibility of unlocking the result when complete, otherwise will deadlock

func (*MemoryCache) BorrowPoolPositions

func (m *MemoryCache) BorrowPoolPositions(loc types.PoolLocation) (map[types.PositionLocation]*model.PositionTracker, *sync.RWMutex)

Caller has responsibility of unlocking the result when complete, otherwise will deadlock

func (*MemoryCache) BorrowPoolTradingHist

func (m *MemoryCache) BorrowPoolTradingHist(loc types.PoolLocation, writeLock bool) (*model.PoolTradingHistory, *sync.RWMutex)

func (*MemoryCache) LatestBlock

func (m *MemoryCache) LatestBlock(chainId types.ChainId) int64

func (*MemoryCache) MaterializeKnockoutPos

func (m *MemoryCache) MaterializeKnockoutPos(loc types.PositionLocation) *model.KnockoutSubplot

func (*MemoryCache) MaterializeKnockoutSaga

func (m *MemoryCache) MaterializeKnockoutSaga(loc types.BookLocation) *model.KnockoutSaga

func (*MemoryCache) MaterializePoolLiqCurve

func (m *MemoryCache) MaterializePoolLiqCurve(loc types.PoolLocation, writeLock bool) (*model.LiquidityCurve, *sync.RWMutex)

func (*MemoryCache) MaterializePoolTradingHist

func (m *MemoryCache) MaterializePoolTradingHist(loc types.PoolLocation, writeLock bool) (*model.PoolTradingHistory, *sync.RWMutex)

func (*MemoryCache) MaterializePosition

func (m *MemoryCache) MaterializePosition(loc types.PositionLocation) *model.PositionTracker

func (*MemoryCache) RetrieveAllCurves

func (m *MemoryCache) RetrieveAllCurves() map[types.PoolLocation]*model.LiquidityCurve

func (*MemoryCache) RetrieveAllPositions

func (m *MemoryCache) RetrieveAllPositions() map[types.PositionLocation]*model.PositionTracker

func (*MemoryCache) RetrieveAllPositionsSorted

func (m *MemoryCache) RetrieveAllPositionsSorted() []PosAndLocPair

Returns all positions sorted by LatestUpdateTime in descending order

func (*MemoryCache) RetrieveChainAccums

func (m *MemoryCache) RetrieveChainAccums(chainId types.ChainId) []AccumTagged

func (*MemoryCache) RetrieveLastNPoolKo

func (m *MemoryCache) RetrieveLastNPoolKo(pool types.PoolLocation, lastN int) []KoAndLocPair

func (*MemoryCache) RetrieveLastNPoolPos

func (m *MemoryCache) RetrieveLastNPoolPos(pool types.PoolLocation, lastN int) []PosAndLocPair

func (*MemoryCache) RetrieveLastNPoolTxs

func (m *MemoryCache) RetrieveLastNPoolTxs(pool types.PoolLocation, lastN int) []types.PoolTxEvent

func (*MemoryCache) RetrieveLastNUserTxs

func (m *MemoryCache) RetrieveLastNUserTxs(chainId types.ChainId, user types.EthAddress, nResults int) []types.PoolTxEvent

func (*MemoryCache) RetrievePivotTime

func (m *MemoryCache) RetrievePivotTime(loc types.BookLocation) int

func (*MemoryCache) RetrievePoolAccum

func (m *MemoryCache) RetrievePoolAccum(loc types.PoolLocation) (stats model.AccumPoolStats, eventCount int)

func (*MemoryCache) RetrievePoolAccumBefore

func (m *MemoryCache) RetrievePoolAccumBefore(loc types.PoolLocation, histTime int) (stats model.AccumPoolStats, eventCount int)

func (*MemoryCache) RetrievePoolAccumFirst

func (m *MemoryCache) RetrievePoolAccumFirst(loc types.PoolLocation) model.AccumPoolStats

func (*MemoryCache) RetrievePoolAccumSeries

func (m *MemoryCache) RetrievePoolAccumSeries(loc types.PoolLocation, startTime int, endTime int) (openVal model.AccumPoolStats, retSeries []model.AccumPoolStats)

func (*MemoryCache) RetrievePoolAccumSeriesOld

func (m *MemoryCache) RetrievePoolAccumSeriesOld(loc types.PoolLocation, startTime int, endTime int) (model.AccumPoolStats, []model.AccumPoolStats)

func (*MemoryCache) RetrievePoolKoAtTime

func (m *MemoryCache) RetrievePoolKoAtTime(pool types.PoolLocation, afterTime int, beforeTime int, n int, seen map[[32]byte]struct{}) []KoAndLocPair

func (*MemoryCache) RetrievePoolLimits

func (m *MemoryCache) RetrievePoolLimits(loc types.PoolLocation) map[types.PositionLocation]*model.KnockoutSubplot

func (*MemoryCache) RetrievePoolLiqCurve

func (m *MemoryCache) RetrievePoolLiqCurve(loc types.PoolLocation) (float64, []*model.LiquidityBump)

func (*MemoryCache) RetrievePoolPosAtTime

func (m *MemoryCache) RetrievePoolPosAtTime(pool types.PoolLocation, afterTime int, beforeTime int, n int, seen map[[32]byte]struct{}) []PosAndLocPair

func (*MemoryCache) RetrievePoolPositions

func (m *MemoryCache) RetrievePoolPositions(loc types.PoolLocation) map[types.PositionLocation]*model.PositionTracker

func (*MemoryCache) RetrievePoolSet

func (m *MemoryCache) RetrievePoolSet() []types.PoolLocation

func (*MemoryCache) RetrievePoolTxs

func (m *MemoryCache) RetrievePoolTxs(pool types.PoolLocation) []types.PoolTxEvent

func (*MemoryCache) RetrievePoolTxsAtTime

func (m *MemoryCache) RetrievePoolTxsAtTime(pool types.PoolLocation, afterTime int, beforeTime int, n int) []types.PoolTxEvent

func (*MemoryCache) RetrieveUserBalances

func (m *MemoryCache) RetrieveUserBalances(chainId types.ChainId, user types.EthAddress) []types.EthAddress

func (*MemoryCache) RetrieveUserLimits

func (m *MemoryCache) RetrieveUserLimits(
	chainId types.ChainId,
	user types.EthAddress) map[types.PositionLocation]*model.KnockoutSubplot

func (*MemoryCache) RetrieveUserPoolLimits

func (m *MemoryCache) RetrieveUserPoolLimits(user types.EthAddress, pool types.PoolLocation) map[types.PositionLocation]*model.KnockoutSubplot

func (*MemoryCache) RetrieveUserPoolPositions

func (m *MemoryCache) RetrieveUserPoolPositions(user types.EthAddress, pool types.PoolLocation) map[types.PositionLocation]*model.PositionTracker

func (*MemoryCache) RetrieveUserPositions

func (m *MemoryCache) RetrieveUserPositions(chainId types.ChainId, user types.EthAddress) map[types.PositionLocation]*model.PositionTracker

func (*MemoryCache) RetrieveUserTxsAtTime

func (m *MemoryCache) RetrieveUserTxsAtTime(chainId types.ChainId, user types.EthAddress, afterTime int, beforeTime int, nResults int) []types.PoolTxEvent

func (*MemoryCache) SetPivotTime

func (m *MemoryCache) SetPivotTime(loc types.BookLocation, pivotTime int)

type PosAndLocPair

type PosAndLocPair struct {
	Loc types.PositionLocation
	Pos *model.PositionTracker
}

func (PosAndLocPair) Hash

func (p PosAndLocPair) Hash(buf *bytes.Buffer) [32]byte

func (PosAndLocPair) Time

func (p PosAndLocPair) Time() int

type RWLockMap

type RWLockMap[Key comparable, Val any] struct {
	// contains filtered or unexported fields
}

type RWLockMapArray

type RWLockMapArray[Key comparable, Val interface {
	HasTime
	HasHash
}] struct {
	// contains filtered or unexported fields
}

HasTime constraint is necessary only for lookupLastNTime, otherwise it would require type assertion for every element, which is very slow.

type RWLockMapMap

type RWLockMapMap[Key comparable, KeyInner interface {
	comparable
	HasHash
}, Val HasTime] struct {
	// contains filtered or unexported fields
}

HasTime constraint is necessary only for lookupLastNTime, otherwise it would require type assertion for every element, which is very slow.

Jump to

Keyboard shortcuts

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