NewBusService creates a new chain bus instance.
( ctx context.Context, addr proto.AccountAddress, checkInterval time.Duration)
| 53 | |
| 54 | // NewBusService creates a new chain bus instance. |
| 55 | func NewBusService( |
| 56 | ctx context.Context, addr proto.AccountAddress, checkInterval time.Duration) (_ *BusService, |
| 57 | ) { |
| 58 | ctd, ccl := context.WithCancel(ctx) |
| 59 | bs := &BusService{ |
| 60 | Bus: chainbus.New(), |
| 61 | wg: sync.WaitGroup{}, |
| 62 | caller: rpc.NewCaller(), |
| 63 | ctx: ctd, |
| 64 | cancel: ccl, |
| 65 | checkInterval: checkInterval, |
| 66 | localAddress: addr, |
| 67 | } |
| 68 | // State initialization: fetch last block and update fields `blockCount` and `sqlChainProfiles` |
| 69 | var _, profiles, count = bs.requestLastBlock() |
| 70 | bs.updateState(count, profiles) |
| 71 | return bs |
| 72 | } |
| 73 | |
| 74 | // GetCurrentDBMapping returns current cached db mapping. |
| 75 | func (bs *BusService) GetCurrentDBMapping() (dbMap map[proto.DatabaseID]*types.SQLChainProfile) { |