Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use interface for ScanForPreImage so it can be called outside of a view #610

Merged
merged 1 commit into from
Apr 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions token/services/interop/htlc/scanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"encoding/base64"
"time"

"github.com/hyperledger-labs/fabric-smart-client/platform/view/view"
"github.com/hyperledger-labs/fabric-token-sdk/token"
"github.com/hyperledger-labs/fabric-token-sdk/token/services/interop/encoding"
"github.com/hyperledger-labs/fabric-token-sdk/token/services/network"
Expand All @@ -35,7 +34,7 @@ func WithStartingTransaction(txID string) token.ServiceOption {
}

// ScanForPreImage scans the ledger for a preimage of the passed image, taking into account the timeout
func ScanForPreImage(ctx view.Context, image []byte, hashFunc crypto.Hash, hashEncoding encoding.Encoding, timeout time.Duration, opts ...token.ServiceOption) ([]byte, error) {
func ScanForPreImage(sp token.ServiceProvider, image []byte, hashFunc crypto.Hash, hashEncoding encoding.Encoding, timeout time.Duration, opts ...token.ServiceOption) ([]byte, error) {
logger.Debugf("scanning for preimage of [%s] with timeout [%s]", base64.StdEncoding.EncodeToString(image), timeout)

if !hashFunc.Available() {
Expand All @@ -49,9 +48,9 @@ func ScanForPreImage(ctx view.Context, image []byte, hashFunc crypto.Hash, hashE
if err != nil {
return nil, err
}
tms := token.GetManagementService(ctx, opts...)
tms := token.GetManagementService(sp, opts...)

network := network.GetInstance(ctx, tms.Network(), tms.Channel())
network := network.GetInstance(sp, tms.Network(), tms.Channel())
if network == nil {
return nil, errors.Errorf("cannot find network [%s:%s]", tms.Namespace(), tms.Channel())
}
Expand Down
Loading