-
Notifications
You must be signed in to change notification settings - Fork 0
/
api.go
59 lines (49 loc) · 1.48 KB
/
api.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
57
58
59
package tomox
import (
"context"
"errors"
"github.com/tomochain/tomochain/tomox/tomox_state"
"math/big"
"sync"
"time"
"github.com/tomochain/tomochain/common"
)
const (
LimitThresholdOrderNonceInQueue = 100
)
// List of errors
var (
ErrNoTopics = errors.New("missing topic(s)")
ErrOrderNonceTooLow = errors.New("OrderNonce too low")
ErrOrderNonceTooHigh = errors.New("OrderNonce too high")
)
// PublicTomoXAPI provides the tomoX RPC service that can be
// use publicly without security implications.
type PublicTomoXAPI struct {
t *TomoX
mu sync.Mutex
lastUsed map[string]time.Time // keeps track when a filter was polled for the last time.
}
// NewPublicTomoXAPI create a new RPC tomoX service.
func NewPublicTomoXAPI(t *TomoX) *PublicTomoXAPI {
api := &PublicTomoXAPI{
t: t,
lastUsed: make(map[string]time.Time),
}
return api
}
// Version returns the TomoX sub-protocol version.
func (api *PublicTomoXAPI) Version(ctx context.Context) string {
return ProtocolVersionStr
}
// GetOrderNonce returns the latest orderNonce of the given address
func (api *PublicTomoXAPI) GetOrderNonce(address common.Address) (*big.Int, error) {
//TODO: getOrderNonce from state
return big.NewInt(0), nil
}
// GetPendingOrders returns pending orders of the given pair
func (api *PublicTomoXAPI) GetPendingOrders(pairName string) ([]*tomox_state.OrderItem, error) {
result := []*tomox_state.OrderItem{}
//TODO: get pending orders from orderpool
return result, nil
}