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))
Beispiel #2
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)]
Beispiel #3
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)