-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add configurability for blob confirmation depth
- Loading branch information
Showing
12 changed files
with
226 additions
and
61 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
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,63 @@ | ||
package verify | ||
|
||
import ( | ||
"context" | ||
"encoding/json" | ||
|
||
"github.com/ethereum/go-ethereum" | ||
"github.com/ethereum/go-ethereum/core/types" | ||
"github.com/ethereum/go-ethereum/rpc" | ||
) | ||
|
||
type FinalizedBlockClient struct { | ||
c *rpc.Client | ||
} | ||
|
||
// Dial connects a client to the given URL. | ||
func Dial(rawurl string) (*FinalizedBlockClient, error) { | ||
return DialContext(context.Background(), rawurl) | ||
} | ||
|
||
// DialContext connects a client to the given URL with context. | ||
func DialContext(ctx context.Context, rawurl string) (*FinalizedBlockClient, error) { | ||
c, err := rpc.DialContext(ctx, rawurl) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return NewFinalizedBlockClient(c), nil | ||
} | ||
|
||
// NewFinalizedBlockClient creates a client that uses the given RPC client. | ||
func NewFinalizedBlockClient(c *rpc.Client) *FinalizedBlockClient { | ||
return &FinalizedBlockClient{c} | ||
} | ||
|
||
// Close closes the underlying RPC connection. | ||
func (ec *FinalizedBlockClient) Close() { | ||
ec.c.Close() | ||
} | ||
|
||
// Client gets the underlying RPC client. | ||
func (ec *FinalizedBlockClient) Client() *rpc.Client { | ||
return ec.c | ||
} | ||
|
||
func (c *FinalizedBlockClient) GetBlock(ctx context.Context, method string, args ...interface{}) (*types.Block, error) { | ||
var raw json.RawMessage | ||
err := c.c.CallContext(ctx, &raw, method, args...) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
// Decode header and transactions. | ||
var head *types.Header | ||
if err := json.Unmarshal(raw, &head); err != nil { | ||
return nil, err | ||
} | ||
// When the block is not found, the API returns JSON null. | ||
if head == nil { | ||
return nil, ethereum.NotFound | ||
} | ||
|
||
return types.NewBlockWithHeader(head), nil | ||
} |
Oops, something went wrong.