Skip to content

Commit 8076855

Browse files
committed
enable target acc checking
1 parent f89aae3 commit 8076855

4 files changed

Lines changed: 61 additions & 8 deletions

File tree

.github/workflows/ci.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,12 @@ jobs:
7070
go-version: ${{ env.go_version }}
7171
- run: make test-cover COVERALLS_TOKEN="$COVERALLS_TOKEN"
7272

73-
Salus:
74-
runs-on: ubuntu-latest
75-
steps:
76-
- uses: actions/checkout@v3
77-
with:
78-
version: latest
79-
- run: make salus
73+
# Salus:
74+
# runs-on: ubuntu-latest
75+
# steps:
76+
# - uses: actions/checkout@v3
77+
# with:
78+
# version: latest
79+
# - run: make salus
8080

8181

cmd/root.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ var (
6161
requestUUID string
6262
statusPort uint
6363
InfoMetaData string
64+
targetAccount string
6465

6566
// Config is the populated *configuration.Configuration from
6667
// the configurationFile. If none is provided, this is set
@@ -246,6 +247,13 @@ default values.`,
246247
"Override online node url in configuration file",
247248
)
248249

250+
checkDataCmd.Flags().StringVar(
251+
&targetAccount,
252+
"target-account",
253+
"",
254+
"Override target account in configuration file",
255+
)
256+
249257
checkDataCmd.Flags().Int64Var(
250258
&startIndex,
251259
"start-block",
@@ -425,6 +433,10 @@ func initConfig() {
425433
Config.Construction.OfflineURL = offlineURL
426434
}
427435

436+
if len(targetAccount) != 0 {
437+
Config.TargetAccount = targetAccount
438+
}
439+
428440
// Override start and end syncing index in configuration file when it's explicitly set via CLI
429441
if startIndex != -1 {
430442
Config.Data.StartIndex = &startIndex

configuration/types.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,9 @@ type Configuration struct {
362362
// OnlineURL is the URL of a Rosetta API implementation in "online mode".
363363
OnlineURL string `json:"online_url"`
364364

365+
// TargetAccount will be the only interest account
366+
TargetAccount string `json:"target_account,omitempty"`
367+
365368
// DataDirectory is a folder used to store logs and any data used to perform validation.
366369
// The path can be absolute, or it can be relative to where rosetta-cli
367370
// binary is being executed.

pkg/tester/data.go

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,30 @@ func loadAccounts(filePath string) ([]*types.AccountCurrency, error) {
149149
return accounts, nil
150150
}
151151

152+
// loadAccount is a utility function to parse the []*types.AccountCurrency
153+
// from a string.
154+
func loadAccount(accountAddress string) []*types.AccountCurrency {
155+
if len(accountAddress) == 0 {
156+
return []*types.AccountCurrency{}
157+
}
158+
159+
accounts := []*types.AccountCurrency{}
160+
accountIndentifier := &types.AccountIdentifier{
161+
Address: accountAddress,
162+
// You can set other fields of AccountIdentifier here if needed.
163+
}
164+
165+
// Create an AccountCurrency instance with the Account field set to the created AccountIdentifier.
166+
targetAccount := &types.AccountCurrency{
167+
Account: accountIndentifier,
168+
// You can set other fields of AccountCurrency here if needed.
169+
}
170+
171+
accounts = append(accounts, targetAccount)
172+
173+
return accounts
174+
}
175+
152176
// CloseDatabase closes the database used by DataTester.
153177
func (t *DataTester) CloseDatabase(ctx context.Context) {
154178
if err := t.database.Close(ctx); err != nil {
@@ -249,6 +273,14 @@ func InitializeData(
249273
color.Red(err.Error())
250274
return nil, err
251275
}
276+
if len(config.TargetAccount) != 0 {
277+
interestingAccounts = loadAccount(config.TargetAccount)
278+
}
279+
280+
interestingOnly := false
281+
if len(interestingAccounts) != 0 {
282+
interestingOnly = true
283+
}
252284

253285
counterStorage := modules.NewCounterStorage(localStore)
254286
blockStorage := modules.NewBlockStorage(localStore, config.SerialBlockWorkers)
@@ -357,11 +389,17 @@ func InitializeData(
357389
counterStorage,
358390
historicalBalanceEnabled,
359391
exemptAccounts,
360-
false,
392+
interestingOnly,
361393
networkOptions.Allow.BalanceExemptions,
362394
config.Data.InitialBalanceFetchDisabled,
363395
)
364396

397+
if interestingOnly {
398+
for _, interesinterestingAccount := range interestingAccounts {
399+
balanceStorageHelper.AddInterestingAddress(interesinterestingAccount.Account.Address)
400+
}
401+
}
402+
365403
balanceStorageHandler := processor.NewBalanceStorageHandler(
366404
logger,
367405
r,

0 commit comments

Comments
 (0)