server

package
v0.0.0-...-fae8f5a Latest Latest
Warning

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

Go to latest
Published: May 22, 2023 License: AGPL-3.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrorMethodNotAllowed is returned when client tries to upgrade method other than GET
	ErrorMethodNotAllowed = errors.New("Method not allowed")
)

Functions

This section is empty.

Types

type InternalServer

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

InternalServer is handle to internal http server

func NewInternalServer

func NewInternalServer(binding, certFiles string, db *db.RocksDB, chain bchain.BlockChain, mempool bchain.Mempool, txCache *db.TxCache, metrics *common.Metrics, is *common.InternalState, fiatRates *fiat.FiatRates) (*InternalServer, error)

NewInternalServer creates new internal http interface to blockbook and returns its handle

func (*InternalServer) Close

func (s *InternalServer) Close() error

Close closes the server

func (*InternalServer) Run

func (s *InternalServer) Run() error

Run starts the server

func (*InternalServer) Shutdown

func (s *InternalServer) Shutdown(ctx context.Context) error

Shutdown shuts down the server

type InternalTemplateData

type InternalTemplateData struct {
	CoinName               string
	CoinShortcut           string
	CoinLabel              string
	ChainType              bchain.ChainType
	Error                  *api.APIError
	InternalDataErrors     []db.BlockInternalDataError
	RefetchingInternalData bool
}

InternalTemplateData is used to transfer data to the templates

type PublicServer

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

PublicServer provides public http server functionality

func NewPublicServer

func NewPublicServer(binding string, certFiles string, db *db.RocksDB, chain bchain.BlockChain, mempool bchain.Mempool, txCache *db.TxCache, explorerURL string, metrics *common.Metrics, is *common.InternalState, fiatRates *fiat.FiatRates, debugMode bool) (*PublicServer, error)

NewPublicServer creates new public server http interface to blockbook and returns its handle only basic functionality is mapped, to map all functions, call

func (*PublicServer) Close

func (s *PublicServer) Close() error

Close closes the server

func (*PublicServer) ConnectFullPublicInterface

func (s *PublicServer) ConnectFullPublicInterface()

ConnectFullPublicInterface enables complete public functionality

func (*PublicServer) OnNewBlock

func (s *PublicServer) OnNewBlock(hash string, height uint32)

OnNewBlock notifies users subscribed to bitcoind/hashblock about new block

func (*PublicServer) OnNewFiatRatesTicker

func (s *PublicServer) OnNewFiatRatesTicker(ticker *common.CurrencyRatesTicker)

OnNewFiatRatesTicker notifies users subscribed to bitcoind/fiatrates about new ticker

func (*PublicServer) OnNewTx

func (s *PublicServer) OnNewTx(tx *bchain.MempoolTx)

OnNewTx notifies users subscribed to notification about new tx

func (*PublicServer) OnNewTxAddr

func (s *PublicServer) OnNewTxAddr(tx *bchain.Tx, desc bchain.AddressDescriptor)

OnNewTxAddr notifies users subscribed to notification about new tx

func (*PublicServer) Run

func (s *PublicServer) Run() error

Run starts the server

func (*PublicServer) Shutdown

func (s *PublicServer) Shutdown(ctx context.Context) error

Shutdown shuts down the server

type SocketIoServer

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

SocketIoServer is handle to SocketIoServer

func NewSocketIoServer

func NewSocketIoServer(db *db.RocksDB, chain bchain.BlockChain, mempool bchain.Mempool, txCache *db.TxCache, metrics *common.Metrics, is *common.InternalState, fiatRates *fiat.FiatRates) (*SocketIoServer, error)

NewSocketIoServer creates new SocketIo interface to blockbook and returns its handle

func (*SocketIoServer) GetHandler

func (s *SocketIoServer) GetHandler() http.Handler

GetHandler returns socket.io http handler

func (*SocketIoServer) OnNewBlockHash

func (s *SocketIoServer) OnNewBlockHash(hash string)

OnNewBlockHash notifies users subscribed to bitcoind/hashblock about new block

func (*SocketIoServer) OnNewTxAddr

func (s *SocketIoServer) OnNewTxAddr(txid string, desc bchain.AddressDescriptor)

OnNewTxAddr notifies users subscribed to bitcoind/addresstxid about new block

type TemplateData

type TemplateData struct {
	CoinName                 string
	CoinShortcut             string
	CoinLabel                string
	InternalExplorer         bool
	ChainType                bchain.ChainType
	FungibleTokenName        bchain.TokenTypeName
	NonFungibleTokenName     bchain.TokenTypeName
	MultiTokenName           bchain.TokenTypeName
	Address                  *api.Address
	AddrStr                  string
	Tx                       *api.Tx
	Error                    *api.APIError
	Blocks                   *api.Blocks
	Block                    *api.Block
	Info                     *api.SystemInfo
	MempoolTxids             *api.MempoolTxids
	Page                     int
	PrevPage                 int
	NextPage                 int
	PagingRange              []int
	PageParams               template.URL
	Minified                 string
	TOSLink                  string
	SendTxHex                string
	Status                   string
	NonZeroBalanceTokens     bool
	TokenId                  string
	URI                      string
	ContractInfo             *bchain.ContractInfo
	SecondaryCoin            string
	UseSecondaryCoin         bool
	CurrentSecondaryCoinRate float64
	CurrentTicker            *common.CurrencyRatesTicker
	SecondaryCurrencies      []string
	TxDate                   string
	TxSecondaryCoinRate      float64
	TxTicker                 *common.CurrencyRatesTicker
}

TemplateData is used to transfer data to the templates

type WebsocketServer

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

WebsocketServer is a handle to websocket server

func NewWebsocketServer

func NewWebsocketServer(db *db.RocksDB, chain bchain.BlockChain, mempool bchain.Mempool, txCache *db.TxCache, metrics *common.Metrics, is *common.InternalState, fiatRates *fiat.FiatRates) (*WebsocketServer, error)

NewWebsocketServer creates new websocket interface to blockbook and returns its handle

func (*WebsocketServer) GetHandler

func (s *WebsocketServer) GetHandler() http.Handler

GetHandler returns http handler

func (*WebsocketServer) OnNewBlock

func (s *WebsocketServer) OnNewBlock(hash string, height uint32)

OnNewBlock is a callback that broadcasts info about new block to subscribed clients

func (*WebsocketServer) OnNewFiatRatesTicker

func (s *WebsocketServer) OnNewFiatRatesTicker(ticker *common.CurrencyRatesTicker)

OnNewFiatRatesTicker is a callback that broadcasts info about fiat rates affecting subscribed currency

func (*WebsocketServer) OnNewTx

func (s *WebsocketServer) OnNewTx(tx *bchain.MempoolTx)

OnNewTx is a callback that broadcasts info about a tx affecting subscribed address

func (*WebsocketServer) ServeHTTP

func (s *WebsocketServer) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP sets up handler of websocket channel

type WsAccountInfoReq

type WsAccountInfoReq struct {
	Descriptor        string `json:"descriptor"`
	Details           string `json:"details,omitempty" ts_type:"'basic' | 'tokens' | 'tokenBalances' | 'txids' | 'txslight' | 'txs'"`
	Tokens            string `json:"tokens,omitempty" ts_type:"'derived' | 'used' | 'nonzero'"`
	PageSize          int    `json:"pageSize,omitempty"`
	Page              int    `json:"page,omitempty"`
	FromHeight        int    `json:"from,omitempty"`
	ToHeight          int    `json:"to,omitempty"`
	ContractFilter    string `json:"contractFilter,omitempty"`
	SecondaryCurrency string `json:"secondaryCurrency,omitempty"`
	Gap               int    `json:"gap,omitempty"`
}

type WsAccountUtxoReq

type WsAccountUtxoReq struct {
	Descriptor string `json:"descriptor"`
}

type WsBackendInfo

type WsBackendInfo struct {
	Version          string      `json:"version,omitempty"`
	Subversion       string      `json:"subversion,omitempty"`
	ConsensusVersion string      `json:"consensus_version,omitempty"`
	Consensus        interface{} `json:"consensus,omitempty"`
}

type WsBalanceHistoryReq

type WsBalanceHistoryReq struct {
	Descriptor string   `json:"descriptor"`
	From       int64    `json:"from,omitempty"`
	To         int64    `json:"to,omitempty"`
	Currencies []string `json:"currencies,omitempty"`
	Gap        int      `json:"gap,omitempty"`
	GroupBy    uint32   `json:"groupBy,omitempty"`
}

type WsBlockHashReq

type WsBlockHashReq struct {
	Height int `json:"height"`
}

type WsBlockHashRes

type WsBlockHashRes struct {
	Hash string `json:"hash"`
}

type WsBlockReq

type WsBlockReq struct {
	Id       string `json:"id"`
	PageSize int    `json:"pageSize,omitempty"`
	Page     int    `json:"page,omitempty"`
}

type WsCurrentFiatRatesReq

type WsCurrentFiatRatesReq struct {
	Currencies []string `json:"currencies,omitempty"`
	Token      string   `json:"token,omitempty"`
}

type WsEstimateFeeReq

type WsEstimateFeeReq struct {
	Blocks   []int                  `json:"blocks,omitempty"`
	Specific map[string]interface{} `` /* 132-byte string literal not displayed */
}

type WsEstimateFeeRes

type WsEstimateFeeRes struct {
	FeePerTx   string `json:"feePerTx,omitempty"`
	FeePerUnit string `json:"feePerUnit,omitempty"`
	FeeLimit   string `json:"feeLimit,omitempty"`
}

type WsFiatRatesForTimestampsReq

type WsFiatRatesForTimestampsReq struct {
	Timestamps []int64  `json:"timestamps"`
	Currencies []string `json:"currencies,omitempty"`
	Token      string   `json:"token,omitempty"`
}

type WsFiatRatesTickersListReq

type WsFiatRatesTickersListReq struct {
	Timestamp int64  `json:"timestamp,omitempty"`
	Token     string `json:"token,omitempty"`
}

type WsInfoRes

type WsInfoRes struct {
	Name       string        `json:"name"`
	Shortcut   string        `json:"shortcut"`
	Decimals   int           `json:"decimals"`
	Version    string        `json:"version"`
	BestHeight int           `json:"bestHeight"`
	BestHash   string        `json:"bestHash"`
	Block0Hash string        `json:"block0Hash"`
	Testnet    bool          `json:"testnet"`
	Backend    WsBackendInfo `json:"backend"`
}

type WsMempoolFiltersReq

type WsMempoolFiltersReq struct {
	ScriptType    string `json:"scriptType"`
	FromTimestamp uint32 `json:"fromTimestamp"`
}

type WsReq

type WsReq struct {
	ID     string          `json:"id"`
	Method string          `` /* 517-byte string literal not displayed */
	Params json.RawMessage `json:"params" ts_type:"any"`
}

type WsRes

type WsRes struct {
	ID   string      `json:"id"`
	Data interface{} `json:"data"`
}

type WsSendTransactionReq

type WsSendTransactionReq struct {
	Hex string `json:"hex"`
}

type WsSubscribeAddressesReq

type WsSubscribeAddressesReq struct {
	Addresses []string `json:"addresses"`
}

type WsSubscribeFiatRatesReq

type WsSubscribeFiatRatesReq struct {
	Currency string   `json:"currency,omitempty"`
	Tokens   []string `json:"tokens,omitempty"`
}

type WsTransactionReq

type WsTransactionReq struct {
	Txid string `json:"txid"`
}

type WsTransactionSpecificReq

type WsTransactionSpecificReq struct {
	Txid string `json:"txid"`
}

Jump to

Keyboard shortcuts

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