-
Notifications
You must be signed in to change notification settings - Fork 0
/
service.go
133 lines (117 loc) · 6.51 KB
/
service.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
package api
import (
"context"
"math/big"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/bloombits"
gethtypes "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/rpc"
"github.com/zeniqsmart/evm-zeniq-smart-chain/types"
"github.com/zeniqsmart/zeniq-smart-chain/app"
cctypes "github.com/zeniqsmart/zeniq-smart-chain/crosschain/types"
stake "github.com/zeniqsmart/zeniq-smart-chain/staking/types"
)
type CallDetail struct {
Status int
GasUsed uint64
OutData []byte
Logs []types.EvmLog
CreatedContractAddress common.Address
InternalTxCalls []types.InternalTxCall
InternalTxReturns []types.InternalTxReturn
RwLists *types.ReadWriteLists
}
type FilterService interface {
HeaderByNumber(ctx context.Context, blockNr rpc.BlockNumber) (*types.Header, error)
HeaderByHash(ctx context.Context, blockHash common.Hash) (*types.Header, error)
GetReceipts(ctx context.Context, blockNum uint64) (gethtypes.Receipts, error)
GetLogs(ctx context.Context, blockHash common.Hash) ([][]*gethtypes.Log, error)
SubscribeNewTxsEvent(chan<- core.NewTxsEvent) event.Subscription
SubscribeChainEvent(ch chan<- types.ChainEvent) event.Subscription
SubscribeRemovedLogsEvent(ch chan<- core.RemovedLogsEvent) event.Subscription
SubscribeLogsEvent(ch chan<- []*gethtypes.Log) event.Subscription
//SubscribePendingLogsEvent(ch chan<- []*stake.Log) event.Subscription
BloomStatus() (uint64, uint64)
ServiceFilter(ctx context.Context, session *bloombits.MatcherSession)
}
type BackendService interface {
FilterService
// General Ethereum API
//Downloader() *downloader.Downloader
ProtocolVersion() int
//SuggestPrice(ctx context.Context) (*big.Int, error)
//ChainDb() Database
//AccountManager() *accounts.Manager
//ExtRPCEnabled() bool
//RPCGasCap() uint64 // global gas cap for eth_call over rpc: DoS protection
//RPCTxFeeCap() float64 // global tx fee cap for all transaction related APIs
// Blockchain API
ChainId() *big.Int
//SetHead(number uint64)
//HeaderByNumber(ctx context.Context, number int64) (*stake.Header, error)
//HeaderByHash(ctx context.Context, hash common.Hash) (*stake.Header, error)
//HeaderByNumberOrHash(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) (*stake.Header, error)
//CurrentHeader() *stake.Header
LatestHeight() int64
CurrentBlock() (*types.Block, error)
BlockByNumber(number int64) (*types.Block, error)
BlockByHash(hash common.Hash) (*types.Block, error)
//BlockByNumberOrHash(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) (*stake.Block, error)
//StateAndHeaderByNumber(ctx context.Context, number int64) (*state.StateDB, error)
//StateAndHeaderByNumberOrHash(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) (*state.StateDB, *stake.Header, error)
//GetReceipts(ctx context.Context, hash common.Hash) (stake.Receipts, error) /*All receipt fields is in stake.Transaction, use getTransaction() instead*/
//GetTd(ctx context.Context, hash common.Hash) *big.Int
//GetEVM(ctx context.Context, msg core.Message, state *state.StateDB, header *stake.Header) (*vm.EVM, func() error, error)
// Transaction pool API
SendRawTx(signedTx []byte) (common.Hash, error)
GetTransaction(txHash common.Hash) (tx *types.Transaction, sig [65]byte, err error)
//GetPoolTransactions() (stake.Transactions, error)
//GetPoolTransaction(txHash common.Hash) *stake.Transaction
//GetPoolNonce(ctx context.Context, addr common.Address) (uint64, error)
//Stats() (pending int, queued int)
//TxPoolContent() (map[common.Address]stake.Transactions, map[common.Address]stake.Transactions)
// Filter API
//BloomStatus() (uint64, uint64)
//GetLogs(blockHash common.Hash) ([][]stake.Log, error)
//ServiceFilter(ctx context.Context, session *bloombits.MatcherSession)
//SubscribeLogsEvent(ch chan<- []*stake.Log) event.Subscription
//SubscribePendingLogsEvent(ch chan<- []*stake.Log) event.Subscription
//SubscribeRemovedLogsEvent(ch chan<- core.RemovedLogsEvent) event.Subscription
//SubscribeNewTxsEvent(chan<- core.NewTxsEvent) event.Subscription
//SubscribeChainEvent(ch chan<- core.ChainEvent) event.Subscription
//SubscribeChainHeadEvent(ch chan<- core.ChainHeadEvent) event.Subscription
//SubscribeChainSideEvent(ch chan<- core.ChainSideEvent) event.Subscription
//Engine() consensus.Engine
//Below is added in zeniq chain only
GetNonce(address common.Address, height int64) (uint64, error)
GetBalance(address common.Address, height int64) (*big.Int, error)
GetCode(contract common.Address, height int64) (bytecode []byte, codeHash []byte)
GetStorageAt(address common.Address, key string, height int64) []byte
Call(tx *gethtypes.Transaction, from common.Address, height int64) (statusCode int, retData []byte)
CallForSbch(tx *gethtypes.Transaction, sender common.Address, height int64) *CallDetail
EstimateGas(tx *gethtypes.Transaction, from common.Address, height int64) (statusCode int, retData []byte, gas int64)
QueryLogs(addresses []common.Address, topics [][]common.Hash, startHeight, endHeight uint32, filter types.FilterFunc) ([]types.Log, error)
QueryTxBySrc(address common.Address, startHeight, endHeight, limit uint32) (tx []*types.Transaction, sigs [][65]byte, err error)
QueryTxByDst(address common.Address, startHeight, endHeight, limit uint32) (tx []*types.Transaction, sigs [][65]byte, err error)
QueryTxByAddr(address common.Address, startHeight, endHeight, limit uint32) (tx []*types.Transaction, sigs [][65]byte, err error)
SbchQueryLogs(addr common.Address, topics []common.Hash, startHeight, endHeight, limit uint32) ([]types.Log, error)
GetTxListByHeight(height uint32) (tx []*types.Transaction, sigs [][65]byte, err error)
GetTxListByHeightWithRange(height uint32, start, end int) (tx []*types.Transaction, sigs [][65]byte, err error)
GetFromAddressCount(addr common.Address) int64
GetToAddressCount(addr common.Address) int64
GetSep20ToAddressCount(contract common.Address, addr common.Address) int64
GetSep20FromAddressCount(contract common.Address, addr common.Address) int64
GetEpochs(start, end uint64) ([]*stake.Epoch, error)
GetEpochList(from string) ([]*stake.Epoch, error)
GetCurrEpoch() *stake.Epoch
GetCCEpochs(start, end uint64) ([]*cctypes.CCEpoch, error)
GetSeq(address common.Address) uint64
GetPosVotes() map[[32]byte]*big.Int
GetSyncBlock(height int64) (blk []byte, err error)
//tendermint info
NodeInfo() Info
ValidatorsInfo() app.ValidatorsInfo
IsArchiveMode() bool
}