Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-blockservice
Commits
f4bab574
Commit
f4bab574
authored
Aug 22, 2021
by
tavit ohanian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor after forking multiformats
parent
e2ca9248
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
857 additions
and
287 deletions
+857
-287
blockservice.go
blockservice.go
+11
-11
blockservice_test.go
blockservice_test.go
+7
-7
go.mod
go.mod
+15
-15
go.sum
go.sum
+811
-241
test/blocks_test.go
test/blocks_test.go
+8
-8
test/mock.go
test/mock.go
+5
-5
No files found.
blockservice.go
View file @
f4bab574
...
...
@@ -9,12 +9,12 @@ import (
"io"
"sync"
blocks
"git
hub.com/ipfs
/go-block-format"
cid
"git
hub.com/ipfs
/go-cid"
blockstore
"git
hub.com/ipfs/go-ipfs
-blockstore"
exchange
"git
hub.com/ipfs/go-ipfs
-exchange-interface"
logging
"git
hub.com/ipfs
/go-log"
"git
hub.com/ipfs
/go-verifcid"
blocks
"git
lab.dms3.io/dms3
/go-block-format"
cid
"git
lab.dms3.io/dms3
/go-cid"
blockstore
"git
lab.dms3.io/dms3/go-dms3
-blockstore"
exchange
"git
lab.dms3.io/dms3/go-dms3
-exchange-interface"
logging
"git
lab.dms3.io/dms3
/go-log"
"git
lab.dms3.io/dms3
/go-verifcid"
)
var
log
=
logging
.
Logger
(
"blockservice"
)
...
...
@@ -147,7 +147,7 @@ func (s *blockService) AddBlock(o blocks.Block) error {
return
err
}
log
.
Event
(
context
.
TODO
(),
"BlockService.BlockAdded"
,
c
)
log
.
Debugf
(
"BlockService.BlockAdded
%s
"
,
c
)
if
s
.
exchange
!=
nil
{
if
err
:=
s
.
exchange
.
HasBlock
(
o
);
err
!=
nil
{
...
...
@@ -193,7 +193,7 @@ func (s *blockService) AddBlocks(bs []blocks.Block) error {
if
s
.
exchange
!=
nil
{
for
_
,
o
:=
range
toput
{
log
.
Event
(
context
.
TODO
(),
"BlockService.BlockAdded"
,
o
.
Cid
())
log
.
Debugf
(
"BlockService.BlockAdded
%s
"
,
o
.
Cid
())
if
err
:=
s
.
exchange
.
HasBlock
(
o
);
err
!=
nil
{
log
.
Errorf
(
"HasBlock: %s"
,
err
.
Error
())
}
...
...
@@ -243,7 +243,7 @@ func getBlock(ctx context.Context, c cid.Cid, bs blockstore.Blockstore, fget fun
}
return
nil
,
err
}
log
.
Event
(
ctx
,
"BlockService.BlockFetched"
,
c
)
log
.
Debugf
(
"BlockService.BlockFetched
%s
"
,
c
)
return
blk
,
nil
}
...
...
@@ -320,7 +320,7 @@ func getBlocks(ctx context.Context, ks []cid.Cid, bs blockstore.Blockstore, fget
}
for
b
:=
range
rblocks
{
log
.
Event
(
ctx
,
"BlockService.BlockFetched"
,
b
.
Cid
())
log
.
Debugf
(
"BlockService.BlockFetched
%s
"
,
b
.
Cid
())
select
{
case
out
<-
b
:
case
<-
ctx
.
Done
()
:
...
...
@@ -335,7 +335,7 @@ func getBlocks(ctx context.Context, ks []cid.Cid, bs blockstore.Blockstore, fget
func
(
s
*
blockService
)
DeleteBlock
(
c
cid
.
Cid
)
error
{
err
:=
s
.
blockstore
.
DeleteBlock
(
c
)
if
err
==
nil
{
log
.
Event
(
context
.
TODO
(),
"BlockService.BlockDeleted"
,
c
)
log
.
Debugf
(
"BlockService.BlockDeleted
%s
"
,
c
)
}
return
err
}
...
...
blockservice_test.go
View file @
f4bab574
...
...
@@ -4,13 +4,13 @@ import (
"context"
"testing"
blocks
"git
hub.com/ipfs
/go-block-format"
ds
"git
hub.com/ipfs
/go-datastore"
dssync
"git
hub.com/ipfs
/go-datastore/sync"
blockstore
"git
hub.com/ipfs/go-ipfs
-blockstore"
butil
"git
hub.com/ipfs/go-ipfs
-blocksutil"
exchange
"git
hub.com/ipfs/go-ipfs
-exchange-interface"
offline
"git
hub.com/ipfs/go-ipfs
-exchange-offline"
blocks
"git
lab.dms3.io/dms3
/go-block-format"
ds
"git
lab.dms3.io/dms3
/go-datastore"
dssync
"git
lab.dms3.io/dms3
/go-datastore/sync"
blockstore
"git
lab.dms3.io/dms3/go-dms3
-blockstore"
butil
"git
lab.dms3.io/dms3/go-dms3
-blocksutil"
exchange
"git
lab.dms3.io/dms3/go-dms3
-exchange-interface"
offline
"git
lab.dms3.io/dms3/go-dms3
-exchange-offline"
)
func
TestWriteThroughWorks
(
t
*
testing
.
T
)
{
...
...
go.mod
View file @
f4bab574
module
git
hub.com/ipfs
/go-blockservice
module
git
lab.dms3.io/dms3
/go-blockservice
go 1.1
3
go 1.1
5
require (
git
hub.com/ipfs
/go-bitswap
v0.
1.8
git
hub.com/ipfs
/go-block-format
v0.0.
2
git
hub.com/ipfs
/go-cid
v0.0.
5
git
hub.com/ipfs
/go-datastore
v0.
4.4
git
hub.com/ipfs/go-ipfs
-blockstore
v0.
1.4
git
hub.com/ipfs/go-ipfs
-blocksutil
v0.0.
1
git
hub.com/ipfs/go-ipfs
-delay
v0.0.
1
git
hub.com/ipfs/go-ipfs
-exchange-interface
v0.0.
1
git
hub.com/ipfs/go-ipfs
-exchange-offline
v0.0.
1
git
hub.com/ipfs/go-ipfs
-routing
v0.
1.0
git
hub.com/ipfs/go-ipfs
-util
v0.0.
1
git
hub.com/ipfs
/go-log
v0.0.
1
git
hub.com/ipfs
/go-verifcid
v0.0.
1
git
lab.dms3.io/dms3
/go-bitswap
v0.
0.1
git
lab.dms3.io/dms3
/go-block-format
v0.0.
3
git
lab.dms3.io/dms3
/go-cid
v0.0.
3
git
lab.dms3.io/dms3
/go-datastore
v0.
0.2
git
lab.dms3.io/dms3/go-dms3
-blockstore
v0.
0.2
git
lab.dms3.io/dms3/go-dms3
-blocksutil
v0.0.
2
git
lab.dms3.io/dms3/go-dms3
-delay
v0.0.
2
git
lab.dms3.io/dms3/go-dms3
-exchange-interface
v0.0.
2
git
lab.dms3.io/dms3/go-dms3
-exchange-offline
v0.0.
2
git
lab.dms3.io/dms3/go-dms3
-routing
v0.
0.2
git
lab.dms3.io/dms3/go-dms3
-util
v0.0.
2
git
lab.dms3.io/dms3
/go-log
v0.0.
2
git
lab.dms3.io/dms3
/go-verifcid
v0.0.
2
)
go.sum
View file @
f4bab574
This diff is collapsed.
Click to expand it.
test/blocks_test.go
View file @
f4bab574
...
...
@@ -7,15 +7,15 @@ import (
"testing"
"time"
.
"git
hub.com/ipfs
/go-blockservice"
.
"git
lab.dms3.io/dms3
/go-blockservice"
blocks
"git
hub.com/ipfs
/go-block-format"
cid
"git
hub.com/ipfs
/go-cid"
ds
"git
hub.com/ipfs
/go-datastore"
dssync
"git
hub.com/ipfs
/go-datastore/sync"
blockstore
"git
hub.com/ipfs/go-ipfs
-blockstore"
offline
"git
hub.com/ipfs/go-ipfs
-exchange-offline"
u
"git
hub.com/ipfs/go-ipfs
-util"
blocks
"git
lab.dms3.io/dms3
/go-block-format"
cid
"git
lab.dms3.io/dms3
/go-cid"
ds
"git
lab.dms3.io/dms3
/go-datastore"
dssync
"git
lab.dms3.io/dms3
/go-datastore/sync"
blockstore
"git
lab.dms3.io/dms3/go-dms3
-blockstore"
offline
"git
lab.dms3.io/dms3/go-dms3
-exchange-offline"
u
"git
lab.dms3.io/dms3/go-dms3
-util"
)
func
newObject
(
data
[]
byte
)
blocks
.
Block
{
...
...
test/mock.go
View file @
f4bab574
package
bstest
import
(
.
"git
hub.com/ipfs
/go-blockservice"
.
"git
lab.dms3.io/dms3
/go-blockservice"
testinstance
"git
hub.com/ipfs
/go-bitswap/testinstance"
tn
"git
hub.com/ipfs
/go-bitswap/testnet"
delay
"git
hub.com/ipfs/go-ipfs
-delay"
mockrouting
"git
hub.com/ipfs/go-ipfs
-routing/mock"
testinstance
"git
lab.dms3.io/dms3
/go-bitswap/testinstance"
tn
"git
lab.dms3.io/dms3
/go-bitswap/testnet"
delay
"git
lab.dms3.io/dms3/go-dms3
-delay"
mockrouting
"git
lab.dms3.io/dms3/go-dms3
-routing/mock"
)
// Mocks returns |n| connected mock Blockservices
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment