Skip to content

Commit

Permalink
Refactor events
Browse files Browse the repository at this point in the history
  • Loading branch information
danil-lashin committed Oct 22, 2018
1 parent c27ca3f commit a995749
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion api/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,30 @@ package api
import (
"encoding/json"
"fmt"
"github.com/MinterTeam/minter-go-node/cmd/utils"
"github.com/MinterTeam/minter-go-node/core/rewards"
"github.com/MinterTeam/minter-go-node/core/transaction"
"github.com/MinterTeam/minter-go-node/core/types"
"github.com/MinterTeam/minter-go-node/eventsdb"
"github.com/gorilla/mux"
"github.com/tendermint/tendermint/libs/common"
"github.com/tendermint/tendermint/libs/db"
"math/big"
"net/http"
"strconv"
"time"
)

var edb *eventsdb.EventsDB

func init() {
eventsDB, err := db.NewGoLevelDB("events", utils.GetMinterHome()+"/data")
if err != nil {
panic(err)
}
edb = eventsdb.NewEventsDB(eventsDB)
}

type BlockResponse struct {
Hash common.HexBytes `json:"hash"`
Height int64 `json:"height"`
Expand Down Expand Up @@ -113,7 +125,7 @@ func Block(w http.ResponseWriter, r *http.Request) {

var eventsRaw []byte

events := eventsdb.GetCurrent().LoadEvents(height)
events := edb.LoadEvents(height)

if len(events) > 0 {
eventsRaw, err = cdc.MarshalJSON(events)
Expand Down

0 comments on commit a995749

Please sign in to comment.