Skip to content

Commit 880678c

Browse files
committed
comments
Signed-off-by: Angelo De Caro <adc@zurich.ibm.com>
1 parent 107d258 commit 880678c

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

token/services/network/fabric/lookup/deliveryllm.go

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ package lookup
88

99
import (
1010
"context"
11+
"slices"
1112
"strings"
1213

1314
vault2 "github.com/hyperledger-labs/fabric-smart-client/platform/common/core/generic/vault"
@@ -32,16 +33,16 @@ import (
3233
type newTxInfoMapper = func(network, channel string) events.EventInfoMapper[KeyInfo]
3334

3435
type EventsListenerManager interface {
35-
AddPermanentEventListener(key string, e events.ListenerEntry[KeyInfo]) error
36-
AddEventListener(key string, e events.ListenerEntry[KeyInfo]) error
37-
RemoveEventListener(key string, e events.ListenerEntry[KeyInfo]) error
36+
AddPermanentEventListener(key driver2.PKey, e events.ListenerEntry[KeyInfo]) error
37+
AddEventListener(key driver2.PKey, e events.ListenerEntry[KeyInfo]) error
38+
RemoveEventListener(key driver2.PKey, e events.ListenerEntry[KeyInfo]) error
3839
}
3940

4041
type Listener interface {
4142
// OnStatus is called when the key has been found
42-
OnStatus(ctx context.Context, key string, value []byte)
43+
OnStatus(ctx context.Context, key driver2.PKey, value []byte)
4344
// OnError is called when an error occurs during the search of the key
44-
OnError(ctx context.Context, key string, err error)
45+
OnError(ctx context.Context, key driver2.PKey, err error)
4546
}
4647

4748
type listenerEntry struct {
@@ -101,9 +102,8 @@ func newEndorserDeliveryBasedLLMProvider(fnsp *fabric.NetworkServiceProvider, tr
101102
}
102103
return NewDeliveryBasedLLMProvider(fnsp, tracerProvider, config, func(network, _ string) events.EventInfoMapper[KeyInfo] {
103104
return &endorserTxInfoMapper{
104-
network: network,
105-
prefix1: prefix,
106-
prefix2: setupKey,
105+
network: network,
106+
prefixes: []string{prefix, setupKey},
107107
}
108108
})
109109
}
@@ -156,9 +156,8 @@ func (m *deliveryBasedLLM) RemoveLookupListener(key string, listener Listener) e
156156
}
157157

158158
type endorserTxInfoMapper struct {
159-
network string
160-
prefix1 string
161-
prefix2 string
159+
network string
160+
prefixes []string
162161
}
163162

164163
func (m *endorserTxInfoMapper) MapTxData(ctx context.Context, tx []byte, block *common.BlockMetadata, blockNum driver2.BlockNum, txNum driver2.TxNum) (map[driver2.Namespace]KeyInfo, error) {
@@ -204,7 +203,7 @@ func (m *endorserTxInfoMapper) mapTxInfo(rwSet vault2.ReadWriteSet, txID string)
204203
for ns, writes := range rwSet.WriteSet.Writes {
205204
logger.Debugf("TX [%s:%s] has [%d] writes", txID, ns, len(writes))
206205
for key, value := range writes {
207-
if strings.HasPrefix(key, m.prefix1) || strings.HasPrefix(key, m.prefix2) {
206+
if slices.ContainsFunc(m.prefixes, func(prefix string) bool { return strings.HasPrefix(key, prefix) }) {
208207
logger.Debugf("TX [%s:%s] does have key [%s].", txID, ns, key)
209208
txInfos[ns] = KeyInfo{
210209
Namespace: ns,

0 commit comments

Comments
 (0)