Skip to content

Commit

Permalink
Closed some opened db leaks
Browse files Browse the repository at this point in the history
  • Loading branch information
ivoras committed Feb 2, 2019
1 parent 8565c1d commit 925c39b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
10 changes: 10 additions & 0 deletions blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,14 @@ func blockchainVerifyEverything() error {
}
blockKeyOps, err := b.dbGetKeyOps()
if err != nil {
if err := b.Close(); err != nil {
panic(err)
}
return fmt.Errorf("block %d: cannot get key ops: %v", height, err)
}
if err = b.Close(); err != nil {
panic(err)
}
Q := QuorumForHeight(height)
for keyOpKeyHash, keyOps := range blockKeyOps {
if len(keyOps) != Q {
Expand Down Expand Up @@ -431,6 +437,10 @@ func OpenBlockFile(fileName string) (*Block, error) {
return &b, nil
}

func (b *Block) Close() error {
return b.db.Close()
}

// Returns an integer value from the _meta table within the block
func (b *Block) dbGetMetaInt(key string) (int, error) {
var value string
Expand Down
1 change: 1 addition & 0 deletions p2p.go
Original file line number Diff line number Diff line change
Expand Up @@ -737,6 +737,7 @@ func (p2pc *p2pConnection) handleBlock(msg StrIfMap) {
return
}
log.Println("Accepted block", blk.Hash, "at height", blk.Height)
blk.Close()
}

// Connect to a peer. Does everything except starting the handler goroutine.
Expand Down

0 comments on commit 925c39b

Please sign in to comment.