Skip to content

Commit

Permalink
rm unused peer2key
Browse files Browse the repository at this point in the history
  • Loading branch information
hunjixin committed Feb 18, 2022
1 parent 996cc82 commit c56217e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 29 deletions.
25 changes: 3 additions & 22 deletions app/node/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,30 +18,12 @@ const defaultPeerKeyBits = 2048

// initCfg contains configuration for initializing a node's repo.
type initCfg struct {
peerKey acrypto.PrivKey
defaultKey *crypto.KeyInfo
initImports []*crypto.KeyInfo
}

// InitOpt is an option for initialization of a node's repo.
type InitOpt func(*initCfg)

// PeerKeyOpt sets the private key for a node's 'self' libp2p identity.
// If unspecified, initialization will create a new one.
func PeerKeyOpt(k acrypto.PrivKey) InitOpt {
return func(opts *initCfg) {
opts.peerKey = k
}
}

// DefaultKeyOpt sets the private key for the wallet's default account.
// If unspecified, initialization will create a new one.
func DefaultKeyOpt(ki *crypto.KeyInfo) InitOpt {
return func(opts *initCfg) {
opts.defaultKey = ki
}
}

// ImportKeyOpt imports the provided key during initialization.
func ImportKeyOpt(ki *crypto.KeyInfo) InitOpt {
return func(opts *initCfg) {
Expand All @@ -66,10 +48,9 @@ func Init(ctx context.Context, r repo.Repo, gen genesis.InitFunc, opts ...InitOp
return errors.Wrap(err, "Could not Init Node")
}

if cfg.peerKey != nil {
if cfg.peerKey, err = createPeerKey(r.Keystore()); err != nil {
return err
}
_, err = createPeerKey(r.Keystore())
if err != nil {
return errors.Wrap(err, "Could not Create P2p key")
}

if err = r.ReplaceConfig(r.Config()); err != nil {
Expand Down
7 changes: 0 additions & 7 deletions app/node/test/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,6 @@ func (cs *ChainSeed) Addr(t *testing.T, key int) address.Address {
return a
}

// MinerInitOpt is a node init option that imports the key for the miner's owner
func (cs *ChainSeed) MinerInitOpt(which int) node.InitOpt {
kwhich := cs.info.Miners[which].Owner
kinfo := cs.info.Keys[kwhich]
return node.ImportKeyOpt(kinfo)
}

// KeyInitOpt is a node init option that imports one of the chain seed's
// keys to a node's wallet
func (cs *ChainSeed) KeyInitOpt(which int) node.InitOpt {
Expand Down

0 comments on commit c56217e

Please sign in to comment.