Skip to content

Commit

Permalink
boostrap with libp2p.me, increase dl timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
magik6k committed Jan 8, 2025
1 parent 1d79cfa commit acfa4bd
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 8 deletions.
21 changes: 20 additions & 1 deletion rbdeal/car_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,25 @@ func (r *ribs) setupCarServer(ctx context.Context, host host.Host) error {
}
}()

// bootstrap to libp2p.me
lmeMaddr := "/dns/libp2p.me/tcp/4001"
lmeMa, err := ma.NewMultiaddr(lmeMaddr)
if err != nil {
return err
}
lmePid, err := peer.Decode("12D3KooWSM8TT2UFGaXk7fisoiS1UC9MkWc2PVwYyKiWuNWBpqBw")
if err != nil {
return err
}

err = host.Connect(ctx, peer.AddrInfo{
ID: lmePid,
Addrs: []ma.Multiaddr{lmeMa},
})
if err != nil {
log.Errorw("failed to connect to peer", "peer", lmePid, "error", err)
}

go r.carStatsWorker(ctx)

// todo also serve tcp
Expand Down Expand Up @@ -154,7 +173,7 @@ func (r *ribs) verify(ctx context.Context, token string) (carRequestToken, error
return carRequestToken{}, xerrors.Errorf("JWT Verification failed: %w", err)
}

if payload.Timeout < time.Now().Unix() {
if payload.Timeout < time.Now().Add(-dealDownloadTimeout).Unix() {
return carRequestToken{}, xerrors.Errorf("token expired")
}

Expand Down
2 changes: 1 addition & 1 deletion rbdeal/deal_db.go
Original file line number Diff line number Diff line change
Expand Up @@ -827,7 +827,7 @@ func (r *ribsDB) UpdateSPDealState(id uuid.UUID, stresp *types.DealStatusRespons
} else if stresp.DealStatus == nil {
errMsg := fmt.Sprintf("DealStatus is nil (resp err: '%s')", stresp.Error)

failed := true
failed := false

_, err := r.db.Exec(`update deals set
failed = ?,
Expand Down
3 changes: 2 additions & 1 deletion rbdeal/deal_params.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ var (

dealPublishFinality abi.ChainEpoch = 60

dealStartTime = abi.ChainEpoch(builtin.EpochsInDay * 4) // 4 days
dealStartTime = abi.ChainEpoch(builtin.EpochsInDay * 4) // 4 days
dealDownloadTimeout = time.Hour * 24 * 4
)

// deal checker
Expand Down
6 changes: 2 additions & 4 deletions rbdeal/group_deal.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ import (
"bytes"
"context"
"fmt"
gobig "math/big"
"time"

"github.com/filecoin-project/go-address"
cborutil "github.com/filecoin-project/go-cbor-util"
commcid "github.com/filecoin-project/go-fil-commcid"
Expand All @@ -23,6 +20,7 @@ import (
"github.com/lotus-web3/ribs/ributil"
types "github.com/lotus-web3/ribs/ributil/boosttypes"
"golang.org/x/xerrors"
gobig "math/big"
)

const DealProtocolv120 = "/fil/storage/mk/1.2.0"
Expand Down Expand Up @@ -161,7 +159,7 @@ func (r *ribs) makeMoreDeals(ctx context.Context, id iface.GroupKey, w *ributil.
}

// generate transfer token
transfer, err := r.makeCarRequest(id, time.Hour*36, dealInfo.CarSize, dealUuid)
transfer, err := r.makeCarRequest(id, dealDownloadTimeout, dealInfo.CarSize, dealUuid)
if err != nil {
return xerrors.Errorf("make car request token: %w", err)
}
Expand Down
2 changes: 1 addition & 1 deletion rbdeal/sp_crawl.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func (r *ribs) spCrawlLoop(ctx context.Context, gw api.Gateway, pingP2P host.Hos
return xerrors.Errorf("loading market actor: %w", err)
}

bt, err := mact.LockedTable()
bt, err := mact.EscrowTable()
if err != nil {
return xerrors.Errorf("getting locked table: %w", err)
}
Expand Down

0 comments on commit acfa4bd

Please sign in to comment.