Skip to content

Commit 60367e1

Browse files
Merge pull request #139 from coinbase/patrick/block-pruning
Add support for storage pruning
2 parents 55f7b85 + 173515e commit 60367e1

File tree

7 files changed

+38
-3
lines changed

7 files changed

+38
-3
lines changed

cmd/check_data.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,10 @@ func runCheckDataCmd(cmd *cobra.Command, args []string) {
133133
return dataTester.StartSyncing(ctx)
134134
})
135135

136+
g.Go(func() error {
137+
return dataTester.StartPruning(ctx)
138+
})
139+
136140
g.Go(func() error {
137141
return dataTester.WatchEndConditions(ctx)
138142
})

cmd/root.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,6 @@ var versionCmd = &cobra.Command{
132132
Use: "version",
133133
Short: "Print rosetta-cli version",
134134
Run: func(cmd *cobra.Command, args []string) {
135-
fmt.Println("v0.5.2")
135+
fmt.Println("v0.5.3")
136136
},
137137
}

configuration/configuration.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,12 @@ type DataConfiguration struct {
274274
// ResultsOutputFile is the absolute filepath of where to save
275275
// the results of a check:data run.
276276
ResultsOutputFile string `json:"results_output_file"`
277+
278+
// PruningDisabled is a bolean that indicates storage pruning should
279+
// not be attempted. This should really only ever be set to true if you
280+
// wish to use `start_index` at a later point to restart from some
281+
// previously synced block.
282+
PruningDisabled bool `json:"pruning_disabled"`
277283
}
278284

279285
// Configuration contains all configuration settings for running

examples/configuration/default.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
"inactive_discrepency_search_disabled": false,
3030
"balance_tracking_disabled": false,
3131
"coin_tracking_disabled": false,
32-
"results_output_file": ""
32+
"results_output_file": "",
33+
"pruning_disabled": false
3334
}
3435
}

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module github.com/coinbase/rosetta-cli
33
go 1.13
44

55
require (
6-
github.com/coinbase/rosetta-sdk-go v0.4.4
6+
github.com/coinbase/rosetta-sdk-go v0.4.5
77
github.com/fatih/color v1.9.0
88
github.com/jinzhu/copier v0.0.0-20190924061706-b57f9002281a
99
github.com/olekukonko/tablewriter v0.0.2-0.20190409134802-7e037d187b0c

go.sum

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,18 @@ github.com/coinbase/rosetta-sdk-go v0.4.4-0.20200916005026-5f676c313cfc h1:huzfl
141141
github.com/coinbase/rosetta-sdk-go v0.4.4-0.20200916005026-5f676c313cfc/go.mod h1:Luv0AhzZH81eul2hYZ3w0hBGwmFPiexwbntYxihEZck=
142142
github.com/coinbase/rosetta-sdk-go v0.4.4 h1:zTUS4bVlTfD4xq/o6JtsuU+g9sf3+S3Nnn2A24Ycow4=
143143
github.com/coinbase/rosetta-sdk-go v0.4.4/go.mod h1:Luv0AhzZH81eul2hYZ3w0hBGwmFPiexwbntYxihEZck=
144+
github.com/coinbase/rosetta-sdk-go v0.4.5-0.20200918214028-4d968344e1a2 h1:SqJ4KAfZeyGiJc5GG9DD2vsOY/gsegJK9q9F8WaQRTc=
145+
github.com/coinbase/rosetta-sdk-go v0.4.5-0.20200918214028-4d968344e1a2/go.mod h1:Luv0AhzZH81eul2hYZ3w0hBGwmFPiexwbntYxihEZck=
146+
github.com/coinbase/rosetta-sdk-go v0.4.5-0.20200918214833-43eb6f18490b h1:BXy7lSdgwJeBRRo03QLzW4Bj5cRYGQJcjJKxRlUmicU=
147+
github.com/coinbase/rosetta-sdk-go v0.4.5-0.20200918214833-43eb6f18490b/go.mod h1:Luv0AhzZH81eul2hYZ3w0hBGwmFPiexwbntYxihEZck=
148+
github.com/coinbase/rosetta-sdk-go v0.4.5-0.20200918215107-9c608cf4c6da h1:4rH5i5ePaF5Q5IpX40ZO+0wUjvGY1WJoHfkYcbGcpYE=
149+
github.com/coinbase/rosetta-sdk-go v0.4.5-0.20200918215107-9c608cf4c6da/go.mod h1:Luv0AhzZH81eul2hYZ3w0hBGwmFPiexwbntYxihEZck=
150+
github.com/coinbase/rosetta-sdk-go v0.4.5-0.20200918215315-15f3222d97c4 h1:NNAwQM58a1eh/5vfrneTMeWG9hNrROlSj8Rwrc4TQW8=
151+
github.com/coinbase/rosetta-sdk-go v0.4.5-0.20200918215315-15f3222d97c4/go.mod h1:Luv0AhzZH81eul2hYZ3w0hBGwmFPiexwbntYxihEZck=
152+
github.com/coinbase/rosetta-sdk-go v0.4.5-0.20200918215605-d46fa023df73 h1:MDM59d52JqwUQFw0/Ow35IWxFQNkcTNIVO71MDRW9HM=
153+
github.com/coinbase/rosetta-sdk-go v0.4.5-0.20200918215605-d46fa023df73/go.mod h1:Luv0AhzZH81eul2hYZ3w0hBGwmFPiexwbntYxihEZck=
154+
github.com/coinbase/rosetta-sdk-go v0.4.5 h1:5Z+25mm/J1SStzSdTp5e8dlEMtCZRBZdOaTFCBfnP4Y=
155+
github.com/coinbase/rosetta-sdk-go v0.4.5/go.mod h1:Luv0AhzZH81eul2hYZ3w0hBGwmFPiexwbntYxihEZck=
144156
github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk=
145157
github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
146158
github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk=

pkg/tester/data.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,18 @@ func (t *DataTester) StartSyncing(
317317
return t.syncer.Sync(ctx, startIndex, endIndex)
318318
}
319319

320+
// StartPruning attempts to prune block storage
321+
// every 10 seconds.
322+
func (t *DataTester) StartPruning(
323+
ctx context.Context,
324+
) error {
325+
if t.config.Data.PruningDisabled {
326+
return nil
327+
}
328+
329+
return t.syncer.Prune(ctx, statefulsyncer.DefaultPruningDepth)
330+
}
331+
320332
// StartReconciler starts the reconciler if
321333
// reconciliation is enabled.
322334
func (t *DataTester) StartReconciler(

0 commit comments

Comments
 (0)