repo stringlengths 5 67 | path stringlengths 4 218 | func_name stringlengths 0 151 | original_string stringlengths 52 373k | language stringclasses 6
values | code stringlengths 52 373k | code_tokens listlengths 10 512 | docstring stringlengths 3 47.2k | docstring_tokens listlengths 3 234 | sha stringlengths 40 40 | url stringlengths 85 339 | partition stringclasses 3
values |
|---|---|---|---|---|---|---|---|---|---|---|---|
brankas/sentinel | sentinel.go | Shutdown | func (s *Sentinel) Shutdown() error {
var firstErr error
for i, f := range s.shutdownFuncs {
ctxt, cancel := context.WithTimeout(context.Background(), s.shutdownDuration)
defer cancel()
if err := f(ctxt); err != nil {
s.errf("could not shutdown %d: %v", i, err)
if firstErr == nil {
firstErr = err
}... | go | func (s *Sentinel) Shutdown() error {
var firstErr error
for i, f := range s.shutdownFuncs {
ctxt, cancel := context.WithTimeout(context.Background(), s.shutdownDuration)
defer cancel()
if err := f(ctxt); err != nil {
s.errf("could not shutdown %d: %v", i, err)
if firstErr == nil {
firstErr = err
}... | [
"func",
"(",
"s",
"*",
"Sentinel",
")",
"Shutdown",
"(",
")",
"error",
"{",
"var",
"firstErr",
"error",
"\n",
"for",
"i",
",",
"f",
":=",
"range",
"s",
".",
"shutdownFuncs",
"{",
"ctxt",
",",
"cancel",
":=",
"context",
".",
"WithTimeout",
"(",
"conte... | // Shutdown calls all registered shutdown funcs. | [
"Shutdown",
"calls",
"all",
"registered",
"shutdown",
"funcs",
"."
] | 0ff081867c31a45cb71f5976ea6144fd06a557b5 | https://github.com/brankas/sentinel/blob/0ff081867c31a45cb71f5976ea6144fd06a557b5/sentinel.go#L108-L121 | test |
brankas/sentinel | sentinel.go | ShutdownIgnore | func (s *Sentinel) ShutdownIgnore(err error) bool {
if err == nil {
return true
}
for _, f := range s.ignoreErrors {
if z := f(err); z {
return true
}
}
return false
} | go | func (s *Sentinel) ShutdownIgnore(err error) bool {
if err == nil {
return true
}
for _, f := range s.ignoreErrors {
if z := f(err); z {
return true
}
}
return false
} | [
"func",
"(",
"s",
"*",
"Sentinel",
")",
"ShutdownIgnore",
"(",
"err",
"error",
")",
"bool",
"{",
"if",
"err",
"==",
"nil",
"{",
"return",
"true",
"\n",
"}",
"\n",
"for",
"_",
",",
"f",
":=",
"range",
"s",
".",
"ignoreErrors",
"{",
"if",
"z",
":="... | // ShutdownIgnore returns if any of the registered ignore funcs reported true. | [
"ShutdownIgnore",
"returns",
"if",
"any",
"of",
"the",
"registered",
"ignore",
"funcs",
"reported",
"true",
"."
] | 0ff081867c31a45cb71f5976ea6144fd06a557b5 | https://github.com/brankas/sentinel/blob/0ff081867c31a45cb71f5976ea6144fd06a557b5/sentinel.go#L124-L134 | test |
brankas/sentinel | sentinel.go | Register | func (s *Sentinel) Register(server, shutdown interface{}, ignore ...func(error) bool) error {
// add server and shutdown funcs
var err error
s.serverFuncs, err = convertAndAppendContextFuncs(s.serverFuncs, server)
if err != nil {
return err
}
s.shutdownFuncs, err = convertAndAppendContextFuncs(s.shutdownFuncs, ... | go | func (s *Sentinel) Register(server, shutdown interface{}, ignore ...func(error) bool) error {
// add server and shutdown funcs
var err error
s.serverFuncs, err = convertAndAppendContextFuncs(s.serverFuncs, server)
if err != nil {
return err
}
s.shutdownFuncs, err = convertAndAppendContextFuncs(s.shutdownFuncs, ... | [
"func",
"(",
"s",
"*",
"Sentinel",
")",
"Register",
"(",
"server",
",",
"shutdown",
"interface",
"{",
"}",
",",
"ignore",
"...",
"func",
"(",
"error",
")",
"bool",
")",
"error",
"{",
"var",
"err",
"error",
"\n",
"s",
".",
"serverFuncs",
",",
"err",
... | // Register registers a server, its shutdown func, and ignore error funcs. | [
"Register",
"registers",
"a",
"server",
"its",
"shutdown",
"func",
"and",
"ignore",
"error",
"funcs",
"."
] | 0ff081867c31a45cb71f5976ea6144fd06a557b5 | https://github.com/brankas/sentinel/blob/0ff081867c31a45cb71f5976ea6144fd06a557b5/sentinel.go#L137-L151 | test |
brankas/sentinel | sentinel.go | Mux | func (s *Sentinel) Mux(listener net.Listener, opts ...netmux.Option) (*netmux.Netmux, error) {
s.Lock()
defer s.Unlock()
if s.started {
return nil, ErrAlreadyStarted
}
// create connection mux
mux, err := netmux.New(listener, opts...)
if err != nil {
return nil, err
}
// register server + shutdown
if e... | go | func (s *Sentinel) Mux(listener net.Listener, opts ...netmux.Option) (*netmux.Netmux, error) {
s.Lock()
defer s.Unlock()
if s.started {
return nil, ErrAlreadyStarted
}
// create connection mux
mux, err := netmux.New(listener, opts...)
if err != nil {
return nil, err
}
// register server + shutdown
if e... | [
"func",
"(",
"s",
"*",
"Sentinel",
")",
"Mux",
"(",
"listener",
"net",
".",
"Listener",
",",
"opts",
"...",
"netmux",
".",
"Option",
")",
"(",
"*",
"netmux",
".",
"Netmux",
",",
"error",
")",
"{",
"s",
".",
"Lock",
"(",
")",
"\n",
"defer",
"s",
... | // Mux creates a new network connection muxer and registers its server,
// shutdown, and ignore error funcs. | [
"Mux",
"creates",
"a",
"new",
"network",
"connection",
"muxer",
"and",
"registers",
"its",
"server",
"shutdown",
"and",
"ignore",
"error",
"funcs",
"."
] | 0ff081867c31a45cb71f5976ea6144fd06a557b5 | https://github.com/brankas/sentinel/blob/0ff081867c31a45cb71f5976ea6144fd06a557b5/sentinel.go#L155-L175 | test |
brankas/sentinel | sentinel.go | HTTP | func (s *Sentinel) HTTP(listener net.Listener, handler http.Handler, opts ...ServerOption) error {
s.Lock()
defer s.Unlock()
if s.started {
return ErrAlreadyStarted
}
var err error
// create server and apply options
server := &http.Server{
Handler: handler,
}
for _, o := range opts {
if err = o(server... | go | func (s *Sentinel) HTTP(listener net.Listener, handler http.Handler, opts ...ServerOption) error {
s.Lock()
defer s.Unlock()
if s.started {
return ErrAlreadyStarted
}
var err error
// create server and apply options
server := &http.Server{
Handler: handler,
}
for _, o := range opts {
if err = o(server... | [
"func",
"(",
"s",
"*",
"Sentinel",
")",
"HTTP",
"(",
"listener",
"net",
".",
"Listener",
",",
"handler",
"http",
".",
"Handler",
",",
"opts",
"...",
"ServerOption",
")",
"error",
"{",
"s",
".",
"Lock",
"(",
")",
"\n",
"defer",
"s",
".",
"Unlock",
"... | // HTTP creates a HTTP server and registers it with the sentinel. | [
"HTTP",
"creates",
"a",
"HTTP",
"server",
"and",
"registers",
"it",
"with",
"the",
"sentinel",
"."
] | 0ff081867c31a45cb71f5976ea6144fd06a557b5 | https://github.com/brankas/sentinel/blob/0ff081867c31a45cb71f5976ea6144fd06a557b5/sentinel.go#L178-L202 | test |
brankas/sentinel | sentinel.go | IgnoreError | func IgnoreError(err error) func(error) bool {
return func(e error) bool {
return err == e
}
} | go | func IgnoreError(err error) func(error) bool {
return func(e error) bool {
return err == e
}
} | [
"func",
"IgnoreError",
"(",
"err",
"error",
")",
"func",
"(",
"error",
")",
"bool",
"{",
"return",
"func",
"(",
"e",
"error",
")",
"bool",
"{",
"return",
"err",
"==",
"e",
"\n",
"}",
"\n",
"}"
] | // IgnoreError returns a func that will return true when the passed errors
// match. | [
"IgnoreError",
"returns",
"a",
"func",
"that",
"will",
"return",
"true",
"when",
"the",
"passed",
"errors",
"match",
"."
] | 0ff081867c31a45cb71f5976ea6144fd06a557b5 | https://github.com/brankas/sentinel/blob/0ff081867c31a45cb71f5976ea6144fd06a557b5/sentinel.go#L206-L210 | test |
brankas/sentinel | sentinel.go | IgnoreNetOpError | func IgnoreNetOpError(err error) bool {
if opErr, ok := err.(*net.OpError); ok {
return opErr.Err.Error() == "use of closed network connection"
}
return false
} | go | func IgnoreNetOpError(err error) bool {
if opErr, ok := err.(*net.OpError); ok {
return opErr.Err.Error() == "use of closed network connection"
}
return false
} | [
"func",
"IgnoreNetOpError",
"(",
"err",
"error",
")",
"bool",
"{",
"if",
"opErr",
",",
"ok",
":=",
"err",
".",
"(",
"*",
"net",
".",
"OpError",
")",
";",
"ok",
"{",
"return",
"opErr",
".",
"Err",
".",
"Error",
"(",
")",
"==",
"\"use of closed network... | // IgnoreNetOpError returns true when the passed error is a net.OpError with
// error "use of closed network connection". | [
"IgnoreNetOpError",
"returns",
"true",
"when",
"the",
"passed",
"error",
"is",
"a",
"net",
".",
"OpError",
"with",
"error",
"use",
"of",
"closed",
"network",
"connection",
"."
] | 0ff081867c31a45cb71f5976ea6144fd06a557b5 | https://github.com/brankas/sentinel/blob/0ff081867c31a45cb71f5976ea6144fd06a557b5/sentinel.go#L226-L231 | test |
brankas/sentinel | util.go | convertAndAppendContextFuncs | func convertAndAppendContextFuncs(o []func(context.Context) error, v ...interface{}) ([]func(context.Context) error, error) {
for _, z := range v {
var t func(context.Context) error
switch f := z.(type) {
case func(context.Context) error:
t = f
case func():
t = func(context.Context) error {
f()
... | go | func convertAndAppendContextFuncs(o []func(context.Context) error, v ...interface{}) ([]func(context.Context) error, error) {
for _, z := range v {
var t func(context.Context) error
switch f := z.(type) {
case func(context.Context) error:
t = f
case func():
t = func(context.Context) error {
f()
... | [
"func",
"convertAndAppendContextFuncs",
"(",
"o",
"[",
"]",
"func",
"(",
"context",
".",
"Context",
")",
"error",
",",
"v",
"...",
"interface",
"{",
"}",
")",
"(",
"[",
"]",
"func",
"(",
"context",
".",
"Context",
")",
"error",
",",
"error",
")",
"{"... | // convertAndAppendContextFuncs converts and appends funcs in v to o. | [
"convertAndAppendContextFuncs",
"converts",
"and",
"appends",
"funcs",
"in",
"v",
"to",
"o",
"."
] | 0ff081867c31a45cb71f5976ea6144fd06a557b5 | https://github.com/brankas/sentinel/blob/0ff081867c31a45cb71f5976ea6144fd06a557b5/util.go#L25-L51 | test |
Financial-Times/base-ft-rw-app-go | baseftrwapp/baseftapp.go | router | func router(apiData []byte, services map[string]Service, healthHandler func(http.ResponseWriter, *http.Request)) *mux.Router {
m := mux.NewRouter()
gtgChecker := make([]gtg.StatusChecker, 0)
for path, service := range services {
handlers := httpHandlers{service}
m.HandleFunc(fmt.Sprintf("/%s/__count", path), h... | go | func router(apiData []byte, services map[string]Service, healthHandler func(http.ResponseWriter, *http.Request)) *mux.Router {
m := mux.NewRouter()
gtgChecker := make([]gtg.StatusChecker, 0)
for path, service := range services {
handlers := httpHandlers{service}
m.HandleFunc(fmt.Sprintf("/%s/__count", path), h... | [
"func",
"router",
"(",
"apiData",
"[",
"]",
"byte",
",",
"services",
"map",
"[",
"string",
"]",
"Service",
",",
"healthHandler",
"func",
"(",
"http",
".",
"ResponseWriter",
",",
"*",
"http",
".",
"Request",
")",
")",
"*",
"mux",
".",
"Router",
"{",
"... | //Router sets up the Router - extracted for testability | [
"Router",
"sets",
"up",
"the",
"Router",
"-",
"extracted",
"for",
"testability"
] | 1ea8a13e1f37b95318cd965796558d932750f407 | https://github.com/Financial-Times/base-ft-rw-app-go/blob/1ea8a13e1f37b95318cd965796558d932750f407/baseftrwapp/baseftapp.go#L84-L128 | test |
Financial-Times/base-ft-rw-app-go | baseftrwapp/http_handlers.go | buildInfoHandler | func buildInfoHandler(w http.ResponseWriter, req *http.Request) {
fmt.Fprintf(w, "build-info")
} | go | func buildInfoHandler(w http.ResponseWriter, req *http.Request) {
fmt.Fprintf(w, "build-info")
} | [
"func",
"buildInfoHandler",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"req",
"*",
"http",
".",
"Request",
")",
"{",
"fmt",
".",
"Fprintf",
"(",
"w",
",",
"\"build-info\"",
")",
"\n",
"}"
] | // buildInfoHandler - This is a stop gap and will be added to when we can define what we should display here | [
"buildInfoHandler",
"-",
"This",
"is",
"a",
"stop",
"gap",
"and",
"will",
"be",
"added",
"to",
"when",
"we",
"can",
"define",
"what",
"we",
"should",
"display",
"here"
] | 1ea8a13e1f37b95318cd965796558d932750f407 | https://github.com/Financial-Times/base-ft-rw-app-go/blob/1ea8a13e1f37b95318cd965796558d932750f407/baseftrwapp/http_handlers.go#L192-L194 | test |
codegangsta/martini-contrib | encoder/encoder.go | Encode | func (_ JsonEncoder) Encode(v ...interface{}) ([]byte, error) {
var data interface{} = v
var result interface{}
if v == nil {
// So that empty results produces `[]` and not `null`
data = []interface{}{}
} else if len(v) == 1 {
data = v[0]
}
t := reflect.TypeOf(data)
if t.Kind() == reflect.Ptr {
t = t.... | go | func (_ JsonEncoder) Encode(v ...interface{}) ([]byte, error) {
var data interface{} = v
var result interface{}
if v == nil {
// So that empty results produces `[]` and not `null`
data = []interface{}{}
} else if len(v) == 1 {
data = v[0]
}
t := reflect.TypeOf(data)
if t.Kind() == reflect.Ptr {
t = t.... | [
"func",
"(",
"_",
"JsonEncoder",
")",
"Encode",
"(",
"v",
"...",
"interface",
"{",
"}",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"var",
"data",
"interface",
"{",
"}",
"=",
"v",
"\n",
"var",
"result",
"interface",
"{",
"}",
"\n",
"if",
... | // jsonEncoder is an Encoder that produces JSON-formatted responses. | [
"jsonEncoder",
"is",
"an",
"Encoder",
"that",
"produces",
"JSON",
"-",
"formatted",
"responses",
"."
] | 8ce6181c2609699e4c7cd30994b76a850a9cdadc | https://github.com/codegangsta/martini-contrib/blob/8ce6181c2609699e4c7cd30994b76a850a9cdadc/encoder/encoder.go#L32-L58 | test |
codegangsta/martini-contrib | binding/binding.go | Json | func Json(jsonStruct interface{}, ifacePtr ...interface{}) martini.Handler {
return func(context martini.Context, req *http.Request) {
ensureNotPointer(jsonStruct)
jsonStruct := reflect.New(reflect.TypeOf(jsonStruct))
errors := newErrors()
if req.Body != nil {
defer req.Body.Close()
}
if err := json.N... | go | func Json(jsonStruct interface{}, ifacePtr ...interface{}) martini.Handler {
return func(context martini.Context, req *http.Request) {
ensureNotPointer(jsonStruct)
jsonStruct := reflect.New(reflect.TypeOf(jsonStruct))
errors := newErrors()
if req.Body != nil {
defer req.Body.Close()
}
if err := json.N... | [
"func",
"Json",
"(",
"jsonStruct",
"interface",
"{",
"}",
",",
"ifacePtr",
"...",
"interface",
"{",
"}",
")",
"martini",
".",
"Handler",
"{",
"return",
"func",
"(",
"context",
"martini",
".",
"Context",
",",
"req",
"*",
"http",
".",
"Request",
")",
"{"... | // Json is middleware to deserialize a JSON payload from the request
// into the struct that is passed in. The resulting struct is then
// validated, but no error handling is actually performed here.
// An interface pointer can be added as a second argument in order
// to map the struct to a specific interface. | [
"Json",
"is",
"middleware",
"to",
"deserialize",
"a",
"JSON",
"payload",
"from",
"the",
"request",
"into",
"the",
"struct",
"that",
"is",
"passed",
"in",
".",
"The",
"resulting",
"struct",
"is",
"then",
"validated",
"but",
"no",
"error",
"handling",
"is",
... | 8ce6181c2609699e4c7cd30994b76a850a9cdadc | https://github.com/codegangsta/martini-contrib/blob/8ce6181c2609699e4c7cd30994b76a850a9cdadc/binding/binding.go#L116-L132 | test |
codegangsta/martini-contrib | binding/binding.go | validateAndMap | func validateAndMap(obj reflect.Value, context martini.Context, errors *Errors, ifacePtr ...interface{}) {
context.Invoke(Validate(obj.Interface()))
errors.combine(getErrors(context))
context.Map(*errors)
context.Map(obj.Elem().Interface())
if len(ifacePtr) > 0 {
context.MapTo(obj.Elem().Interface(), ifacePtr[0]... | go | func validateAndMap(obj reflect.Value, context martini.Context, errors *Errors, ifacePtr ...interface{}) {
context.Invoke(Validate(obj.Interface()))
errors.combine(getErrors(context))
context.Map(*errors)
context.Map(obj.Elem().Interface())
if len(ifacePtr) > 0 {
context.MapTo(obj.Elem().Interface(), ifacePtr[0]... | [
"func",
"validateAndMap",
"(",
"obj",
"reflect",
".",
"Value",
",",
"context",
"martini",
".",
"Context",
",",
"errors",
"*",
"Errors",
",",
"ifacePtr",
"...",
"interface",
"{",
"}",
")",
"{",
"context",
".",
"Invoke",
"(",
"Validate",
"(",
"obj",
".",
... | // Performs validation and combines errors from validation
// with errors from deserialization, then maps both the
// resulting struct and the errors to the context. | [
"Performs",
"validation",
"and",
"combines",
"errors",
"from",
"validation",
"with",
"errors",
"from",
"deserialization",
"then",
"maps",
"both",
"the",
"resulting",
"struct",
"and",
"the",
"errors",
"to",
"the",
"context",
"."
] | 8ce6181c2609699e4c7cd30994b76a850a9cdadc | https://github.com/codegangsta/martini-contrib/blob/8ce6181c2609699e4c7cd30994b76a850a9cdadc/binding/binding.go#L299-L307 | test |
codegangsta/martini-contrib | binding/binding.go | Count | func (self Errors) Count() int {
return len(self.Overall) + len(self.Fields)
} | go | func (self Errors) Count() int {
return len(self.Overall) + len(self.Fields)
} | [
"func",
"(",
"self",
"Errors",
")",
"Count",
"(",
")",
"int",
"{",
"return",
"len",
"(",
"self",
".",
"Overall",
")",
"+",
"len",
"(",
"self",
".",
"Fields",
")",
"\n",
"}"
] | // Total errors is the sum of errors with the request overall
// and errors on individual fields. | [
"Total",
"errors",
"is",
"the",
"sum",
"of",
"errors",
"with",
"the",
"request",
"overall",
"and",
"errors",
"on",
"individual",
"fields",
"."
] | 8ce6181c2609699e4c7cd30994b76a850a9cdadc | https://github.com/codegangsta/martini-contrib/blob/8ce6181c2609699e4c7cd30994b76a850a9cdadc/binding/binding.go#L332-L334 | test |
codegangsta/martini-contrib | cors/cors.go | Header | func (o *Options) Header(origin string) (headers map[string]string) {
headers = make(map[string]string)
// if origin is not alowed, don't extend the headers
// with CORS headers.
if !o.AllowAllOrigins && !o.IsOriginAllowed(origin) {
return
}
// add allow origin
if o.AllowAllOrigins {
headers[headerAllowOrig... | go | func (o *Options) Header(origin string) (headers map[string]string) {
headers = make(map[string]string)
// if origin is not alowed, don't extend the headers
// with CORS headers.
if !o.AllowAllOrigins && !o.IsOriginAllowed(origin) {
return
}
// add allow origin
if o.AllowAllOrigins {
headers[headerAllowOrig... | [
"func",
"(",
"o",
"*",
"Options",
")",
"Header",
"(",
"origin",
"string",
")",
"(",
"headers",
"map",
"[",
"string",
"]",
"string",
")",
"{",
"headers",
"=",
"make",
"(",
"map",
"[",
"string",
"]",
"string",
")",
"\n",
"if",
"!",
"o",
".",
"Allow... | // Converts options into CORS headers. | [
"Converts",
"options",
"into",
"CORS",
"headers",
"."
] | 8ce6181c2609699e4c7cd30994b76a850a9cdadc | https://github.com/codegangsta/martini-contrib/blob/8ce6181c2609699e4c7cd30994b76a850a9cdadc/cors/cors.go#L44-L82 | test |
codegangsta/martini-contrib | cors/cors.go | PreflightHeader | func (o *Options) PreflightHeader(origin, rMethod, rHeaders string) (headers map[string]string) {
headers = make(map[string]string)
if !o.AllowAllOrigins && !o.IsOriginAllowed(origin) {
return
}
// verify if requested method is allowed
// TODO: Too many for loops
for _, method := range o.AllowMethods {
if met... | go | func (o *Options) PreflightHeader(origin, rMethod, rHeaders string) (headers map[string]string) {
headers = make(map[string]string)
if !o.AllowAllOrigins && !o.IsOriginAllowed(origin) {
return
}
// verify if requested method is allowed
// TODO: Too many for loops
for _, method := range o.AllowMethods {
if met... | [
"func",
"(",
"o",
"*",
"Options",
")",
"PreflightHeader",
"(",
"origin",
",",
"rMethod",
",",
"rHeaders",
"string",
")",
"(",
"headers",
"map",
"[",
"string",
"]",
"string",
")",
"{",
"headers",
"=",
"make",
"(",
"map",
"[",
"string",
"]",
"string",
... | // Converts options into CORS headers for a preflight response. | [
"Converts",
"options",
"into",
"CORS",
"headers",
"for",
"a",
"preflight",
"response",
"."
] | 8ce6181c2609699e4c7cd30994b76a850a9cdadc | https://github.com/codegangsta/martini-contrib/blob/8ce6181c2609699e4c7cd30994b76a850a9cdadc/cors/cors.go#L85-L125 | test |
codegangsta/martini-contrib | cors/cors.go | IsOriginAllowed | func (o *Options) IsOriginAllowed(origin string) (allowed bool) {
for _, pattern := range o.AllowOrigins {
allowed, _ = regexp.MatchString(pattern, origin)
if allowed {
return
}
}
return
} | go | func (o *Options) IsOriginAllowed(origin string) (allowed bool) {
for _, pattern := range o.AllowOrigins {
allowed, _ = regexp.MatchString(pattern, origin)
if allowed {
return
}
}
return
} | [
"func",
"(",
"o",
"*",
"Options",
")",
"IsOriginAllowed",
"(",
"origin",
"string",
")",
"(",
"allowed",
"bool",
")",
"{",
"for",
"_",
",",
"pattern",
":=",
"range",
"o",
".",
"AllowOrigins",
"{",
"allowed",
",",
"_",
"=",
"regexp",
".",
"MatchString",
... | // Looks up if the origin matches one of the patterns
// provided in Options.AllowOrigins patterns. | [
"Looks",
"up",
"if",
"the",
"origin",
"matches",
"one",
"of",
"the",
"patterns",
"provided",
"in",
"Options",
".",
"AllowOrigins",
"patterns",
"."
] | 8ce6181c2609699e4c7cd30994b76a850a9cdadc | https://github.com/codegangsta/martini-contrib/blob/8ce6181c2609699e4c7cd30994b76a850a9cdadc/cors/cors.go#L129-L137 | test |
codegangsta/martini-contrib | cors/cors.go | Allow | func Allow(opts *Options) http.HandlerFunc {
return func(res http.ResponseWriter, req *http.Request) {
var (
origin = req.Header.Get(headerOrigin)
requestedMethod = req.Header.Get(headerRequestMethod)
requestedHeaders = req.Header.Get(headerRequestHeaders)
// additional headers to be added
... | go | func Allow(opts *Options) http.HandlerFunc {
return func(res http.ResponseWriter, req *http.Request) {
var (
origin = req.Header.Get(headerOrigin)
requestedMethod = req.Header.Get(headerRequestMethod)
requestedHeaders = req.Header.Get(headerRequestHeaders)
// additional headers to be added
... | [
"func",
"Allow",
"(",
"opts",
"*",
"Options",
")",
"http",
".",
"HandlerFunc",
"{",
"return",
"func",
"(",
"res",
"http",
".",
"ResponseWriter",
",",
"req",
"*",
"http",
".",
"Request",
")",
"{",
"var",
"(",
"origin",
"=",
"req",
".",
"Header",
".",
... | // Allows CORS for requests those match the provided options. | [
"Allows",
"CORS",
"for",
"requests",
"those",
"match",
"the",
"provided",
"options",
"."
] | 8ce6181c2609699e4c7cd30994b76a850a9cdadc | https://github.com/codegangsta/martini-contrib/blob/8ce6181c2609699e4c7cd30994b76a850a9cdadc/cors/cors.go#L140-L163 | test |
codegangsta/martini-contrib | render/render.go | Renderer | func Renderer(options ...Options) martini.Handler {
opt := prepareOptions(options)
cs := prepareCharset(opt.Charset)
t := compile(opt)
return func(res http.ResponseWriter, req *http.Request, c martini.Context) {
// recompile for easy development
if martini.Env == martini.Dev {
t = compile(opt)
}
tc, _ :=... | go | func Renderer(options ...Options) martini.Handler {
opt := prepareOptions(options)
cs := prepareCharset(opt.Charset)
t := compile(opt)
return func(res http.ResponseWriter, req *http.Request, c martini.Context) {
// recompile for easy development
if martini.Env == martini.Dev {
t = compile(opt)
}
tc, _ :=... | [
"func",
"Renderer",
"(",
"options",
"...",
"Options",
")",
"martini",
".",
"Handler",
"{",
"opt",
":=",
"prepareOptions",
"(",
"options",
")",
"\n",
"cs",
":=",
"prepareCharset",
"(",
"opt",
".",
"Charset",
")",
"\n",
"t",
":=",
"compile",
"(",
"opt",
... | // Renderer is a Middleware that maps a render.Render service into the Martini handler chain. An single variadic render.Options
// struct can be optionally provided to configure HTML rendering. The default directory for templates is "templates" and the default
// file extension is ".tmpl".
//
// If MARTINI_ENV is set t... | [
"Renderer",
"is",
"a",
"Middleware",
"that",
"maps",
"a",
"render",
".",
"Render",
"service",
"into",
"the",
"Martini",
"handler",
"chain",
".",
"An",
"single",
"variadic",
"render",
".",
"Options",
"struct",
"can",
"be",
"optionally",
"provided",
"to",
"con... | 8ce6181c2609699e4c7cd30994b76a850a9cdadc | https://github.com/codegangsta/martini-contrib/blob/8ce6181c2609699e4c7cd30994b76a850a9cdadc/render/render.go#L107-L119 | test |
codegangsta/martini-contrib | acceptlang/handler.go | String | func (al AcceptLanguages) String() string {
output := bytes.NewBufferString("")
for i, language := range al {
output.WriteString(fmt.Sprintf("%s (%1.1f)", language.Language, language.Quality))
if i != len(al)-1 {
output.WriteString(", ")
}
}
if output.Len() == 0 {
output.WriteString("[]")
}
return ou... | go | func (al AcceptLanguages) String() string {
output := bytes.NewBufferString("")
for i, language := range al {
output.WriteString(fmt.Sprintf("%s (%1.1f)", language.Language, language.Quality))
if i != len(al)-1 {
output.WriteString(", ")
}
}
if output.Len() == 0 {
output.WriteString("[]")
}
return ou... | [
"func",
"(",
"al",
"AcceptLanguages",
")",
"String",
"(",
")",
"string",
"{",
"output",
":=",
"bytes",
".",
"NewBufferString",
"(",
"\"\"",
")",
"\n",
"for",
"i",
",",
"language",
":=",
"range",
"al",
"{",
"output",
".",
"WriteString",
"(",
"fmt",
".",... | // Returns the parsed languages in a human readable fashion. | [
"Returns",
"the",
"parsed",
"languages",
"in",
"a",
"human",
"readable",
"fashion",
"."
] | 8ce6181c2609699e4c7cd30994b76a850a9cdadc | https://github.com/codegangsta/martini-contrib/blob/8ce6181c2609699e4c7cd30994b76a850a9cdadc/acceptlang/handler.go#L52-L66 | test |
codegangsta/martini-contrib | acceptlang/handler.go | Languages | func Languages() martini.Handler {
return func(context martini.Context, request *http.Request) {
header := request.Header.Get(acceptLanguageHeader)
if header != "" {
acceptLanguageHeaderValues := strings.Split(header, ",")
acceptLanguages := make(AcceptLanguages, len(acceptLanguageHeaderValues))
for i, l... | go | func Languages() martini.Handler {
return func(context martini.Context, request *http.Request) {
header := request.Header.Get(acceptLanguageHeader)
if header != "" {
acceptLanguageHeaderValues := strings.Split(header, ",")
acceptLanguages := make(AcceptLanguages, len(acceptLanguageHeaderValues))
for i, l... | [
"func",
"Languages",
"(",
")",
"martini",
".",
"Handler",
"{",
"return",
"func",
"(",
"context",
"martini",
".",
"Context",
",",
"request",
"*",
"http",
".",
"Request",
")",
"{",
"header",
":=",
"request",
".",
"Header",
".",
"Get",
"(",
"acceptLanguageH... | // Creates a new handler that parses the Accept-Language HTTP header.
//
// The parsed structure is a slice of Accept-Language values stored in an
// AcceptLanguages instance, sorted based on the language qualifier. | [
"Creates",
"a",
"new",
"handler",
"that",
"parses",
"the",
"Accept",
"-",
"Language",
"HTTP",
"header",
".",
"The",
"parsed",
"structure",
"is",
"a",
"slice",
"of",
"Accept",
"-",
"Language",
"values",
"stored",
"in",
"an",
"AcceptLanguages",
"instance",
"so... | 8ce6181c2609699e4c7cd30994b76a850a9cdadc | https://github.com/codegangsta/martini-contrib/blob/8ce6181c2609699e4c7cd30994b76a850a9cdadc/acceptlang/handler.go#L72-L101 | test |
codegangsta/martini-contrib | strip/prefix.go | Prefix | func Prefix(prefix string) martini.Handler {
return func(w http.ResponseWriter, r *http.Request) {
if prefix == "" {
return
}
if p := strings.TrimPrefix(r.URL.Path, prefix); len(p) < len(r.URL.Path) {
r.URL.Path = p
} else {
http.NotFound(w, r)
}
}
} | go | func Prefix(prefix string) martini.Handler {
return func(w http.ResponseWriter, r *http.Request) {
if prefix == "" {
return
}
if p := strings.TrimPrefix(r.URL.Path, prefix); len(p) < len(r.URL.Path) {
r.URL.Path = p
} else {
http.NotFound(w, r)
}
}
} | [
"func",
"Prefix",
"(",
"prefix",
"string",
")",
"martini",
".",
"Handler",
"{",
"return",
"func",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"if",
"prefix",
"==",
"\"\"",
"{",
"return",
"\n",
"}",
"\n",
... | // strip Prefix for every incoming http request | [
"strip",
"Prefix",
"for",
"every",
"incoming",
"http",
"request"
] | 8ce6181c2609699e4c7cd30994b76a850a9cdadc | https://github.com/codegangsta/martini-contrib/blob/8ce6181c2609699e4c7cd30994b76a850a9cdadc/strip/prefix.go#L12-L23 | test |
codegangsta/martini-contrib | auth/basic.go | Basic | func Basic(username string, password string) http.HandlerFunc {
var siteAuth = base64.StdEncoding.EncodeToString([]byte(username + ":" + password))
return func(res http.ResponseWriter, req *http.Request) {
auth := req.Header.Get("Authorization")
if !SecureCompare(auth, "Basic "+siteAuth) {
res.Header().Set("WW... | go | func Basic(username string, password string) http.HandlerFunc {
var siteAuth = base64.StdEncoding.EncodeToString([]byte(username + ":" + password))
return func(res http.ResponseWriter, req *http.Request) {
auth := req.Header.Get("Authorization")
if !SecureCompare(auth, "Basic "+siteAuth) {
res.Header().Set("WW... | [
"func",
"Basic",
"(",
"username",
"string",
",",
"password",
"string",
")",
"http",
".",
"HandlerFunc",
"{",
"var",
"siteAuth",
"=",
"base64",
".",
"StdEncoding",
".",
"EncodeToString",
"(",
"[",
"]",
"byte",
"(",
"username",
"+",
"\":\"",
"+",
"password",... | // Basic returns a Handler that authenticates via Basic Auth. Writes a http.StatusUnauthorized
// if authentication fails | [
"Basic",
"returns",
"a",
"Handler",
"that",
"authenticates",
"via",
"Basic",
"Auth",
".",
"Writes",
"a",
"http",
".",
"StatusUnauthorized",
"if",
"authentication",
"fails"
] | 8ce6181c2609699e4c7cd30994b76a850a9cdadc | https://github.com/codegangsta/martini-contrib/blob/8ce6181c2609699e4c7cd30994b76a850a9cdadc/auth/basic.go#L10-L19 | test |
codegangsta/martini-contrib | sessionauth/login.go | UpdateUser | func UpdateUser(s sessions.Session, user User) error {
s.Set(SessionKey, user.UniqueId())
return nil
} | go | func UpdateUser(s sessions.Session, user User) error {
s.Set(SessionKey, user.UniqueId())
return nil
} | [
"func",
"UpdateUser",
"(",
"s",
"sessions",
".",
"Session",
",",
"user",
"User",
")",
"error",
"{",
"s",
".",
"Set",
"(",
"SessionKey",
",",
"user",
".",
"UniqueId",
"(",
")",
")",
"\n",
"return",
"nil",
"\n",
"}"
] | // UpdateUser updates the User object stored in the session. This is useful incase a change
// is made to the user model that needs to persist across requests. | [
"UpdateUser",
"updates",
"the",
"User",
"object",
"stored",
"in",
"the",
"session",
".",
"This",
"is",
"useful",
"incase",
"a",
"change",
"is",
"made",
"to",
"the",
"user",
"model",
"that",
"needs",
"to",
"persist",
"across",
"requests",
"."
] | 8ce6181c2609699e4c7cd30994b76a850a9cdadc | https://github.com/codegangsta/martini-contrib/blob/8ce6181c2609699e4c7cd30994b76a850a9cdadc/sessionauth/login.go#L101-L104 | test |
codegangsta/martini-contrib | sessionauth/example/user.go | GetById | func (u *MyUserModel) GetById(id interface{}) error {
err := dbmap.SelectOne(u, "SELECT * FROM users WHERE id = $1", id)
if err != nil {
return err
}
return nil
} | go | func (u *MyUserModel) GetById(id interface{}) error {
err := dbmap.SelectOne(u, "SELECT * FROM users WHERE id = $1", id)
if err != nil {
return err
}
return nil
} | [
"func",
"(",
"u",
"*",
"MyUserModel",
")",
"GetById",
"(",
"id",
"interface",
"{",
"}",
")",
"error",
"{",
"err",
":=",
"dbmap",
".",
"SelectOne",
"(",
"u",
",",
"\"SELECT * FROM users WHERE id = $1\"",
",",
"id",
")",
"\n",
"if",
"err",
"!=",
"nil",
"... | // GetById will populate a user object from a database model with
// a matching id. | [
"GetById",
"will",
"populate",
"a",
"user",
"object",
"from",
"a",
"database",
"model",
"with",
"a",
"matching",
"id",
"."
] | 8ce6181c2609699e4c7cd30994b76a850a9cdadc | https://github.com/codegangsta/martini-contrib/blob/8ce6181c2609699e4c7cd30994b76a850a9cdadc/sessionauth/example/user.go#L48-L55 | test |
stellar/go-stellar-base | main.go | AddressToAccountId | func AddressToAccountId(address string) (result xdr.AccountId, err error) {
bytes, err := strkey.Decode(strkey.VersionByteAccountID, address)
if err != nil {
return
}
var raw xdr.Uint256
copy(raw[:], bytes)
pk, err := xdr.NewPublicKey(xdr.CryptoKeyTypeKeyTypeEd25519, raw)
if err != nil {
return
}
resul... | go | func AddressToAccountId(address string) (result xdr.AccountId, err error) {
bytes, err := strkey.Decode(strkey.VersionByteAccountID, address)
if err != nil {
return
}
var raw xdr.Uint256
copy(raw[:], bytes)
pk, err := xdr.NewPublicKey(xdr.CryptoKeyTypeKeyTypeEd25519, raw)
if err != nil {
return
}
resul... | [
"func",
"AddressToAccountId",
"(",
"address",
"string",
")",
"(",
"result",
"xdr",
".",
"AccountId",
",",
"err",
"error",
")",
"{",
"bytes",
",",
"err",
":=",
"strkey",
".",
"Decode",
"(",
"strkey",
".",
"VersionByteAccountID",
",",
"address",
")",
"\n",
... | // AddressToAccountId converts the provided address into a xdr.AccountId | [
"AddressToAccountId",
"converts",
"the",
"provided",
"address",
"into",
"a",
"xdr",
".",
"AccountId"
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/main.go#L16-L34 | test |
stellar/go-stellar-base | build/change_trust.go | MutateChangeTrust | func (m Asset) MutateChangeTrust(o *xdr.ChangeTrustOp) (err error) {
if m.Native {
return errors.New("Native asset not allowed")
}
o.Line, err = m.ToXdrObject()
return
} | go | func (m Asset) MutateChangeTrust(o *xdr.ChangeTrustOp) (err error) {
if m.Native {
return errors.New("Native asset not allowed")
}
o.Line, err = m.ToXdrObject()
return
} | [
"func",
"(",
"m",
"Asset",
")",
"MutateChangeTrust",
"(",
"o",
"*",
"xdr",
".",
"ChangeTrustOp",
")",
"(",
"err",
"error",
")",
"{",
"if",
"m",
".",
"Native",
"{",
"return",
"errors",
".",
"New",
"(",
"\"Native asset not allowed\"",
")",
"\n",
"}",
"\n... | // MutateChangeTrust for Asset sets the ChangeTrustOp's Line field | [
"MutateChangeTrust",
"for",
"Asset",
"sets",
"the",
"ChangeTrustOp",
"s",
"Line",
"field"
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/build/change_trust.go#L51-L58 | test |
stellar/go-stellar-base | build/change_trust.go | MutateChangeTrust | func (m Limit) MutateChangeTrust(o *xdr.ChangeTrustOp) (err error) {
o.Limit, err = amount.Parse(string(m))
return
} | go | func (m Limit) MutateChangeTrust(o *xdr.ChangeTrustOp) (err error) {
o.Limit, err = amount.Parse(string(m))
return
} | [
"func",
"(",
"m",
"Limit",
")",
"MutateChangeTrust",
"(",
"o",
"*",
"xdr",
".",
"ChangeTrustOp",
")",
"(",
"err",
"error",
")",
"{",
"o",
".",
"Limit",
",",
"err",
"=",
"amount",
".",
"Parse",
"(",
"string",
"(",
"m",
")",
")",
"\n",
"return",
"\... | // MutateChangeTrust for Limit sets the ChangeTrustOp's Limit field | [
"MutateChangeTrust",
"for",
"Limit",
"sets",
"the",
"ChangeTrustOp",
"s",
"Limit",
"field"
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/build/change_trust.go#L61-L64 | test |
stellar/go-stellar-base | build/change_trust.go | Trust | func Trust(code, issuer string, args ...interface{}) (result ChangeTrustBuilder) {
mutators := []interface{}{
CreditAsset(code, issuer),
}
limitSet := false
for _, mut := range args {
mutators = append(mutators, mut)
_, isLimit := mut.(Limit)
if isLimit {
limitSet = true
}
}
if !limitSet {
mutat... | go | func Trust(code, issuer string, args ...interface{}) (result ChangeTrustBuilder) {
mutators := []interface{}{
CreditAsset(code, issuer),
}
limitSet := false
for _, mut := range args {
mutators = append(mutators, mut)
_, isLimit := mut.(Limit)
if isLimit {
limitSet = true
}
}
if !limitSet {
mutat... | [
"func",
"Trust",
"(",
"code",
",",
"issuer",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"(",
"result",
"ChangeTrustBuilder",
")",
"{",
"mutators",
":=",
"[",
"]",
"interface",
"{",
"}",
"{",
"CreditAsset",
"(",
"code",
",",
"issuer",
")"... | // Trust is a helper that creates ChangeTrustBuilder | [
"Trust",
"is",
"a",
"helper",
"that",
"creates",
"ChangeTrustBuilder"
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/build/change_trust.go#L67-L87 | test |
stellar/go-stellar-base | build/change_trust.go | RemoveTrust | func RemoveTrust(code, issuer string, args ...interface{}) (result ChangeTrustBuilder) {
mutators := []interface{}{
CreditAsset(code, issuer),
Limit("0"),
}
for _, mut := range args {
mutators = append(mutators, mut)
}
return ChangeTrust(mutators...)
} | go | func RemoveTrust(code, issuer string, args ...interface{}) (result ChangeTrustBuilder) {
mutators := []interface{}{
CreditAsset(code, issuer),
Limit("0"),
}
for _, mut := range args {
mutators = append(mutators, mut)
}
return ChangeTrust(mutators...)
} | [
"func",
"RemoveTrust",
"(",
"code",
",",
"issuer",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"(",
"result",
"ChangeTrustBuilder",
")",
"{",
"mutators",
":=",
"[",
"]",
"interface",
"{",
"}",
"{",
"CreditAsset",
"(",
"code",
",",
"issuer",... | // RemoveTrust is a helper that creates ChangeTrustBuilder | [
"RemoveTrust",
"is",
"a",
"helper",
"that",
"creates",
"ChangeTrustBuilder"
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/build/change_trust.go#L90-L101 | test |
stellar/go-stellar-base | build/payment.go | MutatePayment | func (m CreditAmount) MutatePayment(o interface{}) (err error) {
switch o := o.(type) {
default:
err = errors.New("Unexpected operation type")
case *xdr.PaymentOp:
o.Amount, err = amount.Parse(m.Amount)
if err != nil {
return
}
o.Asset, err = createAlphaNumAsset(m.Code, m.Issuer)
case *xdr.PathPayment... | go | func (m CreditAmount) MutatePayment(o interface{}) (err error) {
switch o := o.(type) {
default:
err = errors.New("Unexpected operation type")
case *xdr.PaymentOp:
o.Amount, err = amount.Parse(m.Amount)
if err != nil {
return
}
o.Asset, err = createAlphaNumAsset(m.Code, m.Issuer)
case *xdr.PathPayment... | [
"func",
"(",
"m",
"CreditAmount",
")",
"MutatePayment",
"(",
"o",
"interface",
"{",
"}",
")",
"(",
"err",
"error",
")",
"{",
"switch",
"o",
":=",
"o",
".",
"(",
"type",
")",
"{",
"default",
":",
"err",
"=",
"errors",
".",
"New",
"(",
"\"Unexpected ... | // MutatePayment for Asset sets the PaymentOp's Asset field | [
"MutatePayment",
"for",
"Asset",
"sets",
"the",
"PaymentOp",
"s",
"Asset",
"field"
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/build/payment.go#L64-L84 | test |
stellar/go-stellar-base | build/payment.go | MutatePayment | func (m Destination) MutatePayment(o interface{}) error {
switch o := o.(type) {
default:
return errors.New("Unexpected operation type")
case *xdr.PaymentOp:
return setAccountId(m.AddressOrSeed, &o.Destination)
case *xdr.PathPaymentOp:
return setAccountId(m.AddressOrSeed, &o.Destination)
}
return nil
} | go | func (m Destination) MutatePayment(o interface{}) error {
switch o := o.(type) {
default:
return errors.New("Unexpected operation type")
case *xdr.PaymentOp:
return setAccountId(m.AddressOrSeed, &o.Destination)
case *xdr.PathPaymentOp:
return setAccountId(m.AddressOrSeed, &o.Destination)
}
return nil
} | [
"func",
"(",
"m",
"Destination",
")",
"MutatePayment",
"(",
"o",
"interface",
"{",
"}",
")",
"error",
"{",
"switch",
"o",
":=",
"o",
".",
"(",
"type",
")",
"{",
"default",
":",
"return",
"errors",
".",
"New",
"(",
"\"Unexpected operation type\"",
")",
... | // MutatePayment for Destination sets the PaymentOp's Destination field | [
"MutatePayment",
"for",
"Destination",
"sets",
"the",
"PaymentOp",
"s",
"Destination",
"field"
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/build/payment.go#L87-L97 | test |
stellar/go-stellar-base | build/payment.go | MutatePayment | func (m NativeAmount) MutatePayment(o interface{}) (err error) {
switch o := o.(type) {
default:
err = errors.New("Unexpected operation type")
case *xdr.PaymentOp:
o.Amount, err = amount.Parse(m.Amount)
if err != nil {
return
}
o.Asset, err = xdr.NewAsset(xdr.AssetTypeAssetTypeNative, nil)
case *xdr.P... | go | func (m NativeAmount) MutatePayment(o interface{}) (err error) {
switch o := o.(type) {
default:
err = errors.New("Unexpected operation type")
case *xdr.PaymentOp:
o.Amount, err = amount.Parse(m.Amount)
if err != nil {
return
}
o.Asset, err = xdr.NewAsset(xdr.AssetTypeAssetTypeNative, nil)
case *xdr.P... | [
"func",
"(",
"m",
"NativeAmount",
")",
"MutatePayment",
"(",
"o",
"interface",
"{",
"}",
")",
"(",
"err",
"error",
")",
"{",
"switch",
"o",
":=",
"o",
".",
"(",
"type",
")",
"{",
"default",
":",
"err",
"=",
"errors",
".",
"New",
"(",
"\"Unexpected ... | // MutatePayment for NativeAmount sets the PaymentOp's currency field to
// native and sets its amount to the provided integer | [
"MutatePayment",
"for",
"NativeAmount",
"sets",
"the",
"PaymentOp",
"s",
"currency",
"field",
"to",
"native",
"and",
"sets",
"its",
"amount",
"to",
"the",
"provided",
"integer"
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/build/payment.go#L101-L121 | test |
stellar/go-stellar-base | build/payment.go | MutatePayment | func (m PayWithPath) MutatePayment(o interface{}) (err error) {
var pathPaymentOp *xdr.PathPaymentOp
var ok bool
if pathPaymentOp, ok = o.(*xdr.PathPaymentOp); !ok {
return errors.New("Unexpected operation type")
}
// MaxAmount
pathPaymentOp.SendMax, err = amount.Parse(m.MaxAmount)
if err != nil {
return
}... | go | func (m PayWithPath) MutatePayment(o interface{}) (err error) {
var pathPaymentOp *xdr.PathPaymentOp
var ok bool
if pathPaymentOp, ok = o.(*xdr.PathPaymentOp); !ok {
return errors.New("Unexpected operation type")
}
// MaxAmount
pathPaymentOp.SendMax, err = amount.Parse(m.MaxAmount)
if err != nil {
return
}... | [
"func",
"(",
"m",
"PayWithPath",
")",
"MutatePayment",
"(",
"o",
"interface",
"{",
"}",
")",
"(",
"err",
"error",
")",
"{",
"var",
"pathPaymentOp",
"*",
"xdr",
".",
"PathPaymentOp",
"\n",
"var",
"ok",
"bool",
"\n",
"if",
"pathPaymentOp",
",",
"ok",
"="... | // MutatePayment for PayWithPath sets the PathPaymentOp's SendAsset,
// SendMax and Path fields | [
"MutatePayment",
"for",
"PayWithPath",
"sets",
"the",
"PathPaymentOp",
"s",
"SendAsset",
"SendMax",
"and",
"Path",
"fields"
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/build/payment.go#L125-L156 | test |
stellar/go-stellar-base | build/account_merge.go | MutateAccountMerge | func (m Destination) MutateAccountMerge(o *AccountMergeBuilder) error {
return setAccountId(m.AddressOrSeed, &o.Destination)
} | go | func (m Destination) MutateAccountMerge(o *AccountMergeBuilder) error {
return setAccountId(m.AddressOrSeed, &o.Destination)
} | [
"func",
"(",
"m",
"Destination",
")",
"MutateAccountMerge",
"(",
"o",
"*",
"AccountMergeBuilder",
")",
"error",
"{",
"return",
"setAccountId",
"(",
"m",
".",
"AddressOrSeed",
",",
"&",
"o",
".",
"Destination",
")",
"\n",
"}"
] | // MutateAccountMerge for Destination sets the AccountMergeBuilder's Destination field | [
"MutateAccountMerge",
"for",
"Destination",
"sets",
"the",
"AccountMergeBuilder",
"s",
"Destination",
"field"
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/build/account_merge.go#L50-L52 | test |
stellar/go-stellar-base | amount/main.go | MustParse | func MustParse(v string) xdr.Int64 {
ret, err := Parse(v)
if err != nil {
panic(err)
}
return ret
} | go | func MustParse(v string) xdr.Int64 {
ret, err := Parse(v)
if err != nil {
panic(err)
}
return ret
} | [
"func",
"MustParse",
"(",
"v",
"string",
")",
"xdr",
".",
"Int64",
"{",
"ret",
",",
"err",
":=",
"Parse",
"(",
"v",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"panic",
"(",
"err",
")",
"\n",
"}",
"\n",
"return",
"ret",
"\n",
"}"
] | // MustParse is the panicking version of Parse | [
"MustParse",
"is",
"the",
"panicking",
"version",
"of",
"Parse"
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/amount/main.go#L25-L31 | test |
stellar/go-stellar-base | amount/main.go | Parse | func Parse(v string) (xdr.Int64, error) {
var f, o, r big.Rat
_, ok := f.SetString(v)
if !ok {
return xdr.Int64(0), fmt.Errorf("cannot parse amount: %s", v)
}
o.SetInt64(One)
r.Mul(&f, &o)
is := r.FloatString(0)
i, err := strconv.ParseInt(is, 10, 64)
if err != nil {
return xdr.Int64(0), err
}
return x... | go | func Parse(v string) (xdr.Int64, error) {
var f, o, r big.Rat
_, ok := f.SetString(v)
if !ok {
return xdr.Int64(0), fmt.Errorf("cannot parse amount: %s", v)
}
o.SetInt64(One)
r.Mul(&f, &o)
is := r.FloatString(0)
i, err := strconv.ParseInt(is, 10, 64)
if err != nil {
return xdr.Int64(0), err
}
return x... | [
"func",
"Parse",
"(",
"v",
"string",
")",
"(",
"xdr",
".",
"Int64",
",",
"error",
")",
"{",
"var",
"f",
",",
"o",
",",
"r",
"big",
".",
"Rat",
"\n",
"_",
",",
"ok",
":=",
"f",
".",
"SetString",
"(",
"v",
")",
"\n",
"if",
"!",
"ok",
"{",
"... | // Parse parses the provided as a stellar "amount", i.e. A 64-bit signed integer
// that represents a decimal number with 7 digits of significance in the
// fractional portion of the number. | [
"Parse",
"parses",
"the",
"provided",
"as",
"a",
"stellar",
"amount",
"i",
".",
"e",
".",
"A",
"64",
"-",
"bit",
"signed",
"integer",
"that",
"represents",
"a",
"decimal",
"number",
"with",
"7",
"digits",
"of",
"significance",
"in",
"the",
"fractional",
... | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/amount/main.go#L36-L53 | test |
stellar/go-stellar-base | amount/main.go | String | func String(v xdr.Int64) string {
var f, o, r big.Rat
f.SetInt64(int64(v))
o.SetInt64(One)
r.Quo(&f, &o)
return r.FloatString(7)
} | go | func String(v xdr.Int64) string {
var f, o, r big.Rat
f.SetInt64(int64(v))
o.SetInt64(One)
r.Quo(&f, &o)
return r.FloatString(7)
} | [
"func",
"String",
"(",
"v",
"xdr",
".",
"Int64",
")",
"string",
"{",
"var",
"f",
",",
"o",
",",
"r",
"big",
".",
"Rat",
"\n",
"f",
".",
"SetInt64",
"(",
"int64",
"(",
"v",
")",
")",
"\n",
"o",
".",
"SetInt64",
"(",
"One",
")",
"\n",
"r",
".... | // String returns an "amount string" from the provided raw value `v`. | [
"String",
"returns",
"an",
"amount",
"string",
"from",
"the",
"provided",
"raw",
"value",
"v",
"."
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/amount/main.go#L56-L64 | test |
stellar/go-stellar-base | build/manage_offer.go | CreateOffer | func CreateOffer(rate Rate, amount Amount) (result ManageOfferBuilder) {
return ManageOffer(false, rate, amount)
} | go | func CreateOffer(rate Rate, amount Amount) (result ManageOfferBuilder) {
return ManageOffer(false, rate, amount)
} | [
"func",
"CreateOffer",
"(",
"rate",
"Rate",
",",
"amount",
"Amount",
")",
"(",
"result",
"ManageOfferBuilder",
")",
"{",
"return",
"ManageOffer",
"(",
"false",
",",
"rate",
",",
"amount",
")",
"\n",
"}"
] | // CreateOffer creates a new offer | [
"CreateOffer",
"creates",
"a",
"new",
"offer"
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/build/manage_offer.go#L12-L14 | test |
stellar/go-stellar-base | build/manage_offer.go | CreatePassiveOffer | func CreatePassiveOffer(rate Rate, amount Amount) (result ManageOfferBuilder) {
return ManageOffer(true, rate, amount)
} | go | func CreatePassiveOffer(rate Rate, amount Amount) (result ManageOfferBuilder) {
return ManageOffer(true, rate, amount)
} | [
"func",
"CreatePassiveOffer",
"(",
"rate",
"Rate",
",",
"amount",
"Amount",
")",
"(",
"result",
"ManageOfferBuilder",
")",
"{",
"return",
"ManageOffer",
"(",
"true",
",",
"rate",
",",
"amount",
")",
"\n",
"}"
] | // CreatePassiveOffer creates a new passive offer | [
"CreatePassiveOffer",
"creates",
"a",
"new",
"passive",
"offer"
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/build/manage_offer.go#L17-L19 | test |
stellar/go-stellar-base | build/manage_offer.go | UpdateOffer | func UpdateOffer(rate Rate, amount Amount, offerID OfferID) (result ManageOfferBuilder) {
return ManageOffer(false, rate, amount, offerID)
} | go | func UpdateOffer(rate Rate, amount Amount, offerID OfferID) (result ManageOfferBuilder) {
return ManageOffer(false, rate, amount, offerID)
} | [
"func",
"UpdateOffer",
"(",
"rate",
"Rate",
",",
"amount",
"Amount",
",",
"offerID",
"OfferID",
")",
"(",
"result",
"ManageOfferBuilder",
")",
"{",
"return",
"ManageOffer",
"(",
"false",
",",
"rate",
",",
"amount",
",",
"offerID",
")",
"\n",
"}"
] | // UpdateOffer updates an existing offer | [
"UpdateOffer",
"updates",
"an",
"existing",
"offer"
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/build/manage_offer.go#L22-L24 | test |
stellar/go-stellar-base | build/manage_offer.go | DeleteOffer | func DeleteOffer(rate Rate, offerID OfferID) (result ManageOfferBuilder) {
return ManageOffer(false, rate, Amount("0"), offerID)
} | go | func DeleteOffer(rate Rate, offerID OfferID) (result ManageOfferBuilder) {
return ManageOffer(false, rate, Amount("0"), offerID)
} | [
"func",
"DeleteOffer",
"(",
"rate",
"Rate",
",",
"offerID",
"OfferID",
")",
"(",
"result",
"ManageOfferBuilder",
")",
"{",
"return",
"ManageOffer",
"(",
"false",
",",
"rate",
",",
"Amount",
"(",
"\"0\"",
")",
",",
"offerID",
")",
"\n",
"}"
] | // DeleteOffer deletes an existing offer | [
"DeleteOffer",
"deletes",
"an",
"existing",
"offer"
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/build/manage_offer.go#L27-L29 | test |
stellar/go-stellar-base | build/manage_offer.go | ManageOffer | func ManageOffer(passiveOffer bool, muts ...interface{}) (result ManageOfferBuilder) {
result.PassiveOffer = passiveOffer
result.Mutate(muts...)
return
} | go | func ManageOffer(passiveOffer bool, muts ...interface{}) (result ManageOfferBuilder) {
result.PassiveOffer = passiveOffer
result.Mutate(muts...)
return
} | [
"func",
"ManageOffer",
"(",
"passiveOffer",
"bool",
",",
"muts",
"...",
"interface",
"{",
"}",
")",
"(",
"result",
"ManageOfferBuilder",
")",
"{",
"result",
".",
"PassiveOffer",
"=",
"passiveOffer",
"\n",
"result",
".",
"Mutate",
"(",
"muts",
"...",
")",
"... | // ManageOffer groups the creation of a new ManageOfferBuilder with a call to Mutate. | [
"ManageOffer",
"groups",
"the",
"creation",
"of",
"a",
"new",
"ManageOfferBuilder",
"with",
"a",
"call",
"to",
"Mutate",
"."
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/build/manage_offer.go#L32-L36 | test |
stellar/go-stellar-base | build/manage_offer.go | Mutate | func (b *ManageOfferBuilder) Mutate(muts ...interface{}) {
for _, m := range muts {
var err error
switch mut := m.(type) {
case ManageOfferMutator:
if b.PassiveOffer {
err = mut.MutateManageOffer(&b.PO)
} else {
err = mut.MutateManageOffer(&b.MO)
}
case OperationMutator:
err = mut.MutateOpe... | go | func (b *ManageOfferBuilder) Mutate(muts ...interface{}) {
for _, m := range muts {
var err error
switch mut := m.(type) {
case ManageOfferMutator:
if b.PassiveOffer {
err = mut.MutateManageOffer(&b.PO)
} else {
err = mut.MutateManageOffer(&b.MO)
}
case OperationMutator:
err = mut.MutateOpe... | [
"func",
"(",
"b",
"*",
"ManageOfferBuilder",
")",
"Mutate",
"(",
"muts",
"...",
"interface",
"{",
"}",
")",
"{",
"for",
"_",
",",
"m",
":=",
"range",
"muts",
"{",
"var",
"err",
"error",
"\n",
"switch",
"mut",
":=",
"m",
".",
"(",
"type",
")",
"{"... | // Mutate applies the provided mutators to this builder's offer or operation. | [
"Mutate",
"applies",
"the",
"provided",
"mutators",
"to",
"this",
"builder",
"s",
"offer",
"or",
"operation",
"."
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/build/manage_offer.go#L55-L76 | test |
stellar/go-stellar-base | build/manage_offer.go | MutateManageOffer | func (m Amount) MutateManageOffer(o interface{}) (err error) {
switch o := o.(type) {
default:
err = errors.New("Unexpected operation type")
case *xdr.ManageOfferOp:
o.Amount, err = amount.Parse(string(m))
case *xdr.CreatePassiveOfferOp:
o.Amount, err = amount.Parse(string(m))
}
return
} | go | func (m Amount) MutateManageOffer(o interface{}) (err error) {
switch o := o.(type) {
default:
err = errors.New("Unexpected operation type")
case *xdr.ManageOfferOp:
o.Amount, err = amount.Parse(string(m))
case *xdr.CreatePassiveOfferOp:
o.Amount, err = amount.Parse(string(m))
}
return
} | [
"func",
"(",
"m",
"Amount",
")",
"MutateManageOffer",
"(",
"o",
"interface",
"{",
"}",
")",
"(",
"err",
"error",
")",
"{",
"switch",
"o",
":=",
"o",
".",
"(",
"type",
")",
"{",
"default",
":",
"err",
"=",
"errors",
".",
"New",
"(",
"\"Unexpected op... | // MutateManageOffer for Amount sets the ManageOfferOp's Amount field | [
"MutateManageOffer",
"for",
"Amount",
"sets",
"the",
"ManageOfferOp",
"s",
"Amount",
"field"
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/build/manage_offer.go#L79-L89 | test |
stellar/go-stellar-base | build/manage_offer.go | MutateManageOffer | func (m OfferID) MutateManageOffer(o interface{}) (err error) {
switch o := o.(type) {
default:
err = errors.New("Unexpected operation type")
case *xdr.ManageOfferOp:
o.OfferId = xdr.Uint64(m)
}
return
} | go | func (m OfferID) MutateManageOffer(o interface{}) (err error) {
switch o := o.(type) {
default:
err = errors.New("Unexpected operation type")
case *xdr.ManageOfferOp:
o.OfferId = xdr.Uint64(m)
}
return
} | [
"func",
"(",
"m",
"OfferID",
")",
"MutateManageOffer",
"(",
"o",
"interface",
"{",
"}",
")",
"(",
"err",
"error",
")",
"{",
"switch",
"o",
":=",
"o",
".",
"(",
"type",
")",
"{",
"default",
":",
"err",
"=",
"errors",
".",
"New",
"(",
"\"Unexpected o... | // MutateManageOffer for OfferID sets the ManageOfferOp's OfferID field | [
"MutateManageOffer",
"for",
"OfferID",
"sets",
"the",
"ManageOfferOp",
"s",
"OfferID",
"field"
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/build/manage_offer.go#L92-L100 | test |
stellar/go-stellar-base | build/manage_offer.go | MutateManageOffer | func (m Rate) MutateManageOffer(o interface{}) (err error) {
switch o := o.(type) {
default:
err = errors.New("Unexpected operation type")
case *xdr.ManageOfferOp:
o.Selling, err = m.Selling.ToXdrObject()
if err != nil {
return
}
o.Buying, err = m.Buying.ToXdrObject()
if err != nil {
return
}
... | go | func (m Rate) MutateManageOffer(o interface{}) (err error) {
switch o := o.(type) {
default:
err = errors.New("Unexpected operation type")
case *xdr.ManageOfferOp:
o.Selling, err = m.Selling.ToXdrObject()
if err != nil {
return
}
o.Buying, err = m.Buying.ToXdrObject()
if err != nil {
return
}
... | [
"func",
"(",
"m",
"Rate",
")",
"MutateManageOffer",
"(",
"o",
"interface",
"{",
"}",
")",
"(",
"err",
"error",
")",
"{",
"switch",
"o",
":=",
"o",
".",
"(",
"type",
")",
"{",
"default",
":",
"err",
"=",
"errors",
".",
"New",
"(",
"\"Unexpected oper... | // MutateManageOffer for Rate sets the ManageOfferOp's selling, buying and price fields | [
"MutateManageOffer",
"for",
"Rate",
"sets",
"the",
"ManageOfferOp",
"s",
"selling",
"buying",
"and",
"price",
"fields"
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/build/manage_offer.go#L103-L133 | test |
stellar/go-stellar-base | build/operation.go | MutateOperation | func (m SourceAccount) MutateOperation(o *xdr.Operation) error {
o.SourceAccount = &xdr.AccountId{}
return setAccountId(m.AddressOrSeed, o.SourceAccount)
} | go | func (m SourceAccount) MutateOperation(o *xdr.Operation) error {
o.SourceAccount = &xdr.AccountId{}
return setAccountId(m.AddressOrSeed, o.SourceAccount)
} | [
"func",
"(",
"m",
"SourceAccount",
")",
"MutateOperation",
"(",
"o",
"*",
"xdr",
".",
"Operation",
")",
"error",
"{",
"o",
".",
"SourceAccount",
"=",
"&",
"xdr",
".",
"AccountId",
"{",
"}",
"\n",
"return",
"setAccountId",
"(",
"m",
".",
"AddressOrSeed",
... | // MutateOperation for SourceAccount sets the operation's SourceAccount
// to the pubilic key for the address provided | [
"MutateOperation",
"for",
"SourceAccount",
"sets",
"the",
"operation",
"s",
"SourceAccount",
"to",
"the",
"pubilic",
"key",
"for",
"the",
"address",
"provided"
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/build/operation.go#L16-L19 | test |
stellar/go-stellar-base | xdr/price.go | String | func (p *Price) String() string {
return big.NewRat(int64(p.N), int64(p.D)).FloatString(7)
} | go | func (p *Price) String() string {
return big.NewRat(int64(p.N), int64(p.D)).FloatString(7)
} | [
"func",
"(",
"p",
"*",
"Price",
")",
"String",
"(",
")",
"string",
"{",
"return",
"big",
".",
"NewRat",
"(",
"int64",
"(",
"p",
".",
"N",
")",
",",
"int64",
"(",
"p",
".",
"D",
")",
")",
".",
"FloatString",
"(",
"7",
")",
"\n",
"}"
] | // String returns a string represenation of `p` | [
"String",
"returns",
"a",
"string",
"represenation",
"of",
"p"
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/xdr/price.go#L8-L10 | test |
stellar/go-stellar-base | build/transaction.go | Transaction | func Transaction(muts ...TransactionMutator) (result *TransactionBuilder) {
result = &TransactionBuilder{}
result.Mutate(muts...)
result.Mutate(Defaults{})
return
} | go | func Transaction(muts ...TransactionMutator) (result *TransactionBuilder) {
result = &TransactionBuilder{}
result.Mutate(muts...)
result.Mutate(Defaults{})
return
} | [
"func",
"Transaction",
"(",
"muts",
"...",
"TransactionMutator",
")",
"(",
"result",
"*",
"TransactionBuilder",
")",
"{",
"result",
"=",
"&",
"TransactionBuilder",
"{",
"}",
"\n",
"result",
".",
"Mutate",
"(",
"muts",
"...",
")",
"\n",
"result",
".",
"Muta... | // Transaction groups the creation of a new TransactionBuilder with a call
// to Mutate. | [
"Transaction",
"groups",
"the",
"creation",
"of",
"a",
"new",
"TransactionBuilder",
"with",
"a",
"call",
"to",
"Mutate",
"."
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/build/transaction.go#L15-L20 | test |
stellar/go-stellar-base | build/transaction.go | Mutate | func (b *TransactionBuilder) Mutate(muts ...TransactionMutator) {
if b.TX == nil {
b.TX = &xdr.Transaction{}
}
for _, m := range muts {
err := m.MutateTransaction(b)
if err != nil {
b.Err = err
return
}
}
} | go | func (b *TransactionBuilder) Mutate(muts ...TransactionMutator) {
if b.TX == nil {
b.TX = &xdr.Transaction{}
}
for _, m := range muts {
err := m.MutateTransaction(b)
if err != nil {
b.Err = err
return
}
}
} | [
"func",
"(",
"b",
"*",
"TransactionBuilder",
")",
"Mutate",
"(",
"muts",
"...",
"TransactionMutator",
")",
"{",
"if",
"b",
".",
"TX",
"==",
"nil",
"{",
"b",
".",
"TX",
"=",
"&",
"xdr",
".",
"Transaction",
"{",
"}",
"\n",
"}",
"\n",
"for",
"_",
",... | // Mutate applies the provided TransactionMutators to this builder's transaction | [
"Mutate",
"applies",
"the",
"provided",
"TransactionMutators",
"to",
"this",
"builder",
"s",
"transaction"
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/build/transaction.go#L37-L49 | test |
stellar/go-stellar-base | build/transaction.go | Hash | func (b *TransactionBuilder) Hash() ([32]byte, error) {
var txBytes bytes.Buffer
_, err := fmt.Fprintf(&txBytes, "%s", b.NetworkID)
if err != nil {
return [32]byte{}, err
}
_, err = xdr.Marshal(&txBytes, xdr.EnvelopeTypeEnvelopeTypeTx)
if err != nil {
return [32]byte{}, err
}
_, err = xdr.Marshal(&txByte... | go | func (b *TransactionBuilder) Hash() ([32]byte, error) {
var txBytes bytes.Buffer
_, err := fmt.Fprintf(&txBytes, "%s", b.NetworkID)
if err != nil {
return [32]byte{}, err
}
_, err = xdr.Marshal(&txBytes, xdr.EnvelopeTypeEnvelopeTypeTx)
if err != nil {
return [32]byte{}, err
}
_, err = xdr.Marshal(&txByte... | [
"func",
"(",
"b",
"*",
"TransactionBuilder",
")",
"Hash",
"(",
")",
"(",
"[",
"32",
"]",
"byte",
",",
"error",
")",
"{",
"var",
"txBytes",
"bytes",
".",
"Buffer",
"\n",
"_",
",",
"err",
":=",
"fmt",
".",
"Fprintf",
"(",
"&",
"txBytes",
",",
"\"%s... | // Hash returns the hash of this builder's transaction. | [
"Hash",
"returns",
"the",
"hash",
"of",
"this",
"builder",
"s",
"transaction",
"."
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/build/transaction.go#L52-L71 | test |
stellar/go-stellar-base | build/transaction.go | HashHex | func (b *TransactionBuilder) HashHex() (string, error) {
hash, err := b.Hash()
if err != nil {
return "", err
}
return hex.EncodeToString(hash[:]), nil
} | go | func (b *TransactionBuilder) HashHex() (string, error) {
hash, err := b.Hash()
if err != nil {
return "", err
}
return hex.EncodeToString(hash[:]), nil
} | [
"func",
"(",
"b",
"*",
"TransactionBuilder",
")",
"HashHex",
"(",
")",
"(",
"string",
",",
"error",
")",
"{",
"hash",
",",
"err",
":=",
"b",
".",
"Hash",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"\"",
",",
"err",
"\n",
"}",
"\... | // HashHex returns the hex-encoded hash of this builder's transaction | [
"HashHex",
"returns",
"the",
"hex",
"-",
"encoded",
"hash",
"of",
"this",
"builder",
"s",
"transaction"
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/build/transaction.go#L74-L81 | test |
stellar/go-stellar-base | build/transaction.go | Sign | func (b *TransactionBuilder) Sign(signers ...string) (result TransactionEnvelopeBuilder) {
result.Mutate(b)
for _, s := range signers {
result.Mutate(Sign{s})
}
return
} | go | func (b *TransactionBuilder) Sign(signers ...string) (result TransactionEnvelopeBuilder) {
result.Mutate(b)
for _, s := range signers {
result.Mutate(Sign{s})
}
return
} | [
"func",
"(",
"b",
"*",
"TransactionBuilder",
")",
"Sign",
"(",
"signers",
"...",
"string",
")",
"(",
"result",
"TransactionEnvelopeBuilder",
")",
"{",
"result",
".",
"Mutate",
"(",
"b",
")",
"\n",
"for",
"_",
",",
"s",
":=",
"range",
"signers",
"{",
"r... | // Sign returns an new TransactionEnvelopeBuilder using this builder's
// transaction as the basis and with signatures of that transaction from the
// provided Signers. | [
"Sign",
"returns",
"an",
"new",
"TransactionEnvelopeBuilder",
"using",
"this",
"builder",
"s",
"transaction",
"as",
"the",
"basis",
"and",
"with",
"signatures",
"of",
"that",
"transaction",
"from",
"the",
"provided",
"Signers",
"."
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/build/transaction.go#L86-L94 | test |
stellar/go-stellar-base | build/transaction.go | MutateTransaction | func (m AllowTrustBuilder) MutateTransaction(o *TransactionBuilder) error {
if m.Err != nil {
return m.Err
}
m.O.Body, m.Err = xdr.NewOperationBody(xdr.OperationTypeAllowTrust, m.AT)
o.TX.Operations = append(o.TX.Operations, m.O)
return m.Err
} | go | func (m AllowTrustBuilder) MutateTransaction(o *TransactionBuilder) error {
if m.Err != nil {
return m.Err
}
m.O.Body, m.Err = xdr.NewOperationBody(xdr.OperationTypeAllowTrust, m.AT)
o.TX.Operations = append(o.TX.Operations, m.O)
return m.Err
} | [
"func",
"(",
"m",
"AllowTrustBuilder",
")",
"MutateTransaction",
"(",
"o",
"*",
"TransactionBuilder",
")",
"error",
"{",
"if",
"m",
".",
"Err",
"!=",
"nil",
"{",
"return",
"m",
".",
"Err",
"\n",
"}",
"\n",
"m",
".",
"O",
".",
"Body",
",",
"m",
".",... | // MutateTransaction for AllowTrustBuilder causes the underylying AllowTrustOp
// to be added to the operation list for the provided transaction | [
"MutateTransaction",
"for",
"AllowTrustBuilder",
"causes",
"the",
"underylying",
"AllowTrustOp",
"to",
"be",
"added",
"to",
"the",
"operation",
"list",
"for",
"the",
"provided",
"transaction"
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/build/transaction.go#L116-L124 | test |
stellar/go-stellar-base | build/transaction.go | MutateTransaction | func (m ChangeTrustBuilder) MutateTransaction(o *TransactionBuilder) error {
if m.Err != nil {
return m.Err
}
m.O.Body, m.Err = xdr.NewOperationBody(xdr.OperationTypeChangeTrust, m.CT)
o.TX.Operations = append(o.TX.Operations, m.O)
return m.Err
} | go | func (m ChangeTrustBuilder) MutateTransaction(o *TransactionBuilder) error {
if m.Err != nil {
return m.Err
}
m.O.Body, m.Err = xdr.NewOperationBody(xdr.OperationTypeChangeTrust, m.CT)
o.TX.Operations = append(o.TX.Operations, m.O)
return m.Err
} | [
"func",
"(",
"m",
"ChangeTrustBuilder",
")",
"MutateTransaction",
"(",
"o",
"*",
"TransactionBuilder",
")",
"error",
"{",
"if",
"m",
".",
"Err",
"!=",
"nil",
"{",
"return",
"m",
".",
"Err",
"\n",
"}",
"\n",
"m",
".",
"O",
".",
"Body",
",",
"m",
"."... | // MutateTransaction for ChangeTrustBuilder causes the underylying
// CreateAccountOp to be added to the operation list for the provided
// transaction | [
"MutateTransaction",
"for",
"ChangeTrustBuilder",
"causes",
"the",
"underylying",
"CreateAccountOp",
"to",
"be",
"added",
"to",
"the",
"operation",
"list",
"for",
"the",
"provided",
"transaction"
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/build/transaction.go#L148-L156 | test |
stellar/go-stellar-base | build/transaction.go | MutateTransaction | func (m CreateAccountBuilder) MutateTransaction(o *TransactionBuilder) error {
if m.Err != nil {
return m.Err
}
m.O.Body, m.Err = xdr.NewOperationBody(xdr.OperationTypeCreateAccount, m.CA)
o.TX.Operations = append(o.TX.Operations, m.O)
return m.Err
} | go | func (m CreateAccountBuilder) MutateTransaction(o *TransactionBuilder) error {
if m.Err != nil {
return m.Err
}
m.O.Body, m.Err = xdr.NewOperationBody(xdr.OperationTypeCreateAccount, m.CA)
o.TX.Operations = append(o.TX.Operations, m.O)
return m.Err
} | [
"func",
"(",
"m",
"CreateAccountBuilder",
")",
"MutateTransaction",
"(",
"o",
"*",
"TransactionBuilder",
")",
"error",
"{",
"if",
"m",
".",
"Err",
"!=",
"nil",
"{",
"return",
"m",
".",
"Err",
"\n",
"}",
"\n",
"m",
".",
"O",
".",
"Body",
",",
"m",
"... | // MutateTransaction for CreateAccountBuilder causes the underylying
// CreateAccountOp to be added to the operation list for the provided
// transaction | [
"MutateTransaction",
"for",
"CreateAccountBuilder",
"causes",
"the",
"underylying",
"CreateAccountOp",
"to",
"be",
"added",
"to",
"the",
"operation",
"list",
"for",
"the",
"provided",
"transaction"
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/build/transaction.go#L161-L169 | test |
stellar/go-stellar-base | build/transaction.go | MutateTransaction | func (m Defaults) MutateTransaction(o *TransactionBuilder) error {
if o.TX.Fee == 0 {
o.TX.Fee = xdr.Uint32(100 * len(o.TX.Operations))
}
if o.NetworkID == [32]byte{} {
o.NetworkID = DefaultNetwork.ID()
}
return nil
} | go | func (m Defaults) MutateTransaction(o *TransactionBuilder) error {
if o.TX.Fee == 0 {
o.TX.Fee = xdr.Uint32(100 * len(o.TX.Operations))
}
if o.NetworkID == [32]byte{} {
o.NetworkID = DefaultNetwork.ID()
}
return nil
} | [
"func",
"(",
"m",
"Defaults",
")",
"MutateTransaction",
"(",
"o",
"*",
"TransactionBuilder",
")",
"error",
"{",
"if",
"o",
".",
"TX",
".",
"Fee",
"==",
"0",
"{",
"o",
".",
"TX",
".",
"Fee",
"=",
"xdr",
".",
"Uint32",
"(",
"100",
"*",
"len",
"(",
... | // MutateTransaction for Defaults sets reasonable defaults on the transaction being built | [
"MutateTransaction",
"for",
"Defaults",
"sets",
"reasonable",
"defaults",
"on",
"the",
"transaction",
"being",
"built"
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/build/transaction.go#L172-L182 | test |
stellar/go-stellar-base | build/transaction.go | MutateTransaction | func (m InflationBuilder) MutateTransaction(o *TransactionBuilder) error {
if m.Err != nil {
return m.Err
}
m.O.Body, m.Err = xdr.NewOperationBody(xdr.OperationTypeInflation, nil)
o.TX.Operations = append(o.TX.Operations, m.O)
return m.Err
} | go | func (m InflationBuilder) MutateTransaction(o *TransactionBuilder) error {
if m.Err != nil {
return m.Err
}
m.O.Body, m.Err = xdr.NewOperationBody(xdr.OperationTypeInflation, nil)
o.TX.Operations = append(o.TX.Operations, m.O)
return m.Err
} | [
"func",
"(",
"m",
"InflationBuilder",
")",
"MutateTransaction",
"(",
"o",
"*",
"TransactionBuilder",
")",
"error",
"{",
"if",
"m",
".",
"Err",
"!=",
"nil",
"{",
"return",
"m",
".",
"Err",
"\n",
"}",
"\n",
"m",
".",
"O",
".",
"Body",
",",
"m",
".",
... | // MutateTransaction for InflationBuilder causes the underylying
// InflationOp to be added to the operation list for the provided
// transaction | [
"MutateTransaction",
"for",
"InflationBuilder",
"causes",
"the",
"underylying",
"InflationOp",
"to",
"be",
"added",
"to",
"the",
"operation",
"list",
"for",
"the",
"provided",
"transaction"
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/build/transaction.go#L187-L195 | test |
stellar/go-stellar-base | build/transaction.go | MutateTransaction | func (m ManageDataBuilder) MutateTransaction(o *TransactionBuilder) error {
if m.Err != nil {
return m.Err
}
m.O.Body, m.Err = xdr.NewOperationBody(xdr.OperationTypeManageData, m.MD)
o.TX.Operations = append(o.TX.Operations, m.O)
return m.Err
} | go | func (m ManageDataBuilder) MutateTransaction(o *TransactionBuilder) error {
if m.Err != nil {
return m.Err
}
m.O.Body, m.Err = xdr.NewOperationBody(xdr.OperationTypeManageData, m.MD)
o.TX.Operations = append(o.TX.Operations, m.O)
return m.Err
} | [
"func",
"(",
"m",
"ManageDataBuilder",
")",
"MutateTransaction",
"(",
"o",
"*",
"TransactionBuilder",
")",
"error",
"{",
"if",
"m",
".",
"Err",
"!=",
"nil",
"{",
"return",
"m",
".",
"Err",
"\n",
"}",
"\n",
"m",
".",
"O",
".",
"Body",
",",
"m",
".",... | // MutateTransaction for ManageDataBuilder causes the underylying
// ManageData to be added to the operation list for the provided
// transaction | [
"MutateTransaction",
"for",
"ManageDataBuilder",
"causes",
"the",
"underylying",
"ManageData",
"to",
"be",
"added",
"to",
"the",
"operation",
"list",
"for",
"the",
"provided",
"transaction"
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/build/transaction.go#L200-L208 | test |
stellar/go-stellar-base | build/transaction.go | MutateTransaction | func (m ManageOfferBuilder) MutateTransaction(o *TransactionBuilder) error {
if m.Err != nil {
return m.Err
}
if m.PassiveOffer {
m.O.Body, m.Err = xdr.NewOperationBody(xdr.OperationTypeCreatePassiveOffer, m.PO)
o.TX.Operations = append(o.TX.Operations, m.O)
} else {
m.O.Body, m.Err = xdr.NewOperationBody(... | go | func (m ManageOfferBuilder) MutateTransaction(o *TransactionBuilder) error {
if m.Err != nil {
return m.Err
}
if m.PassiveOffer {
m.O.Body, m.Err = xdr.NewOperationBody(xdr.OperationTypeCreatePassiveOffer, m.PO)
o.TX.Operations = append(o.TX.Operations, m.O)
} else {
m.O.Body, m.Err = xdr.NewOperationBody(... | [
"func",
"(",
"m",
"ManageOfferBuilder",
")",
"MutateTransaction",
"(",
"o",
"*",
"TransactionBuilder",
")",
"error",
"{",
"if",
"m",
".",
"Err",
"!=",
"nil",
"{",
"return",
"m",
".",
"Err",
"\n",
"}",
"\n",
"if",
"m",
".",
"PassiveOffer",
"{",
"m",
"... | // MutateTransaction for ManageOfferBuilder causes the underylying
// ManageData to be added to the operation list for the provided
// transaction | [
"MutateTransaction",
"for",
"ManageOfferBuilder",
"causes",
"the",
"underylying",
"ManageData",
"to",
"be",
"added",
"to",
"the",
"operation",
"list",
"for",
"the",
"provided",
"transaction"
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/build/transaction.go#L213-L226 | test |
stellar/go-stellar-base | build/transaction.go | MutateTransaction | func (m MemoHash) MutateTransaction(o *TransactionBuilder) (err error) {
o.TX.Memo, err = xdr.NewMemo(xdr.MemoTypeMemoHash, m.Value)
return
} | go | func (m MemoHash) MutateTransaction(o *TransactionBuilder) (err error) {
o.TX.Memo, err = xdr.NewMemo(xdr.MemoTypeMemoHash, m.Value)
return
} | [
"func",
"(",
"m",
"MemoHash",
")",
"MutateTransaction",
"(",
"o",
"*",
"TransactionBuilder",
")",
"(",
"err",
"error",
")",
"{",
"o",
".",
"TX",
".",
"Memo",
",",
"err",
"=",
"xdr",
".",
"NewMemo",
"(",
"xdr",
".",
"MemoTypeMemoHash",
",",
"m",
".",
... | // MutateTransaction for MemoHash sets the memo. | [
"MutateTransaction",
"for",
"MemoHash",
"sets",
"the",
"memo",
"."
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/build/transaction.go#L229-L232 | test |
stellar/go-stellar-base | build/transaction.go | MutateTransaction | func (m MemoID) MutateTransaction(o *TransactionBuilder) (err error) {
o.TX.Memo, err = xdr.NewMemo(xdr.MemoTypeMemoId, xdr.Uint64(m.Value))
return
} | go | func (m MemoID) MutateTransaction(o *TransactionBuilder) (err error) {
o.TX.Memo, err = xdr.NewMemo(xdr.MemoTypeMemoId, xdr.Uint64(m.Value))
return
} | [
"func",
"(",
"m",
"MemoID",
")",
"MutateTransaction",
"(",
"o",
"*",
"TransactionBuilder",
")",
"(",
"err",
"error",
")",
"{",
"o",
".",
"TX",
".",
"Memo",
",",
"err",
"=",
"xdr",
".",
"NewMemo",
"(",
"xdr",
".",
"MemoTypeMemoId",
",",
"xdr",
".",
... | // MutateTransaction for MemoID sets the memo. | [
"MutateTransaction",
"for",
"MemoID",
"sets",
"the",
"memo",
"."
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/build/transaction.go#L235-L238 | test |
stellar/go-stellar-base | build/transaction.go | MutateTransaction | func (m MemoReturn) MutateTransaction(o *TransactionBuilder) (err error) {
o.TX.Memo, err = xdr.NewMemo(xdr.MemoTypeMemoReturn, m.Value)
return
} | go | func (m MemoReturn) MutateTransaction(o *TransactionBuilder) (err error) {
o.TX.Memo, err = xdr.NewMemo(xdr.MemoTypeMemoReturn, m.Value)
return
} | [
"func",
"(",
"m",
"MemoReturn",
")",
"MutateTransaction",
"(",
"o",
"*",
"TransactionBuilder",
")",
"(",
"err",
"error",
")",
"{",
"o",
".",
"TX",
".",
"Memo",
",",
"err",
"=",
"xdr",
".",
"NewMemo",
"(",
"xdr",
".",
"MemoTypeMemoReturn",
",",
"m",
"... | // MutateTransaction for MemoReturn sets the memo. | [
"MutateTransaction",
"for",
"MemoReturn",
"sets",
"the",
"memo",
"."
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/build/transaction.go#L241-L244 | test |
stellar/go-stellar-base | build/transaction.go | MutateTransaction | func (m MemoText) MutateTransaction(o *TransactionBuilder) (err error) {
if len([]byte(m.Value)) > MemoTextMaxLength {
err = errors.New("Memo too long; over 28 bytes")
return
}
o.TX.Memo, err = xdr.NewMemo(xdr.MemoTypeMemoText, m.Value)
return
} | go | func (m MemoText) MutateTransaction(o *TransactionBuilder) (err error) {
if len([]byte(m.Value)) > MemoTextMaxLength {
err = errors.New("Memo too long; over 28 bytes")
return
}
o.TX.Memo, err = xdr.NewMemo(xdr.MemoTypeMemoText, m.Value)
return
} | [
"func",
"(",
"m",
"MemoText",
")",
"MutateTransaction",
"(",
"o",
"*",
"TransactionBuilder",
")",
"(",
"err",
"error",
")",
"{",
"if",
"len",
"(",
"[",
"]",
"byte",
"(",
"m",
".",
"Value",
")",
")",
">",
"MemoTextMaxLength",
"{",
"err",
"=",
"errors"... | // MutateTransaction for MemoText sets the memo. | [
"MutateTransaction",
"for",
"MemoText",
"sets",
"the",
"memo",
"."
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/build/transaction.go#L247-L256 | test |
stellar/go-stellar-base | build/transaction.go | MutateTransaction | func (m Network) MutateTransaction(o *TransactionBuilder) error {
o.NetworkID = m.ID()
return nil
} | go | func (m Network) MutateTransaction(o *TransactionBuilder) error {
o.NetworkID = m.ID()
return nil
} | [
"func",
"(",
"m",
"Network",
")",
"MutateTransaction",
"(",
"o",
"*",
"TransactionBuilder",
")",
"error",
"{",
"o",
".",
"NetworkID",
"=",
"m",
".",
"ID",
"(",
")",
"\n",
"return",
"nil",
"\n",
"}"
] | // MutateTransaction for Network sets the Network ID to use when signing this transaction | [
"MutateTransaction",
"for",
"Network",
"sets",
"the",
"Network",
"ID",
"to",
"use",
"when",
"signing",
"this",
"transaction"
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/build/transaction.go#L259-L262 | test |
stellar/go-stellar-base | build/transaction.go | MutateTransaction | func (m PaymentBuilder) MutateTransaction(o *TransactionBuilder) error {
if m.Err != nil {
return m.Err
}
if m.PathPayment {
m.O.Body, m.Err = xdr.NewOperationBody(xdr.OperationTypePathPayment, m.PP)
o.TX.Operations = append(o.TX.Operations, m.O)
return m.Err
}
m.O.Body, m.Err = xdr.NewOperationBody(xdr.... | go | func (m PaymentBuilder) MutateTransaction(o *TransactionBuilder) error {
if m.Err != nil {
return m.Err
}
if m.PathPayment {
m.O.Body, m.Err = xdr.NewOperationBody(xdr.OperationTypePathPayment, m.PP)
o.TX.Operations = append(o.TX.Operations, m.O)
return m.Err
}
m.O.Body, m.Err = xdr.NewOperationBody(xdr.... | [
"func",
"(",
"m",
"PaymentBuilder",
")",
"MutateTransaction",
"(",
"o",
"*",
"TransactionBuilder",
")",
"error",
"{",
"if",
"m",
".",
"Err",
"!=",
"nil",
"{",
"return",
"m",
".",
"Err",
"\n",
"}",
"\n",
"if",
"m",
".",
"PathPayment",
"{",
"m",
".",
... | // MutateTransaction for PaymentBuilder causes the underylying PaymentOp
// or PathPaymentOp to be added to the operation list for the provided transaction | [
"MutateTransaction",
"for",
"PaymentBuilder",
"causes",
"the",
"underylying",
"PaymentOp",
"or",
"PathPaymentOp",
"to",
"be",
"added",
"to",
"the",
"operation",
"list",
"for",
"the",
"provided",
"transaction"
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/build/transaction.go#L266-L280 | test |
stellar/go-stellar-base | build/transaction.go | MutateTransaction | func (m SetOptionsBuilder) MutateTransaction(o *TransactionBuilder) error {
if m.Err != nil {
return m.Err
}
m.O.Body, m.Err = xdr.NewOperationBody(xdr.OperationTypeSetOptions, m.SO)
o.TX.Operations = append(o.TX.Operations, m.O)
return m.Err
} | go | func (m SetOptionsBuilder) MutateTransaction(o *TransactionBuilder) error {
if m.Err != nil {
return m.Err
}
m.O.Body, m.Err = xdr.NewOperationBody(xdr.OperationTypeSetOptions, m.SO)
o.TX.Operations = append(o.TX.Operations, m.O)
return m.Err
} | [
"func",
"(",
"m",
"SetOptionsBuilder",
")",
"MutateTransaction",
"(",
"o",
"*",
"TransactionBuilder",
")",
"error",
"{",
"if",
"m",
".",
"Err",
"!=",
"nil",
"{",
"return",
"m",
".",
"Err",
"\n",
"}",
"\n",
"m",
".",
"O",
".",
"Body",
",",
"m",
".",... | // MutateTransaction for SetOptionsBuilder causes the underylying
// SetOptionsOp to be added to the operation list for the provided
// transaction | [
"MutateTransaction",
"for",
"SetOptionsBuilder",
"causes",
"the",
"underylying",
"SetOptionsOp",
"to",
"be",
"added",
"to",
"the",
"operation",
"list",
"for",
"the",
"provided",
"transaction"
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/build/transaction.go#L285-L293 | test |
stellar/go-stellar-base | build/transaction.go | MutateTransaction | func (m Sequence) MutateTransaction(o *TransactionBuilder) error {
o.TX.SeqNum = xdr.SequenceNumber(m.Sequence)
return nil
} | go | func (m Sequence) MutateTransaction(o *TransactionBuilder) error {
o.TX.SeqNum = xdr.SequenceNumber(m.Sequence)
return nil
} | [
"func",
"(",
"m",
"Sequence",
")",
"MutateTransaction",
"(",
"o",
"*",
"TransactionBuilder",
")",
"error",
"{",
"o",
".",
"TX",
".",
"SeqNum",
"=",
"xdr",
".",
"SequenceNumber",
"(",
"m",
".",
"Sequence",
")",
"\n",
"return",
"nil",
"\n",
"}"
] | // MutateTransaction for Sequence sets the SeqNum on the transaction. | [
"MutateTransaction",
"for",
"Sequence",
"sets",
"the",
"SeqNum",
"on",
"the",
"transaction",
"."
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/build/transaction.go#L296-L299 | test |
stellar/go-stellar-base | build/transaction.go | MutateTransaction | func (m SourceAccount) MutateTransaction(o *TransactionBuilder) error {
return setAccountId(m.AddressOrSeed, &o.TX.SourceAccount)
} | go | func (m SourceAccount) MutateTransaction(o *TransactionBuilder) error {
return setAccountId(m.AddressOrSeed, &o.TX.SourceAccount)
} | [
"func",
"(",
"m",
"SourceAccount",
")",
"MutateTransaction",
"(",
"o",
"*",
"TransactionBuilder",
")",
"error",
"{",
"return",
"setAccountId",
"(",
"m",
".",
"AddressOrSeed",
",",
"&",
"o",
".",
"TX",
".",
"SourceAccount",
")",
"\n",
"}"
] | // MutateTransaction for SourceAccount sets the transaction's SourceAccount
// to the pubilic key for the address provided | [
"MutateTransaction",
"for",
"SourceAccount",
"sets",
"the",
"transaction",
"s",
"SourceAccount",
"to",
"the",
"pubilic",
"key",
"for",
"the",
"address",
"provided"
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/build/transaction.go#L303-L305 | test |
stellar/go-stellar-base | xdr/db.go | Scan | func (t *Int64) Scan(src interface{}) error {
val, ok := src.(int64)
if !ok {
return errors.New("Invalid value for xdr.Int64")
}
*t = Int64(val)
return nil
} | go | func (t *Int64) Scan(src interface{}) error {
val, ok := src.(int64)
if !ok {
return errors.New("Invalid value for xdr.Int64")
}
*t = Int64(val)
return nil
} | [
"func",
"(",
"t",
"*",
"Int64",
")",
"Scan",
"(",
"src",
"interface",
"{",
"}",
")",
"error",
"{",
"val",
",",
"ok",
":=",
"src",
".",
"(",
"int64",
")",
"\n",
"if",
"!",
"ok",
"{",
"return",
"errors",
".",
"New",
"(",
"\"Invalid value for xdr.Int6... | // Scan reads from src into an Int64 | [
"Scan",
"reads",
"from",
"src",
"into",
"an",
"Int64"
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/xdr/db.go#L33-L41 | test |
stellar/go-stellar-base | meta/bundle.go | InitialState | func (b *Bundle) InitialState(key xdr.LedgerKey) (*xdr.LedgerEntry, error) {
all := b.Changes(key)
if len(all) == 0 {
return nil, ErrMetaNotFound
}
first := all[0]
if first.Type != xdr.LedgerEntryChangeTypeLedgerEntryState {
return nil, nil
}
result := first.MustState()
return &result, nil
} | go | func (b *Bundle) InitialState(key xdr.LedgerKey) (*xdr.LedgerEntry, error) {
all := b.Changes(key)
if len(all) == 0 {
return nil, ErrMetaNotFound
}
first := all[0]
if first.Type != xdr.LedgerEntryChangeTypeLedgerEntryState {
return nil, nil
}
result := first.MustState()
return &result, nil
} | [
"func",
"(",
"b",
"*",
"Bundle",
")",
"InitialState",
"(",
"key",
"xdr",
".",
"LedgerKey",
")",
"(",
"*",
"xdr",
".",
"LedgerEntry",
",",
"error",
")",
"{",
"all",
":=",
"b",
".",
"Changes",
"(",
"key",
")",
"\n",
"if",
"len",
"(",
"all",
")",
... | // InitialState returns the initial state of the LedgerEntry identified by `key`
// just prior to the application of the transaction the produced `b`. Returns
// nil if the ledger entry did not exist prior to the bundle. | [
"InitialState",
"returns",
"the",
"initial",
"state",
"of",
"the",
"LedgerEntry",
"identified",
"by",
"key",
"just",
"prior",
"to",
"the",
"application",
"of",
"the",
"transaction",
"the",
"produced",
"b",
".",
"Returns",
"nil",
"if",
"the",
"ledger",
"entry",... | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/meta/bundle.go#L18-L34 | test |
stellar/go-stellar-base | meta/bundle.go | Changes | func (b *Bundle) Changes(target xdr.LedgerKey) (ret []xdr.LedgerEntryChange) {
return b.changes(target, math.MaxInt32)
} | go | func (b *Bundle) Changes(target xdr.LedgerKey) (ret []xdr.LedgerEntryChange) {
return b.changes(target, math.MaxInt32)
} | [
"func",
"(",
"b",
"*",
"Bundle",
")",
"Changes",
"(",
"target",
"xdr",
".",
"LedgerKey",
")",
"(",
"ret",
"[",
"]",
"xdr",
".",
"LedgerEntryChange",
")",
"{",
"return",
"b",
".",
"changes",
"(",
"target",
",",
"math",
".",
"MaxInt32",
")",
"\n",
"}... | // Changes returns any changes within the bundle that apply to the entry
// identified by `key`. | [
"Changes",
"returns",
"any",
"changes",
"within",
"the",
"bundle",
"that",
"apply",
"to",
"the",
"entry",
"identified",
"by",
"key",
"."
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/meta/bundle.go#L38-L40 | test |
stellar/go-stellar-base | meta/bundle.go | StateAfter | func (b *Bundle) StateAfter(key xdr.LedgerKey, opidx int) (*xdr.LedgerEntry, error) {
all := b.changes(key, opidx)
if len(all) == 0 {
return nil, ErrMetaNotFound
}
change := all[len(all)-1]
switch change.Type {
case xdr.LedgerEntryChangeTypeLedgerEntryCreated:
entry := change.MustCreated()
return &entry,... | go | func (b *Bundle) StateAfter(key xdr.LedgerKey, opidx int) (*xdr.LedgerEntry, error) {
all := b.changes(key, opidx)
if len(all) == 0 {
return nil, ErrMetaNotFound
}
change := all[len(all)-1]
switch change.Type {
case xdr.LedgerEntryChangeTypeLedgerEntryCreated:
entry := change.MustCreated()
return &entry,... | [
"func",
"(",
"b",
"*",
"Bundle",
")",
"StateAfter",
"(",
"key",
"xdr",
".",
"LedgerKey",
",",
"opidx",
"int",
")",
"(",
"*",
"xdr",
".",
"LedgerEntry",
",",
"error",
")",
"{",
"all",
":=",
"b",
".",
"changes",
"(",
"key",
",",
"opidx",
")",
"\n",... | // StateAfter returns the state of entry `key` after the application of the
// operation at `opidx` | [
"StateAfter",
"returns",
"the",
"state",
"of",
"entry",
"key",
"after",
"the",
"application",
"of",
"the",
"operation",
"at",
"opidx"
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/meta/bundle.go#L44-L71 | test |
stellar/go-stellar-base | meta/bundle.go | changes | func (b *Bundle) changes(target xdr.LedgerKey, maxOp int) (ret []xdr.LedgerEntryChange) {
for _, change := range b.FeeMeta {
key := change.LedgerKey()
if !key.Equals(target) {
continue
}
ret = append(ret, change)
}
for i, op := range b.TransactionMeta.MustOperations() {
if i > maxOp {
break
}
... | go | func (b *Bundle) changes(target xdr.LedgerKey, maxOp int) (ret []xdr.LedgerEntryChange) {
for _, change := range b.FeeMeta {
key := change.LedgerKey()
if !key.Equals(target) {
continue
}
ret = append(ret, change)
}
for i, op := range b.TransactionMeta.MustOperations() {
if i > maxOp {
break
}
... | [
"func",
"(",
"b",
"*",
"Bundle",
")",
"changes",
"(",
"target",
"xdr",
".",
"LedgerKey",
",",
"maxOp",
"int",
")",
"(",
"ret",
"[",
"]",
"xdr",
".",
"LedgerEntryChange",
")",
"{",
"for",
"_",
",",
"change",
":=",
"range",
"b",
".",
"FeeMeta",
"{",
... | // changes returns any changes within the bundle that apply to the entry
// identified by `key` that occurred at or before `maxOp`. | [
"changes",
"returns",
"any",
"changes",
"within",
"the",
"bundle",
"that",
"apply",
"to",
"the",
"entry",
"identified",
"by",
"key",
"that",
"occurred",
"at",
"or",
"before",
"maxOp",
"."
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/meta/bundle.go#L109-L137 | test |
stellar/go-stellar-base | strkey/main.go | MustDecode | func MustDecode(expected VersionByte, src string) []byte {
d, err := Decode(expected, src)
if err != nil {
panic(err)
}
return d
} | go | func MustDecode(expected VersionByte, src string) []byte {
d, err := Decode(expected, src)
if err != nil {
panic(err)
}
return d
} | [
"func",
"MustDecode",
"(",
"expected",
"VersionByte",
",",
"src",
"string",
")",
"[",
"]",
"byte",
"{",
"d",
",",
"err",
":=",
"Decode",
"(",
"expected",
",",
"src",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"panic",
"(",
"err",
")",
"\n",
"}",
"... | // MustDecode is like Decode, but panics on error | [
"MustDecode",
"is",
"like",
"Decode",
"but",
"panics",
"on",
"error"
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/strkey/main.go#L64-L70 | test |
stellar/go-stellar-base | strkey/main.go | Encode | func Encode(version VersionByte, src []byte) (string, error) {
if err := checkValidVersionByte(version); err != nil {
return "", err
}
var raw bytes.Buffer
// write version byte
if err := binary.Write(&raw, binary.LittleEndian, version); err != nil {
return "", err
}
// write payload
if _, err := raw.Wri... | go | func Encode(version VersionByte, src []byte) (string, error) {
if err := checkValidVersionByte(version); err != nil {
return "", err
}
var raw bytes.Buffer
// write version byte
if err := binary.Write(&raw, binary.LittleEndian, version); err != nil {
return "", err
}
// write payload
if _, err := raw.Wri... | [
"func",
"Encode",
"(",
"version",
"VersionByte",
",",
"src",
"[",
"]",
"byte",
")",
"(",
"string",
",",
"error",
")",
"{",
"if",
"err",
":=",
"checkValidVersionByte",
"(",
"version",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"\"\"",
",",
"err",
"\... | // Encode encodes the provided data to a StrKey, using the provided version
// byte. | [
"Encode",
"encodes",
"the",
"provided",
"data",
"to",
"a",
"StrKey",
"using",
"the",
"provided",
"version",
"byte",
"."
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/strkey/main.go#L74-L99 | test |
stellar/go-stellar-base | strkey/main.go | MustEncode | func MustEncode(version VersionByte, src []byte) string {
e, err := Encode(version, src)
if err != nil {
panic(err)
}
return e
} | go | func MustEncode(version VersionByte, src []byte) string {
e, err := Encode(version, src)
if err != nil {
panic(err)
}
return e
} | [
"func",
"MustEncode",
"(",
"version",
"VersionByte",
",",
"src",
"[",
"]",
"byte",
")",
"string",
"{",
"e",
",",
"err",
":=",
"Encode",
"(",
"version",
",",
"src",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"panic",
"(",
"err",
")",
"\n",
"}",
"\n... | // MustEncode is like Encode, but panics on error | [
"MustEncode",
"is",
"like",
"Encode",
"but",
"panics",
"on",
"error"
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/strkey/main.go#L102-L108 | test |
stellar/go-stellar-base | strkey/main.go | checkValidVersionByte | func checkValidVersionByte(version VersionByte) error {
if version == VersionByteAccountID {
return nil
}
if version == VersionByteSeed {
return nil
}
return ErrInvalidVersionByte
} | go | func checkValidVersionByte(version VersionByte) error {
if version == VersionByteAccountID {
return nil
}
if version == VersionByteSeed {
return nil
}
return ErrInvalidVersionByte
} | [
"func",
"checkValidVersionByte",
"(",
"version",
"VersionByte",
")",
"error",
"{",
"if",
"version",
"==",
"VersionByteAccountID",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"if",
"version",
"==",
"VersionByteSeed",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"return",
... | // checkValidVersionByte returns an error if the provided value
// is not one of the defined valid version byte constants. | [
"checkValidVersionByte",
"returns",
"an",
"error",
"if",
"the",
"provided",
"value",
"is",
"not",
"one",
"of",
"the",
"defined",
"valid",
"version",
"byte",
"constants",
"."
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/strkey/main.go#L112-L121 | test |
stellar/go-stellar-base | crc16/main.go | Checksum | func Checksum(data []byte) []byte {
var crc uint16
var out bytes.Buffer
for _, b := range data {
crc = ((crc << 8) & 0xffff) ^ crc16tab[((crc>>8)^uint16(b))&0x00FF]
}
err := binary.Write(&out, binary.LittleEndian, crc)
if err != nil {
panic(err)
}
return out.Bytes()
} | go | func Checksum(data []byte) []byte {
var crc uint16
var out bytes.Buffer
for _, b := range data {
crc = ((crc << 8) & 0xffff) ^ crc16tab[((crc>>8)^uint16(b))&0x00FF]
}
err := binary.Write(&out, binary.LittleEndian, crc)
if err != nil {
panic(err)
}
return out.Bytes()
} | [
"func",
"Checksum",
"(",
"data",
"[",
"]",
"byte",
")",
"[",
"]",
"byte",
"{",
"var",
"crc",
"uint16",
"\n",
"var",
"out",
"bytes",
".",
"Buffer",
"\n",
"for",
"_",
",",
"b",
":=",
"range",
"data",
"{",
"crc",
"=",
"(",
"(",
"crc",
"<<",
"8",
... | // Checksum returns the 2-byte checksum for the provided data | [
"Checksum",
"returns",
"the",
"2",
"-",
"byte",
"checksum",
"for",
"the",
"provided",
"data"
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/crc16/main.go#L95-L108 | test |
stellar/go-stellar-base | crc16/main.go | Validate | func Validate(data []byte, expected []byte) error {
actual := Checksum(data)
// validate the provided checksum against the calculated
if !bytes.Equal(actual, expected) {
return ErrInvalidChecksum
}
return nil
} | go | func Validate(data []byte, expected []byte) error {
actual := Checksum(data)
// validate the provided checksum against the calculated
if !bytes.Equal(actual, expected) {
return ErrInvalidChecksum
}
return nil
} | [
"func",
"Validate",
"(",
"data",
"[",
"]",
"byte",
",",
"expected",
"[",
"]",
"byte",
")",
"error",
"{",
"actual",
":=",
"Checksum",
"(",
"data",
")",
"\n",
"if",
"!",
"bytes",
".",
"Equal",
"(",
"actual",
",",
"expected",
")",
"{",
"return",
"ErrI... | // Validate returns an error if the provided checksum does not match
// the calculated checksum of the provided data | [
"Validate",
"returns",
"an",
"error",
"if",
"the",
"provided",
"checksum",
"does",
"not",
"match",
"the",
"calculated",
"checksum",
"of",
"the",
"provided",
"data"
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/crc16/main.go#L112-L122 | test |
stellar/go-stellar-base | xdr/ledger_entry_change.go | LedgerKey | func (change *LedgerEntryChange) LedgerKey() LedgerKey {
switch change.Type {
case LedgerEntryChangeTypeLedgerEntryCreated:
change := change.MustCreated()
return change.LedgerKey()
case LedgerEntryChangeTypeLedgerEntryRemoved:
return change.MustRemoved()
case LedgerEntryChangeTypeLedgerEntryUpdated:
change ... | go | func (change *LedgerEntryChange) LedgerKey() LedgerKey {
switch change.Type {
case LedgerEntryChangeTypeLedgerEntryCreated:
change := change.MustCreated()
return change.LedgerKey()
case LedgerEntryChangeTypeLedgerEntryRemoved:
return change.MustRemoved()
case LedgerEntryChangeTypeLedgerEntryUpdated:
change ... | [
"func",
"(",
"change",
"*",
"LedgerEntryChange",
")",
"LedgerKey",
"(",
")",
"LedgerKey",
"{",
"switch",
"change",
".",
"Type",
"{",
"case",
"LedgerEntryChangeTypeLedgerEntryCreated",
":",
"change",
":=",
"change",
".",
"MustCreated",
"(",
")",
"\n",
"return",
... | // LedgerKey returns the key for the ledger entry that was changed
// in `change`. | [
"LedgerKey",
"returns",
"the",
"key",
"for",
"the",
"ledger",
"entry",
"that",
"was",
"changed",
"in",
"change",
"."
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/xdr/ledger_entry_change.go#L12-L28 | test |
stellar/go-stellar-base | cmd/stellar-vanity-gen/main.go | checkPlausible | func checkPlausible() {
for _, r := range prefix {
if !strings.ContainsRune(alphabet, r) {
fmt.Printf("Invalid prefix: %s is not in the base32 alphabet\n", strconv.QuoteRune(r))
os.Exit(1)
}
}
} | go | func checkPlausible() {
for _, r := range prefix {
if !strings.ContainsRune(alphabet, r) {
fmt.Printf("Invalid prefix: %s is not in the base32 alphabet\n", strconv.QuoteRune(r))
os.Exit(1)
}
}
} | [
"func",
"checkPlausible",
"(",
")",
"{",
"for",
"_",
",",
"r",
":=",
"range",
"prefix",
"{",
"if",
"!",
"strings",
".",
"ContainsRune",
"(",
"alphabet",
",",
"r",
")",
"{",
"fmt",
".",
"Printf",
"(",
"\"Invalid prefix: %s is not in the base32 alphabet\\n\"",
... | // aborts the attempt if a desired character is not a valid base32 digit | [
"aborts",
"the",
"attempt",
"if",
"a",
"desired",
"character",
"is",
"not",
"a",
"valid",
"base32",
"digit"
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/cmd/stellar-vanity-gen/main.go#L50-L57 | test |
stellar/go-stellar-base | xdr/account_id.go | Address | func (aid *AccountId) Address() string {
if aid == nil {
return ""
}
switch aid.Type {
case CryptoKeyTypeKeyTypeEd25519:
ed := aid.MustEd25519()
raw := make([]byte, 32)
copy(raw, ed[:])
return strkey.MustEncode(strkey.VersionByteAccountID, raw)
default:
panic(fmt.Errorf("Unknown account id type: %v", ... | go | func (aid *AccountId) Address() string {
if aid == nil {
return ""
}
switch aid.Type {
case CryptoKeyTypeKeyTypeEd25519:
ed := aid.MustEd25519()
raw := make([]byte, 32)
copy(raw, ed[:])
return strkey.MustEncode(strkey.VersionByteAccountID, raw)
default:
panic(fmt.Errorf("Unknown account id type: %v", ... | [
"func",
"(",
"aid",
"*",
"AccountId",
")",
"Address",
"(",
")",
"string",
"{",
"if",
"aid",
"==",
"nil",
"{",
"return",
"\"\"",
"\n",
"}",
"\n",
"switch",
"aid",
".",
"Type",
"{",
"case",
"CryptoKeyTypeKeyTypeEd25519",
":",
"ed",
":=",
"aid",
".",
"M... | // Address returns the strkey encoded form of this AccountId. This method will
// panic if the accountid is backed by a public key of an unknown type. | [
"Address",
"returns",
"the",
"strkey",
"encoded",
"form",
"of",
"this",
"AccountId",
".",
"This",
"method",
"will",
"panic",
"if",
"the",
"accountid",
"is",
"backed",
"by",
"a",
"public",
"key",
"of",
"an",
"unknown",
"type",
"."
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/xdr/account_id.go#L12-L26 | test |
stellar/go-stellar-base | xdr/account_id.go | Equals | func (aid *AccountId) Equals(other AccountId) bool {
if aid.Type != other.Type {
return false
}
switch aid.Type {
case CryptoKeyTypeKeyTypeEd25519:
l := aid.MustEd25519()
r := other.MustEd25519()
return l == r
default:
panic(fmt.Errorf("Unknown account id type: %v", aid.Type))
}
} | go | func (aid *AccountId) Equals(other AccountId) bool {
if aid.Type != other.Type {
return false
}
switch aid.Type {
case CryptoKeyTypeKeyTypeEd25519:
l := aid.MustEd25519()
r := other.MustEd25519()
return l == r
default:
panic(fmt.Errorf("Unknown account id type: %v", aid.Type))
}
} | [
"func",
"(",
"aid",
"*",
"AccountId",
")",
"Equals",
"(",
"other",
"AccountId",
")",
"bool",
"{",
"if",
"aid",
".",
"Type",
"!=",
"other",
".",
"Type",
"{",
"return",
"false",
"\n",
"}",
"\n",
"switch",
"aid",
".",
"Type",
"{",
"case",
"CryptoKeyType... | // Equals returns true if `other` is equivalent to `aid` | [
"Equals",
"returns",
"true",
"if",
"other",
"is",
"equivalent",
"to",
"aid"
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/xdr/account_id.go#L29-L42 | test |
stellar/go-stellar-base | xdr/account_id.go | SetAddress | func (aid *AccountId) SetAddress(address string) error {
if aid == nil {
return nil
}
raw, err := strkey.Decode(strkey.VersionByteAccountID, address)
if err != nil {
return err
}
if len(raw) != 32 {
return errors.New("invalid address")
}
var ui Uint256
copy(ui[:], raw)
*aid, err = NewAccountId(Crypt... | go | func (aid *AccountId) SetAddress(address string) error {
if aid == nil {
return nil
}
raw, err := strkey.Decode(strkey.VersionByteAccountID, address)
if err != nil {
return err
}
if len(raw) != 32 {
return errors.New("invalid address")
}
var ui Uint256
copy(ui[:], raw)
*aid, err = NewAccountId(Crypt... | [
"func",
"(",
"aid",
"*",
"AccountId",
")",
"SetAddress",
"(",
"address",
"string",
")",
"error",
"{",
"if",
"aid",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"raw",
",",
"err",
":=",
"strkey",
".",
"Decode",
"(",
"strkey",
".",
"VersionByteA... | // SetAddress modifies the receiver, setting it's value to the AccountId form
// of the provided address. | [
"SetAddress",
"modifies",
"the",
"receiver",
"setting",
"it",
"s",
"value",
"to",
"the",
"AccountId",
"form",
"of",
"the",
"provided",
"address",
"."
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/xdr/account_id.go#L56-L76 | test |
stellar/go-stellar-base | build/main.go | ToXdrObject | func (a Asset) ToXdrObject() (xdr.Asset, error) {
if a.Native {
return xdr.NewAsset(xdr.AssetTypeAssetTypeNative, nil)
}
var issuer xdr.AccountId
err := setAccountId(a.Issuer, &issuer)
if err != nil {
return xdr.Asset{}, err
}
length := len(a.Code)
switch {
case length >= 1 && length <= 4:
var codeArra... | go | func (a Asset) ToXdrObject() (xdr.Asset, error) {
if a.Native {
return xdr.NewAsset(xdr.AssetTypeAssetTypeNative, nil)
}
var issuer xdr.AccountId
err := setAccountId(a.Issuer, &issuer)
if err != nil {
return xdr.Asset{}, err
}
length := len(a.Code)
switch {
case length >= 1 && length <= 4:
var codeArra... | [
"func",
"(",
"a",
"Asset",
")",
"ToXdrObject",
"(",
")",
"(",
"xdr",
".",
"Asset",
",",
"error",
")",
"{",
"if",
"a",
".",
"Native",
"{",
"return",
"xdr",
".",
"NewAsset",
"(",
"xdr",
".",
"AssetTypeAssetTypeNative",
",",
"nil",
")",
"\n",
"}",
"\n... | // ToXdrObject creates xdr.Asset object from build.Asset object | [
"ToXdrObject",
"creates",
"xdr",
".",
"Asset",
"object",
"from",
"build",
".",
"Asset",
"object"
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/build/main.go#L52-L80 | test |
stellar/go-stellar-base | build/main.go | Through | func (pathSend PayWithPath) Through(asset Asset) PayWithPath {
pathSend.Path = append(pathSend.Path, asset)
return pathSend
} | go | func (pathSend PayWithPath) Through(asset Asset) PayWithPath {
pathSend.Path = append(pathSend.Path, asset)
return pathSend
} | [
"func",
"(",
"pathSend",
"PayWithPath",
")",
"Through",
"(",
"asset",
"Asset",
")",
"PayWithPath",
"{",
"pathSend",
".",
"Path",
"=",
"append",
"(",
"pathSend",
".",
"Path",
",",
"asset",
")",
"\n",
"return",
"pathSend",
"\n",
"}"
] | // Through appends a new asset to the path | [
"Through",
"appends",
"a",
"new",
"asset",
"to",
"the",
"path"
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/build/main.go#L182-L185 | test |
stellar/go-stellar-base | build/main.go | PayWith | func PayWith(sendAsset Asset, maxAmount string) PayWithPath {
return PayWithPath{
Asset: sendAsset,
MaxAmount: maxAmount,
}
} | go | func PayWith(sendAsset Asset, maxAmount string) PayWithPath {
return PayWithPath{
Asset: sendAsset,
MaxAmount: maxAmount,
}
} | [
"func",
"PayWith",
"(",
"sendAsset",
"Asset",
",",
"maxAmount",
"string",
")",
"PayWithPath",
"{",
"return",
"PayWithPath",
"{",
"Asset",
":",
"sendAsset",
",",
"MaxAmount",
":",
"maxAmount",
",",
"}",
"\n",
"}"
] | // PayWith is a helper to create PayWithPath struct | [
"PayWith",
"is",
"a",
"helper",
"to",
"create",
"PayWithPath",
"struct"
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/build/main.go#L188-L193 | test |
stellar/go-stellar-base | price/main.go | continuedFraction | func continuedFraction(price string) (xdrPrice xdr.Price, err error) {
number := &big.Rat{}
maxInt32 := &big.Rat{}
zero := &big.Rat{}
one := &big.Rat{}
_, ok := number.SetString(price)
if !ok {
return xdrPrice, fmt.Errorf("cannot parse price: %s", price)
}
maxInt32.SetInt64(int64(math.MaxInt32))
zero.SetIn... | go | func continuedFraction(price string) (xdrPrice xdr.Price, err error) {
number := &big.Rat{}
maxInt32 := &big.Rat{}
zero := &big.Rat{}
one := &big.Rat{}
_, ok := number.SetString(price)
if !ok {
return xdrPrice, fmt.Errorf("cannot parse price: %s", price)
}
maxInt32.SetInt64(int64(math.MaxInt32))
zero.SetIn... | [
"func",
"continuedFraction",
"(",
"price",
"string",
")",
"(",
"xdrPrice",
"xdr",
".",
"Price",
",",
"err",
"error",
")",
"{",
"number",
":=",
"&",
"big",
".",
"Rat",
"{",
"}",
"\n",
"maxInt32",
":=",
"&",
"big",
".",
"Rat",
"{",
"}",
"\n",
"zero",... | // continuedFraction calculates and returns the best rational approximation of the given real number. | [
"continuedFraction",
"calculates",
"and",
"returns",
"the",
"best",
"rational",
"approximation",
"of",
"the",
"given",
"real",
"number",
"."
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/price/main.go#L18-L77 | test |
stellar/go-stellar-base | build/transaction_envelope.go | Mutate | func (b *TransactionEnvelopeBuilder) Mutate(muts ...TransactionEnvelopeMutator) {
b.Init()
for _, m := range muts {
err := m.MutateTransactionEnvelope(b)
if err != nil {
b.Err = err
return
}
}
} | go | func (b *TransactionEnvelopeBuilder) Mutate(muts ...TransactionEnvelopeMutator) {
b.Init()
for _, m := range muts {
err := m.MutateTransactionEnvelope(b)
if err != nil {
b.Err = err
return
}
}
} | [
"func",
"(",
"b",
"*",
"TransactionEnvelopeBuilder",
")",
"Mutate",
"(",
"muts",
"...",
"TransactionEnvelopeMutator",
")",
"{",
"b",
".",
"Init",
"(",
")",
"\n",
"for",
"_",
",",
"m",
":=",
"range",
"muts",
"{",
"err",
":=",
"m",
".",
"MutateTransactionE... | // Mutate applies the provided TransactionEnvelopeMutators to this builder's
// envelope | [
"Mutate",
"applies",
"the",
"provided",
"TransactionEnvelopeMutators",
"to",
"this",
"builder",
"s",
"envelope"
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/build/transaction_envelope.go#L38-L48 | test |
stellar/go-stellar-base | build/transaction_envelope.go | MutateTX | func (b *TransactionEnvelopeBuilder) MutateTX(muts ...TransactionMutator) {
b.Init()
if b.Err != nil {
return
}
b.child.Mutate(muts...)
b.Err = b.child.Err
} | go | func (b *TransactionEnvelopeBuilder) MutateTX(muts ...TransactionMutator) {
b.Init()
if b.Err != nil {
return
}
b.child.Mutate(muts...)
b.Err = b.child.Err
} | [
"func",
"(",
"b",
"*",
"TransactionEnvelopeBuilder",
")",
"MutateTX",
"(",
"muts",
"...",
"TransactionMutator",
")",
"{",
"b",
".",
"Init",
"(",
")",
"\n",
"if",
"b",
".",
"Err",
"!=",
"nil",
"{",
"return",
"\n",
"}",
"\n",
"b",
".",
"child",
".",
... | // MutateTX runs Mutate on the underlying transaction using the provided
// mutators. | [
"MutateTX",
"runs",
"Mutate",
"on",
"the",
"underlying",
"transaction",
"using",
"the",
"provided",
"mutators",
"."
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/build/transaction_envelope.go#L52-L61 | test |
stellar/go-stellar-base | build/transaction_envelope.go | Bytes | func (b *TransactionEnvelopeBuilder) Bytes() ([]byte, error) {
if b.Err != nil {
return nil, b.Err
}
var txBytes bytes.Buffer
_, err := xdr.Marshal(&txBytes, b.E)
if err != nil {
return nil, err
}
return txBytes.Bytes(), nil
} | go | func (b *TransactionEnvelopeBuilder) Bytes() ([]byte, error) {
if b.Err != nil {
return nil, b.Err
}
var txBytes bytes.Buffer
_, err := xdr.Marshal(&txBytes, b.E)
if err != nil {
return nil, err
}
return txBytes.Bytes(), nil
} | [
"func",
"(",
"b",
"*",
"TransactionEnvelopeBuilder",
")",
"Bytes",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"if",
"b",
".",
"Err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"b",
".",
"Err",
"\n",
"}",
"\n",
"var",
"txBytes",
"bytes"... | // Bytes encodes the builder's underlying envelope to XDR | [
"Bytes",
"encodes",
"the",
"builder",
"s",
"underlying",
"envelope",
"to",
"XDR"
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/build/transaction_envelope.go#L64-L76 | test |
stellar/go-stellar-base | build/transaction_envelope.go | Base64 | func (b *TransactionEnvelopeBuilder) Base64() (string, error) {
bs, err := b.Bytes()
return base64.StdEncoding.EncodeToString(bs), err
} | go | func (b *TransactionEnvelopeBuilder) Base64() (string, error) {
bs, err := b.Bytes()
return base64.StdEncoding.EncodeToString(bs), err
} | [
"func",
"(",
"b",
"*",
"TransactionEnvelopeBuilder",
")",
"Base64",
"(",
")",
"(",
"string",
",",
"error",
")",
"{",
"bs",
",",
"err",
":=",
"b",
".",
"Bytes",
"(",
")",
"\n",
"return",
"base64",
".",
"StdEncoding",
".",
"EncodeToString",
"(",
"bs",
... | // Base64 returns a string which is the xdr-then-base64-encoded form
// of the builder's underlying transaction envelope | [
"Base64",
"returns",
"a",
"string",
"which",
"is",
"the",
"xdr",
"-",
"then",
"-",
"base64",
"-",
"encoded",
"form",
"of",
"the",
"builder",
"s",
"underlying",
"transaction",
"envelope"
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/build/transaction_envelope.go#L80-L83 | test |
stellar/go-stellar-base | build/transaction_envelope.go | MutateTransactionEnvelope | func (m *TransactionBuilder) MutateTransactionEnvelope(txe *TransactionEnvelopeBuilder) error {
if m.Err != nil {
return m.Err
}
txe.E.Tx = *m.TX
newChild := *m
txe.child = &newChild
m.TX = &txe.E.Tx
return nil
} | go | func (m *TransactionBuilder) MutateTransactionEnvelope(txe *TransactionEnvelopeBuilder) error {
if m.Err != nil {
return m.Err
}
txe.E.Tx = *m.TX
newChild := *m
txe.child = &newChild
m.TX = &txe.E.Tx
return nil
} | [
"func",
"(",
"m",
"*",
"TransactionBuilder",
")",
"MutateTransactionEnvelope",
"(",
"txe",
"*",
"TransactionEnvelopeBuilder",
")",
"error",
"{",
"if",
"m",
".",
"Err",
"!=",
"nil",
"{",
"return",
"m",
".",
"Err",
"\n",
"}",
"\n",
"txe",
".",
"E",
".",
... | // MutateTransactionEnvelope for TransactionBuilder causes the underylying
// transaction to be set as the provided envelope's Tx field | [
"MutateTransactionEnvelope",
"for",
"TransactionBuilder",
"causes",
"the",
"underylying",
"transaction",
"to",
"be",
"set",
"as",
"the",
"provided",
"envelope",
"s",
"Tx",
"field"
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/build/transaction_envelope.go#L115-L125 | test |
stellar/go-stellar-base | build/set_options.go | MutateSetOptions | func (m HomeDomain) MutateSetOptions(o *xdr.SetOptionsOp) (err error) {
if len(m) > 32 {
return errors.New("HomeDomain is too long")
}
value := xdr.String32(m)
o.HomeDomain = &value
return
} | go | func (m HomeDomain) MutateSetOptions(o *xdr.SetOptionsOp) (err error) {
if len(m) > 32 {
return errors.New("HomeDomain is too long")
}
value := xdr.String32(m)
o.HomeDomain = &value
return
} | [
"func",
"(",
"m",
"HomeDomain",
")",
"MutateSetOptions",
"(",
"o",
"*",
"xdr",
".",
"SetOptionsOp",
")",
"(",
"err",
"error",
")",
"{",
"if",
"len",
"(",
"m",
")",
">",
"32",
"{",
"return",
"errors",
".",
"New",
"(",
"\"HomeDomain is too long\"",
")",
... | // MutateSetOptions for HomeDomain sets the SetOptionsOp's HomeDomain field | [
"MutateSetOptions",
"for",
"HomeDomain",
"sets",
"the",
"SetOptionsOp",
"s",
"HomeDomain",
"field"
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/build/set_options.go#L50-L58 | test |
stellar/go-stellar-base | build/set_options.go | MutateSetOptions | func (m InflationDest) MutateSetOptions(o *xdr.SetOptionsOp) (err error) {
o.InflationDest = &xdr.AccountId{}
err = setAccountId(string(m), o.InflationDest)
return
} | go | func (m InflationDest) MutateSetOptions(o *xdr.SetOptionsOp) (err error) {
o.InflationDest = &xdr.AccountId{}
err = setAccountId(string(m), o.InflationDest)
return
} | [
"func",
"(",
"m",
"InflationDest",
")",
"MutateSetOptions",
"(",
"o",
"*",
"xdr",
".",
"SetOptionsOp",
")",
"(",
"err",
"error",
")",
"{",
"o",
".",
"InflationDest",
"=",
"&",
"xdr",
".",
"AccountId",
"{",
"}",
"\n",
"err",
"=",
"setAccountId",
"(",
... | // MutateSetOptions for InflationDest sets the SetOptionsOp's InflationDest field | [
"MutateSetOptions",
"for",
"InflationDest",
"sets",
"the",
"SetOptionsOp",
"s",
"InflationDest",
"field"
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/build/set_options.go#L66-L70 | test |
stellar/go-stellar-base | build/set_options.go | MutateSetOptions | func (m MasterWeight) MutateSetOptions(o *xdr.SetOptionsOp) (err error) {
val := xdr.Uint32(m)
o.MasterWeight = &val
return
} | go | func (m MasterWeight) MutateSetOptions(o *xdr.SetOptionsOp) (err error) {
val := xdr.Uint32(m)
o.MasterWeight = &val
return
} | [
"func",
"(",
"m",
"MasterWeight",
")",
"MutateSetOptions",
"(",
"o",
"*",
"xdr",
".",
"SetOptionsOp",
")",
"(",
"err",
"error",
")",
"{",
"val",
":=",
"xdr",
".",
"Uint32",
"(",
"m",
")",
"\n",
"o",
".",
"MasterWeight",
"=",
"&",
"val",
"\n",
"retu... | // MutateSetOptions for MasterWeight sets the SetOptionsOp's MasterWeight field | [
"MutateSetOptions",
"for",
"MasterWeight",
"sets",
"the",
"SetOptionsOp",
"s",
"MasterWeight",
"field"
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/build/set_options.go#L78-L82 | test |
stellar/go-stellar-base | build/set_options.go | MutateSetOptions | func (m Signer) MutateSetOptions(o *xdr.SetOptionsOp) (err error) {
var signer xdr.Signer
signer.Weight = xdr.Uint32(m.Weight)
err = setAccountId(m.PublicKey, &signer.PubKey)
o.Signer = &signer
return
} | go | func (m Signer) MutateSetOptions(o *xdr.SetOptionsOp) (err error) {
var signer xdr.Signer
signer.Weight = xdr.Uint32(m.Weight)
err = setAccountId(m.PublicKey, &signer.PubKey)
o.Signer = &signer
return
} | [
"func",
"(",
"m",
"Signer",
")",
"MutateSetOptions",
"(",
"o",
"*",
"xdr",
".",
"SetOptionsOp",
")",
"(",
"err",
"error",
")",
"{",
"var",
"signer",
"xdr",
".",
"Signer",
"\n",
"signer",
".",
"Weight",
"=",
"xdr",
".",
"Uint32",
"(",
"m",
".",
"Wei... | // MutateSetOptions for Signer sets the SetOptionsOp's signer field | [
"MutateSetOptions",
"for",
"Signer",
"sets",
"the",
"SetOptionsOp",
"s",
"signer",
"field"
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/build/set_options.go#L100-L106 | test |
stellar/go-stellar-base | build/set_options.go | SetThresholds | func SetThresholds(low, medium, high uint32) Thresholds {
return Thresholds{
Low: &low,
Medium: &medium,
High: &high,
}
} | go | func SetThresholds(low, medium, high uint32) Thresholds {
return Thresholds{
Low: &low,
Medium: &medium,
High: &high,
}
} | [
"func",
"SetThresholds",
"(",
"low",
",",
"medium",
",",
"high",
"uint32",
")",
"Thresholds",
"{",
"return",
"Thresholds",
"{",
"Low",
":",
"&",
"low",
",",
"Medium",
":",
"&",
"medium",
",",
"High",
":",
"&",
"high",
",",
"}",
"\n",
"}"
] | // SetThresholds creates Thresholds mutator | [
"SetThresholds",
"creates",
"Thresholds",
"mutator"
] | 79c570612c0b461db178aa8949d9f13cafc2a7c9 | https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/build/set_options.go#L114-L120 | test |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.