Add support for never-ending transformer

This commit is contained in:
Edvard 2018-11-09 11:55:43 +01:00 committed by Rob Mulholand
parent 82fd73ba3f
commit 8f4648a9e3
31 changed files with 50 additions and 42 deletions

View File

@ -27,5 +27,5 @@ var BiteConfig = shared.TransformerConfig{
ContractAbi: constants.CatABI, ContractAbi: constants.CatABI,
Topic: constants.BiteSignature, Topic: constants.BiteSignature,
StartingBlockNumber: 0, StartingBlockNumber: 0,
EndingBlockNumber: 10000000, EndingBlockNumber: -1,
} }

View File

@ -25,5 +25,5 @@ var CatFileChopLumpConfig = shared.TransformerConfig{
ContractAbi: constants.CatABI, ContractAbi: constants.CatABI,
Topic: constants.CatFileChopLumpSignature, Topic: constants.CatFileChopLumpSignature,
StartingBlockNumber: 0, StartingBlockNumber: 0,
EndingBlockNumber: 10000000, EndingBlockNumber: -1,
} }

View File

@ -25,5 +25,5 @@ var CatFileFlipConfig = shared.TransformerConfig{
ContractAbi: constants.CatABI, ContractAbi: constants.CatABI,
Topic: constants.CatFileFlipSignature, Topic: constants.CatFileFlipSignature,
StartingBlockNumber: 0, StartingBlockNumber: 0,
EndingBlockNumber: 10000000, EndingBlockNumber: -1,
} }

View File

@ -25,5 +25,5 @@ var CatFilePitVowConfig = shared.TransformerConfig{
ContractAbi: constants.CatABI, ContractAbi: constants.CatABI,
Topic: constants.CatFilePitVowSignature, Topic: constants.CatFilePitVowSignature,
StartingBlockNumber: 0, StartingBlockNumber: 0,
EndingBlockNumber: 10000000, EndingBlockNumber: -1,
} }

View File

@ -25,5 +25,5 @@ var DealConfig = shared.TransformerConfig{
ContractAbi: constants.FlipperABI, ContractAbi: constants.FlipperABI,
Topic: constants.DealSignature, Topic: constants.DealSignature,
StartingBlockNumber: 0, StartingBlockNumber: 0,
EndingBlockNumber: 10000000, EndingBlockNumber: -1,
} }

View File

@ -25,5 +25,5 @@ var DentConfig = shared.TransformerConfig{
ContractAbi: constants.FlipperABI, ContractAbi: constants.FlipperABI,
Topic: constants.DentFunctionSignature, Topic: constants.DentFunctionSignature,
StartingBlockNumber: 0, StartingBlockNumber: 0,
EndingBlockNumber: 10000000, EndingBlockNumber: -1,
} }

View File

@ -25,5 +25,5 @@ var DripDripConfig = shared.TransformerConfig{
ContractAbi: constants.DripABI, ContractAbi: constants.DripABI,
Topic: constants.DripDripSignature, Topic: constants.DripDripSignature,
StartingBlockNumber: 0, StartingBlockNumber: 0,
EndingBlockNumber: 10000000, EndingBlockNumber: -1,
} }

View File

@ -25,5 +25,5 @@ var DripFileIlkConfig = shared.TransformerConfig{
ContractAbi: constants.DripABI, ContractAbi: constants.DripABI,
Topic: constants.DripFileIlkSignature, Topic: constants.DripFileIlkSignature,
StartingBlockNumber: 0, StartingBlockNumber: 0,
EndingBlockNumber: 10000000, EndingBlockNumber: -1,
} }

View File

@ -25,5 +25,5 @@ var DripFileRepoConfig = shared.TransformerConfig{
ContractAbi: constants.DripABI, ContractAbi: constants.DripABI,
Topic: constants.DripFileRepoSignature, Topic: constants.DripFileRepoSignature,
StartingBlockNumber: 0, StartingBlockNumber: 0,
EndingBlockNumber: 10000000, EndingBlockNumber: -1,
} }

View File

@ -25,5 +25,5 @@ var DripFileVowConfig = shared.TransformerConfig{
ContractAbi: constants.DripABI, ContractAbi: constants.DripABI,
Topic: constants.DripFileVowSignature, Topic: constants.DripFileVowSignature,
StartingBlockNumber: 0, StartingBlockNumber: 0,
EndingBlockNumber: 10000000, EndingBlockNumber: -1,
} }

View File

@ -25,5 +25,5 @@ var FlapKickConfig = shared.TransformerConfig{
ContractAbi: constants.FlapperABI, ContractAbi: constants.FlapperABI,
Topic: constants.FlapKickSignature, Topic: constants.FlapKickSignature,
StartingBlockNumber: 0, StartingBlockNumber: 0,
EndingBlockNumber: 10000000, EndingBlockNumber: -1,
} }

View File

@ -25,5 +25,5 @@ var FlipKickConfig = shared.TransformerConfig{
ContractAbi: constants.FlipperABI, ContractAbi: constants.FlipperABI,
Topic: constants.FlipKickSignature, Topic: constants.FlipKickSignature,
StartingBlockNumber: 0, StartingBlockNumber: 0,
EndingBlockNumber: 10000000, EndingBlockNumber: -1,
} }

View File

@ -25,5 +25,5 @@ var Config = shared.TransformerConfig{
ContractAbi: constants.FlopperABI, ContractAbi: constants.FlopperABI,
Topic: constants.FlopKickSignature, Topic: constants.FlopKickSignature,
StartingBlockNumber: 0, StartingBlockNumber: 0,
EndingBlockNumber: 10000000, EndingBlockNumber: -1,
} }

View File

@ -25,5 +25,5 @@ var FrobConfig = shared.TransformerConfig{
ContractAbi: constants.PitABI, ContractAbi: constants.PitABI,
Topic: constants.FrobSignature, Topic: constants.FrobSignature,
StartingBlockNumber: 0, StartingBlockNumber: 0,
EndingBlockNumber: 10000000, EndingBlockNumber: -1,
} }

View File

@ -25,5 +25,5 @@ var DebtCeilingFileConfig = shared.TransformerConfig{
ContractAbi: constants.PitABI, ContractAbi: constants.PitABI,
Topic: constants.PitFileDebtCeilingSignature, Topic: constants.PitFileDebtCeilingSignature,
StartingBlockNumber: 0, StartingBlockNumber: 0,
EndingBlockNumber: 10000000, EndingBlockNumber: -1,
} }

View File

@ -25,5 +25,5 @@ var IlkFileConfig = shared.TransformerConfig{
ContractAbi: constants.PitABI, ContractAbi: constants.PitABI,
Topic: constants.PitFileIlkSignature, Topic: constants.PitFileIlkSignature,
StartingBlockNumber: 0, StartingBlockNumber: 0,
EndingBlockNumber: 10000000, EndingBlockNumber: -1,
} }

View File

@ -25,5 +25,5 @@ var StabilityFeeFileConfig = shared.TransformerConfig{
ContractAbi: constants.PitABI, ContractAbi: constants.PitABI,
Topic: constants.PitFileStabilityFeeSignature, Topic: constants.PitFileStabilityFeeSignature,
StartingBlockNumber: 0, StartingBlockNumber: 0,
EndingBlockNumber: 10000000, EndingBlockNumber: -1,
} }

View File

@ -29,5 +29,5 @@ var PriceFeedConfig = shared.TransformerConfig{
ContractAbi: constants.MedianizerABI, ContractAbi: constants.MedianizerABI,
Topic: constants.LogValueSignature, Topic: constants.LogValueSignature,
StartingBlockNumber: 0, StartingBlockNumber: 0,
EndingBlockNumber: 10000000, EndingBlockNumber: -1,
} }

View File

@ -55,17 +55,25 @@ func MarkHeaderCheckedInTransaction(headerID int64, tx *sql.Tx, checkedHeadersCo
func MissingHeaders(startingBlockNumber, endingBlockNumber int64, db *postgres.DB, checkedHeadersColumn string) ([]core.Header, error) { func MissingHeaders(startingBlockNumber, endingBlockNumber int64, db *postgres.DB, checkedHeadersColumn string) ([]core.Header, error) {
var result []core.Header var result []core.Header
err := db.Select( var query string
&result, var err error
`SELECT headers.id, headers.block_number FROM headers
LEFT JOIN checked_headers on headers.id = header_id if endingBlockNumber == -1 {
WHERE (header_id ISNULL OR `+checkedHeadersColumn+` IS FALSE) query = `SELECT headers.id, headers.block_number FROM headers
AND headers.block_number >= $1 LEFT JOIN checked_headers on headers.id = header_id
AND headers.block_number <= $2 WHERE (header_id ISNULL OR ` + checkedHeadersColumn + ` IS FALSE)
AND headers.eth_node_fingerprint = $3`, AND headers.block_number >= $1
startingBlockNumber, AND headers.eth_node_fingerprint = $2`
endingBlockNumber, err = db.Select(&result, query, startingBlockNumber, db.Node.ID)
db.Node.ID, } else {
) query = `SELECT headers.id, headers.block_number FROM headers
LEFT JOIN checked_headers on headers.id = header_id
WHERE (header_id ISNULL OR ` + checkedHeadersColumn + ` IS FALSE)
AND headers.block_number >= $1
AND headers.block_number <= $2
AND headers.eth_node_fingerprint = $3`
err = db.Select(&result, query, startingBlockNumber, endingBlockNumber, db.Node.ID)
}
return result, err return result, err
} }

View File

@ -33,7 +33,7 @@ type TransformerConfig struct {
ContractAbi string ContractAbi string
Topic string Topic string
StartingBlockNumber int64 StartingBlockNumber int64
EndingBlockNumber int64 EndingBlockNumber int64 // Set -1 for indefinite transformer
} }
func HexToInt64(byteString string) int64 { func HexToInt64(byteString string) int64 {

View File

@ -25,5 +25,5 @@ var TendConfig = shared.TransformerConfig{
ContractAbi: constants.FlipperABI, ContractAbi: constants.FlipperABI,
Topic: constants.TendFunctionSignature, Topic: constants.TendFunctionSignature,
StartingBlockNumber: 0, StartingBlockNumber: 0,
EndingBlockNumber: 10000000, EndingBlockNumber: -1,
} }

View File

@ -11,5 +11,5 @@ var VatFluxConfig = shared.TransformerConfig{
ContractAbi: constants.VatABI, ContractAbi: constants.VatABI,
Topic: constants.VatFluxSignature, Topic: constants.VatFluxSignature,
StartingBlockNumber: 0, StartingBlockNumber: 0,
EndingBlockNumber: 10000000, EndingBlockNumber: -1,
} }

View File

@ -25,5 +25,5 @@ var VatFoldConfig = shared.TransformerConfig{
ContractAbi: constants.VatABI, ContractAbi: constants.VatABI,
Topic: constants.VatFoldSignature, Topic: constants.VatFoldSignature,
StartingBlockNumber: 0, StartingBlockNumber: 0,
EndingBlockNumber: 10000000, EndingBlockNumber: -1,
} }

View File

@ -11,5 +11,5 @@ var VatGrabConfig = shared.TransformerConfig{
ContractAbi: constants.VatABI, ContractAbi: constants.VatABI,
Topic: constants.VatGrabSignature, Topic: constants.VatGrabSignature,
StartingBlockNumber: 0, StartingBlockNumber: 0,
EndingBlockNumber: 10000000, EndingBlockNumber: -1,
} }

View File

@ -25,5 +25,5 @@ var VatHealConfig = shared.TransformerConfig{
ContractAbi: constants.VatABI, ContractAbi: constants.VatABI,
Topic: constants.VatHealSignature, Topic: constants.VatHealSignature,
StartingBlockNumber: 0, StartingBlockNumber: 0,
EndingBlockNumber: 10000000, EndingBlockNumber: -1,
} }

View File

@ -25,5 +25,5 @@ var VatInitConfig = shared.TransformerConfig{
ContractAbi: constants.VatABI, ContractAbi: constants.VatABI,
Topic: constants.VatInitSignature, Topic: constants.VatInitSignature,
StartingBlockNumber: 0, StartingBlockNumber: 0,
EndingBlockNumber: 10000000, EndingBlockNumber: -1,
} }

View File

@ -25,5 +25,5 @@ var VatMoveConfig = shared.TransformerConfig{
ContractAbi: constants.VatABI, ContractAbi: constants.VatABI,
Topic: constants.VatMoveSignature, Topic: constants.VatMoveSignature,
StartingBlockNumber: 0, StartingBlockNumber: 0,
EndingBlockNumber: 10000000, EndingBlockNumber: -1,
} }

View File

@ -11,5 +11,5 @@ var VatSlipConfig = shared.TransformerConfig{
ContractAbi: constants.VatABI, ContractAbi: constants.VatABI,
Topic: constants.VatSlipSignature, Topic: constants.VatSlipSignature,
StartingBlockNumber: 0, StartingBlockNumber: 0,
EndingBlockNumber: 10000000, EndingBlockNumber: -1,
} }

View File

@ -11,5 +11,5 @@ var VatTollConfig = shared.TransformerConfig{
ContractAbi: constants.VatABI, ContractAbi: constants.VatABI,
Topic: constants.VatTollSignature, Topic: constants.VatTollSignature,
StartingBlockNumber: 0, StartingBlockNumber: 0,
EndingBlockNumber: 10000000, EndingBlockNumber: -1,
} }

View File

@ -11,5 +11,5 @@ var VatTuneConfig = shared.TransformerConfig{
ContractAbi: constants.VatABI, ContractAbi: constants.VatABI,
Topic: constants.VatTuneSignature, Topic: constants.VatTuneSignature,
StartingBlockNumber: 0, StartingBlockNumber: 0,
EndingBlockNumber: 10000000, EndingBlockNumber: -1,
} }

View File

@ -25,5 +25,5 @@ var VowFlogConfig = shared.TransformerConfig{
ContractAbi: constants.VowABI, ContractAbi: constants.VowABI,
Topic: constants.VowFlogSignature, Topic: constants.VowFlogSignature,
StartingBlockNumber: 0, StartingBlockNumber: 0,
EndingBlockNumber: 10000000, EndingBlockNumber: -1,
} }