Skip to content

Commit

Permalink
corrected ipfs pin_ls and push rate to 100 everywhere
Browse files Browse the repository at this point in the history
  • Loading branch information
ehsan6sha committed Jan 15, 2024
1 parent c682599 commit 60d4520
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
21 changes: 16 additions & 5 deletions blox/ipfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ func (p *Blox) ServeIpfsRpc() http.Handler {
mux := http.NewServeMux()
// https://docs.ipfs.tech/reference/kubo/rpc/#api-v0-pin-ls
mux.HandleFunc("/api/v0/pin/ls", func(w http.ResponseWriter, r *http.Request) {
log.Debug("pin/ls request received")
var resp pinListResp
resp.PinLsList.Keys = make(map[string]pinListKeysType)
results, err := p.ds.Query(r.Context(), query.Query{
Expand All @@ -111,12 +112,22 @@ func (p *Blox) ServeIpfsRpc() http.Handler {
http.Error(w, "internal error while traversing datastore results: "+err.Error(), http.StatusInternalServerError)
return
}
c, err := cid.Cast([]byte(result.Key))
if err != nil {
log.Debugw("failed to cast key to cid", "key", result.Key, "err", err)
continue
keyBytes := []byte(result.Key) // Convert the key to a byte slice

if len(keyBytes) > 1 {
// Slice the keyBytes to remove the first byte
slicedKeyBytes := keyBytes[1:]

c, err := cid.Cast(slicedKeyBytes)
if err != nil {
log.Debugw("failed to cast sliced key to cid", "slicedKeyBytes", slicedKeyBytes, "err", err)
continue
}

resp.PinLsList.Keys[c.String()] = pinListKeysType{Type: "fx"} //TODO: what should the type be?
} else {
log.Debugw("key too short to be a valid CID", "keyBytes", keyBytes)
}
resp.PinLsList.Keys[c.String()] = pinListKeysType{Type: "fx"} //TODO: what should the type be?
}
if err := json.NewEncoder(w).Encode(resp); err != nil {
log.Errorw("failed to encode response to pin ls", "err", err)
Expand Down
2 changes: 1 addition & 1 deletion exchange/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func newOptions(o ...Option) (*options, error) {
ipniPublishMaxBatchSize: 16 << 10,
ipniPublishChanBuffer: 1,
wg: nil,
pushRateLimiter: ratelimit.New(50), // Default of 50 per second
pushRateLimiter: ratelimit.New(100), // Default of 50 per second
}
for _, apply := range o {
if err := apply(&opts); err != nil {
Expand Down

0 comments on commit 60d4520

Please sign in to comment.