Init defines init process for client.
(configFile string, masterKey []byte)
| 130 | |
| 131 | // Init defines init process for client. |
| 132 | func Init(configFile string, masterKey []byte) (err error) { |
| 133 | if !atomic.CompareAndSwapUint32(&driverInitialized, 0, 1) { |
| 134 | err = ErrAlreadyInitialized |
| 135 | return |
| 136 | } |
| 137 | |
| 138 | // load config |
| 139 | if conf.GConf, err = conf.LoadConfig(configFile); err != nil { |
| 140 | return |
| 141 | } |
| 142 | |
| 143 | route.InitKMS(conf.GConf.PubKeyStoreFile) |
| 144 | if err = kms.InitLocalKeyPair(conf.GConf.PrivateKeyFile, masterKey); err != nil { |
| 145 | return |
| 146 | } |
| 147 | |
| 148 | // ping block producer to register node |
| 149 | if err = registerNode(); err != nil { |
| 150 | return |
| 151 | } |
| 152 | |
| 153 | // run peers updater |
| 154 | if err = runPeerListUpdater(); err != nil { |
| 155 | return |
| 156 | } |
| 157 | |
| 158 | return |
| 159 | } |
| 160 | |
| 161 | // Create sends create database operation to block producer. |
| 162 | func Create(meta ResourceMeta) (txHash hash.Hash, dsn string, err error) { |