Search in sources :

Example 6 with Block

use of com.jd.blockchain.consensus.raft.consensus.Block in project jdchain-core by blockchain-jd-com.

the class BlockProposerServiceTest method testProposalBlock.

@Test
public void testProposalBlock() {
    RaftNodeServer server = new RaftNodeServer(null, null, null);
    BlockProposerService proposer = new BlockProposerService(mockLedgerRepository);
    Block b1 = proposer.proposeBlock(Lists.newArrayList(new byte[][] {}));
    Block b2 = proposer.proposeBlock(Lists.newArrayList(new byte[][] {}));
    Block b3 = proposer.proposeBlock(Lists.newArrayList(new byte[][] {}));
    Block b4 = proposer.proposeBlock(Lists.newArrayList(new byte[][] {}));
    Block b5 = proposer.proposeBlock(Lists.newArrayList(new byte[][] {}));
    Block b6 = proposer.proposeBlock(Lists.newArrayList(new byte[][] {}));
    b1.setCurrentBlockHash(Crypto.resolveAsHashDigest(Base58Utils.decode("b1")));
    proposer.commitCallBack(b1, true);
    b2.setCurrentBlockHash(Crypto.resolveAsHashDigest(Base58Utils.decode("b2")));
    proposer.commitCallBack(b2, true);
    b3.setCurrentBlockHash(Crypto.resolveAsHashDigest(Base58Utils.decode("b3")));
    proposer.commitCallBack(b3, false);
    b4.setCurrentBlockHash(Crypto.resolveAsHashDigest(Base58Utils.decode("b4")));
    proposer.commitCallBack(b4, true);
    b5.setCurrentBlockHash(Crypto.resolveAsHashDigest(Base58Utils.decode("b5")));
    proposer.commitCallBack(b5, false);
    b6.setCurrentBlockHash(Crypto.resolveAsHashDigest(Base58Utils.decode("b6")));
    proposer.commitCallBack(b6, true);
}
Also used : LedgerBlock(com.jd.blockchain.ledger.LedgerBlock) Block(com.jd.blockchain.consensus.raft.consensus.Block) Test(org.junit.Test)

Aggregations

Block (com.jd.blockchain.consensus.raft.consensus.Block)6 LedgerBlock (com.jd.blockchain.ledger.LedgerBlock)4 Status (com.alipay.sofa.jraft.Status)2 LoggerUtils (com.jd.blockchain.consensus.raft.util.LoggerUtils)2 TransactionState (com.jd.blockchain.ledger.TransactionState)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Logger (org.slf4j.Logger)2 LoggerFactory (org.slf4j.LoggerFactory)2 Closure (com.alipay.sofa.jraft.Closure)1 JRaftUtils (com.alipay.sofa.jraft.JRaftUtils)1 Configuration (com.alipay.sofa.jraft.conf.Configuration)1 PeerId (com.alipay.sofa.jraft.entity.PeerId)1 Task (com.alipay.sofa.jraft.entity.Task)1 RaftError (com.alipay.sofa.jraft.error.RaftError)1 com.alipay.sofa.jraft.util (com.alipay.sofa.jraft.util)1 Longs (com.google.common.primitives.Longs)1 BlockCommitCallback (com.jd.blockchain.consensus.raft.consensus.BlockCommitCallback)1 BlockCommittedException (com.jd.blockchain.consensus.raft.consensus.BlockCommittedException)1 BlockCommitter (com.jd.blockchain.consensus.raft.consensus.BlockCommitter)1