(ctx context.Context)
| 160 | } |
| 161 | |
| 162 | func asyncSQL(ctx context.Context) { |
| 163 | utils.GoWithRecover(func() { |
| 164 | for { |
| 165 | select { |
| 166 | case <-ctx.Done(): |
| 167 | return |
| 168 | case s := <-p2pPubSub.Inbound: |
| 169 | _, err := db.Exec(s.Message) |
| 170 | if err != nil { |
| 171 | logrus.Infof("Inbound sql: %s err: %v", s, err) |
| 172 | continue |
| 173 | } |
| 174 | logrus.Infof("Inbound sql: %s", s.Message) |
| 175 | } |
| 176 | } |
| 177 | }, func(r any) { |
| 178 | time.Sleep(time.Second) |
| 179 | asyncSQL(ctx) |
| 180 | }) |
| 181 | } |
| 182 | |
| 183 | func getTableName(sql string) string { |
| 184 | s := strings.ToLower(sql) |
no test coverage detected