when reflecting a sdblob, insert all the stream and intermediate blobs using a transaction #50
2 changed files with 6 additions and 5 deletions
|
@ -11,6 +11,7 @@ import (
|
||||||
"math/big"
|
"math/big"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/lbryio/reflector.go/internal/metrics"
|
"github.com/lbryio/reflector.go/internal/metrics"
|
||||||
|
@ -70,11 +71,10 @@ func (s *Server) Start(address string) error {
|
||||||
}
|
}
|
||||||
r := mux.NewRouter()
|
r := mux.NewRouter()
|
||||||
r.HandleFunc("/get/{hash}", func(w http.ResponseWriter, r *http.Request) {
|
r.HandleFunc("/get/{hash}", func(w http.ResponseWriter, r *http.Request) {
|
||||||
waiter := stop.New()
|
waiter := &sync.WaitGroup{}
|
||||||
|
waiter.Add(1)
|
||||||
enqueue(&blobRequest{request: r, reply: w, finished: waiter})
|
enqueue(&blobRequest{request: r, reply: w, finished: waiter})
|
||||||
select {
|
waiter.Wait()
|
||||||
case <-waiter.Ch():
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
r.HandleFunc("/has/{hash}", func(w http.ResponseWriter, r *http.Request) {
|
r.HandleFunc("/has/{hash}", func(w http.ResponseWriter, r *http.Request) {
|
||||||
vars := mux.Vars(r)
|
vars := mux.Vars(r)
|
||||||
|
|
|
@ -2,6 +2,7 @@ package http3
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"sync"
|
||||||
|
|
||||||
"github.com/lbryio/reflector.go/internal/metrics"
|
"github.com/lbryio/reflector.go/internal/metrics"
|
||||||
|
|
||||||
|
@ -11,7 +12,7 @@ import (
|
||||||
type blobRequest struct {
|
type blobRequest struct {
|
||||||
request *http.Request
|
request *http.Request
|
||||||
reply http.ResponseWriter
|
reply http.ResponseWriter
|
||||||
finished *stop.Group
|
finished *sync.WaitGroup
|
||||||
}
|
}
|
||||||
|
|
||||||
var getReqCh = make(chan *blobRequest)
|
var getReqCh = make(chan *blobRequest)
|
||||||
|
|
Loading…
Reference in a new issue