// New returns a new Api instance.
New returns a new Api instance.
// New returns a new Api instance .
func New(ds datastore.Datastore, iid ffs.APIID, sch *scheduler.Scheduler, wm ffs.WalletManager, drm ffs.DealRecordsManager, dc ffs.StorageConfig, addrInfo AddrInfo) (*API, error) {
	is := newInstanceStore(namespace.Wrap(ds, datastore.NewKey("istore")))
	dc.Cold.Filecoin.Addr = addrInfo.Addr
	if err := dc.Validate(); err != nil {
		return nil, fmt.Errorf("default storage config is invalid: %s", err)
	}
	config := InstanceConfig{
		ID:                   iid,
		Addrs:                map[string]AddrInfo{addrInfo.Addr: addrInfo},
		DefaultStorageConfig: dc,
	}
	ctx, cancel := context.WithCancel(context.Background())
	i := new(ctx, is, wm, drm, config, sch, cancel)
	if err := i.is.putInstanceConfig(config); err != nil {
		return nil, fmt.Errorf("saving new instance %s: %s", i.cfg.ID, err)
	}
	return i, nil
}
func New ( ds datastore . Datastore , iid ffs . APIID , sch * scheduler . Scheduler , wm ffs . WalletManager , drm ffs . DealRecordsManager , dc ffs . StorageConfig , addrInfo AddrInfo ) ( * API , error ) { is := newInstanceStore ( namespace . Wrap ( ds , datastore . NewKey ( " " ) ) ) dc . Cold . Filecoin . Addr = addrInfo . Addr if err := dc . Validate ( ) ; err != nil { return nil , fmt . Errorf ( " " , err ) } config := InstanceConfig { ID : iid , Addrs : map [ string ] AddrInfo { addrInfo . Addr : addrInfo } , DefaultStorageConfig : dc , } ctx , cancel := context . WithCancel ( context . Background ( ) ) i := new ( ctx , is , wm , drm , config , sch , cancel ) if err := i . is . putInstanceConfig ( config ) ; err != nil { return nil , fmt . Errorf ( " " , i . cfg . ID , err ) } return i , nil }
New returns a new Api instance.
New returns a new Api instance .