-
Notifications
You must be signed in to change notification settings - Fork 199
/
interface.go
140 lines (112 loc) · 7.5 KB
/
interface.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
134
135
136
137
138
139
140
package facade
import (
"context"
"math/big"
"github.com/ElrondNetwork/elrond-go-core/core"
"github.com/ElrondNetwork/elrond-go-core/data/api"
"github.com/ElrondNetwork/elrond-go-core/data/esdt"
"github.com/ElrondNetwork/elrond-go-core/data/transaction"
"github.com/ElrondNetwork/elrond-go/common"
"github.com/ElrondNetwork/elrond-go/debug"
"github.com/ElrondNetwork/elrond-go/heartbeat/data"
"github.com/ElrondNetwork/elrond-go/node/external"
"github.com/ElrondNetwork/elrond-go/process"
txSimData "github.com/ElrondNetwork/elrond-go/process/txsimulator/data"
"github.com/ElrondNetwork/elrond-go/state"
vmcommon "github.com/ElrondNetwork/elrond-vm-common"
)
// NodeHandler contains all functions that a node should contain.
type NodeHandler interface {
// GetBalance returns the balance for a specific address
GetBalance(address string, options api.AccountQueryOptions) (*big.Int, api.BlockInfo, error)
// GetUsername returns the username for a specific address
GetUsername(address string, options api.AccountQueryOptions) (string, api.BlockInfo, error)
// GetValueForKey returns the value of a key from a given account
GetValueForKey(address string, key string, options api.AccountQueryOptions) (string, api.BlockInfo, error)
// GetKeyValuePairs returns the key-value pairs under a given address
GetKeyValuePairs(address string, options api.AccountQueryOptions, ctx context.Context) (map[string]string, api.BlockInfo, error)
// GetAllIssuedESDTs returns all the issued esdt tokens from esdt system smart contract
GetAllIssuedESDTs(tokenType string, ctx context.Context) ([]string, error)
// GetESDTData returns the esdt data from a given account, given key and given nonce
GetESDTData(address, tokenID string, nonce uint64, options api.AccountQueryOptions) (*esdt.ESDigitalToken, api.BlockInfo, error)
// GetESDTsRoles returns the the token identifiers and the roles for a given address
GetESDTsRoles(address string, options api.AccountQueryOptions, ctx context.Context) (map[string][]string, api.BlockInfo, error)
// GetNFTTokenIDsRegisteredByAddress returns all the token identifiers for semi or non fungible tokens registered by the address
GetNFTTokenIDsRegisteredByAddress(address string, options api.AccountQueryOptions, ctx context.Context) ([]string, api.BlockInfo, error)
// GetESDTsWithRole returns the token identifiers where the specified address has the given role
GetESDTsWithRole(address string, role string, options api.AccountQueryOptions, ctx context.Context) ([]string, api.BlockInfo, error)
// GetAllESDTTokens returns the value of a key from a given account
GetAllESDTTokens(address string, options api.AccountQueryOptions, ctx context.Context) (map[string]*esdt.ESDigitalToken, api.BlockInfo, error)
// GetTokenSupply returns the provided token supply from current shard
GetTokenSupply(token string) (*api.ESDTSupply, error)
// CreateTransaction will return a transaction from all needed fields
CreateTransaction(nonce uint64, value string, receiver string, receiverUsername []byte, sender string, senderUsername []byte, gasPrice uint64,
gasLimit uint64, data []byte, signatureHex string, chainID string, version uint32, options uint32) (*transaction.Transaction, []byte, error)
// ValidateTransaction will validate a transaction
ValidateTransaction(tx *transaction.Transaction) error
ValidateTransactionForSimulation(tx *transaction.Transaction, checkSignature bool) error
// SendBulkTransactions will send a bulk of transactions on the 'send transactions pipe' channel
SendBulkTransactions(txs []*transaction.Transaction) (uint64, error)
// GetAccount returns an accountResponse containing information
// about the account correlated with provided address
GetAccount(address string, options api.AccountQueryOptions) (api.AccountResponse, api.BlockInfo, error)
// GetCode returns the code for the given code hash
GetCode(codeHash []byte, options api.AccountQueryOptions) ([]byte, api.BlockInfo)
// GetHeartbeats returns the heartbeat status for each public key defined in genesis.json
GetHeartbeats() []data.PubKeyHeartbeat
// IsInterfaceNil returns true if there is no value under the interface
IsInterfaceNil() bool
// ValidatorStatisticsApi return the statistics for all the validators
ValidatorStatisticsApi() (map[string]*state.ValidatorApiResponse, error)
DirectTrigger(epoch uint32, withEarlyEndOfEpoch bool) error
IsSelfTrigger() bool
EncodeAddressPubkey(pk []byte) (string, error)
DecodeAddressPubkey(pk string) ([]byte, error)
GetQueryHandler(name string) (debug.QueryHandler, error)
GetPeerInfo(pid string) ([]core.QueryP2PPeerInfo, error)
GetEpochStartDataAPI(epoch uint32) (*common.EpochStartDataAPI, error)
GetProof(rootHash string, key string) (*common.GetProofResponse, error)
GetProofDataTrie(rootHash string, address string, key string) (*common.GetProofResponse, *common.GetProofResponse, error)
VerifyProof(rootHash string, address string, proof [][]byte) (bool, error)
}
// TransactionSimulatorProcessor defines the actions which a transaction simulator processor has to implement
type TransactionSimulatorProcessor interface {
ProcessTx(tx *transaction.Transaction) (*txSimData.SimulationResults, error)
IsInterfaceNil() bool
}
// ApiResolver defines a structure capable of resolving REST API requests
type ApiResolver interface {
ExecuteSCQuery(query *process.SCQuery) (*vmcommon.VMOutput, error)
ComputeTransactionGasLimit(tx *transaction.Transaction) (*transaction.CostResponse, error)
StatusMetrics() external.StatusMetricsHandler
GetTotalStakedValue(ctx context.Context) (*api.StakeValues, error)
GetDirectStakedList(ctx context.Context) ([]*api.DirectStakedValue, error)
GetDelegatorsList(ctx context.Context) ([]*api.Delegator, error)
GetTransaction(hash string, withResults bool) (*transaction.ApiTransactionResult, error)
GetTransactionsPool(fields string) (*common.TransactionsPoolAPIResponse, error)
GetTransactionsPoolForSender(sender, fields string) (*common.TransactionsPoolForSenderApiResponse, error)
GetLastPoolNonceForSender(sender string) (uint64, error)
GetTransactionsPoolNonceGapsForSender(sender string) (*common.TransactionsPoolNonceGapsForSenderApiResponse, error)
GetBlockByHash(hash string, options api.BlockQueryOptions) (*api.Block, error)
GetBlockByNonce(nonce uint64, options api.BlockQueryOptions) (*api.Block, error)
GetBlockByRound(round uint64, options api.BlockQueryOptions) (*api.Block, error)
GetInternalShardBlockByNonce(format common.ApiOutputFormat, nonce uint64) (interface{}, error)
GetInternalShardBlockByHash(format common.ApiOutputFormat, hash string) (interface{}, error)
GetInternalShardBlockByRound(format common.ApiOutputFormat, round uint64) (interface{}, error)
GetInternalMetaBlockByNonce(format common.ApiOutputFormat, nonce uint64) (interface{}, error)
GetInternalMetaBlockByHash(format common.ApiOutputFormat, hash string) (interface{}, error)
GetInternalMetaBlockByRound(format common.ApiOutputFormat, round uint64) (interface{}, error)
GetInternalStartOfEpochMetaBlock(format common.ApiOutputFormat, epoch uint32) (interface{}, error)
GetInternalMiniBlock(format common.ApiOutputFormat, txHash string, epoch uint32) (interface{}, error)
GetGenesisNodesPubKeys() (map[uint32][]string, map[uint32][]string)
GetGenesisBalances() ([]*common.InitialAccountAPI, error)
GetGasConfigs() map[string]map[string]uint64
Close() error
IsInterfaceNil() bool
}
// HardforkTrigger defines the structure used to trigger hardforks
type HardforkTrigger interface {
Trigger(epoch uint32, withEarlyEndOfEpoch bool) error
IsSelfTrigger() bool
IsInterfaceNil() bool
}