ipld-eth-server/pkg/datastore/repository.go

72 lines
2.5 KiB
Go
Raw Normal View History

// VulcanizeDB
// Copyright © 2019 Vulcanize
// 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/>.
package datastore
import (
"github.com/jmoiron/sqlx"
2018-01-26 00:08:26 +00:00
"github.com/vulcanize/vulcanizedb/pkg/core"
"github.com/vulcanize/vulcanizedb/pkg/filters"
)
2019-08-01 20:24:02 +00:00
type AddressRepository interface {
GetOrCreateAddress(address string) (int, error)
}
type BlockRepository interface {
2018-05-02 16:17:02 +00:00
CreateOrUpdateBlock(block core.Block) (int64, error)
GetBlock(blockNumber int64) (core.Block, error)
MissingBlockNumbers(startingBlockNumber, endingBlockNumber int64, nodeID string) []int64
2019-02-14 15:03:57 +00:00
SetBlocksStatus(chainHead int64) error
}
type ContractRepository interface {
2017-12-04 22:54:35 +00:00
CreateContract(contract core.Contract) error
GetContract(contractHash string) (core.Contract, error)
2019-02-14 15:03:57 +00:00
ContractExists(contractHash string) (bool, error)
}
type FilterRepository interface {
CreateFilter(filter filters.LogFilter) error
GetFilter(name string) (filters.LogFilter, error)
}
type HeaderRepository interface {
CreateOrUpdateHeader(header core.Header) (int64, error)
2019-03-27 17:26:04 +00:00
CreateTransactions(headerID int64, transactions []core.TransactionModel) error
GetHeader(blockNumber int64) (core.Header, error)
MissingBlockNumbers(startingBlockNumber, endingBlockNumber int64, nodeID string) ([]int64, error)
}
type LogRepository interface {
2018-05-02 16:17:02 +00:00
CreateLogs(logs []core.Log, receiptId int64) error
2019-02-14 15:03:57 +00:00
GetLogs(address string, blockNumber int64) ([]core.Log, error)
}
type FullSyncReceiptRepository interface {
2018-05-02 16:17:02 +00:00
CreateReceiptsAndLogs(blockId int64, receipts []core.Receipt) error
CreateFullSyncReceiptInTx(blockId int64, receipt core.Receipt, tx *sqlx.Tx) (int64, error)
GetFullSyncReceipt(txHash string) (core.Receipt, error)
}
2019-08-05 18:13:53 +00:00
type HeaderSyncReceiptRepository interface {
CreateFullSyncReceiptInTx(blockId int64, receipt core.Receipt, tx *sqlx.Tx) (int64, error)
}
type WatchedEventRepository interface {
GetWatchedEvents(name string) ([]*core.WatchedEvent, error)
}