From 6c1fbf7c5cfca8ada71d7d1b2cd47ba3f0a73cf0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Mon, 30 Sep 2019 20:20:44 +0200 Subject: [PATCH] chain: Fix voucher increment math --- chain/deals/handler_states.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/chain/deals/handler_states.go b/chain/deals/handler_states.go index 7908026a2..4ab32b146 100644 --- a/chain/deals/handler_states.go +++ b/chain/deals/handler_states.go @@ -105,11 +105,11 @@ func (h *Handler) consumeVouchers(ctx context.Context, deal MinerDeal) error { return xerrors.Errorf("no payment vouchers for deal") } - increments := deal.Proposal.Duration / uint64(len(deal.Proposal.Payment.Vouchers)) + increment := deal.Proposal.Duration / uint64(len(deal.Proposal.Payment.Vouchers)) - startH := deal.Proposal.Payment.Vouchers[0].TimeLock - (deal.Proposal.Duration / increments) + startH := deal.Proposal.Payment.Vouchers[0].TimeLock - increment if startH > curHead.Height()+build.DealVoucherSkewLimit { - return xerrors.Errorf("deal starts too far into the future") + return xerrors.Errorf("deal starts too far into the future: start=%d; h=%d; max=%d; inc=%d", startH, curHead.Height(), curHead.Height()+build.DealVoucherSkewLimit, increment) } vspec := VoucherSpec(deal.Proposal.Duration, deal.Proposal.TotalPrice, startH, nil) @@ -117,7 +117,7 @@ func (h *Handler) consumeVouchers(ctx context.Context, deal MinerDeal) error { lane := deal.Proposal.Payment.Vouchers[0].Lane for i, voucher := range deal.Proposal.Payment.Vouchers { - maxClose := curHead.Height() + (increments * uint64(i+1)) + build.DealVoucherSkewLimit + maxClose := curHead.Height() + (increment * uint64(i+1)) + build.DealVoucherSkewLimit if err := h.checkVoucher(ctx, deal, voucher, lane, maxClose, vspec[i].Amount); err != nil { return xerrors.Errorf("validating payment voucher %d: %w", i, err)