diff --git a/swarm/storage/ldbstore.go b/swarm/storage/ldbstore.go index 38b54e8f14..2a7f51cb38 100644 --- a/swarm/storage/ldbstore.go +++ b/swarm/storage/ldbstore.go @@ -731,6 +731,7 @@ func (s *LDBStore) tryAccessIdx(ikey []byte, index *dpaDBIndex) bool { return true } +// GetSchema is returning the current named schema of the datastore as read from LevelDB func (s *LDBStore) GetSchema() (string, error) { s.lock.Lock() defer s.lock.Unlock() @@ -746,6 +747,7 @@ func (s *LDBStore) GetSchema() (string, error) { return string(data), nil } +// PutSchema is saving a named schema to the LevelDB datastore func (s *LDBStore) PutSchema(schema string) error { s.lock.Lock() defer s.lock.Unlock() diff --git a/swarm/storage/localstore.go b/swarm/storage/localstore.go index 553aeeaf9a..b28f625246 100644 --- a/swarm/storage/localstore.go +++ b/swarm/storage/localstore.go @@ -185,6 +185,7 @@ func (ls *LocalStore) Close() { ls.DbStore.Close() } +// Migrate checks the datastore schema vs the runtime schema, and runs migrations if they don't match func (ls *LocalStore) Migrate() error { schema, err := ls.DbStore.GetSchema() if err != nil { @@ -200,6 +201,7 @@ func (ls *LocalStore) Migrate() error { log.Debug("running migrations for", "schema", schema, "runtime-schema", CurrentDbSchema) cleanupFunc := func(c *chunk) bool { + // if one of the ls.Validators passes, it means a chunk is of particular type and it is valid valid := false for _, v := range ls.Validators { if valid = v.Validate(c.Address(), c.Data()); valid {