-
Notifications
You must be signed in to change notification settings - Fork 120
/
Copy pathcli.go
35 lines (28 loc) · 840 Bytes
/
cli.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
// Copyright (C) 2024, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package cli
import (
"github.com/ava-labs/avalanchego/database"
"github.com/prometheus/client_golang/prometheus"
"github.com/ava-labs/hypersdk/chain"
"github.com/ava-labs/hypersdk/codec"
"github.com/ava-labs/hypersdk/internal/pebble"
)
type Controller interface {
DatabasePath() string
Symbol() string
GetParser(string) (chain.Parser, error)
HandleTx(*chain.Transaction, *chain.Result)
LookupBalance(address codec.Address, uri string) (uint64, error)
}
type Handler struct {
c Controller
db database.Database
}
func New(c Controller) (*Handler, error) {
db, err := pebble.New(c.DatabasePath(), pebble.NewDefaultConfig(), prometheus.NewRegistry())
if err != nil {
return nil, err
}
return &Handler{c, db}, nil
}