2018-11-07 21:50:43 +00:00
|
|
|
// VulcanizeDB
|
2019-03-12 15:46:42 +00:00
|
|
|
// Copyright © 2019 Vulcanize
|
2018-11-07 21:50:43 +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/>.
|
|
|
|
|
2018-02-13 16:31:57 +00:00
|
|
|
package datastore
|
2017-11-06 16:52:07 +00:00
|
|
|
|
2018-01-23 18:43:35 +00:00
|
|
|
import (
|
2019-08-06 21:57:08 +00:00
|
|
|
"github.com/ethereum/go-ethereum/core/types"
|
2019-08-02 15:09:59 +00:00
|
|
|
"github.com/jmoiron/sqlx"
|
2018-01-26 00:08:26 +00:00
|
|
|
"github.com/vulcanize/vulcanizedb/pkg/core"
|
|
|
|
"github.com/vulcanize/vulcanizedb/pkg/filters"
|
2018-01-23 18:43:35 +00:00
|
|
|
)
|
2017-11-06 16:52:07 +00:00
|
|
|
|
2019-08-01 20:24:02 +00:00
|
|
|
type AddressRepository interface {
|
|
|
|
GetOrCreateAddress(address string) (int, error)
|
|
|
|
}
|
|
|
|
|
2018-02-02 21:53:16 +00:00
|
|
|
type BlockRepository interface {
|
2018-05-02 16:17:02 +00:00
|
|
|
CreateOrUpdateBlock(block core.Block) (int64, error)
|
2018-02-08 16:12:08 +00:00
|
|
|
GetBlock(blockNumber int64) (core.Block, error)
|
2018-07-17 21:23:07 +00:00
|
|
|
MissingBlockNumbers(startingBlockNumber, endingBlockNumber int64, nodeID string) []int64
|
2019-02-14 15:03:57 +00:00
|
|
|
SetBlocksStatus(chainHead int64) error
|
2018-02-02 21:53:16 +00:00
|
|
|
}
|
|
|
|
|
2019-08-06 21:57:08 +00:00
|
|
|
type CheckedHeadersRepository interface {
|
|
|
|
MarkHeaderChecked(headerID int64) error
|
2019-08-26 21:43:14 +00:00
|
|
|
MarkHeadersUnchecked(startingBlockNumber int64) error
|
2019-08-27 21:30:50 +00:00
|
|
|
UncheckedHeaders(startingBlockNumber, endingBlockNumber, checkCount int64) ([]core.Header, error)
|
2019-08-06 21:57:08 +00:00
|
|
|
}
|
|
|
|
|
2019-08-26 21:43:14 +00:00
|
|
|
type CheckedLogsRepository interface {
|
2019-09-11 02:22:14 +00:00
|
|
|
AlreadyWatchingLog(addresses []string, topic0 string) (bool, error)
|
|
|
|
MarkLogWatched(addresses []string, topic0 string) error
|
2019-08-26 21:43:14 +00:00
|
|
|
}
|
|
|
|
|
2018-02-02 21:53:16 +00:00
|
|
|
type ContractRepository interface {
|
2017-12-04 22:54:35 +00:00
|
|
|
CreateContract(contract core.Contract) error
|
2018-02-08 16:12:08 +00:00
|
|
|
GetContract(contractHash string) (core.Contract, error)
|
2019-02-14 15:03:57 +00:00
|
|
|
ContractExists(contractHash string) (bool, error)
|
2018-02-08 16:12:08 +00:00
|
|
|
}
|
|
|
|
|
2018-02-02 21:53:16 +00:00
|
|
|
type FilterRepository interface {
|
2018-02-08 16:12:08 +00:00
|
|
|
CreateFilter(filter filters.LogFilter) error
|
|
|
|
GetFilter(name string) (filters.LogFilter, error)
|
2017-11-06 16:52:07 +00:00
|
|
|
}
|
2018-02-02 21:53:16 +00:00
|
|
|
|
2019-08-06 21:57:08 +00:00
|
|
|
type FullSyncLogRepository interface {
|
2019-10-18 16:16:19 +00:00
|
|
|
CreateLogs(logs []core.FullSyncLog, receiptID int64) error
|
2019-08-06 21:57:08 +00:00
|
|
|
GetLogs(address string, blockNumber int64) ([]core.FullSyncLog, error)
|
|
|
|
}
|
|
|
|
|
2018-07-17 21:23:07 +00:00
|
|
|
type HeaderRepository interface {
|
|
|
|
CreateOrUpdateHeader(header core.Header) (int64, error)
|
2019-03-27 17:26:04 +00:00
|
|
|
CreateTransactions(headerID int64, transactions []core.TransactionModel) error
|
2018-07-17 21:23:07 +00:00
|
|
|
GetHeader(blockNumber int64) (core.Header, error)
|
2019-01-11 09:58:41 +00:00
|
|
|
MissingBlockNumbers(startingBlockNumber, endingBlockNumber int64, nodeID string) ([]int64, error)
|
2018-07-17 21:23:07 +00:00
|
|
|
}
|
|
|
|
|
2019-08-06 21:57:08 +00:00
|
|
|
type HeaderSyncLogRepository interface {
|
|
|
|
GetUntransformedHeaderSyncLogs() ([]core.HeaderSyncLog, error)
|
|
|
|
CreateHeaderSyncLogs(headerID int64, logs []types.Log) error
|
2018-02-02 21:53:16 +00:00
|
|
|
}
|
|
|
|
|
2019-08-05 15:38:37 +00:00
|
|
|
type FullSyncReceiptRepository interface {
|
2019-10-18 16:16:19 +00:00
|
|
|
CreateReceiptsAndLogs(blockID int64, receipts []core.Receipt) error
|
|
|
|
CreateFullSyncReceiptInTx(blockID int64, receipt core.Receipt, tx *sqlx.Tx) (int64, error)
|
2019-08-05 15:38:37 +00:00
|
|
|
GetFullSyncReceipt(txHash string) (core.Receipt, error)
|
2018-02-08 16:12:08 +00:00
|
|
|
}
|
|
|
|
|
2019-08-05 18:13:53 +00:00
|
|
|
type HeaderSyncReceiptRepository interface {
|
2019-10-18 16:16:19 +00:00
|
|
|
CreateFullSyncReceiptInTx(blockID int64, receipt core.Receipt, tx *sqlx.Tx) (int64, error)
|
2019-08-05 18:13:53 +00:00
|
|
|
}
|
|
|
|
|
2018-02-12 16:54:05 +00:00
|
|
|
type WatchedEventRepository interface {
|
2018-02-08 16:12:08 +00:00
|
|
|
GetWatchedEvents(name string) ([]*core.WatchedEvent, error)
|
2018-02-02 21:53:16 +00:00
|
|
|
}
|