Block categorization (#110)

* Add block categorization (is_final=)

* Add godo task for vulcanizeDB (Example of how everything could work together)

* Add unique constraint on block_number and node

* Add index on block_id for transactions_table

* Add node_id index on blocks table

* Sort transactions returned from FindBlock by tx_hash

* lowercase tx_to, tx_from like etherscan
This commit is contained in:
Matt K
2017-12-20 14:06:22 -06:00
committed by GitHub
parent 266c9587c8
commit 24bc83a448
26 changed files with 239 additions and 86 deletions
+4 -2
View File
@@ -1,6 +1,8 @@
package geth
import (
"strings"
"github.com/8thlight/vulcanizedb/pkg/core"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
@@ -39,8 +41,8 @@ func gethTransToCoreTrans(transaction *types.Transaction, from *common.Address)
Hash: transaction.Hash().Hex(),
Data: transaction.Data(),
Nonce: transaction.Nonce(),
To: addressToHex(transaction.To()),
From: addressToHex(from),
To: strings.ToLower(addressToHex(transaction.To())),
From: strings.ToLower(addressToHex(from)),
GasLimit: transaction.Gas().Int64(),
GasPrice: transaction.GasPrice().Int64(),
Value: transaction.Value().Int64(),
@@ -53,6 +53,7 @@ var _ = Describe("Conversion of GethBlock to core.Block", func() {
Expect(gethBlock.Size).To(Equal(block.Size().Int64()))
Expect(gethBlock.Time).To(Equal(time))
Expect(gethBlock.UncleHash).To(Equal(block.UncleHash().Hex()))
Expect(gethBlock.IsFinal).To(BeFalse())
})
Describe("the converted transations", func() {
+2 -2
View File
@@ -25,7 +25,7 @@ type GethBlockchain struct {
func (blockchain *GethBlockchain) GetLogs(contract core.Contract, blockNumber *big.Int) ([]core.Log, error) {
if blockNumber == nil {
blockNumber = blockchain.latestBlock()
blockNumber = blockchain.LastBlock()
}
contractAddress := common.HexToAddress(contract.Hash)
fc := ethereum.FilterQuery{
@@ -80,7 +80,7 @@ func (blockchain *GethBlockchain) StopListening() {
blockchain.newHeadSubscription.Unsubscribe()
}
func (blockchain *GethBlockchain) latestBlock() *big.Int {
func (blockchain *GethBlockchain) LastBlock() *big.Int {
block, _ := blockchain.client.HeaderByNumber(context.Background(), nil)
return block.Number
}