diff options
author | Maksim <mchusovlianov@gmail.com> | 2017-02-09 01:01:12 +0800 |
---|---|---|
committer | Felix Lange <fjl@users.noreply.github.com> | 2017-02-09 01:01:12 +0800 |
commit | 6dd27e7cff818493356ddecd8918b69fb18b998a (patch) | |
tree | f90e05a601acc2b5934e3398e3fdbd38eef3d0d6 /swarm/swarm.go | |
parent | fa99986143fe3dec08cdffcff9185e3700719edd (diff) | |
download | dexon-6dd27e7cff818493356ddecd8918b69fb18b998a.tar dexon-6dd27e7cff818493356ddecd8918b69fb18b998a.tar.gz dexon-6dd27e7cff818493356ddecd8918b69fb18b998a.tar.bz2 dexon-6dd27e7cff818493356ddecd8918b69fb18b998a.tar.lz dexon-6dd27e7cff818493356ddecd8918b69fb18b998a.tar.xz dexon-6dd27e7cff818493356ddecd8918b69fb18b998a.tar.zst dexon-6dd27e7cff818493356ddecd8918b69fb18b998a.zip |
swarm/storage: release chunk storage after stop swarm (#3651)
closes #3650
Diffstat (limited to 'swarm/swarm.go')
-rw-r--r-- | swarm/swarm.go | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/swarm/swarm.go b/swarm/swarm.go index 4b3621aff..eab01f036 100644 --- a/swarm/swarm.go +++ b/swarm/swarm.go @@ -54,6 +54,7 @@ type Swarm struct { privateKey *ecdsa.PrivateKey corsString string swapEnabled bool + lstore *storage.LocalStore // local store, needs to store for releasing resources after node stopped } type SwarmAPI struct { @@ -90,7 +91,7 @@ func NewSwarm(ctx *node.ServiceContext, backend chequebook.Backend, config *api. glog.V(logger.Debug).Infof("Setting up Swarm service components") hash := storage.MakeHashFunc(config.ChunkerParams.Hash) - lstore, err := storage.NewLocalStore(hash, config.StoreParams) + self.lstore, err = storage.NewLocalStore(hash, config.StoreParams) if err != nil { return } @@ -98,7 +99,7 @@ func NewSwarm(ctx *node.ServiceContext, backend chequebook.Backend, config *api. // setup local store 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)") // set up the kademlia hive @@ -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") // 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") // 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") // 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") // Swarm Hash Merklised Chunking for Arbitrary-length Document/File storage self.dpa = storage.NewDPA(dpaChunkStore, self.config.ChunkerParams) @@ -212,6 +213,11 @@ func (self *Swarm) Stop() error { ch.Stop() ch.Save() } + + if self.lstore != nil { + self.lstore.DbStore.Close() + } + return self.config.Save() } |