@@ -82,8 +82,8 @@ type QueryParams struct {
8282// known to universe servers in our federation.
8383type AssetSyncer interface {
8484 // SyncAssetInfo queries the universes in our federation for genesis
85- // and asset group information about the given asset ID .
86- SyncAssetInfo (ctx context.Context , assetID * asset.ID ) error
85+ // and asset group information about the given asset.
86+ SyncAssetInfo (ctx context.Context , specifier asset.Specifier ) error
8787
8888 // EnableAssetSync updates the sync config for the given asset so that
8989 // we sync future issuance proofs.
@@ -232,7 +232,7 @@ func (b *Book) QueryAssetInfo(ctx context.Context,
232232 log .Debugf ("Asset %v is unknown, attempting to bootstrap" , id .String ())
233233
234234 // Use the AssetSyncer to query our universe federation for the asset.
235- err = b .cfg .Syncer .SyncAssetInfo (ctx , & id )
235+ err = b .cfg .Syncer .SyncAssetInfo (ctx , asset . NewSpecifierFromId ( id ) )
236236 if err != nil {
237237 return nil , err
238238 }
@@ -264,6 +264,27 @@ func (b *Book) QueryAssetInfo(ctx context.Context,
264264 return assetGroup , nil
265265}
266266
267+ // SyncAssetGroup attempts to enable asset sync for the given asset group, then
268+ // perform an initial sync with the federation for that group.
269+ func (b * Book ) SyncAssetGroup (ctx context.Context ,
270+ groupKey btcec.PublicKey ) error {
271+
272+ groupInfo := & asset.AssetGroup {
273+ GroupKey : & asset.GroupKey {
274+ GroupPubKey : groupKey ,
275+ },
276+ }
277+ err := b .cfg .Syncer .EnableAssetSync (ctx , groupInfo )
278+ if err != nil {
279+ return fmt .Errorf ("unable to enable asset sync: %w" , err )
280+ }
281+
282+ // Use the AssetSyncer to query our universe federation for the asset.
283+ return b .cfg .Syncer .SyncAssetInfo (
284+ ctx , asset .NewSpecifierFromGroupKey (groupKey ),
285+ )
286+ }
287+
267288// FetchAssetMetaByHash attempts to fetch an asset meta based on an asset hash.
268289func (b * Book ) FetchAssetMetaByHash (ctx context.Context ,
269290 metaHash [asset .MetaHashLen ]byte ) (* proof.MetaReveal , error ) {
@@ -296,7 +317,7 @@ func (b *Book) FetchAssetMetaForAsset(ctx context.Context,
296317 assetID .String ())
297318
298319 // Use the AssetSyncer to query our universe federation for the asset.
299- err = b .cfg .Syncer .SyncAssetInfo (ctx , & assetID )
320+ err = b .cfg .Syncer .SyncAssetInfo (ctx , asset . NewSpecifierFromId ( assetID ) )
300321 if err != nil {
301322 return nil , err
302323 }
0 commit comments