forked from cerc-io/ipld-eth-server
* The command populates up to the highest known block number
* The anticipated use case is that the listener will be running
in parallel to the populateBlocks command
* This will mean that the listener is responsible for picking up
new blocks, and the populateBlocks command is reposible for
historical blocks
* Reformat SQL statements
16 lines
499 B
Go
16 lines
499 B
Go
package history
|
|
|
|
import (
|
|
"github.com/8thlight/vulcanizedb/pkg/core"
|
|
"github.com/8thlight/vulcanizedb/pkg/repositories"
|
|
)
|
|
|
|
func PopulateBlocks(blockchain core.Blockchain, repository repositories.Repository, startingBlockNumber int64) int {
|
|
blockNumbers := repository.MissingBlockNumbers(startingBlockNumber, repository.MaxBlockNumber())
|
|
for _, blockNumber := range blockNumbers {
|
|
block := blockchain.GetBlockByNumber(blockNumber)
|
|
repository.CreateBlock(block)
|
|
}
|
|
return len(blockNumbers)
|
|
}
|