本文整理汇总了Java中org.spongycastle.util.BigIntegers.fromUnsignedByteArray方法的典型用法代码示例。如果您正苦于以下问题:Java BigIntegers.fromUnsignedByteArray方法的具体用法?Java BigIntegers.fromUnsignedByteArray怎么用?Java BigIntegers.fromUnsignedByteArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.spongycastle.util.BigIntegers
的用法示例。
在下文中一共展示了BigIntegers.fromUnsignedByteArray方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: create
import org.spongycastle.util.BigIntegers; //导入方法依赖的package包/类
public static RemascState create(byte[] data) {
RLPList rlpList = (RLPList)RLP.decode2(data).get(0);
byte[] rlpRewardBalanceBytes = rlpList.get(0).getRLPData();
byte[] rlpBurnedBalanceBytes = rlpList.get(1).getRLPData();
BigInteger rlpRewardBalance = rlpRewardBalanceBytes == null ? BigInteger.ZERO : BigIntegers.fromUnsignedByteArray(rlpRewardBalanceBytes);
BigInteger rlpBurnedBalance = rlpBurnedBalanceBytes == null ? BigInteger.ZERO : BigIntegers.fromUnsignedByteArray(rlpBurnedBalanceBytes);
SortedMap<Long, List<Sibling>> rlpSiblings = RemascStorageProvider.getSiblingsFromBytes(rlpList.get(2).getRLPData());
byte[] rlpBrokenSelectionRuleBytes = rlpList.get(3).getRLPData();
Boolean rlpBrokenSelectionRule;
if (rlpBrokenSelectionRuleBytes != null && rlpBrokenSelectionRuleBytes.length != 0 && rlpBrokenSelectionRuleBytes[0] != 0) {
rlpBrokenSelectionRule = Boolean.TRUE;
} else {
rlpBrokenSelectionRule = Boolean.FALSE;
}
return new RemascState(rlpRewardBalance, rlpBurnedBalance, rlpSiblings, rlpBrokenSelectionRule);
}
示例2: create
import org.spongycastle.util.BigIntegers; //导入方法依赖的package包/类
public static Sibling create(byte[] data) {
ArrayList<RLPElement> params = RLP.decode2(data);
RLPList sibling = (RLPList) params.get(0);
byte[] hash = sibling.get(0).getRLPData();
byte[] coinbase = sibling.get(1).getRLPData();
byte[] includedBlockCoinbase = sibling.get(2).getRLPData();
byte[] bytesPaidFees = sibling.get(3).getRLPData();
byte[] bytesIncludedHeight = sibling.get(4).getRLPData();
RLPElement uncleCountElement = sibling.get(5);
byte[] bytesUncleCount = uncleCountElement != null? uncleCountElement.getRLPData():null;
BigInteger paidFees = bytesPaidFees == null ? BigInteger.ZERO : BigIntegers.fromUnsignedByteArray(bytesPaidFees);
long includedHeight = bytesIncludedHeight == null ? 0 : BigIntegers.fromUnsignedByteArray(bytesIncludedHeight).longValue();
int uncleCount = bytesUncleCount == null ? 0 : BigIntegers.fromUnsignedByteArray(bytesUncleCount).intValue();
return new Sibling(hash, coinbase, includedBlockCoinbase, paidFees, includedHeight, uncleCount);
}
示例3: runCreate01Resource
import org.spongycastle.util.BigIntegers; //导入方法依赖的package包/类
@Test
public void runCreate01Resource() throws FileNotFoundException, DslProcessorException {
DslParser parser = DslParser.fromResource("dsl/create01.txt");
World world = new World();
WorldDslProcessor processor = new WorldDslProcessor(world);
processor.processCommands(parser);
Transaction transaction = world.getTransactionByName("tx01");
Assert.assertNotNull(transaction);
TransactionInfo txinfo = world.getBlockChain().getTransactionInfo(transaction.getHash());
Assert.assertNotNull(txinfo);
BigInteger gasUsed = BigIntegers.fromUnsignedByteArray(txinfo.getReceipt().getGasUsed());
Assert.assertNotEquals(BigInteger.ZERO, gasUsed);
// According to TestRPC and geth, the gas used is 0x010c2d
Assert.assertEquals(BigIntegers.fromUnsignedByteArray(Hex.decode("010c2d")), gasUsed);
}
示例4: getRewardBalance
import org.spongycastle.util.BigIntegers; //导入方法依赖的package包/类
public BigInteger getRewardBalance() {
if (rewardBalance!= null) {
return rewardBalance;
}
DataWord address = new DataWord(REWARD_BALANCE_KEY.getBytes(StandardCharsets.UTF_8));
DataWord value = this.repository.getStorageValue(this.contractAddress.getBytes(), address);
if (value == null) {
return BigInteger.ZERO;
}
return BigIntegers.fromUnsignedByteArray(value.getData());
}
示例5: getBurnedBalance
import org.spongycastle.util.BigIntegers; //导入方法依赖的package包/类
public BigInteger getBurnedBalance() {
if (burnedBalance!= null) {
return burnedBalance;
}
DataWord address = new DataWord(BURNED_BALANCE_KEY.getBytes(StandardCharsets.UTF_8));
DataWord value = this.repository.getStorageValue(this.contractAddress.getBytes(), address);
if (value == null) {
return BigInteger.ZERO;
}
return BigIntegers.fromUnsignedByteArray(value.getData());
}
示例6: decodeBigInteger
import org.spongycastle.util.BigIntegers; //导入方法依赖的package包/类
public static BigInteger decodeBigInteger(byte[] data, int index) {
RLPElementView info = RLPElementView.calculateFirstElementInfo(ByteBuffer.wrap(data, index, data.length - index));
if (info.getType() == RLPElementType.NULL_ITEM) {
return BigInteger.ZERO;
}
return BigIntegers.fromUnsignedByteArray(info.getOrCreateElement().getRLPData());
}
示例7: safeToBigInteger
import org.spongycastle.util.BigIntegers; //导入方法依赖的package包/类
private static BigInteger safeToBigInteger(byte[] data) {
return data == null ? BigInteger.ZERO : BigIntegers.fromUnsignedByteArray(data);
}
示例8: getGasPriceAsInteger
import org.spongycastle.util.BigIntegers; //导入方法依赖的package包/类
public BigInteger getGasPriceAsInteger() {
return (this.getGasPrice() == null) ? null : BigIntegers.fromUnsignedByteArray(this.getGasPrice());
}
示例9: getGasLimitAsInteger
import org.spongycastle.util.BigIntegers; //导入方法依赖的package包/类
public BigInteger getGasLimitAsInteger() {
return (this.getGasLimit() == null) ? null : BigIntegers.fromUnsignedByteArray(this.getGasLimit());
}
示例10: getNonceAsInteger
import org.spongycastle.util.BigIntegers; //导入方法依赖的package包/类
public BigInteger getNonceAsInteger() {
return (this.getNonce() == null) ? null : BigIntegers.fromUnsignedByteArray(this.getNonce());
}
示例11: getMinGasPriceAsInteger
import org.spongycastle.util.BigIntegers; //导入方法依赖的package包/类
public BigInteger getMinGasPriceAsInteger() {
return (this.getMinimumGasPrice() == null) ? null : BigIntegers.fromUnsignedByteArray(this.getMinimumGasPrice());
}
示例12: parseBigInteger
import org.spongycastle.util.BigIntegers; //导入方法依赖的package包/类
private static BigInteger parseBigInteger(byte[] bytes) {
return bytes == null ? BigInteger.ZERO : BigIntegers.fromUnsignedByteArray(bytes);
}
示例13: parseLong
import org.spongycastle.util.BigIntegers; //导入方法依赖的package包/类
private long parseLong(byte[] nrBytes) {
if (nrBytes == null) return 0;
BigInteger b = BigIntegers.fromUnsignedByteArray(nrBytes);
return b.longValueExact();
}
示例14: parseInt
import org.spongycastle.util.BigIntegers; //导入方法依赖的package包/类
private int parseInt(byte[] nrBytes) {
if (nrBytes == null) return 0;
BigInteger b = BigIntegers.fromUnsignedByteArray(nrBytes);
return b.intValueExact();
}