Skip to content

Commit

Permalink
feat: update local-state-query callback definitions (#656)
Browse files Browse the repository at this point in the history
This updates the callback function definitions for the server side of
LocalStateQuery to use more specific types where possible

Fixes #353
  • Loading branch information
agaffney authored Jun 12, 2024
1 parent f90a4b9 commit 5eea50d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions protocol/localstatequery/localstatequery.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (

"github.com/blinklabs-io/gouroboros/connection"
"github.com/blinklabs-io/gouroboros/protocol"
"github.com/blinklabs-io/gouroboros/protocol/common"
)

// Protocol identifiers
Expand Down Expand Up @@ -128,11 +129,10 @@ type CallbackContext struct {
}

// Callback function types
// TODO: update callbacks
type AcquireFunc func(CallbackContext, interface{}) error
type QueryFunc func(CallbackContext, interface{}) error
type AcquireFunc func(CallbackContext, *common.Point) error
type QueryFunc func(CallbackContext, any) error
type ReleaseFunc func(CallbackContext) error
type ReAcquireFunc func(CallbackContext, interface{}) error
type ReAcquireFunc func(CallbackContext, *common.Point) error
type DoneFunc func(CallbackContext) error

// New returns a new LocalStateQuery object
Expand Down
4 changes: 2 additions & 2 deletions protocol/localstatequery/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func (s *Server) handleAcquire(msg protocol.Message) error {
switch msgAcquire := msg.(type) {
case *MsgAcquire:
// Call the user callback function
return s.config.AcquireFunc(s.callbackContext, msgAcquire.Point)
return s.config.AcquireFunc(s.callbackContext, &msgAcquire.Point)
case *MsgAcquireNoPoint:
// Call the user callback function
return s.config.AcquireFunc(s.callbackContext, nil)
Expand Down Expand Up @@ -137,7 +137,7 @@ func (s *Server) handleReAcquire(msg protocol.Message) error {
switch msgReAcquire := msg.(type) {
case *MsgReAcquire:
// Call the user callback function
return s.config.ReAcquireFunc(s.callbackContext, msgReAcquire.Point)
return s.config.ReAcquireFunc(s.callbackContext, &msgReAcquire.Point)
case *MsgReAcquireNoPoint:
// Call the user callback function
return s.config.ReAcquireFunc(s.callbackContext, nil)
Expand Down

0 comments on commit 5eea50d

Please sign in to comment.