_id
stringlengths
2
7
title
stringlengths
1
118
partition
stringclasses
3 values
text
stringlengths
52
85.5k
language
stringclasses
1 value
meta_information
dict
q35800
NewIteratorLong
train
func NewIteratorLong(t0 uint32, b []byte) (*IterLong, error) { return bstreamIteratorLong(t0, newBReader(b)) }
go
{ "resource": "" }
q35801
Next
train
func (it *IterLong) Next() bool { if it.err != nil || it.finished { return false } var first bool if it.t == 0 { it.t = it.T0 first = true } // read delta-of-delta dod, ok := it.dod() if !ok { return false } it.tDelta += uint32(dod) it.t = it.t + it.tDelta if first { // first point. read the ...
go
{ "resource": "" }
q35802
tick
train
func tick(period time.Duration) chan time.Time { ch := make(chan time.Time) go func() { for { now := time.Now() nowUnix := now.UnixNano() diff := period - (time.Duration(nowUnix) % period) ideal := now.Add(diff) time.Sleep(diff) // try to write, if it blocks, skip the tick select { case ch ...
go
{ "resource": "" }
q35803
Trace
train
func (r Req) Trace(span opentracing.Span) { span.SetTag("key", r.MKey) span.SetTag("target", r.Target) span.SetTag("pattern", r.Pattern) span.SetTag("from", r.From) span.SetTag("to", r.To) span.SetTag("span", r.To-r.From-1) span.SetTag("mdp", r.MaxPoints) span.SetTag("rawInterval", r.RawInterval) span.SetTag("...
go
{ "resource": "" }
q35804
TraceLog
train
func (r Req) TraceLog(span opentracing.Span) { span.LogFields( log.Object("key", r.MKey), log.String("target", r.Target), log.String("pattern", r.Pattern), log.Int("from", int(r.From)), log.Int("to", int(r.To)), log.Int("span", int(r.To-r.From-1)), log.Int("mdp", int(r.MaxPoints)), log.Int("rawInterval...
go
{ "resource": "" }
q35805
NewAggregations
train
func NewAggregations() Aggregations { return Aggregations{ Data: make([]Aggregation, 0), DefaultAggregation: Aggregation{ Name: "default", Pattern: regexp.MustCompile(".*"), XFilesFactor: 0.5, AggregationMethod: []Method{Avg}, }, } }
go
{ "resource": "" }
q35806
ReadAggregations
train
func ReadAggregations(file string) (Aggregations, error) { config, err := configparser.Read(file) if err != nil { return Aggregations{}, err } sections, err := config.AllSections() if err != nil { return Aggregations{}, err } result := NewAggregations() for _, s := range sections { item := Aggregation{}...
go
{ "resource": "" }
q35807
Match
train
func (a Aggregations) Match(metric string) (uint16, Aggregation) { for i, s := range a.Data { if s.Pattern.MatchString(metric) { return uint16(i), s } } return uint16(len(a.Data)), a.DefaultAggregation }
go
{ "resource": "" }
q35808
Get
train
func (a Aggregations) Get(i uint16) Aggregation { if i+1 > uint16(len(a.Data)) { return a.DefaultAggregation } return a.Data[i] }
go
{ "resource": "" }
q35809
NewArchiveBare
train
func NewArchiveBare(name string) Archive { return Archive{ MetricDefinition: schema.MetricDefinition{ Name: name, }, } }
go
{ "resource": "" }
q35810
RequestStats
train
func RequestStats() macaron.Handler { stats := requestStats{ responseCounts: make(map[string]map[int]*stats.Counter32), latencyHistograms: make(map[string]*stats.LatencyHistogram15s32), sizeMeters: make(map[string]*stats.Meter32), } return func(ctx *macaron.Context) { start := time.Now() rw := c...
go
{ "resource": "" }
q35811
WrapErrorForTagDB
train
func WrapErrorForTagDB(e error) *ErrorResp { b, err := json.Marshal(TagDBError{Error: e.Error()}) if err != nil { return &ErrorResp{ err: "{\"error\": \"failed to encode error message\"}", code: http.StatusInternalServerError, } } resp := &ErrorResp{ err: string(b), code: http.StatusInternalServerE...
go
{ "resource": "" }
q35812
NewIdxConfig
train
func NewIdxConfig() *IdxConfig { return &IdxConfig{ Enabled: true, hosts: "localhost:9042", keyspace: "metrictank", consistency: "one", timeout: time.Second, numConns: 10, writeQueueSize: 100000, ...
go
{ "resource": "" }
q35813
Validate
train
func (cfg *IdxConfig) Validate() error { if cfg.pruneInterval == 0 { return errors.New("pruneInterval must be greater then 0. " + timeUnits) } if cfg.timeout == 0 { return errors.New("timeout must be greater than 0. " + timeUnits) } return nil }
go
{ "resource": "" }
q35814
NewAggMetric
train
func NewAggMetric(store Store, cachePusher cache.CachePusher, key schema.AMKey, retentions conf.Retentions, reorderWindow, interval uint32, agg *conf.Aggregation, dropFirstChunk bool) *AggMetric { // note: during parsing of retentions, we assure there's at least 1. ret := retentions[0] m := AggMetric{ cachePushe...
go
{ "resource": "" }
q35815
addAggregators
train
func (a *AggMetric) addAggregators(ts uint32, val float64) { for _, agg := range a.aggregators { log.Debugf("AM: %s pushing %d,%f to aggregator %d", a.key, ts, val, agg.span) agg.Add(ts, val) } }
go
{ "resource": "" }
q35816
pushToCache
train
func (a *AggMetric) pushToCache(c *chunk.Chunk) { if a.cachePusher == nil { return } // push into cache intervalHint := a.key.Archive.Span() itergen, err := chunk.NewIterGen(c.Series.T0, intervalHint, c.Encode(a.chunkSpan)) if err != nil { log.Errorf("AM: %s failed to generate IterGen. this should never happ...
go
{ "resource": "" }
q35817
Add
train
func (a *AggMetric) Add(ts uint32, val float64) { a.Lock() defer a.Unlock() if a.rob == nil { // write directly a.add(ts, val) } else { // write through reorder buffer res, err := a.rob.Add(ts, val) if err == nil { if len(res) == 0 { a.lastWrite = uint32(time.Now().Unix()) } else { for _, ...
go
{ "resource": "" }
q35818
GC
train
func (a *AggMetric) GC(now, chunkMinTs, metricMinTs uint32) (uint32, bool) { a.Lock() defer a.Unlock() // unless it looks like the AggMetric is collectable, abort and mark as not stale if !a.collectable(now, chunkMinTs) { return 0, false } // make sure any points in the reorderBuffer are moved into our chunks...
go
{ "resource": "" }
q35819
gcAggregators
train
func (a *AggMetric) gcAggregators(now, chunkMinTs, metricMinTs uint32) (uint32, bool) { var points uint32 stale := true for _, agg := range a.aggregators { p, s := agg.GC(now, chunkMinTs, metricMinTs, a.lastWrite) points += p stale = stale && s } return points, stale }
go
{ "resource": "" }
q35820
Purge
train
func (c *FindCache) Purge(orgId uint32) { c.RLock() cache, ok := c.cache[orgId] c.RUnlock() if !ok { return } cache.Purge() }
go
{ "resource": "" }
q35821
PurgeAll
train
func (c *FindCache) PurgeAll() { c.RLock() orgs := make([]uint32, len(c.cache)) i := 0 for k := range c.cache { orgs[i] = k i++ } c.RUnlock() for _, org := range orgs { c.Purge(org) } }
go
{ "resource": "" }
q35822
InvalidateFor
train
func (c *FindCache) InvalidateFor(orgId uint32, path string) { c.Lock() findCacheInvalidationsReceived.Inc() defer c.Unlock() if c.backoff { findCacheInvalidationsDropped.Inc() return } cache, ok := c.cache[orgId] if !ok || cache.Len() < 1 { findCacheInvalidationsDropped.Inc() return } req := invalid...
go
{ "resource": "" }
q35823
triggerBackoff
train
func (c *FindCache) triggerBackoff() { log.Infof("memory-idx: findCache invalidate-queue full. Disabling cache for %s", c.backoffTime.String()) findCacheBackoff.Inc() c.backoff = true time.AfterFunc(c.backoffTime, func() { findCacheBackoff.Dec() c.Lock() c.backoff = false c.Unlock() }) c.cache = make(map[...
go
{ "resource": "" }
q35824
PurgeFindCache
train
func (p *PartitionedMemoryIdx) PurgeFindCache() { for _, m := range p.Partition { if m.findCache != nil { m.findCache.PurgeAll() } } }
go
{ "resource": "" }
q35825
ForceInvalidationFindCache
train
func (p *PartitionedMemoryIdx) ForceInvalidationFindCache() { for _, m := range p.Partition { if m.findCache != nil { m.findCache.forceInvalidation() } } }
go
{ "resource": "" }
q35826
getTables
train
func getTables(store *cassandra.CassandraStore, match string) ([]cassandra.Table, error) { var tables []cassandra.Table if match == "*" || match == "" { for _, table := range store.TTLTables { if table.Name == "metric_idx" || !strings.HasPrefix(table.Name, "metric_") { continue } tables = append(tables...
go
{ "resource": "" }
q35827
printTables
train
func printTables(store *cassandra.CassandraStore) { tables, err := getTables(store, "") if err != nil { log.Fatal(err.Error()) } for _, table := range tables { fmt.Printf("%s (%d hours <= ttl < %d hours)\n", table.Name, table.TTL, table.TTL*2) } }
go
{ "resource": "" }
q35828
Querier
train
func (s *Server) Querier(ctx context.Context, min, max int64) (storage.Querier, error) { from := uint32(min / 1000) to := uint32(max / 1000) return NewQuerier(ctx, s, from, to, ctx.Value(orgID("org-id")).(uint32), false), nil }
go
{ "resource": "" }
q35829
Select
train
func (q *querier) Select(matchers ...*labels.Matcher) (storage.SeriesSet, error) { minFrom := uint32(math.MaxUint32) var maxTo uint32 var target string var reqs []models.Req expressions := []string{} for _, matcher := range matchers { if matcher.Name == model.MetricNameLabel { matcher.Name = "name" } if...
go
{ "resource": "" }
q35830
LabelValues
train
func (q *querier) LabelValues(name string) ([]string, error) { expressions := []string{"name=~[a-zA-Z_][a-zA-Z0-9_]*$"} if name == model.MetricNameLabel { name = "name" expressions = append(expressions, "name=~[a-zA-Z_:][a-zA-Z0-9_:]*$") } return q.MetricIndex.FindTagValues(q.OrgID, name, "", expressions, 0, 10...
go
{ "resource": "" }
q35831
closestAggMethod
train
func closestAggMethod(requested consolidation.Consolidator, available []conf.Method) consolidation.Consolidator { // if there is only 1 consolidation method available, then that is all we can return. if len(available) == 1 { return consolidation.Consolidator(available[0]) } avail := map[consolidation.Consolidato...
go
{ "resource": "" }
q35832
newMockBlockHeaderStore
train
func newMockBlockHeaderStore() headerfs.BlockHeaderStore { return &mockBlockHeaderStore{ headers: make(map[chainhash.Hash]wire.BlockHeader), } }
go
{ "resource": "" }
q35833
Size
train
func (c *CacheableBlock) Size() (uint64, error) { return uint64(c.Block.MsgBlock().SerializeSize()), nil }
go
{ "resource": "" }
q35834
newHeaderIndex
train
func newHeaderIndex(db walletdb.DB, indexType HeaderType) (*headerIndex, error) { // As an initially step, we'll attempt to create all the buckets // necessary for functioning of the index. If these buckets has already // been created, then we can exit early. err := walletdb.Update(db, func(tx walletdb.ReadWriteTx)...
go
{ "resource": "" }
q35835
addHeaders
train
func (h *headerIndex) addHeaders(batch headerBatch) error { // If we're writing a 0-length batch, make no changes and return. if len(batch) == 0 { return nil } // In order to ensure optimal write performance, we'll ensure that the // items are sorted by their hash before insertion into the database. sort.Sort(...
go
{ "resource": "" }
q35836
heightFromHash
train
func (h *headerIndex) heightFromHash(hash *chainhash.Hash) (uint32, error) { var height uint32 err := walletdb.View(h.db, func(tx walletdb.ReadTx) error { rootBucket := tx.ReadBucket(indexBucket) heightBytes := rootBucket.Get(hash[:]) if heightBytes == nil { // If the hash wasn't found, then we don't know o...
go
{ "resource": "" }
q35837
chainTip
train
func (h *headerIndex) chainTip() (*chainhash.Hash, uint32, error) { var ( tipHeight uint32 tipHash *chainhash.Hash ) err := walletdb.View(h.db, func(tx walletdb.ReadTx) error { rootBucket := tx.ReadBucket(indexBucket) var tipKey []byte // Based on the specified index type of this instance of the // ...
go
{ "resource": "" }
q35838
truncateIndex
train
func (h *headerIndex) truncateIndex(newTip *chainhash.Hash, delete bool) error { return walletdb.Update(h.db, func(tx walletdb.ReadWriteTx) error { rootBucket := tx.ReadWriteBucket(indexBucket) var tipKey []byte // Based on the specified index type of this instance of the // index, we'll grab the key that tr...
go
{ "resource": "" }
q35839
newBatchSpendReporter
train
func newBatchSpendReporter() *batchSpendReporter { return &batchSpendReporter{ requests: make(map[wire.OutPoint][]*GetUtxoRequest), initialTxns: make(map[wire.OutPoint]*SpendReport), outpoints: make(map[wire.OutPoint][]byte), } }
go
{ "resource": "" }
q35840
NotifyUnspentAndUnfound
train
func (b *batchSpendReporter) NotifyUnspentAndUnfound() { log.Debugf("Finished batch, %d unspent outpoints", len(b.requests)) for outpoint, requests := range b.requests { // A nil SpendReport indicates the output was not found. tx, ok := b.initialTxns[outpoint] if !ok { log.Warnf("Unknown initial txn for get...
go
{ "resource": "" }
q35841
ProcessBlock
train
func (b *batchSpendReporter) ProcessBlock(blk *wire.MsgBlock, newReqs []*GetUtxoRequest, height uint32) { // If any requests want the UTXOs at this height, scan the block to find // the original outputs that might be spent from. if len(newReqs) > 0 { b.addNewRequests(newReqs) b.findInitialTransactions(blk, new...
go
{ "resource": "" }
q35842
addNewRequests
train
func (b *batchSpendReporter) addNewRequests(reqs []*GetUtxoRequest) { for _, req := range reqs { outpoint := req.Input.OutPoint log.Debugf("Adding outpoint=%s height=%d to watchlist", outpoint, req.BirthHeight) b.requests[outpoint] = append(b.requests[outpoint], req) // Build the filter entry only if it ...
go
{ "resource": "" }
q35843
findInitialTransactions
train
func (b *batchSpendReporter) findInitialTransactions(block *wire.MsgBlock, newReqs []*GetUtxoRequest, height uint32) map[wire.OutPoint]*SpendReport { // First, construct a reverse index from txid to all a list of requests // whose outputs share the same txid. txidReverseIndex := make(map[chainhash.Hash][]*GetUtxo...
go
{ "resource": "" }
q35844
notifySpends
train
func (b *batchSpendReporter) notifySpends(block *wire.MsgBlock, height uint32) map[wire.OutPoint]*SpendReport { spends := make(map[wire.OutPoint]*SpendReport) for _, tx := range block.Transactions { // Check each input to see if this transaction spends one of our // watched outpoints. for i, ti := range tx.Tx...
go
{ "resource": "" }
q35845
appendRaw
train
func (h *headerStore) appendRaw(header []byte) error { if _, err := h.file.Write(header); err != nil { return err } return nil }
go
{ "resource": "" }
q35846
readRaw
train
func (h *headerStore) readRaw(seekDist uint64) ([]byte, error) { var headerSize uint32 // Based on the defined header type, we'll determine the number of // bytes that we need to read past the sync point. switch h.indexType { case Block: headerSize = 80 case RegularFilter: headerSize = 32 default: retur...
go
{ "resource": "" }
q35847
readHeader
train
func (h *blockHeaderStore) readHeader(height uint32) (wire.BlockHeader, error) { var header wire.BlockHeader // Each header is 80 bytes, so using this information, we'll seek a // distance to cover that height based on the size of block headers. seekDistance := uint64(height) * 80 // With the distance calculated...
go
{ "resource": "" }
q35848
readHeader
train
func (f *FilterHeaderStore) readHeader(height uint32) (*chainhash.Hash, error) { seekDistance := uint64(height) * 32 rawHeader, err := f.readRaw(seekDistance) if err != nil { return nil, err } return chainhash.NewHash(rawHeader) }
go
{ "resource": "" }
q35849
readHeadersFromFile
train
func readHeadersFromFile(f *os.File, headerSize, startHeight, endHeight uint32) (*bytes.Reader, error) { // Each header is headerSize bytes, so using this information, we'll // seek a distance to cover that height based on the size the headers. seekDistance := uint64(startHeight) * uint64(headerSize) // Based on...
go
{ "resource": "" }
q35850
Count
train
func (ps *peerState) Count() int { return len(ps.outboundPeers) + len(ps.persistentPeers) }
go
{ "resource": "" }
q35851
forAllOutboundPeers
train
func (ps *peerState) forAllOutboundPeers(closure func(sp *ServerPeer)) { for _, e := range ps.outboundPeers { closure(e) } for _, e := range ps.persistentPeers { closure(e) } }
go
{ "resource": "" }
q35852
newServerPeer
train
func newServerPeer(s *ChainService, isPersistent bool) *ServerPeer { return &ServerPeer{ server: s, persistent: isPersistent, knownAddresses: make(map[string]struct{}), quit: make(chan struct{}), recvSubscribers: make(map[spMsgSubscription]struct{}), } }
go
{ "resource": "" }
q35853
addKnownAddresses
train
func (sp *ServerPeer) addKnownAddresses(addresses []*wire.NetAddress) { for _, na := range addresses { sp.knownAddresses[addrmgr.NetAddressKey(na)] = struct{}{} } }
go
{ "resource": "" }
q35854
pushSendHeadersMsg
train
func (sp *ServerPeer) pushSendHeadersMsg() error { if sp.VersionKnown() { if sp.ProtocolVersion() > wire.SendHeadersVersion { sp.QueueMessage(wire.NewMsgSendHeaders(), nil) } } return nil }
go
{ "resource": "" }
q35855
OnVerAck
train
func (sp *ServerPeer) OnVerAck(_ *peer.Peer, msg *wire.MsgVerAck) { sp.pushSendHeadersMsg() }
go
{ "resource": "" }
q35856
OnHeaders
train
func (sp *ServerPeer) OnHeaders(p *peer.Peer, msg *wire.MsgHeaders) { log.Tracef("Got headers with %d items from %s", len(msg.Headers), p.Addr()) sp.server.blockManager.QueueHeaders(msg, sp) }
go
{ "resource": "" }
q35857
subscribeRecvMsg
train
func (sp *ServerPeer) subscribeRecvMsg(subscription spMsgSubscription) { sp.mtxSubscribers.Lock() defer sp.mtxSubscribers.Unlock() sp.recvSubscribers[subscription] = struct{}{} }
go
{ "resource": "" }
q35858
unsubscribeRecvMsgs
train
func (sp *ServerPeer) unsubscribeRecvMsgs(subscription spMsgSubscription) { sp.mtxSubscribers.Lock() defer sp.mtxSubscribers.Unlock() delete(sp.recvSubscribers, subscription) }
go
{ "resource": "" }
q35859
BestBlock
train
func (s *ChainService) BestBlock() (*waddrmgr.BlockStamp, error) { bestHeader, bestHeight, err := s.BlockHeaders.ChainTip() if err != nil { return nil, err } _, filterHeight, err := s.RegFilterHeaders.ChainTip() if err != nil { return nil, err } // Filter headers might lag behind block headers, so we can c...
go
{ "resource": "" }
q35860
GetBlockHash
train
func (s *ChainService) GetBlockHash(height int64) (*chainhash.Hash, error) { header, err := s.BlockHeaders.FetchHeaderByHeight(uint32(height)) if err != nil { return nil, err } hash := header.BlockHash() return &hash, err }
go
{ "resource": "" }
q35861
GetBlockHeader
train
func (s *ChainService) GetBlockHeader( blockHash *chainhash.Hash) (*wire.BlockHeader, error) { header, _, err := s.BlockHeaders.FetchHeader(blockHash) return header, err }
go
{ "resource": "" }
q35862
GetBlockHeight
train
func (s *ChainService) GetBlockHeight(hash *chainhash.Hash) (int32, error) { _, height, err := s.BlockHeaders.FetchHeader(hash) if err != nil { return 0, err } return int32(height), nil }
go
{ "resource": "" }
q35863
BanPeer
train
func (s *ChainService) BanPeer(sp *ServerPeer) { select { case s.banPeers <- sp: case <-s.quit: return } }
go
{ "resource": "" }
q35864
AddPeer
train
func (s *ChainService) AddPeer(sp *ServerPeer) { select { case s.newPeers <- sp: case <-s.quit: return } }
go
{ "resource": "" }
q35865
rollBackToHeight
train
func (s *ChainService) rollBackToHeight(height uint32) (*waddrmgr.BlockStamp, error) { header, headerHeight, err := s.BlockHeaders.ChainTip() if err != nil { return nil, err } bs := &waddrmgr.BlockStamp{ Height: int32(headerHeight), Hash: header.BlockHash(), } _, regHeight, err := s.RegFilterHeaders.Chai...
go
{ "resource": "" }
q35866
isBanned
train
func (s *ChainService) isBanned(addr string, state *peerState) bool { // First, we'll extract the host so we can consider it without taking // into account the target port. host, _, err := net.SplitHostPort(addr) if err != nil { log.Debugf("can't split host/port: %s", err) return false } // With the host obt...
go
{ "resource": "" }
q35867
SendTransaction
train
func (s *ChainService) SendTransaction(tx *wire.MsgTx) error { // TODO(roasbeef): pipe through querying interface return s.broadcaster.Broadcast(tx) }
go
{ "resource": "" }
q35868
newPeerConfig
train
func newPeerConfig(sp *ServerPeer) *peer.Config { return &peer.Config{ Listeners: peer.MessageListeners{ OnVersion: sp.OnVersion, //OnVerAck: sp.OnVerAck, // Don't use sendheaders yet OnInv: sp.OnInv, OnHeaders: sp.OnHeaders, OnReject: sp.OnReject, OnFeeFilter: sp.OnFeeFilter, OnAd...
go
{ "resource": "" }
q35869
Start
train
func (s *ChainService) Start() error { // Already started? if atomic.AddInt32(&s.started, 1) != 1 { return nil } // Start the address manager and block manager, both of which are // needed by peers. s.addrManager.Start() s.blockManager.Start() s.blockSubscriptionMgr.Start() s.utxoScanner.Start() if err :...
go
{ "resource": "" }
q35870
PeerByAddr
train
func (s *ChainService) PeerByAddr(addr string) *ServerPeer { for _, peer := range s.Peers() { if peer.Addr() == addr { return peer } } return nil }
go
{ "resource": "" }
q35871
GetBlockHeaderByHeight
train
func (s *RescanChainSource) GetBlockHeaderByHeight( height uint32) (*wire.BlockHeader, error) { return s.BlockHeaders.FetchHeaderByHeight(height) }
go
{ "resource": "" }
q35872
GetBlockHeader
train
func (s *RescanChainSource) GetBlockHeader( hash *chainhash.Hash) (*wire.BlockHeader, uint32, error) { return s.BlockHeaders.FetchHeader(hash) }
go
{ "resource": "" }
q35873
GetFilterHeaderByHeight
train
func (s *RescanChainSource) GetFilterHeaderByHeight( height uint32) (*chainhash.Hash, error) { return s.RegFilterHeaders.FetchHeaderByHeight(height) }
go
{ "resource": "" }
q35874
Subscribe
train
func (s *RescanChainSource) Subscribe( bestHeight uint32) (*blockntfns.Subscription, error) { return s.blockSubscriptionMgr.NewSubscription(bestHeight) }
go
{ "resource": "" }
q35875
NewBlockConnected
train
func NewBlockConnected(header wire.BlockHeader, height uint32) *Connected { return &Connected{header: header, height: height} }
go
{ "resource": "" }
q35876
String
train
func (n *Connected) String() string { return fmt.Sprintf("block connected (height=%d, hash=%v)", n.height, n.header.BlockHash()) }
go
{ "resource": "" }
q35877
NewBlockDisconnected
train
func NewBlockDisconnected(headerDisconnected wire.BlockHeader, heightDisconnected uint32, chainTip wire.BlockHeader) *Disconnected { return &Disconnected{ headerDisconnected: headerDisconnected, heightDisconnected: heightDisconnected, chainTip: chainTip, } }
go
{ "resource": "" }
q35878
String
train
func (n *Disconnected) String() string { return fmt.Sprintf("block disconnected (height=%d, hash=%v)", n.heightDisconnected, n.headerDisconnected.BlockHash()) }
go
{ "resource": "" }
q35879
defaultQueryOptions
train
func defaultQueryOptions() *queryOptions { return &queryOptions{ timeout: QueryTimeout, numRetries: uint8(QueryNumRetries), peerConnectTimeout: QueryPeerConnectTimeout, encoding: QueryEncoding, optimisticBatch: noBatch, } }
go
{ "resource": "" }
q35880
applyQueryOptions
train
func (qo *queryOptions) applyQueryOptions(options ...QueryOption) { for _, option := range options { option(qo) } }
go
{ "resource": "" }
q35881
Timeout
train
func Timeout(timeout time.Duration) QueryOption { return func(qo *queryOptions) { qo.timeout = timeout } }
go
{ "resource": "" }
q35882
PeerConnectTimeout
train
func PeerConnectTimeout(timeout time.Duration) QueryOption { return func(qo *queryOptions) { qo.peerConnectTimeout = timeout } }
go
{ "resource": "" }
q35883
Encoding
train
func Encoding(encoding wire.MessageEncoding) QueryOption { return func(qo *queryOptions) { qo.encoding = encoding } }
go
{ "resource": "" }
q35884
queryAllPeers
train
func (s *ChainService) queryAllPeers( // queryMsg is the message to broadcast to all peers. queryMsg wire.Message, // checkResponse is called for every message within the timeout period. // The quit channel lets the query know to terminate because the // required response has been found. This is done by closing t...
go
{ "resource": "" }
q35885
queryChainServicePeers
train
func queryChainServicePeers( // s is the ChainService to use. s *ChainService, // queryMsg is the message to send to each peer selected by selectPeer. queryMsg wire.Message, // checkResponse is called for every message within the timeout period. // The quit channel lets the query know to terminate because the ...
go
{ "resource": "" }
q35886
getFilterFromCache
train
func (s *ChainService) getFilterFromCache(blockHash *chainhash.Hash, filterType filterdb.FilterType) (*gcs.Filter, error) { cacheKey := cache.FilterCacheKey{*blockHash, filterType} filterValue, err := s.FilterCache.Get(cacheKey) if err != nil { return nil, err } return filterValue.(*cache.CacheableFilter).Fi...
go
{ "resource": "" }
q35887
putFilterToCache
train
func (s *ChainService) putFilterToCache(blockHash *chainhash.Hash, filterType filterdb.FilterType, filter *gcs.Filter) (bool, error) { cacheKey := cache.FilterCacheKey{*blockHash, filterType} return s.FilterCache.Put(cacheKey, &cache.CacheableFilter{Filter: filter}) }
go
{ "resource": "" }
q35888
queryMsg
train
func (q *cfiltersQuery) queryMsg() wire.Message { return wire.NewMsgGetCFilters( q.filterType, uint32(q.startHeight), q.stopHash, ) }
go
{ "resource": "" }
q35889
handleCFiltersResponse
train
func (s *ChainService) handleCFiltersResponse(q *cfiltersQuery, resp wire.Message, quit chan<- struct{}) { // We're only interested in "cfilter" messages. response, ok := resp.(*wire.MsgCFilter) if !ok { return } // If the response doesn't match our request, ignore this message. if q.filterType != response.F...
go
{ "resource": "" }
q35890
GetCFilter
train
func (s *ChainService) GetCFilter(blockHash chainhash.Hash, filterType wire.FilterType, options ...QueryOption) (*gcs.Filter, error) { // The only supported filter atm is the regular filter, so we'll reject // all other filters. if filterType != wire.GCSFilterRegular { return nil, fmt.Errorf("unknown filter type...
go
{ "resource": "" }
q35891
GetBlock
train
func (s *ChainService) GetBlock(blockHash chainhash.Hash, options ...QueryOption) (*btcutil.Block, error) { // Fetch the corresponding block header from the database. If this // isn't found, then we don't have the header for this block so we // can't request it. blockHeader, height, err := s.BlockHeaders.FetchHea...
go
{ "resource": "" }
q35892
Peers
train
func (s *ChainService) Peers() []*ServerPeer { replyChan := make(chan []*ServerPeer) select { case s.query <- getPeersMsg{reply: replyChan}: return <-replyChan case <-s.quit: return nil } }
go
{ "resource": "" }
q35893
DisconnectNodeByAddr
train
func (s *ChainService) DisconnectNodeByAddr(addr string) error { replyChan := make(chan error) select { case s.query <- disconnectNodeMsg{ cmp: func(sp *ServerPeer) bool { return sp.Addr() == addr }, reply: replyChan, }: return <-replyChan case <-s.quit: return nil } }
go
{ "resource": "" }
q35894
DisconnectNodeByID
train
func (s *ChainService) DisconnectNodeByID(id int32) error { replyChan := make(chan error) select { case s.query <- disconnectNodeMsg{ cmp: func(sp *ServerPeer) bool { return sp.ID() == id }, reply: replyChan, }: return <-replyChan case <-s.quit: return nil } }
go
{ "resource": "" }
q35895
ConnectNode
train
func (s *ChainService) ConnectNode(addr string, permanent bool) error { replyChan := make(chan error) select { case s.query <- connectNodeMsg{ addr: addr, permanent: permanent, reply: replyChan, }: return <-replyChan case <-s.quit: return nil } }
go
{ "resource": "" }
q35896
IsBanned
train
func (s *ChainService) IsBanned(addr string) bool { replyChan := make(chan bool, 1) select { case s.query <- banQueryMsg{ addr: addr, reply: replyChan, }: return <-replyChan case <-s.quit: return false } }
go
{ "resource": "" }
q35897
NotificationHandlers
train
func NotificationHandlers(ntfn rpcclient.NotificationHandlers) RescanOption { return func(ro *rescanOptions) { ro.ntfn = ntfn } }
go
{ "resource": "" }
q35898
StartTime
train
func StartTime(startTime time.Time) RescanOption { return func(ro *rescanOptions) { ro.startTime = startTime } }
go
{ "resource": "" }
q35899
WatchInputs
train
func WatchInputs(watchInputs ...InputWithScript) RescanOption { return func(ro *rescanOptions) { ro.watchInputs = append(ro.watchInputs, watchInputs...) } }
go
{ "resource": "" }