示例#1
0
// Loop through the Process List items and get the touched chains
// Put End-Of-Minute marker in the entry chains
func buildEndOfMinute(pl *consensus.ProcessList, pli *consensus.ProcessListItem) {
	tmpChains := make(map[string]*common.EChain)
	for _, v := range pl.GetPLItems()[:pli.Ack.Index] {
		if v.Ack.Type == wire.ACK_REVEAL_ENTRY ||
			v.Ack.Type == wire.ACK_REVEAL_CHAIN {
			cid := v.Msg.(*wire.MsgRevealEntry).Entry.ChainID.String()
			tmpChains[cid] = chainIDMap[cid]
		} else if wire.END_MINUTE_1 <= v.Ack.Type &&
			v.Ack.Type <= wire.END_MINUTE_10 {
			tmpChains = make(map[string]*common.EChain)
		}
	}
	for _, v := range tmpChains {
		v.NextBlock.AddEndOfMinuteMarker(pli.Ack.Type)
	}

	// Add it to the entry credit chain
	cbEntry := common.NewMinuteNumber()
	cbEntry.Number = pli.Ack.Type
	ecchain.NextBlock.AddEntry(cbEntry)

	// Add it to the admin chain
	abEntries := achain.NextBlock.ABEntries
	if len(abEntries) > 0 && abEntries[len(abEntries)-1].Type() != common.TYPE_MINUTE_NUM {
		achain.NextBlock.AddEndOfMinuteMarker(pli.Ack.Type)
	}
}
示例#2
0
// build blocks from a process lists
func buildFromProcessList(pl *consensus.ProcessList) error {
	for _, pli := range pl.GetPLItems() {
		if pli.Ack.Type == wire.ACK_COMMIT_CHAIN {
			buildCommitChain(pli.Msg.(*wire.MsgCommitChain))
		} else if pli.Ack.Type == wire.ACK_FACTOID_TX {
			buildIncreaseBalance(pli.Msg.(*wire.MsgFactoidTX))
		} else if pli.Ack.Type == wire.ACK_COMMIT_ENTRY {
			buildCommitEntry(pli.Msg.(*wire.MsgCommitEntry))
		} else if pli.Ack.Type == wire.ACK_REVEAL_CHAIN {
			buildRevealChain(pli.Msg.(*wire.MsgRevealEntry))
		} else if pli.Ack.Type == wire.ACK_REVEAL_ENTRY {
			buildRevealEntry(pli.Msg.(*wire.MsgRevealEntry))
		} else if wire.END_MINUTE_1 <= pli.Ack.Type && pli.Ack.Type <= wire.END_MINUTE_10 {
			buildEndOfMinute(pl, pli)
		}
	}

	return nil
}