id int32 0 167k | repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1
value | code stringlengths 52 85.5k | code_tokens listlengths 21 1.41k | docstring stringlengths 6 2.61k | docstring_tokens listlengths 3 215 | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
26,900 | jasonlvhit/gocron | gocron.go | Second | func (j *Job) Second() (job *Job) {
if j.interval != 1 {
panic("")
}
job = j.Seconds()
return
} | go | func (j *Job) Second() (job *Job) {
if j.interval != 1 {
panic("")
}
job = j.Seconds()
return
} | [
"func",
"(",
"j",
"*",
"Job",
")",
"Second",
"(",
")",
"(",
"job",
"*",
"Job",
")",
"{",
"if",
"j",
".",
"interval",
"!=",
"1",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"job",
"=",
"j",
".",
"Seconds",
"(",
")",
"\n",
"return",
... | // the follow functions set the job's unit with seconds,minutes,hours...
// Set the unit with second | [
"the",
"follow",
"functions",
"set",
"the",
"job",
"s",
"unit",
"with",
"seconds",
"minutes",
"hours",
"...",
"Set",
"the",
"unit",
"with",
"second"
] | 5bcdd9fcfa9bf10574722841a11ccb2a57866dc8 | https://github.com/jasonlvhit/gocron/blob/5bcdd9fcfa9bf10574722841a11ccb2a57866dc8/gocron.go#L230-L236 |
26,901 | jasonlvhit/gocron | gocron.go | Minute | func (j *Job) Minute() (job *Job) {
if j.interval != 1 {
panic("")
}
job = j.Minutes()
return
} | go | func (j *Job) Minute() (job *Job) {
if j.interval != 1 {
panic("")
}
job = j.Minutes()
return
} | [
"func",
"(",
"j",
"*",
"Job",
")",
"Minute",
"(",
")",
"(",
"job",
"*",
"Job",
")",
"{",
"if",
"j",
".",
"interval",
"!=",
"1",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"job",
"=",
"j",
".",
"Minutes",
"(",
")",
"\n",
"return",
... | // Set the unit with minute, which interval is 1 | [
"Set",
"the",
"unit",
"with",
"minute",
"which",
"interval",
"is",
"1"
] | 5bcdd9fcfa9bf10574722841a11ccb2a57866dc8 | https://github.com/jasonlvhit/gocron/blob/5bcdd9fcfa9bf10574722841a11ccb2a57866dc8/gocron.go#L245-L251 |
26,902 | jasonlvhit/gocron | gocron.go | Hour | func (j *Job) Hour() (job *Job) {
if j.interval != 1 {
panic("")
}
job = j.Hours()
return
} | go | func (j *Job) Hour() (job *Job) {
if j.interval != 1 {
panic("")
}
job = j.Hours()
return
} | [
"func",
"(",
"j",
"*",
"Job",
")",
"Hour",
"(",
")",
"(",
"job",
"*",
"Job",
")",
"{",
"if",
"j",
".",
"interval",
"!=",
"1",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"job",
"=",
"j",
".",
"Hours",
"(",
")",
"\n",
"return",
"\... | //set the unit with hour, which interval is 1 | [
"set",
"the",
"unit",
"with",
"hour",
"which",
"interval",
"is",
"1"
] | 5bcdd9fcfa9bf10574722841a11ccb2a57866dc8 | https://github.com/jasonlvhit/gocron/blob/5bcdd9fcfa9bf10574722841a11ccb2a57866dc8/gocron.go#L260-L266 |
26,903 | jasonlvhit/gocron | gocron.go | Day | func (j *Job) Day() (job *Job) {
if j.interval != 1 {
panic("")
}
job = j.Days()
return
} | go | func (j *Job) Day() (job *Job) {
if j.interval != 1 {
panic("")
}
job = j.Days()
return
} | [
"func",
"(",
"j",
"*",
"Job",
")",
"Day",
"(",
")",
"(",
"job",
"*",
"Job",
")",
"{",
"if",
"j",
".",
"interval",
"!=",
"1",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"job",
"=",
"j",
".",
"Days",
"(",
")",
"\n",
"return",
"\n"... | // Set the job's unit with day, which interval is 1 | [
"Set",
"the",
"job",
"s",
"unit",
"with",
"day",
"which",
"interval",
"is",
"1"
] | 5bcdd9fcfa9bf10574722841a11ccb2a57866dc8 | https://github.com/jasonlvhit/gocron/blob/5bcdd9fcfa9bf10574722841a11ccb2a57866dc8/gocron.go#L275-L281 |
26,904 | jasonlvhit/gocron | gocron.go | Tuesday | func (j *Job) Tuesday() (job *Job) {
if j.interval != 1 {
panic("")
}
j.startDay = 2
job = j.Weeks()
return
} | go | func (j *Job) Tuesday() (job *Job) {
if j.interval != 1 {
panic("")
}
j.startDay = 2
job = j.Weeks()
return
} | [
"func",
"(",
"j",
"*",
"Job",
")",
"Tuesday",
"(",
")",
"(",
"job",
"*",
"Job",
")",
"{",
"if",
"j",
".",
"interval",
"!=",
"1",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"j",
".",
"startDay",
"=",
"2",
"\n",
"job",
"=",
"j",
"... | // Set the start day with Tuesday | [
"Set",
"the",
"start",
"day",
"with",
"Tuesday"
] | 5bcdd9fcfa9bf10574722841a11ccb2a57866dc8 | https://github.com/jasonlvhit/gocron/blob/5bcdd9fcfa9bf10574722841a11ccb2a57866dc8/gocron.go#L301-L308 |
26,905 | jasonlvhit/gocron | gocron.go | Wednesday | func (j *Job) Wednesday() (job *Job) {
if j.interval != 1 {
panic("")
}
j.startDay = 3
job = j.Weeks()
return
} | go | func (j *Job) Wednesday() (job *Job) {
if j.interval != 1 {
panic("")
}
j.startDay = 3
job = j.Weeks()
return
} | [
"func",
"(",
"j",
"*",
"Job",
")",
"Wednesday",
"(",
")",
"(",
"job",
"*",
"Job",
")",
"{",
"if",
"j",
".",
"interval",
"!=",
"1",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"j",
".",
"startDay",
"=",
"3",
"\n",
"job",
"=",
"j",
... | // Set the start day woth Wednesday | [
"Set",
"the",
"start",
"day",
"woth",
"Wednesday"
] | 5bcdd9fcfa9bf10574722841a11ccb2a57866dc8 | https://github.com/jasonlvhit/gocron/blob/5bcdd9fcfa9bf10574722841a11ccb2a57866dc8/gocron.go#L311-L318 |
26,906 | jasonlvhit/gocron | gocron.go | Thursday | func (j *Job) Thursday() (job *Job) {
if j.interval != 1 {
panic("")
}
j.startDay = 4
job = j.Weeks()
return
} | go | func (j *Job) Thursday() (job *Job) {
if j.interval != 1 {
panic("")
}
j.startDay = 4
job = j.Weeks()
return
} | [
"func",
"(",
"j",
"*",
"Job",
")",
"Thursday",
"(",
")",
"(",
"job",
"*",
"Job",
")",
"{",
"if",
"j",
".",
"interval",
"!=",
"1",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"j",
".",
"startDay",
"=",
"4",
"\n",
"job",
"=",
"j",
... | // Set the start day with thursday | [
"Set",
"the",
"start",
"day",
"with",
"thursday"
] | 5bcdd9fcfa9bf10574722841a11ccb2a57866dc8 | https://github.com/jasonlvhit/gocron/blob/5bcdd9fcfa9bf10574722841a11ccb2a57866dc8/gocron.go#L321-L328 |
26,907 | jasonlvhit/gocron | gocron.go | Friday | func (j *Job) Friday() (job *Job) {
if j.interval != 1 {
panic("")
}
j.startDay = 5
job = j.Weeks()
return
} | go | func (j *Job) Friday() (job *Job) {
if j.interval != 1 {
panic("")
}
j.startDay = 5
job = j.Weeks()
return
} | [
"func",
"(",
"j",
"*",
"Job",
")",
"Friday",
"(",
")",
"(",
"job",
"*",
"Job",
")",
"{",
"if",
"j",
".",
"interval",
"!=",
"1",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"j",
".",
"startDay",
"=",
"5",
"\n",
"job",
"=",
"j",
".... | // Set the start day with friday | [
"Set",
"the",
"start",
"day",
"with",
"friday"
] | 5bcdd9fcfa9bf10574722841a11ccb2a57866dc8 | https://github.com/jasonlvhit/gocron/blob/5bcdd9fcfa9bf10574722841a11ccb2a57866dc8/gocron.go#L331-L338 |
26,908 | jasonlvhit/gocron | gocron.go | Saturday | func (j *Job) Saturday() (job *Job) {
if j.interval != 1 {
panic("")
}
j.startDay = 6
job = j.Weeks()
return
} | go | func (j *Job) Saturday() (job *Job) {
if j.interval != 1 {
panic("")
}
j.startDay = 6
job = j.Weeks()
return
} | [
"func",
"(",
"j",
"*",
"Job",
")",
"Saturday",
"(",
")",
"(",
"job",
"*",
"Job",
")",
"{",
"if",
"j",
".",
"interval",
"!=",
"1",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"j",
".",
"startDay",
"=",
"6",
"\n",
"job",
"=",
"j",
... | // Set the start day with saturday | [
"Set",
"the",
"start",
"day",
"with",
"saturday"
] | 5bcdd9fcfa9bf10574722841a11ccb2a57866dc8 | https://github.com/jasonlvhit/gocron/blob/5bcdd9fcfa9bf10574722841a11ccb2a57866dc8/gocron.go#L341-L348 |
26,909 | jasonlvhit/gocron | gocron.go | Sunday | func (j *Job) Sunday() (job *Job) {
if j.interval != 1 {
panic("")
}
j.startDay = 0
job = j.Weeks()
return
} | go | func (j *Job) Sunday() (job *Job) {
if j.interval != 1 {
panic("")
}
j.startDay = 0
job = j.Weeks()
return
} | [
"func",
"(",
"j",
"*",
"Job",
")",
"Sunday",
"(",
")",
"(",
"job",
"*",
"Job",
")",
"{",
"if",
"j",
".",
"interval",
"!=",
"1",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"j",
".",
"startDay",
"=",
"0",
"\n",
"job",
"=",
"j",
".... | // Set the start day with sunday | [
"Set",
"the",
"start",
"day",
"with",
"sunday"
] | 5bcdd9fcfa9bf10574722841a11ccb2a57866dc8 | https://github.com/jasonlvhit/gocron/blob/5bcdd9fcfa9bf10574722841a11ccb2a57866dc8/gocron.go#L351-L358 |
26,910 | jasonlvhit/gocron | gocron.go | getRunnableJobs | func (s *Scheduler) getRunnableJobs() (running_jobs [MAXJOBNUM]*Job, n int) {
runnableJobs := [MAXJOBNUM]*Job{}
n = 0
sort.Sort(s)
for i := 0; i < s.size; i++ {
if s.jobs[i].shouldRun() {
runnableJobs[n] = s.jobs[i]
//fmt.Println(runnableJobs)
n++
} else {
break
}
}
return runnableJobs, n
} | go | func (s *Scheduler) getRunnableJobs() (running_jobs [MAXJOBNUM]*Job, n int) {
runnableJobs := [MAXJOBNUM]*Job{}
n = 0
sort.Sort(s)
for i := 0; i < s.size; i++ {
if s.jobs[i].shouldRun() {
runnableJobs[n] = s.jobs[i]
//fmt.Println(runnableJobs)
n++
} else {
break
}
}
return runnableJobs, n
} | [
"func",
"(",
"s",
"*",
"Scheduler",
")",
"getRunnableJobs",
"(",
")",
"(",
"running_jobs",
"[",
"MAXJOBNUM",
"]",
"*",
"Job",
",",
"n",
"int",
")",
"{",
"runnableJobs",
":=",
"[",
"MAXJOBNUM",
"]",
"*",
"Job",
"{",
"}",
"\n",
"n",
"=",
"0",
"\n",
... | // Get the current runnable jobs, which shouldRun is True | [
"Get",
"the",
"current",
"runnable",
"jobs",
"which",
"shouldRun",
"is",
"True"
] | 5bcdd9fcfa9bf10574722841a11ccb2a57866dc8 | https://github.com/jasonlvhit/gocron/blob/5bcdd9fcfa9bf10574722841a11ccb2a57866dc8/gocron.go#L395-L410 |
26,911 | jasonlvhit/gocron | gocron.go | NextRun | func (s *Scheduler) NextRun() (*Job, time.Time) {
if s.size <= 0 {
return nil, time.Now()
}
sort.Sort(s)
return s.jobs[0], s.jobs[0].nextRun
} | go | func (s *Scheduler) NextRun() (*Job, time.Time) {
if s.size <= 0 {
return nil, time.Now()
}
sort.Sort(s)
return s.jobs[0], s.jobs[0].nextRun
} | [
"func",
"(",
"s",
"*",
"Scheduler",
")",
"NextRun",
"(",
")",
"(",
"*",
"Job",
",",
"time",
".",
"Time",
")",
"{",
"if",
"s",
".",
"size",
"<=",
"0",
"{",
"return",
"nil",
",",
"time",
".",
"Now",
"(",
")",
"\n",
"}",
"\n",
"sort",
".",
"So... | // Datetime when the next job should run. | [
"Datetime",
"when",
"the",
"next",
"job",
"should",
"run",
"."
] | 5bcdd9fcfa9bf10574722841a11ccb2a57866dc8 | https://github.com/jasonlvhit/gocron/blob/5bcdd9fcfa9bf10574722841a11ccb2a57866dc8/gocron.go#L413-L419 |
26,912 | jasonlvhit/gocron | gocron.go | Every | func (s *Scheduler) Every(interval uint64) *Job {
job := NewJob(interval)
s.jobs[s.size] = job
s.size++
return job
} | go | func (s *Scheduler) Every(interval uint64) *Job {
job := NewJob(interval)
s.jobs[s.size] = job
s.size++
return job
} | [
"func",
"(",
"s",
"*",
"Scheduler",
")",
"Every",
"(",
"interval",
"uint64",
")",
"*",
"Job",
"{",
"job",
":=",
"NewJob",
"(",
"interval",
")",
"\n",
"s",
".",
"jobs",
"[",
"s",
".",
"size",
"]",
"=",
"job",
"\n",
"s",
".",
"size",
"++",
"\n",
... | // Schedule a new periodic job | [
"Schedule",
"a",
"new",
"periodic",
"job"
] | 5bcdd9fcfa9bf10574722841a11ccb2a57866dc8 | https://github.com/jasonlvhit/gocron/blob/5bcdd9fcfa9bf10574722841a11ccb2a57866dc8/gocron.go#L422-L427 |
26,913 | jasonlvhit/gocron | gocron.go | RunPending | func (s *Scheduler) RunPending() {
runnableJobs, n := s.getRunnableJobs()
if n != 0 {
for i := 0; i < n; i++ {
runnableJobs[i].run()
}
}
} | go | func (s *Scheduler) RunPending() {
runnableJobs, n := s.getRunnableJobs()
if n != 0 {
for i := 0; i < n; i++ {
runnableJobs[i].run()
}
}
} | [
"func",
"(",
"s",
"*",
"Scheduler",
")",
"RunPending",
"(",
")",
"{",
"runnableJobs",
",",
"n",
":=",
"s",
".",
"getRunnableJobs",
"(",
")",
"\n\n",
"if",
"n",
"!=",
"0",
"{",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"n",
";",
"i",
"++",
"{",
"r... | // Run all the jobs that are scheduled to run. | [
"Run",
"all",
"the",
"jobs",
"that",
"are",
"scheduled",
"to",
"run",
"."
] | 5bcdd9fcfa9bf10574722841a11ccb2a57866dc8 | https://github.com/jasonlvhit/gocron/blob/5bcdd9fcfa9bf10574722841a11ccb2a57866dc8/gocron.go#L430-L438 |
26,914 | jasonlvhit/gocron | gocron.go | RunAll | func (s *Scheduler) RunAll() {
for i := 0; i < s.size; i++ {
s.jobs[i].run()
}
} | go | func (s *Scheduler) RunAll() {
for i := 0; i < s.size; i++ {
s.jobs[i].run()
}
} | [
"func",
"(",
"s",
"*",
"Scheduler",
")",
"RunAll",
"(",
")",
"{",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"s",
".",
"size",
";",
"i",
"++",
"{",
"s",
".",
"jobs",
"[",
"i",
"]",
".",
"run",
"(",
")",
"\n",
"}",
"\n",
"}"
] | // Run all jobs regardless if they are scheduled to run or not | [
"Run",
"all",
"jobs",
"regardless",
"if",
"they",
"are",
"scheduled",
"to",
"run",
"or",
"not"
] | 5bcdd9fcfa9bf10574722841a11ccb2a57866dc8 | https://github.com/jasonlvhit/gocron/blob/5bcdd9fcfa9bf10574722841a11ccb2a57866dc8/gocron.go#L441-L445 |
26,915 | jasonlvhit/gocron | gocron.go | RunAllwithDelay | func (s *Scheduler) RunAllwithDelay(d int) {
for i := 0; i < s.size; i++ {
s.jobs[i].run()
time.Sleep(time.Duration(d))
}
} | go | func (s *Scheduler) RunAllwithDelay(d int) {
for i := 0; i < s.size; i++ {
s.jobs[i].run()
time.Sleep(time.Duration(d))
}
} | [
"func",
"(",
"s",
"*",
"Scheduler",
")",
"RunAllwithDelay",
"(",
"d",
"int",
")",
"{",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"s",
".",
"size",
";",
"i",
"++",
"{",
"s",
".",
"jobs",
"[",
"i",
"]",
".",
"run",
"(",
")",
"\n",
"time",
".",
... | // Run all jobs with delay seconds | [
"Run",
"all",
"jobs",
"with",
"delay",
"seconds"
] | 5bcdd9fcfa9bf10574722841a11ccb2a57866dc8 | https://github.com/jasonlvhit/gocron/blob/5bcdd9fcfa9bf10574722841a11ccb2a57866dc8/gocron.go#L448-L453 |
26,916 | jasonlvhit/gocron | gocron.go | Remove | func (s *Scheduler) Remove(j interface{}) {
i := 0
found := false
for ; i < s.size; i++ {
if s.jobs[i].jobFunc == getFunctionName(j) {
found = true
break
}
}
if !found {
return
}
for j := (i + 1); j < s.size; j++ {
s.jobs[i] = s.jobs[j]
i++
}
s.size = s.size - 1
} | go | func (s *Scheduler) Remove(j interface{}) {
i := 0
found := false
for ; i < s.size; i++ {
if s.jobs[i].jobFunc == getFunctionName(j) {
found = true
break
}
}
if !found {
return
}
for j := (i + 1); j < s.size; j++ {
s.jobs[i] = s.jobs[j]
i++
}
s.size = s.size - 1
} | [
"func",
"(",
"s",
"*",
"Scheduler",
")",
"Remove",
"(",
"j",
"interface",
"{",
"}",
")",
"{",
"i",
":=",
"0",
"\n",
"found",
":=",
"false",
"\n\n",
"for",
";",
"i",
"<",
"s",
".",
"size",
";",
"i",
"++",
"{",
"if",
"s",
".",
"jobs",
"[",
"i... | // Remove specific job j | [
"Remove",
"specific",
"job",
"j"
] | 5bcdd9fcfa9bf10574722841a11ccb2a57866dc8 | https://github.com/jasonlvhit/gocron/blob/5bcdd9fcfa9bf10574722841a11ccb2a57866dc8/gocron.go#L456-L476 |
26,917 | jasonlvhit/gocron | gocron.go | Clear | func (s *Scheduler) Clear() {
for i := 0; i < s.size; i++ {
s.jobs[i] = nil
}
s.size = 0
} | go | func (s *Scheduler) Clear() {
for i := 0; i < s.size; i++ {
s.jobs[i] = nil
}
s.size = 0
} | [
"func",
"(",
"s",
"*",
"Scheduler",
")",
"Clear",
"(",
")",
"{",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"s",
".",
"size",
";",
"i",
"++",
"{",
"s",
".",
"jobs",
"[",
"i",
"]",
"=",
"nil",
"\n",
"}",
"\n",
"s",
".",
"size",
"=",
"0",
"\n"... | // Delete all scheduled jobs | [
"Delete",
"all",
"scheduled",
"jobs"
] | 5bcdd9fcfa9bf10574722841a11ccb2a57866dc8 | https://github.com/jasonlvhit/gocron/blob/5bcdd9fcfa9bf10574722841a11ccb2a57866dc8/gocron.go#L479-L484 |
26,918 | jasonlvhit/gocron | gocron.go | Start | func (s *Scheduler) Start() chan bool {
stopped := make(chan bool, 1)
ticker := time.NewTicker(1 * time.Second)
go func() {
for {
select {
case <-ticker.C:
s.RunPending()
case <-stopped:
return
}
}
}()
return stopped
} | go | func (s *Scheduler) Start() chan bool {
stopped := make(chan bool, 1)
ticker := time.NewTicker(1 * time.Second)
go func() {
for {
select {
case <-ticker.C:
s.RunPending()
case <-stopped:
return
}
}
}()
return stopped
} | [
"func",
"(",
"s",
"*",
"Scheduler",
")",
"Start",
"(",
")",
"chan",
"bool",
"{",
"stopped",
":=",
"make",
"(",
"chan",
"bool",
",",
"1",
")",
"\n",
"ticker",
":=",
"time",
".",
"NewTicker",
"(",
"1",
"*",
"time",
".",
"Second",
")",
"\n\n",
"go",... | // Start all the pending jobs
// Add seconds ticker | [
"Start",
"all",
"the",
"pending",
"jobs",
"Add",
"seconds",
"ticker"
] | 5bcdd9fcfa9bf10574722841a11ccb2a57866dc8 | https://github.com/jasonlvhit/gocron/blob/5bcdd9fcfa9bf10574722841a11ccb2a57866dc8/gocron.go#L488-L504 |
26,919 | hyperledger/burrow | acm/acmstate/state.go | GlobalAccountPermissions | func GlobalAccountPermissions(getter AccountGetter) permission.AccountPermissions {
if getter == nil {
return permission.AccountPermissions{
Roles: []string{},
}
}
return GlobalPermissionsAccount(getter).Permissions
} | go | func GlobalAccountPermissions(getter AccountGetter) permission.AccountPermissions {
if getter == nil {
return permission.AccountPermissions{
Roles: []string{},
}
}
return GlobalPermissionsAccount(getter).Permissions
} | [
"func",
"GlobalAccountPermissions",
"(",
"getter",
"AccountGetter",
")",
"permission",
".",
"AccountPermissions",
"{",
"if",
"getter",
"==",
"nil",
"{",
"return",
"permission",
".",
"AccountPermissions",
"{",
"Roles",
":",
"[",
"]",
"string",
"{",
"}",
",",
"}... | // Get global permissions from the account at GlobalPermissionsAddress | [
"Get",
"global",
"permissions",
"from",
"the",
"account",
"at",
"GlobalPermissionsAddress"
] | 59993f5aad71a8e16ab6ed4e57e138e2398eae4e | https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/acm/acmstate/state.go#L108-L115 |
26,920 | hyperledger/burrow | execution/state/accounts.go | GetAccount | func (s *ReadState) GetAccount(address crypto.Address) (*acm.Account, error) {
tree, err := s.Forest.Reader(keys.Account.Prefix())
if err != nil {
return nil, err
}
accBytes := tree.Get(keys.Account.KeyNoPrefix(address))
if accBytes == nil {
return nil, nil
}
return acm.Decode(accBytes)
} | go | func (s *ReadState) GetAccount(address crypto.Address) (*acm.Account, error) {
tree, err := s.Forest.Reader(keys.Account.Prefix())
if err != nil {
return nil, err
}
accBytes := tree.Get(keys.Account.KeyNoPrefix(address))
if accBytes == nil {
return nil, nil
}
return acm.Decode(accBytes)
} | [
"func",
"(",
"s",
"*",
"ReadState",
")",
"GetAccount",
"(",
"address",
"crypto",
".",
"Address",
")",
"(",
"*",
"acm",
".",
"Account",
",",
"error",
")",
"{",
"tree",
",",
"err",
":=",
"s",
".",
"Forest",
".",
"Reader",
"(",
"keys",
".",
"Account",... | // Returns nil if account does not exist with given address. | [
"Returns",
"nil",
"if",
"account",
"does",
"not",
"exist",
"with",
"given",
"address",
"."
] | 59993f5aad71a8e16ab6ed4e57e138e2398eae4e | https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/execution/state/accounts.go#L13-L23 |
26,921 | hyperledger/burrow | execution/state/validators.go | LoadValidatorRing | func LoadValidatorRing(version int64, ringSize int,
getImmutable func(version int64) (*storage.ImmutableForest, error)) (*validator.Ring, error) {
// In this method we have to page through previous version of the tree in order to reconstruct the in-memory
// ring structure. The corner cases are a little subtle but ... | go | func LoadValidatorRing(version int64, ringSize int,
getImmutable func(version int64) (*storage.ImmutableForest, error)) (*validator.Ring, error) {
// In this method we have to page through previous version of the tree in order to reconstruct the in-memory
// ring structure. The corner cases are a little subtle but ... | [
"func",
"LoadValidatorRing",
"(",
"version",
"int64",
",",
"ringSize",
"int",
",",
"getImmutable",
"func",
"(",
"version",
"int64",
")",
"(",
"*",
"storage",
".",
"ImmutableForest",
",",
"error",
")",
")",
"(",
"*",
"validator",
".",
"Ring",
",",
"error",
... | // Initialises the validator Ring from the validator storage in forest | [
"Initialises",
"the",
"validator",
"Ring",
"from",
"the",
"validator",
"storage",
"in",
"forest"
] | 59993f5aad71a8e16ab6ed4e57e138e2398eae4e | https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/execution/state/validators.go#L15-L77 |
26,922 | hyperledger/burrow | storage/key_format.go | ScanBytes | func (kf *KeyFormat) ScanBytes(key []byte) [][]byte {
segments := make([][]byte, len(kf.layout))
n := kf.prefix.Length()
for i, l := range kf.layout {
if l == 0 {
// Must be final variadic segment
segments[i] = key[n:]
return segments
}
n += l
if n > len(key) {
return segments[:i]
}
segments[... | go | func (kf *KeyFormat) ScanBytes(key []byte) [][]byte {
segments := make([][]byte, len(kf.layout))
n := kf.prefix.Length()
for i, l := range kf.layout {
if l == 0 {
// Must be final variadic segment
segments[i] = key[n:]
return segments
}
n += l
if n > len(key) {
return segments[:i]
}
segments[... | [
"func",
"(",
"kf",
"*",
"KeyFormat",
")",
"ScanBytes",
"(",
"key",
"[",
"]",
"byte",
")",
"[",
"]",
"[",
"]",
"byte",
"{",
"segments",
":=",
"make",
"(",
"[",
"]",
"[",
"]",
"byte",
",",
"len",
"(",
"kf",
".",
"layout",
")",
")",
"\n",
"n",
... | // Reads out the bytes associated with each segment of the key format from key. | [
"Reads",
"out",
"the",
"bytes",
"associated",
"with",
"each",
"segment",
"of",
"the",
"key",
"format",
"from",
"key",
"."
] | 59993f5aad71a8e16ab6ed4e57e138e2398eae4e | https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/storage/key_format.go#L111-L127 |
26,923 | hyperledger/burrow | storage/key_format.go | ScanNoPrefix | func (kf *KeyFormat) ScanNoPrefix(key []byte, args ...interface{}) error {
// Just pad by the length of the prefix
paddedKey := make([]byte, len(kf.prefix)+len(key))
copy(paddedKey[len(kf.prefix):], key)
return kf.Scan(paddedKey, args...)
} | go | func (kf *KeyFormat) ScanNoPrefix(key []byte, args ...interface{}) error {
// Just pad by the length of the prefix
paddedKey := make([]byte, len(kf.prefix)+len(key))
copy(paddedKey[len(kf.prefix):], key)
return kf.Scan(paddedKey, args...)
} | [
"func",
"(",
"kf",
"*",
"KeyFormat",
")",
"ScanNoPrefix",
"(",
"key",
"[",
"]",
"byte",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"error",
"{",
"// Just pad by the length of the prefix",
"paddedKey",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"len",
... | // Like Scan but adds expects a key with the KeyFormat's prefix trimmed | [
"Like",
"Scan",
"but",
"adds",
"expects",
"a",
"key",
"with",
"the",
"KeyFormat",
"s",
"prefix",
"trimmed"
] | 59993f5aad71a8e16ab6ed4e57e138e2398eae4e | https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/storage/key_format.go#L149-L154 |
26,924 | hyperledger/burrow | storage/key_format.go | KeyNoPrefix | func (kf *KeyFormat) KeyNoPrefix(args ...interface{}) (Prefix, error) {
key, err := kf.Key(args...)
if err != nil {
return nil, err
}
return key[len(kf.prefix):], nil
} | go | func (kf *KeyFormat) KeyNoPrefix(args ...interface{}) (Prefix, error) {
key, err := kf.Key(args...)
if err != nil {
return nil, err
}
return key[len(kf.prefix):], nil
} | [
"func",
"(",
"kf",
"*",
"KeyFormat",
")",
"KeyNoPrefix",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"(",
"Prefix",
",",
"error",
")",
"{",
"key",
",",
"err",
":=",
"kf",
".",
"Key",
"(",
"args",
"...",
")",
"\n",
"if",
"err",
"!=",
"nil",
... | // Like Key but removes the prefix string | [
"Like",
"Key",
"but",
"removes",
"the",
"prefix",
"string"
] | 59993f5aad71a8e16ab6ed4e57e138e2398eae4e | https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/storage/key_format.go#L157-L163 |
26,925 | hyperledger/burrow | storage/key_format.go | Fix | func (kf *KeyFormat) Fix(args ...interface{}) (*KeyFormat, error) {
key, err := kf.Key(args...)
if err != nil {
return nil, err
}
return NewKeyFormat(string(key), kf.layout[len(args):]...)
} | go | func (kf *KeyFormat) Fix(args ...interface{}) (*KeyFormat, error) {
key, err := kf.Key(args...)
if err != nil {
return nil, err
}
return NewKeyFormat(string(key), kf.layout[len(args):]...)
} | [
"func",
"(",
"kf",
"*",
"KeyFormat",
")",
"Fix",
"(",
"args",
"...",
"interface",
"{",
"}",
")",
"(",
"*",
"KeyFormat",
",",
"error",
")",
"{",
"key",
",",
"err",
":=",
"kf",
".",
"Key",
"(",
"args",
"...",
")",
"\n",
"if",
"err",
"!=",
"nil",
... | // Fixes the first args many segments as the prefix of a new KeyFormat by using the args to generate a key that becomes
// that prefix. Any remaining unassigned segments become the layout of the new KeyFormat. | [
"Fixes",
"the",
"first",
"args",
"many",
"segments",
"as",
"the",
"prefix",
"of",
"a",
"new",
"KeyFormat",
"by",
"using",
"the",
"args",
"to",
"generate",
"a",
"key",
"that",
"becomes",
"that",
"prefix",
".",
"Any",
"remaining",
"unassigned",
"segments",
"... | 59993f5aad71a8e16ab6ed4e57e138e2398eae4e | https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/storage/key_format.go#L167-L173 |
26,926 | hyperledger/burrow | storage/key_format.go | Iterator | func (kf *KeyFormat) Iterator(iterable KVIterable, start, end []byte, reverse ...bool) KVIterator {
if len(reverse) > 0 && reverse[0] {
return kf.prefix.Iterator(iterable.ReverseIterator, start, end)
}
return kf.prefix.Iterator(iterable.Iterator, start, end)
} | go | func (kf *KeyFormat) Iterator(iterable KVIterable, start, end []byte, reverse ...bool) KVIterator {
if len(reverse) > 0 && reverse[0] {
return kf.prefix.Iterator(iterable.ReverseIterator, start, end)
}
return kf.prefix.Iterator(iterable.Iterator, start, end)
} | [
"func",
"(",
"kf",
"*",
"KeyFormat",
")",
"Iterator",
"(",
"iterable",
"KVIterable",
",",
"start",
",",
"end",
"[",
"]",
"byte",
",",
"reverse",
"...",
"bool",
")",
"KVIterator",
"{",
"if",
"len",
"(",
"reverse",
")",
">",
"0",
"&&",
"reverse",
"[",
... | // Returns an iterator over the underlying iterable using this KeyFormat's prefix. This is to support proper iteration over the
// prefix in the presence of nil start or end which requests iteration to the inclusive edges of the domain. An optional
// argument for reverse can be passed to get reverse iteration. | [
"Returns",
"an",
"iterator",
"over",
"the",
"underlying",
"iterable",
"using",
"this",
"KeyFormat",
"s",
"prefix",
".",
"This",
"is",
"to",
"support",
"proper",
"iteration",
"over",
"the",
"prefix",
"in",
"the",
"presence",
"of",
"nil",
"start",
"or",
"end",... | 59993f5aad71a8e16ab6ed4e57e138e2398eae4e | https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/storage/key_format.go#L178-L183 |
26,927 | hyperledger/burrow | vent/service/server.go | NewServer | func NewServer(cfg *config.VentConfig, log *logger.Logger, consumer *Consumer) *Server {
// setup handlers
mux := http.NewServeMux()
mux.HandleFunc("/health", healthHandler(consumer))
return &Server{
Config: cfg,
Log: log,
Consumer: consumer,
mux: mux,
stopCh: make(chan bool, 1),
}
} | go | func NewServer(cfg *config.VentConfig, log *logger.Logger, consumer *Consumer) *Server {
// setup handlers
mux := http.NewServeMux()
mux.HandleFunc("/health", healthHandler(consumer))
return &Server{
Config: cfg,
Log: log,
Consumer: consumer,
mux: mux,
stopCh: make(chan bool, 1),
}
} | [
"func",
"NewServer",
"(",
"cfg",
"*",
"config",
".",
"VentConfig",
",",
"log",
"*",
"logger",
".",
"Logger",
",",
"consumer",
"*",
"Consumer",
")",
"*",
"Server",
"{",
"// setup handlers",
"mux",
":=",
"http",
".",
"NewServeMux",
"(",
")",
"\n\n",
"mux",... | // NewServer returns a new HTTP server | [
"NewServer",
"returns",
"a",
"new",
"HTTP",
"server"
] | 59993f5aad71a8e16ab6ed4e57e138e2398eae4e | https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/vent/service/server.go#L21-L34 |
26,928 | hyperledger/burrow | vent/service/server.go | Run | func (s *Server) Run() {
s.Log.Info("msg", "Starting HTTP Server")
// start http server
httpServer := &http.Server{Addr: s.Config.HTTPAddr, Handler: s}
go func() {
s.Log.Info("msg", "HTTP Server listening", "address", s.Config.HTTPAddr)
httpServer.ListenAndServe()
}()
// wait for stop signal
<-s.stopCh
... | go | func (s *Server) Run() {
s.Log.Info("msg", "Starting HTTP Server")
// start http server
httpServer := &http.Server{Addr: s.Config.HTTPAddr, Handler: s}
go func() {
s.Log.Info("msg", "HTTP Server listening", "address", s.Config.HTTPAddr)
httpServer.ListenAndServe()
}()
// wait for stop signal
<-s.stopCh
... | [
"func",
"(",
"s",
"*",
"Server",
")",
"Run",
"(",
")",
"{",
"s",
".",
"Log",
".",
"Info",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n\n",
"// start http server",
"httpServer",
":=",
"&",
"http",
".",
"Server",
"{",
"Addr",
":",
"s",
".",
"Config",... | // Run starts the HTTP server | [
"Run",
"starts",
"the",
"HTTP",
"server"
] | 59993f5aad71a8e16ab6ed4e57e138e2398eae4e | https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/vent/service/server.go#L37-L54 |
26,929 | hyperledger/burrow | vent/service/server.go | ServeHTTP | func (s *Server) ServeHTTP(resp http.ResponseWriter, req *http.Request) {
s.mux.ServeHTTP(resp, req)
} | go | func (s *Server) ServeHTTP(resp http.ResponseWriter, req *http.Request) {
s.mux.ServeHTTP(resp, req)
} | [
"func",
"(",
"s",
"*",
"Server",
")",
"ServeHTTP",
"(",
"resp",
"http",
".",
"ResponseWriter",
",",
"req",
"*",
"http",
".",
"Request",
")",
"{",
"s",
".",
"mux",
".",
"ServeHTTP",
"(",
"resp",
",",
"req",
")",
"\n",
"}"
] | // ServeHTTP dispatches the HTTP requests using the Server Mux | [
"ServeHTTP",
"dispatches",
"the",
"HTTP",
"requests",
"using",
"the",
"Server",
"Mux"
] | 59993f5aad71a8e16ab6ed4e57e138e2398eae4e | https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/vent/service/server.go#L57-L59 |
26,930 | hyperledger/burrow | vent/service/rowbuilder.go | buildEventData | func buildEventData(projection *sqlsol.Projection, eventClass *types.EventClass, event *exec.Event, abiSpec *abi.AbiSpec,
l *logger.Logger) (types.EventDataRow, error) {
// a fresh new row to store column/value data
row := make(map[string]interface{})
// get header & log data for the given event
eventHeader := e... | go | func buildEventData(projection *sqlsol.Projection, eventClass *types.EventClass, event *exec.Event, abiSpec *abi.AbiSpec,
l *logger.Logger) (types.EventDataRow, error) {
// a fresh new row to store column/value data
row := make(map[string]interface{})
// get header & log data for the given event
eventHeader := e... | [
"func",
"buildEventData",
"(",
"projection",
"*",
"sqlsol",
".",
"Projection",
",",
"eventClass",
"*",
"types",
".",
"EventClass",
",",
"event",
"*",
"exec",
".",
"Event",
",",
"abiSpec",
"*",
"abi",
".",
"AbiSpec",
",",
"l",
"*",
"logger",
".",
"Logger"... | // buildEventData builds event data from transactions | [
"buildEventData",
"builds",
"event",
"data",
"from",
"transactions"
] | 59993f5aad71a8e16ab6ed4e57e138e2398eae4e | https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/vent/service/rowbuilder.go#L19-L67 |
26,931 | hyperledger/burrow | vent/service/rowbuilder.go | buildBlkData | func buildBlkData(tbls types.EventTables, block *exec.BlockExecution) (types.EventDataRow, error) {
// a fresh new row to store column/value data
row := make(map[string]interface{})
// block raw data
if _, ok := tbls[types.SQLBlockTableName]; ok {
blockHeader, err := json.Marshal(block.Header)
if err != nil {
... | go | func buildBlkData(tbls types.EventTables, block *exec.BlockExecution) (types.EventDataRow, error) {
// a fresh new row to store column/value data
row := make(map[string]interface{})
// block raw data
if _, ok := tbls[types.SQLBlockTableName]; ok {
blockHeader, err := json.Marshal(block.Header)
if err != nil {
... | [
"func",
"buildBlkData",
"(",
"tbls",
"types",
".",
"EventTables",
",",
"block",
"*",
"exec",
".",
"BlockExecution",
")",
"(",
"types",
".",
"EventDataRow",
",",
"error",
")",
"{",
"// a fresh new row to store column/value data",
"row",
":=",
"make",
"(",
"map",
... | // buildBlkData builds block data from block stream | [
"buildBlkData",
"builds",
"block",
"data",
"from",
"block",
"stream"
] | 59993f5aad71a8e16ab6ed4e57e138e2398eae4e | https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/vent/service/rowbuilder.go#L70-L88 |
26,932 | hyperledger/burrow | vent/service/rowbuilder.go | buildTxData | func buildTxData(txe *exec.TxExecution) (types.EventDataRow, error) {
// transaction raw data
envelope, err := json.Marshal(txe.Envelope)
if err != nil {
return types.EventDataRow{}, fmt.Errorf("couldn't marshal envelope in tx %v", txe)
}
events, err := json.Marshal(txe.Events)
if err != nil {
return types.E... | go | func buildTxData(txe *exec.TxExecution) (types.EventDataRow, error) {
// transaction raw data
envelope, err := json.Marshal(txe.Envelope)
if err != nil {
return types.EventDataRow{}, fmt.Errorf("couldn't marshal envelope in tx %v", txe)
}
events, err := json.Marshal(txe.Events)
if err != nil {
return types.E... | [
"func",
"buildTxData",
"(",
"txe",
"*",
"exec",
".",
"TxExecution",
")",
"(",
"types",
".",
"EventDataRow",
",",
"error",
")",
"{",
"// transaction raw data",
"envelope",
",",
"err",
":=",
"json",
".",
"Marshal",
"(",
"txe",
".",
"Envelope",
")",
"\n",
"... | // buildTxData builds transaction data from tx stream | [
"buildTxData",
"builds",
"transaction",
"data",
"from",
"tx",
"stream"
] | 59993f5aad71a8e16ab6ed4e57e138e2398eae4e | https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/vent/service/rowbuilder.go#L91-L131 |
26,933 | hyperledger/burrow | event/pubsub/pubsub.go | NewServer | func NewServer(options ...Option) *Server {
s := &Server{
subscriptions: make(map[string]map[string]query.Query),
}
s.BaseService = *common.NewBaseService(nil, "PubSub", s)
for _, option := range options {
option(s)
}
// if BufferCapacity option was not set, the channel is unbuffered
s.cmds = make(chan cmd... | go | func NewServer(options ...Option) *Server {
s := &Server{
subscriptions: make(map[string]map[string]query.Query),
}
s.BaseService = *common.NewBaseService(nil, "PubSub", s)
for _, option := range options {
option(s)
}
// if BufferCapacity option was not set, the channel is unbuffered
s.cmds = make(chan cmd... | [
"func",
"NewServer",
"(",
"options",
"...",
"Option",
")",
"*",
"Server",
"{",
"s",
":=",
"&",
"Server",
"{",
"subscriptions",
":",
"make",
"(",
"map",
"[",
"string",
"]",
"map",
"[",
"string",
"]",
"query",
".",
"Query",
")",
",",
"}",
"\n",
"s",
... | // NewServer returns a new server. See the commentary on the Option functions
// for a detailed description of how to configure buffering. If no options are
// provided, the resulting server's queue is unbuffered. | [
"NewServer",
"returns",
"a",
"new",
"server",
".",
"See",
"the",
"commentary",
"on",
"the",
"Option",
"functions",
"for",
"a",
"detailed",
"description",
"of",
"how",
"to",
"configure",
"buffering",
".",
"If",
"no",
"options",
"are",
"provided",
"the",
"resu... | 59993f5aad71a8e16ab6ed4e57e138e2398eae4e | https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/event/pubsub/pubsub.go#L71-L85 |
26,934 | hyperledger/burrow | event/pubsub/pubsub.go | Subscribe | func (s *Server) Subscribe(ctx context.Context, clientID string, qry query.Query, outBuffer int) (<-chan interface{}, error) {
s.mtx.RLock()
clientSubscriptions, ok := s.subscriptions[clientID]
if ok {
_, ok = clientSubscriptions[qry.String()]
}
s.mtx.RUnlock()
if ok {
return nil, ErrAlreadySubscribed
}
// ... | go | func (s *Server) Subscribe(ctx context.Context, clientID string, qry query.Query, outBuffer int) (<-chan interface{}, error) {
s.mtx.RLock()
clientSubscriptions, ok := s.subscriptions[clientID]
if ok {
_, ok = clientSubscriptions[qry.String()]
}
s.mtx.RUnlock()
if ok {
return nil, ErrAlreadySubscribed
}
// ... | [
"func",
"(",
"s",
"*",
"Server",
")",
"Subscribe",
"(",
"ctx",
"context",
".",
"Context",
",",
"clientID",
"string",
",",
"qry",
"query",
".",
"Query",
",",
"outBuffer",
"int",
")",
"(",
"<-",
"chan",
"interface",
"{",
"}",
",",
"error",
")",
"{",
... | // Subscribe creates a subscription for the given client. It accepts a channel
// on which messages matching the given query can be received. An error will be
// returned to the caller if the context is canceled or if subscription already
// exist for pair clientID and query. | [
"Subscribe",
"creates",
"a",
"subscription",
"for",
"the",
"given",
"client",
".",
"It",
"accepts",
"a",
"channel",
"on",
"which",
"messages",
"matching",
"the",
"given",
"query",
"can",
"be",
"received",
".",
"An",
"error",
"will",
"be",
"returned",
"to",
... | 59993f5aad71a8e16ab6ed4e57e138e2398eae4e | https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/event/pubsub/pubsub.go#L108-L134 |
26,935 | hyperledger/burrow | event/pubsub/pubsub.go | Publish | func (s *Server) Publish(ctx context.Context, msg interface{}) error {
return s.PublishWithTags(ctx, msg, query.TagMap(make(map[string]interface{})))
} | go | func (s *Server) Publish(ctx context.Context, msg interface{}) error {
return s.PublishWithTags(ctx, msg, query.TagMap(make(map[string]interface{})))
} | [
"func",
"(",
"s",
"*",
"Server",
")",
"Publish",
"(",
"ctx",
"context",
".",
"Context",
",",
"msg",
"interface",
"{",
"}",
")",
"error",
"{",
"return",
"s",
".",
"PublishWithTags",
"(",
"ctx",
",",
"msg",
",",
"query",
".",
"TagMap",
"(",
"make",
"... | // Publish publishes the given message. An error will be returned to the caller
// if the context is canceled. | [
"Publish",
"publishes",
"the",
"given",
"message",
".",
"An",
"error",
"will",
"be",
"returned",
"to",
"the",
"caller",
"if",
"the",
"context",
"is",
"canceled",
"."
] | 59993f5aad71a8e16ab6ed4e57e138e2398eae4e | https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/event/pubsub/pubsub.go#L186-L188 |
26,936 | hyperledger/burrow | event/pubsub/pubsub.go | PublishWithTags | func (s *Server) PublishWithTags(ctx context.Context, msg interface{}, tags query.Tagged) error {
select {
case s.cmds <- cmd{op: pub, msg: msg, tags: tags}:
return nil
case <-ctx.Done():
return ctx.Err()
}
} | go | func (s *Server) PublishWithTags(ctx context.Context, msg interface{}, tags query.Tagged) error {
select {
case s.cmds <- cmd{op: pub, msg: msg, tags: tags}:
return nil
case <-ctx.Done():
return ctx.Err()
}
} | [
"func",
"(",
"s",
"*",
"Server",
")",
"PublishWithTags",
"(",
"ctx",
"context",
".",
"Context",
",",
"msg",
"interface",
"{",
"}",
",",
"tags",
"query",
".",
"Tagged",
")",
"error",
"{",
"select",
"{",
"case",
"s",
".",
"cmds",
"<-",
"cmd",
"{",
"o... | // PublishWithTags publishes the given message with the set of tags. The set is
// matched with clients queries. If there is a match, the message is sent to
// the client. | [
"PublishWithTags",
"publishes",
"the",
"given",
"message",
"with",
"the",
"set",
"of",
"tags",
".",
"The",
"set",
"is",
"matched",
"with",
"clients",
"queries",
".",
"If",
"there",
"is",
"a",
"match",
"the",
"message",
"is",
"sent",
"to",
"the",
"client",
... | 59993f5aad71a8e16ab6ed4e57e138e2398eae4e | https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/event/pubsub/pubsub.go#L193-L200 |
26,937 | hyperledger/burrow | logging/loggers/sort_logger.go | SortLogger | func SortLogger(outputLogger log.Logger, keys ...string) log.Logger {
indices := make(map[string]int, len(keys))
for i, k := range keys {
indices[k] = i
}
return log.LoggerFunc(func(keyvals ...interface{}) error {
sortKeyvals(indices, keyvals)
return outputLogger.Log(keyvals...)
})
} | go | func SortLogger(outputLogger log.Logger, keys ...string) log.Logger {
indices := make(map[string]int, len(keys))
for i, k := range keys {
indices[k] = i
}
return log.LoggerFunc(func(keyvals ...interface{}) error {
sortKeyvals(indices, keyvals)
return outputLogger.Log(keyvals...)
})
} | [
"func",
"SortLogger",
"(",
"outputLogger",
"log",
".",
"Logger",
",",
"keys",
"...",
"string",
")",
"log",
".",
"Logger",
"{",
"indices",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"int",
",",
"len",
"(",
"keys",
")",
")",
"\n",
"for",
"i",
",",... | // Provides a logger that sorts key-values with keys in keys before other key-values | [
"Provides",
"a",
"logger",
"that",
"sorts",
"key",
"-",
"values",
"with",
"keys",
"in",
"keys",
"before",
"other",
"key",
"-",
"values"
] | 59993f5aad71a8e16ab6ed4e57e138e2398eae4e | https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/logging/loggers/sort_logger.go#L63-L72 |
26,938 | hyperledger/burrow | permission/account_permissions.go | HasRole | func (ap AccountPermissions) HasRole(role string) bool {
role = string(binary.RightPadBytes([]byte(role), 32))
for _, r := range ap.Roles {
if r == role {
return true
}
}
return false
} | go | func (ap AccountPermissions) HasRole(role string) bool {
role = string(binary.RightPadBytes([]byte(role), 32))
for _, r := range ap.Roles {
if r == role {
return true
}
}
return false
} | [
"func",
"(",
"ap",
"AccountPermissions",
")",
"HasRole",
"(",
"role",
"string",
")",
"bool",
"{",
"role",
"=",
"string",
"(",
"binary",
".",
"RightPadBytes",
"(",
"[",
"]",
"byte",
"(",
"role",
")",
",",
"32",
")",
")",
"\n",
"for",
"_",
",",
"r",
... | // Returns true if the role is found | [
"Returns",
"true",
"if",
"the",
"role",
"is",
"found"
] | 59993f5aad71a8e16ab6ed4e57e138e2398eae4e | https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/permission/account_permissions.go#L19-L27 |
26,939 | hyperledger/burrow | permission/account_permissions.go | RemoveRole | func (ap *AccountPermissions) RemoveRole(role string) bool {
role = string(binary.RightPadBytes([]byte(role), 32))
for i, r := range ap.Roles {
if r == role {
post := []string{}
if len(ap.Roles) > i+1 {
post = ap.Roles[i+1:]
}
ap.Roles = append(ap.Roles[:i], post...)
return true
}
}
return fa... | go | func (ap *AccountPermissions) RemoveRole(role string) bool {
role = string(binary.RightPadBytes([]byte(role), 32))
for i, r := range ap.Roles {
if r == role {
post := []string{}
if len(ap.Roles) > i+1 {
post = ap.Roles[i+1:]
}
ap.Roles = append(ap.Roles[:i], post...)
return true
}
}
return fa... | [
"func",
"(",
"ap",
"*",
"AccountPermissions",
")",
"RemoveRole",
"(",
"role",
"string",
")",
"bool",
"{",
"role",
"=",
"string",
"(",
"binary",
".",
"RightPadBytes",
"(",
"[",
"]",
"byte",
"(",
"role",
")",
",",
"32",
")",
")",
"\n",
"for",
"i",
",... | // Returns true if the role is removed, and false if it is not found | [
"Returns",
"true",
"if",
"the",
"role",
"is",
"removed",
"and",
"false",
"if",
"it",
"is",
"not",
"found"
] | 59993f5aad71a8e16ab6ed4e57e138e2398eae4e | https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/permission/account_permissions.go#L42-L55 |
26,940 | hyperledger/burrow | permission/account_permissions.go | Clone | func (ap *AccountPermissions) Clone() AccountPermissions {
// clone base permissions
basePermissionsClone := ap.Base
var rolesClone []string
// It helps if we normalise empty roles to []string(nil) rather than []string{}
if len(ap.Roles) > 0 {
// clone roles []string
rolesClone = make([]string, len(ap.Roles))
... | go | func (ap *AccountPermissions) Clone() AccountPermissions {
// clone base permissions
basePermissionsClone := ap.Base
var rolesClone []string
// It helps if we normalise empty roles to []string(nil) rather than []string{}
if len(ap.Roles) > 0 {
// clone roles []string
rolesClone = make([]string, len(ap.Roles))
... | [
"func",
"(",
"ap",
"*",
"AccountPermissions",
")",
"Clone",
"(",
")",
"AccountPermissions",
"{",
"// clone base permissions",
"basePermissionsClone",
":=",
"ap",
".",
"Base",
"\n",
"var",
"rolesClone",
"[",
"]",
"string",
"\n",
"// It helps if we normalise empty roles... | // Clone clones the account permissions | [
"Clone",
"clones",
"the",
"account",
"permissions"
] | 59993f5aad71a8e16ab6ed4e57e138e2398eae4e | https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/permission/account_permissions.go#L58-L74 |
26,941 | hyperledger/burrow | txs/envelope.go | RealisePublicKey | func (s *Signatory) RealisePublicKey(getter acmstate.AccountGetter) error {
const errPrefix = "could not realise public key for signatory"
if s.PublicKey == nil {
if s.Address == nil {
return fmt.Errorf("%s: address not provided", errPrefix)
}
acc, err := getter.GetAccount(*s.Address)
if err != nil {
re... | go | func (s *Signatory) RealisePublicKey(getter acmstate.AccountGetter) error {
const errPrefix = "could not realise public key for signatory"
if s.PublicKey == nil {
if s.Address == nil {
return fmt.Errorf("%s: address not provided", errPrefix)
}
acc, err := getter.GetAccount(*s.Address)
if err != nil {
re... | [
"func",
"(",
"s",
"*",
"Signatory",
")",
"RealisePublicKey",
"(",
"getter",
"acmstate",
".",
"AccountGetter",
")",
"error",
"{",
"const",
"errPrefix",
"=",
"\"",
"\"",
"\n",
"if",
"s",
".",
"PublicKey",
"==",
"nil",
"{",
"if",
"s",
".",
"Address",
"=="... | // Attempts to 'realise' the PublicKey and Address of a Signatory possibly referring to state
// in the case where the Signatory contains an Address by no PublicKey. Checks consistency in other
// cases, possibly generating the Address from the PublicKey | [
"Attempts",
"to",
"realise",
"the",
"PublicKey",
"and",
"Address",
"of",
"a",
"Signatory",
"possibly",
"referring",
"to",
"state",
"in",
"the",
"case",
"where",
"the",
"Signatory",
"contains",
"an",
"Address",
"by",
"no",
"PublicKey",
".",
"Checks",
"consisten... | 59993f5aad71a8e16ab6ed4e57e138e2398eae4e | https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/txs/envelope.go#L41-L65 |
26,942 | hyperledger/burrow | vent/types/event_class.go | Validate | func (ec *EventClass) Validate() error {
return validation.ValidateStruct(ec,
validation.Field(&ec.TableName, validation.Required, validation.Length(1, 60)),
validation.Field(&ec.Filter, validation.Required),
validation.Field(&ec.FieldMappings, validation.Required, validation.Length(1, 0)),
)
} | go | func (ec *EventClass) Validate() error {
return validation.ValidateStruct(ec,
validation.Field(&ec.TableName, validation.Required, validation.Length(1, 60)),
validation.Field(&ec.Filter, validation.Required),
validation.Field(&ec.FieldMappings, validation.Required, validation.Length(1, 0)),
)
} | [
"func",
"(",
"ec",
"*",
"EventClass",
")",
"Validate",
"(",
")",
"error",
"{",
"return",
"validation",
".",
"ValidateStruct",
"(",
"ec",
",",
"validation",
".",
"Field",
"(",
"&",
"ec",
".",
"TableName",
",",
"validation",
".",
"Required",
",",
"validati... | // Validate checks the structure of an EventClass | [
"Validate",
"checks",
"the",
"structure",
"of",
"an",
"EventClass"
] | 59993f5aad71a8e16ab6ed4e57e138e2398eae4e | https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/vent/types/event_class.go#L33-L39 |
26,943 | hyperledger/burrow | vent/types/event_class.go | Validate | func (evColumn EventFieldMapping) Validate() error {
return validation.ValidateStruct(&evColumn,
validation.Field(&evColumn.ColumnName, validation.Required, validation.Length(1, 60)),
)
} | go | func (evColumn EventFieldMapping) Validate() error {
return validation.ValidateStruct(&evColumn,
validation.Field(&evColumn.ColumnName, validation.Required, validation.Length(1, 60)),
)
} | [
"func",
"(",
"evColumn",
"EventFieldMapping",
")",
"Validate",
"(",
")",
"error",
"{",
"return",
"validation",
".",
"ValidateStruct",
"(",
"&",
"evColumn",
",",
"validation",
".",
"Field",
"(",
"&",
"evColumn",
".",
"ColumnName",
",",
"validation",
".",
"Req... | // Validate checks the structure of an EventFieldMapping | [
"Validate",
"checks",
"the",
"structure",
"of",
"an",
"EventFieldMapping"
] | 59993f5aad71a8e16ab6ed4e57e138e2398eae4e | https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/vent/types/event_class.go#L88-L92 |
26,944 | hyperledger/burrow | storage/mutable_forest.go | Load | func (muf *MutableForest) Load(version int64) error {
return muf.commitsTree.Load(version, true)
} | go | func (muf *MutableForest) Load(version int64) error {
return muf.commitsTree.Load(version, true)
} | [
"func",
"(",
"muf",
"*",
"MutableForest",
")",
"Load",
"(",
"version",
"int64",
")",
"error",
"{",
"return",
"muf",
".",
"commitsTree",
".",
"Load",
"(",
"version",
",",
"true",
")",
"\n",
"}"
] | // Load mutable forest from database, pass overwriting = true if you wish to make writes to version version + 1.
// this will | [
"Load",
"mutable",
"forest",
"from",
"database",
"pass",
"overwriting",
"=",
"true",
"if",
"you",
"wish",
"to",
"make",
"writes",
"to",
"version",
"version",
"+",
"1",
".",
"this",
"will"
] | 59993f5aad71a8e16ab6ed4e57e138e2398eae4e | https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/storage/mutable_forest.go#L84-L86 |
26,945 | hyperledger/burrow | storage/mutable_forest.go | Writer | func (muf *MutableForest) Writer(prefix []byte) (*RWTree, error) {
// Try dirty cache first (if tree is new it may only be in this location)
prefixString := string(prefix)
if tree, ok := muf.dirty[prefixString]; ok {
return tree, nil
}
tree, err := muf.tree(prefix)
if err != nil {
return nil, err
}
// Mark ... | go | func (muf *MutableForest) Writer(prefix []byte) (*RWTree, error) {
// Try dirty cache first (if tree is new it may only be in this location)
prefixString := string(prefix)
if tree, ok := muf.dirty[prefixString]; ok {
return tree, nil
}
tree, err := muf.tree(prefix)
if err != nil {
return nil, err
}
// Mark ... | [
"func",
"(",
"muf",
"*",
"MutableForest",
")",
"Writer",
"(",
"prefix",
"[",
"]",
"byte",
")",
"(",
"*",
"RWTree",
",",
"error",
")",
"{",
"// Try dirty cache first (if tree is new it may only be in this location)",
"prefixString",
":=",
"string",
"(",
"prefix",
"... | // Calls to writer should be serialised as should writes to the tree | [
"Calls",
"to",
"writer",
"should",
"be",
"serialised",
"as",
"should",
"writes",
"to",
"the",
"tree"
] | 59993f5aad71a8e16ab6ed4e57e138e2398eae4e | https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/storage/mutable_forest.go#L115-L129 |
26,946 | hyperledger/burrow | storage/mutable_forest.go | Delete | func (muf *MutableForest) Delete(prefix []byte) (*CommitID, error) {
bs, removed := muf.commitsTree.Delete(prefix)
if !removed {
return nil, nil
}
return UnmarshalCommitID(bs)
} | go | func (muf *MutableForest) Delete(prefix []byte) (*CommitID, error) {
bs, removed := muf.commitsTree.Delete(prefix)
if !removed {
return nil, nil
}
return UnmarshalCommitID(bs)
} | [
"func",
"(",
"muf",
"*",
"MutableForest",
")",
"Delete",
"(",
"prefix",
"[",
"]",
"byte",
")",
"(",
"*",
"CommitID",
",",
"error",
")",
"{",
"bs",
",",
"removed",
":=",
"muf",
".",
"commitsTree",
".",
"Delete",
"(",
"prefix",
")",
"\n",
"if",
"!",
... | // Delete a tree - if the tree exists will return the CommitID of the latest saved version | [
"Delete",
"a",
"tree",
"-",
"if",
"the",
"tree",
"exists",
"will",
"return",
"the",
"CommitID",
"of",
"the",
"latest",
"saved",
"version"
] | 59993f5aad71a8e16ab6ed4e57e138e2398eae4e | https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/storage/mutable_forest.go#L132-L138 |
26,947 | hyperledger/burrow | logging/loggers/multiple_output_logger.go | NewMultipleOutputLogger | func NewMultipleOutputLogger(outputLoggers ...log.Logger) log.Logger {
moLogger := make(MultipleOutputLogger, 0, len(outputLoggers))
// Flatten any MultipleOutputLoggers
for _, ol := range outputLoggers {
if ls, ok := ol.(MultipleOutputLogger); ok {
moLogger = append(moLogger, ls...)
} else {
moLogger = ap... | go | func NewMultipleOutputLogger(outputLoggers ...log.Logger) log.Logger {
moLogger := make(MultipleOutputLogger, 0, len(outputLoggers))
// Flatten any MultipleOutputLoggers
for _, ol := range outputLoggers {
if ls, ok := ol.(MultipleOutputLogger); ok {
moLogger = append(moLogger, ls...)
} else {
moLogger = ap... | [
"func",
"NewMultipleOutputLogger",
"(",
"outputLoggers",
"...",
"log",
".",
"Logger",
")",
"log",
".",
"Logger",
"{",
"moLogger",
":=",
"make",
"(",
"MultipleOutputLogger",
",",
"0",
",",
"len",
"(",
"outputLoggers",
")",
")",
"\n",
"// Flatten any MultipleOutpu... | // Creates a logger that forks log messages to each of its outputLoggers | [
"Creates",
"a",
"logger",
"that",
"forks",
"log",
"messages",
"to",
"each",
"of",
"its",
"outputLoggers"
] | 59993f5aad71a8e16ab6ed4e57e138e2398eae4e | https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/logging/loggers/multiple_output_logger.go#L40-L51 |
26,948 | hyperledger/burrow | deploy/util/readers.go | ReadTxSignAndBroadcast | func ReadTxSignAndBroadcast(txe *exec.TxExecution, err error, logger *logging.Logger) error {
// if there's an error just return.
if err != nil {
return err
}
// if there is nothing to unpack then just return.
if txe == nil {
return nil
}
// Unpack and display for the user.
height := fmt.Sprintf("%d", txe... | go | func ReadTxSignAndBroadcast(txe *exec.TxExecution, err error, logger *logging.Logger) error {
// if there's an error just return.
if err != nil {
return err
}
// if there is nothing to unpack then just return.
if txe == nil {
return nil
}
// Unpack and display for the user.
height := fmt.Sprintf("%d", txe... | [
"func",
"ReadTxSignAndBroadcast",
"(",
"txe",
"*",
"exec",
".",
"TxExecution",
",",
"err",
"error",
",",
"logger",
"*",
"logging",
".",
"Logger",
")",
"error",
"{",
"// if there's an error just return.",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
... | // This is a closer function which is called by most of the tx_run functions | [
"This",
"is",
"a",
"closer",
"function",
"which",
"is",
"called",
"by",
"most",
"of",
"the",
"tx_run",
"functions"
] | 59993f5aad71a8e16ab6ed4e57e138e2398eae4e | https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/deploy/util/readers.go#L16-L48 |
26,949 | hyperledger/burrow | deploy/util/readers.go | GetBoolResponse | func GetBoolResponse(question string, defaultAnswer bool, reader *os.File, logger *logging.Logger) (bool, error) {
var result bool
readr := bufio.NewReader(reader)
logger.InfoMsg(question)
text, _ := readr.ReadString('\n')
text = strings.Replace(text, "\n", "", 1)
if text == "" {
return defaultAnswer, nil
}
... | go | func GetBoolResponse(question string, defaultAnswer bool, reader *os.File, logger *logging.Logger) (bool, error) {
var result bool
readr := bufio.NewReader(reader)
logger.InfoMsg(question)
text, _ := readr.ReadString('\n')
text = strings.Replace(text, "\n", "", 1)
if text == "" {
return defaultAnswer, nil
}
... | [
"func",
"GetBoolResponse",
"(",
"question",
"string",
",",
"defaultAnswer",
"bool",
",",
"reader",
"*",
"os",
".",
"File",
",",
"logger",
"*",
"logging",
".",
"Logger",
")",
"(",
"bool",
",",
"error",
")",
"{",
"var",
"result",
"bool",
"\n",
"readr",
"... | // displays the question, scans for the response, if the response is an empty
// string will return default, otherwise will parseBool and return the result. | [
"displays",
"the",
"question",
"scans",
"for",
"the",
"response",
"if",
"the",
"response",
"is",
"an",
"empty",
"string",
"will",
"return",
"default",
"otherwise",
"will",
"parseBool",
"and",
"return",
"the",
"result",
"."
] | 59993f5aad71a8e16ab6ed4e57e138e2398eae4e | https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/deploy/util/readers.go#L81-L99 |
26,950 | hyperledger/burrow | execution/proposal/cache.go | Flush | func (cache *Cache) Flush(output Writer, backend Reader) error {
err := cache.Sync(output)
if err != nil {
return err
}
cache.Reset(backend)
return nil
} | go | func (cache *Cache) Flush(output Writer, backend Reader) error {
err := cache.Sync(output)
if err != nil {
return err
}
cache.Reset(backend)
return nil
} | [
"func",
"(",
"cache",
"*",
"Cache",
")",
"Flush",
"(",
"output",
"Writer",
",",
"backend",
"Reader",
")",
"error",
"{",
"err",
":=",
"cache",
".",
"Sync",
"(",
"output",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
... | // Syncs the Cache and Resets it to use Writer as the backend Reader | [
"Syncs",
"the",
"Cache",
"and",
"Resets",
"it",
"to",
"use",
"Writer",
"as",
"the",
"backend",
"Reader"
] | 59993f5aad71a8e16ab6ed4e57e138e2398eae4e | https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/execution/proposal/cache.go#L163-L170 |
26,951 | hyperledger/burrow | vent/config/config.go | DefaultVentConfig | func DefaultVentConfig() *VentConfig {
return &VentConfig{
DBAdapter: types.PostgresDB,
DBURL: DefaultPostgresDBURL,
DBSchema: "vent",
GRPCAddr: "localhost:10997",
HTTPAddr: "0.0.0.0:8080",
LogLevel: "debug",
DBBlockTx: false,
AnnounceEvery: time.Second * 5,
}
} | go | func DefaultVentConfig() *VentConfig {
return &VentConfig{
DBAdapter: types.PostgresDB,
DBURL: DefaultPostgresDBURL,
DBSchema: "vent",
GRPCAddr: "localhost:10997",
HTTPAddr: "0.0.0.0:8080",
LogLevel: "debug",
DBBlockTx: false,
AnnounceEvery: time.Second * 5,
}
} | [
"func",
"DefaultVentConfig",
"(",
")",
"*",
"VentConfig",
"{",
"return",
"&",
"VentConfig",
"{",
"DBAdapter",
":",
"types",
".",
"PostgresDB",
",",
"DBURL",
":",
"DefaultPostgresDBURL",
",",
"DBSchema",
":",
"\"",
"\"",
",",
"GRPCAddr",
":",
"\"",
"\"",
",... | // DefaultFlags returns a configuration with default values | [
"DefaultFlags",
"returns",
"a",
"configuration",
"with",
"default",
"values"
] | 59993f5aad71a8e16ab6ed4e57e138e2398eae4e | https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/vent/config/config.go#L27-L38 |
26,952 | hyperledger/burrow | rpc/metrics/exporter.go | NewExporter | func NewExporter(service InfoService, blockSampleSize int, logger *logging.Logger) (*Exporter, error) {
chainStatus, err := service.Status()
if err != nil {
return nil, fmt.Errorf("NewExporter(): %v", err)
}
return &Exporter{
datum: &Datum{},
service: service,
cha... | go | func NewExporter(service InfoService, blockSampleSize int, logger *logging.Logger) (*Exporter, error) {
chainStatus, err := service.Status()
if err != nil {
return nil, fmt.Errorf("NewExporter(): %v", err)
}
return &Exporter{
datum: &Datum{},
service: service,
cha... | [
"func",
"NewExporter",
"(",
"service",
"InfoService",
",",
"blockSampleSize",
"int",
",",
"logger",
"*",
"logging",
".",
"Logger",
")",
"(",
"*",
"Exporter",
",",
"error",
")",
"{",
"chainStatus",
",",
"err",
":=",
"service",
".",
"Status",
"(",
")",
"\n... | // Exporter uses the InfoService to provide pre-aggregated metrics of various types that are then passed to prometheus
// as Const metrics rather than being accumulated by individual operations throughout the rest of the Burrow code. | [
"Exporter",
"uses",
"the",
"InfoService",
"to",
"provide",
"pre",
"-",
"aggregated",
"metrics",
"of",
"various",
"types",
"that",
"are",
"then",
"passed",
"to",
"prometheus",
"as",
"Const",
"metrics",
"rather",
"than",
"being",
"accumulated",
"by",
"individual",... | 59993f5aad71a8e16ab6ed4e57e138e2398eae4e | https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/rpc/metrics/exporter.go#L77-L92 |
26,953 | hyperledger/burrow | rpc/metrics/exporter.go | Describe | func (e *Exporter) Describe(ch chan<- *prometheus.Desc) {
for _, m := range MetricDescriptions {
ch <- m
}
} | go | func (e *Exporter) Describe(ch chan<- *prometheus.Desc) {
for _, m := range MetricDescriptions {
ch <- m
}
} | [
"func",
"(",
"e",
"*",
"Exporter",
")",
"Describe",
"(",
"ch",
"chan",
"<-",
"*",
"prometheus",
".",
"Desc",
")",
"{",
"for",
"_",
",",
"m",
":=",
"range",
"MetricDescriptions",
"{",
"ch",
"<-",
"m",
"\n",
"}",
"\n",
"}"
] | // Describe - loops through the API metrics and passes them to prometheus.Describe | [
"Describe",
"-",
"loops",
"through",
"the",
"API",
"metrics",
"and",
"passes",
"them",
"to",
"prometheus",
".",
"Describe"
] | 59993f5aad71a8e16ab6ed4e57e138e2398eae4e | https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/rpc/metrics/exporter.go#L95-L99 |
26,954 | hyperledger/burrow | rpc/metrics/exporter.go | gatherData | func (e *Exporter) gatherData() error {
var err error
err = e.getStatus()
if err != nil {
return err
}
err = e.getMemPoolDepth()
if err != nil {
return err
}
err = e.getPeers()
if err != nil {
return err
}
blocks, err := e.getBlocks()
if err != nil {
return err
}
err = e.getTxBuckets(blocks.Block... | go | func (e *Exporter) gatherData() error {
var err error
err = e.getStatus()
if err != nil {
return err
}
err = e.getMemPoolDepth()
if err != nil {
return err
}
err = e.getPeers()
if err != nil {
return err
}
blocks, err := e.getBlocks()
if err != nil {
return err
}
err = e.getTxBuckets(blocks.Block... | [
"func",
"(",
"e",
"*",
"Exporter",
")",
"gatherData",
"(",
")",
"error",
"{",
"var",
"err",
"error",
"\n\n",
"err",
"=",
"e",
".",
"getStatus",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"err",
"=",
"e",
".... | // gatherData - Collects the data from the API and stores into struct | [
"gatherData",
"-",
"Collects",
"the",
"data",
"from",
"the",
"API",
"and",
"stores",
"into",
"struct"
] | 59993f5aad71a8e16ab6ed4e57e138e2398eae4e | https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/rpc/metrics/exporter.go#L181-L211 |
26,955 | hyperledger/burrow | rpc/metrics/exporter.go | getPeers | func (e *Exporter) getPeers() error {
peers := e.service.Peers()
e.datum.TotalPeers = float64(len(peers))
e.datum.InboundPeers = 0
e.datum.OutboundPeers = 0
for _, peer := range peers {
if peer.IsOutbound {
e.datum.OutboundPeers += 1
} else {
e.datum.InboundPeers += 1
}
}
return nil
} | go | func (e *Exporter) getPeers() error {
peers := e.service.Peers()
e.datum.TotalPeers = float64(len(peers))
e.datum.InboundPeers = 0
e.datum.OutboundPeers = 0
for _, peer := range peers {
if peer.IsOutbound {
e.datum.OutboundPeers += 1
} else {
e.datum.InboundPeers += 1
}
}
return nil
} | [
"func",
"(",
"e",
"*",
"Exporter",
")",
"getPeers",
"(",
")",
"error",
"{",
"peers",
":=",
"e",
".",
"service",
".",
"Peers",
"(",
")",
"\n",
"e",
".",
"datum",
".",
"TotalPeers",
"=",
"float64",
"(",
"len",
"(",
"peers",
")",
")",
"\n",
"e",
"... | // Get total peers | [
"Get",
"total",
"peers"
] | 59993f5aad71a8e16ab6ed4e57e138e2398eae4e | https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/rpc/metrics/exporter.go#L234-L249 |
26,956 | hyperledger/burrow | rpc/metrics/exporter.go | getTxBuckets | func (e *Exporter) getTxBuckets(blockMetas []*types.BlockMeta) error {
e.datum.TotalTxs = 0
e.datum.TxPerBlockBuckets = map[float64]uint64{}
if len(blockMetas) == 0 {
return nil
}
// Collect number of txs per block as an array of floats
txsPerBlock := make([]float64, len(blockMetas))
for i, block := range bloc... | go | func (e *Exporter) getTxBuckets(blockMetas []*types.BlockMeta) error {
e.datum.TotalTxs = 0
e.datum.TxPerBlockBuckets = map[float64]uint64{}
if len(blockMetas) == 0 {
return nil
}
// Collect number of txs per block as an array of floats
txsPerBlock := make([]float64, len(blockMetas))
for i, block := range bloc... | [
"func",
"(",
"e",
"*",
"Exporter",
")",
"getTxBuckets",
"(",
"blockMetas",
"[",
"]",
"*",
"types",
".",
"BlockMeta",
")",
"error",
"{",
"e",
".",
"datum",
".",
"TotalTxs",
"=",
"0",
"\n",
"e",
".",
"datum",
".",
"TxPerBlockBuckets",
"=",
"map",
"[",
... | // Get transaction buckets | [
"Get",
"transaction",
"buckets"
] | 59993f5aad71a8e16ab6ed4e57e138e2398eae4e | https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/rpc/metrics/exporter.go#L277-L291 |
26,957 | hyperledger/burrow | event/query/query.go | Conditions | func (q *query) Conditions() []Condition {
conditions := make([]Condition, 0)
buffer, begin, end := q.parser.Buffer, 0, 0
var tag string
var op Operator
// tokens must be in the following order: tag ("tx.gas") -> operator ("=") -> operand ("7")
for _, token := range q.parser.Tokens() {
switch token.pegRule {... | go | func (q *query) Conditions() []Condition {
conditions := make([]Condition, 0)
buffer, begin, end := q.parser.Buffer, 0, 0
var tag string
var op Operator
// tokens must be in the following order: tag ("tx.gas") -> operator ("=") -> operand ("7")
for _, token := range q.parser.Tokens() {
switch token.pegRule {... | [
"func",
"(",
"q",
"*",
"query",
")",
"Conditions",
"(",
")",
"[",
"]",
"Condition",
"{",
"conditions",
":=",
"make",
"(",
"[",
"]",
"Condition",
",",
"0",
")",
"\n\n",
"buffer",
",",
"begin",
",",
"end",
":=",
"q",
".",
"parser",
".",
"Buffer",
"... | // Conditions returns a list of conditions. | [
"Conditions",
"returns",
"a",
"list",
"of",
"conditions",
"."
] | 59993f5aad71a8e16ab6ed4e57e138e2398eae4e | https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/event/query/query.go#L93-L156 |
26,958 | hyperledger/burrow | deploy/def/job.go | PayloadField | func (job *Job) PayloadField() (reflect.Value, error) {
rv := reflect.ValueOf(job).Elem()
rt := rv.Type()
payloadIndex := -1
for i := 0; i < rt.NumField(); i++ {
if rt.Field(i).Type.Implements(payloadType) && !rv.Field(i).IsNil() {
if payloadIndex >= 0 {
return reflect.Value{}, fmt.Errorf("only one Job pa... | go | func (job *Job) PayloadField() (reflect.Value, error) {
rv := reflect.ValueOf(job).Elem()
rt := rv.Type()
payloadIndex := -1
for i := 0; i < rt.NumField(); i++ {
if rt.Field(i).Type.Implements(payloadType) && !rv.Field(i).IsNil() {
if payloadIndex >= 0 {
return reflect.Value{}, fmt.Errorf("only one Job pa... | [
"func",
"(",
"job",
"*",
"Job",
")",
"PayloadField",
"(",
")",
"(",
"reflect",
".",
"Value",
",",
"error",
")",
"{",
"rv",
":=",
"reflect",
".",
"ValueOf",
"(",
"job",
")",
".",
"Elem",
"(",
")",
"\n",
"rt",
":=",
"rv",
".",
"Type",
"(",
")",
... | // Ensures only one Job payload is set and returns a pointer to that field or an error if none or multiple
// job payload fields are set | [
"Ensures",
"only",
"one",
"Job",
"payload",
"is",
"set",
"and",
"returns",
"a",
"pointer",
"to",
"that",
"field",
"or",
"an",
"error",
"if",
"none",
"or",
"multiple",
"job",
"payload",
"fields",
"are",
"set"
] | 59993f5aad71a8e16ab6ed4e57e138e2398eae4e | https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/deploy/def/job.go#L95-L114 |
26,959 | hyperledger/burrow | crypto/public_key.go | PublicKeyLength | func PublicKeyLength(curveType CurveType) int {
switch curveType {
case CurveTypeEd25519:
return ed25519.PublicKeySize
case CurveTypeSecp256k1:
return btcec.PubKeyBytesLenCompressed
default:
// Other functions rely on this
return 0
}
} | go | func PublicKeyLength(curveType CurveType) int {
switch curveType {
case CurveTypeEd25519:
return ed25519.PublicKeySize
case CurveTypeSecp256k1:
return btcec.PubKeyBytesLenCompressed
default:
// Other functions rely on this
return 0
}
} | [
"func",
"PublicKeyLength",
"(",
"curveType",
"CurveType",
")",
"int",
"{",
"switch",
"curveType",
"{",
"case",
"CurveTypeEd25519",
":",
"return",
"ed25519",
".",
"PublicKeySize",
"\n",
"case",
"CurveTypeSecp256k1",
":",
"return",
"btcec",
".",
"PubKeyBytesLenCompres... | // Returns the length in bytes of the public key | [
"Returns",
"the",
"length",
"in",
"bytes",
"of",
"the",
"public",
"key"
] | 59993f5aad71a8e16ab6ed4e57e138e2398eae4e | https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/crypto/public_key.go#L26-L36 |
26,960 | hyperledger/burrow | crypto/public_key.go | EncodeFixedWidth | func (p PublicKey) EncodeFixedWidth() []byte {
encoded := make([]byte, PublicKeyFixedWidthEncodingLength)
encoded[0] = p.CurveType.Byte()
copy(encoded[1:], p.PublicKey)
return encoded
} | go | func (p PublicKey) EncodeFixedWidth() []byte {
encoded := make([]byte, PublicKeyFixedWidthEncodingLength)
encoded[0] = p.CurveType.Byte()
copy(encoded[1:], p.PublicKey)
return encoded
} | [
"func",
"(",
"p",
"PublicKey",
")",
"EncodeFixedWidth",
"(",
")",
"[",
"]",
"byte",
"{",
"encoded",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"PublicKeyFixedWidthEncodingLength",
")",
"\n",
"encoded",
"[",
"0",
"]",
"=",
"p",
".",
"CurveType",
".",
"By... | // Produces a binary encoding of the CurveType byte plus
// the public key for padded to a fixed width on the right | [
"Produces",
"a",
"binary",
"encoding",
"of",
"the",
"CurveType",
"byte",
"plus",
"the",
"public",
"key",
"for",
"padded",
"to",
"a",
"fixed",
"width",
"on",
"the",
"right"
] | 59993f5aad71a8e16ab6ed4e57e138e2398eae4e | https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/crypto/public_key.go#L145-L150 |
26,961 | hyperledger/burrow | crypto/address.go | SequenceNonce | func SequenceNonce(address Address, sequence uint64) []byte {
bs := make([]byte, 8)
binary.PutUint64BE(bs, sequence)
return Nonce(address, bs)
} | go | func SequenceNonce(address Address, sequence uint64) []byte {
bs := make([]byte, 8)
binary.PutUint64BE(bs, sequence)
return Nonce(address, bs)
} | [
"func",
"SequenceNonce",
"(",
"address",
"Address",
",",
"sequence",
"uint64",
")",
"[",
"]",
"byte",
"{",
"bs",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"8",
")",
"\n",
"binary",
".",
"PutUint64BE",
"(",
"bs",
",",
"sequence",
")",
"\n",
"return",
... | // Obtain a nearly unique nonce based on a montonic account sequence number | [
"Obtain",
"a",
"nearly",
"unique",
"nonce",
"based",
"on",
"a",
"montonic",
"account",
"sequence",
"number"
] | 59993f5aad71a8e16ab6ed4e57e138e2398eae4e | https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/crypto/address.go#L191-L195 |
26,962 | hyperledger/burrow | rpc/rpcquery/query_server.go | GetBlockHeader | func (qs *queryServer) GetBlockHeader(ctx context.Context, param *GetBlockParam) (*types.Header, error) {
header, err := qs.blockchain.GetBlockHeader(param.Height)
if err != nil {
return nil, err
}
abciHeader := tmtypes.TM2PB.Header(header)
return &abciHeader, nil
} | go | func (qs *queryServer) GetBlockHeader(ctx context.Context, param *GetBlockParam) (*types.Header, error) {
header, err := qs.blockchain.GetBlockHeader(param.Height)
if err != nil {
return nil, err
}
abciHeader := tmtypes.TM2PB.Header(header)
return &abciHeader, nil
} | [
"func",
"(",
"qs",
"*",
"queryServer",
")",
"GetBlockHeader",
"(",
"ctx",
"context",
".",
"Context",
",",
"param",
"*",
"GetBlockParam",
")",
"(",
"*",
"types",
".",
"Header",
",",
"error",
")",
"{",
"header",
",",
"err",
":=",
"qs",
".",
"blockchain",... | // Tendermint and blocks | [
"Tendermint",
"and",
"blocks"
] | 59993f5aad71a8e16ab6ed4e57e138e2398eae4e | https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/rpc/rpcquery/query_server.go#L181-L188 |
26,963 | hyperledger/burrow | keys/key_store.go | IsValidKeyJson | func IsValidKeyJson(j []byte) []byte {
j1 := new(keyJSON)
e1 := json.Unmarshal(j, &j1)
if e1 == nil {
addr, _ := hex.DecodeString(j1.Address)
return addr
}
return nil
} | go | func IsValidKeyJson(j []byte) []byte {
j1 := new(keyJSON)
e1 := json.Unmarshal(j, &j1)
if e1 == nil {
addr, _ := hex.DecodeString(j1.Address)
return addr
}
return nil
} | [
"func",
"IsValidKeyJson",
"(",
"j",
"[",
"]",
"byte",
")",
"[",
"]",
"byte",
"{",
"j1",
":=",
"new",
"(",
"keyJSON",
")",
"\n",
"e1",
":=",
"json",
".",
"Unmarshal",
"(",
"j",
",",
"&",
"j1",
")",
"\n",
"if",
"e1",
"==",
"nil",
"{",
"addr",
"... | // returns the address if valid, nil otherwise | [
"returns",
"the",
"address",
"if",
"valid",
"nil",
"otherwise"
] | 59993f5aad71a8e16ab6ed4e57e138e2398eae4e | https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/keys/key_store.go#L96-L104 |
26,964 | hyperledger/burrow | consensus/tendermint/priv_validator_memory.go | NewPrivValidatorMemory | func NewPrivValidatorMemory(addressable crypto.Addressable, signer crypto.Signer) *privValidatorMemory {
return &privValidatorMemory{
Addressable: addressable,
signer: asTendermintSigner(signer),
lastSignedInfo: NewLastSignedInfo(),
}
} | go | func NewPrivValidatorMemory(addressable crypto.Addressable, signer crypto.Signer) *privValidatorMemory {
return &privValidatorMemory{
Addressable: addressable,
signer: asTendermintSigner(signer),
lastSignedInfo: NewLastSignedInfo(),
}
} | [
"func",
"NewPrivValidatorMemory",
"(",
"addressable",
"crypto",
".",
"Addressable",
",",
"signer",
"crypto",
".",
"Signer",
")",
"*",
"privValidatorMemory",
"{",
"return",
"&",
"privValidatorMemory",
"{",
"Addressable",
":",
"addressable",
",",
"signer",
":",
"asT... | // Create a PrivValidator with in-memory state that takes an addressable representing the validator identity
// and a signer providing private signing for that identity. | [
"Create",
"a",
"PrivValidator",
"with",
"in",
"-",
"memory",
"state",
"that",
"takes",
"an",
"addressable",
"representing",
"the",
"validator",
"identity",
"and",
"a",
"signer",
"providing",
"private",
"signing",
"for",
"that",
"identity",
"."
] | 59993f5aad71a8e16ab6ed4e57e138e2398eae4e | https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/consensus/tendermint/priv_validator_memory.go#L19-L25 |
26,965 | hyperledger/burrow | util/snatives/templates/indent_writer.go | NewIndentWriter | func NewIndentWriter(indentLevel uint, indentString string,
writer io.Writer) *indentWriter {
return &indentWriter{
writer: writer,
indentLevel: indentLevel,
indentBytes: []byte(indentString),
indent: true,
}
} | go | func NewIndentWriter(indentLevel uint, indentString string,
writer io.Writer) *indentWriter {
return &indentWriter{
writer: writer,
indentLevel: indentLevel,
indentBytes: []byte(indentString),
indent: true,
}
} | [
"func",
"NewIndentWriter",
"(",
"indentLevel",
"uint",
",",
"indentString",
"string",
",",
"writer",
"io",
".",
"Writer",
")",
"*",
"indentWriter",
"{",
"return",
"&",
"indentWriter",
"{",
"writer",
":",
"writer",
",",
"indentLevel",
":",
"indentLevel",
",",
... | // indentWriter indents all lines written to it with a specified indent string
// indented the specified number of indents | [
"indentWriter",
"indents",
"all",
"lines",
"written",
"to",
"it",
"with",
"a",
"specified",
"indent",
"string",
"indented",
"the",
"specified",
"number",
"of",
"indents"
] | 59993f5aad71a8e16ab6ed4e57e138e2398eae4e | https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/util/snatives/templates/indent_writer.go#L32-L40 |
26,966 | hyperledger/burrow | acm/validator/ring.go | NewRing | func NewRing(initialSet Iterable, windowSize int) *Ring {
if windowSize < 1 {
windowSize = 1
}
vc := &Ring{
buckets: make([]*Bucket, windowSize),
power: NewTrimSet(),
size: windowSize,
}
for i := 0; i < windowSize; i++ {
vc.buckets[i] = NewBucket()
}
if initialSet != nil {
vc.populated = 1
vc.... | go | func NewRing(initialSet Iterable, windowSize int) *Ring {
if windowSize < 1 {
windowSize = 1
}
vc := &Ring{
buckets: make([]*Bucket, windowSize),
power: NewTrimSet(),
size: windowSize,
}
for i := 0; i < windowSize; i++ {
vc.buckets[i] = NewBucket()
}
if initialSet != nil {
vc.populated = 1
vc.... | [
"func",
"NewRing",
"(",
"initialSet",
"Iterable",
",",
"windowSize",
"int",
")",
"*",
"Ring",
"{",
"if",
"windowSize",
"<",
"1",
"{",
"windowSize",
"=",
"1",
"\n",
"}",
"\n",
"vc",
":=",
"&",
"Ring",
"{",
"buckets",
":",
"make",
"(",
"[",
"]",
"*",... | // Provides a sliding window over the last size buckets of validator power changes | [
"Provides",
"a",
"sliding",
"window",
"over",
"the",
"last",
"size",
"buckets",
"of",
"validator",
"power",
"changes"
] | 59993f5aad71a8e16ab6ed4e57e138e2398eae4e | https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/acm/validator/ring.go#L40-L57 |
26,967 | hyperledger/burrow | acm/validator/ring.go | Power | func (vc *Ring) Power(id crypto.Address) (*big.Int, error) {
return vc.GetPower(id), nil
} | go | func (vc *Ring) Power(id crypto.Address) (*big.Int, error) {
return vc.GetPower(id), nil
} | [
"func",
"(",
"vc",
"*",
"Ring",
")",
"Power",
"(",
"id",
"crypto",
".",
"Address",
")",
"(",
"*",
"big",
".",
"Int",
",",
"error",
")",
"{",
"return",
"vc",
".",
"GetPower",
"(",
"id",
")",
",",
"nil",
"\n",
"}"
] | // Implement Reader
// Get power at index from the delta bucket then falling through to the cumulative | [
"Implement",
"Reader",
"Get",
"power",
"at",
"index",
"from",
"the",
"delta",
"bucket",
"then",
"falling",
"through",
"to",
"the",
"cumulative"
] | 59993f5aad71a8e16ab6ed4e57e138e2398eae4e | https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/acm/validator/ring.go#L61-L63 |
26,968 | hyperledger/burrow | acm/validator/ring.go | Rotate | func (vc *Ring) Rotate() (totalPowerChange *big.Int, totalFlow *big.Int, err error) {
// Subtract the tail bucket (if any) from the total
err = Subtract(vc.power, vc.Next().Delta)
if err != nil {
return
}
// Capture current head as previous before advancing buffer
prevHead := vc.Head()
// Add head delta to tot... | go | func (vc *Ring) Rotate() (totalPowerChange *big.Int, totalFlow *big.Int, err error) {
// Subtract the tail bucket (if any) from the total
err = Subtract(vc.power, vc.Next().Delta)
if err != nil {
return
}
// Capture current head as previous before advancing buffer
prevHead := vc.Head()
// Add head delta to tot... | [
"func",
"(",
"vc",
"*",
"Ring",
")",
"Rotate",
"(",
")",
"(",
"totalPowerChange",
"*",
"big",
".",
"Int",
",",
"totalFlow",
"*",
"big",
".",
"Int",
",",
"err",
"error",
")",
"{",
"// Subtract the tail bucket (if any) from the total",
"err",
"=",
"Subtract",
... | // Advance the current head bucket to the next bucket and returns the change in total power between the previous bucket
// and the current head, and the total flow which is the sum of absolute values of all changes each validator's power
// after rotation the next head is a copy of the current head | [
"Advance",
"the",
"current",
"head",
"bucket",
"to",
"the",
"next",
"bucket",
"and",
"returns",
"the",
"change",
"in",
"total",
"power",
"between",
"the",
"previous",
"bucket",
"and",
"the",
"current",
"head",
"and",
"the",
"total",
"flow",
"which",
"is",
... | 59993f5aad71a8e16ab6ed4e57e138e2398eae4e | https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/acm/validator/ring.go#L86-L112 |
26,969 | hyperledger/burrow | acm/validator/ring.go | OrderedBuckets | func (vc *Ring) OrderedBuckets() []*Bucket {
buckets := make([]*Bucket, len(vc.buckets))
for i := int(0); i < vc.size; i++ {
index := vc.index(-i)
buckets[i] = vc.buckets[index]
}
return buckets
} | go | func (vc *Ring) OrderedBuckets() []*Bucket {
buckets := make([]*Bucket, len(vc.buckets))
for i := int(0); i < vc.size; i++ {
index := vc.index(-i)
buckets[i] = vc.buckets[index]
}
return buckets
} | [
"func",
"(",
"vc",
"*",
"Ring",
")",
"OrderedBuckets",
"(",
")",
"[",
"]",
"*",
"Bucket",
"{",
"buckets",
":=",
"make",
"(",
"[",
"]",
"*",
"Bucket",
",",
"len",
"(",
"vc",
".",
"buckets",
")",
")",
"\n",
"for",
"i",
":=",
"int",
"(",
"0",
")... | // Returns buckets in order head, previous, ... | [
"Returns",
"buckets",
"in",
"order",
"head",
"previous",
"..."
] | 59993f5aad71a8e16ab6ed4e57e138e2398eae4e | https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/acm/validator/ring.go#L169-L176 |
26,970 | hyperledger/burrow | execution/evm/asm/bc/helpers.go | Concat | func Concat(bss ...[]byte) []byte {
offset := 0
for _, bs := range bss {
offset += len(bs)
}
bytes := make([]byte, offset)
offset = 0
for _, bs := range bss {
for i, b := range bs {
bytes[offset+i] = b
}
offset += len(bs)
}
return bytes
} | go | func Concat(bss ...[]byte) []byte {
offset := 0
for _, bs := range bss {
offset += len(bs)
}
bytes := make([]byte, offset)
offset = 0
for _, bs := range bss {
for i, b := range bs {
bytes[offset+i] = b
}
offset += len(bs)
}
return bytes
} | [
"func",
"Concat",
"(",
"bss",
"...",
"[",
"]",
"byte",
")",
"[",
"]",
"byte",
"{",
"offset",
":=",
"0",
"\n",
"for",
"_",
",",
"bs",
":=",
"range",
"bss",
"{",
"offset",
"+=",
"len",
"(",
"bs",
")",
"\n",
"}",
"\n",
"bytes",
":=",
"make",
"("... | // Concatenate multiple byte slices without unnecessary copying | [
"Concatenate",
"multiple",
"byte",
"slices",
"without",
"unnecessary",
"copying"
] | 59993f5aad71a8e16ab6ed4e57e138e2398eae4e | https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/execution/evm/asm/bc/helpers.go#L14-L28 |
26,971 | hyperledger/burrow | execution/evm/asm/bc/helpers.go | MustSplice | func MustSplice(bytelikes ...interface{}) []byte {
spliced, err := Splice(bytelikes...)
if err != nil {
panic(err)
}
return spliced
} | go | func MustSplice(bytelikes ...interface{}) []byte {
spliced, err := Splice(bytelikes...)
if err != nil {
panic(err)
}
return spliced
} | [
"func",
"MustSplice",
"(",
"bytelikes",
"...",
"interface",
"{",
"}",
")",
"[",
"]",
"byte",
"{",
"spliced",
",",
"err",
":=",
"Splice",
"(",
"bytelikes",
"...",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"panic",
"(",
"err",
")",
"\n",
"}",
"\n",
... | // Splice or panic | [
"Splice",
"or",
"panic"
] | 59993f5aad71a8e16ab6ed4e57e138e2398eae4e | https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/execution/evm/asm/bc/helpers.go#L31-L37 |
26,972 | hyperledger/burrow | execution/evm/asm/bc/helpers.go | byteSlicify | func byteSlicify(bytelike interface{}) ([]byte, error) {
switch b := bytelike.(type) {
case byte:
return []byte{b}, nil
case asm.OpCode:
return []byte{byte(b)}, nil
case int:
if int(byte(b)) != b {
return nil, fmt.Errorf("the int %v does not fit inside a byte", b)
}
return []byte{byte(b)}, nil
case in... | go | func byteSlicify(bytelike interface{}) ([]byte, error) {
switch b := bytelike.(type) {
case byte:
return []byte{b}, nil
case asm.OpCode:
return []byte{byte(b)}, nil
case int:
if int(byte(b)) != b {
return nil, fmt.Errorf("the int %v does not fit inside a byte", b)
}
return []byte{byte(b)}, nil
case in... | [
"func",
"byteSlicify",
"(",
"bytelike",
"interface",
"{",
"}",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"switch",
"b",
":=",
"bytelike",
".",
"(",
"type",
")",
"{",
"case",
"byte",
":",
"return",
"[",
"]",
"byte",
"{",
"b",
"}",
",",
... | // Convert anything byte or byte slice like to a byte slice | [
"Convert",
"anything",
"byte",
"or",
"byte",
"slice",
"like",
"to",
"a",
"byte",
"slice"
] | 59993f5aad71a8e16ab6ed4e57e138e2398eae4e | https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/execution/evm/asm/bc/helpers.go#L56-L86 |
26,973 | hyperledger/burrow | util/slice/slice.go | CopyPrepend | func CopyPrepend(slice []interface{}, elements ...interface{}) []interface{} {
elementsLength := len(elements)
newSlice := make([]interface{}, len(slice)+elementsLength)
for i, e := range elements {
newSlice[i] = e
}
for i, e := range slice {
newSlice[elementsLength+i] = e
}
return newSlice
} | go | func CopyPrepend(slice []interface{}, elements ...interface{}) []interface{} {
elementsLength := len(elements)
newSlice := make([]interface{}, len(slice)+elementsLength)
for i, e := range elements {
newSlice[i] = e
}
for i, e := range slice {
newSlice[elementsLength+i] = e
}
return newSlice
} | [
"func",
"CopyPrepend",
"(",
"slice",
"[",
"]",
"interface",
"{",
"}",
",",
"elements",
"...",
"interface",
"{",
"}",
")",
"[",
"]",
"interface",
"{",
"}",
"{",
"elementsLength",
":=",
"len",
"(",
"elements",
")",
"\n",
"newSlice",
":=",
"make",
"(",
... | // Prepend elements to slice in the order they appear | [
"Prepend",
"elements",
"to",
"slice",
"in",
"the",
"order",
"they",
"appear"
] | 59993f5aad71a8e16ab6ed4e57e138e2398eae4e | https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/util/slice/slice.go#L41-L51 |
26,974 | hyperledger/burrow | util/slice/slice.go | Concat | func Concat(slices ...[]interface{}) []interface{} {
offset := 0
for _, slice := range slices {
offset += len(slice)
}
concat := make([]interface{}, offset)
offset = 0
for _, slice := range slices {
for i, e := range slice {
concat[offset+i] = e
}
offset += len(slice)
}
return concat
} | go | func Concat(slices ...[]interface{}) []interface{} {
offset := 0
for _, slice := range slices {
offset += len(slice)
}
concat := make([]interface{}, offset)
offset = 0
for _, slice := range slices {
for i, e := range slice {
concat[offset+i] = e
}
offset += len(slice)
}
return concat
} | [
"func",
"Concat",
"(",
"slices",
"...",
"[",
"]",
"interface",
"{",
"}",
")",
"[",
"]",
"interface",
"{",
"}",
"{",
"offset",
":=",
"0",
"\n",
"for",
"_",
",",
"slice",
":=",
"range",
"slices",
"{",
"offset",
"+=",
"len",
"(",
"slice",
")",
"\n",... | // Concatenate slices into a single slice | [
"Concatenate",
"slices",
"into",
"a",
"single",
"slice"
] | 59993f5aad71a8e16ab6ed4e57e138e2398eae4e | https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/util/slice/slice.go#L54-L68 |
26,975 | hyperledger/burrow | util/slice/slice.go | Delete | func Delete(slice []interface{}, i int, n int) []interface{} {
return append(slice[:i], slice[i+n:]...)
} | go | func Delete(slice []interface{}, i int, n int) []interface{} {
return append(slice[:i], slice[i+n:]...)
} | [
"func",
"Delete",
"(",
"slice",
"[",
"]",
"interface",
"{",
"}",
",",
"i",
"int",
",",
"n",
"int",
")",
"[",
"]",
"interface",
"{",
"}",
"{",
"return",
"append",
"(",
"slice",
"[",
":",
"i",
"]",
",",
"slice",
"[",
"i",
"+",
"n",
":",
"]",
... | // Deletes n elements starting with the ith from a slice by splicing.
// Beware uses append so the underlying backing array will be modified! | [
"Deletes",
"n",
"elements",
"starting",
"with",
"the",
"ith",
"from",
"a",
"slice",
"by",
"splicing",
".",
"Beware",
"uses",
"append",
"so",
"the",
"underlying",
"backing",
"array",
"will",
"be",
"modified!"
] | 59993f5aad71a8e16ab6ed4e57e138e2398eae4e | https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/util/slice/slice.go#L72-L74 |
26,976 | hyperledger/burrow | util/slice/slice.go | DeepFlatten | func DeepFlatten(slice []interface{}, depth int) []interface{} {
if depth == 0 {
return slice
}
returnSlice := []interface{}{}
for _, element := range slice {
if s, ok := element.([]interface{}); ok {
returnSlice = append(returnSlice, DeepFlatten(s, depth-1)...)
} else {
returnSlice = append(returnSlic... | go | func DeepFlatten(slice []interface{}, depth int) []interface{} {
if depth == 0 {
return slice
}
returnSlice := []interface{}{}
for _, element := range slice {
if s, ok := element.([]interface{}); ok {
returnSlice = append(returnSlice, DeepFlatten(s, depth-1)...)
} else {
returnSlice = append(returnSlic... | [
"func",
"DeepFlatten",
"(",
"slice",
"[",
"]",
"interface",
"{",
"}",
",",
"depth",
"int",
")",
"[",
"]",
"interface",
"{",
"}",
"{",
"if",
"depth",
"==",
"0",
"{",
"return",
"slice",
"\n",
"}",
"\n",
"returnSlice",
":=",
"[",
"]",
"interface",
"{"... | // Recursively flattens a list by splicing any sub-lists into their parent until
// depth is reached. If a negative number is passed for depth then it continues
// until no elements of the returned list are lists | [
"Recursively",
"flattens",
"a",
"list",
"by",
"splicing",
"any",
"sub",
"-",
"lists",
"into",
"their",
"parent",
"until",
"depth",
"is",
"reached",
".",
"If",
"a",
"negative",
"number",
"is",
"passed",
"for",
"depth",
"then",
"it",
"continues",
"until",
"n... | 59993f5aad71a8e16ab6ed4e57e138e2398eae4e | https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/util/slice/slice.go#L90-L106 |
26,977 | hyperledger/burrow | execution/transactor.go | BroadcastTxAsync | func (trans *Transactor) BroadcastTxAsync(ctx context.Context, txEnv *txs.Envelope) (*txs.Receipt, error) {
return trans.CheckTxSync(ctx, txEnv)
} | go | func (trans *Transactor) BroadcastTxAsync(ctx context.Context, txEnv *txs.Envelope) (*txs.Receipt, error) {
return trans.CheckTxSync(ctx, txEnv)
} | [
"func",
"(",
"trans",
"*",
"Transactor",
")",
"BroadcastTxAsync",
"(",
"ctx",
"context",
".",
"Context",
",",
"txEnv",
"*",
"txs",
".",
"Envelope",
")",
"(",
"*",
"txs",
".",
"Receipt",
",",
"error",
")",
"{",
"return",
"trans",
".",
"CheckTxSync",
"("... | // Broadcast a transaction without waiting for confirmation - will attempt to sign server-side and set sequence numbers
// if no signatures are provided | [
"Broadcast",
"a",
"transaction",
"without",
"waiting",
"for",
"confirmation",
"-",
"will",
"attempt",
"to",
"sign",
"server",
"-",
"side",
"and",
"set",
"sequence",
"numbers",
"if",
"no",
"signatures",
"are",
"provided"
] | 59993f5aad71a8e16ab6ed4e57e138e2398eae4e | https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/execution/transactor.go#L117-L119 |
26,978 | hyperledger/burrow | execution/exec/stream_event.go | Consume | func (ba *BlockAccumulator) Consume(ev *StreamEvent) *BlockExecution {
switch {
case ev.BeginBlock != nil:
ba.block = &BlockExecution{
Height: ev.BeginBlock.Height,
Header: ev.BeginBlock.Header,
}
case ev.BeginTx != nil, ev.Envelope != nil, ev.Event != nil, ev.EndTx != nil:
txe := ba.stack.Consume(ev)
... | go | func (ba *BlockAccumulator) Consume(ev *StreamEvent) *BlockExecution {
switch {
case ev.BeginBlock != nil:
ba.block = &BlockExecution{
Height: ev.BeginBlock.Height,
Header: ev.BeginBlock.Header,
}
case ev.BeginTx != nil, ev.Envelope != nil, ev.Event != nil, ev.EndTx != nil:
txe := ba.stack.Consume(ev)
... | [
"func",
"(",
"ba",
"*",
"BlockAccumulator",
")",
"Consume",
"(",
"ev",
"*",
"StreamEvent",
")",
"*",
"BlockExecution",
"{",
"switch",
"{",
"case",
"ev",
".",
"BeginBlock",
"!=",
"nil",
":",
"ba",
".",
"block",
"=",
"&",
"BlockExecution",
"{",
"Height",
... | // Consume will add the StreamEvent passed to the block accumulator and if the block complete is complete return the
// BlockExecution, otherwise will return nil | [
"Consume",
"will",
"add",
"the",
"StreamEvent",
"passed",
"to",
"the",
"block",
"accumulator",
"and",
"if",
"the",
"block",
"complete",
"is",
"complete",
"return",
"the",
"BlockExecution",
"otherwise",
"will",
"return",
"nil"
] | 59993f5aad71a8e16ab6ed4e57e138e2398eae4e | https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/execution/exec/stream_event.go#L43-L59 |
26,979 | hyperledger/burrow | execution/exec/stream_event.go | Consume | func (stack *TxStack) Consume(ev *StreamEvent) *TxExecution {
switch {
case ev.BeginTx != nil:
stack.Push(initTx(ev.BeginTx))
case ev.Envelope != nil:
txe := stack.Peek()
txe.Envelope = ev.Envelope
txe.Receipt = txe.Envelope.Tx.GenerateReceipt()
case ev.Event != nil:
txe := stack.Peek()
txe.Events = app... | go | func (stack *TxStack) Consume(ev *StreamEvent) *TxExecution {
switch {
case ev.BeginTx != nil:
stack.Push(initTx(ev.BeginTx))
case ev.Envelope != nil:
txe := stack.Peek()
txe.Envelope = ev.Envelope
txe.Receipt = txe.Envelope.Tx.GenerateReceipt()
case ev.Event != nil:
txe := stack.Peek()
txe.Events = app... | [
"func",
"(",
"stack",
"*",
"TxStack",
")",
"Consume",
"(",
"ev",
"*",
"StreamEvent",
")",
"*",
"TxExecution",
"{",
"switch",
"{",
"case",
"ev",
".",
"BeginTx",
"!=",
"nil",
":",
"stack",
".",
"Push",
"(",
"initTx",
"(",
"ev",
".",
"BeginTx",
")",
"... | // Consume will add the StreamEvent to the transaction stack and if that completes a single outermost transaction
// returns the TxExecution otherwise will return nil | [
"Consume",
"will",
"add",
"the",
"StreamEvent",
"to",
"the",
"transaction",
"stack",
"and",
"if",
"that",
"completes",
"a",
"single",
"outermost",
"transaction",
"returns",
"the",
"TxExecution",
"otherwise",
"will",
"return",
"nil"
] | 59993f5aad71a8e16ab6ed4e57e138e2398eae4e | https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/execution/exec/stream_event.go#L82-L104 |
26,980 | hyperledger/burrow | acm/validator/validators.go | Diff | func Diff(before, after IterableReader) (*Set, error) {
diff := NewSet()
err := after.IterateValidators(func(id crypto.Addressable, powerAfter *big.Int) error {
powerBefore, err := before.Power(id.GetAddress())
if err != nil {
return err
}
// Exclude any powers from before that much after
if powerBefore.... | go | func Diff(before, after IterableReader) (*Set, error) {
diff := NewSet()
err := after.IterateValidators(func(id crypto.Addressable, powerAfter *big.Int) error {
powerBefore, err := before.Power(id.GetAddress())
if err != nil {
return err
}
// Exclude any powers from before that much after
if powerBefore.... | [
"func",
"Diff",
"(",
"before",
",",
"after",
"IterableReader",
")",
"(",
"*",
"Set",
",",
"error",
")",
"{",
"diff",
":=",
"NewSet",
"(",
")",
"\n",
"err",
":=",
"after",
".",
"IterateValidators",
"(",
"func",
"(",
"id",
"crypto",
".",
"Addressable",
... | // Returns the asymmetric difference, diff, between two Sets such that applying diff to before results in after | [
"Returns",
"the",
"asymmetric",
"difference",
"diff",
"between",
"two",
"Sets",
"such",
"that",
"applying",
"diff",
"to",
"before",
"results",
"in",
"after"
] | 59993f5aad71a8e16ab6ed4e57e138e2398eae4e | https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/acm/validator/validators.go#L65-L97 |
26,981 | hyperledger/burrow | acm/validator/validators.go | Add | func Add(vs ReaderWriter, vsOther Iterable) error {
return vsOther.IterateValidators(func(id crypto.Addressable, power *big.Int) error {
return AddPower(vs, id.GetPublicKey(), power)
})
} | go | func Add(vs ReaderWriter, vsOther Iterable) error {
return vsOther.IterateValidators(func(id crypto.Addressable, power *big.Int) error {
return AddPower(vs, id.GetPublicKey(), power)
})
} | [
"func",
"Add",
"(",
"vs",
"ReaderWriter",
",",
"vsOther",
"Iterable",
")",
"error",
"{",
"return",
"vsOther",
".",
"IterateValidators",
"(",
"func",
"(",
"id",
"crypto",
".",
"Addressable",
",",
"power",
"*",
"big",
".",
"Int",
")",
"error",
"{",
"return... | // Adds vsOther to vs | [
"Adds",
"vsOther",
"to",
"vs"
] | 59993f5aad71a8e16ab6ed4e57e138e2398eae4e | https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/acm/validator/validators.go#L113-L117 |
26,982 | hyperledger/burrow | acm/validator/validators.go | Subtract | func Subtract(vs ReaderWriter, vsOther Iterable) error {
return vsOther.IterateValidators(func(id crypto.Addressable, power *big.Int) error {
return SubtractPower(vs, id.GetPublicKey(), power)
})
} | go | func Subtract(vs ReaderWriter, vsOther Iterable) error {
return vsOther.IterateValidators(func(id crypto.Addressable, power *big.Int) error {
return SubtractPower(vs, id.GetPublicKey(), power)
})
} | [
"func",
"Subtract",
"(",
"vs",
"ReaderWriter",
",",
"vsOther",
"Iterable",
")",
"error",
"{",
"return",
"vsOther",
".",
"IterateValidators",
"(",
"func",
"(",
"id",
"crypto",
".",
"Addressable",
",",
"power",
"*",
"big",
".",
"Int",
")",
"error",
"{",
"r... | // Subtracts vsOther from vs | [
"Subtracts",
"vsOther",
"from",
"vs"
] | 59993f5aad71a8e16ab6ed4e57e138e2398eae4e | https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/acm/validator/validators.go#L120-L124 |
26,983 | hyperledger/burrow | event/query/reflect_tagged.go | ReflectTags | func ReflectTags(value interface{}, fieldNames ...string) (*ReflectTagged, error) {
rv := reflect.ValueOf(value)
if rv.IsNil() {
return &ReflectTagged{}, nil
}
if rv.Kind() != reflect.Ptr {
return nil, fmt.Errorf("ReflectStructTags needs a pointer to a struct but %v is not a pointer",
rv.Interface())
}
if ... | go | func ReflectTags(value interface{}, fieldNames ...string) (*ReflectTagged, error) {
rv := reflect.ValueOf(value)
if rv.IsNil() {
return &ReflectTagged{}, nil
}
if rv.Kind() != reflect.Ptr {
return nil, fmt.Errorf("ReflectStructTags needs a pointer to a struct but %v is not a pointer",
rv.Interface())
}
if ... | [
"func",
"ReflectTags",
"(",
"value",
"interface",
"{",
"}",
",",
"fieldNames",
"...",
"string",
")",
"(",
"*",
"ReflectTagged",
",",
"error",
")",
"{",
"rv",
":=",
"reflect",
".",
"ValueOf",
"(",
"value",
")",
"\n",
"if",
"rv",
".",
"IsNil",
"(",
")"... | // ReflectTags provides a query.Tagged on a structs exported fields using query.StringFromValue to derive the string
// values associated with each field. If passed explicit field names will only only provide those fields as tags,
// otherwise all exported fields are provided. | [
"ReflectTags",
"provides",
"a",
"query",
".",
"Tagged",
"on",
"a",
"structs",
"exported",
"fields",
"using",
"query",
".",
"StringFromValue",
"to",
"derive",
"the",
"string",
"values",
"associated",
"with",
"each",
"field",
".",
"If",
"passed",
"explicit",
"fi... | 59993f5aad71a8e16ab6ed4e57e138e2398eae4e | https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/event/query/reflect_tagged.go#L29-L83 |
26,984 | hyperledger/burrow | acm/acmstate/memory_state.go | NewMemoryState | func NewMemoryState() *MemoryState {
return &MemoryState{
Accounts: make(map[crypto.Address]*acm.Account),
Storage: make(map[crypto.Address]map[binary.Word256]binary.Word256),
}
} | go | func NewMemoryState() *MemoryState {
return &MemoryState{
Accounts: make(map[crypto.Address]*acm.Account),
Storage: make(map[crypto.Address]map[binary.Word256]binary.Word256),
}
} | [
"func",
"NewMemoryState",
"(",
")",
"*",
"MemoryState",
"{",
"return",
"&",
"MemoryState",
"{",
"Accounts",
":",
"make",
"(",
"map",
"[",
"crypto",
".",
"Address",
"]",
"*",
"acm",
".",
"Account",
")",
",",
"Storage",
":",
"make",
"(",
"map",
"[",
"c... | // Get an in-memory state IterableReader | [
"Get",
"an",
"in",
"-",
"memory",
"state",
"IterableReader"
] | 59993f5aad71a8e16ab6ed4e57e138e2398eae4e | https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/acm/acmstate/memory_state.go#L19-L24 |
26,985 | hyperledger/burrow | logging/structure/structure.go | ValuesAndContext | func ValuesAndContext(keyvals []interface{},
keys ...interface{}) (map[string]interface{}, []interface{}) {
vals := make(map[string]interface{}, len(keys))
context := make([]interface{}, len(keyvals))
copy(context, keyvals)
deletions := 0
// We can't really do better than a linear scan of both lists here. N is s... | go | func ValuesAndContext(keyvals []interface{},
keys ...interface{}) (map[string]interface{}, []interface{}) {
vals := make(map[string]interface{}, len(keys))
context := make([]interface{}, len(keyvals))
copy(context, keyvals)
deletions := 0
// We can't really do better than a linear scan of both lists here. N is s... | [
"func",
"ValuesAndContext",
"(",
"keyvals",
"[",
"]",
"interface",
"{",
"}",
",",
"keys",
"...",
"interface",
"{",
"}",
")",
"(",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
",",
"[",
"]",
"interface",
"{",
"}",
")",
"{",
"vals",
":=",
"make"... | // Pull the specified values from a structured log line into a map.
// Assumes keys are single-valued.
// Returns a map of the key-values from the requested keys and
// the unmatched remainder keyvals as context as a slice of key-values. | [
"Pull",
"the",
"specified",
"values",
"from",
"a",
"structured",
"log",
"line",
"into",
"a",
"map",
".",
"Assumes",
"keys",
"are",
"single",
"-",
"valued",
".",
"Returns",
"a",
"map",
"of",
"the",
"key",
"-",
"values",
"from",
"the",
"requested",
"keys",... | 59993f5aad71a8e16ab6ed4e57e138e2398eae4e | https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/logging/structure/structure.go#L65-L92 |
26,986 | hyperledger/burrow | logging/structure/structure.go | KeyValuesMap | func KeyValuesMap(keyvals []interface{}) map[string]interface{} {
length := len(keyvals) / 2
vals := make(map[string]interface{}, length)
for i := 0; i < 2*length; i += 2 {
vals[StringifyKey(keyvals[i])] = keyvals[i+1]
}
return vals
} | go | func KeyValuesMap(keyvals []interface{}) map[string]interface{} {
length := len(keyvals) / 2
vals := make(map[string]interface{}, length)
for i := 0; i < 2*length; i += 2 {
vals[StringifyKey(keyvals[i])] = keyvals[i+1]
}
return vals
} | [
"func",
"KeyValuesMap",
"(",
"keyvals",
"[",
"]",
"interface",
"{",
"}",
")",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"length",
":=",
"len",
"(",
"keyvals",
")",
"/",
"2",
"\n",
"vals",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
... | // Returns keyvals as a map from keys to vals | [
"Returns",
"keyvals",
"as",
"a",
"map",
"from",
"keys",
"to",
"vals"
] | 59993f5aad71a8e16ab6ed4e57e138e2398eae4e | https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/logging/structure/structure.go#L95-L102 |
26,987 | hyperledger/burrow | logging/structure/structure.go | DropKeys | func DropKeys(keyvals []interface{}, dropKeyValPredicate func(key, value interface{}) bool) []interface{} {
keyvalsDropped := make([]interface{}, 0, len(keyvals))
for i := 0; i < 2*(len(keyvals)/2); i += 2 {
if !dropKeyValPredicate(keyvals[i], keyvals[i+1]) {
keyvalsDropped = append(keyvalsDropped, keyvals[i], k... | go | func DropKeys(keyvals []interface{}, dropKeyValPredicate func(key, value interface{}) bool) []interface{} {
keyvalsDropped := make([]interface{}, 0, len(keyvals))
for i := 0; i < 2*(len(keyvals)/2); i += 2 {
if !dropKeyValPredicate(keyvals[i], keyvals[i+1]) {
keyvalsDropped = append(keyvalsDropped, keyvals[i], k... | [
"func",
"DropKeys",
"(",
"keyvals",
"[",
"]",
"interface",
"{",
"}",
",",
"dropKeyValPredicate",
"func",
"(",
"key",
",",
"value",
"interface",
"{",
"}",
")",
"bool",
")",
"[",
"]",
"interface",
"{",
"}",
"{",
"keyvalsDropped",
":=",
"make",
"(",
"[",
... | // Drops all key value pairs where dropKeyValPredicate is true | [
"Drops",
"all",
"key",
"value",
"pairs",
"where",
"dropKeyValPredicate",
"is",
"true"
] | 59993f5aad71a8e16ab6ed4e57e138e2398eae4e | https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/logging/structure/structure.go#L127-L135 |
26,988 | hyperledger/burrow | logging/structure/structure.go | Vectorise | func Vectorise(keyvals []interface{}, vectorKeys ...string) []interface{} {
// We rely on working against a single backing array, so we use a capacity that is the maximum possible size of the
// slice after vectorising (in the case there are no duplicate keys and this is a no-op)
outputKeyvals := make([]interface{},... | go | func Vectorise(keyvals []interface{}, vectorKeys ...string) []interface{} {
// We rely on working against a single backing array, so we use a capacity that is the maximum possible size of the
// slice after vectorising (in the case there are no duplicate keys and this is a no-op)
outputKeyvals := make([]interface{},... | [
"func",
"Vectorise",
"(",
"keyvals",
"[",
"]",
"interface",
"{",
"}",
",",
"vectorKeys",
"...",
"string",
")",
"[",
"]",
"interface",
"{",
"}",
"{",
"// We rely on working against a single backing array, so we use a capacity that is the maximum possible size of the",
"// sl... | // 'Vectorises' values associated with repeated string keys member by collapsing many values into a single vector value.
// The result is a copy of keyvals where the first occurrence of each matching key and its first value are replaced by
// that key and all of its values in a single slice. | [
"Vectorises",
"values",
"associated",
"with",
"repeated",
"string",
"keys",
"member",
"by",
"collapsing",
"many",
"values",
"into",
"a",
"single",
"vector",
"value",
".",
"The",
"result",
"is",
"a",
"copy",
"of",
"keyvals",
"where",
"the",
"first",
"occurrence... | 59993f5aad71a8e16ab6ed4e57e138e2398eae4e | https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/logging/structure/structure.go#L167-L206 |
26,989 | hyperledger/burrow | logging/structure/structure.go | Value | func Value(keyvals []interface{}, key interface{}) interface{} {
for i := 0; i < 2*(len(keyvals)/2); i += 2 {
if keyvals[i] == key {
return keyvals[i+1]
}
}
return nil
} | go | func Value(keyvals []interface{}, key interface{}) interface{} {
for i := 0; i < 2*(len(keyvals)/2); i += 2 {
if keyvals[i] == key {
return keyvals[i+1]
}
}
return nil
} | [
"func",
"Value",
"(",
"keyvals",
"[",
"]",
"interface",
"{",
"}",
",",
"key",
"interface",
"{",
"}",
")",
"interface",
"{",
"}",
"{",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"2",
"*",
"(",
"len",
"(",
"keyvals",
")",
"/",
"2",
")",
";",
"i",
... | // Return a single value corresponding to key in keyvals | [
"Return",
"a",
"single",
"value",
"corresponding",
"to",
"key",
"in",
"keyvals"
] | 59993f5aad71a8e16ab6ed4e57e138e2398eae4e | https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/logging/structure/structure.go#L209-L216 |
26,990 | hyperledger/burrow | logging/structure/structure.go | StringifyKey | func StringifyKey(key interface{}) string {
switch key {
// For named keys we want to handle explicitly
default:
// Stringify keys
switch k := key.(type) {
case string:
return k
case fmt.Stringer:
return k.String()
default:
return fmt.Sprintf("%v", key)
}
}
} | go | func StringifyKey(key interface{}) string {
switch key {
// For named keys we want to handle explicitly
default:
// Stringify keys
switch k := key.(type) {
case string:
return k
case fmt.Stringer:
return k.String()
default:
return fmt.Sprintf("%v", key)
}
}
} | [
"func",
"StringifyKey",
"(",
"key",
"interface",
"{",
"}",
")",
"string",
"{",
"switch",
"key",
"{",
"// For named keys we want to handle explicitly",
"default",
":",
"// Stringify keys",
"switch",
"k",
":=",
"key",
".",
"(",
"type",
")",
"{",
"case",
"string",
... | // Provides a canonical way to stringify keys | [
"Provides",
"a",
"canonical",
"way",
"to",
"stringify",
"keys"
] | 59993f5aad71a8e16ab6ed4e57e138e2398eae4e | https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/logging/structure/structure.go#L254-L269 |
26,991 | hyperledger/burrow | logging/structure/structure.go | Signal | func Signal(keyvals []interface{}) string {
last := len(keyvals) - 1
if last > 0 && keyvals[last-1] == SignalKey {
signal, ok := keyvals[last].(string)
if ok {
return signal
}
}
return ""
} | go | func Signal(keyvals []interface{}) string {
last := len(keyvals) - 1
if last > 0 && keyvals[last-1] == SignalKey {
signal, ok := keyvals[last].(string)
if ok {
return signal
}
}
return ""
} | [
"func",
"Signal",
"(",
"keyvals",
"[",
"]",
"interface",
"{",
"}",
")",
"string",
"{",
"last",
":=",
"len",
"(",
"keyvals",
")",
"-",
"1",
"\n",
"if",
"last",
">",
"0",
"&&",
"keyvals",
"[",
"last",
"-",
"1",
"]",
"==",
"SignalKey",
"{",
"signal"... | // Tried to interpret the logline as a signal by matching the last key-value pair as a signal,
// returns empty string if no match. The idea with signals is that the should be transmitted to a root logger
// as a single key-value pair so we avoid the need to do a linear probe over every log line in order to detect a si... | [
"Tried",
"to",
"interpret",
"the",
"logline",
"as",
"a",
"signal",
"by",
"matching",
"the",
"last",
"key",
"-",
"value",
"pair",
"as",
"a",
"signal",
"returns",
"empty",
"string",
"if",
"no",
"match",
".",
"The",
"idea",
"with",
"signals",
"is",
"that",
... | 59993f5aad71a8e16ab6ed4e57e138e2398eae4e | https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/logging/structure/structure.go#L284-L293 |
26,992 | hyperledger/burrow | execution/exec/block_execution.go | StreamEvents | func (be *BlockExecution) StreamEvents() StreamEvents {
var ses StreamEvents
ses = append(ses, &StreamEvent{
BeginBlock: &BeginBlock{
Height: be.Height,
Header: be.Header,
},
})
for _, txe := range be.TxExecutions {
ses = append(ses, txe.StreamEvents()...)
}
return append(ses, &StreamEvent{
EndBlock... | go | func (be *BlockExecution) StreamEvents() StreamEvents {
var ses StreamEvents
ses = append(ses, &StreamEvent{
BeginBlock: &BeginBlock{
Height: be.Height,
Header: be.Header,
},
})
for _, txe := range be.TxExecutions {
ses = append(ses, txe.StreamEvents()...)
}
return append(ses, &StreamEvent{
EndBlock... | [
"func",
"(",
"be",
"*",
"BlockExecution",
")",
"StreamEvents",
"(",
")",
"StreamEvents",
"{",
"var",
"ses",
"StreamEvents",
"\n",
"ses",
"=",
"append",
"(",
"ses",
",",
"&",
"StreamEvent",
"{",
"BeginBlock",
":",
"&",
"BeginBlock",
"{",
"Height",
":",
"b... | // Write out TxExecutions parenthetically | [
"Write",
"out",
"TxExecutions",
"parenthetically"
] | 59993f5aad71a8e16ab6ed4e57e138e2398eae4e | https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/execution/exec/block_execution.go#L23-L39 |
26,993 | hyperledger/burrow | storage/kvcache.go | WriteTo | func (kvc *KVCache) WriteTo(writer KVWriter) {
kvc.Lock()
defer kvc.Unlock()
for k, vi := range kvc.cache {
kb := []byte(k)
if vi.deleted {
writer.Delete(kb)
} else {
writer.Set(kb, vi.value)
}
}
} | go | func (kvc *KVCache) WriteTo(writer KVWriter) {
kvc.Lock()
defer kvc.Unlock()
for k, vi := range kvc.cache {
kb := []byte(k)
if vi.deleted {
writer.Delete(kb)
} else {
writer.Set(kb, vi.value)
}
}
} | [
"func",
"(",
"kvc",
"*",
"KVCache",
")",
"WriteTo",
"(",
"writer",
"KVWriter",
")",
"{",
"kvc",
".",
"Lock",
"(",
")",
"\n",
"defer",
"kvc",
".",
"Unlock",
"(",
")",
"\n",
"for",
"k",
",",
"vi",
":=",
"range",
"kvc",
".",
"cache",
"{",
"kb",
":... | // Writes contents of cache to backend without flushing the cache | [
"Writes",
"contents",
"of",
"cache",
"to",
"backend",
"without",
"flushing",
"the",
"cache"
] | 59993f5aad71a8e16ab6ed4e57e138e2398eae4e | https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/storage/kvcache.go#L109-L120 |
26,994 | hyperledger/burrow | event/emitter.go | NewEmitter | func NewEmitter() *Emitter {
pubsubServer := pubsub.NewServer(pubsub.BufferCapacity(DefaultEventBufferCapacity))
pubsubServer.BaseService = *common.NewBaseService(nil, "Emitter", pubsubServer)
pubsubServer.Start()
return &Emitter{
pubsubServer: pubsubServer,
}
} | go | func NewEmitter() *Emitter {
pubsubServer := pubsub.NewServer(pubsub.BufferCapacity(DefaultEventBufferCapacity))
pubsubServer.BaseService = *common.NewBaseService(nil, "Emitter", pubsubServer)
pubsubServer.Start()
return &Emitter{
pubsubServer: pubsubServer,
}
} | [
"func",
"NewEmitter",
"(",
")",
"*",
"Emitter",
"{",
"pubsubServer",
":=",
"pubsub",
".",
"NewServer",
"(",
"pubsub",
".",
"BufferCapacity",
"(",
"DefaultEventBufferCapacity",
")",
")",
"\n",
"pubsubServer",
".",
"BaseService",
"=",
"*",
"common",
".",
"NewBas... | // NewEmitter initializes an emitter struct with a pubsubServer | [
"NewEmitter",
"initializes",
"an",
"emitter",
"struct",
"with",
"a",
"pubsubServer"
] | 59993f5aad71a8e16ab6ed4e57e138e2398eae4e | https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/event/emitter.go#L42-L49 |
26,995 | hyperledger/burrow | event/emitter.go | SetLogger | func (em *Emitter) SetLogger(logger *logging.Logger) {
em.logger = logger.With(structure.ComponentKey, "Events")
} | go | func (em *Emitter) SetLogger(logger *logging.Logger) {
em.logger = logger.With(structure.ComponentKey, "Events")
} | [
"func",
"(",
"em",
"*",
"Emitter",
")",
"SetLogger",
"(",
"logger",
"*",
"logging",
".",
"Logger",
")",
"{",
"em",
".",
"logger",
"=",
"logger",
".",
"With",
"(",
"structure",
".",
"ComponentKey",
",",
"\"",
"\"",
")",
"\n",
"}"
] | // SetLogger attaches a log handler to this emitter | [
"SetLogger",
"attaches",
"a",
"log",
"handler",
"to",
"this",
"emitter"
] | 59993f5aad71a8e16ab6ed4e57e138e2398eae4e | https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/event/emitter.go#L52-L54 |
26,996 | hyperledger/burrow | event/emitter.go | Shutdown | func (em *Emitter) Shutdown(ctx context.Context) error {
return em.pubsubServer.Stop()
} | go | func (em *Emitter) Shutdown(ctx context.Context) error {
return em.pubsubServer.Stop()
} | [
"func",
"(",
"em",
"*",
"Emitter",
")",
"Shutdown",
"(",
"ctx",
"context",
".",
"Context",
")",
"error",
"{",
"return",
"em",
".",
"pubsubServer",
".",
"Stop",
"(",
")",
"\n",
"}"
] | // Shutdown stops the pubsubServer | [
"Shutdown",
"stops",
"the",
"pubsubServer"
] | 59993f5aad71a8e16ab6ed4e57e138e2398eae4e | https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/event/emitter.go#L57-L59 |
26,997 | hyperledger/burrow | event/emitter.go | Publish | func (em *Emitter) Publish(ctx context.Context, message interface{}, tags query.Tagged) error {
if em == nil || em.pubsubServer == nil {
return nil
}
return em.pubsubServer.PublishWithTags(ctx, message, tags)
} | go | func (em *Emitter) Publish(ctx context.Context, message interface{}, tags query.Tagged) error {
if em == nil || em.pubsubServer == nil {
return nil
}
return em.pubsubServer.PublishWithTags(ctx, message, tags)
} | [
"func",
"(",
"em",
"*",
"Emitter",
")",
"Publish",
"(",
"ctx",
"context",
".",
"Context",
",",
"message",
"interface",
"{",
"}",
",",
"tags",
"query",
".",
"Tagged",
")",
"error",
"{",
"if",
"em",
"==",
"nil",
"||",
"em",
".",
"pubsubServer",
"==",
... | // Publish tells the emitter to publish with the given message and tags | [
"Publish",
"tells",
"the",
"emitter",
"to",
"publish",
"with",
"the",
"given",
"message",
"and",
"tags"
] | 59993f5aad71a8e16ab6ed4e57e138e2398eae4e | https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/event/emitter.go#L62-L67 |
26,998 | hyperledger/burrow | event/emitter.go | Subscribe | func (em *Emitter) Subscribe(ctx context.Context, subscriber string, queryable query.Queryable, bufferSize int) (<-chan interface{}, error) {
qry, err := queryable.Query()
if err != nil {
return nil, err
}
return em.pubsubServer.Subscribe(ctx, subscriber, qry, bufferSize)
} | go | func (em *Emitter) Subscribe(ctx context.Context, subscriber string, queryable query.Queryable, bufferSize int) (<-chan interface{}, error) {
qry, err := queryable.Query()
if err != nil {
return nil, err
}
return em.pubsubServer.Subscribe(ctx, subscriber, qry, bufferSize)
} | [
"func",
"(",
"em",
"*",
"Emitter",
")",
"Subscribe",
"(",
"ctx",
"context",
".",
"Context",
",",
"subscriber",
"string",
",",
"queryable",
"query",
".",
"Queryable",
",",
"bufferSize",
"int",
")",
"(",
"<-",
"chan",
"interface",
"{",
"}",
",",
"error",
... | // Subscribe tells the emitter to listen for messages on the given query | [
"Subscribe",
"tells",
"the",
"emitter",
"to",
"listen",
"for",
"messages",
"on",
"the",
"given",
"query"
] | 59993f5aad71a8e16ab6ed4e57e138e2398eae4e | https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/event/emitter.go#L70-L76 |
26,999 | hyperledger/burrow | event/emitter.go | Unsubscribe | func (em *Emitter) Unsubscribe(ctx context.Context, subscriber string, queryable query.Queryable) error {
pubsubQuery, err := queryable.Query()
if err != nil {
return nil
}
return em.pubsubServer.Unsubscribe(ctx, subscriber, pubsubQuery)
} | go | func (em *Emitter) Unsubscribe(ctx context.Context, subscriber string, queryable query.Queryable) error {
pubsubQuery, err := queryable.Query()
if err != nil {
return nil
}
return em.pubsubServer.Unsubscribe(ctx, subscriber, pubsubQuery)
} | [
"func",
"(",
"em",
"*",
"Emitter",
")",
"Unsubscribe",
"(",
"ctx",
"context",
".",
"Context",
",",
"subscriber",
"string",
",",
"queryable",
"query",
".",
"Queryable",
")",
"error",
"{",
"pubsubQuery",
",",
"err",
":=",
"queryable",
".",
"Query",
"(",
")... | // Unsubscribe tells the emitter to stop listening for said messages | [
"Unsubscribe",
"tells",
"the",
"emitter",
"to",
"stop",
"listening",
"for",
"said",
"messages"
] | 59993f5aad71a8e16ab6ed4e57e138e2398eae4e | https://github.com/hyperledger/burrow/blob/59993f5aad71a8e16ab6ed4e57e138e2398eae4e/event/emitter.go#L79-L85 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.