embedded.go 820 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11
//go:build mips

package oracle

import (
	"fmt"
	"io/ioutil"
	"math/big"
	"os"

	"github.com/ethereum/go-ethereum/common"
12
	"github.com/ethereum/go-ethereum/crypto"
13 14 15 16 17 18 19 20 21 22 23 24 25
)

func Preimage(hash common.Hash) []byte {
	f, err := os.Open(fmt.Sprintf("/tmp/eth/%s", hash))
	if err != nil {
		panic("missing preimage")
	}

	defer f.Close()
	ret, err := ioutil.ReadAll(f)
	if err != nil {
		panic("preimage read failed")
	}
26 27 28 29 30 31

	realhash := crypto.Keccak256Hash(ret)
	if realhash != hash {
		panic("preimage has wrong hash")
	}

32 33 34 35 36 37 38
	return ret
}

// these are stubs in embedded world
func PrefetchStorage(blockNumber *big.Int, addr common.Address, skey common.Hash) {}
func PrefetchAccount(blockNumber *big.Int, addr common.Address)                   {}
func PrefetchCode(blockNumber *big.Int, addrHash common.Hash)                     {}