2020-12-02 21:18:47 +00:00
|
|
|
package filecoin
|
|
|
|
|
|
|
|
import (
|
2021-06-11 11:40:32 +00:00
|
|
|
"github.com/Secured-Finance/dione/types"
|
2020-12-02 21:18:47 +00:00
|
|
|
|
|
|
|
"github.com/Secured-Finance/dione/consensus/validation"
|
|
|
|
rtypes "github.com/Secured-Finance/dione/rpc/types"
|
|
|
|
)
|
|
|
|
|
2021-06-11 11:40:32 +00:00
|
|
|
func ValidateGetTransaction(task *types.DioneTask) error {
|
|
|
|
//var msg ftypes.SignedMessage
|
|
|
|
//if err := msg.UnmarshalCBOR(bytes.NewReader(payload)); err != nil {
|
|
|
|
// if err := msg.Message.UnmarshalCBOR(bytes.NewReader(payload)); err != nil {
|
|
|
|
// return xerrors.Errorf("cannot unmarshal payload: %s", err.Error())
|
|
|
|
// }
|
|
|
|
//}
|
|
|
|
//
|
|
|
|
//if msg.Type == ftypes.MessageTypeSecp256k1 {
|
|
|
|
// if err := sigs.Verify(&msg.Signature, msg.Message.From.Bytes(), msg.Message.Cid().Bytes()); err != nil {
|
|
|
|
// logrus.Errorf("Couldn't verify transaction %v", err)
|
|
|
|
// return xerrors.Errorf("Couldn't verify transaction: %v")
|
|
|
|
// }
|
|
|
|
// return nil
|
|
|
|
//} else {
|
|
|
|
// // TODO: BLS Signature verification
|
|
|
|
// return nil
|
|
|
|
//}
|
|
|
|
return validation.VerifyExactMatching(task)
|
2020-12-02 21:18:47 +00:00
|
|
|
}
|
|
|
|
|
2021-07-28 21:47:09 +00:00
|
|
|
func ValidateGetBlock(task *types.DioneTask) error {
|
|
|
|
return validation.VerifyExactMatching(task)
|
|
|
|
}
|
|
|
|
|
2020-12-02 21:18:47 +00:00
|
|
|
func init() {
|
2021-06-11 11:40:32 +00:00
|
|
|
validation.RegisterValidation(rtypes.RPCTypeFilecoin, map[string]func(*types.DioneTask) error{
|
2020-12-02 21:18:47 +00:00
|
|
|
"getTransaction": ValidateGetTransaction,
|
2021-07-28 21:47:09 +00:00
|
|
|
"getBlock": ValidateGetBlock,
|
2020-12-02 21:18:47 +00:00
|
|
|
})
|
|
|
|
}
|