当前位置: 首页>>代码示例>>Java>>正文


Java Block.getCoinbase方法代码示例

本文整理汇总了Java中org.ethereum.core.Block.getCoinbase方法的典型用法代码示例。如果您正苦于以下问题:Java Block.getCoinbase方法的具体用法?Java Block.getCoinbase怎么用?Java Block.getCoinbase使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.ethereum.core.Block的用法示例。


在下文中一共展示了Block.getCoinbase方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setAndGetSiblings

import org.ethereum.core.Block; //导入方法依赖的package包/类
@Test
public void setAndGetSiblings() {
    RskAddress accountAddress = randomAddress();
    Repository repository = new RepositoryImpl(ConfigHelper.CONFIG);

    RemascStorageProvider provider = new RemascStorageProvider(repository, accountAddress);

    Block genesis = BlockGenerator.getInstance().getGenesisBlock();
    Block block = BlockGenerator.getInstance().createChildBlock(genesis);

    Sibling sibling1 = new Sibling(genesis.getHeader(), genesis.getCoinbase(), 1);
    Sibling sibling2 = new Sibling(block.getHeader(), block.getCoinbase(), 2);

    List<Sibling> siblings = new ArrayList<>();
    siblings.add(sibling1);
    siblings.add(sibling2);

    provider.getSiblings().put(Long.valueOf(1), siblings);

    SortedMap<Long, List<Sibling>> map = provider.getSiblings();

    Assert.assertNotNull(map);
    Assert.assertFalse(map.isEmpty());
    Assert.assertTrue(map.containsKey(Long.valueOf(1)));

    Assert.assertEquals(2, map.get(Long.valueOf(1)).size());
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:28,代码来源:RemascStorageProviderTest.java

示例2: setSaveRetrieveAndGetManySiblings

import org.ethereum.core.Block; //导入方法依赖的package包/类
@Test
public void setSaveRetrieveAndGetManySiblings() throws IOException {
    RskAddress accountAddress = randomAddress();
    Repository repository = new RepositoryImplForTesting();

    RemascStorageProvider provider = new RemascStorageProvider(repository, accountAddress);

    Block genesis = BlockGenerator.getInstance().getGenesisBlock();
    Block block1 = BlockGenerator.getInstance().createChildBlock(genesis);
    Block block2 = BlockGenerator.getInstance().createChildBlock(block1);
    Block block3 = BlockGenerator.getInstance().createChildBlock(block2);
    Block block4 = BlockGenerator.getInstance().createChildBlock(block3);
    Block block5 = BlockGenerator.getInstance().createChildBlock(block4);

    Sibling sibling1 = new Sibling(genesis.getHeader(), genesis.getCoinbase(), 1);
    Sibling sibling2 = new Sibling(block1.getHeader(), block1.getCoinbase(), 2);
    Sibling sibling3 = new Sibling(block2.getHeader(), block2.getCoinbase(), 3);
    Sibling sibling4 = new Sibling(block3.getHeader(), block3.getCoinbase(), 4);
    Sibling sibling5 = new Sibling(block4.getHeader(), block4.getCoinbase(), 5);
    Sibling sibling6 = new Sibling(block5.getHeader(), block5.getCoinbase(), 6);

    List<Sibling> siblings0 = new ArrayList<>();
    List<Sibling> siblings1 = new ArrayList<>();
    List<Sibling> siblings2 = new ArrayList<>();

    siblings0.add(sibling1);
    siblings0.add(sibling2);

    siblings1.add(sibling3);
    siblings1.add(sibling4);

    siblings2.add(sibling5);
    siblings2.add(sibling6);

    provider.getSiblings().put(Long.valueOf(0), siblings0);
    provider.getSiblings().put(Long.valueOf(1), siblings1);
    provider.getSiblings().put(Long.valueOf(2), siblings2);

    provider.save();

    RemascStorageProvider newProvider = new RemascStorageProvider(repository, accountAddress);

    SortedMap<Long, List<Sibling>> map = newProvider.getSiblings();

    Assert.assertNotNull(map);
    Assert.assertFalse(map.isEmpty());

    Assert.assertTrue(map.containsKey(Long.valueOf(0)));
    Assert.assertTrue(map.containsKey(Long.valueOf(1)));
    Assert.assertTrue(map.containsKey(Long.valueOf(2)));

    Assert.assertEquals(2, map.get(Long.valueOf(0)).size());
    Assert.assertEquals(2, map.get(Long.valueOf(1)).size());
    Assert.assertEquals(2, map.get(Long.valueOf(2)).size());

    List<Sibling> list0 = map.get(Long.valueOf(0));
    List<Sibling> list1 = map.get(Long.valueOf(1));
    List<Sibling> list2 = map.get(Long.valueOf(2));

    Assert.assertEquals(1, list0.get(0).getIncludedHeight());
    Assert.assertArrayEquals(genesis.getHeader().getHash(), list0.get(0).getHash());
    Assert.assertEquals(2, list0.get(1).getIncludedHeight());
    Assert.assertArrayEquals(block1.getHeader().getHash(), list0.get(1).getHash());

    Assert.assertEquals(3, list1.get(0).getIncludedHeight());
    Assert.assertArrayEquals(block2.getHeader().getHash(), list1.get(0).getHash());
    Assert.assertEquals(4, list1.get(1).getIncludedHeight());
    Assert.assertArrayEquals(block3.getHeader().getHash(), list1.get(1).getHash());

    Assert.assertEquals(5, list2.get(0).getIncludedHeight());
    Assert.assertArrayEquals(block4.getHeader().getHash(), list2.get(0).getHash());
    Assert.assertEquals(6, list2.get(1).getIncludedHeight());
    Assert.assertArrayEquals(block5.getHeader().getHash(), list2.get(1).getHash());
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:75,代码来源:RemascStorageProviderTest.java

示例3: siblingSerializeWithGenesis

import org.ethereum.core.Block; //导入方法依赖的package包/类
@Test
public void siblingSerializeWithGenesis() {
    Block genesis = BlockGenerator.getInstance().getGenesisBlock();

    Sibling sibling = new Sibling(genesis.getHeader(), genesis.getCoinbase(), 1);

    byte[] bytes = sibling.getEncoded();

    Assert.assertNotNull(bytes);

    Sibling result = Sibling.create(bytes);

    Assert.assertNotNull(result);

    Assert.assertArrayEquals(sibling.getHash(), result.getHash());
    Assert.assertArrayEquals(sibling.getIncludedBlockCoinbase(), result.getIncludedBlockCoinbase());
    Assert.assertArrayEquals(sibling.getEncoded(), result.getEncoded());

    Assert.assertEquals(sibling.getIncludedHeight(), result.getIncludedHeight());
    Assert.assertEquals(sibling.getPaidFees(), result.getPaidFees());
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:22,代码来源:SiblingTest.java

示例4: siblingSerializeWithBlock

import org.ethereum.core.Block; //导入方法依赖的package包/类
@Test
public void siblingSerializeWithBlock() {
    Block genesis = BlockGenerator.getInstance().getGenesisBlock();
    Block block = BlockGenerator.getInstance().createChildBlock(genesis);

    Sibling sibling = new Sibling(block.getHeader(), block.getCoinbase(), 0);

    byte[] bytes = sibling.getEncoded();

    Assert.assertNotNull(bytes);

    Sibling result = Sibling.create(bytes);

    Assert.assertNotNull(result);

    Assert.assertArrayEquals(sibling.getHash(), result.getHash());
    Assert.assertArrayEquals(sibling.getIncludedBlockCoinbase(), result.getIncludedBlockCoinbase());
    Assert.assertArrayEquals(sibling.getEncoded(), result.getEncoded());

    Assert.assertEquals(sibling.getIncludedHeight(), result.getIncludedHeight());
    Assert.assertEquals(sibling.getPaidFees(), result.getPaidFees());
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:23,代码来源:SiblingTest.java

示例5: serializeAndDeserializeWithSomeValues

import org.ethereum.core.Block; //导入方法依赖的package包/类
@Test
public void serializeAndDeserializeWithSomeValues() {
    Block genesis = BlockGenerator.getInstance().getGenesisBlock();
    Block block1 = BlockGenerator.getInstance().createChildBlock(genesis);
    Block block2 = BlockGenerator.getInstance().createChildBlock(block1);
    Block block3 = BlockGenerator.getInstance().createChildBlock(block2);
    Block block4 = BlockGenerator.getInstance().createChildBlock(block3);
    Block block5 = BlockGenerator.getInstance().createChildBlock(block4);

    Sibling sibling1 = new Sibling(genesis.getHeader(), genesis.getCoinbase(), 1);
    Sibling sibling2 = new Sibling(block1.getHeader(), block1.getCoinbase(), 2);
    Sibling sibling3 = new Sibling(block2.getHeader(), block2.getCoinbase(), 3);
    Sibling sibling4 = new Sibling(block3.getHeader(), block3.getCoinbase(), 4);
    Sibling sibling5 = new Sibling(block4.getHeader(), block4.getCoinbase(), 5);
    Sibling sibling6 = new Sibling(block5.getHeader(), block5.getCoinbase(), 6);

    List<Sibling> siblings0 = new ArrayList<>();
    List<Sibling> siblings1 = new ArrayList<>();
    List<Sibling> siblings2 = new ArrayList<>();

    siblings0.add(sibling1);
    siblings0.add(sibling2);

    siblings1.add(sibling3);
    siblings1.add(sibling4);

    siblings2.add(sibling5);
    siblings2.add(sibling6);

    SortedMap<Long, List<Sibling>> siblings = new TreeMap<>();

    siblings.put(Long.valueOf(0), siblings0);
    siblings.put(Long.valueOf(1), siblings1);
    siblings.put(Long.valueOf(2), siblings2);

    RemascState state = new RemascState(BigInteger.ONE, BigInteger.TEN, siblings, true);

    byte[] bytes = state.getEncoded();

    RemascState result = RemascState.create(bytes);

    Assert.assertNotNull(result);
    Assert.assertEquals(BigInteger.ONE, result.getRewardBalance());
    Assert.assertEquals(BigInteger.TEN, result.getBurnedBalance());
    Assert.assertNotNull(result.getSiblings());
    Assert.assertFalse(result.getSiblings().isEmpty());
    Assert.assertTrue(result.getBrokenSelectionRule());
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:49,代码来源:RemascStateTest.java

示例6: setSaveRetrieveAndGetSiblings

import org.ethereum.core.Block; //导入方法依赖的package包/类
@Test
public void setSaveRetrieveAndGetSiblings() throws IOException {
    RskAddress accountAddress = randomAddress();
    Repository repository = new RepositoryImplForTesting();

    RemascStorageProvider provider = new RemascStorageProvider(repository, accountAddress);

    Block genesis = BlockGenerator.getInstance().getGenesisBlock();
    Block block = BlockGenerator.getInstance().createChildBlock(genesis);

    Sibling sibling1 = new Sibling(genesis.getHeader(), genesis.getCoinbase(), 1);
    Sibling sibling2 = new Sibling(block.getHeader(), block.getCoinbase(), 2);

    List<Sibling> siblings = new ArrayList<>();
    siblings.add(sibling1);
    siblings.add(sibling2);

    provider.getSiblings().put(Long.valueOf(1), siblings);

    provider.save();

    RemascStorageProvider newProvider = new RemascStorageProvider(repository, accountAddress);

    SortedMap<Long, List<Sibling>> map = newProvider.getSiblings();

    Assert.assertNotNull(map);
    Assert.assertFalse(map.isEmpty());
    Assert.assertTrue(map.containsKey(Long.valueOf(1)));

    Assert.assertEquals(2, map.get(Long.valueOf(1)).size());
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:32,代码来源:RemascStorageProviderTest.java


注:本文中的org.ethereum.core.Block.getCoinbase方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。