-
Notifications
You must be signed in to change notification settings - Fork 2
/
convention.go
42 lines (34 loc) · 885 Bytes
/
convention.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
37
38
39
40
41
42
package event
import (
"fmt"
"github.com/klyed/hivesmartchain/event/query"
)
const (
EventTypeKey = "EventType"
EventIDKey = "EventID"
MessageTypeKey = "MessageType"
TxHashKey = "TxHash"
HeightKey = "Height"
IndexKey = "Index"
StackDepthKey = "StackDepth"
AddressKey = "Address"
)
type EventID string
func (eid EventID) Matches(tags query.Tagged) bool {
value, ok := tags.Get(EventIDKey)
if !ok {
return false
}
return string(eid) == value
}
func (eid EventID) String() string {
return fmt.Sprintf("%s = %s", EventIDKey, string(eid))
}
func (eid EventID) MatchError() error {
return nil
}
// Get a query that matches events with a specific eventID
func QueryForEventID(eventID string) query.Queryable {
// Since we're accepting external output here there is a chance it won't parse...
return query.AsQueryable(EventID(eventID))
}