Skip to content

Commit

Permalink
remove unuse code
Browse files Browse the repository at this point in the history
  • Loading branch information
frankcrypto committed Dec 11, 2023
1 parent 04946b4 commit ce9c333
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 29 deletions.
1 change: 1 addition & 0 deletions consensus/model/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ type Block interface {
GetOrder() uint
HasParents() bool
GetMainParent() uint
GetHeight() uint
}
1 change: 0 additions & 1 deletion consensus/model/difficulty_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
// DifficultyManager provides a method to resolve the
// difficulty value of a block
type DifficultyManager interface {
CalcNextRequiredDifficulty(timestamp time.Time, powType pow.PowType) (uint32, error)
RequiredDifficulty(block Block, newBlockTime time.Time, powInstance pow.IPow) (uint32, error)
CalcEasiestDifficulty(bits uint32, duration time.Duration, powInstance pow.IPow) uint32
GetCurrentPowDiff(ib Block, powType pow.PowType) *big.Int
Expand Down
2 changes: 1 addition & 1 deletion core/blockchain/difficulty.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func (m *BlockChain) calcNextRequiredDifficulty(block model.Block, newBlockTime
// This function is safe for concurrent access.
func (b *BlockChain) CalcNextRequiredDifficulty(timestamp time.Time, powType pow.PowType) (uint32, error) {
b.ChainRLock()
block := b.GetMainChainTip()
block := b.bd.GetMainChainTip()
instance := pow.GetInstance(powType, 0, []byte{})
instance.SetParams(b.params.PowConfig)
instance.SetMainHeight(pow.MainHeight(block.GetHeight() + 1))
Expand Down
11 changes: 0 additions & 11 deletions core/types/pow/difficultymanager/kaspad.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,17 +108,6 @@ func (m *kaspadDiff) CalcEasiestDifficulty(bits uint32, duration time.Duration,
return pow.BigToCompact(newTarget)
}

func (m *kaspadDiff) CalcNextRequiredDifficulty(timestamp time.Time, powType pow.PowType) (uint32, error) {
m.b.ChainRLock()
block := m.b.GetMainChainTip()
instance := pow.GetInstance(powType, 0, []byte{})
instance.SetParams(m.cfg.PowConfig)
instance.SetMainHeight(pow.MainHeight(block.GetHeight() + 1))
difficulty, err := m.RequiredDifficultyByWindows(m.getblockWindows(block, instance.GetPowType(), int(m.cfg.WorkDiffWindowSize)))
m.b.ChainRUnlock()
return difficulty, err
}

func (m *kaspadDiff) RequiredDifficulty(block model.Block, newBlockTime time.Time, powInstance pow.IPow) (uint32, error) {
return m.RequiredDifficultyByWindows(m.getblockWindows(block, powInstance.GetPowType(), int(m.cfg.WorkDiffWindowSize)))
}
Expand Down
16 changes: 0 additions & 16 deletions core/types/pow/difficultymanager/meer.go
Original file line number Diff line number Diff line change
Expand Up @@ -396,22 +396,6 @@ func (m *meerDiff) getDistanceFromLastAdjustment(block model.Block, powType pow.
}
}

// CalcNextRequiredDifficulty calculates the required difficulty for the block
// after the end of the current best chain based on the difficulty retarget
// rules.
//
// This function is safe for concurrent access.
func (m *meerDiff) CalcNextRequiredDifficulty(timestamp time.Time, powType pow.PowType) (uint32, error) {
m.b.ChainRLock()
block := m.b.GetMainChainTip()
instance := pow.GetInstance(powType, 0, []byte{})
instance.SetParams(m.cfg.PowConfig)
instance.SetMainHeight(pow.MainHeight(block.GetHeight() + 1))
difficulty, err := m.RequiredDifficulty(block, timestamp, instance)
m.b.ChainRUnlock()
return difficulty, err
}

// find block node by pow type
func (m *meerDiff) getPowTypeNode(block model.Block, powType pow.PowType) model.Block {
for {
Expand Down

0 comments on commit ce9c333

Please sign in to comment.