Skip to content

Commit

Permalink
Del Query struct
Browse files Browse the repository at this point in the history
  • Loading branch information
claygod committed Jun 22, 2018
1 parent 63fffe9 commit 178f60e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
28 changes: 19 additions & 9 deletions adb_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,20 +63,28 @@ func New(patch string) (*Adb, error) {

func (a *Adb) ExeTransaction(order *Order) *Answer {
num := atomic.AddInt64(&a.counter, 1)
ans := a.DoTransaction(order, num)
ans := a.doTransaction(order, num)
// runtime.Gosched()
//time.Sleep(1 * time.Microsecond)
return a.GetAnswer(num, ans)
return a.getAnswer(num, ans)
}

func (a *Adb) DoTransaction(order *Order, num int64) *Answer {
func (a *Adb) ExeTransaction(order *Order) *Answer {
num := atomic.AddInt64(&a.counter, 1)
ans := a.doTransaction(order, num)
// runtime.Gosched()
//time.Sleep(1 * time.Microsecond)
return a.getAnswer(num, ans)
}

func (a *Adb) doTransaction(order *Order, num int64) *Answer {
ans := &Answer{code: 0}
tsk := a.getTask(order, ans)
a.ch <- tsk
return ans
}

func (a *Adb) GetAnswer(num int64, ans *Answer) *Answer { // , a **Answer
func (a *Adb) getAnswer(num int64, ans *Answer) *Answer { // , a **Answer
runtime.Gosched()
for i := 0; ; i++ { // i := 0; i < 1500000; i++
if atomic.LoadInt64(&ans.code) > 0 {
Expand All @@ -89,16 +97,18 @@ func (a *Adb) GetAnswer(num int64, ans *Answer) *Answer { // , a **Answer
return nil
}

type Answer struct {
code int64
balance map[string]map[string]account.Balance
}

/*
type Query struct {
num int64
order *Order
log []byte
}
*/

type Answer struct {
code int64
balance map[string]map[string]account.Balance
}

type Order struct {
Hash string
Expand Down
2 changes: 2 additions & 0 deletions adb_bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,7 @@ func ForTestGenTransactionsArray(cnt int) []*Order {
return tArray
}

/*
func ForTestGenQueryArray(cnt int) []*Query {
qArray := make([]*Query, 0, cnt)
for i := 0; i < cnt; i++ {
Expand All @@ -435,3 +436,4 @@ func ForTestGenQueryArray(cnt int) []*Query {
}
return qArray
}
*/

0 comments on commit 178f60e

Please sign in to comment.