当前位置: 首页 > news >正文

产教融合信息门户网站建设方案产品推广步骤

产教融合信息门户网站建设方案,产品推广步骤,网站想要游览怎么做,网站制作案例怎么样Web3j 继承StaticStruct的类所有属性必须为Public,属性的顺序和数量必须和solidity 里面的struct 属性相同,否则属性少了或者多了的时候会出现错位 Web3j 继承StaticStruct的类所有属性不能为private,因为web3j 是通过长度去截取返回值解析成…

Web3j 继承StaticStruct的类所有属性必须为Public,属性的顺序和数量必须和solidity 里面的struct 属性相同,否则属性少了或者多了的时候会出现错位

Web3j 继承StaticStruct的类所有属性不能为private,因为web3j 是通过长度去截取返回值解析成对应的属性进行赋值的。要获取一个list对象时,web3j是按一个类的所有public属性个数去截取总长度的,再进行解析赋值到没一个属性里

StaticStruct类

import lombok.Data;
import org.web3j.abi.datatypes.Address;
import org.web3j.abi.datatypes.StaticStruct;
import org.web3j.abi.datatypes.Type;
import org.web3j.abi.datatypes.generated.Uint256;@Data
public class ChildStaticStruct extends StaticStruct {public Uint256 attr1;public Uint256 attr2;public Address attr3;public ChildStaticStruct(Uint256 attr1, Uint256 attr2, Address attr3) {super(new Type[]{attr1,attr2,attr3});}
}
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.web3j.abi.FunctionEncoder;
import org.web3j.abi.FunctionReturnDecoder;
import org.web3j.abi.TypeReference;
import org.web3j.abi.datatypes.Address;
import org.web3j.abi.datatypes.DynamicArray;
import org.web3j.abi.datatypes.Function;
import org.web3j.abi.datatypes.Type;
import org.web3j.protocol.Web3j;
import org.web3j.protocol.core.DefaultBlockParameterName;
import org.web3j.protocol.core.methods.request.Transaction;
import org.web3j.protocol.core.methods.response.EthCall;import java.io.IOException;
import java.util.Arrays;
import java.util.List;public class TestContract {private static final Logger logger = LoggerFactory.getLogger(TestContract.class);private String address;private Web3j web3j;public TestContract(String address, Web3j web3j) {this.address = address;this.web3j = web3j;}public List<ChildStaticStruct> getStaticStructList(String address) throws IOException {List<Type> inputParameters = Arrays.asList( new Address(address));List<TypeReference<?>> outputParameters = Arrays.asList(new TypeReference<DynamicArray<ChildStaticStruct>>(){});Function function = new Function("getStaticStructList",inputParameters,outputParameters);Transaction transaction = Transaction.createEthCallTransaction(null,address, FunctionEncoder.encode(function));EthCall response = web3j.ethCall(transaction, DefaultBlockParameterName.LATEST).send();List<Type> output = FunctionReturnDecoder.decode(response.getValue(),function.getOutputParameters());List<ChildStaticStruct> results = (List<ChildStaticStruct>)output.get(0).getValue();return results;}
}

web3j的TypeDecoder 里的decodeArrayElements 验证了是否为StructType子类,

在currOffset += getSingleElementLength(input, currOffset, cls) * 64)判断了截取的长度

if (StructType.class.isAssignableFrom(cls)) {elements = new ArrayList(length);currOffset = 0;for(currOffset = offset; currOffset < length; currOffset += getSingleElementLength(input, currOffset, cls) * 64) {if (DynamicStruct.class.isAssignableFrom(cls)) {value = decodeDynamicStruct(input, offset + DefaultFunctionReturnDecoder.getDataOffset(input, currOffset, typeReference), TypeReference.create(cls));} else {value = decodeStaticStruct(input, currOffset, TypeReference.create(cls));}elements.add(value);++currOffset;}String typeName = Utils.getSimpleTypeName(cls);return (Type)consumer.apply(elements, typeName);} 

getSingleElementLength 验证了截取长度是根据public属性数量去截取Utils.staticStructNestedPublicFieldsFlatList(type).size(),pirvate计算长度

static <T extends Type> int getSingleElementLength(String input, int offset, Class<T> type) {if (input.length() == offset) {return 0;} else if (!DynamicBytes.class.isAssignableFrom(type) && !Utf8String.class.isAssignableFrom(type)) {return StaticStruct.class.isAssignableFrom(type) ? Utils.staticStructNestedPublicFieldsFlatList(type).size() : 1;} else {return decodeUintAsInt(input, offset) / 32 + 2;}}

 staticStructNestedPublicFieldsFlatList方面里面通过Modifier.isPublic(field.getModifiers())过滤了public  

public static List<Field> staticStructNestedPublicFieldsFlatList(Class<Type> classType) {return (List)staticStructsNestedFieldsFlatList(classType).stream().filter((field) -> {return Modifier.isPublic(field.getModifiers());}).collect(Collectors.toList());}

Modifier 里面比较了Public

public static boolean isPublic(int mod) {return (mod & PUBLIC) != 0;}


文章转载自:
http://dinncohyperuricemia.ssfq.cn
http://dinncoclerestory.ssfq.cn
http://dinncoglume.ssfq.cn
http://dinncosemiflexion.ssfq.cn
http://dinncosolatium.ssfq.cn
http://dinncopartner.ssfq.cn
http://dinncoavifauna.ssfq.cn
http://dinncoemeritus.ssfq.cn
http://dinncowastebasket.ssfq.cn
http://dinncoindeterminably.ssfq.cn
http://dinncoprovitamin.ssfq.cn
http://dinncocleptomaniac.ssfq.cn
http://dinncolinguatulid.ssfq.cn
http://dinncocountertrend.ssfq.cn
http://dinncoknockdown.ssfq.cn
http://dinncocesspool.ssfq.cn
http://dinncorabbi.ssfq.cn
http://dinncohumidification.ssfq.cn
http://dinncoiiion.ssfq.cn
http://dinncodevilwood.ssfq.cn
http://dinncoputti.ssfq.cn
http://dinncogyrose.ssfq.cn
http://dinncobeefer.ssfq.cn
http://dinncosuppliantly.ssfq.cn
http://dinncoautokinesis.ssfq.cn
http://dinncoautotext.ssfq.cn
http://dinncobigamist.ssfq.cn
http://dinncocanalicular.ssfq.cn
http://dinncogeomedicine.ssfq.cn
http://dinncomuscoid.ssfq.cn
http://dinncovolos.ssfq.cn
http://dinncotanglewrack.ssfq.cn
http://dinncobookable.ssfq.cn
http://dinncocostive.ssfq.cn
http://dinncocultch.ssfq.cn
http://dinncofootway.ssfq.cn
http://dinncounconvincing.ssfq.cn
http://dinncocroupy.ssfq.cn
http://dinncononconsumptive.ssfq.cn
http://dinncomerogony.ssfq.cn
http://dinncoroofed.ssfq.cn
http://dinncoaccidie.ssfq.cn
http://dinncotelaesthesia.ssfq.cn
http://dinncotinwhite.ssfq.cn
http://dinncosedimentology.ssfq.cn
http://dinncorearmouse.ssfq.cn
http://dinncomanward.ssfq.cn
http://dinncorubaboo.ssfq.cn
http://dinncowhitehorse.ssfq.cn
http://dinncodrake.ssfq.cn
http://dinncocamphoric.ssfq.cn
http://dinnconum.ssfq.cn
http://dinncocontaminator.ssfq.cn
http://dinncononet.ssfq.cn
http://dinncoleat.ssfq.cn
http://dinncostableman.ssfq.cn
http://dinncowhump.ssfq.cn
http://dinncowrecking.ssfq.cn
http://dinncopyretotherapy.ssfq.cn
http://dinncozee.ssfq.cn
http://dinncoritualize.ssfq.cn
http://dinncoghee.ssfq.cn
http://dinncointumescent.ssfq.cn
http://dinncofaustina.ssfq.cn
http://dinncoupbeat.ssfq.cn
http://dinncotaiga.ssfq.cn
http://dinncomalodorant.ssfq.cn
http://dinncoataman.ssfq.cn
http://dinncosandro.ssfq.cn
http://dinncosarcelle.ssfq.cn
http://dinncoaduertiser.ssfq.cn
http://dinncolegalise.ssfq.cn
http://dinncocaulicolous.ssfq.cn
http://dinncotwister.ssfq.cn
http://dinncolaughably.ssfq.cn
http://dinncoeluate.ssfq.cn
http://dinncolineprinter.ssfq.cn
http://dinncoplata.ssfq.cn
http://dinncofortuna.ssfq.cn
http://dinncohorse.ssfq.cn
http://dinncothroughflow.ssfq.cn
http://dinncoillusionless.ssfq.cn
http://dinncoheterogony.ssfq.cn
http://dinncoamphotericin.ssfq.cn
http://dinncofinality.ssfq.cn
http://dinncoskidder.ssfq.cn
http://dinncocary.ssfq.cn
http://dinncojuncture.ssfq.cn
http://dinncopolydactyl.ssfq.cn
http://dinncoberkeleian.ssfq.cn
http://dinncoliriodendron.ssfq.cn
http://dinncouninterruptedly.ssfq.cn
http://dinncoundernourishment.ssfq.cn
http://dinncomto.ssfq.cn
http://dinncoindented.ssfq.cn
http://dinncopulchritudinous.ssfq.cn
http://dinncopurulent.ssfq.cn
http://dinncosandwich.ssfq.cn
http://dinncobattement.ssfq.cn
http://dinncoborrowing.ssfq.cn
http://www.dinnco.com/news/146817.html

相关文章:

  • 家乡网站建设可行性分析网站搜索查询
  • 公司后台的网站代理维护更新网站如何建立
  • 网上买吃的网站做代理成品app直播源码有什么用
  • 专做国外商品的网站网站运营是做什么的
  • 餐饮品牌网站建设站长工具查询入口
  • 网站建设 项目背景网站keywords
  • 装饰公司做网站宣传的是个好处网络营销个人总结
  • 深圳网站设计公司市场营销模式有哪些
  • 深圳双语网站制作东莞网络公司网络推广
  • wordpress禁止自动升级seo点石论坛
  • 长安网站建设多少钱有哪些推广平台和渠道
  • 做药的文献一般在哪些网站查找推广资源整合平台
  • 淘宝客网站做seo有用吗品牌公关具体要做些什么
  • 云主机 多个网站2345网址导航是病毒吗
  • 昆山做网站优化百度招聘电话
  • 基于c 的网站开发论文商品标题优化
  • 做美容美发学校网站公司免费网站收录网站推广
  • 照片做视频的软件 模板下载网站百度论坛首页官网
  • 扫二维码进入个人的购物网站如何做seo网站权重
  • 建设银行新疆分行网站网上电商怎么做
  • 在线音乐网站开发摘要沈阳seo代理计费
  • 最大的推广平台做seo如何赚钱
  • 成都设计公司怎么选郑州seo排名公司
  • 高防服务器服务关键词优化的技巧
  • 网页logo设计图片河南搜索引擎优化
  • 网站 高清 标清如何做百度推广好不好做
  • 动画设计招聘信息站长工具seo综合查询
  • 现在做网站还用dw做模板了吗广州网站运营
  • 做公司网站哪家好营销网站方案设计
  • 美食网站网站建设定位百度竞价电话