mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-19 21:31:37 +00:00
review feedback
This commit is contained in:
parent
57cff66861
commit
d86d56c8cf
2 changed files with 5 additions and 21 deletions
|
|
@ -90,7 +90,8 @@ func main() {
|
|||
fatal("failed to fetch execution witness: %v", err)
|
||||
}
|
||||
|
||||
witness, err := fromExtWitness(&extWitness)
|
||||
witness := new(stateless.Witness)
|
||||
err = witness.FromExtWitness(&extWitness)
|
||||
if err != nil {
|
||||
fatal("failed to convert witness: %v", err)
|
||||
}
|
||||
|
|
@ -154,23 +155,6 @@ func parseBlockNumber(s string) (*big.Int, error) {
|
|||
return n, nil
|
||||
}
|
||||
|
||||
// fromExtWitness converts the consensus ExtWitness into the internal Witness.
|
||||
// Duplicated from core/stateless (unexported method) and cmd/keeper/getpayload_example.go.
|
||||
func fromExtWitness(ext *stateless.ExtWitness) (*stateless.Witness, error) {
|
||||
w := &stateless.Witness{}
|
||||
w.Headers = ext.Headers
|
||||
|
||||
w.Codes = make(map[string]struct{}, len(ext.Codes))
|
||||
for _, code := range ext.Codes {
|
||||
w.Codes[string(code)] = struct{}{}
|
||||
}
|
||||
w.State = make(map[string]struct{}, len(ext.State))
|
||||
for _, node := range ext.State {
|
||||
w.State[string(node)] = struct{}{}
|
||||
}
|
||||
return w, nil
|
||||
}
|
||||
|
||||
// jsonPayload is a JSON-friendly representation of Payload. It uses ExtWitness
|
||||
// instead of the internal Witness (which has no JSON marshaling).
|
||||
type jsonPayload struct {
|
||||
|
|
|
|||
|
|
@ -40,8 +40,8 @@ func (w *Witness) ToExtWitness() *ExtWitness {
|
|||
return ext
|
||||
}
|
||||
|
||||
// fromExtWitness converts the consensus witness format into our internal one.
|
||||
func (w *Witness) fromExtWitness(ext *ExtWitness) error {
|
||||
// FromExtWitness converts the consensus witness format into our internal one.
|
||||
func (w *Witness) FromExtWitness(ext *ExtWitness) error {
|
||||
w.Headers = ext.Headers
|
||||
|
||||
w.Codes = make(map[string]struct{}, len(ext.Codes))
|
||||
|
|
@ -66,7 +66,7 @@ func (w *Witness) DecodeRLP(s *rlp.Stream) error {
|
|||
if err := s.Decode(&ext); err != nil {
|
||||
return err
|
||||
}
|
||||
return w.fromExtWitness(&ext)
|
||||
return w.FromExtWitness(&ext)
|
||||
}
|
||||
|
||||
// ExtWitness is a witness RLP encoding for transferring across clients.
|
||||
|
|
|
|||
Loading…
Reference in a new issue