-
Notifications
You must be signed in to change notification settings - Fork 60
Scale the DAG #908
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
base: master
Are you sure you want to change the base?
Scale the DAG #908
Changes from 4 commits
2b42b93
bed30a7
e8fbb86
e39e4d2
94adccb
5c4ebc6
7f613f1
395e128
cc93afb
9588705
18932e9
56f6cd1
c706f56
a88e895
2a737f6
691480f
bfa79c7
2fa7689
bb6d7dc
35c1944
38a7945
7d4d296
09f331d
1122bd9
bd5e93c
0046567
307269e
a6f0d8c
fe8a755
55618c4
4dddd82
49ed51c
dc70231
ae19758
d3de56e
b7a8089
de7518f
9463acb
6905b83
eabad6f
678ca28
fa0bf77
3231064
86f9190
ce2ef67
f13064c
2b8afb6
f7cfde2
8d8faba
373eeec
453417e
69879d0
40ff9f8
7bb2a6a
a266382
b9f58d8
6833a6c
2ff4b78
30cc8c6
54924c0
2d8c1ba
f6f3d65
e0d0c0e
4bf8b90
e8d55da
52ff7a2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| package domain | ||
|
|
||
| // MarkerInterval is the depth interval at which markers are created. | ||
| // VTXOs at depth 0, 100, 200, etc. create new markers. | ||
| const MarkerInterval = 100 | ||
|
Collaborator
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. what's happening to prod if we change this value ? like we have a DB with MarkerInterval 100 and we migrate to 150, do we need a specific migration for this ?
Collaborator
Author
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. that would be problematic. |
||
|
|
||
| // Marker represents a DAG traversal checkpoint created at regular depth intervals. | ||
| // Markers enable compressed traversal of the VTXO chain by allowing jumps of | ||
| // MarkerInterval depths instead of traversing each VTXO individually. | ||
| type Marker struct { | ||
| // ID is the unique identifier for this marker (typically the VTXO outpoint) | ||
| ID string | ||
| // Depth is the chain depth at which this marker exists (0, 100, 200, ...) | ||
| Depth uint32 | ||
| // ParentMarkerIDs is a list of marker IDs that this marker descends from | ||
| ParentMarkerIDs []string | ||
| } | ||
|
|
||
| // IsAtMarkerBoundary returns true if the given depth is at a marker boundary. | ||
| func IsAtMarkerBoundary(depth uint32) bool { | ||
| return depth%MarkerInterval == 0 | ||
| } | ||
|
|
||
| // SweptMarker records when a marker (and all VTXOs it covers) was swept. | ||
| // This is an append-only table that enables efficient bulk sweep operations. | ||
| type SweptMarker struct { | ||
| // MarkerID is the ID of the marker that was swept | ||
| MarkerID string | ||
| // SweptAt is the Unix timestamp (milliseconds) when the marker was swept | ||
| SweptAt int64 | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| package domain | ||
|
|
||
| import "context" | ||
|
|
||
| type MarkerRepository interface { | ||
| // AddMarker creates or updates a marker | ||
| AddMarker(ctx context.Context, marker Marker) error | ||
| // GetMarker retrieves a marker by ID | ||
| GetMarker(ctx context.Context, id string) (*Marker, error) | ||
| // GetMarkersByDepth retrieves all markers at a specific depth | ||
| GetMarkersByDepth(ctx context.Context, depth uint32) ([]Marker, error) | ||
| // GetMarkersByDepthRange retrieves all markers within a depth range | ||
| GetMarkersByDepthRange(ctx context.Context, minDepth, maxDepth uint32) ([]Marker, error) | ||
| // GetMarkersByIds retrieves markers by their IDs | ||
| GetMarkersByIds(ctx context.Context, ids []string) ([]Marker, error) | ||
|
|
||
| // SweepMarker marks a marker as swept at the given timestamp | ||
| SweepMarker(ctx context.Context, markerID string, sweptAt int64) error | ||
| // SweepMarkerWithDescendants marks a marker and all its descendants as swept | ||
| // Returns the number of markers swept (including descendants) | ||
| SweepMarkerWithDescendants(ctx context.Context, markerID string, sweptAt int64) (int64, error) | ||
| // IsMarkerSwept checks if a marker has been swept | ||
| IsMarkerSwept(ctx context.Context, markerID string) (bool, error) | ||
| // GetSweptMarkers retrieves swept marker records for the given marker IDs | ||
| GetSweptMarkers(ctx context.Context, markerIDs []string) ([]SweptMarker, error) | ||
|
|
||
| // UpdateVtxoMarker updates the marker_id for a VTXO | ||
| UpdateVtxoMarker(ctx context.Context, outpoint Outpoint, markerID string) error | ||
| // GetVtxosByMarker retrieves all VTXOs associated with a marker | ||
| GetVtxosByMarker(ctx context.Context, markerID string) ([]Vtxo, error) | ||
| // SweepVtxosByMarker marks all VTXOs with the given marker_id as swept | ||
| // Returns the number of VTXOs that were swept (not already swept) | ||
| SweepVtxosByMarker(ctx context.Context, markerID string) (int64, error) | ||
|
|
||
| // Chain traversal methods for GetVtxoChain optimization | ||
| // GetVtxosByDepthRange retrieves VTXOs within a depth range | ||
| GetVtxosByDepthRange(ctx context.Context, minDepth, maxDepth uint32) ([]Vtxo, error) | ||
| // GetVtxosByArkTxid retrieves VTXOs created by a specific ark tx | ||
| GetVtxosByArkTxid(ctx context.Context, arkTxid string) ([]Vtxo, error) | ||
| // GetVtxoChainByMarkers retrieves VTXOs that have markers in the given list | ||
| GetVtxoChainByMarkers(ctx context.Context, markerIDs []string) ([]Vtxo, error) | ||
|
|
||
| Close() | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.