package services import ( "ripple/bug" "ripple/types" ) func (m *PaymentManager) PreviewBandwidthIn(id types.UserIdentifier) uint64 { bandwidth := int64(m.st.Storage.GetBandwidthIn(id)) for paymentID := range m.st.Memory.Commit[id] { pf, ok := m.st.Memory.GetPathfinding(paymentID) if !ok { continue } if pf.Incoming == id && pf.Commit { bandwidth -= int64(pf.Amount+pf.FeeIn()) } } if bandwidth < 0 { panic(bug.BugStateViolated) } return uint64(bandwidth) }