OSDN Git Service

Hulk did something
[bytom/vapor.git] / vendor / github.com / tendermint / go-crypto / privkeyinner_wrapper.go
diff --git a/vendor/github.com/tendermint/go-crypto/privkeyinner_wrapper.go b/vendor/github.com/tendermint/go-crypto/privkeyinner_wrapper.go
new file mode 100644 (file)
index 0000000..78b1754
--- /dev/null
@@ -0,0 +1,50 @@
+// Generated by: main
+// TypeWriter: wrapper
+// Directive: +gen on PrivKeyInner
+
+package crypto
+
+import (
+       "github.com/tendermint/go-wire/data"
+)
+
+// Auto-generated adapters for happily unmarshaling interfaces
+// Apache License 2.0
+// Copyright (c) 2017 Ethan Frey (ethan.frey@tendermint.com)
+
+type PrivKey struct {
+       PrivKeyInner "json:\"unwrap\""
+}
+
+var PrivKeyMapper = data.NewMapper(PrivKey{})
+
+func (h PrivKey) MarshalJSON() ([]byte, error) {
+       return PrivKeyMapper.ToJSON(h.PrivKeyInner)
+}
+
+func (h *PrivKey) UnmarshalJSON(data []byte) (err error) {
+       parsed, err := PrivKeyMapper.FromJSON(data)
+       if err == nil && parsed != nil {
+               h.PrivKeyInner = parsed.(PrivKeyInner)
+       }
+       return err
+}
+
+// Unwrap recovers the concrete interface safely (regardless of levels of embeds)
+func (h PrivKey) Unwrap() PrivKeyInner {
+       hi := h.PrivKeyInner
+       for wrap, ok := hi.(PrivKey); ok; wrap, ok = hi.(PrivKey) {
+               hi = wrap.PrivKeyInner
+       }
+       return hi
+}
+
+/*** below are bindings for each implementation ***/
+
+func init() {
+       PrivKeyMapper.RegisterImplementation(PrivKeyEd25519{}, "ed25519", 0x1)
+}
+
+func (hi PrivKeyEd25519) Wrap() PrivKey {
+       return PrivKey{hi}
+}