id
int32
0
167k
repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
list
docstring
stringlengths
6
2.61k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
85
252
130,800
coredns/coredns
plugin/cache/cache.go
key
func key(qname string, m *dns.Msg, t response.Type, do bool) (bool, uint64) { // We don't store truncated responses. if m.Truncated { return false, 0 } // Nor errors or Meta or Update if t == response.OtherError || t == response.Meta || t == response.Update { return false, 0 } return true, hash(qname, m.Que...
go
func key(qname string, m *dns.Msg, t response.Type, do bool) (bool, uint64) { // We don't store truncated responses. if m.Truncated { return false, 0 } // Nor errors or Meta or Update if t == response.OtherError || t == response.Meta || t == response.Update { return false, 0 } return true, hash(qname, m.Que...
[ "func", "key", "(", "qname", "string", ",", "m", "*", "dns", ".", "Msg", ",", "t", "response", ".", "Type", ",", "do", "bool", ")", "(", "bool", ",", "uint64", ")", "{", "// We don't store truncated responses.", "if", "m", ".", "Truncated", "{", "retur...
// key returns key under which we store the item, -1 will be returned if we don't store the message. // Currently we do not cache Truncated, errors zone transfers or dynamic update messages. // qname holds the already lowercased qname.
[ "key", "returns", "key", "under", "which", "we", "store", "the", "item", "-", "1", "will", "be", "returned", "if", "we", "don", "t", "store", "the", "message", ".", "Currently", "we", "do", "not", "cache", "Truncated", "errors", "zone", "transfers", "or"...
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/cache/cache.go#L66-L77
130,801
coredns/coredns
plugin/cache/cache.go
RemoteAddr
func (w *ResponseWriter) RemoteAddr() net.Addr { if w.remoteAddr != nil { return w.remoteAddr } return w.ResponseWriter.RemoteAddr() }
go
func (w *ResponseWriter) RemoteAddr() net.Addr { if w.remoteAddr != nil { return w.remoteAddr } return w.ResponseWriter.RemoteAddr() }
[ "func", "(", "w", "*", "ResponseWriter", ")", "RemoteAddr", "(", ")", "net", ".", "Addr", "{", "if", "w", ".", "remoteAddr", "!=", "nil", "{", "return", "w", ".", "remoteAddr", "\n", "}", "\n", "return", "w", ".", "ResponseWriter", ".", "RemoteAddr", ...
// RemoteAddr implements the dns.ResponseWriter interface.
[ "RemoteAddr", "implements", "the", "dns", ".", "ResponseWriter", "interface", "." ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/cache/cache.go#L144-L149
130,802
coredns/coredns
plugin/etcd/msg/service.go
NewSRV
func (s *Service) NewSRV(name string, weight uint16) *dns.SRV { host := dns.Fqdn(s.Host) if s.TargetStrip > 0 { host = targetStrip(host, s.TargetStrip) } return &dns.SRV{Hdr: dns.RR_Header{Name: name, Rrtype: dns.TypeSRV, Class: dns.ClassINET, Ttl: s.TTL}, Priority: uint16(s.Priority), Weight: weight, Port: ui...
go
func (s *Service) NewSRV(name string, weight uint16) *dns.SRV { host := dns.Fqdn(s.Host) if s.TargetStrip > 0 { host = targetStrip(host, s.TargetStrip) } return &dns.SRV{Hdr: dns.RR_Header{Name: name, Rrtype: dns.TypeSRV, Class: dns.ClassINET, Ttl: s.TTL}, Priority: uint16(s.Priority), Weight: weight, Port: ui...
[ "func", "(", "s", "*", "Service", ")", "NewSRV", "(", "name", "string", ",", "weight", "uint16", ")", "*", "dns", ".", "SRV", "{", "host", ":=", "dns", ".", "Fqdn", "(", "s", ".", "Host", ")", "\n", "if", "s", ".", "TargetStrip", ">", "0", "{",...
// NewSRV returns a new SRV record based on the Service.
[ "NewSRV", "returns", "a", "new", "SRV", "record", "based", "on", "the", "Service", "." ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/etcd/msg/service.go#L40-L48
130,803
coredns/coredns
plugin/etcd/msg/service.go
NewMX
func (s *Service) NewMX(name string) *dns.MX { host := dns.Fqdn(s.Host) if s.TargetStrip > 0 { host = targetStrip(host, s.TargetStrip) } return &dns.MX{Hdr: dns.RR_Header{Name: name, Rrtype: dns.TypeMX, Class: dns.ClassINET, Ttl: s.TTL}, Preference: uint16(s.Priority), Mx: host} }
go
func (s *Service) NewMX(name string) *dns.MX { host := dns.Fqdn(s.Host) if s.TargetStrip > 0 { host = targetStrip(host, s.TargetStrip) } return &dns.MX{Hdr: dns.RR_Header{Name: name, Rrtype: dns.TypeMX, Class: dns.ClassINET, Ttl: s.TTL}, Preference: uint16(s.Priority), Mx: host} }
[ "func", "(", "s", "*", "Service", ")", "NewMX", "(", "name", "string", ")", "*", "dns", ".", "MX", "{", "host", ":=", "dns", ".", "Fqdn", "(", "s", ".", "Host", ")", "\n", "if", "s", ".", "TargetStrip", ">", "0", "{", "host", "=", "targetStrip"...
// NewMX returns a new MX record based on the Service.
[ "NewMX", "returns", "a", "new", "MX", "record", "based", "on", "the", "Service", "." ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/etcd/msg/service.go#L51-L59
130,804
coredns/coredns
plugin/etcd/msg/service.go
NewA
func (s *Service) NewA(name string, ip net.IP) *dns.A { return &dns.A{Hdr: dns.RR_Header{Name: name, Rrtype: dns.TypeA, Class: dns.ClassINET, Ttl: s.TTL}, A: ip} }
go
func (s *Service) NewA(name string, ip net.IP) *dns.A { return &dns.A{Hdr: dns.RR_Header{Name: name, Rrtype: dns.TypeA, Class: dns.ClassINET, Ttl: s.TTL}, A: ip} }
[ "func", "(", "s", "*", "Service", ")", "NewA", "(", "name", "string", ",", "ip", "net", ".", "IP", ")", "*", "dns", ".", "A", "{", "return", "&", "dns", ".", "A", "{", "Hdr", ":", "dns", ".", "RR_Header", "{", "Name", ":", "name", ",", "Rrtyp...
// NewA returns a new A record based on the Service.
[ "NewA", "returns", "a", "new", "A", "record", "based", "on", "the", "Service", "." ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/etcd/msg/service.go#L62-L64
130,805
coredns/coredns
plugin/etcd/msg/service.go
NewAAAA
func (s *Service) NewAAAA(name string, ip net.IP) *dns.AAAA { return &dns.AAAA{Hdr: dns.RR_Header{Name: name, Rrtype: dns.TypeAAAA, Class: dns.ClassINET, Ttl: s.TTL}, AAAA: ip} }
go
func (s *Service) NewAAAA(name string, ip net.IP) *dns.AAAA { return &dns.AAAA{Hdr: dns.RR_Header{Name: name, Rrtype: dns.TypeAAAA, Class: dns.ClassINET, Ttl: s.TTL}, AAAA: ip} }
[ "func", "(", "s", "*", "Service", ")", "NewAAAA", "(", "name", "string", ",", "ip", "net", ".", "IP", ")", "*", "dns", ".", "AAAA", "{", "return", "&", "dns", ".", "AAAA", "{", "Hdr", ":", "dns", ".", "RR_Header", "{", "Name", ":", "name", ",",...
// NewAAAA returns a new AAAA record based on the Service.
[ "NewAAAA", "returns", "a", "new", "AAAA", "record", "based", "on", "the", "Service", "." ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/etcd/msg/service.go#L67-L69
130,806
coredns/coredns
plugin/etcd/msg/service.go
NewCNAME
func (s *Service) NewCNAME(name string, target string) *dns.CNAME { return &dns.CNAME{Hdr: dns.RR_Header{Name: name, Rrtype: dns.TypeCNAME, Class: dns.ClassINET, Ttl: s.TTL}, Target: dns.Fqdn(target)} }
go
func (s *Service) NewCNAME(name string, target string) *dns.CNAME { return &dns.CNAME{Hdr: dns.RR_Header{Name: name, Rrtype: dns.TypeCNAME, Class: dns.ClassINET, Ttl: s.TTL}, Target: dns.Fqdn(target)} }
[ "func", "(", "s", "*", "Service", ")", "NewCNAME", "(", "name", "string", ",", "target", "string", ")", "*", "dns", ".", "CNAME", "{", "return", "&", "dns", ".", "CNAME", "{", "Hdr", ":", "dns", ".", "RR_Header", "{", "Name", ":", "name", ",", "R...
// NewCNAME returns a new CNAME record based on the Service.
[ "NewCNAME", "returns", "a", "new", "CNAME", "record", "based", "on", "the", "Service", "." ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/etcd/msg/service.go#L72-L74
130,807
coredns/coredns
plugin/etcd/msg/service.go
NewTXT
func (s *Service) NewTXT(name string) *dns.TXT { return &dns.TXT{Hdr: dns.RR_Header{Name: name, Rrtype: dns.TypeTXT, Class: dns.ClassINET, Ttl: s.TTL}, Txt: split255(s.Text)} }
go
func (s *Service) NewTXT(name string) *dns.TXT { return &dns.TXT{Hdr: dns.RR_Header{Name: name, Rrtype: dns.TypeTXT, Class: dns.ClassINET, Ttl: s.TTL}, Txt: split255(s.Text)} }
[ "func", "(", "s", "*", "Service", ")", "NewTXT", "(", "name", "string", ")", "*", "dns", ".", "TXT", "{", "return", "&", "dns", ".", "TXT", "{", "Hdr", ":", "dns", ".", "RR_Header", "{", "Name", ":", "name", ",", "Rrtype", ":", "dns", ".", "Typ...
// NewTXT returns a new TXT record based on the Service.
[ "NewTXT", "returns", "a", "new", "TXT", "record", "based", "on", "the", "Service", "." ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/etcd/msg/service.go#L77-L79
130,808
coredns/coredns
plugin/etcd/msg/service.go
NewPTR
func (s *Service) NewPTR(name string, target string) *dns.PTR { return &dns.PTR{Hdr: dns.RR_Header{Name: name, Rrtype: dns.TypePTR, Class: dns.ClassINET, Ttl: s.TTL}, Ptr: dns.Fqdn(target)} }
go
func (s *Service) NewPTR(name string, target string) *dns.PTR { return &dns.PTR{Hdr: dns.RR_Header{Name: name, Rrtype: dns.TypePTR, Class: dns.ClassINET, Ttl: s.TTL}, Ptr: dns.Fqdn(target)} }
[ "func", "(", "s", "*", "Service", ")", "NewPTR", "(", "name", "string", ",", "target", "string", ")", "*", "dns", ".", "PTR", "{", "return", "&", "dns", ".", "PTR", "{", "Hdr", ":", "dns", ".", "RR_Header", "{", "Name", ":", "name", ",", "Rrtype"...
// NewPTR returns a new PTR record based on the Service.
[ "NewPTR", "returns", "a", "new", "PTR", "record", "based", "on", "the", "Service", "." ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/etcd/msg/service.go#L82-L84
130,809
coredns/coredns
plugin/etcd/msg/service.go
NewNS
func (s *Service) NewNS(name string) *dns.NS { host := dns.Fqdn(s.Host) if s.TargetStrip > 0 { host = targetStrip(host, s.TargetStrip) } return &dns.NS{Hdr: dns.RR_Header{Name: name, Rrtype: dns.TypeNS, Class: dns.ClassINET, Ttl: s.TTL}, Ns: host} }
go
func (s *Service) NewNS(name string) *dns.NS { host := dns.Fqdn(s.Host) if s.TargetStrip > 0 { host = targetStrip(host, s.TargetStrip) } return &dns.NS{Hdr: dns.RR_Header{Name: name, Rrtype: dns.TypeNS, Class: dns.ClassINET, Ttl: s.TTL}, Ns: host} }
[ "func", "(", "s", "*", "Service", ")", "NewNS", "(", "name", "string", ")", "*", "dns", ".", "NS", "{", "host", ":=", "dns", ".", "Fqdn", "(", "s", ".", "Host", ")", "\n", "if", "s", ".", "TargetStrip", ">", "0", "{", "host", "=", "targetStrip"...
// NewNS returns a new NS record based on the Service.
[ "NewNS", "returns", "a", "new", "NS", "record", "based", "on", "the", "Service", "." ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/etcd/msg/service.go#L87-L93
130,810
coredns/coredns
plugin/etcd/msg/service.go
split255
func split255(s string) []string { if len(s) < 255 { return []string{s} } sx := []string{} p, i := 0, 255 for { if i <= len(s) { sx = append(sx, s[p:i]) } else { sx = append(sx, s[p:]) break } p, i = p+255, i+255 } return sx }
go
func split255(s string) []string { if len(s) < 255 { return []string{s} } sx := []string{} p, i := 0, 255 for { if i <= len(s) { sx = append(sx, s[p:i]) } else { sx = append(sx, s[p:]) break } p, i = p+255, i+255 } return sx }
[ "func", "split255", "(", "s", "string", ")", "[", "]", "string", "{", "if", "len", "(", "s", ")", "<", "255", "{", "return", "[", "]", "string", "{", "s", "}", "\n", "}", "\n", "sx", ":=", "[", "]", "string", "{", "}", "\n", "p", ",", "i", ...
// Split255 splits a string into 255 byte chunks.
[ "Split255", "splits", "a", "string", "into", "255", "byte", "chunks", "." ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/etcd/msg/service.go#L145-L163
130,811
coredns/coredns
plugin/forward/connect.go
limitTimeout
func limitTimeout(currentAvg *int64, minValue time.Duration, maxValue time.Duration) time.Duration { rt := time.Duration(atomic.LoadInt64(currentAvg)) if rt < minValue { return minValue } if rt < maxValue/2 { return 2 * rt } return maxValue }
go
func limitTimeout(currentAvg *int64, minValue time.Duration, maxValue time.Duration) time.Duration { rt := time.Duration(atomic.LoadInt64(currentAvg)) if rt < minValue { return minValue } if rt < maxValue/2 { return 2 * rt } return maxValue }
[ "func", "limitTimeout", "(", "currentAvg", "*", "int64", ",", "minValue", "time", ".", "Duration", ",", "maxValue", "time", ".", "Duration", ")", "time", ".", "Duration", "{", "rt", ":=", "time", ".", "Duration", "(", "atomic", ".", "LoadInt64", "(", "cu...
// limitTimeout is a utility function to auto-tune timeout values // average observed time is moved towards the last observed delay moderated by a weight // next timeout to use will be the double of the computed average, limited by min and max frame.
[ "limitTimeout", "is", "a", "utility", "function", "to", "auto", "-", "tune", "timeout", "values", "average", "observed", "time", "is", "moved", "towards", "the", "last", "observed", "delay", "moderated", "by", "a", "weight", "next", "timeout", "to", "use", "...
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/forward/connect.go#L22-L31
130,812
coredns/coredns
plugin/forward/connect.go
Dial
func (t *Transport) Dial(proto string) (*dns.Conn, bool, error) { // If tls has been configured; use it. if t.tlsConfig != nil { proto = "tcp-tls" } t.dial <- proto c := <-t.ret if c != nil { return c, true, nil } reqTime := time.Now() timeout := t.dialTimeout() if proto == "tcp-tls" { conn, err := d...
go
func (t *Transport) Dial(proto string) (*dns.Conn, bool, error) { // If tls has been configured; use it. if t.tlsConfig != nil { proto = "tcp-tls" } t.dial <- proto c := <-t.ret if c != nil { return c, true, nil } reqTime := time.Now() timeout := t.dialTimeout() if proto == "tcp-tls" { conn, err := d...
[ "func", "(", "t", "*", "Transport", ")", "Dial", "(", "proto", "string", ")", "(", "*", "dns", ".", "Conn", ",", "bool", ",", "error", ")", "{", "// If tls has been configured; use it.", "if", "t", ".", "tlsConfig", "!=", "nil", "{", "proto", "=", "\""...
// Dial dials the address configured in transport, potentially reusing a connection or creating a new one.
[ "Dial", "dials", "the", "address", "configured", "in", "transport", "potentially", "reusing", "a", "connection", "or", "creating", "a", "new", "one", "." ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/forward/connect.go#L47-L70
130,813
coredns/coredns
plugin/forward/connect.go
Connect
func (p *Proxy) Connect(ctx context.Context, state request.Request, opts options) (*dns.Msg, error) { start := time.Now() proto := "" switch { case opts.forceTCP: // TCP flag has precedence over UDP flag proto = "tcp" case opts.preferUDP: proto = "udp" default: proto = state.Proto() } conn, cached, err ...
go
func (p *Proxy) Connect(ctx context.Context, state request.Request, opts options) (*dns.Msg, error) { start := time.Now() proto := "" switch { case opts.forceTCP: // TCP flag has precedence over UDP flag proto = "tcp" case opts.preferUDP: proto = "udp" default: proto = state.Proto() } conn, cached, err ...
[ "func", "(", "p", "*", "Proxy", ")", "Connect", "(", "ctx", "context", ".", "Context", ",", "state", "request", ".", "Request", ",", "opts", "options", ")", "(", "*", "dns", ".", "Msg", ",", "error", ")", "{", "start", ":=", "time", ".", "Now", "...
// Connect selects an upstream, sends the request and waits for a response.
[ "Connect", "selects", "an", "upstream", "sends", "the", "request", "and", "waits", "for", "a", "response", "." ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/forward/connect.go#L73-L135
130,814
coredns/coredns
plugin/route53/route53.go
Run
func (h *Route53) Run(ctx context.Context) error { if err := h.updateZones(ctx); err != nil { return err } go func() { for { select { case <-ctx.Done(): log.Infof("Breaking out of Route53 update loop: %v", ctx.Err()) return case <-time.After(1 * time.Minute): if err := h.updateZones(ctx); er...
go
func (h *Route53) Run(ctx context.Context) error { if err := h.updateZones(ctx); err != nil { return err } go func() { for { select { case <-ctx.Done(): log.Infof("Breaking out of Route53 update loop: %v", ctx.Err()) return case <-time.After(1 * time.Minute): if err := h.updateZones(ctx); er...
[ "func", "(", "h", "*", "Route53", ")", "Run", "(", "ctx", "context", ".", "Context", ")", "error", "{", "if", "err", ":=", "h", ".", "updateZones", "(", "ctx", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "go", "func", "...
// Run executes first update, spins up an update forever-loop. // Returns error if first update fails.
[ "Run", "executes", "first", "update", "spins", "up", "an", "update", "forever", "-", "loop", ".", "Returns", "error", "if", "first", "update", "fails", "." ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/route53/route53.go#L80-L98
130,815
coredns/coredns
plugin/route53/route53.go
ServeDNS
func (h *Route53) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error) { state := request.Request{W: w, Req: r} qname := state.Name() zName := plugin.Zones(h.zoneNames).Matches(qname) if zName == "" { return plugin.NextOrFailure(h.Name(), h.Next, ctx, w, r) } z, ok := h.zones[zName] if...
go
func (h *Route53) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error) { state := request.Request{W: w, Req: r} qname := state.Name() zName := plugin.Zones(h.zoneNames).Matches(qname) if zName == "" { return plugin.NextOrFailure(h.Name(), h.Next, ctx, w, r) } z, ok := h.zones[zName] if...
[ "func", "(", "h", "*", "Route53", ")", "ServeDNS", "(", "ctx", "context", ".", "Context", ",", "w", "dns", ".", "ResponseWriter", ",", "r", "*", "dns", ".", "Msg", ")", "(", "int", ",", "error", ")", "{", "state", ":=", "request", ".", "Request", ...
// ServeDNS implements the plugin.Handler.ServeDNS.
[ "ServeDNS", "implements", "the", "plugin", ".", "Handler", ".", "ServeDNS", "." ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/route53/route53.go#L101-L147
130,816
coredns/coredns
plugin/route53/route53.go
updateZones
func (h *Route53) updateZones(ctx context.Context) error { errc := make(chan error) defer close(errc) for zName, z := range h.zones { go func(zName string, z []*zone) { var err error defer func() { errc <- err }() for i, hostedZone := range z { newZ := file.NewZone(zName, "") newZ.Upstream...
go
func (h *Route53) updateZones(ctx context.Context) error { errc := make(chan error) defer close(errc) for zName, z := range h.zones { go func(zName string, z []*zone) { var err error defer func() { errc <- err }() for i, hostedZone := range z { newZ := file.NewZone(zName, "") newZ.Upstream...
[ "func", "(", "h", "*", "Route53", ")", "updateZones", "(", "ctx", "context", ".", "Context", ")", "error", "{", "errc", ":=", "make", "(", "chan", "error", ")", "\n", "defer", "close", "(", "errc", ")", "\n", "for", "zName", ",", "z", ":=", "range"...
// updateZones re-queries resource record sets for each zone and updates the // zone object. // Returns error if any zones error'ed out, but waits for other zones to // complete first.
[ "updateZones", "re", "-", "queries", "resource", "record", "sets", "for", "each", "zone", "and", "updates", "the", "zone", "object", ".", "Returns", "error", "if", "any", "zones", "error", "ed", "out", "but", "waits", "for", "other", "zones", "to", "comple...
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/route53/route53.go#L236-L286
130,817
coredns/coredns
plugin/dnssec/rrsig.go
newRRSIG
func (k *DNSKEY) newRRSIG(signerName string, ttl, incep, expir uint32) *dns.RRSIG { sig := new(dns.RRSIG) sig.Hdr.Rrtype = dns.TypeRRSIG sig.Algorithm = k.K.Algorithm sig.KeyTag = k.tag sig.SignerName = signerName sig.Hdr.Ttl = ttl sig.OrigTtl = origTTL sig.Inception = incep sig.Expiration = expir return s...
go
func (k *DNSKEY) newRRSIG(signerName string, ttl, incep, expir uint32) *dns.RRSIG { sig := new(dns.RRSIG) sig.Hdr.Rrtype = dns.TypeRRSIG sig.Algorithm = k.K.Algorithm sig.KeyTag = k.tag sig.SignerName = signerName sig.Hdr.Ttl = ttl sig.OrigTtl = origTTL sig.Inception = incep sig.Expiration = expir return s...
[ "func", "(", "k", "*", "DNSKEY", ")", "newRRSIG", "(", "signerName", "string", ",", "ttl", ",", "incep", ",", "expir", "uint32", ")", "*", "dns", ".", "RRSIG", "{", "sig", ":=", "new", "(", "dns", ".", "RRSIG", ")", "\n\n", "sig", ".", "Hdr", "."...
// newRRSIG return a new RRSIG, with all fields filled out, except the signed data.
[ "newRRSIG", "return", "a", "new", "RRSIG", "with", "all", "fields", "filled", "out", "except", "the", "signed", "data", "." ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/dnssec/rrsig.go#L6-L20
130,818
coredns/coredns
plugin/dnssec/rrsig.go
rrSets
func rrSets(rrs []dns.RR) map[rrset][]dns.RR { m := make(map[rrset][]dns.RR) for _, r := range rrs { if r.Header().Rrtype == dns.TypeRRSIG || r.Header().Rrtype == dns.TypeOPT { continue } if s, ok := m[rrset{r.Header().Name, r.Header().Rrtype}]; ok { s = append(s, r) m[rrset{r.Header().Name, r.Header...
go
func rrSets(rrs []dns.RR) map[rrset][]dns.RR { m := make(map[rrset][]dns.RR) for _, r := range rrs { if r.Header().Rrtype == dns.TypeRRSIG || r.Header().Rrtype == dns.TypeOPT { continue } if s, ok := m[rrset{r.Header().Name, r.Header().Rrtype}]; ok { s = append(s, r) m[rrset{r.Header().Name, r.Header...
[ "func", "rrSets", "(", "rrs", "[", "]", "dns", ".", "RR", ")", "map", "[", "rrset", "]", "[", "]", "dns", ".", "RR", "{", "m", ":=", "make", "(", "map", "[", "rrset", "]", "[", "]", "dns", ".", "RR", ")", "\n\n", "for", "_", ",", "r", ":=...
// rrSets returns rrs as a map of RRsets. It skips RRSIG and OPT records as those don't need to be signed.
[ "rrSets", "returns", "rrs", "as", "a", "map", "of", "RRsets", ".", "It", "skips", "RRSIG", "and", "OPT", "records", "as", "those", "don", "t", "need", "to", "be", "signed", "." ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/dnssec/rrsig.go#L28-L51
130,819
coredns/coredns
owners_generate.go
owners
func owners(path string, owners map[string]struct{}) (map[string]struct{}, error) { file, err := ioutil.ReadFile(path) if err != nil { return nil, err } c := yaml.MapSlice{} err = yaml.Unmarshal(file, &c) if err != nil { return nil, err } for _, mi := range c { key, ok := mi.Key.(string) if !ok { con...
go
func owners(path string, owners map[string]struct{}) (map[string]struct{}, error) { file, err := ioutil.ReadFile(path) if err != nil { return nil, err } c := yaml.MapSlice{} err = yaml.Unmarshal(file, &c) if err != nil { return nil, err } for _, mi := range c { key, ok := mi.Key.(string) if !ok { con...
[ "func", "owners", "(", "path", "string", ",", "owners", "map", "[", "string", "]", "struct", "{", "}", ")", "(", "map", "[", "string", "]", "struct", "{", "}", ",", "error", ")", "{", "file", ",", "err", ":=", "ioutil", ".", "ReadFile", "(", "pat...
// owners parses a owner file without knowning a whole lot about its structure.
[ "owners", "parses", "a", "owner", "file", "without", "knowning", "a", "whole", "lot", "about", "its", "structure", "." ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/owners_generate.go#L69-L91
130,820
coredns/coredns
plugin/dnssec/dnskey.go
ParseKeyFile
func ParseKeyFile(pubFile, privFile string) (*DNSKEY, error) { f, e := os.Open(pubFile) if e != nil { return nil, e } defer f.Close() k, e := dns.ReadRR(f, pubFile) if e != nil { return nil, e } f, e = os.Open(privFile) if e != nil { return nil, e } defer f.Close() dk, ok := k.(*dns.DNSKEY) if !ok ...
go
func ParseKeyFile(pubFile, privFile string) (*DNSKEY, error) { f, e := os.Open(pubFile) if e != nil { return nil, e } defer f.Close() k, e := dns.ReadRR(f, pubFile) if e != nil { return nil, e } f, e = os.Open(privFile) if e != nil { return nil, e } defer f.Close() dk, ok := k.(*dns.DNSKEY) if !ok ...
[ "func", "ParseKeyFile", "(", "pubFile", ",", "privFile", "string", ")", "(", "*", "DNSKEY", ",", "error", ")", "{", "f", ",", "e", ":=", "os", ".", "Open", "(", "pubFile", ")", "\n", "if", "e", "!=", "nil", "{", "return", "nil", ",", "e", "\n", ...
// ParseKeyFile read a DNSSEC keyfile as generated by dnssec-keygen or other // utilities. It adds ".key" for the public key and ".private" for the private key.
[ "ParseKeyFile", "read", "a", "DNSSEC", "keyfile", "as", "generated", "by", "dnssec", "-", "keygen", "or", "other", "utilities", ".", "It", "adds", ".", "key", "for", "the", "public", "key", "and", ".", "private", "for", "the", "private", "key", "." ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/dnssec/dnskey.go#L26-L59
130,821
coredns/coredns
plugin/dnssec/dnskey.go
getDNSKEY
func (d Dnssec) getDNSKEY(state request.Request, zone string, do bool, server string) *dns.Msg { keys := make([]dns.RR, len(d.keys)) for i, k := range d.keys { keys[i] = dns.Copy(k.K) keys[i].Header().Name = zone } m := new(dns.Msg) m.SetReply(state.Req) m.Answer = keys if !do { return m } incep, expir ...
go
func (d Dnssec) getDNSKEY(state request.Request, zone string, do bool, server string) *dns.Msg { keys := make([]dns.RR, len(d.keys)) for i, k := range d.keys { keys[i] = dns.Copy(k.K) keys[i].Header().Name = zone } m := new(dns.Msg) m.SetReply(state.Req) m.Answer = keys if !do { return m } incep, expir ...
[ "func", "(", "d", "Dnssec", ")", "getDNSKEY", "(", "state", "request", ".", "Request", ",", "zone", "string", ",", "do", "bool", ",", "server", "string", ")", "*", "dns", ".", "Msg", "{", "keys", ":=", "make", "(", "[", "]", "dns", ".", "RR", ","...
// getDNSKEY returns the correct DNSKEY to the client. Signatures are added when do is true.
[ "getDNSKEY", "returns", "the", "correct", "DNSKEY", "to", "the", "client", ".", "Signatures", "are", "added", "when", "do", "is", "true", "." ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/dnssec/dnskey.go#L62-L80
130,822
coredns/coredns
plugin/template/metrics.go
setupMetrics
func setupMetrics(c *caddy.Controller) error { c.OnStartup(func() error { metrics.MustRegister(c, templateMatchesCount, templateFailureCount, templateRRFailureCount) return nil }) return nil }
go
func setupMetrics(c *caddy.Controller) error { c.OnStartup(func() error { metrics.MustRegister(c, templateMatchesCount, templateFailureCount, templateRRFailureCount) return nil }) return nil }
[ "func", "setupMetrics", "(", "c", "*", "caddy", ".", "Controller", ")", "error", "{", "c", ".", "OnStartup", "(", "func", "(", ")", "error", "{", "metrics", ".", "MustRegister", "(", "c", ",", "templateMatchesCount", ",", "templateFailureCount", ",", "temp...
// OnStartupMetrics sets up the metrics on startup.
[ "OnStartupMetrics", "sets", "up", "the", "metrics", "on", "startup", "." ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/template/metrics.go#L33-L40
130,823
coredns/coredns
plugin/dnstap/handler.go
ServeDNS
func (h Dnstap) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error) { // Add send option into context so other plugin can decide on which DNSTap // message to be sent out sendOption := taprw.SendOption{Cq: true, Cr: true} newCtx := context.WithValue(ctx, DnstapSendOption, &sendOption) new...
go
func (h Dnstap) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error) { // Add send option into context so other plugin can decide on which DNSTap // message to be sent out sendOption := taprw.SendOption{Cq: true, Cr: true} newCtx := context.WithValue(ctx, DnstapSendOption, &sendOption) new...
[ "func", "(", "h", "Dnstap", ")", "ServeDNS", "(", "ctx", "context", ".", "Context", ",", "w", "dns", ".", "ResponseWriter", ",", "r", "*", "dns", ".", "Msg", ")", "(", "int", ",", "error", ")", "{", "// Add send option into context so other plugin can decide...
// ServeDNS logs the client query and response to dnstap and passes the dnstap Context.
[ "ServeDNS", "logs", "the", "client", "query", "and", "response", "to", "dnstap", "and", "passes", "the", "dnstap", "Context", "." ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/dnstap/handler.go#L62-L89
130,824
coredns/coredns
plugin/kubernetes/xfr.go
emitAddressRecord
func emitAddressRecord(c chan dns.RR, message msg.Service) string { ip := net.ParseIP(message.Host) var host string dnsType, _ := message.HostType() switch dnsType { case dns.TypeA: arec := message.NewA(msg.Domain(message.Key), ip) host = arec.Hdr.Name c <- arec case dns.TypeAAAA: arec := message.NewAAAA(...
go
func emitAddressRecord(c chan dns.RR, message msg.Service) string { ip := net.ParseIP(message.Host) var host string dnsType, _ := message.HostType() switch dnsType { case dns.TypeA: arec := message.NewA(msg.Domain(message.Key), ip) host = arec.Hdr.Name c <- arec case dns.TypeAAAA: arec := message.NewAAAA(...
[ "func", "emitAddressRecord", "(", "c", "chan", "dns", ".", "RR", ",", "message", "msg", ".", "Service", ")", "string", "{", "ip", ":=", "net", ".", "ParseIP", "(", "message", ".", "Host", ")", "\n", "var", "host", "string", "\n", "dnsType", ",", "_",...
// emitAddressRecord generates a new A or AAAA record based on the msg.Service and writes it to // a channel. // emitAddressRecord returns the host name from the generated record.
[ "emitAddressRecord", "generates", "a", "new", "A", "or", "AAAA", "record", "based", "on", "the", "msg", ".", "Service", "and", "writes", "it", "to", "a", "channel", ".", "emitAddressRecord", "returns", "the", "host", "name", "from", "the", "generated", "reco...
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/kubernetes/xfr.go#L192-L208
130,825
coredns/coredns
plugin/kubernetes/xfr.go
calcSRVWeight
func calcSRVWeight(numservices int) uint16 { var services []msg.Service for i := 0; i < numservices; i++ { services = append(services, msg.Service{}) } w := make(map[int]int) for _, serv := range services { weight := 100 if serv.Weight != 0 { weight = serv.Weight } if _, ok := w[serv.Priority]; !ok ...
go
func calcSRVWeight(numservices int) uint16 { var services []msg.Service for i := 0; i < numservices; i++ { services = append(services, msg.Service{}) } w := make(map[int]int) for _, serv := range services { weight := 100 if serv.Weight != 0 { weight = serv.Weight } if _, ok := w[serv.Priority]; !ok ...
[ "func", "calcSRVWeight", "(", "numservices", "int", ")", "uint16", "{", "var", "services", "[", "]", "msg", ".", "Service", "\n\n", "for", "i", ":=", "0", ";", "i", "<", "numservices", ";", "i", "++", "{", "services", "=", "append", "(", "services", ...
// calcSrvWeight borrows the logic implemented in plugin.SRV for dynamically // calculating the srv weight and priority
[ "calcSrvWeight", "borrows", "the", "logic", "implemented", "in", "plugin", ".", "SRV", "for", "dynamically", "calculating", "the", "srv", "weight", "and", "priority" ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/kubernetes/xfr.go#L212-L233
130,826
coredns/coredns
plugin/metrics/register.go
MustRegister
func MustRegister(c *caddy.Controller, cs ...prometheus.Collector) { m := dnsserver.GetConfig(c).Handler("prometheus") if m == nil { return } x, ok := m.(*Metrics) if !ok { return } for _, c := range cs { x.MustRegister(c) } }
go
func MustRegister(c *caddy.Controller, cs ...prometheus.Collector) { m := dnsserver.GetConfig(c).Handler("prometheus") if m == nil { return } x, ok := m.(*Metrics) if !ok { return } for _, c := range cs { x.MustRegister(c) } }
[ "func", "MustRegister", "(", "c", "*", "caddy", ".", "Controller", ",", "cs", "...", "prometheus", ".", "Collector", ")", "{", "m", ":=", "dnsserver", ".", "GetConfig", "(", "c", ")", ".", "Handler", "(", "\"", "\"", ")", "\n", "if", "m", "==", "ni...
// MustRegister registers the prometheus Collectors when the metrics middleware is used.
[ "MustRegister", "registers", "the", "prometheus", "Collectors", "when", "the", "metrics", "middleware", "is", "used", "." ]
e178291ed6a9eae5d24bae132b0f4c2f4d75f662
https://github.com/coredns/coredns/blob/e178291ed6a9eae5d24bae132b0f4c2f4d75f662/plugin/metrics/register.go#L11-L23
130,827
tendermint/tendermint
libs/cli/helper.go
WriteConfigVals
func WriteConfigVals(dir string, vals map[string]string) error { data := "" for k, v := range vals { data = data + fmt.Sprintf("%s = \"%s\"\n", k, v) } cfile := filepath.Join(dir, "config.toml") return ioutil.WriteFile(cfile, []byte(data), 0666) }
go
func WriteConfigVals(dir string, vals map[string]string) error { data := "" for k, v := range vals { data = data + fmt.Sprintf("%s = \"%s\"\n", k, v) } cfile := filepath.Join(dir, "config.toml") return ioutil.WriteFile(cfile, []byte(data), 0666) }
[ "func", "WriteConfigVals", "(", "dir", "string", ",", "vals", "map", "[", "string", "]", "string", ")", "error", "{", "data", ":=", "\"", "\"", "\n", "for", "k", ",", "v", ":=", "range", "vals", "{", "data", "=", "data", "+", "fmt", ".", "Sprintf",...
// WriteConfigVals writes a toml file with the given values. // It returns an error if writing was impossible.
[ "WriteConfigVals", "writes", "a", "toml", "file", "with", "the", "given", "values", ".", "It", "returns", "an", "error", "if", "writing", "was", "impossible", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/libs/cli/helper.go#L14-L21
130,828
tendermint/tendermint
abci/cmd/abci-cli/abci-cli.go
persistentArgs
func persistentArgs(line []byte) []string { // generate the arguments to run from original os.Args // to maintain flag arguments args := os.Args args = args[:len(args)-1] // remove the previous command argument if len(line) > 0 { // prevents introduction of extra space leading to argument parse errors args = a...
go
func persistentArgs(line []byte) []string { // generate the arguments to run from original os.Args // to maintain flag arguments args := os.Args args = args[:len(args)-1] // remove the previous command argument if len(line) > 0 { // prevents introduction of extra space leading to argument parse errors args = a...
[ "func", "persistentArgs", "(", "line", "[", "]", "byte", ")", "[", "]", "string", "{", "// generate the arguments to run from original os.Args", "// to maintain flag arguments", "args", ":=", "os", ".", "Args", "\n", "args", "=", "args", "[", ":", "len", "(", "a...
// Generates new Args array based off of previous call args to maintain flag persistence
[ "Generates", "new", "Args", "array", "based", "off", "of", "previous", "call", "args", "to", "maintain", "flag", "persistence" ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/abci/cmd/abci-cli/abci-cli.go#L307-L318
130,829
tendermint/tendermint
abci/cmd/abci-cli/abci-cli.go
cmdEcho
func cmdEcho(cmd *cobra.Command, args []string) error { msg := "" if len(args) > 0 { msg = args[0] } res, err := client.EchoSync(msg) if err != nil { return err } printResponse(cmd, args, response{ Data: []byte(res.Message), }) return nil }
go
func cmdEcho(cmd *cobra.Command, args []string) error { msg := "" if len(args) > 0 { msg = args[0] } res, err := client.EchoSync(msg) if err != nil { return err } printResponse(cmd, args, response{ Data: []byte(res.Message), }) return nil }
[ "func", "cmdEcho", "(", "cmd", "*", "cobra", ".", "Command", ",", "args", "[", "]", "string", ")", "error", "{", "msg", ":=", "\"", "\"", "\n", "if", "len", "(", "args", ")", ">", "0", "{", "msg", "=", "args", "[", "0", "]", "\n", "}", "\n", ...
// Have the application echo a message
[ "Have", "the", "application", "echo", "a", "message" ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/abci/cmd/abci-cli/abci-cli.go#L484-L497
130,830
tendermint/tendermint
abci/cmd/abci-cli/abci-cli.go
cmdInfo
func cmdInfo(cmd *cobra.Command, args []string) error { var version string if len(args) == 1 { version = args[0] } res, err := client.InfoSync(types.RequestInfo{Version: version}) if err != nil { return err } printResponse(cmd, args, response{ Data: []byte(res.Data), }) return nil }
go
func cmdInfo(cmd *cobra.Command, args []string) error { var version string if len(args) == 1 { version = args[0] } res, err := client.InfoSync(types.RequestInfo{Version: version}) if err != nil { return err } printResponse(cmd, args, response{ Data: []byte(res.Data), }) return nil }
[ "func", "cmdInfo", "(", "cmd", "*", "cobra", ".", "Command", ",", "args", "[", "]", "string", ")", "error", "{", "var", "version", "string", "\n", "if", "len", "(", "args", ")", "==", "1", "{", "version", "=", "args", "[", "0", "]", "\n", "}", ...
// Get some info from the application
[ "Get", "some", "info", "from", "the", "application" ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/abci/cmd/abci-cli/abci-cli.go#L500-L513
130,831
tendermint/tendermint
abci/cmd/abci-cli/abci-cli.go
cmdCheckTx
func cmdCheckTx(cmd *cobra.Command, args []string) error { if len(args) == 0 { printResponse(cmd, args, response{ Code: codeBad, Info: "want the tx", }) return nil } txBytes, err := stringOrHexToBytes(args[0]) if err != nil { return err } res, err := client.CheckTxSync(txBytes) if err != nil { re...
go
func cmdCheckTx(cmd *cobra.Command, args []string) error { if len(args) == 0 { printResponse(cmd, args, response{ Code: codeBad, Info: "want the tx", }) return nil } txBytes, err := stringOrHexToBytes(args[0]) if err != nil { return err } res, err := client.CheckTxSync(txBytes) if err != nil { re...
[ "func", "cmdCheckTx", "(", "cmd", "*", "cobra", ".", "Command", ",", "args", "[", "]", "string", ")", "error", "{", "if", "len", "(", "args", ")", "==", "0", "{", "printResponse", "(", "cmd", ",", "args", ",", "response", "{", "Code", ":", "codeBad...
// Validate a tx
[ "Validate", "a", "tx" ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/abci/cmd/abci-cli/abci-cli.go#L563-L586
130,832
tendermint/tendermint
abci/cmd/abci-cli/abci-cli.go
cmdCommit
func cmdCommit(cmd *cobra.Command, args []string) error { res, err := client.CommitSync() if err != nil { return err } printResponse(cmd, args, response{ Data: res.Data, }) return nil }
go
func cmdCommit(cmd *cobra.Command, args []string) error { res, err := client.CommitSync() if err != nil { return err } printResponse(cmd, args, response{ Data: res.Data, }) return nil }
[ "func", "cmdCommit", "(", "cmd", "*", "cobra", ".", "Command", ",", "args", "[", "]", "string", ")", "error", "{", "res", ",", "err", ":=", "client", ".", "CommitSync", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\...
// Get application Merkle root hash
[ "Get", "application", "Merkle", "root", "hash" ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/abci/cmd/abci-cli/abci-cli.go#L589-L598
130,833
tendermint/tendermint
abci/cmd/abci-cli/abci-cli.go
cmdQuery
func cmdQuery(cmd *cobra.Command, args []string) error { if len(args) == 0 { printResponse(cmd, args, response{ Code: codeBad, Info: "want the query", Log: "", }) return nil } queryBytes, err := stringOrHexToBytes(args[0]) if err != nil { return err } resQuery, err := client.QuerySync(types.Req...
go
func cmdQuery(cmd *cobra.Command, args []string) error { if len(args) == 0 { printResponse(cmd, args, response{ Code: codeBad, Info: "want the query", Log: "", }) return nil } queryBytes, err := stringOrHexToBytes(args[0]) if err != nil { return err } resQuery, err := client.QuerySync(types.Req...
[ "func", "cmdQuery", "(", "cmd", "*", "cobra", ".", "Command", ",", "args", "[", "]", "string", ")", "error", "{", "if", "len", "(", "args", ")", "==", "0", "{", "printResponse", "(", "cmd", ",", "args", ",", "response", "{", "Code", ":", "codeBad",...
// Query application state
[ "Query", "application", "state" ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/abci/cmd/abci-cli/abci-cli.go#L601-L636
130,834
tendermint/tendermint
libs/common/nil.go
IsEmpty
func IsEmpty(o interface{}) bool { rv := reflect.ValueOf(o) switch rv.Kind() { case reflect.Array, reflect.Chan, reflect.Map, reflect.Slice, reflect.String: return rv.Len() == 0 default: return false } }
go
func IsEmpty(o interface{}) bool { rv := reflect.ValueOf(o) switch rv.Kind() { case reflect.Array, reflect.Chan, reflect.Map, reflect.Slice, reflect.String: return rv.Len() == 0 default: return false } }
[ "func", "IsEmpty", "(", "o", "interface", "{", "}", ")", "bool", "{", "rv", ":=", "reflect", ".", "ValueOf", "(", "o", ")", "\n", "switch", "rv", ".", "Kind", "(", ")", "{", "case", "reflect", ".", "Array", ",", "reflect", ".", "Chan", ",", "refl...
// Returns true if it has zero length.
[ "Returns", "true", "if", "it", "has", "zero", "length", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/libs/common/nil.go#L21-L29
130,835
tendermint/tendermint
mempool/mempool.go
PreCheckAminoMaxBytes
func PreCheckAminoMaxBytes(maxBytes int64) PreCheckFunc { return func(tx types.Tx) error { // We have to account for the amino overhead in the tx size as well // NOTE: fieldNum = 1 as types.Block.Data contains Txs []Tx as first field. // If this field order ever changes this needs to updated here accordingly. ...
go
func PreCheckAminoMaxBytes(maxBytes int64) PreCheckFunc { return func(tx types.Tx) error { // We have to account for the amino overhead in the tx size as well // NOTE: fieldNum = 1 as types.Block.Data contains Txs []Tx as first field. // If this field order ever changes this needs to updated here accordingly. ...
[ "func", "PreCheckAminoMaxBytes", "(", "maxBytes", "int64", ")", "PreCheckFunc", "{", "return", "func", "(", "tx", "types", ".", "Tx", ")", "error", "{", "// We have to account for the amino overhead in the tx size as well", "// NOTE: fieldNum = 1 as types.Block.Data contains Tx...
// PreCheckAminoMaxBytes checks that the size of the transaction plus the amino // overhead is smaller or equal to the expected maxBytes.
[ "PreCheckAminoMaxBytes", "checks", "that", "the", "size", "of", "the", "transaction", "plus", "the", "amino", "overhead", "is", "smaller", "or", "equal", "to", "the", "expected", "maxBytes", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/mempool/mempool.go#L111-L126
130,836
tendermint/tendermint
mempool/mempool.go
PostCheckMaxGas
func PostCheckMaxGas(maxGas int64) PostCheckFunc { return func(tx types.Tx, res *abci.ResponseCheckTx) error { if maxGas == -1 { return nil } if res.GasWanted < 0 { return fmt.Errorf("gas wanted %d is negative", res.GasWanted) } if res.GasWanted > maxGas { return fmt.Errorf("gas wanted %d is gre...
go
func PostCheckMaxGas(maxGas int64) PostCheckFunc { return func(tx types.Tx, res *abci.ResponseCheckTx) error { if maxGas == -1 { return nil } if res.GasWanted < 0 { return fmt.Errorf("gas wanted %d is negative", res.GasWanted) } if res.GasWanted > maxGas { return fmt.Errorf("gas wanted %d is gre...
[ "func", "PostCheckMaxGas", "(", "maxGas", "int64", ")", "PostCheckFunc", "{", "return", "func", "(", "tx", "types", ".", "Tx", ",", "res", "*", "abci", ".", "ResponseCheckTx", ")", "error", "{", "if", "maxGas", "==", "-", "1", "{", "return", "nil", "\n...
// PostCheckMaxGas checks that the wanted gas is smaller or equal to the passed // maxGas. Returns nil if maxGas is -1.
[ "PostCheckMaxGas", "checks", "that", "the", "wanted", "gas", "is", "smaller", "or", "equal", "to", "the", "passed", "maxGas", ".", "Returns", "nil", "if", "maxGas", "is", "-", "1", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/mempool/mempool.go#L130-L145
130,837
tendermint/tendermint
mempool/mempool.go
TxID
func TxID(tx []byte) string { return fmt.Sprintf("%X", types.Tx(tx).Hash()) }
go
func TxID(tx []byte) string { return fmt.Sprintf("%X", types.Tx(tx).Hash()) }
[ "func", "TxID", "(", "tx", "[", "]", "byte", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "types", ".", "Tx", "(", "tx", ")", ".", "Hash", "(", ")", ")", "\n", "}" ]
// TxID is the hex encoded hash of the bytes as a types.Tx.
[ "TxID", "is", "the", "hex", "encoded", "hash", "of", "the", "bytes", "as", "a", "types", ".", "Tx", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/mempool/mempool.go#L148-L150
130,838
tendermint/tendermint
mempool/mempool.go
txKey
func txKey(tx types.Tx) [sha256.Size]byte { return sha256.Sum256(tx) }
go
func txKey(tx types.Tx) [sha256.Size]byte { return sha256.Sum256(tx) }
[ "func", "txKey", "(", "tx", "types", ".", "Tx", ")", "[", "sha256", ".", "Size", "]", "byte", "{", "return", "sha256", ".", "Sum256", "(", "tx", ")", "\n", "}" ]
// txKey is the fixed length array sha256 hash used as the key in maps.
[ "txKey", "is", "the", "fixed", "length", "array", "sha256", "hash", "used", "as", "the", "key", "in", "maps", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/mempool/mempool.go#L153-L155
130,839
tendermint/tendermint
mempool/mempool.go
NewMempool
func NewMempool( config *cfg.MempoolConfig, proxyAppConn proxy.AppConnMempool, height int64, options ...MempoolOption, ) *Mempool { mempool := &Mempool{ config: config, proxyAppConn: proxyAppConn, txs: clist.New(), height: height, rechecking: 0, recheckCursor: nil, recheck...
go
func NewMempool( config *cfg.MempoolConfig, proxyAppConn proxy.AppConnMempool, height int64, options ...MempoolOption, ) *Mempool { mempool := &Mempool{ config: config, proxyAppConn: proxyAppConn, txs: clist.New(), height: height, rechecking: 0, recheckCursor: nil, recheck...
[ "func", "NewMempool", "(", "config", "*", "cfg", ".", "MempoolConfig", ",", "proxyAppConn", "proxy", ".", "AppConnMempool", ",", "height", "int64", ",", "options", "...", "MempoolOption", ",", ")", "*", "Mempool", "{", "mempool", ":=", "&", "Mempool", "{", ...
// NewMempool returns a new Mempool with the given configuration and connection to an application.
[ "NewMempool", "returns", "a", "new", "Mempool", "with", "the", "given", "configuration", "and", "connection", "to", "an", "application", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/mempool/mempool.go#L205-L232
130,840
tendermint/tendermint
mempool/mempool.go
CloseWAL
func (mem *Mempool) CloseWAL() { mem.proxyMtx.Lock() defer mem.proxyMtx.Unlock() if err := mem.wal.Close(); err != nil { mem.logger.Error("Error closing WAL", "err", err) } mem.wal = nil }
go
func (mem *Mempool) CloseWAL() { mem.proxyMtx.Lock() defer mem.proxyMtx.Unlock() if err := mem.wal.Close(); err != nil { mem.logger.Error("Error closing WAL", "err", err) } mem.wal = nil }
[ "func", "(", "mem", "*", "Mempool", ")", "CloseWAL", "(", ")", "{", "mem", ".", "proxyMtx", ".", "Lock", "(", ")", "\n", "defer", "mem", ".", "proxyMtx", ".", "Unlock", "(", ")", "\n\n", "if", "err", ":=", "mem", ".", "wal", ".", "Close", "(", ...
// CloseWAL closes and discards the underlying WAL file. // Any further writes will not be relayed to disk.
[ "CloseWAL", "closes", "and", "discards", "the", "underlying", "WAL", "file", ".", "Any", "further", "writes", "will", "not", "be", "relayed", "to", "disk", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/mempool/mempool.go#L282-L290
130,841
tendermint/tendermint
mempool/mempool.go
Flush
func (mem *Mempool) Flush() { mem.proxyMtx.Lock() defer mem.proxyMtx.Unlock() mem.cache.Reset() for e := mem.txs.Front(); e != nil; e = e.Next() { mem.txs.Remove(e) e.DetachPrev() } mem.txsMap = sync.Map{} _ = atomic.SwapInt64(&mem.txsBytes, 0) }
go
func (mem *Mempool) Flush() { mem.proxyMtx.Lock() defer mem.proxyMtx.Unlock() mem.cache.Reset() for e := mem.txs.Front(); e != nil; e = e.Next() { mem.txs.Remove(e) e.DetachPrev() } mem.txsMap = sync.Map{} _ = atomic.SwapInt64(&mem.txsBytes, 0) }
[ "func", "(", "mem", "*", "Mempool", ")", "Flush", "(", ")", "{", "mem", ".", "proxyMtx", ".", "Lock", "(", ")", "\n", "defer", "mem", ".", "proxyMtx", ".", "Unlock", "(", ")", "\n\n", "mem", ".", "cache", ".", "Reset", "(", ")", "\n\n", "for", ...
// Flush removes all transactions from the mempool and cache
[ "Flush", "removes", "all", "transactions", "from", "the", "mempool", "and", "cache" ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/mempool/mempool.go#L319-L332
130,842
tendermint/tendermint
mempool/mempool.go
CheckTxWithInfo
func (mem *Mempool) CheckTxWithInfo(tx types.Tx, cb func(*abci.Response), txInfo TxInfo) (err error) { mem.proxyMtx.Lock() // use defer to unlock mutex because application (*local client*) might panic defer mem.proxyMtx.Unlock() var ( memSize = mem.Size() txsBytes = mem.TxsBytes() ) if memSize >= mem.config...
go
func (mem *Mempool) CheckTxWithInfo(tx types.Tx, cb func(*abci.Response), txInfo TxInfo) (err error) { mem.proxyMtx.Lock() // use defer to unlock mutex because application (*local client*) might panic defer mem.proxyMtx.Unlock() var ( memSize = mem.Size() txsBytes = mem.TxsBytes() ) if memSize >= mem.config...
[ "func", "(", "mem", "*", "Mempool", ")", "CheckTxWithInfo", "(", "tx", "types", ".", "Tx", ",", "cb", "func", "(", "*", "abci", ".", "Response", ")", ",", "txInfo", "TxInfo", ")", "(", "err", "error", ")", "{", "mem", ".", "proxyMtx", ".", "Lock", ...
// CheckTxWithInfo performs the same operation as CheckTx, but with extra meta data about the tx. // Currently this metadata is the peer who sent it, // used to prevent the tx from being gossiped back to them.
[ "CheckTxWithInfo", "performs", "the", "same", "operation", "as", "CheckTx", "but", "with", "extra", "meta", "data", "about", "the", "tx", ".", "Currently", "this", "metadata", "is", "the", "peer", "who", "sent", "it", "used", "to", "prevent", "the", "tx", ...
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/mempool/mempool.go#L360-L431
130,843
tendermint/tendermint
mempool/mempool.go
resCbFirstTime
func (mem *Mempool) resCbFirstTime(tx []byte, peerID uint16, res *abci.Response) { switch r := res.Value.(type) { case *abci.Response_CheckTx: var postCheckErr error if mem.postCheck != nil { postCheckErr = mem.postCheck(tx, r.CheckTx) } if (r.CheckTx.Code == abci.CodeTypeOK) && postCheckErr == nil { me...
go
func (mem *Mempool) resCbFirstTime(tx []byte, peerID uint16, res *abci.Response) { switch r := res.Value.(type) { case *abci.Response_CheckTx: var postCheckErr error if mem.postCheck != nil { postCheckErr = mem.postCheck(tx, r.CheckTx) } if (r.CheckTx.Code == abci.CodeTypeOK) && postCheckErr == nil { me...
[ "func", "(", "mem", "*", "Mempool", ")", "resCbFirstTime", "(", "tx", "[", "]", "byte", ",", "peerID", "uint16", ",", "res", "*", "abci", ".", "Response", ")", "{", "switch", "r", ":=", "res", ".", "Value", ".", "(", "type", ")", "{", "case", "*"...
// callback, which is called after the app checked the tx for the first time. // // The case where the app checks the tx for the second and subsequent times is // handled by the resCbRecheck callback.
[ "callback", "which", "is", "called", "after", "the", "app", "checked", "the", "tx", "for", "the", "first", "time", ".", "The", "case", "where", "the", "app", "checks", "the", "tx", "for", "the", "second", "and", "subsequent", "times", "is", "handled", "b...
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/mempool/mempool.go#L507-L539
130,844
tendermint/tendermint
mempool/mempool.go
resCbRecheck
func (mem *Mempool) resCbRecheck(req *abci.Request, res *abci.Response) { switch r := res.Value.(type) { case *abci.Response_CheckTx: tx := req.GetCheckTx().Tx memTx := mem.recheckCursor.Value.(*mempoolTx) if !bytes.Equal(tx, memTx.tx) { panic(fmt.Sprintf( "Unexpected tx response from proxy during rechec...
go
func (mem *Mempool) resCbRecheck(req *abci.Request, res *abci.Response) { switch r := res.Value.(type) { case *abci.Response_CheckTx: tx := req.GetCheckTx().Tx memTx := mem.recheckCursor.Value.(*mempoolTx) if !bytes.Equal(tx, memTx.tx) { panic(fmt.Sprintf( "Unexpected tx response from proxy during rechec...
[ "func", "(", "mem", "*", "Mempool", ")", "resCbRecheck", "(", "req", "*", "abci", ".", "Request", ",", "res", "*", "abci", ".", "Response", ")", "{", "switch", "r", ":=", "res", ".", "Value", ".", "(", "type", ")", "{", "case", "*", "abci", ".", ...
// callback, which is called after the app rechecked the tx. // // The case where the app checks the tx for the first time is handled by the // resCbFirstTime callback.
[ "callback", "which", "is", "called", "after", "the", "app", "rechecked", "the", "tx", ".", "The", "case", "where", "the", "app", "checks", "the", "tx", "for", "the", "first", "time", "is", "handled", "by", "the", "resCbFirstTime", "callback", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/mempool/mempool.go#L545-L586
130,845
tendermint/tendermint
mempool/mempool.go
newMapTxCache
func newMapTxCache(cacheSize int) *mapTxCache { return &mapTxCache{ size: cacheSize, map_: make(map[[sha256.Size]byte]*list.Element, cacheSize), list: list.New(), } }
go
func newMapTxCache(cacheSize int) *mapTxCache { return &mapTxCache{ size: cacheSize, map_: make(map[[sha256.Size]byte]*list.Element, cacheSize), list: list.New(), } }
[ "func", "newMapTxCache", "(", "cacheSize", "int", ")", "*", "mapTxCache", "{", "return", "&", "mapTxCache", "{", "size", ":", "cacheSize", ",", "map_", ":", "make", "(", "map", "[", "[", "sha256", ".", "Size", "]", "byte", "]", "*", "list", ".", "Ele...
// newMapTxCache returns a new mapTxCache.
[ "newMapTxCache", "returns", "a", "new", "mapTxCache", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/mempool/mempool.go#L799-L805
130,846
tendermint/tendermint
mempool/mempool.go
Reset
func (cache *mapTxCache) Reset() { cache.mtx.Lock() cache.map_ = make(map[[sha256.Size]byte]*list.Element, cache.size) cache.list.Init() cache.mtx.Unlock() }
go
func (cache *mapTxCache) Reset() { cache.mtx.Lock() cache.map_ = make(map[[sha256.Size]byte]*list.Element, cache.size) cache.list.Init() cache.mtx.Unlock() }
[ "func", "(", "cache", "*", "mapTxCache", ")", "Reset", "(", ")", "{", "cache", ".", "mtx", ".", "Lock", "(", ")", "\n", "cache", ".", "map_", "=", "make", "(", "map", "[", "[", "sha256", ".", "Size", "]", "byte", "]", "*", "list", ".", "Element...
// Reset resets the cache to an empty state.
[ "Reset", "resets", "the", "cache", "to", "an", "empty", "state", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/mempool/mempool.go#L808-L813
130,847
tendermint/tendermint
mempool/mempool.go
Push
func (cache *mapTxCache) Push(tx types.Tx) bool { cache.mtx.Lock() defer cache.mtx.Unlock() // Use the tx hash in the cache txHash := txKey(tx) if moved, exists := cache.map_[txHash]; exists { cache.list.MoveToBack(moved) return false } if cache.list.Len() >= cache.size { popped := cache.list.Front() p...
go
func (cache *mapTxCache) Push(tx types.Tx) bool { cache.mtx.Lock() defer cache.mtx.Unlock() // Use the tx hash in the cache txHash := txKey(tx) if moved, exists := cache.map_[txHash]; exists { cache.list.MoveToBack(moved) return false } if cache.list.Len() >= cache.size { popped := cache.list.Front() p...
[ "func", "(", "cache", "*", "mapTxCache", ")", "Push", "(", "tx", "types", ".", "Tx", ")", "bool", "{", "cache", ".", "mtx", ".", "Lock", "(", ")", "\n", "defer", "cache", ".", "mtx", ".", "Unlock", "(", ")", "\n\n", "// Use the tx hash in the cache", ...
// Push adds the given tx to the cache and returns true. It returns // false if tx is already in the cache.
[ "Push", "adds", "the", "given", "tx", "to", "the", "cache", "and", "returns", "true", ".", "It", "returns", "false", "if", "tx", "is", "already", "in", "the", "cache", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/mempool/mempool.go#L817-L839
130,848
tendermint/tendermint
mempool/mempool.go
Remove
func (cache *mapTxCache) Remove(tx types.Tx) { cache.mtx.Lock() txHash := txKey(tx) popped := cache.map_[txHash] delete(cache.map_, txHash) if popped != nil { cache.list.Remove(popped) } cache.mtx.Unlock() }
go
func (cache *mapTxCache) Remove(tx types.Tx) { cache.mtx.Lock() txHash := txKey(tx) popped := cache.map_[txHash] delete(cache.map_, txHash) if popped != nil { cache.list.Remove(popped) } cache.mtx.Unlock() }
[ "func", "(", "cache", "*", "mapTxCache", ")", "Remove", "(", "tx", "types", ".", "Tx", ")", "{", "cache", ".", "mtx", ".", "Lock", "(", ")", "\n", "txHash", ":=", "txKey", "(", "tx", ")", "\n", "popped", ":=", "cache", ".", "map_", "[", "txHash",...
// Remove removes the given tx from the cache.
[ "Remove", "removes", "the", "given", "tx", "from", "the", "cache", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/mempool/mempool.go#L842-L852
130,849
tendermint/tendermint
cmd/tendermint/commands/root.go
ParseConfig
func ParseConfig() (*cfg.Config, error) { conf := cfg.DefaultConfig() err := viper.Unmarshal(conf) if err != nil { return nil, err } conf.SetRoot(conf.RootDir) cfg.EnsureRoot(conf.RootDir) if err = conf.ValidateBasic(); err != nil { return nil, fmt.Errorf("Error in config file: %v", err) } return conf, err...
go
func ParseConfig() (*cfg.Config, error) { conf := cfg.DefaultConfig() err := viper.Unmarshal(conf) if err != nil { return nil, err } conf.SetRoot(conf.RootDir) cfg.EnsureRoot(conf.RootDir) if err = conf.ValidateBasic(); err != nil { return nil, fmt.Errorf("Error in config file: %v", err) } return conf, err...
[ "func", "ParseConfig", "(", ")", "(", "*", "cfg", ".", "Config", ",", "error", ")", "{", "conf", ":=", "cfg", ".", "DefaultConfig", "(", ")", "\n", "err", ":=", "viper", ".", "Unmarshal", "(", "conf", ")", "\n", "if", "err", "!=", "nil", "{", "re...
// ParseConfig retrieves the default environment configuration, // sets up the Tendermint root and ensures that the root exists
[ "ParseConfig", "retrieves", "the", "default", "environment", "configuration", "sets", "up", "the", "Tendermint", "root", "and", "ensures", "that", "the", "root", "exists" ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/cmd/tendermint/commands/root.go#L31-L43
130,850
tendermint/tendermint
lite/dbprovider.go
SaveFullCommit
func (dbp *DBProvider) SaveFullCommit(fc FullCommit) error { dbp.logger.Info("DBProvider.SaveFullCommit()...", "fc", fc) batch := dbp.db.NewBatch() defer batch.Close() // Save the fc.validators. // We might be overwriting what we already have, but // it makes the logic easier for now. vsKey := validatorSetKey(...
go
func (dbp *DBProvider) SaveFullCommit(fc FullCommit) error { dbp.logger.Info("DBProvider.SaveFullCommit()...", "fc", fc) batch := dbp.db.NewBatch() defer batch.Close() // Save the fc.validators. // We might be overwriting what we already have, but // it makes the logic easier for now. vsKey := validatorSetKey(...
[ "func", "(", "dbp", "*", "DBProvider", ")", "SaveFullCommit", "(", "fc", "FullCommit", ")", "error", "{", "dbp", ".", "logger", ".", "Info", "(", "\"", "\"", ",", "\"", "\"", ",", "fc", ")", "\n", "batch", ":=", "dbp", ".", "db", ".", "NewBatch", ...
// Implements PersistentProvider.
[ "Implements", "PersistentProvider", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/lite/dbprovider.go#L53-L95
130,851
tendermint/tendermint
p2p/trust/metric.go
NewMetricWithConfig
func NewMetricWithConfig(tmc TrustMetricConfig) *TrustMetric { tm := new(TrustMetric) config := customConfig(tmc) // Setup using the configuration values tm.proportionalWeight = config.ProportionalWeight tm.integralWeight = config.IntegralWeight tm.intervalLen = config.IntervalLength // The maximum number of ti...
go
func NewMetricWithConfig(tmc TrustMetricConfig) *TrustMetric { tm := new(TrustMetric) config := customConfig(tmc) // Setup using the configuration values tm.proportionalWeight = config.ProportionalWeight tm.integralWeight = config.IntegralWeight tm.intervalLen = config.IntervalLength // The maximum number of ti...
[ "func", "NewMetricWithConfig", "(", "tmc", "TrustMetricConfig", ")", "*", "TrustMetric", "{", "tm", ":=", "new", "(", "TrustMetric", ")", "\n", "config", ":=", "customConfig", "(", "tmc", ")", "\n\n", "// Setup using the configuration values", "tm", ".", "proporti...
// NewMetricWithConfig returns a trust metric with a custom configuration. // Use Start to begin tracking the quality of peer behavior over time
[ "NewMetricWithConfig", "returns", "a", "trust", "metric", "with", "a", "custom", "configuration", ".", "Use", "Start", "to", "begin", "tracking", "the", "quality", "of", "peer", "behavior", "over", "time" ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/p2p/trust/metric.go#L92-L109
130,852
tendermint/tendermint
p2p/trust/metric.go
HistoryJSON
func (tm *TrustMetric) HistoryJSON() MetricHistoryJSON { tm.mtx.Lock() defer tm.mtx.Unlock() return MetricHistoryJSON{ NumIntervals: tm.numIntervals, History: tm.history, } }
go
func (tm *TrustMetric) HistoryJSON() MetricHistoryJSON { tm.mtx.Lock() defer tm.mtx.Unlock() return MetricHistoryJSON{ NumIntervals: tm.numIntervals, History: tm.history, } }
[ "func", "(", "tm", "*", "TrustMetric", ")", "HistoryJSON", "(", ")", "MetricHistoryJSON", "{", "tm", ".", "mtx", ".", "Lock", "(", ")", "\n", "defer", "tm", ".", "mtx", ".", "Unlock", "(", ")", "\n\n", "return", "MetricHistoryJSON", "{", "NumIntervals", ...
// Returns a snapshot of the trust metric history data
[ "Returns", "a", "snapshot", "of", "the", "trust", "metric", "history", "data" ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/p2p/trust/metric.go#L125-L133
130,853
tendermint/tendermint
p2p/trust/metric.go
Init
func (tm *TrustMetric) Init(hist MetricHistoryJSON) { // Restore the number of time intervals we have previously tracked if hist.NumIntervals > tm.maxIntervals { hist.NumIntervals = tm.maxIntervals } tm.numIntervals = hist.NumIntervals // Restore the history and its current size if len(hist.History) > tm.histor...
go
func (tm *TrustMetric) Init(hist MetricHistoryJSON) { // Restore the number of time intervals we have previously tracked if hist.NumIntervals > tm.maxIntervals { hist.NumIntervals = tm.maxIntervals } tm.numIntervals = hist.NumIntervals // Restore the history and its current size if len(hist.History) > tm.histor...
[ "func", "(", "tm", "*", "TrustMetric", ")", "Init", "(", "hist", "MetricHistoryJSON", ")", "{", "// Restore the number of time intervals we have previously tracked", "if", "hist", ".", "NumIntervals", ">", "tm", ".", "maxIntervals", "{", "hist", ".", "NumIntervals", ...
// Instantiates a trust metric by loading the history data for a single peer. // This is called only once and only right after creation, which is why the // lock is not held while accessing the trust metric struct members
[ "Instantiates", "a", "trust", "metric", "by", "loading", "the", "history", "data", "for", "a", "single", "peer", ".", "This", "is", "called", "only", "once", "and", "only", "right", "after", "creation", "which", "is", "why", "the", "lock", "is", "not", "...
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/p2p/trust/metric.go#L138-L163
130,854
tendermint/tendermint
p2p/trust/metric.go
Pause
func (tm *TrustMetric) Pause() { tm.mtx.Lock() defer tm.mtx.Unlock() // Pause the metric for now tm.paused = true }
go
func (tm *TrustMetric) Pause() { tm.mtx.Lock() defer tm.mtx.Unlock() // Pause the metric for now tm.paused = true }
[ "func", "(", "tm", "*", "TrustMetric", ")", "Pause", "(", ")", "{", "tm", ".", "mtx", ".", "Lock", "(", ")", "\n", "defer", "tm", ".", "mtx", ".", "Unlock", "(", ")", "\n\n", "// Pause the metric for now", "tm", ".", "paused", "=", "true", "\n", "}...
// Pause tells the metric to pause recording data over time intervals. // All method calls that indicate events will unpause the metric
[ "Pause", "tells", "the", "metric", "to", "pause", "recording", "data", "over", "time", "intervals", ".", "All", "method", "calls", "that", "indicate", "events", "will", "unpause", "the", "metric" ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/p2p/trust/metric.go#L167-L173
130,855
tendermint/tendermint
p2p/trust/metric.go
TrustValue
func (tm *TrustMetric) TrustValue() float64 { tm.mtx.Lock() defer tm.mtx.Unlock() return tm.calcTrustValue() }
go
func (tm *TrustMetric) TrustValue() float64 { tm.mtx.Lock() defer tm.mtx.Unlock() return tm.calcTrustValue() }
[ "func", "(", "tm", "*", "TrustMetric", ")", "TrustValue", "(", ")", "float64", "{", "tm", ".", "mtx", ".", "Lock", "(", ")", "\n", "defer", "tm", ".", "mtx", ".", "Unlock", "(", ")", "\n\n", "return", "tm", ".", "calcTrustValue", "(", ")", "\n", ...
// TrustValue gets the dependable trust value; always between 0 and 1
[ "TrustValue", "gets", "the", "dependable", "trust", "value", ";", "always", "between", "0", "and", "1" ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/p2p/trust/metric.go#L194-L199
130,856
tendermint/tendermint
p2p/trust/metric.go
TrustScore
func (tm *TrustMetric) TrustScore() int { score := tm.TrustValue() * 100 return int(math.Floor(score)) }
go
func (tm *TrustMetric) TrustScore() int { score := tm.TrustValue() * 100 return int(math.Floor(score)) }
[ "func", "(", "tm", "*", "TrustMetric", ")", "TrustScore", "(", ")", "int", "{", "score", ":=", "tm", ".", "TrustValue", "(", ")", "*", "100", "\n\n", "return", "int", "(", "math", ".", "Floor", "(", "score", ")", ")", "\n", "}" ]
// TrustScore gets a score based on the trust value always between 0 and 100
[ "TrustScore", "gets", "a", "score", "based", "on", "the", "trust", "value", "always", "between", "0", "and", "100" ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/p2p/trust/metric.go#L202-L206
130,857
tendermint/tendermint
p2p/trust/metric.go
NextTimeInterval
func (tm *TrustMetric) NextTimeInterval() { tm.mtx.Lock() defer tm.mtx.Unlock() if tm.paused { // Do not prepare for the next time interval while paused return } // Add the current trust value to the history data newHist := tm.calcTrustValue() tm.history = append(tm.history, newHist) // Update history an...
go
func (tm *TrustMetric) NextTimeInterval() { tm.mtx.Lock() defer tm.mtx.Unlock() if tm.paused { // Do not prepare for the next time interval while paused return } // Add the current trust value to the history data newHist := tm.calcTrustValue() tm.history = append(tm.history, newHist) // Update history an...
[ "func", "(", "tm", "*", "TrustMetric", ")", "NextTimeInterval", "(", ")", "{", "tm", ".", "mtx", ".", "Lock", "(", ")", "\n", "defer", "tm", ".", "mtx", ".", "Unlock", "(", ")", "\n\n", "if", "tm", ".", "paused", "{", "// Do not prepare for the next ti...
// NextTimeInterval saves current time interval data and prepares for the following interval
[ "NextTimeInterval", "saves", "current", "time", "interval", "data", "and", "prepares", "for", "the", "following", "interval" ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/p2p/trust/metric.go#L209-L245
130,858
tendermint/tendermint
p2p/trust/metric.go
SetTicker
func (tm *TrustMetric) SetTicker(ticker MetricTicker) { tm.mtx.Lock() defer tm.mtx.Unlock() tm.testTicker = ticker }
go
func (tm *TrustMetric) SetTicker(ticker MetricTicker) { tm.mtx.Lock() defer tm.mtx.Unlock() tm.testTicker = ticker }
[ "func", "(", "tm", "*", "TrustMetric", ")", "SetTicker", "(", "ticker", "MetricTicker", ")", "{", "tm", ".", "mtx", ".", "Lock", "(", ")", "\n", "defer", "tm", ".", "mtx", ".", "Unlock", "(", ")", "\n\n", "tm", ".", "testTicker", "=", "ticker", "\n...
// SetTicker allows a TestTicker to be provided that will manually control // the passing of time from the perspective of the TrustMetric. // The ticker must be set before Start is called on the metric
[ "SetTicker", "allows", "a", "TestTicker", "to", "be", "provided", "that", "will", "manually", "control", "the", "passing", "of", "time", "from", "the", "perspective", "of", "the", "TrustMetric", ".", "The", "ticker", "must", "be", "set", "before", "Start", "...
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/p2p/trust/metric.go#L250-L255
130,859
tendermint/tendermint
p2p/trust/metric.go
Copy
func (tm *TrustMetric) Copy() *TrustMetric { if tm == nil { return nil } tm.mtx.Lock() defer tm.mtx.Unlock() return &TrustMetric{ proportionalWeight: tm.proportionalWeight, integralWeight: tm.integralWeight, numIntervals: tm.numIntervals, maxIntervals: tm.maxIntervals, intervalLen: ...
go
func (tm *TrustMetric) Copy() *TrustMetric { if tm == nil { return nil } tm.mtx.Lock() defer tm.mtx.Unlock() return &TrustMetric{ proportionalWeight: tm.proportionalWeight, integralWeight: tm.integralWeight, numIntervals: tm.numIntervals, maxIntervals: tm.maxIntervals, intervalLen: ...
[ "func", "(", "tm", "*", "TrustMetric", ")", "Copy", "(", ")", "*", "TrustMetric", "{", "if", "tm", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "tm", ".", "mtx", ".", "Lock", "(", ")", "\n", "defer", "tm", ".", "mtx", ".", "Unlock", "(...
// Copy returns a new trust metric with members containing the same values
[ "Copy", "returns", "a", "new", "trust", "metric", "with", "members", "containing", "the", "same", "values" ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/p2p/trust/metric.go#L258-L283
130,860
tendermint/tendermint
p2p/trust/metric.go
unpause
func (tm *TrustMetric) unpause() { // Check if this is the first experience with // what we are tracking since being paused if tm.paused { tm.good = 0 tm.bad = 0 // New events cause us to unpause the metric tm.paused = false } }
go
func (tm *TrustMetric) unpause() { // Check if this is the first experience with // what we are tracking since being paused if tm.paused { tm.good = 0 tm.bad = 0 // New events cause us to unpause the metric tm.paused = false } }
[ "func", "(", "tm", "*", "TrustMetric", ")", "unpause", "(", ")", "{", "// Check if this is the first experience with", "// what we are tracking since being paused", "if", "tm", ".", "paused", "{", "tm", ".", "good", "=", "0", "\n", "tm", ".", "bad", "=", "0", ...
// Wakes the trust metric up if it is currently paused // This method needs to be called with the mutex locked
[ "Wakes", "the", "trust", "metric", "up", "if", "it", "is", "currently", "paused", "This", "method", "needs", "to", "be", "called", "with", "the", "mutex", "locked" ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/p2p/trust/metric.go#L311-L320
130,861
tendermint/tendermint
p2p/trust/metric.go
calcTrustValue
func (tm *TrustMetric) calcTrustValue() float64 { weightedP := tm.proportionalWeight * tm.proportionalValue() weightedI := tm.integralWeight * tm.historyValue weightedD := tm.weightedDerivative() tv := weightedP + weightedI + weightedD // Do not return a negative value. if tv < 0 { tv = 0 } return tv }
go
func (tm *TrustMetric) calcTrustValue() float64 { weightedP := tm.proportionalWeight * tm.proportionalValue() weightedI := tm.integralWeight * tm.historyValue weightedD := tm.weightedDerivative() tv := weightedP + weightedI + weightedD // Do not return a negative value. if tv < 0 { tv = 0 } return tv }
[ "func", "(", "tm", "*", "TrustMetric", ")", "calcTrustValue", "(", ")", "float64", "{", "weightedP", ":=", "tm", ".", "proportionalWeight", "*", "tm", ".", "proportionalValue", "(", ")", "\n", "weightedI", ":=", "tm", ".", "integralWeight", "*", "tm", ".",...
// Calculates the trust value for the request processing
[ "Calculates", "the", "trust", "value", "for", "the", "request", "processing" ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/p2p/trust/metric.go#L323-L334
130,862
tendermint/tendermint
p2p/trust/metric.go
weightedDerivative
func (tm *TrustMetric) weightedDerivative() float64 { var weight float64 = defaultDerivativeGamma1 d := tm.derivativeValue() if d < 0 { weight = defaultDerivativeGamma2 } return weight * d }
go
func (tm *TrustMetric) weightedDerivative() float64 { var weight float64 = defaultDerivativeGamma1 d := tm.derivativeValue() if d < 0 { weight = defaultDerivativeGamma2 } return weight * d }
[ "func", "(", "tm", "*", "TrustMetric", ")", "weightedDerivative", "(", ")", "float64", "{", "var", "weight", "float64", "=", "defaultDerivativeGamma1", "\n\n", "d", ":=", "tm", ".", "derivativeValue", "(", ")", "\n", "if", "d", "<", "0", "{", "weight", "...
// Strengthens the derivative component when the change is negative
[ "Strengthens", "the", "derivative", "component", "when", "the", "change", "is", "negative" ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/p2p/trust/metric.go#L348-L356
130,863
tendermint/tendermint
p2p/trust/metric.go
fadedMemoryValue
func (tm *TrustMetric) fadedMemoryValue(interval int) float64 { first := tm.historySize - 1 if interval == 0 { // Base case return tm.history[first] } offset := intervalToHistoryOffset(interval) return tm.history[first-offset] }
go
func (tm *TrustMetric) fadedMemoryValue(interval int) float64 { first := tm.historySize - 1 if interval == 0 { // Base case return tm.history[first] } offset := intervalToHistoryOffset(interval) return tm.history[first-offset] }
[ "func", "(", "tm", "*", "TrustMetric", ")", "fadedMemoryValue", "(", "interval", "int", ")", "float64", "{", "first", ":=", "tm", ".", "historySize", "-", "1", "\n\n", "if", "interval", "==", "0", "{", "// Base case", "return", "tm", ".", "history", "[",...
// Retrieves the actual history data value that represents the requested time interval
[ "Retrieves", "the", "actual", "history", "data", "value", "that", "represents", "the", "requested", "time", "interval" ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/p2p/trust/metric.go#L375-L385
130,864
tendermint/tendermint
p2p/trust/metric.go
updateFadedMemory
func (tm *TrustMetric) updateFadedMemory() { if tm.historySize < 2 { return } end := tm.historySize - 1 // Keep the most recent history element for count := 1; count < tm.historySize; count++ { i := end - count // The older the data is, the more we spread it out x := math.Pow(2, float64(count)) // Two h...
go
func (tm *TrustMetric) updateFadedMemory() { if tm.historySize < 2 { return } end := tm.historySize - 1 // Keep the most recent history element for count := 1; count < tm.historySize; count++ { i := end - count // The older the data is, the more we spread it out x := math.Pow(2, float64(count)) // Two h...
[ "func", "(", "tm", "*", "TrustMetric", ")", "updateFadedMemory", "(", ")", "{", "if", "tm", ".", "historySize", "<", "2", "{", "return", "\n", "}", "\n\n", "end", ":=", "tm", ".", "historySize", "-", "1", "\n", "// Keep the most recent history element", "f...
// Performs the update for our Faded Memories process, which allows the // trust metric tracking window to be large while maintaining a small // number of history data values
[ "Performs", "the", "update", "for", "our", "Faded", "Memories", "process", "which", "allows", "the", "trust", "metric", "tracking", "window", "to", "be", "large", "while", "maintaining", "a", "small", "number", "of", "history", "data", "values" ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/p2p/trust/metric.go#L390-L404
130,865
tendermint/tendermint
p2p/trust/metric.go
intervalToHistoryOffset
func intervalToHistoryOffset(interval int) int { // The system maintains 2^m interval values in the form of m history // data values. Therefore, we access the ith interval by obtaining // the history data index = the floor of log2(i) return int(math.Floor(math.Log2(float64(interval)))) }
go
func intervalToHistoryOffset(interval int) int { // The system maintains 2^m interval values in the form of m history // data values. Therefore, we access the ith interval by obtaining // the history data index = the floor of log2(i) return int(math.Floor(math.Log2(float64(interval)))) }
[ "func", "intervalToHistoryOffset", "(", "interval", "int", ")", "int", "{", "// The system maintains 2^m interval values in the form of m history", "// data values. Therefore, we access the ith interval by obtaining", "// the history data index = the floor of log2(i)", "return", "int", "("...
// Map the interval value down to an offset from the beginning of history
[ "Map", "the", "interval", "value", "down", "to", "an", "offset", "from", "the", "beginning", "of", "history" ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/p2p/trust/metric.go#L407-L412
130,866
tendermint/tendermint
rpc/core/types/responses.go
NewResultCommit
func NewResultCommit(header *types.Header, commit *types.Commit, canonical bool) *ResultCommit { return &ResultCommit{ SignedHeader: types.SignedHeader{ Header: header, Commit: commit, }, CanonicalCommit: canonical, } }
go
func NewResultCommit(header *types.Header, commit *types.Commit, canonical bool) *ResultCommit { return &ResultCommit{ SignedHeader: types.SignedHeader{ Header: header, Commit: commit, }, CanonicalCommit: canonical, } }
[ "func", "NewResultCommit", "(", "header", "*", "types", ".", "Header", ",", "commit", "*", "types", ".", "Commit", ",", "canonical", "bool", ")", "*", "ResultCommit", "{", "return", "&", "ResultCommit", "{", "SignedHeader", ":", "types", ".", "SignedHeader",...
// NewResultCommit is a helper to initialize the ResultCommit with // the embedded struct
[ "NewResultCommit", "is", "a", "helper", "to", "initialize", "the", "ResultCommit", "with", "the", "embedded", "struct" ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/rpc/core/types/responses.go#L47-L57
130,867
tendermint/tendermint
rpc/core/types/responses.go
TxIndexEnabled
func (s *ResultStatus) TxIndexEnabled() bool { if s == nil { return false } return s.NodeInfo.Other.TxIndex == "on" }
go
func (s *ResultStatus) TxIndexEnabled() bool { if s == nil { return false } return s.NodeInfo.Other.TxIndex == "on" }
[ "func", "(", "s", "*", "ResultStatus", ")", "TxIndexEnabled", "(", ")", "bool", "{", "if", "s", "==", "nil", "{", "return", "false", "\n", "}", "\n", "return", "s", ".", "NodeInfo", ".", "Other", ".", "TxIndex", "==", "\"", "\"", "\n", "}" ]
// Is TxIndexing enabled
[ "Is", "TxIndexing", "enabled" ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/rpc/core/types/responses.go#L83-L88
130,868
tendermint/tendermint
rpc/client/mock/client.go
GetResponse
func (c Call) GetResponse(args interface{}) (interface{}, error) { // handle the case with no response if c.Response == nil { if c.Error == nil { panic("Misconfigured call, you must set either Response or Error") } return nil, c.Error } // response without error if c.Error == nil { return c.Response, ni...
go
func (c Call) GetResponse(args interface{}) (interface{}, error) { // handle the case with no response if c.Response == nil { if c.Error == nil { panic("Misconfigured call, you must set either Response or Error") } return nil, c.Error } // response without error if c.Error == nil { return c.Response, ni...
[ "func", "(", "c", "Call", ")", "GetResponse", "(", "args", "interface", "{", "}", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "// handle the case with no response", "if", "c", ".", "Response", "==", "nil", "{", "if", "c", ".", "Error", "==...
// GetResponse will generate the apporiate response for us, when // using the Call struct to configure a Mock handler. // // When configuring a response, if only one of Response or Error is // set then that will always be returned. If both are set, then // we return Response if the Args match the set args, Error otherw...
[ "GetResponse", "will", "generate", "the", "apporiate", "response", "for", "us", "when", "using", "the", "Call", "struct", "to", "configure", "a", "Mock", "handler", ".", "When", "configuring", "a", "response", "if", "only", "one", "of", "Response", "or", "Er...
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/rpc/client/mock/client.go#L60-L77
130,869
tendermint/tendermint
consensus/replay.go
catchupReplay
func (cs *ConsensusState) catchupReplay(csHeight int64) error { // Set replayMode to true so we don't log signing errors. cs.replayMode = true defer func() { cs.replayMode = false }() // Ensure that #ENDHEIGHT for this height doesn't exist. // NOTE: This is just a sanity check. As far as we know things work fine...
go
func (cs *ConsensusState) catchupReplay(csHeight int64) error { // Set replayMode to true so we don't log signing errors. cs.replayMode = true defer func() { cs.replayMode = false }() // Ensure that #ENDHEIGHT for this height doesn't exist. // NOTE: This is just a sanity check. As far as we know things work fine...
[ "func", "(", "cs", "*", "ConsensusState", ")", "catchupReplay", "(", "csHeight", "int64", ")", "error", "{", "// Set replayMode to true so we don't log signing errors.", "cs", ".", "replayMode", "=", "true", "\n", "defer", "func", "(", ")", "{", "cs", ".", "repl...
// Replay only those messages since the last block. `timeoutRoutine` should // run concurrently to read off tickChan.
[ "Replay", "only", "those", "messages", "since", "the", "last", "block", ".", "timeoutRoutine", "should", "run", "concurrently", "to", "read", "off", "tickChan", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/consensus/replay.go#L100-L164
130,870
tendermint/tendermint
consensus/replay.go
replayBlock
func (h *Handshaker) replayBlock(state sm.State, height int64, proxyApp proxy.AppConnConsensus) (sm.State, error) { block := h.store.LoadBlock(height) meta := h.store.LoadBlockMeta(height) blockExec := sm.NewBlockExecutor(h.stateDB, h.logger, proxyApp, sm.MockMempool{}, sm.MockEvidencePool{}) blockExec.SetEventBus...
go
func (h *Handshaker) replayBlock(state sm.State, height int64, proxyApp proxy.AppConnConsensus) (sm.State, error) { block := h.store.LoadBlock(height) meta := h.store.LoadBlockMeta(height) blockExec := sm.NewBlockExecutor(h.stateDB, h.logger, proxyApp, sm.MockMempool{}, sm.MockEvidencePool{}) blockExec.SetEventBus...
[ "func", "(", "h", "*", "Handshaker", ")", "replayBlock", "(", "state", "sm", ".", "State", ",", "height", "int64", ",", "proxyApp", "proxy", ".", "AppConnConsensus", ")", "(", "sm", ".", "State", ",", "error", ")", "{", "block", ":=", "h", ".", "stor...
// ApplyBlock on the proxyApp with the last block.
[ "ApplyBlock", "on", "the", "proxyApp", "with", "the", "last", "block", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/consensus/replay.go#L441-L457
130,871
tendermint/tendermint
types/vote_set.go
addVerifiedVote
func (voteSet *VoteSet) addVerifiedVote(vote *Vote, blockKey string, votingPower int64) (added bool, conflicting *Vote) { valIndex := vote.ValidatorIndex // Already exists in voteSet.votes? if existing := voteSet.votes[valIndex]; existing != nil { if existing.BlockID.Equals(vote.BlockID) { cmn.PanicSanity("add...
go
func (voteSet *VoteSet) addVerifiedVote(vote *Vote, blockKey string, votingPower int64) (added bool, conflicting *Vote) { valIndex := vote.ValidatorIndex // Already exists in voteSet.votes? if existing := voteSet.votes[valIndex]; existing != nil { if existing.BlockID.Equals(vote.BlockID) { cmn.PanicSanity("add...
[ "func", "(", "voteSet", "*", "VoteSet", ")", "addVerifiedVote", "(", "vote", "*", "Vote", ",", "blockKey", "string", ",", "votingPower", "int64", ")", "(", "added", "bool", ",", "conflicting", "*", "Vote", ")", "{", "valIndex", ":=", "vote", ".", "Valida...
// Assumes signature is valid. // If conflicting vote exists, returns it.
[ "Assumes", "signature", "is", "valid", ".", "If", "conflicting", "vote", "exists", "returns", "it", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/types/vote_set.go#L217-L284
130,872
tendermint/tendermint
types/vote_set.go
VoteStrings
func (voteSet *VoteSet) VoteStrings() []string { voteSet.mtx.Lock() defer voteSet.mtx.Unlock() return voteSet.voteStrings() }
go
func (voteSet *VoteSet) VoteStrings() []string { voteSet.mtx.Lock() defer voteSet.mtx.Unlock() return voteSet.voteStrings() }
[ "func", "(", "voteSet", "*", "VoteSet", ")", "VoteStrings", "(", ")", "[", "]", "string", "{", "voteSet", ".", "mtx", ".", "Lock", "(", ")", "\n", "defer", "voteSet", ".", "mtx", ".", "Unlock", "(", ")", "\n", "return", "voteSet", ".", "voteStrings",...
// Returns a list of votes compressed to more readable strings.
[ "Returns", "a", "list", "of", "votes", "compressed", "to", "more", "readable", "strings", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/types/vote_set.go#L492-L496
130,873
tendermint/tendermint
types/vote_set.go
sumTotalFrac
func (voteSet *VoteSet) sumTotalFrac() (int64, int64, float64) { voted, total := voteSet.sum, voteSet.valSet.TotalVotingPower() fracVoted := float64(voted) / float64(total) return voted, total, fracVoted }
go
func (voteSet *VoteSet) sumTotalFrac() (int64, int64, float64) { voted, total := voteSet.sum, voteSet.valSet.TotalVotingPower() fracVoted := float64(voted) / float64(total) return voted, total, fracVoted }
[ "func", "(", "voteSet", "*", "VoteSet", ")", "sumTotalFrac", "(", ")", "(", "int64", ",", "int64", ",", "float64", ")", "{", "voted", ",", "total", ":=", "voteSet", ".", "sum", ",", "voteSet", ".", "valSet", ".", "TotalVotingPower", "(", ")", "\n", "...
// return the power voted, the total, and the fraction
[ "return", "the", "power", "voted", "the", "total", "and", "the", "fraction" ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/types/vote_set.go#L522-L526
130,874
tendermint/tendermint
crypto/secp256k1/secp256k1_nocgo.go
VerifyBytes
func (pubKey PubKeySecp256k1) VerifyBytes(msg []byte, sigStr []byte) bool { if len(sigStr) != 64 { return false } pub, err := secp256k1.ParsePubKey(pubKey[:], secp256k1.S256()) if err != nil { return false } // parse the signature: signature := signatureFromBytes(sigStr) // Reject malleable signatures. libs...
go
func (pubKey PubKeySecp256k1) VerifyBytes(msg []byte, sigStr []byte) bool { if len(sigStr) != 64 { return false } pub, err := secp256k1.ParsePubKey(pubKey[:], secp256k1.S256()) if err != nil { return false } // parse the signature: signature := signatureFromBytes(sigStr) // Reject malleable signatures. libs...
[ "func", "(", "pubKey", "PubKeySecp256k1", ")", "VerifyBytes", "(", "msg", "[", "]", "byte", ",", "sigStr", "[", "]", "byte", ")", "bool", "{", "if", "len", "(", "sigStr", ")", "!=", "64", "{", "return", "false", "\n", "}", "\n", "pub", ",", "err", ...
// VerifyBytes verifies a signature of the form R || S. // It rejects signatures which are not in lower-S form.
[ "VerifyBytes", "verifies", "a", "signature", "of", "the", "form", "R", "||", "S", ".", "It", "rejects", "signatures", "which", "are", "not", "in", "lower", "-", "S", "form", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/crypto/secp256k1/secp256k1_nocgo.go#L33-L49
130,875
tendermint/tendermint
crypto/secp256k1/secp256k1_nocgo.go
serializeSig
func serializeSig(sig *secp256k1.Signature) []byte { rBytes := sig.R.Bytes() sBytes := sig.S.Bytes() sigBytes := make([]byte, 64) // 0 pad the byte arrays from the left if they aren't big enough. copy(sigBytes[32-len(rBytes):32], rBytes) copy(sigBytes[64-len(sBytes):64], sBytes) return sigBytes }
go
func serializeSig(sig *secp256k1.Signature) []byte { rBytes := sig.R.Bytes() sBytes := sig.S.Bytes() sigBytes := make([]byte, 64) // 0 pad the byte arrays from the left if they aren't big enough. copy(sigBytes[32-len(rBytes):32], rBytes) copy(sigBytes[64-len(sBytes):64], sBytes) return sigBytes }
[ "func", "serializeSig", "(", "sig", "*", "secp256k1", ".", "Signature", ")", "[", "]", "byte", "{", "rBytes", ":=", "sig", ".", "R", ".", "Bytes", "(", ")", "\n", "sBytes", ":=", "sig", ".", "S", ".", "Bytes", "(", ")", "\n", "sigBytes", ":=", "m...
// Serialize signature to R || S. // R, S are padded to 32 bytes respectively.
[ "Serialize", "signature", "to", "R", "||", "S", ".", "R", "S", "are", "padded", "to", "32", "bytes", "respectively", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/crypto/secp256k1/secp256k1_nocgo.go#L62-L70
130,876
tendermint/tendermint
evidence/store.go
PriorityEvidence
func (store *EvidenceStore) PriorityEvidence() (evidence []types.Evidence) { // reverse the order so highest priority is first l := store.listEvidence(baseKeyOutqueue, -1) for i, j := 0, len(l)-1; i < j; i, j = i+1, j-1 { l[i], l[j] = l[j], l[i] } return l }
go
func (store *EvidenceStore) PriorityEvidence() (evidence []types.Evidence) { // reverse the order so highest priority is first l := store.listEvidence(baseKeyOutqueue, -1) for i, j := 0, len(l)-1; i < j; i, j = i+1, j-1 { l[i], l[j] = l[j], l[i] } return l }
[ "func", "(", "store", "*", "EvidenceStore", ")", "PriorityEvidence", "(", ")", "(", "evidence", "[", "]", "types", ".", "Evidence", ")", "{", "// reverse the order so highest priority is first", "l", ":=", "store", ".", "listEvidence", "(", "baseKeyOutqueue", ",",...
// PriorityEvidence returns the evidence from the outqueue, sorted by highest priority.
[ "PriorityEvidence", "returns", "the", "evidence", "from", "the", "outqueue", "sorted", "by", "highest", "priority", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/evidence/store.go#L79-L87
130,877
tendermint/tendermint
evidence/store.go
PendingEvidence
func (store *EvidenceStore) PendingEvidence(maxNum int64) (evidence []types.Evidence) { return store.listEvidence(baseKeyPending, maxNum) }
go
func (store *EvidenceStore) PendingEvidence(maxNum int64) (evidence []types.Evidence) { return store.listEvidence(baseKeyPending, maxNum) }
[ "func", "(", "store", "*", "EvidenceStore", ")", "PendingEvidence", "(", "maxNum", "int64", ")", "(", "evidence", "[", "]", "types", ".", "Evidence", ")", "{", "return", "store", ".", "listEvidence", "(", "baseKeyPending", ",", "maxNum", ")", "\n", "}" ]
// PendingEvidence returns up to maxNum known, uncommitted evidence. // If maxNum is -1, all evidence is returned.
[ "PendingEvidence", "returns", "up", "to", "maxNum", "known", "uncommitted", "evidence", ".", "If", "maxNum", "is", "-", "1", "all", "evidence", "is", "returned", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/evidence/store.go#L91-L93
130,878
tendermint/tendermint
evidence/store.go
listEvidence
func (store *EvidenceStore) listEvidence(prefixKey string, maxNum int64) (evidence []types.Evidence) { var count int64 iter := dbm.IteratePrefix(store.db, []byte(prefixKey)) defer iter.Close() for ; iter.Valid(); iter.Next() { val := iter.Value() if count == maxNum { return evidence } count++ var ei ...
go
func (store *EvidenceStore) listEvidence(prefixKey string, maxNum int64) (evidence []types.Evidence) { var count int64 iter := dbm.IteratePrefix(store.db, []byte(prefixKey)) defer iter.Close() for ; iter.Valid(); iter.Next() { val := iter.Value() if count == maxNum { return evidence } count++ var ei ...
[ "func", "(", "store", "*", "EvidenceStore", ")", "listEvidence", "(", "prefixKey", "string", ",", "maxNum", "int64", ")", "(", "evidence", "[", "]", "types", ".", "Evidence", ")", "{", "var", "count", "int64", "\n", "iter", ":=", "dbm", ".", "IteratePref...
// listEvidence lists up to maxNum pieces of evidence for the given prefix key. // It is wrapped by PriorityEvidence and PendingEvidence for convenience. // If maxNum is -1, there's no cap on the size of returned evidence.
[ "listEvidence", "lists", "up", "to", "maxNum", "pieces", "of", "evidence", "for", "the", "given", "prefix", "key", ".", "It", "is", "wrapped", "by", "PriorityEvidence", "and", "PendingEvidence", "for", "convenience", ".", "If", "maxNum", "is", "-", "1", "the...
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/evidence/store.go#L98-L118
130,879
tendermint/tendermint
evidence/store.go
GetEvidenceInfo
func (store *EvidenceStore) GetEvidenceInfo(height int64, hash []byte) EvidenceInfo { key := keyLookupFromHeightAndHash(height, hash) val := store.db.Get(key) if len(val) == 0 { return EvidenceInfo{} } var ei EvidenceInfo err := cdc.UnmarshalBinaryBare(val, &ei) if err != nil { panic(err) } return ei }
go
func (store *EvidenceStore) GetEvidenceInfo(height int64, hash []byte) EvidenceInfo { key := keyLookupFromHeightAndHash(height, hash) val := store.db.Get(key) if len(val) == 0 { return EvidenceInfo{} } var ei EvidenceInfo err := cdc.UnmarshalBinaryBare(val, &ei) if err != nil { panic(err) } return ei }
[ "func", "(", "store", "*", "EvidenceStore", ")", "GetEvidenceInfo", "(", "height", "int64", ",", "hash", "[", "]", "byte", ")", "EvidenceInfo", "{", "key", ":=", "keyLookupFromHeightAndHash", "(", "height", ",", "hash", ")", "\n", "val", ":=", "store", "."...
// GetEvidenceInfo fetches the EvidenceInfo with the given height and hash. // If not found, ei.Evidence is nil.
[ "GetEvidenceInfo", "fetches", "the", "EvidenceInfo", "with", "the", "given", "height", "and", "hash", ".", "If", "not", "found", "ei", ".", "Evidence", "is", "nil", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/evidence/store.go#L122-L135
130,880
tendermint/tendermint
evidence/store.go
AddNewEvidence
func (store *EvidenceStore) AddNewEvidence(evidence types.Evidence, priority int64) bool { // check if we already have seen it ei := store.getEvidenceInfo(evidence) if ei.Evidence != nil { return false } ei = EvidenceInfo{ Committed: false, Priority: priority, Evidence: evidence, } eiBytes := cdc.Must...
go
func (store *EvidenceStore) AddNewEvidence(evidence types.Evidence, priority int64) bool { // check if we already have seen it ei := store.getEvidenceInfo(evidence) if ei.Evidence != nil { return false } ei = EvidenceInfo{ Committed: false, Priority: priority, Evidence: evidence, } eiBytes := cdc.Must...
[ "func", "(", "store", "*", "EvidenceStore", ")", "AddNewEvidence", "(", "evidence", "types", ".", "Evidence", ",", "priority", "int64", ")", "bool", "{", "// check if we already have seen it", "ei", ":=", "store", ".", "getEvidenceInfo", "(", "evidence", ")", "\...
// AddNewEvidence adds the given evidence to the database. // It returns false if the evidence is already stored.
[ "AddNewEvidence", "adds", "the", "given", "evidence", "to", "the", "database", ".", "It", "returns", "false", "if", "the", "evidence", "is", "already", "stored", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/evidence/store.go#L139-L164
130,881
tendermint/tendermint
evidence/store.go
MarkEvidenceAsBroadcasted
func (store *EvidenceStore) MarkEvidenceAsBroadcasted(evidence types.Evidence) { ei := store.getEvidenceInfo(evidence) if ei.Evidence == nil { // nothing to do; we did not store the evidence yet (AddNewEvidence): return } // remove from the outqueue key := keyOutqueue(evidence, ei.Priority) store.db.Delete(ke...
go
func (store *EvidenceStore) MarkEvidenceAsBroadcasted(evidence types.Evidence) { ei := store.getEvidenceInfo(evidence) if ei.Evidence == nil { // nothing to do; we did not store the evidence yet (AddNewEvidence): return } // remove from the outqueue key := keyOutqueue(evidence, ei.Priority) store.db.Delete(ke...
[ "func", "(", "store", "*", "EvidenceStore", ")", "MarkEvidenceAsBroadcasted", "(", "evidence", "types", ".", "Evidence", ")", "{", "ei", ":=", "store", ".", "getEvidenceInfo", "(", "evidence", ")", "\n", "if", "ei", ".", "Evidence", "==", "nil", "{", "// n...
// MarkEvidenceAsBroadcasted removes evidence from Outqueue.
[ "MarkEvidenceAsBroadcasted", "removes", "evidence", "from", "Outqueue", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/evidence/store.go#L167-L176
130,882
tendermint/tendermint
evidence/store.go
MarkEvidenceAsCommitted
func (store *EvidenceStore) MarkEvidenceAsCommitted(evidence types.Evidence) { // if its committed, its been broadcast store.MarkEvidenceAsBroadcasted(evidence) pendingKey := keyPending(evidence) store.db.Delete(pendingKey) // committed EvidenceInfo doens't need priority ei := EvidenceInfo{ Committed: true, ...
go
func (store *EvidenceStore) MarkEvidenceAsCommitted(evidence types.Evidence) { // if its committed, its been broadcast store.MarkEvidenceAsBroadcasted(evidence) pendingKey := keyPending(evidence) store.db.Delete(pendingKey) // committed EvidenceInfo doens't need priority ei := EvidenceInfo{ Committed: true, ...
[ "func", "(", "store", "*", "EvidenceStore", ")", "MarkEvidenceAsCommitted", "(", "evidence", "types", ".", "Evidence", ")", "{", "// if its committed, its been broadcast", "store", ".", "MarkEvidenceAsBroadcasted", "(", "evidence", ")", "\n\n", "pendingKey", ":=", "ke...
// MarkEvidenceAsCommitted removes evidence from pending and outqueue and sets the state to committed.
[ "MarkEvidenceAsCommitted", "removes", "evidence", "from", "pending", "and", "outqueue", "and", "sets", "the", "state", "to", "committed", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/evidence/store.go#L179-L195
130,883
tendermint/tendermint
libs/db/remotedb/grpcdb/server.go
ListenAndServe
func ListenAndServe(addr, cert, key string, opts ...grpc.ServerOption) error { ln, err := net.Listen("tcp", addr) if err != nil { return err } srv, err := NewServer(cert, key, opts...) if err != nil { return err } return srv.Serve(ln) }
go
func ListenAndServe(addr, cert, key string, opts ...grpc.ServerOption) error { ln, err := net.Listen("tcp", addr) if err != nil { return err } srv, err := NewServer(cert, key, opts...) if err != nil { return err } return srv.Serve(ln) }
[ "func", "ListenAndServe", "(", "addr", ",", "cert", ",", "key", "string", ",", "opts", "...", "grpc", ".", "ServerOption", ")", "error", "{", "ln", ",", "err", ":=", "net", ".", "Listen", "(", "\"", "\"", ",", "addr", ")", "\n", "if", "err", "!=", ...
// ListenAndServe is a blocking function that sets up a gRPC based // server at the address supplied, with the gRPC options passed in. // Normally in usage, invoke it in a goroutine like you would for http.ListenAndServe.
[ "ListenAndServe", "is", "a", "blocking", "function", "that", "sets", "up", "a", "gRPC", "based", "server", "at", "the", "address", "supplied", "with", "the", "gRPC", "options", "passed", "in", ".", "Normally", "in", "usage", "invoke", "it", "in", "a", "gor...
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/libs/db/remotedb/grpcdb/server.go#L19-L29
130,884
tendermint/tendermint
types/time/time.go
NewWeightedTime
func NewWeightedTime(time time.Time, weight int64) *WeightedTime { return &WeightedTime{ Time: time, Weight: weight, } }
go
func NewWeightedTime(time time.Time, weight int64) *WeightedTime { return &WeightedTime{ Time: time, Weight: weight, } }
[ "func", "NewWeightedTime", "(", "time", "time", ".", "Time", ",", "weight", "int64", ")", "*", "WeightedTime", "{", "return", "&", "WeightedTime", "{", "Time", ":", "time", ",", "Weight", ":", "weight", ",", "}", "\n", "}" ]
// NewWeightedTime with time and weight.
[ "NewWeightedTime", "with", "time", "and", "weight", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/types/time/time.go#L27-L32
130,885
tendermint/tendermint
types/time/time.go
WeightedMedian
func WeightedMedian(weightedTimes []*WeightedTime, totalVotingPower int64) (res time.Time) { median := totalVotingPower / 2 sort.Slice(weightedTimes, func(i, j int) bool { if weightedTimes[i] == nil { return false } if weightedTimes[j] == nil { return true } return weightedTimes[i].Time.UnixNano() < ...
go
func WeightedMedian(weightedTimes []*WeightedTime, totalVotingPower int64) (res time.Time) { median := totalVotingPower / 2 sort.Slice(weightedTimes, func(i, j int) bool { if weightedTimes[i] == nil { return false } if weightedTimes[j] == nil { return true } return weightedTimes[i].Time.UnixNano() < ...
[ "func", "WeightedMedian", "(", "weightedTimes", "[", "]", "*", "WeightedTime", ",", "totalVotingPower", "int64", ")", "(", "res", "time", ".", "Time", ")", "{", "median", ":=", "totalVotingPower", "/", "2", "\n\n", "sort", ".", "Slice", "(", "weightedTimes",...
// WeightedMedian computes weighted median time for a given array of WeightedTime and the total voting power.
[ "WeightedMedian", "computes", "weighted", "median", "time", "for", "a", "given", "array", "of", "WeightedTime", "and", "the", "total", "voting", "power", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/types/time/time.go#L35-L58
130,886
tendermint/tendermint
p2p/conn/connection.go
DefaultMConnConfig
func DefaultMConnConfig() MConnConfig { return MConnConfig{ SendRate: defaultSendRate, RecvRate: defaultRecvRate, MaxPacketMsgPayloadSize: defaultMaxPacketMsgPayloadSize, FlushThrottle: defaultFlushThrottle, PingInterval: defaultPingInterval, PongTimeout: ...
go
func DefaultMConnConfig() MConnConfig { return MConnConfig{ SendRate: defaultSendRate, RecvRate: defaultRecvRate, MaxPacketMsgPayloadSize: defaultMaxPacketMsgPayloadSize, FlushThrottle: defaultFlushThrottle, PingInterval: defaultPingInterval, PongTimeout: ...
[ "func", "DefaultMConnConfig", "(", ")", "MConnConfig", "{", "return", "MConnConfig", "{", "SendRate", ":", "defaultSendRate", ",", "RecvRate", ":", "defaultRecvRate", ",", "MaxPacketMsgPayloadSize", ":", "defaultMaxPacketMsgPayloadSize", ",", "FlushThrottle", ":", "defa...
// DefaultMConnConfig returns the default config.
[ "DefaultMConnConfig", "returns", "the", "default", "config", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/p2p/conn/connection.go#L130-L139
130,887
tendermint/tendermint
p2p/conn/connection.go
NewMConnection
func NewMConnection(conn net.Conn, chDescs []*ChannelDescriptor, onReceive receiveCbFunc, onError errorCbFunc) *MConnection { return NewMConnectionWithConfig( conn, chDescs, onReceive, onError, DefaultMConnConfig()) }
go
func NewMConnection(conn net.Conn, chDescs []*ChannelDescriptor, onReceive receiveCbFunc, onError errorCbFunc) *MConnection { return NewMConnectionWithConfig( conn, chDescs, onReceive, onError, DefaultMConnConfig()) }
[ "func", "NewMConnection", "(", "conn", "net", ".", "Conn", ",", "chDescs", "[", "]", "*", "ChannelDescriptor", ",", "onReceive", "receiveCbFunc", ",", "onError", "errorCbFunc", ")", "*", "MConnection", "{", "return", "NewMConnectionWithConfig", "(", "conn", ",",...
// NewMConnection wraps net.Conn and creates multiplex connection
[ "NewMConnection", "wraps", "net", ".", "Conn", "and", "creates", "multiplex", "connection" ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/p2p/conn/connection.go#L142-L149
130,888
tendermint/tendermint
p2p/conn/connection.go
NewMConnectionWithConfig
func NewMConnectionWithConfig(conn net.Conn, chDescs []*ChannelDescriptor, onReceive receiveCbFunc, onError errorCbFunc, config MConnConfig) *MConnection { if config.PongTimeout >= config.PingInterval { panic("pongTimeout must be less than pingInterval (otherwise, next ping will reset pong timer)") } mconn := &MC...
go
func NewMConnectionWithConfig(conn net.Conn, chDescs []*ChannelDescriptor, onReceive receiveCbFunc, onError errorCbFunc, config MConnConfig) *MConnection { if config.PongTimeout >= config.PingInterval { panic("pongTimeout must be less than pingInterval (otherwise, next ping will reset pong timer)") } mconn := &MC...
[ "func", "NewMConnectionWithConfig", "(", "conn", "net", ".", "Conn", ",", "chDescs", "[", "]", "*", "ChannelDescriptor", ",", "onReceive", "receiveCbFunc", ",", "onError", "errorCbFunc", ",", "config", "MConnConfig", ")", "*", "MConnection", "{", "if", "config",...
// NewMConnectionWithConfig wraps net.Conn and creates multiplex connection with a config
[ "NewMConnectionWithConfig", "wraps", "net", ".", "Conn", "and", "creates", "multiplex", "connection", "with", "a", "config" ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/p2p/conn/connection.go#L152-L189
130,889
tendermint/tendermint
p2p/conn/connection.go
stopServices
func (c *MConnection) stopServices() (alreadyStopped bool) { c.stopMtx.Lock() defer c.stopMtx.Unlock() select { case <-c.quitSendRoutine: // already quit via FlushStop or OnStop return true default: } c.BaseService.OnStop() c.flushTimer.Stop() c.pingTimer.Stop() c.chStatsTimer.Stop() close(c.quitSendR...
go
func (c *MConnection) stopServices() (alreadyStopped bool) { c.stopMtx.Lock() defer c.stopMtx.Unlock() select { case <-c.quitSendRoutine: // already quit via FlushStop or OnStop return true default: } c.BaseService.OnStop() c.flushTimer.Stop() c.pingTimer.Stop() c.chStatsTimer.Stop() close(c.quitSendR...
[ "func", "(", "c", "*", "MConnection", ")", "stopServices", "(", ")", "(", "alreadyStopped", "bool", ")", "{", "c", ".", "stopMtx", ".", "Lock", "(", ")", "\n", "defer", "c", ".", "stopMtx", ".", "Unlock", "(", ")", "\n\n", "select", "{", "case", "<...
// stopServices stops the BaseService and timers and closes the quitSendRoutine. // if the quitSendRoutine was already closed, it returns true, otherwise it returns false. // It uses the stopMtx to ensure only one of FlushStop and OnStop can do this at a time.
[ "stopServices", "stops", "the", "BaseService", "and", "timers", "and", "closes", "the", "quitSendRoutine", ".", "if", "the", "quitSendRoutine", "was", "already", "closed", "it", "returns", "true", "otherwise", "it", "returns", "false", ".", "It", "uses", "the", ...
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/p2p/conn/connection.go#L217-L235
130,890
tendermint/tendermint
p2p/conn/connection.go
_recover
func (c *MConnection) _recover() { if r := recover(); r != nil { err := cmn.ErrorWrap(r, "recovered panic in MConnection") c.stopForError(err) } }
go
func (c *MConnection) _recover() { if r := recover(); r != nil { err := cmn.ErrorWrap(r, "recovered panic in MConnection") c.stopForError(err) } }
[ "func", "(", "c", "*", "MConnection", ")", "_recover", "(", ")", "{", "if", "r", ":=", "recover", "(", ")", ";", "r", "!=", "nil", "{", "err", ":=", "cmn", ".", "ErrorWrap", "(", "r", ",", "\"", "\"", ")", "\n", "c", ".", "stopForError", "(", ...
// Catch panics, usually caused by remote disconnects.
[ "Catch", "panics", "usually", "caused", "by", "remote", "disconnects", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/p2p/conn/connection.go#L303-L308
130,891
tendermint/tendermint
p2p/conn/connection.go
Send
func (c *MConnection) Send(chID byte, msgBytes []byte) bool { if !c.IsRunning() { return false } c.Logger.Debug("Send", "channel", chID, "conn", c, "msgBytes", fmt.Sprintf("%X", msgBytes)) // Send message to channel. channel, ok := c.channelsIdx[chID] if !ok { c.Logger.Error(fmt.Sprintf("Cannot send bytes, ...
go
func (c *MConnection) Send(chID byte, msgBytes []byte) bool { if !c.IsRunning() { return false } c.Logger.Debug("Send", "channel", chID, "conn", c, "msgBytes", fmt.Sprintf("%X", msgBytes)) // Send message to channel. channel, ok := c.channelsIdx[chID] if !ok { c.Logger.Error(fmt.Sprintf("Cannot send bytes, ...
[ "func", "(", "c", "*", "MConnection", ")", "Send", "(", "chID", "byte", ",", "msgBytes", "[", "]", "byte", ")", "bool", "{", "if", "!", "c", ".", "IsRunning", "(", ")", "{", "return", "false", "\n", "}", "\n\n", "c", ".", "Logger", ".", "Debug", ...
// Queues a message to be sent to channel.
[ "Queues", "a", "message", "to", "be", "sent", "to", "channel", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/p2p/conn/connection.go#L320-L345
130,892
tendermint/tendermint
p2p/conn/connection.go
TrySend
func (c *MConnection) TrySend(chID byte, msgBytes []byte) bool { if !c.IsRunning() { return false } c.Logger.Debug("TrySend", "channel", chID, "conn", c, "msgBytes", fmt.Sprintf("%X", msgBytes)) // Send message to channel. channel, ok := c.channelsIdx[chID] if !ok { c.Logger.Error(fmt.Sprintf("Cannot send b...
go
func (c *MConnection) TrySend(chID byte, msgBytes []byte) bool { if !c.IsRunning() { return false } c.Logger.Debug("TrySend", "channel", chID, "conn", c, "msgBytes", fmt.Sprintf("%X", msgBytes)) // Send message to channel. channel, ok := c.channelsIdx[chID] if !ok { c.Logger.Error(fmt.Sprintf("Cannot send b...
[ "func", "(", "c", "*", "MConnection", ")", "TrySend", "(", "chID", "byte", ",", "msgBytes", "[", "]", "byte", ")", "bool", "{", "if", "!", "c", ".", "IsRunning", "(", ")", "{", "return", "false", "\n", "}", "\n\n", "c", ".", "Logger", ".", "Debug...
// Queues a message to be sent to channel. // Nonblocking, returns true if successful.
[ "Queues", "a", "message", "to", "be", "sent", "to", "channel", ".", "Nonblocking", "returns", "true", "if", "successful", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/p2p/conn/connection.go#L349-L373
130,893
tendermint/tendermint
p2p/conn/connection.go
CanSend
func (c *MConnection) CanSend(chID byte) bool { if !c.IsRunning() { return false } channel, ok := c.channelsIdx[chID] if !ok { c.Logger.Error(fmt.Sprintf("Unknown channel %X", chID)) return false } return channel.canSend() }
go
func (c *MConnection) CanSend(chID byte) bool { if !c.IsRunning() { return false } channel, ok := c.channelsIdx[chID] if !ok { c.Logger.Error(fmt.Sprintf("Unknown channel %X", chID)) return false } return channel.canSend() }
[ "func", "(", "c", "*", "MConnection", ")", "CanSend", "(", "chID", "byte", ")", "bool", "{", "if", "!", "c", ".", "IsRunning", "(", ")", "{", "return", "false", "\n", "}", "\n\n", "channel", ",", "ok", ":=", "c", ".", "channelsIdx", "[", "chID", ...
// CanSend returns true if you can send more data onto the chID, false // otherwise. Use only as a heuristic.
[ "CanSend", "returns", "true", "if", "you", "can", "send", "more", "data", "onto", "the", "chID", "false", "otherwise", ".", "Use", "only", "as", "a", "heuristic", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/p2p/conn/connection.go#L377-L388
130,894
tendermint/tendermint
p2p/conn/connection.go
sendRoutine
func (c *MConnection) sendRoutine() { defer c._recover() FOR_LOOP: for { var _n int64 var err error SELECTION: select { case <-c.flushTimer.Ch: // NOTE: flushTimer.Set() must be called every time // something is written to .bufConnWriter. c.flush() case <-c.chStatsTimer.C: for _, channel := ra...
go
func (c *MConnection) sendRoutine() { defer c._recover() FOR_LOOP: for { var _n int64 var err error SELECTION: select { case <-c.flushTimer.Ch: // NOTE: flushTimer.Set() must be called every time // something is written to .bufConnWriter. c.flush() case <-c.chStatsTimer.C: for _, channel := ra...
[ "func", "(", "c", "*", "MConnection", ")", "sendRoutine", "(", ")", "{", "defer", "c", ".", "_recover", "(", ")", "\n\n", "FOR_LOOP", ":", "for", "{", "var", "_n", "int64", "\n", "var", "err", "error", "\n", "SELECTION", ":", "select", "{", "case", ...
// sendRoutine polls for packets to send from channels.
[ "sendRoutine", "polls", "for", "packets", "to", "send", "from", "channels", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/p2p/conn/connection.go#L391-L465
130,895
tendermint/tendermint
p2p/conn/connection.go
sendSomePacketMsgs
func (c *MConnection) sendSomePacketMsgs() bool { // Block until .sendMonitor says we can write. // Once we're ready we send more than we asked for, // but amortized it should even out. c.sendMonitor.Limit(c._maxPacketMsgSize, atomic.LoadInt64(&c.config.SendRate), true) // Now send some PacketMsgs. for i := 0; i...
go
func (c *MConnection) sendSomePacketMsgs() bool { // Block until .sendMonitor says we can write. // Once we're ready we send more than we asked for, // but amortized it should even out. c.sendMonitor.Limit(c._maxPacketMsgSize, atomic.LoadInt64(&c.config.SendRate), true) // Now send some PacketMsgs. for i := 0; i...
[ "func", "(", "c", "*", "MConnection", ")", "sendSomePacketMsgs", "(", ")", "bool", "{", "// Block until .sendMonitor says we can write.", "// Once we're ready we send more than we asked for,", "// but amortized it should even out.", "c", ".", "sendMonitor", ".", "Limit", "(", ...
// Returns true if messages from channels were exhausted. // Blocks in accordance to .sendMonitor throttling.
[ "Returns", "true", "if", "messages", "from", "channels", "were", "exhausted", ".", "Blocks", "in", "accordance", "to", ".", "sendMonitor", "throttling", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/p2p/conn/connection.go#L469-L482
130,896
tendermint/tendermint
p2p/conn/connection.go
sendPacketMsg
func (c *MConnection) sendPacketMsg() bool { // Choose a channel to create a PacketMsg from. // The chosen channel will be the one whose recentlySent/priority is the least. var leastRatio float32 = math.MaxFloat32 var leastChannel *Channel for _, channel := range c.channels { // If nothing to send, skip this cha...
go
func (c *MConnection) sendPacketMsg() bool { // Choose a channel to create a PacketMsg from. // The chosen channel will be the one whose recentlySent/priority is the least. var leastRatio float32 = math.MaxFloat32 var leastChannel *Channel for _, channel := range c.channels { // If nothing to send, skip this cha...
[ "func", "(", "c", "*", "MConnection", ")", "sendPacketMsg", "(", ")", "bool", "{", "// Choose a channel to create a PacketMsg from.", "// The chosen channel will be the one whose recentlySent/priority is the least.", "var", "leastRatio", "float32", "=", "math", ".", "MaxFloat32...
// Returns true if messages from channels were exhausted.
[ "Returns", "true", "if", "messages", "from", "channels", "were", "exhausted", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/p2p/conn/connection.go#L485-L519
130,897
tendermint/tendermint
p2p/conn/connection.go
stopPongTimer
func (c *MConnection) stopPongTimer() { if c.pongTimer != nil { _ = c.pongTimer.Stop() c.pongTimer = nil } }
go
func (c *MConnection) stopPongTimer() { if c.pongTimer != nil { _ = c.pongTimer.Stop() c.pongTimer = nil } }
[ "func", "(", "c", "*", "MConnection", ")", "stopPongTimer", "(", ")", "{", "if", "c", ".", "pongTimer", "!=", "nil", "{", "_", "=", "c", ".", "pongTimer", ".", "Stop", "(", ")", "\n", "c", ".", "pongTimer", "=", "nil", "\n", "}", "\n", "}" ]
// not goroutine-safe
[ "not", "goroutine", "-", "safe" ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/p2p/conn/connection.go#L617-L622
130,898
tendermint/tendermint
p2p/conn/connection.go
maxPacketMsgSize
func (c *MConnection) maxPacketMsgSize() int { return len(cdc.MustMarshalBinaryLengthPrefixed(PacketMsg{ ChannelID: 0x01, EOF: 1, Bytes: make([]byte, c.config.MaxPacketMsgPayloadSize), })) + 10 // leave room for changes in amino }
go
func (c *MConnection) maxPacketMsgSize() int { return len(cdc.MustMarshalBinaryLengthPrefixed(PacketMsg{ ChannelID: 0x01, EOF: 1, Bytes: make([]byte, c.config.MaxPacketMsgPayloadSize), })) + 10 // leave room for changes in amino }
[ "func", "(", "c", "*", "MConnection", ")", "maxPacketMsgSize", "(", ")", "int", "{", "return", "len", "(", "cdc", ".", "MustMarshalBinaryLengthPrefixed", "(", "PacketMsg", "{", "ChannelID", ":", "0x01", ",", "EOF", ":", "1", ",", "Bytes", ":", "make", "(...
// maxPacketMsgSize returns a maximum size of PacketMsg, including the overhead // of amino encoding.
[ "maxPacketMsgSize", "returns", "a", "maximum", "size", "of", "PacketMsg", "including", "the", "overhead", "of", "amino", "encoding", "." ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/p2p/conn/connection.go#L626-L632
130,899
tendermint/tendermint
p2p/conn/connection.go
trySendBytes
func (ch *Channel) trySendBytes(bytes []byte) bool { select { case ch.sendQueue <- bytes: atomic.AddInt32(&ch.sendQueueSize, 1) return true default: return false } }
go
func (ch *Channel) trySendBytes(bytes []byte) bool { select { case ch.sendQueue <- bytes: atomic.AddInt32(&ch.sendQueueSize, 1) return true default: return false } }
[ "func", "(", "ch", "*", "Channel", ")", "trySendBytes", "(", "bytes", "[", "]", "byte", ")", "bool", "{", "select", "{", "case", "ch", ".", "sendQueue", "<-", "bytes", ":", "atomic", ".", "AddInt32", "(", "&", "ch", ".", "sendQueueSize", ",", "1", ...
// Queues message to send to this channel. // Nonblocking, returns true if successful. // Goroutine-safe
[ "Queues", "message", "to", "send", "to", "this", "channel", ".", "Nonblocking", "returns", "true", "if", "successful", ".", "Goroutine", "-", "safe" ]
4253e67c07c69be6d7f7263ab03944ce30a9fc90
https://github.com/tendermint/tendermint/blob/4253e67c07c69be6d7f7263ab03944ce30a9fc90/p2p/conn/connection.go#L741-L749