blockchain: TimeSource is required.

This commit is contained in:
David Hill 2017-01-12 11:19:51 -05:00
parent 7c0fd83c87
commit 406ddd17d3
2 changed files with 4 additions and 0 deletions

View file

@ -1683,6 +1683,9 @@ func New(config *Config) (*BlockChain, error) {
if config.ChainParams == nil { if config.ChainParams == nil {
return nil, AssertError("blockchain.New chain parameters nil") return nil, AssertError("blockchain.New chain parameters nil")
} }
if config.TimeSource == nil {
return nil, AssertError("blockchain.New timesource is nil")
}
// Generate a checkpoint by height map from the provided checkpoints. // Generate a checkpoint by height map from the provided checkpoints.
params := config.ChainParams params := config.ChainParams

View file

@ -153,6 +153,7 @@ func main() {
chain, err := blockchain.New(&blockchain.Config{ chain, err := blockchain.New(&blockchain.Config{
DB: db, DB: db,
ChainParams: activeNetParams, ChainParams: activeNetParams,
TimeSource: blockchain.NewMedianTime(),
}) })
if err != nil { if err != nil {
fmt.Fprintf(os.Stderr, "failed to initialize chain: %v\n", err) fmt.Fprintf(os.Stderr, "failed to initialize chain: %v\n", err)