func updateHostHistoricInteractions(host *modules.HostDBEntry, bh types.BlockHeight) {
	if host.LastHistoricUpdate >= bh {
		return
	}
	passedTime := bh - host.LastHistoricUpdate
	hsi := host.HistoricSuccessfulInteractions
	hfi := host.HistoricFailedInteractions
	decay := historicInteractionDecay
	hsi *= decay
	hfi *= decay
	rsi := float64(host.RecentSuccessfulInteractions)
	rfi := float64(host.RecentFailedInteractions)
	if hsi+hfi > historicInteractionDecayLimit {
		if rsi+rfi > recentInteractionWeightLimit*(hsi+hfi) {
			adjustment := recentInteractionWeightLimit * (hsi + hfi) / (rsi + rfi)
			rsi *= adjustment
			rfi *= adjustment
		}
	} else {
		if rsi+rfi > recentInteractionWeightLimit*historicInteractionDecayLimit {
			adjustment := recentInteractionWeightLimit * historicInteractionDecayLimit / (rsi + rfi)
			rsi *= adjustment
			rfi *= adjustment
		}
	}
	hsi += rsi
	hfi += rfi
	if passedTime > 1 && hsi+hfi > historicInteractionDecayLimit {
		decay := math.Pow(historicInteractionDecay, float64(passedTime-1))
		hsi *= decay
		hfi *= decay
	}
	host.HistoricSuccessfulInteractions = hsi
	host.HistoricFailedInteractions = hfi
	host.RecentSuccessfulInteractions = 0
	host.RecentFailedInteractions = 0
	host.LastHistoricUpdate = bh
}
updateHostDBEntry updates a HostDBEntries's historic interactions if more
than one block passed since the last update. This should be called every time
before the recent interactions are updated.  if passedTime is e.g. 10, this
means that the recent interactions were updated 10 blocks ago but never
since. So we need to apply the decay of 1 block before we append the recent
interactions from 10 blocks ago and then apply the decay of 9 more blocks in
which the recent interactions have been 0
package hostdb
import (
	"math"
	"github.com/NebulousLabs/Sia/modules"
	"github.com/NebulousLabs/Sia/types"
)