Ejemplo n.º 1
0
    def set_genesis_location(self, genesis_dir: str):
        pool_genesis_file = getattr(self.config, "poolTransactionsFile")
        self.pool_genesis = GenesisTxnInitiatorFromFile(
            genesis_dir, pool_genesis_file)

        domain_genesis_file = getattr(self.config, "domainTransactionsFile")
        self.domain_genesis = GenesisTxnInitiatorFromFile(
            genesis_dir, domain_genesis_file)
Ejemplo n.º 2
0
def create_default_ledger(tempdir, init_genesis_txn_file=None):
    genesis_txn_initiator = GenesisTxnInitiatorFromFile(
        tempdir, init_genesis_txn_file) if init_genesis_txn_file else None
    ledger = Ledger(
        CompactMerkleTree(hashStore=FileHashStore(dataDir=tempdir)),
        dataDir=tempdir,
        genesis_txn_initiator=genesis_txn_initiator)
    return ledger
Ejemplo n.º 3
0
 def init_pool_ledger(self):
     genesis_txn_initiator = GenesisTxnInitiatorFromFile(
         self.node.genesis_dir, self.node.config.poolTransactionsFile)
     tree = CompactMerkleTree(hashStore=self.node.getHashStore('pool'))
     return Ledger(tree,
                   dataDir=self.node.dataLocation,
                   fileName=self.node.config.poolTransactionsFile,
                   ensureDurability=self.node.config.EnsureLedgerDurability,
                   genesis_txn_initiator=genesis_txn_initiator)
Ejemplo n.º 4
0
def get_pool_ledger(node_name):
    config = getConfig()
    config_helper = NodeConfigHelper(node_name, config)

    genesis_txn_initiator = GenesisTxnInitiatorFromFile(config_helper.genesis_dir,
                                                        config.poolTransactionsFile)
    hash_store = initHashStore(config_helper.ledger_dir, "pool", config)
    return Ledger(CompactMerkleTree(hashStore=hash_store),
                  dataDir=config_helper.ledger_dir,
                  fileName=config.poolTransactionsFile,
                  ensureDurability=config.EnsureLedgerDurability,
                  genesis_txn_initiator=genesis_txn_initiator)
Ejemplo n.º 5
0
    def ledger(self):
        data_dir = self.ledgerLocation
        genesis_txn_initiator = GenesisTxnInitiatorFromFile(
            self.genesis_dir, self.ledgerFile)
        tree = CompactMerkleTree(hashStore=self.hashStore)
        ledger = Ledger(tree,
                        dataDir=data_dir,
                        fileName=self.ledgerFile,
                        ensureDurability=self.config.EnsureLedgerDurability,
                        genesis_txn_initiator=genesis_txn_initiator)

        return ledger
Ejemplo n.º 6
0
def __create_ledger(store,
                    txn_serializer,
                    hash_serializer,
                    tempdir,
                    init_genesis_txn_file=None):
    genesis_txn_initiator = GenesisTxnInitiatorFromFile(
        tempdir, init_genesis_txn_file) if init_genesis_txn_file else None
    ledger = Ledger(
        CompactMerkleTree(hashStore=FileHashStore(dataDir=tempdir)),
        dataDir=tempdir,
        transactionLogStore=store,
        txn_serializer=txn_serializer,
        hash_serializer=hash_serializer,
        genesis_txn_initiator=genesis_txn_initiator)
    return ledger
Ejemplo n.º 7
0
 def ledger(self):
     if self._ledger is None:
         genesis_txn_initiator = GenesisTxnInitiatorFromFile(
             self.basedirpath, self.ledgerFile)
         dataDir = self.ledgerLocation
         self.hashStore = LevelDbHashStore(
             dataDir=dataDir, fileNamePrefix='pool')
         self._ledger = Ledger(
             CompactMerkleTree(
                 hashStore=self.hashStore),
             dataDir=dataDir,
             fileName=self.ledgerFile,
             ensureDurability=self.config.EnsureLedgerDurability,
             genesis_txn_initiator=genesis_txn_initiator)
     return self._ledger
Ejemplo n.º 8
0
 def init_domain_ledger(self):
     """
     This is usually an implementation of Ledger
     """
     if self.config.primaryStorage is None:
         genesis_txn_initiator = GenesisTxnInitiatorFromFile(
             self.genesis_dir, self.config.domainTransactionsFile)
         return Ledger(
             CompactMerkleTree(hashStore=self.getHashStore('domain')),
             dataDir=self.dataLocation,
             fileName=self.config.domainTransactionsFile,
             ensureDurability=self.config.EnsureLedgerDurability,
             genesis_txn_initiator=genesis_txn_initiator)
     else:
         return initStorage(self.config.primaryStorage,
                            name=self.name + NODE_PRIMARY_STORAGE_SUFFIX,
                            dataDir=self.dataLocation,
                            config=self.config)
Ejemplo n.º 9
0
 def init_domain_ledger(self):
     """
     This is usually an implementation of Ledger
     """
     if self.node.config.primaryStorage is None:
         # TODO: add a place for initialization of all ledgers, so it's
         # clear what ledgers we have and how they are initialized
         genesis_txn_initiator = GenesisTxnInitiatorFromFile(
             self.node.genesis_dir, self.node.config.domainTransactionsFile)
         tree = CompactMerkleTree(hashStore=self.node.getHashStore('domain'))
         return Ledger(tree,
                       dataDir=self.node.dataLocation,
                       fileName=self.node.config.domainTransactionsFile,
                       ensureDurability=self.node.config.EnsureLedgerDurability,
                       genesis_txn_initiator=genesis_txn_initiator)
     else:
         # TODO: we need to rethink this functionality
         return initStorage(self.node.config.primaryStorage,
                            name=self.node.name + NODE_PRIMARY_STORAGE_SUFFIX,
                            dataDir=self.node.dataLocation,
                            config=self.node.config)
Ejemplo n.º 10
0
def create_genesis_txn_init_ledger(data_dir, txn_file):
    from ledger.genesis_txn.genesis_txn_initiator_from_file import GenesisTxnInitiatorFromFile
    initiator = GenesisTxnInitiatorFromFile(data_dir, txn_file)
    return initiator.create_initiator_ledger()
def create_genesis_txn_init_ledger(data_dir, txn_file):
    from ledger.genesis_txn.genesis_txn_initiator_from_file import GenesisTxnInitiatorFromFile
    initiator = GenesisTxnInitiatorFromFile(data_dir, txn_file)
    return initiator.create_initiator_ledger()