package services import ( "encoding/binary" "ripple/commands" "ripple/types" ) func (m *PaymentManager) ForwardFindPath(paymentID [32]byte) { pf, ok := m.st.Memory.GetPathfinding(paymentID) if !ok { return } var from types.UserIdentifier var amountPos int64 var bandwidthFn func(types.UserIdentifier) int64 if pf.Amount < 0 { from = pf.Incoming bandwidthFn = m.PreviewBandwidthOut amountPos = -pf.Amount } else { from = pf.Outgoing bandwidthFn = m.PreviewBandwidthIn amountPos = pf.Amount } args := make([]byte, 40) copy(args, paymentID[:]) binary.BigEndian.PutUint64(args[32:40], uint64(pf.Amount)) instr := types.Instruction{ Command: commands.ACCOUNT_FIND_PATH, Arguments: args, } for id := range m.st.Storage.Accounts { if id == from { continue } bandwidth := bandwidthFn(id) if bandwidth >= amountPos { m.accSender.Send(id, instr) } } }