From 9dd3f463f5a09683d4137423512b86012b12021e Mon Sep 17 00:00:00 2001 From: ffranr Date: Tue, 3 Oct 2023 12:50:02 +0100 Subject: [PATCH] rpc: export function unmarshall universe ID --- rpcserver.go | 21 ++++++++++----------- universe_rpc_diff.go | 4 ++-- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/rpcserver.go b/rpcserver.go index 142124f5e..466d1a248 100644 --- a/rpcserver.go +++ b/rpcserver.go @@ -2669,7 +2669,7 @@ func unmarshalAssetSyncConfig( error) { // Parse the universe ID from the RPC form. - uniID, err := unmarshalUniID(config.Id) + uniID, err := UnmarshalUniID(config.Id) if err != nil { return nil, fmt.Errorf("unable to parse universe id: %w", err) @@ -2682,15 +2682,14 @@ func unmarshalAssetSyncConfig( }, nil } -// unmarshalUniID parses the RPC universe ID into the native counterpart. -func unmarshalUniID(rpcID *unirpc.ID) (universe.Identifier, error) { +// UnmarshalUniID parses the RPC universe ID into the native counterpart. +func UnmarshalUniID(rpcID *unirpc.ID) (universe.Identifier, error) { // Unmarshal the proof type. proofType, err := UnmarshalUniProofType(rpcID.ProofType) if err != nil { return universe.Identifier{}, fmt.Errorf("unable to unmarshal "+ "proof type: %w", err) } - switch { case rpcID.GetAssetId() != nil: var assetID asset.ID @@ -2756,7 +2755,7 @@ func unmarshalUniID(rpcID *unirpc.ID) (universe.Identifier, error) { func (r *rpcServer) QueryAssetRoots(ctx context.Context, req *unirpc.AssetRootQuery) (*unirpc.QueryRootResponse, error) { - universeID, err := unmarshalUniID(req.Id) + universeID, err := UnmarshalUniID(req.Id) if err != nil { return nil, err } @@ -2814,7 +2813,7 @@ func (r *rpcServer) QueryAssetRoots(ctx context.Context, func (r *rpcServer) DeleteAssetRoot(ctx context.Context, req *unirpc.DeleteRootQuery) (*unirpc.DeleteRootResponse, error) { - universeID, err := unmarshalUniID(req.Id) + universeID, err := UnmarshalUniID(req.Id) if err != nil { return nil, err } @@ -2870,7 +2869,7 @@ func marshalLeafKey(leafKey universe.LeafKey) *unirpc.AssetKey { func (r *rpcServer) AssetLeafKeys(ctx context.Context, req *unirpc.ID) (*unirpc.AssetLeafKeyResponse, error) { - universeID, err := unmarshalUniID(req) + universeID, err := UnmarshalUniID(req) if err != nil { return nil, err } @@ -2932,7 +2931,7 @@ func (r *rpcServer) marshalAssetLeaf(ctx context.Context, func (r *rpcServer) AssetLeaves(ctx context.Context, req *unirpc.ID) (*unirpc.AssetLeafResponse, error) { - universeID, err := unmarshalUniID(req) + universeID, err := UnmarshalUniID(req) if err != nil { return nil, err } @@ -3121,7 +3120,7 @@ func (r *rpcServer) marshalIssuanceProof(ctx context.Context, func (r *rpcServer) QueryProof(ctx context.Context, req *unirpc.UniverseKey) (*unirpc.AssetProofResponse, error) { - universeID, err := unmarshalUniID(req.Id) + universeID, err := UnmarshalUniID(req.Id) if err != nil { return nil, err } @@ -3225,7 +3224,7 @@ func (r *rpcServer) InsertProof(ctx context.Context, return nil, fmt.Errorf("key cannot be nil") } - universeID, err := unmarshalUniID(req.Key.Id) + universeID, err := UnmarshalUniID(req.Key.Id) if err != nil { return nil, err } @@ -3311,7 +3310,7 @@ func unmarshalUniverseSyncType(req unirpc.UniverseSyncMode) ( func unmarshalSyncTargets(targets []*unirpc.SyncTarget) ([]universe.Identifier, error) { uniIDs := make([]universe.Identifier, 0, len(targets)) for _, target := range targets { - uniID, err := unmarshalUniID(target.Id) + uniID, err := UnmarshalUniID(target.Id) if err != nil { return nil, err } diff --git a/universe_rpc_diff.go b/universe_rpc_diff.go index 7a657c378..04301a5b0 100644 --- a/universe_rpc_diff.go +++ b/universe_rpc_diff.go @@ -44,7 +44,7 @@ func unmarshalMerkleSumNode(root *unirpc.MerkleSumNode) mssmt.Node { func unmarshalUniverseRoot( root *unirpc.UniverseRoot) (universe.BaseRoot, error) { - id, err := unmarshalUniID(root.Id) + id, err := UnmarshalUniID(root.Id) if err != nil { return universe.BaseRoot{}, err } @@ -60,7 +60,7 @@ func unmarshalUniverseRoots( baseRoots := make([]universe.BaseRoot, 0, len(roots)) for _, root := range roots { - id, err := unmarshalUniID(root.Id) + id, err := UnmarshalUniID(root.Id) if err != nil { return nil, err }