swarm/storage: extract keySchema

This commit is contained in:
Anton Evangelatov 2018-09-17 13:34:57 +02:00
parent 9fc36171d0
commit ec17cab926

View file

@ -61,6 +61,7 @@ var (
keyDataIdx = []byte{4} keyDataIdx = []byte{4}
keyData = byte(6) keyData = byte(6)
keyDistanceCnt = byte(7) keyDistanceCnt = byte(7)
keySchema = byte(8)
) )
var ( var (
@ -734,7 +735,7 @@ func (s *LDBStore) GetSchema() (string, error) {
s.lock.Lock() s.lock.Lock()
defer s.lock.Unlock() defer s.lock.Unlock()
data, err := s.db.Get([]byte(`schema`)) data, err := s.db.Get(keySchema)
if err != nil { if err != nil {
if err == leveldb.ErrNotFound { if err == leveldb.ErrNotFound {
return "", nil return "", nil
@ -749,7 +750,7 @@ func (s *LDBStore) PutSchema(schema string) error {
s.lock.Lock() s.lock.Lock()
defer s.lock.Unlock() defer s.lock.Unlock()
return s.db.Put([]byte(`schema`), []byte(schema)) return s.db.Put(keySchema, []byte(schema))
} }
func (s *LDBStore) Get(_ context.Context, addr Address) (chunk Chunk, err error) { func (s *LDBStore) Get(_ context.Context, addr Address) (chunk Chunk, err error) {