Skip to content

Commit

Permalink
Merge pull request #48 from SiaFoundation/surpass
Browse files Browse the repository at this point in the history
chain: Use SufficientlyHeavierThan
  • Loading branch information
n8maninger authored May 2, 2024
2 parents 45aa6bf + 1a3fdf1 commit 5df7ad9
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 1 addition & 3 deletions chain/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,7 @@ func (m *Manager) AddBlocks(blocks []types.Block) error {
}

// if this chain is now the best chain, trigger a reorg
//
// TODO: SurpassThreshold?
if cs.Depth.CmpWork(m.tipState.Depth) > 0 {
if cs.SufficientlyHeavierThan(m.tipState) {
oldTip := m.tipState.Index
if err := m.reorgTo(cs.Index); err != nil {
if err := m.reorgTo(oldTip); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.21.6

require (
go.etcd.io/bbolt v1.3.9
go.sia.tech/core v0.2.2
go.sia.tech/core v0.2.3-0.20240416172826-f9d44a4149e1
go.uber.org/zap v1.27.0
golang.org/x/crypto v0.22.0
lukechampine.com/frand v1.4.2
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ go.etcd.io/bbolt v1.3.9 h1:8x7aARPEXiXbHmtUwAIv7eV2fQFHrLLavdiJ3uzJXoI=
go.etcd.io/bbolt v1.3.9/go.mod h1:zaO32+Ti0PK1ivdPtgMESzuzL2VPoIG1PCQNvOdo/dE=
go.sia.tech/core v0.2.2 h1:33RJrt08o7KyUOY4tITH6ECmRq1lhtapqc/SncIF/2A=
go.sia.tech/core v0.2.2/go.mod h1:Zk7HaybEPgkPC1p6e6tTQr8PIeZClTgNcLNGYDLQJeE=
go.sia.tech/core v0.2.3-0.20240416172826-f9d44a4149e1 h1:tG9JJk6qPevT2CrFttL9Y4ZIT5+RS3J+Hk9E3zJaGiY=
go.sia.tech/core v0.2.3-0.20240416172826-f9d44a4149e1/go.mod h1:24liZWimivGQF+h3d14ly9oEpMIYxHPSgEMKmunxxi0=
go.sia.tech/mux v1.2.0 h1:ofa1Us9mdymBbGMY2XH/lSpY8itFsKIo/Aq8zwe+GHU=
go.sia.tech/mux v1.2.0/go.mod h1:Yyo6wZelOYTyvrHmJZ6aQfRoer3o4xyKQ4NmQLJrBSo=
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
Expand Down

0 comments on commit 5df7ad9

Please sign in to comment.