diff --git a/core/node/helpers.go b/core/node/helpers.go index 63e76ead7f2..2c32409a0fc 100644 --- a/core/node/helpers.go +++ b/core/node/helpers.go @@ -36,6 +36,33 @@ func (lp *lcProcess) Append(f goprocess.ProcessFunc) { }) } +type lcStartStop struct { + fx.In + + LC fx.Lifecycle +} + +// Append runx CtxFunc, and appends it to the lifecycle +func (lcss *lcStartStop) Append(f func() func()) { + // Hooks are guaranteed to run in sequence. If a hook fails to start, its + // OnStop won't be executed. + var stopFunc func() + + lcss.LC.Append(fx.Hook{ + OnStart: func(ctx context.Context) error { + stopFunc = f() + return nil + }, + OnStop: func(ctx context.Context) error { + if stopFunc == nil { // Theoretically this shouldn't ever happen + return errors.New("lcStatStop: stopFunc was nil") + } + stopFunc() + return nil + }, + }) +} + func maybeProvide(opt interface{}, enable bool) fx.Option { if enable { return fx.Provide(opt) diff --git a/core/node/ipns.go b/core/node/ipns.go index 5f516d0354b..df9b087c542 100644 --- a/core/node/ipns.go +++ b/core/node/ipns.go @@ -45,8 +45,8 @@ func Namesys(cacheSize int, cacheMaxTTL time.Duration) func(rt irouting.ProvideM } // IpnsRepublisher runs new IPNS republisher service -func IpnsRepublisher(repubPeriod time.Duration, recordLifetime time.Duration) func(lcProcess, namesys.NameSystem, repo.Repo, crypto.PrivKey) error { - return func(lc lcProcess, namesys namesys.NameSystem, repo repo.Repo, privKey crypto.PrivKey) error { +func IpnsRepublisher(repubPeriod time.Duration, recordLifetime time.Duration) func(lcStartStop, namesys.NameSystem, repo.Repo, crypto.PrivKey) error { + return func(lc lcStartStop, namesys namesys.NameSystem, repo repo.Repo, privKey crypto.PrivKey) error { repub := republisher.NewRepublisher(namesys, repo.Datastore(), privKey, repo.Keystore()) if repubPeriod != 0 { diff --git a/docs/examples/kubo-as-a-library/go.mod b/docs/examples/kubo-as-a-library/go.mod index 6fed80107a3..afd81783246 100644 --- a/docs/examples/kubo-as-a-library/go.mod +++ b/docs/examples/kubo-as-a-library/go.mod @@ -7,7 +7,7 @@ go 1.23 replace github.com/ipfs/kubo => ./../../.. require ( - github.com/ipfs/boxo v0.24.2 + github.com/ipfs/boxo v0.24.3-0.20241030212043-d15e9528c333 github.com/ipfs/kubo v0.0.0-00010101000000-000000000000 github.com/libp2p/go-libp2p v0.37.0 github.com/multiformats/go-multiaddr v0.13.0 diff --git a/docs/examples/kubo-as-a-library/go.sum b/docs/examples/kubo-as-a-library/go.sum index 774aa59feb6..4d680cb48a8 100644 --- a/docs/examples/kubo-as-a-library/go.sum +++ b/docs/examples/kubo-as-a-library/go.sum @@ -298,8 +298,8 @@ github.com/ipfs-shipyard/nopfs/ipfs v0.13.2-0.20231027223058-cde3b5ba964c h1:7Uy github.com/ipfs-shipyard/nopfs/ipfs v0.13.2-0.20231027223058-cde3b5ba964c/go.mod h1:6EekK/jo+TynwSE/ZOiOJd4eEvRXoavEC3vquKtv4yI= github.com/ipfs/bbloom v0.0.4 h1:Gi+8EGJ2y5qiD5FbsbpX/TMNcJw8gSqr7eyjHa4Fhvs= github.com/ipfs/bbloom v0.0.4/go.mod h1:cS9YprKXpoZ9lT0n/Mw/a6/aFV6DTjTLYHeA+gyqMG0= -github.com/ipfs/boxo v0.24.2 h1:feLM6DY6CNI0uSG3TvP/Hv4PdM/fsekjqSCqKtifF0E= -github.com/ipfs/boxo v0.24.2/go.mod h1:Dt3TJjMZtF2QksMv2LC8pQlG9VQUiSV2DsHQzvDiroo= +github.com/ipfs/boxo v0.24.3-0.20241030212043-d15e9528c333 h1:2OvIEEviF9OEqnEp4khojrAR+cxn2OVpx9VAZNJV9jc= +github.com/ipfs/boxo v0.24.3-0.20241030212043-d15e9528c333/go.mod h1:cDmTBd0IEM6UuOIZGXfxhumKlGr5CK/kfh+2Ka662lc= github.com/ipfs/go-bitfield v1.1.0 h1:fh7FIo8bSwaJEh6DdTWbCeZ1eqOaOkKFI74SCnsWbGA= github.com/ipfs/go-bitfield v1.1.0/go.mod h1:paqf1wjq/D2BBmzfTVFlJQ9IlFOZpg422HL0HqsGWHU= github.com/ipfs/go-bitswap v0.11.0 h1:j1WVvhDX1yhG32NTC9xfxnqycqYIlhzEzLXG/cU1HyQ= @@ -406,7 +406,6 @@ github.com/ipshipyard/p2p-forge v0.0.0-20241028231853-f599f4803109 h1:Od9XhliY3E github.com/ipshipyard/p2p-forge v0.0.0-20241028231853-f599f4803109/go.mod h1:taPeh3PDSO8Ual0/N2tIOAUXPV8gZoPF3uPXoUyiq14= github.com/jackpal/go-nat-pmp v1.0.2 h1:KzKSgb7qkJvOUTqYl9/Hg/me3pWgBmERKrTGD7BdWus= github.com/jackpal/go-nat-pmp v1.0.2/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc= -github.com/jbenet/go-cienv v0.1.0 h1:Vc/s0QbQtoxX8MwwSLWWh+xNNZvM3Lw7NsTcHrvvhMc= github.com/jbenet/go-cienv v0.1.0/go.mod h1:TqNnHUmJgXau0nCzC7kXWeotg3J9W34CUv5Djy1+FlA= github.com/jbenet/go-temp-err-catcher v0.1.0 h1:zpb3ZH6wIE8Shj2sKS+khgRvf7T7RABoLk/+KKHggpk= github.com/jbenet/go-temp-err-catcher v0.1.0/go.mod h1:0kJRvmDZXNMIiJirNPEYfhpPwbGVtZVWC34vc5WLsDk= diff --git a/go.mod b/go.mod index ca181eea14d..bba9304f2c5 100644 --- a/go.mod +++ b/go.mod @@ -22,7 +22,7 @@ require ( github.com/hashicorp/go-version v1.7.0 github.com/ipfs-shipyard/nopfs v0.0.12 github.com/ipfs-shipyard/nopfs/ipfs v0.13.2-0.20231027223058-cde3b5ba964c - github.com/ipfs/boxo v0.24.2 + github.com/ipfs/boxo v0.24.3-0.20241030212043-d15e9528c333 github.com/ipfs/go-block-format v0.2.0 github.com/ipfs/go-cid v0.4.1 github.com/ipfs/go-cidutil v0.1.0 diff --git a/go.sum b/go.sum index 2c513c5a5cc..34492a396a4 100644 --- a/go.sum +++ b/go.sum @@ -361,8 +361,8 @@ github.com/ipfs-shipyard/nopfs/ipfs v0.13.2-0.20231027223058-cde3b5ba964c h1:7Uy github.com/ipfs-shipyard/nopfs/ipfs v0.13.2-0.20231027223058-cde3b5ba964c/go.mod h1:6EekK/jo+TynwSE/ZOiOJd4eEvRXoavEC3vquKtv4yI= github.com/ipfs/bbloom v0.0.4 h1:Gi+8EGJ2y5qiD5FbsbpX/TMNcJw8gSqr7eyjHa4Fhvs= github.com/ipfs/bbloom v0.0.4/go.mod h1:cS9YprKXpoZ9lT0n/Mw/a6/aFV6DTjTLYHeA+gyqMG0= -github.com/ipfs/boxo v0.24.2 h1:feLM6DY6CNI0uSG3TvP/Hv4PdM/fsekjqSCqKtifF0E= -github.com/ipfs/boxo v0.24.2/go.mod h1:Dt3TJjMZtF2QksMv2LC8pQlG9VQUiSV2DsHQzvDiroo= +github.com/ipfs/boxo v0.24.3-0.20241030212043-d15e9528c333 h1:2OvIEEviF9OEqnEp4khojrAR+cxn2OVpx9VAZNJV9jc= +github.com/ipfs/boxo v0.24.3-0.20241030212043-d15e9528c333/go.mod h1:cDmTBd0IEM6UuOIZGXfxhumKlGr5CK/kfh+2Ka662lc= github.com/ipfs/go-bitfield v1.1.0 h1:fh7FIo8bSwaJEh6DdTWbCeZ1eqOaOkKFI74SCnsWbGA= github.com/ipfs/go-bitfield v1.1.0/go.mod h1:paqf1wjq/D2BBmzfTVFlJQ9IlFOZpg422HL0HqsGWHU= github.com/ipfs/go-bitswap v0.11.0 h1:j1WVvhDX1yhG32NTC9xfxnqycqYIlhzEzLXG/cU1HyQ= diff --git a/test/dependencies/go.mod b/test/dependencies/go.mod index 80f598e62fd..942fbae0d01 100644 --- a/test/dependencies/go.mod +++ b/test/dependencies/go.mod @@ -119,7 +119,7 @@ require ( github.com/huin/goupnp v1.3.0 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/ipfs/bbloom v0.0.4 // indirect - github.com/ipfs/boxo v0.24.2 // indirect + github.com/ipfs/boxo v0.24.3-0.20241030212043-d15e9528c333 // indirect github.com/ipfs/go-block-format v0.2.0 // indirect github.com/ipfs/go-cid v0.4.1 // indirect github.com/ipfs/go-datastore v0.6.0 // indirect diff --git a/test/dependencies/go.sum b/test/dependencies/go.sum index 3f49a4a46b0..65a457cde88 100644 --- a/test/dependencies/go.sum +++ b/test/dependencies/go.sum @@ -318,8 +318,8 @@ github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2 github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= github.com/ipfs/bbloom v0.0.4 h1:Gi+8EGJ2y5qiD5FbsbpX/TMNcJw8gSqr7eyjHa4Fhvs= github.com/ipfs/bbloom v0.0.4/go.mod h1:cS9YprKXpoZ9lT0n/Mw/a6/aFV6DTjTLYHeA+gyqMG0= -github.com/ipfs/boxo v0.24.2 h1:feLM6DY6CNI0uSG3TvP/Hv4PdM/fsekjqSCqKtifF0E= -github.com/ipfs/boxo v0.24.2/go.mod h1:Dt3TJjMZtF2QksMv2LC8pQlG9VQUiSV2DsHQzvDiroo= +github.com/ipfs/boxo v0.24.3-0.20241030212043-d15e9528c333 h1:2OvIEEviF9OEqnEp4khojrAR+cxn2OVpx9VAZNJV9jc= +github.com/ipfs/boxo v0.24.3-0.20241030212043-d15e9528c333/go.mod h1:cDmTBd0IEM6UuOIZGXfxhumKlGr5CK/kfh+2Ka662lc= github.com/ipfs/go-block-format v0.2.0 h1:ZqrkxBA2ICbDRbK8KJs/u0O3dlp6gmAuuXUJNiW1Ycs= github.com/ipfs/go-block-format v0.2.0/go.mod h1:+jpL11nFx5A/SPpsoBn6Bzkra/zaArfSmsknbPMYgzM= github.com/ipfs/go-cid v0.4.1 h1:A/T3qGvxi4kpKWWcPC/PgbvDA2bjVLO7n4UeVwnbs/s=