Esempio n. 1
0
 def __init__(self, config):
     fname = File.normalize(ARGS.rippled)
     if not os.path.exists(fname):
         raise Exception('No rippled found at %s.' % fname)
     self.cmd = [fname]
     if ARGS.config:
         self.cmd.extend(['--conf', File.normalize(ARGS.config)])
     self.info = self._command('server_info')['info']
     c = self.info.get('complete_ledgers')
     if c == 'empty':
         self.complete = []
     else:
         self.complete = sorted(Range.from_string(c))
Esempio n. 2
0
 def __init__(self, config):
     fname = File.normalize(ARGS.rippled)
     if not os.path.exists(fname):
         raise Exception('No rippled found at %s.' % fname)
     self.cmd = [fname]
     if ARGS.config:
         self.cmd.extend(['--conf', File.normalize(ARGS.config)])
     self.info = self._command('server_info')['info']
     c = self.info.get('complete_ledgers')
     if c == 'empty':
         self.complete = []
     else:
         self.complete = sorted(Range.from_string(c))
Esempio n. 3
0
    def __init__(self):
        cfg_file = File.normalize(ARGS.config or 'rippled.cfg')
        self.config = ConfigFile.read(open(cfg_file))
        if ARGS.database != ARGS.NONE:
            reader = DatabaseReader.DatabaseReader(self.config)
        else:
            reader = RippledReader.RippledReader(self.config)

        self.reader = reader
        self.complete = reader.complete

        names = {
            'closed': reader.name_to_ledger_index('closed'),
            'current': reader.name_to_ledger_index('current'),
            'validated': reader.name_to_ledger_index('validated'),
            'first': self.complete[0] if self.complete else None,
            'last': self.complete[-1] if self.complete else None,
        }
        self.__dict__.update(names)
        self.ledgers = sorted(Range.join_ranges(*ARGS.ledgers, **names))

        def make_cache(is_full):
            name = 'full' if is_full else 'summary'
            filepath = os.path.join(ARGS.cache, name)
            creator = lambda n: reader.get_ledger(n, is_full)
            return FileCache(filepath, creator)

        self._caches = [make_cache(False), make_cache(True)]
Esempio n. 4
0
    def __init__(self):
        cfg_file = File.normalize(ARGS.config or 'rippled.cfg')
        self.config = ConfigFile.read(open(cfg_file))
        if ARGS.database != ARGS.NONE:
            reader = DatabaseReader.DatabaseReader(self.config)
        else:
            reader = RippledReader.RippledReader(self.config)

        self.reader = reader
        self.complete = reader.complete

        names = {
            'closed': reader.name_to_ledger_index('closed'),
            'current': reader.name_to_ledger_index('current'),
            'validated': reader.name_to_ledger_index('validated'),
            'first': self.complete[0] if self.complete else None,
            'last': self.complete[-1] if self.complete else None,
        }
        self.__dict__.update(names)
        self.ledgers = sorted(Range.join_ranges(*ARGS.ledgers, **names))

        def make_cache(is_full):
            name = 'full' if is_full else 'summary'
            filepath = os.path.join(ARGS.cache, name)
            creator = lambda n: reader.get_ledger(n, is_full)
            return FileCache(filepath, creator)
        self._caches = [make_cache(False), make_cache(True)]
Esempio n. 5
0
# Read the arguments from the command line.
ARGS = _parser.parse_args()
ARGS.NONE = NONE

Log.VERBOSE = ARGS.verbose

# Now remove any items that look like ledger numbers from the command line.
_command = ARGS.command
_parts = (ARGS.command, ARGS.ledgers) = ([], [])

for c in _command:
    _parts[Range.is_range(c, *LedgerNumber.LEDGERS)].append(c)

ARGS.command = ARGS.command or ['print' if ARGS.ledgers else 'info']

ARGS.cache = File.normalize(ARGS.cache)

if not ARGS.ledgers:
    if ARGS.condition:
        Log.warn('--condition needs a range of ledgers')
    if ARGS.display:
        Log.warn('--display needs a range of ledgers')

ARGS.condition = Function(ARGS.condition or 'all_ledgers',
                          'ripple.ledger.conditions')
ARGS.display = Function(ARGS.display or 'ledger_number',
                        'ripple.ledger.displays')

if ARGS.window < 0:
    raise ValueError('Window cannot be negative: --window=%d' % ARGS.window)
Esempio n. 6
0
# Read the arguments from the command line.
ARGS = _parser.parse_args()
ARGS.NONE = NONE

Log.VERBOSE = ARGS.verbose

# Now remove any items that look like ledger numbers from the command line.
_command = ARGS.command
_parts = (ARGS.command, ARGS.ledgers) = ([], [])

for c in _command:
    _parts[Range.is_range(c, *LedgerNumber.LEDGERS)].append(c)

ARGS.command = ARGS.command or ['print' if ARGS.ledgers else 'info']

ARGS.cache = File.normalize(ARGS.cache)

if not ARGS.ledgers:
    if ARGS.condition:
        Log.warn('--condition needs a range of ledgers')
    if ARGS.display:
        Log.warn('--display needs a range of ledgers')

ARGS.condition = Function(
    ARGS.condition or 'all_ledgers', 'ripple.ledger.conditions')
ARGS.display = Function(
    ARGS.display or 'ledger_number', 'ripple.ledger.displays')

if ARGS.window < 0:
    raise ValueError('Window cannot be negative: --window=%d' %
                     ARGS.window)