forked from okx/xlayer-node
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add custom methods to json RPC with prefix hez (okx#139)
- Loading branch information
Showing
13 changed files
with
92 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package jsonrpc | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/hermeznetwork/hermez-core/hex" | ||
"github.com/hermeznetwork/hermez-core/state" | ||
) | ||
|
||
// Hez contains implementations for the "hez" RPC endpoints | ||
type Hez struct { | ||
defaultChainID uint64 | ||
state state.State | ||
} | ||
|
||
// DefaultChainId returns the default chain id that is allowed to be used by all the sequencers | ||
func (h *Hez) DefaultChainId() (interface{}, error) { //nolint:golint | ||
return hex.EncodeUint64(h.defaultChainID), nil | ||
} | ||
|
||
// ConsolidatedBlockNumber returns current block number for consolidated batches | ||
func (h *Hez) ConsolidatedBlockNumber() (interface{}, error) { | ||
ctx := context.Background() | ||
|
||
lastBatchNumber, err := h.state.GetLastConsolidatedBatchNumber(ctx) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return hex.EncodeUint64(lastBatchNumber), nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters