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 (
|
2018-02-02 21:53:16 +00:00
|
|
|
"fmt"
|
|
|
|
|
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
|
|
|
|
2018-02-02 21:53:16 +00:00
|
|
|
var ErrBlockDoesNotExist = func(blockNumber int64) error {
|
2018-02-13 16:31:57 +00:00
|
|
|
return fmt.Errorf("Block number %d does not exist", blockNumber)
|
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-05-07 15:41:02 +00:00
|
|
|
MissingBlockNumbers(startingBlockNumber int64, endingBlockNumber int64, nodeId string) []int64
|
2018-02-02 21:53:16 +00:00
|
|
|
SetBlocksStatus(chainHead int64)
|
|
|
|
}
|
|
|
|
|
|
|
|
var ErrContractDoesNotExist = func(contractHash string) error {
|
2018-02-13 16:31:57 +00:00
|
|
|
return fmt.Errorf("Contract %v does not exist", contractHash)
|
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)
|
2017-12-04 22:54:35 +00:00
|
|
|
ContractExists(contractHash string) bool
|
2018-02-08 16:12:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
var ErrFilterDoesNotExist = func(name string) error {
|
2018-02-13 16:31:57 +00:00
|
|
|
return fmt.Errorf("filter %s does not exist", name)
|
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
|
|
|
|
2018-02-12 16:54:05 +00:00
|
|
|
type LogRepository interface {
|
2018-05-02 16:17:02 +00:00
|
|
|
CreateLogs(logs []core.Log, receiptId int64) error
|
2018-02-08 16:12:08 +00:00
|
|
|
GetLogs(address string, blockNumber int64) []core.Log
|
2018-02-02 21:53:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
var ErrReceiptDoesNotExist = func(txHash string) error {
|
2018-02-13 16:31:57 +00:00
|
|
|
return fmt.Errorf("Receipt for tx: %v does not exist", txHash)
|
2018-02-02 21:53:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type ReceiptRepository interface {
|
2018-05-02 16:17:02 +00:00
|
|
|
CreateReceiptsAndLogs(blockId int64, receipts []core.Receipt) error
|
|
|
|
CreateReceipt(blockId int64, receipt core.Receipt) (int64, error)
|
2018-02-08 16:12:08 +00:00
|
|
|
GetReceipt(txHash string) (core.Receipt, error)
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|