-
Notifications
You must be signed in to change notification settings - Fork 19
Cleanup service - move preserve parent and utxo cleanup from blockass… #114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
freemans13
wants to merge
15
commits into
bsv-blockchain:main
Choose a base branch
from
freemans13:stu/cleanup-service
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 7 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
3983922
Cleanup service - move preserve parent and utxo cleanup from blockass…
freemans13 906d697
tweaks
freemans13 2333fb9
race condition fixes plus cleanup for old expired parents
freemans13 05a9023
Merge branch 'main' of https://github.com/bsv-blockchain/teranode int…
freemans13 b7c4d74
linting
freemans13 9d42989
Merge branch 'main' into stu/cleanup-service
freemans13 4c9f918
fixes
freemans13 2e0d684
Merge branch 'main' of https://github.com/bsv-blockchain/teranode int…
freemans13 1a81e8e
Merge branch 'main' of https://github.com/bsv-blockchain/teranode int…
freemans13 8da4367
Merge branch 'main' of https://github.com/bsv-blockchain/teranode int…
freemans13 948ae6a
fixes
freemans13 daa38cd
cleanup timeout setting default 10m
freemans13 4c71e98
Merge branch 'main' of https://github.com/bsv-blockchain/teranode int…
freemans13 c2923d6
cleanup aerospike batch size tweaks
freemans13 1a89ed4
Merge branch 'main' of https://github.com/bsv-blockchain/teranode int…
freemans13 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| package config | ||
|
|
||
| import "time" | ||
|
|
||
| // CleanupSettings contains configuration for the Cleanup service. | ||
| type CleanupSettings struct { | ||
| // GRPCListenAddress is the address the cleanup service listens on for gRPC requests | ||
| GRPCListenAddress string | ||
|
|
||
| // GRPCAddress is the address other services use to connect to the cleanup service | ||
| GRPCAddress string | ||
|
|
||
| // PollingInterval is how often to poll block assembly state for cleanup triggers | ||
| PollingInterval time.Duration | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,6 +15,7 @@ import ( | |
| "github.com/bsv-blockchain/teranode/services/blockchain" | ||
| "github.com/bsv-blockchain/teranode/services/blockpersister" | ||
| "github.com/bsv-blockchain/teranode/services/blockvalidation" | ||
| "github.com/bsv-blockchain/teranode/services/cleanup" | ||
| "github.com/bsv-blockchain/teranode/services/legacy" | ||
| "github.com/bsv-blockchain/teranode/services/legacy/peer" | ||
| "github.com/bsv-blockchain/teranode/services/p2p" | ||
|
|
@@ -68,6 +69,7 @@ func (d *Daemon) startServices(ctx context.Context, logger ulogger.Logger, appSe | |
| startLegacy := d.shouldStart(serviceLegacyFormal, args) | ||
| startRPC := d.shouldStart(serviceRPCFormal, args) | ||
| startAlert := d.shouldStart(serviceAlertFormal, args) | ||
| startCleanup := d.shouldStart(serviceCleanupFormal, args) | ||
|
|
||
| // Create the application count based on the services that are going to be started | ||
| d.appCount += len(d.externalServices) | ||
|
|
@@ -117,6 +119,7 @@ func (d *Daemon) startServices(ctx context.Context, logger ulogger.Logger, appSe | |
| {startValidator, func() error { return d.startValidatorService(ctx, appSettings, createLogger) }}, | ||
| {startPropagation, func() error { return d.startPropagationService(ctx, appSettings, createLogger) }}, | ||
| {startLegacy, func() error { return d.startLegacyService(ctx, appSettings, createLogger) }}, | ||
| {startCleanup, func() error { return d.startCleanupService(ctx, appSettings, createLogger) }}, | ||
| } | ||
|
|
||
| // Loop through and start each service if needed | ||
|
|
@@ -1065,3 +1068,38 @@ func (d *Daemon) startLegacyService( | |
| blockassemblyClient, | ||
| )) | ||
| } | ||
|
|
||
| // startCleanupService initializes and adds the Cleanup service to the ServiceManager. | ||
| func (d *Daemon) startCleanupService(ctx context.Context, appSettings *settings.Settings, | ||
| createLogger func(string) ulogger.Logger) error { | ||
| // Create the UTXO store for the Cleanup service | ||
| utxoStore, err := d.daemonStores.GetUtxoStore(ctx, createLogger(loggerUtxos), appSettings) | ||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
||
| // Create the blockchain client for the Cleanup service | ||
| blockchainClient, err := d.daemonStores.GetBlockchainClient( | ||
| ctx, createLogger(loggerBlockchainClient), appSettings, serviceCleanup, | ||
| ) | ||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
||
| // Create the block assembly client for the Cleanup service | ||
| blockAssemblyClient, err := blockassembly.NewClient(ctx, createLogger(loggerBlockAssembly), appSettings) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use |
||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
||
| // Add the Cleanup service to the ServiceManager | ||
| return d.ServiceManager.AddService(serviceCleanupFormal, cleanup.New( | ||
| ctx, | ||
| createLogger(loggerCleanup), | ||
| appSettings, | ||
| utxoStore, | ||
| blockchainClient, | ||
| blockAssemblyClient, | ||
| nil, // blobStore not needed for cleanup service | ||
| )) | ||
| } | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this in a new config package and not the settings package?