/
api.go
36 lines (28 loc) · 1.07 KB
/
api.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package roothash
import (
"fmt"
tmpubsub "github.com/tendermint/tendermint/libs/pubsub"
tmquery "github.com/tendermint/tendermint/libs/pubsub/query"
"github.com/oasisprotocol/oasis-core/go/common"
"github.com/oasisprotocol/oasis-core/go/consensus/tendermint/api"
roothash "github.com/oasisprotocol/oasis-core/go/roothash/api"
)
const (
// AppID is the unique application identifier.
AppID uint8 = 0x02
// AppName is the ABCI application name.
AppName string = "999_roothash"
)
var (
// EventType is the ABCI event type for roothash events.
EventType = api.EventTypeForApp(AppName)
// QueryApp is a query for filtering transactions processed by the
// roothash application.
QueryApp = api.QueryForApp(AppName)
)
// QueryForRuntime returns a query for filtering transactions processed by the roothash application
// limited to a specific runtime.
func QueryForRuntime(runtimeID common.Namespace) tmpubsub.Query {
ev := roothash.RuntimeIDAttribute{ID: runtimeID}
return tmquery.MustParse(fmt.Sprintf("%s AND %s.%s='%s'", QueryApp, EventType, ev.EventKind(), ev.EventValue()))
}