-
Notifications
You must be signed in to change notification settings - Fork 6
/
nat.go
56 lines (47 loc) · 1019 Bytes
/
nat.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package ast
import "github.com/dipdup-net/go-lib/tools/consts"
//
// NAT
//
// Nat -
type Nat struct {
Default
}
// NewNat -
func NewNat(depth int) *Nat {
return &Nat{
Default: NewDefault(consts.NAT, 0, depth),
}
}
// ToJSONSchema -
func (n *Nat) ToJSONSchema() (*JSONSchema, error) {
return getIntJSONSchema(n.Default), nil
}
// Compare -
func (n *Nat) Compare(second Comparable) (int, error) {
secondItem, ok := second.(*Nat)
if !ok {
return 0, consts.ErrTypeIsNotComparable
}
return compareBigInt(n.Default, secondItem.Default), nil
}
// Distinguish -
func (n *Nat) Distinguish(x Distinguishable) (*MiguelNode, error) {
second, ok := x.(*Nat)
if !ok {
return nil, nil
}
return n.Default.Distinguish(&second.Default)
}
// FromJSONSchema -
func (n *Nat) FromJSONSchema(data map[string]interface{}) error {
setIntJSONSchema(&n.Default, data)
return nil
}
// FindByName -
func (n *Nat) FindByName(name string, isEntrypoint bool) Node {
if n.GetName() == name {
return n
}
return nil
}