From 5eea50dcab8687269b5c3b46a82d7514a99ee67d Mon Sep 17 00:00:00 2001 From: Aurora Gaffney Date: Wed, 12 Jun 2024 15:45:48 -0500 Subject: [PATCH] feat: update local-state-query callback definitions (#656) This updates the callback function definitions for the server side of LocalStateQuery to use more specific types where possible Fixes #353 --- protocol/localstatequery/localstatequery.go | 8 ++++---- protocol/localstatequery/server.go | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/protocol/localstatequery/localstatequery.go b/protocol/localstatequery/localstatequery.go index 5c584413..3544c3d3 100644 --- a/protocol/localstatequery/localstatequery.go +++ b/protocol/localstatequery/localstatequery.go @@ -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 @@ -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 diff --git a/protocol/localstatequery/server.go b/protocol/localstatequery/server.go index a555b1d3..23c0ea05 100644 --- a/protocol/localstatequery/server.go +++ b/protocol/localstatequery/server.go @@ -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) @@ -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)