delayedACPsMu sync.Mutex
delayedACPs map[*txbuilder.TemplateBuilder][]*CtrlProgram
- acpIndexCap uint64 // points to end of block
accIndexMu sync.Mutex
}
}
func (m *Manager) createP2PKH(ctx context.Context, account *Account, change bool) (*CtrlProgram, error) {
- idx := m.nextAccountIndex(account)
+ idx := m.getNextXpubsIndex(account.Signer.XPubs)
path := signers.Path(account.Signer, signers.AccountKeySpace, idx)
derivedXPubs := chainkd.DeriveXPubs(account.XPubs, path)
derivedPK := derivedXPubs[0].PublicKey()
}
func (m *Manager) createP2SH(ctx context.Context, account *Account, change bool) (*CtrlProgram, error) {
- idx := m.nextAccountIndex(account)
+ idx := m.getNextXpubsIndex(account.Signer.XPubs)
path := signers.Path(account.Signer, signers.AccountKeySpace, idx)
derivedXPubs := chainkd.DeriveXPubs(account.XPubs, path)
derivedPKs := chainkd.XPubKeys(derivedXPubs)
return program.ControlProgram, nil
}
-func (m *Manager) nextAccountIndex(account *Account) uint64 {
- return m.getNextXpubsIndex(account.Signer.XPubs)
-}
-
// DeleteAccount deletes the account's ID or alias matching accountInfo.
func (m *Manager) DeleteAccount(in struct {
AccountInfo string `json:"account_info"`
path string
request interface{}
respWant *Response
- respWantErr error
}{
{
path: "/create-key",
package api
import (
- "expvar"
"net/http"
"sync"
"time"
"github.com/bytom/metrics"
- "github.com/bytom/net/http/reqid"
)
var (
}
return nil
}
-
-var (
- ncoreMu sync.Mutex
- ncore = expvar.NewInt("ncore")
- ncoreTime time.Time
- coresSeen map[string]bool
-)
-
-func coreCounter(h http.Handler) http.Handler {
- return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
- countCore(reqid.CoreIDFromContext(req.Context()))
- h.ServeHTTP(w, req)
- })
-}
-
-func countCore(id string) {
- t := time.Now()
- ncoreMu.Lock()
- defer ncoreMu.Unlock()
- if t.Sub(ncoreTime) > time.Minute {
- ncore.Set(int64(len(coresSeen)))
- ncoreTime = t
- coresSeen = make(map[string]bool)
- }
- coresSeen[id] = true
-}
"sync"
"github.com/golang/groupcache/lru"
- "github.com/golang/groupcache/singleflight"
dbm "github.com/tendermint/tmlibs/db"
"golang.org/x/crypto/sha3"
db dbm.DB
chain *protocol.Chain
- idGroup singleflight.Group
- aliasGroup singleflight.Group
-
cacheMu sync.Mutex
cache *lru.Cache
aliasCache *lru.Cache
return ripemd.Sum(nil)
}
-
-func zeroBytes(bytes []byte) {
- for i := range bytes {
- bytes[i] = 0
- }
-}
-
-func toInt(bytes []byte) []int {
- ints := make([]int, len(bytes))
- for i := range bytes {
- ints[i] = int(bytes[i])
- }
- return ints
-}
-
-func toBytes(ints []int) []byte {
- bytes := make([]byte, len(ints))
- for i := range ints {
- bytes[i] = byte(ints[i])
- }
- return bytes
-}
"github.com/bytom/protocol/state"
)
-// maxCachedValidatedTxs is the max number of validated txs to cache.
const (
- maxCachedValidatedTxs = 1000
maxProcessBlockChSize = 1024
)