feat: ENABLE_SELF_MINT_HEIGHT as a conf

This commit is contained in:
jiedo
2024-05-14 16:25:29 +08:00
parent 26c001fdfa
commit c7f275d3a6
4 changed files with 16 additions and 9 deletions

View File

@@ -4,6 +4,7 @@ import (
"flag"
"log"
"os"
"strconv"
"github.com/btcsuite/btcd/chaincfg"
"github.com/unisat-wallet/libbrc20-indexer/conf"
@@ -37,6 +38,12 @@ func init() {
if id := os.Getenv("MODULE_SWAP_SOURCE_INSCRIPTION_ID"); id != "" {
conf.MODULE_SWAP_SOURCE_INSCRIPTION_ID = id
}
if heightStr := os.Getenv("BRC20_ENABLE_SELF_MINT_HEIGHT"); heightStr != "" {
if h, err := strconv.Atoi(heightStr); err != nil {
conf.ENABLE_SELF_MINT_HEIGHT = uint32(h)
}
}
}
func main() {

View File

@@ -9,4 +9,5 @@ var (
MODULE_SWAP_SOURCE_INSCRIPTION_ID = "d2a30f6131324e06b1366876c8c089d7ad2a9c2b0ea971c5b0dc6198615bda2ei0"
GlobalNetParams = &chaincfg.MainNetParams
TICKS_ENABLED = ""
ENABLE_SELF_MINT_HEIGHT uint32 = 837090
)

View File

@@ -31,7 +31,7 @@ func (g *BRC20ModuleIndexer) ProcessDeploy(data *model.InscriptionBRC20Data) err
return nil
// return errors.New("deploy, tick length 5, but not self_mint")
}
if data.Height < g.EnableSelfMintHeight {
if data.Height < conf.ENABLE_SELF_MINT_HEIGHT {
return nil
// return errors.New("deploy, tick length 5, but not enabled")
}

View File

@@ -11,7 +11,6 @@ import (
type BRC20ModuleIndexer struct {
BestHeight uint32
EnableSelfMintHeight uint32
EnableHistory bool
HistoryCount uint32
@@ -108,6 +107,7 @@ func (g *BRC20ModuleIndexer) UpdateHistoryHeightAndGetHistoryIndex(historyObj *m
func (g *BRC20ModuleIndexer) initBRC20() {
g.EnableHistory = true
g.BestHeight = 0
g.HistoryCount = 0
g.HistoryData = make([][]byte, 0)
@@ -237,7 +237,6 @@ func (g *BRC20ModuleIndexer) GenerateApproveEventsByApprove(owner string, balanc
func (copyDup *BRC20ModuleIndexer) deepCopyBRC20Data(base *BRC20ModuleIndexer) {
// history
copyDup.BestHeight = base.BestHeight
copyDup.EnableSelfMintHeight = base.EnableSelfMintHeight
copyDup.EnableHistory = base.EnableHistory
copyDup.HistoryCount = base.HistoryCount