Search in sources :

Example 1 with BlockTemplate

use of org.aion.rpc.types.RPCTypes.BlockTemplate in project aion by aionnetwork.

the class MiningRPCImplTest method getWorkTest.

@Test
public void getWorkTest() {
    ChainHolder chainHolder = new AionChainHolder(AionImpl.instForTest(), accountManager);
    rpcMethods = new RPCMethods(chainHolder);
    final BlockTemplate blockTemplate = rpcMethods.getBlockTemplate();
    assertNotNull(blockTemplate);
    assertTrue(chainHolder.canSeal(blockTemplate.headerHash.toBytes()));
    BlockTemplateConverter.encode(blockTemplate);
    final Request request = buildRequest("getBlockTemplate", VoidParamsConverter.encode(new VoidParams()));
    BlockTemplateConverter.encode(execute(request, BlockTemplateConverter::decode));
}
Also used : Request(org.aion.rpc.types.RPCTypes.Request) VoidParams(org.aion.rpc.types.RPCTypes.VoidParams) BlockTemplate(org.aion.rpc.types.RPCTypes.BlockTemplate) Test(org.junit.Test)

Example 2 with BlockTemplate

use of org.aion.rpc.types.RPCTypes.BlockTemplate in project aion by aionnetwork.

the class RPCMethods method getBlockTemplate.

@Override
public BlockTemplate getBlockTemplate() {
    BlockContext context = chainHolder.getBlockTemplate();
    MiningBlock block = context.block;
    return new BlockTemplate(ByteArray.wrap(block.getParentHash()), block.getNumber(), block.getHeader().getPowBoundaryBI(), ByteArray.wrap(block.getHeader().getMineHash()), context.baseBlockReward, context.transactionFee);
}
Also used : BlockContext(org.aion.zero.impl.types.BlockContext) MiningBlock(org.aion.zero.impl.types.MiningBlock) BlockTemplate(org.aion.rpc.types.RPCTypes.BlockTemplate)

Aggregations

BlockTemplate (org.aion.rpc.types.RPCTypes.BlockTemplate)2 Request (org.aion.rpc.types.RPCTypes.Request)1 VoidParams (org.aion.rpc.types.RPCTypes.VoidParams)1 BlockContext (org.aion.zero.impl.types.BlockContext)1 MiningBlock (org.aion.zero.impl.types.MiningBlock)1 Test (org.junit.Test)1