This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type chain struct { | |
support consensus.ConsenterSupport | |
sendChan chan *message | |
exitChan chan struct{} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Order accepts normal messages for ordering | |
func (ch *chain) Order(env *cb.Envelope, configSeq uint64) error { | |
select { | |
case ch.sendChan <- &message{ | |
configSeq: configSeq, | |
normalMsg: env, | |
}: | |
return nil | |
case <-ch.exitChan: | |
return fmt.Errorf("Exiting") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Chain defines a way to inject messages for ordering. | |
// Note, that in order to allow flexibility in the implementation, it is the responsibility of the implementer | |
// to take the ordered messages, send them through the blockcutter.Receiver supplied via HandleChain to cut blocks, | |
// and ultimately write the ledger also supplied via HandleChain. This design allows for two primary flows | |
// 1. Messages are ordered into a stream, the stream is cut into blocks, the blocks are committed (solo, kafka) | |
// 2. Messages are cut into blocks, the blocks are ordered, then the blocks are committed (sbft) | |
type Chain interface { | |
// Order accepts a message which has been processed at a given configSeq. | |
// If the configSeq advances, it is the responsibility of the consenter | |
// to revalidate and potentially discard the message |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void IncrementExtraNonce(CBlock* pblock, const CBlockIndex* pindexPrev, unsigned int& nExtraNonce) | |
{ | |
// Update nExtraNonce | |
static uint256 hashPrevBlock; | |
if (hashPrevBlock != pblock->hashPrevBlock) | |
{ | |
nExtraNonce = 0; | |
hashPrevBlock = pblock->hashPrevBlock; | |
} | |
++nExtraNonce; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CBlockHeader | |
{ | |
public: | |
// header | |
int32_t nVersion; | |
uint256 hashPrevBlock; | |
uint256 hashMerkleRoot; | |
uint32_t nTime; | |
uint32_t nBits; | |
uint32_t nNonce; |