Example #1
0
import sys  # noqa

from bos_consensus.common import Message
from bos_consensus.network import Endpoint
from bos_consensus.util import (
    ArgumentParserShowDefaults,
    logger,
)

from client.client import send_message_multiple

parser = ArgumentParserShowDefaults()

log = None
logger.set_argparse(parser)

parser.add_argument(
    'endpoints',
    nargs='+',
    help=
    'endpoints with the number of endpoints\'s messages want to send; ex) http://localhost:80?m=5 http://localhost:80?m=10',  # noqa
    type=str,
)

parser.add_argument(
    'message',
    nargs='?',
    help='Messages you want to send to the server',
    type=str,
)
import asyncio
import copy
import time

from bos_consensus.common import Message, node_factory
from bos_consensus.blockchain import Blockchain
from bos_consensus.network import Endpoint, get_network_module
from bos_consensus.consensus import get_fba_module

from bos_consensus.util import (
    logger,
    ArgumentParserShowDefaults,
)

parser = ArgumentParserShowDefaults()
logger.set_argparse(parser)
parser.add_argument('-n',
                    '--nodes',
                    help='Number of nodes',
                    default=5,
                    type=int)
parser.add_argument('-t',
                    '--threshold',
                    help='Threshold of all nodes',
                    default=60,
                    type=int)
parser.add_argument('-b',
                    '--ballots',
                    help='Number of ballots in slot',
                    default=5,
                    type=int)
import lorem
import sys  # noqa

from bos_consensus.common import Message
from bos_consensus.network import Endpoint
from bos_consensus.util import (
    ArgumentParserShowDefaults,
    logger,
)

from client.client import send_message_multiple

parser = ArgumentParserShowDefaults()

log = None
logger.set_argparse(parser)

parser.add_argument(
    'endpoints',
    nargs='+',
    help='endpoints, you want to send the message to',
    type=str,
)

parser.add_argument(
    'message',
    nargs='?',
    default=lorem.sentence().split()[0],
    help='Messages you want to send to the server',
    type=str,
)
import sys  # noqa

from bos_consensus.common import Message
from bos_consensus.network import Endpoint
from bos_consensus.util import (
    ArgumentParserShowDefaults,
    logger,
)

from client.client import send_message_multiple

parser = ArgumentParserShowDefaults()

log = None
logger.set_argparse(parser)

parser.add_argument(
    '-same-message-id',
    action='store_true',
    help='messsages will have same `message_id`, but different `data`',
)
parser.add_argument(
    'endpoints',
    nargs='+',
    help=
    'endpoints with the number of endpoints\'s messages want to send; ex) http://localhost:80?m=5 http://localhost:80?m=10',  # noqa
    type=str,
)

parser.add_argument(
    'message',
Example #5
0
from bos_consensus.consensus import get_fba_module
from bos_consensus.network import get_network_module
from bos_consensus.util import (
    ArgumentParserShowDefaults,
    convert_namedtuple_to_dict,
    get_module,
    logger,
    Printer,
)
from util import log_current_state

CONSENSUS_MODULE = get_fba_module('isaac')

PRINTER = Printer(sys.stdout)

parser = ArgumentParserShowDefaults()
logger.set_argparse(parser)
parser.add_argument(
    '-case',
    help='set the case name',
    default=None,
    type=str,
)

parser.add_argument(
    'design',
    help='design should be yaml or json',
    type=str,
)

parser.add_argument(
Example #6
0
import logging
import pathlib
import uuid

from bos_consensus.blockchain import Blockchain
from bos_consensus.consensus import get_fba_module
from bos_consensus.network import Endpoint, get_network_module, BaseServer
from bos_consensus.common import Node, node_factory

from bos_consensus.util import (
    get_local_ipaddress,
    logger,
    ArgumentParserShowDefaults,
)

parser = ArgumentParserShowDefaults()
parser.add_argument('conf', help='ini config file for server node')
log = None

logger.set_argparse(parser)

NETWORK_MODULE = get_network_module('default_http')


def main(options):
    config = collections.namedtuple(
        'Config',
        ('node_name', 'port', 'threshold', 'validators', 'faulty_percent'),
    )(uuid.uuid1().hex, 8001, 51, [], 0)

    if not pathlib.Path(options.conf).exists():
Example #7
0
import lorem
import sys

from bos_consensus.util import (
    ArgumentParserShowDefaults,
    get_uuid,
    logger,
)

from client.client import (MessageInfo, send_message)

parser = ArgumentParserShowDefaults()

log = None
logger.set_argparse(parser)

parser.add_argument(
    '-id',
    '--id',
    default=get_uuid(),
    help='Message id',
    type=str,
)
parser.add_argument(
    '-m',
    '--message',
    default=lorem.sentence().split()[0],
    help='Messages you want to send to the server',
    type=str,
)
parser.add_argument(
    ArgumentParserShowDefaults,
    convert_namedtuple_to_dict,
    get_module,
    logger,
)
from util import log_current_state

from common import (
    FaultyBlockchain,
    load_design,
)
from common.audit import FaultyNodeAuditor

CONSENSUS_MODULE = get_fba_module('isaac')

parser = ArgumentParserShowDefaults()
logger.set_argparse(parser)
parser.add_argument(
    '-case',
    help='set the case name',
    default=None,
    type=str,
)

parser.add_argument(
    'design',
    help='design should be yaml or json',
    type=str,
)

MS = 0.001
Example #9
0
from bos_consensus.consensus import get_fba_module
from bos_consensus.network import get_network_module
from bos_consensus.util import (
    ArgumentParserShowDefaults,
    convert_namedtuple_to_dict,
    get_module,
    logger,
    Printer,
)
from util import log_current_state

CONSENSUS_MODULE = get_fba_module('isaac')

PRINTER = Printer(sys.stdout)

parser = ArgumentParserShowDefaults()
logger.set_argparse(parser)

parser.add_argument(
    '-case',
    help='set the case name',
    default=None,
    type=str,
)

parser.add_argument(
    '-viz-format',
    default='png',
    help='network topology image format',
    type=str,
    choices=graphviz.FORMATS,
ANALYZERS = {
    'history': NodesHistoryAnalyzer,
    'safety': SafetyAnalyzer,
    'fault-tolerance': FaultToleranceAnalyzer,
}


try:
    _, TERMINAL_COLUMNS = os.popen('stty size', 'r').read().split()
except ValueError:
    TERMINAL_COLUMNS = 0
else:
    TERMINAL_COLUMNS = int(TERMINAL_COLUMNS)

parser = ArgumentParserShowDefaults()

log = None
logger.set_argparse(parser)

parser.add_argument(
    '-type',
    help='set the analyzer type to be shown (%s)' % ANALYZERS.keys(),
    type=str,
)

parser.add_argument(
    '-nodes',
    help='set the nodes to be shown',
    type=str,
)