Skip to content

Add support for getLogs() on FilterAPI #199

@EnchanterIO

Description

@EnchanterIO

Summary

Some web3 libraries such as https://www.npmjs.com/package/ethers and other projects have the necessity to filter Lightchain logs.

The web3 method is called getLogs() and translates to Geth API as eth_getLogs.

ethers/providers/json-rpc-provider.ts

            case 'getLogs':
                if (params.filter && params.filter.address != null) {
                    params.filter.address = getLowerCase(params.filter.address);
                }
                return this.send('eth_getLogs', [params.filter]);

Steps to resolve

  1. Implement func (api *PublicFilterAPI) GetLogs(ctx context.Context, crit FilterCriteria) ([]*types.Log, error) {

Screen Shot 2019-08-29 at 15 26 02

From: go-ethereum/eth/filters/api.go

Something like this should work as fix:

lightchain/database/database.go

		if _, ok := v.Service.(*filters.PublicFilterAPI); ok {
			v.Service = filters.NewPublicFilterAPI(
				db.eth.APIBackend,
				false,
			)
		}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions