Skip to content

Commit c451150

Browse files
authored
chore(p2p)!: internalize nodekey (cometbft#4557)
Refs cometbft#4549
1 parent 13d852b commit c451150

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+100
-100
lines changed

.mockery.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
issue-845-fix: True
22
resolve-type-alias: False
3+
case: underscore # deprecated
4+
replace-type: github.com/cometbft/cometbft/p2p/internal/nodekey.ID=github.com/cometbft/cometbft/p2p.ID

abci/client/mocks/client.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

abci/tutorials/abci-v2-forum-app/forum.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import (
1919
cmtflags "github.com/cometbft/cometbft/libs/cli/flags"
2020
cmtlog "github.com/cometbft/cometbft/libs/log"
2121
nm "github.com/cometbft/cometbft/node"
22-
"github.com/cometbft/cometbft/p2p/nodekey"
22+
"github.com/cometbft/cometbft/p2p"
2323
"github.com/cometbft/cometbft/privval"
2424
"github.com/cometbft/cometbft/proxy"
2525
)
@@ -57,7 +57,7 @@ func main() {
5757
panic(fmt.Errorf("failed to create Forum Application: %w", err))
5858
}
5959

60-
nodeKey, err := nodekey.Load(config.NodeKeyFile())
60+
nodeKey, err := p2p.LoadNodeKey(config.NodeKeyFile())
6161
if err != nil {
6262
panic(fmt.Errorf("failed to load node key: %w", err))
6363
}

abci/types/mocks/application.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/cometbft/commands/gen_node_key.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"github.com/spf13/cobra"
77

88
cmtos "github.com/cometbft/cometbft/internal/os"
9-
"github.com/cometbft/cometbft/p2p/nodekey"
9+
"github.com/cometbft/cometbft/p2p"
1010
)
1111

1212
// GenNodeKeyCmd allows the generation of a node key. It prints node's ID to
@@ -24,7 +24,7 @@ func genNodeKey(*cobra.Command, []string) error {
2424
return fmt.Errorf("node key at %s already exists", nodeKeyFile)
2525
}
2626

27-
nk, err := nodekey.LoadOrGen(nodeKeyFile)
27+
nk, err := p2p.LoadOrGenNodeKey(nodeKeyFile)
2828
if err != nil {
2929
return err
3030
}

cmd/cometbft/commands/init.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
kt "github.com/cometbft/cometbft/internal/keytypes"
1111
cmtos "github.com/cometbft/cometbft/internal/os"
1212
cmtrand "github.com/cometbft/cometbft/internal/rand"
13-
"github.com/cometbft/cometbft/p2p/nodekey"
13+
"github.com/cometbft/cometbft/p2p"
1414
"github.com/cometbft/cometbft/privval"
1515
"github.com/cometbft/cometbft/types"
1616
cmttime "github.com/cometbft/cometbft/types/time"
@@ -55,7 +55,7 @@ func initFilesWithConfig(config *cfg.Config) error {
5555
if cmtos.FileExists(nodeKeyFile) {
5656
logger.Info("Found node key", "path", nodeKeyFile)
5757
} else {
58-
if _, err := nodekey.LoadOrGen(nodeKeyFile); err != nil {
58+
if _, err := p2p.LoadOrGenNodeKey(nodeKeyFile); err != nil {
5959
return err
6060
}
6161
logger.Info("Generated node key", "path", nodeKeyFile)

cmd/cometbft/commands/show_node_id.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55

66
"github.com/spf13/cobra"
77

8-
"github.com/cometbft/cometbft/p2p/nodekey"
8+
"github.com/cometbft/cometbft/p2p"
99
)
1010

1111
// ShowNodeIDCmd dumps node's ID to the standard output.
@@ -17,7 +17,7 @@ var ShowNodeIDCmd = &cobra.Command{
1717
}
1818

1919
func showNodeID(*cobra.Command, []string) error {
20-
nk, err := nodekey.Load(config.NodeKeyFile())
20+
nk, err := p2p.LoadNodeKey(config.NodeKeyFile())
2121
if err != nil {
2222
return err
2323
}

cmd/cometbft/commands/testnet.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ import (
1313
cfg "github.com/cometbft/cometbft/config"
1414
cmtrand "github.com/cometbft/cometbft/internal/rand"
1515
"github.com/cometbft/cometbft/libs/bytes"
16+
"github.com/cometbft/cometbft/p2p"
1617
na "github.com/cometbft/cometbft/p2p/netaddr"
17-
"github.com/cometbft/cometbft/p2p/nodekey"
1818
"github.com/cometbft/cometbft/privval"
1919
"github.com/cometbft/cometbft/types"
2020
cmttime "github.com/cometbft/cometbft/types/time"
@@ -252,7 +252,7 @@ func persistentPeersString(config *cfg.Config) (string, error) {
252252
for i := 0; i < nValidators+nNonValidators; i++ {
253253
nodeDir := filepath.Join(outputDir, fmt.Sprintf("%s%d", nodeDirPrefix, i))
254254
config.SetRoot(nodeDir)
255-
nk, err := nodekey.Load(config.NodeKeyFile())
255+
nk, err := p2p.LoadNodeKey(config.NodeKeyFile())
256256
if err != nil {
257257
return "", err
258258
}

crypto/mocks/batch_verifier.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crypto/mocks/pub_key.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)