sentinel

package
v0.0.0-...-a41a74f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 8, 2024 License: MIT Imports: 40 Imported by: 0

Documentation

Index

Constants

View Source
const (
	QueryArkAuth  = "arkauth"
	QueryContract = "arkcontract"
	ServiceHeader = "arkservice"
)
View Source
const (
	RoutesMetaData       = "/metadata.json"
	RoutesActiveContract = "/active-contract/{service}/{spender}"
	RoutesClaim          = "/claim/{id}"
	RoutesOpenClaims     = "/open-claims"
	RouteManage          = "/manage/contract/{id}"
)

Variables

View Source
var ModuleBasics = module.NewBasicManager()
View Source
var Version = "0.0.0"

Functions

func GenerateArkAuthString

func GenerateArkAuthString(contractId uint64, nonce int64, signature []byte) string

func GenerateMessageToSign

func GenerateMessageToSign(contractId uint64, nonce int64) string

Types

type ArkAuth

type ArkAuth struct {
	ContractId uint64
	Spender    common.PubKey
	Nonce      int64
	Signature  []byte
}

func (ArkAuth) String

func (aa ArkAuth) String() string

String implement fmt.Stringer

func (ArkAuth) Validate

func (aa ArkAuth) Validate(provider common.PubKey) error

type CORs

type CORs struct {
	AllowOrigins []string `json:"allow_origins"`
	AllowMethods []string `json:"allow_methods"`
	AllowHeaders []string `json:"allow_headers"`
}

func NewCORs

func NewCORs() CORs

type Claim

type Claim struct {
	Provider   common.PubKey `json:"provider"`
	ContractId uint64        `json:"contract_id"`
	Spender    common.PubKey `json:"spender"`
	Nonce      int64         `json:"nonce"`
	Signature  string        `json:"signature"`
	Claimed    bool          `json:"claimed"`
}

func NewClaim

func NewClaim(contractId uint64, spender common.PubKey, nonce int64, signature string) Claim

func (Claim) Key

func (c Claim) Key() string

type ClaimContractIncome

type ClaimContractIncome struct {
	Contract types.Contract
	Paid     cosmos.Int
	Reserve  cosmos.Int
}

type ClaimStore

type ClaimStore struct {
	// contains filtered or unexported fields
}

func NewClaimStore

func NewClaimStore(levelDbFolder string) (*ClaimStore, error)

func (*ClaimStore) Batch

func (s *ClaimStore) Batch(items []Claim) error

func (*ClaimStore) Close

func (s *ClaimStore) Close() error

Close underlying db

func (*ClaimStore) Get

func (s *ClaimStore) Get(key string) (item Claim, err error)

func (*ClaimStore) GetInternalDb

func (s *ClaimStore) GetInternalDb() *leveldb.DB

func (*ClaimStore) Has

func (s *ClaimStore) Has(key string) (ok bool)

Has check whether the given key exist in key value store

func (*ClaimStore) List

func (s *ClaimStore) List() []Claim

List send back tx out to retry depending on arg failed only

func (*ClaimStore) Remove

func (s *ClaimStore) Remove(key string) error

Remove remove the given item from key values store

func (*ClaimStore) Set

func (s *ClaimStore) Set(item Claim) error

type CloseContract

type CloseContract struct {
	Contract types.Contract
}

type ContractAuth

type ContractAuth struct {
	ContractId uint64
	Timestamp  int64
	Signature  []byte
}

func (ContractAuth) String

func (auth ContractAuth) String() string

func (ContractAuth) Validate

func (auth ContractAuth) Validate(lastTimestamp int64, client common.PubKey) error

type ContractConfiguration

type ContractConfiguration struct {
	ContractId           uint64   `json:"contract_id"`
	LastTimeStamp        int64    `json:"last_timestamp"`
	PerUserRateLimit     int      `json:"per_user_rate_limit"`
	CORs                 CORs     `json:"cors"`
	WhitelistIPAddresses []string `json:"white_listed_ip_addresses"`
}

func NewContractConfiguration

func NewContractConfiguration(contractId uint64, cors CORs, ips []string, rateLimit int) ContractConfiguration

func (ContractConfiguration) Key

func (c ContractConfiguration) Key() string

type ContractConfigurationStore

type ContractConfigurationStore struct {
	// contains filtered or unexported fields
}

func NewContractConfigurationStore

func NewContractConfigurationStore(levelDbFolder string) (*ContractConfigurationStore, error)

func (*ContractConfigurationStore) Batch

func (*ContractConfigurationStore) Close

func (s *ContractConfigurationStore) Close() error

Close underlying db

func (*ContractConfigurationStore) Get

func (*ContractConfigurationStore) GetInternalDb

func (s *ContractConfigurationStore) GetInternalDb() *leveldb.DB

func (*ContractConfigurationStore) Has

func (s *ContractConfigurationStore) Has(id uint64) (ok bool)

Has check whether the given key exist in key value store

func (*ContractConfigurationStore) List

List send back tx out to retry depending on arg failed only

func (*ContractConfigurationStore) Remove

func (s *ContractConfigurationStore) Remove(id uint64) error

Remove remove the given item from key values store

func (*ContractConfigurationStore) Set

type ContractConfigurations

type ContractConfigurations []ContractConfiguration

type MemStore

type MemStore struct {
	// contains filtered or unexported fields
}

TODO: this should receive events from arceo chain to update its database TODO: clean up contracts from memory after they expire

func NewMemStore

func NewMemStore(baseURL string, logger log.Logger) *MemStore

func (*MemStore) Get

func (k *MemStore) Get(key string) (types.Contract, error)

func (*MemStore) GetActiveContract

func (k *MemStore) GetActiveContract(provider common.PubKey, service common.Service, spender common.PubKey) (types.Contract, error)

func (*MemStore) GetHeight

func (k *MemStore) GetHeight() int64

func (*MemStore) Key

func (k *MemStore) Key(pubkey, service, spender string) string

func (*MemStore) Put

func (k *MemStore) Put(contract types.Contract)

func (*MemStore) SetHeight

func (k *MemStore) SetHeight(height int64)

type Metadata

type Metadata struct {
	Configuration conf.Configuration `json:"config"`
	Version       string             `json:"version"`
}

func NewMetadata

func NewMetadata(config conf.Configuration) Metadata

type ProviderBondEvent

type ProviderBondEvent struct {
	PubKey       common.PubKey
	Service      common.Service
	BondRelative cosmos.Int
	BondAbsolute cosmos.Int
}

type ProviderModEvent

type ProviderModEvent struct {
	Provider types.Provider
}

type Proxy

type Proxy struct {
	Metadata            Metadata
	Config              conf.Configuration
	MemStore            *MemStore
	ClaimStore          *ClaimStore
	ContractConfigStore *ContractConfigurationStore
	// contains filtered or unexported fields
}

func NewProxy

func NewProxy(config conf.Configuration) Proxy

func (Proxy) EventListener

func (p Proxy) EventListener(host string)

func (Proxy) Run

func (p Proxy) Run()

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL