// Register registers a new content hash in the registry. func (api *PrivateRegistarAPI) Register(sender common.Address, addr common.Address, contentHashHex string) (bool, error) { block := api.be.bc.CurrentBlock() state, err := state.New(block.Root(), api.be.chainDb) if err != nil { return false, err } codeb := state.GetCode(addr) codeHash := common.BytesToHash(crypto.Sha3(codeb)) contentHash := common.HexToHash(contentHashHex) _, err = registrar.New(api.be).SetHashToHash(sender, codeHash, contentHash) return err == nil, err }
// GetData returns the data stored at the given address in the state for the given block number. func (s *PublicBlockChainAPI) GetData(address common.Address, blockNr rpc.BlockNumber) (string, error) { if block := blockByNumber(s.miner, s.bc, blockNr); block != nil { state, err := state.New(block.Root(), s.chainDb) if err != nil { return "", err } res := state.GetCode(address) if len(res) == 0 { // backwards compatibility return "0x", nil } return common.ToHex(res), nil } return "0x", nil }