use wallet has instead of list
This commit is contained in:
parent
959fe371b0
commit
28ef081d0e
@ -107,6 +107,7 @@ type FullNode interface {
|
||||
// wallet
|
||||
|
||||
WalletNew(context.Context, string) (address.Address, error)
|
||||
WalletHas(context.Context, address.Address) (bool, error)
|
||||
WalletList(context.Context) ([]address.Address, error)
|
||||
WalletBalance(context.Context, address.Address) (types.BigInt, error)
|
||||
WalletSign(context.Context, address.Address, []byte) (*types.Signature, error)
|
||||
|
@ -56,6 +56,7 @@ type FullNodeStruct struct {
|
||||
MinerCreateBlock func(context.Context, address.Address, *types.TipSet, []types.Ticket, types.ElectionProof, []*types.SignedMessage) (*chain.BlockMsg, error) `perm:"write"`
|
||||
|
||||
WalletNew func(context.Context, string) (address.Address, error) `perm:"write"`
|
||||
WalletHas func(context.Context, address.Address) (bool, error) `perm:"write"`
|
||||
WalletList func(context.Context) ([]address.Address, error) `perm:"write"`
|
||||
WalletBalance func(context.Context, address.Address) (types.BigInt, error) `perm:"read"`
|
||||
WalletSign func(context.Context, address.Address, []byte) (*types.Signature, error) `perm:"sign"`
|
||||
@ -173,6 +174,10 @@ func (c *FullNodeStruct) WalletNew(ctx context.Context, typ string) (address.Add
|
||||
return c.Internal.WalletNew(ctx, typ)
|
||||
}
|
||||
|
||||
func (c *FullNodeStruct) WalletHas(ctx context.Context, addr address.Address) (bool, error) {
|
||||
return c.Internal.WalletHas(ctx, addr)
|
||||
}
|
||||
|
||||
func (c *FullNodeStruct) WalletList(ctx context.Context) ([]address.Address, error) {
|
||||
return c.Internal.WalletList(ctx)
|
||||
}
|
||||
|
@ -244,6 +244,10 @@ func (a *FullNodeAPI) WalletNew(ctx context.Context, typ string) (address.Addres
|
||||
return a.Wallet.GenerateKey(typ)
|
||||
}
|
||||
|
||||
func (a *FullNodeAPI) WalletHas(ctx context.Context, addr address.Address) (bool, error) {
|
||||
return a.Wallet.HasKey(addr)
|
||||
}
|
||||
|
||||
func (a *FullNodeAPI) WalletList(ctx context.Context) ([]address.Address, error) {
|
||||
return a.Wallet.ListAddrs()
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ type storageMinerApi interface {
|
||||
|
||||
WalletBalance(context.Context, address.Address) (types.BigInt, error)
|
||||
WalletSign(context.Context, address.Address, []byte) (*types.Signature, error)
|
||||
WalletList(context.Context) ([]address.Address, error)
|
||||
WalletHas(context.Context, address.Address) (bool, error)
|
||||
}
|
||||
|
||||
func NewMiner(api storageMinerApi, addr address.Address, h host.Host, ds datastore.Batching, sb *sectorbuilder.SectorBuilder) (*Miner, error) {
|
||||
@ -173,17 +173,10 @@ func (m *Miner) runPreflightChecks(ctx context.Context) error {
|
||||
|
||||
m.worker = worker
|
||||
|
||||
addrs, err := m.api.WalletList(ctx)
|
||||
has, err := m.api.WalletHas(ctx, worker)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to check wallet for worker key")
|
||||
}
|
||||
var has bool
|
||||
for _, a := range addrs {
|
||||
if a == worker {
|
||||
has = true
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if !has {
|
||||
return errors.New("key for worker not found in local wallet")
|
||||
|
Loading…
Reference in New Issue
Block a user