method2testcases stringlengths 118 6.63k |
|---|
### Question:
ByteUtil { public static String nibblesToPrettyString(byte[] nibbles) { StringBuilder builder = new StringBuilder(); for (byte nibble : nibbles) { final String nibbleString = oneByteToHexString(nibble); builder.append("\\x").append(nibbleString); } return builder.toString(); } private ByteUtil(); static ... |
### Question:
ByteUtil { public static int firstNonZeroByte(byte[] data) { for (int i = 0; i < data.length; ++i) { if (data[i] != 0) { return i; } } return -1; } private ByteUtil(); static byte[] appendByte(byte[] bytes, byte b); static byte[] cloneBytes(byte[] bytes); static byte[] bigIntegerToBytes(BigInteger b, int... |
### Question:
ByteUtil { public static int getBit(byte[] data, int pos) { if ((data.length * 8) - 1 < pos) { throw new Error("outside byte array limit, pos: " + pos); } int posByte = data.length - 1 - pos / 8; int posBit = pos % 8; byte dataByte = data[posByte]; return Math.min(1, (dataByte & 0xff & (1 << (posBit)))); ... |
### Question:
ByteUtil { public static int numberOfLeadingZeros(byte[] bytes) { int i = firstNonZeroByte(bytes); if (i == -1) { return bytes.length * 8; } else { int byteLeadingZeros = Integer.numberOfLeadingZeros((int)bytes[i] & 0xff) - 24; return i * 8 + byteLeadingZeros; } } private ByteUtil(); static byte[] append... |
### Question:
ByteUtil { public static byte[] parseBytes(byte[] input, int offset, int len) { if (offset >= input.length || len == 0) { return EMPTY_BYTE_ARRAY; } byte[] bytes = new byte[len]; System.arraycopy(input, offset, bytes, 0, Math.min(input.length - offset, len)); return bytes; } private ByteUtil(); static by... |
### Question:
Utils { public static String getValueShortString(BigInteger number) { BigInteger result = number; int pow = 0; while (result.compareTo(_1000_) == 1 || result.compareTo(_1000_) == 0) { result = result.divide(_1000_); pow += 3; } return result.toString() + "·(" + "10^" + pow + ")"; } static BigInteger unif... |
### Question:
Utils { public static byte[] addressStringToBytes(String hex) { final byte[] addr; try { addr = Hex.decode(hex); } catch (DecoderException addressIsNotValid) { return null; } if (isValidAddress(addr)) { return addr; } return null; } static BigInteger unifiedNumericToBigInteger(String number); static Stri... |
### Question:
Utils { public static void validateArrayAllegedSize(byte[] data, int offset, int allegedSize) { if (data.length < Math.addExact(allegedSize, offset)) { throw new IllegalArgumentException("The specified size exceeds the size of the payload"); } } static BigInteger unifiedNumericToBigInteger(String number)... |
### Question:
Utils { public static byte[] safeCopyOfRange(byte[] data, int from, int size) { validateArrayAllegedSize(data, from, size); return Arrays.copyOfRange(data, from, from + size); } static BigInteger unifiedNumericToBigInteger(String number); static String longToDateTime(long timestamp); static String getVal... |
### Question:
Utils { public static boolean isHexadecimalString(String s) { return s.matches("^0x[\\da-fA-F]+$"); } static BigInteger unifiedNumericToBigInteger(String number); static String longToDateTime(long timestamp); static String getValueShortString(BigInteger number); static byte[] addressStringToBytes(String ... |
### Question:
Utils { public static boolean isDecimalString(String s) { return s.matches("^\\d+$"); } static BigInteger unifiedNumericToBigInteger(String number); static String longToDateTime(long timestamp); static String getValueShortString(BigInteger number); static byte[] addressStringToBytes(String hex); static b... |
### Question:
Utils { public static long decimalStringToLong(String s) { try { return Long.parseLong(s, 10); } catch (NumberFormatException e) { throw new IllegalArgumentException(String.format("Invalid decimal number: %s", s), e); } } static BigInteger unifiedNumericToBigInteger(String number); static String longToDa... |
### Question:
Utils { public static long hexadecimalStringToLong(String s) { if (!s.startsWith("0x")) { throw new IllegalArgumentException(String.format("Invalid hexadecimal number: %s", s)); } try { return Long.parseLong(s.substring(2), 16); } catch (NumberFormatException e) { throw new IllegalArgumentException(String... |
### Question:
Utils { public static int significantBitCount(int number) { int result = 0; while (number > 0) { result++; number >>= 1; } return result; } static BigInteger unifiedNumericToBigInteger(String number); static String longToDateTime(long timestamp); static String getValueShortString(BigInteger number); stat... |
### Question:
ByteArrayWrapper implements Comparable<ByteArrayWrapper>, Serializable { public boolean equals(Object other) { if (!(other instanceof ByteArrayWrapper)) { return false; } byte[] otherData = ((ByteArrayWrapper) other).data; return ByteUtil.fastEquals(data, otherData); } ByteArrayWrapper(byte[] data); boole... |
### Question:
ByteArrayWrapper implements Comparable<ByteArrayWrapper>, Serializable { @Override public int compareTo(ByteArrayWrapper o) { return FastByteComparisons.compareTo( data, 0, data.length, o.data, 0, o.data.length); } ByteArrayWrapper(byte[] data); boolean equals(Object other); @Override int hashCode(); @Ove... |
### Question:
ReceiptStoreImpl implements ReceiptStore { @Override public TransactionInfo get(byte[] transactionHash){ List<TransactionInfo> txs = getAll(transactionHash); if (txs.isEmpty()) { return null; } return txs.get(txs.size() - 1); } ReceiptStoreImpl(KeyValueDataSource receiptsDS); @Override void add(byte[] blo... |
### Question:
IndexedBlockStore implements BlockStore { public void rewind(long blockNumber) { if (index.isEmpty()) { return; } long maxNumber = getMaxNumber(); for (long i = maxNumber; i > blockNumber; i--) { List<BlockInfo> blockInfos = index.removeLast(); for (BlockInfo blockInfo : blockInfos) { this.blocks.delete(b... |
### Question:
Constants { public static Constants devnetWithFederation(List<BtcECKey> federationPublicKeys) { return new Constants( DEVNET_CHAIN_ID, false, 14, new BlockDifficulty(BigInteger.valueOf(131072)), new BlockDifficulty(BigInteger.valueOf((long) 14E15)), BigInteger.valueOf(50), 540, new BridgeDevNetConstants(f... |
### Question:
ActivationConfig { public static ActivationConfig read(Config config) { Map<NetworkUpgrade, Long> networkUpgrades = new EnumMap<>(NetworkUpgrade.class); Config networkUpgradesConfig = config.getConfig(PROPERTY_ACTIVATION_HEIGHTS); for (Map.Entry<String, ConfigValue> e : networkUpgradesConfig.entrySet()) {... |
### Question:
EncryptionHandshake { public AuthInitiateMessage createAuthInitiate(@Nullable byte[] token, ECKey key) { AuthInitiateMessage message = new AuthInitiateMessage(); boolean isToken; if (token == null) { isToken = false; BigInteger secretScalar = remotePublicKey.multiply(key.getPrivKey()).normalize().getXCoor... |
### Question:
Node implements Serializable { public InetSocketAddress getAddress() { return new InetSocketAddress(this.getHost(), this.getPort()); } Node(String enodeURL); Node(byte[] id, String host, int port); Node(byte[] rlp); NodeID getId(); String getHexId(); String getHost(); int getPort(); byte[] getRLP(); Ine... |
### Question:
NodeManager { public synchronized List<NodeHandler> getNodes(Set<String> nodesInUse) { List<NodeHandler> handlers = new ArrayList<>(); List<Node> foundNodes = this.peerExplorer.getNodes(); if (this.discoveryEnabled && !foundNodes.isEmpty()) { logger.debug("{} Nodes retrieved from the PE.", foundNodes.size... |
### Question:
NodeManager { public NodeStatistics getNodeStatistics(Node n) { return discoveryEnabled ? getNodeHandler(n).getNodeStatistics() : DUMMY_STAT; } NodeManager(PeerExplorer peerExplorer, SystemProperties config); NodeStatistics getNodeStatistics(Node n); synchronized List<NodeHandler> getNodes(Set<String> nod... |
### Question:
Channel implements Peer { public void setInetSocketAddress(InetSocketAddress inetSocketAddress) { this.inetSocketAddress = inetSocketAddress; } Channel(MessageQueue msgQueue,
MessageCodec messageCodec,
NodeManager nodeManager,
RskWireProtocol.Factor... |
### Question:
ChannelManagerImpl implements ChannelManager { @VisibleForTesting int getNumberOfPeersToSendStatusTo(int peerCount) { int peerCountSqrt = (int) Math.sqrt(peerCount); return Math.min(10, Math.min(Math.max(3, peerCountSqrt), peerCount)); } ChannelManagerImpl(RskSystemProperties config, SyncPool syncPool); @... |
### Question:
ChannelManagerImpl implements ChannelManager { public boolean isAddressBlockAvailable(InetAddress inetAddress) { synchronized (activePeersLock) { return activePeers.values().stream() .map(ch -> new InetAddressBlock(ch.getInetSocketAddress().getAddress(), networkCIDR)) .filter(block -> block.contains(inetA... |
### Question:
ChannelManagerImpl implements ChannelManager { @Nonnull public Set<NodeID> broadcastBlock(@Nonnull final Block block) { final Set<NodeID> nodesIdsBroadcastedTo = new HashSet<>(); final BlockIdentifier bi = new BlockIdentifier(block.getHash().getBytes(), block.getNumber()); final Message newBlock = new Blo... |
### Question:
DataSourceWithCache implements KeyValueDataSource { @Override public byte[] put(byte[] key, byte[] value) { ByteArrayWrapper wrappedKey = ByteUtil.wrap(key); return put(wrappedKey, value); } DataSourceWithCache(KeyValueDataSource base, int cacheSize); @Override byte[] get(byte[] key); @Override byte[] put... |
### Question:
DataSourceWithCache implements KeyValueDataSource { @Override public Set<byte[]> keys() { Stream<ByteArrayWrapper> baseKeys; Stream<ByteArrayWrapper> committedKeys; Stream<ByteArrayWrapper> uncommittedKeys; Set<ByteArrayWrapper> uncommittedKeysToRemove; this.lock.readLock().lock(); try { baseKeys = base.k... |
### Question:
DataSourceWithCache implements KeyValueDataSource { @Override public void delete(byte[] key) { delete(ByteUtil.wrap(key)); } DataSourceWithCache(KeyValueDataSource base, int cacheSize); @Override byte[] get(byte[] key); @Override byte[] put(byte[] key, byte[] value); @Override void delete(byte[] key); @Ov... |
### Question:
DataSourceWithCache implements KeyValueDataSource { @Override public void updateBatch(Map<ByteArrayWrapper, byte[]> rows, Set<ByteArrayWrapper> keysToRemove) { if (rows.containsKey(null) || rows.containsValue(null)) { throw new IllegalArgumentException("Cannot update null values"); } rows.keySet().removeA... |
### Question:
TransactionSet { public List<Transaction> getTransactions() { return transactionsByHash.values().stream() .collect(Collectors.collectingAndThen(Collectors.toList(), Collections::unmodifiableList)); } TransactionSet(); TransactionSet(TransactionSet transactionSet); TransactionSet(Map<Keccak256, Transacti... |
### Question:
TransactionSet { public boolean hasTransaction(Transaction transaction) { return this.transactionsByHash.containsKey(transaction.getHash()); } TransactionSet(); TransactionSet(TransactionSet transactionSet); TransactionSet(Map<Keccak256, Transaction> transactionsByHash, Map<RskAddress, List<Transaction>... |
### Question:
TransactionSet { public List<Transaction> getTransactionsWithSender(RskAddress senderAddress) { List<Transaction> list = this.transactionsByAddress.get(senderAddress); if (list == null) { return Collections.emptyList(); } return list; } TransactionSet(); TransactionSet(TransactionSet transactionSet); Tr... |
### Question:
Transaction { public void verify() { validate(); } protected Transaction(byte[] rawData); Transaction(byte[] nonce, byte[] gasPriceRaw, byte[] gasLimit, byte[] receiveAddress, byte[] value, byte[] data); Transaction(byte[] nonce, byte[] gasPriceRaw, byte[] gasLimit, byte[] receiveAddress, byte[] value,... |
### Question:
Transaction { @Override public String toString() { return "TransactionData [" + "hash=" + ByteUtil.toHexStringOrEmpty(getHash().getBytes()) + " nonce=" + ByteUtil.toHexStringOrEmpty(nonce) + ", gasPrice=" + gasPrice + ", gas=" + ByteUtil.toHexStringOrEmpty(gasLimit) + ", receiveAddress=" + receiveAddress ... |
### Question:
AccountState { public byte[] getEncoded() { if (rlpEncoded == null) { byte[] anonce = RLP.encodeBigInteger(this.nonce); byte[] abalance = RLP.encodeSignedCoinNonNullZero(this.balance); if (stateFlags != 0) { byte[] astateFlags = RLP.encodeInt(this.stateFlags); this.rlpEncoded = RLP.encodeList(anonce, abal... |
### Question:
DifficultyRule extends DependentBlockHeaderRule { @Override public boolean validate(BlockHeader header, BlockHeader parent) { BlockDifficulty calcDifficulty = difficultyCalculator.calcDifficulty(header, parent); BlockDifficulty difficulty = header.getDifficulty(); if (!difficulty.equals(calcDifficulty)) {... |
### Question:
ParentNumberRule extends DependentBlockHeaderRule { @Override public boolean validate(BlockHeader header, BlockHeader parent) { if (header.getNumber() != (parent.getNumber() + 1)) { logger.error(String.format("#%d: block number is not parentBlock number + 1", header.getNumber())); return false; } return t... |
### Question:
ParentGasLimitRule extends DependentBlockHeaderRule { @Override public boolean validate(BlockHeader header, BlockHeader parent) { BigInteger headerGasLimit = new BigInteger(1, header.getGasLimit()); BigInteger parentGasLimit = new BigInteger(1, parent.getGasLimit()); BigInteger deltaLimit = parentGasLimit... |
### Question:
GasCost { public static long add(long x, long y) throws InvalidGasException { if (x < 0 || y < 0) { throw new InvalidGasException(String.format("%d + %d", x, y)); } long result = x + y; if (result < 0) { return Long.MAX_VALUE; } return result; } private GasCost(); static long toGas(byte[] bytes); static ... |
### Question:
GasCost { public static long subtract(long x, long y) throws InvalidGasException { if (y < 0 || y > x) { throw new InvalidGasException(String.format("%d - %d", x, y)); } return x - y; } private GasCost(); static long toGas(byte[] bytes); static long toGas(BigInteger big); static long toGas(long number); ... |
### Question:
DataWord implements Comparable<DataWord> { public DataWord add(DataWord word) { byte[] newdata = new byte[BYTES]; for (int i = 31, overflow = 0; i >= 0; i--) { int v = (this.data[i] & 0xff) + (word.data[i] & 0xff) + overflow; newdata[i] = (byte) v; overflow = v >>> 8; } return new DataWord(newdata); } pri... |
### Question:
DataWord implements Comparable<DataWord> { public DataWord mod(DataWord word) { if (word.isZero()) { return DataWord.ZERO; } BigInteger result = value().mod(word.value()); return valueOf(result.and(MAX_VALUE)); } private DataWord(byte[] data); byte[] getData(); byte[] getNoLeadZeroesData(); byte[] getByt... |
### Question:
DataWord implements Comparable<DataWord> { public DataWord mul(DataWord word) { BigInteger result = value().multiply(word.value()); return valueOf(result.and(MAX_VALUE)); } private DataWord(byte[] data); byte[] getData(); byte[] getNoLeadZeroesData(); byte[] getByteArrayForStorage(); byte[] getLast20Byte... |
### Question:
DataWord implements Comparable<DataWord> { public DataWord div(DataWord word) { if (word.isZero()) { return DataWord.ZERO; } BigInteger result = value().divide(word.value()); return valueOf(result.and(MAX_VALUE)); } private DataWord(byte[] data); byte[] getData(); byte[] getNoLeadZeroesData(); byte[] get... |
### Question:
DataWord implements Comparable<DataWord> { public static DataWord valueOf(int num) { byte[] data = new byte[BYTES]; ByteBuffer.wrap(data).putInt(data.length - Integer.BYTES, num); return valueOf(data); } private DataWord(byte[] data); byte[] getData(); byte[] getNoLeadZeroesData(); byte[] getByteArrayFor... |
### Question:
DataWord implements Comparable<DataWord> { public DataWord signExtend(byte k) { byte[] newdata = getData(); if (0 > k || k > 31) { throw new IndexOutOfBoundsException(); } byte mask = (new BigInteger(newdata)).testBit((k * 8) + 7) ? (byte) 0xff : 0; for (int i = 31; i > k; i--) { newdata[31 - i] = mask; }... |
### Question:
DataWord implements Comparable<DataWord> { public static DataWord fromString(String value) { return valueOf(value.getBytes(StandardCharsets.UTF_8)); } private DataWord(byte[] data); byte[] getData(); byte[] getNoLeadZeroesData(); byte[] getByteArrayForStorage(); byte[] getLast20Bytes(); BigInteger value(... |
### Question:
DataWord implements Comparable<DataWord> { public static DataWord fromLongString(String value) { return valueOf(HashUtil.keccak256(value.getBytes(StandardCharsets.UTF_8))); } private DataWord(byte[] data); byte[] getData(); byte[] getNoLeadZeroesData(); byte[] getByteArrayForStorage(); byte[] getLast20By... |
### Question:
CallArgumentsToByteArray { public byte[] getGasLimit() { String maxGasLimit = "0x5AF3107A4000"; byte[] gasLimit = stringHexToByteArray(maxGasLimit); if (args.gas != null && args.gas.length() != 0) { gasLimit = stringHexToByteArray(args.gas); } return gasLimit; } CallArgumentsToByteArray(Web3.CallArguments... |
### Question:
EthSubscriptionNotificationEmitter implements EthSubscribeParamsVisitor { @Override public SubscriptionId visit(EthSubscribeNewHeadsParams params, Channel channel) { SubscriptionId subscriptionId = new SubscriptionId(); blockHeader.subscribe(subscriptionId, channel); return subscriptionId; } EthSubscripti... |
### Question:
EthSubscriptionNotificationEmitter implements EthSubscribeParamsVisitor { public boolean unsubscribe(SubscriptionId subscriptionId) { boolean unsubscribedBlockHeader = blockHeader.unsubscribe(subscriptionId); boolean unsubscribedLogs = logs.unsubscribe(subscriptionId); return unsubscribedBlockHeader || un... |
### Question:
TxPoolModuleImpl implements TxPoolModule { @Override public JsonNode status() { Map<String, JsonNode> txProps = new HashMap<>(); txProps.put(PENDING, jsonNodeFactory.numberNode(transactionPool.getPendingTransactions().size())); txProps.put(QUEUED, jsonNodeFactory.numberNode(transactionPool.getQueuedTransa... |
### Question:
CallArgumentsToByteArray { public byte[] getToAddress() { byte[] toAddress = null; if (args.to != null) { toAddress = stringHexToByteArray(args.to); } return toAddress; } CallArgumentsToByteArray(Web3.CallArguments args); byte[] getGasPrice(); byte[] getGasLimit(); byte[] getToAddress(); byte[] getValue()... |
### Question:
DebugModuleImpl implements DebugModule { @Override public String wireProtocolQueueSize() { long n = messageHandler.getMessageQueueSize(); return TypeConverter.toQuantityJsonHex(n); } DebugModuleImpl(
BlockStore blockStore,
ReceiptStore receiptStore,
MessageHandler messa... |
### Question:
EthModule implements EthModuleWallet, EthModuleTransaction { public String call(Web3.CallArguments args, String bnOrId) { String s = null; try { BlockResult blockResult = executionBlockRetriever.getExecutionBlock_workaround(bnOrId); ProgramResult res; if (blockResult.getFinalState() != null) { res = callC... |
### Question:
EthModule implements EthModuleWallet, EthModuleTransaction { public String getCode(String address, String blockId) { if (blockId == null) { throw new NullPointerException(); } String s = null; try { RskAddress addr = new RskAddress(address); AccountInformationProvider accountInformationProvider = getAccou... |
### Question:
EthModule implements EthModuleWallet, EthModuleTransaction { public String chainId() { return TypeConverter.toJsonHex(new byte[] { chainId }); } EthModule(
BridgeConstants bridgeConstants,
byte chainId,
Blockchain blockchain,
TransactionPool transactionPool,... |
### Question:
EthUnsubscribeRequest extends RskJsonRpcRequest { @JsonInclude(JsonInclude.Include.NON_NULL) public EthUnsubscribeParams getParams() { return params; } @JsonCreator EthUnsubscribeRequest(
@JsonProperty("jsonrpc") JsonRpcVersion version,
@JsonProperty("method") RskJsonRpcMethod met... |
### Question:
LogsNotification implements EthSubscriptionNotificationDTO { public String getLogIndex() { if (lazyLogIndex == null) { lazyLogIndex = toQuantityJsonHex(logInfoIndex); } return lazyLogIndex; } LogsNotification(LogInfo logInfo, Block b, int txIndex, Transaction tx, int logIdx, boolean r); String getLogIndex... |
### Question:
LogsNotification implements EthSubscriptionNotificationDTO { public String getBlockNumber() { if (lazyBlockNumber == null) { lazyBlockNumber = toQuantityJsonHex(block.getNumber()); } return lazyBlockNumber; } LogsNotification(LogInfo logInfo, Block b, int txIndex, Transaction tx, int logIdx, boolean r); S... |
### Question:
LogsNotification implements EthSubscriptionNotificationDTO { public String getBlockHash() { if (lazyBlockHash == null) { lazyBlockHash = block.getHashJsonString(); } return lazyBlockHash; } LogsNotification(LogInfo logInfo, Block b, int txIndex, Transaction tx, int logIdx, boolean r); String getLogIndex()... |
### Question:
LogsNotification implements EthSubscriptionNotificationDTO { public String getTransactionHash() { if (lazyTransactionHash == null) { lazyTransactionHash = transaction.getHash().toJsonString(); } return lazyTransactionHash; } LogsNotification(LogInfo logInfo, Block b, int txIndex, Transaction tx, int logId... |
### Question:
LogsNotification implements EthSubscriptionNotificationDTO { public String getTransactionIndex() { if (lazyTransactionIndex == null) { lazyTransactionIndex = toQuantityJsonHex(transactionIndex); } return lazyTransactionIndex; } LogsNotification(LogInfo logInfo, Block b, int txIndex, Transaction tx, int lo... |
### Question:
LogsNotification implements EthSubscriptionNotificationDTO { public String getAddress() { if (lazyAddress == null) { lazyAddress = toJsonHex(logInfo.getAddress()); } return lazyAddress; } LogsNotification(LogInfo logInfo, Block b, int txIndex, Transaction tx, int logIdx, boolean r); String getLogIndex(); ... |
### Question:
LogsNotification implements EthSubscriptionNotificationDTO { public String getData() { if (lazyData == null) { lazyData = toJsonHex(logInfo.getData()); } return lazyData; } LogsNotification(LogInfo logInfo, Block b, int txIndex, Transaction tx, int logIdx, boolean r); String getLogIndex(); String getBlock... |
### Question:
LogsNotification implements EthSubscriptionNotificationDTO { public List<String> getTopics() { if (lazyTopics == null) { lazyTopics = logInfo.getTopics().stream() .map(t -> toJsonHex(t.getData())) .collect(Collectors.toList()); } return Collections.unmodifiableList(lazyTopics); } LogsNotification(LogInfo ... |
### Question:
BlockHeaderNotificationEmitter { public void subscribe(SubscriptionId subscriptionId, Channel channel) { subscriptions.put(subscriptionId, channel); } BlockHeaderNotificationEmitter(Ethereum ethereum, JsonRpcSerializer jsonRpcSerializer); void subscribe(SubscriptionId subscriptionId, Channel channel); boo... |
### Question:
TraceAddress { @JsonValue public int[] toAddress() { if (this.parent == null) { return EMPTY_ADDRESS; } int[] parentAddress = this.parent.toAddress(); int[] address = Arrays.copyOf(parentAddress, parentAddress.length + 1); address[address.length - 1] = this.index; return address; } TraceAddress(); TraceA... |
### Question:
TraceModuleImpl implements TraceModule { @Override public JsonNode traceBlock(String blockArgument) throws Exception { logger.trace("trace_block({})", blockArgument); Block block = this.getByJsonArgument(blockArgument); if (block == null) { logger.trace("No block for {}", blockArgument); return null; } Bl... |
### Question:
RskJsonRpcHandler extends SimpleChannelInboundHandler<ByteBufHolder> implements RskJsonRpcRequestVisitor { @Override public JsonRpcResultOrError visit(EthUnsubscribeRequest request, ChannelHandlerContext ctx) { boolean unsubscribed = emitter.unsubscribe(request.getParams().getSubscriptionId()); return new... |
### Question:
Web3RskImpl extends Web3Impl { public void ext_dumpState() { Block bestBlcock = blockStore.getBestBlock(); logger.info("Dumping state for block hash {}, block number {}", bestBlcock.getHash(), bestBlcock.getNumber()); networkStateExporter.exportStatus(System.getProperty("user.dir") + "/" + "rskdump.json")... |
### Question:
Web3InformationRetriever { public Optional<Block> getBlock(String identifier) { if (PENDING.equals(identifier)) { throw unimplemented("This method doesn't support 'pending' as a parameter"); } Block block; if (LATEST.equals(identifier)) { block = blockchain.getBestBlock(); } else if (EARLIEST.equals(ident... |
### Question:
Web3InformationRetriever { public List<Transaction> getTransactions(String identifier) { if (PENDING.equals(identifier)) { return transactionPool.getPendingTransactions(); } Optional<Block> block = getBlock(identifier); return block.map(Block::getTransactionsList) .orElseThrow(() -> blockNotFound(String.f... |
### Question:
Web3InformationRetriever { public AccountInformationProvider getInformationProvider(String identifier) { if (PENDING.equals(identifier)) { return transactionPool.getPendingState(); } Optional<Block> optBlock = getBlock(identifier); if (!optBlock.isPresent()) { throw blockNotFound(String.format("Block %s n... |
### Question:
JsonRpcMethodFilter implements RequestInterceptor { @Override public void interceptRequest(JsonNode node) throws IOException { if (node.hasNonNull(JsonRpcBasicServer.METHOD)) { checkMethod(node.get(JsonRpcBasicServer.METHOD).asText()); } } JsonRpcMethodFilter(List<ModuleDescription> modules); @Override vo... |
### Question:
OriginValidator { public boolean isValidReferer(String referer) { if (this.allowAllOrigins) { return true; } URL refererUrl = null; try { refererUrl = new URL(referer); } catch (MalformedURLException e) { return false; } String refererProtocol = refererUrl.getProtocol(); if (refererProtocol == null) { ret... |
### Question:
ModuleDescription { public boolean methodIsInModule(String methodName) { if (methodName == null) { return false; } if (!methodName.startsWith(this.name)) { return false; } if (methodName.length() == this.name.length()) { return false; } if (methodName.charAt(this.name.length()) != '_') { return false; } r... |
### Question:
EncryptedData { public EncryptedData(byte[] initialisationVector, byte[] encryptedBytes) { this.initialisationVector = Arrays.copyOf(initialisationVector, initialisationVector.length); this.encryptedBytes = Arrays.copyOf(encryptedBytes, encryptedBytes.length); } EncryptedData(byte[] initialisationVector, ... |
### Question:
MinerManager { public void mineBlock(MinerClient minerClient, MinerServer minerServer) { minerServer.buildBlockToMine(false); minerClient.mineBlock(); } void mineBlock(MinerClient minerClient, MinerServer minerServer); }### Answer:
@Test public void refreshWorkRunOnce() { Assert.assertEquals(0, blockcha... |
### Question:
AutoMinerClient implements MinerClient { @Override public boolean isMining() { return this.isMining; } AutoMinerClient(MinerServer minerServer); @Override void start(); @Override boolean isMining(); @Override boolean mineBlock(); @Override void stop(); }### Answer:
@Test public void byDefaultIsDisabled()... |
### Question:
LogFilter extends Filter { @Override public void newBlockReceived(Block b) { if (this.fromLatestBlock) { this.clearEvents(); onBlock(b); } else if (this.toLatestBlock) { onBlock(b); } } LogFilter(AddressesTopicsFilter addressesTopicsFilter, Blockchain blockchain, boolean fromLatestBlock, boolean toLatestB... |
### Question:
CallArgumentsToByteArray { public byte[] getValue() { byte[] value = new byte[] { 0 }; if (args.value != null && args.value.length() != 0) { value = stringHexToByteArray(args.value); } return value; } CallArgumentsToByteArray(Web3.CallArguments args); byte[] getGasPrice(); byte[] getGasLimit(); byte[] get... |
### Question:
MinerClock { public long calculateTimestampForChild(BlockHeader parentHeader) { long previousTimestamp = parentHeader.getTimestamp(); if (isFixedClock) { return previousTimestamp + timeAdjustment; } long ret = clock.instant().plusSeconds(timeAdjustment).getEpochSecond(); return Long.max(ret, previousTimes... |
### Question:
MinimumGasPriceCalculator { public Coin calculate(Coin previousMGP) { BlockGasPriceRange priceRange = new BlockGasPriceRange(previousMGP); if (priceRange.inRange(targetMGP)) { return targetMGP; } if (previousMGP.compareTo(targetMGP) < 0) { return priceRange.getUpperLimit(); } return priceRange.getLowerLim... |
### Question:
HashRateCalculator { public abstract BigInteger calculateNodeHashRate(Duration duration); HashRateCalculator(BlockStore blockStore, RskCustomCache<Keccak256, BlockHeaderElement> headerCache); void start(); void stop(); abstract BigInteger calculateNodeHashRate(Duration duration); BigInteger calculateNetHa... |
### Question:
HashRateCalculator { public BigInteger calculateNetHashRate(Duration period) { return calculateHashRate(b -> true, period); } HashRateCalculator(BlockStore blockStore, RskCustomCache<Keccak256, BlockHeaderElement> headerCache); void start(); void stop(); abstract BigInteger calculateNodeHashRate(Duration ... |
### Question:
ListArrayUtil { public static List<Byte> asByteList(byte[] primitiveByteArray) { Byte[] arrayObj = convertTo(primitiveByteArray); return Arrays.asList(arrayObj); } private ListArrayUtil(); static List<Byte> asByteList(byte[] primitiveByteArray); static boolean isEmpty(@Nullable byte[] array); static int ... |
### Question:
ListArrayUtil { public static boolean isEmpty(@Nullable byte[] array) { return array == null || array.length == 0; } private ListArrayUtil(); static List<Byte> asByteList(byte[] primitiveByteArray); static boolean isEmpty(@Nullable byte[] array); static int getLength(@Nullable byte[] array); static byte[... |
### Question:
ListArrayUtil { public static byte[] nullToEmpty(@Nullable byte[] array) { if (array == null) { return new byte[0]; } return array; } private ListArrayUtil(); static List<Byte> asByteList(byte[] primitiveByteArray); static boolean isEmpty(@Nullable byte[] array); static int getLength(@Nullable byte[] arr... |
### Question:
ListArrayUtil { public static int getLength(@Nullable byte[] array) { if (array == null) { return 0; } return array.length; } private ListArrayUtil(); static List<Byte> asByteList(byte[] primitiveByteArray); static boolean isEmpty(@Nullable byte[] array); static int getLength(@Nullable byte[] array); sta... |
### Question:
Topic { @Override public boolean equals(Object other) { if (this == other) { return true; } if (other == null || this.getClass() != other.getClass()) { return false; } Topic otherTopic = (Topic) other; return Arrays.equals(bytes, otherTopic.bytes); } Topic(String topic); Topic(byte[] bytes); byte[] getBy... |
### Question:
IpUtils { public static InetSocketAddress parseAddress(String address) { if(StringUtils.isBlank(address)) { return null; } Matcher matcher = ipv6Pattern.matcher(address); if(matcher.matches()) { return parseMatch(matcher); } matcher = ipv4Pattern.matcher(address); if (matcher.matches() && matcher.groupCou... |
### Question:
PendingTransactionFilter extends Filter { @Override public void newPendingTx(Transaction tx) { add(new PendingTransactionFilterEvent(tx)); } @Override void newPendingTx(Transaction tx); }### Answer:
@Test public void oneTransactionAndEvents() { PendingTransactionFilter filter = new PendingTransactionFil... |
### Question:
IpUtils { public static List<InetSocketAddress> parseAddresses(List<String> addresses) { List<InetSocketAddress> result = new ArrayList<>(); for(String a : addresses) { InetSocketAddress res = parseAddress(a); if (res != null) { result.add(res); } } return result; } static InetSocketAddress parseAddress(... |
### Question:
FormatUtils { public static String formatNanosecondsToSeconds(long nanoseconds) { return String.format("%.6f", nanoseconds / 1_000_000_000.0); } private FormatUtils(); static String formatNanosecondsToSeconds(long nanoseconds); }### Answer:
@Test public void formatNanosecondsToSeconds() { Assert.assertE... |
### Question:
FullNodeRunner implements NodeRunner { @Override public void run() { logger.info("Starting RSK"); logger.info( "Running {}, core version: {}-{}", rskSystemProperties.genesisInfo(), rskSystemProperties.projectVersion(), rskSystemProperties.projectVersionModifier() ); buildInfo.printInfo(logger); for (Inter... |
### Question:
FullNodeRunner implements NodeRunner { @Override public void stop() { logger.info("Shutting down RSK node"); for (int i = internalServices.size() - 1; i >= 0; i--) { internalServices.get(i).stop(); } logger.info("RSK node Shut down"); } FullNodeRunner(
List<InternalService> internalServices,
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.