-
Notifications
You must be signed in to change notification settings - Fork 40
/
server.go
51 lines (40 loc) · 1.02 KB
/
server.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
43
44
45
46
47
48
49
50
51
package api
import (
"github.com/gorilla/mux"
"github.com/cosmos/cosmos-sdk/client/context"
keyscli "github.com/cosmos/cosmos-sdk/client/keys"
"github.com/cosmos/cosmos-sdk/crypto/keys"
"github.com/bnb-chain/node/common"
"github.com/bnb-chain/node/plugins/tokens"
"github.com/bnb-chain/node/wire"
)
// config consts
const maxPostSize int64 = 1024 * 1024 * 0.5 // ~500KB
type server struct {
router *mux.Router
// settings
maxPostSize int64
// handler dependencies
ctx context.CLIContext
cdc *wire.Codec
// stores for handlers
keyBase keys.Keybase
tokens tokens.Mapper
accStoreName string
}
// NewServer provides a new server structure.
func newServer(ctx context.CLIContext, cdc *wire.Codec) *server {
kb, err := keyscli.GetKeyBase()
if err != nil {
panic(err)
}
return &server{
router: mux.NewRouter(),
maxPostSize: maxPostSize,
ctx: ctx,
cdc: cdc,
keyBase: kb,
tokens: tokens.NewMapper(cdc, common.TokenStoreKey),
accStoreName: common.AccountStoreName,
}
}