OSDN Git Service

Hulk did something
[bytom/vapor.git] / vendor / github.com / tendermint / go-crypto / privkeyinner_wrapper.go
1 // Generated by: main
2 // TypeWriter: wrapper
3 // Directive: +gen on PrivKeyInner
4
5 package crypto
6
7 import (
8         "github.com/tendermint/go-wire/data"
9 )
10
11 // Auto-generated adapters for happily unmarshaling interfaces
12 // Apache License 2.0
13 // Copyright (c) 2017 Ethan Frey (ethan.frey@tendermint.com)
14
15 type PrivKey struct {
16         PrivKeyInner "json:\"unwrap\""
17 }
18
19 var PrivKeyMapper = data.NewMapper(PrivKey{})
20
21 func (h PrivKey) MarshalJSON() ([]byte, error) {
22         return PrivKeyMapper.ToJSON(h.PrivKeyInner)
23 }
24
25 func (h *PrivKey) UnmarshalJSON(data []byte) (err error) {
26         parsed, err := PrivKeyMapper.FromJSON(data)
27         if err == nil && parsed != nil {
28                 h.PrivKeyInner = parsed.(PrivKeyInner)
29         }
30         return err
31 }
32
33 // Unwrap recovers the concrete interface safely (regardless of levels of embeds)
34 func (h PrivKey) Unwrap() PrivKeyInner {
35         hi := h.PrivKeyInner
36         for wrap, ok := hi.(PrivKey); ok; wrap, ok = hi.(PrivKey) {
37                 hi = wrap.PrivKeyInner
38         }
39         return hi
40 }
41
42 /*** below are bindings for each implementation ***/
43
44 func init() {
45         PrivKeyMapper.RegisterImplementation(PrivKeyEd25519{}, "ed25519", 0x1)
46 }
47
48 func (hi PrivKeyEd25519) Wrap() PrivKey {
49         return PrivKey{hi}
50 }