Merge pull request #1848 from chaosma/fix-rlp-encoding

work around rlp encoding/decoding issue for StakeMsg field type casting
pull/1853/head
chaosma 5 years ago committed by GitHub
commit f10b5f7acc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  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