Initial plugin implementation

* refactor packages, flags, subscriptions
* DRY refactor builder tests
* use mockgen to generate mocks
* update README
* MODE=statediff no longer needed for unit tests
* simplify func names, clean up metrics
* move write params to service field
* sql indexer: confirm quit after ipld cache reset
  prevents negative waitgroup panic
* don't let TotalDifficulty become nil
* use forked plugeth, plugeth-utils for now
This commit is contained in:
2023-07-14 12:56:36 +08:00
parent bb00c46735
commit ebc2eb37e7
89 changed files with 3742 additions and 3160 deletions
+13 -2
View File
@@ -28,7 +28,7 @@ const (
POSTGRES DBType = "Postgres"
DUMP DBType = "Dump"
FILE DBType = "File"
UNKNOWN DBType = "Unknown"
INVALID DBType = "Invalid"
)
// ResolveDBType resolves a DBType from a provided string
@@ -41,6 +41,17 @@ func ResolveDBType(str string) (DBType, error) {
case "file", "f", "fs":
return FILE, nil
default:
return UNKNOWN, fmt.Errorf("unrecognized db type string: %s", str)
return INVALID, fmt.Errorf("unrecognized db type string: %s", str)
}
}
// Set satisfies flag.Value
func (dbt *DBType) Set(v string) (err error) {
*dbt, err = ResolveDBType(v)
return
}
// String satisfies flag.Value
func (dbt *DBType) String() string {
return strings.ToLower(string(*dbt))
}
+3 -3
View File
@@ -25,13 +25,13 @@ func HandleZeroAddrPointer(to *common.Address) string {
if to == nil {
return ""
}
return to.Hex()
return to.String()
}
// HandleZeroAddr will return an empty string for a 0 value address
func HandleZeroAddr(to common.Address) string {
if to.Hex() == "0x0000000000000000000000000000000000000000" {
if to == (common.Address{}) {
return ""
}
return to.Hex()
return to.String()
}
+1 -1
View File
@@ -5,7 +5,7 @@ import (
"github.com/stretchr/testify/require"
. "github.com/ethereum/go-ethereum/statediff/indexer/shared/schema"
. "github.com/cerc-io/plugeth-statediff/indexer/shared/schema"
)
var testHeaderTable = Table{