Prefer all caps for initialisms and acronyms
This commit is contained in:
parent
eba868ff00
commit
e1236b4072
@ -187,7 +187,7 @@ func composeAndExecute() {
|
|||||||
rpcClient, _ := getClients()
|
rpcClient, _ := getClients()
|
||||||
stateDiffStreamer := streamer.NewStateDiffStreamer(rpcClient)
|
stateDiffStreamer := streamer.NewStateDiffStreamer(rpcClient)
|
||||||
payloadChan := make(chan statediff.Payload)
|
payloadChan := make(chan statediff.Payload)
|
||||||
storageFetcher := fetcher.NewGethRpcStorageFetcher(&stateDiffStreamer, payloadChan)
|
storageFetcher := fetcher.NewGethRPCStorageFetcher(&stateDiffStreamer, payloadChan)
|
||||||
sw := watcher.NewStorageWatcher(storageFetcher, &db)
|
sw := watcher.NewStorageWatcher(storageFetcher, &db)
|
||||||
sw.AddTransformers(ethStorageInitializers)
|
sw.AddTransformers(ethStorageInitializers)
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
|
@ -131,7 +131,7 @@ func execute() {
|
|||||||
rpcClient, _ := getClients()
|
rpcClient, _ := getClients()
|
||||||
stateDiffStreamer := streamer.NewStateDiffStreamer(rpcClient)
|
stateDiffStreamer := streamer.NewStateDiffStreamer(rpcClient)
|
||||||
payloadChan := make(chan statediff.Payload)
|
payloadChan := make(chan statediff.Payload)
|
||||||
storageFetcher := fetcher.NewGethRpcStorageFetcher(&stateDiffStreamer, payloadChan)
|
storageFetcher := fetcher.NewGethRPCStorageFetcher(&stateDiffStreamer, payloadChan)
|
||||||
sw := watcher.NewStorageWatcher(storageFetcher, &db)
|
sw := watcher.NewStorageWatcher(storageFetcher, &db)
|
||||||
sw.AddTransformers(ethStorageInitializers)
|
sw.AddTransformers(ethStorageInitializers)
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
|
10
cmd/root.go
10
cmd/root.go
@ -159,18 +159,18 @@ func getBlockChain() *eth.BlockChain {
|
|||||||
rpcClient, ethClient := getClients()
|
rpcClient, ethClient := getClients()
|
||||||
vdbEthClient := client.NewEthClient(ethClient)
|
vdbEthClient := client.NewEthClient(ethClient)
|
||||||
vdbNode := node.MakeNode(rpcClient)
|
vdbNode := node.MakeNode(rpcClient)
|
||||||
transactionConverter := vRpc.NewRpcTransactionConverter(ethClient)
|
transactionConverter := vRpc.NewRPCTransactionConverter(ethClient)
|
||||||
return eth.NewBlockChain(vdbEthClient, rpcClient, vdbNode, transactionConverter)
|
return eth.NewBlockChain(vdbEthClient, rpcClient, vdbNode, transactionConverter)
|
||||||
}
|
}
|
||||||
|
|
||||||
func getClients() (client.RpcClient, *ethclient.Client) {
|
func getClients() (client.RPCClient, *ethclient.Client) {
|
||||||
rawRpcClient, err := rpc.Dial(ipc)
|
rawRPCClient, err := rpc.Dial(ipc)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
LogWithCommand.Fatal(err)
|
LogWithCommand.Fatal(err)
|
||||||
}
|
}
|
||||||
rpcClient := client.NewRpcClient(rawRpcClient, ipc)
|
rpcClient := client.NewRPCClient(rawRPCClient, ipc)
|
||||||
ethClient := ethclient.NewClient(rawRpcClient)
|
ethClient := ethclient.NewClient(rawRPCClient)
|
||||||
|
|
||||||
return rpcClient, ethClient
|
return rpcClient, ethClient
|
||||||
}
|
}
|
||||||
|
@ -32,13 +32,13 @@ import (
|
|||||||
var _ = Describe("Rewards calculations", func() {
|
var _ = Describe("Rewards calculations", func() {
|
||||||
|
|
||||||
It("calculates a block reward for a real block", func() {
|
It("calculates a block reward for a real block", func() {
|
||||||
rawRpcClient, err := rpc.Dial(test_config.TestClient.IPCPath)
|
rawRPCClient, err := rpc.Dial(test_config.TestClient.IPCPath)
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
rpcClient := client.NewRpcClient(rawRpcClient, test_config.TestClient.IPCPath)
|
rpcClient := client.NewRPCClient(rawRPCClient, test_config.TestClient.IPCPath)
|
||||||
ethClient := ethclient.NewClient(rawRpcClient)
|
ethClient := ethclient.NewClient(rawRPCClient)
|
||||||
blockChainClient := client.NewEthClient(ethClient)
|
blockChainClient := client.NewEthClient(ethClient)
|
||||||
node := node.MakeNode(rpcClient)
|
node := node.MakeNode(rpcClient)
|
||||||
transactionConverter := vRpc.NewRpcTransactionConverter(ethClient)
|
transactionConverter := vRpc.NewRPCTransactionConverter(ethClient)
|
||||||
blockChain := eth.NewBlockChain(blockChainClient, rpcClient, node, transactionConverter)
|
blockChain := eth.NewBlockChain(blockChainClient, rpcClient, node, transactionConverter)
|
||||||
block, err := blockChain.GetBlockByNumber(1071819)
|
block, err := blockChain.GetBlockByNumber(1071819)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
@ -46,13 +46,13 @@ var _ = Describe("Rewards calculations", func() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
It("calculates an uncle reward for a real block", func() {
|
It("calculates an uncle reward for a real block", func() {
|
||||||
rawRpcClient, err := rpc.Dial(test_config.TestClient.IPCPath)
|
rawRPCClient, err := rpc.Dial(test_config.TestClient.IPCPath)
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
rpcClient := client.NewRpcClient(rawRpcClient, test_config.TestClient.IPCPath)
|
rpcClient := client.NewRPCClient(rawRPCClient, test_config.TestClient.IPCPath)
|
||||||
ethClient := ethclient.NewClient(rawRpcClient)
|
ethClient := ethclient.NewClient(rawRPCClient)
|
||||||
blockChainClient := client.NewEthClient(ethClient)
|
blockChainClient := client.NewEthClient(ethClient)
|
||||||
node := node.MakeNode(rpcClient)
|
node := node.MakeNode(rpcClient)
|
||||||
transactionConverter := vRpc.NewRpcTransactionConverter(ethClient)
|
transactionConverter := vRpc.NewRPCTransactionConverter(ethClient)
|
||||||
blockChain := eth.NewBlockChain(blockChainClient, rpcClient, node, transactionConverter)
|
blockChain := eth.NewBlockChain(blockChainClient, rpcClient, node, transactionConverter)
|
||||||
block, err := blockChain.GetBlockByNumber(1071819)
|
block, err := blockChain.GetBlockByNumber(1071819)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
@ -49,13 +49,13 @@ var _ = Describe("Reading contracts", func() {
|
|||||||
},
|
},
|
||||||
Index: 19,
|
Index: 19,
|
||||||
Data: "0x0000000000000000000000000000000000000000000000000c7d713b49da0000"}
|
Data: "0x0000000000000000000000000000000000000000000000000c7d713b49da0000"}
|
||||||
rawRpcClient, err := rpc.Dial(test_config.TestClient.IPCPath)
|
rawRPCClient, err := rpc.Dial(test_config.TestClient.IPCPath)
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
rpcClient := client.NewRpcClient(rawRpcClient, test_config.TestClient.IPCPath)
|
rpcClient := client.NewRPCClient(rawRPCClient, test_config.TestClient.IPCPath)
|
||||||
ethClient := ethclient.NewClient(rawRpcClient)
|
ethClient := ethclient.NewClient(rawRPCClient)
|
||||||
blockChainClient := client.NewEthClient(ethClient)
|
blockChainClient := client.NewEthClient(ethClient)
|
||||||
node := node.MakeNode(rpcClient)
|
node := node.MakeNode(rpcClient)
|
||||||
transactionConverter := rpc2.NewRpcTransactionConverter(ethClient)
|
transactionConverter := rpc2.NewRPCTransactionConverter(ethClient)
|
||||||
blockChain := eth.NewBlockChain(blockChainClient, rpcClient, node, transactionConverter)
|
blockChain := eth.NewBlockChain(blockChainClient, rpcClient, node, transactionConverter)
|
||||||
contract := testing.SampleContract()
|
contract := testing.SampleContract()
|
||||||
|
|
||||||
@ -67,13 +67,13 @@ var _ = Describe("Reading contracts", func() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
It("returns and empty log array when no events for a given block / contract combo", func() {
|
It("returns and empty log array when no events for a given block / contract combo", func() {
|
||||||
rawRpcClient, err := rpc.Dial(test_config.TestClient.IPCPath)
|
rawRPCClient, err := rpc.Dial(test_config.TestClient.IPCPath)
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
rpcClient := client.NewRpcClient(rawRpcClient, test_config.TestClient.IPCPath)
|
rpcClient := client.NewRPCClient(rawRPCClient, test_config.TestClient.IPCPath)
|
||||||
ethClient := ethclient.NewClient(rawRpcClient)
|
ethClient := ethclient.NewClient(rawRPCClient)
|
||||||
blockChainClient := client.NewEthClient(ethClient)
|
blockChainClient := client.NewEthClient(ethClient)
|
||||||
node := node.MakeNode(rpcClient)
|
node := node.MakeNode(rpcClient)
|
||||||
transactionConverter := rpc2.NewRpcTransactionConverter(ethClient)
|
transactionConverter := rpc2.NewRPCTransactionConverter(ethClient)
|
||||||
blockChain := eth.NewBlockChain(blockChainClient, rpcClient, node, transactionConverter)
|
blockChain := eth.NewBlockChain(blockChainClient, rpcClient, node, transactionConverter)
|
||||||
|
|
||||||
logs, err := blockChain.GetFullSyncLogs(core.Contract{Hash: "0x123"}, big.NewInt(4703824), nil)
|
logs, err := blockChain.GetFullSyncLogs(core.Contract{Hash: "0x123"}, big.NewInt(4703824), nil)
|
||||||
@ -85,13 +85,13 @@ var _ = Describe("Reading contracts", func() {
|
|||||||
|
|
||||||
Describe("Fetching Contract data", func() {
|
Describe("Fetching Contract data", func() {
|
||||||
It("returns the correct attribute for a real contract", func() {
|
It("returns the correct attribute for a real contract", func() {
|
||||||
rawRpcClient, err := rpc.Dial(test_config.TestClient.IPCPath)
|
rawRPCClient, err := rpc.Dial(test_config.TestClient.IPCPath)
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
rpcClient := client.NewRpcClient(rawRpcClient, test_config.TestClient.IPCPath)
|
rpcClient := client.NewRPCClient(rawRPCClient, test_config.TestClient.IPCPath)
|
||||||
ethClient := ethclient.NewClient(rawRpcClient)
|
ethClient := ethclient.NewClient(rawRPCClient)
|
||||||
blockChainClient := client.NewEthClient(ethClient)
|
blockChainClient := client.NewEthClient(ethClient)
|
||||||
node := node.MakeNode(rpcClient)
|
node := node.MakeNode(rpcClient)
|
||||||
transactionConverter := rpc2.NewRpcTransactionConverter(ethClient)
|
transactionConverter := rpc2.NewRPCTransactionConverter(ethClient)
|
||||||
blockChain := eth.NewBlockChain(blockChainClient, rpcClient, node, transactionConverter)
|
blockChain := eth.NewBlockChain(blockChainClient, rpcClient, node, transactionConverter)
|
||||||
|
|
||||||
contract := testing.SampleContract()
|
contract := testing.SampleContract()
|
||||||
|
@ -37,13 +37,13 @@ var _ = Describe("Reading from the Geth blockchain", func() {
|
|||||||
var blockChain *eth.BlockChain
|
var blockChain *eth.BlockChain
|
||||||
|
|
||||||
BeforeEach(func() {
|
BeforeEach(func() {
|
||||||
rawRpcClient, err := rpc.Dial(test_config.TestClient.IPCPath)
|
rawRPCClient, err := rpc.Dial(test_config.TestClient.IPCPath)
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
rpcClient := client.NewRpcClient(rawRpcClient, test_config.TestClient.IPCPath)
|
rpcClient := client.NewRPCClient(rawRPCClient, test_config.TestClient.IPCPath)
|
||||||
ethClient := ethclient.NewClient(rawRpcClient)
|
ethClient := ethclient.NewClient(rawRPCClient)
|
||||||
blockChainClient := client.NewEthClient(ethClient)
|
blockChainClient := client.NewEthClient(ethClient)
|
||||||
node := node.MakeNode(rpcClient)
|
node := node.MakeNode(rpcClient)
|
||||||
transactionConverter := rpc2.NewRpcTransactionConverter(ethClient)
|
transactionConverter := rpc2.NewRPCTransactionConverter(ethClient)
|
||||||
blockChain = eth.NewBlockChain(blockChainClient, rpcClient, node, transactionConverter)
|
blockChain = eth.NewBlockChain(blockChainClient, rpcClient, node, transactionConverter)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -48,11 +48,11 @@ var _ = Describe("Transformer", func() {
|
|||||||
Config: config,
|
Config: config,
|
||||||
}.NewTransformer(nil)
|
}.NewTransformer(nil)
|
||||||
|
|
||||||
headerOne = core.Header{Id: rand.Int63(), BlockNumber: rand.Int63()}
|
headerOne = core.Header{ID: rand.Int63(), BlockNumber: rand.Int63()}
|
||||||
|
|
||||||
logs = []core.HeaderSyncLog{{
|
logs = []core.HeaderSyncLog{{
|
||||||
ID: 0,
|
ID: 0,
|
||||||
HeaderID: headerOne.Id,
|
HeaderID: headerOne.ID,
|
||||||
Log: test_data.GenericTestLog(),
|
Log: test_data.GenericTestLog(),
|
||||||
Transformed: false,
|
Transformed: false,
|
||||||
}}
|
}}
|
||||||
|
@ -23,19 +23,19 @@ import (
|
|||||||
"github.com/vulcanize/vulcanizedb/libraries/shared/streamer"
|
"github.com/vulcanize/vulcanizedb/libraries/shared/streamer"
|
||||||
)
|
)
|
||||||
|
|
||||||
type GethRpcStorageFetcher struct {
|
type GethRPCStorageFetcher struct {
|
||||||
statediffPayloadChan chan statediff.Payload
|
statediffPayloadChan chan statediff.Payload
|
||||||
streamer streamer.Streamer
|
streamer streamer.Streamer
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewGethRpcStorageFetcher(streamer streamer.Streamer, statediffPayloadChan chan statediff.Payload) GethRpcStorageFetcher {
|
func NewGethRPCStorageFetcher(streamer streamer.Streamer, statediffPayloadChan chan statediff.Payload) GethRPCStorageFetcher {
|
||||||
return GethRpcStorageFetcher{
|
return GethRPCStorageFetcher{
|
||||||
statediffPayloadChan: statediffPayloadChan,
|
statediffPayloadChan: statediffPayloadChan,
|
||||||
streamer: streamer,
|
streamer: streamer,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (fetcher GethRpcStorageFetcher) FetchStorageDiffs(out chan<- utils.StorageDiff, errs chan<- error) {
|
func (fetcher GethRPCStorageFetcher) FetchStorageDiffs(out chan<- utils.StorageDiff, errs chan<- error) {
|
||||||
ethStatediffPayloadChan := fetcher.statediffPayloadChan
|
ethStatediffPayloadChan := fetcher.statediffPayloadChan
|
||||||
clientSubscription, clientSubErr := fetcher.streamer.Stream(ethStatediffPayloadChan)
|
clientSubscription, clientSubErr := fetcher.streamer.Stream(ethStatediffPayloadChan)
|
||||||
if clientSubErr != nil {
|
if clientSubErr != nil {
|
||||||
|
@ -57,14 +57,14 @@ func (streamer *MockStoragediffStreamer) SetPayloads(payloads []statediff.Payloa
|
|||||||
var _ = Describe("Geth RPC Storage Fetcher", func() {
|
var _ = Describe("Geth RPC Storage Fetcher", func() {
|
||||||
var streamer MockStoragediffStreamer
|
var streamer MockStoragediffStreamer
|
||||||
var statediffPayloadChan chan statediff.Payload
|
var statediffPayloadChan chan statediff.Payload
|
||||||
var statediffFetcher fetcher.GethRpcStorageFetcher
|
var statediffFetcher fetcher.GethRPCStorageFetcher
|
||||||
var storagediffChan chan utils.StorageDiff
|
var storagediffChan chan utils.StorageDiff
|
||||||
var errorChan chan error
|
var errorChan chan error
|
||||||
|
|
||||||
BeforeEach(func() {
|
BeforeEach(func() {
|
||||||
streamer = MockStoragediffStreamer{}
|
streamer = MockStoragediffStreamer{}
|
||||||
statediffPayloadChan = make(chan statediff.Payload, 1)
|
statediffPayloadChan = make(chan statediff.Payload, 1)
|
||||||
statediffFetcher = fetcher.NewGethRpcStorageFetcher(&streamer, statediffPayloadChan)
|
statediffFetcher = fetcher.NewGethRPCStorageFetcher(&streamer, statediffPayloadChan)
|
||||||
storagediffChan = make(chan utils.StorageDiff)
|
storagediffChan = make(chan utils.StorageDiff)
|
||||||
errorChan = make(chan error)
|
errorChan = make(chan error)
|
||||||
})
|
})
|
||||||
|
@ -93,20 +93,20 @@ func (extractor LogExtractor) ExtractLogs(recheckHeaders constants.TransformerEx
|
|||||||
}
|
}
|
||||||
|
|
||||||
if len(logs) > 0 {
|
if len(logs) > 0 {
|
||||||
transactionsSyncErr := extractor.Syncer.SyncTransactions(header.Id, logs)
|
transactionsSyncErr := extractor.Syncer.SyncTransactions(header.ID, logs)
|
||||||
if transactionsSyncErr != nil {
|
if transactionsSyncErr != nil {
|
||||||
logError("error syncing transactions: %s", transactionsSyncErr, header)
|
logError("error syncing transactions: %s", transactionsSyncErr, header)
|
||||||
return transactionsSyncErr
|
return transactionsSyncErr
|
||||||
}
|
}
|
||||||
|
|
||||||
createLogsErr := extractor.LogRepository.CreateHeaderSyncLogs(header.Id, logs)
|
createLogsErr := extractor.LogRepository.CreateHeaderSyncLogs(header.ID, logs)
|
||||||
if createLogsErr != nil {
|
if createLogsErr != nil {
|
||||||
logError("error persisting logs: %s", createLogsErr, header)
|
logError("error persisting logs: %s", createLogsErr, header)
|
||||||
return createLogsErr
|
return createLogsErr
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
markHeaderCheckedErr := extractor.CheckedHeadersRepository.MarkHeaderChecked(header.Id)
|
markHeaderCheckedErr := extractor.CheckedHeadersRepository.MarkHeaderChecked(header.ID)
|
||||||
if markHeaderCheckedErr != nil {
|
if markHeaderCheckedErr != nil {
|
||||||
logError("error marking header checked: %s", markHeaderCheckedErr, header)
|
logError("error marking header checked: %s", markHeaderCheckedErr, header)
|
||||||
return markHeaderCheckedErr
|
return markHeaderCheckedErr
|
||||||
@ -121,7 +121,7 @@ func earlierStartingBlockNumber(transformerBlock, watcherBlock int64) bool {
|
|||||||
|
|
||||||
func logError(description string, err error, header core.Header) {
|
func logError(description string, err error, header core.Header) {
|
||||||
logrus.WithFields(logrus.Fields{
|
logrus.WithFields(logrus.Fields{
|
||||||
"headerId": header.Id,
|
"headerId": header.ID,
|
||||||
"headerHash": header.Hash,
|
"headerHash": header.Hash,
|
||||||
"blockNumber": header.BlockNumber,
|
"blockNumber": header.BlockNumber,
|
||||||
}).Errorf(description, err.Error())
|
}).Errorf(description, err.Error())
|
||||||
|
@ -349,7 +349,7 @@ var _ = Describe("Log extractor", func() {
|
|||||||
addTransformerConfig(extractor)
|
addTransformerConfig(extractor)
|
||||||
mockCheckedHeadersRepository := &fakes.MockCheckedHeadersRepository{}
|
mockCheckedHeadersRepository := &fakes.MockCheckedHeadersRepository{}
|
||||||
headerID := rand.Int63()
|
headerID := rand.Int63()
|
||||||
mockCheckedHeadersRepository.UncheckedHeadersReturnHeaders = []core.Header{{Id: headerID}}
|
mockCheckedHeadersRepository.UncheckedHeadersReturnHeaders = []core.Header{{ID: headerID}}
|
||||||
extractor.CheckedHeadersRepository = mockCheckedHeadersRepository
|
extractor.CheckedHeadersRepository = mockCheckedHeadersRepository
|
||||||
|
|
||||||
err := extractor.ExtractLogs(constants.HeaderUnchecked)
|
err := extractor.ExtractLogs(constants.HeaderUnchecked)
|
||||||
@ -362,7 +362,7 @@ var _ = Describe("Log extractor", func() {
|
|||||||
addFetchedLog(extractor)
|
addFetchedLog(extractor)
|
||||||
addTransformerConfig(extractor)
|
addTransformerConfig(extractor)
|
||||||
mockCheckedHeadersRepository := &fakes.MockCheckedHeadersRepository{}
|
mockCheckedHeadersRepository := &fakes.MockCheckedHeadersRepository{}
|
||||||
mockCheckedHeadersRepository.UncheckedHeadersReturnHeaders = []core.Header{{Id: rand.Int63()}}
|
mockCheckedHeadersRepository.UncheckedHeadersReturnHeaders = []core.Header{{ID: rand.Int63()}}
|
||||||
mockCheckedHeadersRepository.MarkHeaderCheckedReturnError = fakes.FakeError
|
mockCheckedHeadersRepository.MarkHeaderCheckedReturnError = fakes.FakeError
|
||||||
extractor.CheckedHeadersRepository = mockCheckedHeadersRepository
|
extractor.CheckedHeadersRepository = mockCheckedHeadersRepository
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ type MockStorageQueue struct {
|
|||||||
AddError error
|
AddError error
|
||||||
AddPassedDiff utils.StorageDiff
|
AddPassedDiff utils.StorageDiff
|
||||||
DeleteErr error
|
DeleteErr error
|
||||||
DeletePassedId int
|
DeletePassedID int
|
||||||
GetAllErr error
|
GetAllErr error
|
||||||
DiffsToReturn []utils.StorageDiff
|
DiffsToReturn []utils.StorageDiff
|
||||||
}
|
}
|
||||||
@ -37,7 +37,7 @@ func (queue *MockStorageQueue) Add(diff utils.StorageDiff) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (queue *MockStorageQueue) Delete(id int) error {
|
func (queue *MockStorageQueue) Delete(id int) error {
|
||||||
queue.DeletePassedId = id
|
queue.DeletePassedID = id
|
||||||
return queue.DeleteErr
|
return queue.DeleteErr
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,23 +47,23 @@ func GetOrCreateAddress(db *postgres.DB, address string) (int64, error) {
|
|||||||
checksumAddress := getChecksumAddress(address)
|
checksumAddress := getChecksumAddress(address)
|
||||||
hashedAddress := utils.HexToKeccak256Hash(checksumAddress).Hex()
|
hashedAddress := utils.HexToKeccak256Hash(checksumAddress).Hex()
|
||||||
|
|
||||||
var addressId int64
|
var addressID int64
|
||||||
getOrCreateErr := db.Get(&addressId, getOrCreateAddressQuery, checksumAddress, hashedAddress)
|
getOrCreateErr := db.Get(&addressID, getOrCreateAddressQuery, checksumAddress, hashedAddress)
|
||||||
|
|
||||||
return addressId, getOrCreateErr
|
return addressID, getOrCreateErr
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetOrCreateAddressInTransaction(tx *sqlx.Tx, address string) (int64, error) {
|
func GetOrCreateAddressInTransaction(tx *sqlx.Tx, address string) (int64, error) {
|
||||||
checksumAddress := getChecksumAddress(address)
|
checksumAddress := getChecksumAddress(address)
|
||||||
hashedAddress := utils.HexToKeccak256Hash(checksumAddress).Hex()
|
hashedAddress := utils.HexToKeccak256Hash(checksumAddress).Hex()
|
||||||
|
|
||||||
var addressId int64
|
var addressID int64
|
||||||
getOrCreateErr := tx.Get(&addressId, getOrCreateAddressQuery, checksumAddress, hashedAddress)
|
getOrCreateErr := tx.Get(&addressID, getOrCreateAddressQuery, checksumAddress, hashedAddress)
|
||||||
|
|
||||||
return addressId, getOrCreateErr
|
return addressID, getOrCreateErr
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetAddressById(db *postgres.DB, id int64) (string, error) {
|
func GetAddressByID(db *postgres.DB, id int64) (string, error) {
|
||||||
var address string
|
var address string
|
||||||
getErr := db.Get(&address, `SELECT address FROM public.addresses WHERE id = $1`, id)
|
getErr := db.Get(&address, `SELECT address FROM public.addresses WHERE id = $1`, id)
|
||||||
return address, getErr
|
return address, getErr
|
||||||
|
@ -164,18 +164,18 @@ var _ = Describe("address lookup", func() {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
Describe("GetAddressById", func() {
|
Describe("GetAddressByID", func() {
|
||||||
It("gets and address by it's id", func() {
|
It("gets and address by it's id", func() {
|
||||||
addressId, createErr := repository.GetOrCreateAddress(db, address)
|
addressId, createErr := repository.GetOrCreateAddress(db, address)
|
||||||
Expect(createErr).NotTo(HaveOccurred())
|
Expect(createErr).NotTo(HaveOccurred())
|
||||||
|
|
||||||
actualAddress, getErr := repository.GetAddressById(db, addressId)
|
actualAddress, getErr := repository.GetAddressByID(db, addressId)
|
||||||
Expect(getErr).NotTo(HaveOccurred())
|
Expect(getErr).NotTo(HaveOccurred())
|
||||||
Expect(actualAddress).To(Equal(address))
|
Expect(actualAddress).To(Equal(address))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("returns an error if the id doesn't exist", func() {
|
It("returns an error if the id doesn't exist", func() {
|
||||||
_, getErr := repository.GetAddressById(db, 0)
|
_, getErr := repository.GetAddressByID(db, 0)
|
||||||
Expect(getErr).To(HaveOccurred())
|
Expect(getErr).To(HaveOccurred())
|
||||||
Expect(getErr).To(MatchError("sql: no rows in result set"))
|
Expect(getErr).To(MatchError("sql: no rows in result set"))
|
||||||
})
|
})
|
||||||
|
@ -72,7 +72,7 @@ var _ = Describe("Storage queue", func() {
|
|||||||
Expect(getErr).NotTo(HaveOccurred())
|
Expect(getErr).NotTo(HaveOccurred())
|
||||||
Expect(len(diffs)).To(Equal(1))
|
Expect(len(diffs)).To(Equal(1))
|
||||||
|
|
||||||
err := queue.Delete(diffs[0].Id)
|
err := queue.Delete(diffs[0].ID)
|
||||||
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
remainingRows, secondGetErr := queue.GetAll()
|
remainingRows, secondGetErr := queue.GetAll()
|
||||||
@ -97,13 +97,13 @@ var _ = Describe("Storage queue", func() {
|
|||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
Expect(len(diffs)).To(Equal(2))
|
Expect(len(diffs)).To(Equal(2))
|
||||||
Expect(diffs[0]).NotTo(Equal(diffs[1]))
|
Expect(diffs[0]).NotTo(Equal(diffs[1]))
|
||||||
Expect(diffs[0].Id).NotTo(BeZero())
|
Expect(diffs[0].ID).NotTo(BeZero())
|
||||||
Expect(diffs[0].HashedAddress).To(Or(Equal(diff.HashedAddress), Equal(diffTwo.HashedAddress)))
|
Expect(diffs[0].HashedAddress).To(Or(Equal(diff.HashedAddress), Equal(diffTwo.HashedAddress)))
|
||||||
Expect(diffs[0].BlockHash).To(Or(Equal(diff.BlockHash), Equal(diffTwo.BlockHash)))
|
Expect(diffs[0].BlockHash).To(Or(Equal(diff.BlockHash), Equal(diffTwo.BlockHash)))
|
||||||
Expect(diffs[0].BlockHeight).To(Or(Equal(diff.BlockHeight), Equal(diffTwo.BlockHeight)))
|
Expect(diffs[0].BlockHeight).To(Or(Equal(diff.BlockHeight), Equal(diffTwo.BlockHeight)))
|
||||||
Expect(diffs[0].StorageKey).To(Or(Equal(diff.StorageKey), Equal(diffTwo.StorageKey)))
|
Expect(diffs[0].StorageKey).To(Or(Equal(diff.StorageKey), Equal(diffTwo.StorageKey)))
|
||||||
Expect(diffs[0].StorageValue).To(Or(Equal(diff.StorageValue), Equal(diffTwo.StorageValue)))
|
Expect(diffs[0].StorageValue).To(Or(Equal(diff.StorageValue), Equal(diffTwo.StorageValue)))
|
||||||
Expect(diffs[1].Id).NotTo(BeZero())
|
Expect(diffs[1].ID).NotTo(BeZero())
|
||||||
Expect(diffs[1].HashedAddress).To(Or(Equal(diff.HashedAddress), Equal(diffTwo.HashedAddress)))
|
Expect(diffs[1].HashedAddress).To(Or(Equal(diff.HashedAddress), Equal(diffTwo.HashedAddress)))
|
||||||
Expect(diffs[1].BlockHash).To(Or(Equal(diff.BlockHash), Equal(diffTwo.BlockHash)))
|
Expect(diffs[1].BlockHash).To(Or(Equal(diff.BlockHash), Equal(diffTwo.BlockHash)))
|
||||||
Expect(diffs[1].BlockHeight).To(Or(Equal(diff.BlockHeight), Equal(diffTwo.BlockHeight)))
|
Expect(diffs[1].BlockHeight).To(Or(Equal(diff.BlockHeight), Equal(diffTwo.BlockHeight)))
|
||||||
|
@ -27,7 +27,7 @@ import (
|
|||||||
const ExpectedRowLength = 5
|
const ExpectedRowLength = 5
|
||||||
|
|
||||||
type StorageDiff struct {
|
type StorageDiff struct {
|
||||||
Id int
|
ID int
|
||||||
HashedAddress common.Hash `db:"contract"`
|
HashedAddress common.Hash `db:"contract"`
|
||||||
BlockHash common.Hash `db:"block_hash"`
|
BlockHash common.Hash `db:"block_hash"`
|
||||||
BlockHeight int `db:"block_height"`
|
BlockHeight int `db:"block_height"`
|
||||||
|
@ -26,7 +26,7 @@ type Streamer interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type StateDiffStreamer struct {
|
type StateDiffStreamer struct {
|
||||||
client core.RpcClient
|
client core.RPCClient
|
||||||
}
|
}
|
||||||
|
|
||||||
func (streamer *StateDiffStreamer) Stream(payloadChan chan statediff.Payload) (*rpc.ClientSubscription, error) {
|
func (streamer *StateDiffStreamer) Stream(payloadChan chan statediff.Payload) (*rpc.ClientSubscription, error) {
|
||||||
@ -34,7 +34,7 @@ func (streamer *StateDiffStreamer) Stream(payloadChan chan statediff.Payload) (*
|
|||||||
return streamer.client.Subscribe("statediff", payloadChan, "stream")
|
return streamer.client.Subscribe("statediff", payloadChan, "stream")
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewStateDiffStreamer(client core.RpcClient) StateDiffStreamer {
|
func NewStateDiffStreamer(client core.RPCClient) StateDiffStreamer {
|
||||||
return StateDiffStreamer{
|
return StateDiffStreamer{
|
||||||
client: client,
|
client: client,
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ import (
|
|||||||
|
|
||||||
var _ = Describe("StateDiff Streamer", func() {
|
var _ = Describe("StateDiff Streamer", func() {
|
||||||
It("subscribes to the geth statediff service", func() {
|
It("subscribes to the geth statediff service", func() {
|
||||||
client := &fakes.MockRpcClient{}
|
client := &fakes.MockRPCClient{}
|
||||||
streamer := streamer.NewStateDiffStreamer(client)
|
streamer := streamer.NewStateDiffStreamer(client)
|
||||||
payloadChan := make(chan statediff.Payload)
|
payloadChan := make(chan statediff.Payload)
|
||||||
_, err := streamer.Stream(payloadChan)
|
_, err := streamer.Stream(payloadChan)
|
||||||
|
@ -103,12 +103,12 @@ func (storageWatcher StorageWatcher) processQueue() {
|
|||||||
storageTransformer, ok := storageWatcher.getTransformer(diff)
|
storageTransformer, ok := storageWatcher.getTransformer(diff)
|
||||||
if !ok {
|
if !ok {
|
||||||
// delete diff from queue if address no longer watched
|
// delete diff from queue if address no longer watched
|
||||||
storageWatcher.deleteRow(diff.Id)
|
storageWatcher.deleteRow(diff.ID)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
executeErr := storageTransformer.Execute(diff)
|
executeErr := storageTransformer.Execute(diff)
|
||||||
if executeErr == nil {
|
if executeErr == nil {
|
||||||
storageWatcher.deleteRow(diff.Id)
|
storageWatcher.deleteRow(diff.ID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -65,7 +65,7 @@ var _ = Describe("Storage Watcher", func() {
|
|||||||
mockQueue = &mocks.MockStorageQueue{}
|
mockQueue = &mocks.MockStorageQueue{}
|
||||||
mockTransformer = &mocks.MockStorageTransformer{KeccakOfAddress: hashedAddress}
|
mockTransformer = &mocks.MockStorageTransformer{KeccakOfAddress: hashedAddress}
|
||||||
csvDiff = utils.StorageDiff{
|
csvDiff = utils.StorageDiff{
|
||||||
Id: 1337,
|
ID: 1337,
|
||||||
HashedAddress: hashedAddress,
|
HashedAddress: hashedAddress,
|
||||||
BlockHash: common.HexToHash("0xfedcba9876543210"),
|
BlockHash: common.HexToHash("0xfedcba9876543210"),
|
||||||
BlockHeight: 0,
|
BlockHeight: 0,
|
||||||
@ -167,8 +167,8 @@ var _ = Describe("Storage Watcher", func() {
|
|||||||
go storageWatcher.Execute(diffs, errs, time.Nanosecond)
|
go storageWatcher.Execute(diffs, errs, time.Nanosecond)
|
||||||
|
|
||||||
Eventually(func() int {
|
Eventually(func() int {
|
||||||
return mockQueue.DeletePassedId
|
return mockQueue.DeletePassedID
|
||||||
}).Should(Equal(csvDiff.Id))
|
}).Should(Equal(csvDiff.ID))
|
||||||
close(done)
|
close(done)
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -190,7 +190,7 @@ var _ = Describe("Storage Watcher", func() {
|
|||||||
|
|
||||||
It("deletes obsolete diff from queue if contract not recognized", func(done Done) {
|
It("deletes obsolete diff from queue if contract not recognized", func(done Done) {
|
||||||
obsoleteDiff := utils.StorageDiff{
|
obsoleteDiff := utils.StorageDiff{
|
||||||
Id: csvDiff.Id + 1,
|
ID: csvDiff.ID + 1,
|
||||||
HashedAddress: utils.HexToKeccak256Hash("0xfedcba9876543210"),
|
HashedAddress: utils.HexToKeccak256Hash("0xfedcba9876543210"),
|
||||||
}
|
}
|
||||||
mockQueue.DiffsToReturn = []utils.StorageDiff{obsoleteDiff}
|
mockQueue.DiffsToReturn = []utils.StorageDiff{obsoleteDiff}
|
||||||
@ -198,14 +198,14 @@ var _ = Describe("Storage Watcher", func() {
|
|||||||
go storageWatcher.Execute(diffs, errs, time.Nanosecond)
|
go storageWatcher.Execute(diffs, errs, time.Nanosecond)
|
||||||
|
|
||||||
Eventually(func() int {
|
Eventually(func() int {
|
||||||
return mockQueue.DeletePassedId
|
return mockQueue.DeletePassedID
|
||||||
}).Should(Equal(obsoleteDiff.Id))
|
}).Should(Equal(obsoleteDiff.ID))
|
||||||
close(done)
|
close(done)
|
||||||
})
|
})
|
||||||
|
|
||||||
It("logs error if deleting obsolete diff fails", func(done Done) {
|
It("logs error if deleting obsolete diff fails", func(done Done) {
|
||||||
obsoleteDiff := utils.StorageDiff{
|
obsoleteDiff := utils.StorageDiff{
|
||||||
Id: csvDiff.Id + 1,
|
ID: csvDiff.ID + 1,
|
||||||
HashedAddress: utils.HexToKeccak256Hash("0xfedcba9876543210"),
|
HashedAddress: utils.HexToKeccak256Hash("0xfedcba9876543210"),
|
||||||
}
|
}
|
||||||
mockQueue.DiffsToReturn = []utils.StorageDiff{obsoleteDiff}
|
mockQueue.DiffsToReturn = []utils.StorageDiff{obsoleteDiff}
|
||||||
|
@ -148,7 +148,7 @@ func (r *headerRepository) MarkHeadersCheckedForAll(headers []core.Header, ids [
|
|||||||
pgStr += fmt.Sprintf("%s = checked_headers.%s + 1, ", id, id)
|
pgStr += fmt.Sprintf("%s = checked_headers.%s + 1, ", id, id)
|
||||||
}
|
}
|
||||||
pgStr = pgStr[:len(pgStr)-2]
|
pgStr = pgStr[:len(pgStr)-2]
|
||||||
_, err = tx.Exec(pgStr, header.Id)
|
_, err = tx.Exec(pgStr, header.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
rollbackErr := tx.Rollback()
|
rollbackErr := tx.Rollback()
|
||||||
if rollbackErr != nil {
|
if rollbackErr != nil {
|
||||||
|
@ -174,16 +174,16 @@ var _ = Describe("Repository", func() {
|
|||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(len(missingHeaders)).To(Equal(3))
|
Expect(len(missingHeaders)).To(Equal(3))
|
||||||
|
|
||||||
err = contractHeaderRepo.MarkHeaderChecked(missingHeaders[0].Id, eventIDs[0])
|
err = contractHeaderRepo.MarkHeaderChecked(missingHeaders[0].ID, eventIDs[0])
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
||||||
missingHeaders, err = contractHeaderRepo.MissingHeadersForAll(mocks.MockHeader1.BlockNumber, mocks.MockHeader4.BlockNumber, eventIDs)
|
missingHeaders, err = contractHeaderRepo.MissingHeadersForAll(mocks.MockHeader1.BlockNumber, mocks.MockHeader4.BlockNumber, eventIDs)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(len(missingHeaders)).To(Equal(3))
|
Expect(len(missingHeaders)).To(Equal(3))
|
||||||
|
|
||||||
err = contractHeaderRepo.MarkHeaderChecked(missingHeaders[0].Id, eventIDs[1])
|
err = contractHeaderRepo.MarkHeaderChecked(missingHeaders[0].ID, eventIDs[1])
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
err = contractHeaderRepo.MarkHeaderChecked(missingHeaders[0].Id, eventIDs[2])
|
err = contractHeaderRepo.MarkHeaderChecked(missingHeaders[0].ID, eventIDs[2])
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
||||||
missingHeaders, err = contractHeaderRepo.MissingHeadersForAll(mocks.MockHeader2.BlockNumber, mocks.MockHeader4.BlockNumber, eventIDs)
|
missingHeaders, err = contractHeaderRepo.MissingHeadersForAll(mocks.MockHeader2.BlockNumber, mocks.MockHeader4.BlockNumber, eventIDs)
|
||||||
@ -236,7 +236,7 @@ var _ = Describe("Repository", func() {
|
|||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(len(missingHeaders)).To(Equal(3))
|
Expect(len(missingHeaders)).To(Equal(3))
|
||||||
|
|
||||||
headerID := missingHeaders[0].Id
|
headerID := missingHeaders[0].ID
|
||||||
err = contractHeaderRepo.MarkHeaderChecked(headerID, eventIDs[0])
|
err = contractHeaderRepo.MarkHeaderChecked(headerID, eventIDs[0])
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
||||||
@ -254,7 +254,7 @@ var _ = Describe("Repository", func() {
|
|||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(len(missingHeaders)).To(Equal(3))
|
Expect(len(missingHeaders)).To(Equal(3))
|
||||||
|
|
||||||
headerID := missingHeaders[0].Id
|
headerID := missingHeaders[0].ID
|
||||||
err = contractHeaderRepo.MarkHeaderChecked(headerID, "notEventId")
|
err = contractHeaderRepo.MarkHeaderChecked(headerID, "notEventId")
|
||||||
Expect(err).To(HaveOccurred())
|
Expect(err).To(HaveOccurred())
|
||||||
|
|
||||||
@ -274,7 +274,7 @@ var _ = Describe("Repository", func() {
|
|||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(len(missingHeaders)).To(Equal(3))
|
Expect(len(missingHeaders)).To(Equal(3))
|
||||||
|
|
||||||
headerID := missingHeaders[0].Id
|
headerID := missingHeaders[0].ID
|
||||||
err = contractHeaderRepo.MarkHeaderCheckedForAll(headerID, eventIDs)
|
err = contractHeaderRepo.MarkHeaderCheckedForAll(headerID, eventIDs)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
||||||
@ -326,8 +326,8 @@ var _ = Describe("Repository", func() {
|
|||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(len(missingHeaders)).To(Equal(3))
|
Expect(len(missingHeaders)).To(Equal(3))
|
||||||
|
|
||||||
headerID := missingHeaders[0].Id
|
headerID := missingHeaders[0].ID
|
||||||
headerID2 := missingHeaders[1].Id
|
headerID2 := missingHeaders[1].ID
|
||||||
for i, id := range eventIDs {
|
for i, id := range eventIDs {
|
||||||
err = contractHeaderRepo.MarkHeaderChecked(headerID, id)
|
err = contractHeaderRepo.MarkHeaderChecked(headerID, id)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
@ -340,7 +340,7 @@ var _ = Describe("Repository", func() {
|
|||||||
intersectionHeaders, err := contractHeaderRepo.MissingMethodsCheckedEventsIntersection(mocks.MockHeader1.BlockNumber, mocks.MockHeader4.BlockNumber, methodIDs, eventIDs)
|
intersectionHeaders, err := contractHeaderRepo.MissingMethodsCheckedEventsIntersection(mocks.MockHeader1.BlockNumber, mocks.MockHeader4.BlockNumber, methodIDs, eventIDs)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(len(intersectionHeaders)).To(Equal(1))
|
Expect(len(intersectionHeaders)).To(Equal(1))
|
||||||
Expect(intersectionHeaders[0].Id).To(Equal(headerID2))
|
Expect(intersectionHeaders[0].ID).To(Equal(headerID2))
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -239,7 +239,7 @@ func (tr *Transformer) Execute() error {
|
|||||||
// If no logs are found mark the header checked for all of these eventIDs
|
// If no logs are found mark the header checked for all of these eventIDs
|
||||||
// and continue to method polling and onto the next iteration
|
// and continue to method polling and onto the next iteration
|
||||||
if len(allLogs) < 1 {
|
if len(allLogs) < 1 {
|
||||||
markCheckedErr := tr.HeaderRepository.MarkHeaderCheckedForAll(header.Id, tr.eventIds)
|
markCheckedErr := tr.HeaderRepository.MarkHeaderCheckedForAll(header.ID, tr.eventIds)
|
||||||
if markCheckedErr != nil {
|
if markCheckedErr != nil {
|
||||||
return fmt.Errorf("error marking header checked: %s", markCheckedErr.Error())
|
return fmt.Errorf("error marking header checked: %s", markCheckedErr.Error())
|
||||||
}
|
}
|
||||||
@ -268,7 +268,7 @@ func (tr *Transformer) Execute() error {
|
|||||||
tr.Converter.Update(con)
|
tr.Converter.Update(con)
|
||||||
|
|
||||||
// Convert logs into batches of log mappings (eventName => []types.Logs
|
// Convert logs into batches of log mappings (eventName => []types.Logs
|
||||||
convertedLogs, convertErr := tr.Converter.ConvertBatch(logs, con.Events, header.Id)
|
convertedLogs, convertErr := tr.Converter.ConvertBatch(logs, con.Events, header.ID)
|
||||||
if convertErr != nil {
|
if convertErr != nil {
|
||||||
return fmt.Errorf("error converting logs: %s", convertErr.Error())
|
return fmt.Errorf("error converting logs: %s", convertErr.Error())
|
||||||
}
|
}
|
||||||
@ -287,7 +287,7 @@ func (tr *Transformer) Execute() error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
markCheckedErr := tr.HeaderRepository.MarkHeaderCheckedForAll(header.Id, tr.eventIds)
|
markCheckedErr := tr.HeaderRepository.MarkHeaderCheckedForAll(header.ID, tr.eventIds)
|
||||||
if markCheckedErr != nil {
|
if markCheckedErr != nil {
|
||||||
return fmt.Errorf("error marking header checked: %s", markCheckedErr.Error())
|
return fmt.Errorf("error marking header checked: %s", markCheckedErr.Error())
|
||||||
}
|
}
|
||||||
@ -321,7 +321,7 @@ func (tr *Transformer) methodPolling(header core.Header, sortedMethodIds map[str
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Mark this header checked for the methods
|
// Mark this header checked for the methods
|
||||||
markCheckedErr := tr.HeaderRepository.MarkHeaderCheckedForAll(header.Id, sortedMethodIds[con.Address])
|
markCheckedErr := tr.HeaderRepository.MarkHeaderCheckedForAll(header.ID, sortedMethodIds[con.Address])
|
||||||
if markCheckedErr != nil {
|
if markCheckedErr != nil {
|
||||||
return fmt.Errorf("error marking header checked: %s", markCheckedErr.Error())
|
return fmt.Errorf("error marking header checked: %s", markCheckedErr.Error())
|
||||||
}
|
}
|
||||||
|
@ -40,11 +40,11 @@ var _ = Describe("Interface Getter", func() {
|
|||||||
blockNumber := int64(6885696)
|
blockNumber := int64(6885696)
|
||||||
rawRpcClient, err := rpc.Dial(testIPC)
|
rawRpcClient, err := rpc.Dial(testIPC)
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
rpcClient := client.NewRpcClient(rawRpcClient, testIPC)
|
rpcClient := client.NewRPCClient(rawRpcClient, testIPC)
|
||||||
ethClient := ethclient.NewClient(rawRpcClient)
|
ethClient := ethclient.NewClient(rawRpcClient)
|
||||||
blockChainClient := client.NewEthClient(ethClient)
|
blockChainClient := client.NewEthClient(ethClient)
|
||||||
node := node.MakeNode(rpcClient)
|
node := node.MakeNode(rpcClient)
|
||||||
transactionConverter := rpc2.NewRpcTransactionConverter(ethClient)
|
transactionConverter := rpc2.NewRPCTransactionConverter(ethClient)
|
||||||
blockChain := eth.NewBlockChain(blockChainClient, rpcClient, node, transactionConverter)
|
blockChain := eth.NewBlockChain(blockChainClient, rpcClient, node, transactionConverter)
|
||||||
interfaceGetter := getter.NewInterfaceGetter(blockChain)
|
interfaceGetter := getter.NewInterfaceGetter(blockChain)
|
||||||
abi, err := interfaceGetter.GetABI(constants.PublicResolverAddress, blockNumber)
|
abi, err := interfaceGetter.GetABI(constants.PublicResolverAddress, blockNumber)
|
||||||
|
@ -38,8 +38,8 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type TransferLog struct {
|
type TransferLog struct {
|
||||||
Id int64 `db:"id"`
|
ID int64 `db:"id"`
|
||||||
VulcanizeLogId int64 `db:"vulcanize_log_id"`
|
VulcanizeLogID int64 `db:"vulcanize_log_id"`
|
||||||
TokenName string `db:"token_name"`
|
TokenName string `db:"token_name"`
|
||||||
Block int64 `db:"block"`
|
Block int64 `db:"block"`
|
||||||
Tx string `db:"tx"`
|
Tx string `db:"tx"`
|
||||||
@ -49,8 +49,8 @@ type TransferLog struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type NewOwnerLog struct {
|
type NewOwnerLog struct {
|
||||||
Id int64 `db:"id"`
|
ID int64 `db:"id"`
|
||||||
VulcanizeLogId int64 `db:"vulcanize_log_id"`
|
VulcanizeLogID int64 `db:"vulcanize_log_id"`
|
||||||
TokenName string `db:"token_name"`
|
TokenName string `db:"token_name"`
|
||||||
Block int64 `db:"block"`
|
Block int64 `db:"block"`
|
||||||
Tx string `db:"tx"`
|
Tx string `db:"tx"`
|
||||||
@ -60,7 +60,7 @@ type NewOwnerLog struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type HeaderSyncTransferLog struct {
|
type HeaderSyncTransferLog struct {
|
||||||
Id int64 `db:"id"`
|
ID int64 `db:"id"`
|
||||||
HeaderID int64 `db:"header_id"`
|
HeaderID int64 `db:"header_id"`
|
||||||
TokenName string `db:"token_name"`
|
TokenName string `db:"token_name"`
|
||||||
LogIndex int64 `db:"log_idx"`
|
LogIndex int64 `db:"log_idx"`
|
||||||
@ -72,7 +72,7 @@ type HeaderSyncTransferLog struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type HeaderSyncNewOwnerLog struct {
|
type HeaderSyncNewOwnerLog struct {
|
||||||
Id int64 `db:"id"`
|
ID int64 `db:"id"`
|
||||||
HeaderID int64 `db:"header_id"`
|
HeaderID int64 `db:"header_id"`
|
||||||
TokenName string `db:"token_name"`
|
TokenName string `db:"token_name"`
|
||||||
LogIndex int64 `db:"log_idx"`
|
LogIndex int64 `db:"log_idx"`
|
||||||
@ -84,7 +84,7 @@ type HeaderSyncNewOwnerLog struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type BalanceOf struct {
|
type BalanceOf struct {
|
||||||
Id int64 `db:"id"`
|
ID int64 `db:"id"`
|
||||||
TokenName string `db:"token_name"`
|
TokenName string `db:"token_name"`
|
||||||
Block int64 `db:"block"`
|
Block int64 `db:"block"`
|
||||||
Address string `db:"who_"`
|
Address string `db:"who_"`
|
||||||
@ -92,7 +92,7 @@ type BalanceOf struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Resolver struct {
|
type Resolver struct {
|
||||||
Id int64 `db:"id"`
|
ID int64 `db:"id"`
|
||||||
TokenName string `db:"token_name"`
|
TokenName string `db:"token_name"`
|
||||||
Block int64 `db:"block"`
|
Block int64 `db:"block"`
|
||||||
Node string `db:"node_"`
|
Node string `db:"node_"`
|
||||||
@ -100,7 +100,7 @@ type Resolver struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Owner struct {
|
type Owner struct {
|
||||||
Id int64 `db:"id"`
|
ID int64 `db:"id"`
|
||||||
TokenName string `db:"token_name"`
|
TokenName string `db:"token_name"`
|
||||||
Block int64 `db:"block"`
|
Block int64 `db:"block"`
|
||||||
Node string `db:"node_"`
|
Node string `db:"node_"`
|
||||||
@ -110,13 +110,13 @@ type Owner struct {
|
|||||||
func SetupDBandBC() (*postgres.DB, core.BlockChain) {
|
func SetupDBandBC() (*postgres.DB, core.BlockChain) {
|
||||||
con := test_config.TestClient
|
con := test_config.TestClient
|
||||||
testIPC := con.IPCPath
|
testIPC := con.IPCPath
|
||||||
rawRpcClient, err := rpc.Dial(testIPC)
|
rawRPCClient, err := rpc.Dial(testIPC)
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
rpcClient := client.NewRpcClient(rawRpcClient, testIPC)
|
rpcClient := client.NewRPCClient(rawRPCClient, testIPC)
|
||||||
ethClient := ethclient.NewClient(rawRpcClient)
|
ethClient := ethclient.NewClient(rawRPCClient)
|
||||||
blockChainClient := client.NewEthClient(ethClient)
|
blockChainClient := client.NewEthClient(ethClient)
|
||||||
madeNode := node.MakeNode(rpcClient)
|
madeNode := node.MakeNode(rpcClient)
|
||||||
transactionConverter := rpc2.NewRpcTransactionConverter(ethClient)
|
transactionConverter := rpc2.NewRPCTransactionConverter(ethClient)
|
||||||
blockChain := eth.NewBlockChain(blockChainClient, rpcClient, madeNode, transactionConverter)
|
blockChain := eth.NewBlockChain(blockChainClient, rpcClient, madeNode, transactionConverter)
|
||||||
|
|
||||||
db, err := postgres.NewDB(config.Database{
|
db, err := postgres.NewDB(config.Database{
|
||||||
@ -129,7 +129,7 @@ func SetupDBandBC() (*postgres.DB, core.BlockChain) {
|
|||||||
return db, blockChain
|
return db, blockChain
|
||||||
}
|
}
|
||||||
|
|
||||||
func SetupTusdRepo(vulcanizeLogId *int64, wantedEvents, wantedMethods []string) (*postgres.DB, *contract.Contract) {
|
func SetupTusdRepo(vulcanizeLogID *int64, wantedEvents, wantedMethods []string) (*postgres.DB, *contract.Contract) {
|
||||||
db, err := postgres.NewDB(config.Database{
|
db, err := postgres.NewDB(config.Database{
|
||||||
Hostname: "localhost",
|
Hostname: "localhost",
|
||||||
Name: "vulcanize_testing",
|
Name: "vulcanize_testing",
|
||||||
@ -142,14 +142,14 @@ func SetupTusdRepo(vulcanizeLogId *int64, wantedEvents, wantedMethods []string)
|
|||||||
blockRepository := *repositories.NewBlockRepository(db)
|
blockRepository := *repositories.NewBlockRepository(db)
|
||||||
|
|
||||||
blockNumber := rand.Int63()
|
blockNumber := rand.Int63()
|
||||||
blockId := CreateBlock(blockNumber, blockRepository)
|
blockID := CreateBlock(blockNumber, blockRepository)
|
||||||
|
|
||||||
receipts := []core.Receipt{{Logs: []core.FullSyncLog{{}}}}
|
receipts := []core.Receipt{{Logs: []core.FullSyncLog{{}}}}
|
||||||
|
|
||||||
err = receiptRepository.CreateReceiptsAndLogs(blockId, receipts)
|
err = receiptRepository.CreateReceiptsAndLogs(blockID, receipts)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
||||||
err = logRepository.Get(vulcanizeLogId, `SELECT id FROM full_sync_logs`)
|
err = logRepository.Get(vulcanizeLogID, `SELECT id FROM full_sync_logs`)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
||||||
info := SetupTusdContract(wantedEvents, wantedMethods)
|
info := SetupTusdContract(wantedEvents, wantedMethods)
|
||||||
@ -175,7 +175,7 @@ func SetupTusdContract(wantedEvents, wantedMethods []string) *contract.Contract
|
|||||||
}.Init()
|
}.Init()
|
||||||
}
|
}
|
||||||
|
|
||||||
func SetupENSRepo(vulcanizeLogId *int64, wantedEvents, wantedMethods []string) (*postgres.DB, *contract.Contract) {
|
func SetupENSRepo(vulcanizeLogID *int64, wantedEvents, wantedMethods []string) (*postgres.DB, *contract.Contract) {
|
||||||
db, err := postgres.NewDB(config.Database{
|
db, err := postgres.NewDB(config.Database{
|
||||||
Hostname: "localhost",
|
Hostname: "localhost",
|
||||||
Name: "vulcanize_testing",
|
Name: "vulcanize_testing",
|
||||||
@ -188,14 +188,14 @@ func SetupENSRepo(vulcanizeLogId *int64, wantedEvents, wantedMethods []string) (
|
|||||||
blockRepository := *repositories.NewBlockRepository(db)
|
blockRepository := *repositories.NewBlockRepository(db)
|
||||||
|
|
||||||
blockNumber := rand.Int63()
|
blockNumber := rand.Int63()
|
||||||
blockId := CreateBlock(blockNumber, blockRepository)
|
blockID := CreateBlock(blockNumber, blockRepository)
|
||||||
|
|
||||||
receipts := []core.Receipt{{Logs: []core.FullSyncLog{{}}}}
|
receipts := []core.Receipt{{Logs: []core.FullSyncLog{{}}}}
|
||||||
|
|
||||||
err = receiptRepository.CreateReceiptsAndLogs(blockId, receipts)
|
err = receiptRepository.CreateReceiptsAndLogs(blockID, receipts)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
||||||
err = logRepository.Get(vulcanizeLogId, `SELECT id FROM full_sync_logs`)
|
err = logRepository.Get(vulcanizeLogID, `SELECT id FROM full_sync_logs`)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
||||||
info := SetupENSContract(wantedEvents, wantedMethods)
|
info := SetupENSContract(wantedEvents, wantedMethods)
|
||||||
@ -316,9 +316,9 @@ func TearDown(db *postgres.DB) {
|
|||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
}
|
}
|
||||||
|
|
||||||
func CreateBlock(blockNumber int64, repository repositories.BlockRepository) (blockId int64) {
|
func CreateBlock(blockNumber int64, repository repositories.BlockRepository) int64 {
|
||||||
blockId, err := repository.CreateOrUpdateBlock(core.Block{Number: blockNumber})
|
blockID, err := repository.CreateOrUpdateBlock(core.Block{Number: blockNumber})
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
|
||||||
return blockId
|
return blockID
|
||||||
}
|
}
|
||||||
|
@ -157,8 +157,8 @@ var _ = Describe("Repository", func() {
|
|||||||
err = db.QueryRowx(fmt.Sprintf("SELECT * FROM full_%s.transfer_event", constants.TusdContractAddress)).StructScan(&scanLog)
|
err = db.QueryRowx(fmt.Sprintf("SELECT * FROM full_%s.transfer_event", constants.TusdContractAddress)).StructScan(&scanLog)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
expectedLog := test_helpers.TransferLog{
|
expectedLog := test_helpers.TransferLog{
|
||||||
Id: 1,
|
ID: 1,
|
||||||
VulcanizeLogId: vulcanizeLogId,
|
VulcanizeLogID: vulcanizeLogId,
|
||||||
TokenName: "TrueUSD",
|
TokenName: "TrueUSD",
|
||||||
Block: 5488076,
|
Block: 5488076,
|
||||||
Tx: "0x135391a0962a63944e5908e6fedfff90fb4be3e3290a21017861099bad6546ae",
|
Tx: "0x135391a0962a63944e5908e6fedfff90fb4be3e3290a21017861099bad6546ae",
|
||||||
@ -179,8 +179,8 @@ var _ = Describe("Repository", func() {
|
|||||||
err = db.QueryRowx(fmt.Sprintf("SELECT * FROM full_%s.transfer_event", constants.TusdContractAddress)).StructScan(&scanLog)
|
err = db.QueryRowx(fmt.Sprintf("SELECT * FROM full_%s.transfer_event", constants.TusdContractAddress)).StructScan(&scanLog)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
expectedLog := test_helpers.TransferLog{
|
expectedLog := test_helpers.TransferLog{
|
||||||
Id: 1,
|
ID: 1,
|
||||||
VulcanizeLogId: vulcanizeLogId,
|
VulcanizeLogID: vulcanizeLogId,
|
||||||
TokenName: "TrueUSD",
|
TokenName: "TrueUSD",
|
||||||
Block: 5488076,
|
Block: 5488076,
|
||||||
Tx: "0x135391a0962a63944e5908e6fedfff90fb4be3e3290a21017861099bad6546ae",
|
Tx: "0x135391a0962a63944e5908e6fedfff90fb4be3e3290a21017861099bad6546ae",
|
||||||
|
@ -133,7 +133,7 @@ var _ = Describe("Repository", func() {
|
|||||||
|
|
||||||
err = db.QueryRowx(fmt.Sprintf("SELECT * FROM full_%s.balanceof_method", constants.TusdContractAddress)).StructScan(&scanStruct)
|
err = db.QueryRowx(fmt.Sprintf("SELECT * FROM full_%s.balanceof_method", constants.TusdContractAddress)).StructScan(&scanStruct)
|
||||||
expectedLog := test_helpers.BalanceOf{
|
expectedLog := test_helpers.BalanceOf{
|
||||||
Id: 1,
|
ID: 1,
|
||||||
TokenName: "TrueUSD",
|
TokenName: "TrueUSD",
|
||||||
Block: 6707323,
|
Block: 6707323,
|
||||||
Address: "0xfE9e8709d3215310075d67E3ed32A380CCf451C8",
|
Address: "0xfE9e8709d3215310075d67E3ed32A380CCf451C8",
|
||||||
@ -222,7 +222,7 @@ var _ = Describe("Repository", func() {
|
|||||||
|
|
||||||
err = db.QueryRowx(fmt.Sprintf("SELECT * FROM header_%s.balanceof_method", constants.TusdContractAddress)).StructScan(&scanStruct)
|
err = db.QueryRowx(fmt.Sprintf("SELECT * FROM header_%s.balanceof_method", constants.TusdContractAddress)).StructScan(&scanStruct)
|
||||||
expectedLog := test_helpers.BalanceOf{
|
expectedLog := test_helpers.BalanceOf{
|
||||||
Id: 1,
|
ID: 1,
|
||||||
TokenName: "TrueUSD",
|
TokenName: "TrueUSD",
|
||||||
Block: 6707323,
|
Block: 6707323,
|
||||||
Address: "0xfE9e8709d3215310075d67E3ed32A380CCf451C8",
|
Address: "0xfE9e8709d3215310075d67E3ed32A380CCf451C8",
|
||||||
|
@ -23,7 +23,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type Header struct {
|
type Header struct {
|
||||||
Id int64
|
ID int64
|
||||||
BlockNumber int64 `db:"block_number"`
|
BlockNumber int64 `db:"block_number"`
|
||||||
Hash string
|
Hash string
|
||||||
Raw []byte
|
Raw []byte
|
||||||
|
@ -23,7 +23,7 @@ import (
|
|||||||
"github.com/vulcanize/vulcanizedb/pkg/eth/client"
|
"github.com/vulcanize/vulcanizedb/pkg/eth/client"
|
||||||
)
|
)
|
||||||
|
|
||||||
type RpcClient interface {
|
type RPCClient interface {
|
||||||
CallContext(ctx context.Context, result interface{}, method string, args ...interface{}) error
|
CallContext(ctx context.Context, result interface{}, method string, args ...interface{}) error
|
||||||
BatchCall(batch []client.BatchElem) error
|
BatchCall(batch []client.BatchElem) error
|
||||||
IpcPath() string
|
IpcPath() string
|
||||||
|
@ -30,7 +30,7 @@ type TransactionModel struct {
|
|||||||
Value string
|
Value string
|
||||||
}
|
}
|
||||||
|
|
||||||
type RpcTransaction struct {
|
type RPCTransaction struct {
|
||||||
Nonce string `json:"nonce"`
|
Nonce string `json:"nonce"`
|
||||||
GasPrice string `json:"gasPrice"`
|
GasPrice string `json:"gasPrice"`
|
||||||
GasLimit string `json:"gas"`
|
GasLimit string `json:"gas"`
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
package core
|
package core
|
||||||
|
|
||||||
type Uncle struct {
|
type Uncle struct {
|
||||||
Id int64
|
ID int64
|
||||||
Miner string
|
Miner string
|
||||||
Reward string
|
Reward string
|
||||||
Hash string
|
Hash string
|
||||||
|
@ -46,7 +46,7 @@ func NewDB(databaseConfig config.Database, node core.Node) (*DB, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (db *DB) CreateNode(node *core.Node) error {
|
func (db *DB) CreateNode(node *core.Node) error {
|
||||||
var nodeId int64
|
var nodeID int64
|
||||||
err := db.QueryRow(
|
err := db.QueryRow(
|
||||||
`INSERT INTO eth_nodes (genesis_block, network_id, eth_node_id, client_name)
|
`INSERT INTO eth_nodes (genesis_block, network_id, eth_node_id, client_name)
|
||||||
VALUES ($1, $2, $3, $4)
|
VALUES ($1, $2, $3, $4)
|
||||||
@ -57,10 +57,10 @@ func (db *DB) CreateNode(node *core.Node) error {
|
|||||||
eth_node_id = $3,
|
eth_node_id = $3,
|
||||||
client_name = $4
|
client_name = $4
|
||||||
RETURNING id`,
|
RETURNING id`,
|
||||||
node.GenesisBlock, node.NetworkID, node.ID, node.ClientName).Scan(&nodeId)
|
node.GenesisBlock, node.NetworkID, node.ID, node.ClientName).Scan(&nodeID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ErrUnableToSetNode(err)
|
return ErrUnableToSetNode(err)
|
||||||
}
|
}
|
||||||
db.NodeID = nodeId
|
db.NodeID = nodeID
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -52,7 +52,7 @@ func (blockRepository BlockRepository) SetBlocksStatus(chainHead int64) error {
|
|||||||
|
|
||||||
func (blockRepository BlockRepository) CreateOrUpdateBlock(block core.Block) (int64, error) {
|
func (blockRepository BlockRepository) CreateOrUpdateBlock(block core.Block) (int64, error) {
|
||||||
var err error
|
var err error
|
||||||
var blockId int64
|
var blockID int64
|
||||||
retrievedBlockHash, ok := blockRepository.getBlockHash(block)
|
retrievedBlockHash, ok := blockRepository.getBlockHash(block)
|
||||||
if !ok {
|
if !ok {
|
||||||
return blockRepository.insertBlock(block)
|
return blockRepository.insertBlock(block)
|
||||||
@ -64,10 +64,10 @@ func (blockRepository BlockRepository) CreateOrUpdateBlock(block core.Block) (in
|
|||||||
}
|
}
|
||||||
return blockRepository.insertBlock(block)
|
return blockRepository.insertBlock(block)
|
||||||
}
|
}
|
||||||
return blockId, ErrBlockExists
|
return blockID, ErrBlockExists
|
||||||
}
|
}
|
||||||
|
|
||||||
func (blockRepository BlockRepository) MissingBlockNumbers(startingBlockNumber int64, highestBlockNumber int64, nodeId string) []int64 {
|
func (blockRepository BlockRepository) MissingBlockNumbers(startingBlockNumber int64, highestBlockNumber int64, nodeID string) []int64 {
|
||||||
numbers := make([]int64, 0)
|
numbers := make([]int64, 0)
|
||||||
err := blockRepository.database.Select(&numbers,
|
err := blockRepository.database.Select(&numbers,
|
||||||
`SELECT all_block_numbers
|
`SELECT all_block_numbers
|
||||||
@ -77,7 +77,7 @@ func (blockRepository BlockRepository) MissingBlockNumbers(startingBlockNumber i
|
|||||||
SELECT number FROM blocks WHERE eth_node_fingerprint = $3
|
SELECT number FROM blocks WHERE eth_node_fingerprint = $3
|
||||||
) `,
|
) `,
|
||||||
startingBlockNumber,
|
startingBlockNumber,
|
||||||
highestBlockNumber, nodeId)
|
highestBlockNumber, nodeID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Error("MissingBlockNumbers: error getting blocks: ", err)
|
logrus.Error("MissingBlockNumbers: error getting blocks: ", err)
|
||||||
}
|
}
|
||||||
@ -118,7 +118,7 @@ func (blockRepository BlockRepository) GetBlock(blockNumber int64) (core.Block,
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (blockRepository BlockRepository) insertBlock(block core.Block) (int64, error) {
|
func (blockRepository BlockRepository) insertBlock(block core.Block) (int64, error) {
|
||||||
var blockId int64
|
var blockID int64
|
||||||
tx, beginErr := blockRepository.database.Beginx()
|
tx, beginErr := blockRepository.database.Beginx()
|
||||||
if beginErr != nil {
|
if beginErr != nil {
|
||||||
return 0, postgres.ErrBeginTransactionFailed(beginErr)
|
return 0, postgres.ErrBeginTransactionFailed(beginErr)
|
||||||
@ -145,7 +145,7 @@ func (blockRepository BlockRepository) insertBlock(block core.Block) (int64, err
|
|||||||
nullStringToZero(block.Reward),
|
nullStringToZero(block.Reward),
|
||||||
nullStringToZero(block.UnclesReward),
|
nullStringToZero(block.UnclesReward),
|
||||||
blockRepository.database.Node.ID).
|
blockRepository.database.Node.ID).
|
||||||
Scan(&blockId)
|
Scan(&blockID)
|
||||||
if insertBlockErr != nil {
|
if insertBlockErr != nil {
|
||||||
rollbackErr := tx.Rollback()
|
rollbackErr := tx.Rollback()
|
||||||
if rollbackErr != nil {
|
if rollbackErr != nil {
|
||||||
@ -154,14 +154,14 @@ func (blockRepository BlockRepository) insertBlock(block core.Block) (int64, err
|
|||||||
return 0, postgres.ErrDBInsertFailed(insertBlockErr)
|
return 0, postgres.ErrDBInsertFailed(insertBlockErr)
|
||||||
}
|
}
|
||||||
if len(block.Uncles) > 0 {
|
if len(block.Uncles) > 0 {
|
||||||
insertUncleErr := blockRepository.createUncles(tx, blockId, block.Hash, block.Uncles)
|
insertUncleErr := blockRepository.createUncles(tx, blockID, block.Hash, block.Uncles)
|
||||||
if insertUncleErr != nil {
|
if insertUncleErr != nil {
|
||||||
tx.Rollback()
|
tx.Rollback()
|
||||||
return 0, postgres.ErrDBInsertFailed(insertUncleErr)
|
return 0, postgres.ErrDBInsertFailed(insertUncleErr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if len(block.Transactions) > 0 {
|
if len(block.Transactions) > 0 {
|
||||||
insertTxErr := blockRepository.createTransactions(tx, blockId, block.Transactions)
|
insertTxErr := blockRepository.createTransactions(tx, blockID, block.Transactions)
|
||||||
if insertTxErr != nil {
|
if insertTxErr != nil {
|
||||||
rollbackErr := tx.Rollback()
|
rollbackErr := tx.Rollback()
|
||||||
if rollbackErr != nil {
|
if rollbackErr != nil {
|
||||||
@ -178,12 +178,12 @@ func (blockRepository BlockRepository) insertBlock(block core.Block) (int64, err
|
|||||||
}
|
}
|
||||||
return 0, commitErr
|
return 0, commitErr
|
||||||
}
|
}
|
||||||
return blockId, nil
|
return blockID, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (blockRepository BlockRepository) createUncles(tx *sqlx.Tx, blockId int64, blockHash string, uncles []core.Uncle) error {
|
func (blockRepository BlockRepository) createUncles(tx *sqlx.Tx, blockID int64, blockHash string, uncles []core.Uncle) error {
|
||||||
for _, uncle := range uncles {
|
for _, uncle := range uncles {
|
||||||
err := blockRepository.createUncle(tx, blockId, uncle)
|
err := blockRepository.createUncle(tx, blockID, uncle)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -191,19 +191,19 @@ func (blockRepository BlockRepository) createUncles(tx *sqlx.Tx, blockId int64,
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (blockRepository BlockRepository) createUncle(tx *sqlx.Tx, blockId int64, uncle core.Uncle) error {
|
func (blockRepository BlockRepository) createUncle(tx *sqlx.Tx, blockID int64, uncle core.Uncle) error {
|
||||||
_, err := tx.Exec(
|
_, err := tx.Exec(
|
||||||
`INSERT INTO uncles
|
`INSERT INTO uncles
|
||||||
(hash, block_id, reward, miner, raw, block_timestamp, eth_node_id, eth_node_fingerprint)
|
(hash, block_id, reward, miner, raw, block_timestamp, eth_node_id, eth_node_fingerprint)
|
||||||
VALUES ($1, $2, $3, $4, $5, $6, $7::NUMERIC, $8)
|
VALUES ($1, $2, $3, $4, $5, $6, $7::NUMERIC, $8)
|
||||||
RETURNING id`,
|
RETURNING id`,
|
||||||
uncle.Hash, blockId, nullStringToZero(uncle.Reward), uncle.Miner, uncle.Raw, uncle.Timestamp, blockRepository.database.NodeID, blockRepository.database.Node.ID)
|
uncle.Hash, blockID, nullStringToZero(uncle.Reward), uncle.Miner, uncle.Raw, uncle.Timestamp, blockRepository.database.NodeID, blockRepository.database.Node.ID)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (blockRepository BlockRepository) createTransactions(tx *sqlx.Tx, blockId int64, transactions []core.TransactionModel) error {
|
func (blockRepository BlockRepository) createTransactions(tx *sqlx.Tx, blockID int64, transactions []core.TransactionModel) error {
|
||||||
for _, transaction := range transactions {
|
for _, transaction := range transactions {
|
||||||
err := blockRepository.createTransaction(tx, blockId, transaction)
|
err := blockRepository.createTransaction(tx, blockID, transaction)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -221,24 +221,24 @@ func nullStringToZero(s string) string {
|
|||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
||||||
func (blockRepository BlockRepository) createTransaction(tx *sqlx.Tx, blockId int64, transaction core.TransactionModel) error {
|
func (blockRepository BlockRepository) createTransaction(tx *sqlx.Tx, blockID int64, transaction core.TransactionModel) error {
|
||||||
_, err := tx.Exec(
|
_, err := tx.Exec(
|
||||||
`INSERT INTO full_sync_transactions
|
`INSERT INTO full_sync_transactions
|
||||||
(block_id, gas_limit, gas_price, hash, input_data, nonce, raw, tx_from, tx_index, tx_to, "value")
|
(block_id, gas_limit, gas_price, hash, input_data, nonce, raw, tx_from, tx_index, tx_to, "value")
|
||||||
VALUES ($1, $2::NUMERIC, $3::NUMERIC, $4, $5, $6::NUMERIC, $7, $8, $9::NUMERIC, $10, $11::NUMERIC)
|
VALUES ($1, $2::NUMERIC, $3::NUMERIC, $4, $5, $6::NUMERIC, $7, $8, $9::NUMERIC, $10, $11::NUMERIC)
|
||||||
RETURNING id`, blockId, transaction.GasLimit, transaction.GasPrice, transaction.Hash, transaction.Data,
|
RETURNING id`, blockID, transaction.GasLimit, transaction.GasPrice, transaction.Hash, transaction.Data,
|
||||||
transaction.Nonce, transaction.Raw, transaction.From, transaction.TxIndex, transaction.To, nullStringToZero(transaction.Value))
|
transaction.Nonce, transaction.Raw, transaction.From, transaction.TxIndex, transaction.To, nullStringToZero(transaction.Value))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if hasReceipt(transaction) {
|
if hasReceipt(transaction) {
|
||||||
receiptRepo := FullSyncReceiptRepository{}
|
receiptRepo := FullSyncReceiptRepository{}
|
||||||
receiptId, err := receiptRepo.CreateFullSyncReceiptInTx(blockId, transaction.Receipt, tx)
|
receiptID, err := receiptRepo.CreateFullSyncReceiptInTx(blockID, transaction.Receipt, tx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if hasLogs(transaction) {
|
if hasLogs(transaction) {
|
||||||
err = blockRepository.createLogs(tx, transaction.Receipt.Logs, receiptId)
|
err = blockRepository.createLogs(tx, transaction.Receipt.Logs, receiptID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -266,13 +266,13 @@ func (blockRepository BlockRepository) getBlockHash(block core.Block) (string, b
|
|||||||
return retrievedBlockHash, blockExists(retrievedBlockHash)
|
return retrievedBlockHash, blockExists(retrievedBlockHash)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (blockRepository BlockRepository) createLogs(tx *sqlx.Tx, logs []core.FullSyncLog, receiptId int64) error {
|
func (blockRepository BlockRepository) createLogs(tx *sqlx.Tx, logs []core.FullSyncLog, receiptID int64) error {
|
||||||
for _, tlog := range logs {
|
for _, tlog := range logs {
|
||||||
_, err := tx.Exec(
|
_, err := tx.Exec(
|
||||||
`INSERT INTO full_sync_logs (block_number, address, tx_hash, index, topic0, topic1, topic2, topic3, data, receipt_id)
|
`INSERT INTO full_sync_logs (block_number, address, tx_hash, index, topic0, topic1, topic2, topic3, data, receipt_id)
|
||||||
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)
|
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)
|
||||||
`,
|
`,
|
||||||
tlog.BlockNumber, tlog.Address, tlog.TxHash, tlog.Index, tlog.Topics[0], tlog.Topics[1], tlog.Topics[2], tlog.Topics[3], tlog.Data, receiptId,
|
tlog.BlockNumber, tlog.Address, tlog.TxHash, tlog.Index, tlog.Topics[0], tlog.Topics[1], tlog.Topics[2], tlog.Topics[3], tlog.Data, receiptID,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return postgres.ErrDBInsertFailed(err)
|
return postgres.ErrDBInsertFailed(err)
|
||||||
|
@ -27,14 +27,14 @@ type FullSyncLogRepository struct {
|
|||||||
*postgres.DB
|
*postgres.DB
|
||||||
}
|
}
|
||||||
|
|
||||||
func (repository FullSyncLogRepository) CreateLogs(lgs []core.FullSyncLog, receiptId int64) error {
|
func (repository FullSyncLogRepository) CreateLogs(lgs []core.FullSyncLog, receiptID int64) error {
|
||||||
tx, _ := repository.DB.Beginx()
|
tx, _ := repository.DB.Beginx()
|
||||||
for _, tlog := range lgs {
|
for _, tlog := range lgs {
|
||||||
_, insertLogErr := tx.Exec(
|
_, insertLogErr := tx.Exec(
|
||||||
`INSERT INTO full_sync_logs (block_number, address, tx_hash, index, topic0, topic1, topic2, topic3, data, receipt_id)
|
`INSERT INTO full_sync_logs (block_number, address, tx_hash, index, topic0, topic1, topic2, topic3, data, receipt_id)
|
||||||
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)
|
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)
|
||||||
`,
|
`,
|
||||||
tlog.BlockNumber, tlog.Address, tlog.TxHash, tlog.Index, tlog.Topics[0], tlog.Topics[1], tlog.Topics[2], tlog.Topics[3], tlog.Data, receiptId,
|
tlog.BlockNumber, tlog.Address, tlog.TxHash, tlog.Index, tlog.Topics[0], tlog.Topics[1], tlog.Topics[2], tlog.Topics[3], tlog.Data, receiptID,
|
||||||
)
|
)
|
||||||
if insertLogErr != nil {
|
if insertLogErr != nil {
|
||||||
rollbackErr := tx.Rollback()
|
rollbackErr := tx.Rollback()
|
||||||
|
@ -30,19 +30,19 @@ type FullSyncReceiptRepository struct {
|
|||||||
*postgres.DB
|
*postgres.DB
|
||||||
}
|
}
|
||||||
|
|
||||||
func (receiptRepository FullSyncReceiptRepository) CreateReceiptsAndLogs(blockId int64, receipts []core.Receipt) error {
|
func (receiptRepository FullSyncReceiptRepository) CreateReceiptsAndLogs(blockID int64, receipts []core.Receipt) error {
|
||||||
tx, err := receiptRepository.DB.Beginx()
|
tx, err := receiptRepository.DB.Beginx()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
for _, receipt := range receipts {
|
for _, receipt := range receipts {
|
||||||
receiptId, err := receiptRepository.CreateFullSyncReceiptInTx(blockId, receipt, tx)
|
receiptID, err := receiptRepository.CreateFullSyncReceiptInTx(blockID, receipt, tx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
tx.Rollback()
|
tx.Rollback()
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if len(receipt.Logs) > 0 {
|
if len(receipt.Logs) > 0 {
|
||||||
err = createLogs(receipt.Logs, receiptId, tx)
|
err = createLogs(receipt.Logs, receiptID, tx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
tx.Rollback()
|
tx.Rollback()
|
||||||
return err
|
return err
|
||||||
@ -53,28 +53,28 @@ func (receiptRepository FullSyncReceiptRepository) CreateReceiptsAndLogs(blockId
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func createReceipt(receipt core.Receipt, blockId int64, tx *sqlx.Tx) (int64, error) {
|
func createReceipt(receipt core.Receipt, blockID int64, tx *sqlx.Tx) (int64, error) {
|
||||||
var receiptId int64
|
var receiptID int64
|
||||||
err := tx.QueryRow(
|
err := tx.QueryRow(
|
||||||
`INSERT INTO full_sync_receipts
|
`INSERT INTO full_sync_receipts
|
||||||
(contract_address, tx_hash, cumulative_gas_used, gas_used, state_root, status, block_id)
|
(contract_address, tx_hash, cumulative_gas_used, gas_used, state_root, status, block_id)
|
||||||
VALUES ($1, $2, $3, $4, $5, $6, $7)
|
VALUES ($1, $2, $3, $4, $5, $6, $7)
|
||||||
RETURNING id`,
|
RETURNING id`,
|
||||||
receipt.ContractAddress, receipt.TxHash, receipt.CumulativeGasUsed, receipt.GasUsed, receipt.StateRoot, receipt.Status, blockId,
|
receipt.ContractAddress, receipt.TxHash, receipt.CumulativeGasUsed, receipt.GasUsed, receipt.StateRoot, receipt.Status, blockID,
|
||||||
).Scan(&receiptId)
|
).Scan(&receiptID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Error("createReceipt: Error inserting: ", err)
|
logrus.Error("createReceipt: Error inserting: ", err)
|
||||||
}
|
}
|
||||||
return receiptId, err
|
return receiptID, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func createLogs(logs []core.FullSyncLog, receiptId int64, tx *sqlx.Tx) error {
|
func createLogs(logs []core.FullSyncLog, receiptID int64, tx *sqlx.Tx) error {
|
||||||
for _, log := range logs {
|
for _, log := range logs {
|
||||||
_, err := tx.Exec(
|
_, err := tx.Exec(
|
||||||
`INSERT INTO full_sync_logs (block_number, address, tx_hash, index, topic0, topic1, topic2, topic3, data, receipt_id)
|
`INSERT INTO full_sync_logs (block_number, address, tx_hash, index, topic0, topic1, topic2, topic3, data, receipt_id)
|
||||||
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)
|
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)
|
||||||
`,
|
`,
|
||||||
log.BlockNumber, log.Address, log.TxHash, log.Index, log.Topics[0], log.Topics[1], log.Topics[2], log.Topics[3], log.Data, receiptId,
|
log.BlockNumber, log.Address, log.TxHash, log.Index, log.Topics[0], log.Topics[1], log.Topics[2], log.Topics[3], log.Data, receiptID,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -83,25 +83,25 @@ func createLogs(logs []core.FullSyncLog, receiptId int64, tx *sqlx.Tx) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (FullSyncReceiptRepository) CreateFullSyncReceiptInTx(blockId int64, receipt core.Receipt, tx *sqlx.Tx) (int64, error) {
|
func (FullSyncReceiptRepository) CreateFullSyncReceiptInTx(blockID int64, receipt core.Receipt, tx *sqlx.Tx) (int64, error) {
|
||||||
var receiptId int64
|
var receiptID int64
|
||||||
addressId, getAddressErr := repository.GetOrCreateAddressInTransaction(tx, receipt.ContractAddress)
|
addressID, getAddressErr := repository.GetOrCreateAddressInTransaction(tx, receipt.ContractAddress)
|
||||||
if getAddressErr != nil {
|
if getAddressErr != nil {
|
||||||
logrus.Error("createReceipt: Error getting address id: ", getAddressErr)
|
logrus.Error("createReceipt: Error getting address id: ", getAddressErr)
|
||||||
return receiptId, getAddressErr
|
return receiptID, getAddressErr
|
||||||
}
|
}
|
||||||
err := tx.QueryRow(
|
err := tx.QueryRow(
|
||||||
`INSERT INTO full_sync_receipts
|
`INSERT INTO full_sync_receipts
|
||||||
(contract_address_id, tx_hash, cumulative_gas_used, gas_used, state_root, status, block_id)
|
(contract_address_id, tx_hash, cumulative_gas_used, gas_used, state_root, status, block_id)
|
||||||
VALUES ($1, $2, $3, $4, $5, $6, $7)
|
VALUES ($1, $2, $3, $4, $5, $6, $7)
|
||||||
RETURNING id`,
|
RETURNING id`,
|
||||||
addressId, receipt.TxHash, receipt.CumulativeGasUsed, receipt.GasUsed, receipt.StateRoot, receipt.Status, blockId).Scan(&receiptId)
|
addressID, receipt.TxHash, receipt.CumulativeGasUsed, receipt.GasUsed, receipt.StateRoot, receipt.Status, blockID).Scan(&receiptID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
tx.Rollback()
|
tx.Rollback()
|
||||||
logrus.Warning("CreateReceipt: error inserting receipt: ", err)
|
logrus.Warning("CreateReceipt: error inserting receipt: ", err)
|
||||||
return receiptId, err
|
return receiptID, err
|
||||||
}
|
}
|
||||||
return receiptId, nil
|
return receiptID, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (receiptRepository FullSyncReceiptRepository) GetFullSyncReceipt(txHash string) (core.Receipt, error) {
|
func (receiptRepository FullSyncReceiptRepository) GetFullSyncReceipt(txHash string) (core.Receipt, error) {
|
||||||
|
@ -68,7 +68,7 @@ func (repository HeaderRepository) CreateTransactions(headerID int64, transactio
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (repository HeaderRepository) CreateTransactionInTx(tx *sqlx.Tx, headerID int64, transaction core.TransactionModel) (int64, error) {
|
func (repository HeaderRepository) CreateTransactionInTx(tx *sqlx.Tx, headerID int64, transaction core.TransactionModel) (int64, error) {
|
||||||
var txId int64
|
var txID int64
|
||||||
err := tx.QueryRowx(`INSERT INTO public.header_sync_transactions
|
err := tx.QueryRowx(`INSERT INTO public.header_sync_transactions
|
||||||
(header_id, hash, gas_limit, gas_price, input_data, nonce, raw, tx_from, tx_index, tx_to, "value")
|
(header_id, hash, gas_limit, gas_price, input_data, nonce, raw, tx_from, tx_index, tx_to, "value")
|
||||||
VALUES ($1, $2, $3::NUMERIC, $4::NUMERIC, $5, $6::NUMERIC, $7, $8, $9::NUMERIC, $10, $11::NUMERIC)
|
VALUES ($1, $2, $3::NUMERIC, $4::NUMERIC, $5, $6::NUMERIC, $7, $8, $9::NUMERIC, $10, $11::NUMERIC)
|
||||||
@ -77,12 +77,12 @@ func (repository HeaderRepository) CreateTransactionInTx(tx *sqlx.Tx, headerID i
|
|||||||
RETURNING id`,
|
RETURNING id`,
|
||||||
headerID, transaction.Hash, transaction.GasLimit, transaction.GasPrice,
|
headerID, transaction.Hash, transaction.GasLimit, transaction.GasPrice,
|
||||||
transaction.Data, transaction.Nonce, transaction.Raw, transaction.From,
|
transaction.Data, transaction.Nonce, transaction.Raw, transaction.From,
|
||||||
transaction.TxIndex, transaction.To, transaction.Value).Scan(&txId)
|
transaction.TxIndex, transaction.To, transaction.Value).Scan(&txID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("header_repository: error inserting transaction: ", err)
|
log.Error("header_repository: error inserting transaction: ", err)
|
||||||
return txId, err
|
return txID, err
|
||||||
}
|
}
|
||||||
return txId, err
|
return txID, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (repository HeaderRepository) GetHeader(blockNumber int64) (core.Header, error) {
|
func (repository HeaderRepository) GetHeader(blockNumber int64) (core.Header, error) {
|
||||||
@ -132,19 +132,19 @@ func (repository HeaderRepository) getHeaderHash(header core.Header) (string, er
|
|||||||
// Can happen when concurrent processes are inserting headers
|
// Can happen when concurrent processes are inserting headers
|
||||||
// Otherwise should not occur since only called in CreateOrUpdateHeader
|
// Otherwise should not occur since only called in CreateOrUpdateHeader
|
||||||
func (repository HeaderRepository) InternalInsertHeader(header core.Header) (int64, error) {
|
func (repository HeaderRepository) InternalInsertHeader(header core.Header) (int64, error) {
|
||||||
var headerId int64
|
var headerID int64
|
||||||
row := repository.database.QueryRowx(
|
row := repository.database.QueryRowx(
|
||||||
`INSERT INTO public.headers (block_number, hash, block_timestamp, raw, eth_node_id, eth_node_fingerprint)
|
`INSERT INTO public.headers (block_number, hash, block_timestamp, raw, eth_node_id, eth_node_fingerprint)
|
||||||
VALUES ($1, $2, $3::NUMERIC, $4, $5, $6) ON CONFLICT DO NOTHING RETURNING id`,
|
VALUES ($1, $2, $3::NUMERIC, $4, $5, $6) ON CONFLICT DO NOTHING RETURNING id`,
|
||||||
header.BlockNumber, header.Hash, header.Timestamp, header.Raw, repository.database.NodeID, repository.database.Node.ID)
|
header.BlockNumber, header.Hash, header.Timestamp, header.Raw, repository.database.NodeID, repository.database.Node.ID)
|
||||||
err := row.Scan(&headerId)
|
err := row.Scan(&headerID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == sql.ErrNoRows {
|
if err == sql.ErrNoRows {
|
||||||
return 0, ErrValidHeaderExists
|
return 0, ErrValidHeaderExists
|
||||||
}
|
}
|
||||||
log.Error("InternalInsertHeader: error inserting header: ", err)
|
log.Error("InternalInsertHeader: error inserting header: ", err)
|
||||||
}
|
}
|
||||||
return headerId, err
|
return headerID, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (repository HeaderRepository) replaceHeader(header core.Header) (int64, error) {
|
func (repository HeaderRepository) replaceHeader(header core.Header) (int64, error) {
|
||||||
|
@ -423,7 +423,7 @@ var _ = Describe("Block header repository", func() {
|
|||||||
dbHeader, err := repo.GetHeader(header.BlockNumber)
|
dbHeader, err := repo.GetHeader(header.BlockNumber)
|
||||||
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
Expect(dbHeader.Id).NotTo(BeZero())
|
Expect(dbHeader.ID).NotTo(BeZero())
|
||||||
Expect(dbHeader.BlockNumber).To(Equal(header.BlockNumber))
|
Expect(dbHeader.BlockNumber).To(Equal(header.BlockNumber))
|
||||||
Expect(dbHeader.Hash).To(Equal(header.Hash))
|
Expect(dbHeader.Hash).To(Equal(header.Hash))
|
||||||
Expect(dbHeader.Raw).To(MatchJSON(header.Raw))
|
Expect(dbHeader.Raw).To(MatchJSON(header.Raw))
|
||||||
|
@ -73,7 +73,7 @@ func (repo HeaderSyncLogRepository) GetUntransformedHeaderSyncLogs() ([]core.Hea
|
|||||||
for _, topic := range rawLog.Topics {
|
for _, topic := range rawLog.Topics {
|
||||||
logTopics = append(logTopics, common.BytesToHash(topic))
|
logTopics = append(logTopics, common.BytesToHash(topic))
|
||||||
}
|
}
|
||||||
address, addrErr := repository.GetAddressById(repo.db, rawLog.Address)
|
address, addrErr := repository.GetAddressByID(repo.db, rawLog.Address)
|
||||||
if addrErr != nil {
|
if addrErr != nil {
|
||||||
return nil, addrErr
|
return nil, addrErr
|
||||||
}
|
}
|
||||||
|
@ -80,7 +80,7 @@ var _ = Describe("Header sync log repository", func() {
|
|||||||
Expect(lookupErr).NotTo(HaveOccurred())
|
Expect(lookupErr).NotTo(HaveOccurred())
|
||||||
Expect(dbLog.ID).NotTo(BeZero())
|
Expect(dbLog.ID).NotTo(BeZero())
|
||||||
Expect(dbLog.HeaderID).To(Equal(headerID))
|
Expect(dbLog.HeaderID).To(Equal(headerID))
|
||||||
actualAddress, addressErr := repository2.GetAddressById(db, dbLog.Address)
|
actualAddress, addressErr := repository2.GetAddressByID(db, dbLog.Address)
|
||||||
Expect(addressErr).NotTo(HaveOccurred())
|
Expect(addressErr).NotTo(HaveOccurred())
|
||||||
Expect(actualAddress).To(Equal(log.Address.Hex()))
|
Expect(actualAddress).To(Equal(log.Address.Hex()))
|
||||||
Expect(dbLog.Topics[0]).To(Equal(log.Topics[0].Bytes()))
|
Expect(dbLog.Topics[0]).To(Equal(log.Topics[0].Bytes()))
|
||||||
@ -128,7 +128,7 @@ var _ = Describe("Header sync log repository", func() {
|
|||||||
logTopics = append(logTopics, common.BytesToHash(topic))
|
logTopics = append(logTopics, common.BytesToHash(topic))
|
||||||
}
|
}
|
||||||
|
|
||||||
actualAddress, addressErr := repository2.GetAddressById(db, dbLog.Address)
|
actualAddress, addressErr := repository2.GetAddressByID(db, dbLog.Address)
|
||||||
Expect(addressErr).NotTo(HaveOccurred())
|
Expect(addressErr).NotTo(HaveOccurred())
|
||||||
reconstructedLog := types.Log{
|
reconstructedLog := types.Log{
|
||||||
Address: common.HexToAddress(actualAddress),
|
Address: common.HexToAddress(actualAddress),
|
||||||
|
@ -26,11 +26,11 @@ import (
|
|||||||
type HeaderSyncReceiptRepository struct{}
|
type HeaderSyncReceiptRepository struct{}
|
||||||
|
|
||||||
func (HeaderSyncReceiptRepository) CreateHeaderSyncReceiptInTx(headerID, transactionID int64, receipt core.Receipt, tx *sqlx.Tx) (int64, error) {
|
func (HeaderSyncReceiptRepository) CreateHeaderSyncReceiptInTx(headerID, transactionID int64, receipt core.Receipt, tx *sqlx.Tx) (int64, error) {
|
||||||
var receiptId int64
|
var receiptID int64
|
||||||
addressId, getAddressErr := repository.GetOrCreateAddressInTransaction(tx, receipt.ContractAddress)
|
addressID, getAddressErr := repository.GetOrCreateAddressInTransaction(tx, receipt.ContractAddress)
|
||||||
if getAddressErr != nil {
|
if getAddressErr != nil {
|
||||||
log.Error("createReceipt: Error getting address id: ", getAddressErr)
|
log.Error("createReceipt: Error getting address id: ", getAddressErr)
|
||||||
return receiptId, getAddressErr
|
return receiptID, getAddressErr
|
||||||
}
|
}
|
||||||
err := tx.QueryRowx(`INSERT INTO public.header_sync_receipts
|
err := tx.QueryRowx(`INSERT INTO public.header_sync_receipts
|
||||||
(header_id, transaction_id, contract_address_id, cumulative_gas_used, gas_used, state_root, status, tx_hash, rlp)
|
(header_id, transaction_id, contract_address_id, cumulative_gas_used, gas_used, state_root, status, tx_hash, rlp)
|
||||||
@ -38,10 +38,10 @@ func (HeaderSyncReceiptRepository) CreateHeaderSyncReceiptInTx(headerID, transac
|
|||||||
ON CONFLICT (header_id, transaction_id) DO UPDATE
|
ON CONFLICT (header_id, transaction_id) DO UPDATE
|
||||||
SET (contract_address_id, cumulative_gas_used, gas_used, state_root, status, tx_hash, rlp) = ($3, $4::NUMERIC, $5::NUMERIC, $6, $7, $8, $9)
|
SET (contract_address_id, cumulative_gas_used, gas_used, state_root, status, tx_hash, rlp) = ($3, $4::NUMERIC, $5::NUMERIC, $6, $7, $8, $9)
|
||||||
RETURNING id`,
|
RETURNING id`,
|
||||||
headerID, transactionID, addressId, receipt.CumulativeGasUsed, receipt.GasUsed, receipt.StateRoot, receipt.Status, receipt.TxHash, receipt.Rlp).Scan(&receiptId)
|
headerID, transactionID, addressID, receipt.CumulativeGasUsed, receipt.GasUsed, receipt.StateRoot, receipt.Status, receipt.TxHash, receipt.Rlp).Scan(&receiptID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("header_repository: error inserting receipt: ", err)
|
log.Error("header_repository: error inserting receipt: ", err)
|
||||||
return receiptId, err
|
return receiptID, err
|
||||||
}
|
}
|
||||||
return receiptId, err
|
return receiptID, err
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,7 @@ type FilterRepository interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type FullSyncLogRepository interface {
|
type FullSyncLogRepository interface {
|
||||||
CreateLogs(logs []core.FullSyncLog, receiptId int64) error
|
CreateLogs(logs []core.FullSyncLog, receiptID int64) error
|
||||||
GetLogs(address string, blockNumber int64) ([]core.FullSyncLog, error)
|
GetLogs(address string, blockNumber int64) ([]core.FullSyncLog, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,13 +74,13 @@ type HeaderSyncLogRepository interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type FullSyncReceiptRepository interface {
|
type FullSyncReceiptRepository interface {
|
||||||
CreateReceiptsAndLogs(blockId int64, receipts []core.Receipt) error
|
CreateReceiptsAndLogs(blockID int64, receipts []core.Receipt) error
|
||||||
CreateFullSyncReceiptInTx(blockId int64, receipt core.Receipt, tx *sqlx.Tx) (int64, error)
|
CreateFullSyncReceiptInTx(blockID int64, receipt core.Receipt, tx *sqlx.Tx) (int64, error)
|
||||||
GetFullSyncReceipt(txHash string) (core.Receipt, error)
|
GetFullSyncReceipt(txHash string) (core.Receipt, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
type HeaderSyncReceiptRepository interface {
|
type HeaderSyncReceiptRepository interface {
|
||||||
CreateFullSyncReceiptInTx(blockId int64, receipt core.Receipt, tx *sqlx.Tx) (int64, error)
|
CreateFullSyncReceiptInTx(blockID int64, receipt core.Receipt, tx *sqlx.Tx) (int64, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
type WatchedEventRepository interface {
|
type WatchedEventRepository interface {
|
||||||
|
@ -32,7 +32,7 @@ import (
|
|||||||
var (
|
var (
|
||||||
ErrInvalidAbiFile = errors.New("invalid abi")
|
ErrInvalidAbiFile = errors.New("invalid abi")
|
||||||
ErrMissingAbiFile = errors.New("missing abi")
|
ErrMissingAbiFile = errors.New("missing abi")
|
||||||
ErrApiRequestFailed = errors.New("etherscan api request failed")
|
ErrAPIRequestFailed = errors.New("etherscan api request failed")
|
||||||
)
|
)
|
||||||
|
|
||||||
type Response struct {
|
type Response struct {
|
||||||
@ -72,7 +72,7 @@ func (e *EtherScanAPI) GetAbi(contractHash string) (string, error) {
|
|||||||
request := fmt.Sprintf("%s/api?module=contract&action=getabi&address=%s", e.url, contractHash)
|
request := fmt.Sprintf("%s/api?module=contract&action=getabi&address=%s", e.url, contractHash)
|
||||||
r, err := e.client.Get(request)
|
r, err := e.client.Get(request)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", ErrApiRequestFailed
|
return "", ErrAPIRequestFailed
|
||||||
}
|
}
|
||||||
defer r.Body.Close()
|
defer r.Body.Close()
|
||||||
err = json.NewDecoder(r.Body).Decode(&target)
|
err = json.NewDecoder(r.Body).Decode(&target)
|
||||||
|
@ -41,11 +41,11 @@ type BlockChain struct {
|
|||||||
ethClient core.EthClient
|
ethClient core.EthClient
|
||||||
headerConverter vulcCommon.HeaderConverter
|
headerConverter vulcCommon.HeaderConverter
|
||||||
node core.Node
|
node core.Node
|
||||||
rpcClient core.RpcClient
|
rpcClient core.RPCClient
|
||||||
transactionConverter vulcCommon.TransactionConverter
|
transactionConverter vulcCommon.TransactionConverter
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewBlockChain(ethClient core.EthClient, rpcClient core.RpcClient, node core.Node, converter vulcCommon.TransactionConverter) *BlockChain {
|
func NewBlockChain(ethClient core.EthClient, rpcClient core.RPCClient, node core.Node, converter vulcCommon.TransactionConverter) *BlockChain {
|
||||||
return &BlockChain{
|
return &BlockChain{
|
||||||
blockConverter: vulcCommon.NewBlockConverter(converter),
|
blockConverter: vulcCommon.NewBlockConverter(converter),
|
||||||
ethClient: ethClient,
|
ethClient: ethClient,
|
||||||
@ -108,7 +108,7 @@ func (blockChain *BlockChain) GetFullSyncLogs(contract core.Contract, startingBl
|
|||||||
func (blockChain *BlockChain) GetTransactions(transactionHashes []common.Hash) ([]core.TransactionModel, error) {
|
func (blockChain *BlockChain) GetTransactions(transactionHashes []common.Hash) ([]core.TransactionModel, error) {
|
||||||
numTransactions := len(transactionHashes)
|
numTransactions := len(transactionHashes)
|
||||||
var batch []client.BatchElem
|
var batch []client.BatchElem
|
||||||
transactions := make([]core.RpcTransaction, numTransactions)
|
transactions := make([]core.RPCTransaction, numTransactions)
|
||||||
|
|
||||||
for index, transactionHash := range transactionHashes {
|
for index, transactionHash := range transactionHashes {
|
||||||
batchElem := client.BatchElem{
|
batchElem := client.BatchElem{
|
||||||
@ -124,7 +124,7 @@ func (blockChain *BlockChain) GetTransactions(transactionHashes []common.Hash) (
|
|||||||
return []core.TransactionModel{}, rpcErr
|
return []core.TransactionModel{}, rpcErr
|
||||||
}
|
}
|
||||||
|
|
||||||
return blockChain.transactionConverter.ConvertRpcTransactionsToModels(transactions)
|
return blockChain.transactionConverter.ConvertRPCTransactionsToModels(transactions)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (blockChain *BlockChain) LastBlock() (*big.Int, error) {
|
func (blockChain *BlockChain) LastBlock() (*big.Int, error) {
|
||||||
|
@ -37,14 +37,14 @@ var _ = Describe("Geth blockchain", func() {
|
|||||||
var (
|
var (
|
||||||
mockClient *fakes.MockEthClient
|
mockClient *fakes.MockEthClient
|
||||||
blockChain *eth.BlockChain
|
blockChain *eth.BlockChain
|
||||||
mockRpcClient *fakes.MockRpcClient
|
mockRpcClient *fakes.MockRPCClient
|
||||||
mockTransactionConverter *fakes.MockTransactionConverter
|
mockTransactionConverter *fakes.MockTransactionConverter
|
||||||
node vulcCore.Node
|
node vulcCore.Node
|
||||||
)
|
)
|
||||||
|
|
||||||
BeforeEach(func() {
|
BeforeEach(func() {
|
||||||
mockClient = fakes.NewMockEthClient()
|
mockClient = fakes.NewMockEthClient()
|
||||||
mockRpcClient = fakes.NewMockRpcClient()
|
mockRpcClient = fakes.NewMockRPCClient()
|
||||||
mockTransactionConverter = fakes.NewMockTransactionConverter()
|
mockTransactionConverter = fakes.NewMockTransactionConverter()
|
||||||
node = vulcCore.Node{}
|
node = vulcCore.Node{}
|
||||||
blockChain = eth.NewBlockChain(mockClient, mockRpcClient, node, mockTransactionConverter)
|
blockChain = eth.NewBlockChain(mockClient, mockRpcClient, node, mockTransactionConverter)
|
||||||
|
@ -24,7 +24,7 @@ import (
|
|||||||
"github.com/ethereum/go-ethereum/rpc"
|
"github.com/ethereum/go-ethereum/rpc"
|
||||||
)
|
)
|
||||||
|
|
||||||
type RpcClient struct {
|
type RPCClient struct {
|
||||||
client *rpc.Client
|
client *rpc.Client
|
||||||
ipcPath string
|
ipcPath string
|
||||||
}
|
}
|
||||||
@ -36,14 +36,14 @@ type BatchElem struct {
|
|||||||
Error error
|
Error error
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewRpcClient(client *rpc.Client, ipcPath string) RpcClient {
|
func NewRPCClient(client *rpc.Client, ipcPath string) RPCClient {
|
||||||
return RpcClient{
|
return RPCClient{
|
||||||
client: client,
|
client: client,
|
||||||
ipcPath: ipcPath,
|
ipcPath: ipcPath,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (client RpcClient) CallContext(ctx context.Context, result interface{}, method string, args ...interface{}) error {
|
func (client RPCClient) CallContext(ctx context.Context, result interface{}, method string, args ...interface{}) error {
|
||||||
//If an empty interface (or other nil object) is passed to CallContext, when the JSONRPC message is created the params will
|
//If an empty interface (or other nil object) is passed to CallContext, when the JSONRPC message is created the params will
|
||||||
//be interpreted as [null]. This seems to work fine for most of the ethereum clients (which presumably ignore a null parameter.
|
//be interpreted as [null]. This seems to work fine for most of the ethereum clients (which presumably ignore a null parameter.
|
||||||
//Ganache however does not ignore it, and throws an 'Incorrect number of arguments' error.
|
//Ganache however does not ignore it, and throws an 'Incorrect number of arguments' error.
|
||||||
@ -53,15 +53,15 @@ func (client RpcClient) CallContext(ctx context.Context, result interface{}, met
|
|||||||
return client.client.CallContext(ctx, result, method, args...)
|
return client.client.CallContext(ctx, result, method, args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (client RpcClient) IpcPath() string {
|
func (client RPCClient) IpcPath() string {
|
||||||
return client.ipcPath
|
return client.ipcPath
|
||||||
}
|
}
|
||||||
|
|
||||||
func (client RpcClient) SupportedModules() (map[string]string, error) {
|
func (client RPCClient) SupportedModules() (map[string]string, error) {
|
||||||
return client.client.SupportedModules()
|
return client.client.SupportedModules()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (client RpcClient) BatchCall(batch []BatchElem) error {
|
func (client RPCClient) BatchCall(batch []BatchElem) error {
|
||||||
var rpcBatch []rpc.BatchElem
|
var rpcBatch []rpc.BatchElem
|
||||||
for _, batchElem := range batch {
|
for _, batchElem := range batch {
|
||||||
var newBatchElem = rpc.BatchElem{
|
var newBatchElem = rpc.BatchElem{
|
||||||
@ -78,7 +78,7 @@ func (client RpcClient) BatchCall(batch []BatchElem) error {
|
|||||||
|
|
||||||
// Subscribe subscribes to an rpc "namespace_subscribe" subscription with the given channel
|
// Subscribe subscribes to an rpc "namespace_subscribe" subscription with the given channel
|
||||||
// The first argument needs to be the method we wish to invoke
|
// The first argument needs to be the method we wish to invoke
|
||||||
func (client RpcClient) Subscribe(namespace string, payloadChan interface{}, args ...interface{}) (*rpc.ClientSubscription, error) {
|
func (client RPCClient) Subscribe(namespace string, payloadChan interface{}, args ...interface{}) (*rpc.ClientSubscription, error) {
|
||||||
chanVal := reflect.ValueOf(payloadChan)
|
chanVal := reflect.ValueOf(payloadChan)
|
||||||
if chanVal.Kind() != reflect.Chan || chanVal.Type().ChanDir()&reflect.SendDir == 0 {
|
if chanVal.Kind() != reflect.Chan || chanVal.Type().ChanDir()&reflect.SendDir == 0 {
|
||||||
return nil, errors.New("second argument to Subscribe must be a writable channel")
|
return nil, errors.New("second argument to Subscribe must be a writable channel")
|
||||||
|
@ -38,16 +38,16 @@ func NewColdImporter(ethDB ethereum.Database, blockRepository datastore.BlockRep
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ci *ColdImporter) Execute(startingBlockNumber int64, endingBlockNumber int64, nodeId string) error {
|
func (ci *ColdImporter) Execute(startingBlockNumber int64, endingBlockNumber int64, nodeID string) error {
|
||||||
missingBlocks := ci.blockRepository.MissingBlockNumbers(startingBlockNumber, endingBlockNumber, nodeId)
|
missingBlocks := ci.blockRepository.MissingBlockNumbers(startingBlockNumber, endingBlockNumber, nodeID)
|
||||||
for _, n := range missingBlocks {
|
for _, n := range missingBlocks {
|
||||||
hash := ci.ethDB.GetBlockHash(n)
|
hash := ci.ethDB.GetBlockHash(n)
|
||||||
|
|
||||||
blockId, err := ci.createBlocksAndTransactions(hash, n)
|
blockID, err := ci.createBlocksAndTransactions(hash, n)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
err = ci.createReceiptsAndLogs(hash, n, blockId)
|
err = ci.createReceiptsAndLogs(hash, n, blockID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -65,11 +65,11 @@ func (ci *ColdImporter) createBlocksAndTransactions(hash []byte, i int64) (int64
|
|||||||
return ci.blockRepository.CreateOrUpdateBlock(coreBlock)
|
return ci.blockRepository.CreateOrUpdateBlock(coreBlock)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ci *ColdImporter) createReceiptsAndLogs(hash []byte, number int64, blockId int64) error {
|
func (ci *ColdImporter) createReceiptsAndLogs(hash []byte, number int64, blockID int64) error {
|
||||||
receipts := ci.ethDB.GetBlockReceipts(hash, number)
|
receipts := ci.ethDB.GetBlockReceipts(hash, number)
|
||||||
coreReceipts, err := common.ToCoreReceipts(receipts)
|
coreReceipts, err := common.ToCoreReceipts(receipts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return ci.receiptRepository.CreateReceiptsAndLogs(blockId, coreReceipts)
|
return ci.receiptRepository.CreateReceiptsAndLogs(blockID, coreReceipts)
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ import (
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
ColdImportClientName = "LevelDbColdImport"
|
ColdImportClientName = "LevelDbColdImport"
|
||||||
ColdImportNetworkId float64 = 1
|
ColdImportNetworkID float64 = 1
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -54,15 +54,15 @@ func (cinb ColdImportNodeBuilder) GetNode(genesisBlock []byte, levelPath string)
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return coldNode, err
|
return coldNode, err
|
||||||
}
|
}
|
||||||
nodeId, err := cinb.parser.ParsePublicKey(string(nodeKey))
|
nodeID, err := cinb.parser.ParsePublicKey(string(nodeKey))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return coldNode, err
|
return coldNode, err
|
||||||
}
|
}
|
||||||
genesisBlockHash := common.BytesToHash(genesisBlock).String()
|
genesisBlockHash := common.BytesToHash(genesisBlock).String()
|
||||||
coldNode = core.Node{
|
coldNode = core.Node{
|
||||||
GenesisBlock: genesisBlockHash,
|
GenesisBlock: genesisBlockHash,
|
||||||
NetworkID: ColdImportNetworkId,
|
NetworkID: ColdImportNetworkID,
|
||||||
ID: nodeId,
|
ID: nodeID,
|
||||||
ClientName: ColdImportClientName,
|
ClientName: ColdImportClientName,
|
||||||
}
|
}
|
||||||
return coldNode, nil
|
return coldNode, nil
|
||||||
|
@ -106,7 +106,7 @@ var _ = Describe("Cold importer node builder", func() {
|
|||||||
expectedGenesisBlock := common.BytesToHash(fakeGenesisBlock).String()
|
expectedGenesisBlock := common.BytesToHash(fakeGenesisBlock).String()
|
||||||
Expect(result.GenesisBlock).To(Equal(expectedGenesisBlock))
|
Expect(result.GenesisBlock).To(Equal(expectedGenesisBlock))
|
||||||
Expect(result.ID).To(Equal(fakePublicKeyString))
|
Expect(result.ID).To(Equal(fakePublicKeyString))
|
||||||
Expect(result.NetworkID).To(Equal(cold_import.ColdImportNetworkId))
|
Expect(result.NetworkID).To(Equal(cold_import.ColdImportNetworkID))
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ func (cdtc *ColdDbTransactionConverter) ConvertBlockTransactionsToCore(gethBlock
|
|||||||
return coreTransactions, nil
|
return coreTransactions, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cdtc *ColdDbTransactionConverter) ConvertRpcTransactionsToModels(transactions []core.RpcTransaction) ([]core.TransactionModel, error) {
|
func (cdtc *ColdDbTransactionConverter) ConvertRPCTransactionsToModels(transactions []core.RPCTransaction) ([]core.TransactionModel, error) {
|
||||||
panic("converting transaction indexes to integer not supported for cold import")
|
panic("converting transaction indexes to integer not supported for cold import")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ var _ = Describe("Conversion of GethBlock to core.Block", func() {
|
|||||||
}
|
}
|
||||||
block := types.NewBlock(&header, []*types.Transaction{}, []*types.Header{}, []*types.Receipt{})
|
block := types.NewBlock(&header, []*types.Transaction{}, []*types.Header{}, []*types.Receipt{})
|
||||||
client := fakes.NewMockEthClient()
|
client := fakes.NewMockEthClient()
|
||||||
transactionConverter := rpc.NewRpcTransactionConverter(client)
|
transactionConverter := rpc.NewRPCTransactionConverter(client)
|
||||||
blockConverter := vulcCommon.NewBlockConverter(transactionConverter)
|
blockConverter := vulcCommon.NewBlockConverter(transactionConverter)
|
||||||
|
|
||||||
coreBlock, err := blockConverter.ToCoreBlock(block)
|
coreBlock, err := blockConverter.ToCoreBlock(block)
|
||||||
@ -110,7 +110,7 @@ var _ = Describe("Conversion of GethBlock to core.Block", func() {
|
|||||||
}
|
}
|
||||||
uncles := []*types.Header{{Number: big.NewInt(1071817)}, {Number: big.NewInt(1071818)}}
|
uncles := []*types.Header{{Number: big.NewInt(1071817)}, {Number: big.NewInt(1071818)}}
|
||||||
block := types.NewBlock(&header, transactions, uncles, []*types.Receipt{&receipt})
|
block := types.NewBlock(&header, transactions, uncles, []*types.Receipt{&receipt})
|
||||||
transactionConverter := rpc.NewRpcTransactionConverter(client)
|
transactionConverter := rpc.NewRPCTransactionConverter(client)
|
||||||
blockConverter := vulcCommon.NewBlockConverter(transactionConverter)
|
blockConverter := vulcCommon.NewBlockConverter(transactionConverter)
|
||||||
|
|
||||||
coreBlock, err := blockConverter.ToCoreBlock(block)
|
coreBlock, err := blockConverter.ToCoreBlock(block)
|
||||||
@ -151,7 +151,7 @@ var _ = Describe("Conversion of GethBlock to core.Block", func() {
|
|||||||
|
|
||||||
client := fakes.NewMockEthClient()
|
client := fakes.NewMockEthClient()
|
||||||
client.SetTransactionReceipts(receipts)
|
client.SetTransactionReceipts(receipts)
|
||||||
transactionConverter := rpc.NewRpcTransactionConverter(client)
|
transactionConverter := rpc.NewRPCTransactionConverter(client)
|
||||||
blockConverter := vulcCommon.NewBlockConverter(transactionConverter)
|
blockConverter := vulcCommon.NewBlockConverter(transactionConverter)
|
||||||
|
|
||||||
coreBlock, err := blockConverter.ToCoreBlock(block)
|
coreBlock, err := blockConverter.ToCoreBlock(block)
|
||||||
@ -211,7 +211,7 @@ var _ = Describe("Conversion of GethBlock to core.Block", func() {
|
|||||||
|
|
||||||
client := fakes.NewMockEthClient()
|
client := fakes.NewMockEthClient()
|
||||||
client.SetTransactionReceipts(receipts)
|
client.SetTransactionReceipts(receipts)
|
||||||
transactionConverter := rpc.NewRpcTransactionConverter(client)
|
transactionConverter := rpc.NewRPCTransactionConverter(client)
|
||||||
blockConverter := vulcCommon.NewBlockConverter(transactionConverter)
|
blockConverter := vulcCommon.NewBlockConverter(transactionConverter)
|
||||||
|
|
||||||
coreBlock, err := blockConverter.ToCoreBlock(block)
|
coreBlock, err := blockConverter.ToCoreBlock(block)
|
||||||
@ -229,7 +229,7 @@ var _ = Describe("Conversion of GethBlock to core.Block", func() {
|
|||||||
header := types.Header{}
|
header := types.Header{}
|
||||||
block := types.NewBlock(&header, []*types.Transaction{}, []*types.Header{}, []*types.Receipt{})
|
block := types.NewBlock(&header, []*types.Transaction{}, []*types.Header{}, []*types.Receipt{})
|
||||||
client := fakes.NewMockEthClient()
|
client := fakes.NewMockEthClient()
|
||||||
transactionConverter := rpc.NewRpcTransactionConverter(client)
|
transactionConverter := rpc.NewRPCTransactionConverter(client)
|
||||||
blockConverter := vulcCommon.NewBlockConverter(transactionConverter)
|
blockConverter := vulcCommon.NewBlockConverter(transactionConverter)
|
||||||
|
|
||||||
coreBlock, err := blockConverter.ToCoreBlock(block)
|
coreBlock, err := blockConverter.ToCoreBlock(block)
|
||||||
@ -270,7 +270,7 @@ var _ = Describe("Conversion of GethBlock to core.Block", func() {
|
|||||||
[]*types.Header{},
|
[]*types.Header{},
|
||||||
[]*types.Receipt{gethReceipt},
|
[]*types.Receipt{gethReceipt},
|
||||||
)
|
)
|
||||||
transactionConverter := rpc.NewRpcTransactionConverter(client)
|
transactionConverter := rpc.NewRPCTransactionConverter(client)
|
||||||
blockConverter := vulcCommon.NewBlockConverter(transactionConverter)
|
blockConverter := vulcCommon.NewBlockConverter(transactionConverter)
|
||||||
|
|
||||||
coreBlock, err := blockConverter.ToCoreBlock(block)
|
coreBlock, err := blockConverter.ToCoreBlock(block)
|
||||||
@ -320,7 +320,7 @@ var _ = Describe("Conversion of GethBlock to core.Block", func() {
|
|||||||
[]*types.Header{},
|
[]*types.Header{},
|
||||||
[]*types.Receipt{gethReceipt},
|
[]*types.Receipt{gethReceipt},
|
||||||
)
|
)
|
||||||
transactionConverter := rpc.NewRpcTransactionConverter(client)
|
transactionConverter := rpc.NewRPCTransactionConverter(client)
|
||||||
blockConverter := vulcCommon.NewBlockConverter(transactionConverter)
|
blockConverter := vulcCommon.NewBlockConverter(transactionConverter)
|
||||||
|
|
||||||
coreBlock, err := blockConverter.ToCoreBlock(block)
|
coreBlock, err := blockConverter.ToCoreBlock(block)
|
||||||
@ -370,7 +370,7 @@ var _ = Describe("Conversion of GethBlock to core.Block", func() {
|
|||||||
It("returns an error when transaction sender call fails", func() {
|
It("returns an error when transaction sender call fails", func() {
|
||||||
client := fakes.NewMockEthClient()
|
client := fakes.NewMockEthClient()
|
||||||
client.SetTransactionSenderErr(fakes.FakeError)
|
client.SetTransactionSenderErr(fakes.FakeError)
|
||||||
transactionConverter := rpc.NewRpcTransactionConverter(client)
|
transactionConverter := rpc.NewRPCTransactionConverter(client)
|
||||||
blockConverter := vulcCommon.NewBlockConverter(transactionConverter)
|
blockConverter := vulcCommon.NewBlockConverter(transactionConverter)
|
||||||
|
|
||||||
_, err := blockConverter.ToCoreBlock(block)
|
_, err := blockConverter.ToCoreBlock(block)
|
||||||
@ -381,7 +381,7 @@ var _ = Describe("Conversion of GethBlock to core.Block", func() {
|
|||||||
It("returns an error when transaction receipt call fails", func() {
|
It("returns an error when transaction receipt call fails", func() {
|
||||||
client := fakes.NewMockEthClient()
|
client := fakes.NewMockEthClient()
|
||||||
client.SetTransactionReceiptErr(fakes.FakeError)
|
client.SetTransactionReceiptErr(fakes.FakeError)
|
||||||
transactionConverter := rpc.NewRpcTransactionConverter(client)
|
transactionConverter := rpc.NewRPCTransactionConverter(client)
|
||||||
blockConverter := vulcCommon.NewBlockConverter(transactionConverter)
|
blockConverter := vulcCommon.NewBlockConverter(transactionConverter)
|
||||||
|
|
||||||
_, err := blockConverter.ToCoreBlock(block)
|
_, err := blockConverter.ToCoreBlock(block)
|
||||||
|
@ -23,5 +23,5 @@ import (
|
|||||||
|
|
||||||
type TransactionConverter interface {
|
type TransactionConverter interface {
|
||||||
ConvertBlockTransactionsToCore(gethBlock *types.Block) ([]core.TransactionModel, error)
|
ConvertBlockTransactionsToCore(gethBlock *types.Block) ([]core.TransactionModel, error)
|
||||||
ConvertRpcTransactionsToModels(transactions []core.RpcTransaction) ([]core.TransactionModel, error)
|
ConvertRPCTransactionsToModels(transactions []core.RPCTransaction) ([]core.TransactionModel, error)
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ import (
|
|||||||
vulcCommon "github.com/vulcanize/vulcanizedb/pkg/eth/converters/common"
|
vulcCommon "github.com/vulcanize/vulcanizedb/pkg/eth/converters/common"
|
||||||
)
|
)
|
||||||
|
|
||||||
type RpcTransactionConverter struct {
|
type RPCTransactionConverter struct {
|
||||||
client core.EthClient
|
client core.EthClient
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,11 +51,11 @@ type transactionData struct {
|
|||||||
S *big.Int
|
S *big.Int
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewRpcTransactionConverter(client core.EthClient) *RpcTransactionConverter {
|
func NewRPCTransactionConverter(client core.EthClient) *RPCTransactionConverter {
|
||||||
return &RpcTransactionConverter{client: client}
|
return &RPCTransactionConverter{client: client}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (converter *RpcTransactionConverter) ConvertRpcTransactionsToModels(transactions []core.RpcTransaction) ([]core.TransactionModel, error) {
|
func (converter *RPCTransactionConverter) ConvertRPCTransactionsToModels(transactions []core.RPCTransaction) ([]core.TransactionModel, error) {
|
||||||
var results []core.TransactionModel
|
var results []core.TransactionModel
|
||||||
for _, transaction := range transactions {
|
for _, transaction := range transactions {
|
||||||
txData, convertErr := getTransactionData(transaction)
|
txData, convertErr := getTransactionData(transaction)
|
||||||
@ -88,7 +88,7 @@ func (converter *RpcTransactionConverter) ConvertRpcTransactionsToModels(transac
|
|||||||
return results, nil
|
return results, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (converter *RpcTransactionConverter) ConvertBlockTransactionsToCore(gethBlock *types.Block) ([]core.TransactionModel, error) {
|
func (converter *RPCTransactionConverter) ConvertBlockTransactionsToCore(gethBlock *types.Block) ([]core.TransactionModel, error) {
|
||||||
var g errgroup.Group
|
var g errgroup.Group
|
||||||
coreTransactions := make([]core.TransactionModel, len(gethBlock.Transactions()))
|
coreTransactions := make([]core.TransactionModel, len(gethBlock.Transactions()))
|
||||||
|
|
||||||
@ -122,8 +122,8 @@ func (converter *RpcTransactionConverter) ConvertBlockTransactionsToCore(gethBlo
|
|||||||
return coreTransactions, nil
|
return coreTransactions, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rtc *RpcTransactionConverter) appendReceiptToTransaction(transaction core.TransactionModel) (core.TransactionModel, error) {
|
func (converter *RPCTransactionConverter) appendReceiptToTransaction(transaction core.TransactionModel) (core.TransactionModel, error) {
|
||||||
gethReceipt, err := rtc.client.TransactionReceipt(context.Background(), common.HexToHash(transaction.Hash))
|
gethReceipt, err := converter.client.TransactionReceipt(context.Background(), common.HexToHash(transaction.Hash))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return transaction, err
|
return transaction, err
|
||||||
}
|
}
|
||||||
@ -155,7 +155,7 @@ func convertGethTransactionToModel(transaction *types.Transaction, from *common.
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func getTransactionData(transaction core.RpcTransaction) (transactionData, error) {
|
func getTransactionData(transaction core.RPCTransaction) (transactionData, error) {
|
||||||
nonce, nonceErr := hexToBigInt(transaction.Nonce)
|
nonce, nonceErr := hexToBigInt(transaction.Nonce)
|
||||||
if nonceErr != nil {
|
if nonceErr != nil {
|
||||||
return transactionData{}, nonceErr
|
return transactionData{}, nonceErr
|
||||||
|
@ -25,16 +25,16 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var _ = Describe("RPC transaction converter", func() {
|
var _ = Describe("RPC transaction converter", func() {
|
||||||
var converter rpc.RpcTransactionConverter
|
var converter rpc.RPCTransactionConverter
|
||||||
|
|
||||||
BeforeEach(func() {
|
BeforeEach(func() {
|
||||||
converter = rpc.RpcTransactionConverter{}
|
converter = rpc.RPCTransactionConverter{}
|
||||||
})
|
})
|
||||||
|
|
||||||
It("converts hex fields to integers", func() {
|
It("converts hex fields to integers", func() {
|
||||||
rpcTransaction := getFakeRpcTransaction("0x1")
|
rpcTransaction := getFakeRpcTransaction("0x1")
|
||||||
|
|
||||||
transactionModels, err := converter.ConvertRpcTransactionsToModels([]core.RpcTransaction{rpcTransaction})
|
transactionModels, err := converter.ConvertRPCTransactionsToModels([]core.RPCTransaction{rpcTransaction})
|
||||||
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
Expect(len(transactionModels)).To(Equal(1))
|
Expect(len(transactionModels)).To(Equal(1))
|
||||||
@ -48,7 +48,7 @@ var _ = Describe("RPC transaction converter", func() {
|
|||||||
It("returns error if invalid hex cannot be converted", func() {
|
It("returns error if invalid hex cannot be converted", func() {
|
||||||
invalidTransaction := getFakeRpcTransaction("invalid")
|
invalidTransaction := getFakeRpcTransaction("invalid")
|
||||||
|
|
||||||
_, err := converter.ConvertRpcTransactionsToModels([]core.RpcTransaction{invalidTransaction})
|
_, err := converter.ConvertRPCTransactionsToModels([]core.RPCTransaction{invalidTransaction})
|
||||||
|
|
||||||
Expect(err).To(HaveOccurred())
|
Expect(err).To(HaveOccurred())
|
||||||
})
|
})
|
||||||
@ -56,7 +56,7 @@ var _ = Describe("RPC transaction converter", func() {
|
|||||||
It("copies RPC transaction hash, from, and to values to model", func() {
|
It("copies RPC transaction hash, from, and to values to model", func() {
|
||||||
rpcTransaction := getFakeRpcTransaction("0x1")
|
rpcTransaction := getFakeRpcTransaction("0x1")
|
||||||
|
|
||||||
transactionModels, err := converter.ConvertRpcTransactionsToModels([]core.RpcTransaction{rpcTransaction})
|
transactionModels, err := converter.ConvertRPCTransactionsToModels([]core.RPCTransaction{rpcTransaction})
|
||||||
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
Expect(len(transactionModels)).To(Equal(1))
|
Expect(len(transactionModels)).To(Equal(1))
|
||||||
@ -67,7 +67,7 @@ var _ = Describe("RPC transaction converter", func() {
|
|||||||
|
|
||||||
It("derives transaction RLP", func() {
|
It("derives transaction RLP", func() {
|
||||||
// actual transaction: https://kovan.etherscan.io/tx/0x3b29ef265425d304069c57e5145cd1c7558568b06d231775f50a693bee1aad4f
|
// actual transaction: https://kovan.etherscan.io/tx/0x3b29ef265425d304069c57e5145cd1c7558568b06d231775f50a693bee1aad4f
|
||||||
rpcTransaction := core.RpcTransaction{
|
rpcTransaction := core.RPCTransaction{
|
||||||
Nonce: "0x7aa9",
|
Nonce: "0x7aa9",
|
||||||
GasPrice: "0x3b9aca00",
|
GasPrice: "0x3b9aca00",
|
||||||
GasLimit: "0x7a120",
|
GasLimit: "0x7a120",
|
||||||
@ -82,7 +82,7 @@ var _ = Describe("RPC transaction converter", func() {
|
|||||||
TransactionIndex: "0xa",
|
TransactionIndex: "0xa",
|
||||||
}
|
}
|
||||||
|
|
||||||
transactionModels, err := converter.ConvertRpcTransactionsToModels([]core.RpcTransaction{rpcTransaction})
|
transactionModels, err := converter.ConvertRPCTransactionsToModels([]core.RPCTransaction{rpcTransaction})
|
||||||
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
Expect(len(transactionModels)).To(Equal(1))
|
Expect(len(transactionModels)).To(Equal(1))
|
||||||
@ -98,7 +98,7 @@ var _ = Describe("RPC transaction converter", func() {
|
|||||||
It("does not include transaction receipt", func() {
|
It("does not include transaction receipt", func() {
|
||||||
rpcTransaction := getFakeRpcTransaction("0x1")
|
rpcTransaction := getFakeRpcTransaction("0x1")
|
||||||
|
|
||||||
transactionModels, err := converter.ConvertRpcTransactionsToModels([]core.RpcTransaction{rpcTransaction})
|
transactionModels, err := converter.ConvertRPCTransactionsToModels([]core.RPCTransaction{rpcTransaction})
|
||||||
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
Expect(len(transactionModels)).To(Equal(1))
|
Expect(len(transactionModels)).To(Equal(1))
|
||||||
@ -106,8 +106,8 @@ var _ = Describe("RPC transaction converter", func() {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
func getFakeRpcTransaction(hex string) core.RpcTransaction {
|
func getFakeRpcTransaction(hex string) core.RPCTransaction {
|
||||||
return core.RpcTransaction{
|
return core.RPCTransaction{
|
||||||
Hash: "0x2",
|
Hash: "0x2",
|
||||||
Amount: hex,
|
Amount: hex,
|
||||||
GasLimit: hex,
|
GasLimit: hex,
|
||||||
|
@ -33,12 +33,12 @@ import (
|
|||||||
|
|
||||||
type IPropertiesReader interface {
|
type IPropertiesReader interface {
|
||||||
NodeInfo() (id string, name string)
|
NodeInfo() (id string, name string)
|
||||||
NetworkId() float64
|
NetworkID() float64
|
||||||
GenesisBlock() string
|
GenesisBlock() string
|
||||||
}
|
}
|
||||||
|
|
||||||
type PropertiesReader struct {
|
type PropertiesReader struct {
|
||||||
client core.RpcClient
|
client core.RPCClient
|
||||||
}
|
}
|
||||||
|
|
||||||
type ParityClient struct {
|
type ParityClient struct {
|
||||||
@ -57,18 +57,18 @@ type GanacheClient struct {
|
|||||||
PropertiesReader
|
PropertiesReader
|
||||||
}
|
}
|
||||||
|
|
||||||
func MakeNode(rpcClient core.RpcClient) core.Node {
|
func MakeNode(rpcClient core.RPCClient) core.Node {
|
||||||
pr := makePropertiesReader(rpcClient)
|
pr := makePropertiesReader(rpcClient)
|
||||||
id, name := pr.NodeInfo()
|
id, name := pr.NodeInfo()
|
||||||
return core.Node{
|
return core.Node{
|
||||||
GenesisBlock: pr.GenesisBlock(),
|
GenesisBlock: pr.GenesisBlock(),
|
||||||
NetworkID: pr.NetworkId(),
|
NetworkID: pr.NetworkID(),
|
||||||
ID: id,
|
ID: id,
|
||||||
ClientName: name,
|
ClientName: name,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func makePropertiesReader(client core.RpcClient) IPropertiesReader {
|
func makePropertiesReader(client core.RPCClient) IPropertiesReader {
|
||||||
switch getNodeType(client) {
|
switch getNodeType(client) {
|
||||||
case core.GETH:
|
case core.GETH:
|
||||||
return GethClient{PropertiesReader: PropertiesReader{client: client}}
|
return GethClient{PropertiesReader: PropertiesReader{client: client}}
|
||||||
@ -83,7 +83,7 @@ func makePropertiesReader(client core.RpcClient) IPropertiesReader {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func getNodeType(client core.RpcClient) core.NodeType {
|
func getNodeType(client core.RPCClient) core.NodeType {
|
||||||
if strings.Contains(client.IpcPath(), "infura") {
|
if strings.Contains(client.IpcPath(), "infura") {
|
||||||
return core.INFURA
|
return core.INFURA
|
||||||
}
|
}
|
||||||
@ -97,14 +97,14 @@ func getNodeType(client core.RpcClient) core.NodeType {
|
|||||||
return core.PARITY
|
return core.PARITY
|
||||||
}
|
}
|
||||||
|
|
||||||
func (reader PropertiesReader) NetworkId() float64 {
|
func (reader PropertiesReader) NetworkID() float64 {
|
||||||
var version string
|
var version string
|
||||||
err := reader.client.CallContext(context.Background(), &version, "net_version")
|
err := reader.client.CallContext(context.Background(), &version, "net_version")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println(err)
|
log.Println(err)
|
||||||
}
|
}
|
||||||
networkId, _ := strconv.ParseFloat(version, 64)
|
networkID, _ := strconv.ParseFloat(version, 64)
|
||||||
return networkId
|
return networkID
|
||||||
}
|
}
|
||||||
|
|
||||||
func (reader PropertiesReader) GenesisBlock() string {
|
func (reader PropertiesReader) GenesisBlock() string {
|
||||||
@ -142,10 +142,10 @@ func (client ParityClient) parityNodeInfo() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (client ParityClient) parityID() string {
|
func (client ParityClient) parityID() string {
|
||||||
var enodeId = regexp.MustCompile(`^enode://(.+)@.+$`)
|
var enodeID = regexp.MustCompile(`^enode://(.+)@.+$`)
|
||||||
var enodeURL string
|
var enodeURL string
|
||||||
client.client.CallContext(context.Background(), &enodeURL, "parity_enode")
|
client.client.CallContext(context.Background(), &enodeURL, "parity_enode")
|
||||||
enode := enodeId.FindStringSubmatch(enodeURL)
|
enode := enodeID.FindStringSubmatch(enodeURL)
|
||||||
if len(enode) < 2 {
|
if len(enode) < 2 {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
@ -65,7 +65,7 @@ var _ = Describe("Node Info", func() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
It("returns parity ID and client name for parity node", func() {
|
It("returns parity ID and client name for parity node", func() {
|
||||||
client := fakes.NewMockRpcClient()
|
client := fakes.NewMockRPCClient()
|
||||||
|
|
||||||
n := node.MakeNode(client)
|
n := node.MakeNode(client)
|
||||||
Expect(n.ID).To(Equal("ParityNode"))
|
Expect(n.ID).To(Equal("ParityNode"))
|
||||||
@ -74,19 +74,19 @@ var _ = Describe("Node Info", func() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
It("returns the genesis block for any client", func() {
|
It("returns the genesis block for any client", func() {
|
||||||
client := fakes.NewMockRpcClient()
|
client := fakes.NewMockRPCClient()
|
||||||
n := node.MakeNode(client)
|
n := node.MakeNode(client)
|
||||||
Expect(n.GenesisBlock).To(Equal(EmpytHeaderHash))
|
Expect(n.GenesisBlock).To(Equal(EmpytHeaderHash))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("returns the network id for any client", func() {
|
It("returns the network id for any client", func() {
|
||||||
client := fakes.NewMockRpcClient()
|
client := fakes.NewMockRPCClient()
|
||||||
n := node.MakeNode(client)
|
n := node.MakeNode(client)
|
||||||
Expect(n.NetworkID).To(Equal(float64(1234)))
|
Expect(n.NetworkID).To(Equal(float64(1234)))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("returns geth ID and client name for geth node", func() {
|
It("returns geth ID and client name for geth node", func() {
|
||||||
client := fakes.NewMockRpcClient()
|
client := fakes.NewMockRPCClient()
|
||||||
supportedModules := make(map[string]string)
|
supportedModules := make(map[string]string)
|
||||||
supportedModules["admin"] = "ok"
|
supportedModules["admin"] = "ok"
|
||||||
client.SetSupporedModules(supportedModules)
|
client.SetSupporedModules(supportedModules)
|
||||||
@ -97,7 +97,7 @@ var _ = Describe("Node Info", func() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
It("returns infura ID and client name for infura node", func() {
|
It("returns infura ID and client name for infura node", func() {
|
||||||
client := fakes.NewMockRpcClient()
|
client := fakes.NewMockRPCClient()
|
||||||
client.SetIpcPath("infura/path")
|
client.SetIpcPath("infura/path")
|
||||||
n := node.MakeNode(client)
|
n := node.MakeNode(client)
|
||||||
Expect(n.ID).To(Equal("infura"))
|
Expect(n.ID).To(Equal("infura"))
|
||||||
@ -105,7 +105,7 @@ var _ = Describe("Node Info", func() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
It("returns local id and client name for Local node", func() {
|
It("returns local id and client name for Local node", func() {
|
||||||
client := fakes.NewMockRpcClient()
|
client := fakes.NewMockRPCClient()
|
||||||
client.SetIpcPath("127.0.0.1")
|
client.SetIpcPath("127.0.0.1")
|
||||||
n := node.MakeNode(client)
|
n := node.MakeNode(client)
|
||||||
Expect(n.ID).To(Equal("ganache"))
|
Expect(n.ID).To(Equal("ganache"))
|
||||||
|
@ -31,7 +31,7 @@ type MockBlockRepository struct {
|
|||||||
createOrUpdateBlockReturnInt int64
|
createOrUpdateBlockReturnInt int64
|
||||||
missingBlockNumbersCalled bool
|
missingBlockNumbersCalled bool
|
||||||
missingBlockNumbersPassedEndingBlockNumber int64
|
missingBlockNumbersPassedEndingBlockNumber int64
|
||||||
missingBlockNumbersPassedNodeId string
|
missingBlockNumbersPassedNodeID string
|
||||||
missingBlockNumbersPassedStartingBlockNumber int64
|
missingBlockNumbersPassedStartingBlockNumber int64
|
||||||
missingBlockNumbersReturnArray []int64
|
missingBlockNumbersReturnArray []int64
|
||||||
setBlockStatusCalled bool
|
setBlockStatusCalled bool
|
||||||
@ -48,7 +48,7 @@ func NewMockBlockRepository() *MockBlockRepository {
|
|||||||
createOrUpdateBlockReturnInt: 0,
|
createOrUpdateBlockReturnInt: 0,
|
||||||
missingBlockNumbersCalled: false,
|
missingBlockNumbersCalled: false,
|
||||||
missingBlockNumbersPassedEndingBlockNumber: 0,
|
missingBlockNumbersPassedEndingBlockNumber: 0,
|
||||||
missingBlockNumbersPassedNodeId: "",
|
missingBlockNumbersPassedNodeID: "",
|
||||||
missingBlockNumbersPassedStartingBlockNumber: 0,
|
missingBlockNumbersPassedStartingBlockNumber: 0,
|
||||||
missingBlockNumbersReturnArray: nil,
|
missingBlockNumbersReturnArray: nil,
|
||||||
setBlockStatusCalled: false,
|
setBlockStatusCalled: false,
|
||||||
@ -77,11 +77,11 @@ func (repository *MockBlockRepository) GetBlock(blockNumber int64) (core.Block,
|
|||||||
return core.Block{Number: blockNumber}, nil
|
return core.Block{Number: blockNumber}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (repository *MockBlockRepository) MissingBlockNumbers(startingBlockNumber int64, endingBlockNumber int64, nodeId string) []int64 {
|
func (repository *MockBlockRepository) MissingBlockNumbers(startingBlockNumber int64, endingBlockNumber int64, nodeID string) []int64 {
|
||||||
repository.missingBlockNumbersCalled = true
|
repository.missingBlockNumbersCalled = true
|
||||||
repository.missingBlockNumbersPassedStartingBlockNumber = startingBlockNumber
|
repository.missingBlockNumbersPassedStartingBlockNumber = startingBlockNumber
|
||||||
repository.missingBlockNumbersPassedEndingBlockNumber = endingBlockNumber
|
repository.missingBlockNumbersPassedEndingBlockNumber = endingBlockNumber
|
||||||
repository.missingBlockNumbersPassedNodeId = nodeId
|
repository.missingBlockNumbersPassedNodeID = nodeID
|
||||||
return repository.missingBlockNumbersReturnArray
|
return repository.missingBlockNumbersReturnArray
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,11 +105,11 @@ func (repository *MockBlockRepository) AssertCreateOrUpdateBlockCalledWith(block
|
|||||||
Expect(repository.createOrUpdateBlockPassedBlock).To(Equal(block))
|
Expect(repository.createOrUpdateBlockPassedBlock).To(Equal(block))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (repository *MockBlockRepository) AssertMissingBlockNumbersCalledWith(startingBlockNumber int64, endingBlockNumber int64, nodeId string) {
|
func (repository *MockBlockRepository) AssertMissingBlockNumbersCalledWith(startingBlockNumber int64, endingBlockNumber int64, nodeID string) {
|
||||||
Expect(repository.missingBlockNumbersCalled).To(BeTrue())
|
Expect(repository.missingBlockNumbersCalled).To(BeTrue())
|
||||||
Expect(repository.missingBlockNumbersPassedStartingBlockNumber).To(Equal(startingBlockNumber))
|
Expect(repository.missingBlockNumbersPassedStartingBlockNumber).To(Equal(startingBlockNumber))
|
||||||
Expect(repository.missingBlockNumbersPassedEndingBlockNumber).To(Equal(endingBlockNumber))
|
Expect(repository.missingBlockNumbersPassedEndingBlockNumber).To(Equal(endingBlockNumber))
|
||||||
Expect(repository.missingBlockNumbersPassedNodeId).To(Equal(nodeId))
|
Expect(repository.missingBlockNumbersPassedNodeID).To(Equal(nodeID))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (repository *MockBlockRepository) AssertSetBlockStatusCalledWith(chainHead int64) {
|
func (repository *MockBlockRepository) AssertSetBlockStatusCalledWith(chainHead int64) {
|
||||||
|
@ -75,23 +75,23 @@ func (chain *MockBlockChain) SetGetEthLogsWithCustomQueryReturnLogs(logs []types
|
|||||||
chain.logQueryReturnLogs = logs
|
chain.logQueryReturnLogs = logs
|
||||||
}
|
}
|
||||||
|
|
||||||
func (blockChain *MockBlockChain) FetchContractData(abiJSON string, address string, method string, methodArgs []interface{}, result interface{}, blockNumber int64) error {
|
func (chain *MockBlockChain) FetchContractData(abiJSON string, address string, method string, methodArgs []interface{}, result interface{}, blockNumber int64) error {
|
||||||
blockChain.fetchContractDataPassedAbi = abiJSON
|
chain.fetchContractDataPassedAbi = abiJSON
|
||||||
blockChain.fetchContractDataPassedAddress = address
|
chain.fetchContractDataPassedAddress = address
|
||||||
blockChain.fetchContractDataPassedMethod = method
|
chain.fetchContractDataPassedMethod = method
|
||||||
blockChain.fetchContractDataPassedMethodArgs = methodArgs
|
chain.fetchContractDataPassedMethodArgs = methodArgs
|
||||||
blockChain.fetchContractDataPassedResult = result
|
chain.fetchContractDataPassedResult = result
|
||||||
blockChain.fetchContractDataPassedBlockNumber = blockNumber
|
chain.fetchContractDataPassedBlockNumber = blockNumber
|
||||||
return blockChain.fetchContractDataErr
|
return chain.fetchContractDataErr
|
||||||
}
|
}
|
||||||
|
|
||||||
func (chain *MockBlockChain) GetBlockByNumber(blockNumber int64) (core.Block, error) {
|
func (chain *MockBlockChain) GetBlockByNumber(blockNumber int64) (core.Block, error) {
|
||||||
return core.Block{Number: blockNumber}, chain.getBlockByNumberErr
|
return core.Block{Number: blockNumber}, chain.getBlockByNumberErr
|
||||||
}
|
}
|
||||||
|
|
||||||
func (blockChain *MockBlockChain) GetEthLogsWithCustomQuery(query ethereum.FilterQuery) ([]types.Log, error) {
|
func (chain *MockBlockChain) GetEthLogsWithCustomQuery(query ethereum.FilterQuery) ([]types.Log, error) {
|
||||||
blockChain.logQuery = query
|
chain.logQuery = query
|
||||||
return blockChain.logQueryReturnLogs, blockChain.logQueryErr
|
return chain.logQueryReturnLogs, chain.logQueryErr
|
||||||
}
|
}
|
||||||
|
|
||||||
func (chain *MockBlockChain) GetHeaderByNumber(blockNumber int64) (core.Header, error) {
|
func (chain *MockBlockChain) GetHeaderByNumber(blockNumber int64) (core.Header, error) {
|
||||||
@ -140,18 +140,18 @@ func (chain *MockBlockChain) AssertFetchContractDataCalledWith(abiJSON string, a
|
|||||||
Expect(chain.fetchContractDataPassedBlockNumber).To(Equal(blockNumber))
|
Expect(chain.fetchContractDataPassedBlockNumber).To(Equal(blockNumber))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (blockChain *MockBlockChain) AssertGetEthLogsWithCustomQueryCalledWith(query ethereum.FilterQuery) {
|
func (chain *MockBlockChain) AssertGetEthLogsWithCustomQueryCalledWith(query ethereum.FilterQuery) {
|
||||||
Expect(blockChain.logQuery).To(Equal(query))
|
Expect(chain.logQuery).To(Equal(query))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (blockChain *MockBlockChain) SetGetAccountBalanceErr(err error) {
|
func (chain *MockBlockChain) SetGetAccountBalanceErr(err error) {
|
||||||
blockChain.getAccountBalanceErr = err
|
chain.getAccountBalanceErr = err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (blockChain *MockBlockChain) SetGetAccountBalance(balance *big.Int) {
|
func (chain *MockBlockChain) SetGetAccountBalance(balance *big.Int) {
|
||||||
blockChain.accountBalanceReturnValue = balance
|
chain.accountBalanceReturnValue = balance
|
||||||
}
|
}
|
||||||
|
|
||||||
func (blockChain *MockBlockChain) GetAccountBalance(address common.Address, blockNumber *big.Int) (*big.Int, error) {
|
func (chain *MockBlockChain) GetAccountBalance(address common.Address, blockNumber *big.Int) (*big.Int, error) {
|
||||||
return blockChain.accountBalanceReturnValue, blockChain.getAccountBalanceErr
|
return chain.accountBalanceReturnValue, chain.getAccountBalanceErr
|
||||||
}
|
}
|
||||||
|
@ -31,8 +31,8 @@ func (*MockParser) Parse(contractAddr string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *MockParser) ParseAbiStr(abiStr string) error {
|
func (parser *MockParser) ParseAbiStr(abiStr string) error {
|
||||||
m.AbiToReturn = abiStr
|
parser.AbiToReturn = abiStr
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ import (
|
|||||||
|
|
||||||
type MockReceiptRepository struct {
|
type MockReceiptRepository struct {
|
||||||
createReceiptsAndLogsCalled bool
|
createReceiptsAndLogsCalled bool
|
||||||
createReceiptsAndLogsPassedBlockId int64
|
createReceiptsAndLogsPassedBlockID int64
|
||||||
createReceiptsAndLogsPassedReceipts []core.Receipt
|
createReceiptsAndLogsPassedReceipts []core.Receipt
|
||||||
createReceiptsAndLogsReturnErr error
|
createReceiptsAndLogsReturnErr error
|
||||||
}
|
}
|
||||||
@ -33,7 +33,7 @@ type MockReceiptRepository struct {
|
|||||||
func NewMockReceiptRepository() *MockReceiptRepository {
|
func NewMockReceiptRepository() *MockReceiptRepository {
|
||||||
return &MockReceiptRepository{
|
return &MockReceiptRepository{
|
||||||
createReceiptsAndLogsCalled: false,
|
createReceiptsAndLogsCalled: false,
|
||||||
createReceiptsAndLogsPassedBlockId: 0,
|
createReceiptsAndLogsPassedBlockID: 0,
|
||||||
createReceiptsAndLogsPassedReceipts: nil,
|
createReceiptsAndLogsPassedReceipts: nil,
|
||||||
createReceiptsAndLogsReturnErr: nil,
|
createReceiptsAndLogsReturnErr: nil,
|
||||||
}
|
}
|
||||||
@ -43,14 +43,14 @@ func (mrr *MockReceiptRepository) SetCreateReceiptsAndLogsReturnErr(err error) {
|
|||||||
mrr.createReceiptsAndLogsReturnErr = err
|
mrr.createReceiptsAndLogsReturnErr = err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (mrr *MockReceiptRepository) CreateReceiptsAndLogs(blockId int64, receipts []core.Receipt) error {
|
func (mrr *MockReceiptRepository) CreateReceiptsAndLogs(blockID int64, receipts []core.Receipt) error {
|
||||||
mrr.createReceiptsAndLogsCalled = true
|
mrr.createReceiptsAndLogsCalled = true
|
||||||
mrr.createReceiptsAndLogsPassedBlockId = blockId
|
mrr.createReceiptsAndLogsPassedBlockID = blockID
|
||||||
mrr.createReceiptsAndLogsPassedReceipts = receipts
|
mrr.createReceiptsAndLogsPassedReceipts = receipts
|
||||||
return mrr.createReceiptsAndLogsReturnErr
|
return mrr.createReceiptsAndLogsReturnErr
|
||||||
}
|
}
|
||||||
|
|
||||||
func (mrr *MockReceiptRepository) CreateFullSyncReceiptInTx(blockId int64, receipt core.Receipt, tx *sqlx.Tx) (int64, error) {
|
func (mrr *MockReceiptRepository) CreateFullSyncReceiptInTx(blockID int64, receipt core.Receipt, tx *sqlx.Tx) (int64, error) {
|
||||||
panic("implement me")
|
panic("implement me")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,9 +58,9 @@ func (mrr *MockReceiptRepository) GetFullSyncReceipt(txHash string) (core.Receip
|
|||||||
panic("implement me")
|
panic("implement me")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (mrr *MockReceiptRepository) AssertCreateReceiptsAndLogsCalledWith(blockId int64, receipts []core.Receipt) {
|
func (mrr *MockReceiptRepository) AssertCreateReceiptsAndLogsCalledWith(blockID int64, receipts []core.Receipt) {
|
||||||
Expect(mrr.createReceiptsAndLogsCalled).To(BeTrue())
|
Expect(mrr.createReceiptsAndLogsCalled).To(BeTrue())
|
||||||
Expect(mrr.createReceiptsAndLogsPassedBlockId).To(Equal(blockId))
|
Expect(mrr.createReceiptsAndLogsPassedBlockID).To(Equal(blockID))
|
||||||
Expect(mrr.createReceiptsAndLogsPassedReceipts).To(Equal(receipts))
|
Expect(mrr.createReceiptsAndLogsPassedReceipts).To(Equal(receipts))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ import (
|
|||||||
"github.com/vulcanize/vulcanizedb/pkg/eth/client"
|
"github.com/vulcanize/vulcanizedb/pkg/eth/client"
|
||||||
)
|
)
|
||||||
|
|
||||||
type MockRpcClient struct {
|
type MockRPCClient struct {
|
||||||
callContextErr error
|
callContextErr error
|
||||||
ipcPath string
|
ipcPath string
|
||||||
nodeType core.NodeType
|
nodeType core.NodeType
|
||||||
@ -49,7 +49,7 @@ type MockRpcClient struct {
|
|||||||
supportedModules map[string]string
|
supportedModules map[string]string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (client *MockRpcClient) Subscribe(namespace string, payloadChan interface{}, args ...interface{}) (*rpc.ClientSubscription, error) {
|
func (client *MockRPCClient) Subscribe(namespace string, payloadChan interface{}, args ...interface{}) (*rpc.ClientSubscription, error) {
|
||||||
client.passedNamespace = namespace
|
client.passedNamespace = namespace
|
||||||
|
|
||||||
passedPayloadChan, ok := payloadChan.(chan statediff.Payload)
|
passedPayloadChan, ok := payloadChan.(chan statediff.Payload)
|
||||||
@ -66,21 +66,21 @@ func (client *MockRpcClient) Subscribe(namespace string, payloadChan interface{}
|
|||||||
return &subscription, nil
|
return &subscription, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (client *MockRpcClient) AssertSubscribeCalledWith(namespace string, payloadChan chan statediff.Payload, args []interface{}) {
|
func (client *MockRPCClient) AssertSubscribeCalledWith(namespace string, payloadChan chan statediff.Payload, args []interface{}) {
|
||||||
Expect(client.passedNamespace).To(Equal(namespace))
|
Expect(client.passedNamespace).To(Equal(namespace))
|
||||||
Expect(client.passedPayloadChan).To(Equal(payloadChan))
|
Expect(client.passedPayloadChan).To(Equal(payloadChan))
|
||||||
Expect(client.passedSubscribeArgs).To(Equal(args))
|
Expect(client.passedSubscribeArgs).To(Equal(args))
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewMockRpcClient() *MockRpcClient {
|
func NewMockRPCClient() *MockRPCClient {
|
||||||
return &MockRpcClient{}
|
return &MockRPCClient{}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (client *MockRpcClient) SetIpcPath(ipcPath string) {
|
func (client *MockRPCClient) SetIpcPath(ipcPath string) {
|
||||||
client.ipcPath = ipcPath
|
client.ipcPath = ipcPath
|
||||||
}
|
}
|
||||||
|
|
||||||
func (client *MockRpcClient) BatchCall(batch []client.BatchElem) error {
|
func (client *MockRPCClient) BatchCall(batch []client.BatchElem) error {
|
||||||
client.passedBatch = batch
|
client.passedBatch = batch
|
||||||
client.passedMethod = batch[0].Method
|
client.passedMethod = batch[0].Method
|
||||||
client.lengthOfBatch = len(batch)
|
client.lengthOfBatch = len(batch)
|
||||||
@ -101,7 +101,7 @@ func (client *MockRpcClient) BatchCall(batch []client.BatchElem) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (client *MockRpcClient) CallContext(ctx context.Context, result interface{}, method string, args ...interface{}) error {
|
func (client *MockRPCClient) CallContext(ctx context.Context, result interface{}, method string, args ...interface{}) error {
|
||||||
client.passedContext = ctx
|
client.passedContext = ctx
|
||||||
client.passedResult = result
|
client.passedResult = result
|
||||||
client.passedMethod = method
|
client.passedMethod = method
|
||||||
@ -146,41 +146,41 @@ func (client *MockRpcClient) CallContext(ctx context.Context, result interface{}
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (client *MockRpcClient) IpcPath() string {
|
func (client *MockRPCClient) IpcPath() string {
|
||||||
return client.ipcPath
|
return client.ipcPath
|
||||||
}
|
}
|
||||||
|
|
||||||
func (client *MockRpcClient) SupportedModules() (map[string]string, error) {
|
func (client *MockRPCClient) SupportedModules() (map[string]string, error) {
|
||||||
return client.supportedModules, nil
|
return client.supportedModules, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (client *MockRpcClient) SetSupporedModules(supportedModules map[string]string) {
|
func (client *MockRPCClient) SetSupporedModules(supportedModules map[string]string) {
|
||||||
client.supportedModules = supportedModules
|
client.supportedModules = supportedModules
|
||||||
}
|
}
|
||||||
|
|
||||||
func (client *MockRpcClient) SetCallContextErr(err error) {
|
func (client *MockRPCClient) SetCallContextErr(err error) {
|
||||||
client.callContextErr = err
|
client.callContextErr = err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (client *MockRpcClient) SetReturnPOAHeader(header core.POAHeader) {
|
func (client *MockRPCClient) SetReturnPOAHeader(header core.POAHeader) {
|
||||||
client.returnPOAHeader = header
|
client.returnPOAHeader = header
|
||||||
}
|
}
|
||||||
|
|
||||||
func (client *MockRpcClient) SetReturnPOWHeaders(headers []*types.Header) {
|
func (client *MockRPCClient) SetReturnPOWHeaders(headers []*types.Header) {
|
||||||
client.returnPOWHeaders = headers
|
client.returnPOWHeaders = headers
|
||||||
}
|
}
|
||||||
|
|
||||||
func (client *MockRpcClient) SetReturnPOAHeaders(headers []core.POAHeader) {
|
func (client *MockRPCClient) SetReturnPOAHeaders(headers []core.POAHeader) {
|
||||||
client.returnPOAHeaders = headers
|
client.returnPOAHeaders = headers
|
||||||
}
|
}
|
||||||
|
|
||||||
func (client *MockRpcClient) AssertCallContextCalledWith(ctx context.Context, result interface{}, method string) {
|
func (client *MockRPCClient) AssertCallContextCalledWith(ctx context.Context, result interface{}, method string) {
|
||||||
Expect(client.passedContext).To(Equal(ctx))
|
Expect(client.passedContext).To(Equal(ctx))
|
||||||
Expect(client.passedResult).To(BeAssignableToTypeOf(result))
|
Expect(client.passedResult).To(BeAssignableToTypeOf(result))
|
||||||
Expect(client.passedMethod).To(Equal(method))
|
Expect(client.passedMethod).To(Equal(method))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (client *MockRpcClient) AssertBatchCalledWith(method string, lengthOfBatch int) {
|
func (client *MockRPCClient) AssertBatchCalledWith(method string, lengthOfBatch int) {
|
||||||
Expect(client.lengthOfBatch).To(Equal(lengthOfBatch))
|
Expect(client.lengthOfBatch).To(Equal(lengthOfBatch))
|
||||||
for _, batch := range client.passedBatch {
|
for _, batch := range client.passedBatch {
|
||||||
Expect(batch.Method).To(Equal(method))
|
Expect(batch.Method).To(Equal(method))
|
||||||
|
@ -41,7 +41,7 @@ func (converter *MockTransactionConverter) ConvertBlockTransactionsToCore(gethBl
|
|||||||
return []core.TransactionModel{}, nil
|
return []core.TransactionModel{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (converter *MockTransactionConverter) ConvertRpcTransactionsToModels(transactions []core.RpcTransaction) ([]core.TransactionModel, error) {
|
func (converter *MockTransactionConverter) ConvertRPCTransactionsToModels(transactions []core.RPCTransaction) ([]core.TransactionModel, error) {
|
||||||
converter.ConvertHeaderTransactionIndexToIntCalled = true
|
converter.ConvertHeaderTransactionIndexToIntCalled = true
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
@ -120,9 +120,9 @@ func NewTestNode() core.Node {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewTestBlock(blockNumber int64, repository repositories.BlockRepository) (blockId int64) {
|
func NewTestBlock(blockNumber int64, repository repositories.BlockRepository) int64 {
|
||||||
blockId, err := repository.CreateOrUpdateBlock(core.Block{Number: blockNumber})
|
blockID, err := repository.CreateOrUpdateBlock(core.Block{Number: blockNumber})
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
|
||||||
return blockId
|
return blockID
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user