leveldb-ethdb-rpc/pkg/api.go

73 lines
2.1 KiB
Go
Raw Permalink Normal View History

2021-12-30 14:28:25 +00:00
// VulcanizeDB
2021-12-30 21:55:21 +00:00
// Copyright © 2022 Vulcanize
2021-12-30 14:28:25 +00:00
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
2021-12-31 18:17:57 +00:00
package leveldb_ethdb_rpc
2021-12-30 21:55:21 +00:00
import (
"context"
"errors"
)
// APIName is the namespace used for the state diffing service API
const APIName = "leveldb"
// APIVersion is the version of the state diffing service API
const APIVersion = "0.0.1"
var (
errWriteNotAllowed = errors.New("write endpoints are not enabled")
)
type PublicLevelDBAPI struct {
b *LevelDBBackend
}
func NewPublicLevelDBAPI(b *LevelDBBackend) *PublicLevelDBAPI {
return &PublicLevelDBAPI{b: b}
}
func (s *PublicLevelDBAPI) Has(ctx context.Context, key []byte) (bool, error) {
return s.b.Has(key)
}
func (s *PublicLevelDBAPI) Get(ctx context.Context, key []byte) ([]byte, error) {
return s.b.Get(key)
}
func (s *PublicLevelDBAPI) HasAncient(ctx context.Context, kind string, number uint64) (bool, error) {
return s.b.HasAncient(kind, number)
}
func (s *PublicLevelDBAPI) Ancient(ctx context.Context, kind string, number uint64) ([]byte, error) {
return s.b.Ancient(kind, number)
}
2021-12-31 18:17:57 +00:00
func (s *PublicLevelDBAPI) AncientRange(ctx context.Context, kind string, start, count, maxBytes uint64) ([][]byte, error) {
return s.b.AncientRange(kind, start, count, maxBytes)
}
2021-12-30 21:55:21 +00:00
func (s *PublicLevelDBAPI) Ancients(ctx context.Context) (uint64, error) {
return s.b.Ancients()
}
func (s *PublicLevelDBAPI) AncientSize(ctx context.Context, kind string) (uint64, error) {
return s.b.AncientSize(kind)
}
func (s *PublicLevelDBAPI) Stat(ctx context.Context, property string) (string, error) {
return s.b.Stat(property)
}