work around rlp encoding/decoding issue for StakeMsg field type casting

pull/1848/head
chao 5 years ago
parent 6c32d569e7
commit 92d80a7fd4
  1. 7
      staking/types/transaction.go

@ -34,7 +34,12 @@ func (d *txdata) CopyFrom(d2 *txdata) {
d.Price = new(big.Int).Set(d2.Price) d.Price = new(big.Int).Set(d2.Price)
d.GasLimit = d2.GasLimit d.GasLimit = d2.GasLimit
// TODO: add code to protect crashing // TODO: add code to protect crashing
d.StakeMsg = d2.StakeMsg.(StakeMsg).Copy() // This is workaround, direct RLP encoding/decoding not work
payload, _ := rlp.EncodeToBytes(d2.StakeMsg)
restored, _ := RLPDecodeStakeMsg(
payload, d2.Directive,
)
d.StakeMsg = restored.(StakeMsg).Copy()
d.V = new(big.Int).Set(d2.V) d.V = new(big.Int).Set(d2.V)
d.R = new(big.Int).Set(d2.R) d.R = new(big.Int).Set(d2.R)
d.S = new(big.Int).Set(d2.S) d.S = new(big.Int).Set(d2.S)

Loading…
Cancel
Save