Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Staging #557

Merged
merged 2 commits into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions cmd/dfs/cmd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,14 @@ import (

var (
optionCORSAllowedOrigins = "cors-allowed-origins"
//optionFeedTracker = "dfs.feed-tracker"
optionDFSHttpPort = "dfs.ports.http-port"
optionDFSPprofPort = "dfs.ports.pprof-port"
optionVerbosity = "verbosity"
optionBeeApi = "bee.bee-api-endpoint"
optionBeePostageBatchId = "bee.postage-batch-id"
optionCookieDomain = "cookie-domain"
optionNetwork = "ens-network"
optionRPC = "rpc"
optionDFSHttpPort = "dfs.ports.http-port"
optionDFSPprofPort = "dfs.ports.pprof-port"
optionVerbosity = "verbosity"
optionBeeApi = "bee.bee-api-endpoint"
optionBeePostageBatchId = "bee.postage-batch-id"
optionCookieDomain = "cookie-domain"
optionNetwork = "ens-network"
optionRPC = "rpc"

defaultCORSAllowedOrigins = []string{}
defaultDFSHttpPort = ":9090"
Expand Down
1 change: 0 additions & 1 deletion cmd/dfs/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@ func initConfig() {

func writeConfig() {
c := viper.New()
//c.Set(optionFeedTracker, false)
c.Set(optionCORSAllowedOrigins, defaultCORSAllowedOrigins)
c.Set(optionDFSHttpPort, defaultDFSHttpPort)
c.Set(optionDFSPprofPort, defaultDFSPprofPort)
Expand Down
6 changes: 0 additions & 6 deletions cmd/dfs/cmd/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ import (

var (
pprof bool
feedTracker bool
swag bool
httpPort string
pprofPort string
Expand Down Expand Up @@ -78,9 +77,6 @@ can consume it.`,
if err := config.BindPFlag(optionDFSHttpPort, cmd.Flags().Lookup("httpPort")); err != nil {
return err
}
//if err := config.BindPFlag(optionFeedTracker, cmd.Flags().Lookup("feed-tracker")); err != nil {
// return err
//}
if err := config.BindPFlag(optionDFSPprofPort, cmd.Flags().Lookup("pprofPort")); err != nil {
return err
}
Expand Down Expand Up @@ -194,7 +190,6 @@ can consume it.`,
EnsConfig: ensConfig,
SubscriptionConfig: subscriptionConfig,
Logger: logger,
FeedTracker: feedTracker,
}

hdlr, err := api.New(ctx, opts)
Expand Down Expand Up @@ -232,7 +227,6 @@ can consume it.`,
func init() {
serverCmd.Flags().BoolVar(&pprof, "pprof", false, "should run pprof")
serverCmd.Flags().BoolVar(&swag, "swag", false, "should run swagger-ui")
//serverCmd.Flags().BoolVar(&feedTracker, "feed-tracker", false, "should run feed tracker")
serverCmd.Flags().String("httpPort", defaultDFSHttpPort, "http port")
serverCmd.Flags().String("pprofPort", defaultDFSPprofPort, "pprof port")
serverCmd.Flags().String("cookieDomain", defaultCookieDomain, "the domain to use in the cookie")
Expand Down
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ require (
github.com/stretchr/testify v1.8.4
github.com/swaggo/http-swagger v1.3.4
github.com/swaggo/swag v1.16.2
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7
github.com/tinygrasshopper/bettercsv v0.0.1
github.com/tyler-smith/go-bip39 v1.1.0
github.com/wealdtech/go-ens/v3 v3.5.5
Expand Down
7 changes: 0 additions & 7 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,6 @@ github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiu
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb h1:PBC98N2aIaM3XXiurYmW7fx4GZkL8feAMVq7nEjURHk=
github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
Expand Down Expand Up @@ -454,19 +453,16 @@ github.com/naoina/go-stringutil v0.1.0/go.mod h1:XJ2SJL9jCtBh+P9q5btrd/Ylo8XwT/h
github.com/naoina/toml v0.1.2-0.20170918210437-9fafd6967416/go.mod h1:NBIhNtsFMo3G2szEBne+bO4gS192HuIYRqfvOWb4i1E=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE=
github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U=
github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec=
github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY=
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk=
github.com/onsi/ginkgo v1.14.0 h1:2mOpI4JVVPBN+WQRa0WKH2eXR+Ey+uK4n7Zj0aYpIQA=
github.com/onsi/ginkgo v1.14.0/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY=
github.com/onsi/gomega v1.4.1/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA=
github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY=
github.com/onsi/gomega v1.10.1 h1:o0+MgICZLuZ7xjH7Vx6zS/zcu93/BEp1VwkIW1mEXCE=
github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
github.com/opentracing/opentracing-go v1.0.2/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
github.com/opentracing/opentracing-go v1.0.3-0.20180606204148-bd9c31933947/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
Expand Down Expand Up @@ -580,7 +576,6 @@ github.com/swaggo/swag v1.16.2 h1:28Pp+8DkQoV+HLzLx8RGJZXNGKbFqnuvSbAAtoxiY04=
github.com/swaggo/swag v1.16.2/go.mod h1:6YzXnDcpr0767iOejs318CwYkCQqyGer6BizOg03f+E=
github.com/syndtr/goleveldb v1.0.1-0.20210305035536-64b5b1c73954/go.mod h1:u2MKkTVTVJWe5D1rCvame8WqhBd88EuIwODJZ1VHCPM=
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70Z7CTTCmYQn2CKbY8j86K7/FAIr141uY=
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc=
github.com/tinygrasshopper/bettercsv v0.0.1 h1:N96aWjbUBN2q+KotgSI9FMR+1Y4IIBMVMPiL8qASK0k=
github.com/tinygrasshopper/bettercsv v0.0.1/go.mod h1:0pXjg6Vm8+zAkvosNH2S0dx8gc7H1hDIV0pMzmq1vRI=
github.com/tinylib/msgp v1.0.2/go.mod h1:+d+yLhGm8mzTaHzB+wgMYrodPfmZrzkirds8fDWklFE=
Expand Down Expand Up @@ -885,7 +880,6 @@ golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8T
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 h1:H2TDz8ibqkAF6YGhCdN3jS9O0/s90v0rJh3X/OLHEUk=
gonum.org/v1/gonum v0.0.0-20180816165407-929014505bf4/go.mod h1:Y+Yx5eoAFn32cQvJDxZx5Dpnq+c3wtXuadVZAcxbbBo=
gonum.org/v1/gonum v0.0.0-20181121035319-3f7ecaa7e8ca/go.mod h1:Y+Yx5eoAFn32cQvJDxZx5Dpnq+c3wtXuadVZAcxbbBo=
gonum.org/v1/gonum v0.6.0/go.mod h1:9mxDZsDKxgMAuccQkewq682L+0eCu4dCN2yonUJTCLU=
Expand Down Expand Up @@ -999,7 +993,6 @@ gopkg.in/natefinch/lumberjack.v2 v2.0.0 h1:1Lc07Kr7qY4U2YPouBjpCLxpiyxIVoxqXgkXL
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce h1:+JknDZhAj8YMt7GC73Ei8pv4MzjDUNPHgQWJdtMAaDU=
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce/go.mod h1:5AcXVHNjg+BDxry382+8OKon8SEWiKktQR07RKPsv1c=
gopkg.in/olebedev/go-duktape.v3 v3.0.0-20200619000410-60c24ae608a6/go.mod h1:uAJfkITjFhyEEuUfm7bsmCZRbW5WRq8s9EY8HZ6hCns=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
gopkg.in/urfave/cli.v1 v1.20.0/go.mod h1:vuBzUtMdQeixQj8LVd+/98pzhxNGQoyuPBlsXHOQNO0=
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
Expand Down
2 changes: 0 additions & 2 deletions pkg/api/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ type Options struct {
EnsConfig *contracts.ENSConfig
SubscriptionConfig *contracts.SubscriptionConfig
Logger logging.Logger
FeedTracker bool
}

// New returns a new handler
Expand All @@ -53,7 +52,6 @@ func New(ctx context.Context, opts *Options) (*Handler, error) {
EnsConfig: opts.EnsConfig,
SubscriptionConfig: opts.SubscriptionConfig,
Logger: opts.Logger,
FeedTracker: opts.FeedTracker,
}
api, err := dfs.NewDfsAPI(ctx, dfsOpts)
if err != nil {
Expand Down
31 changes: 14 additions & 17 deletions pkg/dfs/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,13 @@ const (

// API is the go api for fairOS
type API struct {
context context.Context
cancel context.CancelFunc
client blockstore.Client
users *user.Users
logger logging.Logger
tm *taskmanager.TaskManager
sm subscriptionManager.SubscriptionManager
shouldInitFeedTracker bool
context context.Context
cancel context.CancelFunc
client blockstore.Client
users *user.Users
logger logging.Logger
tm *taskmanager.TaskManager
sm subscriptionManager.SubscriptionManager
io.Closer
}

Expand All @@ -56,7 +55,6 @@ type Options struct {
EnsConfig *contracts.ENSConfig
SubscriptionConfig *contracts.SubscriptionConfig
Logger logging.Logger
FeedTracker bool
}

// NewDfsAPI is the main entry point for the df controller.
Expand Down Expand Up @@ -91,14 +89,13 @@ func NewDfsAPI(ctx context.Context, opts *Options) (*API, error) {
tmLogger := logging.New(io.Discard, 0)
ctx2, cancel := context.WithCancel(ctx)
return &API{
context: ctx2,
cancel: cancel,
shouldInitFeedTracker: opts.FeedTracker,
client: c,
users: users,
logger: logger,
tm: taskmanager.New(10, defaultMaxWorkers, time.Second*15, tmLogger),
sm: sm,
context: ctx2,
cancel: cancel,
client: c,
users: users,
logger: logger,
tm: taskmanager.New(10, defaultMaxWorkers, time.Second*15, tmLogger),
sm: sm,
}, nil
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/dfs/user_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func (a *API) CreateUserV2(userName, passPhrase, mnemonic, sessionId string) (*u

// LoginUserV2 is a controller function which calls the users login function.
func (a *API) LoginUserV2(userName, passPhrase, sessionId string) (*user.LoginResponse, error) {
return a.users.LoginUserV2(userName, passPhrase, a.client, a.tm, a.sm, sessionId, a.shouldInitFeedTracker)
return a.users.LoginUserV2(userName, passPhrase, a.client, a.tm, a.sm, sessionId)
}

// LoadLiteUser is a controller function which loads user from mnemonic and doesn't store any user info on chain
Expand Down
62 changes: 1 addition & 61 deletions pkg/feed/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import (
"github.com/fairdatasociety/fairOS-dfs/pkg/feed/lookup"
"github.com/fairdatasociety/fairOS-dfs/pkg/logging"
"github.com/fairdatasociety/fairOS-dfs/pkg/utils"
"github.com/syndtr/goleveldb/leveldb"
"golang.org/x/crypto/sha3"
)

Expand All @@ -58,7 +57,6 @@ type API struct {
handler *Handler
accountInfo *account.Info
logger logging.Logger
db *leveldb.DB
}

// request is a custom type that involves in the fairOS feed creation
Expand All @@ -82,16 +80,6 @@ func New(accountInfo *account.Info, client blockstore.Client, logger logging.Log
}
}

// SetUpdateTracker sets the update tracker for the feed
func (a *API) SetUpdateTracker(db *leveldb.DB) {
a.db = db
}

// GetUpdateTracker gets the update tracker for the feed
func (a *API) GetUpdateTracker() *leveldb.DB {
return a.db
}

// CreateFeed creates a feed by constructing a single owner chunk. This chunk
// can only be accessed if the pod address is known. Also, no one else can spoof this
// chunk since this is signed by the pod.
Expand Down Expand Up @@ -172,13 +160,6 @@ func (a *API) CreateFeed(user utils.Address, topic, data, encryptionPassword []b
if err != nil { // skipcq: TCV-001
return nil, err
}
// update the feed update tracker
if a.db != nil {
err = a.PutFeedUpdateEpoch(append(topic, user[:20]...), req.Epoch)
if err != nil { // skipcq: TCV-001
return nil, err
}
}
return addr, nil
}

Expand Down Expand Up @@ -249,16 +230,7 @@ func (a *API) GetFeedData(topic []byte, user utils.Address, encryptionPassword [
// create the query from values
q := &Query{Feed: *f}
q.TimeLimit = 0
if a.db != nil && !isFeedUpdater {
epoch, err := a.GetFeedUpdateEpoch(append(topic, user[:20]...))
if err != nil {
q.Hint = lookup.NoClue
} else {
q.Hint = epoch
}
} else {
q.Hint = lookup.NoClue
}
q.Hint = lookup.NoClue
if q.Hint == lookup.NoClue {
_, err := a.handler.Lookup(ctx, q)
if err != nil {
Expand Down Expand Up @@ -399,12 +371,6 @@ retry:
}
return nil, err
}
if a.db != nil && !isFeedUpdater {
err = a.PutFeedUpdateEpoch(append(topic, user[:20]...), req.Epoch)
if err != nil { // skipcq: TCV-001
return nil, err
}
}
return address, nil
}

Expand Down Expand Up @@ -453,32 +419,6 @@ func (a *API) IsReadOnlyFeed() bool {
return a.accountInfo.GetPrivateKey() == nil
}

// PutFeedUpdateEpoch
func (a *API) PutFeedUpdateEpoch(topic []byte, epoch lookup.Epoch) error {
data, err := epoch.MarshalBinary()
if err != nil {
return err
}
return a.db.Put(topic, data, nil)
}

// GetFeedUpdateEpoch
func (a *API) GetFeedUpdateEpoch(topic []byte) (lookup.Epoch, error) {
epoch := lookup.Epoch{}
data, err := a.db.Get(topic, nil)
if err != nil {
return epoch, err
}
err = epoch.UnmarshalBinary(data)
if err != nil {
return epoch, err
}
return epoch, nil
}

func (a *API) Close() error {
if a.db != nil {
return a.db.Close()
}
return nil
}
Loading
Loading