Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
whqwjb
go-ethereum
提交
6dd27e7c
G
go-ethereum
项目概览
whqwjb
/
go-ethereum
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
go-ethereum
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
6dd27e7c
编写于
2月 09, 2017
作者:
M
Maksim
提交者:
Felix Lange
2月 08, 2017
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
swarm/storage: release chunk storage after stop swarm (#3651)
closes #3650
上级
fa999861
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
36 addition
and
9 deletion
+36
-9
swarm/storage/dbstore.go
swarm/storage/dbstore.go
+1
-1
swarm/storage/dbstore_test.go
swarm/storage/dbstore_test.go
+3
-3
swarm/storage/dpa.go
swarm/storage/dpa.go
+5
-0
swarm/storage/localstore.go
swarm/storage/localstore.go
+5
-0
swarm/storage/memstore.go
swarm/storage/memstore.go
+5
-0
swarm/storage/netstore.go
swarm/storage/netstore.go
+5
-0
swarm/storage/types.go
swarm/storage/types.go
+1
-0
swarm/swarm.go
swarm/swarm.go
+11
-5
未找到文件。
swarm/storage/dbstore.go
浏览文件 @
6dd27e7c
...
@@ -408,7 +408,7 @@ func (s *DbStore) getEntryCnt() uint64 {
...
@@ -408,7 +408,7 @@ func (s *DbStore) getEntryCnt() uint64 {
return
s
.
entryCnt
return
s
.
entryCnt
}
}
func
(
s
*
DbStore
)
c
lose
()
{
func
(
s
*
DbStore
)
C
lose
()
{
s
.
db
.
Close
()
s
.
db
.
Close
()
}
}
...
...
swarm/storage/dbstore_test.go
浏览文件 @
6dd27e7c
...
@@ -38,7 +38,7 @@ func initDbStore(t *testing.T) *DbStore {
...
@@ -38,7 +38,7 @@ func initDbStore(t *testing.T) *DbStore {
func
testDbStore
(
l
int64
,
branches
int64
,
t
*
testing
.
T
)
{
func
testDbStore
(
l
int64
,
branches
int64
,
t
*
testing
.
T
)
{
m
:=
initDbStore
(
t
)
m
:=
initDbStore
(
t
)
defer
m
.
c
lose
()
defer
m
.
C
lose
()
testStore
(
m
,
l
,
branches
,
t
)
testStore
(
m
,
l
,
branches
,
t
)
}
}
...
@@ -64,7 +64,7 @@ func TestDbStore2_100_(t *testing.T) {
...
@@ -64,7 +64,7 @@ func TestDbStore2_100_(t *testing.T) {
func
TestDbStoreNotFound
(
t
*
testing
.
T
)
{
func
TestDbStoreNotFound
(
t
*
testing
.
T
)
{
m
:=
initDbStore
(
t
)
m
:=
initDbStore
(
t
)
defer
m
.
c
lose
()
defer
m
.
C
lose
()
_
,
err
:=
m
.
Get
(
ZeroKey
)
_
,
err
:=
m
.
Get
(
ZeroKey
)
if
err
!=
notFound
{
if
err
!=
notFound
{
t
.
Errorf
(
"Expected notFound, got %v"
,
err
)
t
.
Errorf
(
"Expected notFound, got %v"
,
err
)
...
@@ -73,7 +73,7 @@ func TestDbStoreNotFound(t *testing.T) {
...
@@ -73,7 +73,7 @@ func TestDbStoreNotFound(t *testing.T) {
func
TestDbStoreSyncIterator
(
t
*
testing
.
T
)
{
func
TestDbStoreSyncIterator
(
t
*
testing
.
T
)
{
m
:=
initDbStore
(
t
)
m
:=
initDbStore
(
t
)
defer
m
.
c
lose
()
defer
m
.
C
lose
()
keys
:=
[]
Key
{
keys
:=
[]
Key
{
Key
(
common
.
Hex2Bytes
(
"0000000000000000000000000000000000000000000000000000000000000000"
)),
Key
(
common
.
Hex2Bytes
(
"0000000000000000000000000000000000000000000000000000000000000000"
)),
Key
(
common
.
Hex2Bytes
(
"4000000000000000000000000000000000000000000000000000000000000000"
)),
Key
(
common
.
Hex2Bytes
(
"4000000000000000000000000000000000000000000000000000000000000000"
)),
...
...
swarm/storage/dpa.go
浏览文件 @
6dd27e7c
...
@@ -237,3 +237,8 @@ func (self *dpaChunkStore) Put(entry *Chunk) {
...
@@ -237,3 +237,8 @@ func (self *dpaChunkStore) Put(entry *Chunk) {
self
.
n
++
self
.
n
++
self
.
netStore
.
Put
(
chunk
)
self
.
netStore
.
Put
(
chunk
)
}
}
// Close chunk store
func
(
self
*
dpaChunkStore
)
Close
()
{
return
}
swarm/storage/localstore.go
浏览文件 @
6dd27e7c
...
@@ -72,3 +72,8 @@ func (self *LocalStore) Get(key Key) (chunk *Chunk, err error) {
...
@@ -72,3 +72,8 @@ func (self *LocalStore) Get(key Key) (chunk *Chunk, err error) {
self
.
memStore
.
Put
(
chunk
)
self
.
memStore
.
Put
(
chunk
)
return
return
}
}
// Close local store
func
(
self
*
LocalStore
)
Close
()
{
return
}
swarm/storage/memstore.go
浏览文件 @
6dd27e7c
...
@@ -314,3 +314,8 @@ func (s *MemStore) removeOldest() {
...
@@ -314,3 +314,8 @@ func (s *MemStore) removeOldest() {
}
}
}
}
}
}
// Close memstore
func
(
s
*
MemStore
)
Close
()
{
return
}
swarm/storage/netstore.go
浏览文件 @
6dd27e7c
...
@@ -132,3 +132,8 @@ func (self *NetStore) Get(key Key) (*Chunk, error) {
...
@@ -132,3 +132,8 @@ func (self *NetStore) Get(key Key) (*Chunk, error) {
go
self
.
cloud
.
Retrieve
(
chunk
)
go
self
.
cloud
.
Retrieve
(
chunk
)
return
chunk
,
nil
return
chunk
,
nil
}
}
// Close netstore
func
(
self
*
NetStore
)
Close
()
{
return
}
swarm/storage/types.go
浏览文件 @
6dd27e7c
...
@@ -167,6 +167,7 @@ The ChunkStore interface is implemented by :
...
@@ -167,6 +167,7 @@ The ChunkStore interface is implemented by :
type
ChunkStore
interface
{
type
ChunkStore
interface
{
Put
(
*
Chunk
)
// effectively there is no error even if there is an error
Put
(
*
Chunk
)
// effectively there is no error even if there is an error
Get
(
Key
)
(
*
Chunk
,
error
)
Get
(
Key
)
(
*
Chunk
,
error
)
Close
()
}
}
/*
/*
...
...
swarm/swarm.go
浏览文件 @
6dd27e7c
...
@@ -54,6 +54,7 @@ type Swarm struct {
...
@@ -54,6 +54,7 @@ type Swarm struct {
privateKey
*
ecdsa
.
PrivateKey
privateKey
*
ecdsa
.
PrivateKey
corsString
string
corsString
string
swapEnabled
bool
swapEnabled
bool
lstore
*
storage
.
LocalStore
// local store, needs to store for releasing resources after node stopped
}
}
type
SwarmAPI
struct
{
type
SwarmAPI
struct
{
...
@@ -90,7 +91,7 @@ func NewSwarm(ctx *node.ServiceContext, backend chequebook.Backend, config *api.
...
@@ -90,7 +91,7 @@ func NewSwarm(ctx *node.ServiceContext, backend chequebook.Backend, config *api.
glog
.
V
(
logger
.
Debug
)
.
Infof
(
"Setting up Swarm service components"
)
glog
.
V
(
logger
.
Debug
)
.
Infof
(
"Setting up Swarm service components"
)
hash
:=
storage
.
MakeHashFunc
(
config
.
ChunkerParams
.
Hash
)
hash
:=
storage
.
MakeHashFunc
(
config
.
ChunkerParams
.
Hash
)
lstore
,
err
:
=
storage
.
NewLocalStore
(
hash
,
config
.
StoreParams
)
self
.
lstore
,
err
=
storage
.
NewLocalStore
(
hash
,
config
.
StoreParams
)
if
err
!=
nil
{
if
err
!=
nil
{
return
return
}
}
...
@@ -98,7 +99,7 @@ func NewSwarm(ctx *node.ServiceContext, backend chequebook.Backend, config *api.
...
@@ -98,7 +99,7 @@ func NewSwarm(ctx *node.ServiceContext, backend chequebook.Backend, config *api.
// setup local store
// setup local store
glog
.
V
(
logger
.
Debug
)
.
Infof
(
"Set up local storage"
)
glog
.
V
(
logger
.
Debug
)
.
Infof
(
"Set up local storage"
)
self
.
dbAccess
=
network
.
NewDbAccess
(
lstore
)
self
.
dbAccess
=
network
.
NewDbAccess
(
self
.
lstore
)
glog
.
V
(
logger
.
Debug
)
.
Infof
(
"Set up local db access (iterator/counter)"
)
glog
.
V
(
logger
.
Debug
)
.
Infof
(
"Set up local db access (iterator/counter)"
)
// set up the kademlia hive
// set up the kademlia hive
...
@@ -115,15 +116,15 @@ func NewSwarm(ctx *node.ServiceContext, backend chequebook.Backend, config *api.
...
@@ -115,15 +116,15 @@ func NewSwarm(ctx *node.ServiceContext, backend chequebook.Backend, config *api.
glog
.
V
(
logger
.
Debug
)
.
Infof
(
"-> set swarm forwarder as cloud storage backend"
)
glog
.
V
(
logger
.
Debug
)
.
Infof
(
"-> set swarm forwarder as cloud storage backend"
)
// setup cloud storage internal access layer
// setup cloud storage internal access layer
self
.
storage
=
storage
.
NewNetStore
(
hash
,
lstore
,
cloud
,
config
.
StoreParams
)
self
.
storage
=
storage
.
NewNetStore
(
hash
,
self
.
lstore
,
cloud
,
config
.
StoreParams
)
glog
.
V
(
logger
.
Debug
)
.
Infof
(
"-> swarm net store shared access layer to Swarm Chunk Store"
)
glog
.
V
(
logger
.
Debug
)
.
Infof
(
"-> swarm net store shared access layer to Swarm Chunk Store"
)
// set up Depo (storage handler = cloud storage access layer for incoming remote requests)
// set up Depo (storage handler = cloud storage access layer for incoming remote requests)
self
.
depo
=
network
.
NewDepo
(
hash
,
lstore
,
self
.
storage
)
self
.
depo
=
network
.
NewDepo
(
hash
,
self
.
lstore
,
self
.
storage
)
glog
.
V
(
logger
.
Debug
)
.
Infof
(
"-> REmote Access to CHunks"
)
glog
.
V
(
logger
.
Debug
)
.
Infof
(
"-> REmote Access to CHunks"
)
// set up DPA, the cloud storage local access layer
// set up DPA, the cloud storage local access layer
dpaChunkStore
:=
storage
.
NewDpaChunkStore
(
lstore
,
self
.
storage
)
dpaChunkStore
:=
storage
.
NewDpaChunkStore
(
self
.
lstore
,
self
.
storage
)
glog
.
V
(
logger
.
Debug
)
.
Infof
(
"-> Local Access to Swarm"
)
glog
.
V
(
logger
.
Debug
)
.
Infof
(
"-> Local Access to Swarm"
)
// Swarm Hash Merklised Chunking for Arbitrary-length Document/File storage
// Swarm Hash Merklised Chunking for Arbitrary-length Document/File storage
self
.
dpa
=
storage
.
NewDPA
(
dpaChunkStore
,
self
.
config
.
ChunkerParams
)
self
.
dpa
=
storage
.
NewDPA
(
dpaChunkStore
,
self
.
config
.
ChunkerParams
)
...
@@ -212,6 +213,11 @@ func (self *Swarm) Stop() error {
...
@@ -212,6 +213,11 @@ func (self *Swarm) Stop() error {
ch
.
Stop
()
ch
.
Stop
()
ch
.
Save
()
ch
.
Save
()
}
}
if
self
.
lstore
!=
nil
{
self
.
lstore
.
DbStore
.
Close
()
}
return
self
.
config
.
Save
()
return
self
.
config
.
Save
()
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录