From d6368823105b630c7b368abd21594e2c4c45c937 Mon Sep 17 00:00:00 2001 From: Adrian Gallagher Date: Fri, 29 Nov 2019 10:38:44 +1100 Subject: [PATCH] Use sync.Mutex instead of sync/atomic for 32 bit systems (#388) Change CLRF -> LF --- contrib/bash_autocomplete | 44 +++++++++++++++++----------------- contrib/zsh_autocomplete | 26 ++++++++++---------- exchanges/huobi/huobi_types.go | 4 ++-- exchanges/nonce/nonce.go | 15 ++++++++---- 4 files changed, 48 insertions(+), 41 deletions(-) diff --git a/contrib/bash_autocomplete b/contrib/bash_autocomplete index bf09a1109d1..6d6c7d9a711 100644 --- a/contrib/bash_autocomplete +++ b/contrib/bash_autocomplete @@ -1,23 +1,23 @@ -#! /bin/bash -# bash programmable completion for gctcli -# copy to /etc/bash_completion.d/gctcli and source it or restart your shell - -: ${PROG:=$(basename ${BASH_SOURCE})} - -_gctcli() { - if [[ "${COMP_WORDS[0]}" != "source" ]]; then - local cur opts base - COMPREPLY=() - cur="${COMP_WORDS[COMP_CWORD]}" - if [[ "$cur" == "-"* ]]; then - opts=$( ${COMP_WORDS[@]:0:$COMP_CWORD} ${cur} --generate-bash-completion ) - else - opts=$( ${COMP_WORDS[@]:0:$COMP_CWORD} --generate-bash-completion ) - fi - COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) - return 0 - fi -} - -complete -o bashdefault -o default -o nospace -F _gctcli $PROG +#! /bin/bash +# bash programmable completion for gctcli +# copy to /etc/bash_completion.d/gctcli and source it or restart your shell + +: ${PROG:=$(basename ${BASH_SOURCE})} + +_gctcli() { + if [[ "${COMP_WORDS[0]}" != "source" ]]; then + local cur opts base + COMPREPLY=() + cur="${COMP_WORDS[COMP_CWORD]}" + if [[ "$cur" == "-"* ]]; then + opts=$( ${COMP_WORDS[@]:0:$COMP_CWORD} ${cur} --generate-bash-completion ) + else + opts=$( ${COMP_WORDS[@]:0:$COMP_CWORD} --generate-bash-completion ) + fi + COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) + return 0 + fi +} + +complete -o bashdefault -o default -o nospace -F _gctcli $PROG unset PROG \ No newline at end of file diff --git a/contrib/zsh_autocomplete b/contrib/zsh_autocomplete index 6aaa948755d..ed4951b2969 100644 --- a/contrib/zsh_autocomplete +++ b/contrib/zsh_autocomplete @@ -1,14 +1,14 @@ -# zsh programmable completion for gctcli -# source zsh_autocomplete - -_gctcli() { - - local -a opts - opts=("${(@f)$(_CLI_ZSH_AUTOCOMPLETE_HACK=1 ${words[@]:0:#words[@]-1} --generate-bash-completion)}") - - _describe 'values' opts - - return -} - +# zsh programmable completion for gctcli +# source zsh_autocomplete + +_gctcli() { + + local -a opts + opts=("${(@f)$(_CLI_ZSH_AUTOCOMPLETE_HACK=1 ${words[@]:0:#words[@]-1} --generate-bash-completion)}") + + _describe 'values' opts + + return +} + compdef _gctcli gctcli \ No newline at end of file diff --git a/exchanges/huobi/huobi_types.go b/exchanges/huobi/huobi_types.go index b7ea87dbddb..c4d516bc2ab 100644 --- a/exchanges/huobi/huobi_types.go +++ b/exchanges/huobi/huobi_types.go @@ -35,7 +35,7 @@ type CancelOpenOrdersBatch struct { // DetailMerged stores the ticker detail merged data type DetailMerged struct { Detail - Version int `json:"version"` + Version int64 `json:"version"` Ask []float64 `json:"ask"` Bid []float64 `json:"bid"` } @@ -108,7 +108,7 @@ type Detail struct { Close float64 `json:"close"` High float64 `json:"high"` Timestamp int64 `json:"timestamp"` - ID int `json:"id"` + ID int64 `json:"id"` Count int `json:"count"` Low float64 `json:"low"` Volume float64 `json:"vol"` diff --git a/exchanges/nonce/nonce.go b/exchanges/nonce/nonce.go index 2a863a16f18..fd358b9f7e4 100644 --- a/exchanges/nonce/nonce.go +++ b/exchanges/nonce/nonce.go @@ -2,22 +2,27 @@ package nonce import ( "strconv" - "sync/atomic" + "sync" ) // Nonce struct holds the nonce value type Nonce struct { n int64 + m sync.Mutex } // Inc increments the nonce value func (n *Nonce) Inc() { - atomic.AddInt64(&n.n, 1) + n.m.Lock() + n.n++ + n.m.Unlock() } // Get retrives the nonce value func (n *Nonce) Get() Value { - return Value(atomic.LoadInt64(&n.n)) + n.m.Lock() + defer n.m.Unlock() + return Value(n.n) } // GetInc increments and returns the value of the nonce @@ -28,7 +33,9 @@ func (n *Nonce) GetInc() Value { // Set sets the nonce value func (n *Nonce) Set(val int64) { - atomic.StoreInt64(&n.n, val) + n.m.Lock() + n.n = val + n.m.Unlock() } // String returns a string version of the nonce