readOnlyState is a helper function to safely wrap TimeMachine access
(height uint64, callback func(s *fsm.StateMachine) lib.ErrorI)
| 283 | |
| 284 | // readOnlyState is a helper function to safely wrap TimeMachine access |
| 285 | func (s *Server) readOnlyState(height uint64, callback func(s *fsm.StateMachine) lib.ErrorI) lib.ErrorI { |
| 286 | // Create a new TimeMachine at specified height |
| 287 | state, err := s.controller.FSM.TimeMachine(height) |
| 288 | if err != nil { |
| 289 | return lib.ErrTimeMachine(err) |
| 290 | } |
| 291 | // Discard state, ensuring proper cleanup is performed |
| 292 | defer state.Discard() |
| 293 | // Execute the provided callback function with the read-only state |
| 294 | err = callback(state) |
| 295 | if err != nil { |
| 296 | return err |
| 297 | } |
| 298 | return nil |
| 299 | } |
| 300 | |
| 301 | // logsHandler writes the Canopy logfile |
| 302 | func logsHandler(s *Server) httprouter.Handle { |
no test coverage detected