InitBP initializes kms.BP struct with conf.GConf.
()
| 91 | |
| 92 | // InitBP initializes kms.BP struct with conf.GConf. |
| 93 | func InitBP() { |
| 94 | if conf.GConf == nil { |
| 95 | log.Fatal("must call conf.LoadConfig first") |
| 96 | } |
| 97 | if conf.GConf.BP == nil && len(conf.GConf.SeedBPNodes) > 0 { |
| 98 | seedBP := &conf.GConf.SeedBPNodes[0] |
| 99 | conf.GConf.BP = &conf.BPInfo{ |
| 100 | PublicKey: seedBP.PublicKey, |
| 101 | NodeID: seedBP.ID, |
| 102 | Nonce: seedBP.Nonce, |
| 103 | } |
| 104 | } |
| 105 | if conf.GConf.BP == nil { |
| 106 | log.Fatal("no available block producer config") |
| 107 | } |
| 108 | |
| 109 | BP = conf.GConf.BP |
| 110 | err := hash.Decode(&conf.GConf.BP.RawNodeID.Hash, string(conf.GConf.BP.NodeID)) |
| 111 | if err != nil { |
| 112 | log.WithError(err).Fatal("BP.NodeID error") |
| 113 | } |
| 114 | } |
| 115 | |
| 116 | var ( |
| 117 | // ErrPKSNotInitialized indicates public keystore not initialized |