aboutsummaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
authoraaronbuchwald <[email protected]>2020-10-26 22:03:05 -0400
committerGitHub <[email protected]>2020-10-26 22:03:05 -0400
commit806d04e9aa4b6e22fc2a484ada6fecb0c9a348e3 (patch)
tree36822cea4b16638e6a246af209ccdf77b3eb2088 /internal
parent8a8ef56dd1a0f2cd28c6d4b3a579b16cdda6e2cf (diff)
parentcccb47666b2bccce378a9a56824061ea3a9a95fa (diff)
Merge pull request #43 from ava-labs/handle-block-number-requests
Handle block number requests
Diffstat (limited to 'internal')
-rw-r--r--internal/ethapi/api.go65
1 files changed, 34 insertions, 31 deletions
diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go
index 825f8fc..728fb07 100644
--- a/internal/ethapi/api.go
+++ b/internal/ethapi/api.go
@@ -77,20 +77,21 @@ func (s *PublicEthereumAPI) ProtocolVersion() hexutil.Uint {
// - pulledStates: number of state entries processed until now
// - knownStates: number of known state entries that still need to be pulled
func (s *PublicEthereumAPI) Syncing() (interface{}, error) {
- progress := s.b.Downloader().Progress()
-
- // Return not syncing if the synchronisation already completed
- if progress.CurrentBlock >= progress.HighestBlock {
- return false, nil
- }
- // Otherwise gather the block sync stats
- return map[string]interface{}{
- "startingBlock": hexutil.Uint64(progress.StartingBlock),
- "currentBlock": hexutil.Uint64(progress.CurrentBlock),
- "highestBlock": hexutil.Uint64(progress.HighestBlock),
- "pulledStates": hexutil.Uint64(progress.PulledStates),
- "knownStates": hexutil.Uint64(progress.KnownStates),
- }, nil
+ return nil, errors.New("not implemented in coreth") // Info or Health API should be used instead
+ // progress := s.b.Downloader().Progress()
+
+ // // Return not syncing if the synchronisation already completed
+ // if progress.CurrentBlock >= progress.HighestBlock {
+ // return false, nil
+ // }
+ // // Otherwise gather the block sync stats
+ // return map[string]interface{}{
+ // "startingBlock": hexutil.Uint64(progress.StartingBlock),
+ // "currentBlock": hexutil.Uint64(progress.CurrentBlock),
+ // "highestBlock": hexutil.Uint64(progress.HighestBlock),
+ // "pulledStates": hexutil.Uint64(progress.PulledStates),
+ // "knownStates": hexutil.Uint64(progress.KnownStates),
+ // }, nil
}
// PublicTxPoolAPI offers and API for the transaction pool. It only operates on data that is non confidential.
@@ -546,8 +547,8 @@ func (s *PublicBlockChainAPI) BlockNumber() hexutil.Uint64 {
}
// GetBalance returns the amount of wei for the given address in the state of the
-// given block number. The rpc.LatestBlockNumber and rpc.PendingBlockNumber meta
-// block numbers are also allowed.
+// given block number. The rpc.LatestBlockNumber, rpc.PendingBlockNumber, and
+// rpc.AcceptedBlockNumber meta block numbers are also allowed.
func (s *PublicBlockChainAPI) GetBalance(ctx context.Context, address common.Address, blockNrOrHash rpc.BlockNumberOrHash) (*hexutil.Big, error) {
state, _, err := s.b.StateAndHeaderByNumberOrHash(ctx, blockNrOrHash)
if state == nil || err != nil {
@@ -556,9 +557,9 @@ func (s *PublicBlockChainAPI) GetBalance(ctx context.Context, address common.Add
return (*hexutil.Big)(state.GetBalance(address)), state.Error()
}
-// GetBalanceMultiCoin returns the amount of wei for the given address in the state of the
-// given block number. The rpc.LatestBlockNumber and rpc.PendingBlockNumber meta
-// block numbers are also allowed.
+// GetAssetBalance returns the amount of wei for the given address in the state of the
+// given block number. The rpc.LatestBlockNumber, rpc.PendingBlockNumber, and
+// rpc.AcceptedBlockNumber meta block numbers are also allowed.
func (s *PublicBlockChainAPI) GetAssetBalance(ctx context.Context, address common.Address, blockNrOrHash rpc.BlockNumberOrHash, assetID ids.ID) (*hexutil.Big, error) {
state, _, err := s.b.StateAndHeaderByNumberOrHash(ctx, blockNrOrHash)
if state == nil || err != nil {
@@ -640,12 +641,13 @@ func (s *PublicBlockChainAPI) GetHeaderByNumber(ctx context.Context, number rpc.
header, err := s.b.HeaderByNumber(ctx, number)
if header != nil && err == nil {
response := s.rpcMarshalHeader(ctx, header)
- if number == rpc.PendingBlockNumber {
- // Pending header need to nil out a few fields
- for _, field := range []string{"hash", "nonce", "miner"} {
- response[field] = nil
- }
- }
+ // coreth has no notion of a pending block
+ // if number == rpc.PendingBlockNumber {
+ // // Pending header need to nil out a few fields
+ // for _, field := range []string{"hash", "nonce", "miner"} {
+ // response[field] = nil
+ // }
+ // }
return response, err
}
return nil, err
@@ -669,12 +671,13 @@ func (s *PublicBlockChainAPI) GetBlockByNumber(ctx context.Context, number rpc.B
block, err := s.b.BlockByNumber(ctx, number)
if block != nil && err == nil {
response, err := s.rpcMarshalBlock(ctx, block, true, fullTx)
- if err == nil && number == rpc.PendingBlockNumber {
- // Pending blocks need to nil out a few fields
- for _, field := range []string{"hash", "nonce", "miner"} {
- response[field] = nil
- }
- }
+ // coreth has no notion of a pending block
+ // if err == nil && number == rpc.PendingBlockNumber {
+ // // Pending blocks need to nil out a few fields
+ // for _, field := range []string{"hash", "nonce", "miner"} {
+ // response[field] = nil
+ // }
+ // }
return response, err
}
return nil, err