| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 9ab6bc0 commit 6bf90a5
5 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -77,6 +77,10 @@ func main() { | |||
| 77 | 77 | } | |
| 78 | 78 | kms.InitBP() | |
| 79 | 79 | ||
| 80 | + if err = initNode(); err != nil { | ||
| 81 | + return | ||
| 82 | + } | ||
| 83 | + | ||
| 80 | 84 | service, httpServer, err := observer.StartObserver(listenAddr, version) | |
| 81 | 85 | if err != nil { | |
| 82 | 86 | log.WithError(err).Fatal("start observer failed") | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,5 +1,5 @@ | |||
| 1 | 1 | /* | |
| 2 | - * Copyright 2018 The CovenantSQL Authors. | ||
| 2 | + * Copyright 2019 The CovenantSQL Authors. | ||
| 3 | 3 | * | |
| 4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); | |
| 5 | 5 | * you may not use this file except in compliance with the License. | |
@@ -14,7 +14,7 @@ | |||
| 14 | 14 | * limitations under the License. | |
| 15 | 15 | */ | |
| 16 | 16 | ||
| 17 | - package observer | ||
| 17 | + package main | ||
| 18 | 18 | ||
| 19 | 19 | import ( | |
| 20 | 20 | "fmt" | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -292,13 +292,14 @@ func main() { | |||
| 292 | 292 | ||
| 293 | 293 | configFile = utils.HomeDirExpand(configFile) | |
| 294 | 294 | ||
| 295 | - if explorerAddr != "" { | ||
| 296 | - var err error | ||
| 297 | - conf.GConf, err = conf.LoadConfig(configFile) | ||
| 298 | - if err != nil { | ||
| 299 | - log.WithField("config", configFile).WithError(err).Fatal("load config failed") | ||
| 300 | - } | ||
| 295 | + // init covenantsql driver | ||
| 296 | + if err = client.Init(configFile, []byte(password)); err != nil { | ||
| 297 | + cLog.WithError(err).Error("init covenantsql client failed") | ||
| 298 | + os.Exit(-1) | ||
| 299 | + return | ||
| 300 | + } | ||
| 301 | 301 | ||
| 302 | + if explorerAddr != "" { | ||
| 302 | 303 | service, httpServer, err = observer.StartObserver(explorerAddr, version) | |
| 303 | 304 | if err != nil { | |
| 304 | 305 | log.WithError(err).Fatal("start explorer failed") | |
@@ -312,13 +313,6 @@ func main() { | |||
| 312 | 313 | _ = observer.StopObserver(service, httpServer) | |
| 313 | 314 | log.Info("explorer stopped") | |
| 314 | 315 | }() | |
| 315 | - } else { | ||
| 316 | - // init covenantsql driver | ||
| 317 | - if err = client.Init(configFile, []byte(password)); err != nil { | ||
| 318 | - cLog.WithError(err).Error("init covenantsql client failed") | ||
| 319 | - os.Exit(-1) | ||
| 320 | - return | ||
| 321 | - } | ||
| 322 | 316 | } | |
| 323 | 317 | ||
| 324 | 318 | // TODO(leventeliu): discover more specific confirmation duration from config. We don't have | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -63,11 +63,6 @@ func stopService(service *Service) (err error) { | |||
| 63 | 63 | ||
| 64 | 64 | // StartObserver starts the observer service and http API server. | |
| 65 | 65 | func StartObserver(listenAddr string, version string) (service *Service, httpServer *http.Server, err error) { | |
| 66 | - // init node | ||
| 67 | - if err = initNode(); err != nil { | ||
| 68 | - log.WithError(err).Fatal("init node failed") | ||
| 69 | - } | ||
| 70 | - | ||
| 71 | 66 | // start service | |
| 72 | 67 | if service, err = startService(); err != nil { | |
| 73 | 68 | log.WithError(err).Fatal("start observation failed") | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -309,6 +309,9 @@ func (s *Service) addBlock(dbID proto.DatabaseID, count int32, b *types.Block) ( | |||
| 309 | 309 | if err != nil { | |
| 310 | 310 | return | |
| 311 | 311 | } | |
| 312 | + if b == nil { | ||
| 313 | + return | ||
| 314 | + } | ||
| 312 | 315 | ||
| 313 | 316 | h := int32(b.Timestamp().Sub(instance.GenesisBlock.Timestamp()) / conf.GConf.SQLChainPeriod) | |
| 314 | 317 | key := utils.ConcatAll(int32ToBytes(h), b.BlockHash().AsBytes(), int32ToBytes(count)) | |
| Back | FazBrowse Home | New Git URL |
0 commit comments