Sync only missing blocks on cold import

= Add eth_node_fingerprint to block that can be imitated by both hot and cold imports
- Only sync missing blocks (blocks that are missing or don't share a fingerprint) on cold import
- Set block is_final status after import
This commit is contained in:
Rob Mulholand
2018-05-07 16:38:04 -05:00
parent 5a5e08bd13
commit d5c2ab33fc
31 changed files with 616 additions and 171 deletions
+13
View File
@@ -0,0 +1,13 @@
package crypto_test
import (
"testing"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
func TestCrypto(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "Crypto Suite")
}
+21
View File
@@ -0,0 +1,21 @@
package crypto
import (
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/p2p/discover"
)
type PublicKeyParser interface {
ParsePublicKey(privateKey string) (string, error)
}
type EthPublicKeyParser struct{}
func (EthPublicKeyParser) ParsePublicKey(privateKey string) (string, error) {
np, err := crypto.HexToECDSA(privateKey)
if err != nil {
return "", err
}
pubKey := discover.PubkeyID(&np.PublicKey)
return pubKey.String(), nil
}
+19
View File
@@ -0,0 +1,19 @@
package crypto_test
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/vulcanize/vulcanizedb/pkg/crypto"
)
var _ = Describe("Public key parser", func() {
It("parses public key from private key", func() {
privKey := "0000000000000000000000000000000000000000000000000000000000000001"
parser := crypto.EthPublicKeyParser{}
pubKey, err := parser.ParsePublicKey(privKey)
Expect(err).NotTo(HaveOccurred())
Expect(pubKey).To(Equal("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"))
})
})