-
Notifications
You must be signed in to change notification settings - Fork 688
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
30 additions
and
18 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,61 @@ | ||
package etherman | ||
|
||
import ( | ||
"github.com/ethereum/go-ethereum/accounts/abi/bind" | ||
"log" | ||
"github.com/ethereum/go-ethereum/common" | ||
"github.com/ethereum/go-ethereum/core/types" | ||
"github.com/hermeznetwork/hermez-core/etherman/smartcontracts/proofofefficiency" | ||
"github.com/hermeznetwork/hermez-core/state" | ||
"github.com/ethereum/go-ethereum/ethclient" | ||
) | ||
type EtherMan struct { | ||
Poe *proofofefficiency.Proofofefficiency | ||
EtherClient *ethclient.Client | ||
PoE *proofofefficiency.Proofofefficiency | ||
} | ||
|
||
func NewEtherman() (*EtherMan, error) { | ||
func NewEtherman(url string, poeAddr common.Address) (*EtherMan, error) { | ||
//TODO | ||
var address common.Address | ||
var backend bind.ContractBackend | ||
poe, err := proofofefficiency.NewProofofefficiency(address, backend) | ||
//Connect to ethereum node | ||
ethClient, err := ethclient.Dial(url) | ||
if err != nil { | ||
log.Printf("GetEthClient - Client: error connecting to %s: %+v", url, err) | ||
return nil, err | ||
} | ||
poe, err := proofofefficiency.NewProofofefficiency(poeAddr, ethClient) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return &EtherMan{Poe: poe}, nil | ||
return &EtherMan{EtherClient: ethClient, PoE: poe}, nil | ||
} | ||
|
||
//This function retrieves the ethereum block information by ethereum block number | ||
// EthBlockByNumber function retrieves the ethereum block information by ethereum block number | ||
func (etherMan *EtherMan) EthBlockByNumber(blockNum int64) (types.Block, error) { | ||
//TODO | ||
return types.Block{}, nil | ||
} | ||
|
||
//This function retrieves the batches information that are included in a specific ethereum block | ||
// GetBatchesByBlock function retrieves the batches information that are included in a specific ethereum block | ||
func (etherMan *EtherMan) GetBatchesByBlock(blockNum int64) ([]state.Batch, error) { | ||
//TODO | ||
return []state.Batch{}, nil | ||
} | ||
|
||
//This function retrieves the batches information that are included in all this ethereum blocks | ||
// GetBatchesFromBlockTo function retrieves the batches information that are included in all this ethereum blocks | ||
//from block x to block y | ||
func (etherMan *EtherMan) GetBatchesFromBlockTo(fromBlock uint, toBlock uint) ([]state.Batch, error) { | ||
//TODO | ||
return []state.Batch{}, nil | ||
} | ||
|
||
//This function allows the sequencer send a new batch proposal to the rollup | ||
func (etherMan *EtherMan) sendBatch(batch state.Batch) (common.Hash, error) { | ||
// SendBatch function allows the sequencer send a new batch proposal to the rollup | ||
func (etherMan *EtherMan) SendBatch(batch state.Batch) (common.Hash, error) { | ||
//TODO | ||
return common.Hash{}, nil | ||
} | ||
|
||
//This function allows the agregator send the proof for a batch and consolidate it | ||
func (etherMan *EtherMan) consolidateBatch(batch state.Batch, proof state.Proof) (common.Hash, error) { | ||
// ConsolidateBatch function allows the agregator send the proof for a batch and consolidate it | ||
func (etherMan *EtherMan) ConsolidateBatch(batch state.Batch, proof state.Proof) (common.Hash, error) { | ||
//TODO | ||
return common.Hash{}, 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