Tabnine Logo
StoreBuilder
Code IndexAdd Tabnine to your IDE (free)

How to use
StoreBuilder
in
io.yggdrash.core.store

Best Java code snippets using io.yggdrash.core.store.StoreBuilder (Showing top 20 results out of 315)

origin: yggdrash/yggdrash

@Bean
StoreBuilder storeBuilder(DefaultConfig defaultConfig) {
  return new StoreBuilder(defaultConfig);
}
origin: yggdrash/yggdrash

private Contract getContract(ContractId contractId) {
  try {
    // get System Contracts
    // TODO remove this
    // TODO Check System Contract
    ContractMeta contractMeta = ContractClassLoader.loadContractById(
        storeBuilder.getConfig().getContractPath(), contractId);
    return contractMeta.getContract().getDeclaredConstructor().newInstance();
  } catch (NoSuchMethodException | InstantiationException | IllegalAccessException
      | InvocationTargetException e) {
    throw new FailedOperationException(e);
  }
}
origin: yggdrash/yggdrash

public TransactionStore buildTxStore(BranchId branchId) {
  return new TransactionStore(getDbSource(branchId + "/txs"));
}
origin: yggdrash/yggdrash

blockStore = storeBuilder.buildBlockStore(genesisBlock.getBranchId());
transactionStore = storeBuilder.buildTxStore(genesisBlock.getBranchId());
metaStore = storeBuilder.buildMetaStore(genesisBlock.getBranchId());
stateStore = storeBuilder.buildStateStore(genesisBlock.getBranchId());
transactionReceiptStore = storeBuilder.buildTransactionReciptStore(
    genesisBlock.getBranchId());
origin: yggdrash/yggdrash

  @Test
  public void executorTest() {

    CoinContract contract = new CoinContract();
    Runtime runtime =
        new Runtime<>(
            new StateStore<>(new HashMapDbSource()),
            new TransactionReceiptStore(new HashMapDbSource())
        );
    runtime.addContract(ContractId.of("c10e873655becf550c4aece75a091f4553d6202d"), contract);

    // Block Store
    // Blockchain Runtime
    StoreBuilder builder = new StoreBuilder(new DefaultConfig(false));
    BlockStore store = builder.buildBlockStore(BRANCH_ID);
    MetaStore meta = builder.buildMetaStore(BRANCH_ID);

    BlockExecutor ex = new BlockExecutor(store, meta, runtime);

    // BlockStore add genesis block and other

    ex.runExecuteBlocks();

  }
}
origin: yggdrash/yggdrash

@Test
public void shouldBeBuiltMetaStore() {
  BlockHusk block = BlockChainTestUtils.genesisBlock();
  StoreBuilder builder = new StoreBuilder(new DefaultConfig());
  MetaStore store = builder.buildMetaStore(BRANCH_ID);
  store.setBestBlock(block);
  assertThat(store.contains(BlockchainMetaInfo.BRANCH.toString())).isTrue();
  assertThat(store.getBestBlockHash()).isEqualTo(block.getHash());
}
origin: yggdrash/yggdrash

  public static PeerTable createPeerTable(int port) {
    Peer owner = Peer.valueOf(NODE_URI_PREFIX + port);
    PeerTable peerTable = new KademliaPeerTable(owner, storeBuilder.buildPeerStore());
    List<String> seedList = Collections.singletonList(NODE_URI_PREFIX + 32918);
    peerTable.setSeedPeerList(seedList);
    return peerTable;
  }
}
origin: yggdrash/yggdrash

@Test
public void buildBlockStore() {
  BlockHusk block = BlockChainTestUtils.genesisBlock();
  BlockStore store = builder.buildBlockStore(BRANCH_ID);
  store.put(block.getHash(), block);
  assert store.contains(block.getHash());
  assert store.get(block.getHash()).equals(block);
}
origin: yggdrash/yggdrash

@Test
public void buildTxStore() {
  TransactionHusk tx = BlockChainTestUtils.createTransferTxHusk();
  TransactionStore store = builder.buildTxStore(BRANCH_ID);
  store.put(tx.getHash(), tx);
  assert store.contains(tx.getHash());
  assert store.get(tx.getHash()).equals(tx);
}
origin: yggdrash/yggdrash

@Bean
PeerTable peerTable(Wallet wallet, StoreBuilder storeBuilder) {
  Peer owner = Peer.valueOf(wallet.getNodeId(), nodeProperties.getGrpc().getHost(),
      nodeProperties.getGrpc().getPort());
  PeerStore peerStore = storeBuilder.buildPeerStore();
  PeerTable peerTable = new KademliaPeerTable(owner, peerStore);
  peerTable.setSeedPeerList(nodeProperties.getSeedPeerList());
  return peerTable;
}
origin: yggdrash/yggdrash

public static StoreBuilder getProdMockBuilder() {
  return new StoreBuilder(new ProdDefaultConfig());
}
origin: yggdrash/yggdrash

  @Test
  public void buildPeerStore() {
    Peer peer = Peer.valueOf("ynode://75bff16c@127.0.0.1:32918");
    PeerStore store = builder.buildPeerStore();
    store.put(peer.getPeerId(), peer);
    assert store.contains(peer.getPeerId());
    assert store.get(peer.getPeerId()).equals(peer);
  }
}
origin: yggdrash/yggdrash

public PeerStore buildPeerStore() {
  return new PeerStore(getDbSource("peers"));
}
origin: yggdrash/yggdrash

@Before
public void setUp() {
  StoreBuilder builder = new StoreBuilder(config);
  this.branchConfig = new BranchConfiguration(builder);
  this.peerHandlerGroup = new SimplePeerHandlerGroup(PeerHandlerMock.factory);
}
origin: yggdrash/yggdrash

public TransactionReceiptStore buildTransactionReciptStore(BranchId branchId) {
  return new TransactionReceiptStore(getDbSource(branchId + "/txreceipt"));
}
origin: yggdrash/yggdrash

@Before
public void setUp() {
  builder = new StoreBuilder(new DefaultConfig());
}
origin: yggdrash/yggdrash

public StateStore buildStateStore(BranchId branchId) {
  return new StateStore(getDbSource(branchId + "/state"));
}
origin: yggdrash/yggdrash

public static BlockChain createBlockChain(boolean isProductionMode) {
  StoreBuilder storeBuilder;
  if (isProductionMode) {
    storeBuilder = StoreTestUtils.getProdMockBuilder();
  } else {
    storeBuilder = new StoreBuilder(new DefaultConfig());
  }
  return BlockChainBuilder.Builder()
      .addGenesis(genesis)
      .setStoreBuilder(storeBuilder)
      .build();
}
origin: yggdrash/yggdrash

public BlockStore buildBlockStore(BranchId branchId) {
  return new BlockStore(getDbSource(branchId + "/blocks"));
}
origin: yggdrash/yggdrash

public MetaStore buildMetaStore(BranchId branchId) {
  MetaStore store = new MetaStore(getDbSource(branchId + "/meta"));
  store.put(BlockchainMetaInfo.BRANCH.toString(), branchId.toString());
  return store;
}
io.yggdrash.core.storeStoreBuilder

Most used methods

  • <init>
  • buildBlockStore
  • buildMetaStore
  • buildPeerStore
  • buildTxStore
  • buildStateStore
  • buildTransactionReciptStore
  • getConfig
  • getDbSource

Popular in Java

  • Parsing JSON documents to java classes using gson
  • addToBackStack (FragmentTransaction)
  • getSharedPreferences (Context)
  • onCreateOptionsMenu (Activity)
  • RandomAccessFile (java.io)
    Allows reading from and writing to a file in a random-access manner. This is different from the uni-
  • Format (java.text)
    The base class for all formats. This is an abstract base class which specifies the protocol for clas
  • PriorityQueue (java.util)
    A PriorityQueue holds elements on a priority heap, which orders the elements according to their natu
  • UUID (java.util)
    UUID is an immutable representation of a 128-bit universally unique identifier (UUID). There are mul
  • Reference (javax.naming)
  • HttpServletRequest (javax.servlet.http)
    Extends the javax.servlet.ServletRequest interface to provide request information for HTTP servlets.
  • Top PhpStorm plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now