github.com/XinFinOrg/XDPoSChain@v1.6.0/XDCx/api.go (about)

     1  package XDCx
     2  
     3  import (
     4  	"context"
     5  	"errors"
     6  	"sync"
     7  	"time"
     8  )
     9  
    10  const (
    11  	LimitThresholdOrderNonceInQueue = 100
    12  )
    13  
    14  // List of errors
    15  var (
    16  	ErrNoTopics          = errors.New("missing topic(s)")
    17  	ErrOrderNonceTooLow  = errors.New("OrderNonce too low")
    18  	ErrOrderNonceTooHigh = errors.New("OrderNonce too high")
    19  )
    20  
    21  // PublicXDCXAPI provides the XDCX RPC service that can be
    22  // use publicly without security implications.
    23  type PublicXDCXAPI struct {
    24  	t        *XDCX
    25  	mu       sync.Mutex
    26  	lastUsed map[string]time.Time // keeps track when a filter was polled for the last time.
    27  
    28  }
    29  
    30  // NewPublicXDCXAPI create a new RPC XDCX service.
    31  func NewPublicXDCXAPI(t *XDCX) *PublicXDCXAPI {
    32  	api := &PublicXDCXAPI{
    33  		t:        t,
    34  		lastUsed: make(map[string]time.Time),
    35  	}
    36  	return api
    37  }
    38  
    39  // Version returns the XDCX sub-protocol version.
    40  func (api *PublicXDCXAPI) Version(ctx context.Context) string {
    41  	return ProtocolVersionStr
    42  }