(ctx *cli.Context)
| 453 | } |
| 454 | |
| 455 | func deletePattern(ctx *cli.Context) (err error) { |
| 456 | if len(ctx.Args()) != 1 { |
| 457 | log.Fatal("This command requires argument <delete-key-substring>.") |
| 458 | } |
| 459 | |
| 460 | cfg, stack := newConfigNode(ctx) |
| 461 | _, chainDb := commons.OpenChain(ctx, stack, &cfg.Cpc) |
| 462 | defer chainDb.Close() |
| 463 | |
| 464 | if db, ok := chainDb.(*database.LDBDatabase); ok { |
| 465 | iter := db.LDB().NewIterator(nil, nil) |
| 466 | |
| 467 | log.Warn("This requires a few minutes to finish, please do not interrupt!") |
| 468 | |
| 469 | for iter.Next() { |
| 470 | key := iter.Key() |
| 471 | |
| 472 | // if matches, delete |
| 473 | if bytes.Contains(key, []byte(ctx.Args()[0])) { |
| 474 | err = db.Delete(key) |
| 475 | if err != nil { |
| 476 | log.Error("Error occurs when deleting key", "key", key) |
| 477 | } |
| 478 | } |
| 479 | } |
| 480 | iter.Release() |
| 481 | err = iter.Error() |
| 482 | |
| 483 | log.Warn("Finished deleting!") |
| 484 | } |
| 485 | |
| 486 | return err |
| 487 | } |
| 488 | |
| 489 | // hashish returns true for strings that look like hashes. |
| 490 | func hashish(x string) bool { |
nothing calls this directly
no test coverage detected