From 103ab8690416996b685a0380836b71210ef78b8f Mon Sep 17 00:00:00 2001 From: Brannon King Date: Fri, 10 Sep 2021 16:15:15 -0400 Subject: [PATCH] fix regtest difficulty --- blockchain/difficulty.go | 7 ++++--- cmd/lbcctl/config.go | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/blockchain/difficulty.go b/blockchain/difficulty.go index 2f16e2e5..051998ba 100644 --- a/blockchain/difficulty.go +++ b/blockchain/difficulty.go @@ -245,10 +245,11 @@ func (b *BlockChain) calcNextRequiredDifficulty(lastNode *blockNode, newBlockTim // Get the block node at the previous retarget (targetTimespan days // worth of blocks). - firstNode := lastNode.RelativeAncestor(b.blocksPerRetarget) - if lastNode.height == 0 { - firstNode = lastNode + blocksBack := b.blocksPerRetarget + if blocksBack > lastNode.height { + blocksBack = lastNode.height } + firstNode := lastNode.RelativeAncestor(blocksBack) if firstNode == nil { return 0, AssertError("unable to obtain previous retarget block") } diff --git a/cmd/lbcctl/config.go b/cmd/lbcctl/config.go index bab6bb18..b2f77447 100644 --- a/cmd/lbcctl/config.go +++ b/cmd/lbcctl/config.go @@ -137,7 +137,7 @@ func normalizeAddress(addr string, chain *chaincfg.Params, useWallet bool) (stri paramErr := fmt.Errorf("cannot use -wallet with -regtest, btcwallet not yet compatible with regtest") return "", paramErr } else { - defaultPort = "18334" + defaultPort = "29245" } case &chaincfg.SigNetParams: if useWallet {