tangled
alpha
login
or
join now
julien.rbrt.fr
/
vow
forked from
hailey.at/cocoon
0
fork
atom
Vow, uncensorable PDS written in Go
0
fork
atom
overview
issues
pulls
pipelines
fix
hailey.at
7 months ago
9a59a94b
5e348fae
+12
-27
4 changed files
expand all
collapse all
unified
split
recording_blockstore
recording_blockstore.go
server
handle_sync_get_blocks.go
repo.go
sqlite_blockstore
sqlite_blockstore.go
+1
recording_blockstore/recording_blockstore.go
···
20
20
return &RecordingBlockstore{
21
21
base: base,
22
22
inserts: make(map[cid.Cid]blockformat.Block),
23
23
+
reads: make(map[cid.Cid]blockformat.Block),
23
24
}
24
25
}
25
26
+10
-8
server/handle_sync_get_blocks.go
···
11
11
"github.com/labstack/echo/v4"
12
12
)
13
13
14
14
+
type ComAtprotoSyncGetBlocksRequest struct {
15
15
+
Did string `query:"did"`
16
16
+
Cids []string `query:"cids"`
17
17
+
}
18
18
+
14
19
func (s *Server) handleGetBlocks(e echo.Context) error {
15
20
ctx := e.Request().Context()
16
16
-
did := e.QueryParam("did")
17
17
-
if did == "" {
18
18
-
return helpers.InputError(e, nil)
19
19
-
}
20
21
21
21
-
cidstrs, ok := e.QueryParams()["cids"]
22
22
-
if !ok {
22
22
+
var req ComAtprotoSyncGetBlocksRequest
23
23
+
if err := e.Bind(&req); err != nil {
23
24
return helpers.InputError(e, nil)
24
25
}
26
26
+
25
27
var cids []cid.Cid
26
28
27
27
-
for _, cs := range cidstrs {
29
29
+
for _, cs := range req.Cids {
28
30
c, err := cid.Cast([]byte(cs))
29
31
if err != nil {
30
32
return err
···
33
35
cids = append(cids, c)
34
36
}
35
37
36
36
-
urepo, err := s.getRepoActorByDid(did)
38
38
+
urepo, err := s.getRepoActorByDid(req.Did)
37
39
if err != nil {
38
40
return helpers.ServerError(e, nil)
39
41
}
+1
-1
server/repo.go
···
104
104
105
105
dbs := rm.s.getBlockstore(urepo.Did)
106
106
bs := recording_blockstore.New(dbs)
107
107
-
r, err := repo.OpenRepo(context.TODO(), dbs, rootcid)
107
107
+
r, err := repo.OpenRepo(context.TODO(), bs, rootcid)
108
108
109
109
entries := []models.Record{}
110
110
var results []ApplyWriteResult
-18
sqlite_blockstore/sqlite_blockstore.go
···
135
135
func (bs *SqliteBlockstore) HashOnRead(enabled bool) {
136
136
panic("not implemented")
137
137
}
138
138
-
139
139
-
func (bs *SqliteBlockstore) Execute(ctx context.Context) error {
140
140
-
if !bs.readonly {
141
141
-
return fmt.Errorf("blockstore was not readonly")
142
142
-
}
143
143
-
144
144
-
bs.readonly = false
145
145
-
for _, b := range bs.inserts {
146
146
-
bs.Put(ctx, b)
147
147
-
}
148
148
-
bs.readonly = true
149
149
-
150
150
-
return nil
151
151
-
}
152
152
-
153
153
-
func (bs *SqliteBlockstore) GetLog() map[cid.Cid]blocks.Block {
154
154
-
return bs.inserts
155
155
-
}