Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
tarassh committed Mar 11, 2024
1 parent ad3c0e4 commit 2970b2b
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,19 @@ func uploadHandler(contents string, node pinner.PinnerNode) (cid.Cid, error) {
log.Printf("uploaded file has root cid: %s\n", ccid)

carf.Close()

assertEquals(fcid, ccid)
log.Printf("the two cids match: %s\n", ccid.String())

log.Printf("removing dag...")
curr := time.Now().UnixMilli()
err = node.UnixfsService().RemoveDag(ctx, ccid)
after := time.Now().UnixMilli()
log.Println("time taken:", after-curr)
if err != nil {
log.Fatalf("%v", err)
}

return ccid, nil
}

Expand Down Expand Up @@ -393,3 +406,9 @@ func timeoutHttpHandler(s *State) http.Handler {
}
return http.HandlerFunc(fn)
}

func assertEquals(obj1 interface{}, obj2 interface{}) {
if obj1 != obj2 {
log.Fatalf("fail %v and %v doesn't match", obj1, obj2)
}
}

0 comments on commit 2970b2b

Please sign in to comment.