Skip to content

Commit 0cb54ec

Browse files
committed
tapdb: turn dbAssetsToChainAssets into function
We'll want to re-use that function in an upcoming commit, without needing to instantiate a full asset store.
1 parent 6155648 commit 0cb54ec

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

tapdb/assets_store.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -624,8 +624,8 @@ func parseAssetWitness(input AssetWitness) (asset.Witness, error) {
624624
// dbAssetsToChainAssets maps a set of confirmed assets in the database, and
625625
// the witnesses of those assets to a set of normal ChainAsset structs needed
626626
// by a higher level application.
627-
func (a *AssetStore) dbAssetsToChainAssets(dbAssets []ConfirmedAsset,
628-
witnesses assetWitnesses) ([]*asset.ChainAsset, error) {
627+
func dbAssetsToChainAssets(dbAssets []ConfirmedAsset, witnesses assetWitnesses,
628+
dbClock clock.Clock) ([]*asset.ChainAsset, error) {
629629

630630
chainAssets := make([]*asset.ChainAsset, len(dbAssets))
631631
for i := range dbAssets {
@@ -829,7 +829,7 @@ func (a *AssetStore) dbAssetsToChainAssets(dbAssets []ConfirmedAsset,
829829
owner := sprout.AnchorLeaseOwner
830830
expiry := sprout.AnchorLeaseExpiry
831831
if len(owner) > 0 && expiry.Valid &&
832-
expiry.Time.UTC().After(a.clock.Now().UTC()) {
832+
expiry.Time.UTC().After(dbClock.Now().UTC()) {
833833

834834
copy(chainAssets[i].AnchorLeaseOwner[:], owner)
835835
chainAssets[i].AnchorLeaseExpiry = &expiry.Time
@@ -1201,7 +1201,7 @@ func (a *AssetStore) FetchAllAssets(ctx context.Context, includeSpent,
12011201
return nil, dbErr
12021202
}
12031203

1204-
return a.dbAssetsToChainAssets(dbAssets, assetWitnesses)
1204+
return dbAssetsToChainAssets(dbAssets, assetWitnesses, a.clock)
12051205
}
12061206

12071207
// FetchManagedUTXOs fetches all UTXOs we manage.
@@ -1909,7 +1909,9 @@ func (a *AssetStore) queryChainAssets(ctx context.Context, q ActiveAssetsStore,
19091909
if err != nil {
19101910
return nil, err
19111911
}
1912-
matchingAssets, err := a.dbAssetsToChainAssets(dbAssets, assetWitnesses)
1912+
matchingAssets, err := dbAssetsToChainAssets(
1913+
dbAssets, assetWitnesses, a.clock,
1914+
)
19131915
if err != nil {
19141916
return nil, err
19151917
}

0 commit comments

Comments
 (0)