Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions routes/dao_coin_exchange.go
Original file line number Diff line number Diff line change
Expand Up @@ -1216,8 +1216,15 @@ func (fes *APIServer) validateTransactorSellingCoinBalance(

// Compare transactor selling balance to total selling quantity.
if transactorSellingBalanceBaseUnits.Lt(totalSellingBaseUnits) {
return errors.Errorf("Insufficient balance to open order: Need %v but have %v",
totalSellingBaseUnits, transactorSellingBalanceBaseUnits)
coinAmountNeeded, _ := CalculateStringDecimalAmountFromBaseUnitsSimple(
sellingDAOCoinCreatorPublicKeyBase58Check,
totalSellingBaseUnits)
coinAmountHave, _ := CalculateStringDecimalAmountFromBaseUnitsSimple(
sellingDAOCoinCreatorPublicKeyBase58Check,
transactorSellingBalanceBaseUnits)
return errors.Errorf("Insufficient balance to open order: Need %v (%v) but have %v (%v)",
totalSellingBaseUnits, coinAmountNeeded,
transactorSellingBalanceBaseUnits, coinAmountHave)
}

// Happy path. No error. Transactor has sufficient balance to cover their selling quantity.
Expand Down
28 changes: 17 additions & 11 deletions routes/hot_feed.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@ const (
DefaultHotFeedInteractionCap uint64 = 4e12
// Maximum score amount that any individual PKID can contribute before time decay for a particular tag grouping.
DefaultHotFeedTagInteractionCap uint64 = 4e12
// How many iterations of the hot feed calculation until the built-up caches should be reset. (Once per day)
ResetCachesIterationLimit int = 288
// How many iterations of the hot feed calculation until the built-up caches should be reset.
// Once per day.
// TODO: Get this from consensus... Right now we assume 1.5s per block
ResetCachesIterationLimit int = 3600 * 24 * 1000 / 1500
)

// A single element in the server's HotFeedOrderedList.
Expand Down Expand Up @@ -402,15 +404,6 @@ func (fes *APIServer) UpdateHotFeedOrderedList(
// which is useful for testing purposes.
blockOffsetForTesting := 0

// Grab the last 60 days worth of blocks (25,920 blocks @ 5min/block).
lookbackWindowBlocks := 60 * 24 * 60 / 5
// Check if the most recent blocks that we'll be considering in hot feed computation have been processed.
for _, blockNode := range fes.blockchain.BestChain() {
if blockNode.Height < blockTip.Height-uint32(lookbackWindowBlocks+blockOffsetForTesting) {
continue
}
}

// Log how long this routine takes, since it could be heavy.
glog.V(2).Info("UpdateHotFeedOrderedList: Starting new update cycle.")
start := time.Now()
Expand All @@ -422,6 +415,19 @@ func (fes *APIServer) UpdateHotFeedOrderedList(
return nil
}

globalParams := utxoView.GetCurrentGlobalParamsEntry()
millisPerBlock := globalParams.BlockProductionIntervalMillisecondsPoS
blocksPerDay := int(24 * 60 * 60 * 1000 / millisPerBlock)

// Grab the last 7 days worth of blocks.
lookbackWindowBlocks := 7 * blocksPerDay
// Check if the most recent blocks that we'll be considering in hot feed computation have been processed.
for _, blockNode := range fes.blockchain.BestChain() {
if blockNode.Height < blockTip.Height-uint32(lookbackWindowBlocks+blockOffsetForTesting) {
continue
}
}

// Grab the last 24 hours worth of blocks (288 blocks @ 5min/block).
blockTipIndex := len(fes.blockchain.BestChain()) - 1 - blockOffsetForTesting
relevantNodes := fes.blockchain.BestChain()
Expand Down