func (fs *FactoidState) UpdateECTransaction(rt bool, trans interfaces.IECBlockEntry) error { switch trans.ECID() { case entryCreditBlock.ECIDServerIndexNumber: return nil case entryCreditBlock.ECIDMinuteNumber: return nil case entryCreditBlock.ECIDChainCommit: t := trans.(*entryCreditBlock.CommitChain) fs.State.PutE(rt, t.ECPubKey.Fixed(), fs.State.GetE(rt, t.ECPubKey.Fixed())-int64(t.Credits)) fs.State.NumTransactions++ fs.State.Replay.IsTSValid(constants.INTERNAL_REPLAY, t.GetSigHash(), t.GetTimestamp()) fs.State.Replay.IsTSValid(constants.NETWORK_REPLAY, t.GetSigHash(), t.GetTimestamp()) case entryCreditBlock.ECIDEntryCommit: t := trans.(*entryCreditBlock.CommitEntry) fs.State.PutE(rt, t.ECPubKey.Fixed(), fs.State.GetE(rt, t.ECPubKey.Fixed())-int64(t.Credits)) fs.State.NumTransactions++ fs.State.Replay.IsTSValid(constants.INTERNAL_REPLAY, t.GetSigHash(), t.GetTimestamp()) fs.State.Replay.IsTSValid(constants.NETWORK_REPLAY, t.GetSigHash(), t.GetTimestamp()) case entryCreditBlock.ECIDBalanceIncrease: t := trans.(*entryCreditBlock.IncreaseBalance) fs.State.PutE(rt, t.ECPubKey.Fixed(), fs.State.GetE(rt, t.ECPubKey.Fixed())+int64(t.NumEC)) fs.State.NumTransactions++ default: return fmt.Errorf("Unknown EC Transaction") } return nil }
func (fs *FactoidState) UpdateECTransaction(trans interfaces.IECBlockEntry) error { var vm ValidationMsg vm.MessageType = MessageTypeUpdateTransaction vm.ECTransaction = trans c := make(chan ValidationResponseMsg) vm.ReturnChannel = c switch trans.ECID() { case entryCreditBlock.ECIDServerIndexNumber: return nil case entryCreditBlock.ECIDMinuteNumber: return nil case entryCreditBlock.ECIDChainCommit: fs.ValidationService <- vm resp := <-c return resp.Error case entryCreditBlock.ECIDEntryCommit: fs.ValidationService <- vm resp := <-c return resp.Error case entryCreditBlock.ECIDBalanceIncrease: fs.ValidationService <- vm resp := <-c return resp.Error default: return fmt.Errorf("Unknown EC Transaction") } return nil }