Skip to content

Commit ba5352b

Browse files
committed
fixed #20 cut through was not applied
the cut-through should now be applied on /tweaks endpoint as expected
1 parent c926454 commit ba5352b

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang as buildstage
1+
FROM golang AS buildstage
22

33
RUN mkdir /app
44
ADD . /app

src/core/cleanup.go

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
)
99

1010
func overwriteUTXOsWithLookUp(utxos []types.UTXO) error {
11+
common.DebugLogger.Println("overwriting utxos with lookup")
1112
var utxosToOverwrite []types.UTXO
1213

1314
for _, utxo := range utxos {
@@ -35,7 +36,7 @@ func overwriteUTXOsWithLookUp(utxos []types.UTXO) error {
3536
common.ErrorLogger.Println(err)
3637
return err
3738
}
38-
_ = key
39+
3940
err = dblevel.PruneUTXOs(key[:64])
4041
if err != nil {
4142
common.ErrorLogger.Println(err)
@@ -52,6 +53,7 @@ func overwriteUTXOsWithLookUp(utxos []types.UTXO) error {
5253

5354
// todo construct the subsequent deletion of all utxos per transaction once all per transaction are spent
5455
func markSpentUTXOsAndTweaks(utxos []types.UTXO) error {
56+
common.DebugLogger.Println("marking utxos")
5557
if len(utxos) == 0 {
5658
if common.Chain == common.Mainnet {
5759
// no warnings on other chains as it is very likely to not have any taproot outputs for several blocks on end
@@ -105,9 +107,13 @@ func markSpentUTXOsAndTweaks(utxos []types.UTXO) error {
105107
common.ErrorLogger.Println(err)
106108
return err
107109
} else if err != nil && errors.Is(err, dblevel.NoEntryErr{}) {
108-
// this case should not even occur at this stage as utxos are not deleted before this query and are only marked as spent
109-
common.DebugLogger.Printf("txid: %s\n", utxo.Txid)
110-
common.DebugLogger.Println("no UTXOs were found for transaction")
110+
// utxos can be already deleted at this point.
111+
// all utxos gone means we can remove the tweak
112+
tweaksToDelete = append(tweaksToDelete, types.Tweak{
113+
// we only need those Fields to serialise the key
114+
BlockHash: utxo.BlockHash,
115+
Txid: utxo.Txid,
116+
})
111117
continue
112118
}
113119
var canBeRemoved = true
@@ -124,8 +130,8 @@ func markSpentUTXOsAndTweaks(utxos []types.UTXO) error {
124130
Txid: utxo.Txid,
125131
})
126132
continue
127-
128133
}
134+
129135
var newBiggest *uint64
130136
newBiggest, err = types.FindBiggestRemainingUTXO(utxo, remainingUTXOs)
131137
if err != nil {

0 commit comments

Comments
 (0)