Skip to content

Commit 5eea50d

Browse files
authored
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
1 parent f90a4b9 commit 5eea50d

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

protocol/localstatequery/localstatequery.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020

2121
"github.com/blinklabs-io/gouroboros/connection"
2222
"github.com/blinklabs-io/gouroboros/protocol"
23+
"github.com/blinklabs-io/gouroboros/protocol/common"
2324
)
2425

2526
// Protocol identifiers
@@ -128,11 +129,10 @@ type CallbackContext struct {
128129
}
129130

130131
// Callback function types
131-
// TODO: update callbacks
132-
type AcquireFunc func(CallbackContext, interface{}) error
133-
type QueryFunc func(CallbackContext, interface{}) error
132+
type AcquireFunc func(CallbackContext, *common.Point) error
133+
type QueryFunc func(CallbackContext, any) error
134134
type ReleaseFunc func(CallbackContext) error
135-
type ReAcquireFunc func(CallbackContext, interface{}) error
135+
type ReAcquireFunc func(CallbackContext, *common.Point) error
136136
type DoneFunc func(CallbackContext) error
137137

138138
// New returns a new LocalStateQuery object

protocol/localstatequery/server.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ func (s *Server) handleAcquire(msg protocol.Message) error {
9999
switch msgAcquire := msg.(type) {
100100
case *MsgAcquire:
101101
// Call the user callback function
102-
return s.config.AcquireFunc(s.callbackContext, msgAcquire.Point)
102+
return s.config.AcquireFunc(s.callbackContext, &msgAcquire.Point)
103103
case *MsgAcquireNoPoint:
104104
// Call the user callback function
105105
return s.config.AcquireFunc(s.callbackContext, nil)
@@ -137,7 +137,7 @@ func (s *Server) handleReAcquire(msg protocol.Message) error {
137137
switch msgReAcquire := msg.(type) {
138138
case *MsgReAcquire:
139139
// Call the user callback function
140-
return s.config.ReAcquireFunc(s.callbackContext, msgReAcquire.Point)
140+
return s.config.ReAcquireFunc(s.callbackContext, &msgReAcquire.Point)
141141
case *MsgReAcquireNoPoint:
142142
// Call the user callback function
143143
return s.config.ReAcquireFunc(s.callbackContext, nil)

0 commit comments

Comments
 (0)