• R/O
  • HTTP
  • SSH
  • HTTPS

vapor: Commit

Golang implemented sidechain for Bytom


Commit MetaInfo

Revisionddc244332d97bce5f6314fd62adccb885ca70aff (tree)
Time2019-06-20 17:48:58
Authorwz <mars@byto...>
CommiterPaladz

Log Message

Test crossin (#213)

* fix crossin

* fix review

Change Summary

Incremental Difference

--- a/blockchain/txbuilder/actions.go
+++ b/blockchain/txbuilder/actions.go
@@ -262,11 +262,11 @@ func DecodeCrossInAction(data []byte) (Action, error) {
262262
263263 type crossInAction struct {
264264 bc.AssetAmount
265- SourceID bc.Hash `json:"source_id"`
266- SourcePos uint64 `json:"source_pos"`
267- VMVersion uint64 `json:"vm_version"`
268- RawDefinitionByte []byte `json:"raw_definition_byte"`
269- IssuanceProgram []byte `json:"issuance_program"`
265+ SourceID bc.Hash `json:"source_id"`
266+ SourcePos uint64 `json:"source_pos"`
267+ VMVersion uint64 `json:"vm_version"`
268+ RawDefinitionByte json.HexBytes `json:"raw_definition_byte"`
269+ IssuanceProgram json.HexBytes `json:"issuance_program"`
270270 }
271271
272272 func (a *crossInAction) Build(ctx context.Context, builder *TemplateBuilder) error {
--- a/blockchain/txbuilder/finalize.go
+++ b/blockchain/txbuilder/finalize.go
@@ -39,8 +39,8 @@ func FinalizeTx(ctx context.Context, c *protocol.Chain, tx *types.Tx) error {
3939 return err
4040 }
4141
42- if len(tx.GasInputIDs) == 0 {
43- return ErrNoGasInput
42+ if err := checkGasInputIDs(tx); err != nil {
43+ return err
4444 }
4545
4646 // This part is use for prevent tx size is 0
@@ -151,3 +151,17 @@ func CalculateTxFee(tx *types.Tx) (fee uint64) {
151151 fee = totalInputBTM - totalOutputBTM
152152 return
153153 }
154+
155+func checkGasInputIDs(tx *types.Tx) error {
156+ for _, inp := range tx.Inputs {
157+ switch inp.InputType() {
158+ case types.CrossChainInputType:
159+ return nil
160+ }
161+ }
162+
163+ if len(tx.GasInputIDs) == 0 {
164+ return ErrNoGasInput
165+ }
166+ return nil
167+}
--- a/protocol/txpool.go
+++ b/protocol/txpool.go
@@ -194,10 +194,15 @@ func (tp *TxPool) HaveTransaction(txHash *bc.Hash) bool {
194194
195195 func isTransactionNoBtmInput(tx *types.Tx) bool {
196196 for _, input := range tx.TxData.Inputs {
197+ switch input.InputType() {
198+ case types.CrossChainInputType:
199+ return false
200+ }
197201 if input.AssetID() == *consensus.BTMAssetID {
198202 return false
199203 }
200204 }
205+
201206 return true
202207 }
203208
Show on old repository browser