Skip to content

Commit

Permalink
multi: fix conversions + unneeded lambdas
Browse files Browse the repository at this point in the history
  • Loading branch information
jharveyb committed Mar 4, 2024
1 parent 3f3dcab commit 8d99137
Show file tree
Hide file tree
Showing 15 changed files with 24 additions and 32 deletions.
6 changes: 1 addition & 5 deletions asset/asset.go
Original file line number Diff line number Diff line change
Expand Up @@ -778,11 +778,7 @@ func (g *GroupKey) IsEqual(otherGroupKey *GroupKey) bool {
return false
}

return slices.EqualFunc(
g.Witness, otherGroupKey.Witness, func(a, b []byte) bool {
return bytes.Equal(a, b)
},
)
return slices.EqualFunc(g.Witness, otherGroupKey.Witness, bytes.Equal)
}

// IsEqualGroup returns true if this group key describes the same asset group
Expand Down
2 changes: 1 addition & 1 deletion cmd/tapcli/addrs.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ func queryAddr(ctx *cli.Context) error {

addrs, err := client.QueryAddrs(ctxc, &taprpc.QueryAddrRequest{
CreatedAfter: start,
CreatedBefore: int64(end),
CreatedBefore: end,
Limit: int32(ctx.Int64(limitName)),
Offset: int32(ctx.Int64(offsetName)),
})
Expand Down
2 changes: 1 addition & 1 deletion commitment/taproot.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ func (t *TapscriptPreimage) IsEmpty() bool {

// Type returns the preimage type.
func (t *TapscriptPreimage) Type() TapscriptPreimageType {
return TapscriptPreimageType(t.siblingType)
return t.siblingType
}

// TapHash returns the tap hash of this preimage according to its type.
Expand Down
2 changes: 1 addition & 1 deletion itest/mint_batch_stress_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func mintBatchStressTest(

// Update the asset name and metadata to match an index.
incrementMintAsset := func(asset *mintrpc.MintAsset, ind int) {
asset.Name = asset.Name + strconv.Itoa(ind)
asset.Name += strconv.Itoa(ind)
binary.PutUvarint(metadataPrefix, uint64(ind))
copy(asset.AssetMeta.Data[0:metaPrefixSize], metadataPrefix)
}
Expand Down
2 changes: 1 addition & 1 deletion itest/psbt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,7 @@ func runPsbtInteractiveSplitSendTest(ctxt context.Context, t *harnessTest,
// Swap the sender and receiver nodes starting at the second
// iteration.
if i > 0 {
sendAmt = sendAmt / 2
sendAmt /= 2
changeAmt = sendAmt
sender, receiver = receiver, sender
senderSum, receiverSum = receiverSum, senderSum
Expand Down
2 changes: 1 addition & 1 deletion itest/universe_pagination_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func mintBatchAssetsTest(

// Update the asset name and metadata to match an index.
incrementMintAsset := func(asset *mintrpc.MintAsset, ind int) {
asset.Name = asset.Name + strconv.Itoa(ind)
asset.Name += strconv.Itoa(ind)
binary.PutUvarint(metadataPrefix, uint64(ind))
copy(asset.AssetMeta.Data[0:metaPrefixSize], metadataPrefix)
}
Expand Down
2 changes: 1 addition & 1 deletion proof/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func NewTxMerkleProof(txs []*wire.MsgTx, txIdx int) (*TxMerkleProof, error) {

// Update the currentIdx to reflect the next level in the tree.
// We divide by 2 since we always hash in pairs.
currentIdx = currentIdx / 2
currentIdx /= 2

// We've arrived at the root so our proof is complete.
if len(hashes) == 1 {
Expand Down
2 changes: 1 addition & 1 deletion rpcserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -817,7 +817,7 @@ func (r *rpcServer) listBalancesByAsset(ctx context.Context,

resp.AssetBalances[assetIDStr] = &taprpc.AssetBalance{
AssetGenesis: &taprpc.GenesisInfo{
Version: int32(balance.Version),
Version: balance.Version,
GenesisPoint: balance.GenesisPoint.String(),
AssetType: taprpc.AssetType(balance.Type),
Name: balance.Tag,
Expand Down
2 changes: 1 addition & 1 deletion tapdb/addrs.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ func (t *TapAddressBook) InsertAddrs(ctx context.Context,
&addr.TaprootOutputKey,
),
Amount: int64(addr.Amount),
AssetType: int16(assetGen.AssetType),
AssetType: assetGen.AssetType,
CreationTime: addr.CreationTime.UTC(),
ProofCourierAddr: proofCourierAddrBytes,
})
Expand Down
6 changes: 2 additions & 4 deletions tapdb/asset_minting.go
Original file line number Diff line number Diff line change
Expand Up @@ -620,10 +620,8 @@ func fetchAssetSprouts(ctx context.Context, q PendingAssetStore,
Index: extractSqlInt32[uint32](
sprout.GroupKeyIndex,
),
Family: keychain.KeyFamily(
extractSqlInt32[keychain.KeyFamily](
sprout.GroupKeyFamily,
),
Family: extractSqlInt32[keychain.KeyFamily](
sprout.GroupKeyFamily,
),
},
},
Expand Down
12 changes: 6 additions & 6 deletions tapdb/multiverse.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,8 @@ func newRootPageQuery(q universe.RootNodesQuery) rootPageQuery {
withAmountsById: q.WithAmountsById,
leafQuery: leafQuery{
sortDirection: q.SortDirection,
offset: int32(q.Offset),
limit: int32(q.Limit),
offset: q.Offset,
limit: q.Limit,
},
}
}
Expand Down Expand Up @@ -401,8 +401,8 @@ type leafQuery struct {
func newLeafQuery(q universe.UniverseLeafKeysQuery) leafQuery {
return leafQuery{
sortDirection: q.SortDirection,
offset: int32(q.Offset),
limit: int32(q.Limit),
offset: q.Offset,
limit: q.Limit,
}
}

Expand Down Expand Up @@ -725,13 +725,13 @@ func (b *MultiverseStore) RootNodes(ctx context.Context,

params := sqlc.UniverseRootsParams{
SortDirection: sqlInt16(q.SortDirection),
NumOffset: int32(q.Offset),
NumOffset: q.Offset,
NumLimit: func() int32 {
if q.Limit == 0 {
return universe.MaxPageSize
}

return int32(q.Limit)
return q.Limit
}(),
}

Expand Down
2 changes: 1 addition & 1 deletion tapdb/universe_federation.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ func (u *UniverseFederationDB) RemoveServers(ctx context.Context,
// host string instead. This avoids bugs where a user
// doesn't set the ID value, and we try to delete the
// very first server.
uniID := int64(a.ID)
uniID := a.ID
if a.HostStr() != "" {
uniID = -1
}
Expand Down
2 changes: 1 addition & 1 deletion tapfreighter/wallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ func (s *CoinSelect) selectForAmount(minTotalAmount uint64,

// Keep track of the total amount of assets we've seen
// so far.
amountSum += uint64(anchoredCommitment.Asset.Amount)
amountSum += anchoredCommitment.Asset.Amount
if amountSum >= minTotalAmount {
// At this point a target min amount was
// specified and has been reached.
Expand Down
4 changes: 1 addition & 3 deletions universe/auto_syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,7 @@ func (f *FederationEnvoy) Start() error {
// Before we start the main goroutine, we'll add the set of
// static Universe servers.
addrs := f.cfg.StaticFederationMembers
serverAddrs := fn.Map(addrs, func(a string) ServerAddr {
return NewServerAddrFromStr(a)
})
serverAddrs := fn.Map(addrs, NewServerAddrFromStr)

serverAddrs = fn.Filter(serverAddrs, func(a ServerAddr) bool {
// Before we add the server as a federation member, we
Expand Down
8 changes: 4 additions & 4 deletions universe_rpc_diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ func (r *RpcUniverseDiff) RootNodes(ctx context.Context,
universeRoots, err := r.conn.AssetRoots(
ctx, &unirpc.AssetRootRequest{
WithAmountsById: q.WithAmountsById,
Offset: int32(q.Offset),
Limit: int32(q.Limit),
Offset: q.Offset,
Limit: q.Limit,
Direction: unirpc.SortDirection(q.SortDirection),
},
)
Expand Down Expand Up @@ -133,8 +133,8 @@ func (r *RpcUniverseDiff) UniverseLeafKeys(ctx context.Context,
ctx, &unirpc.AssetLeafKeysRequest{
Id: uniID,
Direction: unirpc.SortDirection(q.SortDirection),
Offset: int32(q.Offset),
Limit: int32(q.Limit),
Offset: q.Offset,
Limit: q.Limit,
},
)
if err != nil {
Expand Down

0 comments on commit 8d99137

Please sign in to comment.