Skip to content

Commit 791e34a

Browse files
Refactoring: remove unuseful files
1 parent 0be45ef commit 791e34a

File tree

4 files changed

+121
-166
lines changed

4 files changed

+121
-166
lines changed

node/chain_data.go

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
package node
22

3+
import (
4+
stdJSON "encoding/json"
5+
6+
"github.com/pkg/errors"
7+
)
8+
39
// InvalidBlock -
410
type InvalidBlock struct {
511
Hash string `json:"block"`
@@ -30,3 +36,103 @@ type Savepoint struct {
3036
Hash string `json:"block_hash"`
3137
Level uint64 `json:"level"`
3238
}
39+
40+
// MempoolResponse -
41+
type MempoolResponse struct {
42+
Applied []Applied `json:"applied"`
43+
Refused []Failed `json:"refused"`
44+
BranchRefused []Failed `json:"branch_refused"`
45+
BranchDelayed []Failed `json:"branch_delayed"`
46+
}
47+
48+
// Applied -
49+
type Applied struct {
50+
Hash string `json:"hash"`
51+
Branch string `json:"branch"`
52+
Signature string `json:"signature"`
53+
Contents []Content `json:"contents"`
54+
Raw stdJSON.RawMessage `json:"raw"`
55+
}
56+
57+
// UnmarshalJSON -
58+
func (a *Applied) UnmarshalJSON(data []byte) error {
59+
type buf Applied
60+
if err := json.Unmarshal(data, (*buf)(a)); err != nil {
61+
return err
62+
}
63+
a.Raw = data
64+
return nil
65+
}
66+
67+
// Failed -
68+
type Failed struct {
69+
Hash string `json:"-"`
70+
Protocol string `json:"protocol"`
71+
Branch string `json:"branch"`
72+
Contents []Content `json:"contents"`
73+
Signature string `json:"signature,omitempty"`
74+
Error stdJSON.RawMessage `json:"error,omitempty"`
75+
Raw stdJSON.RawMessage `json:"raw"`
76+
}
77+
78+
// UnmarshalJSON -
79+
func (f *Failed) UnmarshalJSON(data []byte) error {
80+
var body []stdJSON.RawMessage
81+
if err := json.Unmarshal(data, &body); err != nil {
82+
return err
83+
}
84+
if len(body) != 2 {
85+
return errors.Errorf("Invalid failed operation body %s", string(data))
86+
}
87+
if err := json.Unmarshal(body[0], &f.Hash); err != nil {
88+
return err
89+
}
90+
type buf Failed
91+
if err := json.Unmarshal(body[1], (*buf)(f)); err != nil {
92+
return err
93+
}
94+
f.Raw = data
95+
return nil
96+
}
97+
98+
// FailedMonitor -
99+
type FailedMonitor struct {
100+
Hash string `json:"hash"`
101+
Protocol string `json:"protocol"`
102+
Branch string `json:"branch"`
103+
Contents []Content `json:"contents"`
104+
Signature string `json:"signature,omitempty"`
105+
Error stdJSON.RawMessage `json:"error,omitempty"`
106+
Raw stdJSON.RawMessage `json:"raw"`
107+
}
108+
109+
// UnmarshalJSON -
110+
func (f *FailedMonitor) UnmarshalJSON(data []byte) error {
111+
type buf FailedMonitor
112+
if err := json.Unmarshal(data, (*buf)(f)); err != nil {
113+
return err
114+
}
115+
f.Raw = data
116+
return nil
117+
}
118+
119+
// Contents -
120+
type Content struct {
121+
Kind string `json:"kind"`
122+
Body stdJSON.RawMessage `json:"-"`
123+
}
124+
125+
// UnmarshalJSON -
126+
func (c *Content) UnmarshalJSON(data []byte) error {
127+
type buf Content
128+
if err := json.Unmarshal(data, (*buf)(c)); err != nil {
129+
return err
130+
}
131+
c.Body = data
132+
return nil
133+
}
134+
135+
// IsManager -
136+
func IsManager(kind string) bool {
137+
return kind == KindDelegation || kind == KindOrigination || kind == KindReveal || kind == KindTransaction
138+
}

node/data.go

Lines changed: 0 additions & 166 deletions
This file was deleted.

node/errors.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@ package node
22

33
import (
44
"fmt"
5+
6+
"github.com/pkg/errors"
7+
)
8+
9+
// Errors
10+
var (
11+
ErrUnknownKind = errors.New("unknown operation kind")
512
)
613

714
// RequestError -

node/inject_data.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package node
2+
3+
// InjectOperationRequest -
4+
type InjectOperationRequest struct {
5+
Operation string
6+
ChainID string
7+
Async bool
8+
}

0 commit comments

Comments
 (0)