Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'ENETUNREACH',
'SOCKET_TIMEOUT',
'RECEIVE_MESSAGE_TIMEOUT',
'EADDRNOTAVAIL',
'ETIMEDOUT',
]);
const NEO_NETWORK_PEER_CLOSED_TOTAL = metrics.createCounter({
name: 'neo_network_peer_closed_total',
help:
'Total number of times a peer was closed due to error or ending the socket.',
});
const NEO_NETWORK_PEER_CONNECT_TOTAL = metrics.createCounter({
name: 'neo_network_peer_connect_total',
});
const NEO_NETWORK_PEER_CONNECT_FAILURES_TOTAL = metrics.createCounter({
name: 'neo_network_peer_connect_failures_total',
});
const NEO_NETWORK_CONNECTED_PEERS_TOTAL = metrics.createGauge({
name: 'neo_network_connected_peers_total',
});
const NEO_NETWORK_CONNECTING_PEERS_TOTAL = metrics.createGauge({
name: 'neo_network_connecting_peers_total',
});
export default class Network {
_monitor: Monitor;
_started: boolean;
_stopped: boolean;
_externalEndpoints: Set;
_maxConnectedPeers: number;
startHeight: number,
endHeight: number,
claimed: boolean,
|};
type Vote = {|
publicKeys: Array,
count: BN,
|};
const NAMESPACE = 'blockchain';
const NEO_BLOCKCHAIN_PERSIST_BLOCK_DURATION_SECONDS = metrics.createHistogram({
name: 'neo_blockchain_persist_block_duration_seconds',
});
const NEO_BLOCKCHAIN_PERSIST_BLOCK_FAILURES_TOTAL = metrics.createCounter({
name: 'neo_blockchain_persist_block_failures_total',
});
const NEO_BLOCKCHAIN_BLOCK_INDEX_GAUGE = metrics.createGauge({
name: 'neo_blockchain_block_index',
help: 'The current block index',
});
const NEO_BLOCKCHAIN_PERSISTING_BLOCK_INDEX_GAUGE = metrics.createGauge({
name: 'neo_blockchain_persisting_block_index',
help: 'The current in progress persist index',
});
const NEO_BLOCKCHAIN_PERSIST_BLOCK_LATENCY_SECONDS = metrics.createHistogram({
name: 'neo_blockchain_persist_block_latency_seconds',
help: 'The latency from block timestamp to persist',
buckets: [1, 2, 5, 7.5, 10, 12.5, 15, 17.5, 20],
});
import Message, { type MessageValue, MessageTransform } from './Message';
import { AlreadyConnectedError, NegotiationError } from './errors';
import { type PeerData } from './PeerData';
import pkg from '../package.json';
const messageReceivedLabelNames = [labels.COMMAND_NAME];
const messageReceivedLabels = commonUtils.values(COMMAND).map((command) => ({
[labels.COMMAND_NAME]: command,
}));
const NEO_PROTOCOL_MESSAGES_RECEIVED_TOTAL = metrics.createCounter({
name: 'neo_protocol_messages_received_total',
labelNames: messageReceivedLabelNames,
labels: messageReceivedLabels,
});
const NEO_PROTOCOL_MESSAGES_FAILURES_TOTAL = metrics.createCounter({
name: 'neo_protocol_messages_failures_total',
labelNames: messageReceivedLabelNames,
labels: messageReceivedLabels,
});
const NEO_PROTOCOL_MEMPOOL_SIZE = metrics.createGauge({
name: 'neo_protocol_mempool_size',
});
export type Environment = {|
network?: NetworkEnvironment,
|};
export type Options = {|
consensus?: {|
enabled: boolean,
options: ConsensusOptions,
|},
'ECONNREFUSED',
'ERR_INVALID_IP_ADDRESS',
'EHOSTUNREACH',
'ENETUNREACH',
'SOCKET_TIMEOUT',
'RECEIVE_MESSAGE_TIMEOUT',
'EADDRNOTAVAIL',
'ETIMEDOUT',
]);
const NEO_NETWORK_PEER_CLOSED_TOTAL = metrics.createCounter({
name: 'neo_network_peer_closed_total',
help:
'Total number of times a peer was closed due to error or ending the socket.',
});
const NEO_NETWORK_PEER_CONNECT_TOTAL = metrics.createCounter({
name: 'neo_network_peer_connect_total',
});
const NEO_NETWORK_PEER_CONNECT_FAILURES_TOTAL = metrics.createCounter({
name: 'neo_network_peer_connect_failures_total',
});
const NEO_NETWORK_CONNECTED_PEERS_TOTAL = metrics.createGauge({
name: 'neo_network_connected_peers_total',
});
const NEO_NETWORK_CONNECTING_PEERS_TOTAL = metrics.createGauge({
name: 'neo_network_connecting_peers_total',
});
export default class Network {
_monitor: Monitor;
_started: boolean;
_stopped: boolean;
MerkleBlockPayload,
NetworkAddress,
VersionPayload,
} from './payload';
import { type ConsensusOptions, Consensus } from './consensus';
import Message, { type MessageValue, MessageTransform } from './Message';
import { AlreadyConnectedError, NegotiationError } from './errors';
import { type PeerData } from './PeerData';
import pkg from '../package.json';
const messageReceivedLabelNames = [labels.COMMAND_NAME];
const messageReceivedLabels = commonUtils.values(COMMAND).map((command) => ({
[labels.COMMAND_NAME]: command,
}));
const NEO_PROTOCOL_MESSAGES_RECEIVED_TOTAL = metrics.createCounter({
name: 'neo_protocol_messages_received_total',
labelNames: messageReceivedLabelNames,
labels: messageReceivedLabels,
});
const NEO_PROTOCOL_MESSAGES_FAILURES_TOTAL = metrics.createCounter({
name: 'neo_protocol_messages_failures_total',
labelNames: messageReceivedLabelNames,
labels: messageReceivedLabels,
});
const NEO_PROTOCOL_MEMPOOL_SIZE = metrics.createGauge({
name: 'neo_protocol_mempool_size',
});
export type Environment = {|
network?: NetworkEnvironment,
|};
const EXTERNAL_ENDPOINTS = new Set();
const MAX_CONNECTED_PEERS = 10;
const CONNECT_PEERS_DELAY_MS = 5000;
const SOCKET_TIMEOUT_MS = 1000 * 60;
const CONNECT_ERROR_CODES = new Set([
'ECONNREFUSED',
'ERR_INVALID_IP_ADDRESS',
'EHOSTUNREACH',
'ENETUNREACH',
'SOCKET_TIMEOUT',
'RECEIVE_MESSAGE_TIMEOUT',
'EADDRNOTAVAIL',
'ETIMEDOUT',
]);
const NEO_NETWORK_PEER_CLOSED_TOTAL = metrics.createCounter({
name: 'neo_network_peer_closed_total',
help:
'Total number of times a peer was closed due to error or ending the socket.',
});
const NEO_NETWORK_PEER_CONNECT_TOTAL = metrics.createCounter({
name: 'neo_network_peer_connect_total',
});
const NEO_NETWORK_PEER_CONNECT_FAILURES_TOTAL = metrics.createCounter({
name: 'neo_network_peer_connect_failures_total',
});
const NEO_NETWORK_CONNECTED_PEERS_TOTAL = metrics.createGauge({
name: 'neo_network_connected_peers_total',
});
const NEO_NETWORK_CONNECTING_PEERS_TOTAL = metrics.createGauge({
name: 'neo_network_connecting_peers_total',
});