Skip to content

Commit f74d304

Browse files
feat: added script to run super proof immediately
1 parent 87c686d commit f74d304

4 files changed

Lines changed: 21 additions & 8 deletions

File tree

da/super_proof.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ func ProcessBTCMsg(msg []byte, protocolId string) ([]byte, error) {
1717
return []byte(hash), nil
1818
}
1919

20-
func SuperProofCronJob(cfg *config.Config) {
20+
func SuperProofCronJob(cfg *config.Config, immediate bool) {
2121
// Initialize database with retry mechanism
2222
err := models.InitDB(cfg.PostgresConnectionURI)
2323
if err != nil {
@@ -37,6 +37,12 @@ func SuperProofCronJob(cfg *config.Config) {
3737
// Define the scheduled hours (0, 6, 12, 18 in 24-hour format)
3838
scheduledHours := []int{0, 6, 12, 18}
3939

40+
if immediate {
41+
log.Println("Running super proof immediately")
42+
processSuperProof(cfg)
43+
return
44+
}
45+
4046
for {
4147
now := time.Now().UTC()
4248

main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ func main() {
6767
}()
6868

6969
log.Println("Starting SuperProofCronJob...")
70-
da.SuperProofCronJob(&cfg)
70+
da.SuperProofCronJob(&cfg, false)
7171
superProofDone <- nil
7272
}()
7373

models/aggregated_proof.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,6 @@ func CreateAggregatedProofWithBTC(agg_proof string, proof_list []string, btc_tx_
4949
return nil, fmt.Errorf("error converting gas used: %w", err)
5050
}
5151

52-
var transaction_fee *string = nil
53-
if btc_tx_hash == nil {
54-
transaction_fee = &data.TransactionFee
55-
}
56-
5752
ap := &AggregatedProof{
5853
BTCTxHash: btc_tx_hash,
5954
BTCBlockNumber: btc_block_number,
@@ -64,7 +59,7 @@ func CreateAggregatedProofWithBTC(agg_proof string, proof_list []string, btc_tx_
6459
Proofs: proof_list,
6560
To: data.To,
6661
TransactionHash: data.TransactionHash,
67-
TransactionFee: *transaction_fee,
62+
TransactionFee: data.TransactionFee,
6863
EdgenPrice: data.EdgenPrice,
6964
Amount: data.Amount,
7065
Success: data.Success,

tools/run_super_proof.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package main
2+
3+
import (
4+
"github.com/Layer-Edge/bitcoin-da/config"
5+
"github.com/Layer-Edge/bitcoin-da/da"
6+
)
7+
8+
var cfg = config.GetConfig()
9+
10+
func main() {
11+
da.SuperProofCronJob(&cfg, true)
12+
}

0 commit comments

Comments
 (0)