func NewMonitor(conf *Config, c Client, db *reform.DB, l log.Logger, psc,
	ptc common.Address, role string, q Queue) (*Monitor, error) {
	abiJSON := contract.PrivatixServiceContractABI
	pscABI, err := abi.JSON(strings.NewReader(abiJSON))
	if err != nil {
		l.Error(err.Error())
		return nil, ErrFailedToParseABI
	}
	abiJSON2 := contract.PrivatixTokenContractABI
	ptcABI, err := abi.JSON(strings.NewReader(abiJSON2))
	if err != nil {
		l.Error(err.Error())
		return nil, ErrFailedToParseABI
	}
	ethCallTimeout := time.Duration(conf.EthCallTimeout) * time.Millisecond
	queryPause := time.Duration(conf.QueryPause) * time.Millisecond
	m := &Monitor{
		db:             db,
		eth:            c,
		logger:         l.Add("type", "monitor.Monitor"),
		queue:          q,
		ethCallTimeout: ethCallTimeout,
		pscABI:         pscABI,
		ptcABI:         ptcABI,
		pscAddr:        psc,
		queryPause:     queryPause,
	}

	m.initLastProcessedBlock(role, conf.InitialBlocks)

	f := m.clientQueries
	m.jobsProducers = m.clientJobsProducers()
	if role == data.RoleAgent {
		f = m.agentQueries
		m.jobsProducers = m.agentJobsProducers()
	}
	m.getFilterLogQueries = func(from, to uint64) ([]ethereum.FilterQuery, error) {
		return f(from, to, psc, ptc)
	}

	return m, nil
}
func NewMonitor(conf *Config, c Client, db *reform.DB, l log.Logger, psc,
	ptc common.Address, role string, q Queue) (*Monitor, error) {
	abiJSON := contract.PrivatixServiceContractABI
	pscABI, err := abi.JSON(strings.NewReader(abiJSON))
	if err != nil {
		l.Error(err.Error())
		return nil, ErrFailedToParseABI
	}
	abiJSON2 := contract.PrivatixTokenContractABI
	ptcABI, err := abi.JSON(strings.NewReader(abiJSON2))
	if err != nil {
		l.Error(err.Error())
		return nil, ErrFailedToParseABI
	}
	ethCallTimeout := time.Duration(conf.EthCallTimeout) * time.Millisecond
	queryPause := time.Duration(conf.QueryPause) * time.Millisecond
	m := &Monitor{
		db:             db,
		eth:            c,
		logger:         l.Add("type", "monitor.Monitor"),
		queue:          q,
		ethCallTimeout: ethCallTimeout,
		pscABI:         pscABI,
		ptcABI:         ptcABI,
		pscAddr:        psc,
		queryPause:     queryPause,
	}

	m.initLastProcessedBlock(role, conf.InitialBlocks)

	f := m.clientQueries
	m.jobsProducers = m.clientJobsProducers()
	if role == data.RoleAgent {
		f = m.agentQueries
		m.jobsProducers = m.agentJobsProducers()
	}
	m.getFilterLogQueries = func(from, to uint64) ([]ethereum.FilterQuery, error) {
		return f(from, to, psc, ptc)
	}

	return m, nil
}
// NewMonitor creates new blockchain monitor.