id
stringlengths 7
14
| text
stringlengths 1
106k
|
---|---|
206414745_1242 | @SuppressWarnings("unchecked")
public <T> Function<Subscription, T> mapToSubscriptionClass(final Class<T> clazz) {
return subscription -> {
if (clazz.isAssignableFrom(subscription.getClass())) {
return (T) subscription;
} else {
final String msg =
String.format(
"%s instance can't be mapped to type %s",
subscription.getClass().getSimpleName(), clazz.getSimpleName());
throw new IllegalArgumentException(msg);
}
};
} |
206414745_1243 | @SuppressWarnings("unchecked")
public <T> Function<Subscription, T> mapToSubscriptionClass(final Class<T> clazz) {
return subscription -> {
if (clazz.isAssignableFrom(subscription.getClass())) {
return (T) subscription;
} else {
final String msg =
String.format(
"%s instance can't be mapped to type %s",
subscription.getClass().getSimpleName(), clazz.getSimpleName());
throw new IllegalArgumentException(msg);
}
};
} |
206414745_1244 | @SuppressWarnings("unchecked")
public <T> Function<Subscription, T> mapToSubscriptionClass(final Class<T> clazz) {
return subscription -> {
if (clazz.isAssignableFrom(subscription.getClass())) {
return (T) subscription;
} else {
final String msg =
String.format(
"%s instance can't be mapped to type %s",
subscription.getClass().getSimpleName(), clazz.getSimpleName());
throw new IllegalArgumentException(msg);
}
};
} |
206414745_1245 | public UnsubscribeRequest mapUnsubscribeRequest(final JsonRpcRequestContext jsonRpcRequestContext)
throws InvalidSubscriptionRequestException {
try {
final WebSocketRpcRequest webSocketRpcRequestBody = validateRequest(jsonRpcRequestContext);
final long subscriptionId =
webSocketRpcRequestBody.getRequiredParameter(0, UnsignedLongParameter.class).getValue();
return new UnsubscribeRequest(subscriptionId, webSocketRpcRequestBody.getConnectionId());
} catch (final Exception e) {
throw new InvalidSubscriptionRequestException("Error parsing unsubscribe request", e);
}
} |
206414745_1246 | public UnsubscribeRequest mapUnsubscribeRequest(final JsonRpcRequestContext jsonRpcRequestContext)
throws InvalidSubscriptionRequestException {
try {
final WebSocketRpcRequest webSocketRpcRequestBody = validateRequest(jsonRpcRequestContext);
final long subscriptionId =
webSocketRpcRequestBody.getRequiredParameter(0, UnsignedLongParameter.class).getValue();
return new UnsubscribeRequest(subscriptionId, webSocketRpcRequestBody.getConnectionId());
} catch (final Exception e) {
throw new InvalidSubscriptionRequestException("Error parsing unsubscribe request", e);
}
} |
206414745_1247 | public SubscribeRequest mapSubscribeRequest(final JsonRpcRequestContext jsonRpcRequestContext)
throws InvalidSubscriptionRequestException {
try {
final WebSocketRpcRequest webSocketRpcRequestBody = validateRequest(jsonRpcRequestContext);
final SubscriptionType subscriptionType =
webSocketRpcRequestBody.getRequiredParameter(0, SubscriptionType.class);
switch (subscriptionType) {
case NEW_BLOCK_HEADERS:
{
final boolean includeTransactions = includeTransactions(webSocketRpcRequestBody);
return parseNewBlockHeadersRequest(webSocketRpcRequestBody, includeTransactions);
}
case LOGS:
{
return parseLogsRequest(webSocketRpcRequestBody);
}
case NEW_PENDING_TRANSACTIONS:
case SYNCING:
default:
final boolean includeTransactions = includeTransactions(webSocketRpcRequestBody);
return new SubscribeRequest(
subscriptionType,
null,
includeTransactions,
webSocketRpcRequestBody.getConnectionId());
}
} catch (final Exception e) {
throw new InvalidSubscriptionRequestException("Error parsing subscribe request", e);
}
} |
206414745_1248 | public SubscribeRequest mapSubscribeRequest(final JsonRpcRequestContext jsonRpcRequestContext)
throws InvalidSubscriptionRequestException {
try {
final WebSocketRpcRequest webSocketRpcRequestBody = validateRequest(jsonRpcRequestContext);
final SubscriptionType subscriptionType =
webSocketRpcRequestBody.getRequiredParameter(0, SubscriptionType.class);
switch (subscriptionType) {
case NEW_BLOCK_HEADERS:
{
final boolean includeTransactions = includeTransactions(webSocketRpcRequestBody);
return parseNewBlockHeadersRequest(webSocketRpcRequestBody, includeTransactions);
}
case LOGS:
{
return parseLogsRequest(webSocketRpcRequestBody);
}
case NEW_PENDING_TRANSACTIONS:
case SYNCING:
default:
final boolean includeTransactions = includeTransactions(webSocketRpcRequestBody);
return new SubscribeRequest(
subscriptionType,
null,
includeTransactions,
webSocketRpcRequestBody.getConnectionId());
}
} catch (final Exception e) {
throw new InvalidSubscriptionRequestException("Error parsing subscribe request", e);
}
} |
206414745_1249 | public SubscribeRequest mapSubscribeRequest(final JsonRpcRequestContext jsonRpcRequestContext)
throws InvalidSubscriptionRequestException {
try {
final WebSocketRpcRequest webSocketRpcRequestBody = validateRequest(jsonRpcRequestContext);
final SubscriptionType subscriptionType =
webSocketRpcRequestBody.getRequiredParameter(0, SubscriptionType.class);
switch (subscriptionType) {
case NEW_BLOCK_HEADERS:
{
final boolean includeTransactions = includeTransactions(webSocketRpcRequestBody);
return parseNewBlockHeadersRequest(webSocketRpcRequestBody, includeTransactions);
}
case LOGS:
{
return parseLogsRequest(webSocketRpcRequestBody);
}
case NEW_PENDING_TRANSACTIONS:
case SYNCING:
default:
final boolean includeTransactions = includeTransactions(webSocketRpcRequestBody);
return new SubscribeRequest(
subscriptionType,
null,
includeTransactions,
webSocketRpcRequestBody.getConnectionId());
}
} catch (final Exception e) {
throw new InvalidSubscriptionRequestException("Error parsing subscribe request", e);
}
} |
206414745_1250 | public SubscribeRequest mapSubscribeRequest(final JsonRpcRequestContext jsonRpcRequestContext)
throws InvalidSubscriptionRequestException {
try {
final WebSocketRpcRequest webSocketRpcRequestBody = validateRequest(jsonRpcRequestContext);
final SubscriptionType subscriptionType =
webSocketRpcRequestBody.getRequiredParameter(0, SubscriptionType.class);
switch (subscriptionType) {
case NEW_BLOCK_HEADERS:
{
final boolean includeTransactions = includeTransactions(webSocketRpcRequestBody);
return parseNewBlockHeadersRequest(webSocketRpcRequestBody, includeTransactions);
}
case LOGS:
{
return parseLogsRequest(webSocketRpcRequestBody);
}
case NEW_PENDING_TRANSACTIONS:
case SYNCING:
default:
final boolean includeTransactions = includeTransactions(webSocketRpcRequestBody);
return new SubscribeRequest(
subscriptionType,
null,
includeTransactions,
webSocketRpcRequestBody.getConnectionId());
}
} catch (final Exception e) {
throw new InvalidSubscriptionRequestException("Error parsing subscribe request", e);
}
} |
206414745_1251 | public SubscribeRequest mapSubscribeRequest(final JsonRpcRequestContext jsonRpcRequestContext)
throws InvalidSubscriptionRequestException {
try {
final WebSocketRpcRequest webSocketRpcRequestBody = validateRequest(jsonRpcRequestContext);
final SubscriptionType subscriptionType =
webSocketRpcRequestBody.getRequiredParameter(0, SubscriptionType.class);
switch (subscriptionType) {
case NEW_BLOCK_HEADERS:
{
final boolean includeTransactions = includeTransactions(webSocketRpcRequestBody);
return parseNewBlockHeadersRequest(webSocketRpcRequestBody, includeTransactions);
}
case LOGS:
{
return parseLogsRequest(webSocketRpcRequestBody);
}
case NEW_PENDING_TRANSACTIONS:
case SYNCING:
default:
final boolean includeTransactions = includeTransactions(webSocketRpcRequestBody);
return new SubscribeRequest(
subscriptionType,
null,
includeTransactions,
webSocketRpcRequestBody.getConnectionId());
}
} catch (final Exception e) {
throw new InvalidSubscriptionRequestException("Error parsing subscribe request", e);
}
} |
206414745_1252 | public SubscribeRequest mapSubscribeRequest(final JsonRpcRequestContext jsonRpcRequestContext)
throws InvalidSubscriptionRequestException {
try {
final WebSocketRpcRequest webSocketRpcRequestBody = validateRequest(jsonRpcRequestContext);
final SubscriptionType subscriptionType =
webSocketRpcRequestBody.getRequiredParameter(0, SubscriptionType.class);
switch (subscriptionType) {
case NEW_BLOCK_HEADERS:
{
final boolean includeTransactions = includeTransactions(webSocketRpcRequestBody);
return parseNewBlockHeadersRequest(webSocketRpcRequestBody, includeTransactions);
}
case LOGS:
{
return parseLogsRequest(webSocketRpcRequestBody);
}
case NEW_PENDING_TRANSACTIONS:
case SYNCING:
default:
final boolean includeTransactions = includeTransactions(webSocketRpcRequestBody);
return new SubscribeRequest(
subscriptionType,
null,
includeTransactions,
webSocketRpcRequestBody.getConnectionId());
}
} catch (final Exception e) {
throw new InvalidSubscriptionRequestException("Error parsing subscribe request", e);
}
} |
206414745_1253 | public SubscribeRequest mapSubscribeRequest(final JsonRpcRequestContext jsonRpcRequestContext)
throws InvalidSubscriptionRequestException {
try {
final WebSocketRpcRequest webSocketRpcRequestBody = validateRequest(jsonRpcRequestContext);
final SubscriptionType subscriptionType =
webSocketRpcRequestBody.getRequiredParameter(0, SubscriptionType.class);
switch (subscriptionType) {
case NEW_BLOCK_HEADERS:
{
final boolean includeTransactions = includeTransactions(webSocketRpcRequestBody);
return parseNewBlockHeadersRequest(webSocketRpcRequestBody, includeTransactions);
}
case LOGS:
{
return parseLogsRequest(webSocketRpcRequestBody);
}
case NEW_PENDING_TRANSACTIONS:
case SYNCING:
default:
final boolean includeTransactions = includeTransactions(webSocketRpcRequestBody);
return new SubscribeRequest(
subscriptionType,
null,
includeTransactions,
webSocketRpcRequestBody.getConnectionId());
}
} catch (final Exception e) {
throw new InvalidSubscriptionRequestException("Error parsing subscribe request", e);
}
} |
206414745_1254 | public SubscribeRequest mapSubscribeRequest(final JsonRpcRequestContext jsonRpcRequestContext)
throws InvalidSubscriptionRequestException {
try {
final WebSocketRpcRequest webSocketRpcRequestBody = validateRequest(jsonRpcRequestContext);
final SubscriptionType subscriptionType =
webSocketRpcRequestBody.getRequiredParameter(0, SubscriptionType.class);
switch (subscriptionType) {
case NEW_BLOCK_HEADERS:
{
final boolean includeTransactions = includeTransactions(webSocketRpcRequestBody);
return parseNewBlockHeadersRequest(webSocketRpcRequestBody, includeTransactions);
}
case LOGS:
{
return parseLogsRequest(webSocketRpcRequestBody);
}
case NEW_PENDING_TRANSACTIONS:
case SYNCING:
default:
final boolean includeTransactions = includeTransactions(webSocketRpcRequestBody);
return new SubscribeRequest(
subscriptionType,
null,
includeTransactions,
webSocketRpcRequestBody.getConnectionId());
}
} catch (final Exception e) {
throw new InvalidSubscriptionRequestException("Error parsing subscribe request", e);
}
} |
206414745_1255 | public SubscribeRequest mapSubscribeRequest(final JsonRpcRequestContext jsonRpcRequestContext)
throws InvalidSubscriptionRequestException {
try {
final WebSocketRpcRequest webSocketRpcRequestBody = validateRequest(jsonRpcRequestContext);
final SubscriptionType subscriptionType =
webSocketRpcRequestBody.getRequiredParameter(0, SubscriptionType.class);
switch (subscriptionType) {
case NEW_BLOCK_HEADERS:
{
final boolean includeTransactions = includeTransactions(webSocketRpcRequestBody);
return parseNewBlockHeadersRequest(webSocketRpcRequestBody, includeTransactions);
}
case LOGS:
{
return parseLogsRequest(webSocketRpcRequestBody);
}
case NEW_PENDING_TRANSACTIONS:
case SYNCING:
default:
final boolean includeTransactions = includeTransactions(webSocketRpcRequestBody);
return new SubscribeRequest(
subscriptionType,
null,
includeTransactions,
webSocketRpcRequestBody.getConnectionId());
}
} catch (final Exception e) {
throw new InvalidSubscriptionRequestException("Error parsing subscribe request", e);
}
} |
206414745_1256 | public SubscribeRequest mapSubscribeRequest(final JsonRpcRequestContext jsonRpcRequestContext)
throws InvalidSubscriptionRequestException {
try {
final WebSocketRpcRequest webSocketRpcRequestBody = validateRequest(jsonRpcRequestContext);
final SubscriptionType subscriptionType =
webSocketRpcRequestBody.getRequiredParameter(0, SubscriptionType.class);
switch (subscriptionType) {
case NEW_BLOCK_HEADERS:
{
final boolean includeTransactions = includeTransactions(webSocketRpcRequestBody);
return parseNewBlockHeadersRequest(webSocketRpcRequestBody, includeTransactions);
}
case LOGS:
{
return parseLogsRequest(webSocketRpcRequestBody);
}
case NEW_PENDING_TRANSACTIONS:
case SYNCING:
default:
final boolean includeTransactions = includeTransactions(webSocketRpcRequestBody);
return new SubscribeRequest(
subscriptionType,
null,
includeTransactions,
webSocketRpcRequestBody.getConnectionId());
}
} catch (final Exception e) {
throw new InvalidSubscriptionRequestException("Error parsing subscribe request", e);
}
} |
206414745_1257 | public SubscribeRequest mapSubscribeRequest(final JsonRpcRequestContext jsonRpcRequestContext)
throws InvalidSubscriptionRequestException {
try {
final WebSocketRpcRequest webSocketRpcRequestBody = validateRequest(jsonRpcRequestContext);
final SubscriptionType subscriptionType =
webSocketRpcRequestBody.getRequiredParameter(0, SubscriptionType.class);
switch (subscriptionType) {
case NEW_BLOCK_HEADERS:
{
final boolean includeTransactions = includeTransactions(webSocketRpcRequestBody);
return parseNewBlockHeadersRequest(webSocketRpcRequestBody, includeTransactions);
}
case LOGS:
{
return parseLogsRequest(webSocketRpcRequestBody);
}
case NEW_PENDING_TRANSACTIONS:
case SYNCING:
default:
final boolean includeTransactions = includeTransactions(webSocketRpcRequestBody);
return new SubscribeRequest(
subscriptionType,
null,
includeTransactions,
webSocketRpcRequestBody.getConnectionId());
}
} catch (final Exception e) {
throw new InvalidSubscriptionRequestException("Error parsing subscribe request", e);
}
} |
206414745_1258 | public SubscribeRequest mapSubscribeRequest(final JsonRpcRequestContext jsonRpcRequestContext)
throws InvalidSubscriptionRequestException {
try {
final WebSocketRpcRequest webSocketRpcRequestBody = validateRequest(jsonRpcRequestContext);
final SubscriptionType subscriptionType =
webSocketRpcRequestBody.getRequiredParameter(0, SubscriptionType.class);
switch (subscriptionType) {
case NEW_BLOCK_HEADERS:
{
final boolean includeTransactions = includeTransactions(webSocketRpcRequestBody);
return parseNewBlockHeadersRequest(webSocketRpcRequestBody, includeTransactions);
}
case LOGS:
{
return parseLogsRequest(webSocketRpcRequestBody);
}
case NEW_PENDING_TRANSACTIONS:
case SYNCING:
default:
final boolean includeTransactions = includeTransactions(webSocketRpcRequestBody);
return new SubscribeRequest(
subscriptionType,
null,
includeTransactions,
webSocketRpcRequestBody.getConnectionId());
}
} catch (final Exception e) {
throw new InvalidSubscriptionRequestException("Error parsing subscribe request", e);
}
} |
206414745_1259 | public SubscribeRequest mapSubscribeRequest(final JsonRpcRequestContext jsonRpcRequestContext)
throws InvalidSubscriptionRequestException {
try {
final WebSocketRpcRequest webSocketRpcRequestBody = validateRequest(jsonRpcRequestContext);
final SubscriptionType subscriptionType =
webSocketRpcRequestBody.getRequiredParameter(0, SubscriptionType.class);
switch (subscriptionType) {
case NEW_BLOCK_HEADERS:
{
final boolean includeTransactions = includeTransactions(webSocketRpcRequestBody);
return parseNewBlockHeadersRequest(webSocketRpcRequestBody, includeTransactions);
}
case LOGS:
{
return parseLogsRequest(webSocketRpcRequestBody);
}
case NEW_PENDING_TRANSACTIONS:
case SYNCING:
default:
final boolean includeTransactions = includeTransactions(webSocketRpcRequestBody);
return new SubscribeRequest(
subscriptionType,
null,
includeTransactions,
webSocketRpcRequestBody.getConnectionId());
}
} catch (final Exception e) {
throw new InvalidSubscriptionRequestException("Error parsing subscribe request", e);
}
} |
206414745_1260 | public SubscribeRequest mapSubscribeRequest(final JsonRpcRequestContext jsonRpcRequestContext)
throws InvalidSubscriptionRequestException {
try {
final WebSocketRpcRequest webSocketRpcRequestBody = validateRequest(jsonRpcRequestContext);
final SubscriptionType subscriptionType =
webSocketRpcRequestBody.getRequiredParameter(0, SubscriptionType.class);
switch (subscriptionType) {
case NEW_BLOCK_HEADERS:
{
final boolean includeTransactions = includeTransactions(webSocketRpcRequestBody);
return parseNewBlockHeadersRequest(webSocketRpcRequestBody, includeTransactions);
}
case LOGS:
{
return parseLogsRequest(webSocketRpcRequestBody);
}
case NEW_PENDING_TRANSACTIONS:
case SYNCING:
default:
final boolean includeTransactions = includeTransactions(webSocketRpcRequestBody);
return new SubscribeRequest(
subscriptionType,
null,
includeTransactions,
webSocketRpcRequestBody.getConnectionId());
}
} catch (final Exception e) {
throw new InvalidSubscriptionRequestException("Error parsing subscribe request", e);
}
} |
206414745_1261 | public SubscribeRequest mapSubscribeRequest(final JsonRpcRequestContext jsonRpcRequestContext)
throws InvalidSubscriptionRequestException {
try {
final WebSocketRpcRequest webSocketRpcRequestBody = validateRequest(jsonRpcRequestContext);
final SubscriptionType subscriptionType =
webSocketRpcRequestBody.getRequiredParameter(0, SubscriptionType.class);
switch (subscriptionType) {
case NEW_BLOCK_HEADERS:
{
final boolean includeTransactions = includeTransactions(webSocketRpcRequestBody);
return parseNewBlockHeadersRequest(webSocketRpcRequestBody, includeTransactions);
}
case LOGS:
{
return parseLogsRequest(webSocketRpcRequestBody);
}
case NEW_PENDING_TRANSACTIONS:
case SYNCING:
default:
final boolean includeTransactions = includeTransactions(webSocketRpcRequestBody);
return new SubscribeRequest(
subscriptionType,
null,
includeTransactions,
webSocketRpcRequestBody.getConnectionId());
}
} catch (final Exception e) {
throw new InvalidSubscriptionRequestException("Error parsing subscribe request", e);
}
} |
206414745_1262 | public SubscribeRequest mapSubscribeRequest(final JsonRpcRequestContext jsonRpcRequestContext)
throws InvalidSubscriptionRequestException {
try {
final WebSocketRpcRequest webSocketRpcRequestBody = validateRequest(jsonRpcRequestContext);
final SubscriptionType subscriptionType =
webSocketRpcRequestBody.getRequiredParameter(0, SubscriptionType.class);
switch (subscriptionType) {
case NEW_BLOCK_HEADERS:
{
final boolean includeTransactions = includeTransactions(webSocketRpcRequestBody);
return parseNewBlockHeadersRequest(webSocketRpcRequestBody, includeTransactions);
}
case LOGS:
{
return parseLogsRequest(webSocketRpcRequestBody);
}
case NEW_PENDING_TRANSACTIONS:
case SYNCING:
default:
final boolean includeTransactions = includeTransactions(webSocketRpcRequestBody);
return new SubscribeRequest(
subscriptionType,
null,
includeTransactions,
webSocketRpcRequestBody.getConnectionId());
}
} catch (final Exception e) {
throw new InvalidSubscriptionRequestException("Error parsing subscribe request", e);
}
} |
206414745_1263 | public SubscribeRequest mapSubscribeRequest(final JsonRpcRequestContext jsonRpcRequestContext)
throws InvalidSubscriptionRequestException {
try {
final WebSocketRpcRequest webSocketRpcRequestBody = validateRequest(jsonRpcRequestContext);
final SubscriptionType subscriptionType =
webSocketRpcRequestBody.getRequiredParameter(0, SubscriptionType.class);
switch (subscriptionType) {
case NEW_BLOCK_HEADERS:
{
final boolean includeTransactions = includeTransactions(webSocketRpcRequestBody);
return parseNewBlockHeadersRequest(webSocketRpcRequestBody, includeTransactions);
}
case LOGS:
{
return parseLogsRequest(webSocketRpcRequestBody);
}
case NEW_PENDING_TRANSACTIONS:
case SYNCING:
default:
final boolean includeTransactions = includeTransactions(webSocketRpcRequestBody);
return new SubscribeRequest(
subscriptionType,
null,
includeTransactions,
webSocketRpcRequestBody.getConnectionId());
}
} catch (final Exception e) {
throw new InvalidSubscriptionRequestException("Error parsing subscribe request", e);
}
} |
206414745_1264 | public PrivateSubscribeRequest mapPrivateSubscribeRequest(
final JsonRpcRequestContext jsonRpcRequestContext, final String enclavePublicKey)
throws InvalidSubscriptionRequestException {
try {
final WebSocketRpcRequest webSocketRpcRequestBody = validateRequest(jsonRpcRequestContext);
final String privacyGroupId = webSocketRpcRequestBody.getRequiredParameter(0, String.class);
final SubscriptionType subscriptionType =
webSocketRpcRequestBody.getRequiredParameter(1, SubscriptionType.class);
switch (subscriptionType) {
case LOGS:
{
final FilterParameter filterParameter =
jsonRpcRequestContext.getRequiredParameter(2, FilterParameter.class);
return new PrivateSubscribeRequest(
SubscriptionType.LOGS,
filterParameter,
null,
webSocketRpcRequestBody.getConnectionId(),
privacyGroupId,
enclavePublicKey);
}
default:
throw new InvalidSubscriptionRequestException(
"Invalid subscribe request. Invalid private subscription type.");
}
} catch (final InvalidSubscriptionRequestException e) {
throw e;
} catch (final Exception e) {
throw new InvalidSubscriptionRequestException("Error parsing subscribe request", e);
}
} |
206414745_1265 | public PrivateSubscribeRequest mapPrivateSubscribeRequest(
final JsonRpcRequestContext jsonRpcRequestContext, final String enclavePublicKey)
throws InvalidSubscriptionRequestException {
try {
final WebSocketRpcRequest webSocketRpcRequestBody = validateRequest(jsonRpcRequestContext);
final String privacyGroupId = webSocketRpcRequestBody.getRequiredParameter(0, String.class);
final SubscriptionType subscriptionType =
webSocketRpcRequestBody.getRequiredParameter(1, SubscriptionType.class);
switch (subscriptionType) {
case LOGS:
{
final FilterParameter filterParameter =
jsonRpcRequestContext.getRequiredParameter(2, FilterParameter.class);
return new PrivateSubscribeRequest(
SubscriptionType.LOGS,
filterParameter,
null,
webSocketRpcRequestBody.getConnectionId(),
privacyGroupId,
enclavePublicKey);
}
default:
throw new InvalidSubscriptionRequestException(
"Invalid subscribe request. Invalid private subscription type.");
}
} catch (final InvalidSubscriptionRequestException e) {
throw e;
} catch (final Exception e) {
throw new InvalidSubscriptionRequestException("Error parsing subscribe request", e);
}
} |
206414745_1266 | public PrivateUnsubscribeRequest mapPrivateUnsubscribeRequest(
final JsonRpcRequestContext jsonRpcRequestContext)
throws InvalidSubscriptionRequestException {
try {
final WebSocketRpcRequest webSocketRpcRequestBody = validateRequest(jsonRpcRequestContext);
final String privacyGroupId = webSocketRpcRequestBody.getRequiredParameter(0, String.class);
final long subscriptionId =
webSocketRpcRequestBody.getRequiredParameter(1, UnsignedLongParameter.class).getValue();
return new PrivateUnsubscribeRequest(
subscriptionId, webSocketRpcRequestBody.getConnectionId(), privacyGroupId);
} catch (final Exception e) {
throw new InvalidSubscriptionRequestException("Error parsing unsubscribe request", e);
}
} |
206414745_1267 | @Override
public void onTransactionDropped(final Transaction transaction) {
notifySubscribers(transaction.getHash());
} |
206414745_1268 | @Override
public void onTransactionAdded(final Transaction pendingTransaction) {
notifySubscribers(pendingTransaction);
} |
206414745_1269 | @Override
public void onTransactionAdded(final Transaction pendingTransaction) {
notifySubscribers(pendingTransaction);
} |
206414745_1270 | public static JsonRpcError convertTransactionInvalidReason(
final TransactionInvalidReason reason) {
switch (reason) {
case NONCE_TOO_LOW:
case PRIVATE_NONCE_TOO_LOW:
return JsonRpcError.NONCE_TOO_LOW;
case INCORRECT_NONCE:
case INCORRECT_PRIVATE_NONCE:
return JsonRpcError.INCORRECT_NONCE;
case INVALID_SIGNATURE:
return JsonRpcError.INVALID_TRANSACTION_SIGNATURE;
case INTRINSIC_GAS_EXCEEDS_GAS_LIMIT:
return JsonRpcError.INTRINSIC_GAS_EXCEEDS_LIMIT;
case UPFRONT_COST_EXCEEDS_BALANCE:
return JsonRpcError.TRANSACTION_UPFRONT_COST_EXCEEDS_BALANCE;
case EXCEEDS_BLOCK_GAS_LIMIT:
return JsonRpcError.EXCEEDS_BLOCK_GAS_LIMIT;
case WRONG_CHAIN_ID:
return JsonRpcError.WRONG_CHAIN_ID;
case REPLAY_PROTECTED_SIGNATURES_NOT_SUPPORTED:
return JsonRpcError.REPLAY_PROTECTED_SIGNATURES_NOT_SUPPORTED;
case TX_SENDER_NOT_AUTHORIZED:
return JsonRpcError.TX_SENDER_NOT_AUTHORIZED;
// Private Transaction Invalid Reasons
case CHAIN_HEAD_WORLD_STATE_NOT_AVAILABLE:
return JsonRpcError.CHAIN_HEAD_WORLD_STATE_NOT_AVAILABLE;
case GAS_PRICE_TOO_LOW:
return JsonRpcError.GAS_PRICE_TOO_LOW;
case TX_FEECAP_EXCEEDED:
return JsonRpcError.TX_FEECAP_EXCEEDED;
case OFFCHAIN_PRIVACY_GROUP_DOES_NOT_EXIST:
return JsonRpcError.OFFCHAIN_PRIVACY_GROUP_DOES_NOT_EXIST;
case TRANSACTION_ALREADY_KNOWN:
return JsonRpcError.ETH_SEND_TX_ALREADY_KNOWN;
case TRANSACTION_REPLACEMENT_UNDERPRICED:
return JsonRpcError.ETH_SEND_TX_REPLACEMENT_UNDERPRICED;
default:
return JsonRpcError.INVALID_PARAMS;
}
} |
206414745_1271 | public boolean matches(final Log log) {
return matchesAddresses(log.getLogger()) && matchesTopics(log.getTopics());
} |
206414745_1272 | public static Path dataFileToIndex(final Path dataName) {
return Path.of(dataName.toString().replaceAll("(.*)[-.]\\d\\d\\d\\d\\.(.)dat", "$1.$2idx"));
} |
206414745_1273 | public static Path accountFileName(
final Path backupDir,
final long targetBlock,
final int fileNumber,
final boolean compressed) {
return backupDir.resolve(
String.format(
"besu-account-backup-%08d-%04d.%sdat",
targetBlock, fileNumber, compressed ? "c" : "r"));
} |
206414745_1274 | public static Path headerFileName(
final Path backupDir, final int fileNumber, final boolean compressed) {
return backupDir.resolve(
String.format("besu-header-backup-%04d.%sdat", fileNumber, compressed ? "c" : "r"));
} |
206414745_1275 | public static Path bodyFileName(
final Path backupDir, final int fileNumber, final boolean compressed) {
return backupDir.resolve(
String.format("besu-body-backup-%04d.%sdat", fileNumber, compressed ? "c" : "r"));
} |
206414745_1276 | public static Path receiptFileName(
final Path backupDir, final int fileNumber, final boolean compressed) {
return backupDir.resolve(
String.format("besu-receipt-backup-%04d.%sdat", fileNumber, compressed ? "c" : "r"));
} |
206414745_1277 | public List<LogWithMetadata> matchingLogs(
final String privacyGroupId,
final long fromBlockNumber,
final long toBlockNumber,
final LogsQuery query) {
return LongStream.rangeClosed(fromBlockNumber, toBlockNumber)
.mapToObj(blockchainQueries::getBlockHashByNumber)
.takeWhile(Optional::isPresent)
.map(Optional::get)
.map(hash -> matchingLogs(privacyGroupId, hash, query))
.flatMap(List::stream)
.collect(Collectors.toList());
} |
206414745_1278 | public List<LogWithMetadata> matchingLogs(
final String privacyGroupId,
final long fromBlockNumber,
final long toBlockNumber,
final LogsQuery query) {
return LongStream.rangeClosed(fromBlockNumber, toBlockNumber)
.mapToObj(blockchainQueries::getBlockHashByNumber)
.takeWhile(Optional::isPresent)
.map(Optional::get)
.map(hash -> matchingLogs(privacyGroupId, hash, query))
.flatMap(List::stream)
.collect(Collectors.toList());
} |
206414745_1279 | public List<LogWithMetadata> matchingLogs(
final String privacyGroupId,
final long fromBlockNumber,
final long toBlockNumber,
final LogsQuery query) {
return LongStream.rangeClosed(fromBlockNumber, toBlockNumber)
.mapToObj(blockchainQueries::getBlockHashByNumber)
.takeWhile(Optional::isPresent)
.map(Optional::get)
.map(hash -> matchingLogs(privacyGroupId, hash, query))
.flatMap(List::stream)
.collect(Collectors.toList());
} |
206414745_1280 | public List<LogWithMetadata> matchingLogs(
final String privacyGroupId,
final long fromBlockNumber,
final long toBlockNumber,
final LogsQuery query) {
return LongStream.rangeClosed(fromBlockNumber, toBlockNumber)
.mapToObj(blockchainQueries::getBlockHashByNumber)
.takeWhile(Optional::isPresent)
.map(Optional::get)
.map(hash -> matchingLogs(privacyGroupId, hash, query))
.flatMap(List::stream)
.collect(Collectors.toList());
} |
206414745_1281 | public List<LogWithMetadata> matchingLogs(
final String privacyGroupId,
final long fromBlockNumber,
final long toBlockNumber,
final LogsQuery query) {
return LongStream.rangeClosed(fromBlockNumber, toBlockNumber)
.mapToObj(blockchainQueries::getBlockHashByNumber)
.takeWhile(Optional::isPresent)
.map(Optional::get)
.map(hash -> matchingLogs(privacyGroupId, hash, query))
.flatMap(List::stream)
.collect(Collectors.toList());
} |
206414745_1282 | public List<LogWithMetadata> matchingLogs(
final String privacyGroupId,
final long fromBlockNumber,
final long toBlockNumber,
final LogsQuery query) {
return LongStream.rangeClosed(fromBlockNumber, toBlockNumber)
.mapToObj(blockchainQueries::getBlockHashByNumber)
.takeWhile(Optional::isPresent)
.map(Optional::get)
.map(hash -> matchingLogs(privacyGroupId, hash, query))
.flatMap(List::stream)
.collect(Collectors.toList());
} |
206414745_1283 | void cacheAll() {
ensurePreviousSegmentsArePresent(blockchain.getChainHeadBlockNumber(), false);
} |
206414745_1284 | void cacheLogsBloomForBlockHeader(
final BlockHeader blockHeader,
final Optional<BlockHeader> commonAncestorBlockHeader,
final Optional<File> reusedCacheFile) {
try {
if (cachingStatus.cachingCount.incrementAndGet() != 1) {
return;
}
final long blockNumber = blockHeader.getNumber();
LOG.debug("Caching logs bloom for block {}.", "0x" + Long.toHexString(blockNumber));
final File cacheFile = reusedCacheFile.orElse(calculateCacheFileName(blockNumber, cacheDir));
if (cacheFile.exists()) {
try {
final Optional<Long> ancestorBlockNumber =
commonAncestorBlockHeader.map(ProcessableBlockHeader::getNumber);
if (ancestorBlockNumber.isPresent()) {
// walk through the blocks from the common ancestor to the received block in order to
// reload the cache in case of reorg
for (long number = ancestorBlockNumber.get() + 1;
number < blockHeader.getNumber();
number++) {
Optional<BlockHeader> ancestorBlockHeader = blockchain.getBlockHeader(number);
if (ancestorBlockHeader.isPresent()) {
cacheSingleBlock(ancestorBlockHeader.get(), cacheFile);
}
}
}
cacheSingleBlock(blockHeader, cacheFile);
} catch (final InvalidCacheException e) {
populateLatestSegment(blockNumber);
}
} else {
populateLatestSegment(blockNumber);
}
} catch (final IOException e) {
LOG.error("Unhandled caching exception.", e);
} finally {
cachingStatus.cachingCount.decrementAndGet();
}
} |
206414745_1285 | void cacheLogsBloomForBlockHeader(
final BlockHeader blockHeader,
final Optional<BlockHeader> commonAncestorBlockHeader,
final Optional<File> reusedCacheFile) {
try {
if (cachingStatus.cachingCount.incrementAndGet() != 1) {
return;
}
final long blockNumber = blockHeader.getNumber();
LOG.debug("Caching logs bloom for block {}.", "0x" + Long.toHexString(blockNumber));
final File cacheFile = reusedCacheFile.orElse(calculateCacheFileName(blockNumber, cacheDir));
if (cacheFile.exists()) {
try {
final Optional<Long> ancestorBlockNumber =
commonAncestorBlockHeader.map(ProcessableBlockHeader::getNumber);
if (ancestorBlockNumber.isPresent()) {
// walk through the blocks from the common ancestor to the received block in order to
// reload the cache in case of reorg
for (long number = ancestorBlockNumber.get() + 1;
number < blockHeader.getNumber();
number++) {
Optional<BlockHeader> ancestorBlockHeader = blockchain.getBlockHeader(number);
if (ancestorBlockHeader.isPresent()) {
cacheSingleBlock(ancestorBlockHeader.get(), cacheFile);
}
}
}
cacheSingleBlock(blockHeader, cacheFile);
} catch (final InvalidCacheException e) {
populateLatestSegment(blockNumber);
}
} else {
populateLatestSegment(blockNumber);
}
} catch (final IOException e) {
LOG.error("Unhandled caching exception.", e);
} finally {
cachingStatus.cachingCount.decrementAndGet();
}
} |
206414745_1286 | void cacheAll() {
ensurePreviousSegmentsArePresent(blockchain.getChainHeadBlockNumber(), false);
} |
206414745_1287 | void cacheLogsBloomForBlockHeader(
final BlockHeader blockHeader,
final Optional<BlockHeader> commonAncestorBlockHeader,
final Optional<File> reusedCacheFile) {
try {
if (cachingStatus.cachingCount.incrementAndGet() != 1) {
return;
}
final long blockNumber = blockHeader.getNumber();
LOG.debug("Caching logs bloom for block {}.", "0x" + Long.toHexString(blockNumber));
final File cacheFile = reusedCacheFile.orElse(calculateCacheFileName(blockNumber, cacheDir));
if (cacheFile.exists()) {
try {
final Optional<Long> ancestorBlockNumber =
commonAncestorBlockHeader.map(ProcessableBlockHeader::getNumber);
if (ancestorBlockNumber.isPresent()) {
// walk through the blocks from the common ancestor to the received block in order to
// reload the cache in case of reorg
for (long number = ancestorBlockNumber.get() + 1;
number < blockHeader.getNumber();
number++) {
Optional<BlockHeader> ancestorBlockHeader = blockchain.getBlockHeader(number);
if (ancestorBlockHeader.isPresent()) {
cacheSingleBlock(ancestorBlockHeader.get(), cacheFile);
}
}
}
cacheSingleBlock(blockHeader, cacheFile);
} catch (final InvalidCacheException e) {
populateLatestSegment(blockNumber);
}
} else {
populateLatestSegment(blockNumber);
}
} catch (final IOException e) {
LOG.error("Unhandled caching exception.", e);
} finally {
cachingStatus.cachingCount.decrementAndGet();
}
} |
206414745_1288 | public static <T> T runIfAlive(final Callable<T> task, final Supplier<Boolean> alive)
throws Exception {
return runIfAlive(Optional.empty(), task, alive);
} |
206414745_1289 | public Optional<BlockWithMetadata<TransactionWithMetadata, Hash>> blockByHash(
final Hash blockHeaderHash) {
return blockchain
.getBlockHeader(blockHeaderHash)
.flatMap(
header ->
blockchain
.getBlockBody(blockHeaderHash)
.flatMap(
body ->
blockchain
.getTotalDifficultyByHash(blockHeaderHash)
.map(
(td) -> {
final List<Transaction> txs = body.getTransactions();
final List<TransactionWithMetadata> formattedTxs =
formatTransactions(
txs, header.getNumber(), blockHeaderHash);
final List<Hash> ommers =
body.getOmmers().stream()
.map(BlockHeader::getHash)
.collect(Collectors.toList());
final int size = new Block(header, body).calculateSize();
return new BlockWithMetadata<>(
header, formattedTxs, ommers, td, size);
})));
} |
206414745_1290 | public Optional<TransactionWithMetadata> transactionByBlockHashAndIndex(
final Hash blockHeaderHash, final int txIndex) {
checkArgument(txIndex >= 0);
return blockchain
.getBlockHeader(blockHeaderHash)
.map(header -> transactionByHeaderAndIndex(header, txIndex));
} |
206414745_1291 | public Optional<BlockWithMetadata<TransactionWithMetadata, Hash>> blockByHash(
final Hash blockHeaderHash) {
return blockchain
.getBlockHeader(blockHeaderHash)
.flatMap(
header ->
blockchain
.getBlockBody(blockHeaderHash)
.flatMap(
body ->
blockchain
.getTotalDifficultyByHash(blockHeaderHash)
.map(
(td) -> {
final List<Transaction> txs = body.getTransactions();
final List<TransactionWithMetadata> formattedTxs =
formatTransactions(
txs, header.getNumber(), blockHeaderHash);
final List<Hash> ommers =
body.getOmmers().stream()
.map(BlockHeader::getHash)
.collect(Collectors.toList());
final int size = new Block(header, body).calculateSize();
return new BlockWithMetadata<>(
header, formattedTxs, ommers, td, size);
})));
} |
206414745_1292 | public Optional<BlockWithMetadata<TransactionWithMetadata, Hash>> blockByNumber(
final long number) {
return blockchain.getBlockHashByNumber(number).flatMap(this::blockByHash);
} |
206414745_1293 | public Optional<BlockWithMetadata<TransactionWithMetadata, Hash>> blockByNumber(
final long number) {
return blockchain.getBlockHashByNumber(number).flatMap(this::blockByHash);
} |
206414745_1294 | public Optional<BlockWithMetadata<TransactionWithMetadata, Hash>> latestBlock() {
return this.blockByHash(blockchain.getChainHeadHash());
} |
206414745_1295 | public Optional<BlockWithMetadata<Hash, Hash>> blockByHashWithTxHashes(
final Hash blockHeaderHash) {
return blockchain
.getBlockHeader(blockHeaderHash)
.flatMap(
header ->
blockchain
.getBlockBody(blockHeaderHash)
.flatMap(
body ->
blockchain
.getTotalDifficultyByHash(blockHeaderHash)
.map(
(td) -> {
final List<Hash> txs =
body.getTransactions().stream()
.map(Transaction::getHash)
.collect(Collectors.toList());
final List<Hash> ommers =
body.getOmmers().stream()
.map(BlockHeader::getHash)
.collect(Collectors.toList());
final int size = new Block(header, body).calculateSize();
return new BlockWithMetadata<>(header, txs, ommers, td, size);
})));
} |
206414745_1296 | public Optional<BlockWithMetadata<Hash, Hash>> blockByHashWithTxHashes(
final Hash blockHeaderHash) {
return blockchain
.getBlockHeader(blockHeaderHash)
.flatMap(
header ->
blockchain
.getBlockBody(blockHeaderHash)
.flatMap(
body ->
blockchain
.getTotalDifficultyByHash(blockHeaderHash)
.map(
(td) -> {
final List<Hash> txs =
body.getTransactions().stream()
.map(Transaction::getHash)
.collect(Collectors.toList());
final List<Hash> ommers =
body.getOmmers().stream()
.map(BlockHeader::getHash)
.collect(Collectors.toList());
final int size = new Block(header, body).calculateSize();
return new BlockWithMetadata<>(header, txs, ommers, td, size);
})));
} |
206414745_1297 | public Optional<BlockWithMetadata<Hash, Hash>> blockByNumberWithTxHashes(final long blockNumber) {
return blockchain.getBlockHashByNumber(blockNumber).flatMap(this::blockByHashWithTxHashes);
} |
206414745_1298 | public Optional<BlockWithMetadata<Hash, Hash>> blockByNumberWithTxHashes(final long blockNumber) {
return blockchain.getBlockHashByNumber(blockNumber).flatMap(this::blockByHashWithTxHashes);
} |
206414745_1299 | public Optional<BlockWithMetadata<Hash, Hash>> latestBlockWithTxHashes() {
return this.blockByHashWithTxHashes(blockchain.getChainHeadHash());
} |
206414745_1300 | public long headBlockNumber() {
return blockchain.getChainHeadBlockNumber();
} |
206414745_1301 | public Optional<UInt256> storageAt(
final Address address, final UInt256 storageIndex, final long blockNumber) {
return fromAccount(
address, blockNumber, account -> account.getStorageValue(storageIndex), UInt256.ZERO);
} |
206414745_1302 | public Optional<Wei> accountBalance(final Address address, final long blockNumber) {
return fromAccount(address, blockNumber, Account::getBalance, Wei.ZERO);
} |
206414745_1303 | public Optional<Wei> accountBalance(final Address address, final long blockNumber) {
return fromAccount(address, blockNumber, Account::getBalance, Wei.ZERO);
} |
206414745_1304 | public Optional<Integer> getOmmerCount(final long blockNumber) {
return blockchain.getBlockHashByNumber(blockNumber).flatMap(this::getOmmerCount);
} |
206414745_1305 | public Optional<Integer> getOmmerCount(final long blockNumber) {
return blockchain.getBlockHashByNumber(blockNumber).flatMap(this::getOmmerCount);
} |
206414745_1306 | public Optional<Integer> getOmmerCount(final long blockNumber) {
return blockchain.getBlockHashByNumber(blockNumber).flatMap(this::getOmmerCount);
} |
206414745_1307 | public Optional<Integer> getOmmerCount(final long blockNumber) {
return blockchain.getBlockHashByNumber(blockNumber).flatMap(this::getOmmerCount);
} |
206414745_1308 | public Optional<Integer> getOmmerCount(final long blockNumber) {
return blockchain.getBlockHashByNumber(blockNumber).flatMap(this::getOmmerCount);
} |
206414745_1309 | public List<LogWithMetadata> matchingLogs(
final long fromBlockNumber,
final long toBlockNumber,
final LogsQuery query,
final Supplier<Boolean> isQueryAlive) {
try {
final List<LogWithMetadata> result = new ArrayList<>();
final long startSegment = fromBlockNumber / BLOCKS_PER_BLOOM_CACHE;
final long endSegment = toBlockNumber / BLOCKS_PER_BLOOM_CACHE;
long currentStep = fromBlockNumber;
for (long segment = startSegment; segment <= endSegment; segment++) {
final long thisSegment = segment;
final long thisStep = currentStep;
final long nextStep = (segment + 1) * BLOCKS_PER_BLOOM_CACHE;
BackendQuery.stopIfExpired(isQueryAlive);
result.addAll(
cachePath
.map(path -> path.resolve("logBloom-" + thisSegment + ".cache"))
.filter(Files::isRegularFile)
.map(
cacheFile -> {
try {
return matchingLogsCached(
thisSegment * BLOCKS_PER_BLOOM_CACHE,
thisStep % BLOCKS_PER_BLOOM_CACHE,
Math.min(toBlockNumber, nextStep - 1) % BLOCKS_PER_BLOOM_CACHE,
query,
cacheFile,
isQueryAlive);
} catch (Exception e) {
throw new RuntimeException(e);
}
})
.orElseGet(
() ->
matchingLogsUncached(
thisStep,
Math.min(toBlockNumber, Math.min(toBlockNumber, nextStep - 1)),
query,
isQueryAlive)));
currentStep = nextStep;
}
return result;
} catch (RpcMethodTimeoutException e) {
LOG.error("Error retrieving matching logs", e);
throw e;
} catch (Exception e) {
LOG.error("Error retrieving matching logs", e);
throw new RuntimeException(e);
}
} |
206414745_1310 | public Optional<BlockHeader> getOmmer(final Hash blockHeaderHash, final int index) {
return blockchain.getBlockBody(blockHeaderHash).map(blockBody -> getOmmer(blockBody, index));
} |
206414745_1311 | public Optional<BlockHeader> getOmmer(final Hash blockHeaderHash, final int index) {
return blockchain.getBlockBody(blockHeaderHash).map(blockBody -> getOmmer(blockBody, index));
} |
206414745_1312 | public Optional<BlockHeader> getOmmer(final Hash blockHeaderHash, final int index) {
return blockchain.getBlockBody(blockHeaderHash).map(blockBody -> getOmmer(blockBody, index));
} |
206414745_1313 | public Optional<BlockHeader> getOmmer(final Hash blockHeaderHash, final int index) {
return blockchain.getBlockBody(blockHeaderHash).map(blockBody -> getOmmer(blockBody, index));
} |
206414745_1314 | public Optional<BlockHeader> getOmmer(final Hash blockHeaderHash, final int index) {
return blockchain.getBlockBody(blockHeaderHash).map(blockBody -> getOmmer(blockBody, index));
} |
206414745_1315 | public Optional<BlockHeader> getOmmer(final Hash blockHeaderHash, final int index) {
return blockchain.getBlockBody(blockHeaderHash).map(blockBody -> getOmmer(blockBody, index));
} |
206414745_1316 | public Optional<BlockHeader> getOmmer(final Hash blockHeaderHash, final int index) {
return blockchain.getBlockBody(blockHeaderHash).map(blockBody -> getOmmer(blockBody, index));
} |
206414745_1317 | public Optional<BlockHeader> getOmmer(final Hash blockHeaderHash, final int index) {
return blockchain.getBlockBody(blockHeaderHash).map(blockBody -> getOmmer(blockBody, index));
} |
206414745_1318 | public Optional<BlockHeader> getOmmer(final Hash blockHeaderHash, final int index) {
return blockchain.getBlockBody(blockHeaderHash).map(blockBody -> getOmmer(blockBody, index));
} |
206414745_1319 | public Optional<BlockHeader> getOmmer(final Hash blockHeaderHash, final int index) {
return blockchain.getBlockBody(blockHeaderHash).map(blockBody -> getOmmer(blockBody, index));
} |
206414745_1320 | public CompletableFuture<?> start() {
LOG.info("Starting GraphQL HTTP service on {}:{}", config.getHost(), config.getPort());
// Create the HTTP server and a router object.
httpServer =
vertx.createHttpServer(
new HttpServerOptions().setHost(config.getHost()).setPort(config.getPort()));
// Handle graphql http requests
final Router router = Router.router(vertx);
// Verify Host header to avoid rebind attack.
router.route().handler(checkWhitelistHostHeader());
router
.route()
.handler(
CorsHandler.create(buildCorsRegexFromConfig())
.allowedHeader("*")
.allowedHeader("content-type"));
router
.route()
.handler(
BodyHandler.create()
.setUploadsDirectory(dataDir.resolve("uploads").toString())
.setDeleteUploadedFilesOnEnd(true));
router.route("/").method(GET).method(POST).handler(this::handleEmptyRequestAndRedirect);
router
.route(GRAPH_QL_ROUTE)
.method(GET)
.method(POST)
.produces(APPLICATION_JSON)
.handler(
TimeoutHandler.handler(
Optional.of(new TimeoutOptions(config.getHttpTimeoutSec())), false))
.handler(this::handleGraphQLRequest);
final CompletableFuture<?> resultFuture = new CompletableFuture<>();
httpServer
.requestHandler(router)
.listen(
res -> {
if (!res.failed()) {
resultFuture.complete(null);
LOG.info(
"GraphQL HTTP service started and listening on {}:{}",
config.getHost(),
httpServer.actualPort());
return;
}
httpServer = null;
final Throwable cause = res.cause();
if (cause instanceof SocketException) {
resultFuture.completeExceptionally(
new GraphQLServiceException(
String.format(
"Failed to bind Ethereum GraphQL HTTP listener to %s:%s: %s",
config.getHost(), config.getPort(), cause.getMessage())));
return;
}
resultFuture.completeExceptionally(cause);
});
return resultFuture;
} |
206414745_1321 | @VisibleForTesting
public String url() {
if (httpServer == null) {
return "";
}
return NetworkUtility.urlForSocketAddress("http", socketAddress());
} |
206414745_1322 | @VisibleForTesting
public String url() {
if (httpServer == null) {
return "";
}
return NetworkUtility.urlForSocketAddress("http", socketAddress());
} |
206414745_1323 | public InetSocketAddress socketAddress() {
if (httpServer == null) {
return EMPTY_SOCKET_ADDRESS;
}
return new InetSocketAddress(config.getHost(), httpServer.actualPort());
} |
206414745_1324 | @Override
public String get() {
try (final Stream<String> fileStream = Files.lines(passwordFile)) {
return fileStream
.findFirst()
.orElseThrow(
() ->
new TlsConfigurationException(
String.format(
"Unable to read keystore password from %s", passwordFile.toString())));
} catch (final IOException e) {
throw new TlsConfigurationException(
String.format("Unable to read keystore password file %s", passwordFile.toString()), e);
}
} |
206414745_1325 | @Override
public String get() {
try (final Stream<String> fileStream = Files.lines(passwordFile)) {
return fileStream
.findFirst()
.orElseThrow(
() ->
new TlsConfigurationException(
String.format(
"Unable to read keystore password from %s", passwordFile.toString())));
} catch (final IOException e) {
throw new TlsConfigurationException(
String.format("Unable to read keystore password file %s", passwordFile.toString()), e);
}
} |
206414745_1326 | @Override
public String get() {
try (final Stream<String> fileStream = Files.lines(passwordFile)) {
return fileStream
.findFirst()
.orElseThrow(
() ->
new TlsConfigurationException(
String.format(
"Unable to read keystore password from %s", passwordFile.toString())));
} catch (final IOException e) {
throw new TlsConfigurationException(
String.format("Unable to read keystore password file %s", passwordFile.toString()), e);
}
} |
206414745_1327 | public RequestManager.ResponseStream getHeadersByHash(
final Hash hash, final int maxHeaders, final int skip, final boolean reverse)
throws PeerNotConnected {
final GetBlockHeadersMessage message =
GetBlockHeadersMessage.create(hash, maxHeaders, skip, reverse);
return sendRequest(headersRequestManager, message);
} |
206414745_1328 | public RequestManager.ResponseStream getBodies(final List<Hash> blockHashes)
throws PeerNotConnected {
final GetBlockBodiesMessage message = GetBlockBodiesMessage.create(blockHashes);
return sendRequest(bodiesRequestManager, message);
} |
206414745_1329 | public RequestManager.ResponseStream getReceipts(final List<Hash> blockHashes)
throws PeerNotConnected {
final GetReceiptsMessage message = GetReceiptsMessage.create(blockHashes);
return sendRequest(receiptsRequestManager, message);
} |
206414745_1330 | public RequestManager.ResponseStream getNodeData(final Iterable<Hash> nodeHashes)
throws PeerNotConnected {
final GetNodeDataMessage message = GetNodeDataMessage.create(nodeHashes);
return sendRequest(nodeDataRequestManager, message);
} |
206414745_1331 | public boolean isFullyValidated() {
for (Boolean isValid : validationStatus.values()) {
if (!isValid) {
return false;
}
}
return true;
} |
206414745_1332 | public boolean isFullyValidated() {
for (Boolean isValid : validationStatus.values()) {
if (!isValid) {
return false;
}
}
return true;
} |
206414745_1333 | public boolean isFullyValidated() {
for (Boolean isValid : validationStatus.values()) {
if (!isValid) {
return false;
}
}
return true;
} |
206414745_1334 | public boolean isFullyValidated() {
for (Boolean isValid : validationStatus.values()) {
if (!isValid) {
return false;
}
}
return true;
} |
206414745_1335 | public PendingPeerRequest executePeerRequest(
final PeerRequest request, final long minimumBlockNumber, final Optional<EthPeer> peer) {
final PendingPeerRequest pendingPeerRequest =
new PendingPeerRequest(this, request, minimumBlockNumber, peer);
synchronized (this) {
if (!pendingPeerRequest.attemptExecution()) {
pendingRequests.add(pendingPeerRequest);
}
}
return pendingPeerRequest;
} |
206414745_1336 | public PendingPeerRequest executePeerRequest(
final PeerRequest request, final long minimumBlockNumber, final Optional<EthPeer> peer) {
final PendingPeerRequest pendingPeerRequest =
new PendingPeerRequest(this, request, minimumBlockNumber, peer);
synchronized (this) {
if (!pendingPeerRequest.attemptExecution()) {
pendingRequests.add(pendingPeerRequest);
}
}
return pendingPeerRequest;
} |
206414745_1337 | public PendingPeerRequest executePeerRequest(
final PeerRequest request, final long minimumBlockNumber, final Optional<EthPeer> peer) {
final PendingPeerRequest pendingPeerRequest =
new PendingPeerRequest(this, request, minimumBlockNumber, peer);
synchronized (this) {
if (!pendingPeerRequest.attemptExecution()) {
pendingRequests.add(pendingPeerRequest);
}
}
return pendingPeerRequest;
} |
206414745_1338 | public PendingPeerRequest executePeerRequest(
final PeerRequest request, final long minimumBlockNumber, final Optional<EthPeer> peer) {
final PendingPeerRequest pendingPeerRequest =
new PendingPeerRequest(this, request, minimumBlockNumber, peer);
synchronized (this) {
if (!pendingPeerRequest.attemptExecution()) {
pendingRequests.add(pendingPeerRequest);
}
}
return pendingPeerRequest;
} |
206414745_1339 | public PendingPeerRequest executePeerRequest(
final PeerRequest request, final long minimumBlockNumber, final Optional<EthPeer> peer) {
final PendingPeerRequest pendingPeerRequest =
new PendingPeerRequest(this, request, minimumBlockNumber, peer);
synchronized (this) {
if (!pendingPeerRequest.attemptExecution()) {
pendingRequests.add(pendingPeerRequest);
}
}
return pendingPeerRequest;
} |
206414745_1340 | public PendingPeerRequest executePeerRequest(
final PeerRequest request, final long minimumBlockNumber, final Optional<EthPeer> peer) {
final PendingPeerRequest pendingPeerRequest =
new PendingPeerRequest(this, request, minimumBlockNumber, peer);
synchronized (this) {
if (!pendingPeerRequest.attemptExecution()) {
pendingRequests.add(pendingPeerRequest);
}
}
return pendingPeerRequest;
} |
206414745_1341 | public PendingPeerRequest executePeerRequest(
final PeerRequest request, final long minimumBlockNumber, final Optional<EthPeer> peer) {
final PendingPeerRequest pendingPeerRequest =
new PendingPeerRequest(this, request, minimumBlockNumber, peer);
synchronized (this) {
if (!pendingPeerRequest.attemptExecution()) {
pendingRequests.add(pendingPeerRequest);
}
}
return pendingPeerRequest;
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.