MCPcopy
hub / github.com/canopy-network/canopy / readOnlyState

Method readOnlyState

cmd/rpc/server.go:285–299  ·  view source on GitHub ↗

readOnlyState is a helper function to safely wrap TimeMachine access

(height uint64, callback func(s *fsm.StateMachine) lib.ErrorI)

Source from the content-addressed store, hash-verified

283
284// readOnlyState is a helper function to safely wrap TimeMachine access
285func (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
302func logsHandler(s *Server) httprouter.Handle {

Callers 10

HeightMethod · 0.95
EcoParametersMethod · 0.95
StateMethod · 0.95
updatePollResultsMethod · 0.95
getFeeFromStateMethod · 0.95
EthBlockNumberMethod · 0.95
EthGetBalanceMethod · 0.95
EthCallMethod · 0.95
TransactionCloseOrderMethod · 0.95

Calls 3

ErrTimeMachineFunction · 0.92
TimeMachineMethod · 0.80
DiscardMethod · 0.65

Tested by

no test coverage detected