Giter Club home page Giter Club logo

indexer.sdk's Introduction

indexer.sdk

Installation

go get github.com/carbonable-labs/indexer.sdk

Usage

import (
 "github.com/carbonable-labs/indexer.sdk"
)

var testConfig = Config{
 AppName: "test_config",
  StartBlock: 1,
 Contracts: []Contract{
  {
   Name:    "project",
   Address: "0x0516d0acb6341dcc567e85dc90c8f64e0c33d3daba0a310157d6bba0656c8769",
   Events: map[string]string{
    "URI": "project:uri",
   },
  },
}
}

func main() {
  res, err := sdk.Configure(testConfigs)
  if err != nil {
    log.Fatal(err)
  }

  duplicates := make(map[string]int)

  cancel, err := sdk.RegisterHandler(res.ApppName, fmt.Sprintf("%s.event.%s.>", res.Hash, "0x0516d0acb6341dcc567e85dc90c8f64e0c33d3daba0a310157d6bba0656c8769"), func(s string, u uint64, re sdk.RawEvent) error {
  slog.Debug("event received")
  _, ok := duplicates[re.EventId]
  if !ok {
   duplicates[re.EventId] = 1
  } else {
   duplicates[re.EventId] = duplicates[re.EventId] + 1
  }
  fmt.Println("========= DUPLICATES =========")
  // logique d'index
  fmt.Println(duplicates)
  return nil
 })
 if err != nil {
  slog.Error("failed to register handler", err)
  return
 }
 defer cancel()

 // Gracefully shutdown
 done := make(chan os.Signal, 1)
 signal.Notify(done, os.Interrupt, syscall.SIGTERM)
 <-done
}

indexer.sdk's People

Contributors

martiangreed avatar

Stargazers

François Schuers avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.