remove btc stuff
This commit is contained in:
@@ -1,144 +0,0 @@
|
||||
// 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 shared
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// DataType is an enum to loosely represent type of chain data
|
||||
type DataType int
|
||||
|
||||
const (
|
||||
UnknownDataType DataType = iota - 1
|
||||
Full
|
||||
Headers
|
||||
Uncles
|
||||
Transactions
|
||||
Receipts
|
||||
State
|
||||
Storage
|
||||
)
|
||||
|
||||
// String() method to resolve ReSyncType enum
|
||||
func (r DataType) String() string {
|
||||
switch r {
|
||||
case Full:
|
||||
return "full"
|
||||
case Headers:
|
||||
return "headers"
|
||||
case Uncles:
|
||||
return "uncles"
|
||||
case Transactions:
|
||||
return "transactions"
|
||||
case Receipts:
|
||||
return "receipts"
|
||||
case State:
|
||||
return "state"
|
||||
case Storage:
|
||||
return "storage"
|
||||
default:
|
||||
return "unknown"
|
||||
}
|
||||
}
|
||||
|
||||
// GenerateDataTypeFromString
|
||||
func GenerateDataTypeFromString(str string) (DataType, error) {
|
||||
switch strings.ToLower(str) {
|
||||
case "full", "f":
|
||||
return Full, nil
|
||||
case "headers", "header", "h":
|
||||
return Headers, nil
|
||||
case "uncles", "u":
|
||||
return Uncles, nil
|
||||
case "transactions", "transaction", "trxs", "txs", "trx", "tx", "t":
|
||||
return Transactions, nil
|
||||
case "receipts", "receipt", "rcts", "rct", "r":
|
||||
return Receipts, nil
|
||||
case "state":
|
||||
return State, nil
|
||||
case "storage":
|
||||
return Storage, nil
|
||||
default:
|
||||
return UnknownDataType, fmt.Errorf("unrecognized resync type: %s", str)
|
||||
}
|
||||
}
|
||||
|
||||
func SupportedDataType(d DataType, c ChainType) (bool, error) {
|
||||
switch c {
|
||||
case Ethereum:
|
||||
switch d {
|
||||
case Full:
|
||||
return true, nil
|
||||
case Headers:
|
||||
return true, nil
|
||||
case Uncles:
|
||||
return true, nil
|
||||
case Transactions:
|
||||
return true, nil
|
||||
case Receipts:
|
||||
return true, nil
|
||||
case State:
|
||||
return true, nil
|
||||
case Storage:
|
||||
return true, nil
|
||||
default:
|
||||
return true, nil
|
||||
}
|
||||
case Bitcoin:
|
||||
switch d {
|
||||
case Full:
|
||||
return true, nil
|
||||
case Headers:
|
||||
return true, nil
|
||||
case Uncles:
|
||||
return false, nil
|
||||
case Transactions:
|
||||
return true, nil
|
||||
case Receipts:
|
||||
return false, nil
|
||||
case State:
|
||||
return false, nil
|
||||
case Storage:
|
||||
return false, nil
|
||||
default:
|
||||
return false, nil
|
||||
}
|
||||
case Omni:
|
||||
switch d {
|
||||
case Full:
|
||||
return false, nil
|
||||
case Headers:
|
||||
return false, nil
|
||||
case Uncles:
|
||||
return false, nil
|
||||
case Transactions:
|
||||
return false, nil
|
||||
case Receipts:
|
||||
return false, nil
|
||||
case State:
|
||||
return false, nil
|
||||
case Storage:
|
||||
return false, nil
|
||||
default:
|
||||
return false, nil
|
||||
}
|
||||
default:
|
||||
return false, fmt.Errorf("unrecognized chain type %s", c.String())
|
||||
}
|
||||
}
|
||||
@@ -1,83 +0,0 @@
|
||||
// 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 shared
|
||||
|
||||
import (
|
||||
"math/big"
|
||||
)
|
||||
|
||||
// PayloadStreamer streams chain-specific payloads to the provided channel
|
||||
type PayloadStreamer interface {
|
||||
Stream(payloadChan chan RawChainData) (ClientSubscription, error)
|
||||
}
|
||||
|
||||
// PayloadFetcher fetches chain-specific payloads
|
||||
type PayloadFetcher interface {
|
||||
FetchAt(blockHeights []uint64) ([]RawChainData, error)
|
||||
}
|
||||
|
||||
// PayloadConverter converts chain-specific payloads into IPLD payloads for publishing
|
||||
type PayloadConverter interface {
|
||||
Convert(payload RawChainData) (ConvertedData, error)
|
||||
}
|
||||
|
||||
// IPLDPublisher publishes IPLD payloads and returns a CID payload for indexing
|
||||
type IPLDPublisher interface {
|
||||
Publish(payload ConvertedData) error
|
||||
}
|
||||
|
||||
// ResponseFilterer applies a filter to an IPLD payload to return a subscription response packet
|
||||
type ResponseFilterer interface {
|
||||
Filter(filter SubscriptionSettings, payload ConvertedData) (response IPLDs, err error)
|
||||
}
|
||||
|
||||
// CIDRetriever retrieves cids according to a provided filter and returns a CID wrapper
|
||||
type CIDRetriever interface {
|
||||
Retrieve(filter SubscriptionSettings, blockNumber int64) ([]CIDsForFetching, bool, error)
|
||||
RetrieveFirstBlockNumber() (int64, error)
|
||||
RetrieveLastBlockNumber() (int64, error)
|
||||
RetrieveGapsInData(validationLevel int) ([]Gap, error)
|
||||
}
|
||||
|
||||
// IPLDFetcher uses a CID wrapper to fetch an IPLD wrapper
|
||||
type IPLDFetcher interface {
|
||||
Fetch(cids CIDsForFetching) (IPLDs, error)
|
||||
}
|
||||
|
||||
// ClientSubscription is a general interface for chain data subscriptions
|
||||
type ClientSubscription interface {
|
||||
Err() <-chan error
|
||||
Unsubscribe()
|
||||
}
|
||||
|
||||
// Cleaner is for cleaning out data from the cache within the given ranges
|
||||
type Cleaner interface {
|
||||
Clean(rngs [][2]uint64, t DataType) error
|
||||
ResetValidation(rngs [][2]uint64) error
|
||||
}
|
||||
|
||||
// SubscriptionSettings is the interface every subscription filter type needs to satisfy, no matter the chain
|
||||
// Further specifics of the underlying filter type depend on the internal needs of the types
|
||||
// which satisfy the ResponseFilterer and CIDRetriever interfaces for a specific chain
|
||||
// The underlying type needs to be rlp serializable
|
||||
type SubscriptionSettings interface {
|
||||
StartingBlock() *big.Int
|
||||
EndingBlock() *big.Int
|
||||
ChainType() ChainType
|
||||
HistoricalData() bool
|
||||
HistoricalDataOnly() bool
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
// 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 shared
|
||||
|
||||
// Very loose interface types for generic processing of different blockchains
|
||||
// TODO: split different blockchain support into separate repos
|
||||
|
||||
// These types serve as very loose wrappers around a generic underlying interface{}
|
||||
type RawChainData interface{}
|
||||
|
||||
// The concrete type underneath StreamedIPLDs should not be a pointer
|
||||
type ConvertedData interface {
|
||||
Height() int64
|
||||
}
|
||||
|
||||
type CIDsForIndexing interface{}
|
||||
|
||||
type CIDsForFetching interface{}
|
||||
|
||||
type IPLDs interface {
|
||||
Height() int64
|
||||
}
|
||||
|
||||
type Gap struct {
|
||||
Start uint64
|
||||
Stop uint64
|
||||
}
|
||||
Reference in New Issue
Block a user