Close closes the LevelDB database of the stack.
()
| 261 | |
| 262 | // Close closes the LevelDB database of the stack. |
| 263 | func (s *Stack) Close() error { |
| 264 | s.Lock() |
| 265 | defer s.Unlock() |
| 266 | |
| 267 | // Check if stack is already closed. |
| 268 | if !s.isOpen { |
| 269 | return nil |
| 270 | } |
| 271 | |
| 272 | // Close the LevelDB database. |
| 273 | if err := s.db.Close(); err != nil { |
| 274 | return err |
| 275 | } |
| 276 | |
| 277 | // Reset stack head and tail and set |
| 278 | // isOpen to false. |
| 279 | s.head = 0 |
| 280 | s.tail = 0 |
| 281 | s.isOpen = false |
| 282 | |
| 283 | return nil |
| 284 | } |
| 285 | |
| 286 | // Drop closes and deletes the LevelDB database of the stack. |
| 287 | func (s *Stack) Drop() error { |
no outgoing calls