Start connects to server and listen to new blocks for token exchanges.
(ctx context.Context)
| 131 | |
| 132 | // Start connects to server and listen to new blocks for token exchanges. |
| 133 | func (e *Exchange) Start(ctx context.Context) (err error) { |
| 134 | e.newBlockCh = make(chan *types.Block) |
| 135 | e.newBlockHeaderCh = make(chan *types.Header) |
| 136 | e.wg = &sync.WaitGroup{} |
| 137 | |
| 138 | err = e.connectServer(ctx) |
| 139 | if err != nil { |
| 140 | return |
| 141 | } |
| 142 | |
| 143 | // process old blocks |
| 144 | err = e.fetchOldBlocks(ctx) |
| 145 | |
| 146 | e.wg.Add(1) |
| 147 | go e.process() |
| 148 | |
| 149 | return |
| 150 | } |
| 151 | |
| 152 | // Stop stops the exchange service and disconnect from the ethereum network. |
| 153 | func (e *Exchange) Stop() { |
no test coverage detected