diff --git a/chain/manager.go b/chain/manager.go index 67f26ad..1da160d 100644 --- a/chain/manager.go +++ b/chain/manager.go @@ -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 { diff --git a/go.mod b/go.mod index ba19d2f..114e186 100644 --- a/go.mod +++ b/go.mod @@ -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 diff --git a/go.sum b/go.sum index 38939c6..4b420de 100644 --- a/go.sum +++ b/go.sum @@ -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=