-
Notifications
You must be signed in to change notification settings - Fork 5
/
backend.go
42 lines (34 loc) · 1.13 KB
/
backend.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 brtapi
import (
"context"
"github.com/BerithFoundation/berith-chain/core/state"
"github.com/BerithFoundation/berith-chain/miner"
"math/big"
"github.com/BerithFoundation/berith-chain/accounts"
"github.com/BerithFoundation/berith-chain/common"
"github.com/BerithFoundation/berith-chain/core/types"
"github.com/BerithFoundation/berith-chain/params"
"github.com/BerithFoundation/berith-chain/rpc"
)
//Backend backend of berith service
type Backend interface {
AccountManager() *accounts.Manager
SuggestPrice(ctx context.Context) (*big.Int, error)
GetPoolNonce(ctx context.Context, addr common.Address) (uint64, error)
SendTx(ctx context.Context, signedTx *types.Transaction) error
ChainConfig() *params.ChainConfig
CurrentBlock() *types.Block
StateAndHeaderByNumber(ctx context.Context, blockNr rpc.BlockNumber) (*state.StateDB, *types.Header, error)
}
//GetAPIs get apis of berith serivce
func GetAPIs(b Backend, miner *miner.Miner) []rpc.API {
nonceLock := new(AddrLocker)
return []rpc.API{
{
Namespace: "berith",
Version: "1.0",
Service: NewPrivateBerithAPI(b, miner, nonceLock),
Public: false,
},
}
}