From a4997ddf1eed5285eabd5fde01261826ca3de631 Mon Sep 17 00:00:00 2001
From: auxten
Date: Mon, 5 Nov 2018 11:59:26 +0800
Subject: [PATCH 001/278] Fix typo in log import
---
client/_example/simple.go | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/client/_example/simple.go b/client/_example/simple.go
index 1dd270aab..cc8c88464 100644
--- a/client/_example/simple.go
+++ b/client/_example/simple.go
@@ -22,7 +22,7 @@ import (
"fmt"
"github.com/CovenantSQL/CovenantSQL/client"
- log "github.com/sirupsen/logrus"
+ "github.com/CovenantSQL/CovenantSQL/utils/log"
)
func main() {
From 674cafe5af7a63890770e58f4ea19ac3f28a326b Mon Sep 17 00:00:00 2001
From: auxten
Date: Fri, 9 Nov 2018 02:59:55 +0800
Subject: [PATCH 002/278] Prune useless chain pkg code
---
chain/doc.go | 18 ----
chain/errors.go | 28 ------
chain/interfaces/doc.go | 18 ----
chain/interfaces/transaction.go | 49 ----------
chain/persistence.go | 124 ------------------------
chain/persistence_test.go | 159 -------------------------------
chain/txindex.go | 125 ------------------------
chain/txindex_test.go | 84 ----------------
chain/xxx_gen_test.go | 31 ------
chain/xxx_gen_test_test.go | 47 ---------
chain/xxx_test.go | 163 --------------------------------
11 files changed, 846 deletions(-)
delete mode 100644 chain/doc.go
delete mode 100644 chain/errors.go
delete mode 100644 chain/interfaces/doc.go
delete mode 100644 chain/interfaces/transaction.go
delete mode 100644 chain/persistence.go
delete mode 100644 chain/persistence_test.go
delete mode 100644 chain/txindex.go
delete mode 100644 chain/txindex_test.go
delete mode 100644 chain/xxx_gen_test.go
delete mode 100644 chain/xxx_gen_test_test.go
delete mode 100644 chain/xxx_test.go
diff --git a/chain/doc.go b/chain/doc.go
deleted file mode 100644
index 2fa161437..000000000
--- a/chain/doc.go
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- * Copyright 2018 The CovenantSQL Authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-// Package chain defines commonly types for block chain.
-package chain
diff --git a/chain/errors.go b/chain/errors.go
deleted file mode 100644
index f936a24db..000000000
--- a/chain/errors.go
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright 2018 The CovenantSQL Authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package chain
-
-import "errors"
-
-var (
- // ErrUnknownTx indicates that the transaction is unknown.
- ErrUnknownTx = errors.New("unknown transaction")
- // ErrDuplicateTx indicates that the transaction will be duplicate in the new block.
- ErrDuplicateTx = errors.New("duplicate transaction")
- // ErrCorruptedIndex indicates that a corrupted index item is detected.
- ErrCorruptedIndex = errors.New("corrupted index")
-)
diff --git a/chain/interfaces/doc.go b/chain/interfaces/doc.go
deleted file mode 100644
index 222335fed..000000000
--- a/chain/interfaces/doc.go
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- * Copyright 2018 The CovenantSQL Authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-// Package interfaces defines commonly used interfaces for block chain.
-package interfaces
diff --git a/chain/interfaces/transaction.go b/chain/interfaces/transaction.go
deleted file mode 100644
index 12f07957f..000000000
--- a/chain/interfaces/transaction.go
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright 2018 The CovenantSQL Authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package interfaces
-
-import (
- "time"
-
- "github.com/CovenantSQL/CovenantSQL/crypto/hash"
- "github.com/CovenantSQL/CovenantSQL/proto"
-)
-
-// Serializer is the interface implemented by an object that can serialize itself into binary form.
-type Serializer interface {
- Serialize() ([]byte, error)
-}
-
-// Deserializer is the interface implemented by an object that can deserialize a binary
-// representation of itself.
-type Deserializer interface {
- Deserialize(enc []byte) error
-}
-
-// Transaction is the interface implemented by an object that can be verified and processed by
-// a blockchain as a transaction.
-type Transaction interface {
- Serializer
- Deserializer
- GetDatabaseID() *proto.DatabaseID
- GetHash() hash.Hash
- GetIndexKey() interface{}
- GetPersistenceKey() []byte
- GetSequenceID() uint32
- GetTime() time.Time
- Verify() error
-}
diff --git a/chain/persistence.go b/chain/persistence.go
deleted file mode 100644
index 3cb46e4d7..000000000
--- a/chain/persistence.go
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * Copyright 2018 The CovenantSQL Authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package chain
-
-import (
- ci "github.com/CovenantSQL/CovenantSQL/chain/interfaces"
- "github.com/coreos/bbolt"
-)
-
-var (
- metaBucket = [4]byte{0x0, 0x0, 0x0, 0x0}
- metaTxIndexBucket = []byte("covenantsql-tx-index-bucket")
-)
-
-// TxPersistence defines a persistence storage for blockchain transactions.
-type TxPersistence struct {
- db *bolt.DB
-}
-
-// NewTxPersistence returns a new TxPersistence instance using the given bolt database as
-// underlying storage engine.
-func NewTxPersistence(db *bolt.DB) (ins *TxPersistence, err error) {
- // Initialize buckets
- if err = db.Update(func(tx *bolt.Tx) (err error) {
- meta, err := tx.CreateBucketIfNotExists(metaBucket[:])
- if err != nil {
- return
- }
- _, err = meta.CreateBucketIfNotExists(metaTxIndexBucket)
- return
- }); err != nil {
- return
- }
- // Create instance if succeed
- ins = &TxPersistence{db: db}
- return
-}
-
-// PutTransaction serializes and puts the transaction tx into the storage.
-func (p *TxPersistence) PutTransaction(tx ci.Transaction) (err error) {
- var key, value []byte
- key = tx.GetPersistenceKey()
- if value, err = tx.Serialize(); err != nil {
- return
- }
- return p.db.Update(func(tx *bolt.Tx) error {
- return tx.Bucket(metaBucket[:]).Bucket(metaTxIndexBucket).Put(key, value)
- })
-}
-
-// GetTransaction gets the transaction binary representation from the storage with key and
-// deserialize to tx.
-//
-// It is important that tx must provide an interface with corresponding concrete value, or the
-// deserialization will cause unexpected error.
-func (p *TxPersistence) GetTransaction(key []byte, tx ci.Transaction) (ok bool, err error) {
- var value []byte
- if err = p.db.View(func(tx *bolt.Tx) error {
- value = tx.Bucket(metaBucket[:]).Bucket(metaTxIndexBucket).Get(key)
- return nil
- }); err != nil {
- return
- }
- if value != nil {
- ok = true
- err = tx.Deserialize(value)
- return
- }
- return
-}
-
-// DelTransaction deletes the transaction from the storage with key.
-func (p *TxPersistence) DelTransaction(key []byte) (err error) {
- return p.db.Update(func(tx *bolt.Tx) error {
- return tx.Bucket(metaBucket[:]).Bucket(metaTxIndexBucket).Delete(key)
- })
-}
-
-// PutTransactionAndUpdateIndex serializes and puts the transaction from the storage with key
-// and updates transaction index ti in a single database transaction.
-func (p *TxPersistence) PutTransactionAndUpdateIndex(tx ci.Transaction, ti *TxIndex) (err error) {
- var (
- key = tx.GetPersistenceKey()
- val []byte
- )
- if val, err = tx.Serialize(); err != nil {
- return
- }
- return p.db.Update(func(dbtx *bolt.Tx) (err error) {
- if err = dbtx.Bucket(metaBucket[:]).Bucket(metaTxIndexBucket).Put(key, val); err != nil {
- return
- }
- ti.StoreTx(tx)
- return
- })
-}
-
-// DelTransactionAndUpdateIndex deletes the transaction from the storage with key and updates
-// transaction index ti in a single database transaction.
-func (p *TxPersistence) DelTransactionAndUpdateIndex(
- pkey []byte, ikey interface{}, ti *TxIndex) (err error,
-) {
- return p.db.Update(func(dbtx *bolt.Tx) (err error) {
- if err = dbtx.Bucket(metaBucket[:]).Bucket(metaTxIndexBucket).Delete(pkey); err != nil {
- return
- }
- ti.DelTx(ikey)
- return
- })
-}
diff --git a/chain/persistence_test.go b/chain/persistence_test.go
deleted file mode 100644
index 963ca08fc..000000000
--- a/chain/persistence_test.go
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
- * Copyright 2018 The CovenantSQL Authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package chain
-
-import (
- "fmt"
- "path"
- "reflect"
- "testing"
-
- ci "github.com/CovenantSQL/CovenantSQL/chain/interfaces"
- "github.com/coreos/bbolt"
-)
-
-func TestBadNewTxPersistence(t *testing.T) {
- fl := path.Join(testDataDir, fmt.Sprintf("%s.db", t.Name()))
- db, err := bolt.Open(fl, 0600, nil)
- if err = db.Close(); err != nil {
- t.Fatalf("Error occurred: %v", err)
- }
- if _, err = NewTxPersistence(db); err == nil {
- t.Fatalf("Unexpected error: %v", err)
- }
-}
-
-func TestTxPersistenceWithClosedDB(t *testing.T) {
- fl := path.Join(testDataDir, fmt.Sprintf("%s.db", t.Name()))
- db, err := bolt.Open(fl, 0600, nil)
- if err != nil {
- t.Fatalf("Error occurred: %v", err)
- }
- tp, err := NewTxPersistence(db)
- if err != nil {
- t.Fatalf("Error occurred: %v", err)
- }
- if err = db.Close(); err != nil {
- t.Fatalf("Error occurred: %v", err)
- }
- var (
- otx ci.Transaction = newRandomDemoTxImpl()
- rtx ci.Transaction = &DemoTxImpl{}
- )
- if _, err := tp.GetTransaction(otx.GetPersistenceKey(), rtx); err == nil {
- t.Fatalf("Unexpected error: %v", err)
- }
- if err = tp.PutTransaction(otx); err == nil {
- t.Fatalf("Unexpected error: %v", err)
- }
- if err = tp.DelTransaction(otx.GetPersistenceKey()); err == nil {
- t.Fatalf("Unexpected error: %v", err)
- }
-}
-
-func TestTxPersistence(t *testing.T) {
- fl := path.Join(testDataDir, fmt.Sprintf("%s.db", t.Name()))
- db, err := bolt.Open(fl, 0600, nil)
- if err != nil {
- t.Fatalf("Error occurred: %v", err)
- }
- tp, err := NewTxPersistence(db)
- if err != nil {
- t.Fatalf("Error occurred: %v", err)
- }
-
- // Test operations: Get -> Put -> Get -> Del -> Get
- var (
- otx ci.Transaction = newRandomDemoTxImpl()
- rtx ci.Transaction = &DemoTxImpl{}
- )
- if ok, err := tp.GetTransaction(otx.GetPersistenceKey(), rtx); err != nil {
- t.Fatalf("Error occurred: %v", err)
- } else if ok {
- t.Fatalf("Unexpected query result: %v", ok)
- }
- if err = tp.PutTransaction(otx); err != nil {
- t.Fatalf("Error occurred: %v", err)
- }
- if ok, err := tp.GetTransaction(otx.GetPersistenceKey(), rtx); err != nil {
- t.Fatalf("Error occurred: %v", err)
- } else if !ok {
- t.Fatalf("Unexpected query result: %v", ok)
- } else if !reflect.DeepEqual(otx, rtx) {
- t.Fatalf("Unexpected result:\n\torigin = %v\n\toutput = %v", otx, rtx)
- }
- if err = tp.DelTransaction(otx.GetPersistenceKey()); err != nil {
- t.Fatalf("Error occurred: %v", err)
- }
- if ok, err := tp.GetTransaction(otx.GetPersistenceKey(), rtx); err != nil {
- t.Fatalf("Error occurred: %v", err)
- } else if ok {
- t.Fatalf("Unexpected query result: %v", ok)
- }
-}
-
-func TestTxPersistenceWithIndex(t *testing.T) {
- fl := path.Join(testDataDir, fmt.Sprintf("%s.db", t.Name()))
- db, err := bolt.Open(fl, 0600, nil)
- if err != nil {
- t.Fatalf("Error occurred: %v", err)
- }
- tp, err := NewTxPersistence(db)
- if err != nil {
- t.Fatalf("Error occurred: %v", err)
- }
- ti := NewTxIndex()
-
- // Test operations: Get -> Put -> Get -> Del -> Get
- var (
- otx ci.Transaction = newRandomDemoTxImpl()
- rtx ci.Transaction = &DemoTxImpl{}
- )
- if ok, err := tp.GetTransaction(otx.GetPersistenceKey(), rtx); err != nil {
- t.Fatalf("Error occurred: %v", err)
- } else if ok {
- t.Fatalf("Unexpected query result: %v", ok)
- }
- if err = tp.PutTransactionAndUpdateIndex(otx, ti); err != nil {
- t.Fatalf("Error occurred: %v", err)
- }
- if ok, err := tp.GetTransaction(otx.GetPersistenceKey(), rtx); err != nil {
- t.Fatalf("Error occurred: %v", err)
- } else if !ok {
- t.Fatalf("Unexpected query result: %v", ok)
- } else if !reflect.DeepEqual(otx, rtx) {
- t.Fatalf("Unexpected result:\n\torigin = %v\n\toutput = %v", otx, rtx)
- }
- if xtx, ok := ti.LoadTx(otx.GetIndexKey()); !ok {
- t.Fatalf("Unexpected query result: %v", ok)
- } else if !reflect.DeepEqual(otx, xtx) {
- t.Fatalf("Unexpected result:\n\torigin = %v\n\toutput = %v", otx, xtx)
- }
- if err = tp.DelTransactionAndUpdateIndex(
- otx.GetPersistenceKey(), otx.GetIndexKey(), ti,
- ); err != nil {
- t.Fatalf("Error occurred: %v", err)
- }
- if ok, err := tp.GetTransaction(otx.GetPersistenceKey(), rtx); err != nil {
- t.Fatalf("Error occurred: %v", err)
- } else if ok {
- t.Fatalf("Unexpected query result: %v", ok)
- }
- if _, ok := ti.LoadTx(otx.GetIndexKey()); ok {
- t.Fatalf("Unexpected query result: %v", ok)
- }
-}
diff --git a/chain/txindex.go b/chain/txindex.go
deleted file mode 100644
index 5d764e972..000000000
--- a/chain/txindex.go
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * Copyright 2018 The CovenantSQL Authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package chain
-
-import (
- "sync"
-
- ci "github.com/CovenantSQL/CovenantSQL/chain/interfaces"
- "github.com/CovenantSQL/CovenantSQL/crypto/hash"
-)
-
-type txCache struct {
- bh *hash.Hash
- tx ci.Transaction
-}
-
-// TxIndex defines transaction index.
-type TxIndex struct {
- index sync.Map
-}
-
-// NewTxIndex returns a new TxIndex instance.
-func NewTxIndex() *TxIndex {
- return &TxIndex{}
-}
-
-// StoreTx stores tx in the transaction index.
-func (i *TxIndex) StoreTx(tx ci.Transaction) {
- i.index.Store(tx.GetIndexKey(), &txCache{tx: tx})
-}
-
-// HasTx returns a boolean value indicating wether the transaction index has key or not.
-func (i *TxIndex) HasTx(key interface{}) (ok bool) {
- _, ok = i.index.Load(key)
- return
-}
-
-// LoadTx loads a transaction with key.
-func (i *TxIndex) LoadTx(key interface{}) (tx ci.Transaction, ok bool) {
- var (
- val interface{}
- tc *txCache
- )
- if val, ok = i.index.Load(key); ok {
- if tc = val.(*txCache); tc != nil {
- tx = tc.tx
- }
- }
- return
-}
-
-// SetBlock sets the block hash filed of txCache with key in the transaction index.
-func (i *TxIndex) SetBlock(key interface{}, bh hash.Hash) (ok bool) {
- var (
- val interface{}
- tc *txCache
- )
- if val, ok = i.index.Load(key); ok {
- if tc = val.(*txCache); tc != nil {
- tc.bh = &bh
- }
- }
- return
-}
-
-// DelTx deletes transaction with key in the transaction index.
-func (i *TxIndex) DelTx(key interface{}) {
- i.index.Delete(key)
-}
-
-// ResetBlock resets the block hash field of txCache with key in the transaction index.
-func (i *TxIndex) ResetBlock(key interface{}) (ok bool) {
- var (
- val interface{}
- tc *txCache
- )
- if val, ok = i.index.Load(key); ok {
- if tc = val.(*txCache); tc != nil {
- tc.bh = nil
- }
- }
- return
-}
-
-// CheckTxState checks the transaction state for block packing with key in the transaction index.
-func (i *TxIndex) CheckTxState(key interface{}) error {
- var (
- ok bool
- val interface{}
- )
- if val, ok = i.index.Load(key); !ok {
- return ErrUnknownTx
- }
- if tc := val.(*txCache); tc == nil {
- return ErrCorruptedIndex
- } else if tc.bh != nil {
- return ErrDuplicateTx
- }
- return nil
-}
-
-// FetchUnpackedTxes fetches all unpacked tranactions and returns them as a slice.
-func (i *TxIndex) FetchUnpackedTxes() (txes []ci.Transaction) {
- i.index.Range(func(key interface{}, val interface{}) bool {
- if tc := val.(*txCache); tc != nil && tc.bh == nil {
- txes = append(txes, tc.tx)
- }
- return true
- })
- return
-}
diff --git a/chain/txindex_test.go b/chain/txindex_test.go
deleted file mode 100644
index bbe109d23..000000000
--- a/chain/txindex_test.go
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright 2018 The CovenantSQL Authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package chain
-
-import (
- "reflect"
- "testing"
-
- ci "github.com/CovenantSQL/CovenantSQL/chain/interfaces"
- "github.com/CovenantSQL/CovenantSQL/crypto/hash"
-)
-
-func TestTxIndex(t *testing.T) {
- var (
- ti = NewTxIndex()
- otx ci.Transaction = newRandomDemoTxImpl()
- )
- // Test operations: Get -> Put -> Get -> Del -> Get
- if ok := ti.HasTx(otx.GetIndexKey()); ok {
- t.Fatalf("Unexpected query result: %v", ok)
- }
- if _, ok := ti.LoadTx(otx.GetIndexKey()); ok {
- t.Fatalf("Unexpected query result: %v", ok)
- }
- if ok := ti.SetBlock(otx.GetIndexKey(), hash.Hash{}); ok {
- t.Fatalf("Unexpected query result: %v", ok)
- }
- if err := ti.CheckTxState(otx.GetIndexKey()); err != ErrUnknownTx {
- t.Fatalf("Unexpected error: %v", err)
- }
- ti.StoreTx(otx)
- if ok := ti.HasTx(otx.GetIndexKey()); !ok {
- t.Fatalf("Unexpected query result: %v", ok)
- }
- if xtx, ok := ti.LoadTx(otx.GetIndexKey()); !ok {
- t.Fatalf("Unexpected query result: %v", ok)
- } else if !reflect.DeepEqual(otx, xtx) {
- t.Fatalf("Unexpected result:\n\torigin = %v\n\toutput = %v", otx, xtx)
- }
- if err := ti.CheckTxState(otx.GetIndexKey()); err != nil {
- t.Fatalf("Unexpected error: %v", err)
- }
- if ok := ti.SetBlock(otx.GetIndexKey(), hash.Hash{}); !ok {
- t.Fatalf("Unexpected query result: %v", ok)
- }
- if err := ti.CheckTxState(otx.GetIndexKey()); err != ErrDuplicateTx {
- t.Fatalf("Unexpected error: %v", err)
- }
- if ok := ti.ResetBlock(otx.GetIndexKey()); !ok {
- t.Fatalf("Unexpected query result: %v", ok)
- }
- if txes := ti.FetchUnpackedTxes(); len(txes) != 1 {
- t.Fatalf("Unexpected query result: %v", txes)
- } else if !reflect.DeepEqual(otx, txes[0]) {
- t.Fatalf("Unexpected result:\n\torigin = %v\n\toutput = %v", otx, txes[0])
- }
- ti.DelTx(otx.GetIndexKey())
- if ok := ti.HasTx(otx.GetIndexKey()); ok {
- t.Fatalf("Unexpected query result: %v", ok)
- }
- if _, ok := ti.LoadTx(otx.GetIndexKey()); ok {
- t.Fatalf("Unexpected query result: %v", ok)
- }
- if ok := ti.SetBlock(otx.GetIndexKey(), hash.Hash{}); ok {
- t.Fatalf("Unexpected query result: %v", ok)
- }
- if err := ti.CheckTxState(otx.GetIndexKey()); err != ErrUnknownTx {
- t.Fatalf("Unexpected error: %v", err)
- }
-}
diff --git a/chain/xxx_gen_test.go b/chain/xxx_gen_test.go
deleted file mode 100644
index ed7deaa59..000000000
--- a/chain/xxx_gen_test.go
+++ /dev/null
@@ -1,31 +0,0 @@
-package chain
-
-// Code generated by github.com/CovenantSQL/HashStablePack DO NOT EDIT.
-
-import (
- hsp "github.com/CovenantSQL/HashStablePack/marshalhash"
-)
-
-// MarshalHash marshals for hash
-func (z *DemoHeader) MarshalHash() (o []byte, err error) {
- var b []byte
- o = hsp.Require(b, z.Msgsize())
- // map header, size 3
- o = append(o, 0x83, 0x83)
- if oTemp, err := z.DatabaseID.MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
- }
- o = append(o, 0x83)
- o = hsp.AppendTime(o, z.Timestamp)
- o = append(o, 0x83)
- o = hsp.AppendUint32(o, z.SequenceID)
- return
-}
-
-// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
-func (z *DemoHeader) Msgsize() (s int) {
- s = 1 + 11 + z.DatabaseID.Msgsize() + 10 + hsp.TimeSize + 11 + hsp.Uint32Size
- return
-}
diff --git a/chain/xxx_gen_test_test.go b/chain/xxx_gen_test_test.go
deleted file mode 100644
index 04c1be79d..000000000
--- a/chain/xxx_gen_test_test.go
+++ /dev/null
@@ -1,47 +0,0 @@
-package chain
-
-// Code generated by github.com/CovenantSQL/HashStablePack DO NOT EDIT.
-
-import (
- "bytes"
- "crypto/rand"
- "encoding/binary"
- "testing"
-)
-
-func TestMarshalHashDemoHeader(t *testing.T) {
- v := DemoHeader{}
- binary.Read(rand.Reader, binary.BigEndian, &v)
- bts1, err := v.MarshalHash()
- if err != nil {
- t.Fatal(err)
- }
- bts2, err := v.MarshalHash()
- if err != nil {
- t.Fatal(err)
- }
- if !bytes.Equal(bts1, bts2) {
- t.Fatal("hash not stable")
- }
-}
-
-func BenchmarkMarshalHashDemoHeader(b *testing.B) {
- v := DemoHeader{}
- b.ReportAllocs()
- b.ResetTimer()
- for i := 0; i < b.N; i++ {
- v.MarshalHash()
- }
-}
-
-func BenchmarkAppendMsgDemoHeader(b *testing.B) {
- v := DemoHeader{}
- bts := make([]byte, 0, v.Msgsize())
- bts, _ = v.MarshalHash()
- b.SetBytes(int64(len(bts)))
- b.ReportAllocs()
- b.ResetTimer()
- for i := 0; i < b.N; i++ {
- bts, _ = v.MarshalHash()
- }
-}
diff --git a/chain/xxx_test.go b/chain/xxx_test.go
deleted file mode 100644
index 80c28b153..000000000
--- a/chain/xxx_test.go
+++ /dev/null
@@ -1,163 +0,0 @@
-/*
- * Copyright 2018 The CovenantSQL Authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package chain
-
-import (
- "io/ioutil"
- "math/rand"
- "os"
- "testing"
- "time"
-
- "github.com/CovenantSQL/CovenantSQL/crypto/asymmetric"
- "github.com/CovenantSQL/CovenantSQL/crypto/hash"
- "github.com/CovenantSQL/CovenantSQL/proto"
- "github.com/CovenantSQL/CovenantSQL/utils"
-)
-
-var (
- testDataDir string
- testPrivKey *asymmetric.PrivateKey
- testPubKey *asymmetric.PublicKey
-)
-
-func createRandomString(offset, length int) string {
- buff := make([]byte, rand.Intn(length)+offset)
- rand.Read(buff)
- for i, v := range buff {
- buff[i] = v%(0x7f-0x20) + 0x20
- }
- return string(buff)
-}
-
-type DemoHeader struct {
- DatabaseID proto.DatabaseID
- SequenceID uint32
- Timestamp time.Time
-}
-
-type DemoTxImpl struct {
- DemoHeader
- HeaderHash hash.Hash
- Signee *asymmetric.PublicKey
- Signature *asymmetric.Signature
-}
-
-func newRandomDemoTxImpl() (i *DemoTxImpl) {
- header := DemoHeader{
- DatabaseID: proto.DatabaseID(createRandomString(10, 10)),
- SequenceID: rand.Uint32(),
- Timestamp: time.Now().UTC(),
- }
-
- enc, err := header.MarshalHash()
- if err != nil {
- panic(err)
- }
-
- hh := hash.HashH(enc)
- sig, err := testPrivKey.Sign(hh[:])
- if err != nil {
- panic(err)
- }
-
- i = &DemoTxImpl{
- DemoHeader: header,
- HeaderHash: hh,
- Signee: testPubKey,
- Signature: sig,
- }
- return
-}
-
-func (i *DemoTxImpl) Serialize() (enc []byte, err error) {
- if b, err := utils.EncodeMsgPack(i); err == nil {
- enc = b.Bytes()
- }
- return
-}
-
-func (i *DemoTxImpl) Deserialize(enc []byte) error {
- return utils.DecodeMsgPack(enc, i)
-}
-
-func (i *DemoTxImpl) GetDatabaseID() *proto.DatabaseID {
- return &i.DatabaseID
-}
-
-func (i *DemoTxImpl) GetHash() hash.Hash {
- return i.HeaderHash
-}
-
-func (i *DemoTxImpl) GetIndexKey() interface{} {
- return i.HeaderHash
-}
-
-func (i *DemoTxImpl) GetPersistenceKey() []byte {
- return i.HeaderHash[:]
-}
-
-func (i *DemoTxImpl) GetSequenceID() uint32 {
- return i.SequenceID
-}
-
-func (i *DemoTxImpl) GetTime() time.Time {
- return i.Timestamp
-}
-
-func (i *DemoTxImpl) Verify() (err error) {
- var enc []byte
- if enc, err = i.DemoHeader.MarshalHash(); err != nil {
- return
- } else if h := hash.THashH(enc); !i.HeaderHash.IsEqual(&h) {
- return
- } else if !i.Signature.Verify(h[:], i.Signee) {
- return
- }
- return
-}
-
-func setup() {
- // Setup RNG
- rand.Seed(time.Now().UnixNano())
-
- var err error
- // Create temp directory
- testDataDir, err = ioutil.TempDir("", "covenantsql")
- if err != nil {
- panic(err)
- }
- // Create key pair for test
- testPrivKey, testPubKey, err = asymmetric.GenSecp256k1KeyPair()
- if err != nil {
- panic(err)
- }
-}
-
-func teardown() {
- if err := os.RemoveAll(testDataDir); err != nil {
- panic(err)
- }
-}
-
-func TestMain(m *testing.M) {
- os.Exit(func() int {
- setup()
- defer teardown()
- return m.Run()
- }())
-}
From f061ab1c87e9d1cad78bcd3d7c729340392800c7 Mon Sep 17 00:00:00 2001
From: auxten
Date: Fri, 9 Nov 2018 03:00:52 +0800
Subject: [PATCH 003/278] Fix PersistentCaller Reconnect logic
---
rpc/rpcutil.go | 39 +++++++++++++++++++++++----------------
1 file changed, 23 insertions(+), 16 deletions(-)
diff --git a/rpc/rpcutil.go b/rpc/rpcutil.go
index cafd60d43..d39b12c86 100644
--- a/rpc/rpcutil.go
+++ b/rpc/rpcutil.go
@@ -61,12 +61,12 @@ func NewPersistentCaller(target proto.NodeID) *PersistentCaller {
}
}
-func (c *PersistentCaller) initClient(method string) (err error) {
+func (c *PersistentCaller) initClient(isAnonymous bool) (err error) {
c.Lock()
defer c.Unlock()
if c.client == nil {
var conn net.Conn
- conn, err = DialToNode(c.TargetID, c.pool, method == route.DHTPing.String())
+ conn, err = DialToNode(c.TargetID, c.pool, isAnonymous)
if err != nil {
log.WithField("target", c.TargetID).WithError(err).Error("dial to node failed")
return
@@ -83,28 +83,21 @@ func (c *PersistentCaller) initClient(method string) (err error) {
// Call invokes the named function, waits for it to complete, and returns its error status.
func (c *PersistentCaller) Call(method string, args interface{}, reply interface{}) (err error) {
- err = c.initClient(method)
+ err = c.initClient(method == route.DHTPing.String())
if err != nil {
log.WithError(err).Error("init PersistentCaller client failed")
return
}
err = c.client.Call(method, args, reply)
if err != nil {
- if err == io.EOF || err == io.ErrUnexpectedEOF {
+ if err == io.EOF ||
+ err == io.ErrUnexpectedEOF ||
+ err == io.ErrClosedPipe ||
+ err == rpc.ErrShutdown {
// if got EOF, retry once
- c.Lock()
- c.Close()
- c.client = nil
- c.Unlock()
- err = c.initClient(method)
+ err = c.Reconnect(method)
if err != nil {
- log.WithField("rpc", method).WithError(err).Error("second init client for RPC failed")
- return
- }
- err = c.client.Call(method, args, reply)
- if err != nil {
- log.WithField("rpc", method).WithError(err).Error("second time call RPC failed")
- return
+ log.WithField("rpc", method).WithError(err).Error("reconnect failed")
}
}
log.WithField("rpc", method).WithError(err).Error("call RPC failed")
@@ -112,6 +105,20 @@ func (c *PersistentCaller) Call(method string, args interface{}, reply interface
return
}
+// Reconnect tries to rebuild RPC client
+func (c *PersistentCaller) Reconnect(method string) (err error) {
+ c.Lock()
+ c.Close()
+ c.client = nil
+ c.Unlock()
+ err = c.initClient(method == route.DHTPing.String())
+ if err != nil {
+ log.WithField("rpc", method).WithError(err).Error("second init client for RPC failed")
+ return
+ }
+ return
+}
+
// CloseStream closes the stream and RPC client
func (c *PersistentCaller) CloseStream() {
if c.client != nil {
From f93ad7856881d1c3a8ac17addccf841ff007d2df Mon Sep 17 00:00:00 2001
From: auxten
Date: Fri, 9 Nov 2018 11:10:17 +0800
Subject: [PATCH 004/278] Add chainbus prototype
---
chainbus/bus.go | 224 +++++++++++++++++++++++++++++++++++++++++++
chainbus/bus_test.go | 175 +++++++++++++++++++++++++++++++++
chainbus/doc.go | 39 ++++++++
3 files changed, 438 insertions(+)
create mode 100644 chainbus/bus.go
create mode 100644 chainbus/bus_test.go
create mode 100644 chainbus/doc.go
diff --git a/chainbus/bus.go b/chainbus/bus.go
new file mode 100644
index 000000000..2a01f5e34
--- /dev/null
+++ b/chainbus/bus.go
@@ -0,0 +1,224 @@
+/*
+ * Copyright 2018 The CovenantSQL Authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package chainbus
+
+import (
+ "fmt"
+ "reflect"
+ "sync"
+
+ bi "github.com/CovenantSQL/CovenantSQL/blockproducer/interfaces"
+)
+
+type ChainSuber interface {
+ Subscribe(topic bi.TransactionType, handler interface{}) error
+ SubscribeAsync(topic bi.TransactionType, handler interface{}, transactional bool) error
+ SubscribeOnce(topic bi.TransactionType, handler interface{}) error
+ SubscribeOnceAsync(topic bi.TransactionType, handler interface{}) error
+ Unsubscribe(topic bi.TransactionType, handler interface{}) error
+}
+
+//ChainPuber defines publishing-related bus behavior
+type ChainPuber interface {
+ Publish(topic bi.TransactionType, args ...interface{})
+}
+
+//BusController defines bus control behavior (checking handler's presence, synchronization)
+type BusController interface {
+ HasCallback(topic bi.TransactionType) bool
+ WaitAsync()
+}
+
+//Bus englobes global (subscribe, publish, control) bus behavior
+type Bus interface {
+ BusController
+ ChainSuber
+ ChainPuber
+}
+
+// ChainBus - box for handlers and callbacks.
+type ChainBus struct {
+ handlers map[bi.TransactionType][]*eventHandler
+ lock sync.Mutex // a lock for the map
+ wg sync.WaitGroup
+}
+
+type eventHandler struct {
+ callBack reflect.Value
+ flagOnce bool
+ async bool
+ transactional bool
+ sync.Mutex // lock for an event handler - useful for running async callbacks serially
+}
+
+// New returns new ChainBus with empty handlers.
+func New() Bus {
+ b := &ChainBus{
+ make(map[bi.TransactionType][]*eventHandler),
+ sync.Mutex{},
+ sync.WaitGroup{},
+ }
+ return b
+}
+
+// doSubscribe handles the subscription logic and is utilized by the public Subscribe functions
+func (bus *ChainBus) doSubscribe(topic bi.TransactionType, fn interface{}, handler *eventHandler) error {
+ bus.lock.Lock()
+ defer bus.lock.Unlock()
+ if !(reflect.TypeOf(fn).Kind() == reflect.Func) {
+ return fmt.Errorf("%s is not of type reflect.Func", reflect.TypeOf(fn).Kind())
+ }
+ bus.handlers[topic] = append(bus.handlers[topic], handler)
+ return nil
+}
+
+// Subscribe subscribes to a topic.
+// Returns error if `fn` is not a function.
+func (bus *ChainBus) Subscribe(topic bi.TransactionType, fn interface{}) error {
+ return bus.doSubscribe(topic, fn, &eventHandler{
+ reflect.ValueOf(fn), false, false, false, sync.Mutex{},
+ })
+}
+
+// SubscribeAsync subscribes to a topic with an asynchronous callback
+// Transactional determines whether subsequent callbacks for a topic are
+// run serially (true) or concurrently (false)
+// Returns error if `fn` is not a function.
+func (bus *ChainBus) SubscribeAsync(topic bi.TransactionType, fn interface{}, transactional bool) error {
+ return bus.doSubscribe(topic, fn, &eventHandler{
+ reflect.ValueOf(fn), false, true, transactional, sync.Mutex{},
+ })
+}
+
+// SubscribeOnce subscribes to a topic once. Handler will be removed after executing.
+// Returns error if `fn` is not a function.
+func (bus *ChainBus) SubscribeOnce(topic bi.TransactionType, fn interface{}) error {
+ return bus.doSubscribe(topic, fn, &eventHandler{
+ reflect.ValueOf(fn), true, false, false, sync.Mutex{},
+ })
+}
+
+// SubscribeOnceAsync subscribes to a topic once with an asynchronous callback
+// Handler will be removed after executing.
+// Returns error if `fn` is not a function.
+func (bus *ChainBus) SubscribeOnceAsync(topic bi.TransactionType, fn interface{}) error {
+ return bus.doSubscribe(topic, fn, &eventHandler{
+ reflect.ValueOf(fn), true, true, false, sync.Mutex{},
+ })
+}
+
+// HasCallback returns true if exists any callback subscribed to the topic.
+func (bus *ChainBus) HasCallback(topic bi.TransactionType) bool {
+ bus.lock.Lock()
+ defer bus.lock.Unlock()
+ _, ok := bus.handlers[topic]
+ if ok {
+ return len(bus.handlers[topic]) > 0
+ }
+ return false
+}
+
+// Unsubscribe removes callback defined for a topic.
+// Returns error if there are no callbacks subscribed to the topic.
+func (bus *ChainBus) Unsubscribe(topic bi.TransactionType, handler interface{}) error {
+ bus.lock.Lock()
+ defer bus.lock.Unlock()
+ if _, ok := bus.handlers[topic]; ok && len(bus.handlers[topic]) > 0 {
+ bus.removeHandler(topic, bus.findHandlerIdx(topic, reflect.ValueOf(handler)))
+ return nil
+ }
+ return fmt.Errorf("topic %s doesn't exist", topic)
+}
+
+// Publish executes callback defined for a topic. Any additional argument will be transferred to the callback.
+func (bus *ChainBus) Publish(topic bi.TransactionType, args ...interface{}) {
+ bus.lock.Lock() // will unlock if handler is not found or always after setUpPublish
+ defer bus.lock.Unlock()
+ if handlers, ok := bus.handlers[topic]; ok && 0 < len(handlers) {
+ // Handlers slice may be changed by removeHandler and Unsubscribe during iteration,
+ // so make a copy and iterate the copied slice.
+ copyHandlers := make([]*eventHandler, 0, len(handlers))
+ copyHandlers = append(copyHandlers, handlers...)
+ for i, handler := range copyHandlers {
+ if handler.flagOnce {
+ bus.removeHandler(topic, i)
+ }
+ if !handler.async {
+ bus.doPublish(handler, topic, args...)
+ } else {
+ bus.wg.Add(1)
+ if handler.transactional {
+ handler.Lock()
+ }
+ go bus.doPublishAsync(handler, topic, args...)
+ }
+ }
+ }
+}
+
+func (bus *ChainBus) doPublish(handler *eventHandler, topic bi.TransactionType, args ...interface{}) {
+ passedArguments := bus.setUpPublish(topic, args...)
+ handler.callBack.Call(passedArguments)
+}
+
+func (bus *ChainBus) doPublishAsync(handler *eventHandler, topic bi.TransactionType, args ...interface{}) {
+ defer bus.wg.Done()
+ if handler.transactional {
+ defer handler.Unlock()
+ }
+ bus.doPublish(handler, topic, args...)
+}
+
+func (bus *ChainBus) removeHandler(topic bi.TransactionType, idx int) {
+ if _, ok := bus.handlers[topic]; !ok {
+ return
+ }
+ l := len(bus.handlers[topic])
+
+ if !(0 <= idx && idx < l) {
+ return
+ }
+
+ copy(bus.handlers[topic][idx:], bus.handlers[topic][idx+1:])
+ bus.handlers[topic][l-1] = nil // or the zero value of T
+ bus.handlers[topic] = bus.handlers[topic][:l-1]
+}
+
+func (bus *ChainBus) findHandlerIdx(topic bi.TransactionType, callback reflect.Value) int {
+ if _, ok := bus.handlers[topic]; ok {
+ for idx, handler := range bus.handlers[topic] {
+ if handler.callBack == callback {
+ return idx
+ }
+ }
+ }
+ return -1
+}
+
+func (bus *ChainBus) setUpPublish(topic bi.TransactionType, args ...interface{}) []reflect.Value {
+
+ passedArguments := make([]reflect.Value, 0)
+ for _, arg := range args {
+ passedArguments = append(passedArguments, reflect.ValueOf(arg))
+ }
+ return passedArguments
+}
+
+// WaitAsync waits for all async callbacks to complete
+func (bus *ChainBus) WaitAsync() {
+ bus.wg.Wait()
+}
diff --git a/chainbus/bus_test.go b/chainbus/bus_test.go
new file mode 100644
index 000000000..55b4cc453
--- /dev/null
+++ b/chainbus/bus_test.go
@@ -0,0 +1,175 @@
+/*
+ * Copyright 2018 The CovenantSQL Authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package chainbus
+
+import (
+ "sync/atomic"
+ "testing"
+ "time"
+
+ bi "github.com/CovenantSQL/CovenantSQL/blockproducer/interfaces"
+)
+
+func TestNew(t *testing.T) {
+ bus := New()
+ if bus == nil {
+ t.Log("New EventBus not created!")
+ t.Fail()
+ }
+}
+
+func TestHasCallback(t *testing.T) {
+ bus := New()
+ bus.Subscribe(bi.TransactionType(1), func() {})
+ if bus.HasCallback(bi.TransactionType(2)) {
+ t.Fail()
+ }
+ if !bus.HasCallback(bi.TransactionType(1)) {
+ t.Fail()
+ }
+}
+
+func TestSubscribe(t *testing.T) {
+ bus := New()
+ if bus.Subscribe(bi.TransactionType(1), func() {}) != nil {
+ t.Fail()
+ }
+ if bus.Subscribe(bi.TransactionType(1), "String") == nil {
+ t.Fail()
+ }
+}
+
+func TestSubscribeOnce(t *testing.T) {
+ bus := New()
+ if bus.SubscribeOnce(bi.TransactionType(1), func() {}) != nil {
+ t.Fail()
+ }
+ if bus.SubscribeOnce(bi.TransactionType(1), "String") == nil {
+ t.Fail()
+ }
+}
+
+func TestSubscribeOnceAndManySubscribe(t *testing.T) {
+ bus := New()
+ event := bi.TransactionType(1)
+ flag := 0
+ fn := func() { flag += 1 }
+ bus.SubscribeOnce(event, fn)
+ bus.Subscribe(event, fn)
+ bus.Subscribe(event, fn)
+ bus.Publish(event)
+
+ if flag != 3 {
+ t.Fail()
+ }
+}
+
+func TestUnsubscribe(t *testing.T) {
+ bus := New()
+ handler := func() {}
+ bus.Subscribe(bi.TransactionType(1), handler)
+ if bus.Unsubscribe(bi.TransactionType(1), handler) != nil {
+ t.Fail()
+ }
+ if bus.Unsubscribe(bi.TransactionType(1), handler) == nil {
+ t.Fail()
+ }
+}
+
+func TestPublish(t *testing.T) {
+ bus := New()
+ bus.Subscribe(bi.TransactionType(1), func(a int, b int) {
+ if a != b {
+ t.Fail()
+ }
+ })
+ bus.Publish(bi.TransactionType(1), 10, 10)
+}
+
+func TestSubcribeOnceAsync(t *testing.T) {
+ results := make([]int, 0)
+
+ bus := New()
+ bus.SubscribeOnceAsync(bi.TransactionType(1), func(a int, out *[]int) {
+ *out = append(*out, a)
+ })
+
+ bus.Publish(bi.TransactionType(1), 10, &results)
+ bus.Publish(bi.TransactionType(1), 10, &results)
+
+ bus.WaitAsync()
+
+ if len(results) != 1 {
+ t.Fail()
+ }
+
+ if bus.HasCallback(bi.TransactionType(1)) {
+ t.Fail()
+ }
+}
+
+func TestSubscribeAsyncTransactional(t *testing.T) {
+ results := make([]int, 0)
+
+ bus := New()
+ bus.SubscribeAsync(bi.TransactionType(1), func(a int, out *[]int, dur string) {
+ sleep, _ := time.ParseDuration(dur)
+ time.Sleep(sleep)
+ *out = append(*out, a)
+ }, true)
+
+ bus.Publish(bi.TransactionType(1), 1, &results, "1s")
+ bus.Publish(bi.TransactionType(1), 2, &results, "0s")
+
+ bus.WaitAsync()
+
+ if len(results) != 2 {
+ t.Fail()
+ }
+
+ if results[0] != 1 || results[1] != 2 {
+ t.Fail()
+ }
+}
+
+func TestSubscribeAsync(t *testing.T) {
+ results := make(chan int)
+
+ bus := New()
+ bus.SubscribeAsync(bi.TransactionType(1), func(a int, out chan<- int) {
+ out <- a
+ }, false)
+
+ bus.Publish(bi.TransactionType(1), 1, results)
+ bus.Publish(bi.TransactionType(1), 2, results)
+
+ var numResults int32
+
+ go func() {
+ for _ = range results {
+ atomic.AddInt32(&numResults, 1)
+ }
+ }()
+
+ bus.WaitAsync()
+
+ time.Sleep(10 * time.Millisecond)
+
+ if atomic.LoadInt32(&numResults) != 2 {
+ t.Fail()
+ }
+}
diff --git a/chainbus/doc.go b/chainbus/doc.go
new file mode 100644
index 000000000..d606ba5bb
--- /dev/null
+++ b/chainbus/doc.go
@@ -0,0 +1,39 @@
+//The MIT License (MIT)
+//
+//Copyright (c) 2014 Alex Saskevich
+//
+//Permission is hereby granted, free of charge, to any person obtaining a copy
+//of this software and associated documentation files (the "Software"), to deal
+//in the Software without restriction, including without limitation the rights
+//to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+//copies of the Software, and to permit persons to whom the Software is
+//furnished to do so, subject to the following conditions:
+//
+//The above copyright notice and this permission notice shall be included in all
+//copies or substantial portions of the Software.
+//
+//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+//IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+//FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+//AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+//LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+//OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+//SOFTWARE.
+
+/*
+ * Copyright 2018 The CovenantSQL Authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package chainbus
From 85b431de9b6fb0f80f22211a4b983afd1f2bf3c1 Mon Sep 17 00:00:00 2001
From: auxten
Date: Fri, 9 Nov 2018 11:10:53 +0800
Subject: [PATCH 005/278] Format imports
---
client/driver.go | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/client/driver.go b/client/driver.go
index 274c32e70..e68ab8a5f 100644
--- a/client/driver.go
+++ b/client/driver.go
@@ -25,6 +25,8 @@ import (
"sync/atomic"
"time"
+ "github.com/pkg/errors"
+
bp "github.com/CovenantSQL/CovenantSQL/blockproducer"
"github.com/CovenantSQL/CovenantSQL/conf"
"github.com/CovenantSQL/CovenantSQL/crypto"
@@ -35,7 +37,6 @@ import (
"github.com/CovenantSQL/CovenantSQL/rpc"
"github.com/CovenantSQL/CovenantSQL/utils/log"
wt "github.com/CovenantSQL/CovenantSQL/worker/types"
- "github.com/pkg/errors"
)
const (
From 540f57870e1908a148382ad278042226357ffbcc Mon Sep 17 00:00:00 2001
From: auxten
Date: Mon, 19 Nov 2018 14:06:45 +0800
Subject: [PATCH 006/278] Change topic to string type
---
chainbus/bus.go | 48 ++++++++++++++++++++++----------------------
chainbus/bus_test.go | 48 +++++++++++++++++++++-----------------------
2 files changed, 47 insertions(+), 49 deletions(-)
diff --git a/chainbus/bus.go b/chainbus/bus.go
index e2bcfebec..293decca5 100644
--- a/chainbus/bus.go
+++ b/chainbus/bus.go
@@ -20,27 +20,25 @@ import (
"fmt"
"reflect"
"sync"
-
- bi "github.com/CovenantSQL/CovenantSQL/blockproducer/interfaces"
)
// ChainSuber defines subscribing-related bus behavior
type ChainSuber interface {
- Subscribe(topic bi.TransactionType, handler interface{}) error
- SubscribeAsync(topic bi.TransactionType, handler interface{}, transactional bool) error
- SubscribeOnce(topic bi.TransactionType, handler interface{}) error
- SubscribeOnceAsync(topic bi.TransactionType, handler interface{}) error
- Unsubscribe(topic bi.TransactionType, handler interface{}) error
+ Subscribe(topic string, handler interface{}) error
+ SubscribeAsync(topic string, handler interface{}, transactional bool) error
+ SubscribeOnce(topic string, handler interface{}) error
+ SubscribeOnceAsync(topic string, handler interface{}) error
+ Unsubscribe(topic string, handler interface{}) error
}
// ChainPuber defines publishing-related bus behavior
type ChainPuber interface {
- Publish(topic bi.TransactionType, args ...interface{})
+ Publish(topic string, args ...interface{})
}
// BusController defines bus control behavior (checking handler's presence, synchronization)
type BusController interface {
- HasCallback(topic bi.TransactionType) bool
+ HasCallback(topic string) bool
WaitAsync()
}
@@ -53,7 +51,7 @@ type Bus interface {
// ChainBus - box for handlers and callbacks.
type ChainBus struct {
- handlers map[bi.TransactionType][]*eventHandler
+ handlers map[string][]*eventHandler
lock sync.Mutex // a lock for the map
wg sync.WaitGroup
}
@@ -69,7 +67,7 @@ type eventHandler struct {
// New returns new ChainBus with empty handlers.
func New() Bus {
b := &ChainBus{
- make(map[bi.TransactionType][]*eventHandler),
+ make(map[string][]*eventHandler),
sync.Mutex{},
sync.WaitGroup{},
}
@@ -77,7 +75,7 @@ func New() Bus {
}
// doSubscribe handles the subscription logic and is utilized by the public Subscribe functions
-func (bus *ChainBus) doSubscribe(topic bi.TransactionType, fn interface{}, handler *eventHandler) error {
+func (bus *ChainBus) doSubscribe(topic string, fn interface{}, handler *eventHandler) error {
bus.lock.Lock()
defer bus.lock.Unlock()
if !(reflect.TypeOf(fn).Kind() == reflect.Func) {
@@ -89,17 +87,18 @@ func (bus *ChainBus) doSubscribe(topic bi.TransactionType, fn interface{}, handl
// Subscribe subscribes to a topic.
// Returns error if `fn` is not a function.
-func (bus *ChainBus) Subscribe(topic bi.TransactionType, fn interface{}) error {
+func (bus *ChainBus) Subscribe(topic string, fn interface{}) error {
return bus.doSubscribe(topic, fn, &eventHandler{
reflect.ValueOf(fn), false, false, false, sync.Mutex{},
})
}
// SubscribeAsync subscribes to a topic with an asynchronous callback
+// Async determines whether subsequent Publish should wait for callback return
// Transactional determines whether subsequent callbacks for a topic are
// run serially (true) or concurrently (false)
// Returns error if `fn` is not a function.
-func (bus *ChainBus) SubscribeAsync(topic bi.TransactionType, fn interface{}, transactional bool) error {
+func (bus *ChainBus) SubscribeAsync(topic string, fn interface{}, transactional bool) error {
return bus.doSubscribe(topic, fn, &eventHandler{
reflect.ValueOf(fn), false, true, transactional, sync.Mutex{},
})
@@ -107,23 +106,24 @@ func (bus *ChainBus) SubscribeAsync(topic bi.TransactionType, fn interface{}, tr
// SubscribeOnce subscribes to a topic once. Handler will be removed after executing.
// Returns error if `fn` is not a function.
-func (bus *ChainBus) SubscribeOnce(topic bi.TransactionType, fn interface{}) error {
+func (bus *ChainBus) SubscribeOnce(topic string, fn interface{}) error {
return bus.doSubscribe(topic, fn, &eventHandler{
reflect.ValueOf(fn), true, false, false, sync.Mutex{},
})
}
// SubscribeOnceAsync subscribes to a topic once with an asynchronous callback
+// Async determines whether subsequent Publish should wait for callback return
// Handler will be removed after executing.
// Returns error if `fn` is not a function.
-func (bus *ChainBus) SubscribeOnceAsync(topic bi.TransactionType, fn interface{}) error {
+func (bus *ChainBus) SubscribeOnceAsync(topic string, fn interface{}) error {
return bus.doSubscribe(topic, fn, &eventHandler{
reflect.ValueOf(fn), true, true, false, sync.Mutex{},
})
}
// HasCallback returns true if exists any callback subscribed to the topic.
-func (bus *ChainBus) HasCallback(topic bi.TransactionType) bool {
+func (bus *ChainBus) HasCallback(topic string) bool {
bus.lock.Lock()
defer bus.lock.Unlock()
_, ok := bus.handlers[topic]
@@ -135,7 +135,7 @@ func (bus *ChainBus) HasCallback(topic bi.TransactionType) bool {
// Unsubscribe removes callback defined for a topic.
// Returns error if there are no callbacks subscribed to the topic.
-func (bus *ChainBus) Unsubscribe(topic bi.TransactionType, handler interface{}) error {
+func (bus *ChainBus) Unsubscribe(topic string, handler interface{}) error {
bus.lock.Lock()
defer bus.lock.Unlock()
if _, ok := bus.handlers[topic]; ok && len(bus.handlers[topic]) > 0 {
@@ -146,7 +146,7 @@ func (bus *ChainBus) Unsubscribe(topic bi.TransactionType, handler interface{})
}
// Publish executes callback defined for a topic. Any additional argument will be transferred to the callback.
-func (bus *ChainBus) Publish(topic bi.TransactionType, args ...interface{}) {
+func (bus *ChainBus) Publish(topic string, args ...interface{}) {
bus.lock.Lock() // will unlock if handler is not found or always after setUpPublish
defer bus.lock.Unlock()
if handlers, ok := bus.handlers[topic]; ok && 0 < len(handlers) {
@@ -171,12 +171,12 @@ func (bus *ChainBus) Publish(topic bi.TransactionType, args ...interface{}) {
}
}
-func (bus *ChainBus) doPublish(handler *eventHandler, topic bi.TransactionType, args ...interface{}) {
+func (bus *ChainBus) doPublish(handler *eventHandler, topic string, args ...interface{}) {
passedArguments := bus.setUpPublish(topic, args...)
handler.callBack.Call(passedArguments)
}
-func (bus *ChainBus) doPublishAsync(handler *eventHandler, topic bi.TransactionType, args ...interface{}) {
+func (bus *ChainBus) doPublishAsync(handler *eventHandler, topic string, args ...interface{}) {
defer bus.wg.Done()
if handler.transactional {
defer handler.Unlock()
@@ -184,7 +184,7 @@ func (bus *ChainBus) doPublishAsync(handler *eventHandler, topic bi.TransactionT
bus.doPublish(handler, topic, args...)
}
-func (bus *ChainBus) removeHandler(topic bi.TransactionType, idx int) {
+func (bus *ChainBus) removeHandler(topic string, idx int) {
if _, ok := bus.handlers[topic]; !ok {
return
}
@@ -199,7 +199,7 @@ func (bus *ChainBus) removeHandler(topic bi.TransactionType, idx int) {
bus.handlers[topic] = bus.handlers[topic][:l-1]
}
-func (bus *ChainBus) findHandlerIdx(topic bi.TransactionType, callback reflect.Value) int {
+func (bus *ChainBus) findHandlerIdx(topic string, callback reflect.Value) int {
if _, ok := bus.handlers[topic]; ok {
for idx, handler := range bus.handlers[topic] {
if handler.callBack == callback {
@@ -210,7 +210,7 @@ func (bus *ChainBus) findHandlerIdx(topic bi.TransactionType, callback reflect.V
return -1
}
-func (bus *ChainBus) setUpPublish(topic bi.TransactionType, args ...interface{}) []reflect.Value {
+func (bus *ChainBus) setUpPublish(topic string, args ...interface{}) []reflect.Value {
passedArguments := make([]reflect.Value, 0)
for _, arg := range args {
diff --git a/chainbus/bus_test.go b/chainbus/bus_test.go
index 552bc8dcc..d4ace81d1 100644
--- a/chainbus/bus_test.go
+++ b/chainbus/bus_test.go
@@ -20,8 +20,6 @@ import (
"sync/atomic"
"testing"
"time"
-
- bi "github.com/CovenantSQL/CovenantSQL/blockproducer/interfaces"
)
func TestNew(t *testing.T) {
@@ -34,38 +32,38 @@ func TestNew(t *testing.T) {
func TestHasCallback(t *testing.T) {
bus := New()
- bus.Subscribe(bi.TransactionType(1), func() {})
- if bus.HasCallback(bi.TransactionType(2)) {
+ bus.Subscribe("/event/test", func() {})
+ if bus.HasCallback(string(2)) {
t.Fail()
}
- if !bus.HasCallback(bi.TransactionType(1)) {
+ if !bus.HasCallback("/event/test") {
t.Fail()
}
}
func TestSubscribe(t *testing.T) {
bus := New()
- if bus.Subscribe(bi.TransactionType(1), func() {}) != nil {
+ if bus.Subscribe("/event/test", func() {}) != nil {
t.Fail()
}
- if bus.Subscribe(bi.TransactionType(1), "String") == nil {
+ if bus.Subscribe("/event/test", "String") == nil {
t.Fail()
}
}
func TestSubscribeOnce(t *testing.T) {
bus := New()
- if bus.SubscribeOnce(bi.TransactionType(1), func() {}) != nil {
+ if bus.SubscribeOnce("/event/test", func() {}) != nil {
t.Fail()
}
- if bus.SubscribeOnce(bi.TransactionType(1), "String") == nil {
+ if bus.SubscribeOnce("/event/test", "String") == nil {
t.Fail()
}
}
func TestSubscribeOnceAndManySubscribe(t *testing.T) {
bus := New()
- event := bi.TransactionType(1)
+ event := "/event/test"
flag := 0
fn := func() { flag++ }
bus.SubscribeOnce(event, fn)
@@ -81,35 +79,35 @@ func TestSubscribeOnceAndManySubscribe(t *testing.T) {
func TestUnsubscribe(t *testing.T) {
bus := New()
handler := func() {}
- bus.Subscribe(bi.TransactionType(1), handler)
- if bus.Unsubscribe(bi.TransactionType(1), handler) != nil {
+ bus.Subscribe("/event/test", handler)
+ if bus.Unsubscribe("/event/test", handler) != nil {
t.Fail()
}
- if bus.Unsubscribe(bi.TransactionType(1), handler) == nil {
+ if bus.Unsubscribe("/event/test", handler) == nil {
t.Fail()
}
}
func TestPublish(t *testing.T) {
bus := New()
- bus.Subscribe(bi.TransactionType(1), func(a int, b int) {
+ bus.Subscribe("/event/test", func(a int, b int) {
if a != b {
t.Fail()
}
})
- bus.Publish(bi.TransactionType(1), 10, 10)
+ bus.Publish("/event/test", 10, 10)
}
func TestSubcribeOnceAsync(t *testing.T) {
results := make([]int, 0)
bus := New()
- bus.SubscribeOnceAsync(bi.TransactionType(1), func(a int, out *[]int) {
+ bus.SubscribeOnceAsync("/event/test", func(a int, out *[]int) {
*out = append(*out, a)
})
- bus.Publish(bi.TransactionType(1), 10, &results)
- bus.Publish(bi.TransactionType(1), 10, &results)
+ bus.Publish("/event/test", 10, &results)
+ bus.Publish("/event/test", 10, &results)
bus.WaitAsync()
@@ -117,7 +115,7 @@ func TestSubcribeOnceAsync(t *testing.T) {
t.Fail()
}
- if bus.HasCallback(bi.TransactionType(1)) {
+ if bus.HasCallback("/event/test") {
t.Fail()
}
}
@@ -126,14 +124,14 @@ func TestSubscribeAsyncTransactional(t *testing.T) {
results := make([]int, 0)
bus := New()
- bus.SubscribeAsync(bi.TransactionType(1), func(a int, out *[]int, dur string) {
+ bus.SubscribeAsync("/event/test", func(a int, out *[]int, dur string) {
sleep, _ := time.ParseDuration(dur)
time.Sleep(sleep)
*out = append(*out, a)
}, true)
- bus.Publish(bi.TransactionType(1), 1, &results, "1s")
- bus.Publish(bi.TransactionType(1), 2, &results, "0s")
+ bus.Publish("/event/test", 1, &results, "1s")
+ bus.Publish("/event/test", 2, &results, "0s")
bus.WaitAsync()
@@ -150,12 +148,12 @@ func TestSubscribeAsync(t *testing.T) {
results := make(chan int)
bus := New()
- bus.SubscribeAsync(bi.TransactionType(1), func(a int, out chan<- int) {
+ bus.SubscribeAsync("/event/test", func(a int, out chan<- int) {
out <- a
}, false)
- bus.Publish(bi.TransactionType(1), 1, results)
- bus.Publish(bi.TransactionType(1), 2, results)
+ bus.Publish("/event/test", 1, results)
+ bus.Publish("/event/test", 2, results)
var numResults int32
From 212762a66ad57843408894c17d2f83322861657d Mon Sep 17 00:00:00 2001
From: auxten
Date: Mon, 19 Nov 2018 17:03:59 +0800
Subject: [PATCH 007/278] Make cql-fuse default log level to InfoLevel
---
cmd/cql-fuse/block.go | 3 ---
cmd/cql-fuse/main.go | 4 +++-
2 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/cmd/cql-fuse/block.go b/cmd/cql-fuse/block.go
index ceb421336..2454035c5 100644
--- a/cmd/cql-fuse/block.go
+++ b/cmd/cql-fuse/block.go
@@ -36,8 +36,6 @@ package main
import (
"fmt"
"strings"
-
- "github.com/CovenantSQL/CovenantSQL/utils/log"
)
// BlockSize is the size of each data block. It must not
@@ -341,7 +339,6 @@ func write(e sqlExecutor, inodeID, originalSize, offset uint64, data []byte) err
}
insStmt := fmt.Sprintf(`INSERT INTO fs_block VALUES %s`, strings.Join(paramStrings, ","))
- log.Warn(insStmt, params)
if _, err := e.Exec(insStmt, params...); err != nil {
return err
}
diff --git a/cmd/cql-fuse/main.go b/cmd/cql-fuse/main.go
index 6f0f9f4b5..2719d6856 100644
--- a/cmd/cql-fuse/main.go
+++ b/cmd/cql-fuse/main.go
@@ -96,7 +96,7 @@ func main() {
flag.Usage = usage
flag.Parse()
- log.SetLevel(log.DebugLevel)
+ log.SetLevel(log.InfoLevel)
err := client.Init(config, []byte(password))
if err != nil {
@@ -134,6 +134,8 @@ func main() {
_ = c.Close()
}()
+ log.Infof("DB: %s mount on %s succeed", dsn, mountPoint)
+
go func() {
sig := make(chan os.Signal, 1)
signal.Notify(sig, os.Interrupt)
From b65e39aa5d046dd85aa6c57f3a5cded029912567 Mon Sep 17 00:00:00 2001
From: auxten
Date: Mon, 19 Nov 2018 17:04:45 +0800
Subject: [PATCH 008/278] Fix chainbus test
---
chainbus/bus.go | 2 +-
chainbus/bus_test.go | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/chainbus/bus.go b/chainbus/bus.go
index 293decca5..3ccacdfb4 100644
--- a/chainbus/bus.go
+++ b/chainbus/bus.go
@@ -190,7 +190,7 @@ func (bus *ChainBus) removeHandler(topic string, idx int) {
}
l := len(bus.handlers[topic])
- if !(0 <= idx && idx < l) {
+ if 0 > idx || idx >= l {
return
}
diff --git a/chainbus/bus_test.go b/chainbus/bus_test.go
index d4ace81d1..8e4fc39b3 100644
--- a/chainbus/bus_test.go
+++ b/chainbus/bus_test.go
@@ -33,7 +33,7 @@ func TestNew(t *testing.T) {
func TestHasCallback(t *testing.T) {
bus := New()
bus.Subscribe("/event/test", func() {})
- if bus.HasCallback(string(2)) {
+ if bus.HasCallback("/event/test2") {
t.Fail()
}
if !bus.HasCallback("/event/test") {
From 2ea43139fe781811143f0a648c414a52a1ccdcfe Mon Sep 17 00:00:00 2001
From: lambda
Date: Wed, 21 Nov 2018 11:08:50 +0800
Subject: [PATCH 009/278] Change AddTx to chainbus
---
blockproducer/chain.go | 36 +++++++++++++++++++-----------------
blockproducer/chain_test.go | 3 +--
blockproducer/metastate.go | 2 +-
cmd/cql-fuse/main.go | 5 ++---
cmd/cql-fuse/node.go | 1 -
cmd/cql/main.go | 7 +++----
route/acl.go | 2 +-
rpc/rpcutil.go | 2 +-
worker/dbms_rpc.go | 1 -
9 files changed, 28 insertions(+), 31 deletions(-)
diff --git a/blockproducer/chain.go b/blockproducer/chain.go
index 31bdb78bc..1bad69e45 100644
--- a/blockproducer/chain.go
+++ b/blockproducer/chain.go
@@ -18,13 +18,13 @@ package blockproducer
import (
"fmt"
- "github.com/CovenantSQL/CovenantSQL/chainbus"
"os"
"sync"
"time"
pi "github.com/CovenantSQL/CovenantSQL/blockproducer/interfaces"
pt "github.com/CovenantSQL/CovenantSQL/blockproducer/types"
+ "github.com/CovenantSQL/CovenantSQL/chainbus"
"github.com/CovenantSQL/CovenantSQL/crypto"
"github.com/CovenantSQL/CovenantSQL/crypto/asymmetric"
"github.com/CovenantSQL/CovenantSQL/crypto/hash"
@@ -48,6 +48,7 @@ var (
metaSQLChainIndexBucket = []byte("covenantsql-sqlchain-index-bucket")
gasPrice uint32 = 1
accountAddress proto.AccountAddress
+ txEvent = "/BP/Tx"
)
// Chain defines the main chain.
@@ -132,14 +133,14 @@ func NewChain(cfg *Config) (*Chain, error) {
bi: newBlockIndex(),
rt: newRuntime(cfg, accountAddress),
cl: caller,
- bs: bus,
+ bs: bus,
blocksFromRPC: make(chan *pt.Block),
pendingTxs: make(chan pi.Transaction),
stopCh: make(chan struct{}),
}
// sub chain events
- chain.bs.Subscribe("/BP/", chain.addTx)
+ chain.bs.Subscribe(txEvent, chain.addTx)
log.WithField("genesis", cfg.Genesis).Debug("pushing genesis block")
@@ -176,6 +177,7 @@ func LoadChain(cfg *Config) (chain *Chain, err error) {
return nil, err
}
+ caller := rpc.NewCaller()
bus := chainbus.New()
chain = &Chain{
@@ -183,14 +185,14 @@ func LoadChain(cfg *Config) (chain *Chain, err error) {
ms: newMetaState(),
bi: newBlockIndex(),
rt: newRuntime(cfg, accountAddress),
- cl: rpc.NewCaller(),
+ cl: caller,
bs: bus,
blocksFromRPC: make(chan *pt.Block),
pendingTxs: make(chan pi.Transaction),
stopCh: make(chan struct{}),
}
- chain.bs.Subscribe("/BP/TransferToken", chain.addTx)
+ chain.bs.Subscribe(txEvent, chain.addTx)
err = chain.db.View(func(tx *bolt.Tx) (err error) {
meta := tx.Bucket(metaBucket[:])
@@ -658,11 +660,19 @@ func (c *Chain) processBlocks() {
}
func (c *Chain) addTx(tx pi.Transaction) {
- c.pendingTxs <- tx
+ if err := c.db.Update(c.ms.applyTransactionProcedure(tx)); err != nil {
+ log.WithFields(log.Fields{
+ "peer": c.rt.getPeerInfoString(),
+ "next_turn": c.rt.getNextTurn(),
+ "head_height": c.rt.getHead().Height,
+ "head_block": c.rt.getHead().Head.String(),
+ "transaction": tx.Hash().String(),
+ }).Debugf("Failed to push tx with error: %v", err)
+ }
}
-func (c *Chain) processTx(tx pi.Transaction) (err error) {
- return c.db.Update(c.ms.applyTransactionProcedure(tx))
+func (c *Chain) processTx(tx pi.Transaction) {
+ c.bs.Publish(txEvent, tx)
}
func (c *Chain) processTxs() {
@@ -670,15 +680,7 @@ func (c *Chain) processTxs() {
for {
select {
case tx := <-c.pendingTxs:
- if err := c.processTx(tx); err != nil {
- log.WithFields(log.Fields{
- "peer": c.rt.getPeerInfoString(),
- "next_turn": c.rt.getNextTurn(),
- "head_height": c.rt.getHead().Height,
- "head_block": c.rt.getHead().Head.String(),
- "transaction": tx.Hash().String(),
- }).Debugf("Failed to push tx with error: %v", err)
- }
+ c.processTx(tx)
case <-c.stopCh:
return
}
diff --git a/blockproducer/chain_test.go b/blockproducer/chain_test.go
index 1da9c742f..6595fec82 100644
--- a/blockproducer/chain_test.go
+++ b/blockproducer/chain_test.go
@@ -146,8 +146,7 @@ func TestChain(t *testing.T) {
tb, err := generateRandomAccountBilling()
So(err, ShouldBeNil)
receivedTbs[i] = tb
- err = chain.processTx(tb)
- So(err, ShouldBeNil)
+ chain.processTx(tb)
}
nextNonce, err = chain.ms.nextNonce(testAddress1)
diff --git a/blockproducer/metastate.go b/blockproducer/metastate.go
index ec7814ae0..07f34c09e 100644
--- a/blockproducer/metastate.go
+++ b/blockproducer/metastate.go
@@ -84,7 +84,7 @@ func (s *metaState) loadAccountStableBalance(addr proto.AccountAddress) (b uint6
"loaded": loaded,
}).Debug("queried stable account")
}()
-
+
s.Lock()
defer s.Unlock()
diff --git a/cmd/cql-fuse/main.go b/cmd/cql-fuse/main.go
index 2719d6856..25a62eb75 100644
--- a/cmd/cql-fuse/main.go
+++ b/cmd/cql-fuse/main.go
@@ -72,12 +72,11 @@ import (
"os"
"os/signal"
- "github.com/CovenantSQL/CovenantSQL/client"
- "github.com/CovenantSQL/CovenantSQL/utils/log"
-
"bazil.org/fuse"
"bazil.org/fuse/fs"
_ "bazil.org/fuse/fs/fstestutil"
+ "github.com/CovenantSQL/CovenantSQL/client"
+ "github.com/CovenantSQL/CovenantSQL/utils/log"
)
var usage = func() {
diff --git a/cmd/cql-fuse/node.go b/cmd/cql-fuse/node.go
index 5ae46a38a..391f47c97 100644
--- a/cmd/cql-fuse/node.go
+++ b/cmd/cql-fuse/node.go
@@ -46,7 +46,6 @@ import (
"bazil.org/fuse"
"bazil.org/fuse/fs"
-
"github.com/CovenantSQL/CovenantSQL/client"
)
diff --git a/cmd/cql/main.go b/cmd/cql/main.go
index 91791193e..4a23f6a87 100644
--- a/cmd/cql/main.go
+++ b/cmd/cql/main.go
@@ -29,6 +29,9 @@ import (
"strconv"
"strings"
+ "github.com/CovenantSQL/CovenantSQL/client"
+ "github.com/CovenantSQL/CovenantSQL/crypto/asymmetric"
+ "github.com/CovenantSQL/CovenantSQL/utils/log"
"github.com/CovenantSQL/go-sqlite3-encrypt"
"github.com/xo/dburl"
"github.com/xo/usql/drivers"
@@ -36,10 +39,6 @@ import (
"github.com/xo/usql/handler"
"github.com/xo/usql/rline"
"github.com/xo/usql/text"
-
- "github.com/CovenantSQL/CovenantSQL/client"
- "github.com/CovenantSQL/CovenantSQL/crypto/asymmetric"
- "github.com/CovenantSQL/CovenantSQL/utils/log"
)
const name = "cql"
diff --git a/route/acl.go b/route/acl.go
index dd6d4ab69..b4b23905c 100644
--- a/route/acl.go
+++ b/route/acl.go
@@ -91,7 +91,7 @@ const (
SQLCAdviseNewBlock
// SQLCAdviseBinLog is usd by sqlchain to advise binlog between adjacent node
SQLCAdviseBinLog
- // SQLCAdviseResponsedQuery is used by sqlchain to advice response query between adjacent node
+ // SQLCAdviseAckedQuery is used by sqlchain to advice response query between adjacent node
SQLCAdviseAckedQuery
// SQLCFetchBlock is used by sqlchain to fetch block from adjacent nodes
SQLCFetchBlock
diff --git a/rpc/rpcutil.go b/rpc/rpcutil.go
index d39b12c86..84dc678c3 100644
--- a/rpc/rpcutil.go
+++ b/rpc/rpcutil.go
@@ -106,7 +106,7 @@ func (c *PersistentCaller) Call(method string, args interface{}, reply interface
}
// Reconnect tries to rebuild RPC client
-func (c *PersistentCaller) Reconnect(method string) (err error) {
+func (c *PersistentCaller) Reconnect(method string) (err error) {
c.Lock()
c.Close()
c.client = nil
diff --git a/worker/dbms_rpc.go b/worker/dbms_rpc.go
index 0bd8a5deb..95737a5c2 100644
--- a/worker/dbms_rpc.go
+++ b/worker/dbms_rpc.go
@@ -19,7 +19,6 @@ package worker
import (
//"context"
//"runtime/trace"
-
"github.com/CovenantSQL/CovenantSQL/route"
"github.com/CovenantSQL/CovenantSQL/rpc"
"github.com/CovenantSQL/CovenantSQL/types"
From 8047503b1800ded1c073864dafb5136209e2332b Mon Sep 17 00:00:00 2001
From: laodouya
Date: Tue, 20 Nov 2018 14:02:44 +0800
Subject: [PATCH 010/278] Utils/Profiler log field name wrong.
Should log memprofile filename in memprofile section.
---
utils/profiler.go | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/utils/profiler.go b/utils/profiler.go
index 013dd3e7c..1842535f2 100644
--- a/utils/profiler.go
+++ b/utils/profiler.go
@@ -48,7 +48,7 @@ func StartProfile(cpuprofile, memprofile string) error {
log.WithField("file", memprofile).WithError(err).Error("failed to create memory profile file")
return err
}
- log.WithField("file", cpuprofile).WithError(err).Info("writing memory profiling to file")
+ log.WithField("file", memprofile).WithError(err).Info("writing memory profiling to file")
prof.mem = f
runtime.MemProfileRate = 4096
}
From 8968898ef7482733784862905d3578edf410b17a Mon Sep 17 00:00:00 2001
From: leventeliu
Date: Tue, 20 Nov 2018 22:08:05 +0800
Subject: [PATCH 011/278] Add block cache pruning
---
sqlchain/blockindex.go | 2 +-
sqlchain/chain.go | 29 +++++++++++++++++++++++++++++
sqlchain/config.go | 2 ++
sqlchain/runtime.go | 18 +++++++++++++-----
4 files changed, 45 insertions(+), 6 deletions(-)
diff --git a/sqlchain/blockindex.go b/sqlchain/blockindex.go
index a5fd16dad..96d773bef 100644
--- a/sqlchain/blockindex.go
+++ b/sqlchain/blockindex.go
@@ -26,7 +26,7 @@ import (
type blockNode struct {
parent *blockNode
- block *types.Block // TODO(leventeliu): cleanup history blocks to release memory.
+ block *types.Block
hash hash.Hash
height int32 // height is the chain height of the head
count int32 // count counts the blocks (except genesis) at this head
diff --git a/sqlchain/chain.go b/sqlchain/chain.go
index 79e68e936..f2d79a851 100644
--- a/sqlchain/chain.go
+++ b/sqlchain/chain.go
@@ -44,6 +44,10 @@ import (
"github.com/syndtr/goleveldb/leveldb/util"
)
+const (
+ minBlockCacheTTL = int32(100)
+)
+
var (
metaState = [4]byte{'S', 'T', 'A', 'T'}
metaBlockIndex = [4]byte{'B', 'L', 'C', 'K'}
@@ -359,6 +363,7 @@ func LoadChain(c *Config) (chain *Chain, err error) {
st.node = last
chain.rt.setHead(st)
chain.st.InitTx(id)
+ chain.pruneBlockCache()
// Read queries and rebuild memory index
respIter := chain.tdb.NewIterator(util.BytesPrefix(metaResponseIndex[:]), nil)
@@ -695,6 +700,7 @@ func (c *Chain) syncHead() {
// runCurrentTurn does the check and runs block producing if its my turn.
func (c *Chain) runCurrentTurn(now time.Time) {
defer func() {
+ c.pruneBlockCache()
c.rt.setNextTurn()
c.qi.advanceBarrier(c.rt.getMinValidHeight())
c.ai.advance(c.rt.getMinValidHeight())
@@ -1187,6 +1193,11 @@ func (c *Chain) getBilling(low, high int32) (req *pt.BillingRequest, err error)
}
for ; n != nil && n.height >= low; n = n.parent {
+ // TODO(leventeliu): block maybe released, use persistence version in this case.
+ if n.block == nil {
+ continue
+ }
+
if lowBlock == nil {
lowBlock = n.block
}
@@ -1521,3 +1532,21 @@ func (c *Chain) register(ack *types.SignedAckHeader) (err error) {
func (c *Chain) remove(ack *types.SignedAckHeader) (err error) {
return c.ai.remove(c.rt.getHeightFromTime(ack.SignedRequestHeader().Timestamp), ack)
}
+
+func (c *Chain) pruneBlockCache() {
+ var (
+ head = c.rt.getHead().node
+ lastCnt int32
+ )
+ if head == nil {
+ return
+ }
+ lastCnt = head.count - c.rt.blockCacheTTL
+ // Move to last count position
+ for ; head != nil && head.count > lastCnt; head = head.parent {
+ }
+ // Prune block references
+ for ; head != nil && head.block != nil; head = head.parent {
+ head.block = nil
+ }
+}
diff --git a/sqlchain/config.go b/sqlchain/config.go
index 9fad34d91..113e99718 100644
--- a/sqlchain/config.go
+++ b/sqlchain/config.go
@@ -46,6 +46,8 @@ type Config struct {
// QueryTTL sets the unacknowledged query TTL in block periods.
QueryTTL int32
+ BlockCacheTTL int32
+
// DBAccount info
TokenType pt.TokenType
GasPrice uint64
diff --git a/sqlchain/runtime.go b/sqlchain/runtime.go
index 1537452dc..b1935558d 100644
--- a/sqlchain/runtime.go
+++ b/sqlchain/runtime.go
@@ -47,6 +47,8 @@ type runtime struct {
tick time.Duration
// queryTTL sets the unacknowledged query TTL in block periods.
queryTTL int32
+ // blockCacheTTL sets the cached block numbers.
+ blockCacheTTL int32
// muxServer is the multiplexing service of sql-chain PRC.
muxService *MuxService
// price sets query price in gases.
@@ -85,11 +87,17 @@ type runtime struct {
// newRunTime returns a new sql-chain runtime instance with the specified config.
func newRunTime(c *Config) (r *runtime) {
r = &runtime{
- stopCh: make(chan struct{}),
- databaseID: c.DatabaseID,
- period: c.Period,
- tick: c.Tick,
- queryTTL: c.QueryTTL,
+ stopCh: make(chan struct{}),
+ databaseID: c.DatabaseID,
+ period: c.Period,
+ tick: c.Tick,
+ queryTTL: c.QueryTTL,
+ blockCacheTTL: func() int32 {
+ if c.BlockCacheTTL < minBlockCacheTTL {
+ return minBlockCacheTTL
+ }
+ return c.BlockCacheTTL
+ }(),
muxService: c.MuxService,
price: c.Price,
producingReward: c.ProducingReward,
From 140fe89306875d99c1cf3eddbc621a48bd76c795 Mon Sep 17 00:00:00 2001
From: zeqing-guo
Date: Wed, 21 Nov 2018 22:53:28 +0800
Subject: [PATCH 012/278] Move blockproducer/types to types and change the
account fields
---
blockproducer/blockindex.go | 6 +-
blockproducer/chain.go | 49 +--
blockproducer/chain_test.go | 3 +-
blockproducer/config.go | 6 +-
blockproducer/metaindex.go | 10 +-
blockproducer/metaindex_test.go | 8 +-
blockproducer/metastate.go | 45 +--
blockproducer/metastate_test.go | 29 +-
.../{types => otypes}/billing_request.go | 0
.../{types => otypes}/billing_request_gen.go | 0
.../billing_request_gen_test.go | 0
.../{types => otypes}/billing_request_test.go | 0
blockproducer/{types => otypes}/errors.go | 12 +-
blockproducer/otypes/xxx_test.go | 102 ++++++
blockproducer/rpc.go | 8 +-
blockproducer/types/account_gen.go | 155 --------
blockproducer/types/xxx_test.go | 281 ---------------
blockproducer/xxx_test.go | 50 ++-
cmd/cql-explorer/api.go | 8 +-
cmd/cql-explorer/service.go | 14 +-
cmd/cql-faucet/verifier.go | 2 +-
cmd/cqld/bootstrap.go | 18 +-
sqlchain/chain.go | 19 +-
sqlchain/config.go | 3 +-
sqlchain/otypes/billing_req.go | 2 +-
sqlchain/rpc.go | 3 +-
{blockproducer/types => types}/account.go | 41 ++-
types/account_gen.go | 226 ++++++++++++
.../types => types}/account_gen_test.go | 37 ++
{blockproducer/types => types}/baseaccount.go | 0
.../types => types}/baseaccount_gen.go | 0
.../types => types}/baseaccount_gen_test.go | 0
.../types => types}/baseaccount_test.go | 0
{blockproducer/types => types}/billing.go | 0
{blockproducer/types => types}/billing_gen.go | 0
.../types => types}/billing_gen_test.go | 0
types/billing_req.go | 5 +-
types/billing_request.go | 155 ++++++++
types/billing_request_gen.go | 132 +++++++
types/billing_request_gen_test.go | 84 +++++
types/billing_request_test.go | 339 ++++++++++++++++++
.../types => types}/billing_test.go | 0
.../types/block.go => types/bp_block.go | 36 +-
.../block_gen.go => types/bp_block_gen.go | 16 +-
.../bp_block_gen_test.go | 36 +-
.../block_test.go => types/bp_block_test.go | 8 +-
{blockproducer/types => types}/createdb.go | 0
.../types => types}/createdb_gen.go | 0
.../types => types}/createdb_gen_test.go | 0
.../types => types}/createdb_test.go | 0
types/errors.go | 7 +
.../types => types}/marshalhash_test.go | 22 +-
.../types => types}/msgpack_test.go | 0
types/request_type_gen.go | 43 ++-
{blockproducer/types => types}/token.go | 56 ++-
types/token_gen.go | 21 ++
types/token_gen_test.go | 3 +
{blockproducer/types => types}/token_test.go | 15 +-
{blockproducer/types => types}/transfer.go | 0
.../types => types}/transfer_gen.go | 0
.../types => types}/transfer_gen_test.go | 0
.../types => types}/transfer_test.go | 0
types/xxx_test.go | 214 ++++++++++-
xenomint/state_test.go | 4 +-
xenomint/types/block.go | 2 +-
65 files changed, 1624 insertions(+), 711 deletions(-)
rename blockproducer/{types => otypes}/billing_request.go (100%)
rename blockproducer/{types => otypes}/billing_request_gen.go (100%)
rename blockproducer/{types => otypes}/billing_request_gen_test.go (100%)
rename blockproducer/{types => otypes}/billing_request_test.go (100%)
rename blockproducer/{types => otypes}/errors.go (66%)
create mode 100644 blockproducer/otypes/xxx_test.go
delete mode 100644 blockproducer/types/account_gen.go
delete mode 100644 blockproducer/types/xxx_test.go
rename {blockproducer/types => types}/account.go (70%)
create mode 100644 types/account_gen.go
rename {blockproducer/types => types}/account_gen_test.go (76%)
rename {blockproducer/types => types}/baseaccount.go (100%)
rename {blockproducer/types => types}/baseaccount_gen.go (100%)
rename {blockproducer/types => types}/baseaccount_gen_test.go (100%)
rename {blockproducer/types => types}/baseaccount_test.go (100%)
rename {blockproducer/types => types}/billing.go (100%)
rename {blockproducer/types => types}/billing_gen.go (100%)
rename {blockproducer/types => types}/billing_gen_test.go (100%)
create mode 100644 types/billing_request.go
create mode 100644 types/billing_request_gen.go
create mode 100644 types/billing_request_gen_test.go
create mode 100644 types/billing_request_test.go
rename {blockproducer/types => types}/billing_test.go (100%)
rename blockproducer/types/block.go => types/bp_block.go (78%)
rename blockproducer/types/block_gen.go => types/bp_block_gen.go (87%)
rename blockproducer/types/block_gen_test.go => types/bp_block_gen_test.go (73%)
rename blockproducer/types/block_test.go => types/bp_block_test.go (96%)
rename {blockproducer/types => types}/createdb.go (100%)
rename {blockproducer/types => types}/createdb_gen.go (100%)
rename {blockproducer/types => types}/createdb_gen_test.go (100%)
rename {blockproducer/types => types}/createdb_test.go (100%)
rename {blockproducer/types => types}/marshalhash_test.go (60%)
rename {blockproducer/types => types}/msgpack_test.go (100%)
rename {blockproducer/types => types}/token.go (56%)
create mode 100644 types/token_gen.go
create mode 100644 types/token_gen_test.go
rename {blockproducer/types => types}/token_test.go (76%)
rename {blockproducer/types => types}/transfer.go (100%)
rename {blockproducer/types => types}/transfer_gen.go (100%)
rename {blockproducer/types => types}/transfer_gen_test.go (100%)
rename {blockproducer/types => types}/transfer_test.go (100%)
diff --git a/blockproducer/blockindex.go b/blockproducer/blockindex.go
index 95991f678..eb2601396 100644
--- a/blockproducer/blockindex.go
+++ b/blockproducer/blockindex.go
@@ -21,7 +21,7 @@ import (
"sync"
"time"
- "github.com/CovenantSQL/CovenantSQL/blockproducer/types"
+ "github.com/CovenantSQL/CovenantSQL/types"
"github.com/CovenantSQL/CovenantSQL/crypto/hash"
"github.com/CovenantSQL/CovenantSQL/utils/log"
)
@@ -33,7 +33,7 @@ type blockNode struct {
count uint32
}
-func newBlockNode(chainInitTime time.Time, period time.Duration, block *types.Block, parent *blockNode) *blockNode {
+func newBlockNode(chainInitTime time.Time, period time.Duration, block *types.BPBlock, parent *blockNode) *blockNode {
var count uint32
h := uint32(block.Timestamp().Sub(chainInitTime) / period)
@@ -62,7 +62,7 @@ func (bn *blockNode) indexKey() (key []byte) {
return
}
-func (bn *blockNode) initBlockNode(block *types.Block, parent *blockNode) {
+func (bn *blockNode) initBlockNode(block *types.BPBlock, parent *blockNode) {
bn.hash = block.SignedHeader.BlockHash
bn.parent = nil
bn.height = 0
diff --git a/blockproducer/chain.go b/blockproducer/chain.go
index 1bad69e45..1f639dd14 100644
--- a/blockproducer/chain.go
+++ b/blockproducer/chain.go
@@ -18,12 +18,13 @@ package blockproducer
import (
"fmt"
+ "github.com/CovenantSQL/CovenantSQL/types"
"os"
"sync"
"time"
pi "github.com/CovenantSQL/CovenantSQL/blockproducer/interfaces"
- pt "github.com/CovenantSQL/CovenantSQL/blockproducer/types"
+ pt "github.com/CovenantSQL/CovenantSQL/types"
"github.com/CovenantSQL/CovenantSQL/chainbus"
"github.com/CovenantSQL/CovenantSQL/crypto"
"github.com/CovenantSQL/CovenantSQL/crypto/asymmetric"
@@ -60,7 +61,7 @@ type Chain struct {
cl *rpc.Caller
bs chainbus.Bus
- blocksFromRPC chan *pt.Block
+ blocksFromRPC chan *pt.BPBlock
pendingTxs chan pi.Transaction
stopCh chan struct{}
}
@@ -134,7 +135,7 @@ func NewChain(cfg *Config) (*Chain, error) {
rt: newRuntime(cfg, accountAddress),
cl: caller,
bs: bus,
- blocksFromRPC: make(chan *pt.Block),
+ blocksFromRPC: make(chan *pt.BPBlock),
pendingTxs: make(chan pi.Transaction),
stopCh: make(chan struct{}),
}
@@ -187,7 +188,7 @@ func LoadChain(cfg *Config) (chain *Chain, err error) {
rt: newRuntime(cfg, accountAddress),
cl: caller,
bs: bus,
- blocksFromRPC: make(chan *pt.Block),
+ blocksFromRPC: make(chan *pt.BPBlock),
pendingTxs: make(chan pi.Transaction),
stopCh: make(chan struct{}),
}
@@ -213,7 +214,7 @@ func LoadChain(cfg *Config) (chain *Chain, err error) {
nodes := make([]blockNode, blocks.Stats().KeyN)
if err = blocks.ForEach(func(k, v []byte) (err error) {
- block := &pt.Block{}
+ block := &pt.BPBlock{}
if err = utils.DecodeMsgPack(v, block); err != nil {
log.WithError(err).Error("load block failed")
return err
@@ -263,7 +264,7 @@ func LoadChain(cfg *Config) (chain *Chain, err error) {
}
// checkBlock has following steps: 1. check parent block 2. checkTx 2. merkle tree 3. Hash 4. Signature.
-func (c *Chain) checkBlock(b *pt.Block) (err error) {
+func (c *Chain) checkBlock(b *pt.BPBlock) (err error) {
// TODO(lambda): process block fork
if !b.ParentHash().IsEqual(&c.rt.getHead().Head) {
log.WithFields(log.Fields{
@@ -279,7 +280,7 @@ func (c *Chain) checkBlock(b *pt.Block) (err error) {
return ErrInvalidMerkleTreeRoot
}
- enc, err := b.SignedHeader.Header.MarshalHash()
+ enc, err := b.SignedHeader.BPHeader.MarshalHash()
if err != nil {
return err
}
@@ -291,7 +292,7 @@ func (c *Chain) checkBlock(b *pt.Block) (err error) {
return nil
}
-func (c *Chain) pushBlockWithoutCheck(b *pt.Block) error {
+func (c *Chain) pushBlockWithoutCheck(b *pt.BPBlock) error {
h := c.rt.getHeightFromTime(b.Timestamp())
log.Debugf("current block %s, height %d, its parent %s", b.BlockHash(), h, b.ParentHash())
node := newBlockNode(c.rt.chainInitTime, c.rt.period, b, c.rt.getHead().Node)
@@ -336,7 +337,7 @@ func (c *Chain) pushBlockWithoutCheck(b *pt.Block) error {
return err
}
-func (c *Chain) pushGenesisBlock(b *pt.Block) (err error) {
+func (c *Chain) pushGenesisBlock(b *pt.BPBlock) (err error) {
err = c.pushBlockWithoutCheck(b)
if err != nil {
log.WithError(err).Error("push genesis block failed")
@@ -344,7 +345,7 @@ func (c *Chain) pushGenesisBlock(b *pt.Block) (err error) {
return
}
-func (c *Chain) pushBlock(b *pt.Block) error {
+func (c *Chain) pushBlock(b *pt.BPBlock) error {
err := c.checkBlock(b)
if err != nil {
err = errors.Wrap(err, "check block failed")
@@ -365,9 +366,9 @@ func (c *Chain) produceBlock(now time.Time) error {
return err
}
- b := &pt.Block{
- SignedHeader: pt.SignedHeader{
- Header: pt.Header{
+ b := &pt.BPBlock{
+ SignedHeader: pt.BPSignedHeader{
+ BPHeader: pt.BPHeader{
Version: blockVersion,
Producer: c.rt.accountAddress,
ParentHash: c.rt.getHead().Head,
@@ -422,7 +423,7 @@ func (c *Chain) produceBlock(now time.Time) error {
return err
}
-func (c *Chain) produceBilling(br *pt.BillingRequest) (_ *pt.BillingRequest, err error) {
+func (c *Chain) produceBilling(br *types.BillingRequest) (_ *types.BillingRequest, err error) {
// TODO(lambda): simplify the function
if err = c.checkBillingRequest(br); err != nil {
return
@@ -462,8 +463,8 @@ func (c *Chain) produceBilling(br *pt.BillingRequest) (_ *pt.BillingRequest, err
return
}
var (
- tc = pt.NewBillingHeader(nc, br, accountAddress, receivers, fees, rewards)
- tb = pt.NewBilling(tc)
+ tc = types.NewBillingHeader(nc, br, accountAddress, receivers, fees, rewards)
+ tb = types.NewBilling(tc)
)
if err = tb.Sign(privKey); err != nil {
return
@@ -480,7 +481,7 @@ func (c *Chain) produceBilling(br *pt.BillingRequest) (_ *pt.BillingRequest, err
// 1. period of sqlchain;
// 2. request's hash
// 3. miners' signatures.
-func (c *Chain) checkBillingRequest(br *pt.BillingRequest) (err error) {
+func (c *Chain) checkBillingRequest(br *types.BillingRequest) (err error) {
// period of sqlchain;
// TODO(lambda): get and check period and miner list of specific sqlchain
@@ -488,13 +489,13 @@ func (c *Chain) checkBillingRequest(br *pt.BillingRequest) (err error) {
return
}
-func (c *Chain) fetchBlockByHeight(h uint32) (b *pt.Block, count uint32, err error) {
+func (c *Chain) fetchBlockByHeight(h uint32) (b *pt.BPBlock, count uint32, err error) {
node := c.rt.getHead().Node.ancestor(h)
if node == nil {
return nil, 0, ErrNoSuchBlock
}
- b = &pt.Block{}
+ b = &pt.BPBlock{}
k := node.indexKey()
err = c.db.View(func(tx *bolt.Tx) error {
@@ -508,13 +509,13 @@ func (c *Chain) fetchBlockByHeight(h uint32) (b *pt.Block, count uint32, err err
return b, node.count, nil
}
-func (c *Chain) fetchBlockByCount(count uint32) (b *pt.Block, height uint32, err error) {
+func (c *Chain) fetchBlockByCount(count uint32) (b *pt.BPBlock, height uint32, err error) {
node := c.rt.getHead().Node.ancestorByCount(count)
if node == nil {
return nil, 0, ErrNoSuchBlock
}
- b = &pt.Block{}
+ b = &pt.BPBlock{}
k := node.indexKey()
err = c.db.View(func(tx *bolt.Tx) error {
@@ -604,7 +605,7 @@ func (c *Chain) Start() error {
func (c *Chain) processBlocks() {
rsCh := make(chan struct{})
rsWG := &sync.WaitGroup{}
- returnStash := func(stash []*pt.Block) {
+ returnStash := func(stash []*pt.BPBlock) {
defer rsWG.Done()
for _, block := range stash {
select {
@@ -621,14 +622,14 @@ func (c *Chain) processBlocks() {
c.rt.wg.Done()
}()
- var stash []*pt.Block
+ var stash []*pt.BPBlock
for {
select {
case block := <-c.blocksFromRPC:
if h := c.rt.getHeightFromTime(block.Timestamp()); h > c.rt.getNextTurn()-1 {
// Stash newer blocks for later check
if stash == nil {
- stash = make([]*pt.Block, 0)
+ stash = make([]*pt.BPBlock, 0)
}
stash = append(stash, block)
} else {
diff --git a/blockproducer/chain_test.go b/blockproducer/chain_test.go
index 6595fec82..2d5c3607f 100644
--- a/blockproducer/chain_test.go
+++ b/blockproducer/chain_test.go
@@ -24,7 +24,6 @@ import (
"time"
pi "github.com/CovenantSQL/CovenantSQL/blockproducer/interfaces"
- pt "github.com/CovenantSQL/CovenantSQL/blockproducer/types"
"github.com/CovenantSQL/CovenantSQL/crypto/kms"
"github.com/CovenantSQL/CovenantSQL/pow/cpuminer"
"github.com/CovenantSQL/CovenantSQL/proto"
@@ -141,7 +140,7 @@ func TestChain(t *testing.T) {
So(err, ShouldNotBeNil)
// receive txs
- receivedTbs := make([]*pt.Billing, 9)
+ receivedTbs := make([]*types.Billing, 9)
for i := range receivedTbs {
tb, err := generateRandomAccountBilling()
So(err, ShouldBeNil)
diff --git a/blockproducer/config.go b/blockproducer/config.go
index 175d2a1d6..2ec553df0 100644
--- a/blockproducer/config.go
+++ b/blockproducer/config.go
@@ -19,7 +19,7 @@ package blockproducer
import (
"time"
- "github.com/CovenantSQL/CovenantSQL/blockproducer/types"
+ "github.com/CovenantSQL/CovenantSQL/types"
"github.com/CovenantSQL/CovenantSQL/proto"
"github.com/CovenantSQL/CovenantSQL/rpc"
)
@@ -30,7 +30,7 @@ const (
// Config is the main chain configuration.
type Config struct {
- Genesis *types.Block
+ Genesis *types.BPBlock
DataFile string
@@ -44,7 +44,7 @@ type Config struct {
}
// NewConfig creates new config.
-func NewConfig(genesis *types.Block, dataFile string,
+func NewConfig(genesis *types.BPBlock, dataFile string,
server *rpc.Server, peers *proto.Peers,
nodeID proto.NodeID, period time.Duration, tick time.Duration) *Config {
config := Config{
diff --git a/blockproducer/metaindex.go b/blockproducer/metaindex.go
index da5c6d05b..dee7e6bf6 100644
--- a/blockproducer/metaindex.go
+++ b/blockproducer/metaindex.go
@@ -20,7 +20,7 @@ import (
"bytes"
"sync"
- pt "github.com/CovenantSQL/CovenantSQL/blockproducer/types"
+ pt "github.com/CovenantSQL/CovenantSQL/types"
"github.com/CovenantSQL/CovenantSQL/proto"
"github.com/CovenantSQL/CovenantSQL/utils"
"github.com/coreos/bbolt"
@@ -126,7 +126,7 @@ func (i *metaIndex) IncreaseAccountStableBalance(
err = ErrAccountNotFound
return
}
- if err = safeAdd(&ao.StableCoinBalance, &amount); err != nil {
+ if err = safeAdd(&ao.TokenBalance[pt.Particle], &amount); err != nil {
return
}
ao.NextNonce++
@@ -161,7 +161,7 @@ func (i *metaIndex) DecreaseAccountStableBalance(
err = ErrAccountNotFound
return
}
- if err = safeSub(&ao.StableCoinBalance, &amount); err != nil {
+ if err = safeSub(&ao.TokenBalance[pt.Particle], &amount); err != nil {
return
}
ao.NextNonce++
@@ -196,7 +196,7 @@ func (i *metaIndex) IncreaseAccountCovenantBalance(
err = ErrAccountNotFound
return
}
- if err = safeAdd(&ao.CovenantCoinBalance, &amount); err != nil {
+ if err = safeAdd(&ao.TokenBalance[pt.Wave], &amount); err != nil {
return
}
ao.NextNonce++
@@ -231,7 +231,7 @@ func (i *metaIndex) DecreaseAccountCovenantBalance(
err = ErrAccountNotFound
return
}
- if err = safeSub(&ao.CovenantCoinBalance, &amount); err != nil {
+ if err = safeSub(&ao.TokenBalance[pt.Wave], &amount); err != nil {
return
}
ao.NextNonce++
diff --git a/blockproducer/metaindex_test.go b/blockproducer/metaindex_test.go
index d85fc0d6c..85d7796c7 100644
--- a/blockproducer/metaindex_test.go
+++ b/blockproducer/metaindex_test.go
@@ -22,7 +22,7 @@ import (
"testing"
pi "github.com/CovenantSQL/CovenantSQL/blockproducer/interfaces"
- pt "github.com/CovenantSQL/CovenantSQL/blockproducer/types"
+ pt "github.com/CovenantSQL/CovenantSQL/types"
"github.com/CovenantSQL/CovenantSQL/proto"
"github.com/coreos/bbolt"
. "github.com/smartystreets/goconvey/convey"
@@ -122,15 +122,13 @@ func TestMetaIndex(t *testing.T) {
mi.storeAccountObject(&accountObject{
Account: pt.Account{
Address: addr1,
- StableCoinBalance: 10,
- CovenantCoinBalance: 10,
+ TokenBalance: [pt.SupportTokenNumber]uint64{10, 10},
},
})
mi.storeAccountObject(&accountObject{
Account: pt.Account{
Address: addr2,
- StableCoinBalance: 10,
- CovenantCoinBalance: 10,
+ TokenBalance: [pt.SupportTokenNumber]uint64{10, 10},
},
})
Convey("The account objects should be retrievable", func() {
diff --git a/blockproducer/metastate.go b/blockproducer/metastate.go
index 07f34c09e..d955e83a6 100644
--- a/blockproducer/metastate.go
+++ b/blockproducer/metastate.go
@@ -18,10 +18,11 @@ package blockproducer
import (
"bytes"
+ "github.com/CovenantSQL/CovenantSQL/types"
"sync"
pi "github.com/CovenantSQL/CovenantSQL/blockproducer/interfaces"
- pt "github.com/CovenantSQL/CovenantSQL/blockproducer/types"
+ pt "github.com/CovenantSQL/CovenantSQL/types"
"github.com/CovenantSQL/CovenantSQL/proto"
"github.com/CovenantSQL/CovenantSQL/utils"
"github.com/CovenantSQL/CovenantSQL/utils/log"
@@ -89,11 +90,11 @@ func (s *metaState) loadAccountStableBalance(addr proto.AccountAddress) (b uint6
defer s.Unlock()
if o, loaded = s.dirty.accounts[addr]; loaded && o != nil {
- b = o.StableCoinBalance
+ b = o.TokenBalance[pt.Particle]
return
}
if o, loaded = s.readonly.accounts[addr]; loaded {
- b = o.StableCoinBalance
+ b = o.TokenBalance[pt.Particle]
return
}
return
@@ -113,11 +114,11 @@ func (s *metaState) loadAccountCovenantBalance(addr proto.AccountAddress) (b uin
defer s.Unlock()
if o, loaded = s.dirty.accounts[addr]; loaded && o != nil {
- b = o.CovenantCoinBalance
+ b = o.TokenBalance[pt.Wave]
return
}
if o, loaded = s.readonly.accounts[addr]; loaded {
- b = o.CovenantCoinBalance
+ b = o.TokenBalance[pt.Wave]
return
}
return
@@ -138,17 +139,17 @@ func (s *metaState) storeBaseAccount(k proto.AccountAddress, v *accountObject) (
return
}
var (
- cb = ao.CovenantCoinBalance
- sb = ao.StableCoinBalance
+ cb = ao.TokenBalance[pt.Wave]
+ sb = ao.TokenBalance[pt.Particle]
)
- if err = safeAdd(&cb, &v.Account.CovenantCoinBalance); err != nil {
+ if err = safeAdd(&cb, &v.Account.TokenBalance[pt.Wave]); err != nil {
return
}
- if err = safeAdd(&sb, &v.Account.StableCoinBalance); err != nil {
+ if err = safeAdd(&sb, &v.Account.TokenBalance[pt.Particle]); err != nil {
return
}
- ao.CovenantCoinBalance = cb
- ao.StableCoinBalance = sb
+ ao.TokenBalance[pt.Wave] = cb
+ ao.TokenBalance[pt.Particle] = sb
}
return
}
@@ -393,7 +394,7 @@ func (s *metaState) increaseAccountStableBalance(k proto.AccountAddress, amount
deepcopier.Copy(&src.Account).To(&dst.Account)
s.dirty.accounts[k] = dst
}
- return safeAdd(&dst.Account.StableCoinBalance, &amount)
+ return safeAdd(&dst.Account.TokenBalance[pt.Particle], &amount)
}
func (s *metaState) decreaseAccountStableBalance(k proto.AccountAddress, amount uint64) error {
@@ -411,7 +412,7 @@ func (s *metaState) decreaseAccountStableBalance(k proto.AccountAddress, amount
deepcopier.Copy(&src.Account).To(&dst.Account)
s.dirty.accounts[k] = dst
}
- return safeSub(&dst.Account.StableCoinBalance, &amount)
+ return safeSub(&dst.Account.TokenBalance[pt.Particle], &amount)
}
func (s *metaState) transferAccountStableBalance(
@@ -447,8 +448,8 @@ func (s *metaState) transferAccountStableBalance(
// Try transfer
var (
- sb = so.StableCoinBalance
- rb = ro.StableCoinBalance
+ sb = so.TokenBalance[pt.Particle]
+ rb = ro.TokenBalance[pt.Particle]
)
if err = safeSub(&sb, &amount); err != nil {
return
@@ -470,8 +471,8 @@ func (s *metaState) transferAccountStableBalance(
ro = cpy
s.dirty.accounts[receiver] = cpy
}
- so.StableCoinBalance = sb
- ro.StableCoinBalance = rb
+ so.TokenBalance[pt.Particle] = sb
+ ro.TokenBalance[pt.Particle] = rb
return
}
@@ -490,7 +491,7 @@ func (s *metaState) increaseAccountCovenantBalance(k proto.AccountAddress, amoun
deepcopier.Copy(&src.Account).To(&dst.Account)
s.dirty.accounts[k] = dst
}
- return safeAdd(&dst.Account.CovenantCoinBalance, &amount)
+ return safeAdd(&dst.Account.TokenBalance[pt.Wave], &amount)
}
func (s *metaState) decreaseAccountCovenantBalance(k proto.AccountAddress, amount uint64) error {
@@ -508,7 +509,7 @@ func (s *metaState) decreaseAccountCovenantBalance(k proto.AccountAddress, amoun
deepcopier.Copy(&src.Account).To(&dst.Account)
s.dirty.accounts[k] = dst
}
- return safeSub(&dst.Account.CovenantCoinBalance, &amount)
+ return safeSub(&dst.Account.TokenBalance[pt.Wave], &amount)
}
func (s *metaState) createSQLChain(addr proto.AccountAddress, id proto.DatabaseID) error {
@@ -528,7 +529,7 @@ func (s *metaState) createSQLChain(addr proto.AccountAddress, id proto.DatabaseI
SQLChainProfile: pt.SQLChainProfile{
ID: id,
Owner: addr,
- Miners: make([]proto.AccountAddress, 0),
+ Miners: make([]*pt.MinerInfo, 0),
Users: []*pt.SQLChainUser{
{
Address: addr,
@@ -660,7 +661,7 @@ func (s *metaState) increaseNonce(addr proto.AccountAddress) (err error) {
return
}
-func (s *metaState) applyBilling(tx *pt.Billing) (err error) {
+func (s *metaState) applyBilling(tx *types.Billing) (err error) {
for i, v := range tx.Receivers {
// Create empty receiver account if not found
s.loadOrStoreAccountObject(*v, &accountObject{Account: pt.Account{Address: *v}})
@@ -679,7 +680,7 @@ func (s *metaState) applyTransaction(tx pi.Transaction) (err error) {
switch t := tx.(type) {
case *pt.Transfer:
err = s.transferAccountStableBalance(t.Sender, t.Receiver, t.Amount)
- case *pt.Billing:
+ case *types.Billing:
err = s.applyBilling(t)
case *pt.BaseAccount:
err = s.storeBaseAccount(t.Address, &accountObject{Account: t.Account})
diff --git a/blockproducer/metastate_test.go b/blockproducer/metastate_test.go
index e27cc13af..cb51b4e22 100644
--- a/blockproducer/metastate_test.go
+++ b/blockproducer/metastate_test.go
@@ -17,13 +17,14 @@
package blockproducer
import (
+ "github.com/CovenantSQL/CovenantSQL/types"
"math"
"os"
"path"
"testing"
pi "github.com/CovenantSQL/CovenantSQL/blockproducer/interfaces"
- pt "github.com/CovenantSQL/CovenantSQL/blockproducer/types"
+ pt "github.com/CovenantSQL/CovenantSQL/types"
"github.com/CovenantSQL/CovenantSQL/proto"
"github.com/coreos/bbolt"
. "github.com/smartystreets/goconvey/convey"
@@ -262,8 +263,8 @@ func TestMetaState(t *testing.T) {
So(loaded, ShouldBeTrue)
So(ao, ShouldNotBeNil)
So(ao.Address, ShouldEqual, addr1)
- So(ao.StableCoinBalance, ShouldEqual, incSta)
- So(ao.CovenantCoinBalance, ShouldEqual, incCov)
+ So(ao.TokenBalance[pt.Particle], ShouldEqual, incSta)
+ So(ao.TokenBalance[pt.Wave], ShouldEqual, incCov)
bl, loaded = ms.loadAccountStableBalance(addr1)
So(loaded, ShouldBeTrue)
So(bl, ShouldEqual, incSta)
@@ -283,8 +284,8 @@ func TestMetaState(t *testing.T) {
So(loaded, ShouldBeTrue)
So(ao, ShouldNotBeNil)
So(ao.Address, ShouldEqual, addr1)
- So(ao.StableCoinBalance, ShouldEqual, incSta-decSta)
- So(ao.CovenantCoinBalance, ShouldEqual, incCov-decCov)
+ So(ao.TokenBalance[pt.Particle], ShouldEqual, incSta-decSta)
+ So(ao.TokenBalance[pt.Wave], ShouldEqual, incCov-decCov)
},
)
})
@@ -582,8 +583,8 @@ func TestMetaState(t *testing.T) {
Amount: 0,
},
)
- t2 = pt.NewBilling(
- &pt.BillingHeader{
+ t2 = types.NewBilling(
+ &types.BillingHeader{
Nonce: 2,
Producer: addr1,
Receivers: []*proto.AccountAddress{&addr2},
@@ -695,15 +696,13 @@ func TestMetaState(t *testing.T) {
pt.NewBaseAccount(
&pt.Account{
Address: addr1,
- StableCoinBalance: 100,
- CovenantCoinBalance: 100,
+ TokenBalance: [pt.SupportTokenNumber]uint64{100, 100},
},
),
pt.NewBaseAccount(
&pt.Account{
Address: addr2,
- StableCoinBalance: 100,
- CovenantCoinBalance: 100,
+ TokenBalance: [pt.SupportTokenNumber]uint64{100, 100},
},
),
pt.NewTransfer(
@@ -714,8 +713,8 @@ func TestMetaState(t *testing.T) {
Amount: 10,
},
),
- pt.NewBilling(
- &pt.BillingHeader{
+ types.NewBilling(
+ &types.BillingHeader{
Nonce: 2,
Producer: addr1,
Receivers: []*proto.AccountAddress{&addr2},
@@ -723,8 +722,8 @@ func TestMetaState(t *testing.T) {
Rewards: []uint64{1},
},
),
- pt.NewBilling(
- &pt.BillingHeader{
+ types.NewBilling(
+ &types.BillingHeader{
Nonce: 1,
Producer: addr2,
Receivers: []*proto.AccountAddress{&addr1},
diff --git a/blockproducer/types/billing_request.go b/blockproducer/otypes/billing_request.go
similarity index 100%
rename from blockproducer/types/billing_request.go
rename to blockproducer/otypes/billing_request.go
diff --git a/blockproducer/types/billing_request_gen.go b/blockproducer/otypes/billing_request_gen.go
similarity index 100%
rename from blockproducer/types/billing_request_gen.go
rename to blockproducer/otypes/billing_request_gen.go
diff --git a/blockproducer/types/billing_request_gen_test.go b/blockproducer/otypes/billing_request_gen_test.go
similarity index 100%
rename from blockproducer/types/billing_request_gen_test.go
rename to blockproducer/otypes/billing_request_gen_test.go
diff --git a/blockproducer/types/billing_request_test.go b/blockproducer/otypes/billing_request_test.go
similarity index 100%
rename from blockproducer/types/billing_request_test.go
rename to blockproducer/otypes/billing_request_test.go
diff --git a/blockproducer/types/errors.go b/blockproducer/otypes/errors.go
similarity index 66%
rename from blockproducer/types/errors.go
rename to blockproducer/otypes/errors.go
index 13d135db1..95b0a04f5 100644
--- a/blockproducer/types/errors.go
+++ b/blockproducer/otypes/errors.go
@@ -21,19 +21,9 @@ import (
)
var (
- // ErrHashVerification indicates a failed hash verification.
- ErrHashVerification = errors.New("hash verification failed")
-
// ErrSignVerification indicates a failed signature verification.
ErrSignVerification = errors.New("signature verification failed")
-
- // ErrMerkleRootVerification indicates a failed merkle root verificatin.
- ErrMerkleRootVerification = errors.New("merkle root verification failed")
-
- // ErrNodePublicKeyNotMatch indicates that the public key given with a node does not match the
- // one in the key store.
- ErrNodePublicKeyNotMatch = errors.New("node publick key doesn't match")
-
// ErrBillingNotMatch indicates that the billing request doesn't match the local result.
ErrBillingNotMatch = errors.New("billing request doesn't match")
+
)
diff --git a/blockproducer/otypes/xxx_test.go b/blockproducer/otypes/xxx_test.go
new file mode 100644
index 000000000..24f42f353
--- /dev/null
+++ b/blockproducer/otypes/xxx_test.go
@@ -0,0 +1,102 @@
+/*
+ * Copyright 2018 The CovenantSQL Authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package types
+
+import (
+ "github.com/CovenantSQL/CovenantSQL/crypto/asymmetric"
+ "github.com/CovenantSQL/CovenantSQL/crypto/hash"
+ "github.com/CovenantSQL/CovenantSQL/proto"
+ "math/rand"
+)
+
+var (
+ uuidLen = 32
+)
+
+const (
+ letterBytes = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
+)
+
+func generateRandomHash() hash.Hash {
+ h := hash.Hash{}
+ rand.Read(h[:])
+ return h
+}
+
+func generateRandomDatabaseID() *proto.DatabaseID {
+ id := proto.DatabaseID(randStringBytes(uuidLen))
+ return &id
+}
+
+func randStringBytes(n int) string {
+ b := make([]byte, n)
+ for i := range b {
+ b[i] = letterBytes[rand.Intn(len(letterBytes))]
+ }
+ return string(b)
+}
+
+func generateRandomBillingRequestHeader() *BillingRequestHeader {
+ return &BillingRequestHeader{
+ DatabaseID: *generateRandomDatabaseID(),
+ LowBlock: generateRandomHash(),
+ LowHeight: rand.Int31(),
+ HighBlock: generateRandomHash(),
+ HighHeight: rand.Int31(),
+ GasAmounts: generateRandomGasAmount(peerNum),
+ }
+}
+
+func generateRandomBillingRequest() (req *BillingRequest, err error) {
+ reqHeader := generateRandomBillingRequestHeader()
+ req = &BillingRequest{
+ Header: *reqHeader,
+ }
+ if _, err = req.PackRequestHeader(); err != nil {
+ return nil, err
+ }
+
+ for i := 0; i < peerNum; i++ {
+ // Generate key pair
+ var priv *asymmetric.PrivateKey
+
+ if priv, _, err = asymmetric.GenSecp256k1KeyPair(); err != nil {
+ return
+ }
+
+ if _, _, err = req.SignRequestHeader(priv, false); err != nil {
+ return
+ }
+ }
+
+ return
+}
+
+func generateRandomGasAmount(n int) []*proto.AddrAndGas {
+ gasAmount := make([]*proto.AddrAndGas, n)
+
+ for i := range gasAmount {
+ gasAmount[i] = &proto.AddrAndGas{
+ AccountAddress: proto.AccountAddress(generateRandomHash()),
+ RawNodeID: proto.RawNodeID{Hash: generateRandomHash()},
+ GasAmount: rand.Uint64(),
+ }
+ }
+
+ return gasAmount
+}
+
diff --git a/blockproducer/rpc.go b/blockproducer/rpc.go
index 1fafe2f2d..138854b5d 100644
--- a/blockproducer/rpc.go
+++ b/blockproducer/rpc.go
@@ -18,7 +18,7 @@ package blockproducer
import (
pi "github.com/CovenantSQL/CovenantSQL/blockproducer/interfaces"
- pt "github.com/CovenantSQL/CovenantSQL/blockproducer/types"
+ pt "github.com/CovenantSQL/CovenantSQL/types"
"github.com/CovenantSQL/CovenantSQL/proto"
"github.com/CovenantSQL/CovenantSQL/types"
)
@@ -31,7 +31,7 @@ type ChainRPCService struct {
// AdviseNewBlockReq defines a request of the AdviseNewBlock RPC method.
type AdviseNewBlockReq struct {
proto.Envelope
- Block *pt.Block
+ Block *pt.BPBlock
}
// AdviseNewBlockResp defines a response of the AdviseNewBlock RPC method.
@@ -42,7 +42,7 @@ type AdviseNewBlockResp struct {
// AdviseTxBillingReq defines a request of the AdviseTxBilling RPC method.
type AdviseTxBillingReq struct {
proto.Envelope
- TxBilling *pt.Billing
+ TxBilling *types.Billing
}
// AdviseTxBillingResp defines a response of the AdviseTxBilling RPC method.
@@ -61,7 +61,7 @@ type FetchBlockResp struct {
proto.Envelope
Height uint32
Count uint32
- Block *pt.Block
+ Block *pt.BPBlock
}
// FetchBlockByCountReq define a request of the FetchBlockByCount RPC method.
diff --git a/blockproducer/types/account_gen.go b/blockproducer/types/account_gen.go
deleted file mode 100644
index 031082942..000000000
--- a/blockproducer/types/account_gen.go
+++ /dev/null
@@ -1,155 +0,0 @@
-package types
-
-// Code generated by github.com/CovenantSQL/HashStablePack DO NOT EDIT.
-
-import (
- hsp "github.com/CovenantSQL/HashStablePack/marshalhash"
-)
-
-// MarshalHash marshals for hash
-func (z *Account) MarshalHash() (o []byte, err error) {
- var b []byte
- o = hsp.Require(b, z.Msgsize())
- // map header, size 5
- o = append(o, 0x85, 0x85)
- o = hsp.AppendFloat64(o, z.Rating)
- o = append(o, 0x85)
- if oTemp, err := z.NextNonce.MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
- }
- o = append(o, 0x85)
- if oTemp, err := z.Address.MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
- }
- o = append(o, 0x85)
- o = hsp.AppendUint64(o, z.StableCoinBalance)
- o = append(o, 0x85)
- o = hsp.AppendUint64(o, z.CovenantCoinBalance)
- return
-}
-
-// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
-func (z *Account) Msgsize() (s int) {
- s = 1 + 7 + hsp.Float64Size + 10 + z.NextNonce.Msgsize() + 8 + z.Address.Msgsize() + 18 + hsp.Uint64Size + 20 + hsp.Uint64Size
- return
-}
-
-// MarshalHash marshals for hash
-func (z *SQLChainProfile) MarshalHash() (o []byte, err error) {
- var b []byte
- o = hsp.Require(b, z.Msgsize())
- // map header, size 5
- o = append(o, 0x85, 0x85)
- o = hsp.AppendArrayHeader(o, uint32(len(z.Users)))
- for za0002 := range z.Users {
- if z.Users[za0002] == nil {
- o = hsp.AppendNil(o)
- } else {
- // map header, size 2
- o = append(o, 0x82, 0x82)
- if oTemp, err := z.Users[za0002].Address.MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
- }
- o = append(o, 0x82)
- o = hsp.AppendInt32(o, int32(z.Users[za0002].Permission))
- }
- }
- o = append(o, 0x85)
- o = hsp.AppendArrayHeader(o, uint32(len(z.Miners)))
- for za0001 := range z.Miners {
- if oTemp, err := z.Miners[za0001].MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
- }
- }
- o = append(o, 0x85)
- if oTemp, err := z.Owner.MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
- }
- o = append(o, 0x85)
- if oTemp, err := z.ID.MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
- }
- o = append(o, 0x85)
- o = hsp.AppendUint64(o, z.Deposit)
- return
-}
-
-// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
-func (z *SQLChainProfile) Msgsize() (s int) {
- s = 1 + 6 + hsp.ArrayHeaderSize
- for za0002 := range z.Users {
- if z.Users[za0002] == nil {
- s += hsp.NilSize
- } else {
- s += 1 + 8 + z.Users[za0002].Address.Msgsize() + 11 + hsp.Int32Size
- }
- }
- s += 7 + hsp.ArrayHeaderSize
- for za0001 := range z.Miners {
- s += z.Miners[za0001].Msgsize()
- }
- s += 6 + z.Owner.Msgsize() + 3 + z.ID.Msgsize() + 8 + hsp.Uint64Size
- return
-}
-
-// MarshalHash marshals for hash
-func (z SQLChainRole) MarshalHash() (o []byte, err error) {
- var b []byte
- o = hsp.Require(b, z.Msgsize())
- o = hsp.AppendByte(o, byte(z))
- return
-}
-
-// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
-func (z SQLChainRole) Msgsize() (s int) {
- s = hsp.ByteSize
- return
-}
-
-// MarshalHash marshals for hash
-func (z *SQLChainUser) MarshalHash() (o []byte, err error) {
- var b []byte
- o = hsp.Require(b, z.Msgsize())
- // map header, size 2
- o = append(o, 0x82, 0x82)
- o = hsp.AppendInt32(o, int32(z.Permission))
- o = append(o, 0x82)
- if oTemp, err := z.Address.MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
- }
- return
-}
-
-// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
-func (z *SQLChainUser) Msgsize() (s int) {
- s = 1 + 11 + hsp.Int32Size + 8 + z.Address.Msgsize()
- return
-}
-
-// MarshalHash marshals for hash
-func (z UserPermission) MarshalHash() (o []byte, err error) {
- var b []byte
- o = hsp.Require(b, z.Msgsize())
- o = hsp.AppendInt32(o, int32(z))
- return
-}
-
-// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
-func (z UserPermission) Msgsize() (s int) {
- s = hsp.Int32Size
- return
-}
diff --git a/blockproducer/types/xxx_test.go b/blockproducer/types/xxx_test.go
deleted file mode 100644
index 31bd5a7ae..000000000
--- a/blockproducer/types/xxx_test.go
+++ /dev/null
@@ -1,281 +0,0 @@
-/*
- * Copyright 2018 The CovenantSQL Authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package types
-
-import (
- "io/ioutil"
- "math/rand"
- "os"
- "testing"
- "time"
-
- pi "github.com/CovenantSQL/CovenantSQL/blockproducer/interfaces"
- "github.com/CovenantSQL/CovenantSQL/crypto/asymmetric"
- "github.com/CovenantSQL/CovenantSQL/crypto/hash"
- "github.com/CovenantSQL/CovenantSQL/crypto/kms"
- "github.com/CovenantSQL/CovenantSQL/proto"
- "github.com/CovenantSQL/CovenantSQL/utils/log"
-)
-
-var (
- genesisHash = hash.Hash{}
- uuidLen = 32
-)
-
-const (
- letterBytes = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
-)
-
-func generateRandomSQLChainUser() *SQLChainUser {
- return &SQLChainUser{
- Address: proto.AccountAddress(generateRandomHash()),
- Permission: UserPermission(rand.Int31n(int32(NumberOfUserPermission))),
- }
-}
-
-func generateRandomSQLChainUsers(n int) (users []*SQLChainUser) {
- users = make([]*SQLChainUser, n)
- for i := range users {
- users[i] = generateRandomSQLChainUser()
- }
- return
-}
-
-func generateRandomAccountAddresses(n int) (s []proto.AccountAddress) {
- s = make([]proto.AccountAddress, n)
- for i := range s {
- s[i] = proto.AccountAddress(generateRandomHash())
- }
- return
-}
-
-func generateRandomProfile() *SQLChainProfile {
- return &SQLChainProfile{
- ID: *generateRandomDatabaseID(),
- Deposit: rand.Uint64(),
- Owner: proto.AccountAddress(generateRandomHash()),
- Miners: generateRandomAccountAddresses(rand.Intn(10) + 1),
- Users: generateRandomSQLChainUsers(rand.Intn(10) + 1),
- }
-}
-
-func generateRandomAccount() *Account {
- return &Account{
- Address: proto.AccountAddress(generateRandomHash()),
- StableCoinBalance: rand.Uint64(),
- CovenantCoinBalance: rand.Uint64(),
- Rating: rand.Float64(),
- }
-}
-
-func generateRandomBytes(n int32) []byte {
- s := make([]byte, n)
- for i := range s {
- s[i] = byte(rand.Int31n(2))
- }
- return s
-}
-
-func generateRandomHash() hash.Hash {
- h := hash.Hash{}
- rand.Read(h[:])
- return h
-}
-
-func generateRandomDatabaseID() *proto.DatabaseID {
- id := proto.DatabaseID(randStringBytes(uuidLen))
- return &id
-}
-
-func generateRandomDatabaseIDs(n int32) []proto.DatabaseID {
- s := make([]proto.DatabaseID, n)
- for i := range s {
- s[i] = proto.DatabaseID(randStringBytes(uuidLen))
- }
- return s
-}
-
-func randStringBytes(n int) string {
- b := make([]byte, n)
- for i := range b {
- b[i] = letterBytes[rand.Intn(len(letterBytes))]
- }
- return string(b)
-}
-
-func generateRandomBlock(parent hash.Hash, isGenesis bool) (b *Block, err error) {
- // Generate key pair
- priv, _, err := asymmetric.GenSecp256k1KeyPair()
-
- if err != nil {
- return
- }
-
- h := hash.Hash{}
- rand.Read(h[:])
-
- b = &Block{
- SignedHeader: SignedHeader{
- Header: Header{
- Version: 0x01000000,
- Producer: proto.AccountAddress(h),
- ParentHash: parent,
- Timestamp: time.Now().UTC(),
- },
- },
- }
-
- for i, n := 0, rand.Intn(10)+10; i < n; i++ {
- tb, err := generateRandomBilling()
- if err != nil {
- return nil, err
- }
- b.Transactions = append(b.Transactions, tb)
- }
-
- err = b.PackAndSignBlock(priv)
- return
-}
-
-func generateRandomBillingRequestHeader() *BillingRequestHeader {
- return &BillingRequestHeader{
- DatabaseID: *generateRandomDatabaseID(),
- LowBlock: generateRandomHash(),
- LowHeight: rand.Int31(),
- HighBlock: generateRandomHash(),
- HighHeight: rand.Int31(),
- GasAmounts: generateRandomGasAmount(peerNum),
- }
-}
-
-func generateRandomBillingRequest() (req *BillingRequest, err error) {
- reqHeader := generateRandomBillingRequestHeader()
- req = &BillingRequest{
- Header: *reqHeader,
- }
- if _, err = req.PackRequestHeader(); err != nil {
- return nil, err
- }
-
- for i := 0; i < peerNum; i++ {
- // Generate key pair
- var priv *asymmetric.PrivateKey
-
- if priv, _, err = asymmetric.GenSecp256k1KeyPair(); err != nil {
- return
- }
-
- if _, _, err = req.SignRequestHeader(priv, false); err != nil {
- return
- }
- }
-
- return
-}
-
-func generateRandomBillingHeader() (tc *BillingHeader, err error) {
- var req *BillingRequest
- if req, err = generateRandomBillingRequest(); err != nil {
- return
- }
-
- var priv *asymmetric.PrivateKey
- if priv, _, err = asymmetric.GenSecp256k1KeyPair(); err != nil {
- return
- }
-
- if _, _, err = req.SignRequestHeader(priv, false); err != nil {
- return
- }
-
- receivers := make([]*proto.AccountAddress, peerNum)
- fees := make([]uint64, peerNum)
- rewards := make([]uint64, peerNum)
- for i := range fees {
- h := generateRandomHash()
- accountAddress := proto.AccountAddress(h)
- receivers[i] = &accountAddress
- fees[i] = rand.Uint64()
- rewards[i] = rand.Uint64()
- }
-
- producer := proto.AccountAddress(generateRandomHash())
- tc = NewBillingHeader(pi.AccountNonce(rand.Uint32()), req, producer, receivers, fees, rewards)
- return tc, nil
-}
-
-func generateRandomBilling() (*Billing, error) {
- header, err := generateRandomBillingHeader()
- if err != nil {
- return nil, err
- }
- priv, _, err := asymmetric.GenSecp256k1KeyPair()
- if err != nil {
- return nil, err
- }
- txBilling := NewBilling(header)
- if err := txBilling.Sign(priv); err != nil {
- return nil, err
- }
- return txBilling, nil
-}
-
-func generateRandomGasAmount(n int) []*proto.AddrAndGas {
- gasAmount := make([]*proto.AddrAndGas, n)
-
- for i := range gasAmount {
- gasAmount[i] = &proto.AddrAndGas{
- AccountAddress: proto.AccountAddress(generateRandomHash()),
- RawNodeID: proto.RawNodeID{Hash: generateRandomHash()},
- GasAmount: rand.Uint64(),
- }
- }
-
- return gasAmount
-}
-
-func setup() {
- rand.Seed(time.Now().UnixNano())
- rand.Read(genesisHash[:])
- f, err := ioutil.TempFile("", "keystore")
-
- if err != nil {
- panic(err)
- }
-
- f.Close()
-
- if err = kms.InitPublicKeyStore(f.Name(), nil); err != nil {
- panic(err)
- }
-
- kms.Unittest = true
-
- if priv, pub, err := asymmetric.GenSecp256k1KeyPair(); err == nil {
- kms.SetLocalKeyPair(priv, pub)
- } else {
- panic(err)
- }
-
- log.SetOutput(os.Stdout)
- log.SetLevel(log.DebugLevel)
-}
-
-func TestMain(m *testing.M) {
- setup()
- os.Exit(m.Run())
-}
diff --git a/blockproducer/xxx_test.go b/blockproducer/xxx_test.go
index 14972dc65..a88859f20 100644
--- a/blockproducer/xxx_test.go
+++ b/blockproducer/xxx_test.go
@@ -17,6 +17,7 @@
package blockproducer
import (
+ "github.com/CovenantSQL/CovenantSQL/types"
"io/ioutil"
"math/rand"
"os"
@@ -25,7 +26,7 @@ import (
"time"
pi "github.com/CovenantSQL/CovenantSQL/blockproducer/interfaces"
- pt "github.com/CovenantSQL/CovenantSQL/blockproducer/types"
+ pt "github.com/CovenantSQL/CovenantSQL/types"
"github.com/CovenantSQL/CovenantSQL/crypto"
"github.com/CovenantSQL/CovenantSQL/crypto/asymmetric"
"github.com/CovenantSQL/CovenantSQL/crypto/hash"
@@ -82,7 +83,7 @@ func randStringBytes(n int) string {
return string(b)
}
-func generateRandomBlock(parent hash.Hash, isGenesis bool) (b *pt.Block, err error) {
+func generateRandomBlock(parent hash.Hash, isGenesis bool) (b *pt.BPBlock, err error) {
// Generate key pair
priv, _, err := asymmetric.GenSecp256k1KeyPair()
@@ -93,9 +94,9 @@ func generateRandomBlock(parent hash.Hash, isGenesis bool) (b *pt.Block, err err
h := hash.Hash{}
rand.Read(h[:])
- b = &pt.Block{
- SignedHeader: pt.SignedHeader{
- Header: pt.Header{
+ b = &pt.BPBlock{
+ SignedHeader: pt.BPSignedHeader{
+ BPHeader: pt.BPHeader{
Version: 0x01000000,
Producer: proto.AccountAddress(h),
ParentHash: parent,
@@ -118,15 +119,13 @@ func generateRandomBlock(parent hash.Hash, isGenesis bool) (b *pt.Block, err err
ba1 = pt.NewBaseAccount(
&pt.Account{
Address: testAddress1,
- StableCoinBalance: testInitBalance,
- CovenantCoinBalance: testInitBalance,
+ TokenBalance: [pt.SupportTokenNumber]uint64{testInitBalance, testInitBalance},
},
)
ba2 = pt.NewBaseAccount(
&pt.Account{
Address: testAddress2,
- StableCoinBalance: testInitBalance,
- CovenantCoinBalance: testInitBalance,
+ TokenBalance: [pt.SupportTokenNumber]uint64{testInitBalance, testInitBalance},
},
)
)
@@ -143,7 +142,7 @@ func generateRandomBlock(parent hash.Hash, isGenesis bool) (b *pt.Block, err err
return
}
-func generateRandomBlockWithTransactions(parent hash.Hash, tbs []pi.Transaction) (b *pt.Block, err error) {
+func generateRandomBlockWithTransactions(parent hash.Hash, tbs []pi.Transaction) (b *pt.BPBlock, err error) {
// Generate key pair
priv, _, err := asymmetric.GenSecp256k1KeyPair()
@@ -154,9 +153,9 @@ func generateRandomBlockWithTransactions(parent hash.Hash, tbs []pi.Transaction)
h := hash.Hash{}
rand.Read(h[:])
- b = &pt.Block{
- SignedHeader: pt.SignedHeader{
- Header: pt.Header{
+ b = &pt.BPBlock{
+ SignedHeader: pt.BPSignedHeader{
+ BPHeader: pt.BPHeader{
Version: 0x01000000,
Producer: proto.AccountAddress(h),
ParentHash: parent,
@@ -188,8 +187,8 @@ func generateRandomBlockWithTransactions(parent hash.Hash, tbs []pi.Transaction)
return
}
-func generateRandomBillingRequestHeader() *pt.BillingRequestHeader {
- return &pt.BillingRequestHeader{
+func generateRandomBillingRequestHeader() *types.BillingRequestHeader {
+ return &types.BillingRequestHeader{
DatabaseID: *generateRandomDatabaseID(),
LowBlock: generateRandomHash(),
LowHeight: rand.Int31(),
@@ -199,9 +198,9 @@ func generateRandomBillingRequestHeader() *pt.BillingRequestHeader {
}
}
-func generateRandomBillingRequest() (*pt.BillingRequest, error) {
+func generateRandomBillingRequest() (*types.BillingRequest, error) {
reqHeader := generateRandomBillingRequestHeader()
- req := pt.BillingRequest{
+ req := types.BillingRequest{
Header: *reqHeader,
}
h, err := req.PackRequestHeader()
@@ -231,8 +230,8 @@ func generateRandomBillingRequest() (*pt.BillingRequest, error) {
return &req, nil
}
-func generateRandomBillingHeader() (tc *pt.BillingHeader, err error) {
- var req *pt.BillingRequest
+func generateRandomBillingHeader() (tc *types.BillingHeader, err error) {
+ var req *types.BillingRequest
if req, err = generateRandomBillingRequest(); err != nil {
return
}
@@ -258,11 +257,11 @@ func generateRandomBillingHeader() (tc *pt.BillingHeader, err error) {
}
producer := proto.AccountAddress(generateRandomHash())
- tc = pt.NewBillingHeader(pi.AccountNonce(rand.Uint32()), req, producer, receivers, fees, rewards)
+ tc = types.NewBillingHeader(pi.AccountNonce(rand.Uint32()), req, producer, receivers, fees, rewards)
return tc, nil
}
-func generateRandomBillingAndBaseAccount() (*pt.BaseAccount, *pt.Billing, error) {
+func generateRandomBillingAndBaseAccount() (*pt.BaseAccount, *types.Billing, error) {
header, err := generateRandomBillingHeader()
if err != nil {
return nil, nil, err
@@ -270,7 +269,7 @@ func generateRandomBillingAndBaseAccount() (*pt.BaseAccount, *pt.Billing, error)
priv, _, err := asymmetric.GenSecp256k1KeyPair()
header.Producer, _ = crypto.PubKeyHash(priv.PubKey())
- txBilling := pt.NewBilling(header)
+ txBilling := types.NewBilling(header)
if err := txBilling.Sign(priv); err != nil {
return nil, nil, err
@@ -279,8 +278,7 @@ func generateRandomBillingAndBaseAccount() (*pt.BaseAccount, *pt.Billing, error)
txBaseAccount := pt.NewBaseAccount(
&pt.Account{
Address: header.Producer,
- StableCoinBalance: testInitBalance,
- CovenantCoinBalance: testInitBalance,
+ TokenBalance: [pt.SupportTokenNumber]uint64{testInitBalance, testInitBalance},
},
)
@@ -291,7 +289,7 @@ func generateRandomBillingAndBaseAccount() (*pt.BaseAccount, *pt.Billing, error)
return txBaseAccount, txBilling, nil
}
-func generateRandomAccountBilling() (*pt.Billing, error) {
+func generateRandomAccountBilling() (*types.Billing, error) {
header, err := generateRandomBillingHeader()
if err != nil {
return nil, err
@@ -299,7 +297,7 @@ func generateRandomAccountBilling() (*pt.Billing, error) {
header.Producer = testAddress1
testAddress1Nonce++
header.Nonce = testAddress1Nonce
- txBilling := pt.NewBilling(header)
+ txBilling := types.NewBilling(header)
if err := txBilling.Sign(testPrivKey); err != nil {
return nil, err
diff --git a/cmd/cql-explorer/api.go b/cmd/cql-explorer/api.go
index fb55c3366..f6c577dfa 100644
--- a/cmd/cql-explorer/api.go
+++ b/cmd/cql-explorer/api.go
@@ -25,7 +25,7 @@ import (
"time"
pi "github.com/CovenantSQL/CovenantSQL/blockproducer/interfaces"
- pt "github.com/CovenantSQL/CovenantSQL/blockproducer/types"
+ pt "github.com/CovenantSQL/CovenantSQL/types"
"github.com/CovenantSQL/CovenantSQL/crypto/hash"
"github.com/CovenantSQL/CovenantSQL/proto"
"github.com/CovenantSQL/CovenantSQL/utils/log"
@@ -167,7 +167,7 @@ func (a *explorerAPI) formatTime(t time.Time) float64 {
return float64(t.UnixNano()) / 1e6
}
-func (a *explorerAPI) formatBlock(count uint32, height uint32, b *pt.Block) map[string]interface{} {
+func (a *explorerAPI) formatBlock(count uint32, height uint32, b *pt.BPBlock) map[string]interface{} {
txs := make([]map[string]interface{}, 0, len(b.Transactions))
for _, tx := range b.Transactions {
@@ -207,8 +207,8 @@ func (a *explorerAPI) formatRawTx(t pi.Transaction) (res map[string]interface{})
res = map[string]interface{}{
"next_nonce": tx.NextNonce,
"address": tx.Address,
- "stable_balance": tx.StableCoinBalance,
- "covenant_balance": tx.CovenantCoinBalance,
+ "stable_balance": tx.TokenBalance[pt.Particle],
+ "covenant_balance": tx.TokenBalance[pt.Wave],
"rating": tx.Rating,
}
case *pi.TransactionWrapper:
diff --git a/cmd/cql-explorer/service.go b/cmd/cql-explorer/service.go
index d77181285..9159e53b9 100644
--- a/cmd/cql-explorer/service.go
+++ b/cmd/cql-explorer/service.go
@@ -26,7 +26,7 @@ import (
bp "github.com/CovenantSQL/CovenantSQL/blockproducer"
pi "github.com/CovenantSQL/CovenantSQL/blockproducer/interfaces"
- pt "github.com/CovenantSQL/CovenantSQL/blockproducer/types"
+ pt "github.com/CovenantSQL/CovenantSQL/types"
"github.com/CovenantSQL/CovenantSQL/conf"
"github.com/CovenantSQL/CovenantSQL/crypto/hash"
"github.com/CovenantSQL/CovenantSQL/proto"
@@ -111,7 +111,7 @@ func (s *Service) start() (err error) {
return
}
-func (s *Service) getBlockByCount(c uint32) (b *pt.Block, count uint32, height uint32, err error) {
+func (s *Service) getBlockByCount(c uint32) (b *pt.BPBlock, count uint32, height uint32, err error) {
var bKey []byte
bKey = append(bKey, blockKeyPrefix...)
bKey = append(bKey, uint32ToBytes(c)...)
@@ -141,7 +141,7 @@ func (s *Service) getBlockByCount(c uint32) (b *pt.Block, count uint32, height u
return
}
-func (s *Service) getBlockByHash(h *hash.Hash) (b *pt.Block, count uint32, height uint32, err error) {
+func (s *Service) getBlockByHash(h *hash.Hash) (b *pt.BPBlock, count uint32, height uint32, err error) {
if h == nil {
err = ErrNotFound
return
@@ -163,7 +163,7 @@ func (s *Service) getBlockByHash(h *hash.Hash) (b *pt.Block, count uint32, heigh
return s.getBlockByCount(count)
}
-func (s *Service) getBlockByHeight(h uint32) (b *pt.Block, count uint32, height uint32, err error) {
+func (s *Service) getBlockByHeight(h uint32) (b *pt.BPBlock, count uint32, height uint32, err error) {
var bKey []byte
bKey = append(bKey, blockHeightPrefix...)
bKey = append(bKey, uint32ToBytes(h)...)
@@ -200,7 +200,7 @@ func (s *Service) getTxByHash(h *hash.Hash) (tx pi.Transaction, c uint32, height
c = bytesToUint32(bCountData)
- var b *pt.Block
+ var b *pt.BPBlock
if b, _, height, err = s.getBlockByCount(c); err != nil {
return
}
@@ -326,7 +326,7 @@ func (s *Service) requestBlock() {
}
}
-func (s *Service) processBlock(c uint32, h uint32, b *pt.Block) (err error) {
+func (s *Service) processBlock(c uint32, h uint32, b *pt.BPBlock) (err error) {
if b == nil {
log.WithField("count", c).Warning("processed nil block")
return ErrNilBlock
@@ -380,7 +380,7 @@ func (s *Service) saveTransaction(c uint32, tx pi.Transaction) (err error) {
return
}
-func (s *Service) saveBlock(c uint32, h uint32, b *pt.Block) (err error) {
+func (s *Service) saveBlock(c uint32, h uint32, b *pt.BPBlock) (err error) {
if b == nil {
return ErrNilBlock
}
diff --git a/cmd/cql-faucet/verifier.go b/cmd/cql-faucet/verifier.go
index aaefa1c30..9e7b3987e 100644
--- a/cmd/cql-faucet/verifier.go
+++ b/cmd/cql-faucet/verifier.go
@@ -28,7 +28,7 @@ import (
"time"
bp "github.com/CovenantSQL/CovenantSQL/blockproducer"
- pt "github.com/CovenantSQL/CovenantSQL/blockproducer/types"
+ pt "github.com/CovenantSQL/CovenantSQL/types"
"github.com/CovenantSQL/CovenantSQL/crypto"
"github.com/CovenantSQL/CovenantSQL/crypto/asymmetric"
"github.com/CovenantSQL/CovenantSQL/crypto/kms"
diff --git a/cmd/cqld/bootstrap.go b/cmd/cqld/bootstrap.go
index ef0ed00c5..5b6b6fb3f 100644
--- a/cmd/cqld/bootstrap.go
+++ b/cmd/cqld/bootstrap.go
@@ -25,8 +25,7 @@ import (
"time"
bp "github.com/CovenantSQL/CovenantSQL/blockproducer"
- "github.com/CovenantSQL/CovenantSQL/blockproducer/types"
- pt "github.com/CovenantSQL/CovenantSQL/blockproducer/types"
+ "github.com/CovenantSQL/CovenantSQL/types"
"github.com/CovenantSQL/CovenantSQL/conf"
"github.com/CovenantSQL/CovenantSQL/crypto/kms"
"github.com/CovenantSQL/CovenantSQL/kayak"
@@ -262,13 +261,13 @@ func initDBService(kvServer *KayakKVServer, metricService *metric.CollectServer)
return
}
-func loadGenesis() *types.Block {
+func loadGenesis() *types.BPBlock {
genesisInfo := conf.GConf.BP.BPGenesis
log.WithField("config", genesisInfo).Info("load genesis config")
- genesis := &types.Block{
- SignedHeader: types.SignedHeader{
- Header: types.Header{
+ genesis := &types.BPBlock{
+ SignedHeader: types.BPSignedHeader{
+ BPHeader: types.BPHeader{
Version: genesisInfo.Version,
Producer: proto.AccountAddress(genesisInfo.Producer),
MerkleRoot: genesisInfo.MerkleRoot,
@@ -285,11 +284,10 @@ func loadGenesis() *types.Block {
"stableCoinBalance": ba.StableCoinBalance,
"covenantCoinBalance": ba.CovenantCoinBalance,
}).Debug("setting one balance fixture in genesis block")
- genesis.Transactions = append(genesis.Transactions, pt.NewBaseAccount(
- &pt.Account{
+ genesis.Transactions = append(genesis.Transactions, types.NewBaseAccount(
+ &types.Account{
Address: proto.AccountAddress(ba.Address),
- StableCoinBalance: ba.StableCoinBalance,
- CovenantCoinBalance: ba.CovenantCoinBalance,
+ TokenBalance: [types.SupportTokenNumber]uint64{ba.StableCoinBalance, ba.CovenantCoinBalance},
}))
}
diff --git a/sqlchain/chain.go b/sqlchain/chain.go
index 79e68e936..5e5a1b24e 100644
--- a/sqlchain/chain.go
+++ b/sqlchain/chain.go
@@ -24,7 +24,6 @@ import (
"sync"
"time"
- pt "github.com/CovenantSQL/CovenantSQL/blockproducer/types"
"github.com/CovenantSQL/CovenantSQL/crypto"
"github.com/CovenantSQL/CovenantSQL/crypto/asymmetric"
"github.com/CovenantSQL/CovenantSQL/crypto/hash"
@@ -106,7 +105,7 @@ type Chain struct {
acks chan *types.AckHeader
// DBAccount info
- tokenType pt.TokenType
+ tokenType types.TokenType
gasPrice uint64
updatePeriod uint64
@@ -550,7 +549,7 @@ func (c *Chain) produceBlockV2(now time.Time) (err error) {
Producer: c.rt.getServer(),
GenesisHash: c.rt.genesisHash,
ParentHash: c.rt.getHead().Head,
- // MerkleRoot: will be set by Block.PackAndSignBlock(PrivateKey)
+ // MerkleRoot: will be set by BPBlock.PackAndSignBlock(PrivateKey)
Timestamp: now,
},
},
@@ -1164,7 +1163,7 @@ func (c *Chain) UpdatePeers(peers *proto.Peers) error {
}
// getBilling returns a billing request from the blocks within height range [low, high].
-func (c *Chain) getBilling(low, high int32) (req *pt.BillingRequest, err error) {
+func (c *Chain) getBilling(low, high int32) (req *types.BillingRequest, err error) {
// Height `n` is ensured (or skipped) if `Next Turn` > `n` + 1
if c.rt.getNextTurn() <= high+1 {
err = ErrUnavailableBillingRang
@@ -1243,8 +1242,8 @@ func (c *Chain) getBilling(low, high int32) (req *pt.BillingRequest, err error)
gasAmounts = append(gasAmounts, v)
}
- req = &pt.BillingRequest{
- Header: pt.BillingRequestHeader{
+ req = &types.BillingRequest{
+ Header: types.BillingRequestHeader{
DatabaseID: c.rt.databaseID,
LowBlock: *lowBlock.BlockHash(),
LowHeight: low,
@@ -1256,7 +1255,7 @@ func (c *Chain) getBilling(low, high int32) (req *pt.BillingRequest, err error)
return
}
-func (c *Chain) collectBillingSignatures(billings *pt.BillingRequest) {
+func (c *Chain) collectBillingSignatures(billings *types.BillingRequest) {
defer c.rt.wg.Done()
// Process sign billing responses, note that range iterating over channel will only break if
// the channle is closed
@@ -1347,7 +1346,7 @@ func (c *Chain) collectBillingSignatures(billings *pt.BillingRequest) {
// (inclusive).
func (c *Chain) LaunchBilling(low, high int32) (err error) {
var (
- req *pt.BillingRequest
+ req *types.BillingRequest
)
defer log.WithFields(log.Fields{
@@ -1371,11 +1370,11 @@ func (c *Chain) LaunchBilling(low, high int32) (err error) {
}
// SignBilling signs a billing request.
-func (c *Chain) SignBilling(req *pt.BillingRequest) (
+func (c *Chain) SignBilling(req *types.BillingRequest) (
pub *asymmetric.PublicKey, sig *asymmetric.Signature, err error,
) {
var (
- loc *pt.BillingRequest
+ loc *types.BillingRequest
)
defer log.WithFields(log.Fields{
"peer": c.rt.getPeerInfoString(),
diff --git a/sqlchain/config.go b/sqlchain/config.go
index 9fad34d91..8f2e09665 100644
--- a/sqlchain/config.go
+++ b/sqlchain/config.go
@@ -19,7 +19,6 @@ package sqlchain
import (
"time"
- pt "github.com/CovenantSQL/CovenantSQL/blockproducer/types"
"github.com/CovenantSQL/CovenantSQL/proto"
"github.com/CovenantSQL/CovenantSQL/types"
)
@@ -47,7 +46,7 @@ type Config struct {
QueryTTL int32
// DBAccount info
- TokenType pt.TokenType
+ TokenType types.TokenType
GasPrice uint64
UpdatePeriod uint64
}
diff --git a/sqlchain/otypes/billing_req.go b/sqlchain/otypes/billing_req.go
index 59521a6d4..2b5c360d2 100644
--- a/sqlchain/otypes/billing_req.go
+++ b/sqlchain/otypes/billing_req.go
@@ -17,7 +17,7 @@
package otypes
import (
- pt "github.com/CovenantSQL/CovenantSQL/blockproducer/types"
+ pt "github.com/CovenantSQL/CovenantSQL/blockproducer/otypes"
"github.com/CovenantSQL/CovenantSQL/proto"
)
diff --git a/sqlchain/rpc.go b/sqlchain/rpc.go
index c30029053..93be29adc 100644
--- a/sqlchain/rpc.go
+++ b/sqlchain/rpc.go
@@ -17,7 +17,6 @@
package sqlchain
import (
- pt "github.com/CovenantSQL/CovenantSQL/blockproducer/types"
"github.com/CovenantSQL/CovenantSQL/crypto/asymmetric"
"github.com/CovenantSQL/CovenantSQL/crypto/hash"
"github.com/CovenantSQL/CovenantSQL/proto"
@@ -80,7 +79,7 @@ type FetchAckedQueryResp struct {
// SignBillingReq defines a request of the SignBilling RPC method.
type SignBillingReq struct {
- pt.BillingRequest
+ types.BillingRequest
}
// SignBillingResp defines a response of the SignBilling RPC method.
diff --git a/blockproducer/types/account.go b/types/account.go
similarity index 70%
rename from blockproducer/types/account.go
rename to types/account.go
index 1c11e5777..66d09658b 100644
--- a/blockproducer/types/account.go
+++ b/types/account.go
@@ -49,26 +49,59 @@ const (
NumberOfUserPermission
)
+// Status defines status of a SQLChain user/miner.
+type Status int32
+
+const (
+ // Normal defines no bad thing happens.
+ Normal Status = iota
+ // Reminder defines the user needs to increase advance payment.
+ Reminder
+ // Arrears defines the user is in arrears.
+ Arrears
+ // Arbitration defines the user/miner is in an arbitration.
+ Arbitration
+)
+
// SQLChainUser defines a SQLChain user.
type SQLChainUser struct {
Address proto.AccountAddress
Permission UserPermission
+ AdvancePayment uint64
+ Arrears uint64
+ Pledge uint64
+ Status Status
+}
+
+// MinerInfo defines a miner.
+type MinerInfo struct {
+ Address proto.AccountAddress
+ Name string
+ PendingIncome uint64
+ ReceivedIncome uint64
+ Pledge uint64
+ Status Status
}
// SQLChainProfile defines a SQLChainProfile related to an account.
type SQLChainProfile struct {
ID proto.DatabaseID
- Deposit uint64
+ Address proto.AccountAddress
+ Period uint64
+ GasPrice uint64
+
+ TokenType TokenType
+
Owner proto.AccountAddress
- Miners []proto.AccountAddress
+ Miners []*MinerInfo
+
Users []*SQLChainUser
}
// Account store its balance, and other mate data.
type Account struct {
Address proto.AccountAddress
- StableCoinBalance uint64
- CovenantCoinBalance uint64
+ TokenBalance [SupportTokenNumber]uint64
Rating float64
NextNonce pi.AccountNonce
}
diff --git a/types/account_gen.go b/types/account_gen.go
new file mode 100644
index 000000000..ea8c2f440
--- /dev/null
+++ b/types/account_gen.go
@@ -0,0 +1,226 @@
+package types
+
+// Code generated by github.com/CovenantSQL/HashStablePack DO NOT EDIT.
+
+import (
+ hsp "github.com/CovenantSQL/HashStablePack/marshalhash"
+)
+
+// MarshalHash marshals for hash
+func (z *Account) MarshalHash() (o []byte, err error) {
+ var b []byte
+ o = hsp.Require(b, z.Msgsize())
+ // map header, size 4
+ o = append(o, 0x84, 0x84)
+ o = hsp.AppendArrayHeader(o, uint32(SupportTokenNumber))
+ for za0001 := range z.TokenBalance {
+ o = hsp.AppendUint64(o, z.TokenBalance[za0001])
+ }
+ o = append(o, 0x84)
+ o = hsp.AppendFloat64(o, z.Rating)
+ o = append(o, 0x84)
+ if oTemp, err := z.NextNonce.MarshalHash(); err != nil {
+ return nil, err
+ } else {
+ o = hsp.AppendBytes(o, oTemp)
+ }
+ o = append(o, 0x84)
+ if oTemp, err := z.Address.MarshalHash(); err != nil {
+ return nil, err
+ } else {
+ o = hsp.AppendBytes(o, oTemp)
+ }
+ return
+}
+
+// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
+func (z *Account) Msgsize() (s int) {
+ s = 1 + 13 + hsp.ArrayHeaderSize + (int(SupportTokenNumber) * (hsp.Uint64Size)) + 7 + hsp.Float64Size + 10 + z.NextNonce.Msgsize() + 8 + z.Address.Msgsize()
+ return
+}
+
+// MarshalHash marshals for hash
+func (z *MinerInfo) MarshalHash() (o []byte, err error) {
+ var b []byte
+ o = hsp.Require(b, z.Msgsize())
+ // map header, size 6
+ o = append(o, 0x86, 0x86)
+ o = hsp.AppendInt32(o, int32(z.Status))
+ o = append(o, 0x86)
+ if oTemp, err := z.Address.MarshalHash(); err != nil {
+ return nil, err
+ } else {
+ o = hsp.AppendBytes(o, oTemp)
+ }
+ o = append(o, 0x86)
+ o = hsp.AppendString(o, z.Name)
+ o = append(o, 0x86)
+ o = hsp.AppendUint64(o, z.PendingIncome)
+ o = append(o, 0x86)
+ o = hsp.AppendUint64(o, z.ReceivedIncome)
+ o = append(o, 0x86)
+ o = hsp.AppendUint64(o, z.Pledge)
+ return
+}
+
+// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
+func (z *MinerInfo) Msgsize() (s int) {
+ s = 1 + 7 + hsp.Int32Size + 8 + z.Address.Msgsize() + 5 + hsp.StringPrefixSize + len(z.Name) + 14 + hsp.Uint64Size + 15 + hsp.Uint64Size + 7 + hsp.Uint64Size
+ return
+}
+
+// MarshalHash marshals for hash
+func (z *SQLChainProfile) MarshalHash() (o []byte, err error) {
+ var b []byte
+ o = hsp.Require(b, z.Msgsize())
+ // map header, size 8
+ o = append(o, 0x88, 0x88)
+ if oTemp, err := z.TokenType.MarshalHash(); err != nil {
+ return nil, err
+ } else {
+ o = hsp.AppendBytes(o, oTemp)
+ }
+ o = append(o, 0x88)
+ o = hsp.AppendArrayHeader(o, uint32(len(z.Miners)))
+ for za0001 := range z.Miners {
+ if z.Miners[za0001] == nil {
+ o = hsp.AppendNil(o)
+ } else {
+ if oTemp, err := z.Miners[za0001].MarshalHash(); err != nil {
+ return nil, err
+ } else {
+ o = hsp.AppendBytes(o, oTemp)
+ }
+ }
+ }
+ o = append(o, 0x88)
+ o = hsp.AppendArrayHeader(o, uint32(len(z.Users)))
+ for za0002 := range z.Users {
+ if z.Users[za0002] == nil {
+ o = hsp.AppendNil(o)
+ } else {
+ if oTemp, err := z.Users[za0002].MarshalHash(); err != nil {
+ return nil, err
+ } else {
+ o = hsp.AppendBytes(o, oTemp)
+ }
+ }
+ }
+ o = append(o, 0x88)
+ if oTemp, err := z.Owner.MarshalHash(); err != nil {
+ return nil, err
+ } else {
+ o = hsp.AppendBytes(o, oTemp)
+ }
+ o = append(o, 0x88)
+ if oTemp, err := z.Address.MarshalHash(); err != nil {
+ return nil, err
+ } else {
+ o = hsp.AppendBytes(o, oTemp)
+ }
+ o = append(o, 0x88)
+ if oTemp, err := z.ID.MarshalHash(); err != nil {
+ return nil, err
+ } else {
+ o = hsp.AppendBytes(o, oTemp)
+ }
+ o = append(o, 0x88)
+ o = hsp.AppendUint64(o, z.Period)
+ o = append(o, 0x88)
+ o = hsp.AppendUint64(o, z.GasPrice)
+ return
+}
+
+// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
+func (z *SQLChainProfile) Msgsize() (s int) {
+ s = 1 + 10 + z.TokenType.Msgsize() + 7 + hsp.ArrayHeaderSize
+ for za0001 := range z.Miners {
+ if z.Miners[za0001] == nil {
+ s += hsp.NilSize
+ } else {
+ s += z.Miners[za0001].Msgsize()
+ }
+ }
+ s += 6 + hsp.ArrayHeaderSize
+ for za0002 := range z.Users {
+ if z.Users[za0002] == nil {
+ s += hsp.NilSize
+ } else {
+ s += z.Users[za0002].Msgsize()
+ }
+ }
+ s += 6 + z.Owner.Msgsize() + 8 + z.Address.Msgsize() + 3 + z.ID.Msgsize() + 7 + hsp.Uint64Size + 9 + hsp.Uint64Size
+ return
+}
+
+// MarshalHash marshals for hash
+func (z SQLChainRole) MarshalHash() (o []byte, err error) {
+ var b []byte
+ o = hsp.Require(b, z.Msgsize())
+ o = hsp.AppendByte(o, byte(z))
+ return
+}
+
+// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
+func (z SQLChainRole) Msgsize() (s int) {
+ s = hsp.ByteSize
+ return
+}
+
+// MarshalHash marshals for hash
+func (z *SQLChainUser) MarshalHash() (o []byte, err error) {
+ var b []byte
+ o = hsp.Require(b, z.Msgsize())
+ // map header, size 6
+ o = append(o, 0x86, 0x86)
+ o = hsp.AppendInt32(o, int32(z.Status))
+ o = append(o, 0x86)
+ o = hsp.AppendInt32(o, int32(z.Permission))
+ o = append(o, 0x86)
+ if oTemp, err := z.Address.MarshalHash(); err != nil {
+ return nil, err
+ } else {
+ o = hsp.AppendBytes(o, oTemp)
+ }
+ o = append(o, 0x86)
+ o = hsp.AppendUint64(o, z.AdvancePayment)
+ o = append(o, 0x86)
+ o = hsp.AppendUint64(o, z.Arrears)
+ o = append(o, 0x86)
+ o = hsp.AppendUint64(o, z.Pledge)
+ return
+}
+
+// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
+func (z *SQLChainUser) Msgsize() (s int) {
+ s = 1 + 7 + hsp.Int32Size + 11 + hsp.Int32Size + 8 + z.Address.Msgsize() + 15 + hsp.Uint64Size + 8 + hsp.Uint64Size + 7 + hsp.Uint64Size
+ return
+}
+
+// MarshalHash marshals for hash
+func (z Status) MarshalHash() (o []byte, err error) {
+ var b []byte
+ o = hsp.Require(b, z.Msgsize())
+ o = hsp.AppendInt32(o, int32(z))
+ return
+}
+
+// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
+func (z Status) Msgsize() (s int) {
+ s = hsp.Int32Size
+ return
+}
+
+// MarshalHash marshals for hash
+func (z UserPermission) MarshalHash() (o []byte, err error) {
+ var b []byte
+ o = hsp.Require(b, z.Msgsize())
+ o = hsp.AppendInt32(o, int32(z))
+ return
+}
+
+// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
+func (z UserPermission) Msgsize() (s int) {
+ s = hsp.Int32Size
+ return
+}
diff --git a/blockproducer/types/account_gen_test.go b/types/account_gen_test.go
similarity index 76%
rename from blockproducer/types/account_gen_test.go
rename to types/account_gen_test.go
index 08edfd164..97169a4ae 100644
--- a/blockproducer/types/account_gen_test.go
+++ b/types/account_gen_test.go
@@ -46,6 +46,43 @@ func BenchmarkAppendMsgAccount(b *testing.B) {
}
}
+func TestMarshalHashMinerInfo(t *testing.T) {
+ v := MinerInfo{}
+ binary.Read(rand.Reader, binary.BigEndian, &v)
+ bts1, err := v.MarshalHash()
+ if err != nil {
+ t.Fatal(err)
+ }
+ bts2, err := v.MarshalHash()
+ if err != nil {
+ t.Fatal(err)
+ }
+ if !bytes.Equal(bts1, bts2) {
+ t.Fatal("hash not stable")
+ }
+}
+
+func BenchmarkMarshalHashMinerInfo(b *testing.B) {
+ v := MinerInfo{}
+ b.ReportAllocs()
+ b.ResetTimer()
+ for i := 0; i < b.N; i++ {
+ v.MarshalHash()
+ }
+}
+
+func BenchmarkAppendMsgMinerInfo(b *testing.B) {
+ v := MinerInfo{}
+ bts := make([]byte, 0, v.Msgsize())
+ bts, _ = v.MarshalHash()
+ b.SetBytes(int64(len(bts)))
+ b.ReportAllocs()
+ b.ResetTimer()
+ for i := 0; i < b.N; i++ {
+ bts, _ = v.MarshalHash()
+ }
+}
+
func TestMarshalHashSQLChainProfile(t *testing.T) {
v := SQLChainProfile{}
binary.Read(rand.Reader, binary.BigEndian, &v)
diff --git a/blockproducer/types/baseaccount.go b/types/baseaccount.go
similarity index 100%
rename from blockproducer/types/baseaccount.go
rename to types/baseaccount.go
diff --git a/blockproducer/types/baseaccount_gen.go b/types/baseaccount_gen.go
similarity index 100%
rename from blockproducer/types/baseaccount_gen.go
rename to types/baseaccount_gen.go
diff --git a/blockproducer/types/baseaccount_gen_test.go b/types/baseaccount_gen_test.go
similarity index 100%
rename from blockproducer/types/baseaccount_gen_test.go
rename to types/baseaccount_gen_test.go
diff --git a/blockproducer/types/baseaccount_test.go b/types/baseaccount_test.go
similarity index 100%
rename from blockproducer/types/baseaccount_test.go
rename to types/baseaccount_test.go
diff --git a/blockproducer/types/billing.go b/types/billing.go
similarity index 100%
rename from blockproducer/types/billing.go
rename to types/billing.go
diff --git a/blockproducer/types/billing_gen.go b/types/billing_gen.go
similarity index 100%
rename from blockproducer/types/billing_gen.go
rename to types/billing_gen.go
diff --git a/blockproducer/types/billing_gen_test.go b/types/billing_gen_test.go
similarity index 100%
rename from blockproducer/types/billing_gen_test.go
rename to types/billing_gen_test.go
diff --git a/types/billing_req.go b/types/billing_req.go
index 00ee3cde2..d3a50a210 100644
--- a/types/billing_req.go
+++ b/types/billing_req.go
@@ -17,18 +17,17 @@
package types
import (
- pt "github.com/CovenantSQL/CovenantSQL/blockproducer/types"
"github.com/CovenantSQL/CovenantSQL/proto"
)
// AdviseBillingReq defines a request of the AdviseBillingRequest RPC method.
type AdviseBillingReq struct {
proto.Envelope
- Req *pt.BillingRequest
+ Req *BillingRequest
}
// AdviseBillingResp defines a request of the AdviseBillingRequest RPC method.
type AdviseBillingResp struct {
proto.Envelope
- Resp *pt.BillingRequest
+ Resp *BillingRequest
}
diff --git a/types/billing_request.go b/types/billing_request.go
new file mode 100644
index 000000000..14d96c1b9
--- /dev/null
+++ b/types/billing_request.go
@@ -0,0 +1,155 @@
+/*
+ * Copyright 2018 The CovenantSQL Authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package types
+
+import (
+ "reflect"
+
+ "github.com/CovenantSQL/CovenantSQL/crypto/asymmetric"
+ "github.com/CovenantSQL/CovenantSQL/crypto/hash"
+ "github.com/CovenantSQL/CovenantSQL/proto"
+)
+
+//go:generate hsp
+
+// BillingRequestHeader includes contents that need to be signed. Billing blocks should be within
+// height range [low, high] (inclusive).
+type BillingRequestHeader struct {
+ DatabaseID proto.DatabaseID
+ // sqlchain block hash and its height
+ LowBlock hash.Hash
+ LowHeight int32
+ HighBlock hash.Hash
+ HighHeight int32
+ GasAmounts []*proto.AddrAndGas
+}
+
+// BillingRequest defines periodically Billing sync.
+type BillingRequest struct {
+ Header BillingRequestHeader
+ RequestHash hash.Hash
+ Signees []*asymmetric.PublicKey
+ Signatures []*asymmetric.Signature
+}
+
+// PackRequestHeader computes the hash of header.
+func (br *BillingRequest) PackRequestHeader() (h *hash.Hash, err error) {
+ var enc []byte
+ if enc, err = br.Header.MarshalHash(); err != nil {
+ return
+ }
+
+ br.RequestHash = hash.THashH(enc)
+ h = &br.RequestHash
+ return
+}
+
+// SignRequestHeader first computes the hash of BillingRequestHeader, then signs the request.
+func (br *BillingRequest) SignRequestHeader(signer *asymmetric.PrivateKey, calcHash bool) (
+ signee *asymmetric.PublicKey, signature *asymmetric.Signature, err error) {
+ if calcHash {
+ if _, err = br.PackRequestHeader(); err != nil {
+ return
+ }
+ }
+
+ if signature, err = signer.Sign(br.RequestHash[:]); err == nil {
+ // append to current signatures
+ signee = signer.PubKey()
+ br.Signees = append(br.Signees, signee)
+ br.Signatures = append(br.Signatures, signature)
+ }
+
+ return
+}
+
+// AddSignature add existing signature to BillingRequest, requires the structure to be packed first.
+func (br *BillingRequest) AddSignature(
+ signee *asymmetric.PublicKey, signature *asymmetric.Signature, calcHash bool) (err error) {
+ if calcHash {
+ if _, err = br.PackRequestHeader(); err != nil {
+ return
+ }
+ }
+
+ if !signature.Verify(br.RequestHash[:], signee) {
+ err = ErrSignVerification
+ return
+ }
+
+ // append
+ br.Signees = append(br.Signees, signee)
+ br.Signatures = append(br.Signatures, signature)
+
+ return
+}
+
+// VerifySignatures verify existing signatures.
+func (br *BillingRequest) VerifySignatures() (err error) {
+ if len(br.Signees) != len(br.Signatures) {
+ return ErrSignVerification
+ }
+
+ var enc []byte
+ if enc, err = br.Header.MarshalHash(); err != nil {
+ return
+ }
+
+ h := hash.THashH(enc)
+ if !br.RequestHash.IsEqual(&h) {
+ return ErrSignVerification
+ }
+
+ if len(br.Signees) == 0 {
+ return
+ }
+
+ for idx, signee := range br.Signees {
+ if !br.Signatures[idx].Verify(br.RequestHash[:], signee) {
+ return ErrSignVerification
+ }
+ }
+
+ return
+}
+
+// Compare returns if two billing records are identical.
+func (br *BillingRequest) Compare(r *BillingRequest) (err error) {
+ if !br.Header.LowBlock.IsEqual(&r.Header.LowBlock) ||
+ !br.Header.HighBlock.IsEqual(&br.Header.HighBlock) {
+ err = ErrBillingNotMatch
+ return
+ }
+
+ reqMap := make(map[proto.AccountAddress]*proto.AddrAndGas)
+ locMap := make(map[proto.AccountAddress]*proto.AddrAndGas)
+
+ for _, v := range br.Header.GasAmounts {
+ reqMap[v.AccountAddress] = v
+ }
+
+ for _, v := range r.Header.GasAmounts {
+ locMap[v.AccountAddress] = v
+ }
+
+ if !reflect.DeepEqual(reqMap, locMap) {
+ err = ErrBillingNotMatch
+ return
+ }
+
+ return
+}
diff --git a/types/billing_request_gen.go b/types/billing_request_gen.go
new file mode 100644
index 000000000..48da8b034
--- /dev/null
+++ b/types/billing_request_gen.go
@@ -0,0 +1,132 @@
+package types
+
+// Code generated by github.com/CovenantSQL/HashStablePack DO NOT EDIT.
+
+import (
+ hsp "github.com/CovenantSQL/HashStablePack/marshalhash"
+)
+
+// MarshalHash marshals for hash
+func (z *BillingRequest) MarshalHash() (o []byte, err error) {
+ var b []byte
+ o = hsp.Require(b, z.Msgsize())
+ // map header, size 4
+ o = append(o, 0x84, 0x84)
+ if oTemp, err := z.Header.MarshalHash(); err != nil {
+ return nil, err
+ } else {
+ o = hsp.AppendBytes(o, oTemp)
+ }
+ o = append(o, 0x84)
+ o = hsp.AppendArrayHeader(o, uint32(len(z.Signees)))
+ for za0001 := range z.Signees {
+ if z.Signees[za0001] == nil {
+ o = hsp.AppendNil(o)
+ } else {
+ if oTemp, err := z.Signees[za0001].MarshalHash(); err != nil {
+ return nil, err
+ } else {
+ o = hsp.AppendBytes(o, oTemp)
+ }
+ }
+ }
+ o = append(o, 0x84)
+ o = hsp.AppendArrayHeader(o, uint32(len(z.Signatures)))
+ for za0002 := range z.Signatures {
+ if z.Signatures[za0002] == nil {
+ o = hsp.AppendNil(o)
+ } else {
+ if oTemp, err := z.Signatures[za0002].MarshalHash(); err != nil {
+ return nil, err
+ } else {
+ o = hsp.AppendBytes(o, oTemp)
+ }
+ }
+ }
+ o = append(o, 0x84)
+ if oTemp, err := z.RequestHash.MarshalHash(); err != nil {
+ return nil, err
+ } else {
+ o = hsp.AppendBytes(o, oTemp)
+ }
+ return
+}
+
+// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
+func (z *BillingRequest) Msgsize() (s int) {
+ s = 1 + 7 + z.Header.Msgsize() + 8 + hsp.ArrayHeaderSize
+ for za0001 := range z.Signees {
+ if z.Signees[za0001] == nil {
+ s += hsp.NilSize
+ } else {
+ s += z.Signees[za0001].Msgsize()
+ }
+ }
+ s += 11 + hsp.ArrayHeaderSize
+ for za0002 := range z.Signatures {
+ if z.Signatures[za0002] == nil {
+ s += hsp.NilSize
+ } else {
+ s += z.Signatures[za0002].Msgsize()
+ }
+ }
+ s += 12 + z.RequestHash.Msgsize()
+ return
+}
+
+// MarshalHash marshals for hash
+func (z *BillingRequestHeader) MarshalHash() (o []byte, err error) {
+ var b []byte
+ o = hsp.Require(b, z.Msgsize())
+ // map header, size 6
+ o = append(o, 0x86, 0x86)
+ o = hsp.AppendArrayHeader(o, uint32(len(z.GasAmounts)))
+ for za0001 := range z.GasAmounts {
+ if z.GasAmounts[za0001] == nil {
+ o = hsp.AppendNil(o)
+ } else {
+ if oTemp, err := z.GasAmounts[za0001].MarshalHash(); err != nil {
+ return nil, err
+ } else {
+ o = hsp.AppendBytes(o, oTemp)
+ }
+ }
+ }
+ o = append(o, 0x86)
+ if oTemp, err := z.LowBlock.MarshalHash(); err != nil {
+ return nil, err
+ } else {
+ o = hsp.AppendBytes(o, oTemp)
+ }
+ o = append(o, 0x86)
+ if oTemp, err := z.HighBlock.MarshalHash(); err != nil {
+ return nil, err
+ } else {
+ o = hsp.AppendBytes(o, oTemp)
+ }
+ o = append(o, 0x86)
+ o = hsp.AppendInt32(o, z.LowHeight)
+ o = append(o, 0x86)
+ o = hsp.AppendInt32(o, z.HighHeight)
+ o = append(o, 0x86)
+ if oTemp, err := z.DatabaseID.MarshalHash(); err != nil {
+ return nil, err
+ } else {
+ o = hsp.AppendBytes(o, oTemp)
+ }
+ return
+}
+
+// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
+func (z *BillingRequestHeader) Msgsize() (s int) {
+ s = 1 + 11 + hsp.ArrayHeaderSize
+ for za0001 := range z.GasAmounts {
+ if z.GasAmounts[za0001] == nil {
+ s += hsp.NilSize
+ } else {
+ s += z.GasAmounts[za0001].Msgsize()
+ }
+ }
+ s += 9 + z.LowBlock.Msgsize() + 10 + z.HighBlock.Msgsize() + 10 + hsp.Int32Size + 11 + hsp.Int32Size + 11 + z.DatabaseID.Msgsize()
+ return
+}
diff --git a/types/billing_request_gen_test.go b/types/billing_request_gen_test.go
new file mode 100644
index 000000000..d46613c46
--- /dev/null
+++ b/types/billing_request_gen_test.go
@@ -0,0 +1,84 @@
+package types
+
+// Code generated by github.com/CovenantSQL/HashStablePack DO NOT EDIT.
+
+import (
+ "bytes"
+ "crypto/rand"
+ "encoding/binary"
+ "testing"
+)
+
+func TestMarshalHashBillingRequest(t *testing.T) {
+ v := BillingRequest{}
+ binary.Read(rand.Reader, binary.BigEndian, &v)
+ bts1, err := v.MarshalHash()
+ if err != nil {
+ t.Fatal(err)
+ }
+ bts2, err := v.MarshalHash()
+ if err != nil {
+ t.Fatal(err)
+ }
+ if !bytes.Equal(bts1, bts2) {
+ t.Fatal("hash not stable")
+ }
+}
+
+func BenchmarkMarshalHashBillingRequest(b *testing.B) {
+ v := BillingRequest{}
+ b.ReportAllocs()
+ b.ResetTimer()
+ for i := 0; i < b.N; i++ {
+ v.MarshalHash()
+ }
+}
+
+func BenchmarkAppendMsgBillingRequest(b *testing.B) {
+ v := BillingRequest{}
+ bts := make([]byte, 0, v.Msgsize())
+ bts, _ = v.MarshalHash()
+ b.SetBytes(int64(len(bts)))
+ b.ReportAllocs()
+ b.ResetTimer()
+ for i := 0; i < b.N; i++ {
+ bts, _ = v.MarshalHash()
+ }
+}
+
+func TestMarshalHashBillingRequestHeader(t *testing.T) {
+ v := BillingRequestHeader{}
+ binary.Read(rand.Reader, binary.BigEndian, &v)
+ bts1, err := v.MarshalHash()
+ if err != nil {
+ t.Fatal(err)
+ }
+ bts2, err := v.MarshalHash()
+ if err != nil {
+ t.Fatal(err)
+ }
+ if !bytes.Equal(bts1, bts2) {
+ t.Fatal("hash not stable")
+ }
+}
+
+func BenchmarkMarshalHashBillingRequestHeader(b *testing.B) {
+ v := BillingRequestHeader{}
+ b.ReportAllocs()
+ b.ResetTimer()
+ for i := 0; i < b.N; i++ {
+ v.MarshalHash()
+ }
+}
+
+func BenchmarkAppendMsgBillingRequestHeader(b *testing.B) {
+ v := BillingRequestHeader{}
+ bts := make([]byte, 0, v.Msgsize())
+ bts, _ = v.MarshalHash()
+ b.SetBytes(int64(len(bts)))
+ b.ReportAllocs()
+ b.ResetTimer()
+ for i := 0; i < b.N; i++ {
+ bts, _ = v.MarshalHash()
+ }
+}
diff --git a/types/billing_request_test.go b/types/billing_request_test.go
new file mode 100644
index 000000000..c6d7ee998
--- /dev/null
+++ b/types/billing_request_test.go
@@ -0,0 +1,339 @@
+/*
+ * Copyright 2018 The CovenantSQL Authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package types
+
+import (
+ "reflect"
+ "testing"
+
+ "github.com/CovenantSQL/CovenantSQL/crypto/asymmetric"
+ "github.com/CovenantSQL/CovenantSQL/crypto/hash"
+ "github.com/CovenantSQL/CovenantSQL/proto"
+ "github.com/CovenantSQL/CovenantSQL/utils"
+ "github.com/CovenantSQL/CovenantSQL/utils/log"
+)
+
+var (
+ peerNum = 32
+)
+
+func TestBillingRequestHeader_MarshalUnmarshalBinary(t *testing.T) {
+ reqHeader := generateRandomBillingRequestHeader()
+ b, err := utils.EncodeMsgPack(reqHeader)
+ if err != nil {
+ t.Fatalf("unexpect error when marshal request header: %v", err)
+ }
+
+ newReqHeader := &BillingRequestHeader{}
+ err = utils.DecodeMsgPack(b.Bytes(), newReqHeader)
+ if err != nil {
+ t.Fatalf("unexpect error when unmashll request header: %v", err)
+ }
+
+ if !reflect.DeepEqual(reqHeader, newReqHeader) {
+ t.Fatalf("values not match:\n\tv0=%+v\n\tv1=%+v", reqHeader, newReqHeader)
+ }
+}
+
+func TestBillingRequest_MarshalUnmarshalBinary(t *testing.T) {
+ req, err := generateRandomBillingRequest()
+ if err != nil {
+ t.Fatalf("unexpected error: %v", err)
+ }
+
+ enc, err := utils.EncodeMsgPack(req)
+ if err != nil {
+ t.Fatalf("unexpected error: %v", err)
+ }
+
+ dec := &BillingRequest{}
+ err = utils.DecodeMsgPack(enc.Bytes(), dec)
+ if err != nil {
+ t.Fatalf("unexpected error: %v", err)
+ }
+
+ if !reflect.DeepEqual(req, dec) {
+ log.Debug(req)
+ log.Debug(dec)
+ t.Fatal("values not match")
+ }
+}
+
+func TestBillingRequest_PackRequestHeader(t *testing.T) {
+ req, err := generateRandomBillingRequest()
+ if err != nil {
+ t.Fatalf("unexpected error: %v", err)
+ }
+
+ enc, err := req.Header.MarshalHash()
+ if err != nil {
+ t.Fatalf("unexpected error: %v", err)
+ }
+
+ h := hash.THashH(enc)
+ if !h.IsEqual(&req.RequestHash) {
+ t.Fatalf("hash not matched: \n\tv1=%v\n\tv2=%v", req.RequestHash, h)
+ }
+}
+
+func TestBillingRequest_SignRequestHeader(t *testing.T) {
+ req, err := generateRandomBillingRequest()
+ if err != nil {
+ t.Fatalf("unexpected error: %v", err)
+ }
+
+ enc, err := req.Header.MarshalHash()
+ if err != nil {
+ t.Fatalf("unexpected error: %v", err)
+ }
+
+ h := hash.THashH(enc)
+ if !h.IsEqual(&req.RequestHash) {
+ t.Fatalf("hash not matched: \n\tv1=%v\n\tv2=%v", req.RequestHash, h)
+ }
+
+ for i, sign := range req.Signatures {
+ if !sign.Verify(req.RequestHash[:], req.Signees[i]) {
+
+ t.Fatalf("signature cannot match the hash and public key: %v", req)
+ }
+ }
+
+ priv, pub, err := asymmetric.GenSecp256k1KeyPair()
+ _, sign, err := req.SignRequestHeader(priv, false)
+ if err != nil || !sign.Verify(req.RequestHash[:], pub) {
+ t.Fatalf("signature cannot match the hash and public key: %v", req)
+ }
+}
+
+func TestBillingRequest_SignRequestHeader2(t *testing.T) {
+ header := generateRandomBillingRequestHeader()
+ req := &BillingRequest{
+ Header: *header,
+ }
+
+ priv, _, err := asymmetric.GenSecp256k1KeyPair()
+ signee, sign, err := req.SignRequestHeader(priv, true)
+ if err != nil || !sign.Verify(req.RequestHash[:], signee) {
+ t.Fatalf("signature cannot match the hash and public key: %v", req)
+ }
+}
+
+func TestBillingRequest_AddSignature(t *testing.T) {
+ header := generateRandomBillingRequestHeader()
+ req := &BillingRequest{
+ Header: *header,
+ }
+
+ priv, _, err := asymmetric.GenSecp256k1KeyPair()
+ signee, sign, err := req.SignRequestHeader(priv, true)
+ if err != nil || !sign.Verify(req.RequestHash[:], signee) {
+ t.Fatalf("signature cannot match the hash and public key, req: %v, err: %v", req, err)
+ }
+
+ // clear previous signees and signatures
+ req.Signees = req.Signees[:0]
+ req.Signatures = req.Signatures[:0]
+
+ if err := req.AddSignature(signee, sign, false); err != nil {
+ t.Fatalf("add signature failed, req: %v, err: %v", req, err)
+ }
+}
+
+func TestBillingRequest_AddSignature2(t *testing.T) {
+ header := generateRandomBillingRequestHeader()
+ req := &BillingRequest{
+ Header: *header,
+ }
+
+ priv, _, err := asymmetric.GenSecp256k1KeyPair()
+ signee, sign, err := req.SignRequestHeader(priv, true)
+ if err != nil || !sign.Verify(req.RequestHash[:], signee) {
+ t.Fatalf("signature cannot match the hash and public key, req: %v, err: %v", req, err)
+ }
+
+ // clear previous signees and signatures
+ req.RequestHash = hash.Hash{}
+ req.Signees = req.Signees[:0]
+ req.Signatures = req.Signatures[:0]
+
+ if err := req.AddSignature(signee, sign, true); err != nil {
+ t.Fatalf("add signature failed, req: %v, err: %v", req, err)
+ }
+}
+
+func TestBillingRequest_AddSignature3(t *testing.T) {
+ header := generateRandomBillingRequestHeader()
+ req := &BillingRequest{
+ Header: *header,
+ }
+
+ priv, _, err := asymmetric.GenSecp256k1KeyPair()
+ signee, sign, err := req.SignRequestHeader(priv, true)
+ if err != nil || !sign.Verify(req.RequestHash[:], signee) {
+ t.Fatalf("signature cannot match the hash and public key, req: %v, err: %v", req, err)
+ }
+
+ // clear previous signees and signatures
+ req.RequestHash = hash.Hash{}
+ req.Signees = req.Signees[:0]
+ req.Signatures = req.Signatures[:0]
+
+ _, signee, _ = asymmetric.GenSecp256k1KeyPair()
+ if err := req.AddSignature(signee, sign, true); err != ErrSignVerification {
+ t.Fatalf("add signature should failed, req: %v, err: %v", req, err)
+ }
+}
+
+func TestBillingRequest_VerifySignatures(t *testing.T) {
+ header := generateRandomBillingRequestHeader()
+ req := &BillingRequest{
+ Header: *header,
+ }
+
+ addSignature := func(calcHash bool) {
+ priv, _, err := asymmetric.GenSecp256k1KeyPair()
+ _, _, err = req.SignRequestHeader(priv, calcHash)
+ if err != nil {
+ t.Fatalf("sign request failed, req: %v, err: %v", req, err)
+ }
+ }
+
+ // add 3 signatures
+ addSignature(true)
+ addSignature(false)
+ addSignature(false)
+
+ if err := req.VerifySignatures(); err != nil {
+ t.Fatalf("verify signature failed, req: %v, err: %v", req, err)
+ }
+}
+
+func TestBillingRequest_VerifySignatures2(t *testing.T) {
+ header := generateRandomBillingRequestHeader()
+ req := &BillingRequest{
+ Header: *header,
+ }
+
+ addSignature := func(calcHash bool) {
+ priv, _, err := asymmetric.GenSecp256k1KeyPair()
+ _, _, err = req.SignRequestHeader(priv, calcHash)
+ if err != nil {
+ t.Fatalf("sign request failed, req: %v, err: %v", req, err)
+ }
+ }
+
+ // add 3 signatures
+ addSignature(true)
+ addSignature(false)
+ addSignature(false)
+
+ // length invalidation
+ req.Signees = req.Signees[:0]
+
+ if err := req.VerifySignatures(); err != ErrSignVerification {
+ t.Fatalf("verify should be failed, req: %v, err: %v", req, err)
+ }
+}
+
+func TestBillingRequest_VerifySignatures3(t *testing.T) {
+ header := generateRandomBillingRequestHeader()
+ req := &BillingRequest{
+ Header: *header,
+ }
+
+ addSignature := func(calcHash bool) {
+ priv, _, err := asymmetric.GenSecp256k1KeyPair()
+ _, _, err = req.SignRequestHeader(priv, calcHash)
+ if err != nil {
+ t.Fatalf("sign request failed, req: %v, err: %v", req, err)
+ }
+ }
+
+ // add 3 signatures
+ addSignature(true)
+ addSignature(false)
+ addSignature(false)
+
+ // length invalidation
+ req.RequestHash = hash.Hash{}
+
+ if err := req.VerifySignatures(); err != ErrSignVerification {
+ t.Fatalf("verify should be failed, req: %v, err: %v", req, err)
+ }
+}
+
+func TestBillingRequest_VerifySignatures4(t *testing.T) {
+ header := generateRandomBillingRequestHeader()
+ req := &BillingRequest{
+ Header: *header,
+ }
+
+ addSignature := func(calcHash bool) {
+ priv, _, err := asymmetric.GenSecp256k1KeyPair()
+ _, _, err = req.SignRequestHeader(priv, calcHash)
+ if err != nil {
+ t.Fatalf("sign request failed, req: %v, err: %v", req, err)
+ }
+ }
+
+ // add 3 signatures
+ addSignature(true)
+ addSignature(false)
+ addSignature(false)
+
+ // length invalidation
+ _, req.Signees[0], _ = asymmetric.GenSecp256k1KeyPair()
+
+ if err := req.VerifySignatures(); err == nil || err != ErrSignVerification {
+ t.Fatalf("verify should be failed, req: %v, err: %v", req, err)
+ }
+}
+
+func TestBillingRequest_Compare(t *testing.T) {
+ req, _ := generateRandomBillingRequest()
+
+ if err := req.Compare(req); err != nil {
+ t.Fatalf("compare failed, req: %v, err: %v", req, err)
+ }
+
+ var req2 BillingRequest
+ req2 = *req
+
+ req2.Header.LowBlock = hash.Hash{}
+
+ if err := req.Compare(&req2); err != ErrBillingNotMatch {
+ t.Fatalf("compare should be failed, req: %v, req2: %v, err: %v", req, req2, err)
+ }
+}
+
+func TestBillingRequest_Compare2(t *testing.T) {
+ req, _ := generateRandomBillingRequest()
+ var req2 BillingRequest
+ req2 = *req
+
+ var gasAmount proto.AddrAndGas
+ gasAmount = *req.Header.GasAmounts[0]
+ gasAmount.GasAmount += 10
+ req2.Header.GasAmounts = nil
+ req2.Header.GasAmounts = append(req2.Header.GasAmounts, &gasAmount)
+ req2.Header.GasAmounts = append(req2.Header.GasAmounts, req.Header.GasAmounts[1:]...)
+
+ if err := req.Compare(&req2); err != ErrBillingNotMatch {
+ t.Fatalf("compare should be failed, req: %v, req2: %v, err: %v", req, req2, err)
+ }
+}
diff --git a/blockproducer/types/billing_test.go b/types/billing_test.go
similarity index 100%
rename from blockproducer/types/billing_test.go
rename to types/billing_test.go
diff --git a/blockproducer/types/block.go b/types/bp_block.go
similarity index 78%
rename from blockproducer/types/block.go
rename to types/bp_block.go
index 42bb57714..72c721e10 100644
--- a/blockproducer/types/block.go
+++ b/types/bp_block.go
@@ -28,8 +28,8 @@ import (
//go:generate hsp
-// Header defines the main chain block header.
-type Header struct {
+// BPHeader defines the main chain block header.
+type BPHeader struct {
Version int32
Producer proto.AccountAddress
MerkleRoot hash.Hash
@@ -37,16 +37,16 @@ type Header struct {
Timestamp time.Time
}
-// SignedHeader defines the main chain header with the signature.
-type SignedHeader struct {
- Header
+// BPSignedHeader defines the main chain header with the signature.
+type BPSignedHeader struct {
+ BPHeader
BlockHash hash.Hash
Signee *asymmetric.PublicKey
Signature *asymmetric.Signature
}
// Verify verifies the signature.
-func (s *SignedHeader) Verify() error {
+func (s *BPSignedHeader) Verify() error {
if !s.Signature.Verify(s.BlockHash[:], s.Signee) {
return ErrSignVerification
}
@@ -54,14 +54,14 @@ func (s *SignedHeader) Verify() error {
return nil
}
-// Block defines the main chain block.
-type Block struct {
- SignedHeader SignedHeader
+// BPBlock defines the main chain block.
+type BPBlock struct {
+ SignedHeader BPSignedHeader
Transactions []pi.Transaction
}
// GetTxHashes returns all hashes of tx in block.{Billings, ...}
-func (b *Block) GetTxHashes() []*hash.Hash {
+func (b *BPBlock) GetTxHashes() []*hash.Hash {
// TODO(lambda): when you add new tx type, you need to put new tx's hash in the slice
// get hashes in block.Transactions
hs := make([]*hash.Hash, len(b.Transactions))
@@ -74,11 +74,11 @@ func (b *Block) GetTxHashes() []*hash.Hash {
}
// PackAndSignBlock computes block's hash and sign it.
-func (b *Block) PackAndSignBlock(signer *asymmetric.PrivateKey) error {
+func (b *BPBlock) PackAndSignBlock(signer *asymmetric.PrivateKey) error {
hs := b.GetTxHashes()
b.SignedHeader.MerkleRoot = *merkle.NewMerkle(hs).GetRoot()
- enc, err := b.SignedHeader.Header.MarshalHash()
+ enc, err := b.SignedHeader.BPHeader.MarshalHash()
if err != nil {
return err
@@ -96,14 +96,14 @@ func (b *Block) PackAndSignBlock(signer *asymmetric.PrivateKey) error {
}
// Verify verifies whether the block is valid.
-func (b *Block) Verify() error {
+func (b *BPBlock) Verify() error {
hs := b.GetTxHashes()
merkleRoot := *merkle.NewMerkle(hs).GetRoot()
if !merkleRoot.IsEqual(&b.SignedHeader.MerkleRoot) {
return ErrMerkleRootVerification
}
- enc, err := b.SignedHeader.Header.MarshalHash()
+ enc, err := b.SignedHeader.BPHeader.MarshalHash()
if err != nil {
return err
}
@@ -117,21 +117,21 @@ func (b *Block) Verify() error {
}
// Timestamp returns timestamp of block.
-func (b *Block) Timestamp() time.Time {
+func (b *BPBlock) Timestamp() time.Time {
return b.SignedHeader.Timestamp
}
// Producer returns the producer of block.
-func (b *Block) Producer() proto.AccountAddress {
+func (b *BPBlock) Producer() proto.AccountAddress {
return b.SignedHeader.Producer
}
// ParentHash returns the parent hash field of the block header.
-func (b *Block) ParentHash() *hash.Hash {
+func (b *BPBlock) ParentHash() *hash.Hash {
return &b.SignedHeader.ParentHash
}
// BlockHash returns the parent hash field of the block header.
-func (b *Block) BlockHash() *hash.Hash {
+func (b *BPBlock) BlockHash() *hash.Hash {
return &b.SignedHeader.BlockHash
}
diff --git a/blockproducer/types/block_gen.go b/types/bp_block_gen.go
similarity index 87%
rename from blockproducer/types/block_gen.go
rename to types/bp_block_gen.go
index 1a0814c1c..5afbe938a 100644
--- a/blockproducer/types/block_gen.go
+++ b/types/bp_block_gen.go
@@ -7,7 +7,7 @@ import (
)
// MarshalHash marshals for hash
-func (z *Block) MarshalHash() (o []byte, err error) {
+func (z *BPBlock) MarshalHash() (o []byte, err error) {
var b []byte
o = hsp.Require(b, z.Msgsize())
// map header, size 2
@@ -30,7 +30,7 @@ func (z *Block) MarshalHash() (o []byte, err error) {
}
// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
-func (z *Block) Msgsize() (s int) {
+func (z *BPBlock) Msgsize() (s int) {
s = 1 + 13 + z.SignedHeader.Msgsize() + 13 + hsp.ArrayHeaderSize
for za0001 := range z.Transactions {
s += z.Transactions[za0001].Msgsize()
@@ -39,7 +39,7 @@ func (z *Block) Msgsize() (s int) {
}
// MarshalHash marshals for hash
-func (z *Header) MarshalHash() (o []byte, err error) {
+func (z *BPHeader) MarshalHash() (o []byte, err error) {
var b []byte
o = hsp.Require(b, z.Msgsize())
// map header, size 5
@@ -69,13 +69,13 @@ func (z *Header) MarshalHash() (o []byte, err error) {
}
// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
-func (z *Header) Msgsize() (s int) {
+func (z *BPHeader) Msgsize() (s int) {
s = 1 + 11 + z.MerkleRoot.Msgsize() + 11 + z.ParentHash.Msgsize() + 8 + hsp.Int32Size + 9 + z.Producer.Msgsize() + 10 + hsp.TimeSize
return
}
// MarshalHash marshals for hash
-func (z *SignedHeader) MarshalHash() (o []byte, err error) {
+func (z *BPSignedHeader) MarshalHash() (o []byte, err error) {
var b []byte
o = hsp.Require(b, z.Msgsize())
// map header, size 4
@@ -100,7 +100,7 @@ func (z *SignedHeader) MarshalHash() (o []byte, err error) {
}
}
o = append(o, 0x84)
- if oTemp, err := z.Header.MarshalHash(); err != nil {
+ if oTemp, err := z.BPHeader.MarshalHash(); err != nil {
return nil, err
} else {
o = hsp.AppendBytes(o, oTemp)
@@ -115,7 +115,7 @@ func (z *SignedHeader) MarshalHash() (o []byte, err error) {
}
// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
-func (z *SignedHeader) Msgsize() (s int) {
+func (z *BPSignedHeader) Msgsize() (s int) {
s = 1 + 7
if z.Signee == nil {
s += hsp.NilSize
@@ -128,6 +128,6 @@ func (z *SignedHeader) Msgsize() (s int) {
} else {
s += z.Signature.Msgsize()
}
- s += 7 + z.Header.Msgsize() + 10 + z.BlockHash.Msgsize()
+ s += 9 + z.BPHeader.Msgsize() + 10 + z.BlockHash.Msgsize()
return
}
diff --git a/blockproducer/types/block_gen_test.go b/types/bp_block_gen_test.go
similarity index 73%
rename from blockproducer/types/block_gen_test.go
rename to types/bp_block_gen_test.go
index 0bedf72a2..b84d99ec6 100644
--- a/blockproducer/types/block_gen_test.go
+++ b/types/bp_block_gen_test.go
@@ -9,8 +9,8 @@ import (
"testing"
)
-func TestMarshalHashBlock(t *testing.T) {
- v := Block{}
+func TestMarshalHashBPBlock(t *testing.T) {
+ v := BPBlock{}
binary.Read(rand.Reader, binary.BigEndian, &v)
bts1, err := v.MarshalHash()
if err != nil {
@@ -25,8 +25,8 @@ func TestMarshalHashBlock(t *testing.T) {
}
}
-func BenchmarkMarshalHashBlock(b *testing.B) {
- v := Block{}
+func BenchmarkMarshalHashBPBlock(b *testing.B) {
+ v := BPBlock{}
b.ReportAllocs()
b.ResetTimer()
for i := 0; i < b.N; i++ {
@@ -34,8 +34,8 @@ func BenchmarkMarshalHashBlock(b *testing.B) {
}
}
-func BenchmarkAppendMsgBlock(b *testing.B) {
- v := Block{}
+func BenchmarkAppendMsgBPBlock(b *testing.B) {
+ v := BPBlock{}
bts := make([]byte, 0, v.Msgsize())
bts, _ = v.MarshalHash()
b.SetBytes(int64(len(bts)))
@@ -46,8 +46,8 @@ func BenchmarkAppendMsgBlock(b *testing.B) {
}
}
-func TestMarshalHashHeader(t *testing.T) {
- v := Header{}
+func TestMarshalHashBPHeader(t *testing.T) {
+ v := BPHeader{}
binary.Read(rand.Reader, binary.BigEndian, &v)
bts1, err := v.MarshalHash()
if err != nil {
@@ -62,8 +62,8 @@ func TestMarshalHashHeader(t *testing.T) {
}
}
-func BenchmarkMarshalHashHeader(b *testing.B) {
- v := Header{}
+func BenchmarkMarshalHashBPHeader(b *testing.B) {
+ v := BPHeader{}
b.ReportAllocs()
b.ResetTimer()
for i := 0; i < b.N; i++ {
@@ -71,8 +71,8 @@ func BenchmarkMarshalHashHeader(b *testing.B) {
}
}
-func BenchmarkAppendMsgHeader(b *testing.B) {
- v := Header{}
+func BenchmarkAppendMsgBPHeader(b *testing.B) {
+ v := BPHeader{}
bts := make([]byte, 0, v.Msgsize())
bts, _ = v.MarshalHash()
b.SetBytes(int64(len(bts)))
@@ -83,8 +83,8 @@ func BenchmarkAppendMsgHeader(b *testing.B) {
}
}
-func TestMarshalHashSignedHeader(t *testing.T) {
- v := SignedHeader{}
+func TestMarshalHashBPSignedHeader(t *testing.T) {
+ v := BPSignedHeader{}
binary.Read(rand.Reader, binary.BigEndian, &v)
bts1, err := v.MarshalHash()
if err != nil {
@@ -99,8 +99,8 @@ func TestMarshalHashSignedHeader(t *testing.T) {
}
}
-func BenchmarkMarshalHashSignedHeader(b *testing.B) {
- v := SignedHeader{}
+func BenchmarkMarshalHashBPSignedHeader(b *testing.B) {
+ v := BPSignedHeader{}
b.ReportAllocs()
b.ResetTimer()
for i := 0; i < b.N; i++ {
@@ -108,8 +108,8 @@ func BenchmarkMarshalHashSignedHeader(b *testing.B) {
}
}
-func BenchmarkAppendMsgSignedHeader(b *testing.B) {
- v := SignedHeader{}
+func BenchmarkAppendMsgBPSignedHeader(b *testing.B) {
+ v := BPSignedHeader{}
bts := make([]byte, 0, v.Msgsize())
bts, _ = v.MarshalHash()
b.SetBytes(int64(len(bts)))
diff --git a/blockproducer/types/block_test.go b/types/bp_block_test.go
similarity index 96%
rename from blockproducer/types/block_test.go
rename to types/bp_block_test.go
index 403123ea6..fb9e8548d 100644
--- a/blockproducer/types/block_test.go
+++ b/types/bp_block_test.go
@@ -28,7 +28,7 @@ import (
func TestHeader_MarshalUnmarshalBinary(t *testing.T) {
block, err := generateRandomBlock(genesisHash, false)
- header := &block.SignedHeader.Header
+ header := &block.SignedHeader.BPHeader
if err != nil {
t.Fatalf("Failed to generate block: %v", err)
}
@@ -38,7 +38,7 @@ func TestHeader_MarshalUnmarshalBinary(t *testing.T) {
t.Fatalf("Failed to mashal binary: %v", err)
}
- dec := &Header{}
+ dec := &BPHeader{}
err = utils.DecodeMsgPack(enc.Bytes(), dec)
if err != nil {
t.Fatalf("Failed to unmashal binary: %v", err)
@@ -61,7 +61,7 @@ func TestSignedHeader_MarshalUnmashalBinary(t *testing.T) {
t.Fatalf("Failed to mashal binary: %v", err)
}
- dec := &SignedHeader{}
+ dec := &BPSignedHeader{}
err = utils.DecodeMsgPack(enc.Bytes(), dec)
if err != nil {
t.Fatalf("Failed to unmashal binary: %v", err)
@@ -89,7 +89,7 @@ func TestBlock_MarshalUnmarshalBinary(t *testing.T) {
t.Fatalf("Failed to mashal binary: %v", err)
}
- dec := &Block{}
+ dec := &BPBlock{}
err = utils.DecodeMsgPack(enc.Bytes(), dec)
if err != nil {
t.Fatalf("Failed to unmashal binary: %v", err)
diff --git a/blockproducer/types/createdb.go b/types/createdb.go
similarity index 100%
rename from blockproducer/types/createdb.go
rename to types/createdb.go
diff --git a/blockproducer/types/createdb_gen.go b/types/createdb_gen.go
similarity index 100%
rename from blockproducer/types/createdb_gen.go
rename to types/createdb_gen.go
diff --git a/blockproducer/types/createdb_gen_test.go b/types/createdb_gen_test.go
similarity index 100%
rename from blockproducer/types/createdb_gen_test.go
rename to types/createdb_gen_test.go
diff --git a/blockproducer/types/createdb_test.go b/types/createdb_test.go
similarity index 100%
rename from blockproducer/types/createdb_test.go
rename to types/createdb_test.go
diff --git a/types/errors.go b/types/errors.go
index 650e46728..fe49db9b9 100644
--- a/types/errors.go
+++ b/types/errors.go
@@ -28,4 +28,11 @@ var (
ErrNodePublicKeyNotMatch = errors.New("node publick key doesn't match")
// ErrSignRequest indicates a failed signature compute operation.
ErrSignRequest = errors.New("signature compute failed")
+ // ErrSignVerification indicates a failed signature verification.
+ ErrSignVerification = errors.New("signature verification failed")
+ // ErrBillingNotMatch indicates that the billing request doesn't match the local result.
+ ErrBillingNotMatch = errors.New("billing request doesn't match")
+ // ErrHashVerification indicates a failed hash verification.
+ ErrHashVerification = errors.New("hash verification failed")
+
)
diff --git a/blockproducer/types/marshalhash_test.go b/types/marshalhash_test.go
similarity index 60%
rename from blockproducer/types/marshalhash_test.go
rename to types/marshalhash_test.go
index 193b1c3e0..68d8e6cdd 100644
--- a/blockproducer/types/marshalhash_test.go
+++ b/types/marshalhash_test.go
@@ -1,3 +1,19 @@
+/*
+ * Copyright 2018 The CovenantSQL Authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package types
import (
@@ -11,8 +27,7 @@ import (
func TestMarshalHashAccountStable(t *testing.T) {
v := Account{
Address: proto.AccountAddress{0x10},
- StableCoinBalance: 10,
- CovenantCoinBalance: 10,
+ TokenBalance: [SupportTokenNumber]uint64{10, 10},
Rating: 1110,
NextNonce: 1,
}
@@ -32,8 +47,7 @@ func TestMarshalHashAccountStable(t *testing.T) {
func TestMarshalHashAccountStable2(t *testing.T) {
v1 := Account{
Address: proto.AccountAddress{0x10},
- StableCoinBalance: 10,
- CovenantCoinBalance: 10,
+ TokenBalance: [SupportTokenNumber]uint64{10, 10},
Rating: 1110,
NextNonce: 1,
}
diff --git a/blockproducer/types/msgpack_test.go b/types/msgpack_test.go
similarity index 100%
rename from blockproducer/types/msgpack_test.go
rename to types/msgpack_test.go
diff --git a/types/request_type_gen.go b/types/request_type_gen.go
index 709e66bb9..2e3990e57 100644
--- a/types/request_type_gen.go
+++ b/types/request_type_gen.go
@@ -102,15 +102,11 @@ func (z *Request) MarshalHash() (o []byte, err error) {
var b []byte
o = hsp.Require(b, z.Msgsize())
// map header, size 3
- // map header, size 1
- o = append(o, 0x83, 0x83, 0x81, 0x81)
- o = hsp.AppendArrayHeader(o, uint32(len(z.Payload.Queries)))
- for za0001 := range z.Payload.Queries {
- if oTemp, err := z.Payload.Queries[za0001].MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
- }
+ o = append(o, 0x83, 0x83)
+ if oTemp, err := z.Payload.MarshalHash(); err != nil {
+ return nil, err
+ } else {
+ o = hsp.AppendBytes(o, oTemp)
}
// map header, size 2
o = append(o, 0x83, 0x82, 0x82)
@@ -136,11 +132,7 @@ func (z *Request) MarshalHash() (o []byte, err error) {
// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (z *Request) Msgsize() (s int) {
- s = 1 + 8 + 1 + 8 + hsp.ArrayHeaderSize
- for za0001 := range z.Payload.Queries {
- s += z.Payload.Queries[za0001].Msgsize()
- }
- s += 7 + 1 + 14 + z.Header.RequestHeader.Msgsize() + 28 + z.Header.DefaultHashSignVerifierImpl.Msgsize() + 9 + z.Envelope.Msgsize()
+ s = 1 + 8 + z.Payload.Msgsize() + 7 + 1 + 14 + z.Header.RequestHeader.Msgsize() + 28 + z.Header.DefaultHashSignVerifierImpl.Msgsize() + 9 + z.Envelope.Msgsize()
return
}
@@ -194,10 +186,20 @@ func (z *RequestPayload) MarshalHash() (o []byte, err error) {
o = append(o, 0x81, 0x81)
o = hsp.AppendArrayHeader(o, uint32(len(z.Queries)))
for za0001 := range z.Queries {
- if oTemp, err := z.Queries[za0001].MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
+ // map header, size 2
+ o = append(o, 0x82, 0x82)
+ o = hsp.AppendString(o, z.Queries[za0001].Pattern)
+ o = append(o, 0x82)
+ o = hsp.AppendArrayHeader(o, uint32(len(z.Queries[za0001].Args)))
+ for za0002 := range z.Queries[za0001].Args {
+ // map header, size 2
+ o = append(o, 0x82, 0x82)
+ o = hsp.AppendString(o, z.Queries[za0001].Args[za0002].Name)
+ o = append(o, 0x82)
+ o, err = hsp.AppendIntf(o, z.Queries[za0001].Args[za0002].Value)
+ if err != nil {
+ return
+ }
}
}
return
@@ -207,7 +209,10 @@ func (z *RequestPayload) MarshalHash() (o []byte, err error) {
func (z *RequestPayload) Msgsize() (s int) {
s = 1 + 8 + hsp.ArrayHeaderSize
for za0001 := range z.Queries {
- s += z.Queries[za0001].Msgsize()
+ s += 1 + 8 + hsp.StringPrefixSize + len(z.Queries[za0001].Pattern) + 5 + hsp.ArrayHeaderSize
+ for za0002 := range z.Queries[za0001].Args {
+ s += 1 + 5 + hsp.StringPrefixSize + len(z.Queries[za0001].Args[za0002].Name) + 6 + hsp.GuessSize(z.Queries[za0001].Args[za0002].Value)
+ }
}
return
}
diff --git a/blockproducer/types/token.go b/types/token.go
similarity index 56%
rename from blockproducer/types/token.go
rename to types/token.go
index 33a39a97f..39efac166 100644
--- a/blockproducer/types/token.go
+++ b/types/token.go
@@ -16,23 +16,7 @@
package types
-import (
- "bytes"
- "encoding/binary"
-
- "github.com/CovenantSQL/HashStablePack/marshalhash"
-)
-
-// SupportTokenNumber defines the number of token covenantsql supports
-const SupportTokenNumber int32 = 4
-
-// Token defines token's number.
-var Token = [SupportTokenNumber]string{
- "Particle",
- "Ether",
- "EOS",
- "Bitcoin",
-}
+//go:generate hsp
// TokenType defines token's type
type TokenType int32
@@ -40,28 +24,42 @@ type TokenType int32
const (
// Particle defines covenantsql's token
Particle TokenType = iota
+ // Wave defines covenantsql's token
+ Wave
// Ether defines Ethereum.
Ether
// EOS defines EOS.
EOS
// Bitcoin defines Bitcoin.
Bitcoin
+ // SupportTokenNumber defines the number of token covenantsql supports
+ SupportTokenNumber
)
+// TokenList lists supporting token.
+var TokenList = map[TokenType]string{
+ Particle: "Particle",
+ Wave: "Wave",
+ Ether: "Ether",
+ EOS: "EOS",
+ Bitcoin: "Bitcoin",
+}
+
// String returns token's symbol.
func (t TokenType) String() string {
- if t < 0 || int32(t) >= SupportTokenNumber {
+ if t < 0 || t >= SupportTokenNumber {
return "Unknown"
}
- return Token[int(t)]
+ return TokenList[t]
}
// FromString returns token's number.
func FromString(t string) TokenType {
- for i := range Token {
- if t == Token[i] {
- return TokenType(i)
+ var i TokenType
+ for ; i < SupportTokenNumber; i++ {
+ if TokenList[i] == t {
+ return i
}
}
return -1
@@ -69,17 +67,5 @@ func FromString(t string) TokenType {
// Listed returns if the token is listed in list.
func (t *TokenType) Listed() bool {
- return (*t) >= 0 && int32(*t) < SupportTokenNumber
-}
-
-// MarshalHash marshals for hash.
-func (t *TokenType) MarshalHash() (o []byte, err error) {
- var binBuf bytes.Buffer
- binary.Write(&binBuf, binary.BigEndian, t)
- return binBuf.Bytes(), nil
-}
-
-// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message.
-func (t *TokenType) Msgsize() (s int) {
- return marshalhash.BytesPrefixSize + 4
+ return (*t) >= 0 && *t < SupportTokenNumber
}
diff --git a/types/token_gen.go b/types/token_gen.go
new file mode 100644
index 000000000..e1121bdf6
--- /dev/null
+++ b/types/token_gen.go
@@ -0,0 +1,21 @@
+package types
+
+// Code generated by github.com/CovenantSQL/HashStablePack DO NOT EDIT.
+
+import (
+ hsp "github.com/CovenantSQL/HashStablePack/marshalhash"
+)
+
+// MarshalHash marshals for hash
+func (z TokenType) MarshalHash() (o []byte, err error) {
+ var b []byte
+ o = hsp.Require(b, z.Msgsize())
+ o = hsp.AppendInt32(o, int32(z))
+ return
+}
+
+// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
+func (z TokenType) Msgsize() (s int) {
+ s = hsp.Int32Size
+ return
+}
diff --git a/types/token_gen_test.go b/types/token_gen_test.go
new file mode 100644
index 000000000..76e7feeed
--- /dev/null
+++ b/types/token_gen_test.go
@@ -0,0 +1,3 @@
+package types
+
+// Code generated by github.com/CovenantSQL/HashStablePack DO NOT EDIT.
diff --git a/blockproducer/types/token_test.go b/types/token_test.go
similarity index 76%
rename from blockproducer/types/token_test.go
rename to types/token_test.go
index b049081f3..c6164c330 100644
--- a/blockproducer/types/token_test.go
+++ b/types/token_test.go
@@ -34,8 +34,21 @@ func TestTokenType(t *testing.T) {
So(token.String(), ShouldEqual, unknown)
So(token.Listed(), ShouldBeFalse)
- token = TokenType(SupportTokenNumber)
+ token = SupportTokenNumber
So(token.String(), ShouldEqual, unknown)
So(token.Listed(), ShouldBeFalse)
})
+
+ Convey("test token list", t, func() {
+ So(SupportTokenNumber, ShouldEqual, len(TokenList))
+
+ var i TokenType
+ token := make(map[string]int)
+ for i = 0; i < SupportTokenNumber; i++ {
+ t, ok := TokenList[i]
+ So(ok, ShouldBeTrue)
+ token[t] = 1
+ }
+ So(len(token), ShouldEqual, SupportTokenNumber)
+ })
}
diff --git a/blockproducer/types/transfer.go b/types/transfer.go
similarity index 100%
rename from blockproducer/types/transfer.go
rename to types/transfer.go
diff --git a/blockproducer/types/transfer_gen.go b/types/transfer_gen.go
similarity index 100%
rename from blockproducer/types/transfer_gen.go
rename to types/transfer_gen.go
diff --git a/blockproducer/types/transfer_gen_test.go b/types/transfer_gen_test.go
similarity index 100%
rename from blockproducer/types/transfer_gen_test.go
rename to types/transfer_gen_test.go
diff --git a/blockproducer/types/transfer_test.go b/types/transfer_test.go
similarity index 100%
rename from blockproducer/types/transfer_test.go
rename to types/transfer_test.go
diff --git a/types/xxx_test.go b/types/xxx_test.go
index 55d87c586..7b4a38f1d 100644
--- a/types/xxx_test.go
+++ b/types/xxx_test.go
@@ -17,24 +17,235 @@
package types
import (
+ "github.com/CovenantSQL/CovenantSQL/pow/cpuminer"
"io/ioutil"
"math/rand"
"os"
"testing"
"time"
+ pi "github.com/CovenantSQL/CovenantSQL/blockproducer/interfaces"
"github.com/CovenantSQL/CovenantSQL/crypto/asymmetric"
"github.com/CovenantSQL/CovenantSQL/crypto/hash"
"github.com/CovenantSQL/CovenantSQL/crypto/kms"
- "github.com/CovenantSQL/CovenantSQL/pow/cpuminer"
"github.com/CovenantSQL/CovenantSQL/proto"
"github.com/CovenantSQL/CovenantSQL/utils/log"
)
var (
genesisHash = hash.Hash{}
+ uuidLen = 32
+)
+
+const (
+ letterBytes = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
)
+func generateRandomSQLChainUser() *SQLChainUser {
+ return &SQLChainUser{
+ Address: proto.AccountAddress(generateRandomHash()),
+ Permission: UserPermission(rand.Int31n(int32(NumberOfUserPermission))),
+ }
+}
+
+func generateRandomSQLChainUsers(n int) (users []*SQLChainUser) {
+ users = make([]*SQLChainUser, n)
+ for i := range users {
+ users[i] = generateRandomSQLChainUser()
+ }
+ return
+}
+
+func generateRandomAccountAddresses(n int) (s []proto.AccountAddress) {
+ s = make([]proto.AccountAddress, n)
+ for i := range s {
+ s[i] = proto.AccountAddress(generateRandomHash())
+ }
+ return
+}
+
+func generateRandomProfile() *SQLChainProfile {
+ return &SQLChainProfile{
+ ID: *generateRandomDatabaseID(),
+ Owner: proto.AccountAddress(generateRandomHash()),
+ Users: generateRandomSQLChainUsers(rand.Intn(10) + 1),
+ }
+}
+
+func generateRandomAccount() *Account {
+ return &Account{
+ Address: proto.AccountAddress(generateRandomHash()),
+ TokenBalance: [SupportTokenNumber]uint64{rand.Uint64(), rand.Uint64()},
+ Rating: rand.Float64(),
+ }
+}
+
+func generateRandomBytes(n int32) []byte {
+ s := make([]byte, n)
+ for i := range s {
+ s[i] = byte(rand.Int31n(2))
+ }
+ return s
+}
+
+func generateRandomHash() hash.Hash {
+ h := hash.Hash{}
+ rand.Read(h[:])
+ return h
+}
+
+func generateRandomDatabaseID() *proto.DatabaseID {
+ id := proto.DatabaseID(randStringBytes(uuidLen))
+ return &id
+}
+
+func generateRandomDatabaseIDs(n int32) []proto.DatabaseID {
+ s := make([]proto.DatabaseID, n)
+ for i := range s {
+ s[i] = proto.DatabaseID(randStringBytes(uuidLen))
+ }
+ return s
+}
+
+func randStringBytes(n int) string {
+ b := make([]byte, n)
+ for i := range b {
+ b[i] = letterBytes[rand.Intn(len(letterBytes))]
+ }
+ return string(b)
+}
+
+func generateRandomBlock(parent hash.Hash, isGenesis bool) (b *BPBlock, err error) {
+ // Generate key pair
+ priv, _, err := asymmetric.GenSecp256k1KeyPair()
+
+ if err != nil {
+ return
+ }
+
+ h := hash.Hash{}
+ rand.Read(h[:])
+
+ b = &BPBlock{
+ SignedHeader: BPSignedHeader{
+ BPHeader: BPHeader{
+ Version: 0x01000000,
+ Producer: proto.AccountAddress(h),
+ ParentHash: parent,
+ Timestamp: time.Now().UTC(),
+ },
+ },
+ }
+
+ for i, n := 0, rand.Intn(10)+10; i < n; i++ {
+ tb, err := generateRandomBilling()
+ if err != nil {
+ return nil, err
+ }
+ b.Transactions = append(b.Transactions, tb)
+ }
+
+ err = b.PackAndSignBlock(priv)
+ return
+}
+
+func generateRandomBillingRequestHeader() *BillingRequestHeader {
+ return &BillingRequestHeader{
+ DatabaseID: *generateRandomDatabaseID(),
+ LowBlock: generateRandomHash(),
+ LowHeight: rand.Int31(),
+ HighBlock: generateRandomHash(),
+ HighHeight: rand.Int31(),
+ GasAmounts: generateRandomGasAmount(peerNum),
+ }
+}
+
+func generateRandomBillingRequest() (req *BillingRequest, err error) {
+ reqHeader := generateRandomBillingRequestHeader()
+ req = &BillingRequest{
+ Header: *reqHeader,
+ }
+ if _, err = req.PackRequestHeader(); err != nil {
+ return nil, err
+ }
+
+ for i := 0; i < peerNum; i++ {
+ // Generate key pair
+ var priv *asymmetric.PrivateKey
+
+ if priv, _, err = asymmetric.GenSecp256k1KeyPair(); err != nil {
+ return
+ }
+
+ if _, _, err = req.SignRequestHeader(priv, false); err != nil {
+ return
+ }
+ }
+
+ return
+}
+
+func generateRandomBillingHeader() (tc *BillingHeader, err error) {
+ var req *BillingRequest
+ if req, err = generateRandomBillingRequest(); err != nil {
+ return
+ }
+
+ var priv *asymmetric.PrivateKey
+ if priv, _, err = asymmetric.GenSecp256k1KeyPair(); err != nil {
+ return
+ }
+
+ if _, _, err = req.SignRequestHeader(priv, false); err != nil {
+ return
+ }
+
+ receivers := make([]*proto.AccountAddress, peerNum)
+ fees := make([]uint64, peerNum)
+ rewards := make([]uint64, peerNum)
+ for i := range fees {
+ h := generateRandomHash()
+ accountAddress := proto.AccountAddress(h)
+ receivers[i] = &accountAddress
+ fees[i] = rand.Uint64()
+ rewards[i] = rand.Uint64()
+ }
+
+ producer := proto.AccountAddress(generateRandomHash())
+ tc = NewBillingHeader(pi.AccountNonce(rand.Uint32()), req, producer, receivers, fees, rewards)
+ return tc, nil
+}
+
+func generateRandomBilling() (*Billing, error) {
+ header, err := generateRandomBillingHeader()
+ if err != nil {
+ return nil, err
+ }
+ priv, _, err := asymmetric.GenSecp256k1KeyPair()
+ if err != nil {
+ return nil, err
+ }
+ txBilling := NewBilling(header)
+ if err := txBilling.Sign(priv); err != nil {
+ return nil, err
+ }
+ return txBilling, nil
+}
+
+func generateRandomGasAmount(n int) []*proto.AddrAndGas {
+ gasAmount := make([]*proto.AddrAndGas, n)
+
+ for i := range gasAmount {
+ gasAmount[i] = &proto.AddrAndGas{
+ AccountAddress: proto.AccountAddress(generateRandomHash()),
+ RawNodeID: proto.RawNodeID{Hash: generateRandomHash()},
+ GasAmount: rand.Uint64(),
+ }
+ }
+
+ return gasAmount
+}
+
func setup() {
rand.Seed(time.Now().UnixNano())
rand.Read(genesisHash[:])
@@ -134,3 +345,4 @@ func TestMain(m *testing.M) {
setup()
os.Exit(m.Run())
}
+
diff --git a/xenomint/state_test.go b/xenomint/state_test.go
index 4a05d4945..4f6f7d39b 100644
--- a/xenomint/state_test.go
+++ b/xenomint/state_test.go
@@ -448,7 +448,7 @@ INSERT INTO t1 (k, v) VALUES (?, ?)`, concat(values[2:4])...),
Convey(
"The state should be reproducible with block replaying in empty instance #2",
func() {
- // Block replaying
+ // BPBlock replaying
for i := range blocks {
err = st2.ReplayBlock(blocks[i])
So(err, ShouldBeNil)
@@ -482,7 +482,7 @@ INSERT INTO t1 (k, v) VALUES (?, ?)`, concat(values[2:4])...),
So(err, ShouldBeNil)
}
}
- // Block replaying
+ // BPBlock replaying
for i := range blocks {
err = st2.ReplayBlock(blocks[i])
So(err, ShouldBeNil)
diff --git a/xenomint/types/block.go b/xenomint/types/block.go
index 2621786ab..91e851df2 100644
--- a/xenomint/types/block.go
+++ b/xenomint/types/block.go
@@ -54,7 +54,7 @@ func (h *SignedBlockHeader) Verify() error {
return h.DefaultHashSignVerifierImpl.Verify(&h.BlockHeader)
}
-// Block defines a block including a signed block header and its query list.
+// BPBlock defines a block including a signed block header and its query list.
type Block struct {
SignedBlockHeader
ReadQueries []*types.Ack
From 2bb91a5299e967db846243b0334608c8f4b92242 Mon Sep 17 00:00:00 2001
From: zeqing-guo
Date: Wed, 21 Nov 2018 22:57:16 +0800
Subject: [PATCH 013/278] Format code
---
blockproducer/blockindex.go | 2 +-
blockproducer/chain.go | 4 ++--
blockproducer/config.go | 2 +-
blockproducer/metaindex.go | 2 +-
blockproducer/metaindex_test.go | 6 +++---
blockproducer/metastate.go | 4 ++--
blockproducer/metastate_test.go | 8 ++++----
blockproducer/otypes/errors.go | 1 -
blockproducer/otypes/xxx_test.go | 6 +++---
blockproducer/rpc.go | 2 +-
blockproducer/xxx_test.go | 10 +++++-----
cmd/cql-explorer/api.go | 2 +-
cmd/cql-explorer/service.go | 2 +-
cmd/cql-faucet/verifier.go | 2 +-
cmd/cqld/bootstrap.go | 4 ++--
types/account.go | 24 ++++++++++++------------
types/errors.go | 1 -
types/marshalhash_test.go | 12 ++++++------
types/xxx_test.go | 13 ++++++-------
19 files changed, 52 insertions(+), 55 deletions(-)
diff --git a/blockproducer/blockindex.go b/blockproducer/blockindex.go
index eb2601396..88884809b 100644
--- a/blockproducer/blockindex.go
+++ b/blockproducer/blockindex.go
@@ -21,8 +21,8 @@ import (
"sync"
"time"
- "github.com/CovenantSQL/CovenantSQL/types"
"github.com/CovenantSQL/CovenantSQL/crypto/hash"
+ "github.com/CovenantSQL/CovenantSQL/types"
"github.com/CovenantSQL/CovenantSQL/utils/log"
)
diff --git a/blockproducer/chain.go b/blockproducer/chain.go
index 1f639dd14..5cb61bff6 100644
--- a/blockproducer/chain.go
+++ b/blockproducer/chain.go
@@ -18,13 +18,11 @@ package blockproducer
import (
"fmt"
- "github.com/CovenantSQL/CovenantSQL/types"
"os"
"sync"
"time"
pi "github.com/CovenantSQL/CovenantSQL/blockproducer/interfaces"
- pt "github.com/CovenantSQL/CovenantSQL/types"
"github.com/CovenantSQL/CovenantSQL/chainbus"
"github.com/CovenantSQL/CovenantSQL/crypto"
"github.com/CovenantSQL/CovenantSQL/crypto/asymmetric"
@@ -34,6 +32,8 @@ import (
"github.com/CovenantSQL/CovenantSQL/proto"
"github.com/CovenantSQL/CovenantSQL/route"
"github.com/CovenantSQL/CovenantSQL/rpc"
+ "github.com/CovenantSQL/CovenantSQL/types"
+ pt "github.com/CovenantSQL/CovenantSQL/types"
"github.com/CovenantSQL/CovenantSQL/utils"
"github.com/CovenantSQL/CovenantSQL/utils/log"
"github.com/coreos/bbolt"
diff --git a/blockproducer/config.go b/blockproducer/config.go
index 2ec553df0..772c58630 100644
--- a/blockproducer/config.go
+++ b/blockproducer/config.go
@@ -19,9 +19,9 @@ package blockproducer
import (
"time"
- "github.com/CovenantSQL/CovenantSQL/types"
"github.com/CovenantSQL/CovenantSQL/proto"
"github.com/CovenantSQL/CovenantSQL/rpc"
+ "github.com/CovenantSQL/CovenantSQL/types"
)
const (
diff --git a/blockproducer/metaindex.go b/blockproducer/metaindex.go
index dee7e6bf6..be611c272 100644
--- a/blockproducer/metaindex.go
+++ b/blockproducer/metaindex.go
@@ -20,8 +20,8 @@ import (
"bytes"
"sync"
- pt "github.com/CovenantSQL/CovenantSQL/types"
"github.com/CovenantSQL/CovenantSQL/proto"
+ pt "github.com/CovenantSQL/CovenantSQL/types"
"github.com/CovenantSQL/CovenantSQL/utils"
"github.com/coreos/bbolt"
"github.com/ulule/deepcopier"
diff --git a/blockproducer/metaindex_test.go b/blockproducer/metaindex_test.go
index 85d7796c7..ecf8e6b79 100644
--- a/blockproducer/metaindex_test.go
+++ b/blockproducer/metaindex_test.go
@@ -22,8 +22,8 @@ import (
"testing"
pi "github.com/CovenantSQL/CovenantSQL/blockproducer/interfaces"
- pt "github.com/CovenantSQL/CovenantSQL/types"
"github.com/CovenantSQL/CovenantSQL/proto"
+ pt "github.com/CovenantSQL/CovenantSQL/types"
"github.com/coreos/bbolt"
. "github.com/smartystreets/goconvey/convey"
)
@@ -121,13 +121,13 @@ func TestMetaIndex(t *testing.T) {
Convey("When account objects are stored", func() {
mi.storeAccountObject(&accountObject{
Account: pt.Account{
- Address: addr1,
+ Address: addr1,
TokenBalance: [pt.SupportTokenNumber]uint64{10, 10},
},
})
mi.storeAccountObject(&accountObject{
Account: pt.Account{
- Address: addr2,
+ Address: addr2,
TokenBalance: [pt.SupportTokenNumber]uint64{10, 10},
},
})
diff --git a/blockproducer/metastate.go b/blockproducer/metastate.go
index d955e83a6..53628e4e5 100644
--- a/blockproducer/metastate.go
+++ b/blockproducer/metastate.go
@@ -18,12 +18,12 @@ package blockproducer
import (
"bytes"
- "github.com/CovenantSQL/CovenantSQL/types"
"sync"
pi "github.com/CovenantSQL/CovenantSQL/blockproducer/interfaces"
- pt "github.com/CovenantSQL/CovenantSQL/types"
"github.com/CovenantSQL/CovenantSQL/proto"
+ "github.com/CovenantSQL/CovenantSQL/types"
+ pt "github.com/CovenantSQL/CovenantSQL/types"
"github.com/CovenantSQL/CovenantSQL/utils"
"github.com/CovenantSQL/CovenantSQL/utils/log"
"github.com/coreos/bbolt"
diff --git a/blockproducer/metastate_test.go b/blockproducer/metastate_test.go
index cb51b4e22..18932596c 100644
--- a/blockproducer/metastate_test.go
+++ b/blockproducer/metastate_test.go
@@ -17,15 +17,15 @@
package blockproducer
import (
- "github.com/CovenantSQL/CovenantSQL/types"
"math"
"os"
"path"
"testing"
pi "github.com/CovenantSQL/CovenantSQL/blockproducer/interfaces"
- pt "github.com/CovenantSQL/CovenantSQL/types"
"github.com/CovenantSQL/CovenantSQL/proto"
+ "github.com/CovenantSQL/CovenantSQL/types"
+ pt "github.com/CovenantSQL/CovenantSQL/types"
"github.com/coreos/bbolt"
. "github.com/smartystreets/goconvey/convey"
)
@@ -695,13 +695,13 @@ func TestMetaState(t *testing.T) {
txs = []pi.Transaction{
pt.NewBaseAccount(
&pt.Account{
- Address: addr1,
+ Address: addr1,
TokenBalance: [pt.SupportTokenNumber]uint64{100, 100},
},
),
pt.NewBaseAccount(
&pt.Account{
- Address: addr2,
+ Address: addr2,
TokenBalance: [pt.SupportTokenNumber]uint64{100, 100},
},
),
diff --git a/blockproducer/otypes/errors.go b/blockproducer/otypes/errors.go
index 95b0a04f5..7de275fe4 100644
--- a/blockproducer/otypes/errors.go
+++ b/blockproducer/otypes/errors.go
@@ -25,5 +25,4 @@ var (
ErrSignVerification = errors.New("signature verification failed")
// ErrBillingNotMatch indicates that the billing request doesn't match the local result.
ErrBillingNotMatch = errors.New("billing request doesn't match")
-
)
diff --git a/blockproducer/otypes/xxx_test.go b/blockproducer/otypes/xxx_test.go
index 24f42f353..76651456e 100644
--- a/blockproducer/otypes/xxx_test.go
+++ b/blockproducer/otypes/xxx_test.go
@@ -17,14 +17,15 @@
package types
import (
+ "math/rand"
+
"github.com/CovenantSQL/CovenantSQL/crypto/asymmetric"
"github.com/CovenantSQL/CovenantSQL/crypto/hash"
"github.com/CovenantSQL/CovenantSQL/proto"
- "math/rand"
)
var (
- uuidLen = 32
+ uuidLen = 32
)
const (
@@ -99,4 +100,3 @@ func generateRandomGasAmount(n int) []*proto.AddrAndGas {
return gasAmount
}
-
diff --git a/blockproducer/rpc.go b/blockproducer/rpc.go
index 138854b5d..7abf5e6ca 100644
--- a/blockproducer/rpc.go
+++ b/blockproducer/rpc.go
@@ -18,9 +18,9 @@ package blockproducer
import (
pi "github.com/CovenantSQL/CovenantSQL/blockproducer/interfaces"
- pt "github.com/CovenantSQL/CovenantSQL/types"
"github.com/CovenantSQL/CovenantSQL/proto"
"github.com/CovenantSQL/CovenantSQL/types"
+ pt "github.com/CovenantSQL/CovenantSQL/types"
)
// ChainRPCService defines a main chain RPC server.
diff --git a/blockproducer/xxx_test.go b/blockproducer/xxx_test.go
index a88859f20..87e6a5e4e 100644
--- a/blockproducer/xxx_test.go
+++ b/blockproducer/xxx_test.go
@@ -17,7 +17,6 @@
package blockproducer
import (
- "github.com/CovenantSQL/CovenantSQL/types"
"io/ioutil"
"math/rand"
"os"
@@ -26,13 +25,14 @@ import (
"time"
pi "github.com/CovenantSQL/CovenantSQL/blockproducer/interfaces"
- pt "github.com/CovenantSQL/CovenantSQL/types"
"github.com/CovenantSQL/CovenantSQL/crypto"
"github.com/CovenantSQL/CovenantSQL/crypto/asymmetric"
"github.com/CovenantSQL/CovenantSQL/crypto/hash"
"github.com/CovenantSQL/CovenantSQL/crypto/kms"
"github.com/CovenantSQL/CovenantSQL/pow/cpuminer"
"github.com/CovenantSQL/CovenantSQL/proto"
+ "github.com/CovenantSQL/CovenantSQL/types"
+ pt "github.com/CovenantSQL/CovenantSQL/types"
"github.com/CovenantSQL/CovenantSQL/utils/log"
)
@@ -118,13 +118,13 @@ func generateRandomBlock(parent hash.Hash, isGenesis bool) (b *pt.BPBlock, err e
var (
ba1 = pt.NewBaseAccount(
&pt.Account{
- Address: testAddress1,
+ Address: testAddress1,
TokenBalance: [pt.SupportTokenNumber]uint64{testInitBalance, testInitBalance},
},
)
ba2 = pt.NewBaseAccount(
&pt.Account{
- Address: testAddress2,
+ Address: testAddress2,
TokenBalance: [pt.SupportTokenNumber]uint64{testInitBalance, testInitBalance},
},
)
@@ -277,7 +277,7 @@ func generateRandomBillingAndBaseAccount() (*pt.BaseAccount, *types.Billing, err
txBaseAccount := pt.NewBaseAccount(
&pt.Account{
- Address: header.Producer,
+ Address: header.Producer,
TokenBalance: [pt.SupportTokenNumber]uint64{testInitBalance, testInitBalance},
},
)
diff --git a/cmd/cql-explorer/api.go b/cmd/cql-explorer/api.go
index f6c577dfa..4a79ca03a 100644
--- a/cmd/cql-explorer/api.go
+++ b/cmd/cql-explorer/api.go
@@ -25,9 +25,9 @@ import (
"time"
pi "github.com/CovenantSQL/CovenantSQL/blockproducer/interfaces"
- pt "github.com/CovenantSQL/CovenantSQL/types"
"github.com/CovenantSQL/CovenantSQL/crypto/hash"
"github.com/CovenantSQL/CovenantSQL/proto"
+ pt "github.com/CovenantSQL/CovenantSQL/types"
"github.com/CovenantSQL/CovenantSQL/utils/log"
"github.com/gorilla/mux"
)
diff --git a/cmd/cql-explorer/service.go b/cmd/cql-explorer/service.go
index 9159e53b9..136a40410 100644
--- a/cmd/cql-explorer/service.go
+++ b/cmd/cql-explorer/service.go
@@ -26,12 +26,12 @@ import (
bp "github.com/CovenantSQL/CovenantSQL/blockproducer"
pi "github.com/CovenantSQL/CovenantSQL/blockproducer/interfaces"
- pt "github.com/CovenantSQL/CovenantSQL/types"
"github.com/CovenantSQL/CovenantSQL/conf"
"github.com/CovenantSQL/CovenantSQL/crypto/hash"
"github.com/CovenantSQL/CovenantSQL/proto"
"github.com/CovenantSQL/CovenantSQL/route"
"github.com/CovenantSQL/CovenantSQL/rpc"
+ pt "github.com/CovenantSQL/CovenantSQL/types"
"github.com/CovenantSQL/CovenantSQL/utils"
"github.com/CovenantSQL/CovenantSQL/utils/log"
"github.com/syndtr/goleveldb/leveldb"
diff --git a/cmd/cql-faucet/verifier.go b/cmd/cql-faucet/verifier.go
index 9e7b3987e..9ebd3b88a 100644
--- a/cmd/cql-faucet/verifier.go
+++ b/cmd/cql-faucet/verifier.go
@@ -28,12 +28,12 @@ import (
"time"
bp "github.com/CovenantSQL/CovenantSQL/blockproducer"
- pt "github.com/CovenantSQL/CovenantSQL/types"
"github.com/CovenantSQL/CovenantSQL/crypto"
"github.com/CovenantSQL/CovenantSQL/crypto/asymmetric"
"github.com/CovenantSQL/CovenantSQL/crypto/kms"
"github.com/CovenantSQL/CovenantSQL/proto"
"github.com/CovenantSQL/CovenantSQL/route"
+ pt "github.com/CovenantSQL/CovenantSQL/types"
"github.com/CovenantSQL/CovenantSQL/utils/log"
"github.com/CovenantSQL/xurls"
"github.com/dyatlov/go-opengraph/opengraph"
diff --git a/cmd/cqld/bootstrap.go b/cmd/cqld/bootstrap.go
index 5b6b6fb3f..414f23fae 100644
--- a/cmd/cqld/bootstrap.go
+++ b/cmd/cqld/bootstrap.go
@@ -25,7 +25,6 @@ import (
"time"
bp "github.com/CovenantSQL/CovenantSQL/blockproducer"
- "github.com/CovenantSQL/CovenantSQL/types"
"github.com/CovenantSQL/CovenantSQL/conf"
"github.com/CovenantSQL/CovenantSQL/crypto/kms"
"github.com/CovenantSQL/CovenantSQL/kayak"
@@ -35,6 +34,7 @@ import (
"github.com/CovenantSQL/CovenantSQL/proto"
"github.com/CovenantSQL/CovenantSQL/route"
"github.com/CovenantSQL/CovenantSQL/rpc"
+ "github.com/CovenantSQL/CovenantSQL/types"
"github.com/CovenantSQL/CovenantSQL/utils/log"
"github.com/pkg/errors"
"golang.org/x/crypto/ssh/terminal"
@@ -286,7 +286,7 @@ func loadGenesis() *types.BPBlock {
}).Debug("setting one balance fixture in genesis block")
genesis.Transactions = append(genesis.Transactions, types.NewBaseAccount(
&types.Account{
- Address: proto.AccountAddress(ba.Address),
+ Address: proto.AccountAddress(ba.Address),
TokenBalance: [types.SupportTokenNumber]uint64{ba.StableCoinBalance, ba.CovenantCoinBalance},
}))
}
diff --git a/types/account.go b/types/account.go
index 66d09658b..4ab28630f 100644
--- a/types/account.go
+++ b/types/account.go
@@ -65,8 +65,8 @@ const (
// SQLChainUser defines a SQLChain user.
type SQLChainUser struct {
- Address proto.AccountAddress
- Permission UserPermission
+ Address proto.AccountAddress
+ Permission UserPermission
AdvancePayment uint64
Arrears uint64
Pledge uint64
@@ -85,23 +85,23 @@ type MinerInfo struct {
// SQLChainProfile defines a SQLChainProfile related to an account.
type SQLChainProfile struct {
- ID proto.DatabaseID
- Address proto.AccountAddress
- Period uint64
+ ID proto.DatabaseID
+ Address proto.AccountAddress
+ Period uint64
GasPrice uint64
TokenType TokenType
- Owner proto.AccountAddress
- Miners []*MinerInfo
+ Owner proto.AccountAddress
+ Miners []*MinerInfo
- Users []*SQLChainUser
+ Users []*SQLChainUser
}
// Account store its balance, and other mate data.
type Account struct {
- Address proto.AccountAddress
- TokenBalance [SupportTokenNumber]uint64
- Rating float64
- NextNonce pi.AccountNonce
+ Address proto.AccountAddress
+ TokenBalance [SupportTokenNumber]uint64
+ Rating float64
+ NextNonce pi.AccountNonce
}
diff --git a/types/errors.go b/types/errors.go
index fe49db9b9..3f7726ba2 100644
--- a/types/errors.go
+++ b/types/errors.go
@@ -34,5 +34,4 @@ var (
ErrBillingNotMatch = errors.New("billing request doesn't match")
// ErrHashVerification indicates a failed hash verification.
ErrHashVerification = errors.New("hash verification failed")
-
)
diff --git a/types/marshalhash_test.go b/types/marshalhash_test.go
index 68d8e6cdd..85f3d6508 100644
--- a/types/marshalhash_test.go
+++ b/types/marshalhash_test.go
@@ -26,10 +26,10 @@ import (
func TestMarshalHashAccountStable(t *testing.T) {
v := Account{
- Address: proto.AccountAddress{0x10},
+ Address: proto.AccountAddress{0x10},
TokenBalance: [SupportTokenNumber]uint64{10, 10},
- Rating: 1110,
- NextNonce: 1,
+ Rating: 1110,
+ NextNonce: 1,
}
bts1, err := v.MarshalHash()
if err != nil {
@@ -46,10 +46,10 @@ func TestMarshalHashAccountStable(t *testing.T) {
func TestMarshalHashAccountStable2(t *testing.T) {
v1 := Account{
- Address: proto.AccountAddress{0x10},
+ Address: proto.AccountAddress{0x10},
TokenBalance: [SupportTokenNumber]uint64{10, 10},
- Rating: 1110,
- NextNonce: 1,
+ Rating: 1110,
+ NextNonce: 1,
}
enc, err := utils.EncodeMsgPack(&v1)
if err != nil {
diff --git a/types/xxx_test.go b/types/xxx_test.go
index 7b4a38f1d..1fd30605d 100644
--- a/types/xxx_test.go
+++ b/types/xxx_test.go
@@ -17,7 +17,6 @@
package types
import (
- "github.com/CovenantSQL/CovenantSQL/pow/cpuminer"
"io/ioutil"
"math/rand"
"os"
@@ -28,6 +27,7 @@ import (
"github.com/CovenantSQL/CovenantSQL/crypto/asymmetric"
"github.com/CovenantSQL/CovenantSQL/crypto/hash"
"github.com/CovenantSQL/CovenantSQL/crypto/kms"
+ "github.com/CovenantSQL/CovenantSQL/pow/cpuminer"
"github.com/CovenantSQL/CovenantSQL/proto"
"github.com/CovenantSQL/CovenantSQL/utils/log"
)
@@ -66,17 +66,17 @@ func generateRandomAccountAddresses(n int) (s []proto.AccountAddress) {
func generateRandomProfile() *SQLChainProfile {
return &SQLChainProfile{
- ID: *generateRandomDatabaseID(),
- Owner: proto.AccountAddress(generateRandomHash()),
- Users: generateRandomSQLChainUsers(rand.Intn(10) + 1),
+ ID: *generateRandomDatabaseID(),
+ Owner: proto.AccountAddress(generateRandomHash()),
+ Users: generateRandomSQLChainUsers(rand.Intn(10) + 1),
}
}
func generateRandomAccount() *Account {
return &Account{
- Address: proto.AccountAddress(generateRandomHash()),
+ Address: proto.AccountAddress(generateRandomHash()),
TokenBalance: [SupportTokenNumber]uint64{rand.Uint64(), rand.Uint64()},
- Rating: rand.Float64(),
+ Rating: rand.Float64(),
}
}
@@ -345,4 +345,3 @@ func TestMain(m *testing.M) {
setup()
os.Exit(m.Run())
}
-
From 459021fd33cc6b97812c479f14b22a1d490371e5 Mon Sep 17 00:00:00 2001
From: leventeliu
Date: Thu, 22 Nov 2018 19:16:10 +0800
Subject: [PATCH 014/278] Add msgpack bench for complex types
---
types/types_test.go | 87 +++++++++++++++++++++++++++++++++++++++++++++
types/xxx_test.go | 83 ++++++++++++++++++++++++++++++++++++++++--
2 files changed, 167 insertions(+), 3 deletions(-)
diff --git a/types/types_test.go b/types/types_test.go
index 39960d09d..ca68ad0d5 100644
--- a/types/types_test.go
+++ b/types/types_test.go
@@ -17,7 +17,10 @@
package types
import (
+ "bytes"
"fmt"
+ "math/rand"
+ "reflect"
"testing"
"time"
@@ -27,6 +30,7 @@ import (
"github.com/CovenantSQL/CovenantSQL/utils"
"github.com/pkg/errors"
. "github.com/smartystreets/goconvey/convey"
+ "github.com/ugorji/go/codec"
)
func getCommKeys() (*asymmetric.PrivateKey, *asymmetric.PublicKey) {
@@ -690,3 +694,86 @@ func TestQueryTypeStringer(t *testing.T) {
}
})
}
+
+func benchmarkEnc(b *testing.B, v interface{}) {
+ var (
+ h = &codec.MsgpackHandle{
+ WriteExt: true,
+ RawToString: true,
+ }
+ err error
+ )
+ for i := 0; i < b.N; i++ {
+ var enc = codec.NewEncoder(bytes.NewBuffer(nil), h)
+ if err = enc.Encode(v); err != nil {
+ b.Error(err)
+ }
+ }
+}
+
+func benchmarkDec(b *testing.B, v interface{}) {
+ var (
+ r []byte
+ err error
+
+ h = &codec.MsgpackHandle{
+ WriteExt: true,
+ RawToString: true,
+ }
+ enc = codec.NewEncoderBytes(&r, h)
+ recvt = reflect.ValueOf(v).Elem().Type()
+ recvs = make([]interface{}, b.N)
+ )
+ // Encode v and make receivers
+ if err = enc.Encode(v); err != nil {
+ b.Error(err)
+ }
+ for i := range recvs {
+ recvs[i] = reflect.New(recvt).Interface()
+ }
+ b.ResetTimer()
+ // Start benchmark
+ for i := 0; i < b.N; i++ {
+ var dec = codec.NewDecoder(bytes.NewReader(r), h)
+ if err = dec.Decode(recvs[i]); err != nil {
+ b.Error(err)
+ }
+ }
+}
+
+func BenchmarkTypes(b *testing.B) {
+ var (
+ // Build a approximate 1KB request
+ req = buildRequest(WriteQuery, []Query{
+ buildQuery(
+ `INSERT INTO "t1" VALUES (?, ?, ?, ?)`,
+ rand.Int(),
+ randBytes(333),
+ randBytes(333),
+ randBytes(333),
+ ),
+ })
+ // Build a approximate 1KB response with the previous request header
+ resp = buildResponse(
+ &req.Header,
+ []string{"k", "v1", "v2", "v3"},
+ []string{"INT", "TEXT", "TEXT", "TEXT"},
+ []ResponseRow{
+ {
+ Values: []interface{}{
+ rand.Int(),
+ randBytes(333),
+ randBytes(333),
+ randBytes(333),
+ },
+ },
+ },
+ )
+ )
+ var subjects = [...]interface{}{req, resp}
+ for _, v := range subjects {
+ var name = reflect.ValueOf(v).Elem().Type().Name()
+ b.Run(fmt.Sprint(name, "Enc"), func(b *testing.B) { benchmarkEnc(b, v) })
+ b.Run(fmt.Sprint(name, "Dec"), func(b *testing.B) { benchmarkDec(b, v) })
+ }
+}
diff --git a/types/xxx_test.go b/types/xxx_test.go
index 55d87c586..87dd332a2 100644
--- a/types/xxx_test.go
+++ b/types/xxx_test.go
@@ -32,9 +32,86 @@ import (
)
var (
- genesisHash = hash.Hash{}
+ genesisHash = hash.Hash{}
+ testingPrivateKey *asymmetric.PrivateKey
+ testingPublicKey *asymmetric.PublicKey
)
+func randBytes(n int) (b []byte) {
+ b = make([]byte, n)
+ rand.Read(b)
+ return
+}
+
+func buildQuery(query string, args ...interface{}) Query {
+ var nargs = make([]NamedArg, len(args))
+ for i := range args {
+ nargs[i] = NamedArg{
+ Name: "",
+ Value: args[i],
+ }
+ }
+ return Query{
+ Pattern: query,
+ Args: nargs,
+ }
+}
+
+func buildRequest(qt QueryType, qs []Query) (r *Request) {
+ var (
+ id proto.NodeID
+ err error
+ )
+ if id, err = kms.GetLocalNodeID(); err != nil {
+ id = proto.NodeID("00000000000000000000000000000000")
+ }
+ r = &Request{
+ Header: SignedRequestHeader{
+ RequestHeader: RequestHeader{
+ NodeID: id,
+ Timestamp: time.Now().UTC(),
+ QueryType: qt,
+ },
+ },
+ Payload: RequestPayload{Queries: qs},
+ }
+ if err = r.Sign(testingPrivateKey); err != nil {
+ panic(err)
+ }
+ return
+}
+
+func buildResponse(header *SignedRequestHeader, cols []string, types []string, rows []ResponseRow) (r *Response) {
+ var (
+ id proto.NodeID
+ err error
+ )
+ if id, err = kms.GetLocalNodeID(); err != nil {
+ id = proto.NodeID("00000000000000000000000000000000")
+ }
+ r = &Response{
+ Header: SignedResponseHeader{
+ ResponseHeader: ResponseHeader{
+ Request: *header,
+ NodeID: id,
+ Timestamp: time.Now().UTC(),
+ RowCount: 0,
+ LogOffset: 0,
+ LastInsertID: 0,
+ AffectedRows: 0,
+ },
+ },
+ Payload: ResponsePayload{
+ Columns: cols,
+ DeclTypes: types,
+ Rows: rows,
+ },
+ }
+ if err = r.Sign(testingPrivateKey); err != nil {
+ panic(err)
+ }
+ return
+}
func setup() {
rand.Seed(time.Now().UnixNano())
rand.Read(genesisHash[:])
@@ -52,8 +129,8 @@ func setup() {
kms.Unittest = true
- if priv, pub, err := asymmetric.GenSecp256k1KeyPair(); err == nil {
- kms.SetLocalKeyPair(priv, pub)
+ if testingPrivateKey, testingPublicKey, err = asymmetric.GenSecp256k1KeyPair(); err == nil {
+ kms.SetLocalKeyPair(testingPrivateKey, testingPublicKey)
} else {
panic(err)
}
From 1f4cb98ebf57c8cf2ce978189c81b46939bfca4a Mon Sep 17 00:00:00 2001
From: leventeliu
Date: Thu, 22 Nov 2018 19:16:30 +0800
Subject: [PATCH 015/278] Fix xenomint bench for sqlparser
---
xenomint/chain_test.go | 9 ++-------
xenomint/mux_test.go | 9 ++-------
2 files changed, 4 insertions(+), 14 deletions(-)
diff --git a/xenomint/chain_test.go b/xenomint/chain_test.go
index a20fa4fa1..0a962fbc7 100644
--- a/xenomint/chain_test.go
+++ b/xenomint/chain_test.go
@@ -66,13 +66,8 @@ func setupBenchmarkChain(b *testing.B) (c *Chain, n int, r []*types.Request) {
n = benchmarkKeySpace
// Setup query requests
var (
- sel = `SELECT "v1", "v2", "v3" FROM "bench" WHERE "k"=?`
- ins = `INSERT INTO "bench" VALUES (?, ?, ?, ?)
- ON CONFLICT("k") DO UPDATE SET
- "v1"="excluded"."v1",
- "v2"="excluded"."v2",
- "v3"="excluded"."v3"
-`
+ sel = `SELECT v1, v2, v3 FROM bench WHERE k=?`
+ ins = `INSERT OR REPLACE INTO bench VALUES (?, ?, ?, ?)`
priv *ca.PrivateKey
src = make([][]interface{}, benchmarkKeySpace)
)
diff --git a/xenomint/mux_test.go b/xenomint/mux_test.go
index e4385ac5a..c5963c705 100644
--- a/xenomint/mux_test.go
+++ b/xenomint/mux_test.go
@@ -111,13 +111,8 @@ func setupBenchmarkMuxParallel(b *testing.B) (
// Setup query requests
var (
- sel = `SELECT "v1", "v2", "v3" FROM "bench" WHERE "k"=?`
- ins = `INSERT INTO "bench" VALUES (?, ?, ?, ?)
- ON CONFLICT("k") DO UPDATE SET
- "v1"="excluded"."v1",
- "v2"="excluded"."v2",
- "v3"="excluded"."v3"
-`
+ sel = `SELECT v1, v2, v3 FROM bench WHERE k=?`
+ ins = `INSERT OR REPLACE INTO bench VALUES (?, ?, ?, ?)`
src = make([][]interface{}, benchmarkKeySpace)
)
r = make([]*MuxQueryRequest, 2*benchmarkKeySpace)
From ccfbf1aa362f25b9eefe77f9b58e4d26ef9e1e51 Mon Sep 17 00:00:00 2001
From: leventeliu
Date: Fri, 23 Nov 2018 03:00:45 +0800
Subject: [PATCH 016/278] Add large write transaction benchmark
---
xenomint/sqlite/sqlite_test.go | 72 ++++++++++++++++++++++++++++++++++
1 file changed, 72 insertions(+)
diff --git a/xenomint/sqlite/sqlite_test.go b/xenomint/sqlite/sqlite_test.go
index 6288b8f51..11429023d 100644
--- a/xenomint/sqlite/sqlite_test.go
+++ b/xenomint/sqlite/sqlite_test.go
@@ -628,6 +628,78 @@ func BenchmarkStorage(b *testing.B) {
}
}
+func setupBenchmarkLargeWriteTx(
+ b *testing.B, st xi.Storage, e string, src [][]interface{}, n int) (tx *sql.Tx,
+) {
+ var err error
+ ipkg.reset()
+ if tx, err = st.Writer().Begin(); err != nil {
+ b.Fatalf("Failed to setup bench environment: %v", err)
+ }
+ for i := 0; i < n; i++ {
+ if _, err = tx.Exec(e, src[ipkg.next()]...); err != nil {
+ b.Fatalf("Failed to setup bench environment: %v", err)
+ }
+ }
+ if _, err = tx.Exec(`SAVEPOINT "xmark"`); err != nil {
+ b.Fatalf("Failed to setup bench environment: %v", err)
+ }
+ return
+}
+
+func resetBenchmarkLargeWriteTx(b *testing.B, tx *sql.Tx) {
+ var err error
+ b.StopTimer()
+ if _, err := tx.Exec(`ROLLBACK TO "xmark"`); err != nil {
+ b.Fatalf("Failed to reset bench environment: %v", err)
+ }
+ if _, err = tx.Exec(`SAVEPOINT "xmark"`); err != nil {
+ b.Fatalf("Failed to reset bench environment: %v", err)
+ }
+}
+
+func teardownBenchmarkLargeWriteTx(b *testing.B, tx *sql.Tx) {
+ if err := tx.Rollback(); err != nil {
+ b.Fatalf("Failed to teardown bench environment: %v", err)
+ }
+}
+
+func BenchmarkLargeWriteTx(b *testing.B) {
+ var (
+ st, _, _, e, src = setupBenchmarkStorage(b)
+
+ profiles = [...]int{0, 10, 100, 1000, 10000, 100000}
+ err error
+ )
+ for _, v := range profiles {
+ func() {
+ var tx = setupBenchmarkLargeWriteTx(b, st, e, src, v)
+ defer teardownBenchmarkLargeWriteTx(b, tx)
+
+ b.Run(fmt.Sprintf("%s#%d", b.Name(), v), func(b *testing.B) {
+ defer resetBenchmarkLargeWriteTx(b, tx)
+ for i := 0; i < b.N; i++ {
+ if _, err = tx.Exec(e, src[ipkg.next()]...); err != nil {
+ b.Errorf("Failed to execute: %v", err)
+ }
+ }
+ })
+ }()
+ }
+ // A simple commit duration testing, but not benchmark
+ for _, v := range profiles {
+ var (
+ tx = setupBenchmarkLargeWriteTx(b, st, e, src, v)
+ start = time.Now()
+ )
+ if err = tx.Commit(); err != nil {
+ b.Errorf("Failed to commit: %v", err)
+ }
+ b.Logf("Commit %d writes in %.3fms", v, float64(time.Since(start).Nanoseconds())/1000000)
+ }
+ teardownBenchmarkStorage(b, st)
+}
+
//func BenchmarkStorageSequentialDirtyRead(b *testing.B) {
// var (
// st, q, dm, _, _ = setupBenchmarkStorage(b)
From bc0f00056b206b16cc773ee5d5f1dd2fec013418 Mon Sep 17 00:00:00 2001
From: leventeliu
Date: Fri, 23 Nov 2018 13:14:00 +0800
Subject: [PATCH 017/278] Add Sign/Verify benchmarking
---
types/types_test.go | 32 ++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+)
diff --git a/types/types_test.go b/types/types_test.go
index ca68ad0d5..29724c951 100644
--- a/types/types_test.go
+++ b/types/types_test.go
@@ -741,6 +741,32 @@ func benchmarkDec(b *testing.B, v interface{}) {
}
}
+type ver interface {
+ Verify() error
+}
+
+type ser interface {
+ Sign(*asymmetric.PrivateKey) error
+}
+
+func benchmarkVerify(b *testing.B, v ver) {
+ var err error
+ for i := 0; i < b.N; i++ {
+ if err = v.Verify(); err != nil {
+ b.Error(err)
+ }
+ }
+}
+
+func benchmarkSign(b *testing.B, s ser) {
+ var err error
+ for i := 0; i < b.N; i++ {
+ if err = s.Sign(testingPrivateKey); err != nil {
+ b.Error(err)
+ }
+ }
+}
+
func BenchmarkTypes(b *testing.B) {
var (
// Build a approximate 1KB request
@@ -775,5 +801,11 @@ func BenchmarkTypes(b *testing.B) {
var name = reflect.ValueOf(v).Elem().Type().Name()
b.Run(fmt.Sprint(name, "Enc"), func(b *testing.B) { benchmarkEnc(b, v) })
b.Run(fmt.Sprint(name, "Dec"), func(b *testing.B) { benchmarkDec(b, v) })
+ if x, ok := v.(ver); ok {
+ b.Run(fmt.Sprint(name, "Verify"), func(b *testing.B) { benchmarkVerify(b, x) })
+ }
+ if x, ok := v.(ser); ok {
+ b.Run(fmt.Sprint(name, "Sign"), func(b *testing.B) { benchmarkSign(b, x) })
+ }
}
}
From 3e608d850ab411659639bec6cf7a145e801d2a2d Mon Sep 17 00:00:00 2001
From: leventeliu
Date: Fri, 23 Nov 2018 16:20:39 +0800
Subject: [PATCH 018/278] Add tracing logs
---
xenomint/chain.go | 26 +++++++++-
xenomint/chain_test.go | 55 ++++++++++++---------
xenomint/mux.go | 22 +++++++++
xenomint/mux_test.go | 48 +++++++++++--------
xenomint/state.go | 105 +++++++++++++++++++++++++++++++++++++++--
xenomint/xxx_test.go | 70 ++++++++++++++++++++++++---
6 files changed, 273 insertions(+), 53 deletions(-)
diff --git a/xenomint/chain.go b/xenomint/chain.go
index 5b24c5956..830ab2a0c 100644
--- a/xenomint/chain.go
+++ b/xenomint/chain.go
@@ -17,11 +17,14 @@
package xenomint
import (
+ "time"
+
ca "github.com/CovenantSQL/CovenantSQL/crypto/asymmetric"
"github.com/CovenantSQL/CovenantSQL/crypto/hash"
"github.com/CovenantSQL/CovenantSQL/crypto/kms"
"github.com/CovenantSQL/CovenantSQL/proto"
"github.com/CovenantSQL/CovenantSQL/types"
+ "github.com/CovenantSQL/CovenantSQL/utils/log"
xi "github.com/CovenantSQL/CovenantSQL/xenomint/interfaces"
xs "github.com/CovenantSQL/CovenantSQL/xenomint/sqlite"
xt "github.com/CovenantSQL/CovenantSQL/xenomint/types"
@@ -83,14 +86,35 @@ func NewChain(filename string) (c *Chain, err error) {
// Query queries req from local chain state and returns the query results in resp.
func (c *Chain) Query(req *types.Request) (resp *types.Response, err error) {
- var ref *QueryTracker
+ var (
+ ref *QueryTracker
+ start = time.Now()
+
+ queried, signed, updated time.Duration
+ )
+ defer func() {
+ var fields = log.Fields{}
+ if queried > 0 {
+ fields["1#queried"] = float64(queried.Nanoseconds()) / 1000
+ }
+ if signed > 0 {
+ fields["2#signed"] = float64((signed - queried).Nanoseconds()) / 1000
+ }
+ if updated > 0 {
+ fields["3#updated"] = float64((updated - signed).Nanoseconds()) / 1000
+ }
+ log.WithFields(fields).Debug("Chain.Query duration stat (us)")
+ }()
if ref, resp, err = c.state.Query(req); err != nil {
return
}
+ queried = time.Since(start)
if err = resp.Sign(c.priv); err != nil {
return
}
+ signed = time.Since(start)
ref.UpdateResp(resp)
+ updated = time.Since(start)
return
}
diff --git a/xenomint/chain_test.go b/xenomint/chain_test.go
index 0a962fbc7..b6db11101 100644
--- a/xenomint/chain_test.go
+++ b/xenomint/chain_test.go
@@ -22,6 +22,7 @@ import (
"math/rand"
"os"
"path"
+ "sync/atomic"
"testing"
ca "github.com/CovenantSQL/CovenantSQL/crypto/asymmetric"
@@ -29,7 +30,7 @@ import (
"github.com/CovenantSQL/CovenantSQL/types"
)
-func setupBenchmarkChain(b *testing.B) (c *Chain, n int, r []*types.Request) {
+func setupBenchmarkChain(b *testing.B) (c *Chain, r []*types.Request) {
// Setup chain state
var (
fl = path.Join(testingDataDir, b.Name())
@@ -49,12 +50,12 @@ func setupBenchmarkChain(b *testing.B) (c *Chain, n int, r []*types.Request) {
); err != nil {
b.Fatalf("Failed to setup bench environment: %v", err)
}
- for i := 0; i < benchmarkKeySpace; i++ {
+ for i := 0; i < benchmarkReservedKeyLength; i++ {
var (
vals [benchmarkVNum][benchmarkVLen]byte
args [benchmarkVNum + 1]interface{}
)
- args[0] = i
+ args[0] = i + benchmarkReservedKeyOffset
for i := range vals {
rand.Read(vals[i][:])
args[i+1] = string(vals[i][:])
@@ -63,22 +64,21 @@ func setupBenchmarkChain(b *testing.B) (c *Chain, n int, r []*types.Request) {
b.Fatalf("Failed to setup bench environment: %v", err)
}
}
- n = benchmarkKeySpace
// Setup query requests
var (
sel = `SELECT v1, v2, v3 FROM bench WHERE k=?`
- ins = `INSERT OR REPLACE INTO bench VALUES (?, ?, ?, ?)`
+ ins = `INSERT INTO bench VALUES (?, ?, ?, ?)`
priv *ca.PrivateKey
- src = make([][]interface{}, benchmarkKeySpace)
+ src = make([][]interface{}, benchmarkNewKeyLength)
)
if priv, err = kms.GetLocalPrivateKey(); err != nil {
b.Fatalf("Failed to setup bench environment: %v", err)
}
- r = make([]*types.Request, 2*benchmarkKeySpace)
+ r = make([]*types.Request, benchmarkMaxKey)
// Read query key space [0, n-1]
- for i := 0; i < benchmarkKeySpace; i++ {
+ for i := 0; i < benchmarkReservedKeyLength; i++ {
r[i] = buildRequest(types.ReadQuery, []types.Query{
- buildQuery(sel, i),
+ buildQuery(sel, i+benchmarkReservedKeyOffset),
})
if err = r[i].Sign(priv); err != nil {
b.Fatalf("Failed to setup bench environment: %v", err)
@@ -88,21 +88,24 @@ func setupBenchmarkChain(b *testing.B) (c *Chain, n int, r []*types.Request) {
for i := range src {
var vals [benchmarkVNum][benchmarkVLen]byte
src[i] = make([]interface{}, benchmarkVNum+1)
- src[i][0] = i + benchmarkKeySpace
+ src[i][0] = i + benchmarkNewKeyOffset
for j := range vals {
rand.Read(vals[j][:])
src[i][j+1] = string(vals[j][:])
}
}
- for i := 0; i < benchmarkKeySpace; i++ {
- r[benchmarkKeySpace+i] = buildRequest(types.WriteQuery, []types.Query{
+ for i := 0; i < benchmarkNewKeyLength; i++ {
+ r[i+benchmarkNewKeyOffset] = buildRequest(types.WriteQuery, []types.Query{
buildQuery(ins, src[i]...),
})
- if err = r[i+benchmarkKeySpace].Sign(priv); err != nil {
+ if err = r[i+benchmarkNewKeyOffset].Sign(priv); err != nil {
b.Fatalf("Failed to setup bench environment: %v", err)
}
}
+ allKeyPermKeygen.reset()
+ newKeyPermKeygen.reset()
+
b.ResetTimer()
return
}
@@ -129,14 +132,17 @@ func teardownBenchmarkChain(b *testing.B, c *Chain) {
}
func BenchmarkChainParallelWrite(b *testing.B) {
- var c, n, r = setupBenchmarkChain(b)
+ var c, r = setupBenchmarkChain(b)
b.RunParallel(func(pb *testing.PB) {
- var err error
- for i := 0; pb.Next(); i++ {
- if _, err = c.Query(r[n+rand.Intn(n)]); err != nil {
+ var (
+ err error
+ counter int32
+ )
+ for pb.Next() {
+ if _, err = c.Query(r[newKeyPermKeygen.next()]); err != nil {
b.Fatalf("Failed to execute: %v", err)
}
- if (i+1)%benchmarkQueriesPerBlock == 0 {
+ if atomic.AddInt32(&counter, 1)%benchmarkQueriesPerBlock == 0 {
if err = c.state.commit(); err != nil {
b.Fatalf("Failed to commit block: %v", err)
}
@@ -147,14 +153,17 @@ func BenchmarkChainParallelWrite(b *testing.B) {
}
func BenchmarkChainParallelMixRW(b *testing.B) {
- var c, n, r = setupBenchmarkChain(b)
+ var c, r = setupBenchmarkChain(b)
b.RunParallel(func(pb *testing.PB) {
- var err error
- for i := 0; pb.Next(); i++ {
- if _, err = c.Query(r[rand.Intn(2*n)]); err != nil {
+ var (
+ err error
+ counter int32
+ )
+ for pb.Next() {
+ if _, err = c.Query(r[allKeyPermKeygen.next()]); err != nil {
b.Fatalf("Failed to execute: %v", err)
}
- if (i+1)%benchmarkQueriesPerBlock == 0 {
+ if atomic.AddInt32(&counter, 1)%benchmarkQueriesPerBlock == 0 {
if err = c.state.commit(); err != nil {
b.Fatalf("Failed to commit block: %v", err)
}
diff --git a/xenomint/mux.go b/xenomint/mux.go
index b1bd308ee..48806ade9 100644
--- a/xenomint/mux.go
+++ b/xenomint/mux.go
@@ -20,10 +20,12 @@ import (
//"context"
//"runtime/trace"
"sync"
+ "time"
"github.com/CovenantSQL/CovenantSQL/proto"
"github.com/CovenantSQL/CovenantSQL/rpc"
"github.com/CovenantSQL/CovenantSQL/types"
+ "github.com/CovenantSQL/CovenantSQL/utils/log"
)
// MuxService defines multiplexing service of xenomint chain.
@@ -91,18 +93,38 @@ func (s *MuxService) Query(req *MuxQueryRequest, resp *MuxQueryResponse) (err er
var (
c *Chain
r *types.Response
+
+ start = time.Now()
+
+ routed, queried, responded time.Duration
)
+ defer func() {
+ var fields = log.Fields{}
+ if routed > 0 {
+ fields["1#routed"] = float64(routed.Nanoseconds()) / 1000
+ }
+ if queried > 0 {
+ fields["2#queried"] = float64((queried - routed).Nanoseconds()) / 1000
+ }
+ if responded > 0 {
+ fields["3#responded"] = float64((responded - queried).Nanoseconds()) / 1000
+ }
+ log.WithFields(fields).Debug("MuxService.Query duration stat (us)")
+ }()
if c, err = s.route(req.DatabaseID); err != nil {
return
}
+ routed = time.Since(start)
if r, err = c.Query(req.Request); err != nil {
return
}
+ queried = time.Since(start)
resp = &MuxQueryResponse{
Envelope: req.Envelope,
DatabaseID: req.DatabaseID,
Response: r,
}
+ responded = time.Since(start)
return
}
diff --git a/xenomint/mux_test.go b/xenomint/mux_test.go
index c5963c705..b62c6f96a 100644
--- a/xenomint/mux_test.go
+++ b/xenomint/mux_test.go
@@ -23,6 +23,7 @@ import (
"os"
"path"
"strings"
+ "sync/atomic"
"testing"
"github.com/CovenantSQL/CovenantSQL/conf"
@@ -112,14 +113,14 @@ func setupBenchmarkMuxParallel(b *testing.B) (
// Setup query requests
var (
sel = `SELECT v1, v2, v3 FROM bench WHERE k=?`
- ins = `INSERT OR REPLACE INTO bench VALUES (?, ?, ?, ?)`
- src = make([][]interface{}, benchmarkKeySpace)
+ ins = `INSERT INTO bench VALUES (?, ?, ?, ?)`
+ src = make([][]interface{}, benchmarkNewKeyLength)
)
- r = make([]*MuxQueryRequest, 2*benchmarkKeySpace)
+ r = make([]*MuxQueryRequest, benchmarkMaxKey)
// Read query key space [0, n-1]
- for i := 0; i < benchmarkKeySpace; i++ {
+ for i := 0; i < benchmarkReservedKeyLength; i++ {
var req = buildRequest(types.ReadQuery, []types.Query{
- buildQuery(sel, i),
+ buildQuery(sel, i+benchmarkReservedKeyOffset),
})
if err = req.Sign(priv); err != nil {
b.Fatalf("Failed to setup bench environment: %v", err)
@@ -133,20 +134,20 @@ func setupBenchmarkMuxParallel(b *testing.B) (
for i := range src {
var vals [benchmarkVNum][benchmarkVLen]byte
src[i] = make([]interface{}, benchmarkVNum+1)
- src[i][0] = i + benchmarkKeySpace
+ src[i][0] = i + benchmarkNewKeyOffset
for j := range vals {
rand.Read(vals[j][:])
src[i][j+1] = string(vals[j][:])
}
}
- for i := 0; i < benchmarkKeySpace; i++ {
+ for i := 0; i < benchmarkNewKeyLength; i++ {
var req = buildRequest(types.WriteQuery, []types.Query{
buildQuery(ins, src[i]...),
})
if err = req.Sign(priv); err != nil {
b.Fatalf("Failed to setup bench environment: %v", err)
}
- r[benchmarkKeySpace+i] = &MuxQueryRequest{
+ r[i+benchmarkNewKeyOffset] = &MuxQueryRequest{
DatabaseID: benchmarkDatabaseID,
Request: req,
}
@@ -193,12 +194,12 @@ func setupSubBenchmarkMuxParallel(b *testing.B, ms *MuxService) (c *Chain) {
); err != nil {
b.Fatalf("Failed to setup bench environment: %v", err)
}
- for i := 0; i < benchmarkKeySpace; i++ {
+ for i := 0; i < benchmarkReservedKeyLength; i++ {
var (
vals [benchmarkVNum][benchmarkVLen]byte
args [benchmarkVNum + 1]interface{}
)
- args[0] = i
+ args[0] = i + benchmarkReservedKeyOffset
for i := range vals {
rand.Read(vals[i][:])
args[i+1] = string(vals[i][:])
@@ -209,6 +210,9 @@ func setupSubBenchmarkMuxParallel(b *testing.B, ms *MuxService) (c *Chain) {
}
ms.register(benchmarkDatabaseID, c)
+ allKeyPermKeygen.reset()
+ newKeyPermKeygen.reset()
+
b.ResetTimer()
return
}
@@ -245,20 +249,24 @@ func BenchmarkMuxParallel(b *testing.B) {
var bp, s, ms, r = setupBenchmarkMuxParallel(b)
defer teardownBenchmarkMuxParallel(b, bp.server, s.server)
var benchmarks = []struct {
- name string
- randkey func(n int) int // Returns a random key from given key space
+ name string
+ kg keygen
}{
{
- name: "Write",
- randkey: func(n int) int { return n + rand.Intn(n) },
+ name: "Write",
+ kg: newKeyPermKeygen,
}, {
- name: "MixRW",
- randkey: func(n int) int { return rand.Intn(2 * n) },
+ name: "MixRW",
+ kg: allKeyPermKeygen,
},
}
for _, bm := range benchmarks {
b.Run(bm.name, func(b *testing.B) {
- var c = setupSubBenchmarkMuxParallel(b, ms)
+ var (
+ counter int32
+
+ c = setupSubBenchmarkMuxParallel(b, ms)
+ )
defer teardownSubBenchmarkMuxParallel(b, ms)
b.RunParallel(func(pb *testing.PB) {
var (
@@ -266,13 +274,13 @@ func BenchmarkMuxParallel(b *testing.B) {
method = fmt.Sprintf("%s.%s", benchmarkRPCName, "Query")
caller = rpc.NewPersistentCaller(s.node.ID)
)
- for i := 0; pb.Next(); i++ {
+ for pb.Next() {
if err = caller.Call(
- method, &r[bm.randkey(benchmarkKeySpace)], &MuxQueryResponse{},
+ method, &r[bm.kg.next()], &MuxQueryResponse{},
); err != nil {
b.Fatalf("Failed to execute: %v", err)
}
- if (i+1)%benchmarkQueriesPerBlock == 0 {
+ if atomic.AddInt32(&counter, 1)%benchmarkQueriesPerBlock == 0 {
if err = c.state.commit(); err != nil {
b.Fatalf("Failed to commit block: %v", err)
}
diff --git a/xenomint/state.go b/xenomint/state.go
index 8599cf012..b156ddd99 100644
--- a/xenomint/state.go
+++ b/xenomint/state.go
@@ -348,17 +348,33 @@ func (s *State) writeSingle(q *types.Query) (res sql.Result, err error) {
containsDDL bool
pattern string
args []interface{}
+ //start = time.Now()
+
+ //parsed, executed time.Duration
)
+ //defer func() {
+ // var fields = log.Fields{}
+ // fields["savepoint"] = s.current
+ // if parsed > 0 {
+ // fields["1#parsed"] = float64(parsed.Nanoseconds()) / 1000
+ // }
+ // if executed > 0 {
+ // fields["2#executed"] = float64((executed - parsed).Nanoseconds()) / 1000
+ // }
+ // log.WithFields(fields).Debug("writeSingle duration stat (us)")
+ //}()
if containsDDL, pattern, args, err = convertQueryAndBuildArgs(q.Pattern, q.Args); err != nil {
return
}
+ //parsed = time.Since(start)
if res, err = s.unc.Exec(pattern, args...); err == nil {
if containsDDL {
atomic.StoreUint32(&s.hasSchemaChange, 1)
}
s.incSeq()
}
+ //executed = time.Since(start)
return
}
@@ -380,13 +396,39 @@ func (s *State) write(req *types.Request) (ref *QueryTracker, resp *types.Respon
totalAffectedRows int64
curAffectedRows int64
lastInsertID int64
+ start = time.Now()
+
+ lockAcquired, writeDone, enqueued, lockReleased, respBuilt time.Duration
)
+ defer func() {
+ var fields = log.Fields{}
+ fields["savepoint"] = savepoint
+ fields["1#lockAcquired"] = float64(lockAcquired.Nanoseconds()) / 1000
+ if writeDone > 0 {
+ fields["2#writeDone"] = float64((writeDone - lockAcquired).Nanoseconds()) / 1000
+ }
+ if enqueued > 0 {
+ fields["3#enqueued"] = float64((enqueued - writeDone).Nanoseconds()) / 1000
+ }
+ if lockReleased > 0 {
+ fields["4#lockReleased"] = float64((lockReleased - enqueued).Nanoseconds()) / 1000
+ }
+ if respBuilt > 0 {
+ fields["5#respBuilt"] = float64((respBuilt - lockReleased).Nanoseconds()) / 1000
+ }
+ log.WithFields(fields).Debug("Write duration stat (us)")
+ }()
+
// TODO(leventeliu): savepoint is a sqlite-specified solution for nested transaction.
if err = func() (err error) {
var ierr error
s.Lock()
- defer s.Unlock()
+ lockAcquired = time.Since(start)
+ defer func() {
+ s.Unlock()
+ lockReleased = time.Since(start)
+ }()
savepoint = s.getID()
for i, v := range req.Payload.Queries {
var res sql.Result
@@ -403,7 +445,9 @@ func (s *State) write(req *types.Request) (ref *QueryTracker, resp *types.Respon
totalAffectedRows += curAffectedRows
}
s.setSavepoint()
+ writeDone = time.Since(start)
s.pool.enqueue(savepoint, query)
+ enqueued = time.Since(start)
return
}(); err != nil {
return
@@ -423,6 +467,7 @@ func (s *State) write(req *types.Request) (ref *QueryTracker, resp *types.Respon
},
},
}
+ respBuilt = time.Since(start)
return
}
@@ -524,25 +569,77 @@ func (s *State) ReplayBlock(block *types.Block) (err error) {
}
func (s *State) commit() (err error) {
+ var (
+ start = time.Now()
+
+ lockAcquired, committed, poolCleaned, lockReleased time.Duration
+ )
+
+ defer func() {
+ var fields = log.Fields{}
+ fields["1#lockAcquired"] = float64(lockAcquired.Nanoseconds()) / 1000
+ if committed > 0 {
+ fields["2#committed"] = float64((committed - lockAcquired).Nanoseconds()) / 1000
+ }
+ if poolCleaned > 0 {
+ fields["3#poolCleaned"] = float64((poolCleaned - committed).Nanoseconds()) / 1000
+ }
+ if lockReleased > 0 {
+ fields["4#lockReleased"] = float64((lockReleased - poolCleaned).Nanoseconds()) / 1000
+ }
+ log.WithFields(fields).Debug("Commit duration stat (us)")
+ }()
+
s.Lock()
- defer s.Unlock()
+ defer func() {
+ s.Unlock()
+ lockReleased = time.Since(start)
+ }()
+ lockAcquired = time.Since(start)
if err = s.uncCommit(); err != nil {
return
}
if s.unc, err = s.strg.Writer().Begin(); err != nil {
return
}
+ committed = time.Since(start)
s.setNextTxID()
s.setSavepoint()
_ = s.pool.queries
s.pool = newPool()
+ poolCleaned = time.Since(start)
return
}
// CommitEx commits the current transaction and returns all the pooled queries.
func (s *State) CommitEx() (failed []*types.Request, queries []*QueryTracker, err error) {
+ var (
+ start = time.Now()
+
+ lockAcquired, committed, poolCleaned, lockReleased time.Duration
+ )
+
+ defer func() {
+ var fields = log.Fields{}
+ fields["1#lockAcquired"] = float64(lockAcquired.Nanoseconds()) / 1000
+ if committed > 0 {
+ fields["2#committed"] = float64((committed - lockAcquired).Nanoseconds()) / 1000
+ }
+ if poolCleaned > 0 {
+ fields["3#poolCleaned"] = float64((poolCleaned - committed).Nanoseconds()) / 1000
+ }
+ if lockReleased > 0 {
+ fields["4#lockReleased"] = float64((lockReleased - poolCleaned).Nanoseconds()) / 1000
+ }
+ log.WithFields(fields).Debug("Commit duration stat (us)")
+ }()
+
s.Lock()
- defer s.Unlock()
+ lockAcquired = time.Since(start)
+ defer func() {
+ s.Unlock()
+ lockReleased = time.Since(start)
+ }()
if err = s.uncCommit(); err != nil {
// FATAL ERROR
return
@@ -551,12 +648,14 @@ func (s *State) CommitEx() (failed []*types.Request, queries []*QueryTracker, er
// FATAL ERROR
return
}
+ committed = time.Since(start)
s.setNextTxID()
s.setSavepoint()
// Return pooled items and reset
failed = s.pool.failedList()
queries = s.pool.queries
s.pool = newPool()
+ poolCleaned = time.Since(start)
return
}
diff --git a/xenomint/xxx_test.go b/xenomint/xxx_test.go
index aabe8fe80..6e19f1b08 100644
--- a/xenomint/xxx_test.go
+++ b/xenomint/xxx_test.go
@@ -21,6 +21,8 @@ import (
"math/rand"
"os"
"path"
+ "sync/atomic"
+
//"runtime/trace"
"sync"
"syscall"
@@ -43,11 +45,12 @@ const (
benchmarkVNum = 3
benchmarkVLen = 333
- // benchmarkKeySpace defines the key space for benchmarking.
- //
- // We will have `benchmarkKeySpace` preserved records in the generated testing table and
- // another `benchmarkKeySpace` constructed incoming records returned from the setup function.
- benchmarkKeySpace = 100000
+
+ benchmarkReservedKeyOffset = 0
+ benchmarkReservedKeyLength = 100000
+ benchmarkNewKeyOffset = benchmarkReservedKeyOffset + benchmarkReservedKeyLength
+ benchmarkNewKeyLength = 100000
+ benchmarkMaxKey = benchmarkNewKeyOffset + benchmarkNewKeyLength
)
var (
@@ -149,6 +152,56 @@ func createNodesWithPublicKey(
return
}
+type keygen interface {
+ next() int
+ reset()
+}
+
+type randKeygen struct {
+ offset int
+ length int
+}
+
+func newRandKeygen(offset, length int) *randKeygen {
+ return &randKeygen{
+ offset: offset,
+ length: length,
+ }
+}
+
+func (k *randKeygen) next() int { return rand.Intn(k.length) + k.offset }
+func (k *randKeygen) reset() {}
+
+type permKeygen struct {
+ offset int
+ length int
+ perm []int
+ pos int32
+}
+
+func newPermKeygen(offset, length int) *permKeygen {
+ return &permKeygen{
+ offset: offset,
+ length: length,
+ perm: rand.Perm(length),
+ }
+}
+
+func (k *permKeygen) next() int {
+ var pos = atomic.AddInt32(&k.pos, 1) - 1
+ if pos >= int32(k.length) {
+ panic("permKeygen: keys have been exhausted")
+ }
+ return k.perm[pos] + k.offset
+}
+
+func (k *permKeygen) reset() { k.pos = 0 }
+
+var (
+ allKeyPermKeygen = newPermKeygen(0, benchmarkMaxKey)
+ newKeyPermKeygen = newPermKeygen(benchmarkNewKeyOffset, benchmarkNewKeyLength)
+)
+
func setup() {
const minNoFile uint64 = 4096
var (
@@ -197,8 +250,13 @@ func setup() {
// panic(err)
//}
- log.SetOutput(os.Stdout)
log.SetLevel(log.DebugLevel)
+ //fl, err := os.OpenFile("./xenomint_test.log", os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0666)
+ //if err != nil {
+ // panic(err)
+ //}
+ //log.SetOutput(fl)
+ log.SetOutput(os.Stdout)
}
func teardown() {
From 9aa17475e3dd4f267d8a7a9da41fe5ee2d41ae34 Mon Sep 17 00:00:00 2001
From: zeqing-guo
Date: Mon, 26 Nov 2018 01:54:10 +0800
Subject: [PATCH 019/278] Add miner-user matching mode
---
blockproducer/chain.go | 6 +
blockproducer/errors.go | 6 +
blockproducer/interfaces/transaction.go | 4 +
blockproducer/metaindex.go | 23 +++
blockproducer/metaindex_test.go | 3 +
blockproducer/metastate.go | 231 +++++++++++++++++++++++-
blockproducer/metastate_test.go | 8 +-
blockproducer/rpc.go | 38 ++++
proto/nodeinfo.go | 58 +++---
proto/nodeinfo_test.go | 19 ++
proto/proto.go | 13 ++
proto/proto_test.go | 20 ++
route/acl.go | 4 +-
types/account.go | 11 ++
types/account_gen.go | 66 +++++--
types/account_gen_test.go | 37 ++++
types/createdb.go | 1 +
types/createdb_gen.go | 28 ++-
types/init_service_type.go | 1 +
types/init_service_type_gen.go | 25 ++-
types/provideservice.go | 74 ++++++++
types/provideservice_gen.go | 71 ++++++++
types/provideservice_gen_test.go | 84 +++++++++
types/request_type_gen.go | 43 ++---
24 files changed, 790 insertions(+), 84 deletions(-)
create mode 100644 types/provideservice.go
create mode 100644 types/provideservice_gen.go
create mode 100644 types/provideservice_gen_test.go
diff --git a/blockproducer/chain.go b/blockproducer/chain.go
index 5cb61bff6..c0d21e3d1 100644
--- a/blockproducer/chain.go
+++ b/blockproducer/chain.go
@@ -47,6 +47,7 @@ var (
metaTransactionBucket = []byte("covenantsql-tx-index-bucket")
metaAccountIndexBucket = []byte("covenantsql-account-index-bucket")
metaSQLChainIndexBucket = []byte("covenantsql-sqlchain-index-bucket")
+ metaProviderIndexBucket = []byte("covenantsql-provider-index-bucket")
gasPrice uint32 = 1
accountAddress proto.AccountAddress
txEvent = "/BP/Tx"
@@ -117,6 +118,11 @@ func NewChain(cfg *Config) (*Chain, error) {
}
_, err = bucket.CreateBucketIfNotExists(metaSQLChainIndexBucket)
+ if err != nil {
+ return
+ }
+
+ _, err = bucket.CreateBucketIfNotExists(metaProviderIndexBucket)
return
})
if err != nil {
diff --git a/blockproducer/errors.go b/blockproducer/errors.go
index a36b9d8a9..06bc1ef74 100644
--- a/blockproducer/errors.go
+++ b/blockproducer/errors.go
@@ -63,6 +63,8 @@ var (
ErrDatabaseExists = errors.New("database already exists")
// ErrDatabaseUserExists indicates that the database user already exists.
ErrDatabaseUserExists = errors.New("database user already exists")
+ // ErrDatabaseCannotCreate indicates that database cannot be created.
+ ErrDatabaseCannotCreate = errors.New("database cannot be created.")
// ErrInvalidAccountNonce indicates that a transaction has a invalid account nonce.
ErrInvalidAccountNonce = errors.New("invalid account nonce")
// ErrUnknownTransactionType indicates that a transaction has a unknown type and cannot be
@@ -72,4 +74,8 @@ var (
ErrTransactionMismatch = errors.New("transaction mismatch")
// ErrMetaStateNotFound indicates that meta state not found in db.
ErrMetaStateNotFound = errors.New("meta state not found in db")
+ // ErrInvalidSender indicates that tx.Signee != tx.Sender.
+ ErrInvalidSender = errors.New("invalid sender")
+ // ErrNoSuchMiner indicates that this miner does not exist or register.
+ ErrNoSuchMiner = errors.New("no such miner")
)
diff --git a/blockproducer/interfaces/transaction.go b/blockproducer/interfaces/transaction.go
index ba1d93a86..48d3817c8 100644
--- a/blockproducer/interfaces/transaction.go
+++ b/blockproducer/interfaces/transaction.go
@@ -63,6 +63,8 @@ const (
TransactionTypeBaseAccount
// TransactionTypeCreateDatabase defines database creation transaction type.
TransactionTypeCreateDatabase
+ // TransactionTypeProvideService define miner providing database service type.
+ TransactionTypeProvideService
// TransactionTypeNumber defines transaction types number.
TransactionTypeNumber
)
@@ -87,6 +89,8 @@ func (t TransactionType) String() string {
return "BaseAccount"
case TransactionTypeCreateDatabase:
return "CreateDatabase"
+ case TransactionTypeProvideService:
+ return "ProvideService"
default:
return "Unknown"
}
diff --git a/blockproducer/metaindex.go b/blockproducer/metaindex.go
index be611c272..e2854665a 100644
--- a/blockproducer/metaindex.go
+++ b/blockproducer/metaindex.go
@@ -55,10 +55,16 @@ type sqlchainObject struct {
pt.SQLChainProfile
}
+type providerObject struct {
+ sync.RWMutex
+ pt.ProviderProfile
+}
+
type metaIndex struct {
sync.RWMutex
accounts map[proto.AccountAddress]*accountObject
databases map[proto.DatabaseID]*sqlchainObject
+ provider map[proto.AccountAddress]*providerObject
}
func newMetaIndex() *metaIndex {
@@ -92,6 +98,18 @@ func (i *metaIndex) deleteSQLChainObject(k proto.DatabaseID) {
delete(i.databases, k)
}
+func (i *metaIndex) storeProviderObject(o *providerObject) {
+ i.Lock()
+ defer i.Unlock()
+ i.provider[o.Provider] = o
+}
+
+func (i *metaIndex) deleteProviderObject(k proto.AccountAddress) {
+ i.Lock()
+ defer i.Unlock()
+ delete(i.provider, k)
+}
+
func (i *metaIndex) deepCopy() (cpy *metaIndex) {
cpy = newMetaIndex()
for k, v := range i.accounts {
@@ -104,6 +122,11 @@ func (i *metaIndex) deepCopy() (cpy *metaIndex) {
deepcopier.Copy(v).To(cpyv)
cpy.databases[k] = cpyv
}
+ for k, v := range i.provider {
+ cpyv := &providerObject{}
+ deepcopier.Copy(v).To(cpyv)
+ cpy.provider[k] = cpyv
+ }
return
}
diff --git a/blockproducer/metaindex_test.go b/blockproducer/metaindex_test.go
index ecf8e6b79..6236a5503 100644
--- a/blockproducer/metaindex_test.go
+++ b/blockproducer/metaindex_test.go
@@ -61,6 +61,9 @@ func TestMetaIndex(t *testing.T) {
if _, err = meta.CreateBucket(metaSQLChainIndexBucket); err != nil {
return
}
+ if _, err = meta.CreateBucket(metaProviderIndexBucket); err != nil {
+ return
+ }
if txbk, err = meta.CreateBucket(metaTransactionBucket); err != nil {
return
}
diff --git a/blockproducer/metastate.go b/blockproducer/metastate.go
index 53628e4e5..6c73c7e6e 100644
--- a/blockproducer/metastate.go
+++ b/blockproducer/metastate.go
@@ -18,11 +18,17 @@ package blockproducer
import (
"bytes"
+ "fmt"
+ "github.com/CovenantSQL/CovenantSQL/crypto"
+ "github.com/CovenantSQL/CovenantSQL/crypto/asymmetric"
+ "github.com/CovenantSQL/CovenantSQL/crypto/hash"
+ "github.com/CovenantSQL/CovenantSQL/crypto/kms"
+ "github.com/pkg/errors"
"sync"
+ "time"
pi "github.com/CovenantSQL/CovenantSQL/blockproducer/interfaces"
"github.com/CovenantSQL/CovenantSQL/proto"
- "github.com/CovenantSQL/CovenantSQL/types"
pt "github.com/CovenantSQL/CovenantSQL/types"
"github.com/CovenantSQL/CovenantSQL/utils"
"github.com/CovenantSQL/CovenantSQL/utils/log"
@@ -30,6 +36,11 @@ import (
"github.com/ulule/deepcopier"
)
+var (
+ sqlchainPeriod uint64 = 60 * 24 * 30
+ sqlchainGasPrice uint64 = 10
+)
+
// TODO(leventeliu): lock optimization.
type metaState struct {
@@ -184,6 +195,34 @@ func (s *metaState) loadOrStoreSQLChainObject(
return
}
+func (s *metaState) loadProviderObject(k proto.AccountAddress) (o *providerObject, loaded bool) {
+ s.RLock()
+ defer s.RUnlock()
+ if o, loaded = s.dirty.provider[k]; loaded {
+ if o == nil {
+ loaded = false
+ }
+ return
+ }
+ if o, loaded = s.readonly.provider[k]; loaded {
+ return
+ }
+ return
+}
+
+func (s *metaState) loadOrStoreProviderObject(k proto.AccountAddress, v *providerObject) (o *providerObject, loaded bool) {
+ s.Lock()
+ defer s.Unlock()
+ if o, loaded = s.dirty.provider[k]; loaded && o != nil {
+ return
+ }
+ if o, loaded = s.readonly.provider[k]; loaded {
+ return
+ }
+ s.dirty.provider[k] = v
+ return
+}
+
func (s *metaState) deleteAccountObject(k proto.AccountAddress) {
s.Lock()
defer s.Unlock()
@@ -198,12 +237,20 @@ func (s *metaState) deleteSQLChainObject(k proto.DatabaseID) {
s.dirty.databases[k] = nil
}
+func (s *metaState) deleteProviderObject(k proto.AccountAddress) {
+ s.Lock()
+ defer s.Unlock()
+ // Use a nil pointer to mark a deletion, which will be later used by commit procedure.
+ s.dirty.provider[k] = nil
+}
+
func (s *metaState) commitProcedure() (_ func(*bolt.Tx) error) {
return func(tx *bolt.Tx) (err error) {
var (
enc *bytes.Buffer
ab = tx.Bucket(metaBucket[:]).Bucket(metaAccountIndexBucket)
cb = tx.Bucket(metaBucket[:]).Bucket(metaSQLChainIndexBucket)
+ pb = tx.Bucket(metaBucket[:]).Bucket(metaProviderIndexBucket)
)
s.Lock()
defer s.Unlock()
@@ -243,6 +290,24 @@ func (s *metaState) commitProcedure() (_ func(*bolt.Tx) error) {
}
}
}
+ for k, v := range s.dirty.provider {
+ if v != nil {
+ // New/update object
+ s.readonly.provider[k] = v
+ if enc, err = utils.EncodeMsgPack(v.ProviderProfile); err != nil {
+ return
+ }
+ if err = pb.Put(k[:], enc.Bytes()); err != nil {
+ return
+ }
+ } else {
+ // Delete object
+ delete(s.readonly.provider, k)
+ if err = pb.Delete(k[:]); err != nil {
+ return
+ }
+ }
+ }
// Clean dirty map and tx pool
s.dirty = newMetaIndex()
s.pool = newTxPool()
@@ -258,6 +323,7 @@ func (s *metaState) partialCommitProcedure(txs []pi.Transaction) (_ func(*bolt.T
enc *bytes.Buffer
ab = tx.Bucket(metaBucket[:]).Bucket(metaAccountIndexBucket)
cb = tx.Bucket(metaBucket[:]).Bucket(metaSQLChainIndexBucket)
+ pb = tx.Bucket(metaBucket[:]).Bucket(metaProviderIndexBucket)
)
s.Lock()
defer s.Unlock()
@@ -318,6 +384,24 @@ func (s *metaState) partialCommitProcedure(txs []pi.Transaction) (_ func(*bolt.T
}
}
}
+ for k, v := range cm.dirty.provider {
+ if v != nil {
+ // New/update object
+ cm.readonly.provider[k] = v
+ if enc, err = utils.EncodeMsgPack(v.Provider); err != nil {
+ return
+ }
+ if err = pb.Put(k[:], enc.Bytes()); err != nil {
+ return
+ }
+ } else {
+ // Delete object
+ delete(cm.readonly.provider, k)
+ if err = pb.Delete(k[:]); err != nil {
+ return
+ }
+ }
+ }
// Rebuild dirty map
cm.dirty = newMetaIndex()
@@ -348,6 +432,7 @@ func (s *metaState) reloadProcedure() (_ func(*bolt.Tx) error) {
var (
ab = tx.Bucket(metaBucket[:]).Bucket(metaAccountIndexBucket)
cb = tx.Bucket(metaBucket[:]).Bucket(metaSQLChainIndexBucket)
+ pb = tx.Bucket(metaBucket[:]).Bucket(metaProviderIndexBucket)
)
if err = ab.ForEach(func(k, v []byte) (err error) {
ao := &accountObject{}
@@ -369,6 +454,16 @@ func (s *metaState) reloadProcedure() (_ func(*bolt.Tx) error) {
}); err != nil {
return
}
+ if err = pb.ForEach(func(k, v []byte) (err error) {
+ ao := &providerObject{}
+ if err = utils.DecodeMsgPack(v, &ao.Provider); err != nil {
+ return
+ }
+ s.readonly.provider[ao.ProviderProfile.Provider] = ao
+ return
+ }); err != nil {
+ return
+ }
return
}
}
@@ -388,7 +483,8 @@ func (s *metaState) increaseAccountStableBalance(k proto.AccountAddress, amount
)
if dst, ok = s.dirty.accounts[k]; !ok {
if src, ok = s.readonly.accounts[k]; !ok {
- return ErrAccountNotFound
+ err := errors.Wrap(ErrAccountNotFound, "increase stable balance fail")
+ return err
}
dst = &accountObject{}
deepcopier.Copy(&src.Account).To(&dst.Account)
@@ -485,7 +581,8 @@ func (s *metaState) increaseAccountCovenantBalance(k proto.AccountAddress, amoun
)
if dst, ok = s.dirty.accounts[k]; !ok {
if src, ok = s.readonly.accounts[k]; !ok {
- return ErrAccountNotFound
+ err := errors.Wrap(ErrAccountNotFound, "increase covenant balance fail")
+ return err
}
dst = &accountObject{}
deepcopier.Copy(&src.Account).To(&dst.Account)
@@ -635,6 +732,9 @@ func (s *metaState) nextNonce(addr proto.AccountAddress) (nonce pi.AccountNonce,
if o, loaded = s.dirty.accounts[addr]; !loaded {
if o, loaded = s.readonly.accounts[addr]; !loaded {
err = ErrAccountNotFound
+ log.WithFields(log.Fields{
+ "addr": addr.String(),
+ }).WithError(err).Error("unexpected error")
return
}
}
@@ -661,7 +761,7 @@ func (s *metaState) increaseNonce(addr proto.AccountAddress) (err error) {
return
}
-func (s *metaState) applyBilling(tx *types.Billing) (err error) {
+func (s *metaState) applyBilling(tx *pt.Billing) (err error) {
for i, v := range tx.Receivers {
// Create empty receiver account if not found
s.loadOrStoreAccountObject(*v, &accountObject{Account: pt.Account{Address: *v}})
@@ -676,14 +776,104 @@ func (s *metaState) applyBilling(tx *types.Billing) (err error) {
return
}
+func (s *metaState) updateProviderList(tx *pt.ProvideService) (err error) {
+ sender, err := crypto.PubKeyHash(tx.Signee)
+ if err != nil {
+ err = errors.Wrap(err, "updateProviderList failed")
+ return
+ }
+ pp := pt.ProviderProfile{
+ Provider: sender,
+ Space: tx.Space,
+ Memory: tx.Memory,
+ LoadAvgPerCPU: tx.LoadAvgPerCPU,
+ }
+ s.loadOrStoreProviderObject(sender, &providerObject{ProviderProfile: pp})
+ return
+}
+
+func (s *metaState) matchProvidersWithUser(tx *pt.CreateDatabase) (err error) {
+ sender, err := crypto.PubKeyHash(tx.Signee)
+ if err != nil {
+ err = errors.Wrapf(err, "match failed with real sender: %s, sender: %s",
+ sender.String(), tx.Owner.String())
+ return
+ }
+ for i := range tx.ResourceMeta.TargetMiners {
+ if _, loaded := s.loadProviderObject(tx.ResourceMeta.TargetMiners[i]); !loaded {
+ err = errors.Wrapf(ErrNoSuchMiner, "miner address: %s", tx.ResourceMeta.TargetMiners[i])
+ return
+ }
+ }
+ // generate new sqlchain id and address
+ addrAndNonce := fmt.Sprintf("%s%d", tx.Owner.String(), tx.Nonce)
+ rawID := hash.THashH([]byte(addrAndNonce))
+ dbID := proto.DatabaseID(rawID.String())
+ dbAddr, err := dbID.AccountAddress()
+ if err != nil {
+ err = errors.Wrapf(err, "unexpected error when convert dbid: %v", dbID)
+ return
+ }
+ // generate userinfo
+ users := make([]*pt.SQLChainUser, 1)
+ users[0] = &pt.SQLChainUser{
+ Address: sender,
+ Permission: pt.Admin,
+ }
+ // generate genesis block
+ gb, err := s.generateGenesisBlock(dbID, tx.ResourceMeta)
+ if err != nil {
+ log.WithFields(log.Fields{
+ "dbID": dbID,
+ "resourceMeta": tx.ResourceMeta,
+ }).WithError(err).Error("unexpected error")
+ return err
+ }
+ // create sqlchain
+ sp := &pt.SQLChainProfile{
+ ID: dbID,
+ Address: dbAddr,
+ Period: sqlchainPeriod,
+ GasPrice: sqlchainGasPrice,
+ TokenType: pt.Particle,
+ Owner: sender,
+ Users: users,
+ Genesis: gb,
+ }
+ if _, loaded := s.loadSQLChainObject(dbID); loaded {
+ err = errors.Wrapf(ErrDatabaseExists, "database exists: %s", dbID)
+ return
+ }
+ s.loadOrStoreSQLChainObject(dbID, &sqlchainObject{SQLChainProfile: *sp})
+ for _, miner := range tx.ResourceMeta.TargetMiners {
+ s.deleteProviderObject(miner)
+ }
+ return
+}
+
func (s *metaState) applyTransaction(tx pi.Transaction) (err error) {
switch t := tx.(type) {
case *pt.Transfer:
+ realSender, err := crypto.PubKeyHash(t.Signee)
+ if err != nil {
+ err = errors.Wrap(err, "applyTx failed")
+ return err
+ }
+ if realSender != t.Sender {
+ err = errors.Wrapf(ErrInvalidSender,
+ "applyTx failed: real sender %s, sender %s", realSender.String(), t.Sender.String())
+ // TODO(lambda): update test cases and return err
+ log.Debug(err)
+ }
err = s.transferAccountStableBalance(t.Sender, t.Receiver, t.Amount)
- case *types.Billing:
+ case *pt.Billing:
err = s.applyBilling(t)
case *pt.BaseAccount:
err = s.storeBaseAccount(t.Address, &accountObject{Account: t.Account})
+ case *pt.ProvideService:
+ err = s.updateProviderList(t)
+ case *pt.CreateDatabase:
+ err = s.matchProvidersWithUser(t)
case *pi.TransactionWrapper:
// call again using unwrapped transaction
err = s.applyTransaction(t.Unwrap())
@@ -780,3 +970,34 @@ func (s *metaState) pullTxs() (txs []pi.Transaction) {
}
return
}
+
+func (s *metaState) generateGenesisBlock(dbID proto.DatabaseID, resourceMeta pt.ResourceMeta) (genesisBlock *pt.Block, err error) {
+ // TODO(xq262144): following is stub code, real logic should be implemented in the future
+ emptyHash := hash.Hash{}
+
+ var privKey *asymmetric.PrivateKey
+ if privKey, err = kms.GetLocalPrivateKey(); err != nil {
+ return
+ }
+ var nodeID proto.NodeID
+ if nodeID, err = kms.GetLocalNodeID(); err != nil {
+ return
+ }
+
+ genesisBlock = &pt.Block{
+ SignedHeader: pt.SignedHeader{
+ Header: pt.Header{
+ Version: 0x01000000,
+ Producer: nodeID,
+ GenesisHash: emptyHash,
+ ParentHash: emptyHash,
+ Timestamp: time.Now().UTC(),
+ },
+ },
+ }
+
+ err = genesisBlock.PackAndSignBlock(privKey)
+
+ return
+}
+
diff --git a/blockproducer/metastate_test.go b/blockproducer/metastate_test.go
index 18932596c..d42f88812 100644
--- a/blockproducer/metastate_test.go
+++ b/blockproducer/metastate_test.go
@@ -17,6 +17,7 @@
package blockproducer
import (
+ "github.com/pkg/errors"
"math"
"os"
"path"
@@ -66,6 +67,9 @@ func TestMetaState(t *testing.T) {
if _, err = meta.CreateBucket(metaSQLChainIndexBucket); err != nil {
return
}
+ if _, err = meta.CreateBucket(metaProviderIndexBucket); err != nil {
+ return
+ }
if txbk, err = meta.CreateBucket(metaTransactionBucket); err != nil {
return
}
@@ -307,7 +311,7 @@ func TestMetaState(t *testing.T) {
"The metaState should copy object when stable balance increased",
func() {
err = ms.increaseAccountStableBalance(addr3, 1)
- So(err, ShouldEqual, ErrAccountNotFound)
+ So(errors.Cause(err), ShouldEqual, ErrAccountNotFound)
err = ms.increaseAccountStableBalance(addr1, 1)
So(err, ShouldBeNil)
},
@@ -325,7 +329,7 @@ func TestMetaState(t *testing.T) {
"The metaState should copy object when covenant balance increased",
func() {
err = ms.increaseAccountCovenantBalance(addr3, 1)
- So(err, ShouldEqual, ErrAccountNotFound)
+ So(errors.Cause(err), ShouldEqual, ErrAccountNotFound)
err = ms.increaseAccountCovenantBalance(addr1, 1)
So(err, ShouldBeNil)
},
diff --git a/blockproducer/rpc.go b/blockproducer/rpc.go
index 7abf5e6ca..1d5f9dcab 100644
--- a/blockproducer/rpc.go
+++ b/blockproducer/rpc.go
@@ -104,6 +104,37 @@ type AddTxResp struct {
proto.Envelope
}
+// SubReq defines a request of the Sub RPC method.
+type SubReq struct {
+ proto.Envelope
+ Topic string
+ Callback string
+}
+
+// SubResp defines a response of the Sub RPC method.
+type SubResp struct {
+ proto.Envelope
+ Result string
+}
+
+// OrderMakerReq defines a request of the order maker in database market.
+type OrderMakerReq struct {
+ proto.Envelope
+
+}
+
+// OrderTakerReq defines a request of the order taker in database market.
+type OrderTakerReq struct {
+ proto.Envelope
+ DBMeta pt.ResourceMeta
+}
+
+// OrderTakerResp defines a response of the order taker in database market.
+type OrderTakerResp struct {
+ proto.Envelope
+ databaseID proto.DatabaseID
+}
+
// QueryAccountStableBalanceReq defines a request of the QueryAccountStableBalance RPC method.
type QueryAccountStableBalanceReq struct {
proto.Envelope
@@ -216,3 +247,10 @@ func (s *ChainRPCService) QueryAccountCovenantBalance(
resp.Balance, resp.OK = s.chain.ms.loadAccountCovenantBalance(req.Addr)
return
}
+
+// Sub is the RPC method to subscribe some event.
+func (s *ChainRPCService) Sub(req *SubReq, resp *SubResp) (err error) {
+ return s.chain.bs.Subscribe(req.Topic, func(request interface{}, response interface{}) {
+ s.chain.cl.CallNode(req.NodeID.ToNodeID(), req.Callback, request, response)
+ })
+}
diff --git a/proto/nodeinfo.go b/proto/nodeinfo.go
index a4822549d..d342c24d9 100644
--- a/proto/nodeinfo.go
+++ b/proto/nodeinfo.go
@@ -30,47 +30,54 @@ import (
//go:generate hsp
var (
- // NewNodeIDDifficulty is exposed for easy testing
+ // NewNodeIDDifficulty is exposed for easy testing.
NewNodeIDDifficulty = 40
- // NewNodeIDDifficultyTimeout is exposed for easy testing
+ // NewNodeIDDifficultyTimeout is exposed for easy testing.
NewNodeIDDifficultyTimeout = 60 * time.Second
)
const (
- // NodeIDLen is the NodeID length
+ // NodeIDLen is the NodeID length.
NodeIDLen = 2 * hash.HashSize
)
// RawNodeID is node name, will be generated from Hash(nodePublicKey)
-// RawNodeID length should be 32 bytes normally
+// RawNodeID length should be 32 bytes normally.
type RawNodeID struct {
hash.Hash
}
-// NodeID is the Hex of RawNodeID
+// NodeID is the Hex of RawNodeID.
type NodeID string
-// AccountAddress is wallet address, will be generated from Hash(nodePublicKey)
+// AccountAddress is wallet address, will be generated from Hash(nodePublicKey).
type AccountAddress hash.Hash
-// NodeKey is node key on consistent hash ring, generate from Hash(NodeID)
+// NodeKey is node key on consistent hash ring, generate from Hash(NodeID).
type NodeKey RawNodeID
-// MarshalHash marshals for hash
+// DatabaseID converts AccountAddress to DatabaseID.
+func (z *AccountAddress) DatabaseID() (d DatabaseID) {
+ d = DatabaseID(z.String())
+ return
+}
+
+// MarshalHash marshals for hash.
func (z *AccountAddress) MarshalHash() (o []byte, err error) {
return (*hash.Hash)(z).MarshalHash()
}
-// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
+// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message.
func (z *AccountAddress) Msgsize() (s int) {
return hsp.BytesPrefixSize + hash.HashSize
}
+// String is a string variable.
func (z *AccountAddress) String() string {
return (*hash.Hash)(z).String()
}
-// Less return true if k is less than y
+// Less return true if k is less than y.
func (k *NodeKey) Less(y *NodeKey) bool {
for idx, val := range k.Hash {
if val == y.Hash[idx] {
@@ -81,7 +88,7 @@ func (k *NodeKey) Less(y *NodeKey) bool {
return false
}
-// Node is all node info struct
+// Node is all node info struct.
type Node struct {
ID NodeID `yaml:"ID"`
Role ServerRole `yaml:"Role"`
@@ -90,12 +97,12 @@ type Node struct {
Nonce mine.Uint256 `yaml:"Nonce"`
}
-// NewNode just return a new node struct
+// NewNode just return a new node struct.
func NewNode() *Node {
return &Node{}
}
-// Difficulty returns NodeID difficulty, returns -1 on length mismatch or any error
+// Difficulty returns NodeID difficulty, returns -1 on length mismatch or any error.
func (id *NodeID) Difficulty() (difficulty int) {
if id == nil {
return -1
@@ -110,7 +117,7 @@ func (id *NodeID) Difficulty() (difficulty int) {
return idHash.Difficulty()
}
-// ToRawNodeID converts NodeID to RawNodeID
+// ToRawNodeID converts NodeID to RawNodeID.
func (id *NodeID) ToRawNodeID() *RawNodeID {
idHash, err := hash.NewHashFromStr(string(*id))
if err != nil {
@@ -125,12 +132,12 @@ func (id *NodeID) IsEmpty() bool {
return id == nil || "" == string(*id)
}
-// IsEqual returns if two node id is equal
+// IsEqual returns if two node id is equal.
func (id *NodeID) IsEqual(target *NodeID) bool {
return strings.Compare(string(*id), string(*target)) == 0
}
-// MarshalBinary does the serialization
+// MarshalBinary does the serialization.
func (id *NodeID) MarshalBinary() (keyBytes []byte, err error) {
if id == nil {
return []byte{}, nil
@@ -139,7 +146,7 @@ func (id *NodeID) MarshalBinary() (keyBytes []byte, err error) {
return h[:], err
}
-// UnmarshalBinary does the deserialization
+// UnmarshalBinary does the deserialization.
func (id *NodeID) UnmarshalBinary(keyBytes []byte) (err error) {
// for backward compatible
if len(keyBytes) == 64 {
@@ -155,8 +162,8 @@ func (id *NodeID) UnmarshalBinary(keyBytes []byte) (err error) {
return
}
-// InitNodeCryptoInfo generate Node asymmetric key pair and generate Node.NonceInfo
-// Node.ID = Node.NonceInfo.Hash
+// InitNodeCryptoInfo generate Node asymmetric key pair and generate Node.NonceInfo.
+// Node.ID = Node.NonceInfo.Hash.
func (node *Node) InitNodeCryptoInfo(timeThreshold time.Duration) (err error) {
_, node.PublicKey, err = asymmetric.GenSecp256k1KeyPair()
if err != nil {
@@ -170,7 +177,7 @@ func (node *Node) InitNodeCryptoInfo(timeThreshold time.Duration) (err error) {
return
}
-// ToNodeID converts RawNodeID to NodeID
+// ToNodeID converts RawNodeID to NodeID.
func (id *RawNodeID) ToNodeID() NodeID {
if id == nil {
return NodeID("")
@@ -178,7 +185,7 @@ func (id *RawNodeID) ToNodeID() NodeID {
return NodeID(id.String())
}
-// AddrAndGas records each node's address, node id and gas that node receives
+// AddrAndGas records each node's address, node id and gas that node receives.
type AddrAndGas struct {
AccountAddress AccountAddress
RawNodeID RawNodeID
@@ -195,12 +202,13 @@ const (
Leader
// Follower is a server that follow the leader log commits.
Follower
- // Miner is a server that run sql database
+ // Miner is a server that run sql database.
Miner
- // Client is a client that send sql query to database
+ // Client is a client that send sql query to database>
Client
)
+// String is a string variable of ServerRole.
func (s ServerRole) String() string {
switch s {
case Leader:
@@ -254,10 +262,10 @@ func parseServerRole(roleStr string) (role ServerRole, err error) {
return Unknown, nil
}
-// ServerRoles is []ServerRole
+// ServerRoles is []ServerRole.
type ServerRoles []ServerRole
-// Contains returns if given role is in the ServerRoles
+// Contains returns if given role is in the ServerRoles>
func (ss *ServerRoles) Contains(role ServerRole) bool {
for _, s := range *ss {
if s == role {
diff --git a/proto/nodeinfo_test.go b/proto/nodeinfo_test.go
index b0ac900ab..cb372910b 100644
--- a/proto/nodeinfo_test.go
+++ b/proto/nodeinfo_test.go
@@ -26,6 +26,25 @@ import (
"gopkg.in/yaml.v2"
)
+func TestAccountAddress_DatabaseID(t *testing.T) {
+ target := []string{
+ "1224a1e9f72eb00d08afa4030dc642edefb6e3249aafe20cf1a5f9d46d0c0bbe",
+ "5b0b8fd3b0700bd0858f3d61ff0a1b621dbbeb2013a3aab5df2885dc10ccf6ce",
+ "b90f502d8aa95573cdc3c50ea1552aa1c163b567980e2555fe84cfd1d5e78765",
+ }
+
+ Convey("DatabaseID Convert", t, func() {
+ for i := range target {
+ dbid := DatabaseID(target[i])
+ a, err := dbid.AccountAddress()
+ So(err, ShouldBeNil)
+ d := a.DatabaseID()
+ So(d, ShouldEqual, dbid)
+ So(string(d), ShouldEqual, target[i])
+ }
+ })
+}
+
func TestNode_InitNodeCryptoInfo(t *testing.T) {
Convey("InitNodeCryptoInfo", t, func() {
node := NewNode()
diff --git a/proto/proto.go b/proto/proto.go
index 2f5a812f8..311eaf68c 100644
--- a/proto/proto.go
+++ b/proto/proto.go
@@ -18,6 +18,8 @@
package proto
import (
+ "github.com/CovenantSQL/CovenantSQL/crypto/hash"
+ "github.com/pkg/errors"
"time"
)
@@ -142,3 +144,14 @@ func (e *Envelope) SetNodeID(nodeID *RawNodeID) {
// DatabaseID is database name, will be generated from UUID
type DatabaseID string
+
+// AccountAddress converts DatabaseID to AccountAddress.
+func (d *DatabaseID) AccountAddress() (a AccountAddress, err error) {
+ h, err := hash.NewHashFromStr(string(*d))
+ if err != nil {
+ err = errors.Wrap(err, "fail to convert string to hash")
+ return
+ }
+ a = AccountAddress(*h)
+ return
+}
diff --git a/proto/proto_test.go b/proto/proto_test.go
index 82428d995..f14aa5645 100644
--- a/proto/proto_test.go
+++ b/proto/proto_test.go
@@ -43,3 +43,23 @@ func TestEnvelope_GetSet(t *testing.T) {
So(env.GetVersion(), ShouldEqual, "0.0.1")
})
}
+
+func TestDatabaseID_AccountAddress(t *testing.T) {
+ target := []string{
+ "1224a1e9f72eb00d08afa4030dc642edefb6e3249aafe20cf1a5f9d46d0c0bbe",
+ "5b0b8fd3b0700bd0858f3d61ff0a1b621dbbeb2013a3aab5df2885dc10ccf6ce",
+ "b90f502d8aa95573cdc3c50ea1552aa1c163b567980e2555fe84cfd1d5e78765",
+ }
+
+ Convey("AccountAddress convert", t, func() {
+ for i := range target {
+ dbid := DatabaseID(target[i])
+ h, err := hash.NewHashFromStr(target[i])
+ So(err, ShouldBeNil)
+ a, err := dbid.AccountAddress()
+ So(err, ShouldBeNil)
+ So(h[:], ShouldResemble, a[:])
+ }
+
+ })
+}
diff --git a/route/acl.go b/route/acl.go
index b4b23905c..c369c42e1 100644
--- a/route/acl.go
+++ b/route/acl.go
@@ -142,7 +142,7 @@ const (
ObserverRPCName = "OBS"
)
-// String returns the RemoteFunc string
+// String returns the RemoteFunc string.
func (s RemoteFunc) String() string {
switch s {
case DHTPing:
@@ -215,7 +215,7 @@ func (s RemoteFunc) String() string {
return "Unknown"
}
-// IsPermitted returns if the node is permitted to call the RPC func
+// IsPermitted returns if the node is permitted to call the RPC func.
func IsPermitted(callerEnvelope *proto.Envelope, funcName RemoteFunc) (ok bool) {
callerETLSNodeID := callerEnvelope.GetNodeID()
// strict anonymous ETLS only used for Ping
diff --git a/types/account.go b/types/account.go
index 4ab28630f..f3ec5951e 100644
--- a/types/account.go
+++ b/types/account.go
@@ -93,9 +93,20 @@ type SQLChainProfile struct {
TokenType TokenType
Owner proto.AccountAddress
+ // first miner in the list is leader
Miners []*MinerInfo
Users []*SQLChainUser
+
+ Genesis *Block
+}
+
+// ProviderProfile defines a provider list.
+type ProviderProfile struct {
+ Provider proto.AccountAddress
+ Space uint64 // reserved storage space in bytes
+ Memory uint64 // reserved memory in bytes
+ LoadAvgPerCPU uint64 // max loadAvg15 per CPU
}
// Account store its balance, and other mate data.
diff --git a/types/account_gen.go b/types/account_gen.go
index ea8c2f440..e1bb53cb6 100644
--- a/types/account_gen.go
+++ b/types/account_gen.go
@@ -69,18 +69,54 @@ func (z *MinerInfo) Msgsize() (s int) {
return
}
+// MarshalHash marshals for hash
+func (z *ProviderProfile) MarshalHash() (o []byte, err error) {
+ var b []byte
+ o = hsp.Require(b, z.Msgsize())
+ // map header, size 4
+ o = append(o, 0x84, 0x84)
+ if oTemp, err := z.Provider.MarshalHash(); err != nil {
+ return nil, err
+ } else {
+ o = hsp.AppendBytes(o, oTemp)
+ }
+ o = append(o, 0x84)
+ o = hsp.AppendUint64(o, z.Space)
+ o = append(o, 0x84)
+ o = hsp.AppendUint64(o, z.Memory)
+ o = append(o, 0x84)
+ o = hsp.AppendUint64(o, z.LoadAvgPerCPU)
+ return
+}
+
+// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
+func (z *ProviderProfile) Msgsize() (s int) {
+ s = 1 + 9 + z.Provider.Msgsize() + 6 + hsp.Uint64Size + 7 + hsp.Uint64Size + 14 + hsp.Uint64Size
+ return
+}
+
// MarshalHash marshals for hash
func (z *SQLChainProfile) MarshalHash() (o []byte, err error) {
var b []byte
o = hsp.Require(b, z.Msgsize())
- // map header, size 8
- o = append(o, 0x88, 0x88)
+ // map header, size 9
+ o = append(o, 0x89, 0x89)
+ if z.Genesis == nil {
+ o = hsp.AppendNil(o)
+ } else {
+ if oTemp, err := z.Genesis.MarshalHash(); err != nil {
+ return nil, err
+ } else {
+ o = hsp.AppendBytes(o, oTemp)
+ }
+ }
+ o = append(o, 0x89)
if oTemp, err := z.TokenType.MarshalHash(); err != nil {
return nil, err
} else {
o = hsp.AppendBytes(o, oTemp)
}
- o = append(o, 0x88)
+ o = append(o, 0x89)
o = hsp.AppendArrayHeader(o, uint32(len(z.Miners)))
for za0001 := range z.Miners {
if z.Miners[za0001] == nil {
@@ -93,7 +129,7 @@ func (z *SQLChainProfile) MarshalHash() (o []byte, err error) {
}
}
}
- o = append(o, 0x88)
+ o = append(o, 0x89)
o = hsp.AppendArrayHeader(o, uint32(len(z.Users)))
for za0002 := range z.Users {
if z.Users[za0002] == nil {
@@ -106,34 +142,40 @@ func (z *SQLChainProfile) MarshalHash() (o []byte, err error) {
}
}
}
- o = append(o, 0x88)
+ o = append(o, 0x89)
if oTemp, err := z.Owner.MarshalHash(); err != nil {
return nil, err
} else {
o = hsp.AppendBytes(o, oTemp)
}
- o = append(o, 0x88)
+ o = append(o, 0x89)
if oTemp, err := z.Address.MarshalHash(); err != nil {
return nil, err
} else {
o = hsp.AppendBytes(o, oTemp)
}
- o = append(o, 0x88)
+ o = append(o, 0x89)
if oTemp, err := z.ID.MarshalHash(); err != nil {
return nil, err
} else {
o = hsp.AppendBytes(o, oTemp)
}
- o = append(o, 0x88)
- o = hsp.AppendUint64(o, z.Period)
- o = append(o, 0x88)
+ o = append(o, 0x89)
o = hsp.AppendUint64(o, z.GasPrice)
+ o = append(o, 0x89)
+ o = hsp.AppendUint64(o, z.Period)
return
}
// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (z *SQLChainProfile) Msgsize() (s int) {
- s = 1 + 10 + z.TokenType.Msgsize() + 7 + hsp.ArrayHeaderSize
+ s = 1 + 8
+ if z.Genesis == nil {
+ s += hsp.NilSize
+ } else {
+ s += z.Genesis.Msgsize()
+ }
+ s += 10 + z.TokenType.Msgsize() + 7 + hsp.ArrayHeaderSize
for za0001 := range z.Miners {
if z.Miners[za0001] == nil {
s += hsp.NilSize
@@ -149,7 +191,7 @@ func (z *SQLChainProfile) Msgsize() (s int) {
s += z.Users[za0002].Msgsize()
}
}
- s += 6 + z.Owner.Msgsize() + 8 + z.Address.Msgsize() + 3 + z.ID.Msgsize() + 7 + hsp.Uint64Size + 9 + hsp.Uint64Size
+ s += 6 + z.Owner.Msgsize() + 8 + z.Address.Msgsize() + 3 + z.ID.Msgsize() + 9 + hsp.Uint64Size + 7 + hsp.Uint64Size
return
}
diff --git a/types/account_gen_test.go b/types/account_gen_test.go
index 97169a4ae..57a2feee1 100644
--- a/types/account_gen_test.go
+++ b/types/account_gen_test.go
@@ -83,6 +83,43 @@ func BenchmarkAppendMsgMinerInfo(b *testing.B) {
}
}
+func TestMarshalHashProviderProfile(t *testing.T) {
+ v := ProviderProfile{}
+ binary.Read(rand.Reader, binary.BigEndian, &v)
+ bts1, err := v.MarshalHash()
+ if err != nil {
+ t.Fatal(err)
+ }
+ bts2, err := v.MarshalHash()
+ if err != nil {
+ t.Fatal(err)
+ }
+ if !bytes.Equal(bts1, bts2) {
+ t.Fatal("hash not stable")
+ }
+}
+
+func BenchmarkMarshalHashProviderProfile(b *testing.B) {
+ v := ProviderProfile{}
+ b.ReportAllocs()
+ b.ResetTimer()
+ for i := 0; i < b.N; i++ {
+ v.MarshalHash()
+ }
+}
+
+func BenchmarkAppendMsgProviderProfile(b *testing.B) {
+ v := ProviderProfile{}
+ bts := make([]byte, 0, v.Msgsize())
+ bts, _ = v.MarshalHash()
+ b.SetBytes(int64(len(bts)))
+ b.ReportAllocs()
+ b.ResetTimer()
+ for i := 0; i < b.N; i++ {
+ bts, _ = v.MarshalHash()
+ }
+}
+
func TestMarshalHashSQLChainProfile(t *testing.T) {
v := SQLChainProfile{}
binary.Read(rand.Reader, binary.BigEndian, &v)
diff --git a/types/createdb.go b/types/createdb.go
index 33749fcb9..8932655e6 100644
--- a/types/createdb.go
+++ b/types/createdb.go
@@ -28,6 +28,7 @@ import (
// CreateDatabaseHeader defines the database creation transaction header.
type CreateDatabaseHeader struct {
Owner proto.AccountAddress
+ ResourceMeta ResourceMeta
Nonce pi.AccountNonce
}
diff --git a/types/createdb_gen.go b/types/createdb_gen.go
index 2d4f51a21..1728df429 100644
--- a/types/createdb_gen.go
+++ b/types/createdb_gen.go
@@ -11,14 +11,20 @@ func (z *CreateDatabase) MarshalHash() (o []byte, err error) {
var b []byte
o = hsp.Require(b, z.Msgsize())
// map header, size 3
- // map header, size 2
- o = append(o, 0x83, 0x83, 0x82, 0x82)
+ // map header, size 3
+ o = append(o, 0x83, 0x83, 0x83, 0x83)
if oTemp, err := z.CreateDatabaseHeader.Owner.MarshalHash(); err != nil {
return nil, err
} else {
o = hsp.AppendBytes(o, oTemp)
}
- o = append(o, 0x82)
+ o = append(o, 0x83)
+ if oTemp, err := z.CreateDatabaseHeader.ResourceMeta.MarshalHash(); err != nil {
+ return nil, err
+ } else {
+ o = hsp.AppendBytes(o, oTemp)
+ }
+ o = append(o, 0x83)
if oTemp, err := z.CreateDatabaseHeader.Nonce.MarshalHash(); err != nil {
return nil, err
} else {
@@ -41,7 +47,7 @@ func (z *CreateDatabase) MarshalHash() (o []byte, err error) {
// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (z *CreateDatabase) Msgsize() (s int) {
- s = 1 + 21 + 1 + 6 + z.CreateDatabaseHeader.Owner.Msgsize() + 6 + z.CreateDatabaseHeader.Nonce.Msgsize() + 21 + z.TransactionTypeMixin.Msgsize() + 28 + z.DefaultHashSignVerifierImpl.Msgsize()
+ s = 1 + 21 + 1 + 6 + z.CreateDatabaseHeader.Owner.Msgsize() + 13 + z.CreateDatabaseHeader.ResourceMeta.Msgsize() + 6 + z.CreateDatabaseHeader.Nonce.Msgsize() + 21 + z.TransactionTypeMixin.Msgsize() + 28 + z.DefaultHashSignVerifierImpl.Msgsize()
return
}
@@ -49,14 +55,20 @@ func (z *CreateDatabase) Msgsize() (s int) {
func (z *CreateDatabaseHeader) MarshalHash() (o []byte, err error) {
var b []byte
o = hsp.Require(b, z.Msgsize())
- // map header, size 2
- o = append(o, 0x82, 0x82)
+ // map header, size 3
+ o = append(o, 0x83, 0x83)
+ if oTemp, err := z.ResourceMeta.MarshalHash(); err != nil {
+ return nil, err
+ } else {
+ o = hsp.AppendBytes(o, oTemp)
+ }
+ o = append(o, 0x83)
if oTemp, err := z.Nonce.MarshalHash(); err != nil {
return nil, err
} else {
o = hsp.AppendBytes(o, oTemp)
}
- o = append(o, 0x82)
+ o = append(o, 0x83)
if oTemp, err := z.Owner.MarshalHash(); err != nil {
return nil, err
} else {
@@ -67,6 +79,6 @@ func (z *CreateDatabaseHeader) MarshalHash() (o []byte, err error) {
// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (z *CreateDatabaseHeader) Msgsize() (s int) {
- s = 1 + 6 + z.Nonce.Msgsize() + 6 + z.Owner.Msgsize()
+ s = 1 + 13 + z.ResourceMeta.Msgsize() + 6 + z.Nonce.Msgsize() + 6 + z.Owner.Msgsize()
return
}
diff --git a/types/init_service_type.go b/types/init_service_type.go
index 9d5462788..0581bc7a3 100644
--- a/types/init_service_type.go
+++ b/types/init_service_type.go
@@ -31,6 +31,7 @@ type InitService struct {
// ResourceMeta defines single database resource meta.
type ResourceMeta struct {
+ TargetMiners []proto.AccountAddress // designated miners
Node uint16 // reserved node count
Space uint64 // reserved storage space in bytes
Memory uint64 // reserved memory in bytes
diff --git a/types/init_service_type_gen.go b/types/init_service_type_gen.go
index f859b2e88..27008aa2e 100644
--- a/types/init_service_type_gen.go
+++ b/types/init_service_type_gen.go
@@ -76,21 +76,34 @@ func (z *InitServiceResponseHeader) Msgsize() (s int) {
func (z *ResourceMeta) MarshalHash() (o []byte, err error) {
var b []byte
o = hsp.Require(b, z.Msgsize())
- // map header, size 4
- o = append(o, 0x84, 0x84)
+ // map header, size 5
+ o = append(o, 0x85, 0x85)
+ o = hsp.AppendArrayHeader(o, uint32(len(z.TargetMiners)))
+ for za0001 := range z.TargetMiners {
+ if oTemp, err := z.TargetMiners[za0001].MarshalHash(); err != nil {
+ return nil, err
+ } else {
+ o = hsp.AppendBytes(o, oTemp)
+ }
+ }
+ o = append(o, 0x85)
o = hsp.AppendUint16(o, z.Node)
- o = append(o, 0x84)
+ o = append(o, 0x85)
o = hsp.AppendUint64(o, z.Space)
- o = append(o, 0x84)
+ o = append(o, 0x85)
o = hsp.AppendUint64(o, z.Memory)
- o = append(o, 0x84)
+ o = append(o, 0x85)
o = hsp.AppendUint64(o, z.LoadAvgPerCPU)
return
}
// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (z *ResourceMeta) Msgsize() (s int) {
- s = 1 + 5 + hsp.Uint16Size + 6 + hsp.Uint64Size + 7 + hsp.Uint64Size + 14 + hsp.Uint64Size
+ s = 1 + 13 + hsp.ArrayHeaderSize
+ for za0001 := range z.TargetMiners {
+ s += z.TargetMiners[za0001].Msgsize()
+ }
+ s += 5 + hsp.Uint16Size + 6 + hsp.Uint64Size + 7 + hsp.Uint64Size + 14 + hsp.Uint64Size
return
}
diff --git a/types/provideservice.go b/types/provideservice.go
new file mode 100644
index 000000000..80fc72019
--- /dev/null
+++ b/types/provideservice.go
@@ -0,0 +1,74 @@
+/*
+ * Copyright 2018 The CovenantSQL Authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package types
+
+import (
+ "github.com/CovenantSQL/CovenantSQL/blockproducer/interfaces"
+ "github.com/CovenantSQL/CovenantSQL/crypto/asymmetric"
+ "github.com/CovenantSQL/CovenantSQL/crypto/verifier"
+ "github.com/CovenantSQL/CovenantSQL/proto"
+)
+
+//go:generate hsp
+
+// ProvideServiceHeader define the miner providing service transaction header.
+type ProvideServiceHeader struct {
+ Contract proto.AccountAddress
+ Space uint64 // reserved storage space in bytes
+ Memory uint64 // reserved memory in bytes
+ LoadAvgPerCPU uint64 // max loadAvg15 per CPU
+ Nonce interfaces.AccountNonce
+}
+
+// GetAccountAddress implements interfaces/Transaction.GetAccountAddress.
+func (h *ProvideServiceHeader) GetAccountAddress() proto.AccountAddress {
+ return h.Contract
+}
+
+// GetAccountNonce implements interfaces/Transaction.GetAccountNonce.
+func (h *ProvideServiceHeader) GetAccountNonce() interfaces.AccountNonce {
+ return h.Nonce
+}
+
+// ProvideService define the miner providing service transaction.
+type ProvideService struct {
+ ProvideServiceHeader
+ interfaces.TransactionTypeMixin
+ verifier.DefaultHashSignVerifierImpl
+}
+
+// NewProvideService returns new instance.
+func NewProvideService(h *ProvideServiceHeader) *ProvideService {
+ return &ProvideService{
+ ProvideServiceHeader: *h,
+ TransactionTypeMixin: *interfaces.NewTransactionTypeMixin(interfaces.TransactionTypeProvideService),
+ }
+}
+
+// Sign implements interfaces/Transaction.Sign.
+func (ps *ProvideService) Sign(signer *asymmetric.PrivateKey) (err error) {
+ return ps.DefaultHashSignVerifierImpl.Sign(&ps.ProvideServiceHeader, signer)
+}
+
+// Verify implements interfaces/Transaction.Verify.
+func (ps *ProvideService) Verify() error {
+ return ps.DefaultHashSignVerifierImpl.Verify(&ps.ProvideServiceHeader)
+}
+
+func init() {
+ interfaces.RegisterTransaction(interfaces.TransactionTypeCreateDatabase, (*ProvideService)(nil))
+}
diff --git a/types/provideservice_gen.go b/types/provideservice_gen.go
new file mode 100644
index 000000000..3a885022f
--- /dev/null
+++ b/types/provideservice_gen.go
@@ -0,0 +1,71 @@
+package types
+
+// Code generated by github.com/CovenantSQL/HashStablePack DO NOT EDIT.
+
+import (
+ hsp "github.com/CovenantSQL/HashStablePack/marshalhash"
+)
+
+// MarshalHash marshals for hash
+func (z *ProvideService) MarshalHash() (o []byte, err error) {
+ var b []byte
+ o = hsp.Require(b, z.Msgsize())
+ // map header, size 3
+ o = append(o, 0x83, 0x83)
+ if oTemp, err := z.ProvideServiceHeader.MarshalHash(); err != nil {
+ return nil, err
+ } else {
+ o = hsp.AppendBytes(o, oTemp)
+ }
+ o = append(o, 0x83)
+ if oTemp, err := z.TransactionTypeMixin.MarshalHash(); err != nil {
+ return nil, err
+ } else {
+ o = hsp.AppendBytes(o, oTemp)
+ }
+ o = append(o, 0x83)
+ if oTemp, err := z.DefaultHashSignVerifierImpl.MarshalHash(); err != nil {
+ return nil, err
+ } else {
+ o = hsp.AppendBytes(o, oTemp)
+ }
+ return
+}
+
+// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
+func (z *ProvideService) Msgsize() (s int) {
+ s = 1 + 21 + z.ProvideServiceHeader.Msgsize() + 21 + z.TransactionTypeMixin.Msgsize() + 28 + z.DefaultHashSignVerifierImpl.Msgsize()
+ return
+}
+
+// MarshalHash marshals for hash
+func (z *ProvideServiceHeader) MarshalHash() (o []byte, err error) {
+ var b []byte
+ o = hsp.Require(b, z.Msgsize())
+ // map header, size 5
+ o = append(o, 0x85, 0x85)
+ if oTemp, err := z.Nonce.MarshalHash(); err != nil {
+ return nil, err
+ } else {
+ o = hsp.AppendBytes(o, oTemp)
+ }
+ o = append(o, 0x85)
+ if oTemp, err := z.Contract.MarshalHash(); err != nil {
+ return nil, err
+ } else {
+ o = hsp.AppendBytes(o, oTemp)
+ }
+ o = append(o, 0x85)
+ o = hsp.AppendUint64(o, z.Space)
+ o = append(o, 0x85)
+ o = hsp.AppendUint64(o, z.Memory)
+ o = append(o, 0x85)
+ o = hsp.AppendUint64(o, z.LoadAvgPerCPU)
+ return
+}
+
+// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
+func (z *ProvideServiceHeader) Msgsize() (s int) {
+ s = 1 + 6 + z.Nonce.Msgsize() + 9 + z.Contract.Msgsize() + 6 + hsp.Uint64Size + 7 + hsp.Uint64Size + 14 + hsp.Uint64Size
+ return
+}
diff --git a/types/provideservice_gen_test.go b/types/provideservice_gen_test.go
new file mode 100644
index 000000000..a71240c45
--- /dev/null
+++ b/types/provideservice_gen_test.go
@@ -0,0 +1,84 @@
+package types
+
+// Code generated by github.com/CovenantSQL/HashStablePack DO NOT EDIT.
+
+import (
+ "bytes"
+ "crypto/rand"
+ "encoding/binary"
+ "testing"
+)
+
+func TestMarshalHashProvideService(t *testing.T) {
+ v := ProvideService{}
+ binary.Read(rand.Reader, binary.BigEndian, &v)
+ bts1, err := v.MarshalHash()
+ if err != nil {
+ t.Fatal(err)
+ }
+ bts2, err := v.MarshalHash()
+ if err != nil {
+ t.Fatal(err)
+ }
+ if !bytes.Equal(bts1, bts2) {
+ t.Fatal("hash not stable")
+ }
+}
+
+func BenchmarkMarshalHashProvideService(b *testing.B) {
+ v := ProvideService{}
+ b.ReportAllocs()
+ b.ResetTimer()
+ for i := 0; i < b.N; i++ {
+ v.MarshalHash()
+ }
+}
+
+func BenchmarkAppendMsgProvideService(b *testing.B) {
+ v := ProvideService{}
+ bts := make([]byte, 0, v.Msgsize())
+ bts, _ = v.MarshalHash()
+ b.SetBytes(int64(len(bts)))
+ b.ReportAllocs()
+ b.ResetTimer()
+ for i := 0; i < b.N; i++ {
+ bts, _ = v.MarshalHash()
+ }
+}
+
+func TestMarshalHashProvideServiceHeader(t *testing.T) {
+ v := ProvideServiceHeader{}
+ binary.Read(rand.Reader, binary.BigEndian, &v)
+ bts1, err := v.MarshalHash()
+ if err != nil {
+ t.Fatal(err)
+ }
+ bts2, err := v.MarshalHash()
+ if err != nil {
+ t.Fatal(err)
+ }
+ if !bytes.Equal(bts1, bts2) {
+ t.Fatal("hash not stable")
+ }
+}
+
+func BenchmarkMarshalHashProvideServiceHeader(b *testing.B) {
+ v := ProvideServiceHeader{}
+ b.ReportAllocs()
+ b.ResetTimer()
+ for i := 0; i < b.N; i++ {
+ v.MarshalHash()
+ }
+}
+
+func BenchmarkAppendMsgProvideServiceHeader(b *testing.B) {
+ v := ProvideServiceHeader{}
+ bts := make([]byte, 0, v.Msgsize())
+ bts, _ = v.MarshalHash()
+ b.SetBytes(int64(len(bts)))
+ b.ReportAllocs()
+ b.ResetTimer()
+ for i := 0; i < b.N; i++ {
+ bts, _ = v.MarshalHash()
+ }
+}
diff --git a/types/request_type_gen.go b/types/request_type_gen.go
index 2e3990e57..709e66bb9 100644
--- a/types/request_type_gen.go
+++ b/types/request_type_gen.go
@@ -102,11 +102,15 @@ func (z *Request) MarshalHash() (o []byte, err error) {
var b []byte
o = hsp.Require(b, z.Msgsize())
// map header, size 3
- o = append(o, 0x83, 0x83)
- if oTemp, err := z.Payload.MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
+ // map header, size 1
+ o = append(o, 0x83, 0x83, 0x81, 0x81)
+ o = hsp.AppendArrayHeader(o, uint32(len(z.Payload.Queries)))
+ for za0001 := range z.Payload.Queries {
+ if oTemp, err := z.Payload.Queries[za0001].MarshalHash(); err != nil {
+ return nil, err
+ } else {
+ o = hsp.AppendBytes(o, oTemp)
+ }
}
// map header, size 2
o = append(o, 0x83, 0x82, 0x82)
@@ -132,7 +136,11 @@ func (z *Request) MarshalHash() (o []byte, err error) {
// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (z *Request) Msgsize() (s int) {
- s = 1 + 8 + z.Payload.Msgsize() + 7 + 1 + 14 + z.Header.RequestHeader.Msgsize() + 28 + z.Header.DefaultHashSignVerifierImpl.Msgsize() + 9 + z.Envelope.Msgsize()
+ s = 1 + 8 + 1 + 8 + hsp.ArrayHeaderSize
+ for za0001 := range z.Payload.Queries {
+ s += z.Payload.Queries[za0001].Msgsize()
+ }
+ s += 7 + 1 + 14 + z.Header.RequestHeader.Msgsize() + 28 + z.Header.DefaultHashSignVerifierImpl.Msgsize() + 9 + z.Envelope.Msgsize()
return
}
@@ -186,20 +194,10 @@ func (z *RequestPayload) MarshalHash() (o []byte, err error) {
o = append(o, 0x81, 0x81)
o = hsp.AppendArrayHeader(o, uint32(len(z.Queries)))
for za0001 := range z.Queries {
- // map header, size 2
- o = append(o, 0x82, 0x82)
- o = hsp.AppendString(o, z.Queries[za0001].Pattern)
- o = append(o, 0x82)
- o = hsp.AppendArrayHeader(o, uint32(len(z.Queries[za0001].Args)))
- for za0002 := range z.Queries[za0001].Args {
- // map header, size 2
- o = append(o, 0x82, 0x82)
- o = hsp.AppendString(o, z.Queries[za0001].Args[za0002].Name)
- o = append(o, 0x82)
- o, err = hsp.AppendIntf(o, z.Queries[za0001].Args[za0002].Value)
- if err != nil {
- return
- }
+ if oTemp, err := z.Queries[za0001].MarshalHash(); err != nil {
+ return nil, err
+ } else {
+ o = hsp.AppendBytes(o, oTemp)
}
}
return
@@ -209,10 +207,7 @@ func (z *RequestPayload) MarshalHash() (o []byte, err error) {
func (z *RequestPayload) Msgsize() (s int) {
s = 1 + 8 + hsp.ArrayHeaderSize
for za0001 := range z.Queries {
- s += 1 + 8 + hsp.StringPrefixSize + len(z.Queries[za0001].Pattern) + 5 + hsp.ArrayHeaderSize
- for za0002 := range z.Queries[za0001].Args {
- s += 1 + 5 + hsp.StringPrefixSize + len(z.Queries[za0001].Args[za0002].Name) + 6 + hsp.GuessSize(z.Queries[za0001].Args[za0002].Value)
- }
+ s += z.Queries[za0001].Msgsize()
}
return
}
From 9d6c393bcaa1e051bfe6f9127f56d8c80204eb4b Mon Sep 17 00:00:00 2001
From: zeqing-guo
Date: Tue, 27 Nov 2018 01:34:38 +0800
Subject: [PATCH 020/278] Add update permission
---
blockproducer/chain.go | 2 +-
blockproducer/errors.go | 4 ++
blockproducer/interfaces/transaction.go | 6 +-
blockproducer/metaindex.go | 2 +-
blockproducer/metastate.go | 94 ++++++++++++++++++++-----
blockproducer/metastate_test.go | 16 ++---
blockproducer/rpc.go | 1 -
proto/proto.go | 3 +-
types/account.go | 10 +--
types/ack_type_gen.go | 22 +++++-
types/createdb.go | 4 +-
types/init_service_type.go | 12 ++--
types/provideservice.go | 4 +-
types/request_type_gen.go | 23 ++++--
types/updatepermission.go | 73 +++++++++++++++++++
types/updatepermission_gen.go | 77 ++++++++++++++++++++
types/updatepermission_gen_test.go | 84 ++++++++++++++++++++++
17 files changed, 383 insertions(+), 54 deletions(-)
create mode 100644 types/updatepermission.go
create mode 100644 types/updatepermission_gen.go
create mode 100644 types/updatepermission_gen_test.go
diff --git a/blockproducer/chain.go b/blockproducer/chain.go
index c0d21e3d1..b8444b5ec 100644
--- a/blockproducer/chain.go
+++ b/blockproducer/chain.go
@@ -47,7 +47,7 @@ var (
metaTransactionBucket = []byte("covenantsql-tx-index-bucket")
metaAccountIndexBucket = []byte("covenantsql-account-index-bucket")
metaSQLChainIndexBucket = []byte("covenantsql-sqlchain-index-bucket")
- metaProviderIndexBucket = []byte("covenantsql-provider-index-bucket")
+ metaProviderIndexBucket = []byte("covenantsql-provider-index-bucket")
gasPrice uint32 = 1
accountAddress proto.AccountAddress
txEvent = "/BP/Tx"
diff --git a/blockproducer/errors.go b/blockproducer/errors.go
index 06bc1ef74..9388596f2 100644
--- a/blockproducer/errors.go
+++ b/blockproducer/errors.go
@@ -78,4 +78,8 @@ var (
ErrInvalidSender = errors.New("invalid sender")
// ErrNoSuchMiner indicates that this miner does not exist or register.
ErrNoSuchMiner = errors.New("no such miner")
+ // ErrAccountPermissionDeny indicates that the sender does not own admin permission to the sqlchain.
+ ErrAccountPermissionDeny = errors.New("account permission deny")
+ // ErrInvalidPermission indicates that the permission is invalid.
+ ErrInvalidPermission = errors.New("invalid permission")
)
diff --git a/blockproducer/interfaces/transaction.go b/blockproducer/interfaces/transaction.go
index 48d3817c8..ee41b7346 100644
--- a/blockproducer/interfaces/transaction.go
+++ b/blockproducer/interfaces/transaction.go
@@ -63,8 +63,10 @@ const (
TransactionTypeBaseAccount
// TransactionTypeCreateDatabase defines database creation transaction type.
TransactionTypeCreateDatabase
- // TransactionTypeProvideService define miner providing database service type.
+ // TransactionTypeProvideService defines miner providing database service type.
TransactionTypeProvideService
+ // TransactionUpdatePermission defines admin user grant/revoke permission type.
+ TransactionUpdatePermission
// TransactionTypeNumber defines transaction types number.
TransactionTypeNumber
)
@@ -91,6 +93,8 @@ func (t TransactionType) String() string {
return "CreateDatabase"
case TransactionTypeProvideService:
return "ProvideService"
+ case TransactionUpdatePermission:
+ return "UpdatePermission"
default:
return "Unknown"
}
diff --git a/blockproducer/metaindex.go b/blockproducer/metaindex.go
index e2854665a..dbabfbcf1 100644
--- a/blockproducer/metaindex.go
+++ b/blockproducer/metaindex.go
@@ -64,7 +64,7 @@ type metaIndex struct {
sync.RWMutex
accounts map[proto.AccountAddress]*accountObject
databases map[proto.DatabaseID]*sqlchainObject
- provider map[proto.AccountAddress]*providerObject
+ provider map[proto.AccountAddress]*providerObject
}
func newMetaIndex() *metaIndex {
diff --git a/blockproducer/metastate.go b/blockproducer/metastate.go
index 6c73c7e6e..f29feec10 100644
--- a/blockproducer/metastate.go
+++ b/blockproducer/metastate.go
@@ -19,25 +19,25 @@ package blockproducer
import (
"bytes"
"fmt"
- "github.com/CovenantSQL/CovenantSQL/crypto"
- "github.com/CovenantSQL/CovenantSQL/crypto/asymmetric"
- "github.com/CovenantSQL/CovenantSQL/crypto/hash"
- "github.com/CovenantSQL/CovenantSQL/crypto/kms"
- "github.com/pkg/errors"
"sync"
"time"
pi "github.com/CovenantSQL/CovenantSQL/blockproducer/interfaces"
+ "github.com/CovenantSQL/CovenantSQL/crypto"
+ "github.com/CovenantSQL/CovenantSQL/crypto/asymmetric"
+ "github.com/CovenantSQL/CovenantSQL/crypto/hash"
+ "github.com/CovenantSQL/CovenantSQL/crypto/kms"
"github.com/CovenantSQL/CovenantSQL/proto"
pt "github.com/CovenantSQL/CovenantSQL/types"
"github.com/CovenantSQL/CovenantSQL/utils"
"github.com/CovenantSQL/CovenantSQL/utils/log"
"github.com/coreos/bbolt"
+ "github.com/pkg/errors"
"github.com/ulule/deepcopier"
)
var (
- sqlchainPeriod uint64 = 60 * 24 * 30
+ sqlchainPeriod uint64 = 60 * 24 * 30
sqlchainGasPrice uint64 = 10
)
@@ -783,9 +783,9 @@ func (s *metaState) updateProviderList(tx *pt.ProvideService) (err error) {
return
}
pp := pt.ProviderProfile{
- Provider: sender,
- Space: tx.Space,
- Memory: tx.Memory,
+ Provider: sender,
+ Space: tx.Space,
+ Memory: tx.Memory,
LoadAvgPerCPU: tx.LoadAvgPerCPU,
}
s.loadOrStoreProviderObject(sender, &providerObject{ProviderProfile: pp})
@@ -817,28 +817,28 @@ func (s *metaState) matchProvidersWithUser(tx *pt.CreateDatabase) (err error) {
// generate userinfo
users := make([]*pt.SQLChainUser, 1)
users[0] = &pt.SQLChainUser{
- Address: sender,
+ Address: sender,
Permission: pt.Admin,
}
// generate genesis block
gb, err := s.generateGenesisBlock(dbID, tx.ResourceMeta)
if err != nil {
log.WithFields(log.Fields{
- "dbID": dbID,
+ "dbID": dbID,
"resourceMeta": tx.ResourceMeta,
}).WithError(err).Error("unexpected error")
return err
}
// create sqlchain
sp := &pt.SQLChainProfile{
- ID: dbID,
- Address: dbAddr,
- Period: sqlchainPeriod,
- GasPrice: sqlchainGasPrice,
+ ID: dbID,
+ Address: dbAddr,
+ Period: sqlchainPeriod,
+ GasPrice: sqlchainGasPrice,
TokenType: pt.Particle,
- Owner: sender,
- Users: users,
- Genesis: gb,
+ Owner: sender,
+ Users: users,
+ Genesis: gb,
}
if _, loaded := s.loadSQLChainObject(dbID); loaded {
err = errors.Wrapf(ErrDatabaseExists, "database exists: %s", dbID)
@@ -851,6 +851,61 @@ func (s *metaState) matchProvidersWithUser(tx *pt.CreateDatabase) (err error) {
return
}
+func (s *metaState) updatePermission(tx *pt.UpdatePermission) (err error) {
+ sender, err := crypto.PubKeyHash(tx.Signee)
+ if err != nil {
+ log.WithFields(log.Fields{
+ "tx": tx.Hash().String(),
+ }).WithError(err).Error("unexpected err")
+ return
+ }
+ so, loaded := s.loadSQLChainObject(tx.TargetSQLChain.DatabaseID())
+ if !loaded {
+ log.WithFields(log.Fields{
+ "dbID": tx.TargetSQLChain.DatabaseID(),
+ }).WithError(ErrDatabaseNotFound).Error("unexpected error")
+ return ErrDatabaseNotFound
+ }
+ if tx.Permission >= pt.NumberOfUserPermission {
+ log.WithFields(log.Fields{
+ "permission": tx.Permission,
+ "dbID": tx.TargetSQLChain.DatabaseID(),
+ }).WithError(ErrInvalidPermission).Error("unexpected error")
+ return ErrInvalidPermission
+ }
+
+ // check whether sender is admin and find targetUser
+ isAdmin := false
+ targetUserIndex := -1
+ for i, u := range so.Users {
+ isAdmin = isAdmin || (sender == u.Address && u.Permission == pt.Admin)
+ if tx.TargetUser == u.Address {
+ targetUserIndex = i
+ }
+ }
+
+ if !isAdmin {
+ log.WithFields(log.Fields{
+ "sender": sender,
+ "dbID": tx.TargetSQLChain,
+ }).WithError(ErrAccountPermissionDeny).Error("unexpected error")
+ return ErrAccountPermissionDeny
+ }
+
+ // update targetUser's permission
+ if targetUserIndex == -1 {
+ u := pt.SQLChainUser{
+ Address: tx.TargetUser,
+ Permission: tx.Permission,
+ Status: pt.Normal,
+ }
+ so.Users = append(so.Users, &u)
+ } else {
+ so.Users[targetUserIndex].Permission = tx.Permission
+ }
+ return
+}
+
func (s *metaState) applyTransaction(tx pi.Transaction) (err error) {
switch t := tx.(type) {
case *pt.Transfer:
@@ -874,6 +929,8 @@ func (s *metaState) applyTransaction(tx pi.Transaction) (err error) {
err = s.updateProviderList(t)
case *pt.CreateDatabase:
err = s.matchProvidersWithUser(t)
+ case *pt.UpdatePermission:
+ err = s.updatePermission(t)
case *pi.TransactionWrapper:
// call again using unwrapped transaction
err = s.applyTransaction(t.Unwrap())
@@ -1000,4 +1057,3 @@ func (s *metaState) generateGenesisBlock(dbID proto.DatabaseID, resourceMeta pt.
return
}
-
diff --git a/blockproducer/metastate_test.go b/blockproducer/metastate_test.go
index d42f88812..e92b8ffa8 100644
--- a/blockproducer/metastate_test.go
+++ b/blockproducer/metastate_test.go
@@ -17,7 +17,6 @@
package blockproducer
import (
- "github.com/pkg/errors"
"math"
"os"
"path"
@@ -28,6 +27,7 @@ import (
"github.com/CovenantSQL/CovenantSQL/types"
pt "github.com/CovenantSQL/CovenantSQL/types"
"github.com/coreos/bbolt"
+ "github.com/pkg/errors"
. "github.com/smartystreets/goconvey/convey"
)
@@ -108,7 +108,7 @@ func TestMetaState(t *testing.T) {
So(err, ShouldEqual, ErrDatabaseNotFound)
err = ms.deleteSQLChainUser(dbid1, addr1)
So(err, ShouldEqual, ErrDatabaseNotFound)
- err = ms.alterSQLChainUser(dbid1, addr1, pt.ReadWrite)
+ err = ms.alterSQLChainUser(dbid1, addr1, pt.Write)
So(err, ShouldEqual, ErrDatabaseNotFound)
})
Convey("When new account and database objects are stored", func() {
@@ -172,9 +172,9 @@ func TestMetaState(t *testing.T) {
So(err, ShouldEqual, ErrDatabaseExists)
})
Convey("When new SQLChain users are added", func() {
- err = ms.addSQLChainUser(dbid3, addr2, pt.ReadWrite)
+ err = ms.addSQLChainUser(dbid3, addr2, pt.Write)
So(err, ShouldBeNil)
- err = ms.addSQLChainUser(dbid3, addr2, pt.ReadWrite)
+ err = ms.addSQLChainUser(dbid3, addr2, pt.Write)
So(err, ShouldEqual, ErrDatabaseUserExists)
Convey("The metaState object should be ok to delete user", func() {
err = ms.deleteSQLChainUser(dbid3, addr2)
@@ -185,7 +185,7 @@ func TestMetaState(t *testing.T) {
Convey("The metaState object should be ok to alter user", func() {
err = ms.alterSQLChainUser(dbid3, addr2, pt.Read)
So(err, ShouldBeNil)
- err = ms.alterSQLChainUser(dbid3, addr2, pt.ReadWrite)
+ err = ms.alterSQLChainUser(dbid3, addr2, pt.Write)
So(err, ShouldBeNil)
})
Convey("When metaState change is committed", func() {
@@ -200,7 +200,7 @@ func TestMetaState(t *testing.T) {
Convey("The metaState object should be ok to alter user", func() {
err = ms.alterSQLChainUser(dbid3, addr2, pt.Read)
So(err, ShouldBeNil)
- err = ms.alterSQLChainUser(dbid3, addr2, pt.ReadWrite)
+ err = ms.alterSQLChainUser(dbid3, addr2, pt.Write)
So(err, ShouldBeNil)
})
})
@@ -209,9 +209,9 @@ func TestMetaState(t *testing.T) {
err = db.Update(ms.commitProcedure())
So(err, ShouldBeNil)
Convey("The metaState object should be ok to add users for database", func() {
- err = ms.addSQLChainUser(dbid3, addr2, pt.ReadWrite)
+ err = ms.addSQLChainUser(dbid3, addr2, pt.Write)
So(err, ShouldBeNil)
- err = ms.addSQLChainUser(dbid3, addr2, pt.ReadWrite)
+ err = ms.addSQLChainUser(dbid3, addr2, pt.Write)
So(err, ShouldEqual, ErrDatabaseUserExists)
})
Convey("The metaState object should report database exists", func() {
diff --git a/blockproducer/rpc.go b/blockproducer/rpc.go
index 1d5f9dcab..e3d9444aa 100644
--- a/blockproducer/rpc.go
+++ b/blockproducer/rpc.go
@@ -120,7 +120,6 @@ type SubResp struct {
// OrderMakerReq defines a request of the order maker in database market.
type OrderMakerReq struct {
proto.Envelope
-
}
// OrderTakerReq defines a request of the order taker in database market.
diff --git a/proto/proto.go b/proto/proto.go
index 311eaf68c..d77fc61cf 100644
--- a/proto/proto.go
+++ b/proto/proto.go
@@ -18,9 +18,10 @@
package proto
import (
+ "time"
+
"github.com/CovenantSQL/CovenantSQL/crypto/hash"
"github.com/pkg/errors"
- "time"
)
//go:generate hsp
diff --git a/types/account.go b/types/account.go
index f3ec5951e..4ec3e8084 100644
--- a/types/account.go
+++ b/types/account.go
@@ -43,8 +43,8 @@ const (
Admin UserPermission = iota
// Read defines the reader user permission.
Read
- // ReadWrite defines the reader/writer user permission.
- ReadWrite
+ // Write defines the reader/writer user permission.
+ Write
// NumberOfUserPermission defines the user permission number.
NumberOfUserPermission
)
@@ -61,6 +61,8 @@ const (
Arrears
// Arbitration defines the user/miner is in an arbitration.
Arbitration
+ // NumberOfStatus defines the number of status.
+ NumberOfStatus
)
// SQLChainUser defines a SQLChain user.
@@ -92,7 +94,7 @@ type SQLChainProfile struct {
TokenType TokenType
- Owner proto.AccountAddress
+ Owner proto.AccountAddress
// first miner in the list is leader
Miners []*MinerInfo
@@ -103,7 +105,7 @@ type SQLChainProfile struct {
// ProviderProfile defines a provider list.
type ProviderProfile struct {
- Provider proto.AccountAddress
+ Provider proto.AccountAddress
Space uint64 // reserved storage space in bytes
Memory uint64 // reserved memory in bytes
LoadAvgPerCPU uint64 // max loadAvg15 per CPU
diff --git a/types/ack_type_gen.go b/types/ack_type_gen.go
index 90fc7a814..d9c850bad 100644
--- a/types/ack_type_gen.go
+++ b/types/ack_type_gen.go
@@ -11,8 +11,24 @@ func (z *Ack) MarshalHash() (o []byte, err error) {
var b []byte
o = hsp.Require(b, z.Msgsize())
// map header, size 2
- o = append(o, 0x82, 0x82)
- if oTemp, err := z.Header.MarshalHash(); err != nil {
+ // map header, size 2
+ // map header, size 3
+ o = append(o, 0x82, 0x82, 0x82, 0x82, 0x83, 0x83)
+ if oTemp, err := z.Header.AckHeader.Response.MarshalHash(); err != nil {
+ return nil, err
+ } else {
+ o = hsp.AppendBytes(o, oTemp)
+ }
+ o = append(o, 0x83)
+ if oTemp, err := z.Header.AckHeader.NodeID.MarshalHash(); err != nil {
+ return nil, err
+ } else {
+ o = hsp.AppendBytes(o, oTemp)
+ }
+ o = append(o, 0x83)
+ o = hsp.AppendTime(o, z.Header.AckHeader.Timestamp)
+ o = append(o, 0x82)
+ if oTemp, err := z.Header.DefaultHashSignVerifierImpl.MarshalHash(); err != nil {
return nil, err
} else {
o = hsp.AppendBytes(o, oTemp)
@@ -28,7 +44,7 @@ func (z *Ack) MarshalHash() (o []byte, err error) {
// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (z *Ack) Msgsize() (s int) {
- s = 1 + 7 + z.Header.Msgsize() + 9 + z.Envelope.Msgsize()
+ s = 1 + 7 + 1 + 10 + 1 + 9 + z.Header.AckHeader.Response.Msgsize() + 7 + z.Header.AckHeader.NodeID.Msgsize() + 10 + hsp.TimeSize + 28 + z.Header.DefaultHashSignVerifierImpl.Msgsize() + 9 + z.Envelope.Msgsize()
return
}
diff --git a/types/createdb.go b/types/createdb.go
index 8932655e6..9033b5664 100644
--- a/types/createdb.go
+++ b/types/createdb.go
@@ -27,9 +27,9 @@ import (
// CreateDatabaseHeader defines the database creation transaction header.
type CreateDatabaseHeader struct {
- Owner proto.AccountAddress
+ Owner proto.AccountAddress
ResourceMeta ResourceMeta
- Nonce pi.AccountNonce
+ Nonce pi.AccountNonce
}
// GetAccountAddress implements interfaces/Transaction.GetAccountAddress.
diff --git a/types/init_service_type.go b/types/init_service_type.go
index 0581bc7a3..acaf5eb7d 100644
--- a/types/init_service_type.go
+++ b/types/init_service_type.go
@@ -31,12 +31,12 @@ type InitService struct {
// ResourceMeta defines single database resource meta.
type ResourceMeta struct {
- TargetMiners []proto.AccountAddress // designated miners
- Node uint16 // reserved node count
- Space uint64 // reserved storage space in bytes
- Memory uint64 // reserved memory in bytes
- LoadAvgPerCPU uint64 // max loadAvg15 per CPU
- EncryptionKey string `hspack:"-"` // encryption key for database instance
+ TargetMiners []proto.AccountAddress // designated miners
+ Node uint16 // reserved node count
+ Space uint64 // reserved storage space in bytes
+ Memory uint64 // reserved memory in bytes
+ LoadAvgPerCPU uint64 // max loadAvg15 per CPU
+ EncryptionKey string `hspack:"-"` // encryption key for database instance
}
// ServiceInstance defines single instance to be initialized.
diff --git a/types/provideservice.go b/types/provideservice.go
index 80fc72019..8d98c90a1 100644
--- a/types/provideservice.go
+++ b/types/provideservice.go
@@ -27,11 +27,11 @@ import (
// ProvideServiceHeader define the miner providing service transaction header.
type ProvideServiceHeader struct {
- Contract proto.AccountAddress
+ Contract proto.AccountAddress
Space uint64 // reserved storage space in bytes
Memory uint64 // reserved memory in bytes
LoadAvgPerCPU uint64 // max loadAvg15 per CPU
- Nonce interfaces.AccountNonce
+ Nonce interfaces.AccountNonce
}
// GetAccountAddress implements interfaces/Transaction.GetAccountAddress.
diff --git a/types/request_type_gen.go b/types/request_type_gen.go
index 709e66bb9..7033d7aa6 100644
--- a/types/request_type_gen.go
+++ b/types/request_type_gen.go
@@ -106,10 +106,20 @@ func (z *Request) MarshalHash() (o []byte, err error) {
o = append(o, 0x83, 0x83, 0x81, 0x81)
o = hsp.AppendArrayHeader(o, uint32(len(z.Payload.Queries)))
for za0001 := range z.Payload.Queries {
- if oTemp, err := z.Payload.Queries[za0001].MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
+ // map header, size 2
+ o = append(o, 0x82, 0x82)
+ o = hsp.AppendString(o, z.Payload.Queries[za0001].Pattern)
+ o = append(o, 0x82)
+ o = hsp.AppendArrayHeader(o, uint32(len(z.Payload.Queries[za0001].Args)))
+ for za0002 := range z.Payload.Queries[za0001].Args {
+ // map header, size 2
+ o = append(o, 0x82, 0x82)
+ o = hsp.AppendString(o, z.Payload.Queries[za0001].Args[za0002].Name)
+ o = append(o, 0x82)
+ o, err = hsp.AppendIntf(o, z.Payload.Queries[za0001].Args[za0002].Value)
+ if err != nil {
+ return
+ }
}
}
// map header, size 2
@@ -138,7 +148,10 @@ func (z *Request) MarshalHash() (o []byte, err error) {
func (z *Request) Msgsize() (s int) {
s = 1 + 8 + 1 + 8 + hsp.ArrayHeaderSize
for za0001 := range z.Payload.Queries {
- s += z.Payload.Queries[za0001].Msgsize()
+ s += 1 + 8 + hsp.StringPrefixSize + len(z.Payload.Queries[za0001].Pattern) + 5 + hsp.ArrayHeaderSize
+ for za0002 := range z.Payload.Queries[za0001].Args {
+ s += 1 + 5 + hsp.StringPrefixSize + len(z.Payload.Queries[za0001].Args[za0002].Name) + 6 + hsp.GuessSize(z.Payload.Queries[za0001].Args[za0002].Value)
+ }
}
s += 7 + 1 + 14 + z.Header.RequestHeader.Msgsize() + 28 + z.Header.DefaultHashSignVerifierImpl.Msgsize() + 9 + z.Envelope.Msgsize()
return
diff --git a/types/updatepermission.go b/types/updatepermission.go
new file mode 100644
index 000000000..c28867034
--- /dev/null
+++ b/types/updatepermission.go
@@ -0,0 +1,73 @@
+/*
+ * Copyright 2018 The CovenantSQL Authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package types
+
+import (
+ "github.com/CovenantSQL/CovenantSQL/blockproducer/interfaces"
+ "github.com/CovenantSQL/CovenantSQL/crypto/asymmetric"
+ "github.com/CovenantSQL/CovenantSQL/crypto/verifier"
+ "github.com/CovenantSQL/CovenantSQL/proto"
+)
+
+//go:generate hsp
+
+// UpdatePermissionHeader defines the updating sqlchain permission transaction header.
+type UpdatePermissionHeader struct {
+ TargetSQLChain proto.AccountAddress
+ TargetUser proto.AccountAddress
+ Permission UserPermission
+ Nonce interfaces.AccountNonce
+}
+
+// GetAccountAddress implements interfaces/Transaction.GetAccountAddress.
+func (u *UpdatePermissionHeader) GetAccountAddress() proto.AccountAddress {
+ return u.TargetSQLChain
+}
+
+// GetAccountNonce implements interfaces/Transaction.GetAccountNonce.
+func (u *UpdatePermissionHeader) GetAccountNonce() interfaces.AccountNonce {
+ return u.Nonce
+}
+
+// UpdatePermission defines the updating sqlchain permission transaction.
+type UpdatePermission struct {
+ UpdatePermissionHeader
+ interfaces.TransactionTypeMixin
+ verifier.DefaultHashSignVerifierImpl
+}
+
+// NewUpdatePermission returns new instance.
+func NewUpdatePermission(header *UpdatePermissionHeader) *UpdatePermission {
+ return &UpdatePermission{
+ UpdatePermissionHeader: *header,
+ TransactionTypeMixin: *interfaces.NewTransactionTypeMixin(interfaces.TransactionUpdatePermission),
+ }
+}
+
+// Sign implements interfaces/Transaction.Sign.
+func (up *UpdatePermission) Sign(signer *asymmetric.PrivateKey) (err error) {
+ return up.DefaultHashSignVerifierImpl.Sign(&up.UpdatePermissionHeader, signer)
+}
+
+// Verify implements interfaces/Transaction.Verify.
+func (up *UpdatePermission) Verify() error {
+ return up.DefaultHashSignVerifierImpl.Verify(&up.UpdatePermissionHeader)
+}
+
+func init() {
+ interfaces.RegisterTransaction(interfaces.TransactionUpdatePermission, (*UpdatePermission)(nil))
+}
diff --git a/types/updatepermission_gen.go b/types/updatepermission_gen.go
new file mode 100644
index 000000000..443bfaa78
--- /dev/null
+++ b/types/updatepermission_gen.go
@@ -0,0 +1,77 @@
+package types
+
+// Code generated by github.com/CovenantSQL/HashStablePack DO NOT EDIT.
+
+import (
+ hsp "github.com/CovenantSQL/HashStablePack/marshalhash"
+)
+
+// MarshalHash marshals for hash
+func (z *UpdatePermission) MarshalHash() (o []byte, err error) {
+ var b []byte
+ o = hsp.Require(b, z.Msgsize())
+ // map header, size 3
+ o = append(o, 0x83, 0x83)
+ if oTemp, err := z.UpdatePermissionHeader.MarshalHash(); err != nil {
+ return nil, err
+ } else {
+ o = hsp.AppendBytes(o, oTemp)
+ }
+ o = append(o, 0x83)
+ if oTemp, err := z.TransactionTypeMixin.MarshalHash(); err != nil {
+ return nil, err
+ } else {
+ o = hsp.AppendBytes(o, oTemp)
+ }
+ o = append(o, 0x83)
+ if oTemp, err := z.DefaultHashSignVerifierImpl.MarshalHash(); err != nil {
+ return nil, err
+ } else {
+ o = hsp.AppendBytes(o, oTemp)
+ }
+ return
+}
+
+// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
+func (z *UpdatePermission) Msgsize() (s int) {
+ s = 1 + 23 + z.UpdatePermissionHeader.Msgsize() + 21 + z.TransactionTypeMixin.Msgsize() + 28 + z.DefaultHashSignVerifierImpl.Msgsize()
+ return
+}
+
+// MarshalHash marshals for hash
+func (z *UpdatePermissionHeader) MarshalHash() (o []byte, err error) {
+ var b []byte
+ o = hsp.Require(b, z.Msgsize())
+ // map header, size 4
+ o = append(o, 0x84, 0x84)
+ if oTemp, err := z.Permission.MarshalHash(); err != nil {
+ return nil, err
+ } else {
+ o = hsp.AppendBytes(o, oTemp)
+ }
+ o = append(o, 0x84)
+ if oTemp, err := z.Nonce.MarshalHash(); err != nil {
+ return nil, err
+ } else {
+ o = hsp.AppendBytes(o, oTemp)
+ }
+ o = append(o, 0x84)
+ if oTemp, err := z.TargetSQLChain.MarshalHash(); err != nil {
+ return nil, err
+ } else {
+ o = hsp.AppendBytes(o, oTemp)
+ }
+ o = append(o, 0x84)
+ if oTemp, err := z.TargetUser.MarshalHash(); err != nil {
+ return nil, err
+ } else {
+ o = hsp.AppendBytes(o, oTemp)
+ }
+ return
+}
+
+// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
+func (z *UpdatePermissionHeader) Msgsize() (s int) {
+ s = 1 + 11 + z.Permission.Msgsize() + 6 + z.Nonce.Msgsize() + 15 + z.TargetSQLChain.Msgsize() + 11 + z.TargetUser.Msgsize()
+ return
+}
diff --git a/types/updatepermission_gen_test.go b/types/updatepermission_gen_test.go
new file mode 100644
index 000000000..3c16ee611
--- /dev/null
+++ b/types/updatepermission_gen_test.go
@@ -0,0 +1,84 @@
+package types
+
+// Code generated by github.com/CovenantSQL/HashStablePack DO NOT EDIT.
+
+import (
+ "bytes"
+ "crypto/rand"
+ "encoding/binary"
+ "testing"
+)
+
+func TestMarshalHashUpdatePermission(t *testing.T) {
+ v := UpdatePermission{}
+ binary.Read(rand.Reader, binary.BigEndian, &v)
+ bts1, err := v.MarshalHash()
+ if err != nil {
+ t.Fatal(err)
+ }
+ bts2, err := v.MarshalHash()
+ if err != nil {
+ t.Fatal(err)
+ }
+ if !bytes.Equal(bts1, bts2) {
+ t.Fatal("hash not stable")
+ }
+}
+
+func BenchmarkMarshalHashUpdatePermission(b *testing.B) {
+ v := UpdatePermission{}
+ b.ReportAllocs()
+ b.ResetTimer()
+ for i := 0; i < b.N; i++ {
+ v.MarshalHash()
+ }
+}
+
+func BenchmarkAppendMsgUpdatePermission(b *testing.B) {
+ v := UpdatePermission{}
+ bts := make([]byte, 0, v.Msgsize())
+ bts, _ = v.MarshalHash()
+ b.SetBytes(int64(len(bts)))
+ b.ReportAllocs()
+ b.ResetTimer()
+ for i := 0; i < b.N; i++ {
+ bts, _ = v.MarshalHash()
+ }
+}
+
+func TestMarshalHashUpdatePermissionHeader(t *testing.T) {
+ v := UpdatePermissionHeader{}
+ binary.Read(rand.Reader, binary.BigEndian, &v)
+ bts1, err := v.MarshalHash()
+ if err != nil {
+ t.Fatal(err)
+ }
+ bts2, err := v.MarshalHash()
+ if err != nil {
+ t.Fatal(err)
+ }
+ if !bytes.Equal(bts1, bts2) {
+ t.Fatal("hash not stable")
+ }
+}
+
+func BenchmarkMarshalHashUpdatePermissionHeader(b *testing.B) {
+ v := UpdatePermissionHeader{}
+ b.ReportAllocs()
+ b.ResetTimer()
+ for i := 0; i < b.N; i++ {
+ v.MarshalHash()
+ }
+}
+
+func BenchmarkAppendMsgUpdatePermissionHeader(b *testing.B) {
+ v := UpdatePermissionHeader{}
+ bts := make([]byte, 0, v.Msgsize())
+ bts, _ = v.MarshalHash()
+ b.SetBytes(int64(len(bts)))
+ b.ReportAllocs()
+ b.ResetTimer()
+ for i := 0; i < b.N; i++ {
+ bts, _ = v.MarshalHash()
+ }
+}
From 8e46764ac65582b769027baaf451d46d24b02f07 Mon Sep 17 00:00:00 2001
From: zeqing-guo
Date: Wed, 28 Nov 2018 00:34:35 +0800
Subject: [PATCH 021/278] Add test case
---
blockproducer/errors.go | 4 +-
blockproducer/metaindex.go | 1 +
blockproducer/metastate.go | 56 +++++--
blockproducer/metastate_test.go | 267 +++++++++++++++++++++++++++++---
blockproducer/xxx_test.go | 2 +-
proto/proto.go | 9 ++
proto/proto_test.go | 33 ++++
types/account.go | 3 +-
types/ack_type_gen.go | 22 +--
types/createdb.go | 12 +-
types/createdb_test.go | 9 +-
types/provideservice.go | 13 +-
types/provideservice_gen.go | 20 ++-
types/updatepermission.go | 12 +-
14 files changed, 383 insertions(+), 80 deletions(-)
diff --git a/blockproducer/errors.go b/blockproducer/errors.go
index 9388596f2..4872d5569 100644
--- a/blockproducer/errors.go
+++ b/blockproducer/errors.go
@@ -64,7 +64,7 @@ var (
// ErrDatabaseUserExists indicates that the database user already exists.
ErrDatabaseUserExists = errors.New("database user already exists")
// ErrDatabaseCannotCreate indicates that database cannot be created.
- ErrDatabaseCannotCreate = errors.New("database cannot be created.")
+ ErrDatabaseCannotCreate = errors.New("database cannot be created")
// ErrInvalidAccountNonce indicates that a transaction has a invalid account nonce.
ErrInvalidAccountNonce = errors.New("invalid account nonce")
// ErrUnknownTransactionType indicates that a transaction has a unknown type and cannot be
@@ -82,4 +82,6 @@ var (
ErrAccountPermissionDeny = errors.New("account permission deny")
// ErrInvalidPermission indicates that the permission is invalid.
ErrInvalidPermission = errors.New("invalid permission")
+ // ErrMinerUserNotMatch indicates that the miner and user do not match.
+ ErrMinerUserNotMatch = errors.New("miner and user do not match")
)
diff --git a/blockproducer/metaindex.go b/blockproducer/metaindex.go
index dbabfbcf1..d69a3f219 100644
--- a/blockproducer/metaindex.go
+++ b/blockproducer/metaindex.go
@@ -71,6 +71,7 @@ func newMetaIndex() *metaIndex {
return &metaIndex{
accounts: make(map[proto.AccountAddress]*accountObject),
databases: make(map[proto.DatabaseID]*sqlchainObject),
+ provider: make(map[proto.AccountAddress]*providerObject),
}
}
diff --git a/blockproducer/metastate.go b/blockproducer/metastate.go
index f29feec10..ccab0c488 100644
--- a/blockproducer/metastate.go
+++ b/blockproducer/metastate.go
@@ -18,7 +18,6 @@ package blockproducer
import (
"bytes"
- "fmt"
"sync"
"time"
@@ -782,11 +781,16 @@ func (s *metaState) updateProviderList(tx *pt.ProvideService) (err error) {
err = errors.Wrap(err, "updateProviderList failed")
return
}
+ if sender != tx.Contract {
+ err = errors.Wrap(ErrInvalidSender, "updateProviderList failed")
+ return
+ }
pp := pt.ProviderProfile{
Provider: sender,
Space: tx.Space,
Memory: tx.Memory,
LoadAvgPerCPU: tx.LoadAvgPerCPU,
+ TargetUser: tx.TargetUser,
}
s.loadOrStoreProviderObject(sender, &providerObject{ProviderProfile: pp})
return
@@ -795,20 +799,39 @@ func (s *metaState) updateProviderList(tx *pt.ProvideService) (err error) {
func (s *metaState) matchProvidersWithUser(tx *pt.CreateDatabase) (err error) {
sender, err := crypto.PubKeyHash(tx.Signee)
if err != nil {
- err = errors.Wrapf(err, "match failed with real sender: %s, sender: %s",
+ err = errors.Wrap(err, "matchProviders failed")
+ return
+ }
+ if sender != tx.Owner {
+ err = errors.Wrapf(ErrInvalidSender, "match failed with real sender: %s, sender: %s",
sender.String(), tx.Owner.String())
return
}
for i := range tx.ResourceMeta.TargetMiners {
- if _, loaded := s.loadProviderObject(tx.ResourceMeta.TargetMiners[i]); !loaded {
- err = errors.Wrapf(ErrNoSuchMiner, "miner address: %s", tx.ResourceMeta.TargetMiners[i])
- return
+ if po, loaded := s.loadProviderObject(tx.ResourceMeta.TargetMiners[i]); !loaded {
+ log.WithFields(log.Fields{
+ "miner_addr": tx.ResourceMeta.TargetMiners[i].String(),
+ "user_addr": sender.String(),
+ }).Error(err)
+ err = ErrNoSuchMiner
+ break
+ } else {
+ if po.TargetUser != sender {
+ log.WithFields(log.Fields{
+ "miner_addr": tx.ResourceMeta.TargetMiners[i].String(),
+ "user_addr": sender.String(),
+ }).Error(ErrMinerUserNotMatch)
+ err = ErrMinerUserNotMatch
+ break
+ }
}
}
+ if err != nil {
+ return
+ }
+
// generate new sqlchain id and address
- addrAndNonce := fmt.Sprintf("%s%d", tx.Owner.String(), tx.Nonce)
- rawID := hash.THashH([]byte(addrAndNonce))
- dbID := proto.DatabaseID(rawID.String())
+ dbID := proto.FromAccountAndNonce(tx.Owner, uint32(tx.Nonce))
dbAddr, err := dbID.AccountAddress()
if err != nil {
err = errors.Wrapf(err, "unexpected error when convert dbid: %v", dbID)
@@ -821,7 +844,7 @@ func (s *metaState) matchProvidersWithUser(tx *pt.CreateDatabase) (err error) {
Permission: pt.Admin,
}
// generate genesis block
- gb, err := s.generateGenesisBlock(dbID, tx.ResourceMeta)
+ gb, err := s.generateGenesisBlock(*dbID, tx.ResourceMeta)
if err != nil {
log.WithFields(log.Fields{
"dbID": dbID,
@@ -831,7 +854,7 @@ func (s *metaState) matchProvidersWithUser(tx *pt.CreateDatabase) (err error) {
}
// create sqlchain
sp := &pt.SQLChainProfile{
- ID: dbID,
+ ID: *dbID,
Address: dbAddr,
Period: sqlchainPeriod,
GasPrice: sqlchainGasPrice,
@@ -840,11 +863,14 @@ func (s *metaState) matchProvidersWithUser(tx *pt.CreateDatabase) (err error) {
Users: users,
Genesis: gb,
}
- if _, loaded := s.loadSQLChainObject(dbID); loaded {
- err = errors.Wrapf(ErrDatabaseExists, "database exists: %s", dbID)
+ if _, loaded := s.loadSQLChainObject(*dbID); loaded {
+ err = errors.Wrapf(ErrDatabaseExists, "database exists: %s", string(*dbID))
return
}
- s.loadOrStoreSQLChainObject(dbID, &sqlchainObject{SQLChainProfile: *sp})
+ s.loadOrStoreAccountObject(dbAddr, &accountObject{
+ Account: pt.Account{Address: dbAddr},
+ })
+ s.loadOrStoreSQLChainObject(*dbID, &sqlchainObject{SQLChainProfile: *sp})
for _, miner := range tx.ResourceMeta.TargetMiners {
s.deleteProviderObject(miner)
}
@@ -859,6 +885,10 @@ func (s *metaState) updatePermission(tx *pt.UpdatePermission) (err error) {
}).WithError(err).Error("unexpected err")
return
}
+ if sender == tx.TargetUser {
+ err = errors.Wrap(ErrInvalidSender, "user cannot update its permission by itself")
+ return
+ }
so, loaded := s.loadSQLChainObject(tx.TargetSQLChain.DatabaseID())
if !loaded {
log.WithFields(log.Fields{
diff --git a/blockproducer/metastate_test.go b/blockproducer/metastate_test.go
index e92b8ffa8..3721abefa 100644
--- a/blockproducer/metastate_test.go
+++ b/blockproducer/metastate_test.go
@@ -20,10 +20,16 @@ import (
"math"
"os"
"path"
+ "sync"
"testing"
pi "github.com/CovenantSQL/CovenantSQL/blockproducer/interfaces"
+ "github.com/CovenantSQL/CovenantSQL/conf"
+ "github.com/CovenantSQL/CovenantSQL/crypto"
+ "github.com/CovenantSQL/CovenantSQL/crypto/asymmetric"
+ "github.com/CovenantSQL/CovenantSQL/crypto/kms"
"github.com/CovenantSQL/CovenantSQL/proto"
+ "github.com/CovenantSQL/CovenantSQL/route"
"github.com/CovenantSQL/CovenantSQL/types"
pt "github.com/CovenantSQL/CovenantSQL/types"
"github.com/coreos/bbolt"
@@ -34,21 +40,46 @@ import (
func TestMetaState(t *testing.T) {
Convey("Given a new metaState object and a persistence db instance", t, func() {
var (
- ao *accountObject
- co *sqlchainObject
- bl uint64
- loaded bool
- addr1 = proto.AccountAddress{0x0, 0x0, 0x0, 0x1}
- addr2 = proto.AccountAddress{0x0, 0x0, 0x0, 0x2}
- addr3 = proto.AccountAddress{0x0, 0x0, 0x0, 0x3}
- dbid1 = proto.DatabaseID("db#1")
- dbid2 = proto.DatabaseID("db#2")
- dbid3 = proto.DatabaseID("db#3")
- ms = newMetaState()
- fl = path.Join(testDataDir, t.Name())
- db, err = bolt.Open(fl, 0600, nil)
+ ao *accountObject
+ co *sqlchainObject
+ po *providerObject
+ bl uint64
+ loaded bool
+ privKey1 *asymmetric.PrivateKey
+ privKey2 *asymmetric.PrivateKey
+ privKey3 *asymmetric.PrivateKey
+ privKey4 *asymmetric.PrivateKey
+ addr1 proto.AccountAddress
+ addr2 proto.AccountAddress
+ addr3 proto.AccountAddress
+ addr4 proto.AccountAddress
+ dbid1 = proto.DatabaseID("db#1")
+ dbid2 = proto.DatabaseID("db#2")
+ dbid3 = proto.DatabaseID("db#3")
+ ms = newMetaState()
+ fl = path.Join(testDataDir, t.Name())
+ db, err = bolt.Open(fl, 0600, nil)
)
So(err, ShouldBeNil)
+
+ // Create key pairs and addresses for test
+ privKey1, _, err = asymmetric.GenSecp256k1KeyPair()
+ So(err, ShouldBeNil)
+ privKey2, _, err = asymmetric.GenSecp256k1KeyPair()
+ So(err, ShouldBeNil)
+ privKey3, _, err = asymmetric.GenSecp256k1KeyPair()
+ So(err, ShouldBeNil)
+ privKey4, _, err = asymmetric.GenSecp256k1KeyPair()
+ So(err, ShouldBeNil)
+ addr1, err = crypto.PubKeyHash(privKey1.PubKey())
+ So(err, ShouldBeNil)
+ addr2, err = crypto.PubKeyHash(privKey2.PubKey())
+ So(err, ShouldBeNil)
+ addr3, err = crypto.PubKeyHash(privKey3.PubKey())
+ So(err, ShouldBeNil)
+ addr4, err = crypto.PubKeyHash(privKey4.PubKey())
+ So(err, ShouldBeNil)
+
Reset(func() {
// Clean database file after each pass
err = db.Close()
@@ -95,6 +126,11 @@ func TestMetaState(t *testing.T) {
So(co, ShouldBeNil)
So(loaded, ShouldBeFalse)
})
+ Convey("The provider state should be empty", func() {
+ po, loaded = ms.loadProviderObject(addr1)
+ So(po, ShouldBeNil)
+ So(loaded, ShouldBeFalse)
+ })
Convey("The nonce state should be empty", func() {
_, err = ms.nextNonce(addr1)
So(err, ShouldEqual, ErrAccountNotFound)
@@ -597,9 +633,9 @@ func TestMetaState(t *testing.T) {
},
)
)
- err = t1.Sign(testPrivKey)
+ err = t1.Sign(privKey1)
So(err, ShouldBeNil)
- err = t2.Sign(testPrivKey)
+ err = t2.Sign(privKey1)
So(err, ShouldBeNil)
err = db.Update(ms.applyTransactionProcedure(t0))
So(err, ShouldBeNil)
@@ -627,7 +663,7 @@ func TestMetaState(t *testing.T) {
Convey("The metaState should report error if tx fails verification", func() {
t1.Nonce = pi.AccountNonce(10)
- err = t1.Sign(testPrivKey)
+ err = t1.Sign(privKey1)
So(err, ShouldBeNil)
err = db.Update(ms.applyTransactionProcedure(t1))
So(err, ShouldEqual, ErrInvalidAccountNonce)
@@ -636,7 +672,7 @@ func TestMetaState(t *testing.T) {
So(t1.Nonce, ShouldEqual, ms.dirty.accounts[addr1].NextNonce)
err = db.Update(ms.applyTransactionProcedure(t1))
So(err, ShouldNotBeNil)
- err = t1.Sign(testPrivKey)
+ err = t1.Sign(privKey1)
So(err, ShouldBeNil)
err = db.Update(ms.applyTransactionProcedure(t1))
So(err, ShouldBeNil)
@@ -685,7 +721,7 @@ func TestMetaState(t *testing.T) {
"The partial commit procedure should not be appliable for modified tx",
func() {
t1.Nonce = pi.AccountNonce(10)
- err = t1.Sign(testPrivKey)
+ err = t1.Sign(privKey1)
So(err, ShouldBeNil)
err = db.Update(ms.partialCommitProcedure([]pi.Transaction{t0, t1, t2}))
So(err, ShouldEqual, ErrTransactionMismatch)
@@ -769,9 +805,16 @@ func TestMetaState(t *testing.T) {
),
}
)
+ txs[0].Sign(privKey1)
+ txs[1].Sign(privKey2)
+ txs[2].Sign(privKey1)
+ txs[3].Sign(privKey1)
+ txs[4].Sign(privKey2)
+ txs[5].Sign(privKey2)
+ txs[6].Sign(privKey1)
+ txs[7].Sign(privKey2)
+ txs[8].Sign(privKey2)
for _, tx := range txs {
- err = tx.Sign(testPrivKey)
- So(err, ShouldBeNil)
err = db.Update(ms.applyTransactionProcedure(tx))
So(err, ShouldBeNil)
}
@@ -844,5 +887,189 @@ func TestMetaState(t *testing.T) {
})
})
})
+ Convey("When SQLChain are created", func() {
+ conf.GConf, err = conf.LoadConfig("../test/node_standalone/config.yaml")
+ So(err, ShouldBeNil)
+
+ privKeyFile := "../test/node_standalone/private.key"
+ pubKeyFile := "../test/node_standalone/public.keystore"
+ os.Remove(pubKeyFile)
+ defer os.Remove(pubKeyFile)
+ route.Once = sync.Once{}
+ route.InitKMS(pubKeyFile)
+ err = kms.InitLocalKeyPair(privKeyFile, []byte(""))
+ So(err, ShouldBeNil)
+
+ ao, loaded = ms.loadOrStoreAccountObject(addr1,
+ &accountObject{Account: pt.Account{
+ Address: addr1,
+ },
+ })
+ So(ao, ShouldBeNil)
+ So(loaded, ShouldBeFalse)
+ ao, loaded = ms.loadOrStoreAccountObject(addr2, &accountObject{
+ Account: pt.Account{
+ Address: addr2,
+ },
+ })
+ So(ao, ShouldBeNil)
+ So(loaded, ShouldBeFalse)
+ ao, loaded = ms.loadOrStoreAccountObject(addr3, &accountObject{
+ Account: pt.Account{
+ Address: addr3,
+ },
+ })
+ So(ao, ShouldBeNil)
+ So(loaded, ShouldBeFalse)
+ ao, loaded = ms.loadOrStoreAccountObject(addr4, &accountObject{
+ Account: pt.Account{
+ Address: addr4,
+ },
+ })
+ So(ao, ShouldBeNil)
+ So(loaded, ShouldBeFalse)
+ Convey("When provider transaction is invalid", func() {
+ invalidPs := pt.ProvideService{
+ ProvideServiceHeader: pt.ProvideServiceHeader{
+ Contract: addr2,
+ },
+ }
+ invalidPs.Sign(privKey1)
+ invalidCd1 := pt.CreateDatabase{
+ CreateDatabaseHeader: pt.CreateDatabaseHeader{
+ Owner: addr2,
+ },
+ }
+ invalidCd1.Sign(privKey1)
+ invalidCd2 := pt.CreateDatabase{
+ CreateDatabaseHeader: pt.CreateDatabaseHeader{
+ Owner: addr1,
+ ResourceMeta: pt.ResourceMeta{
+ TargetMiners: []proto.AccountAddress{addr2},
+ },
+ },
+ }
+ invalidCd2.Sign(privKey1)
+
+ err = db.Update(ms.applyTransactionProcedure(&invalidPs))
+ So(errors.Cause(err), ShouldEqual, ErrInvalidSender)
+ err = db.Update(ms.applyTransactionProcedure(&invalidCd1))
+ So(errors.Cause(err), ShouldEqual, ErrInvalidSender)
+ err = db.Update(ms.applyTransactionProcedure(&invalidCd2))
+ So(errors.Cause(err), ShouldEqual, ErrNoSuchMiner)
+ })
+ Convey("When SQLChain create", func() {
+ ps := pt.ProvideService{
+ ProvideServiceHeader: pt.ProvideServiceHeader{
+ Contract: addr2,
+ TargetUser: addr1,
+ },
+ }
+ err = ps.Sign(privKey2)
+ So(err, ShouldBeNil)
+ cd1 := pt.CreateDatabase{
+ CreateDatabaseHeader: pt.CreateDatabaseHeader{
+ Owner: addr1,
+ ResourceMeta: pt.ResourceMeta{
+ TargetMiners: []proto.AccountAddress{addr2},
+ },
+ },
+ }
+ cd1.Sign(privKey1)
+ So(err, ShouldBeNil)
+ cd2 := pt.CreateDatabase{
+ CreateDatabaseHeader: pt.CreateDatabaseHeader{
+ Owner: addr3,
+ ResourceMeta: pt.ResourceMeta{
+ TargetMiners: []proto.AccountAddress{addr2},
+ },
+ },
+ }
+ cd2.Sign(privKey3)
+ So(err, ShouldBeNil)
+
+ err = db.Update(ms.applyTransactionProcedure(&ps))
+ So(err, ShouldBeNil)
+ err = db.Update(ms.applyTransactionProcedure(&cd2))
+ So(errors.Cause(err), ShouldEqual, ErrMinerUserNotMatch)
+ err = db.Update(ms.applyTransactionProcedure(&cd1))
+ So(err, ShouldBeNil)
+ dbID := proto.FromAccountAndNonce(cd1.Owner, uint32(cd1.Nonce))
+ co, loaded = ms.loadSQLChainObject(*dbID)
+ So(loaded, ShouldBeTrue)
+ dbAccount, err := dbID.AccountAddress()
+ So(err, ShouldBeNil)
+
+ up := pt.UpdatePermission{
+ UpdatePermissionHeader: pt.UpdatePermissionHeader{
+ TargetSQLChain: addr1,
+ TargetUser: addr3,
+ Permission: pt.Read,
+ Nonce: cd1.Nonce + 1,
+ },
+ }
+ up.Sign(privKey1)
+ err = db.Update(ms.applyTransactionProcedure(&up))
+ So(errors.Cause(err), ShouldEqual, ErrDatabaseNotFound)
+ up.Permission = 4
+ up.TargetSQLChain = dbAccount
+ err = up.Sign(privKey1)
+ So(err, ShouldBeNil)
+ err = db.Update(ms.applyTransactionProcedure(&up))
+ So(errors.Cause(err), ShouldEqual, ErrInvalidPermission)
+ // test permission update
+ // addr1(admin) update addr3 as admin
+ up.TargetUser = addr3
+ up.Permission = pt.Admin
+ err = up.Sign(privKey1)
+ So(err, ShouldBeNil)
+ err = db.Update(ms.applyTransactionProcedure(&up))
+ So(err, ShouldBeNil)
+ // addr3(admin) update addr4 as read
+ up.TargetUser = addr4
+ up.Nonce = 0
+ up.Permission = pt.Read
+ err = up.Sign(privKey3)
+ So(err, ShouldBeNil)
+ err = db.Update(ms.applyTransactionProcedure(&up))
+ So(err, ShouldBeNil)
+ // addr3(admin) update addr1(admin) as read
+ up.TargetUser = addr1
+ up.Nonce = up.Nonce + 1
+ err = up.Sign(privKey3)
+ So(err, ShouldBeNil)
+ err = db.Update(ms.applyTransactionProcedure(&up))
+ So(err, ShouldBeNil)
+ // addr3(admin) update addr3(admin) as read fail
+ up.TargetUser = addr3
+ up.Permission = pt.Read
+ up.Nonce = up.Nonce + 1
+ err = up.Sign(privKey3)
+ So(err, ShouldBeNil)
+ err = db.Update(ms.applyTransactionProcedure(&up))
+ So(errors.Cause(err), ShouldEqual, ErrInvalidSender)
+ // addr1(read) update addr3(admin) fail
+ up.Nonce = cd1.Nonce + 2
+ err = up.Sign(privKey1)
+ err = db.Update(ms.applyTransactionProcedure(&up))
+ So(errors.Cause(err), ShouldEqual, ErrAccountPermissionDeny)
+
+ co, loaded = ms.loadSQLChainObject(*dbID)
+ for _, user := range co.Users {
+ if user.Address == addr1 {
+ So(user.Permission, ShouldEqual, pt.Read)
+ continue
+ }
+ if user.Address == addr3 {
+ So(user.Permission, ShouldEqual, pt.Admin)
+ continue
+ }
+ if user.Address == addr4 {
+ So(user.Permission, ShouldEqual, pt.Read)
+ continue
+ }
+ }
+ })
+ })
})
}
diff --git a/blockproducer/xxx_test.go b/blockproducer/xxx_test.go
index 87e6a5e4e..8318d6e10 100644
--- a/blockproducer/xxx_test.go
+++ b/blockproducer/xxx_test.go
@@ -460,7 +460,7 @@ func setup() {
rand.Seed(time.Now().UnixNano())
rand.Read(genesisHash[:])
- // Create key paire for test
+ // Create key pairs for test
if testPrivKey, _, err = asymmetric.GenSecp256k1KeyPair(); err != nil {
panic(err)
}
diff --git a/proto/proto.go b/proto/proto.go
index d77fc61cf..88f369692 100644
--- a/proto/proto.go
+++ b/proto/proto.go
@@ -18,6 +18,7 @@
package proto
import (
+ "fmt"
"time"
"github.com/CovenantSQL/CovenantSQL/crypto/hash"
@@ -156,3 +157,11 @@ func (d *DatabaseID) AccountAddress() (a AccountAddress, err error) {
a = AccountAddress(*h)
return
}
+
+// FromAccountAndNonce generates databaseID from Account and its nonce.
+func FromAccountAndNonce(accountAddress AccountAddress, nonce uint32) *DatabaseID {
+ addrAndNonce := fmt.Sprintf("%s%d", accountAddress.String(), nonce)
+ rawID := hash.THashH([]byte(addrAndNonce))
+ d := DatabaseID(rawID.String())
+ return &d
+}
diff --git a/proto/proto_test.go b/proto/proto_test.go
index f14aa5645..ff9c51087 100644
--- a/proto/proto_test.go
+++ b/proto/proto_test.go
@@ -63,3 +63,36 @@ func TestDatabaseID_AccountAddress(t *testing.T) {
})
}
+
+func TestFromAccountAndNonce(t *testing.T) {
+ target := []struct {
+ account string
+ nonce uint32
+ result string
+ }{
+ {
+ "aecd0b238518f023a81db3bdce5b2f1211b4e383dac96efc5d7205c761e15519",
+ 1,
+ "a2710c0f9550c2713e9ff25543d9b5ef96bdc4927ea8d56262bb938718b8b717",
+ },
+ {
+ "8374e39c82c847681341245d9964f31a15cf2844994ec64a9b99c38dd3b7f54b",
+ 2,
+ "da05187b8da4ec8dc3320c7d103590573d4f40beed414ad2afed7c3bdbaca628",
+ },
+ {
+ "72cb315f225c8ce03cd4b8d8ef802e871f9aa0924ddd9a358b647f4187730b12",
+ 0,
+ "293e94eecddd941eab73d47e0cb967102b271bd4fc3a1398c1c1496c3dd06f0f",
+ },
+ }
+ Convey("Generate DatabaseID", t, func() {
+ for i := range target {
+ h, err := hash.NewHashFromStr(target[i].account)
+ So(err, ShouldBeNil)
+ a := AccountAddress(*h)
+ dbID := FromAccountAndNonce(a, target[i].nonce)
+ So(string(*dbID), ShouldResemble, target[i].result)
+ }
+ })
+}
diff --git a/types/account.go b/types/account.go
index 4ec3e8084..a9506e8fc 100644
--- a/types/account.go
+++ b/types/account.go
@@ -43,7 +43,7 @@ const (
Admin UserPermission = iota
// Read defines the reader user permission.
Read
- // Write defines the reader/writer user permission.
+ // Write defines the writer user permission.
Write
// NumberOfUserPermission defines the user permission number.
NumberOfUserPermission
@@ -109,6 +109,7 @@ type ProviderProfile struct {
Space uint64 // reserved storage space in bytes
Memory uint64 // reserved memory in bytes
LoadAvgPerCPU uint64 // max loadAvg15 per CPU
+ TargetUser proto.AccountAddress
}
// Account store its balance, and other mate data.
diff --git a/types/ack_type_gen.go b/types/ack_type_gen.go
index d9c850bad..90fc7a814 100644
--- a/types/ack_type_gen.go
+++ b/types/ack_type_gen.go
@@ -11,24 +11,8 @@ func (z *Ack) MarshalHash() (o []byte, err error) {
var b []byte
o = hsp.Require(b, z.Msgsize())
// map header, size 2
- // map header, size 2
- // map header, size 3
- o = append(o, 0x82, 0x82, 0x82, 0x82, 0x83, 0x83)
- if oTemp, err := z.Header.AckHeader.Response.MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
- }
- o = append(o, 0x83)
- if oTemp, err := z.Header.AckHeader.NodeID.MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
- }
- o = append(o, 0x83)
- o = hsp.AppendTime(o, z.Header.AckHeader.Timestamp)
- o = append(o, 0x82)
- if oTemp, err := z.Header.DefaultHashSignVerifierImpl.MarshalHash(); err != nil {
+ o = append(o, 0x82, 0x82)
+ if oTemp, err := z.Header.MarshalHash(); err != nil {
return nil, err
} else {
o = hsp.AppendBytes(o, oTemp)
@@ -44,7 +28,7 @@ func (z *Ack) MarshalHash() (o []byte, err error) {
// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (z *Ack) Msgsize() (s int) {
- s = 1 + 7 + 1 + 10 + 1 + 9 + z.Header.AckHeader.Response.Msgsize() + 7 + z.Header.AckHeader.NodeID.Msgsize() + 10 + hsp.TimeSize + 28 + z.Header.DefaultHashSignVerifierImpl.Msgsize() + 9 + z.Envelope.Msgsize()
+ s = 1 + 7 + z.Header.Msgsize() + 9 + z.Envelope.Msgsize()
return
}
diff --git a/types/createdb.go b/types/createdb.go
index 9033b5664..87c49d4ad 100644
--- a/types/createdb.go
+++ b/types/createdb.go
@@ -18,6 +18,7 @@ package types
import (
pi "github.com/CovenantSQL/CovenantSQL/blockproducer/interfaces"
+ "github.com/CovenantSQL/CovenantSQL/crypto"
"github.com/CovenantSQL/CovenantSQL/crypto/asymmetric"
"github.com/CovenantSQL/CovenantSQL/crypto/verifier"
"github.com/CovenantSQL/CovenantSQL/proto"
@@ -32,11 +33,6 @@ type CreateDatabaseHeader struct {
Nonce pi.AccountNonce
}
-// GetAccountAddress implements interfaces/Transaction.GetAccountAddress.
-func (h *CreateDatabaseHeader) GetAccountAddress() proto.AccountAddress {
- return h.Owner
-}
-
// GetAccountNonce implements interfaces/Transaction.GetAccountNonce.
func (h *CreateDatabaseHeader) GetAccountNonce() pi.AccountNonce {
return h.Nonce
@@ -67,6 +63,12 @@ func (cd *CreateDatabase) Verify() error {
return cd.DefaultHashSignVerifierImpl.Verify(&cd.CreateDatabaseHeader)
}
+// GetAccountAddress implements interfaces/Transaction.GetAccountAddress.
+func (cd *CreateDatabase) GetAccountAddress() proto.AccountAddress {
+ addr, _ := crypto.PubKeyHash(cd.Signee)
+ return addr
+}
+
func init() {
pi.RegisterTransaction(pi.TransactionTypeCreateDatabase, (*CreateDatabase)(nil))
}
diff --git a/types/createdb_test.go b/types/createdb_test.go
index e61381a4b..97ebd5b3a 100644
--- a/types/createdb_test.go
+++ b/types/createdb_test.go
@@ -19,6 +19,7 @@ package types
import (
"testing"
+ "github.com/CovenantSQL/CovenantSQL/crypto"
"github.com/CovenantSQL/CovenantSQL/crypto/asymmetric"
"github.com/CovenantSQL/CovenantSQL/crypto/hash"
"github.com/CovenantSQL/CovenantSQL/proto"
@@ -29,14 +30,12 @@ func TestTxCreateDatabase(t *testing.T) {
Convey("test tx create database", t, func() {
h, err := hash.NewHashFromStr("000005aa62048f85da4ae9698ed59c14ec0d48a88a07c15a32265634e7e64ade")
So(err, ShouldBeNil)
- addr := proto.AccountAddress(*h)
cd := NewCreateDatabase(&CreateDatabaseHeader{
- Owner: addr,
+ Owner: proto.AccountAddress(*h),
Nonce: 1,
})
- So(cd.GetAccountAddress(), ShouldEqual, addr)
So(cd.GetAccountNonce(), ShouldEqual, 1)
priv, _, err := asymmetric.GenSecp256k1KeyPair()
@@ -47,5 +46,9 @@ func TestTxCreateDatabase(t *testing.T) {
err = cd.Verify()
So(err, ShouldBeNil)
+
+ addr, err := crypto.PubKeyHash(priv.PubKey())
+ So(err, ShouldBeNil)
+ So(cd.GetAccountAddress(), ShouldEqual, addr)
})
}
diff --git a/types/provideservice.go b/types/provideservice.go
index 8d98c90a1..9fcd23adc 100644
--- a/types/provideservice.go
+++ b/types/provideservice.go
@@ -18,6 +18,7 @@ package types
import (
"github.com/CovenantSQL/CovenantSQL/blockproducer/interfaces"
+ "github.com/CovenantSQL/CovenantSQL/crypto"
"github.com/CovenantSQL/CovenantSQL/crypto/asymmetric"
"github.com/CovenantSQL/CovenantSQL/crypto/verifier"
"github.com/CovenantSQL/CovenantSQL/proto"
@@ -31,14 +32,10 @@ type ProvideServiceHeader struct {
Space uint64 // reserved storage space in bytes
Memory uint64 // reserved memory in bytes
LoadAvgPerCPU uint64 // max loadAvg15 per CPU
+ TargetUser proto.AccountAddress
Nonce interfaces.AccountNonce
}
-// GetAccountAddress implements interfaces/Transaction.GetAccountAddress.
-func (h *ProvideServiceHeader) GetAccountAddress() proto.AccountAddress {
- return h.Contract
-}
-
// GetAccountNonce implements interfaces/Transaction.GetAccountNonce.
func (h *ProvideServiceHeader) GetAccountNonce() interfaces.AccountNonce {
return h.Nonce
@@ -69,6 +66,12 @@ func (ps *ProvideService) Verify() error {
return ps.DefaultHashSignVerifierImpl.Verify(&ps.ProvideServiceHeader)
}
+// GetAccountAddress implements interfaces/Transaction.GetAccountAddress.
+func (ps *ProvideService) GetAccountAddress() proto.AccountAddress {
+ addr, _ := crypto.PubKeyHash(ps.Signee)
+ return addr
+}
+
func init() {
interfaces.RegisterTransaction(interfaces.TransactionTypeCreateDatabase, (*ProvideService)(nil))
}
diff --git a/types/provideservice_gen.go b/types/provideservice_gen.go
index 3a885022f..fe1ec511d 100644
--- a/types/provideservice_gen.go
+++ b/types/provideservice_gen.go
@@ -42,30 +42,36 @@ func (z *ProvideService) Msgsize() (s int) {
func (z *ProvideServiceHeader) MarshalHash() (o []byte, err error) {
var b []byte
o = hsp.Require(b, z.Msgsize())
- // map header, size 5
- o = append(o, 0x85, 0x85)
+ // map header, size 6
+ o = append(o, 0x86, 0x86)
if oTemp, err := z.Nonce.MarshalHash(); err != nil {
return nil, err
} else {
o = hsp.AppendBytes(o, oTemp)
}
- o = append(o, 0x85)
+ o = append(o, 0x86)
if oTemp, err := z.Contract.MarshalHash(); err != nil {
return nil, err
} else {
o = hsp.AppendBytes(o, oTemp)
}
- o = append(o, 0x85)
+ o = append(o, 0x86)
+ if oTemp, err := z.TargetUser.MarshalHash(); err != nil {
+ return nil, err
+ } else {
+ o = hsp.AppendBytes(o, oTemp)
+ }
+ o = append(o, 0x86)
o = hsp.AppendUint64(o, z.Space)
- o = append(o, 0x85)
+ o = append(o, 0x86)
o = hsp.AppendUint64(o, z.Memory)
- o = append(o, 0x85)
+ o = append(o, 0x86)
o = hsp.AppendUint64(o, z.LoadAvgPerCPU)
return
}
// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (z *ProvideServiceHeader) Msgsize() (s int) {
- s = 1 + 6 + z.Nonce.Msgsize() + 9 + z.Contract.Msgsize() + 6 + hsp.Uint64Size + 7 + hsp.Uint64Size + 14 + hsp.Uint64Size
+ s = 1 + 6 + z.Nonce.Msgsize() + 9 + z.Contract.Msgsize() + 11 + z.TargetUser.Msgsize() + 6 + hsp.Uint64Size + 7 + hsp.Uint64Size + 14 + hsp.Uint64Size
return
}
diff --git a/types/updatepermission.go b/types/updatepermission.go
index c28867034..22da0e158 100644
--- a/types/updatepermission.go
+++ b/types/updatepermission.go
@@ -18,6 +18,7 @@ package types
import (
"github.com/CovenantSQL/CovenantSQL/blockproducer/interfaces"
+ "github.com/CovenantSQL/CovenantSQL/crypto"
"github.com/CovenantSQL/CovenantSQL/crypto/asymmetric"
"github.com/CovenantSQL/CovenantSQL/crypto/verifier"
"github.com/CovenantSQL/CovenantSQL/proto"
@@ -33,11 +34,6 @@ type UpdatePermissionHeader struct {
Nonce interfaces.AccountNonce
}
-// GetAccountAddress implements interfaces/Transaction.GetAccountAddress.
-func (u *UpdatePermissionHeader) GetAccountAddress() proto.AccountAddress {
- return u.TargetSQLChain
-}
-
// GetAccountNonce implements interfaces/Transaction.GetAccountNonce.
func (u *UpdatePermissionHeader) GetAccountNonce() interfaces.AccountNonce {
return u.Nonce
@@ -68,6 +64,12 @@ func (up *UpdatePermission) Verify() error {
return up.DefaultHashSignVerifierImpl.Verify(&up.UpdatePermissionHeader)
}
+// GetAccountAddress implements interfaces/Transaction.GetAccountAddress.
+func (up *UpdatePermission) GetAccountAddress() proto.AccountAddress {
+ addr, _ := crypto.PubKeyHash(up.Signee)
+ return addr
+}
+
func init() {
interfaces.RegisterTransaction(interfaces.TransactionUpdatePermission, (*UpdatePermission)(nil))
}
From 2366b0688001418327c3128e3d2312179ecd48ac Mon Sep 17 00:00:00 2001
From: leventeliu
Date: Tue, 27 Nov 2018 15:43:44 +0800
Subject: [PATCH 022/278] Use context instead of stop signal channel
---
blockproducer/chain.go | 153 +++++++++++++++++++--------------------
blockproducer/runtime.go | 24 +++---
2 files changed, 89 insertions(+), 88 deletions(-)
diff --git a/blockproducer/chain.go b/blockproducer/chain.go
index b8444b5ec..d3f490e6d 100644
--- a/blockproducer/chain.go
+++ b/blockproducer/chain.go
@@ -17,6 +17,7 @@
package blockproducer
import (
+ "context"
"fmt"
"os"
"sync"
@@ -64,7 +65,7 @@ type Chain struct {
blocksFromRPC chan *pt.BPBlock
pendingTxs chan pi.Transaction
- stopCh chan struct{}
+ ctx context.Context
}
// NewChain creates a new blockchain.
@@ -129,21 +130,23 @@ func NewChain(cfg *Config) (*Chain, error) {
return nil, err
}
- // init rpc and chain bus
- caller := rpc.NewCaller()
- bus := chainbus.New()
-
// create chain
+ var (
+ bus = chainbus.New()
+ caller = rpc.NewCaller()
+ ctx = context.Background()
+ )
+
chain := &Chain{
db: db,
ms: newMetaState(),
bi: newBlockIndex(),
- rt: newRuntime(cfg, accountAddress),
+ rt: newRuntime(ctx, cfg, accountAddress),
cl: caller,
bs: bus,
blocksFromRPC: make(chan *pt.BPBlock),
pendingTxs: make(chan pi.Transaction),
- stopCh: make(chan struct{}),
+ ctx: ctx,
}
// sub chain events
@@ -184,19 +187,22 @@ func LoadChain(cfg *Config) (chain *Chain, err error) {
return nil, err
}
- caller := rpc.NewCaller()
- bus := chainbus.New()
+ var (
+ bus = chainbus.New()
+ caller = rpc.NewCaller()
+ ctx = context.Background()
+ )
chain = &Chain{
db: db,
ms: newMetaState(),
bi: newBlockIndex(),
- rt: newRuntime(cfg, accountAddress),
+ rt: newRuntime(ctx, cfg, accountAddress),
cl: caller,
bs: bus,
blocksFromRPC: make(chan *pt.BPBlock),
pendingTxs: make(chan pi.Transaction),
- stopCh: make(chan struct{}),
+ ctx: ctx,
}
chain.bs.Subscribe(txEvent, chain.addTx)
@@ -397,32 +403,34 @@ func (c *Chain) produceBlock(now time.Time) error {
}
peers := c.rt.getPeers()
- wg := &sync.WaitGroup{}
for _, s := range peers.Servers {
if !s.IsEqual(&c.rt.nodeID) {
- wg.Add(1)
- go func(id proto.NodeID) {
- defer wg.Done()
- blockReq := &AdviseNewBlockReq{
- Envelope: proto.Envelope{
- // TODO(lambda): Add fields.
- },
- Block: b,
- }
- blockResp := &AdviseNewBlockResp{}
- if err := c.cl.CallNode(id, route.MCCAdviseNewBlock.String(), blockReq, blockResp); err != nil {
- log.WithFields(log.Fields{
- "peer": c.rt.getPeerInfoString(),
- "now_time": time.Now().UTC().Format(time.RFC3339Nano),
- "block_hash": b.BlockHash(),
- }).WithError(err).Error(
- "failed to advise new block")
- } else {
- log.WithFields(log.Fields{
- "node": id,
- }).Debug("success advising block")
- }
- }(s)
+ c.rt.goFunc(func(ctx context.Context, wg *sync.WaitGroup) {
+ // Bind NodeID to subroutine
+ func(_ context.Context, wg *sync.WaitGroup, id proto.NodeID) {
+ // TODO(leventeliu): context is not used, WaitGroup is not guaranteed to be
+ // waitable.
+ defer wg.Done()
+ blockReq := &AdviseNewBlockReq{
+ Envelope: proto.Envelope{
+ // TODO(lambda): Add fields.
+ },
+ Block: b,
+ }
+ blockResp := &AdviseNewBlockResp{}
+ if err := c.cl.CallNode(id, route.MCCAdviseNewBlock.String(), blockReq, blockResp); err != nil {
+ log.WithFields(log.Fields{
+ "peer": c.rt.getPeerInfoString(),
+ "now_time": time.Now().UTC().Format(time.RFC3339Nano),
+ "block_hash": b.BlockHash(),
+ }).WithError(err).Error("failed to advise new block")
+ } else {
+ log.WithFields(log.Fields{
+ "node": id,
+ }).Debug("success advising block")
+ }
+ }(ctx, wg, s)
+ })
}
}
@@ -597,35 +605,37 @@ func (c *Chain) Start() error {
return err
}
- c.rt.wg.Add(1)
- go c.processBlocks()
- c.rt.wg.Add(1)
- go c.processTxs()
- c.rt.wg.Add(1)
- go c.mainCycle()
+ c.rt.goFunc(c.processBlocks)
+ c.rt.goFunc(c.processTxs)
+ c.rt.goFunc(c.mainCycle)
c.rt.startService(c)
return nil
}
-func (c *Chain) processBlocks() {
- rsCh := make(chan struct{})
- rsWG := &sync.WaitGroup{}
- returnStash := func(stash []*pt.BPBlock) {
- defer rsWG.Done()
- for _, block := range stash {
- select {
- case c.blocksFromRPC <- block:
- case <-rsCh:
- return
+func (c *Chain) processBlocks(ctx context.Context, wg *sync.WaitGroup) {
+ var (
+ returnStash = func(ctx context.Context, wg *sync.WaitGroup, stash []*pt.BPBlock) {
+ defer wg.Done()
+ for _, block := range stash {
+ select {
+ case c.blocksFromRPC <- block:
+ case <-ctx.Done():
+ return
+ }
}
}
- }
+ // Subroutine control
+ subCtx, subCancel = context.WithCancel(ctx)
+ subWg = &sync.WaitGroup{}
+ )
defer func() {
- close(rsCh)
- rsWG.Wait()
- c.rt.wg.Done()
+ // Wait for subroutines to exit
+ subCancel()
+ subWg.Wait()
+ // Parent done
+ wg.Done()
}()
var stash []*pt.BPBlock
@@ -634,9 +644,6 @@ func (c *Chain) processBlocks() {
case block := <-c.blocksFromRPC:
if h := c.rt.getHeightFromTime(block.Timestamp()); h > c.rt.getNextTurn()-1 {
// Stash newer blocks for later check
- if stash == nil {
- stash = make([]*pt.BPBlock, 0)
- }
stash = append(stash, block)
} else {
// Process block
@@ -655,12 +662,12 @@ func (c *Chain) processBlocks() {
// Return all stashed blocks to pending channel
if stash != nil {
- rsWG.Add(1)
- go returnStash(stash)
+ subWg.Add(1)
+ go returnStash(subCtx, subWg, stash)
stash = nil
}
}
- case <-c.stopCh:
+ case <-ctx.Done():
return
}
}
@@ -682,32 +689,26 @@ func (c *Chain) processTx(tx pi.Transaction) {
c.bs.Publish(txEvent, tx)
}
-func (c *Chain) processTxs() {
- defer c.rt.wg.Done()
+func (c *Chain) processTxs(ctx context.Context, wg *sync.WaitGroup) {
+ defer wg.Done()
for {
select {
case tx := <-c.pendingTxs:
c.processTx(tx)
- case <-c.stopCh:
+ case <-ctx.Done():
return
}
}
}
-func (c *Chain) mainCycle() {
- defer func() {
- c.rt.wg.Done()
- // Signal worker goroutines to stop
- close(c.stopCh)
- }()
-
+func (c *Chain) mainCycle(ctx context.Context, wg *sync.WaitGroup) {
+ defer wg.Done()
for {
select {
- case <-c.rt.stopCh:
+ case <-ctx.Done():
return
default:
c.syncHead()
-
if t, d := c.rt.nextTick(); d > 0 {
log.WithFields(log.Fields{
"peer": c.rt.getPeerInfoString(),
@@ -755,8 +756,7 @@ func (c *Chain) syncHead() {
"curr_turn": c.rt.getNextTurn(),
"head_height": c.rt.getHead().Height,
"head_block": c.rt.getHead().Head.String(),
- }).WithError(err).Debug(
- "Failed to fetch block from peer")
+ }).WithError(err).Debug("Failed to fetch block from peer")
} else {
c.blocksFromRPC <- resp.Block
log.WithFields(log.Fields{
@@ -765,8 +765,7 @@ func (c *Chain) syncHead() {
"curr_turn": c.rt.getNextTurn(),
"head_height": c.rt.getHead().Height,
"head_block": c.rt.getHead().Head.String(),
- }).Debug(
- "Fetch block from remote peer successfully")
+ }).Debug("Fetch block from remote peer successfully")
succ = true
break
}
diff --git a/blockproducer/runtime.go b/blockproducer/runtime.go
index a4e15bf03..9af6dd0a2 100644
--- a/blockproducer/runtime.go
+++ b/blockproducer/runtime.go
@@ -17,6 +17,7 @@
package blockproducer
import (
+ "context"
"fmt"
"sync"
"time"
@@ -29,8 +30,9 @@ import (
// copy from /sqlchain/runtime.go
// rt define the runtime of main chain.
type rt struct {
- wg sync.WaitGroup
- stopCh chan struct{}
+ ctx context.Context
+ cancel context.CancelFunc
+ wg *sync.WaitGroup
// chainInitTime is the initial cycle time, when the Genesis block is produced.
chainInitTime time.Time
@@ -74,15 +76,18 @@ func (r *rt) now() time.Time {
return time.Now().UTC().Add(r.offset)
}
-func newRuntime(cfg *Config, accountAddress proto.AccountAddress) *rt {
+func newRuntime(ctx context.Context, cfg *Config, accountAddress proto.AccountAddress) *rt {
var index uint32
for i, s := range cfg.Peers.Servers {
if cfg.NodeID.IsEqual(&s) {
index = uint32(i)
}
}
+ var cld, ccl = context.WithCancel(ctx)
return &rt{
- stopCh: make(chan struct{}),
+ ctx: cld,
+ cancel: ccl,
+ wg: &sync.WaitGroup{},
chainInitTime: cfg.Genesis.SignedHeader.Timestamp,
accountAddress: accountAddress,
server: cfg.Server,
@@ -170,14 +175,11 @@ func (r *rt) setHead(head *State) {
}
func (r *rt) stop() {
- r.stopService()
- select {
- case <-r.stopCh:
- default:
- close(r.stopCh)
- }
+ r.cancel()
r.wg.Wait()
}
-func (r *rt) stopService() {
+func (r *rt) goFunc(f func(ctx context.Context, wg *sync.WaitGroup)) {
+ r.wg.Add(1)
+ go f(r.ctx, r.wg)
}
From 0739eae96ac1babac4411bcc0e9a1c453ec19143 Mon Sep 17 00:00:00 2001
From: leventeliu
Date: Tue, 27 Nov 2018 15:55:26 +0800
Subject: [PATCH 023/278] Use context version of CallNode
---
blockproducer/chain.go | 24 +++++++++++++-----------
1 file changed, 13 insertions(+), 11 deletions(-)
diff --git a/blockproducer/chain.go b/blockproducer/chain.go
index d3f490e6d..4326cfa6e 100644
--- a/blockproducer/chain.go
+++ b/blockproducer/chain.go
@@ -407,18 +407,20 @@ func (c *Chain) produceBlock(now time.Time) error {
if !s.IsEqual(&c.rt.nodeID) {
c.rt.goFunc(func(ctx context.Context, wg *sync.WaitGroup) {
// Bind NodeID to subroutine
- func(_ context.Context, wg *sync.WaitGroup, id proto.NodeID) {
- // TODO(leventeliu): context is not used, WaitGroup is not guaranteed to be
- // waitable.
+ func(ctx context.Context, wg *sync.WaitGroup, id proto.NodeID) {
defer wg.Done()
- blockReq := &AdviseNewBlockReq{
- Envelope: proto.Envelope{
- // TODO(lambda): Add fields.
- },
- Block: b,
- }
- blockResp := &AdviseNewBlockResp{}
- if err := c.cl.CallNode(id, route.MCCAdviseNewBlock.String(), blockReq, blockResp); err != nil {
+ var (
+ blockReq = &AdviseNewBlockReq{
+ Envelope: proto.Envelope{
+ // TODO(lambda): Add fields.
+ },
+ Block: b,
+ }
+ blockResp = &AdviseNewBlockResp{}
+ )
+ if err := c.cl.CallNodeWithContext(
+ ctx, id, route.MCCAdviseNewBlock.String(), blockReq, blockResp,
+ ); err != nil {
log.WithFields(log.Fields{
"peer": c.rt.getPeerInfoString(),
"now_time": time.Now().UTC().Format(time.RFC3339Nano),
From af7a0b41c7f39fd49b25f3a0300acf1148707964 Mon Sep 17 00:00:00 2001
From: leventeliu
Date: Tue, 27 Nov 2018 20:48:55 +0800
Subject: [PATCH 024/278] Refactor imports
---
blockproducer/chain.go | 35 +++++----
blockproducer/metaindex.go | 18 ++---
blockproducer/metaindex_test.go | 14 ++--
blockproducer/metastate_test.go | 131 ++++++++++++++++----------------
blockproducer/rpc.go | 7 +-
blockproducer/xxx_test.go | 41 +++++-----
6 files changed, 121 insertions(+), 125 deletions(-)
diff --git a/blockproducer/chain.go b/blockproducer/chain.go
index 4326cfa6e..41ef1a576 100644
--- a/blockproducer/chain.go
+++ b/blockproducer/chain.go
@@ -34,7 +34,6 @@ import (
"github.com/CovenantSQL/CovenantSQL/route"
"github.com/CovenantSQL/CovenantSQL/rpc"
"github.com/CovenantSQL/CovenantSQL/types"
- pt "github.com/CovenantSQL/CovenantSQL/types"
"github.com/CovenantSQL/CovenantSQL/utils"
"github.com/CovenantSQL/CovenantSQL/utils/log"
"github.com/coreos/bbolt"
@@ -63,7 +62,7 @@ type Chain struct {
cl *rpc.Caller
bs chainbus.Bus
- blocksFromRPC chan *pt.BPBlock
+ blocksFromRPC chan *types.BPBlock
pendingTxs chan pi.Transaction
ctx context.Context
}
@@ -144,7 +143,7 @@ func NewChain(cfg *Config) (*Chain, error) {
rt: newRuntime(ctx, cfg, accountAddress),
cl: caller,
bs: bus,
- blocksFromRPC: make(chan *pt.BPBlock),
+ blocksFromRPC: make(chan *types.BPBlock),
pendingTxs: make(chan pi.Transaction),
ctx: ctx,
}
@@ -200,7 +199,7 @@ func LoadChain(cfg *Config) (chain *Chain, err error) {
rt: newRuntime(ctx, cfg, accountAddress),
cl: caller,
bs: bus,
- blocksFromRPC: make(chan *pt.BPBlock),
+ blocksFromRPC: make(chan *types.BPBlock),
pendingTxs: make(chan pi.Transaction),
ctx: ctx,
}
@@ -226,7 +225,7 @@ func LoadChain(cfg *Config) (chain *Chain, err error) {
nodes := make([]blockNode, blocks.Stats().KeyN)
if err = blocks.ForEach(func(k, v []byte) (err error) {
- block := &pt.BPBlock{}
+ block := &types.BPBlock{}
if err = utils.DecodeMsgPack(v, block); err != nil {
log.WithError(err).Error("load block failed")
return err
@@ -276,7 +275,7 @@ func LoadChain(cfg *Config) (chain *Chain, err error) {
}
// checkBlock has following steps: 1. check parent block 2. checkTx 2. merkle tree 3. Hash 4. Signature.
-func (c *Chain) checkBlock(b *pt.BPBlock) (err error) {
+func (c *Chain) checkBlock(b *types.BPBlock) (err error) {
// TODO(lambda): process block fork
if !b.ParentHash().IsEqual(&c.rt.getHead().Head) {
log.WithFields(log.Fields{
@@ -304,7 +303,7 @@ func (c *Chain) checkBlock(b *pt.BPBlock) (err error) {
return nil
}
-func (c *Chain) pushBlockWithoutCheck(b *pt.BPBlock) error {
+func (c *Chain) pushBlockWithoutCheck(b *types.BPBlock) error {
h := c.rt.getHeightFromTime(b.Timestamp())
log.Debugf("current block %s, height %d, its parent %s", b.BlockHash(), h, b.ParentHash())
node := newBlockNode(c.rt.chainInitTime, c.rt.period, b, c.rt.getHead().Node)
@@ -349,7 +348,7 @@ func (c *Chain) pushBlockWithoutCheck(b *pt.BPBlock) error {
return err
}
-func (c *Chain) pushGenesisBlock(b *pt.BPBlock) (err error) {
+func (c *Chain) pushGenesisBlock(b *types.BPBlock) (err error) {
err = c.pushBlockWithoutCheck(b)
if err != nil {
log.WithError(err).Error("push genesis block failed")
@@ -357,7 +356,7 @@ func (c *Chain) pushGenesisBlock(b *pt.BPBlock) (err error) {
return
}
-func (c *Chain) pushBlock(b *pt.BPBlock) error {
+func (c *Chain) pushBlock(b *types.BPBlock) error {
err := c.checkBlock(b)
if err != nil {
err = errors.Wrap(err, "check block failed")
@@ -378,9 +377,9 @@ func (c *Chain) produceBlock(now time.Time) error {
return err
}
- b := &pt.BPBlock{
- SignedHeader: pt.BPSignedHeader{
- BPHeader: pt.BPHeader{
+ b := &types.BPBlock{
+ SignedHeader: types.BPSignedHeader{
+ BPHeader: types.BPHeader{
Version: blockVersion,
Producer: c.rt.accountAddress,
ParentHash: c.rt.getHead().Head,
@@ -505,13 +504,13 @@ func (c *Chain) checkBillingRequest(br *types.BillingRequest) (err error) {
return
}
-func (c *Chain) fetchBlockByHeight(h uint32) (b *pt.BPBlock, count uint32, err error) {
+func (c *Chain) fetchBlockByHeight(h uint32) (b *types.BPBlock, count uint32, err error) {
node := c.rt.getHead().Node.ancestor(h)
if node == nil {
return nil, 0, ErrNoSuchBlock
}
- b = &pt.BPBlock{}
+ b = &types.BPBlock{}
k := node.indexKey()
err = c.db.View(func(tx *bolt.Tx) error {
@@ -525,13 +524,13 @@ func (c *Chain) fetchBlockByHeight(h uint32) (b *pt.BPBlock, count uint32, err e
return b, node.count, nil
}
-func (c *Chain) fetchBlockByCount(count uint32) (b *pt.BPBlock, height uint32, err error) {
+func (c *Chain) fetchBlockByCount(count uint32) (b *types.BPBlock, height uint32, err error) {
node := c.rt.getHead().Node.ancestorByCount(count)
if node == nil {
return nil, 0, ErrNoSuchBlock
}
- b = &pt.BPBlock{}
+ b = &types.BPBlock{}
k := node.indexKey()
err = c.db.View(func(tx *bolt.Tx) error {
@@ -617,7 +616,7 @@ func (c *Chain) Start() error {
func (c *Chain) processBlocks(ctx context.Context, wg *sync.WaitGroup) {
var (
- returnStash = func(ctx context.Context, wg *sync.WaitGroup, stash []*pt.BPBlock) {
+ returnStash = func(ctx context.Context, wg *sync.WaitGroup, stash []*types.BPBlock) {
defer wg.Done()
for _, block := range stash {
select {
@@ -640,7 +639,7 @@ func (c *Chain) processBlocks(ctx context.Context, wg *sync.WaitGroup) {
wg.Done()
}()
- var stash []*pt.BPBlock
+ var stash []*types.BPBlock
for {
select {
case block := <-c.blocksFromRPC:
diff --git a/blockproducer/metaindex.go b/blockproducer/metaindex.go
index d69a3f219..7d7796cc6 100644
--- a/blockproducer/metaindex.go
+++ b/blockproducer/metaindex.go
@@ -21,7 +21,7 @@ import (
"sync"
"github.com/CovenantSQL/CovenantSQL/proto"
- pt "github.com/CovenantSQL/CovenantSQL/types"
+ "github.com/CovenantSQL/CovenantSQL/types"
"github.com/CovenantSQL/CovenantSQL/utils"
"github.com/coreos/bbolt"
"github.com/ulule/deepcopier"
@@ -47,17 +47,17 @@ func safeSub(x, y *uint64) (err error) {
type accountObject struct {
sync.RWMutex
- pt.Account
+ types.Account
}
type sqlchainObject struct {
sync.RWMutex
- pt.SQLChainProfile
+ types.SQLChainProfile
}
type providerObject struct {
sync.RWMutex
- pt.ProviderProfile
+ types.ProviderProfile
}
type metaIndex struct {
@@ -150,7 +150,7 @@ func (i *metaIndex) IncreaseAccountStableBalance(
err = ErrAccountNotFound
return
}
- if err = safeAdd(&ao.TokenBalance[pt.Particle], &amount); err != nil {
+ if err = safeAdd(&ao.TokenBalance[types.Particle], &amount); err != nil {
return
}
ao.NextNonce++
@@ -185,7 +185,7 @@ func (i *metaIndex) DecreaseAccountStableBalance(
err = ErrAccountNotFound
return
}
- if err = safeSub(&ao.TokenBalance[pt.Particle], &amount); err != nil {
+ if err = safeSub(&ao.TokenBalance[types.Particle], &amount); err != nil {
return
}
ao.NextNonce++
@@ -220,7 +220,7 @@ func (i *metaIndex) IncreaseAccountCovenantBalance(
err = ErrAccountNotFound
return
}
- if err = safeAdd(&ao.TokenBalance[pt.Wave], &amount); err != nil {
+ if err = safeAdd(&ao.TokenBalance[types.Wave], &amount); err != nil {
return
}
ao.NextNonce++
@@ -255,7 +255,7 @@ func (i *metaIndex) DecreaseAccountCovenantBalance(
err = ErrAccountNotFound
return
}
- if err = safeSub(&ao.TokenBalance[pt.Wave], &amount); err != nil {
+ if err = safeSub(&ao.TokenBalance[types.Wave], &amount); err != nil {
return
}
ao.NextNonce++
@@ -292,7 +292,7 @@ func (i *metaIndex) CreateSQLChain(
}
// Create new sqlchainProfile
co = &sqlchainObject{
- SQLChainProfile: pt.SQLChainProfile{
+ SQLChainProfile: types.SQLChainProfile{
ID: id,
Owner: addr,
},
diff --git a/blockproducer/metaindex_test.go b/blockproducer/metaindex_test.go
index 6236a5503..e5145feda 100644
--- a/blockproducer/metaindex_test.go
+++ b/blockproducer/metaindex_test.go
@@ -23,7 +23,7 @@ import (
pi "github.com/CovenantSQL/CovenantSQL/blockproducer/interfaces"
"github.com/CovenantSQL/CovenantSQL/proto"
- pt "github.com/CovenantSQL/CovenantSQL/types"
+ "github.com/CovenantSQL/CovenantSQL/types"
"github.com/coreos/bbolt"
. "github.com/smartystreets/goconvey/convey"
)
@@ -89,12 +89,12 @@ func TestMetaIndex(t *testing.T) {
})
Convey("When database objects are stored", func() {
mi.storeSQLChainObject(&sqlchainObject{
- SQLChainProfile: pt.SQLChainProfile{
+ SQLChainProfile: types.SQLChainProfile{
ID: dbid1,
},
})
mi.storeSQLChainObject(&sqlchainObject{
- SQLChainProfile: pt.SQLChainProfile{
+ SQLChainProfile: types.SQLChainProfile{
ID: dbid2,
},
})
@@ -123,15 +123,15 @@ func TestMetaIndex(t *testing.T) {
})
Convey("When account objects are stored", func() {
mi.storeAccountObject(&accountObject{
- Account: pt.Account{
+ Account: types.Account{
Address: addr1,
- TokenBalance: [pt.SupportTokenNumber]uint64{10, 10},
+ TokenBalance: [types.SupportTokenNumber]uint64{10, 10},
},
})
mi.storeAccountObject(&accountObject{
- Account: pt.Account{
+ Account: types.Account{
Address: addr2,
- TokenBalance: [pt.SupportTokenNumber]uint64{10, 10},
+ TokenBalance: [types.SupportTokenNumber]uint64{10, 10},
},
})
Convey("The account objects should be retrievable", func() {
diff --git a/blockproducer/metastate_test.go b/blockproducer/metastate_test.go
index 3721abefa..46e14c880 100644
--- a/blockproducer/metastate_test.go
+++ b/blockproducer/metastate_test.go
@@ -31,7 +31,6 @@ import (
"github.com/CovenantSQL/CovenantSQL/proto"
"github.com/CovenantSQL/CovenantSQL/route"
"github.com/CovenantSQL/CovenantSQL/types"
- pt "github.com/CovenantSQL/CovenantSQL/types"
"github.com/coreos/bbolt"
"github.com/pkg/errors"
. "github.com/smartystreets/goconvey/convey"
@@ -140,37 +139,37 @@ func TestMetaState(t *testing.T) {
Convey("The metaState should failed to operate SQLChain for unknown user", func() {
err = ms.createSQLChain(addr1, dbid1)
So(err, ShouldEqual, ErrAccountNotFound)
- err = ms.addSQLChainUser(dbid1, addr1, pt.Admin)
+ err = ms.addSQLChainUser(dbid1, addr1, types.Admin)
So(err, ShouldEqual, ErrDatabaseNotFound)
err = ms.deleteSQLChainUser(dbid1, addr1)
So(err, ShouldEqual, ErrDatabaseNotFound)
- err = ms.alterSQLChainUser(dbid1, addr1, pt.Write)
+ err = ms.alterSQLChainUser(dbid1, addr1, types.Write)
So(err, ShouldEqual, ErrDatabaseNotFound)
})
Convey("When new account and database objects are stored", func() {
ao, loaded = ms.loadOrStoreAccountObject(addr1, &accountObject{
- Account: pt.Account{
+ Account: types.Account{
Address: addr1,
},
})
So(ao, ShouldBeNil)
So(loaded, ShouldBeFalse)
ao, loaded = ms.loadOrStoreAccountObject(addr2, &accountObject{
- Account: pt.Account{
+ Account: types.Account{
Address: addr2,
},
})
So(ao, ShouldBeNil)
So(loaded, ShouldBeFalse)
co, loaded = ms.loadOrStoreSQLChainObject(dbid1, &sqlchainObject{
- SQLChainProfile: pt.SQLChainProfile{
+ SQLChainProfile: types.SQLChainProfile{
ID: dbid1,
},
})
So(co, ShouldBeNil)
So(loaded, ShouldBeFalse)
co, loaded = ms.loadOrStoreSQLChainObject(dbid2, &sqlchainObject{
- SQLChainProfile: pt.SQLChainProfile{
+ SQLChainProfile: types.SQLChainProfile{
ID: dbid2,
},
})
@@ -208,9 +207,9 @@ func TestMetaState(t *testing.T) {
So(err, ShouldEqual, ErrDatabaseExists)
})
Convey("When new SQLChain users are added", func() {
- err = ms.addSQLChainUser(dbid3, addr2, pt.Write)
+ err = ms.addSQLChainUser(dbid3, addr2, types.Write)
So(err, ShouldBeNil)
- err = ms.addSQLChainUser(dbid3, addr2, pt.Write)
+ err = ms.addSQLChainUser(dbid3, addr2, types.Write)
So(err, ShouldEqual, ErrDatabaseUserExists)
Convey("The metaState object should be ok to delete user", func() {
err = ms.deleteSQLChainUser(dbid3, addr2)
@@ -219,9 +218,9 @@ func TestMetaState(t *testing.T) {
So(err, ShouldBeNil)
})
Convey("The metaState object should be ok to alter user", func() {
- err = ms.alterSQLChainUser(dbid3, addr2, pt.Read)
+ err = ms.alterSQLChainUser(dbid3, addr2, types.Read)
So(err, ShouldBeNil)
- err = ms.alterSQLChainUser(dbid3, addr2, pt.Write)
+ err = ms.alterSQLChainUser(dbid3, addr2, types.Write)
So(err, ShouldBeNil)
})
Convey("When metaState change is committed", func() {
@@ -234,9 +233,9 @@ func TestMetaState(t *testing.T) {
So(err, ShouldBeNil)
})
Convey("The metaState object should be ok to alter user", func() {
- err = ms.alterSQLChainUser(dbid3, addr2, pt.Read)
+ err = ms.alterSQLChainUser(dbid3, addr2, types.Read)
So(err, ShouldBeNil)
- err = ms.alterSQLChainUser(dbid3, addr2, pt.Write)
+ err = ms.alterSQLChainUser(dbid3, addr2, types.Write)
So(err, ShouldBeNil)
})
})
@@ -245,9 +244,9 @@ func TestMetaState(t *testing.T) {
err = db.Update(ms.commitProcedure())
So(err, ShouldBeNil)
Convey("The metaState object should be ok to add users for database", func() {
- err = ms.addSQLChainUser(dbid3, addr2, pt.Write)
+ err = ms.addSQLChainUser(dbid3, addr2, types.Write)
So(err, ShouldBeNil)
- err = ms.addSQLChainUser(dbid3, addr2, pt.Write)
+ err = ms.addSQLChainUser(dbid3, addr2, types.Write)
So(err, ShouldEqual, ErrDatabaseUserExists)
})
Convey("The metaState object should report database exists", func() {
@@ -303,8 +302,8 @@ func TestMetaState(t *testing.T) {
So(loaded, ShouldBeTrue)
So(ao, ShouldNotBeNil)
So(ao.Address, ShouldEqual, addr1)
- So(ao.TokenBalance[pt.Particle], ShouldEqual, incSta)
- So(ao.TokenBalance[pt.Wave], ShouldEqual, incCov)
+ So(ao.TokenBalance[types.Particle], ShouldEqual, incSta)
+ So(ao.TokenBalance[types.Wave], ShouldEqual, incCov)
bl, loaded = ms.loadAccountStableBalance(addr1)
So(loaded, ShouldBeTrue)
So(bl, ShouldEqual, incSta)
@@ -324,8 +323,8 @@ func TestMetaState(t *testing.T) {
So(loaded, ShouldBeTrue)
So(ao, ShouldNotBeNil)
So(ao.Address, ShouldEqual, addr1)
- So(ao.TokenBalance[pt.Particle], ShouldEqual, incSta-decSta)
- So(ao.TokenBalance[pt.Wave], ShouldEqual, incCov-decCov)
+ So(ao.TokenBalance[types.Particle], ShouldEqual, incSta-decSta)
+ So(ao.TokenBalance[types.Wave], ShouldEqual, incCov-decCov)
},
)
})
@@ -612,11 +611,11 @@ func TestMetaState(t *testing.T) {
Convey("When transactions are added", func() {
var (
n pi.AccountNonce
- t0 = pt.NewBaseAccount(&pt.Account{
+ t0 = types.NewBaseAccount(&types.Account{
Address: addr1,
})
- t1 = pt.NewTransfer(
- &pt.TransferHeader{
+ t1 = types.NewTransfer(
+ &types.TransferHeader{
Sender: addr1,
Receiver: addr2,
Nonce: 1,
@@ -733,20 +732,20 @@ func TestMetaState(t *testing.T) {
Convey("When base account txs are added", func() {
var (
txs = []pi.Transaction{
- pt.NewBaseAccount(
- &pt.Account{
+ types.NewBaseAccount(
+ &types.Account{
Address: addr1,
- TokenBalance: [pt.SupportTokenNumber]uint64{100, 100},
+ TokenBalance: [types.SupportTokenNumber]uint64{100, 100},
},
),
- pt.NewBaseAccount(
- &pt.Account{
+ types.NewBaseAccount(
+ &types.Account{
Address: addr2,
- TokenBalance: [pt.SupportTokenNumber]uint64{100, 100},
+ TokenBalance: [types.SupportTokenNumber]uint64{100, 100},
},
),
- pt.NewTransfer(
- &pt.TransferHeader{
+ types.NewTransfer(
+ &types.TransferHeader{
Sender: addr1,
Receiver: addr2,
Nonce: 1,
@@ -771,32 +770,32 @@ func TestMetaState(t *testing.T) {
Rewards: []uint64{1},
},
),
- pt.NewTransfer(
- &pt.TransferHeader{
+ types.NewTransfer(
+ &types.TransferHeader{
Sender: addr2,
Receiver: addr1,
Nonce: 2,
Amount: 1,
},
),
- pt.NewTransfer(
- &pt.TransferHeader{
+ types.NewTransfer(
+ &types.TransferHeader{
Sender: addr1,
Receiver: addr2,
Nonce: 3,
Amount: 10,
},
),
- pt.NewTransfer(
- &pt.TransferHeader{
+ types.NewTransfer(
+ &types.TransferHeader{
Sender: addr2,
Receiver: addr1,
Nonce: 3,
Amount: 1,
},
),
- pt.NewTransfer(
- &pt.TransferHeader{
+ types.NewTransfer(
+ &types.TransferHeader{
Sender: addr2,
Receiver: addr1,
Nonce: 4,
@@ -901,50 +900,50 @@ func TestMetaState(t *testing.T) {
So(err, ShouldBeNil)
ao, loaded = ms.loadOrStoreAccountObject(addr1,
- &accountObject{Account: pt.Account{
+ &accountObject{Account: types.Account{
Address: addr1,
},
})
So(ao, ShouldBeNil)
So(loaded, ShouldBeFalse)
ao, loaded = ms.loadOrStoreAccountObject(addr2, &accountObject{
- Account: pt.Account{
+ Account: types.Account{
Address: addr2,
},
})
So(ao, ShouldBeNil)
So(loaded, ShouldBeFalse)
ao, loaded = ms.loadOrStoreAccountObject(addr3, &accountObject{
- Account: pt.Account{
+ Account: types.Account{
Address: addr3,
},
})
So(ao, ShouldBeNil)
So(loaded, ShouldBeFalse)
ao, loaded = ms.loadOrStoreAccountObject(addr4, &accountObject{
- Account: pt.Account{
+ Account: types.Account{
Address: addr4,
},
})
So(ao, ShouldBeNil)
So(loaded, ShouldBeFalse)
Convey("When provider transaction is invalid", func() {
- invalidPs := pt.ProvideService{
- ProvideServiceHeader: pt.ProvideServiceHeader{
+ invalidPs := types.ProvideService{
+ ProvideServiceHeader: types.ProvideServiceHeader{
Contract: addr2,
},
}
invalidPs.Sign(privKey1)
- invalidCd1 := pt.CreateDatabase{
- CreateDatabaseHeader: pt.CreateDatabaseHeader{
+ invalidCd1 := types.CreateDatabase{
+ CreateDatabaseHeader: types.CreateDatabaseHeader{
Owner: addr2,
},
}
invalidCd1.Sign(privKey1)
- invalidCd2 := pt.CreateDatabase{
- CreateDatabaseHeader: pt.CreateDatabaseHeader{
+ invalidCd2 := types.CreateDatabase{
+ CreateDatabaseHeader: types.CreateDatabaseHeader{
Owner: addr1,
- ResourceMeta: pt.ResourceMeta{
+ ResourceMeta: types.ResourceMeta{
TargetMiners: []proto.AccountAddress{addr2},
},
},
@@ -959,28 +958,28 @@ func TestMetaState(t *testing.T) {
So(errors.Cause(err), ShouldEqual, ErrNoSuchMiner)
})
Convey("When SQLChain create", func() {
- ps := pt.ProvideService{
- ProvideServiceHeader: pt.ProvideServiceHeader{
+ ps := types.ProvideService{
+ ProvideServiceHeader: types.ProvideServiceHeader{
Contract: addr2,
TargetUser: addr1,
},
}
err = ps.Sign(privKey2)
So(err, ShouldBeNil)
- cd1 := pt.CreateDatabase{
- CreateDatabaseHeader: pt.CreateDatabaseHeader{
+ cd1 := types.CreateDatabase{
+ CreateDatabaseHeader: types.CreateDatabaseHeader{
Owner: addr1,
- ResourceMeta: pt.ResourceMeta{
+ ResourceMeta: types.ResourceMeta{
TargetMiners: []proto.AccountAddress{addr2},
},
},
}
cd1.Sign(privKey1)
So(err, ShouldBeNil)
- cd2 := pt.CreateDatabase{
- CreateDatabaseHeader: pt.CreateDatabaseHeader{
+ cd2 := types.CreateDatabase{
+ CreateDatabaseHeader: types.CreateDatabaseHeader{
Owner: addr3,
- ResourceMeta: pt.ResourceMeta{
+ ResourceMeta: types.ResourceMeta{
TargetMiners: []proto.AccountAddress{addr2},
},
},
@@ -1000,11 +999,11 @@ func TestMetaState(t *testing.T) {
dbAccount, err := dbID.AccountAddress()
So(err, ShouldBeNil)
- up := pt.UpdatePermission{
- UpdatePermissionHeader: pt.UpdatePermissionHeader{
+ up := types.UpdatePermission{
+ UpdatePermissionHeader: types.UpdatePermissionHeader{
TargetSQLChain: addr1,
TargetUser: addr3,
- Permission: pt.Read,
+ Permission: types.Read,
Nonce: cd1.Nonce + 1,
},
}
@@ -1020,7 +1019,7 @@ func TestMetaState(t *testing.T) {
// test permission update
// addr1(admin) update addr3 as admin
up.TargetUser = addr3
- up.Permission = pt.Admin
+ up.Permission = types.Admin
err = up.Sign(privKey1)
So(err, ShouldBeNil)
err = db.Update(ms.applyTransactionProcedure(&up))
@@ -1028,7 +1027,7 @@ func TestMetaState(t *testing.T) {
// addr3(admin) update addr4 as read
up.TargetUser = addr4
up.Nonce = 0
- up.Permission = pt.Read
+ up.Permission = types.Read
err = up.Sign(privKey3)
So(err, ShouldBeNil)
err = db.Update(ms.applyTransactionProcedure(&up))
@@ -1042,7 +1041,7 @@ func TestMetaState(t *testing.T) {
So(err, ShouldBeNil)
// addr3(admin) update addr3(admin) as read fail
up.TargetUser = addr3
- up.Permission = pt.Read
+ up.Permission = types.Read
up.Nonce = up.Nonce + 1
err = up.Sign(privKey3)
So(err, ShouldBeNil)
@@ -1057,15 +1056,15 @@ func TestMetaState(t *testing.T) {
co, loaded = ms.loadSQLChainObject(*dbID)
for _, user := range co.Users {
if user.Address == addr1 {
- So(user.Permission, ShouldEqual, pt.Read)
+ So(user.Permission, ShouldEqual, types.Read)
continue
}
if user.Address == addr3 {
- So(user.Permission, ShouldEqual, pt.Admin)
+ So(user.Permission, ShouldEqual, types.Admin)
continue
}
if user.Address == addr4 {
- So(user.Permission, ShouldEqual, pt.Read)
+ So(user.Permission, ShouldEqual, types.Read)
continue
}
}
diff --git a/blockproducer/rpc.go b/blockproducer/rpc.go
index e3d9444aa..bb71a68d3 100644
--- a/blockproducer/rpc.go
+++ b/blockproducer/rpc.go
@@ -20,7 +20,6 @@ import (
pi "github.com/CovenantSQL/CovenantSQL/blockproducer/interfaces"
"github.com/CovenantSQL/CovenantSQL/proto"
"github.com/CovenantSQL/CovenantSQL/types"
- pt "github.com/CovenantSQL/CovenantSQL/types"
)
// ChainRPCService defines a main chain RPC server.
@@ -31,7 +30,7 @@ type ChainRPCService struct {
// AdviseNewBlockReq defines a request of the AdviseNewBlock RPC method.
type AdviseNewBlockReq struct {
proto.Envelope
- Block *pt.BPBlock
+ Block *types.BPBlock
}
// AdviseNewBlockResp defines a response of the AdviseNewBlock RPC method.
@@ -61,7 +60,7 @@ type FetchBlockResp struct {
proto.Envelope
Height uint32
Count uint32
- Block *pt.BPBlock
+ Block *types.BPBlock
}
// FetchBlockByCountReq define a request of the FetchBlockByCount RPC method.
@@ -125,7 +124,7 @@ type OrderMakerReq struct {
// OrderTakerReq defines a request of the order taker in database market.
type OrderTakerReq struct {
proto.Envelope
- DBMeta pt.ResourceMeta
+ DBMeta types.ResourceMeta
}
// OrderTakerResp defines a response of the order taker in database market.
diff --git a/blockproducer/xxx_test.go b/blockproducer/xxx_test.go
index 8318d6e10..bea04f022 100644
--- a/blockproducer/xxx_test.go
+++ b/blockproducer/xxx_test.go
@@ -32,7 +32,6 @@ import (
"github.com/CovenantSQL/CovenantSQL/pow/cpuminer"
"github.com/CovenantSQL/CovenantSQL/proto"
"github.com/CovenantSQL/CovenantSQL/types"
- pt "github.com/CovenantSQL/CovenantSQL/types"
"github.com/CovenantSQL/CovenantSQL/utils/log"
)
@@ -83,7 +82,7 @@ func randStringBytes(n int) string {
return string(b)
}
-func generateRandomBlock(parent hash.Hash, isGenesis bool) (b *pt.BPBlock, err error) {
+func generateRandomBlock(parent hash.Hash, isGenesis bool) (b *types.BPBlock, err error) {
// Generate key pair
priv, _, err := asymmetric.GenSecp256k1KeyPair()
@@ -94,9 +93,9 @@ func generateRandomBlock(parent hash.Hash, isGenesis bool) (b *pt.BPBlock, err e
h := hash.Hash{}
rand.Read(h[:])
- b = &pt.BPBlock{
- SignedHeader: pt.BPSignedHeader{
- BPHeader: pt.BPHeader{
+ b = &types.BPBlock{
+ SignedHeader: types.BPSignedHeader{
+ BPHeader: types.BPHeader{
Version: 0x01000000,
Producer: proto.AccountAddress(h),
ParentHash: parent,
@@ -116,16 +115,16 @@ func generateRandomBlock(parent hash.Hash, isGenesis bool) (b *pt.BPBlock, err e
} else {
// Create base accounts
var (
- ba1 = pt.NewBaseAccount(
- &pt.Account{
+ ba1 = types.NewBaseAccount(
+ &types.Account{
Address: testAddress1,
- TokenBalance: [pt.SupportTokenNumber]uint64{testInitBalance, testInitBalance},
+ TokenBalance: [types.SupportTokenNumber]uint64{testInitBalance, testInitBalance},
},
)
- ba2 = pt.NewBaseAccount(
- &pt.Account{
+ ba2 = types.NewBaseAccount(
+ &types.Account{
Address: testAddress2,
- TokenBalance: [pt.SupportTokenNumber]uint64{testInitBalance, testInitBalance},
+ TokenBalance: [types.SupportTokenNumber]uint64{testInitBalance, testInitBalance},
},
)
)
@@ -142,7 +141,7 @@ func generateRandomBlock(parent hash.Hash, isGenesis bool) (b *pt.BPBlock, err e
return
}
-func generateRandomBlockWithTransactions(parent hash.Hash, tbs []pi.Transaction) (b *pt.BPBlock, err error) {
+func generateRandomBlockWithTransactions(parent hash.Hash, tbs []pi.Transaction) (b *types.BPBlock, err error) {
// Generate key pair
priv, _, err := asymmetric.GenSecp256k1KeyPair()
@@ -153,9 +152,9 @@ func generateRandomBlockWithTransactions(parent hash.Hash, tbs []pi.Transaction)
h := hash.Hash{}
rand.Read(h[:])
- b = &pt.BPBlock{
- SignedHeader: pt.BPSignedHeader{
- BPHeader: pt.BPHeader{
+ b = &types.BPBlock{
+ SignedHeader: types.BPSignedHeader{
+ BPHeader: types.BPHeader{
Version: 0x01000000,
Producer: proto.AccountAddress(h),
ParentHash: parent,
@@ -169,8 +168,8 @@ func generateRandomBlockWithTransactions(parent hash.Hash, tbs []pi.Transaction)
}
testAddress1Nonce++
- var tr = pt.NewTransfer(
- &pt.TransferHeader{
+ var tr = types.NewTransfer(
+ &types.TransferHeader{
Sender: testAddress1,
Receiver: testAddress2,
Nonce: testAddress1Nonce,
@@ -261,7 +260,7 @@ func generateRandomBillingHeader() (tc *types.BillingHeader, err error) {
return tc, nil
}
-func generateRandomBillingAndBaseAccount() (*pt.BaseAccount, *types.Billing, error) {
+func generateRandomBillingAndBaseAccount() (*types.BaseAccount, *types.Billing, error) {
header, err := generateRandomBillingHeader()
if err != nil {
return nil, nil, err
@@ -275,10 +274,10 @@ func generateRandomBillingAndBaseAccount() (*pt.BaseAccount, *types.Billing, err
return nil, nil, err
}
- txBaseAccount := pt.NewBaseAccount(
- &pt.Account{
+ txBaseAccount := types.NewBaseAccount(
+ &types.Account{
Address: header.Producer,
- TokenBalance: [pt.SupportTokenNumber]uint64{testInitBalance, testInitBalance},
+ TokenBalance: [types.SupportTokenNumber]uint64{testInitBalance, testInitBalance},
},
)
From 63a55676e0f8d7531309c06cc5cc54d43d9f22a9 Mon Sep 17 00:00:00 2001
From: leventeliu
Date: Thu, 29 Nov 2018 11:02:57 +0800
Subject: [PATCH 025/278] Fix DATARACE in testing
---
blockproducer/chain.go | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/blockproducer/chain.go b/blockproducer/chain.go
index 41ef1a576..4b75e903e 100644
--- a/blockproducer/chain.go
+++ b/blockproducer/chain.go
@@ -404,9 +404,9 @@ func (c *Chain) produceBlock(now time.Time) error {
peers := c.rt.getPeers()
for _, s := range peers.Servers {
if !s.IsEqual(&c.rt.nodeID) {
- c.rt.goFunc(func(ctx context.Context, wg *sync.WaitGroup) {
- // Bind NodeID to subroutine
- func(ctx context.Context, wg *sync.WaitGroup, id proto.NodeID) {
+ // Bind NodeID to subroutine
+ func(id proto.NodeID) {
+ c.rt.goFunc(func(ctx context.Context, wg *sync.WaitGroup) {
defer wg.Done()
var (
blockReq = &AdviseNewBlockReq{
@@ -430,8 +430,8 @@ func (c *Chain) produceBlock(now time.Time) error {
"node": id,
}).Debug("success advising block")
}
- }(ctx, wg, s)
- })
+ })
+ }(s)
}
}
From ec3b46dd1241b86c1cd321cc2ddf13e366bf1486 Mon Sep 17 00:00:00 2001
From: zeqing-guo
Date: Thu, 29 Nov 2018 11:25:54 +0800
Subject: [PATCH 026/278] Support db encryption on SQLChainProfile
---
blockproducer/interfaces/transaction.go | 10 +-
blockproducer/metastate.go | 59 ++++++++++--
types/account.go | 5 +-
types/account_gen.go | 36 ++++---
types/init_service_type_gen.go | 21 +++-
types/issuekeys.go | 78 +++++++++++++++
types/issuekeys_gen.go | 104 ++++++++++++++++++++
types/issuekeys_gen_test.go | 121 ++++++++++++++++++++++++
types/updatepermission.go | 4 +-
worker/dbms.go | 48 ++++++++++
worker/errors.go | 7 ++
11 files changed, 463 insertions(+), 30 deletions(-)
create mode 100644 types/issuekeys.go
create mode 100644 types/issuekeys_gen.go
create mode 100644 types/issuekeys_gen_test.go
diff --git a/blockproducer/interfaces/transaction.go b/blockproducer/interfaces/transaction.go
index ee41b7346..d7ed71e9d 100644
--- a/blockproducer/interfaces/transaction.go
+++ b/blockproducer/interfaces/transaction.go
@@ -65,8 +65,10 @@ const (
TransactionTypeCreateDatabase
// TransactionTypeProvideService defines miner providing database service type.
TransactionTypeProvideService
- // TransactionUpdatePermission defines admin user grant/revoke permission type.
- TransactionUpdatePermission
+ // TransactionTypeUpdatePermission defines admin user grant/revoke permission type.
+ TransactionTypeUpdatePermission
+ // TransactionTypeIssueKeys defines SQLChain owner assign symmetric key.
+ TransactionTypeIssueKeys
// TransactionTypeNumber defines transaction types number.
TransactionTypeNumber
)
@@ -93,8 +95,10 @@ func (t TransactionType) String() string {
return "CreateDatabase"
case TransactionTypeProvideService:
return "ProvideService"
- case TransactionUpdatePermission:
+ case TransactionTypeUpdatePermission:
return "UpdatePermission"
+ case TransactionTypeIssueKeys:
+ return "IssueKeys"
default:
return "Unknown"
}
diff --git a/blockproducer/metastate.go b/blockproducer/metastate.go
index ccab0c488..29ec12dba 100644
--- a/blockproducer/metastate.go
+++ b/blockproducer/metastate.go
@@ -18,9 +18,6 @@ package blockproducer
import (
"bytes"
- "sync"
- "time"
-
pi "github.com/CovenantSQL/CovenantSQL/blockproducer/interfaces"
"github.com/CovenantSQL/CovenantSQL/crypto"
"github.com/CovenantSQL/CovenantSQL/crypto/asymmetric"
@@ -33,6 +30,8 @@ import (
"github.com/coreos/bbolt"
"github.com/pkg/errors"
"github.com/ulule/deepcopier"
+ "sync"
+ "time"
)
var (
@@ -893,14 +892,14 @@ func (s *metaState) updatePermission(tx *pt.UpdatePermission) (err error) {
if !loaded {
log.WithFields(log.Fields{
"dbID": tx.TargetSQLChain.DatabaseID(),
- }).WithError(ErrDatabaseNotFound).Error("unexpected error")
+ }).WithError(ErrDatabaseNotFound).Error("unexpected error in updatePermission")
return ErrDatabaseNotFound
}
if tx.Permission >= pt.NumberOfUserPermission {
log.WithFields(log.Fields{
"permission": tx.Permission,
"dbID": tx.TargetSQLChain.DatabaseID(),
- }).WithError(ErrInvalidPermission).Error("unexpected error")
+ }).WithError(ErrInvalidPermission).Error("unexpected error in updatePermission")
return ErrInvalidPermission
}
@@ -918,7 +917,7 @@ func (s *metaState) updatePermission(tx *pt.UpdatePermission) (err error) {
log.WithFields(log.Fields{
"sender": sender,
"dbID": tx.TargetSQLChain,
- }).WithError(ErrAccountPermissionDeny).Error("unexpected error")
+ }).WithError(ErrAccountPermissionDeny).Error("unexpected error in updatePermission")
return ErrAccountPermissionDeny
}
@@ -936,6 +935,52 @@ func (s *metaState) updatePermission(tx *pt.UpdatePermission) (err error) {
return
}
+func (s *metaState) updateKeys(tx *pt.IssueKeys) (err error) {
+ sender := tx.GetAccountAddress()
+ so, loaded := s.loadSQLChainObject(tx.TargetSQLChain.DatabaseID())
+ if !loaded {
+ log.WithFields(log.Fields{
+ "dbID": tx.TargetSQLChain.DatabaseID(),
+ }).WithError(ErrDatabaseNotFound).Error("unexpected error in updateKeys")
+ return ErrDatabaseNotFound
+ }
+
+ // check sender's permission
+ if so.Owner != sender {
+ log.WithFields(log.Fields{
+ "sender": sender,
+ "dbID": tx.TargetSQLChain,
+ }).WithError(ErrAccountPermissionDeny).Error("unexpected error in updateKeys")
+ return ErrAccountPermissionDeny
+ }
+ isAdmin := false
+ for _, user := range so.Users {
+ if sender == user.Address && user.Permission == pt.Admin {
+ isAdmin = true
+ break
+ }
+ }
+ if !isAdmin {
+ log.WithFields(log.Fields{
+ "sender": sender,
+ "dbID": tx.TargetSQLChain,
+ }).WithError(ErrAccountPermissionDeny).Error("unexpected error in updateKeys")
+ return ErrAccountPermissionDeny
+ }
+
+ // update miner's key
+ keyMap := make(map[proto.AccountAddress] string)
+ for i := range tx.MinerKeys {
+ keyMap[tx.MinerKeys[i].Miner] = tx.MinerKeys[i].EncryptionKey
+ }
+ for _, miner := range so.Miners {
+ if key, ok := keyMap[miner.Address]; ok {
+ miner.EncryptionKey = key
+ }
+ }
+ return
+}
+
func (s *metaState) applyTransaction(tx pi.Transaction) (err error) {
switch t := tx.(type) {
case *pt.Transfer:
@@ -961,6 +1006,8 @@ func (s *metaState) applyTransaction(tx pi.Transaction) (err error) {
err = s.matchProvidersWithUser(t)
case *pt.UpdatePermission:
err = s.updatePermission(t)
+ case *pt.IssueKeys:
+ err = s.updateKeys(t)
case *pi.TransactionWrapper:
// call again using unwrapped transaction
err = s.applyTransaction(t.Unwrap())
diff --git a/types/account.go b/types/account.go
index a9506e8fc..36cfc1689 100644
--- a/types/account.go
+++ b/types/account.go
@@ -41,10 +41,10 @@ type UserPermission int32
const (
// Admin defines the admin user permission.
Admin UserPermission = iota
- // Read defines the reader user permission.
- Read
// Write defines the writer user permission.
Write
+ // Read defines the reader user permission.
+ Read
// NumberOfUserPermission defines the user permission number.
NumberOfUserPermission
)
@@ -83,6 +83,7 @@ type MinerInfo struct {
ReceivedIncome uint64
Pledge uint64
Status Status
+ EncryptionKey string
}
// SQLChainProfile defines a SQLChainProfile related to an account.
diff --git a/types/account_gen.go b/types/account_gen.go
index e1bb53cb6..aa51ff8d6 100644
--- a/types/account_gen.go
+++ b/types/account_gen.go
@@ -43,29 +43,31 @@ func (z *Account) Msgsize() (s int) {
func (z *MinerInfo) MarshalHash() (o []byte, err error) {
var b []byte
o = hsp.Require(b, z.Msgsize())
- // map header, size 6
- o = append(o, 0x86, 0x86)
+ // map header, size 7
+ o = append(o, 0x87, 0x87)
o = hsp.AppendInt32(o, int32(z.Status))
- o = append(o, 0x86)
+ o = append(o, 0x87)
if oTemp, err := z.Address.MarshalHash(); err != nil {
return nil, err
} else {
o = hsp.AppendBytes(o, oTemp)
}
- o = append(o, 0x86)
+ o = append(o, 0x87)
o = hsp.AppendString(o, z.Name)
- o = append(o, 0x86)
+ o = append(o, 0x87)
+ o = hsp.AppendString(o, z.EncryptionKey)
+ o = append(o, 0x87)
o = hsp.AppendUint64(o, z.PendingIncome)
- o = append(o, 0x86)
+ o = append(o, 0x87)
o = hsp.AppendUint64(o, z.ReceivedIncome)
- o = append(o, 0x86)
+ o = append(o, 0x87)
o = hsp.AppendUint64(o, z.Pledge)
return
}
// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (z *MinerInfo) Msgsize() (s int) {
- s = 1 + 7 + hsp.Int32Size + 8 + z.Address.Msgsize() + 5 + hsp.StringPrefixSize + len(z.Name) + 14 + hsp.Uint64Size + 15 + hsp.Uint64Size + 7 + hsp.Uint64Size
+ s = 1 + 7 + hsp.Int32Size + 8 + z.Address.Msgsize() + 5 + hsp.StringPrefixSize + len(z.Name) + 14 + hsp.StringPrefixSize + len(z.EncryptionKey) + 14 + hsp.Uint64Size + 15 + hsp.Uint64Size + 7 + hsp.Uint64Size
return
}
@@ -73,25 +75,31 @@ func (z *MinerInfo) Msgsize() (s int) {
func (z *ProviderProfile) MarshalHash() (o []byte, err error) {
var b []byte
o = hsp.Require(b, z.Msgsize())
- // map header, size 4
- o = append(o, 0x84, 0x84)
+ // map header, size 5
+ o = append(o, 0x85, 0x85)
if oTemp, err := z.Provider.MarshalHash(); err != nil {
return nil, err
} else {
o = hsp.AppendBytes(o, oTemp)
}
- o = append(o, 0x84)
+ o = append(o, 0x85)
+ if oTemp, err := z.TargetUser.MarshalHash(); err != nil {
+ return nil, err
+ } else {
+ o = hsp.AppendBytes(o, oTemp)
+ }
+ o = append(o, 0x85)
o = hsp.AppendUint64(o, z.Space)
- o = append(o, 0x84)
+ o = append(o, 0x85)
o = hsp.AppendUint64(o, z.Memory)
- o = append(o, 0x84)
+ o = append(o, 0x85)
o = hsp.AppendUint64(o, z.LoadAvgPerCPU)
return
}
// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (z *ProviderProfile) Msgsize() (s int) {
- s = 1 + 9 + z.Provider.Msgsize() + 6 + hsp.Uint64Size + 7 + hsp.Uint64Size + 14 + hsp.Uint64Size
+ s = 1 + 9 + z.Provider.Msgsize() + 11 + z.TargetUser.Msgsize() + 6 + hsp.Uint64Size + 7 + hsp.Uint64Size + 14 + hsp.Uint64Size
return
}
diff --git a/types/init_service_type_gen.go b/types/init_service_type_gen.go
index 27008aa2e..7ff4eb63a 100644
--- a/types/init_service_type_gen.go
+++ b/types/init_service_type_gen.go
@@ -31,8 +31,19 @@ func (z *InitServiceResponse) MarshalHash() (o []byte, err error) {
var b []byte
o = hsp.Require(b, z.Msgsize())
// map header, size 1
- o = append(o, 0x81, 0x81)
- if oTemp, err := z.Header.MarshalHash(); err != nil {
+ // map header, size 2
+ // map header, size 1
+ o = append(o, 0x81, 0x81, 0x82, 0x82, 0x81, 0x81)
+ o = hsp.AppendArrayHeader(o, uint32(len(z.Header.InitServiceResponseHeader.Instances)))
+ for za0001 := range z.Header.InitServiceResponseHeader.Instances {
+ if oTemp, err := z.Header.InitServiceResponseHeader.Instances[za0001].MarshalHash(); err != nil {
+ return nil, err
+ } else {
+ o = hsp.AppendBytes(o, oTemp)
+ }
+ }
+ o = append(o, 0x82)
+ if oTemp, err := z.Header.DefaultHashSignVerifierImpl.MarshalHash(); err != nil {
return nil, err
} else {
o = hsp.AppendBytes(o, oTemp)
@@ -42,7 +53,11 @@ func (z *InitServiceResponse) MarshalHash() (o []byte, err error) {
// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (z *InitServiceResponse) Msgsize() (s int) {
- s = 1 + 7 + z.Header.Msgsize()
+ s = 1 + 7 + 1 + 26 + 1 + 10 + hsp.ArrayHeaderSize
+ for za0001 := range z.Header.InitServiceResponseHeader.Instances {
+ s += z.Header.InitServiceResponseHeader.Instances[za0001].Msgsize()
+ }
+ s += 28 + z.Header.DefaultHashSignVerifierImpl.Msgsize()
return
}
diff --git a/types/issuekeys.go b/types/issuekeys.go
new file mode 100644
index 000000000..b12f82533
--- /dev/null
+++ b/types/issuekeys.go
@@ -0,0 +1,78 @@
+/*
+ * Copyright 2018 The CovenantSQL Authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package types
+
+import (
+ "github.com/CovenantSQL/CovenantSQL/blockproducer/interfaces"
+ "github.com/CovenantSQL/CovenantSQL/crypto"
+ "github.com/CovenantSQL/CovenantSQL/crypto/asymmetric"
+ "github.com/CovenantSQL/CovenantSQL/crypto/verifier"
+ "github.com/CovenantSQL/CovenantSQL/proto"
+)
+
+//go:generate hsp
+
+type MinerKey struct {
+ Miner proto.AccountAddress
+ EncryptionKey string
+}
+
+type IssueKeysHeader struct {
+ TargetSQLChain proto.AccountAddress
+ MinerKeys []MinerKey
+ Nonce interfaces.AccountNonce
+}
+
+// GetAccountNonce implements interfaces/Transaction.GetAccountNonce.
+func (h *IssueKeysHeader) GetAccountNonce() interfaces.AccountNonce {
+ return h.Nonce
+}
+
+// IssueKeys defines the database creation transaction.
+type IssueKeys struct {
+ IssueKeysHeader
+ interfaces.TransactionTypeMixin
+ verifier.DefaultHashSignVerifierImpl
+}
+
+// NewIssueKeys returns new instance.
+func NewIssueKeys(header *IssueKeysHeader) *IssueKeys {
+ return &IssueKeys{
+ IssueKeysHeader: *header,
+ TransactionTypeMixin: *interfaces.NewTransactionTypeMixin(interfaces.TransactionTypeIssueKeys),
+ }
+}
+
+// Sign implements interfaces/Transaction.Sign.
+func (ik *IssueKeys) Sign(signer *asymmetric.PrivateKey) (err error) {
+ return ik.DefaultHashSignVerifierImpl.Sign(&ik.IssueKeysHeader, signer)
+}
+
+// Verify implements interfaces/Transaction.Verify.
+func (ik *IssueKeys) Verify() error {
+ return ik.DefaultHashSignVerifierImpl.Verify(&ik.IssueKeysHeader)
+}
+
+// GetAccountAddress implements interfaces/Transaction.GetAccountAddress.
+func (ik *IssueKeys) GetAccountAddress() proto.AccountAddress {
+ addr, _ := crypto.PubKeyHash(ik.Signee)
+ return addr
+}
+
+func init() {
+ interfaces.RegisterTransaction(interfaces.TransactionTypeIssueKeys, (*IssueKeys)(nil))
+}
diff --git a/types/issuekeys_gen.go b/types/issuekeys_gen.go
new file mode 100644
index 000000000..79e86df52
--- /dev/null
+++ b/types/issuekeys_gen.go
@@ -0,0 +1,104 @@
+package types
+
+// Code generated by github.com/CovenantSQL/HashStablePack DO NOT EDIT.
+
+import (
+ hsp "github.com/CovenantSQL/HashStablePack/marshalhash"
+)
+
+// MarshalHash marshals for hash
+func (z *IssueKeys) MarshalHash() (o []byte, err error) {
+ var b []byte
+ o = hsp.Require(b, z.Msgsize())
+ // map header, size 3
+ o = append(o, 0x83, 0x83)
+ if oTemp, err := z.IssueKeysHeader.MarshalHash(); err != nil {
+ return nil, err
+ } else {
+ o = hsp.AppendBytes(o, oTemp)
+ }
+ o = append(o, 0x83)
+ if oTemp, err := z.TransactionTypeMixin.MarshalHash(); err != nil {
+ return nil, err
+ } else {
+ o = hsp.AppendBytes(o, oTemp)
+ }
+ o = append(o, 0x83)
+ if oTemp, err := z.DefaultHashSignVerifierImpl.MarshalHash(); err != nil {
+ return nil, err
+ } else {
+ o = hsp.AppendBytes(o, oTemp)
+ }
+ return
+}
+
+// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
+func (z *IssueKeys) Msgsize() (s int) {
+ s = 1 + 16 + z.IssueKeysHeader.Msgsize() + 21 + z.TransactionTypeMixin.Msgsize() + 28 + z.DefaultHashSignVerifierImpl.Msgsize()
+ return
+}
+
+// MarshalHash marshals for hash
+func (z *IssueKeysHeader) MarshalHash() (o []byte, err error) {
+ var b []byte
+ o = hsp.Require(b, z.Msgsize())
+ // map header, size 3
+ o = append(o, 0x83, 0x83)
+ o = hsp.AppendArrayHeader(o, uint32(len(z.MinerKeys)))
+ for za0001 := range z.MinerKeys {
+ // map header, size 2
+ o = append(o, 0x82, 0x82)
+ if oTemp, err := z.MinerKeys[za0001].Miner.MarshalHash(); err != nil {
+ return nil, err
+ } else {
+ o = hsp.AppendBytes(o, oTemp)
+ }
+ o = append(o, 0x82)
+ o = hsp.AppendString(o, z.MinerKeys[za0001].EncryptionKey)
+ }
+ o = append(o, 0x83)
+ if oTemp, err := z.Nonce.MarshalHash(); err != nil {
+ return nil, err
+ } else {
+ o = hsp.AppendBytes(o, oTemp)
+ }
+ o = append(o, 0x83)
+ if oTemp, err := z.TargetSQLChain.MarshalHash(); err != nil {
+ return nil, err
+ } else {
+ o = hsp.AppendBytes(o, oTemp)
+ }
+ return
+}
+
+// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
+func (z *IssueKeysHeader) Msgsize() (s int) {
+ s = 1 + 10 + hsp.ArrayHeaderSize
+ for za0001 := range z.MinerKeys {
+ s += 1 + 6 + z.MinerKeys[za0001].Miner.Msgsize() + 14 + hsp.StringPrefixSize + len(z.MinerKeys[za0001].EncryptionKey)
+ }
+ s += 6 + z.Nonce.Msgsize() + 15 + z.TargetSQLChain.Msgsize()
+ return
+}
+
+// MarshalHash marshals for hash
+func (z *MinerKey) MarshalHash() (o []byte, err error) {
+ var b []byte
+ o = hsp.Require(b, z.Msgsize())
+ // map header, size 2
+ o = append(o, 0x82, 0x82)
+ if oTemp, err := z.Miner.MarshalHash(); err != nil {
+ return nil, err
+ } else {
+ o = hsp.AppendBytes(o, oTemp)
+ }
+ o = append(o, 0x82)
+ o = hsp.AppendString(o, z.EncryptionKey)
+ return
+}
+
+// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
+func (z *MinerKey) Msgsize() (s int) {
+ s = 1 + 6 + z.Miner.Msgsize() + 14 + hsp.StringPrefixSize + len(z.EncryptionKey)
+ return
+}
diff --git a/types/issuekeys_gen_test.go b/types/issuekeys_gen_test.go
new file mode 100644
index 000000000..30b7fc1ac
--- /dev/null
+++ b/types/issuekeys_gen_test.go
@@ -0,0 +1,121 @@
+package types
+
+// Code generated by github.com/CovenantSQL/HashStablePack DO NOT EDIT.
+
+import (
+ "bytes"
+ "crypto/rand"
+ "encoding/binary"
+ "testing"
+)
+
+func TestMarshalHashIssueKeys(t *testing.T) {
+ v := IssueKeys{}
+ binary.Read(rand.Reader, binary.BigEndian, &v)
+ bts1, err := v.MarshalHash()
+ if err != nil {
+ t.Fatal(err)
+ }
+ bts2, err := v.MarshalHash()
+ if err != nil {
+ t.Fatal(err)
+ }
+ if !bytes.Equal(bts1, bts2) {
+ t.Fatal("hash not stable")
+ }
+}
+
+func BenchmarkMarshalHashIssueKeys(b *testing.B) {
+ v := IssueKeys{}
+ b.ReportAllocs()
+ b.ResetTimer()
+ for i := 0; i < b.N; i++ {
+ v.MarshalHash()
+ }
+}
+
+func BenchmarkAppendMsgIssueKeys(b *testing.B) {
+ v := IssueKeys{}
+ bts := make([]byte, 0, v.Msgsize())
+ bts, _ = v.MarshalHash()
+ b.SetBytes(int64(len(bts)))
+ b.ReportAllocs()
+ b.ResetTimer()
+ for i := 0; i < b.N; i++ {
+ bts, _ = v.MarshalHash()
+ }
+}
+
+func TestMarshalHashIssueKeysHeader(t *testing.T) {
+ v := IssueKeysHeader{}
+ binary.Read(rand.Reader, binary.BigEndian, &v)
+ bts1, err := v.MarshalHash()
+ if err != nil {
+ t.Fatal(err)
+ }
+ bts2, err := v.MarshalHash()
+ if err != nil {
+ t.Fatal(err)
+ }
+ if !bytes.Equal(bts1, bts2) {
+ t.Fatal("hash not stable")
+ }
+}
+
+func BenchmarkMarshalHashIssueKeysHeader(b *testing.B) {
+ v := IssueKeysHeader{}
+ b.ReportAllocs()
+ b.ResetTimer()
+ for i := 0; i < b.N; i++ {
+ v.MarshalHash()
+ }
+}
+
+func BenchmarkAppendMsgIssueKeysHeader(b *testing.B) {
+ v := IssueKeysHeader{}
+ bts := make([]byte, 0, v.Msgsize())
+ bts, _ = v.MarshalHash()
+ b.SetBytes(int64(len(bts)))
+ b.ReportAllocs()
+ b.ResetTimer()
+ for i := 0; i < b.N; i++ {
+ bts, _ = v.MarshalHash()
+ }
+}
+
+func TestMarshalHashMinerKey(t *testing.T) {
+ v := MinerKey{}
+ binary.Read(rand.Reader, binary.BigEndian, &v)
+ bts1, err := v.MarshalHash()
+ if err != nil {
+ t.Fatal(err)
+ }
+ bts2, err := v.MarshalHash()
+ if err != nil {
+ t.Fatal(err)
+ }
+ if !bytes.Equal(bts1, bts2) {
+ t.Fatal("hash not stable")
+ }
+}
+
+func BenchmarkMarshalHashMinerKey(b *testing.B) {
+ v := MinerKey{}
+ b.ReportAllocs()
+ b.ResetTimer()
+ for i := 0; i < b.N; i++ {
+ v.MarshalHash()
+ }
+}
+
+func BenchmarkAppendMsgMinerKey(b *testing.B) {
+ v := MinerKey{}
+ bts := make([]byte, 0, v.Msgsize())
+ bts, _ = v.MarshalHash()
+ b.SetBytes(int64(len(bts)))
+ b.ReportAllocs()
+ b.ResetTimer()
+ for i := 0; i < b.N; i++ {
+ bts, _ = v.MarshalHash()
+ }
+}
diff --git a/types/updatepermission.go b/types/updatepermission.go
index 22da0e158..1b7ed46a6 100644
--- a/types/updatepermission.go
+++ b/types/updatepermission.go
@@ -50,7 +50,7 @@ type UpdatePermission struct {
func NewUpdatePermission(header *UpdatePermissionHeader) *UpdatePermission {
return &UpdatePermission{
UpdatePermissionHeader: *header,
- TransactionTypeMixin: *interfaces.NewTransactionTypeMixin(interfaces.TransactionUpdatePermission),
+ TransactionTypeMixin: *interfaces.NewTransactionTypeMixin(interfaces.TransactionTypeUpdatePermission),
}
}
@@ -71,5 +71,5 @@ func (up *UpdatePermission) GetAccountAddress() proto.AccountAddress {
}
func init() {
- interfaces.RegisterTransaction(interfaces.TransactionUpdatePermission, (*UpdatePermission)(nil))
+ interfaces.RegisterTransaction(interfaces.TransactionTypeUpdatePermission, (*UpdatePermission)(nil))
}
diff --git a/worker/dbms.go b/worker/dbms.go
index 647d4d786..fe79171b5 100644
--- a/worker/dbms.go
+++ b/worker/dbms.go
@@ -18,6 +18,7 @@ package worker
import (
"bytes"
+ "github.com/CovenantSQL/CovenantSQL/crypto"
"io/ioutil"
"os"
"path/filepath"
@@ -48,6 +49,8 @@ type DBMS struct {
kayakMux *DBKayakMuxService
chainMux *sqlchain.MuxService
rpc *DBMSRPCService
+ // TODO(lambda): change it to chain bus after chain bus finished.
+ profileMap map[proto.DatabaseID]*types.SQLChainProfile
}
// NewDBMS returns new database management instance.
@@ -261,6 +264,16 @@ func (dbms *DBMS) Query(req *types.Request) (res *types.Response, err error) {
var db *Database
var exists bool
+ // check permission
+ addr, err := crypto.PubKeyHash(req.Header.Signee)
+ if err != nil {
+ return
+ }
+ err = dbms.checkPermission(addr, req)
+ if err != nil {
+ return
+ }
+
// find database
if db, exists = dbms.getMeta(req.Header.DatabaseID); !exists {
err = ErrNotExists
@@ -334,6 +347,41 @@ func (dbms *DBMS) getMappedInstances() (instances []types.ServiceInstance, err e
return
}
+func (dbms *DBMS) checkPermission(addr proto.AccountAddress, req *types.Request) (err error) {
+ // TODO(lambda): change it to chain bus after chain bus finished.
+ profile := dbms.profileMap[req.Header.DatabaseID]
+ if profile != nil {
+ var i int
+ var user *types.SQLChainUser
+ for i, user = range profile.Users {
+ if user.Address == addr {
+ break
+ }
+ }
+ profileLen := len(profile.Users)
+ if i < profileLen && profileLen > 0 {
+ if req.Header.QueryType == types.ReadQuery {
+ if profile.Users[i].Permission > types.Read {
+ err = ErrPermissionDeny
+ return
+ }
+ } else if req.Header.QueryType == types.WriteQuery {
+ if profile.Users[i].Permission > types.Write {
+ err = ErrPermissionDeny
+ return
+ }
+ } else {
+ err = ErrInvalidPermission
+ return
+ }
+ } else {
+ err = ErrPermissionDeny
+ return
+ }
+ }
+ return
+}
+
// Shutdown defines dbms shutdown logic.
func (dbms *DBMS) Shutdown() (err error) {
dbms.dbMap.Range(func(_, rawDB interface{}) bool {
diff --git a/worker/errors.go b/worker/errors.go
index 02f832ea7..49232895a 100644
--- a/worker/errors.go
+++ b/worker/errors.go
@@ -42,4 +42,11 @@ var (
// ErrUnknownMuxRequest indicates that the a multiplexing request endpoint is not found.
ErrUnknownMuxRequest = errors.New("unknown multiplexing request")
+
+ // ErrPermissionDeny indicates that the requester has no permission to send read or write query.
+ ErrPermissionDeny = errors.New("permission deny")
+
+ // ErrInvalidPermission indicates that the requester sends a unrecognized permission.
+ ErrInvalidPermission = errors.New("invalid permission")
+
)
From b502fdc2d96ef507780c5960737026e3ea6e1873 Mon Sep 17 00:00:00 2001
From: leventeliu
Date: Thu, 29 Nov 2018 11:26:42 +0800
Subject: [PATCH 027/278] Simplify goFunc of chain runtime
---
blockproducer/chain.go | 13 ++++---------
blockproducer/runtime.go | 7 +++++--
2 files changed, 9 insertions(+), 11 deletions(-)
diff --git a/blockproducer/chain.go b/blockproducer/chain.go
index 4b75e903e..2b9ba794f 100644
--- a/blockproducer/chain.go
+++ b/blockproducer/chain.go
@@ -406,8 +406,7 @@ func (c *Chain) produceBlock(now time.Time) error {
if !s.IsEqual(&c.rt.nodeID) {
// Bind NodeID to subroutine
func(id proto.NodeID) {
- c.rt.goFunc(func(ctx context.Context, wg *sync.WaitGroup) {
- defer wg.Done()
+ c.rt.goFunc(func(ctx context.Context) {
var (
blockReq = &AdviseNewBlockReq{
Envelope: proto.Envelope{
@@ -614,7 +613,7 @@ func (c *Chain) Start() error {
return nil
}
-func (c *Chain) processBlocks(ctx context.Context, wg *sync.WaitGroup) {
+func (c *Chain) processBlocks(ctx context.Context) {
var (
returnStash = func(ctx context.Context, wg *sync.WaitGroup, stash []*types.BPBlock) {
defer wg.Done()
@@ -635,8 +634,6 @@ func (c *Chain) processBlocks(ctx context.Context, wg *sync.WaitGroup) {
// Wait for subroutines to exit
subCancel()
subWg.Wait()
- // Parent done
- wg.Done()
}()
var stash []*types.BPBlock
@@ -690,8 +687,7 @@ func (c *Chain) processTx(tx pi.Transaction) {
c.bs.Publish(txEvent, tx)
}
-func (c *Chain) processTxs(ctx context.Context, wg *sync.WaitGroup) {
- defer wg.Done()
+func (c *Chain) processTxs(ctx context.Context) {
for {
select {
case tx := <-c.pendingTxs:
@@ -702,8 +698,7 @@ func (c *Chain) processTxs(ctx context.Context, wg *sync.WaitGroup) {
}
}
-func (c *Chain) mainCycle(ctx context.Context, wg *sync.WaitGroup) {
- defer wg.Done()
+func (c *Chain) mainCycle(ctx context.Context) {
for {
select {
case <-ctx.Done():
diff --git a/blockproducer/runtime.go b/blockproducer/runtime.go
index 9af6dd0a2..f369ce066 100644
--- a/blockproducer/runtime.go
+++ b/blockproducer/runtime.go
@@ -179,7 +179,10 @@ func (r *rt) stop() {
r.wg.Wait()
}
-func (r *rt) goFunc(f func(ctx context.Context, wg *sync.WaitGroup)) {
+func (r *rt) goFunc(f func(ctx context.Context)) {
r.wg.Add(1)
- go f(r.ctx, r.wg)
+ go func() {
+ f(r.ctx)
+ r.wg.Done()
+ }()
}
From a524e2671dbb13b1fcbb1e7746bd10c89e423562 Mon Sep 17 00:00:00 2001
From: leventeliu
Date: Thu, 29 Nov 2018 11:29:57 +0800
Subject: [PATCH 028/278] Use defer to decrement WaitGroup counter
---
blockproducer/runtime.go | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/blockproducer/runtime.go b/blockproducer/runtime.go
index f369ce066..f9a5f593b 100644
--- a/blockproducer/runtime.go
+++ b/blockproducer/runtime.go
@@ -182,7 +182,7 @@ func (r *rt) stop() {
func (r *rt) goFunc(f func(ctx context.Context)) {
r.wg.Add(1)
go func() {
+ defer r.wg.Done()
f(r.ctx)
- r.wg.Done()
}()
}
From acaf2cbbf2649c121aa4f96fbaa9edd57e86d43c Mon Sep 17 00:00:00 2001
From: zeqing-guo
Date: Thu, 29 Nov 2018 11:32:40 +0800
Subject: [PATCH 029/278] Format code
---
blockproducer/metastate.go | 7 ++++---
types/account.go | 2 +-
types/issuekeys.go | 8 ++++----
worker/dbms.go | 2 +-
worker/errors.go | 1 -
5 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/blockproducer/metastate.go b/blockproducer/metastate.go
index 29ec12dba..136f9068c 100644
--- a/blockproducer/metastate.go
+++ b/blockproducer/metastate.go
@@ -18,6 +18,9 @@ package blockproducer
import (
"bytes"
+ "sync"
+ "time"
+
pi "github.com/CovenantSQL/CovenantSQL/blockproducer/interfaces"
"github.com/CovenantSQL/CovenantSQL/crypto"
"github.com/CovenantSQL/CovenantSQL/crypto/asymmetric"
@@ -30,8 +33,6 @@ import (
"github.com/coreos/bbolt"
"github.com/pkg/errors"
"github.com/ulule/deepcopier"
- "sync"
- "time"
)
var (
@@ -969,7 +970,7 @@ func (s *metaState) updateKeys(tx *pt.IssueKeys) (err error) {
}
// update miner's key
- keyMap := make(map[proto.AccountAddress] string)
+ keyMap := make(map[proto.AccountAddress]string)
for i := range tx.MinerKeys {
keyMap[tx.MinerKeys[i].Miner] = tx.MinerKeys[i].EncryptionKey
}
diff --git a/types/account.go b/types/account.go
index 36cfc1689..f3840c1dc 100644
--- a/types/account.go
+++ b/types/account.go
@@ -83,7 +83,7 @@ type MinerInfo struct {
ReceivedIncome uint64
Pledge uint64
Status Status
- EncryptionKey string
+ EncryptionKey string
}
// SQLChainProfile defines a SQLChainProfile related to an account.
diff --git a/types/issuekeys.go b/types/issuekeys.go
index b12f82533..446a772b0 100644
--- a/types/issuekeys.go
+++ b/types/issuekeys.go
@@ -27,14 +27,14 @@ import (
//go:generate hsp
type MinerKey struct {
- Miner proto.AccountAddress
+ Miner proto.AccountAddress
EncryptionKey string
}
type IssueKeysHeader struct {
TargetSQLChain proto.AccountAddress
- MinerKeys []MinerKey
- Nonce interfaces.AccountNonce
+ MinerKeys []MinerKey
+ Nonce interfaces.AccountNonce
}
// GetAccountNonce implements interfaces/Transaction.GetAccountNonce.
@@ -52,7 +52,7 @@ type IssueKeys struct {
// NewIssueKeys returns new instance.
func NewIssueKeys(header *IssueKeysHeader) *IssueKeys {
return &IssueKeys{
- IssueKeysHeader: *header,
+ IssueKeysHeader: *header,
TransactionTypeMixin: *interfaces.NewTransactionTypeMixin(interfaces.TransactionTypeIssueKeys),
}
}
diff --git a/worker/dbms.go b/worker/dbms.go
index fe79171b5..61e7e76aa 100644
--- a/worker/dbms.go
+++ b/worker/dbms.go
@@ -18,12 +18,12 @@ package worker
import (
"bytes"
- "github.com/CovenantSQL/CovenantSQL/crypto"
"io/ioutil"
"os"
"path/filepath"
"sync"
+ "github.com/CovenantSQL/CovenantSQL/crypto"
"github.com/CovenantSQL/CovenantSQL/proto"
"github.com/CovenantSQL/CovenantSQL/route"
"github.com/CovenantSQL/CovenantSQL/rpc"
diff --git a/worker/errors.go b/worker/errors.go
index 49232895a..cd754221f 100644
--- a/worker/errors.go
+++ b/worker/errors.go
@@ -48,5 +48,4 @@ var (
// ErrInvalidPermission indicates that the requester sends a unrecognized permission.
ErrInvalidPermission = errors.New("invalid permission")
-
)
From bb2e01c1c69eb5eccbc7c328949667ed7ee7279f Mon Sep 17 00:00:00 2001
From: zeqing-guo
Date: Wed, 5 Dec 2018 00:38:35 +0800
Subject: [PATCH 030/278] Add chain-bus on sqlchain
---
blockproducer/chain.go | 70 +++++++++------
blockproducer/rpc.go | 165 +++++-------------------------------
chainbus/bus.go | 19 +++--
client/driver.go | 8 +-
client/helper_test.go | 9 +-
cmd/cql-explorer/service.go | 5 +-
cmd/cql-faucet/verifier.go | 13 ++-
cmd/cql-utils/rpc.go | 3 +-
route/acl.go | 4 +
sqlchain/chainbusservice.go | 145 +++++++++++++++++++++++++++++++
types/bprpc.go | 160 ++++++++++++++++++++++++++++++++++
11 files changed, 402 insertions(+), 199 deletions(-)
create mode 100644 sqlchain/chainbusservice.go
create mode 100644 types/bprpc.go
diff --git a/blockproducer/chain.go b/blockproducer/chain.go
index 2b9ba794f..1c7b0afd1 100644
--- a/blockproducer/chain.go
+++ b/blockproducer/chain.go
@@ -408,13 +408,13 @@ func (c *Chain) produceBlock(now time.Time) error {
func(id proto.NodeID) {
c.rt.goFunc(func(ctx context.Context) {
var (
- blockReq = &AdviseNewBlockReq{
+ blockReq = &types.AdviseNewBlockReq{
Envelope: proto.Envelope{
// TODO(lambda): Add fields.
},
Block: b,
}
- blockResp = &AdviseNewBlockResp{}
+ blockResp = &types.AdviseNewBlockResp{}
)
if err := c.cl.CallNodeWithContext(
ctx, id, route.MCCAdviseNewBlock.String(), blockReq, blockResp,
@@ -504,43 +504,65 @@ func (c *Chain) checkBillingRequest(br *types.BillingRequest) (err error) {
}
func (c *Chain) fetchBlockByHeight(h uint32) (b *types.BPBlock, count uint32, err error) {
- node := c.rt.getHead().Node.ancestor(h)
- if node == nil {
- return nil, 0, ErrNoSuchBlock
+ n := c.rt.getHead().Node.ancestor(h)
+ if n == nil {
+ err = errors.Wrapf(ErrNoSuchBlock, "not %d height block", count)
+ return
}
- b = &types.BPBlock{}
- k := node.indexKey()
-
- err = c.db.View(func(tx *bolt.Tx) error {
- v := tx.Bucket(metaBucket[:]).Bucket(metaBlockIndexBucket).Get(k)
- return utils.DecodeMsgPack(v, b)
- })
+ b, err = c.fetchBlockByIndexKey(n.indexKey())
if err != nil {
- return nil, 0, err
+ err = errors.Wrapf(err, "not %d height block", count)
+ return
}
- return b, node.count, nil
+ return b, n.count, nil
}
func (c *Chain) fetchBlockByCount(count uint32) (b *types.BPBlock, height uint32, err error) {
- node := c.rt.getHead().Node.ancestorByCount(count)
- if node == nil {
- return nil, 0, ErrNoSuchBlock
+ n := c.rt.getHead().Node.ancestorByCount(count)
+ if n == nil {
+ err = errors.Wrapf(ErrNoSuchBlock, "not %d count block", count)
+ return
}
- b = &types.BPBlock{}
- k := node.indexKey()
+ b, err = c.fetchBlockByIndexKey(n.indexKey())
+ if err != nil {
+ err = errors.Wrapf(err, "not %d count block", count)
+ return
+ }
+
+ return b, n.height, nil
+}
+
+func (c *Chain) fetchLastBlock() (b *types.BPBlock, count uint32, height uint32, err error) {
+ n := c.rt.getHead().Node
+ if n == nil {
+ err = errors.Wrap(ErrNoSuchBlock, "no last block")
+ return
+ }
+ b, err = c.fetchBlockByIndexKey(n.indexKey())
+ if err != nil {
+ err = errors.Wrap(err, "no last block")
+ return
+ }
+ count = n.count
+ height = n.height
+ return
+}
+
+func (c *Chain) fetchBlockByIndexKey(key []byte) (b *types.BPBlock, err error) {
+ b = &types.BPBlock{}
err = c.db.View(func(tx *bolt.Tx) error {
- v := tx.Bucket(metaBucket[:]).Bucket(metaBlockIndexBucket).Get(k)
+ v := tx.Bucket(metaBucket[:]).Bucket(metaBlockIndexBucket).Get(key)
return utils.DecodeMsgPack(v, b)
})
if err != nil {
- return nil, 0, err
+ return
}
- return b, node.height, nil
+ return
}
// runCurrentTurn does the check and runs block producing if its my turn.
@@ -732,13 +754,13 @@ func (c *Chain) syncHead() {
if h := c.rt.getNextTurn() - 1; c.rt.getHead().Height < h {
log.Debugf("sync header with height %d", h)
var err error
- req := &FetchBlockReq{
+ req := &types.FetchBlockReq{
Envelope: proto.Envelope{
// TODO(lambda): Add fields.
},
Height: h,
}
- resp := &FetchBlockResp{}
+ resp := &types.FetchBlockResp{}
peers := c.rt.getPeers()
succ := false
diff --git a/blockproducer/rpc.go b/blockproducer/rpc.go
index bb71a68d3..eff8fefc4 100644
--- a/blockproducer/rpc.go
+++ b/blockproducer/rpc.go
@@ -17,8 +17,6 @@
package blockproducer
import (
- pi "github.com/CovenantSQL/CovenantSQL/blockproducer/interfaces"
- "github.com/CovenantSQL/CovenantSQL/proto"
"github.com/CovenantSQL/CovenantSQL/types"
)
@@ -27,142 +25,8 @@ type ChainRPCService struct {
chain *Chain
}
-// AdviseNewBlockReq defines a request of the AdviseNewBlock RPC method.
-type AdviseNewBlockReq struct {
- proto.Envelope
- Block *types.BPBlock
-}
-
-// AdviseNewBlockResp defines a response of the AdviseNewBlock RPC method.
-type AdviseNewBlockResp struct {
- proto.Envelope
-}
-
-// AdviseTxBillingReq defines a request of the AdviseTxBilling RPC method.
-type AdviseTxBillingReq struct {
- proto.Envelope
- TxBilling *types.Billing
-}
-
-// AdviseTxBillingResp defines a response of the AdviseTxBilling RPC method.
-type AdviseTxBillingResp struct {
- proto.Envelope
-}
-
-// FetchBlockReq defines a request of the FetchBlock RPC method.
-type FetchBlockReq struct {
- proto.Envelope
- Height uint32
-}
-
-// FetchBlockResp defines a response of the FetchBlock RPC method.
-type FetchBlockResp struct {
- proto.Envelope
- Height uint32
- Count uint32
- Block *types.BPBlock
-}
-
-// FetchBlockByCountReq define a request of the FetchBlockByCount RPC method.
-type FetchBlockByCountReq struct {
- proto.Envelope
- Count uint32
-}
-
-// FetchTxBillingReq defines a request of the FetchTxBilling RPC method.
-type FetchTxBillingReq struct {
- proto.Envelope
-}
-
-// FetchTxBillingResp defines a response of the FetchTxBilling RPC method.
-type FetchTxBillingResp struct {
- proto.Envelope
-}
-
-// NextAccountNonceReq defines a request of the NextAccountNonce RPC method.
-type NextAccountNonceReq struct {
- proto.Envelope
- Addr proto.AccountAddress
-}
-
-// NextAccountNonceResp defines a response of the NextAccountNonce RPC method.
-type NextAccountNonceResp struct {
- proto.Envelope
- Addr proto.AccountAddress
- Nonce pi.AccountNonce
-}
-
-// AddTxReq defines a request of the AddTx RPC method.
-type AddTxReq struct {
- proto.Envelope
- Tx pi.Transaction
-}
-
-// AddTxResp defines a response of the AddTx RPC method.
-type AddTxResp struct {
- proto.Envelope
-}
-
-// SubReq defines a request of the Sub RPC method.
-type SubReq struct {
- proto.Envelope
- Topic string
- Callback string
-}
-
-// SubResp defines a response of the Sub RPC method.
-type SubResp struct {
- proto.Envelope
- Result string
-}
-
-// OrderMakerReq defines a request of the order maker in database market.
-type OrderMakerReq struct {
- proto.Envelope
-}
-
-// OrderTakerReq defines a request of the order taker in database market.
-type OrderTakerReq struct {
- proto.Envelope
- DBMeta types.ResourceMeta
-}
-
-// OrderTakerResp defines a response of the order taker in database market.
-type OrderTakerResp struct {
- proto.Envelope
- databaseID proto.DatabaseID
-}
-
-// QueryAccountStableBalanceReq defines a request of the QueryAccountStableBalance RPC method.
-type QueryAccountStableBalanceReq struct {
- proto.Envelope
- Addr proto.AccountAddress
-}
-
-// QueryAccountStableBalanceResp defines a request of the QueryAccountStableBalance RPC method.
-type QueryAccountStableBalanceResp struct {
- proto.Envelope
- Addr proto.AccountAddress
- OK bool
- Balance uint64
-}
-
-// QueryAccountCovenantBalanceReq defines a request of the QueryAccountCovenantBalance RPC method.
-type QueryAccountCovenantBalanceReq struct {
- proto.Envelope
- Addr proto.AccountAddress
-}
-
-// QueryAccountCovenantBalanceResp defines a request of the QueryAccountCovenantBalance RPC method.
-type QueryAccountCovenantBalanceResp struct {
- proto.Envelope
- Addr proto.AccountAddress
- OK bool
- Balance uint64
-}
-
// AdviseNewBlock is the RPC method to advise a new block to target server.
-func (s *ChainRPCService) AdviseNewBlock(req *AdviseNewBlockReq, resp *AdviseNewBlockResp) error {
+func (s *ChainRPCService) AdviseNewBlock(req *types.AdviseNewBlockReq, resp *types.AdviseNewBlockResp) error {
s.chain.blocksFromRPC <- req.Block
return nil
}
@@ -178,7 +42,7 @@ func (s *ChainRPCService) AdviseBillingRequest(req *types.AdviseBillingReq, resp
}
// FetchBlock is the RPC method to fetch a known block from the target server.
-func (s *ChainRPCService) FetchBlock(req *FetchBlockReq, resp *FetchBlockResp) error {
+func (s *ChainRPCService) FetchBlock(req *types.FetchBlockReq, resp *types.FetchBlockResp) error {
resp.Height = req.Height
block, count, err := s.chain.fetchBlockByHeight(req.Height)
if err != nil {
@@ -189,8 +53,19 @@ func (s *ChainRPCService) FetchBlock(req *FetchBlockReq, resp *FetchBlockResp) e
return err
}
+func (s *ChainRPCService) FetchLastBlock(req *types.FetchLastBlockReq, resp *types.FetchBlockResp) error {
+ b, c, h, err := s.chain.fetchLastBlock()
+ if err != nil {
+ return err
+ }
+ resp.Block = b
+ resp.Count = c
+ resp.Height = h
+ return nil
+}
+
// FetchBlockByCount is the RPC method to fetch a known block from the target server.
-func (s *ChainRPCService) FetchBlockByCount(req *FetchBlockByCountReq, resp *FetchBlockResp) error {
+func (s *ChainRPCService) FetchBlockByCount(req *types.FetchBlockByCountReq, resp *types.FetchBlockResp) error {
resp.Count = req.Count
block, height, err := s.chain.fetchBlockByCount(req.Count)
if err != nil {
@@ -202,13 +77,13 @@ func (s *ChainRPCService) FetchBlockByCount(req *FetchBlockByCountReq, resp *Fet
}
// FetchTxBilling is the RPC method to fetch a known billing tx from the target server.
-func (s *ChainRPCService) FetchTxBilling(req *FetchTxBillingReq, resp *FetchTxBillingResp) error {
+func (s *ChainRPCService) FetchTxBilling(req *types.FetchTxBillingReq, resp *types.FetchTxBillingResp) error {
return nil
}
// NextAccountNonce is the RPC method to query the next nonce of an account.
func (s *ChainRPCService) NextAccountNonce(
- req *NextAccountNonceReq, resp *NextAccountNonceResp) (err error,
+ req *types.NextAccountNonceReq, resp *types.NextAccountNonceResp) (err error,
) {
if resp.Nonce, err = s.chain.ms.nextNonce(req.Addr); err != nil {
return
@@ -218,7 +93,7 @@ func (s *ChainRPCService) NextAccountNonce(
}
// AddTx is the RPC method to add a transaction.
-func (s *ChainRPCService) AddTx(req *AddTxReq, resp *AddTxResp) (err error) {
+func (s *ChainRPCService) AddTx(req *types.AddTxReq, resp *types.AddTxResp) (err error) {
if req.Tx == nil {
return ErrUnknownTransactionType
}
@@ -230,7 +105,7 @@ func (s *ChainRPCService) AddTx(req *AddTxReq, resp *AddTxResp) (err error) {
// QueryAccountStableBalance is the RPC method to query acccount stable coin balance.
func (s *ChainRPCService) QueryAccountStableBalance(
- req *QueryAccountStableBalanceReq, resp *QueryAccountStableBalanceResp) (err error,
+ req *types.QueryAccountStableBalanceReq, resp *types.QueryAccountStableBalanceResp) (err error,
) {
resp.Addr = req.Addr
resp.Balance, resp.OK = s.chain.ms.loadAccountStableBalance(req.Addr)
@@ -239,7 +114,7 @@ func (s *ChainRPCService) QueryAccountStableBalance(
// QueryAccountCovenantBalance is the RPC method to query acccount covenant coin balance.
func (s *ChainRPCService) QueryAccountCovenantBalance(
- req *QueryAccountCovenantBalanceReq, resp *QueryAccountCovenantBalanceResp) (err error,
+ req *types.QueryAccountCovenantBalanceReq, resp *types.QueryAccountCovenantBalanceResp) (err error,
) {
resp.Addr = req.Addr
resp.Balance, resp.OK = s.chain.ms.loadAccountCovenantBalance(req.Addr)
@@ -247,7 +122,7 @@ func (s *ChainRPCService) QueryAccountCovenantBalance(
}
// Sub is the RPC method to subscribe some event.
-func (s *ChainRPCService) Sub(req *SubReq, resp *SubResp) (err error) {
+func (s *ChainRPCService) Sub(req *types.SubReq, resp *types.SubResp) (err error) {
return s.chain.bs.Subscribe(req.Topic, func(request interface{}, response interface{}) {
s.chain.cl.CallNode(req.NodeID.ToNodeID(), req.Callback, request, response)
})
diff --git a/chainbus/bus.go b/chainbus/bus.go
index 3ccacdfb4..2b64fec35 100644
--- a/chainbus/bus.go
+++ b/chainbus/bus.go
@@ -22,7 +22,7 @@ import (
"sync"
)
-// ChainSuber defines subscribing-related bus behavior
+// ChainSuber defines subscribing-related bus behavior.
type ChainSuber interface {
Subscribe(topic string, handler interface{}) error
SubscribeAsync(topic string, handler interface{}, transactional bool) error
@@ -31,18 +31,18 @@ type ChainSuber interface {
Unsubscribe(topic string, handler interface{}) error
}
-// ChainPuber defines publishing-related bus behavior
+// ChainPuber defines publishing-related bus behavior.
type ChainPuber interface {
Publish(topic string, args ...interface{})
}
-// BusController defines bus control behavior (checking handler's presence, synchronization)
+// BusController defines bus control behavior (checking handler's presence, synchronization).
type BusController interface {
HasCallback(topic string) bool
WaitAsync()
}
-// Bus englobes global (subscribe, publish, control) bus behavior
+// Bus englobes global (subscribe, publish, control) bus behavior.
type Bus interface {
BusController
ChainSuber
@@ -67,14 +67,14 @@ type eventHandler struct {
// New returns new ChainBus with empty handlers.
func New() Bus {
b := &ChainBus{
- make(map[string][]*eventHandler),
- sync.Mutex{},
- sync.WaitGroup{},
+ handlers: make(map[string][]*eventHandler),
+ lock: sync.Mutex{},
+ wg: sync.WaitGroup{},
}
return b
}
-// doSubscribe handles the subscription logic and is utilized by the public Subscribe functions
+// doSubscribe handles the subscription logic and is utilized by the public Subscribe functions.
func (bus *ChainBus) doSubscribe(topic string, fn interface{}, handler *eventHandler) error {
bus.lock.Lock()
defer bus.lock.Unlock()
@@ -219,7 +219,8 @@ func (bus *ChainBus) setUpPublish(topic string, args ...interface{}) []reflect.V
return passedArguments
}
-// WaitAsync waits for all async callbacks to complete
+// WaitAsync waits for all async callbacks to complete.
func (bus *ChainBus) WaitAsync() {
bus.wg.Wait()
}
+
diff --git a/client/driver.go b/client/driver.go
index 5a789ae88..dc5a8dfc8 100644
--- a/client/driver.go
+++ b/client/driver.go
@@ -185,8 +185,8 @@ func GetStableCoinBalance() (balance uint64, err error) {
return
}
- req := new(bp.QueryAccountStableBalanceReq)
- resp := new(bp.QueryAccountStableBalanceResp)
+ req := new(types.QueryAccountStableBalanceReq)
+ resp := new(types.QueryAccountStableBalanceResp)
var pubKey *asymmetric.PublicKey
if pubKey, err = kms.GetLocalPublicKey(); err != nil {
@@ -211,8 +211,8 @@ func GetCovenantCoinBalance() (balance uint64, err error) {
return
}
- req := new(bp.QueryAccountCovenantBalanceReq)
- resp := new(bp.QueryAccountCovenantBalanceResp)
+ req := new(types.QueryAccountCovenantBalanceReq)
+ resp := new(types.QueryAccountCovenantBalanceResp)
var pubKey *asymmetric.PublicKey
if pubKey, err = kms.GetLocalPublicKey(); err != nil {
diff --git a/client/helper_test.go b/client/helper_test.go
index 9b4be6670..58a60541f 100644
--- a/client/helper_test.go
+++ b/client/helper_test.go
@@ -28,7 +28,6 @@ import (
"sync/atomic"
"time"
- bp "github.com/CovenantSQL/CovenantSQL/blockproducer"
"github.com/CovenantSQL/CovenantSQL/conf"
"github.com/CovenantSQL/CovenantSQL/consistent"
"github.com/CovenantSQL/CovenantSQL/crypto/asymmetric"
@@ -136,13 +135,13 @@ func (s *stubBPDBService) getInstanceMeta(dbID proto.DatabaseID) (instance types
return
}
-func (s *stubBPDBService) QueryAccountStableBalance(req *bp.QueryAccountStableBalanceReq,
- resp *bp.QueryAccountStableBalanceResp) (err error) {
+func (s *stubBPDBService) QueryAccountStableBalance(req *types.QueryAccountStableBalanceReq,
+ resp *types.QueryAccountStableBalanceResp) (err error) {
return
}
-func (s *stubBPDBService) QueryAccountCovenantBalance(req *bp.QueryAccountCovenantBalanceReq,
- resp *bp.QueryAccountCovenantBalanceResp) (err error) {
+func (s *stubBPDBService) QueryAccountCovenantBalance(req *types.QueryAccountCovenantBalanceReq,
+ resp *types.QueryAccountCovenantBalanceResp) (err error) {
return
}
diff --git a/cmd/cql-explorer/service.go b/cmd/cql-explorer/service.go
index 136a40410..6e26c1618 100644
--- a/cmd/cql-explorer/service.go
+++ b/cmd/cql-explorer/service.go
@@ -24,7 +24,6 @@ import (
"sync/atomic"
"time"
- bp "github.com/CovenantSQL/CovenantSQL/blockproducer"
pi "github.com/CovenantSQL/CovenantSQL/blockproducer/interfaces"
"github.com/CovenantSQL/CovenantSQL/conf"
"github.com/CovenantSQL/CovenantSQL/crypto/hash"
@@ -302,8 +301,8 @@ func (s *Service) requestBlock() {
blockCount := atomic.LoadUint32(&s.nextBlockToFetch)
log.WithFields(log.Fields{"count": blockCount}).Info("try fetch next block")
- req := &bp.FetchBlockByCountReq{Count: blockCount}
- resp := &bp.FetchBlockResp{}
+ req := &pt.FetchBlockByCountReq{Count: blockCount}
+ resp := &pt.FetchBlockResp{}
if err := s.requestBP(route.MCCFetchBlockByCount.String(), req, resp); err != nil {
// fetch block failed
diff --git a/cmd/cql-faucet/verifier.go b/cmd/cql-faucet/verifier.go
index 9ebd3b88a..f12502693 100644
--- a/cmd/cql-faucet/verifier.go
+++ b/cmd/cql-faucet/verifier.go
@@ -27,7 +27,6 @@ import (
"sync"
"time"
- bp "github.com/CovenantSQL/CovenantSQL/blockproducer"
"github.com/CovenantSQL/CovenantSQL/crypto"
"github.com/CovenantSQL/CovenantSQL/crypto/asymmetric"
"github.com/CovenantSQL/CovenantSQL/crypto/kms"
@@ -211,8 +210,8 @@ func (v *Verifier) dispense() (err error) {
}
func (v *Verifier) dispenseOne(r *applicationRecord) (err error) {
- balanceReq := &bp.QueryAccountStableBalanceReq{}
- balanceRes := &bp.QueryAccountStableBalanceResp{}
+ balanceReq := &pt.QueryAccountStableBalanceReq{}
+ balanceRes := &pt.QueryAccountStableBalanceResp{}
balanceReq.Addr = v.vaultAddress
// get current balance
@@ -223,8 +222,8 @@ func (v *Verifier) dispenseOne(r *applicationRecord) (err error) {
}
// allocate nonce
- nonceReq := &bp.NextAccountNonceReq{}
- nonceResp := &bp.NextAccountNonceResp{}
+ nonceReq := &pt.NextAccountNonceReq{}
+ nonceResp := &pt.NextAccountNonceResp{}
nonceReq.Addr = v.vaultAddress
if err = requestBP(route.MCCNextAccountNonce.String(), nonceReq, nonceResp); err != nil {
@@ -258,8 +257,8 @@ func (v *Verifier) dispenseOne(r *applicationRecord) (err error) {
return
}
- req := &bp.AddTxReq{}
- resp := &bp.AddTxResp{}
+ req := &pt.AddTxReq{}
+ resp := &pt.AddTxResp{}
req.Tx = pt.NewTransfer(
&pt.TransferHeader{
Sender: v.vaultAddress,
diff --git a/cmd/cql-utils/rpc.go b/cmd/cql-utils/rpc.go
index f3663fceb..3eac18a31 100644
--- a/cmd/cql-utils/rpc.go
+++ b/cmd/cql-utils/rpc.go
@@ -24,7 +24,6 @@ import (
"reflect"
"strings"
- "github.com/CovenantSQL/CovenantSQL/blockproducer"
bp "github.com/CovenantSQL/CovenantSQL/blockproducer"
"github.com/CovenantSQL/CovenantSQL/client"
"github.com/CovenantSQL/CovenantSQL/crypto/asymmetric"
@@ -42,7 +41,7 @@ var (
rpcServiceMap = map[string]interface{}{
route.DHTRPCName: &route.DHTService{},
route.DBRPCName: &worker.DBMSRPCService{},
- route.BPDBRPCName: &blockproducer.DBService{},
+ route.BPDBRPCName: &bp.DBService{},
route.SQLChainRPCName: &sqlchain.MuxService{},
route.BlockProducerRPCName: &bp.ChainRPCService{},
}
diff --git a/route/acl.go b/route/acl.go
index c369c42e1..9b87667ba 100644
--- a/route/acl.go
+++ b/route/acl.go
@@ -117,6 +117,8 @@ const (
MCCFetchBlock
// MCCFetchBlockByCount is used by nodes to fetch block from block producer by block count since genesis
MCCFetchBlockByCount
+ // MCCFetchLastBlock is used by nodes to fetch last block from block producer
+ MCCFetchLastBlock
// MCCFetchTxBilling is used by nodes to fetch billing transaction from block producer
MCCFetchTxBilling
// MCCNextAccountNonce is used by block producer main chain to allocate next nonce for transactions
@@ -201,6 +203,8 @@ func (s RemoteFunc) String() string {
return "MCC.FetchBlock"
case MCCFetchBlockByCount:
return "MCC.FetchBlockByCount"
+ case MCCFetchLastBlock:
+ return "MCC.FetchLastBlock"
case MCCFetchTxBilling:
return "MCC.FetchTxBilling"
case MCCNextAccountNonce:
diff --git a/sqlchain/chainbusservice.go b/sqlchain/chainbusservice.go
new file mode 100644
index 000000000..2d9b10b4e
--- /dev/null
+++ b/sqlchain/chainbusservice.go
@@ -0,0 +1,145 @@
+/*
+ * Copyright 2018 The CovenantSQL Authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package sqlchain
+
+import (
+ "context"
+ "fmt"
+ "github.com/CovenantSQL/CovenantSQL/blockproducer/interfaces"
+ "github.com/CovenantSQL/CovenantSQL/chainbus"
+ "github.com/CovenantSQL/CovenantSQL/proto"
+ "github.com/CovenantSQL/CovenantSQL/route"
+ "github.com/CovenantSQL/CovenantSQL/rpc"
+ "github.com/CovenantSQL/CovenantSQL/types"
+ "github.com/CovenantSQL/CovenantSQL/utils/log"
+ "sync"
+ "sync/atomic"
+ "time"
+)
+
+type BusService struct {
+ chainbus.Bus
+
+ caller *rpc.Caller
+
+ lock sync.Mutex // a lock for the map
+ wg sync.WaitGroup
+ ctx context.Context
+ cancel context.CancelFunc
+
+ checkInterval time.Duration
+ blockCount uint32
+}
+
+func NewBusService(ctx context.Context, checkInterval time.Duration) *BusService {
+ ctd, ccl := context.WithCancel(ctx)
+ bs := &BusService{
+ Bus: chainbus.New(),
+ lock: sync.Mutex{},
+ wg: sync.WaitGroup{},
+ caller: rpc.NewCaller(),
+ ctx: ctd,
+ cancel: ccl,
+ checkInterval: checkInterval,
+ }
+ return bs
+}
+
+func (bs *BusService) subscribeBlock(ctx context.Context) {
+ defer bs.wg.Done()
+
+ log.Info("start to subscribe blocks")
+ for {
+ select {
+ case <-ctx.Done():
+ log.Info("exit subscription service")
+ return
+ case <- time.After(bs.checkInterval):
+ // fetch block from remote block producer
+ c := atomic.LoadUint32(&bs.blockCount)
+ b := bs.requestBlock(c)
+ bs.extractTxs(b, c)
+ atomic.AddUint32(&bs.blockCount, 1)
+ }
+ }
+
+}
+
+func (bs *BusService) requestLastBlock() (block *types.BPBlock, count uint32) {
+ req := &types.FetchLastBlockReq{}
+ resp := &types.FetchBlockResp{}
+
+ if err := bs.requestBP(route.MCCFetchLastBlock.String(), req, resp); err != nil {
+ log.WithError(err).Warning("fetch last block failed")
+ return
+ }
+
+ block = resp.Block
+ count = resp.Count
+ return
+}
+
+func (bs *BusService) requestBlock(count uint32) (block *types.BPBlock) {
+ req := &types.FetchBlockByCountReq{Count: count}
+ resp := &types.FetchBlockResp{}
+
+ if err := bs.requestBP(route.MCCFetchBlockByCount.String(), req, resp); err != nil {
+ log.WithError(err).Warning("fetch specific block failed")
+ return
+ }
+
+ block = resp.Block
+ return
+}
+
+func (bs *BusService) requestBP(method string, request interface{}, response interface{}) (err error) {
+ var bpNodeID proto.NodeID
+ if bpNodeID, err = rpc.GetCurrentBP(); err != nil {
+ return
+ }
+ return bs.caller.CallNode(bpNodeID, method, request, response)
+}
+
+func (bs *BusService) extractTxs(blocks *types.BPBlock, count uint32) {
+ for _, tx := range blocks.Transactions {
+ eventName := bs.unwrapTx(tx)
+ bs.Publish(eventName, blocks, count)
+ }
+}
+
+func (bs *BusService) unwrapTx(tx interfaces.Transaction) string {
+ switch t := tx.(type) {
+ case *interfaces.TransactionWrapper:
+ return bs.unwrapTx(t.Unwrap())
+ default:
+ eventName := fmt.Sprintf("/%s/", t.GetTransactionType().String())
+ return eventName
+ }
+}
+
+// Start starts a chain bus service.
+func (bs *BusService) Start() {
+ bs.wg.Add(1)
+ go bs.subscribeBlock(bs.ctx)
+}
+
+// Stop stops the chain bus service.
+func (bs *BusService) Stop() {
+ bs.cancel()
+ bs.wg.Wait()
+}
+
diff --git a/types/bprpc.go b/types/bprpc.go
new file mode 100644
index 000000000..76cc95487
--- /dev/null
+++ b/types/bprpc.go
@@ -0,0 +1,160 @@
+/*
+ * Copyright 2018 The CovenantSQL Authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package types
+
+import (
+ "github.com/CovenantSQL/CovenantSQL/blockproducer/interfaces"
+ "github.com/CovenantSQL/CovenantSQL/proto"
+)
+
+// AdviseNewBlockReq defines a request of the AdviseNewBlock RPC method.
+type AdviseNewBlockReq struct {
+ proto.Envelope
+ Block *BPBlock
+}
+
+// AdviseNewBlockResp defines a response of the AdviseNewBlock RPC method.
+type AdviseNewBlockResp struct {
+ proto.Envelope
+}
+
+// AdviseTxBillingReq defines a request of the AdviseTxBilling RPC method.
+type AdviseTxBillingReq struct {
+ proto.Envelope
+ TxBilling *Billing
+}
+
+// AdviseTxBillingResp defines a response of the AdviseTxBilling RPC method.
+type AdviseTxBillingResp struct {
+ proto.Envelope
+}
+
+// FetchBlockReq defines a request of the FetchBlock RPC method.
+type FetchBlockReq struct {
+ proto.Envelope
+ Height uint32
+}
+
+// FetchBlockResp defines a response of the FetchBlock RPC method.
+type FetchBlockResp struct {
+ proto.Envelope
+ Height uint32
+ Count uint32
+ Block *BPBlock
+}
+
+type FetchLastBlockReq struct {
+ proto.Envelope
+}
+
+// FetchBlockByCountReq define a request of the FetchBlockByCount RPC method.
+type FetchBlockByCountReq struct {
+ proto.Envelope
+ Count uint32
+}
+
+// FetchTxBillingReq defines a request of the FetchTxBilling RPC method.
+type FetchTxBillingReq struct {
+ proto.Envelope
+}
+
+// FetchTxBillingResp defines a response of the FetchTxBilling RPC method.
+type FetchTxBillingResp struct {
+ proto.Envelope
+}
+
+// NextAccountNonceReq defines a request of the NextAccountNonce RPC method.
+type NextAccountNonceReq struct {
+ proto.Envelope
+ Addr proto.AccountAddress
+}
+
+// NextAccountNonceResp defines a response of the NextAccountNonce RPC method.
+type NextAccountNonceResp struct {
+ proto.Envelope
+ Addr proto.AccountAddress
+ Nonce interfaces.AccountNonce
+}
+
+// AddTxReq defines a request of the AddTx RPC method.
+type AddTxReq struct {
+ proto.Envelope
+ Tx interfaces.Transaction
+}
+
+// AddTxResp defines a response of the AddTx RPC method.
+type AddTxResp struct {
+ proto.Envelope
+}
+
+// SubReq defines a request of the Sub RPC method.
+type SubReq struct {
+ proto.Envelope
+ Topic string
+ Callback string
+}
+
+// SubResp defines a response of the Sub RPC method.
+type SubResp struct {
+ proto.Envelope
+ Result string
+}
+
+// OrderMakerReq defines a request of the order maker in database market.
+type OrderMakerReq struct {
+ proto.Envelope
+}
+
+// OrderTakerReq defines a request of the order taker in database market.
+type OrderTakerReq struct {
+ proto.Envelope
+ DBMeta ResourceMeta
+}
+
+// OrderTakerResp defines a response of the order taker in database market.
+type OrderTakerResp struct {
+ proto.Envelope
+ databaseID proto.DatabaseID
+}
+
+// QueryAccountStableBalanceReq defines a request of the QueryAccountStableBalance RPC method.
+type QueryAccountStableBalanceReq struct {
+ proto.Envelope
+ Addr proto.AccountAddress
+}
+
+// QueryAccountStableBalanceResp defines a request of the QueryAccountStableBalance RPC method.
+type QueryAccountStableBalanceResp struct {
+ proto.Envelope
+ Addr proto.AccountAddress
+ OK bool
+ Balance uint64
+}
+
+// QueryAccountCovenantBalanceReq defines a request of the QueryAccountCovenantBalance RPC method.
+type QueryAccountCovenantBalanceReq struct {
+ proto.Envelope
+ Addr proto.AccountAddress
+}
+
+// QueryAccountCovenantBalanceResp defines a request of the QueryAccountCovenantBalance RPC method.
+type QueryAccountCovenantBalanceResp struct {
+ proto.Envelope
+ Addr proto.AccountAddress
+ OK bool
+ Balance uint64
+}
From 769c544617b901332ed3ab3001a5916ab5f68756 Mon Sep 17 00:00:00 2001
From: zeqing-guo
Date: Wed, 5 Dec 2018 16:40:13 +0800
Subject: [PATCH 031/278] Add cloudflare key
---
chainbus/bus.go | 5 ++--
sqlchain/chainbusservice.go | 28 +++++++++----------
test/GNTE/conf/node_0/config.yaml | 1 +
test/GNTE/conf/node_1/config.yaml | 1 +
test/GNTE/conf/node_2/config.yaml | 1 +
test/GNTE/conf/node_c/config.yaml | 1 +
.../conf/node_miner_10.250.100.2/config.yaml | 1 +
.../conf/node_miner_10.250.100.3/config.yaml | 1 +
.../conf/node_miner_10.250.100.4/config.yaml | 1 +
.../conf/node_miner_10.250.100.5/config.yaml | 1 +
.../conf/node_miner_10.250.100.6/config.yaml | 1 +
.../conf/node_miner_10.250.100.7/config.yaml | 1 +
.../conf/node_miner_10.250.100.8/config.yaml | 1 +
.../conf/node_miner_10.250.100.9/config.yaml | 1 +
test/bootstrap.yaml | 1 +
test/fuse/node_0/config.yaml | 1 +
test/fuse/node_1/config.yaml | 1 +
test/fuse/node_2/config.yaml | 1 +
test/fuse/node_c/config.yaml | 1 +
test/fuse/node_miner_0/config.yaml | 1 +
test/fuse/node_miner_1/config.yaml | 1 +
test/fuse/node_miner_2/config.yaml | 1 +
test/integration/node_0/config.yaml | 1 +
test/integration/node_1/config.yaml | 1 +
test/integration/node_2/config.yaml | 1 +
test/integration/node_c/config.yaml | 1 +
test/integration/node_miner_0/config.yaml | 1 +
test/integration/node_miner_1/config.yaml | 1 +
test/integration/node_miner_2/config.yaml | 1 +
test/leak/client.yaml | 1 +
test/leak/leader.yaml | 1 +
test/mainchain/node_0/config.yaml | 1 +
test/mainchain/node_1/config.yaml | 1 +
test/mainchain/node_2/config.yaml | 1 +
test/mainchain/node_c/config.yaml | 1 +
test/mainchain/node_miner_0/config.yaml | 1 +
test/mainchain/node_miner_1/config.yaml | 1 +
test/mainchain/node_miner_2/config.yaml | 1 +
test/mainchain/node_multi_0/config.yaml | 1 +
test/mainchain/node_multi_1/config.yaml | 1 +
test/mainchain/node_multi_2/config.yaml | 1 +
test/mainchain/node_standalone/config.yaml | 1 +
test/node_0/config.yaml | 1 +
test/node_1/config.yaml | 1 +
test/node_2/config.yaml | 1 +
test/node_c/config.yaml | 1 +
test/node_standalone/config.yaml | 1 +
test/node_standalone/config2.yaml | 1 +
test/observation/node_0/config.yaml | 1 +
test/observation/node_1/config.yaml | 1 +
test/observation/node_2/config.yaml | 1 +
test/observation/node_c/config.yaml | 1 +
test/observation/node_miner_0/config.yaml | 1 +
test/observation/node_miner_1/config.yaml | 1 +
test/observation/node_miner_2/config.yaml | 1 +
test/observation/node_observer/config.yaml | 1 +
test/pool/client.yaml | 1 +
test/pool/leader.yaml | 1 +
test/service/node_0/config.yaml | 1 +
test/service/node_1/config.yaml | 1 +
test/service/node_2/config.yaml | 1 +
test/service/node_adapter/config.yaml | 1 +
test/service/node_c/config.yaml | 1 +
test/service/node_miner_0/config.yaml | 1 +
test/service/node_miner_1/config.yaml | 1 +
test/service/node_miner_2/config.yaml | 1 +
test/service/node_mysql_adapter/config.yaml | 1 +
test/service/node_observer/config.yaml | 1 +
68 files changed, 82 insertions(+), 17 deletions(-)
diff --git a/chainbus/bus.go b/chainbus/bus.go
index 2b64fec35..35a74ca15 100644
--- a/chainbus/bus.go
+++ b/chainbus/bus.go
@@ -68,8 +68,8 @@ type eventHandler struct {
func New() Bus {
b := &ChainBus{
handlers: make(map[string][]*eventHandler),
- lock: sync.Mutex{},
- wg: sync.WaitGroup{},
+ lock: sync.Mutex{},
+ wg: sync.WaitGroup{},
}
return b
}
@@ -223,4 +223,3 @@ func (bus *ChainBus) setUpPublish(topic string, args ...interface{}) []reflect.V
func (bus *ChainBus) WaitAsync() {
bus.wg.Wait()
}
-
diff --git a/sqlchain/chainbusservice.go b/sqlchain/chainbusservice.go
index 2d9b10b4e..219f2e884 100644
--- a/sqlchain/chainbusservice.go
+++ b/sqlchain/chainbusservice.go
@@ -19,6 +19,10 @@ package sqlchain
import (
"context"
"fmt"
+ "sync"
+ "sync/atomic"
+ "time"
+
"github.com/CovenantSQL/CovenantSQL/blockproducer/interfaces"
"github.com/CovenantSQL/CovenantSQL/chainbus"
"github.com/CovenantSQL/CovenantSQL/proto"
@@ -26,9 +30,6 @@ import (
"github.com/CovenantSQL/CovenantSQL/rpc"
"github.com/CovenantSQL/CovenantSQL/types"
"github.com/CovenantSQL/CovenantSQL/utils/log"
- "sync"
- "sync/atomic"
- "time"
)
type BusService struct {
@@ -36,24 +37,24 @@ type BusService struct {
caller *rpc.Caller
- lock sync.Mutex // a lock for the map
- wg sync.WaitGroup
+ lock sync.Mutex // a lock for the map
+ wg sync.WaitGroup
ctx context.Context
cancel context.CancelFunc
checkInterval time.Duration
- blockCount uint32
+ blockCount uint32
}
func NewBusService(ctx context.Context, checkInterval time.Duration) *BusService {
ctd, ccl := context.WithCancel(ctx)
bs := &BusService{
- Bus: chainbus.New(),
- lock: sync.Mutex{},
- wg: sync.WaitGroup{},
- caller: rpc.NewCaller(),
- ctx: ctd,
- cancel: ccl,
+ Bus: chainbus.New(),
+ lock: sync.Mutex{},
+ wg: sync.WaitGroup{},
+ caller: rpc.NewCaller(),
+ ctx: ctd,
+ cancel: ccl,
checkInterval: checkInterval,
}
return bs
@@ -68,7 +69,7 @@ func (bs *BusService) subscribeBlock(ctx context.Context) {
case <-ctx.Done():
log.Info("exit subscription service")
return
- case <- time.After(bs.checkInterval):
+ case <-time.After(bs.checkInterval):
// fetch block from remote block producer
c := atomic.LoadUint32(&bs.blockCount)
b := bs.requestBlock(c)
@@ -142,4 +143,3 @@ func (bs *BusService) Stop() {
bs.cancel()
bs.wg.Wait()
}
-
diff --git a/test/GNTE/conf/node_0/config.yaml b/test/GNTE/conf/node_0/config.yaml
index d0f183e52..f1e7fe0fa 100644
--- a/test/GNTE/conf/node_0/config.yaml
+++ b/test/GNTE/conf/node_0/config.yaml
@@ -6,6 +6,7 @@ DHTFileName: "dht.db"
ListenAddr: "10.250.1.2:4661"
ThisNodeID: "00000bef611d346c0cbe1beaa76e7f0ed705a194fdf9ac3a248ec70e9c198bf9"
ValidDNSKeys:
+ oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
MinNodeIDDifficulty: 2
diff --git a/test/GNTE/conf/node_1/config.yaml b/test/GNTE/conf/node_1/config.yaml
index 70f6ca0f8..57b5519c8 100644
--- a/test/GNTE/conf/node_1/config.yaml
+++ b/test/GNTE/conf/node_1/config.yaml
@@ -6,6 +6,7 @@ DHTFileName: "dht.db"
ListenAddr: "10.250.1.3:4661"
ThisNodeID: "00000381d46fd6cf7742d7fb94e2422033af989c0e348b5781b3219599a3af35"
ValidDNSKeys:
+ oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
MinNodeIDDifficulty: 2
diff --git a/test/GNTE/conf/node_2/config.yaml b/test/GNTE/conf/node_2/config.yaml
index c1321a15c..b1067f196 100644
--- a/test/GNTE/conf/node_2/config.yaml
+++ b/test/GNTE/conf/node_2/config.yaml
@@ -6,6 +6,7 @@ DHTFileName: "dht.db"
ListenAddr: "10.250.1.4:4661"
ThisNodeID: "000000172580063ded88e010556b0aca2851265be8845b1ef397e8fce6ab5582"
ValidDNSKeys:
+ oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
MinNodeIDDifficulty: 2
diff --git a/test/GNTE/conf/node_c/config.yaml b/test/GNTE/conf/node_c/config.yaml
index 75aa1975c..8ee84e636 100644
--- a/test/GNTE/conf/node_c/config.yaml
+++ b/test/GNTE/conf/node_c/config.yaml
@@ -6,6 +6,7 @@ DHTFileName: "dht.db"
ListenAddr: "10.250.0.254:4661"
ThisNodeID: "00000f3b43288fe99831eb533ab77ec455d13e11fc38ec35a42d4edd17aa320d"
ValidDNSKeys:
+ oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
MinNodeIDDifficulty: 2
diff --git a/test/GNTE/conf/node_miner_10.250.100.2/config.yaml b/test/GNTE/conf/node_miner_10.250.100.2/config.yaml
index 2a301d150..ea667dc53 100644
--- a/test/GNTE/conf/node_miner_10.250.100.2/config.yaml
+++ b/test/GNTE/conf/node_miner_10.250.100.2/config.yaml
@@ -6,6 +6,7 @@ DHTFileName: "dht.db"
ListenAddr: "10.250.100.2:4661"
ThisNodeID: "000005aa62048f85da4ae9698ed59c14ec0d48a88a07c15a32265634e7e64ade"
ValidDNSKeys:
+ oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
BlockProducer:
diff --git a/test/GNTE/conf/node_miner_10.250.100.3/config.yaml b/test/GNTE/conf/node_miner_10.250.100.3/config.yaml
index 1106c28bb..419d21044 100644
--- a/test/GNTE/conf/node_miner_10.250.100.3/config.yaml
+++ b/test/GNTE/conf/node_miner_10.250.100.3/config.yaml
@@ -6,6 +6,7 @@ DHTFileName: "dht.db"
ListenAddr: "10.250.100.3:4661"
ThisNodeID: "000005f4f22c06f76c43c4f48d5a7ec1309cc94030cbf9ebae814172884ac8b5"
ValidDNSKeys:
+ oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
BlockProducer:
diff --git a/test/GNTE/conf/node_miner_10.250.100.4/config.yaml b/test/GNTE/conf/node_miner_10.250.100.4/config.yaml
index b19dace89..af88e3836 100644
--- a/test/GNTE/conf/node_miner_10.250.100.4/config.yaml
+++ b/test/GNTE/conf/node_miner_10.250.100.4/config.yaml
@@ -6,6 +6,7 @@ DHTFileName: "dht.db"
ListenAddr: "10.250.100.4:4661"
ThisNodeID: "000003f49592f83d0473bddb70d543f1096b4ffed5e5f942a3117e256b7052b8"
ValidDNSKeys:
+ oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
BlockProducer:
diff --git a/test/GNTE/conf/node_miner_10.250.100.5/config.yaml b/test/GNTE/conf/node_miner_10.250.100.5/config.yaml
index a09d83606..9d20819ea 100755
--- a/test/GNTE/conf/node_miner_10.250.100.5/config.yaml
+++ b/test/GNTE/conf/node_miner_10.250.100.5/config.yaml
@@ -6,6 +6,7 @@ DHTFileName: "dht.db"
ListenAddr: "10.250.100.5:4661"
ThisNodeID: "00eda359cd2aa0920cdd37b083b896cb18cd26b3bd51744d1b4f127830f820f2"
ValidDNSKeys:
+ oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
BlockProducer:
diff --git a/test/GNTE/conf/node_miner_10.250.100.6/config.yaml b/test/GNTE/conf/node_miner_10.250.100.6/config.yaml
index b96505d19..a50ccc5d1 100755
--- a/test/GNTE/conf/node_miner_10.250.100.6/config.yaml
+++ b/test/GNTE/conf/node_miner_10.250.100.6/config.yaml
@@ -6,6 +6,7 @@ DHTFileName: "dht.db"
ListenAddr: "10.250.100.6:4661"
ThisNodeID: "0017017845ff9f9f7e8599d308652eb8ce480e689fbd49afb6b44cc9726cf84b"
ValidDNSKeys:
+ oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
BlockProducer:
diff --git a/test/GNTE/conf/node_miner_10.250.100.7/config.yaml b/test/GNTE/conf/node_miner_10.250.100.7/config.yaml
index 5370e24f6..c24f4ea9e 100755
--- a/test/GNTE/conf/node_miner_10.250.100.7/config.yaml
+++ b/test/GNTE/conf/node_miner_10.250.100.7/config.yaml
@@ -6,6 +6,7 @@ DHTFileName: "dht.db"
ListenAddr: "10.250.100.7:4661"
ThisNodeID: "0075b97519d0a5cf9f7269a61b82bb3e082a5e7d796604e877ee28d08491979a"
ValidDNSKeys:
+ oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
BlockProducer:
diff --git a/test/GNTE/conf/node_miner_10.250.100.8/config.yaml b/test/GNTE/conf/node_miner_10.250.100.8/config.yaml
index bc633a6fc..6d0e61666 100755
--- a/test/GNTE/conf/node_miner_10.250.100.8/config.yaml
+++ b/test/GNTE/conf/node_miner_10.250.100.8/config.yaml
@@ -6,6 +6,7 @@ DHTFileName: "dht.db"
ListenAddr: "10.250.100.8:4661"
ThisNodeID: "0060bb3394f5185f760af690b0c124a70acbaf952fd79d794a0d394c37d7c0bc"
ValidDNSKeys:
+ oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
BlockProducer:
diff --git a/test/GNTE/conf/node_miner_10.250.100.9/config.yaml b/test/GNTE/conf/node_miner_10.250.100.9/config.yaml
index 887064529..f2a38bab0 100755
--- a/test/GNTE/conf/node_miner_10.250.100.9/config.yaml
+++ b/test/GNTE/conf/node_miner_10.250.100.9/config.yaml
@@ -6,6 +6,7 @@ DHTFileName: "dht.db"
ListenAddr: "10.250.100.9:4661"
ThisNodeID: "004e5cf49e88f6e35e344f35d73ffe6232d4ebe93a63a825e171b8f6f2a88859"
ValidDNSKeys:
+ oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
BlockProducer:
diff --git a/test/bootstrap.yaml b/test/bootstrap.yaml
index 08c2c7c50..ca382010e 100644
--- a/test/bootstrap.yaml
+++ b/test/bootstrap.yaml
@@ -6,6 +6,7 @@ DHTFileName: "dht.db"
ListenAddr: "127.0.0.1:2120"
ThisNodeID: "00000f3b43288fe99831eb533ab77ec455d13e11fc38ec35a42d4edd17aa320d"
ValidDNSKeys:
+ oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
MinNodeIDDifficulty: 2
diff --git a/test/fuse/node_0/config.yaml b/test/fuse/node_0/config.yaml
index 9919e977e..8ec135d3b 100644
--- a/test/fuse/node_0/config.yaml
+++ b/test/fuse/node_0/config.yaml
@@ -6,6 +6,7 @@ DHTFileName: "dht.db"
ListenAddr: "127.0.0.1:6122"
ThisNodeID: "00000bef611d346c0cbe1beaa76e7f0ed705a194fdf9ac3a248ec70e9c198bf9"
ValidDNSKeys:
+ oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
MinNodeIDDifficulty: 2
diff --git a/test/fuse/node_1/config.yaml b/test/fuse/node_1/config.yaml
index caaa118d5..0c710bfe4 100644
--- a/test/fuse/node_1/config.yaml
+++ b/test/fuse/node_1/config.yaml
@@ -6,6 +6,7 @@ DHTFileName: "dht.db"
ListenAddr: "127.0.0.1:6121"
ThisNodeID: "00000381d46fd6cf7742d7fb94e2422033af989c0e348b5781b3219599a3af35"
ValidDNSKeys:
+ oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
MinNodeIDDifficulty: 2
diff --git a/test/fuse/node_2/config.yaml b/test/fuse/node_2/config.yaml
index 18c3409d0..98672478e 100644
--- a/test/fuse/node_2/config.yaml
+++ b/test/fuse/node_2/config.yaml
@@ -6,6 +6,7 @@ DHTFileName: "dht.db"
ListenAddr: "127.0.0.1:6120"
ThisNodeID: "000000172580063ded88e010556b0aca2851265be8845b1ef397e8fce6ab5582"
ValidDNSKeys:
+ oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
MinNodeIDDifficulty: 2
diff --git a/test/fuse/node_c/config.yaml b/test/fuse/node_c/config.yaml
index d90eca3fe..739c0143f 100644
--- a/test/fuse/node_c/config.yaml
+++ b/test/fuse/node_c/config.yaml
@@ -6,6 +6,7 @@ DHTFileName: "dht.db"
ListenAddr: "127.0.0.1:6120"
ThisNodeID: "00000f3b43288fe99831eb533ab77ec455d13e11fc38ec35a42d4edd17aa320d"
ValidDNSKeys:
+ oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
MinNodeIDDifficulty: 2
diff --git a/test/fuse/node_miner_0/config.yaml b/test/fuse/node_miner_0/config.yaml
index 448bb795f..44711a8eb 100644
--- a/test/fuse/node_miner_0/config.yaml
+++ b/test/fuse/node_miner_0/config.yaml
@@ -6,6 +6,7 @@ DHTFileName: "dht.db"
ListenAddr: "127.0.0.1:3144"
ThisNodeID: "000005aa62048f85da4ae9698ed59c14ec0d48a88a07c15a32265634e7e64ade"
ValidDNSKeys:
+ oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
BlockProducer:
diff --git a/test/fuse/node_miner_1/config.yaml b/test/fuse/node_miner_1/config.yaml
index 558ca1cb1..9dd1d183e 100644
--- a/test/fuse/node_miner_1/config.yaml
+++ b/test/fuse/node_miner_1/config.yaml
@@ -6,6 +6,7 @@ DHTFileName: "dht.db"
ListenAddr: "127.0.0.1:3145"
ThisNodeID: "000005f4f22c06f76c43c4f48d5a7ec1309cc94030cbf9ebae814172884ac8b5"
ValidDNSKeys:
+ oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
BlockProducer:
diff --git a/test/fuse/node_miner_2/config.yaml b/test/fuse/node_miner_2/config.yaml
index e6edd4d68..167209f93 100644
--- a/test/fuse/node_miner_2/config.yaml
+++ b/test/fuse/node_miner_2/config.yaml
@@ -6,6 +6,7 @@ DHTFileName: "dht.db"
ListenAddr: "127.0.0.1:3146"
ThisNodeID: "000003f49592f83d0473bddb70d543f1096b4ffed5e5f942a3117e256b7052b8"
ValidDNSKeys:
+ oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
BlockProducer:
diff --git a/test/integration/node_0/config.yaml b/test/integration/node_0/config.yaml
index af162afb2..ec29709d6 100644
--- a/test/integration/node_0/config.yaml
+++ b/test/integration/node_0/config.yaml
@@ -6,6 +6,7 @@ DHTFileName: "dht.db"
ListenAddr: "127.0.0.1:3122"
ThisNodeID: "00000bef611d346c0cbe1beaa76e7f0ed705a194fdf9ac3a248ec70e9c198bf9"
ValidDNSKeys:
+ oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
MinNodeIDDifficulty: 2
diff --git a/test/integration/node_1/config.yaml b/test/integration/node_1/config.yaml
index 0aa1f5a9b..d28c785bf 100644
--- a/test/integration/node_1/config.yaml
+++ b/test/integration/node_1/config.yaml
@@ -6,6 +6,7 @@ DHTFileName: "dht.db"
ListenAddr: "127.0.0.1:3121"
ThisNodeID: "00000381d46fd6cf7742d7fb94e2422033af989c0e348b5781b3219599a3af35"
ValidDNSKeys:
+ oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
MinNodeIDDifficulty: 2
diff --git a/test/integration/node_2/config.yaml b/test/integration/node_2/config.yaml
index 8f36e3ab9..435ed3b2e 100644
--- a/test/integration/node_2/config.yaml
+++ b/test/integration/node_2/config.yaml
@@ -6,6 +6,7 @@ DHTFileName: "dht.db"
ListenAddr: "127.0.0.1:3120"
ThisNodeID: "000000172580063ded88e010556b0aca2851265be8845b1ef397e8fce6ab5582"
ValidDNSKeys:
+ oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
MinNodeIDDifficulty: 2
diff --git a/test/integration/node_c/config.yaml b/test/integration/node_c/config.yaml
index fe9fa6eb2..09628f821 100644
--- a/test/integration/node_c/config.yaml
+++ b/test/integration/node_c/config.yaml
@@ -6,6 +6,7 @@ DHTFileName: "dht.db"
ListenAddr: "127.0.0.1:3120"
ThisNodeID: "00000f3b43288fe99831eb533ab77ec455d13e11fc38ec35a42d4edd17aa320d"
ValidDNSKeys:
+ oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
MinNodeIDDifficulty: 2
diff --git a/test/integration/node_miner_0/config.yaml b/test/integration/node_miner_0/config.yaml
index 8fd498a09..9ad28b4ed 100644
--- a/test/integration/node_miner_0/config.yaml
+++ b/test/integration/node_miner_0/config.yaml
@@ -6,6 +6,7 @@ DHTFileName: "dht.db"
ListenAddr: "127.0.0.1:2144"
ThisNodeID: "000005aa62048f85da4ae9698ed59c14ec0d48a88a07c15a32265634e7e64ade"
ValidDNSKeys:
+ oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
BlockProducer:
diff --git a/test/integration/node_miner_1/config.yaml b/test/integration/node_miner_1/config.yaml
index a2b44aaf6..d16a395b1 100644
--- a/test/integration/node_miner_1/config.yaml
+++ b/test/integration/node_miner_1/config.yaml
@@ -6,6 +6,7 @@ DHTFileName: "dht.db"
ListenAddr: "127.0.0.1:2145"
ThisNodeID: "000005f4f22c06f76c43c4f48d5a7ec1309cc94030cbf9ebae814172884ac8b5"
ValidDNSKeys:
+ oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
BlockProducer:
diff --git a/test/integration/node_miner_2/config.yaml b/test/integration/node_miner_2/config.yaml
index 900670988..d1a86c0cd 100644
--- a/test/integration/node_miner_2/config.yaml
+++ b/test/integration/node_miner_2/config.yaml
@@ -6,6 +6,7 @@ DHTFileName: "dht.db"
ListenAddr: "127.0.0.1:2146"
ThisNodeID: "000003f49592f83d0473bddb70d543f1096b4ffed5e5f942a3117e256b7052b8"
ValidDNSKeys:
+ oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
BlockProducer:
diff --git a/test/leak/client.yaml b/test/leak/client.yaml
index 89911d9ef..29601af4c 100644
--- a/test/leak/client.yaml
+++ b/test/leak/client.yaml
@@ -6,6 +6,7 @@ DHTFileName: "dht.db"
ListenAddr: "127.0.0.1:2120"
ThisNodeID: "00000f3b43288fe99831eb533ab77ec455d13e11fc38ec35a42d4edd17aa320d"
ValidDNSKeys:
+ oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
MinNodeIDDifficulty: 2
diff --git a/test/leak/leader.yaml b/test/leak/leader.yaml
index 330ee46b5..6ed3215e2 100644
--- a/test/leak/leader.yaml
+++ b/test/leak/leader.yaml
@@ -6,6 +6,7 @@ DHTFileName: "./leader/dht.db"
ListenAddr: "127.0.0.1:2331"
ThisNodeID: "00000bef611d346c0cbe1beaa76e7f0ed705a194fdf9ac3a248ec70e9c198bf9"
ValidDNSKeys:
+ oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
MinNodeIDDifficulty: 2
diff --git a/test/mainchain/node_0/config.yaml b/test/mainchain/node_0/config.yaml
index 866534570..00e043ce6 100644
--- a/test/mainchain/node_0/config.yaml
+++ b/test/mainchain/node_0/config.yaml
@@ -6,6 +6,7 @@ DHTFileName: "dht.db"
ListenAddr: "127.0.0.1:5122"
ThisNodeID: "00000bef611d346c0cbe1beaa76e7f0ed705a194fdf9ac3a248ec70e9c198bf9"
ValidDNSKeys:
+ oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
MinNodeIDDifficulty: 2
diff --git a/test/mainchain/node_1/config.yaml b/test/mainchain/node_1/config.yaml
index c53b9fba4..c64a912b8 100644
--- a/test/mainchain/node_1/config.yaml
+++ b/test/mainchain/node_1/config.yaml
@@ -6,6 +6,7 @@ DHTFileName: "dht.db"
ListenAddr: "127.0.0.1:5121"
ThisNodeID: "00000381d46fd6cf7742d7fb94e2422033af989c0e348b5781b3219599a3af35"
ValidDNSKeys:
+ oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
MinNodeIDDifficulty: 2
diff --git a/test/mainchain/node_2/config.yaml b/test/mainchain/node_2/config.yaml
index b15a972b7..6e34bdc39 100644
--- a/test/mainchain/node_2/config.yaml
+++ b/test/mainchain/node_2/config.yaml
@@ -6,6 +6,7 @@ DHTFileName: "dht.db"
ListenAddr: "127.0.0.1:5120"
ThisNodeID: "000000172580063ded88e010556b0aca2851265be8845b1ef397e8fce6ab5582"
ValidDNSKeys:
+ oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
MinNodeIDDifficulty: 2
diff --git a/test/mainchain/node_c/config.yaml b/test/mainchain/node_c/config.yaml
index 9c509ef03..d774b6628 100644
--- a/test/mainchain/node_c/config.yaml
+++ b/test/mainchain/node_c/config.yaml
@@ -6,6 +6,7 @@ DHTFileName: "dht.db"
ListenAddr: "127.0.0.1:5120"
ThisNodeID: "00000f3b43288fe99831eb533ab77ec455d13e11fc38ec35a42d4edd17aa320d"
ValidDNSKeys:
+ oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
MinNodeIDDifficulty: 2
diff --git a/test/mainchain/node_miner_0/config.yaml b/test/mainchain/node_miner_0/config.yaml
index b5f65dc73..684571381 100644
--- a/test/mainchain/node_miner_0/config.yaml
+++ b/test/mainchain/node_miner_0/config.yaml
@@ -6,6 +6,7 @@ DHTFileName: "dht.db"
ListenAddr: "127.0.0.1:5144"
ThisNodeID: "000005aa62048f85da4ae9698ed59c14ec0d48a88a07c15a32265634e7e64ade"
ValidDNSKeys:
+ oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
BlockProducer:
diff --git a/test/mainchain/node_miner_1/config.yaml b/test/mainchain/node_miner_1/config.yaml
index 8d88cd5c9..985c135e0 100644
--- a/test/mainchain/node_miner_1/config.yaml
+++ b/test/mainchain/node_miner_1/config.yaml
@@ -6,6 +6,7 @@ DHTFileName: "dht.db"
ListenAddr: "127.0.0.1:5145"
ThisNodeID: "000005f4f22c06f76c43c4f48d5a7ec1309cc94030cbf9ebae814172884ac8b5"
ValidDNSKeys:
+ oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
BlockProducer:
diff --git a/test/mainchain/node_miner_2/config.yaml b/test/mainchain/node_miner_2/config.yaml
index 3e67adecf..7b595fc54 100644
--- a/test/mainchain/node_miner_2/config.yaml
+++ b/test/mainchain/node_miner_2/config.yaml
@@ -6,6 +6,7 @@ DHTFileName: "dht.db"
ListenAddr: "127.0.0.1:5146"
ThisNodeID: "000003f49592f83d0473bddb70d543f1096b4ffed5e5f942a3117e256b7052b8"
ValidDNSKeys:
+ oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
BlockProducer:
diff --git a/test/mainchain/node_multi_0/config.yaml b/test/mainchain/node_multi_0/config.yaml
index a0b088db4..0bb19157a 100644
--- a/test/mainchain/node_multi_0/config.yaml
+++ b/test/mainchain/node_multi_0/config.yaml
@@ -6,6 +6,7 @@ DHTFileName: "dht.db"
ListenAddr: "127.0.0.1:5230"
ThisNodeID: "00000bef611d346c0cbe1beaa76e7f0ed705a194fdf9ac3a248ec70e9c198bf9"
ValidDNSKeys:
+ oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
MinNodeIDDifficulty: 2
diff --git a/test/mainchain/node_multi_1/config.yaml b/test/mainchain/node_multi_1/config.yaml
index c92846f87..6db666061 100644
--- a/test/mainchain/node_multi_1/config.yaml
+++ b/test/mainchain/node_multi_1/config.yaml
@@ -6,6 +6,7 @@ DHTFileName: "dht.db"
ListenAddr: "127.0.0.1:5231"
ThisNodeID: "00000bef611d346c0cbe1beaa76e7f0ed705a194fdf9ac3a248ec70e9c198bf9"
ValidDNSKeys:
+ oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
MinNodeIDDifficulty: 2
diff --git a/test/mainchain/node_multi_2/config.yaml b/test/mainchain/node_multi_2/config.yaml
index 8d5f46eee..3aded00a2 100644
--- a/test/mainchain/node_multi_2/config.yaml
+++ b/test/mainchain/node_multi_2/config.yaml
@@ -6,6 +6,7 @@ DHTFileName: "dht.db"
ListenAddr: "127.0.0.1:5232"
ThisNodeID: "00000bef611d346c0cbe1beaa76e7f0ed705a194fdf9ac3a248ec70e9c198bf9"
ValidDNSKeys:
+ oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
MinNodeIDDifficulty: 2
diff --git a/test/mainchain/node_standalone/config.yaml b/test/mainchain/node_standalone/config.yaml
index a0b088db4..0bb19157a 100644
--- a/test/mainchain/node_standalone/config.yaml
+++ b/test/mainchain/node_standalone/config.yaml
@@ -6,6 +6,7 @@ DHTFileName: "dht.db"
ListenAddr: "127.0.0.1:5230"
ThisNodeID: "00000bef611d346c0cbe1beaa76e7f0ed705a194fdf9ac3a248ec70e9c198bf9"
ValidDNSKeys:
+ oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
MinNodeIDDifficulty: 2
diff --git a/test/node_0/config.yaml b/test/node_0/config.yaml
index 9c2327abb..54ba3cb2c 100644
--- a/test/node_0/config.yaml
+++ b/test/node_0/config.yaml
@@ -6,6 +6,7 @@ DHTFileName: "dht.db"
ListenAddr: "127.0.0.1:2122"
ThisNodeID: "00000bef611d346c0cbe1beaa76e7f0ed705a194fdf9ac3a248ec70e9c198bf9"
ValidDNSKeys:
+ oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
MinNodeIDDifficulty: 2
diff --git a/test/node_1/config.yaml b/test/node_1/config.yaml
index be088389f..0be7bbf5f 100644
--- a/test/node_1/config.yaml
+++ b/test/node_1/config.yaml
@@ -6,6 +6,7 @@ DHTFileName: "dht.db"
ListenAddr: "127.0.0.1:2121"
ThisNodeID: "00000381d46fd6cf7742d7fb94e2422033af989c0e348b5781b3219599a3af35"
ValidDNSKeys:
+ oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
MinNodeIDDifficulty: 2
diff --git a/test/node_2/config.yaml b/test/node_2/config.yaml
index 0e05b138f..48624c72c 100644
--- a/test/node_2/config.yaml
+++ b/test/node_2/config.yaml
@@ -6,6 +6,7 @@ DHTFileName: "dht.db"
ListenAddr: "127.0.0.1:2120"
ThisNodeID: "000000172580063ded88e010556b0aca2851265be8845b1ef397e8fce6ab5582"
ValidDNSKeys:
+ oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
MinNodeIDDifficulty: 2
diff --git a/test/node_c/config.yaml b/test/node_c/config.yaml
index b23931038..402ff3c4a 100644
--- a/test/node_c/config.yaml
+++ b/test/node_c/config.yaml
@@ -6,6 +6,7 @@ DHTFileName: "dht.db"
ListenAddr: "127.0.0.1:2120"
ThisNodeID: "00000f3b43288fe99831eb533ab77ec455d13e11fc38ec35a42d4edd17aa320d"
ValidDNSKeys:
+ oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
MinNodeIDDifficulty: 2
diff --git a/test/node_standalone/config.yaml b/test/node_standalone/config.yaml
index b5709bde4..71a8a114f 100644
--- a/test/node_standalone/config.yaml
+++ b/test/node_standalone/config.yaml
@@ -6,6 +6,7 @@ DHTFileName: "dht.db"
ListenAddr: "127.0.0.1:2230"
ThisNodeID: "00000bef611d346c0cbe1beaa76e7f0ed705a194fdf9ac3a248ec70e9c198bf9"
ValidDNSKeys:
+ oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
MinNodeIDDifficulty: 2
diff --git a/test/node_standalone/config2.yaml b/test/node_standalone/config2.yaml
index 7921f4cd1..11dc6df97 100644
--- a/test/node_standalone/config2.yaml
+++ b/test/node_standalone/config2.yaml
@@ -6,6 +6,7 @@ DHTFileName: "dht.db"
ListenAddr: "127.0.0.1:12230"
ThisNodeID: "00000bef611d346c0cbe1beaa76e7f0ed705a194fdf9ac3a248ec70e9c198bf9"
ValidDNSKeys:
+ oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
MinNodeIDDifficulty: 2
diff --git a/test/observation/node_0/config.yaml b/test/observation/node_0/config.yaml
index 5f28396f8..a53f7915d 100644
--- a/test/observation/node_0/config.yaml
+++ b/test/observation/node_0/config.yaml
@@ -6,6 +6,7 @@ DHTFileName: "dht.db"
ListenAddr: "127.0.0.1:4122"
ThisNodeID: "00000bef611d346c0cbe1beaa76e7f0ed705a194fdf9ac3a248ec70e9c198bf9"
ValidDNSKeys:
+ oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
MinNodeIDDifficulty: 2
diff --git a/test/observation/node_1/config.yaml b/test/observation/node_1/config.yaml
index 1d4a67dcd..fc39df287 100644
--- a/test/observation/node_1/config.yaml
+++ b/test/observation/node_1/config.yaml
@@ -6,6 +6,7 @@ DHTFileName: "dht.db"
ListenAddr: "127.0.0.1:4121"
ThisNodeID: "00000381d46fd6cf7742d7fb94e2422033af989c0e348b5781b3219599a3af35"
ValidDNSKeys:
+ oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
MinNodeIDDifficulty: 2
diff --git a/test/observation/node_2/config.yaml b/test/observation/node_2/config.yaml
index af8bc1911..faa1c477e 100644
--- a/test/observation/node_2/config.yaml
+++ b/test/observation/node_2/config.yaml
@@ -6,6 +6,7 @@ DHTFileName: "dht.db"
ListenAddr: "127.0.0.1:4120"
ThisNodeID: "000000172580063ded88e010556b0aca2851265be8845b1ef397e8fce6ab5582"
ValidDNSKeys:
+ oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
MinNodeIDDifficulty: 2
diff --git a/test/observation/node_c/config.yaml b/test/observation/node_c/config.yaml
index 098da0e36..d577fd86c 100644
--- a/test/observation/node_c/config.yaml
+++ b/test/observation/node_c/config.yaml
@@ -6,6 +6,7 @@ DHTFileName: "dht.db"
ListenAddr: "127.0.0.1:4120"
ThisNodeID: "00000f3b43288fe99831eb533ab77ec455d13e11fc38ec35a42d4edd17aa320d"
ValidDNSKeys:
+ oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
MinNodeIDDifficulty: 2
diff --git a/test/observation/node_miner_0/config.yaml b/test/observation/node_miner_0/config.yaml
index 43934a95e..03f6e9f7c 100644
--- a/test/observation/node_miner_0/config.yaml
+++ b/test/observation/node_miner_0/config.yaml
@@ -6,6 +6,7 @@ DHTFileName: "dht.db"
ListenAddr: "127.0.0.1:4144"
ThisNodeID: "000005aa62048f85da4ae9698ed59c14ec0d48a88a07c15a32265634e7e64ade"
ValidDNSKeys:
+ oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
BlockProducer:
diff --git a/test/observation/node_miner_1/config.yaml b/test/observation/node_miner_1/config.yaml
index 400a21ad9..c9ee38439 100644
--- a/test/observation/node_miner_1/config.yaml
+++ b/test/observation/node_miner_1/config.yaml
@@ -6,6 +6,7 @@ DHTFileName: "dht.db"
ListenAddr: "127.0.0.1:4145"
ThisNodeID: "000005f4f22c06f76c43c4f48d5a7ec1309cc94030cbf9ebae814172884ac8b5"
ValidDNSKeys:
+ oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
BlockProducer:
diff --git a/test/observation/node_miner_2/config.yaml b/test/observation/node_miner_2/config.yaml
index edeb37ebc..6de8223a7 100644
--- a/test/observation/node_miner_2/config.yaml
+++ b/test/observation/node_miner_2/config.yaml
@@ -6,6 +6,7 @@ DHTFileName: "dht.db"
ListenAddr: "127.0.0.1:4146"
ThisNodeID: "000003f49592f83d0473bddb70d543f1096b4ffed5e5f942a3117e256b7052b8"
ValidDNSKeys:
+ oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
BlockProducer:
diff --git a/test/observation/node_observer/config.yaml b/test/observation/node_observer/config.yaml
index 3a344a39f..6becaa0fc 100644
--- a/test/observation/node_observer/config.yaml
+++ b/test/observation/node_observer/config.yaml
@@ -6,6 +6,7 @@ DHTFileName: "dht.db"
ListenAddr: "127.0.0.1:4123"
ThisNodeID: "0000037c786c744967bf536e58d51f24c074f14f693b1daedef88bf9efb92349"
ValidDNSKeys:
+ oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
MinNodeIDDifficulty: 2
diff --git a/test/pool/client.yaml b/test/pool/client.yaml
index 7bc3f1165..cf25cfe8a 100644
--- a/test/pool/client.yaml
+++ b/test/pool/client.yaml
@@ -6,6 +6,7 @@ DHTFileName: "dht.db"
ListenAddr: "127.0.0.1:2520"
ThisNodeID: "00000f3b43288fe99831eb533ab77ec455d13e11fc38ec35a42d4edd17aa320d"
ValidDNSKeys:
+ oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
MinNodeIDDifficulty: 2
diff --git a/test/pool/leader.yaml b/test/pool/leader.yaml
index 400fb667d..cc2f1517f 100644
--- a/test/pool/leader.yaml
+++ b/test/pool/leader.yaml
@@ -6,6 +6,7 @@ DHTFileName: "dht.db"
ListenAddr: "127.0.0.1:2530"
ThisNodeID: "00000bef611d346c0cbe1beaa76e7f0ed705a194fdf9ac3a248ec70e9c198bf9"
ValidDNSKeys:
+ oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
MinNodeIDDifficulty: 2
diff --git a/test/service/node_0/config.yaml b/test/service/node_0/config.yaml
index b346a58a2..40b86586c 100644
--- a/test/service/node_0/config.yaml
+++ b/test/service/node_0/config.yaml
@@ -6,6 +6,7 @@ DHTFileName: "dht.db"
ListenAddr: "172.254.1.2:4661"
ThisNodeID: "00000bef611d346c0cbe1beaa76e7f0ed705a194fdf9ac3a248ec70e9c198bf9"
ValidDNSKeys:
+ oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
MinNodeIDDifficulty: 2
diff --git a/test/service/node_1/config.yaml b/test/service/node_1/config.yaml
index 0c0d2bf5f..bf1845112 100644
--- a/test/service/node_1/config.yaml
+++ b/test/service/node_1/config.yaml
@@ -6,6 +6,7 @@ DHTFileName: "dht.db"
ListenAddr: "172.254.1.3:4661"
ThisNodeID: "00000381d46fd6cf7742d7fb94e2422033af989c0e348b5781b3219599a3af35"
ValidDNSKeys:
+ oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
MinNodeIDDifficulty: 2
diff --git a/test/service/node_2/config.yaml b/test/service/node_2/config.yaml
index 47d526619..491ac21a4 100644
--- a/test/service/node_2/config.yaml
+++ b/test/service/node_2/config.yaml
@@ -6,6 +6,7 @@ DHTFileName: "dht.db"
ListenAddr: "172.254.1.4:4661"
ThisNodeID: "000000172580063ded88e010556b0aca2851265be8845b1ef397e8fce6ab5582"
ValidDNSKeys:
+ oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
MinNodeIDDifficulty: 2
diff --git a/test/service/node_adapter/config.yaml b/test/service/node_adapter/config.yaml
index aeefebf7f..198cfc1d5 100644
--- a/test/service/node_adapter/config.yaml
+++ b/test/service/node_adapter/config.yaml
@@ -6,6 +6,7 @@ DHTFileName: "dht.db"
ListenAddr: "172.254.1.4:4661"
ThisNodeID: "00000f3b43288fe99831eb533ab77ec455d13e11fc38ec35a42d4edd17aa320d"
ValidDNSKeys:
+ oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
MinNodeIDDifficulty: 2
diff --git a/test/service/node_c/config.yaml b/test/service/node_c/config.yaml
index aeefebf7f..198cfc1d5 100644
--- a/test/service/node_c/config.yaml
+++ b/test/service/node_c/config.yaml
@@ -6,6 +6,7 @@ DHTFileName: "dht.db"
ListenAddr: "172.254.1.4:4661"
ThisNodeID: "00000f3b43288fe99831eb533ab77ec455d13e11fc38ec35a42d4edd17aa320d"
ValidDNSKeys:
+ oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
MinNodeIDDifficulty: 2
diff --git a/test/service/node_miner_0/config.yaml b/test/service/node_miner_0/config.yaml
index 4c981fcb7..15731d216 100644
--- a/test/service/node_miner_0/config.yaml
+++ b/test/service/node_miner_0/config.yaml
@@ -6,6 +6,7 @@ DHTFileName: "dht.db"
ListenAddr: "172.254.1.5:4661"
ThisNodeID: "000005aa62048f85da4ae9698ed59c14ec0d48a88a07c15a32265634e7e64ade"
ValidDNSKeys:
+ oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
BlockProducer:
diff --git a/test/service/node_miner_1/config.yaml b/test/service/node_miner_1/config.yaml
index e41bbbb9f..0e6722625 100644
--- a/test/service/node_miner_1/config.yaml
+++ b/test/service/node_miner_1/config.yaml
@@ -6,6 +6,7 @@ DHTFileName: "dht.db"
ListenAddr: "172.254.1.6:4661"
ThisNodeID: "000005f4f22c06f76c43c4f48d5a7ec1309cc94030cbf9ebae814172884ac8b5"
ValidDNSKeys:
+ oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
BlockProducer:
diff --git a/test/service/node_miner_2/config.yaml b/test/service/node_miner_2/config.yaml
index 00d4caed0..49f792650 100644
--- a/test/service/node_miner_2/config.yaml
+++ b/test/service/node_miner_2/config.yaml
@@ -6,6 +6,7 @@ DHTFileName: "dht.db"
ListenAddr: "172.254.1.7:4661"
ThisNodeID: "000003f49592f83d0473bddb70d543f1096b4ffed5e5f942a3117e256b7052b8"
ValidDNSKeys:
+ oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
BlockProducer:
diff --git a/test/service/node_mysql_adapter/config.yaml b/test/service/node_mysql_adapter/config.yaml
index 3045d1535..f6272cfd1 100644
--- a/test/service/node_mysql_adapter/config.yaml
+++ b/test/service/node_mysql_adapter/config.yaml
@@ -6,6 +6,7 @@ DHTFileName: "dht.db"
ListenAddr: "172.254.1.4:4661"
ThisNodeID: "00000f3b43288fe99831eb533ab77ec455d13e11fc38ec35a42d4edd17aa320d"
ValidDNSKeys:
+ oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
MinNodeIDDifficulty: 2
diff --git a/test/service/node_observer/config.yaml b/test/service/node_observer/config.yaml
index 9f6dff35a..774dee83e 100644
--- a/test/service/node_observer/config.yaml
+++ b/test/service/node_observer/config.yaml
@@ -6,6 +6,7 @@ DHTFileName: "dht.db"
ListenAddr: "172.254.1.9:4661"
ThisNodeID: "0000037c786c744967bf536e58d51f24c074f14f693b1daedef88bf9efb92349"
ValidDNSKeys:
+ oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
MinNodeIDDifficulty: 2
From 339247b31fdcf3f5c12db5066763a831710e5146 Mon Sep 17 00:00:00 2001
From: leventeliu
Date: Thu, 6 Dec 2018 21:35:09 +0800
Subject: [PATCH 032/278] Add branch and runtime state
---
blockproducer/blockindex.go | 21 ++++++
blockproducer/branch.go | 147 ++++++++++++++++++++++++++++++++++++
blockproducer/chain.go | 7 +-
blockproducer/config.go | 5 +-
blockproducer/runtime.go | 115 ++++++++++++++++++++++++++--
blockproducer/state.go | 4 +-
blockproducer/storage.go | 110 +++++++++++++++++++++++++++
7 files changed, 397 insertions(+), 12 deletions(-)
create mode 100644 blockproducer/branch.go
create mode 100644 blockproducer/storage.go
diff --git a/blockproducer/blockindex.go b/blockproducer/blockindex.go
index 88884809b..7bcde5d4e 100644
--- a/blockproducer/blockindex.go
+++ b/blockproducer/blockindex.go
@@ -31,6 +31,15 @@ type blockNode struct {
parent *blockNode
height uint32
count uint32
+ block *types.BPBlock
+}
+
+func newBlockNodeEx(b *types.BPBlock, p *blockNode) *blockNode {
+ return &blockNode{
+ hash: b.SignedHeader.BlockHash,
+ parent: p,
+ block: b,
+ }
}
func newBlockNode(chainInitTime time.Time, period time.Duration, block *types.BPBlock, parent *blockNode) *blockNode {
@@ -50,6 +59,7 @@ func newBlockNode(chainInitTime time.Time, period time.Duration, block *types.BP
parent: parent,
height: h,
count: count,
+ block: block,
}
return bn
@@ -97,6 +107,17 @@ func (bn *blockNode) ancestorByCount(c uint32) *blockNode {
return ancestor
}
+func (bn *blockNode) lastIrreversible(comfirm uint32) (irr *blockNode) {
+ var count = bn.count - comfirm
+ for irr = bn; irr.count == 0 && irr.count > count; irr = irr.parent {
+ }
+ return
+}
+
+func (bn *blockNode) hasAncestor(anc *blockNode) bool {
+ return bn.ancestorByCount(anc.count).hash == anc.hash
+}
+
type blockIndex struct {
mu sync.RWMutex
index map[hash.Hash]*blockNode
diff --git a/blockproducer/branch.go b/blockproducer/branch.go
new file mode 100644
index 000000000..de73004c8
--- /dev/null
+++ b/blockproducer/branch.go
@@ -0,0 +1,147 @@
+/*
+ * Copyright 2018 The CovenantSQL Authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package blockproducer
+
+import (
+ "bytes"
+ "sort"
+
+ pi "github.com/CovenantSQL/CovenantSQL/blockproducer/interfaces"
+ "github.com/CovenantSQL/CovenantSQL/crypto/hash"
+ "github.com/CovenantSQL/CovenantSQL/types"
+)
+
+type view struct {
+}
+
+func (v *view) apply(tx pi.Transaction) (err error) {
+ return
+}
+
+func (v *view) makeCopy() *view {
+ return &view{}
+}
+
+type branch struct {
+ head *blockNode
+ preview *view
+ packed map[hash.Hash]pi.Transaction
+ unpacked map[hash.Hash]pi.Transaction
+}
+
+func (b *branch) makeCopy() *branch {
+ var (
+ p = make(map[hash.Hash]pi.Transaction)
+ u = make(map[hash.Hash]pi.Transaction)
+ )
+ for k, v := range b.packed {
+ p[k] = v
+ }
+ for k, v := range b.unpacked {
+ u[k] = v
+ }
+ return &branch{
+ head: b.head,
+ preview: b.preview.makeCopy(),
+ packed: p,
+ unpacked: u,
+ }
+}
+
+func (b *branch) addTx(tx pi.Transaction) {
+ var k = tx.Hash()
+ if _, ok := b.packed[k]; !ok {
+ if _, ok := b.unpacked[k]; !ok {
+ b.unpacked[k] = tx
+ }
+ }
+}
+
+func (b *branch) applyBlock(bl *types.BPBlock) (br *branch, err error) {
+ if !b.head.hash.IsEqual(bl.ParentHash()) {
+ err = ErrParentNotMatch
+ return
+ }
+ var cpy = b.makeCopy()
+ for _, v := range bl.Transactions {
+ var k = v.Hash()
+ // Check in tx pool
+ if _, ok := cpy.unpacked[k]; ok {
+ delete(cpy.unpacked, k)
+ } else if err = v.Verify(); err != nil {
+ return
+ }
+ if _, ok := cpy.packed[k]; ok {
+ err = ErrExistedTx
+ return
+ }
+ cpy.packed[k] = v
+ // Apply to preview
+ if err = cpy.preview.apply(v); err != nil {
+ return
+ }
+ }
+ cpy.head = newBlockNodeEx(bl, cpy.head)
+ br = cpy
+ return
+}
+
+func (b *branch) sortUnpackedTxs() (txs []pi.Transaction) {
+ txs = make([]pi.Transaction, 0, len(b.unpacked))
+ for _, v := range b.unpacked {
+ txs = append(txs, v)
+ }
+ sort.Slice(txs, func(i, j int) bool {
+ if cmp := bytes.Compare(txs[i].Hash().AsBytes(), txs[j].Hash().AsBytes()); cmp != 0 {
+ return cmp < 0
+ }
+ return txs[i].GetAccountNonce() < txs[j].GetAccountNonce()
+ })
+ return
+}
+
+func newBlock(out []pi.Transaction) (bl *types.BPBlock) {
+ return
+}
+
+func (b *branch) produceBlock() (br *branch, bl *types.BPBlock, err error) {
+ var (
+ cpy = b.makeCopy()
+ txs = cpy.sortUnpackedTxs()
+ out = make([]pi.Transaction, 0, len(txs))
+ )
+ for _, v := range txs {
+ var k = v.Hash()
+ if err = cpy.preview.apply(v); err != nil {
+ continue
+ }
+ delete(cpy.unpacked, k)
+ cpy.packed[k] = v
+ out = append(out, v)
+ }
+ // Create new block and update head
+ bl = newBlock(out)
+ cpy.head = newBlockNodeEx(bl, cpy.head)
+ br = cpy
+ return
+}
+
+func (b *branch) clearPackedTxs(txs []pi.Transaction) {
+ for _, v := range txs {
+ delete(b.packed, v.Hash())
+ }
+}
diff --git a/blockproducer/chain.go b/blockproducer/chain.go
index 2b9ba794f..b1ca03626 100644
--- a/blockproducer/chain.go
+++ b/blockproducer/chain.go
@@ -36,6 +36,7 @@ import (
"github.com/CovenantSQL/CovenantSQL/types"
"github.com/CovenantSQL/CovenantSQL/utils"
"github.com/CovenantSQL/CovenantSQL/utils/log"
+ xi "github.com/CovenantSQL/CovenantSQL/xenomint/interfaces"
"github.com/coreos/bbolt"
"github.com/pkg/errors"
)
@@ -65,6 +66,8 @@ type Chain struct {
blocksFromRPC chan *types.BPBlock
pendingTxs chan pi.Transaction
ctx context.Context
+
+ st xi.Storage
}
// NewChain creates a new blockchain.
@@ -213,7 +216,7 @@ func LoadChain(cfg *Config) (chain *Chain, err error) {
return ErrMetaStateNotFound
}
- state := &State{}
+ state := &Obsolete{}
if err = utils.DecodeMsgPack(metaEnc, state); err != nil {
return
}
@@ -307,7 +310,7 @@ func (c *Chain) pushBlockWithoutCheck(b *types.BPBlock) error {
h := c.rt.getHeightFromTime(b.Timestamp())
log.Debugf("current block %s, height %d, its parent %s", b.BlockHash(), h, b.ParentHash())
node := newBlockNode(c.rt.chainInitTime, c.rt.period, b, c.rt.getHead().Node)
- state := &State{
+ state := &Obsolete{
Node: node,
Head: node.hash,
Height: node.height,
diff --git a/blockproducer/config.go b/blockproducer/config.go
index 772c58630..2dea39005 100644
--- a/blockproducer/config.go
+++ b/blockproducer/config.go
@@ -36,8 +36,9 @@ type Config struct {
Server *rpc.Server
- Peers *proto.Peers
- NodeID proto.NodeID
+ Peers *proto.Peers
+ NodeID proto.NodeID
+ ComfirmThreshold float64
Period time.Duration
Tick time.Duration
diff --git a/blockproducer/runtime.go b/blockproducer/runtime.go
index f9a5f593b..c155b5762 100644
--- a/blockproducer/runtime.go
+++ b/blockproducer/runtime.go
@@ -19,12 +19,17 @@ package blockproducer
import (
"context"
"fmt"
+ "math"
"sync"
"time"
+ pi "github.com/CovenantSQL/CovenantSQL/blockproducer/interfaces"
+ "github.com/CovenantSQL/CovenantSQL/crypto/hash"
"github.com/CovenantSQL/CovenantSQL/proto"
"github.com/CovenantSQL/CovenantSQL/route"
"github.com/CovenantSQL/CovenantSQL/rpc"
+ "github.com/CovenantSQL/CovenantSQL/types"
+ xi "github.com/CovenantSQL/CovenantSQL/xenomint/interfaces"
)
// copy from /sqlchain/runtime.go
@@ -53,12 +58,14 @@ type rt struct {
peersMutex sync.Mutex
peers *proto.Peers
nodeID proto.NodeID
+ minComfirm uint32
stateMutex sync.Mutex // Protects following fields.
// nextTurn is the height of the next block.
nextTurn uint32
// head is the current head of the best chain.
- head *State
+ head *Obsolete
+ optionalHeads []*Obsolete
// timeMutex protects following time-relative fields.
timeMutex sync.Mutex
@@ -66,9 +73,93 @@ type rt struct {
//
// TODO(leventeliu): update offset in ping cycle.
offset time.Duration
+
+ // Cached state
+ cacheMu sync.RWMutex
+ irre *blockNode
+ immutable *view
+ current *branch
+ optional []*branch
+ txPool map[hash.Hash]pi.Transaction
+}
+
+func (r *rt) addTx(tx pi.Transaction) {
+ var k = tx.Hash()
+ r.cacheMu.Lock()
+ defer r.cacheMu.Unlock()
+ if _, ok := r.txPool[k]; !ok {
+ r.txPool[k] = tx
+ }
+ r.current.addTx(tx)
+ for _, v := range r.optional {
+ v.addTx(tx)
+ }
}
-// now returns the current coodinated chain time.
+func (r *rt) produceBlock(st xi.Storage) (err error) {
+ var (
+ br *branch
+ bl *types.BPBlock
+ irre *blockNode
+ newIrres []*blockNode
+ )
+ r.cacheMu.Lock()
+ r.cacheMu.Unlock()
+
+ // Try to produce new block
+ if br, bl, err = r.current.produceBlock(); err != nil {
+ return
+ }
+
+ // Find new irreversible blocks
+ //
+ // NOTE(leventeliu):
+ // May have multiple new irreversible blocks here if peer list shrinks.
+ // May also have no new irreversible block at all if peer list expands.
+ irre = br.head.lastIrreversible(r.minComfirm)
+ for n := irre; n.count > r.irre.count; n = n.parent {
+ newIrres = append(newIrres, n)
+ }
+
+ var (
+ sps []storageProcedure
+ up storageCallback
+ )
+
+ // Prepare storage procedures to update immutable
+ sps = append(sps, addBlock(bl))
+ // Note that block nodes are pushed in reverse order and should be applied in ascending order
+ for i := len(newIrres) - 1; i >= 0; i-- {
+ var v = newIrres[i]
+ sps = append(
+ sps,
+ updateImmutable(v.block.Transactions),
+ deleteTxs(v.block.Transactions),
+ )
+ }
+ sps = append(sps, updateIrreversible(irre.hash))
+
+ // Prepare callback to update cache
+ up = func() {
+ // Replace current branch
+ r.current = br
+ // Prune branches
+ var brs = make([]*branch, 0, len(r.optional))
+ for _, v := range r.optional {
+ if v.head.hasAncestor(irre) {
+ brs = append(brs, v)
+ }
+ }
+ r.optional = brs
+ // Update last irreversible block
+ r.irre = irre
+ }
+
+ // Write to immutable database and update cache
+ return store(st, sps, up)
+}
+
+// now returns the current coordinated chain time.
func (r *rt) now() time.Time {
r.timeMutex.Lock()
defer r.timeMutex.Unlock()
@@ -83,7 +174,18 @@ func newRuntime(ctx context.Context, cfg *Config, accountAddress proto.AccountAd
index = uint32(i)
}
}
- var cld, ccl = context.WithCancel(ctx)
+ var (
+ cld, ccl = context.WithCancel(ctx)
+ l = float64(len(cfg.Peers.Servers))
+ t float64
+ m float64
+ )
+ if t = cfg.ComfirmThreshold; t <= 0.0 {
+ t = float64(2) / 3.0
+ }
+ if m = math.Ceil(l*t + 1); m > l {
+ m = l
+ }
return &rt{
ctx: cld,
cancel: ccl,
@@ -97,8 +199,9 @@ func newRuntime(ctx context.Context, cfg *Config, accountAddress proto.AccountAd
tick: cfg.Tick,
peers: cfg.Peers,
nodeID: cfg.NodeID,
+ minComfirm: uint32(m),
nextTurn: 1,
- head: &State{},
+ head: &Obsolete{},
offset: time.Duration(0),
}
}
@@ -162,13 +265,13 @@ func (r *rt) getPeers() *proto.Peers {
return &peers
}
-func (r *rt) getHead() *State {
+func (r *rt) getHead() *Obsolete {
r.stateMutex.Lock()
defer r.stateMutex.Unlock()
return r.head
}
-func (r *rt) setHead(head *State) {
+func (r *rt) setHead(head *Obsolete) {
r.stateMutex.Lock()
defer r.stateMutex.Unlock()
r.head = head
diff --git a/blockproducer/state.go b/blockproducer/state.go
index 9e0723e2f..227603864 100644
--- a/blockproducer/state.go
+++ b/blockproducer/state.go
@@ -20,8 +20,8 @@ import (
"github.com/CovenantSQL/CovenantSQL/crypto/hash"
)
-// State store the node info of chain.
-type State struct {
+// Obsolete stores the node info of chain.
+type Obsolete struct {
Node *blockNode
Head hash.Hash
Height uint32
diff --git a/blockproducer/storage.go b/blockproducer/storage.go
new file mode 100644
index 000000000..84ddb77a6
--- /dev/null
+++ b/blockproducer/storage.go
@@ -0,0 +1,110 @@
+/*
+ * Copyright 2018 The CovenantSQL Authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package blockproducer
+
+import (
+ "bytes"
+ "database/sql"
+
+ pi "github.com/CovenantSQL/CovenantSQL/blockproducer/interfaces"
+ "github.com/CovenantSQL/CovenantSQL/crypto/hash"
+ "github.com/CovenantSQL/CovenantSQL/types"
+ "github.com/CovenantSQL/CovenantSQL/utils"
+ "github.com/CovenantSQL/CovenantSQL/utils/log"
+ xi "github.com/CovenantSQL/CovenantSQL/xenomint/interfaces"
+)
+
+type storageProcedure func(tx *sql.Tx) error
+type storageCallback func()
+
+func store(st xi.Storage, sps []storageProcedure, cb storageCallback) (err error) {
+ var tx *sql.Tx
+ // BEGIN
+ if tx, err = st.Writer().Begin(); err != nil {
+ return
+ }
+ // ROLLBACK on failure
+ defer tx.Rollback()
+ // WRITE
+ for _, sp := range sps {
+ if err = sp(tx); err != nil {
+ return
+ }
+ }
+ // CALLBACK: MUST NOT FAIL
+ cb()
+ // COMMIT
+ if err = tx.Commit(); err != nil {
+ log.WithError(err).Fatalf("Failed to commit storage transaction")
+ }
+ return
+}
+
+func errPass(err error) storageProcedure {
+ return func(_ *sql.Tx) error {
+ return err
+ }
+}
+
+func initStorage(tx *sql.Tx) (err error) {
+ return
+}
+
+func addBlock(b *types.BPBlock) storageProcedure {
+ var (
+ enc *bytes.Buffer
+ err error
+ )
+ if enc, err = utils.EncodeMsgPack(b); err != nil {
+ return errPass(err)
+ }
+ return func(tx *sql.Tx) (err error) {
+ _, err = tx.Exec(`?`, enc.Bytes())
+ return
+ }
+}
+
+func updateImmutable(tx []pi.Transaction) storageProcedure {
+ return nil
+}
+
+func updateIrreversible(h hash.Hash) storageProcedure {
+ return func(tx *sql.Tx) (err error) {
+ _, err = tx.Exec(`INSERT INTO "irreversible" VALUES (?)`, h)
+ return
+ }
+}
+
+func deleteTxs(txs []pi.Transaction) storageProcedure {
+ var hs = make([]hash.Hash, len(txs))
+ for i, v := range txs {
+ hs[i] = v.Hash()
+ }
+ return func(tx *sql.Tx) (err error) {
+ var stmt *sql.Stmt
+ if stmt, err = tx.Prepare(`DELETE FROM "txPool" WHERE "hash"=?`); err != nil {
+ return
+ }
+ defer stmt.Close()
+ for _, v := range hs {
+ if _, err = stmt.Exec(v); err != nil {
+ return
+ }
+ }
+ return
+ }
+}
From f6b44820745f3ba2178fb9b31249f81728622530 Mon Sep 17 00:00:00 2001
From: leventeliu
Date: Mon, 10 Dec 2018 17:20:34 +0800
Subject: [PATCH 033/278] Add method for both block producing and applying to
switch branch
---
blockproducer/blockindex.go | 32 ++++++-
blockproducer/branch.go | 40 +++++++++
blockproducer/runtime.go | 173 ++++++++++++++++++++++++++----------
blockproducer/storage.go | 14 +++
4 files changed, 210 insertions(+), 49 deletions(-)
diff --git a/blockproducer/blockindex.go b/blockproducer/blockindex.go
index 7bcde5d4e..22f6de803 100644
--- a/blockproducer/blockindex.go
+++ b/blockproducer/blockindex.go
@@ -83,6 +83,20 @@ func (bn *blockNode) initBlockNode(block *types.BPBlock, parent *blockNode) {
}
}
+// blockNodeListFrom return the block node list (forkPoint, bn].
+func (bn *blockNode) blockNodeListFrom(forkPoint uint32) (bl []*blockNode) {
+ if bn.count <= forkPoint {
+ return
+ }
+ bl = make([]*blockNode, bn.count-forkPoint)
+ var iter = bn
+ for i := len(bl) - 1; i >= 0; i-- {
+ bl[i] = iter
+ iter = iter.parent
+ }
+ return
+}
+
func (bn *blockNode) ancestor(h uint32) *blockNode {
if h > bn.height {
return nil
@@ -108,8 +122,11 @@ func (bn *blockNode) ancestorByCount(c uint32) *blockNode {
}
func (bn *blockNode) lastIrreversible(comfirm uint32) (irr *blockNode) {
- var count = bn.count - comfirm
- for irr = bn; irr.count == 0 && irr.count > count; irr = irr.parent {
+ var count uint32
+ if bn.count > comfirm {
+ count = bn.count - comfirm
+ }
+ for irr = bn; irr.count > count; irr = irr.parent {
}
return
}
@@ -118,6 +135,17 @@ func (bn *blockNode) hasAncestor(anc *blockNode) bool {
return bn.ancestorByCount(anc.count).hash == anc.hash
}
+func (bn *blockNode) findNodeAfterCount(hash hash.Hash, min uint32) (match *blockNode, ok bool) {
+ for match = bn; match.count >= min; match = match.parent {
+ if match.hash.IsEqual(&hash) {
+ ok = true
+ return
+ }
+ }
+ match = nil
+ return
+}
+
type blockIndex struct {
mu sync.RWMutex
index map[hash.Hash]*blockNode
diff --git a/blockproducer/branch.go b/blockproducer/branch.go
index de73004c8..fe7f014b8 100644
--- a/blockproducer/branch.go
+++ b/blockproducer/branch.go
@@ -43,6 +43,46 @@ type branch struct {
unpacked map[hash.Hash]pi.Transaction
}
+func fork(
+ from, to *blockNode, v *view, txPool map[hash.Hash]pi.Transaction) (br *branch, err error,
+) {
+ var (
+ diff = to.blockNodeListFrom(from.count)
+ inst = &branch{
+ head: to,
+ preview: v.makeCopy(),
+ packed: make(map[hash.Hash]pi.Transaction),
+ unpacked: make(map[hash.Hash]pi.Transaction),
+ }
+ )
+ // Copy pool
+ for k, v := range txPool {
+ inst.unpacked[k] = v
+ }
+ // Apply new blocks to view and pool
+ for _, bn := range diff {
+ for _, v := range bn.block.Transactions {
+ var k = v.Hash()
+ // Check in tx pool
+ if _, ok := inst.unpacked[k]; ok {
+ delete(inst.unpacked, k)
+ } else if err = v.Verify(); err != nil {
+ return
+ }
+ if _, ok := inst.packed[k]; ok {
+ err = ErrExistedTx
+ return
+ }
+ inst.packed[k] = v
+ // Apply to preview
+ if err = inst.preview.apply(v); err != nil {
+ return
+ }
+ }
+ }
+ return
+}
+
func (b *branch) makeCopy() *branch {
var (
p = make(map[hash.Hash]pi.Transaction)
diff --git a/blockproducer/runtime.go b/blockproducer/runtime.go
index c155b5762..0e217a976 100644
--- a/blockproducer/runtime.go
+++ b/blockproducer/runtime.go
@@ -29,6 +29,7 @@ import (
"github.com/CovenantSQL/CovenantSQL/route"
"github.com/CovenantSQL/CovenantSQL/rpc"
"github.com/CovenantSQL/CovenantSQL/types"
+ "github.com/CovenantSQL/CovenantSQL/utils/log"
xi "github.com/CovenantSQL/CovenantSQL/xenomint/interfaces"
)
@@ -78,87 +79,165 @@ type rt struct {
cacheMu sync.RWMutex
irre *blockNode
immutable *view
+ currIdx int
current *branch
- optional []*branch
+ branches []*branch
txPool map[hash.Hash]pi.Transaction
}
-func (r *rt) addTx(tx pi.Transaction) {
- var k = tx.Hash()
- r.cacheMu.Lock()
- defer r.cacheMu.Unlock()
- if _, ok := r.txPool[k]; !ok {
- r.txPool[k] = tx
- }
- r.current.addTx(tx)
- for _, v := range r.optional {
- v.addTx(tx)
- }
+func (r *rt) addTx(st xi.Storage, tx pi.Transaction) (err error) {
+ return store(st, []storageProcedure{addTx(tx)}, func() {
+ var k = tx.Hash()
+ r.cacheMu.Lock()
+ defer r.cacheMu.Unlock()
+ if _, ok := r.txPool[k]; !ok {
+ r.txPool[k] = tx
+ }
+ for _, v := range r.branches {
+ v.addTx(tx)
+ }
+ })
}
-func (r *rt) produceBlock(st xi.Storage) (err error) {
+func (r *rt) switchBranch(st xi.Storage, bl *types.BPBlock, origin int, head *branch) (err error) {
var (
- br *branch
- bl *types.BPBlock
irre *blockNode
newIrres []*blockNode
+ sps []storageProcedure
+ up storageCallback
)
- r.cacheMu.Lock()
- r.cacheMu.Unlock()
-
- // Try to produce new block
- if br, bl, err = r.current.produceBlock(); err != nil {
- return
- }
// Find new irreversible blocks
//
// NOTE(leventeliu):
- // May have multiple new irreversible blocks here if peer list shrinks.
- // May also have no new irreversible block at all if peer list expands.
- irre = br.head.lastIrreversible(r.minComfirm)
- for n := irre; n.count > r.irre.count; n = n.parent {
- newIrres = append(newIrres, n)
- }
-
- var (
- sps []storageProcedure
- up storageCallback
- )
+ // May have multiple new irreversible blocks here if peer list shrinks. May also have
+ // no new irreversible block at all if peer list expands.
+ irre = head.head.lastIrreversible(r.minComfirm)
+ newIrres = irre.blockNodeListFrom(r.irre.count)
// Prepare storage procedures to update immutable
sps = append(sps, addBlock(bl))
- // Note that block nodes are pushed in reverse order and should be applied in ascending order
- for i := len(newIrres) - 1; i >= 0; i-- {
- var v = newIrres[i]
+ for _, n := range newIrres {
sps = append(
sps,
- updateImmutable(v.block.Transactions),
- deleteTxs(v.block.Transactions),
+ updateImmutable(n.block.Transactions),
+ deleteTxs(n.block.Transactions),
)
}
sps = append(sps, updateIrreversible(irre.hash))
// Prepare callback to update cache
up = func() {
- // Replace current branch
- r.current = br
+ // Update last irreversible block
+ r.irre = irre
+ // Apply irreversible blocks to immutable database
+ for _, b := range newIrres {
+ for _, tx := range b.block.Transactions {
+ if err := r.immutable.apply(tx); err != nil {
+ log.WithError(err).Fatal("Failed to apply block to immutable database")
+ }
+ }
+ }
// Prune branches
- var brs = make([]*branch, 0, len(r.optional))
- for _, v := range r.optional {
- if v.head.hasAncestor(irre) {
- brs = append(brs, v)
+ var (
+ idx int
+ brs = make([]*branch, 0, len(r.branches))
+ )
+ for i, b := range r.branches {
+ if i == origin {
+ // Current branch
+ brs = append(brs, head)
+ idx = len(brs) - 1
+ } else if b.head.hasAncestor(irre) {
+ brs = append(brs, b)
+ }
+ }
+ // Replace current branches
+ r.current = head
+ r.currIdx = idx
+ r.branches = brs
+ // Clear packed transactions
+ for _, b := range newIrres {
+ for _, br := range r.branches {
+ br.clearPackedTxs(b.block.Transactions)
+ }
+ for _, tx := range b.block.Transactions {
+ delete(r.txPool, tx.Hash())
}
}
- r.optional = brs
- // Update last irreversible block
- r.irre = irre
}
// Write to immutable database and update cache
return store(st, sps, up)
}
+func (r *rt) applyBlock(st xi.Storage, bl *types.BPBlock) (err error) {
+ var (
+ ok bool
+ br *branch
+ parent *blockNode
+ irre *blockNode
+ newIrres []*blockNode
+ )
+ r.cacheMu.Lock()
+ defer r.cacheMu.Unlock()
+
+ for i, v := range r.branches {
+ // Grow a branch
+ if v.head.hash.IsEqual(&bl.SignedHeader.ParentHash) {
+ if br, err = v.applyBlock(bl); err != nil {
+ return
+ }
+
+ // Grow a branch while the current branch is not changed
+ if br.head.count <= r.current.head.count {
+ return store(st, []storageProcedure{addBlock(bl)}, func() { r.branches[i] = br })
+ }
+
+ // Switch branch or grow current branch
+ return r.switchBranch(st, bl, i, br)
+ }
+ // Create a fork
+ if parent, ok = v.head.findNodeAfterCount(bl.SignedHeader.ParentHash, r.irre.count); ok {
+ if br, err = fork(r.irre, parent, r.immutable, r.txPool); err != nil {
+ return
+ }
+ if br, err = v.applyBlock(bl); err != nil {
+ return
+ }
+ if br.head.count > r.current.head.count {
+ // Switch branch
+ irre = br.head.lastIrreversible(r.minComfirm)
+ for n := irre; n.count > r.irre.count; n = n.parent {
+ newIrres = append(newIrres, n)
+ }
+ } else {
+ // Update branch
+ r.branches[i] = br
+ }
+ return
+ }
+ }
+
+ return
+}
+
+func (r *rt) produceBlock(st xi.Storage) (err error) {
+ var (
+ br *branch
+ bl *types.BPBlock
+ )
+ r.cacheMu.Lock()
+ defer r.cacheMu.Unlock()
+
+ // Try to produce new block
+ if br, bl, err = r.current.produceBlock(); err != nil {
+ return
+ }
+
+ return r.switchBranch(st, bl, r.currIdx, br)
+}
+
// now returns the current coordinated chain time.
func (r *rt) now() time.Time {
r.timeMutex.Lock()
diff --git a/blockproducer/storage.go b/blockproducer/storage.go
index 84ddb77a6..a72e6f464 100644
--- a/blockproducer/storage.go
+++ b/blockproducer/storage.go
@@ -78,6 +78,20 @@ func addBlock(b *types.BPBlock) storageProcedure {
}
}
+func addTx(tx pi.Transaction) storageProcedure {
+ var (
+ enc *bytes.Buffer
+ err error
+ )
+ if enc, err = utils.EncodeMsgPack(tx); err != nil {
+ return errPass(err)
+ }
+ return func(tx *sql.Tx) (err error) {
+ _, err = tx.Exec(`INSERT INTO "txPool" VALUES (?, ?)`, enc.Bytes())
+ return
+ }
+}
+
func updateImmutable(tx []pi.Transaction) storageProcedure {
return nil
}
From 1cf0d7639ea9efffcb4478eac9dcec7b55c64e6a Mon Sep 17 00:00:00 2001
From: leventeliu
Date: Mon, 10 Dec 2018 20:58:51 +0800
Subject: [PATCH 034/278] Move state cache to metaState
---
blockproducer/branch.go | 19 ++---
blockproducer/metastate.go | 78 +++++++++++++++++++++
blockproducer/runtime.go | 86 +++++++++++++----------
blockproducer/storage.go | 139 +++++++++++++++++++++++++++++++++++--
4 files changed, 264 insertions(+), 58 deletions(-)
diff --git a/blockproducer/branch.go b/blockproducer/branch.go
index fe7f014b8..afe2341a2 100644
--- a/blockproducer/branch.go
+++ b/blockproducer/branch.go
@@ -25,29 +25,18 @@ import (
"github.com/CovenantSQL/CovenantSQL/types"
)
-type view struct {
-}
-
-func (v *view) apply(tx pi.Transaction) (err error) {
- return
-}
-
-func (v *view) makeCopy() *view {
- return &view{}
-}
-
type branch struct {
head *blockNode
- preview *view
+ preview *metaState
packed map[hash.Hash]pi.Transaction
unpacked map[hash.Hash]pi.Transaction
}
func fork(
- from, to *blockNode, v *view, txPool map[hash.Hash]pi.Transaction) (br *branch, err error,
+ from, to *blockNode, v *metaState, txPool map[hash.Hash]pi.Transaction) (br *branch, err error,
) {
var (
- diff = to.blockNodeListFrom(from.count)
+ list = to.blockNodeListFrom(from.count)
inst = &branch{
head: to,
preview: v.makeCopy(),
@@ -60,7 +49,7 @@ func fork(
inst.unpacked[k] = v
}
// Apply new blocks to view and pool
- for _, bn := range diff {
+ for _, bn := range list {
for _, v := range bn.block.Transactions {
var k = v.Hash()
// Check in tx pool
diff --git a/blockproducer/metastate.go b/blockproducer/metastate.go
index 136f9068c..71f1489ae 100644
--- a/blockproducer/metastate.go
+++ b/blockproducer/metastate.go
@@ -243,6 +243,42 @@ func (s *metaState) deleteProviderObject(k proto.AccountAddress) {
s.dirty.provider[k] = nil
}
+func (s *metaState) commit() {
+ s.Lock()
+ defer s.Unlock()
+ for k, v := range s.dirty.accounts {
+ if v != nil {
+ // New/update object
+ s.readonly.accounts[k] = v
+ } else {
+ // Delete object
+ delete(s.readonly.accounts, k)
+ }
+ }
+ for k, v := range s.dirty.databases {
+ if v != nil {
+ // New/update object
+ s.readonly.databases[k] = v
+ } else {
+ // Delete object
+ delete(s.readonly.databases, k)
+ }
+ }
+ for k, v := range s.dirty.provider {
+ if v != nil {
+ // New/update object
+ s.readonly.provider[k] = v
+ } else {
+ // Delete object
+ delete(s.readonly.provider, k)
+ }
+ }
+ // Clean dirty map and tx pool
+ s.dirty = newMetaIndex()
+ s.pool = newTxPool()
+ return
+}
+
func (s *metaState) commitProcedure() (_ func(*bolt.Tx) error) {
return func(tx *bolt.Tx) (err error) {
var (
@@ -1135,3 +1171,45 @@ func (s *metaState) generateGenesisBlock(dbID proto.DatabaseID, resourceMeta pt.
return
}
+
+func (s *metaState) apply(t pi.Transaction) (err error) {
+ // NOTE(leventeliu): bypass pool in this method.
+ var (
+ addr = t.GetAccountAddress()
+ nonce = t.GetAccountNonce()
+ )
+ // Check account nonce
+ var nextNonce pi.AccountNonce
+ if nextNonce, err = s.nextNonce(addr); err != nil {
+ if t.GetTransactionType() != pi.TransactionTypeBaseAccount {
+ return
+ }
+ // Consider the first nonce 0
+ err = nil
+ }
+ if nextNonce != nonce {
+ err = ErrInvalidAccountNonce
+ log.WithFields(log.Fields{
+ "actual": nonce,
+ "expected": nextNonce,
+ }).WithError(err).Debug("nonce not match during transaction apply")
+ return
+ }
+ // Try to apply transaction to metaState
+ if err = s.applyTransaction(t); err != nil {
+ log.WithError(err).Debug("apply transaction failed")
+ return
+ }
+ if err = s.increaseNonce(addr); err != nil {
+ return
+ }
+ return
+}
+
+func (s *metaState) makeCopy() *metaState {
+ return &metaState{
+ dirty: newMetaIndex(),
+ readonly: s.readonly.deepCopy(),
+ pool: newTxPool(),
+ }
+}
diff --git a/blockproducer/runtime.go b/blockproducer/runtime.go
index 0e217a976..19e8b38ca 100644
--- a/blockproducer/runtime.go
+++ b/blockproducer/runtime.go
@@ -78,7 +78,7 @@ type rt struct {
// Cached state
cacheMu sync.RWMutex
irre *blockNode
- immutable *view
+ immutable *metaState
currIdx int
current *branch
branches []*branch
@@ -115,14 +115,42 @@ func (r *rt) switchBranch(st xi.Storage, bl *types.BPBlock, origin int, head *br
irre = head.head.lastIrreversible(r.minComfirm)
newIrres = irre.blockNodeListFrom(r.irre.count)
- // Prepare storage procedures to update immutable
+ // Apply irreversible blocks to create dirty map on immutable cache
+ //
+ // TODO(leventeliu): use old metaState for now, better use separated dirty cache.
+ for _, b := range newIrres {
+ for _, tx := range b.block.Transactions {
+ if err := r.immutable.apply(tx); err != nil {
+ log.WithError(err).Fatal("Failed to apply block to immutable database")
+ }
+ }
+ }
+
+ // Prepare storage procedures to update immutable database
sps = append(sps, addBlock(bl))
+ for k, v := range r.immutable.dirty.accounts {
+ if v != nil {
+ sps = append(sps, updateAccount(&v.Account))
+ } else {
+ sps = append(sps, deleteAccount(k))
+ }
+ }
+ for k, v := range r.immutable.dirty.databases {
+ if v != nil {
+ sps = append(sps, updateShardChain(&v.SQLChainProfile))
+ } else {
+ sps = append(sps, deleteShardChain(k))
+ }
+ }
+ for k, v := range r.immutable.dirty.provider {
+ if v != nil {
+ sps = append(sps, updateProvider(&v.ProviderProfile))
+ } else {
+ sps = append(sps, deleteProvider(k))
+ }
+ }
for _, n := range newIrres {
- sps = append(
- sps,
- updateImmutable(n.block.Transactions),
- deleteTxs(n.block.Transactions),
- )
+ sps = append(sps, deleteTxs(n.block.Transactions))
}
sps = append(sps, updateIrreversible(irre.hash))
@@ -131,13 +159,7 @@ func (r *rt) switchBranch(st xi.Storage, bl *types.BPBlock, origin int, head *br
// Update last irreversible block
r.irre = irre
// Apply irreversible blocks to immutable database
- for _, b := range newIrres {
- for _, tx := range b.block.Transactions {
- if err := r.immutable.apply(tx); err != nil {
- log.WithError(err).Fatal("Failed to apply block to immutable database")
- }
- }
- }
+ r.immutable.commit()
// Prune branches
var (
idx int
@@ -168,16 +190,17 @@ func (r *rt) switchBranch(st xi.Storage, bl *types.BPBlock, origin int, head *br
}
// Write to immutable database and update cache
- return store(st, sps, up)
+ if err = store(st, sps, up); err != nil {
+ r.immutable.clean()
+ }
+ return
}
func (r *rt) applyBlock(st xi.Storage, bl *types.BPBlock) (err error) {
var (
- ok bool
- br *branch
- parent *blockNode
- irre *blockNode
- newIrres []*blockNode
+ ok bool
+ br *branch
+ parent *blockNode
)
r.cacheMu.Lock()
defer r.cacheMu.Unlock()
@@ -197,25 +220,16 @@ func (r *rt) applyBlock(st xi.Storage, bl *types.BPBlock) (err error) {
// Switch branch or grow current branch
return r.switchBranch(st, bl, i, br)
}
- // Create a fork
+ // Fork and create new branch
if parent, ok = v.head.findNodeAfterCount(bl.SignedHeader.ParentHash, r.irre.count); ok {
- if br, err = fork(r.irre, parent, r.immutable, r.txPool); err != nil {
- return
- }
- if br, err = v.applyBlock(bl); err != nil {
+ var head = newBlockNodeEx(bl, parent)
+ if br, err = fork(r.irre, head, r.immutable, r.txPool); err != nil {
return
}
- if br.head.count > r.current.head.count {
- // Switch branch
- irre = br.head.lastIrreversible(r.minComfirm)
- for n := irre; n.count > r.irre.count; n = n.parent {
- newIrres = append(newIrres, n)
- }
- } else {
- // Update branch
- r.branches[i] = br
- }
- return
+ return store(st,
+ []storageProcedure{addBlock(bl)},
+ func() { r.branches = append(r.branches, br) },
+ )
}
}
diff --git a/blockproducer/storage.go b/blockproducer/storage.go
index a72e6f464..00ef655aa 100644
--- a/blockproducer/storage.go
+++ b/blockproducer/storage.go
@@ -22,10 +22,51 @@ import (
pi "github.com/CovenantSQL/CovenantSQL/blockproducer/interfaces"
"github.com/CovenantSQL/CovenantSQL/crypto/hash"
+ "github.com/CovenantSQL/CovenantSQL/proto"
"github.com/CovenantSQL/CovenantSQL/types"
"github.com/CovenantSQL/CovenantSQL/utils"
"github.com/CovenantSQL/CovenantSQL/utils/log"
xi "github.com/CovenantSQL/CovenantSQL/xenomint/interfaces"
+ xs "github.com/CovenantSQL/CovenantSQL/xenomint/sqlite"
+)
+
+var (
+ ddls = [...]string{
+ // Chain state tables
+ `CREATE TABLE IF NOT EXISTS "blocks" (
+ "hash" TEXT
+ "parent" TEXT
+ "encoded" BLOB
+ UNIQUE INDEX ("hash")
+)`,
+ `CREATE TABLE IF NOT EXISTS "txPool" (
+ "type" INT
+ "hash" TEXT
+ "encoded" BLOB
+ UNIQUE INDEX ("hash")
+)`,
+ `CREATE TABLE IF NOT EXISTS "irreversible" (
+ "id" INT
+ "hash" TEXT
+)`,
+ // Meta state tables
+ `CREATE TABLE IF NOT EXISTS "accounts" (
+ "address" TEXT
+ "encoded" BLOB
+ UNIQUE INDEX ("address")
+)`,
+ `CREATE TABLE IF NOT EXISTS "shardChain" (
+ "address" TEXT
+ "id" TEXT
+ "encoded" BLOB
+ UNIQUE INDEX ("address", "id")
+)`,
+ `CREATE TABLE IF NOT EXISTS "provider" (
+ "address" TEXT
+ "encoded" BLOB
+ UNIQUE INDEX ("address")
+)`,
+ }
)
type storageProcedure func(tx *sql.Tx) error
@@ -60,7 +101,15 @@ func errPass(err error) storageProcedure {
}
}
-func initStorage(tx *sql.Tx) (err error) {
+func openStorage(path string) (st xi.Storage, err error) {
+ if st, err = xs.NewSqlite(path); err != nil {
+ return
+ }
+ for _, v := range ddls {
+ if _, err = st.Writer().Exec(v); err != nil {
+ return
+ }
+ }
return
}
@@ -73,21 +122,27 @@ func addBlock(b *types.BPBlock) storageProcedure {
return errPass(err)
}
return func(tx *sql.Tx) (err error) {
- _, err = tx.Exec(`?`, enc.Bytes())
+ _, err = tx.Exec(`INSERT OR REPLACE INTO "blocks" VALUES (?, ?, ?)`,
+ b.BlockHash().String(),
+ b.ParentHash().String(),
+ enc.Bytes())
return
}
}
-func addTx(tx pi.Transaction) storageProcedure {
+func addTx(t pi.Transaction) storageProcedure {
var (
enc *bytes.Buffer
err error
)
- if enc, err = utils.EncodeMsgPack(tx); err != nil {
+ if enc, err = utils.EncodeMsgPack(t); err != nil {
return errPass(err)
}
return func(tx *sql.Tx) (err error) {
- _, err = tx.Exec(`INSERT INTO "txPool" VALUES (?, ?)`, enc.Bytes())
+ _, err = tx.Exec(`INSERT OR REPLACE INTO "txPool" VALUES (?, ?, ?)`,
+ uint32(t.GetTransactionType()),
+ t.Hash().String(),
+ enc.Bytes())
return
}
}
@@ -98,7 +153,7 @@ func updateImmutable(tx []pi.Transaction) storageProcedure {
func updateIrreversible(h hash.Hash) storageProcedure {
return func(tx *sql.Tx) (err error) {
- _, err = tx.Exec(`INSERT INTO "irreversible" VALUES (?)`, h)
+ _, err = tx.Exec(`INSERT OR REPLACE INTO "irreversible" VALUES (?, ?)`, 0, h.String())
return
}
}
@@ -115,10 +170,80 @@ func deleteTxs(txs []pi.Transaction) storageProcedure {
}
defer stmt.Close()
for _, v := range hs {
- if _, err = stmt.Exec(v); err != nil {
+ if _, err = stmt.Exec(v.String()); err != nil {
return
}
}
return
}
}
+
+func updateAccount(account *types.Account) storageProcedure {
+ var (
+ enc *bytes.Buffer
+ err error
+ )
+ if enc, err = utils.EncodeMsgPack(account); err != nil {
+ return errPass(err)
+ }
+ return func(tx *sql.Tx) (err error) {
+ _, err = tx.Exec(`INSERT OR REPLACE INTO "accounts" VALUES (?, ?)`,
+ account.Address.String(),
+ enc.Bytes())
+ return
+ }
+}
+
+func deleteAccount(address proto.AccountAddress) storageProcedure {
+ return func(tx *sql.Tx) (err error) {
+ _, err = tx.Exec(`DELETE FROM "accounts" WHERE "address"=?`, address.String())
+ return
+ }
+}
+
+func updateShardChain(profile *types.SQLChainProfile) storageProcedure {
+ var (
+ enc *bytes.Buffer
+ err error
+ )
+ if enc, err = utils.EncodeMsgPack(profile); err != nil {
+ return errPass(err)
+ }
+ return func(tx *sql.Tx) (err error) {
+ _, err = tx.Exec(`INSERT OR REPLACE INTO "shardChain" VALUES (?, ?, ?)`,
+ profile.Address.String(),
+ string(profile.ID),
+ enc.Bytes())
+ return
+ }
+}
+
+func deleteShardChain(id proto.DatabaseID) storageProcedure {
+ return func(tx *sql.Tx) (err error) {
+ _, err = tx.Exec(`DELETE FROM "shardChain" WHERE "id"=?`, id)
+ return
+ }
+}
+
+func updateProvider(profile *types.ProviderProfile) storageProcedure {
+ var (
+ enc *bytes.Buffer
+ err error
+ )
+ if enc, err = utils.EncodeMsgPack(profile); err != nil {
+ return errPass(err)
+ }
+ return func(tx *sql.Tx) (err error) {
+ _, err = tx.Exec(`INSERT OR REPLACE INTO "provider" VALUES (?, ?)`,
+ profile.Provider.String(),
+ enc.Bytes())
+ return
+ }
+}
+
+func deleteProvider(address proto.AccountAddress) storageProcedure {
+ return func(tx *sql.Tx) (err error) {
+ _, err = tx.Exec(`DELETE FROM "provider" WHERE "address"=?`, address.String())
+ return
+ }
+}
From 4a79cc3a975a7278b58967a40b24a306a115de05 Mon Sep 17 00:00:00 2001
From: leventeliu
Date: Mon, 10 Dec 2018 21:44:00 +0800
Subject: [PATCH 035/278] Remove boltdb, use new version block producing
---
blockproducer/chain.go | 320 ++++++++----------------------------
blockproducer/chain_test.go | 16 +-
blockproducer/runtime.go | 35 ++--
blockproducer/state.go | 28 ----
4 files changed, 93 insertions(+), 306 deletions(-)
delete mode 100644 blockproducer/state.go
diff --git a/blockproducer/chain.go b/blockproducer/chain.go
index b1ca03626..6daf86ffa 100644
--- a/blockproducer/chain.go
+++ b/blockproducer/chain.go
@@ -37,7 +37,6 @@ import (
"github.com/CovenantSQL/CovenantSQL/utils"
"github.com/CovenantSQL/CovenantSQL/utils/log"
xi "github.com/CovenantSQL/CovenantSQL/xenomint/interfaces"
- "github.com/coreos/bbolt"
"github.com/pkg/errors"
)
@@ -56,9 +55,7 @@ var (
// Chain defines the main chain.
type Chain struct {
- db *bolt.DB
ms *metaState
- bi *blockIndex
rt *rt
cl *rpc.Caller
bs chainbus.Bus
@@ -76,12 +73,6 @@ func NewChain(cfg *Config) (*Chain, error) {
return LoadChain(cfg)
}
- // open db file
- db, err := bolt.Open(cfg.DataFile, 0600, nil)
- if err != nil {
- return nil, err
- }
-
// get accountAddress
pubKey, err := kms.GetLocalPublicKey()
if err != nil {
@@ -92,46 +83,6 @@ func NewChain(cfg *Config) (*Chain, error) {
return nil, err
}
- // create bucket for meta data
- err = db.Update(func(tx *bolt.Tx) (err error) {
- bucket, err := tx.CreateBucketIfNotExists(metaBucket[:])
-
- if err != nil {
- return
- }
-
- _, err = bucket.CreateBucketIfNotExists(metaBlockIndexBucket)
- if err != nil {
- return
- }
-
- txbk, err := bucket.CreateBucketIfNotExists(metaTransactionBucket)
- if err != nil {
- return
- }
- for i := pi.TransactionType(0); i < pi.TransactionTypeNumber; i++ {
- if _, err = txbk.CreateBucketIfNotExists(i.Bytes()); err != nil {
- return
- }
- }
-
- _, err = bucket.CreateBucketIfNotExists(metaAccountIndexBucket)
- if err != nil {
- return
- }
-
- _, err = bucket.CreateBucketIfNotExists(metaSQLChainIndexBucket)
- if err != nil {
- return
- }
-
- _, err = bucket.CreateBucketIfNotExists(metaProviderIndexBucket)
- return
- })
- if err != nil {
- return nil, err
- }
-
// create chain
var (
bus = chainbus.New()
@@ -140,9 +91,7 @@ func NewChain(cfg *Config) (*Chain, error) {
)
chain := &Chain{
- db: db,
ms: newMetaState(),
- bi: newBlockIndex(),
rt: newRuntime(ctx, cfg, accountAddress),
cl: caller,
bs: bus,
@@ -165,7 +114,7 @@ func NewChain(cfg *Config) (*Chain, error) {
"bp_number": chain.rt.bpNum,
"period": chain.rt.period.String(),
"tick": chain.rt.tick.String(),
- "height": chain.rt.getHead().Height,
+ "height": chain.rt.currentBranch().head.height,
}).Debug("current chain state")
return chain, nil
@@ -173,12 +122,6 @@ func NewChain(cfg *Config) (*Chain, error) {
// LoadChain rebuilds the chain from db.
func LoadChain(cfg *Config) (chain *Chain, err error) {
- // open db file
- db, err := bolt.Open(cfg.DataFile, 0600, nil)
- if err != nil {
- return nil, err
- }
-
// get accountAddress
pubKey, err := kms.GetLocalPublicKey()
if err != nil {
@@ -196,9 +139,7 @@ func LoadChain(cfg *Config) (chain *Chain, err error) {
)
chain = &Chain{
- db: db,
ms: newMetaState(),
- bi: newBlockIndex(),
rt: newRuntime(ctx, cfg, accountAddress),
cl: caller,
bs: bus,
@@ -209,86 +150,11 @@ func LoadChain(cfg *Config) (chain *Chain, err error) {
chain.bs.Subscribe(txEvent, chain.addTx)
- err = chain.db.View(func(tx *bolt.Tx) (err error) {
- meta := tx.Bucket(metaBucket[:])
- metaEnc := meta.Get(metaStateKey)
- if metaEnc == nil {
- return ErrMetaStateNotFound
- }
-
- state := &Obsolete{}
- if err = utils.DecodeMsgPack(metaEnc, state); err != nil {
- return
- }
- chain.rt.setHead(state)
-
- var last *blockNode
- var index int32
- blocks := meta.Bucket(metaBlockIndexBucket)
- nodes := make([]blockNode, blocks.Stats().KeyN)
-
- if err = blocks.ForEach(func(k, v []byte) (err error) {
- block := &types.BPBlock{}
- if err = utils.DecodeMsgPack(v, block); err != nil {
- log.WithError(err).Error("load block failed")
- return err
- }
-
- log.Debugf("load chain block %s, parent block %s", block.BlockHash(), block.ParentHash())
-
- parent := (*blockNode)(nil)
-
- if last == nil {
- // check genesis block
- } else if block.ParentHash().IsEqual(&last.hash) {
- if err = block.SignedHeader.Verify(); err != nil {
- return err
- }
-
- parent = last
- } else {
- parent = chain.bi.lookupNode(block.ParentHash())
-
- if parent == nil {
- return ErrParentNotFound
- }
- }
-
- nodes[index].initBlockNode(block, parent)
- chain.bi.addBlock(&nodes[index])
- last = &nodes[index]
- index++
- return err
- }); err != nil {
- return err
- }
-
- // Reload state
- if err = chain.ms.reloadProcedure()(tx); err != nil {
- return
- }
-
- return
- })
- if err != nil {
- return nil, err
- }
-
return chain, nil
}
// checkBlock has following steps: 1. check parent block 2. checkTx 2. merkle tree 3. Hash 4. Signature.
func (c *Chain) checkBlock(b *types.BPBlock) (err error) {
- // TODO(lambda): process block fork
- if !b.ParentHash().IsEqual(&c.rt.getHead().Head) {
- log.WithFields(log.Fields{
- "head": c.rt.getHead().Head.String(),
- "height": c.rt.getHead().Height,
- "received_parent": b.ParentHash(),
- }).Debug("invalid parent")
- return ErrParentNotMatch
- }
-
rootHash := merkle.NewMerkle(b.GetTxHashes()).GetRoot()
if !b.SignedHeader.MerkleRoot.IsEqual(rootHash) {
return ErrInvalidMerkleTreeRoot
@@ -306,48 +172,10 @@ func (c *Chain) checkBlock(b *types.BPBlock) (err error) {
return nil
}
-func (c *Chain) pushBlockWithoutCheck(b *types.BPBlock) error {
- h := c.rt.getHeightFromTime(b.Timestamp())
- log.Debugf("current block %s, height %d, its parent %s", b.BlockHash(), h, b.ParentHash())
- node := newBlockNode(c.rt.chainInitTime, c.rt.period, b, c.rt.getHead().Node)
- state := &Obsolete{
- Node: node,
- Head: node.hash,
- Height: node.height,
- }
-
- encBlock, err := utils.EncodeMsgPack(b)
- if err != nil {
- return err
- }
-
- encState, err := utils.EncodeMsgPack(state)
- if err != nil {
+func (c *Chain) pushBlockWithoutCheck(b *types.BPBlock) (err error) {
+ if err = c.rt.applyBlock(c.st, b); err != nil {
return err
}
-
- err = c.db.Update(func(tx *bolt.Tx) (err error) {
- err = tx.Bucket(metaBucket[:]).Bucket(metaBlockIndexBucket).Put(node.indexKey(), encBlock.Bytes())
- if err != nil {
- return
- }
- for _, v := range b.Transactions {
- if err = c.ms.applyTransactionProcedure(v)(tx); err != nil {
- return
- }
- }
- err = c.ms.partialCommitProcedure(b.Transactions)(tx)
- if err != nil {
- return
- }
- err = tx.Bucket(metaBucket[:]).Put(metaStateKey, encState.Bytes())
- if err != nil {
- return
- }
- c.rt.setHead(state)
- c.bi.addBlock(node)
- return
- })
return err
}
@@ -374,37 +202,21 @@ func (c *Chain) pushBlock(b *types.BPBlock) error {
return nil
}
-func (c *Chain) produceBlock(now time.Time) error {
- priv, err := kms.GetLocalPrivateKey()
- if err != nil {
- return err
- }
+func (c *Chain) produceBlock(now time.Time) (err error) {
+ var (
+ priv *asymmetric.PrivateKey
+ b *types.BPBlock
+ )
- b := &types.BPBlock{
- SignedHeader: types.BPSignedHeader{
- BPHeader: types.BPHeader{
- Version: blockVersion,
- Producer: c.rt.accountAddress,
- ParentHash: c.rt.getHead().Head,
- Timestamp: now,
- },
- },
- Transactions: c.ms.pullTxs(),
+ if priv, err = kms.GetLocalPrivateKey(); err != nil {
+ return
}
-
- err = b.PackAndSignBlock(priv)
- if err != nil {
- return err
+ if b, err = c.rt.produceBlock(c.st, priv); err != nil {
+ return
}
-
log.WithField("block", b).Debug("produced new block")
- err = c.pushBlockWithoutCheck(b)
- if err != nil {
- return err
- }
-
- peers := c.rt.getPeers()
+ var peers = c.rt.getPeers()
for _, s := range peers.Servers {
if !s.IsEqual(&c.rt.nodeID) {
// Bind NodeID to subroutine
@@ -506,44 +318,57 @@ func (c *Chain) checkBillingRequest(br *types.BillingRequest) (err error) {
return
}
+func (c *Chain) fetchBlock(h hash.Hash) (b *types.BPBlock, err error) {
+ var (
+ enc []byte
+ out = &types.BPBlock{}
+ )
+ if err = c.st.Reader().QueryRow(
+ `SELECT "encoded" FROM "blocks" WHERE "hash"=?`, h.String(),
+ ).Scan(&enc); err != nil {
+ return
+ }
+ if err = utils.DecodeMsgPack(enc, out); err != nil {
+ return
+ }
+ b = out
+ return
+}
+
func (c *Chain) fetchBlockByHeight(h uint32) (b *types.BPBlock, count uint32, err error) {
- node := c.rt.getHead().Node.ancestor(h)
+ var node = c.rt.currentBranch().head.ancestor(h)
if node == nil {
- return nil, 0, ErrNoSuchBlock
+ err = ErrNoSuchBlock
+ return
+ } else if node.block != nil {
+ b = node.block
+ count = node.count
+ return
}
-
- b = &types.BPBlock{}
- k := node.indexKey()
-
- err = c.db.View(func(tx *bolt.Tx) error {
- v := tx.Bucket(metaBucket[:]).Bucket(metaBlockIndexBucket).Get(k)
- return utils.DecodeMsgPack(v, b)
- })
- if err != nil {
- return nil, 0, err
+ // Not cached, read from database
+ if b, err = c.fetchBlock(node.hash); err != nil {
+ return
}
-
- return b, node.count, nil
+ count = node.count
+ return
}
func (c *Chain) fetchBlockByCount(count uint32) (b *types.BPBlock, height uint32, err error) {
- node := c.rt.getHead().Node.ancestorByCount(count)
+ var node = c.rt.currentBranch().head.ancestorByCount(count)
if node == nil {
- return nil, 0, ErrNoSuchBlock
+ err = ErrNoSuchBlock
+ return
+ } else if node.block != nil {
+ b = node.block
+ height = node.height
+ return
}
-
- b = &types.BPBlock{}
- k := node.indexKey()
-
- err = c.db.View(func(tx *bolt.Tx) error {
- v := tx.Bucket(metaBucket[:]).Bucket(metaBlockIndexBucket).Get(k)
- return utils.DecodeMsgPack(v, b)
- })
- if err != nil {
- return nil, 0, err
+ // Not cached, read from database
+ if b, err = c.fetchBlock(node.hash); err != nil {
+ return
}
-
- return b, node.height, nil
+ height = node.height
+ return
}
// runCurrentTurn does the check and runs block producing if its my turn.
@@ -675,19 +500,13 @@ func (c *Chain) processBlocks(ctx context.Context) {
}
func (c *Chain) addTx(tx pi.Transaction) {
- if err := c.db.Update(c.ms.applyTransactionProcedure(tx)); err != nil {
- log.WithFields(log.Fields{
- "peer": c.rt.getPeerInfoString(),
- "next_turn": c.rt.getNextTurn(),
- "head_height": c.rt.getHead().Height,
- "head_block": c.rt.getHead().Head.String(),
- "transaction": tx.Hash().String(),
- }).Debugf("Failed to push tx with error: %v", err)
- }
+ c.pendingTxs <- tx
}
func (c *Chain) processTx(tx pi.Transaction) {
- c.bs.Publish(txEvent, tx)
+ if err := c.rt.addTx(c.st, tx); err != nil {
+ log.WithError(err).Error("Failed to add transaction")
+ }
}
func (c *Chain) processTxs(ctx context.Context) {
@@ -712,8 +531,8 @@ func (c *Chain) mainCycle(ctx context.Context) {
log.WithFields(log.Fields{
"peer": c.rt.getPeerInfoString(),
"next_turn": c.rt.getNextTurn(),
- "head_height": c.rt.getHead().Height,
- "head_block": c.rt.getHead().Head.String(),
+ "head_height": c.rt.currentBranch().head.height,
+ "head_block": c.rt.currentBranch().head.hash.String(),
"now_time": t.Format(time.RFC3339Nano),
"duration": d,
}).Debug("Main cycle")
@@ -730,9 +549,9 @@ func (c *Chain) syncHead() {
log.WithFields(log.Fields{
"index": c.rt.index,
"next_turn": c.rt.getNextTurn(),
- "height": c.rt.getHead().Height,
+ "height": c.rt.currentBranch().head.height,
}).Debug("sync header")
- if h := c.rt.getNextTurn() - 1; c.rt.getHead().Height < h {
+ if h := c.rt.getNextTurn() - 1; c.rt.currentBranch().head.height < h {
log.Debugf("sync header with height %d", h)
var err error
req := &FetchBlockReq{
@@ -753,8 +572,8 @@ func (c *Chain) syncHead() {
"peer": c.rt.getPeerInfoString(),
"remote": fmt.Sprintf("[%d/%d] %s", i, len(peers.Servers), s),
"curr_turn": c.rt.getNextTurn(),
- "head_height": c.rt.getHead().Height,
- "head_block": c.rt.getHead().Head.String(),
+ "head_height": c.rt.currentBranch().head.height,
+ "head_block": c.rt.currentBranch().head.hash.String(),
}).WithError(err).Debug("Failed to fetch block from peer")
} else {
c.blocksFromRPC <- resp.Block
@@ -762,8 +581,8 @@ func (c *Chain) syncHead() {
"peer": c.rt.getPeerInfoString(),
"remote": fmt.Sprintf("[%d/%d] %s", i, len(peers.Servers), s),
"curr_turn": c.rt.getNextTurn(),
- "head_height": c.rt.getHead().Height,
- "head_block": c.rt.getHead().Head.String(),
+ "head_height": c.rt.currentBranch().head.height,
+ "head_block": c.rt.currentBranch().head.hash.String(),
}).Debug("Fetch block from remote peer successfully")
succ = true
break
@@ -775,8 +594,8 @@ func (c *Chain) syncHead() {
log.WithFields(log.Fields{
"peer": c.rt.getPeerInfoString(),
"curr_turn": c.rt.getNextTurn(),
- "head_height": c.rt.getHead().Height,
- "head_block": c.rt.getHead().Head.String(),
+ "head_height": c.rt.currentBranch().head.height,
+ "head_block": c.rt.currentBranch().head.hash.String(),
}).Debug(
"Cannot get block from any peer")
}
@@ -789,8 +608,5 @@ func (c *Chain) Stop() (err error) {
log.WithFields(log.Fields{"peer": c.rt.getPeerInfoString()}).Debug("Stopping chain")
c.rt.stop()
log.WithFields(log.Fields{"peer": c.rt.getPeerInfoString()}).Debug("Chain service stopped")
- // Close database file
- err = c.db.Close()
- log.WithFields(log.Fields{"peer": c.rt.getPeerInfoString()}).Debug("Chain database closed")
return
}
diff --git a/blockproducer/chain_test.go b/blockproducer/chain_test.go
index 2d5c3607f..91f0d2a27 100644
--- a/blockproducer/chain_test.go
+++ b/blockproducer/chain_test.go
@@ -98,7 +98,7 @@ func TestChain(t *testing.T) {
for {
time.Sleep(testPeriod)
t.Logf("Chain state: head = %s, height = %d, turn = %d, nextturnstart = %s, ismyturn = %t",
- chain.rt.getHead().Head, chain.rt.getHead().Height, chain.rt.nextTurn,
+ chain.rt.currentBranch().head.hash, chain.rt.currentBranch().head.height, chain.rt.nextTurn,
chain.rt.chainInitTime.Add(
chain.rt.period*time.Duration(chain.rt.nextTurn)).Format(time.RFC3339Nano),
chain.rt.isMyTurn())
@@ -118,7 +118,7 @@ func TestChain(t *testing.T) {
}
// generate block
- block, err := generateRandomBlockWithTransactions(chain.rt.getHead().Head, tbs)
+ block, err := generateRandomBlockWithTransactions(chain.rt.currentBranch().head.hash, tbs)
So(err, ShouldBeNil)
err = chain.pushBlock(block)
So(err, ShouldBeNil)
@@ -128,10 +128,10 @@ func TestChain(t *testing.T) {
// should be packed
So(nextNonce >= val.GetAccountNonce(), ShouldBeTrue)
}
- So(chain.bi.hasBlock(block.SignedHeader.BlockHash), ShouldBeTrue)
- // So(chain.rt.getHead().Height, ShouldEqual, height)
+ // So(chain.bi.hasBlock(block.SignedHeader.BlockHash), ShouldBeTrue)
+ // So(chain.rt.currentBranch().head.height, ShouldEqual, height)
- height := chain.rt.getHead().Height
+ height := chain.rt.currentBranch().head.height
specificHeightBlock1, _, err := chain.fetchBlockByHeight(height)
So(err, ShouldBeNil)
So(block.SignedHeader.BlockHash, ShouldResemble, specificHeightBlock1.SignedHeader.BlockHash)
@@ -155,15 +155,15 @@ func TestChain(t *testing.T) {
So(chain.ms.pool.hasTx(val), ShouldBeTrue)
}
- // So(height, ShouldEqual, chain.rt.getHead().Height)
+ // So(height, ShouldEqual, chain.rt.currentBranch().head.height)
height++
t.Logf("Pushed new block: height = %d, %s <- %s",
- chain.rt.getHead().Height,
+ chain.rt.currentBranch().head.height,
block.ParentHash(),
block.BlockHash())
- if chain.rt.getHead().Height >= testPeriodNumber {
+ if chain.rt.currentBranch().head.height >= testPeriodNumber {
break
}
}
diff --git a/blockproducer/runtime.go b/blockproducer/runtime.go
index 19e8b38ca..f61d8ea86 100644
--- a/blockproducer/runtime.go
+++ b/blockproducer/runtime.go
@@ -24,6 +24,7 @@ import (
"time"
pi "github.com/CovenantSQL/CovenantSQL/blockproducer/interfaces"
+ "github.com/CovenantSQL/CovenantSQL/crypto/asymmetric"
"github.com/CovenantSQL/CovenantSQL/crypto/hash"
"github.com/CovenantSQL/CovenantSQL/proto"
"github.com/CovenantSQL/CovenantSQL/route"
@@ -64,9 +65,6 @@ type rt struct {
stateMutex sync.Mutex // Protects following fields.
// nextTurn is the height of the next block.
nextTurn uint32
- // head is the current head of the best chain.
- head *Obsolete
- optionalHeads []*Obsolete
// timeMutex protects following time-relative fields.
timeMutex sync.Mutex
@@ -236,10 +234,12 @@ func (r *rt) applyBlock(st xi.Storage, bl *types.BPBlock) (err error) {
return
}
-func (r *rt) produceBlock(st xi.Storage) (err error) {
+func (r *rt) produceBlock(
+ st xi.Storage, priv *asymmetric.PrivateKey) (out *types.BPBlock, err error,
+) {
var (
- br *branch
bl *types.BPBlock
+ br *branch
)
r.cacheMu.Lock()
defer r.cacheMu.Unlock()
@@ -248,8 +248,14 @@ func (r *rt) produceBlock(st xi.Storage) (err error) {
if br, bl, err = r.current.produceBlock(); err != nil {
return
}
-
- return r.switchBranch(st, bl, r.currIdx, br)
+ if err = bl.PackAndSignBlock(priv); err != nil {
+ return
+ }
+ if err = r.switchBranch(st, bl, r.currIdx, br); err != nil {
+ return
+ }
+ out = bl
+ return
}
// now returns the current coordinated chain time.
@@ -294,7 +300,6 @@ func newRuntime(ctx context.Context, cfg *Config, accountAddress proto.AccountAd
nodeID: cfg.NodeID,
minComfirm: uint32(m),
nextTurn: 1,
- head: &Obsolete{},
offset: time.Duration(0),
}
}
@@ -358,16 +363,10 @@ func (r *rt) getPeers() *proto.Peers {
return &peers
}
-func (r *rt) getHead() *Obsolete {
- r.stateMutex.Lock()
- defer r.stateMutex.Unlock()
- return r.head
-}
-
-func (r *rt) setHead(head *Obsolete) {
- r.stateMutex.Lock()
- defer r.stateMutex.Unlock()
- r.head = head
+func (r *rt) currentBranch() *branch {
+ r.cacheMu.RLock()
+ defer r.cacheMu.RUnlock()
+ return r.current
}
func (r *rt) stop() {
diff --git a/blockproducer/state.go b/blockproducer/state.go
deleted file mode 100644
index 227603864..000000000
--- a/blockproducer/state.go
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright 2018 The CovenantSQL Authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package blockproducer
-
-import (
- "github.com/CovenantSQL/CovenantSQL/crypto/hash"
-)
-
-// Obsolete stores the node info of chain.
-type Obsolete struct {
- Node *blockNode
- Head hash.Hash
- Height uint32
-}
From ec92ecc671653976ee00b7a7adf5532cbb1d402e Mon Sep 17 00:00:00 2001
From: leventeliu
Date: Tue, 11 Dec 2018 10:22:41 +0800
Subject: [PATCH 036/278] Remove main metaState in chain struct
---
blockproducer/chain.go | 8 ++------
blockproducer/rpc.go | 6 +++---
blockproducer/runtime.go | 18 ++++++++++++++++++
3 files changed, 23 insertions(+), 9 deletions(-)
diff --git a/blockproducer/chain.go b/blockproducer/chain.go
index 6daf86ffa..c33fb7343 100644
--- a/blockproducer/chain.go
+++ b/blockproducer/chain.go
@@ -55,16 +55,14 @@ var (
// Chain defines the main chain.
type Chain struct {
- ms *metaState
rt *rt
+ st xi.Storage
cl *rpc.Caller
bs chainbus.Bus
blocksFromRPC chan *types.BPBlock
pendingTxs chan pi.Transaction
ctx context.Context
-
- st xi.Storage
}
// NewChain creates a new blockchain.
@@ -91,7 +89,6 @@ func NewChain(cfg *Config) (*Chain, error) {
)
chain := &Chain{
- ms: newMetaState(),
rt: newRuntime(ctx, cfg, accountAddress),
cl: caller,
bs: bus,
@@ -139,7 +136,6 @@ func LoadChain(cfg *Config) (chain *Chain, err error) {
)
chain = &Chain{
- ms: newMetaState(),
rt: newRuntime(ctx, cfg, accountAddress),
cl: caller,
bs: bus,
@@ -288,7 +284,7 @@ func (c *Chain) produceBilling(br *types.BillingRequest) (_ *types.BillingReques
// generate and push the txbilling
// 1. generate txbilling
var nc pi.AccountNonce
- if nc, err = c.ms.nextNonce(accountAddress); err != nil {
+ if nc, err = c.rt.nextNonce(accountAddress); err != nil {
return
}
var (
diff --git a/blockproducer/rpc.go b/blockproducer/rpc.go
index bb71a68d3..015f1a34c 100644
--- a/blockproducer/rpc.go
+++ b/blockproducer/rpc.go
@@ -210,7 +210,7 @@ func (s *ChainRPCService) FetchTxBilling(req *FetchTxBillingReq, resp *FetchTxBi
func (s *ChainRPCService) NextAccountNonce(
req *NextAccountNonceReq, resp *NextAccountNonceResp) (err error,
) {
- if resp.Nonce, err = s.chain.ms.nextNonce(req.Addr); err != nil {
+ if resp.Nonce, err = s.chain.rt.nextNonce(req.Addr); err != nil {
return
}
resp.Addr = req.Addr
@@ -233,7 +233,7 @@ func (s *ChainRPCService) QueryAccountStableBalance(
req *QueryAccountStableBalanceReq, resp *QueryAccountStableBalanceResp) (err error,
) {
resp.Addr = req.Addr
- resp.Balance, resp.OK = s.chain.ms.loadAccountStableBalance(req.Addr)
+ resp.Balance, resp.OK = s.chain.rt.loadAccountStableBalance(req.Addr)
return
}
@@ -242,7 +242,7 @@ func (s *ChainRPCService) QueryAccountCovenantBalance(
req *QueryAccountCovenantBalanceReq, resp *QueryAccountCovenantBalanceResp) (err error,
) {
resp.Addr = req.Addr
- resp.Balance, resp.OK = s.chain.ms.loadAccountCovenantBalance(req.Addr)
+ resp.Balance, resp.OK = s.chain.rt.loadAccountCovenantBalance(req.Addr)
return
}
diff --git a/blockproducer/runtime.go b/blockproducer/runtime.go
index f61d8ea86..fca1ddd64 100644
--- a/blockproducer/runtime.go
+++ b/blockproducer/runtime.go
@@ -97,6 +97,24 @@ func (r *rt) addTx(st xi.Storage, tx pi.Transaction) (err error) {
})
}
+func (r *rt) nextNonce(addr proto.AccountAddress) (n pi.AccountNonce, err error) {
+ r.cacheMu.RLock()
+ defer r.cacheMu.RUnlock()
+ return r.current.preview.nextNonce(addr)
+}
+
+func (r *rt) loadAccountCovenantBalance(addr proto.AccountAddress) (balance uint64, ok bool) {
+ r.cacheMu.RLock()
+ defer r.cacheMu.RUnlock()
+ return r.immutable.loadAccountCovenantBalance(addr)
+}
+
+func (r *rt) loadAccountStableBalance(addr proto.AccountAddress) (balance uint64, ok bool) {
+ r.cacheMu.RLock()
+ defer r.cacheMu.RUnlock()
+ return r.immutable.loadAccountStableBalance(addr)
+}
+
func (r *rt) switchBranch(st xi.Storage, bl *types.BPBlock, origin int, head *branch) (err error) {
var (
irre *blockNode
From fd4c3ea0093fe3c5cdde02e97a6a261b9c88eb9a Mon Sep 17 00:00:00 2001
From: leventeliu
Date: Tue, 11 Dec 2018 10:23:37 +0800
Subject: [PATCH 037/278] Remove chain testing
---
blockproducer/chain_test.go | 290 ------------------------------------
1 file changed, 290 deletions(-)
diff --git a/blockproducer/chain_test.go b/blockproducer/chain_test.go
index 91f0d2a27..ced66a539 100644
--- a/blockproducer/chain_test.go
+++ b/blockproducer/chain_test.go
@@ -17,20 +17,7 @@
package blockproducer
import (
- "io/ioutil"
- "os"
- "sync"
- "testing"
"time"
-
- pi "github.com/CovenantSQL/CovenantSQL/blockproducer/interfaces"
- "github.com/CovenantSQL/CovenantSQL/crypto/kms"
- "github.com/CovenantSQL/CovenantSQL/pow/cpuminer"
- "github.com/CovenantSQL/CovenantSQL/proto"
- "github.com/CovenantSQL/CovenantSQL/route"
- "github.com/CovenantSQL/CovenantSQL/types"
- "github.com/CovenantSQL/CovenantSQL/utils/log"
- . "github.com/smartystreets/goconvey/convey"
)
var (
@@ -40,280 +27,3 @@ var (
testPeriodNumber uint32 = 10
testClientNumberPerChain = 10
)
-
-func TestChain(t *testing.T) {
- Convey("test main chain", t, func() {
- log.SetLevel(log.InfoLevel)
- confDir := "../test/mainchain/node_standalone/config.yaml"
- privDir := "../test/mainchain/node_standalone/private.key"
- cleanup, _, _, rpcServer, err := initNode(
- confDir,
- privDir,
- )
- defer cleanup()
- So(err, ShouldBeNil)
-
- fl, err := ioutil.TempFile("", "mainchain")
- So(err, ShouldBeNil)
-
- fl.Close()
- os.Remove(fl.Name())
-
- // create genesis block
- genesis, err := generateRandomBlock(genesisHash, true)
- So(err, ShouldBeNil)
-
- priv, err := kms.GetLocalPrivateKey()
- So(err, ShouldBeNil)
- _, peers, err := createTestPeersWithPrivKeys(priv, testPeersNumber)
-
- cfg := NewConfig(genesis, fl.Name(), rpcServer, peers, peers.Servers[0], testPeriod, testTick)
- chain, err := NewChain(cfg)
- So(err, ShouldBeNil)
- ao, ok := chain.ms.readonly.accounts[testAddress1]
- So(ok, ShouldBeTrue)
- So(ao, ShouldNotBeNil)
- So(chain.ms.pool.entries[testAddress1].transactions, ShouldBeEmpty)
- So(chain.ms.pool.entries[testAddress1].baseNonce, ShouldEqual, 1)
- var (
- bl uint64
- loaded bool
- )
- bl, loaded = chain.ms.loadAccountStableBalance(testAddress1)
- So(loaded, ShouldBeTrue)
- So(bl, ShouldEqual, testInitBalance)
- bl, loaded = chain.ms.loadAccountStableBalance(testAddress2)
- So(loaded, ShouldBeTrue)
- So(bl, ShouldEqual, testInitBalance)
- bl, loaded = chain.ms.loadAccountCovenantBalance(testAddress1)
- So(loaded, ShouldBeTrue)
- So(bl, ShouldEqual, testInitBalance)
- bl, loaded = chain.ms.loadAccountCovenantBalance(testAddress2)
- So(loaded, ShouldBeTrue)
- So(bl, ShouldEqual, testInitBalance)
-
- // Hack for single instance test
- chain.rt.bpNum = 5
-
- for {
- time.Sleep(testPeriod)
- t.Logf("Chain state: head = %s, height = %d, turn = %d, nextturnstart = %s, ismyturn = %t",
- chain.rt.currentBranch().head.hash, chain.rt.currentBranch().head.height, chain.rt.nextTurn,
- chain.rt.chainInitTime.Add(
- chain.rt.period*time.Duration(chain.rt.nextTurn)).Format(time.RFC3339Nano),
- chain.rt.isMyTurn())
-
- // chain will receive blocks and tx
- // receive block
- // generate valid txbillings
- tbs := make([]pi.Transaction, 0, 20)
-
- // pull previous processed transactions
- tbs = append(tbs, chain.ms.pullTxs()...)
-
- for i := 0; i != 10; i++ {
- tb, err := generateRandomAccountBilling()
- So(err, ShouldBeNil)
- tbs = append(tbs, tb)
- }
-
- // generate block
- block, err := generateRandomBlockWithTransactions(chain.rt.currentBranch().head.hash, tbs)
- So(err, ShouldBeNil)
- err = chain.pushBlock(block)
- So(err, ShouldBeNil)
- nextNonce, err := chain.ms.nextNonce(testAddress1)
- So(err, ShouldBeNil)
- for _, val := range tbs {
- // should be packed
- So(nextNonce >= val.GetAccountNonce(), ShouldBeTrue)
- }
- // So(chain.bi.hasBlock(block.SignedHeader.BlockHash), ShouldBeTrue)
- // So(chain.rt.currentBranch().head.height, ShouldEqual, height)
-
- height := chain.rt.currentBranch().head.height
- specificHeightBlock1, _, err := chain.fetchBlockByHeight(height)
- So(err, ShouldBeNil)
- So(block.SignedHeader.BlockHash, ShouldResemble, specificHeightBlock1.SignedHeader.BlockHash)
- specificHeightBlock2, _, err := chain.fetchBlockByHeight(height + 1000)
- So(specificHeightBlock2, ShouldBeNil)
- So(err, ShouldNotBeNil)
-
- // receive txs
- receivedTbs := make([]*types.Billing, 9)
- for i := range receivedTbs {
- tb, err := generateRandomAccountBilling()
- So(err, ShouldBeNil)
- receivedTbs[i] = tb
- chain.processTx(tb)
- }
-
- nextNonce, err = chain.ms.nextNonce(testAddress1)
-
- for _, val := range receivedTbs {
- // should be packed or unpacked
- So(chain.ms.pool.hasTx(val), ShouldBeTrue)
- }
-
- // So(height, ShouldEqual, chain.rt.currentBranch().head.height)
- height++
-
- t.Logf("Pushed new block: height = %d, %s <- %s",
- chain.rt.currentBranch().head.height,
- block.ParentHash(),
- block.BlockHash())
-
- if chain.rt.currentBranch().head.height >= testPeriodNumber {
- break
- }
- }
-
- // load chain from db
- err = chain.Stop()
- So(err, ShouldBeNil)
- _, err = LoadChain(cfg)
- So(err, ShouldBeNil)
- })
-}
-
-func TestMultiNode(t *testing.T) {
- Convey("test multi-nodes", t, func(c C) {
- // create genesis block
- genesis, err := generateRandomBlock(genesisHash, true)
- So(err, ShouldBeNil)
- So(genesis.Transactions, ShouldNotBeEmpty)
-
- // Create sql-chain instances
- chains := make([]*Chain, testPeersNumber)
- configs := []string{
- "../test/mainchain/node_multi_0/config.yaml",
- // "../test/mainchain/node_multi_1/config.yaml",
- // "../test/mainchain/node_multi_2/config.yaml",
- }
- privateKeys := []string{
- "../test/mainchain/node_multi_0/private.key",
- // "../test/mainchain/node_multi_1/private.key",
- // "../test/mainchain/node_multi_2/private.key",
- }
-
- var nis []cpuminer.NonceInfo
- var peers *proto.Peers
- peerInited := false
- for i := range chains {
- // create tmp file
- fl, err := ioutil.TempFile("", "mainchain")
- So(err, ShouldBeNil)
- fl.Close()
- os.Remove(fl.Name())
-
- // init config
- cleanup, dht, _, server, err := initNode(configs[i], privateKeys[i])
- So(err, ShouldBeNil)
- defer cleanup()
-
- // Create peer list
- if !peerInited {
- nis, peers, err = createTestPeers(testPeersNumber)
- So(err, ShouldBeNil)
-
- for i, p := range peers.Servers {
- t.Logf("Peer #%d: %s", i, p)
- }
-
- peerInited = true
- }
-
- cfg := NewConfig(genesis, fl.Name(), server, peers, peers.Servers[i], testPeriod, testTick)
-
- // init chain
- chains[i], err = NewChain(cfg)
- So(err, ShouldBeNil)
-
- // Register address
- pub, err := kms.GetLocalPublicKey()
- So(err, ShouldBeNil)
- node := proto.Node{
- ID: peers.Servers[i],
- Role: func(peers *proto.Peers, i int) proto.ServerRole {
- if peers.Leader.IsEqual(&peers.Servers[i]) {
- return proto.Leader
- }
- return proto.Follower
- }(peers, i),
- Addr: server.Listener.Addr().String(),
- PublicKey: pub,
- Nonce: nis[i].Nonce,
- }
- req := proto.PingReq{
- Node: node,
- Envelope: proto.Envelope{},
- }
- var resp proto.PingResp
- dht.Ping(&req, &resp)
- log.WithField("resp", resp).Debug("got ping response")
-
- err = chains[i].Start()
- So(err, ShouldBeNil)
- defer func(c *Chain) {
- c.Stop()
- }(chains[i])
- }
-
- for i := range chains {
- wg := &sync.WaitGroup{}
- sC := make(chan struct{})
-
- for j := 0; j < testClientNumberPerChain; j++ {
- wg.Add(1)
- go func(val int) {
- defer wg.Done()
- foreverLoop:
- for {
- select {
- case <-sC:
- break foreverLoop
- default:
- // test AdviseBillingRequest RPC
- br, err := generateRandomBillingRequest()
- c.So(err, ShouldBeNil)
-
- bReq := &types.AdviseBillingReq{
- Envelope: proto.Envelope{
- // TODO(lambda): Add fields.
- },
- Req: br,
- }
- bResp := &types.AdviseBillingResp{}
- log.WithFields(log.Fields{
- "node": val,
- "requestHash": br.RequestHash,
- }).Debug("advising billing request")
- err = chains[i].cl.CallNode(chains[i].rt.nodeID, route.MCCAdviseBillingRequest.String(), bReq, bResp)
- if err != nil {
- log.WithFields(log.Fields{
- "peer": chains[i].rt.getPeerInfoString(),
- "curr_turn": chains[i].rt.getNextTurn(),
- "now_time": time.Now().UTC().Format(time.RFC3339Nano),
- "request_hash": br.RequestHash,
- }).WithError(err).Error("Failed to advise new billing request")
- }
- // TODO(leventeliu): this test needs to be improved using some preset
- // accounts. Or this request will return an "ErrAccountNotFound" error.
- c.So(err, ShouldNotBeNil)
- c.So(err.Error(), ShouldEqual, ErrAccountNotFound.Error())
- //log.Debugf("response %d hash is %s", val, bResp.Resp.RequestHash)
-
- }
- }
- }(j)
- }
- defer func() {
- close(sC)
- wg.Wait()
- }()
- }
- time.Sleep(time.Duration(testPeriodNumber) * testPeriod)
- })
-
- return
-}
From 5afe3fb05ecdb0d0576cc7774370a8ce084b6556 Mon Sep 17 00:00:00 2001
From: leventeliu
Date: Tue, 11 Dec 2018 10:52:19 +0800
Subject: [PATCH 038/278] Remove redundant codes in the new design
---
blockproducer/chain.go | 55 ++++++------------------------------------
1 file changed, 7 insertions(+), 48 deletions(-)
diff --git a/blockproducer/chain.go b/blockproducer/chain.go
index c33fb7343..0b7fc6b3f 100644
--- a/blockproducer/chain.go
+++ b/blockproducer/chain.go
@@ -20,7 +20,6 @@ import (
"context"
"fmt"
"os"
- "sync"
"time"
pi "github.com/CovenantSQL/CovenantSQL/blockproducer/interfaces"
@@ -438,56 +437,16 @@ func (c *Chain) Start() error {
}
func (c *Chain) processBlocks(ctx context.Context) {
- var (
- returnStash = func(ctx context.Context, wg *sync.WaitGroup, stash []*types.BPBlock) {
- defer wg.Done()
- for _, block := range stash {
- select {
- case c.blocksFromRPC <- block:
- case <-ctx.Done():
- return
- }
- }
- }
- // Subroutine control
- subCtx, subCancel = context.WithCancel(ctx)
- subWg = &sync.WaitGroup{}
- )
-
- defer func() {
- // Wait for subroutines to exit
- subCancel()
- subWg.Wait()
- }()
-
- var stash []*types.BPBlock
for {
select {
case block := <-c.blocksFromRPC:
- if h := c.rt.getHeightFromTime(block.Timestamp()); h > c.rt.getNextTurn()-1 {
- // Stash newer blocks for later check
- stash = append(stash, block)
- } else {
- // Process block
- if h < c.rt.getNextTurn()-1 {
- // TODO(lambda): check and add to fork list.
- } else {
- err := c.pushBlock(block)
- if err != nil {
- log.WithFields(log.Fields{
- "block_hash": block.BlockHash(),
- "block_parent_hash": block.ParentHash(),
- "block_timestamp": block.Timestamp(),
- }).Debug(err)
- }
- }
-
- // Return all stashed blocks to pending channel
- if stash != nil {
- subWg.Add(1)
- go returnStash(subCtx, subWg, stash)
- stash = nil
- }
+ err := c.pushBlock(block)
+ if err != nil {
+ log.WithFields(log.Fields{
+ "block_hash": block.BlockHash(),
+ "block_parent_hash": block.ParentHash(),
+ "block_timestamp": block.Timestamp(),
+ }).Debug(err)
}
case <-ctx.Done():
return
From 8a15c7cbb9f0fe97909021c6d1152873277e09e6 Mon Sep 17 00:00:00 2001
From: leventeliu
Date: Tue, 11 Dec 2018 11:20:14 +0800
Subject: [PATCH 039/278] Remove block index
---
blockproducer/{blockindex.go => blocknode.go} | 44 ++---------------
.../{blockindex_test.go => blocknode_test.go} | 49 -------------------
blockproducer/branch.go | 3 ++
3 files changed, 8 insertions(+), 88 deletions(-)
rename blockproducer/{blockindex.go => blocknode.go} (84%)
rename blockproducer/{blockindex_test.go => blocknode_test.go} (75%)
diff --git a/blockproducer/blockindex.go b/blockproducer/blocknode.go
similarity index 84%
rename from blockproducer/blockindex.go
rename to blockproducer/blocknode.go
index 22f6de803..867a4f4f5 100644
--- a/blockproducer/blockindex.go
+++ b/blockproducer/blocknode.go
@@ -18,7 +18,6 @@ package blockproducer
import (
"encoding/binary"
- "sync"
"time"
"github.com/CovenantSQL/CovenantSQL/crypto/hash"
@@ -27,11 +26,13 @@ import (
)
type blockNode struct {
- hash hash.Hash
parent *blockNode
- height uint32
+ // Extra fields
count uint32
- block *types.BPBlock
+ height uint32
+ // Cached fields for quick reference
+ hash hash.Hash
+ block *types.BPBlock
}
func newBlockNodeEx(b *types.BPBlock, p *blockNode) *blockNode {
@@ -145,38 +146,3 @@ func (bn *blockNode) findNodeAfterCount(hash hash.Hash, min uint32) (match *bloc
match = nil
return
}
-
-type blockIndex struct {
- mu sync.RWMutex
- index map[hash.Hash]*blockNode
-}
-
-func newBlockIndex() *blockIndex {
- bi := &blockIndex{
- index: make(map[hash.Hash]*blockNode),
- }
-
- return bi
-}
-
-func (bi *blockIndex) addBlock(b *blockNode) {
- bi.mu.Lock()
- defer bi.mu.Unlock()
-
- bi.index[b.hash] = b
-}
-
-func (bi *blockIndex) hasBlock(h hash.Hash) bool {
- bi.mu.RLock()
- defer bi.mu.RUnlock()
-
- _, has := bi.index[h]
- return has
-}
-
-func (bi *blockIndex) lookupNode(h *hash.Hash) *blockNode {
- bi.mu.RLock()
- defer bi.mu.RUnlock()
-
- return bi.index[*h]
-}
diff --git a/blockproducer/blockindex_test.go b/blockproducer/blocknode_test.go
similarity index 75%
rename from blockproducer/blockindex_test.go
rename to blockproducer/blocknode_test.go
index ea5069e29..40f6aa279 100644
--- a/blockproducer/blockindex_test.go
+++ b/blockproducer/blocknode_test.go
@@ -18,7 +18,6 @@ package blockproducer
import (
"encoding/binary"
- "reflect"
"testing"
"time"
@@ -112,51 +111,3 @@ func TestAncestor(t *testing.T) {
t.Fatal("block node should not be nil and its height should be 0")
}
}
-
-func TestIndexBlock(t *testing.T) {
- chainInitTime := time.Now()
- period := time.Second
-
- bi := newBlockIndex()
-
- if bi == nil {
- t.Fatal("unexpected result: nil")
- }
-
- block0, err := generateRandomBlock(hash.Hash{}, true)
- if err != nil {
- t.Fatalf("Unexcepted error: %v", err)
- }
- bn0 := newBlockNode(chainInitTime, period, block0, nil)
-
- time.Sleep(time.Second)
-
- block1, err := generateRandomBlock(hash.Hash{}, true)
- if err != nil {
- t.Fatalf("Unexcepted error: %v", err)
- }
- bn1 := newBlockNode(chainInitTime, period, block1, bn0)
-
- time.Sleep(time.Second)
-
- block2, err := generateRandomBlock(hash.Hash{}, true)
- if err != nil {
- t.Fatalf("Unexcepted error: %v", err)
- }
- bn2 := newBlockNode(chainInitTime, period, block2, bn1)
-
- bi.addBlock(bn0)
- bi.addBlock(bn1)
-
- if bi.hasBlock(bn2.hash) {
- t.Fatalf("unexpected block index: %v", bn2)
- }
- if !bi.hasBlock(bn1.hash) {
- t.Fatalf("lack of block index: %v", bn1)
- }
-
- bn3 := bi.lookupNode(&bn0.hash)
- if !reflect.DeepEqual(bn0, bn3) {
- t.Fatalf("two values should be equal: \n\tv0=%+v\n\tv1=%+v", bn0, bn3)
- }
-}
diff --git a/blockproducer/branch.go b/blockproducer/branch.go
index afe2341a2..debe67aa0 100644
--- a/blockproducer/branch.go
+++ b/blockproducer/branch.go
@@ -69,6 +69,7 @@ func fork(
}
}
}
+ inst.preview.commit()
return
}
@@ -124,6 +125,7 @@ func (b *branch) applyBlock(bl *types.BPBlock) (br *branch, err error) {
return
}
}
+ cpy.preview.commit()
cpy.head = newBlockNodeEx(bl, cpy.head)
br = cpy
return
@@ -164,6 +166,7 @@ func (b *branch) produceBlock() (br *branch, bl *types.BPBlock, err error) {
}
// Create new block and update head
bl = newBlock(out)
+ cpy.preview.commit()
cpy.head = newBlockNodeEx(bl, cpy.head)
br = cpy
return
From 06f6512fe9f798d4992a8f1bdecf69454918a1ab Mon Sep 17 00:00:00 2001
From: leventeliu
Date: Tue, 11 Dec 2018 21:53:59 +0800
Subject: [PATCH 040/278] Add methods to reload chain state
---
blockproducer/blocknode.go | 82 +++++-----
blockproducer/branch.go | 42 ++++--
blockproducer/chain.go | 197 ++++++++++++++----------
blockproducer/errors.go | 2 +
blockproducer/rpc.go | 2 +-
blockproducer/runtime.go | 302 +++++++++++++++++++------------------
blockproducer/storage.go | 272 ++++++++++++++++++++++++++++++++-
7 files changed, 614 insertions(+), 285 deletions(-)
diff --git a/blockproducer/blocknode.go b/blockproducer/blocknode.go
index 867a4f4f5..faa8ae7fe 100644
--- a/blockproducer/blocknode.go
+++ b/blockproducer/blocknode.go
@@ -35,11 +35,20 @@ type blockNode struct {
block *types.BPBlock
}
-func newBlockNodeEx(b *types.BPBlock, p *blockNode) *blockNode {
+func newBlockNodeEx(h uint32, b *types.BPBlock, p *blockNode) *blockNode {
return &blockNode{
- hash: b.SignedHeader.BlockHash,
parent: p,
- block: b,
+
+ count: func() uint32 {
+ if p != nil {
+ return p.count + 1
+ }
+ return 0
+ }(),
+ height: h,
+
+ hash: b.SignedHeader.BlockHash,
+ block: b,
}
}
@@ -55,7 +64,7 @@ func newBlockNode(chainInitTime time.Time, period time.Duration, block *types.BP
} else {
count = 0
}
- bn := &blockNode{
+ n := &blockNode{
hash: *block.BlockHash(),
parent: parent,
height: h,
@@ -63,34 +72,23 @@ func newBlockNode(chainInitTime time.Time, period time.Duration, block *types.BP
block: block,
}
- return bn
+ return n
}
-func (bn *blockNode) indexKey() (key []byte) {
+func (n *blockNode) indexKey() (key []byte) {
key = make([]byte, hash.HashSize+4)
- binary.BigEndian.PutUint32(key[0:4], bn.height)
- copy(key[4:hash.HashSize], bn.hash[:])
+ binary.BigEndian.PutUint32(key[0:4], n.height)
+ copy(key[4:hash.HashSize], n.hash[:])
return
}
-func (bn *blockNode) initBlockNode(block *types.BPBlock, parent *blockNode) {
- bn.hash = block.SignedHeader.BlockHash
- bn.parent = nil
- bn.height = 0
-
- if parent != nil {
- bn.parent = parent
- bn.height = parent.height + 1
- }
-}
-
-// blockNodeListFrom return the block node list (forkPoint, bn].
-func (bn *blockNode) blockNodeListFrom(forkPoint uint32) (bl []*blockNode) {
- if bn.count <= forkPoint {
+// fetchNodeList returns the block node list within range (from, n.count] from node head n.
+func (n *blockNode) fetchNodeList(from uint32) (bl []*blockNode) {
+ if n.count <= from {
return
}
- bl = make([]*blockNode, bn.count-forkPoint)
- var iter = bn
+ bl = make([]*blockNode, n.count-from)
+ var iter = n
for i := len(bl) - 1; i >= 0; i-- {
bl[i] = iter
iter = iter.parent
@@ -98,47 +96,53 @@ func (bn *blockNode) blockNodeListFrom(forkPoint uint32) (bl []*blockNode) {
return
}
-func (bn *blockNode) ancestor(h uint32) *blockNode {
- if h > bn.height {
+func (n *blockNode) ancestor(h uint32) *blockNode {
+ if h > n.height {
return nil
}
- ancestor := bn
+ ancestor := n
for ancestor != nil && ancestor.height != h {
ancestor = ancestor.parent
}
return ancestor
}
-func (bn *blockNode) ancestorByCount(c uint32) *blockNode {
- if c > bn.count {
+func (n *blockNode) ancestorByCount(c uint32) *blockNode {
+ if c > n.count {
return nil
}
- ancestor := bn
+ ancestor := n
for ancestor != nil && ancestor.count != c {
ancestor = ancestor.parent
}
return ancestor
}
-func (bn *blockNode) lastIrreversible(comfirm uint32) (irr *blockNode) {
+// lastIrreversible returns the last irreversible block node with the given confirmations
+// from head n. Especially, the block at count 0, also known as the genesis block,
+// is irreversible.
+func (n *blockNode) lastIrreversible(confirm uint32) (irr *blockNode) {
var count uint32
- if bn.count > comfirm {
- count = bn.count - comfirm
+ if n.count > confirm {
+ count = n.count - confirm
}
- for irr = bn; irr.count > count; irr = irr.parent {
+ for irr = n; irr.count > count; irr = irr.parent {
}
return
}
-func (bn *blockNode) hasAncestor(anc *blockNode) bool {
- return bn.ancestorByCount(anc.count).hash == anc.hash
+func (n *blockNode) hasAncestor(anc *blockNode) bool {
+ var match = n.ancestorByCount(anc.count)
+ return match != nil && match.hash == anc.hash
}
-func (bn *blockNode) findNodeAfterCount(hash hash.Hash, min uint32) (match *blockNode, ok bool) {
- for match = bn; match.count >= min; match = match.parent {
- if match.hash.IsEqual(&hash) {
+func (n *blockNode) canForkFrom(
+ parent hash.Hash, lastIrreCount uint32) (match *blockNode, ok bool,
+) {
+ for match = n; match.count >= lastIrreCount; match = match.parent {
+ if match.hash.IsEqual(&parent) {
ok = true
return
}
diff --git a/blockproducer/branch.go b/blockproducer/branch.go
index debe67aa0..d03969608 100644
--- a/blockproducer/branch.go
+++ b/blockproducer/branch.go
@@ -10,8 +10,7 @@
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * See the License for the specific language governing permissions and * limitations under the License.
*/
package blockproducer
@@ -19,9 +18,12 @@ package blockproducer
import (
"bytes"
"sort"
+ "time"
pi "github.com/CovenantSQL/CovenantSQL/blockproducer/interfaces"
+ ca "github.com/CovenantSQL/CovenantSQL/crypto/asymmetric"
"github.com/CovenantSQL/CovenantSQL/crypto/hash"
+ "github.com/CovenantSQL/CovenantSQL/proto"
"github.com/CovenantSQL/CovenantSQL/types"
)
@@ -36,7 +38,7 @@ func fork(
from, to *blockNode, v *metaState, txPool map[hash.Hash]pi.Transaction) (br *branch, err error,
) {
var (
- list = to.blockNodeListFrom(from.count)
+ list = to.fetchNodeList(from.count)
inst = &branch{
head: to,
preview: v.makeCopy(),
@@ -101,13 +103,13 @@ func (b *branch) addTx(tx pi.Transaction) {
}
}
-func (b *branch) applyBlock(bl *types.BPBlock) (br *branch, err error) {
- if !b.head.hash.IsEqual(bl.ParentHash()) {
+func (b *branch) applyBlock(n *blockNode) (br *branch, err error) {
+ if !b.head.hash.IsEqual(n.block.ParentHash()) {
err = ErrParentNotMatch
return
}
var cpy = b.makeCopy()
- for _, v := range bl.Transactions {
+ for _, v := range n.block.Transactions {
var k = v.Hash()
// Check in tx pool
if _, ok := cpy.unpacked[k]; ok {
@@ -126,7 +128,7 @@ func (b *branch) applyBlock(bl *types.BPBlock) (br *branch, err error) {
}
}
cpy.preview.commit()
- cpy.head = newBlockNodeEx(bl, cpy.head)
+ cpy.head = n
br = cpy
return
}
@@ -149,7 +151,11 @@ func newBlock(out []pi.Transaction) (bl *types.BPBlock) {
return
}
-func (b *branch) produceBlock() (br *branch, bl *types.BPBlock, err error) {
+func (b *branch) produceBlock(
+ h uint32, ts time.Time, addr proto.AccountAddress, signer *ca.PrivateKey,
+) (
+ br *branch, bl *types.BPBlock, err error,
+) {
var (
cpy = b.makeCopy()
txs = cpy.sortUnpackedTxs()
@@ -164,11 +170,25 @@ func (b *branch) produceBlock() (br *branch, bl *types.BPBlock, err error) {
cpy.packed[k] = v
out = append(out, v)
}
- // Create new block and update head
- bl = newBlock(out)
cpy.preview.commit()
- cpy.head = newBlockNodeEx(bl, cpy.head)
+ // Create new block and update head
+ var block = &types.BPBlock{
+ SignedHeader: types.BPSignedHeader{
+ BPHeader: types.BPHeader{
+ Version: 0x01000000,
+ Producer: addr,
+ ParentHash: cpy.head.hash,
+ Timestamp: ts,
+ },
+ },
+ Transactions: out,
+ }
+ if err = block.PackAndSignBlock(signer); err != nil {
+ return
+ }
+ cpy.head = newBlockNodeEx(h, block, cpy.head)
br = cpy
+ bl = block
return
}
diff --git a/blockproducer/chain.go b/blockproducer/chain.go
index 0b7fc6b3f..6ca0978c3 100644
--- a/blockproducer/chain.go
+++ b/blockproducer/chain.go
@@ -54,98 +54,129 @@ var (
// Chain defines the main chain.
type Chain struct {
- rt *rt
- st xi.Storage
- cl *rpc.Caller
- bs chainbus.Bus
+ ctx context.Context
+ rt *rt
+ st xi.Storage
+ cl *rpc.Caller
+ bs chainbus.Bus
- blocksFromRPC chan *types.BPBlock
+ pendingBlocks chan *types.BPBlock
pendingTxs chan pi.Transaction
- ctx context.Context
}
// NewChain creates a new blockchain.
-func NewChain(cfg *Config) (*Chain, error) {
+func NewChain(cfg *Config) (c *Chain, err error) {
if fi, err := os.Stat(cfg.DataFile); err == nil && fi.Mode().IsRegular() {
return LoadChain(cfg)
}
- // get accountAddress
- pubKey, err := kms.GetLocalPublicKey()
- if err != nil {
- return nil, err
- }
- accountAddress, err := crypto.PubKeyHash(pubKey)
- if err != nil {
- return nil, err
- }
-
- // create chain
var (
bus = chainbus.New()
caller = rpc.NewCaller()
ctx = context.Background()
+ pubKey *asymmetric.PublicKey
+ st xi.Storage
+ addr proto.AccountAddress
+ inst *Chain
)
- chain := &Chain{
- rt: newRuntime(ctx, cfg, accountAddress),
- cl: caller,
- bs: bus,
- blocksFromRPC: make(chan *types.BPBlock),
- pendingTxs: make(chan pi.Transaction),
- ctx: ctx,
+ // Open storage
+ if st, err = openStorage(fmt.Sprintf("file:%s", cfg.DataFile)); err != nil {
+ return
}
- // sub chain events
- chain.bs.Subscribe(txEvent, chain.addTx)
+ // get accountAddress
+ if pubKey, err = kms.GetLocalPublicKey(); err != nil {
+ return
+ }
+ if addr, err = crypto.PubKeyHash(pubKey); err != nil {
+ return
+ }
- log.WithField("genesis", cfg.Genesis).Debug("pushing genesis block")
+ // create chain
+ inst = &Chain{
+ ctx: ctx,
+ rt: newRuntime(ctx, cfg, addr),
+ st: st,
+ cl: caller,
+ bs: bus,
+
+ pendingBlocks: make(chan *types.BPBlock),
+ pendingTxs: make(chan pi.Transaction),
+ }
- if err = chain.pushGenesisBlock(cfg.Genesis); err != nil {
- return nil, err
+ // Push genesis block
+ if err = inst.pushGenesisBlock(cfg.Genesis); err != nil {
+ return
}
log.WithFields(log.Fields{
- "index": chain.rt.index,
- "bp_number": chain.rt.bpNum,
- "period": chain.rt.period.String(),
- "tick": chain.rt.tick.String(),
- "height": chain.rt.currentBranch().head.height,
+ "index": inst.rt.locSvIndex,
+ "bp_number": inst.rt.serversNum,
+ "period": inst.rt.period.String(),
+ "tick": inst.rt.tick.String(),
+ "height": inst.rt.head().height,
}).Debug("current chain state")
- return chain, nil
+ // sub chain events
+ inst.bs.Subscribe(txEvent, inst.addTx)
+
+ c = inst
+ return
}
// LoadChain rebuilds the chain from db.
-func LoadChain(cfg *Config) (chain *Chain, err error) {
- // get accountAddress
- pubKey, err := kms.GetLocalPublicKey()
- if err != nil {
- return nil, err
- }
- accountAddress, err = crypto.PubKeyHash(pubKey)
- if err != nil {
- return nil, err
- }
-
+func LoadChain(cfg *Config) (c *Chain, err error) {
var (
bus = chainbus.New()
caller = rpc.NewCaller()
ctx = context.Background()
+ pubKey *asymmetric.PublicKey
+ st xi.Storage
+ addr proto.AccountAddress
+ inst *Chain
)
- chain = &Chain{
- rt: newRuntime(ctx, cfg, accountAddress),
- cl: caller,
- bs: bus,
- blocksFromRPC: make(chan *types.BPBlock),
+ // Open storage
+ if st, err = openStorage(fmt.Sprintf("file:%s", cfg.DataFile)); err != nil {
+ return
+ }
+
+ // get accountAddress
+ if pubKey, err = kms.GetLocalPublicKey(); err != nil {
+ return
+ }
+ if addr, err = crypto.PubKeyHash(pubKey); err != nil {
+ return
+ }
+
+ // create chain
+ inst = &Chain{
+ ctx: ctx,
+ rt: newRuntime(ctx, cfg, addr),
+ st: st,
+ cl: caller,
+ bs: bus,
+
+ pendingBlocks: make(chan *types.BPBlock),
pendingTxs: make(chan pi.Transaction),
- ctx: ctx,
}
- chain.bs.Subscribe(txEvent, chain.addTx)
+ // Load chain state from database
- return chain, nil
+ log.WithFields(log.Fields{
+ "index": inst.rt.locSvIndex,
+ "bp_number": inst.rt.serversNum,
+ "period": inst.rt.period.String(),
+ "tick": inst.rt.tick.String(),
+ "height": inst.rt.head().height,
+ }).Debug("current chain state")
+
+ // sub chain events
+ inst.bs.Subscribe(txEvent, inst.addTx)
+
+ c = inst
+ return
}
// checkBlock has following steps: 1. check parent block 2. checkTx 2. merkle tree 3. Hash 4. Signature.
@@ -206,7 +237,7 @@ func (c *Chain) produceBlock(now time.Time) (err error) {
if priv, err = kms.GetLocalPrivateKey(); err != nil {
return
}
- if b, err = c.rt.produceBlock(c.st, priv); err != nil {
+ if b, err = c.rt.produceBlock(c.st, now, priv); err != nil {
return
}
log.WithField("block", b).Debug("produced new block")
@@ -230,7 +261,7 @@ func (c *Chain) produceBlock(now time.Time) (err error) {
ctx, id, route.MCCAdviseNewBlock.String(), blockReq, blockResp,
); err != nil {
log.WithFields(log.Fields{
- "peer": c.rt.getPeerInfoString(),
+ "peer": c.rt.peerInfo(),
"now_time": time.Now().UTC().Format(time.RFC3339Nano),
"block_hash": b.BlockHash(),
}).WithError(err).Error("failed to advise new block")
@@ -331,7 +362,7 @@ func (c *Chain) fetchBlock(h hash.Hash) (b *types.BPBlock, err error) {
}
func (c *Chain) fetchBlockByHeight(h uint32) (b *types.BPBlock, count uint32, err error) {
- var node = c.rt.currentBranch().head.ancestor(h)
+ var node = c.rt.head().ancestor(h)
if node == nil {
err = ErrNoSuchBlock
return
@@ -349,7 +380,7 @@ func (c *Chain) fetchBlockByHeight(h uint32) (b *types.BPBlock, count uint32, er
}
func (c *Chain) fetchBlockByCount(count uint32) (b *types.BPBlock, height uint32, err error) {
- var node = c.rt.currentBranch().head.ancestorByCount(count)
+ var node = c.rt.head().ancestorByCount(count)
if node == nil {
err = ErrNoSuchBlock
return
@@ -370,8 +401,8 @@ func (c *Chain) fetchBlockByCount(count uint32) (b *types.BPBlock, height uint32
func (c *Chain) runCurrentTurn(now time.Time) {
log.WithFields(log.Fields{
"next_turn": c.rt.getNextTurn(),
- "bp_number": c.rt.bpNum,
- "node_index": c.rt.index,
+ "bp_number": c.rt.serversNum,
+ "node_index": c.rt.locSvIndex,
}).Info("check turns")
defer c.rt.setNextTurn()
@@ -389,13 +420,13 @@ func (c *Chain) runCurrentTurn(now time.Time) {
// sync synchronizes blocks and queries from the other peers.
func (c *Chain) sync() error {
log.WithFields(log.Fields{
- "peer": c.rt.getPeerInfoString(),
+ "peer": c.rt.peerInfo(),
}).Debug("synchronizing chain state")
// sync executes firstly alone, so it's ok to sync without locking runtime
for {
now := c.rt.now()
- height := c.rt.getHeightFromTime(now)
+ height := c.rt.height(now)
log.WithFields(log.Fields{
"height": height,
@@ -439,7 +470,7 @@ func (c *Chain) Start() error {
func (c *Chain) processBlocks(ctx context.Context) {
for {
select {
- case block := <-c.blocksFromRPC:
+ case block := <-c.pendingBlocks:
err := c.pushBlock(block)
if err != nil {
log.WithFields(log.Fields{
@@ -484,10 +515,10 @@ func (c *Chain) mainCycle(ctx context.Context) {
c.syncHead()
if t, d := c.rt.nextTick(); d > 0 {
log.WithFields(log.Fields{
- "peer": c.rt.getPeerInfoString(),
+ "peer": c.rt.peerInfo(),
"next_turn": c.rt.getNextTurn(),
- "head_height": c.rt.currentBranch().head.height,
- "head_block": c.rt.currentBranch().head.hash.String(),
+ "head_height": c.rt.head().height,
+ "head_block": c.rt.head().hash.String(),
"now_time": t.Format(time.RFC3339Nano),
"duration": d,
}).Debug("Main cycle")
@@ -502,11 +533,11 @@ func (c *Chain) mainCycle(ctx context.Context) {
func (c *Chain) syncHead() {
// Try to fetch if the the block of the current turn is not advised yet
log.WithFields(log.Fields{
- "index": c.rt.index,
+ "index": c.rt.locSvIndex,
"next_turn": c.rt.getNextTurn(),
- "height": c.rt.currentBranch().head.height,
+ "height": c.rt.head().height,
}).Debug("sync header")
- if h := c.rt.getNextTurn() - 1; c.rt.currentBranch().head.height < h {
+ if h := c.rt.getNextTurn() - 1; c.rt.head().height < h {
log.Debugf("sync header with height %d", h)
var err error
req := &FetchBlockReq{
@@ -524,20 +555,20 @@ func (c *Chain) syncHead() {
err = c.cl.CallNode(s, route.MCCFetchBlock.String(), req, resp)
if err != nil || resp.Block == nil {
log.WithFields(log.Fields{
- "peer": c.rt.getPeerInfoString(),
+ "peer": c.rt.peerInfo(),
"remote": fmt.Sprintf("[%d/%d] %s", i, len(peers.Servers), s),
"curr_turn": c.rt.getNextTurn(),
- "head_height": c.rt.currentBranch().head.height,
- "head_block": c.rt.currentBranch().head.hash.String(),
+ "head_height": c.rt.head().height,
+ "head_block": c.rt.head().hash.String(),
}).WithError(err).Debug("Failed to fetch block from peer")
} else {
- c.blocksFromRPC <- resp.Block
+ c.pendingBlocks <- resp.Block
log.WithFields(log.Fields{
- "peer": c.rt.getPeerInfoString(),
+ "peer": c.rt.peerInfo(),
"remote": fmt.Sprintf("[%d/%d] %s", i, len(peers.Servers), s),
"curr_turn": c.rt.getNextTurn(),
- "head_height": c.rt.currentBranch().head.height,
- "head_block": c.rt.currentBranch().head.hash.String(),
+ "head_height": c.rt.head().height,
+ "head_block": c.rt.head().hash.String(),
}).Debug("Fetch block from remote peer successfully")
succ = true
break
@@ -547,10 +578,10 @@ func (c *Chain) syncHead() {
if !succ {
log.WithFields(log.Fields{
- "peer": c.rt.getPeerInfoString(),
+ "peer": c.rt.peerInfo(),
"curr_turn": c.rt.getNextTurn(),
- "head_height": c.rt.currentBranch().head.height,
- "head_block": c.rt.currentBranch().head.hash.String(),
+ "head_height": c.rt.head().height,
+ "head_block": c.rt.head().hash.String(),
}).Debug(
"Cannot get block from any peer")
}
@@ -560,8 +591,10 @@ func (c *Chain) syncHead() {
// Stop stops the main process of the sql-chain.
func (c *Chain) Stop() (err error) {
// Stop main process
- log.WithFields(log.Fields{"peer": c.rt.getPeerInfoString()}).Debug("Stopping chain")
+ log.WithFields(log.Fields{"peer": c.rt.peerInfo()}).Debug("Stopping chain")
c.rt.stop()
- log.WithFields(log.Fields{"peer": c.rt.getPeerInfoString()}).Debug("Chain service stopped")
+ log.WithFields(log.Fields{"peer": c.rt.peerInfo()}).Debug("Chain service stopped")
+ close(c.pendingBlocks)
+ close(c.pendingTxs)
return
}
diff --git a/blockproducer/errors.go b/blockproducer/errors.go
index 4872d5569..387572979 100644
--- a/blockproducer/errors.go
+++ b/blockproducer/errors.go
@@ -84,4 +84,6 @@ var (
ErrInvalidPermission = errors.New("invalid permission")
// ErrMinerUserNotMatch indicates that the miner and user do not match.
ErrMinerUserNotMatch = errors.New("miner and user do not match")
+ // ErrMultipleGenesis indicates that there're multiple genesis blocks while loading.
+ ErrMultipleGenesis = errors.New("multiple genesis blocks")
)
diff --git a/blockproducer/rpc.go b/blockproducer/rpc.go
index 015f1a34c..93471eac3 100644
--- a/blockproducer/rpc.go
+++ b/blockproducer/rpc.go
@@ -163,7 +163,7 @@ type QueryAccountCovenantBalanceResp struct {
// AdviseNewBlock is the RPC method to advise a new block to target server.
func (s *ChainRPCService) AdviseNewBlock(req *AdviseNewBlockReq, resp *AdviseNewBlockResp) error {
- s.chain.blocksFromRPC <- req.Block
+ s.chain.pendingBlocks <- req.Block
return nil
}
diff --git a/blockproducer/runtime.go b/blockproducer/runtime.go
index fca1ddd64..209b4f4db 100644
--- a/blockproducer/runtime.go
+++ b/blockproducer/runtime.go
@@ -34,60 +34,104 @@ import (
xi "github.com/CovenantSQL/CovenantSQL/xenomint/interfaces"
)
-// copy from /sqlchain/runtime.go
-// rt define the runtime of main chain.
+// rt defines the runtime of main chain.
type rt struct {
ctx context.Context
cancel context.CancelFunc
wg *sync.WaitGroup
- // chainInitTime is the initial cycle time, when the Genesis block is produced.
- chainInitTime time.Time
-
- accountAddress proto.AccountAddress
- server *rpc.Server
-
- bpNum uint32
- // index is the index of the current server in the peer list.
- index uint32
-
- // period is the block producing cycle.
- period time.Duration
- // tick defines the maximum duration between each cycle.
- tick time.Duration
-
- // peersMutex protects following peers-relative fields.
- peersMutex sync.Mutex
- peers *proto.Peers
- nodeID proto.NodeID
- minComfirm uint32
+ // The following fields are read-only in runtime.
+ server *rpc.Server
+ address proto.AccountAddress
+ genesisTime time.Time
+ period time.Duration
+ tick time.Duration
+
+ sync.RWMutex // protects following fields
+ peers *proto.Peers
+ nodeID proto.NodeID
+ comfirms uint32
+ serversNum uint32
+ locSvIndex uint32
+ nextTurn uint32
+ offset time.Duration
+ lastIrre *blockNode
+ immutable *metaState
+ headIndex int
+ headBranch *branch
+ branches []*branch
+ txPool map[hash.Hash]pi.Transaction
+}
- stateMutex sync.Mutex // Protects following fields.
- // nextTurn is the height of the next block.
- nextTurn uint32
+func newRuntime(ctx context.Context, cfg *Config, accountAddress proto.AccountAddress) *rt {
+ var index uint32
+ for i, s := range cfg.Peers.Servers {
+ if cfg.NodeID.IsEqual(&s) {
+ index = uint32(i)
+ }
+ }
+ var (
+ cld, ccl = context.WithCancel(ctx)
+ l = float64(len(cfg.Peers.Servers))
+ t float64
+ m float64
+ err error
- // timeMutex protects following time-relative fields.
- timeMutex sync.Mutex
- // offset is the time difference calculated by: coodinatedChainTime - time.Now().
- //
- // TODO(leventeliu): update offset in ping cycle.
- offset time.Duration
-
- // Cached state
- cacheMu sync.RWMutex
- irre *blockNode
- immutable *metaState
- currIdx int
- current *branch
- branches []*branch
- txPool map[hash.Hash]pi.Transaction
+ genesis = newBlockNodeEx(0, cfg.Genesis, nil)
+ immutable = newMetaState()
+ headBranch *branch
+ )
+ if t = cfg.ComfirmThreshold; t <= 0.0 {
+ t = float64(2) / 3.0
+ }
+ if m = math.Ceil(l*t + 1); m > l {
+ m = l
+ }
+ for _, tx := range genesis.block.Transactions {
+ if err = immutable.apply(tx); err != nil {
+ log.WithError(err).Fatal("Failed to initialize immutable state from genesis")
+ }
+ }
+ immutable.commit()
+ headBranch = &branch{
+ head: genesis,
+ preview: immutable.makeCopy(),
+ packed: make(map[hash.Hash]pi.Transaction),
+ unpacked: make(map[hash.Hash]pi.Transaction),
+ }
+ return &rt{
+ ctx: cld,
+ cancel: ccl,
+ wg: &sync.WaitGroup{},
+
+ server: cfg.Server,
+ address: accountAddress,
+ genesisTime: cfg.Genesis.SignedHeader.Timestamp,
+ period: cfg.Period,
+ tick: cfg.Tick,
+
+ peers: cfg.Peers,
+ nodeID: cfg.NodeID,
+ comfirms: uint32(m),
+ serversNum: uint32(len(cfg.Peers.Servers)),
+ locSvIndex: index,
+ nextTurn: 1,
+ offset: time.Duration(0),
+
+ lastIrre: genesis,
+ immutable: immutable,
+ headIndex: 0,
+ headBranch: headBranch,
+ branches: []*branch{headBranch},
+ txPool: make(map[hash.Hash]pi.Transaction),
+ }
}
func (r *rt) addTx(st xi.Storage, tx pi.Transaction) (err error) {
return store(st, []storageProcedure{addTx(tx)}, func() {
var k = tx.Hash()
- r.cacheMu.Lock()
- defer r.cacheMu.Unlock()
+ r.Lock()
+ defer r.Unlock()
if _, ok := r.txPool[k]; !ok {
r.txPool[k] = tx
}
@@ -98,20 +142,20 @@ func (r *rt) addTx(st xi.Storage, tx pi.Transaction) (err error) {
}
func (r *rt) nextNonce(addr proto.AccountAddress) (n pi.AccountNonce, err error) {
- r.cacheMu.RLock()
- defer r.cacheMu.RUnlock()
- return r.current.preview.nextNonce(addr)
+ r.RLock()
+ defer r.RUnlock()
+ return r.headBranch.preview.nextNonce(addr)
}
func (r *rt) loadAccountCovenantBalance(addr proto.AccountAddress) (balance uint64, ok bool) {
- r.cacheMu.RLock()
- defer r.cacheMu.RUnlock()
+ r.RLock()
+ defer r.RUnlock()
return r.immutable.loadAccountCovenantBalance(addr)
}
func (r *rt) loadAccountStableBalance(addr proto.AccountAddress) (balance uint64, ok bool) {
- r.cacheMu.RLock()
- defer r.cacheMu.RUnlock()
+ r.RLock()
+ defer r.RUnlock()
return r.immutable.loadAccountStableBalance(addr)
}
@@ -121,6 +165,7 @@ func (r *rt) switchBranch(st xi.Storage, bl *types.BPBlock, origin int, head *br
newIrres []*blockNode
sps []storageProcedure
up storageCallback
+ height = r.height(bl.Timestamp())
)
// Find new irreversible blocks
@@ -128,8 +173,8 @@ func (r *rt) switchBranch(st xi.Storage, bl *types.BPBlock, origin int, head *br
// NOTE(leventeliu):
// May have multiple new irreversible blocks here if peer list shrinks. May also have
// no new irreversible block at all if peer list expands.
- irre = head.head.lastIrreversible(r.minComfirm)
- newIrres = irre.blockNodeListFrom(r.irre.count)
+ irre = head.head.lastIrreversible(r.comfirms)
+ newIrres = irre.fetchNodeList(r.lastIrre.count)
// Apply irreversible blocks to create dirty map on immutable cache
//
@@ -143,7 +188,7 @@ func (r *rt) switchBranch(st xi.Storage, bl *types.BPBlock, origin int, head *br
}
// Prepare storage procedures to update immutable database
- sps = append(sps, addBlock(bl))
+ sps = append(sps, addBlock(height, bl))
for k, v := range r.immutable.dirty.accounts {
if v != nil {
sps = append(sps, updateAccount(&v.Account))
@@ -173,7 +218,7 @@ func (r *rt) switchBranch(st xi.Storage, bl *types.BPBlock, origin int, head *br
// Prepare callback to update cache
up = func() {
// Update last irreversible block
- r.irre = irre
+ r.lastIrre = irre
// Apply irreversible blocks to immutable database
r.immutable.commit()
// Prune branches
@@ -191,8 +236,8 @@ func (r *rt) switchBranch(st xi.Storage, bl *types.BPBlock, origin int, head *br
}
}
// Replace current branches
- r.current = head
- r.currIdx = idx
+ r.headBranch = head
+ r.headIndex = idx
r.branches = brs
// Clear packed transactions
for _, b := range newIrres {
@@ -217,33 +262,37 @@ func (r *rt) applyBlock(st xi.Storage, bl *types.BPBlock) (err error) {
ok bool
br *branch
parent *blockNode
+ head *blockNode
+ height = r.height(bl.Timestamp())
)
- r.cacheMu.Lock()
- defer r.cacheMu.Unlock()
+ r.Lock()
+ defer r.Unlock()
for i, v := range r.branches {
// Grow a branch
if v.head.hash.IsEqual(&bl.SignedHeader.ParentHash) {
- if br, err = v.applyBlock(bl); err != nil {
+ head = newBlockNodeEx(height, bl, v.head)
+ if br, err = v.applyBlock(head); err != nil {
return
}
-
// Grow a branch while the current branch is not changed
- if br.head.count <= r.current.head.count {
- return store(st, []storageProcedure{addBlock(bl)}, func() { r.branches[i] = br })
+ if br.head.count <= r.headBranch.head.count {
+ return store(st,
+ []storageProcedure{addBlock(height, bl)},
+ func() { r.branches[i] = br },
+ )
}
-
// Switch branch or grow current branch
return r.switchBranch(st, bl, i, br)
}
// Fork and create new branch
- if parent, ok = v.head.findNodeAfterCount(bl.SignedHeader.ParentHash, r.irre.count); ok {
- var head = newBlockNodeEx(bl, parent)
- if br, err = fork(r.irre, head, r.immutable, r.txPool); err != nil {
+ if parent, ok = v.head.canForkFrom(bl.SignedHeader.ParentHash, r.lastIrre.count); ok {
+ head = newBlockNodeEx(height, bl, parent)
+ if br, err = fork(r.lastIrre, head, r.immutable, r.txPool); err != nil {
return
}
return store(st,
- []storageProcedure{addBlock(bl)},
+ []storageProcedure{addBlock(height, bl)},
func() { r.branches = append(r.branches, br) },
)
}
@@ -253,23 +302,21 @@ func (r *rt) applyBlock(st xi.Storage, bl *types.BPBlock) (err error) {
}
func (r *rt) produceBlock(
- st xi.Storage, priv *asymmetric.PrivateKey) (out *types.BPBlock, err error,
+ st xi.Storage, now time.Time, priv *asymmetric.PrivateKey) (out *types.BPBlock, err error,
) {
var (
bl *types.BPBlock
br *branch
)
- r.cacheMu.Lock()
- defer r.cacheMu.Unlock()
-
+ r.Lock()
+ defer r.Unlock()
// Try to produce new block
- if br, bl, err = r.current.produceBlock(); err != nil {
+ if br, bl, err = r.headBranch.produceBlock(
+ r.height(now), now, r.address, priv,
+ ); err != nil {
return
}
- if err = bl.PackAndSignBlock(priv); err != nil {
- return
- }
- if err = r.switchBranch(st, bl, r.currIdx, br); err != nil {
+ if err = r.switchBranch(st, bl, r.headIndex, br); err != nil {
return
}
out = bl
@@ -278,113 +325,78 @@ func (r *rt) produceBlock(
// now returns the current coordinated chain time.
func (r *rt) now() time.Time {
- r.timeMutex.Lock()
- defer r.timeMutex.Unlock()
- // TODO(lambda): why does sqlchain not need UTC
+ r.RLock()
+ defer r.RUnlock()
return time.Now().UTC().Add(r.offset)
}
-func newRuntime(ctx context.Context, cfg *Config, accountAddress proto.AccountAddress) *rt {
- var index uint32
- for i, s := range cfg.Peers.Servers {
- if cfg.NodeID.IsEqual(&s) {
- index = uint32(i)
- }
- }
- var (
- cld, ccl = context.WithCancel(ctx)
- l = float64(len(cfg.Peers.Servers))
- t float64
- m float64
- )
- if t = cfg.ComfirmThreshold; t <= 0.0 {
- t = float64(2) / 3.0
- }
- if m = math.Ceil(l*t + 1); m > l {
- m = l
- }
- return &rt{
- ctx: cld,
- cancel: ccl,
- wg: &sync.WaitGroup{},
- chainInitTime: cfg.Genesis.SignedHeader.Timestamp,
- accountAddress: accountAddress,
- server: cfg.Server,
- bpNum: uint32(len(cfg.Peers.Servers)),
- index: index,
- period: cfg.Period,
- tick: cfg.Tick,
- peers: cfg.Peers,
- nodeID: cfg.NodeID,
- minComfirm: uint32(m),
- nextTurn: 1,
- offset: time.Duration(0),
- }
-}
-
func (r *rt) startService(chain *Chain) {
r.server.RegisterService(route.BlockProducerRPCName, &ChainRPCService{chain: chain})
}
// nextTick returns the current clock reading and the duration till the next turn. If duration
// is less or equal to 0, use the clock reading to run the next cycle - this avoids some problem
-// caused by concurrently time synchronization.
+// caused by concurrent time synchronization.
func (r *rt) nextTick() (t time.Time, d time.Duration) {
- t = r.now()
- d = r.chainInitTime.Add(time.Duration(r.nextTurn) * r.period).Sub(t)
-
+ var nt uint32
+ nt, t = func() (nt uint32, t time.Time) {
+ r.RLock()
+ defer r.RUnlock()
+ nt = r.nextTurn
+ t = time.Now().UTC().Add(r.offset)
+ return
+ }()
+ d = r.genesisTime.Add(time.Duration(nt) * r.period).Sub(t)
if d > r.tick {
d = r.tick
}
-
return
}
func (r *rt) isMyTurn() bool {
- r.stateMutex.Lock()
- defer r.stateMutex.Unlock()
- return r.nextTurn%r.bpNum == r.index
+ r.RLock()
+ defer r.RUnlock()
+ return r.nextTurn%r.serversNum == r.locSvIndex
}
// setNextTurn prepares the runtime state for the next turn.
func (r *rt) setNextTurn() {
- r.stateMutex.Lock()
- defer r.stateMutex.Unlock()
+ r.Lock()
+ defer r.Unlock()
r.nextTurn++
}
-func (r *rt) getIndexTotalServer() (uint32, uint32, proto.NodeID) {
- return r.index, r.bpNum, r.nodeID
-}
-
-func (r *rt) getPeerInfoString() string {
- index, bpNum, nodeID := r.getIndexTotalServer()
+func (r *rt) peerInfo() string {
+ var index, bpNum, nodeID = func() (uint32, uint32, proto.NodeID) {
+ r.RLock()
+ defer r.RUnlock()
+ return r.locSvIndex, r.serversNum, r.nodeID
+ }()
return fmt.Sprintf("[%d/%d] %s", index, bpNum, nodeID)
}
-// getHeightFromTime calculates the height with this sql-chain config of a given time reading.
-func (r *rt) getHeightFromTime(t time.Time) uint32 {
- return uint32(t.Sub(r.chainInitTime) / r.period)
+// height calculates the height with this sql-chain config of a given time reading.
+func (r *rt) height(t time.Time) uint32 {
+ return uint32(t.Sub(r.genesisTime) / r.period)
}
func (r *rt) getNextTurn() uint32 {
- r.stateMutex.Lock()
- defer r.stateMutex.Unlock()
-
+ r.RLock()
+ defer r.RUnlock()
return r.nextTurn
}
func (r *rt) getPeers() *proto.Peers {
- r.peersMutex.Lock()
- defer r.peersMutex.Unlock()
- peers := r.peers.Clone()
+ r.RLock()
+ defer r.RUnlock()
+ var peers = r.peers.Clone()
return &peers
}
-func (r *rt) currentBranch() *branch {
- r.cacheMu.RLock()
- defer r.cacheMu.RUnlock()
- return r.current
+func (r *rt) head() *blockNode {
+ r.RLock()
+ defer r.RUnlock()
+ return r.headBranch.head
}
func (r *rt) stop() {
diff --git a/blockproducer/storage.go b/blockproducer/storage.go
index 00ef655aa..650cae327 100644
--- a/blockproducer/storage.go
+++ b/blockproducer/storage.go
@@ -34,6 +34,7 @@ var (
ddls = [...]string{
// Chain state tables
`CREATE TABLE IF NOT EXISTS "blocks" (
+ "height" INT
"hash" TEXT
"parent" TEXT
"encoded" BLOB
@@ -113,7 +114,7 @@ func openStorage(path string) (st xi.Storage, err error) {
return
}
-func addBlock(b *types.BPBlock) storageProcedure {
+func addBlock(height uint32, b *types.BPBlock) storageProcedure {
var (
enc *bytes.Buffer
err error
@@ -122,7 +123,8 @@ func addBlock(b *types.BPBlock) storageProcedure {
return errPass(err)
}
return func(tx *sql.Tx) (err error) {
- _, err = tx.Exec(`INSERT OR REPLACE INTO "blocks" VALUES (?, ?, ?)`,
+ _, err = tx.Exec(`INSERT OR REPLACE INTO "blocks" VALUES (?, ?, ?, ?)`,
+ height,
b.BlockHash().String(),
b.ParentHash().String(),
enc.Bytes())
@@ -132,10 +134,14 @@ func addBlock(b *types.BPBlock) storageProcedure {
func addTx(t pi.Transaction) storageProcedure {
var (
+ tt = t
enc *bytes.Buffer
err error
)
- if enc, err = utils.EncodeMsgPack(t); err != nil {
+ if _, ok := tt.(*pi.TransactionWrapper); !ok {
+ tt = pi.WrapTransaction(tt)
+ }
+ if enc, err = utils.EncodeMsgPack(tt); err != nil {
return errPass(err)
}
return func(tx *sql.Tx) (err error) {
@@ -147,10 +153,6 @@ func addTx(t pi.Transaction) storageProcedure {
}
}
-func updateImmutable(tx []pi.Transaction) storageProcedure {
- return nil
-}
-
func updateIrreversible(h hash.Hash) storageProcedure {
return func(tx *sql.Tx) (err error) {
_, err = tx.Exec(`INSERT OR REPLACE INTO "irreversible" VALUES (?, ?)`, 0, h.String())
@@ -247,3 +249,259 @@ func deleteProvider(address proto.AccountAddress) storageProcedure {
return
}
}
+
+func loadIrreHash(st xi.Storage) (irre hash.Hash, err error) {
+ var hex string
+ // Load last irreversible block hash
+ if err = st.Reader().QueryRow(
+ `SELECT "hash" FROM "irreversible" WHERE "id"=0`,
+ ).Scan(&hex); err != nil {
+ return
+ }
+ if err = hash.Decode(&irre, hex); err != nil {
+ return
+ }
+ return
+}
+
+func loadTxPool(st xi.Storage) (txPool map[hash.Hash]pi.Transaction, err error) {
+ var (
+ th hash.Hash
+ rows *sql.Rows
+ tt uint32
+ hex string
+ enc []byte
+ pool = make(map[hash.Hash]pi.Transaction)
+ )
+
+ if rows, err = st.Reader().Query(
+ `SELECT "type", "hash", "encoded" FROM "txPool"`,
+ ); err != nil {
+ return
+ }
+ defer rows.Close()
+
+ for rows.Next() {
+ if err = rows.Scan(&tt, &hex, &enc); err != nil {
+ return
+ }
+ if err = hash.Decode(&th, hex); err != nil {
+ return
+ }
+ var dec = &pi.TransactionWrapper{}
+ if err = utils.DecodeMsgPack(enc, dec); err != nil {
+ return
+ }
+ pool[th] = dec.Unwrap()
+ }
+
+ txPool = pool
+ return
+}
+
+func loadBlocks(
+ st xi.Storage, irreHash hash.Hash) (irre *blockNode, heads []*blockNode, err error,
+) {
+ var (
+ rows *sql.Rows
+
+ genesis = hash.Hash{}
+ index = make(map[hash.Hash]*blockNode)
+ headsIndex = make(map[hash.Hash]*blockNode)
+
+ // Scan buffer
+ v1 uint32
+ v2, v3 string
+ v4 []byte
+
+ ok bool
+ bh, ph hash.Hash
+ bn, pn *blockNode
+ )
+
+ // Load blocks
+ if rows, err = st.Reader().Query(
+ `SELECT "height", "hash", "parent", "encoded" FROM "blocks" ORDER BY "rowid"`,
+ ); err != nil {
+ return
+ }
+ defer rows.Close()
+
+ for rows.Next() {
+ // Scan and decode block
+ if err = rows.Scan(&v1, &v2, &v3, &v4); err != nil {
+ return
+ }
+ if err = hash.Decode(&bh, v2); err != nil {
+ return
+ }
+ if err = hash.Decode(&ph, v3); err != nil {
+ return
+ }
+ var dec = &types.BPBlock{}
+ if err = utils.DecodeMsgPack(v4, dec); err != nil {
+ return
+ }
+ // Add genesis block
+ if ph.IsEqual(&genesis) {
+ if _, ok = index[ph]; ok {
+ err = ErrMultipleGenesis
+ return
+ }
+ bn = newBlockNodeEx(0, dec, nil)
+ index[bh] = bn
+ headsIndex[bh] = bn
+ return
+ }
+ // Add normal block
+ if pn, ok = index[ph]; ok {
+ err = ErrParentNotFound
+ return
+ }
+ bn = newBlockNodeEx(v1, dec, pn)
+ index[bh] = bn
+ if _, ok = headsIndex[ph]; ok {
+ delete(headsIndex, ph)
+ }
+ headsIndex[bh] = bn
+ }
+
+ if irre, ok = index[irreHash]; !ok {
+ err = ErrParentNotFound
+ return
+ }
+
+ for _, v := range headsIndex {
+ heads = append(heads, v)
+ }
+
+ return
+}
+
+func loadAndCacheAccounts(st xi.Storage, view *metaState) (err error) {
+ var (
+ rows *sql.Rows
+ hex string
+ addr hash.Hash
+ enc []byte
+ )
+
+ if rows, err = st.Reader().Query(`SELECT "address", "encoded" FROM "accounts"`); err != nil {
+ return
+ }
+ defer rows.Close()
+
+ for rows.Next() {
+ if err = rows.Scan(&hex, &enc); err != nil {
+ return
+ }
+ if err = hash.Decode(&addr, hex); err != nil {
+ return
+ }
+ var dec = &accountObject{}
+ if err = utils.DecodeMsgPack(enc, &dec.Account); err != nil {
+ return
+ }
+ view.readonly.accounts[proto.AccountAddress(addr)] = dec
+ }
+
+ return
+}
+
+func loadAndCacheShardChainProfiles(st xi.Storage, view *metaState) (err error) {
+ var (
+ rows *sql.Rows
+ id string
+ enc []byte
+ )
+
+ if rows, err = st.Reader().Query(`SELECT "id", "encoded" FROM "shardChain"`); err != nil {
+ return
+ }
+ defer rows.Close()
+
+ for rows.Next() {
+ if err = rows.Scan(&id, &enc); err != nil {
+ return
+ }
+ var dec = &sqlchainObject{}
+ if err = utils.DecodeMsgPack(enc, &dec.SQLChainProfile); err != nil {
+ return
+ }
+ view.readonly.databases[proto.DatabaseID(id)] = dec
+ }
+
+ return
+}
+
+func loadAndCacheProviders(st xi.Storage, view *metaState) (err error) {
+ var (
+ rows *sql.Rows
+ hex string
+ addr hash.Hash
+ enc []byte
+ )
+
+ if rows, err = st.Reader().Query(`SELECT "address", "encoded" FROM "provider"`); err != nil {
+ return
+ }
+ defer rows.Close()
+
+ for rows.Next() {
+ if err = rows.Scan(&hex, &enc); err != nil {
+ return
+ }
+ if err = hash.Decode(&addr, hex); err != nil {
+ return
+ }
+ var dec = &providerObject{}
+ if err = utils.DecodeMsgPack(enc, &dec.ProviderProfile); err != nil {
+ return
+ }
+ view.readonly.provider[proto.AccountAddress(addr)] = dec
+ }
+
+ return
+}
+
+func loadImmutableState(st xi.Storage) (immutable *metaState, err error) {
+ immutable = newMetaState()
+ if err = loadAndCacheAccounts(st, immutable); err != nil {
+ return
+ }
+ if err = loadAndCacheShardChainProfiles(st, immutable); err != nil {
+ return
+ }
+ if err = loadAndCacheProviders(st, immutable); err != nil {
+ return
+ }
+ return
+}
+
+func loadDatabase(st xi.Storage) (
+ irre *blockNode,
+ heads []*blockNode,
+ immutable *metaState,
+ txPool map[hash.Hash]pi.Transaction,
+ err error,
+) {
+ var irreHash hash.Hash
+ // Load last irreversible block hash
+ if irreHash, err = loadIrreHash(st); err != nil {
+ return
+ }
+ // Load blocks
+ if irre, heads, err = loadBlocks(st, irreHash); err != nil {
+ return
+ }
+ // Load immutable state
+ if immutable, err = loadImmutableState(st); err != nil {
+ return
+ }
+ // Load tx pool
+ if txPool, err = loadTxPool(st); err != nil {
+ return
+ }
+
+ return
+}
From 85c44038bff7746cc29751c828bb3a0fd09a3ebd Mon Sep 17 00:00:00 2001
From: zeqing-guo
Date: Tue, 11 Dec 2018 22:21:29 +0800
Subject: [PATCH 041/278] Add deposit
---
blockproducer/chain.go | 20 ++++-----
blockproducer/config.go | 7 ++-
blockproducer/errors.go | 4 ++
blockproducer/metastate.go | 28 +++++++++++-
blockproducer/metastate_test.go | 2 -
blockproducer/runtime.go | 2 +-
cmd/cqld/bootstrap.go | 1 +
conf/config.go | 3 ++
test/GNTE/conf/node_0/config.yaml | 2 +
test/GNTE/conf/node_1/config.yaml | 2 +
test/GNTE/conf/node_2/config.yaml | 2 +
test/GNTE/conf/node_c/config.yaml | 2 +
.../conf/node_miner_10.250.100.2/config.yaml | 2 +
.../conf/node_miner_10.250.100.3/config.yaml | 2 +
.../conf/node_miner_10.250.100.4/config.yaml | 2 +
.../conf/node_miner_10.250.100.5/config.yaml | 2 +
.../conf/node_miner_10.250.100.6/config.yaml | 2 +
.../conf/node_miner_10.250.100.7/config.yaml | 2 +
.../conf/node_miner_10.250.100.8/config.yaml | 2 +
.../conf/node_miner_10.250.100.9/config.yaml | 2 +
test/bootstrap.yaml | 2 +
test/fuse/node_0/config.yaml | 2 +
test/fuse/node_1/config.yaml | 2 +
test/fuse/node_2/config.yaml | 2 +
test/fuse/node_c/config.yaml | 2 +
test/fuse/node_miner_0/config.yaml | 2 +
test/fuse/node_miner_1/config.yaml | 2 +
test/fuse/node_miner_2/config.yaml | 2 +
test/integration/node_0/config.yaml | 2 +
test/integration/node_1/config.yaml | 2 +
test/integration/node_2/config.yaml | 2 +
test/integration/node_c/config.yaml | 2 +
test/integration/node_miner_0/config.yaml | 2 +
test/integration/node_miner_1/config.yaml | 2 +
test/integration/node_miner_2/config.yaml | 2 +
test/leak/client.yaml | 2 +
test/leak/leader.yaml | 2 +
test/mainchain/node_0/config.yaml | 2 +
test/mainchain/node_1/config.yaml | 2 +
test/mainchain/node_2/config.yaml | 2 +
test/mainchain/node_c/config.yaml | 2 +
test/mainchain/node_miner_0/config.yaml | 2 +
test/mainchain/node_miner_1/config.yaml | 2 +
test/mainchain/node_miner_2/config.yaml | 2 +
test/mainchain/node_multi_0/config.yaml | 2 +
test/mainchain/node_multi_1/config.yaml | 2 +
test/mainchain/node_multi_2/config.yaml | 2 +
test/mainchain/node_standalone/config.yaml | 2 +
test/node_0/config.yaml | 2 +
test/node_1/config.yaml | 2 +
test/node_2/config.yaml | 2 +
test/node_c/config.yaml | 2 +
test/node_standalone/config.yaml | 2 +
test/node_standalone/config2.yaml | 2 +
test/observation/node_0/config.yaml | 2 +
test/observation/node_1/config.yaml | 2 +
test/observation/node_2/config.yaml | 2 +
test/observation/node_c/config.yaml | 2 +
test/observation/node_miner_0/config.yaml | 2 +
test/observation/node_miner_1/config.yaml | 2 +
test/observation/node_miner_2/config.yaml | 2 +
test/observation/node_observer/config.yaml | 2 +
test/pool/client.yaml | 2 +
test/pool/leader.yaml | 2 +
test/service/node_0/config.yaml | 2 +
test/service/node_1/config.yaml | 2 +
test/service/node_2/config.yaml | 2 +
test/service/node_adapter/config.yaml | 2 +
test/service/node_c/config.yaml | 2 +
test/service/node_miner_0/config.yaml | 2 +
test/service/node_miner_1/config.yaml | 2 +
test/service/node_miner_2/config.yaml | 2 +
test/service/node_mysql_adapter/config.yaml | 2 +
test/service/node_observer/config.yaml | 2 +
types/account.go | 5 ++-
types/account_gen.go | 30 ++++++++-----
types/createdb.go | 3 ++
types/createdb_gen.go | 39 ++++++++---------
types/init_service_type_gen.go | 21 ++-------
types/no_ack_report_type_gen.go | 43 ++++++++++++++++---
types/provideservice.go | 3 +-
types/provideservice_gen.go | 24 ++++++-----
types/request_type_gen.go | 23 +++-------
83 files changed, 288 insertions(+), 102 deletions(-)
diff --git a/blockproducer/chain.go b/blockproducer/chain.go
index ae2759020..0aad4a449 100644
--- a/blockproducer/chain.go
+++ b/blockproducer/chain.go
@@ -367,16 +367,16 @@ func (c *Chain) fetchBlockByCount(count uint32) (b *types.BPBlock, height uint32
}
func (c *Chain) fetchLastBlock() (b *types.BPBlock, count uint32, height uint32, err error) {
- var node = c.rt.currentBranch().head
- if node == nil {
- err = ErrNoSuchBlock
- return
- } else if node.block != nil {
- b = node.block
- height = node.height
- count = node.count
- return
- }
+ var node = c.rt.currentBranch().head
+ if node == nil {
+ err = ErrNoSuchBlock
+ return
+ } else if node.block != nil {
+ b = node.block
+ height = node.height
+ count = node.count
+ return
+ }
// Not cached, read from database
if b, err = c.fetchBlock(node.hash); err != nil {
return
diff --git a/blockproducer/config.go b/blockproducer/config.go
index 2dea39005..4ab8c9d63 100644
--- a/blockproducer/config.go
+++ b/blockproducer/config.go
@@ -38,16 +38,18 @@ type Config struct {
Peers *proto.Peers
NodeID proto.NodeID
- ComfirmThreshold float64
+ ConfirmThreshold float64
Period time.Duration
Tick time.Duration
+
+ QPS uint32
}
// NewConfig creates new config.
func NewConfig(genesis *types.BPBlock, dataFile string,
server *rpc.Server, peers *proto.Peers,
- nodeID proto.NodeID, period time.Duration, tick time.Duration) *Config {
+ nodeID proto.NodeID, period time.Duration, tick time.Duration, qps uint32) *Config {
config := Config{
Genesis: genesis,
DataFile: dataFile,
@@ -56,6 +58,7 @@ func NewConfig(genesis *types.BPBlock, dataFile string,
NodeID: nodeID,
Period: period,
Tick: tick,
+ QPS: qps,
}
return &config
}
diff --git a/blockproducer/errors.go b/blockproducer/errors.go
index 4872d5569..f6bf6856b 100644
--- a/blockproducer/errors.go
+++ b/blockproducer/errors.go
@@ -84,4 +84,8 @@ var (
ErrInvalidPermission = errors.New("invalid permission")
// ErrMinerUserNotMatch indicates that the miner and user do not match.
ErrMinerUserNotMatch = errors.New("miner and user do not match")
+ // ErrGasPriceMismatch indicates that the gas price of miner and user do not match.
+ ErrGasPriceMismatch = errors.New("gas price mismatches")
+ // ErrInsufficientAdvancePayment indicates that the advance payment is insufficient.
+ ErrInsufficientAdvancePayment = errors.New("insufficient advance payment")
)
diff --git a/blockproducer/metastate.go b/blockproducer/metastate.go
index 71f1489ae..c62fd6ab9 100644
--- a/blockproducer/metastate.go
+++ b/blockproducer/metastate.go
@@ -18,6 +18,7 @@ package blockproducer
import (
"bytes"
+ "github.com/CovenantSQL/CovenantSQL/conf"
"sync"
"time"
@@ -817,16 +818,23 @@ func (s *metaState) updateProviderList(tx *pt.ProvideService) (err error) {
err = errors.Wrap(err, "updateProviderList failed")
return
}
- if sender != tx.Contract {
- err = errors.Wrap(ErrInvalidSender, "updateProviderList failed")
+
+ // deposit
+ var (
+ balance uint64 = 10
+ )
+ if err = s.decreaseAccountStableBalance(sender, balance); err != nil {
return
}
+
pp := pt.ProviderProfile{
Provider: sender,
Space: tx.Space,
Memory: tx.Memory,
LoadAvgPerCPU: tx.LoadAvgPerCPU,
TargetUser: tx.TargetUser,
+ Deposit: balance,
+ GasPrice: tx.GasPrice,
}
s.loadOrStoreProviderObject(sender, &providerObject{ProviderProfile: pp})
return
@@ -843,6 +851,16 @@ func (s *metaState) matchProvidersWithUser(tx *pt.CreateDatabase) (err error) {
sender.String(), tx.Owner.String())
return
}
+
+ var (
+ minAdvancePayment = uint64(tx.GasPrice) * uint64(conf.GConf.QPS) *
+ uint64(conf.GConf.Period) * uint64(len(tx.ResourceMeta.TargetMiners))
+ )
+ if tx.AdvancePayment < minAdvancePayment {
+ err = ErrInsufficientAdvancePayment
+ return
+ }
+
for i := range tx.ResourceMeta.TargetMiners {
if po, loaded := s.loadProviderObject(tx.ResourceMeta.TargetMiners[i]); !loaded {
log.WithFields(log.Fields{
@@ -860,6 +878,10 @@ func (s *metaState) matchProvidersWithUser(tx *pt.CreateDatabase) (err error) {
err = ErrMinerUserNotMatch
break
}
+ if po.GasPrice > tx.GasPrice {
+ err = ErrGasPriceMismatch
+ break
+ }
}
}
if err != nil {
@@ -878,6 +900,8 @@ func (s *metaState) matchProvidersWithUser(tx *pt.CreateDatabase) (err error) {
users[0] = &pt.SQLChainUser{
Address: sender,
Permission: pt.Admin,
+ Deposit: minAdvancePayment,
+ AdvancePayment: tx.AdvancePayment,
}
// generate genesis block
gb, err := s.generateGenesisBlock(*dbID, tx.ResourceMeta)
diff --git a/blockproducer/metastate_test.go b/blockproducer/metastate_test.go
index 46e14c880..19e50e62f 100644
--- a/blockproducer/metastate_test.go
+++ b/blockproducer/metastate_test.go
@@ -930,7 +930,6 @@ func TestMetaState(t *testing.T) {
Convey("When provider transaction is invalid", func() {
invalidPs := types.ProvideService{
ProvideServiceHeader: types.ProvideServiceHeader{
- Contract: addr2,
},
}
invalidPs.Sign(privKey1)
@@ -960,7 +959,6 @@ func TestMetaState(t *testing.T) {
Convey("When SQLChain create", func() {
ps := types.ProvideService{
ProvideServiceHeader: types.ProvideServiceHeader{
- Contract: addr2,
TargetUser: addr1,
},
}
diff --git a/blockproducer/runtime.go b/blockproducer/runtime.go
index fca1ddd64..06f38a2b6 100644
--- a/blockproducer/runtime.go
+++ b/blockproducer/runtime.go
@@ -297,7 +297,7 @@ func newRuntime(ctx context.Context, cfg *Config, accountAddress proto.AccountAd
t float64
m float64
)
- if t = cfg.ComfirmThreshold; t <= 0.0 {
+ if t = cfg.ConfirmThreshold; t <= 0.0 {
t = float64(2) / 3.0
}
if m = math.Ceil(l*t + 1); m > l {
diff --git a/cmd/cqld/bootstrap.go b/cmd/cqld/bootstrap.go
index 414f23fae..7b879eff7 100644
--- a/cmd/cqld/bootstrap.go
+++ b/cmd/cqld/bootstrap.go
@@ -155,6 +155,7 @@ func runNode(nodeID proto.NodeID, listenAddr string) (err error) {
nodeID,
time.Minute,
20*time.Second,
+ conf.GConf.QPS,
)
chain, err := bp.NewChain(chainConfig)
if err != nil {
diff --git a/conf/config.go b/conf/config.go
index 29ae8f1da..0437ba092 100644
--- a/conf/config.go
+++ b/conf/config.go
@@ -134,6 +134,9 @@ type Config struct {
KnownNodes []proto.Node `yaml:"KnownNodes"`
SeedBPNodes []proto.Node `yaml:"-"`
+
+ QPS uint32 `yaml:"QPS"`
+ Period uint32 `yaml:"Period"` // Period is for sql chain miners syncing billing with main chain
}
// GConf is the global config pointer.
diff --git a/test/GNTE/conf/node_0/config.yaml b/test/GNTE/conf/node_0/config.yaml
index 6500f1620..42d95591c 100644
--- a/test/GNTE/conf/node_0/config.yaml
+++ b/test/GNTE/conf/node_0/config.yaml
@@ -5,6 +5,8 @@ PrivateKeyFile: "private.key"
DHTFileName: "dht.db"
ListenAddr: "10.250.1.2:4661"
ThisNodeID: "00000bef611d346c0cbe1beaa76e7f0ed705a194fdf9ac3a248ec70e9c198bf9"
+QPS: 1000
+Period: 3600
ValidDNSKeys:
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
diff --git a/test/GNTE/conf/node_1/config.yaml b/test/GNTE/conf/node_1/config.yaml
index 45eef5fed..091e19210 100644
--- a/test/GNTE/conf/node_1/config.yaml
+++ b/test/GNTE/conf/node_1/config.yaml
@@ -5,6 +5,8 @@ PrivateKeyFile: "private.key"
DHTFileName: "dht.db"
ListenAddr: "10.250.1.3:4661"
ThisNodeID: "00000381d46fd6cf7742d7fb94e2422033af989c0e348b5781b3219599a3af35"
+QPS: 1000
+Period: 3600
ValidDNSKeys:
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
diff --git a/test/GNTE/conf/node_2/config.yaml b/test/GNTE/conf/node_2/config.yaml
index 65033e340..fc22190fe 100644
--- a/test/GNTE/conf/node_2/config.yaml
+++ b/test/GNTE/conf/node_2/config.yaml
@@ -5,6 +5,8 @@ PrivateKeyFile: "private.key"
DHTFileName: "dht.db"
ListenAddr: "10.250.1.4:4661"
ThisNodeID: "000000172580063ded88e010556b0aca2851265be8845b1ef397e8fce6ab5582"
+QPS: 1000
+Period: 3600
ValidDNSKeys:
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
diff --git a/test/GNTE/conf/node_c/config.yaml b/test/GNTE/conf/node_c/config.yaml
index 855607144..cdcbc6f6e 100644
--- a/test/GNTE/conf/node_c/config.yaml
+++ b/test/GNTE/conf/node_c/config.yaml
@@ -5,6 +5,8 @@ PrivateKeyFile: "private.key"
DHTFileName: "dht.db"
ListenAddr: "10.250.0.254:4661"
ThisNodeID: "00000f3b43288fe99831eb533ab77ec455d13e11fc38ec35a42d4edd17aa320d"
+QPS: 1000
+Period: 3600
ValidDNSKeys:
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
diff --git a/test/GNTE/conf/node_miner_10.250.100.2/config.yaml b/test/GNTE/conf/node_miner_10.250.100.2/config.yaml
index d4ebdf768..eaabe4036 100644
--- a/test/GNTE/conf/node_miner_10.250.100.2/config.yaml
+++ b/test/GNTE/conf/node_miner_10.250.100.2/config.yaml
@@ -5,6 +5,8 @@ PrivateKeyFile: "private.key"
DHTFileName: "dht.db"
ListenAddr: "10.250.100.2:4661"
ThisNodeID: "000005aa62048f85da4ae9698ed59c14ec0d48a88a07c15a32265634e7e64ade"
+QPS: 1000
+Period: 3600
ValidDNSKeys:
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
diff --git a/test/GNTE/conf/node_miner_10.250.100.3/config.yaml b/test/GNTE/conf/node_miner_10.250.100.3/config.yaml
index 7f4c89a70..3961db8a6 100644
--- a/test/GNTE/conf/node_miner_10.250.100.3/config.yaml
+++ b/test/GNTE/conf/node_miner_10.250.100.3/config.yaml
@@ -5,6 +5,8 @@ PrivateKeyFile: "private.key"
DHTFileName: "dht.db"
ListenAddr: "10.250.100.3:4661"
ThisNodeID: "000005f4f22c06f76c43c4f48d5a7ec1309cc94030cbf9ebae814172884ac8b5"
+QPS: 1000
+Period: 3600
ValidDNSKeys:
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
diff --git a/test/GNTE/conf/node_miner_10.250.100.4/config.yaml b/test/GNTE/conf/node_miner_10.250.100.4/config.yaml
index b770d449f..797d23d7f 100644
--- a/test/GNTE/conf/node_miner_10.250.100.4/config.yaml
+++ b/test/GNTE/conf/node_miner_10.250.100.4/config.yaml
@@ -5,6 +5,8 @@ PrivateKeyFile: "private.key"
DHTFileName: "dht.db"
ListenAddr: "10.250.100.4:4661"
ThisNodeID: "000003f49592f83d0473bddb70d543f1096b4ffed5e5f942a3117e256b7052b8"
+QPS: 1000
+Period: 3600
ValidDNSKeys:
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
diff --git a/test/GNTE/conf/node_miner_10.250.100.5/config.yaml b/test/GNTE/conf/node_miner_10.250.100.5/config.yaml
index 5b973c1b8..02c2d8e31 100755
--- a/test/GNTE/conf/node_miner_10.250.100.5/config.yaml
+++ b/test/GNTE/conf/node_miner_10.250.100.5/config.yaml
@@ -5,6 +5,8 @@ PrivateKeyFile: "private.key"
DHTFileName: "dht.db"
ListenAddr: "10.250.100.5:4661"
ThisNodeID: "00eda359cd2aa0920cdd37b083b896cb18cd26b3bd51744d1b4f127830f820f2"
+QPS: 1000
+Period: 3600
ValidDNSKeys:
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
diff --git a/test/GNTE/conf/node_miner_10.250.100.6/config.yaml b/test/GNTE/conf/node_miner_10.250.100.6/config.yaml
index a00201501..81a7eb23c 100755
--- a/test/GNTE/conf/node_miner_10.250.100.6/config.yaml
+++ b/test/GNTE/conf/node_miner_10.250.100.6/config.yaml
@@ -5,6 +5,8 @@ PrivateKeyFile: "private.key"
DHTFileName: "dht.db"
ListenAddr: "10.250.100.6:4661"
ThisNodeID: "0017017845ff9f9f7e8599d308652eb8ce480e689fbd49afb6b44cc9726cf84b"
+QPS: 1000
+Period: 3600
ValidDNSKeys:
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
diff --git a/test/GNTE/conf/node_miner_10.250.100.7/config.yaml b/test/GNTE/conf/node_miner_10.250.100.7/config.yaml
index 373995cc5..1d3077e9c 100755
--- a/test/GNTE/conf/node_miner_10.250.100.7/config.yaml
+++ b/test/GNTE/conf/node_miner_10.250.100.7/config.yaml
@@ -5,6 +5,8 @@ PrivateKeyFile: "private.key"
DHTFileName: "dht.db"
ListenAddr: "10.250.100.7:4661"
ThisNodeID: "0075b97519d0a5cf9f7269a61b82bb3e082a5e7d796604e877ee28d08491979a"
+QPS: 1000
+Period: 3600
ValidDNSKeys:
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
diff --git a/test/GNTE/conf/node_miner_10.250.100.8/config.yaml b/test/GNTE/conf/node_miner_10.250.100.8/config.yaml
index f6d23a744..22a7d329a 100755
--- a/test/GNTE/conf/node_miner_10.250.100.8/config.yaml
+++ b/test/GNTE/conf/node_miner_10.250.100.8/config.yaml
@@ -5,6 +5,8 @@ PrivateKeyFile: "private.key"
DHTFileName: "dht.db"
ListenAddr: "10.250.100.8:4661"
ThisNodeID: "0060bb3394f5185f760af690b0c124a70acbaf952fd79d794a0d394c37d7c0bc"
+QPS: 1000
+Period: 3600
ValidDNSKeys:
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
diff --git a/test/GNTE/conf/node_miner_10.250.100.9/config.yaml b/test/GNTE/conf/node_miner_10.250.100.9/config.yaml
index 222fd6b23..d592376a1 100755
--- a/test/GNTE/conf/node_miner_10.250.100.9/config.yaml
+++ b/test/GNTE/conf/node_miner_10.250.100.9/config.yaml
@@ -5,6 +5,8 @@ PrivateKeyFile: "private.key"
DHTFileName: "dht.db"
ListenAddr: "10.250.100.9:4661"
ThisNodeID: "004e5cf49e88f6e35e344f35d73ffe6232d4ebe93a63a825e171b8f6f2a88859"
+QPS: 1000
+Period: 3600
ValidDNSKeys:
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
diff --git a/test/bootstrap.yaml b/test/bootstrap.yaml
index a8daea8a2..52ded858e 100644
--- a/test/bootstrap.yaml
+++ b/test/bootstrap.yaml
@@ -5,6 +5,8 @@ PrivateKeyFile: "private.key"
DHTFileName: "dht.db"
ListenAddr: "127.0.0.1:2120"
ThisNodeID: "00000f3b43288fe99831eb533ab77ec455d13e11fc38ec35a42d4edd17aa320d"
+QPS: 1000
+Period: 3600
ValidDNSKeys:
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
diff --git a/test/fuse/node_0/config.yaml b/test/fuse/node_0/config.yaml
index a88a6ed6e..2d6154325 100644
--- a/test/fuse/node_0/config.yaml
+++ b/test/fuse/node_0/config.yaml
@@ -5,6 +5,8 @@ PrivateKeyFile: "private.key"
DHTFileName: "dht.db"
ListenAddr: "127.0.0.1:6122"
ThisNodeID: "00000bef611d346c0cbe1beaa76e7f0ed705a194fdf9ac3a248ec70e9c198bf9"
+QPS: 1000
+Period: 3600
ValidDNSKeys:
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
diff --git a/test/fuse/node_1/config.yaml b/test/fuse/node_1/config.yaml
index a751fa3ef..f4535b110 100644
--- a/test/fuse/node_1/config.yaml
+++ b/test/fuse/node_1/config.yaml
@@ -5,6 +5,8 @@ PrivateKeyFile: "private.key"
DHTFileName: "dht.db"
ListenAddr: "127.0.0.1:6121"
ThisNodeID: "00000381d46fd6cf7742d7fb94e2422033af989c0e348b5781b3219599a3af35"
+QPS: 1000
+Period: 3600
ValidDNSKeys:
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
diff --git a/test/fuse/node_2/config.yaml b/test/fuse/node_2/config.yaml
index 8a7cf4f74..07a685597 100644
--- a/test/fuse/node_2/config.yaml
+++ b/test/fuse/node_2/config.yaml
@@ -5,6 +5,8 @@ PrivateKeyFile: "private.key"
DHTFileName: "dht.db"
ListenAddr: "127.0.0.1:6120"
ThisNodeID: "000000172580063ded88e010556b0aca2851265be8845b1ef397e8fce6ab5582"
+QPS: 1000
+Period: 3600
ValidDNSKeys:
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
diff --git a/test/fuse/node_c/config.yaml b/test/fuse/node_c/config.yaml
index 10434ec43..04bfd5259 100644
--- a/test/fuse/node_c/config.yaml
+++ b/test/fuse/node_c/config.yaml
@@ -5,6 +5,8 @@ PrivateKeyFile: "private.key"
DHTFileName: "dht.db"
ListenAddr: "127.0.0.1:6120"
ThisNodeID: "00000f3b43288fe99831eb533ab77ec455d13e11fc38ec35a42d4edd17aa320d"
+QPS: 1000
+Period: 3600
ValidDNSKeys:
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
diff --git a/test/fuse/node_miner_0/config.yaml b/test/fuse/node_miner_0/config.yaml
index c374e8eb7..a288cea17 100644
--- a/test/fuse/node_miner_0/config.yaml
+++ b/test/fuse/node_miner_0/config.yaml
@@ -5,6 +5,8 @@ PrivateKeyFile: "private.key"
DHTFileName: "dht.db"
ListenAddr: "127.0.0.1:3144"
ThisNodeID: "000005aa62048f85da4ae9698ed59c14ec0d48a88a07c15a32265634e7e64ade"
+QPS: 1000
+Period: 3600
ValidDNSKeys:
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
diff --git a/test/fuse/node_miner_1/config.yaml b/test/fuse/node_miner_1/config.yaml
index 325297563..1aa958298 100644
--- a/test/fuse/node_miner_1/config.yaml
+++ b/test/fuse/node_miner_1/config.yaml
@@ -5,6 +5,8 @@ PrivateKeyFile: "private.key"
DHTFileName: "dht.db"
ListenAddr: "127.0.0.1:3145"
ThisNodeID: "000005f4f22c06f76c43c4f48d5a7ec1309cc94030cbf9ebae814172884ac8b5"
+QPS: 1000
+Period: 3600
ValidDNSKeys:
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
diff --git a/test/fuse/node_miner_2/config.yaml b/test/fuse/node_miner_2/config.yaml
index 7a30bcbe7..6cc12228d 100644
--- a/test/fuse/node_miner_2/config.yaml
+++ b/test/fuse/node_miner_2/config.yaml
@@ -5,6 +5,8 @@ PrivateKeyFile: "private.key"
DHTFileName: "dht.db"
ListenAddr: "127.0.0.1:3146"
ThisNodeID: "000003f49592f83d0473bddb70d543f1096b4ffed5e5f942a3117e256b7052b8"
+QPS: 1000
+Period: 3600
ValidDNSKeys:
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
diff --git a/test/integration/node_0/config.yaml b/test/integration/node_0/config.yaml
index 71a6090b0..f9b46f4ee 100644
--- a/test/integration/node_0/config.yaml
+++ b/test/integration/node_0/config.yaml
@@ -5,6 +5,8 @@ PrivateKeyFile: "private.key"
DHTFileName: "dht.db"
ListenAddr: "127.0.0.1:3122"
ThisNodeID: "00000bef611d346c0cbe1beaa76e7f0ed705a194fdf9ac3a248ec70e9c198bf9"
+QPS: 1000
+Period: 3600
ValidDNSKeys:
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
diff --git a/test/integration/node_1/config.yaml b/test/integration/node_1/config.yaml
index e31af64ad..279c1b5d1 100644
--- a/test/integration/node_1/config.yaml
+++ b/test/integration/node_1/config.yaml
@@ -5,6 +5,8 @@ PrivateKeyFile: "private.key"
DHTFileName: "dht.db"
ListenAddr: "127.0.0.1:3121"
ThisNodeID: "00000381d46fd6cf7742d7fb94e2422033af989c0e348b5781b3219599a3af35"
+QPS: 1000
+Period: 3600
ValidDNSKeys:
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
diff --git a/test/integration/node_2/config.yaml b/test/integration/node_2/config.yaml
index c721a05c4..6b66351a5 100644
--- a/test/integration/node_2/config.yaml
+++ b/test/integration/node_2/config.yaml
@@ -5,6 +5,8 @@ PrivateKeyFile: "private.key"
DHTFileName: "dht.db"
ListenAddr: "127.0.0.1:3120"
ThisNodeID: "000000172580063ded88e010556b0aca2851265be8845b1ef397e8fce6ab5582"
+QPS: 1000
+Period: 3600
ValidDNSKeys:
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
diff --git a/test/integration/node_c/config.yaml b/test/integration/node_c/config.yaml
index c167d29b0..3eee9a4e2 100644
--- a/test/integration/node_c/config.yaml
+++ b/test/integration/node_c/config.yaml
@@ -5,6 +5,8 @@ PrivateKeyFile: "private.key"
DHTFileName: "dht.db"
ListenAddr: "127.0.0.1:3120"
ThisNodeID: "00000f3b43288fe99831eb533ab77ec455d13e11fc38ec35a42d4edd17aa320d"
+QPS: 1000
+Period: 3600
ValidDNSKeys:
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
diff --git a/test/integration/node_miner_0/config.yaml b/test/integration/node_miner_0/config.yaml
index 8008945c0..fa0ff1d92 100644
--- a/test/integration/node_miner_0/config.yaml
+++ b/test/integration/node_miner_0/config.yaml
@@ -5,6 +5,8 @@ PrivateKeyFile: "private.key"
DHTFileName: "dht.db"
ListenAddr: "127.0.0.1:2144"
ThisNodeID: "000005aa62048f85da4ae9698ed59c14ec0d48a88a07c15a32265634e7e64ade"
+QPS: 1000
+Period: 3600
ValidDNSKeys:
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
diff --git a/test/integration/node_miner_1/config.yaml b/test/integration/node_miner_1/config.yaml
index 61a4aa5d9..4152eab91 100644
--- a/test/integration/node_miner_1/config.yaml
+++ b/test/integration/node_miner_1/config.yaml
@@ -5,6 +5,8 @@ PrivateKeyFile: "private.key"
DHTFileName: "dht.db"
ListenAddr: "127.0.0.1:2145"
ThisNodeID: "000005f4f22c06f76c43c4f48d5a7ec1309cc94030cbf9ebae814172884ac8b5"
+QPS: 1000
+Period: 3600
ValidDNSKeys:
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
diff --git a/test/integration/node_miner_2/config.yaml b/test/integration/node_miner_2/config.yaml
index 7690db035..2c8631cd4 100644
--- a/test/integration/node_miner_2/config.yaml
+++ b/test/integration/node_miner_2/config.yaml
@@ -5,6 +5,8 @@ PrivateKeyFile: "private.key"
DHTFileName: "dht.db"
ListenAddr: "127.0.0.1:2146"
ThisNodeID: "000003f49592f83d0473bddb70d543f1096b4ffed5e5f942a3117e256b7052b8"
+QPS: 1000
+Period: 3600
ValidDNSKeys:
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
diff --git a/test/leak/client.yaml b/test/leak/client.yaml
index 512d0d7bc..efbb65f73 100644
--- a/test/leak/client.yaml
+++ b/test/leak/client.yaml
@@ -5,6 +5,8 @@ PrivateKeyFile: "private.key"
DHTFileName: "dht.db"
ListenAddr: "127.0.0.1:2120"
ThisNodeID: "00000f3b43288fe99831eb533ab77ec455d13e11fc38ec35a42d4edd17aa320d"
+QPS: 1000
+Period: 3600
ValidDNSKeys:
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
diff --git a/test/leak/leader.yaml b/test/leak/leader.yaml
index ec7bb9f0b..4be5221b3 100644
--- a/test/leak/leader.yaml
+++ b/test/leak/leader.yaml
@@ -5,6 +5,8 @@ PrivateKeyFile: "./leader/private.key"
DHTFileName: "./leader/dht.db"
ListenAddr: "127.0.0.1:2331"
ThisNodeID: "00000bef611d346c0cbe1beaa76e7f0ed705a194fdf9ac3a248ec70e9c198bf9"
+QPS: 1000
+Period: 3600
ValidDNSKeys:
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
diff --git a/test/mainchain/node_0/config.yaml b/test/mainchain/node_0/config.yaml
index f63f69dfc..f28dff474 100644
--- a/test/mainchain/node_0/config.yaml
+++ b/test/mainchain/node_0/config.yaml
@@ -5,6 +5,8 @@ PrivateKeyFile: "private.key"
DHTFileName: "dht.db"
ListenAddr: "127.0.0.1:5122"
ThisNodeID: "00000bef611d346c0cbe1beaa76e7f0ed705a194fdf9ac3a248ec70e9c198bf9"
+QPS: 1000
+Period: 3600
ValidDNSKeys:
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
diff --git a/test/mainchain/node_1/config.yaml b/test/mainchain/node_1/config.yaml
index b7f0b68c2..3a8c31a9f 100644
--- a/test/mainchain/node_1/config.yaml
+++ b/test/mainchain/node_1/config.yaml
@@ -5,6 +5,8 @@ PrivateKeyFile: "private.key"
DHTFileName: "dht.db"
ListenAddr: "127.0.0.1:5121"
ThisNodeID: "00000381d46fd6cf7742d7fb94e2422033af989c0e348b5781b3219599a3af35"
+QPS: 1000
+Period: 3600
ValidDNSKeys:
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
diff --git a/test/mainchain/node_2/config.yaml b/test/mainchain/node_2/config.yaml
index e9cda2a0c..dbfd3e5d4 100644
--- a/test/mainchain/node_2/config.yaml
+++ b/test/mainchain/node_2/config.yaml
@@ -5,6 +5,8 @@ PrivateKeyFile: "private.key"
DHTFileName: "dht.db"
ListenAddr: "127.0.0.1:5120"
ThisNodeID: "000000172580063ded88e010556b0aca2851265be8845b1ef397e8fce6ab5582"
+QPS: 1000
+Period: 3600
ValidDNSKeys:
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
diff --git a/test/mainchain/node_c/config.yaml b/test/mainchain/node_c/config.yaml
index 1e52fbaaf..4c080f32f 100644
--- a/test/mainchain/node_c/config.yaml
+++ b/test/mainchain/node_c/config.yaml
@@ -5,6 +5,8 @@ PrivateKeyFile: "private.key"
DHTFileName: "dht.db"
ListenAddr: "127.0.0.1:5120"
ThisNodeID: "00000f3b43288fe99831eb533ab77ec455d13e11fc38ec35a42d4edd17aa320d"
+QPS: 1000
+Period: 3600
ValidDNSKeys:
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
diff --git a/test/mainchain/node_miner_0/config.yaml b/test/mainchain/node_miner_0/config.yaml
index 357cb4320..14c6cbc9e 100644
--- a/test/mainchain/node_miner_0/config.yaml
+++ b/test/mainchain/node_miner_0/config.yaml
@@ -5,6 +5,8 @@ PrivateKeyFile: "private.key"
DHTFileName: "dht.db"
ListenAddr: "127.0.0.1:5144"
ThisNodeID: "000005aa62048f85da4ae9698ed59c14ec0d48a88a07c15a32265634e7e64ade"
+QPS: 1000
+Period: 3600
ValidDNSKeys:
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
diff --git a/test/mainchain/node_miner_1/config.yaml b/test/mainchain/node_miner_1/config.yaml
index aeb3246a1..667fd42a8 100644
--- a/test/mainchain/node_miner_1/config.yaml
+++ b/test/mainchain/node_miner_1/config.yaml
@@ -5,6 +5,8 @@ PrivateKeyFile: "private.key"
DHTFileName: "dht.db"
ListenAddr: "127.0.0.1:5145"
ThisNodeID: "000005f4f22c06f76c43c4f48d5a7ec1309cc94030cbf9ebae814172884ac8b5"
+QPS: 1000
+Period: 3600
ValidDNSKeys:
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
diff --git a/test/mainchain/node_miner_2/config.yaml b/test/mainchain/node_miner_2/config.yaml
index 2414960c0..afdd15168 100644
--- a/test/mainchain/node_miner_2/config.yaml
+++ b/test/mainchain/node_miner_2/config.yaml
@@ -5,6 +5,8 @@ PrivateKeyFile: "private.key"
DHTFileName: "dht.db"
ListenAddr: "127.0.0.1:5146"
ThisNodeID: "000003f49592f83d0473bddb70d543f1096b4ffed5e5f942a3117e256b7052b8"
+QPS: 1000
+Period: 3600
ValidDNSKeys:
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
diff --git a/test/mainchain/node_multi_0/config.yaml b/test/mainchain/node_multi_0/config.yaml
index f2e5a89d0..ea22239f7 100644
--- a/test/mainchain/node_multi_0/config.yaml
+++ b/test/mainchain/node_multi_0/config.yaml
@@ -5,6 +5,8 @@ PrivateKeyFile: "private.key"
DHTFileName: "dht.db"
ListenAddr: "127.0.0.1:5230"
ThisNodeID: "00000bef611d346c0cbe1beaa76e7f0ed705a194fdf9ac3a248ec70e9c198bf9"
+QPS: 1000
+Period: 3600
ValidDNSKeys:
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
diff --git a/test/mainchain/node_multi_1/config.yaml b/test/mainchain/node_multi_1/config.yaml
index 7cf3a98f0..02cec0d54 100644
--- a/test/mainchain/node_multi_1/config.yaml
+++ b/test/mainchain/node_multi_1/config.yaml
@@ -5,6 +5,8 @@ PrivateKeyFile: "private.key"
DHTFileName: "dht.db"
ListenAddr: "127.0.0.1:5231"
ThisNodeID: "00000bef611d346c0cbe1beaa76e7f0ed705a194fdf9ac3a248ec70e9c198bf9"
+QPS: 1000
+Period: 3600
ValidDNSKeys:
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
diff --git a/test/mainchain/node_multi_2/config.yaml b/test/mainchain/node_multi_2/config.yaml
index 876c1738e..452b18269 100644
--- a/test/mainchain/node_multi_2/config.yaml
+++ b/test/mainchain/node_multi_2/config.yaml
@@ -5,6 +5,8 @@ PrivateKeyFile: "private.key"
DHTFileName: "dht.db"
ListenAddr: "127.0.0.1:5232"
ThisNodeID: "00000bef611d346c0cbe1beaa76e7f0ed705a194fdf9ac3a248ec70e9c198bf9"
+QPS: 1000
+Period: 3600
ValidDNSKeys:
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
diff --git a/test/mainchain/node_standalone/config.yaml b/test/mainchain/node_standalone/config.yaml
index f2e5a89d0..ea22239f7 100644
--- a/test/mainchain/node_standalone/config.yaml
+++ b/test/mainchain/node_standalone/config.yaml
@@ -5,6 +5,8 @@ PrivateKeyFile: "private.key"
DHTFileName: "dht.db"
ListenAddr: "127.0.0.1:5230"
ThisNodeID: "00000bef611d346c0cbe1beaa76e7f0ed705a194fdf9ac3a248ec70e9c198bf9"
+QPS: 1000
+Period: 3600
ValidDNSKeys:
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
diff --git a/test/node_0/config.yaml b/test/node_0/config.yaml
index c3897fa59..1f5eda745 100644
--- a/test/node_0/config.yaml
+++ b/test/node_0/config.yaml
@@ -5,6 +5,8 @@ PrivateKeyFile: "private.key"
DHTFileName: "dht.db"
ListenAddr: "127.0.0.1:2122"
ThisNodeID: "00000bef611d346c0cbe1beaa76e7f0ed705a194fdf9ac3a248ec70e9c198bf9"
+QPS: 1000
+Period: 3600
ValidDNSKeys:
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
diff --git a/test/node_1/config.yaml b/test/node_1/config.yaml
index 2c8cce4da..d9032f01b 100644
--- a/test/node_1/config.yaml
+++ b/test/node_1/config.yaml
@@ -5,6 +5,8 @@ PrivateKeyFile: "private.key"
DHTFileName: "dht.db"
ListenAddr: "127.0.0.1:2121"
ThisNodeID: "00000381d46fd6cf7742d7fb94e2422033af989c0e348b5781b3219599a3af35"
+QPS: 1000
+Period: 3600
ValidDNSKeys:
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
diff --git a/test/node_2/config.yaml b/test/node_2/config.yaml
index 43c88aaa5..a00462092 100644
--- a/test/node_2/config.yaml
+++ b/test/node_2/config.yaml
@@ -5,6 +5,8 @@ PrivateKeyFile: "private.key"
DHTFileName: "dht.db"
ListenAddr: "127.0.0.1:2120"
ThisNodeID: "000000172580063ded88e010556b0aca2851265be8845b1ef397e8fce6ab5582"
+QPS: 1000
+Period: 3600
ValidDNSKeys:
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
diff --git a/test/node_c/config.yaml b/test/node_c/config.yaml
index b5a40f0ab..63a4dffb4 100644
--- a/test/node_c/config.yaml
+++ b/test/node_c/config.yaml
@@ -5,6 +5,8 @@ PrivateKeyFile: "private.key"
DHTFileName: "dht.db"
ListenAddr: "127.0.0.1:2120"
ThisNodeID: "00000f3b43288fe99831eb533ab77ec455d13e11fc38ec35a42d4edd17aa320d"
+QPS: 1000
+Period: 3600
ValidDNSKeys:
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
diff --git a/test/node_standalone/config.yaml b/test/node_standalone/config.yaml
index bf9436a03..89d784925 100644
--- a/test/node_standalone/config.yaml
+++ b/test/node_standalone/config.yaml
@@ -5,6 +5,8 @@ PrivateKeyFile: "private.key"
DHTFileName: "dht.db"
ListenAddr: "127.0.0.1:2230"
ThisNodeID: "00000bef611d346c0cbe1beaa76e7f0ed705a194fdf9ac3a248ec70e9c198bf9"
+QPS: 1000
+Period: 3600
ValidDNSKeys:
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
diff --git a/test/node_standalone/config2.yaml b/test/node_standalone/config2.yaml
index afe26ad05..ae238c089 100644
--- a/test/node_standalone/config2.yaml
+++ b/test/node_standalone/config2.yaml
@@ -5,6 +5,8 @@ PrivateKeyFile: "private.key"
DHTFileName: "dht.db"
ListenAddr: "127.0.0.1:12230"
ThisNodeID: "00000bef611d346c0cbe1beaa76e7f0ed705a194fdf9ac3a248ec70e9c198bf9"
+QPS: 1000
+Period: 3600
ValidDNSKeys:
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
diff --git a/test/observation/node_0/config.yaml b/test/observation/node_0/config.yaml
index 60d0a5bdd..9426d2c70 100644
--- a/test/observation/node_0/config.yaml
+++ b/test/observation/node_0/config.yaml
@@ -5,6 +5,8 @@ PrivateKeyFile: "private.key"
DHTFileName: "dht.db"
ListenAddr: "127.0.0.1:4122"
ThisNodeID: "00000bef611d346c0cbe1beaa76e7f0ed705a194fdf9ac3a248ec70e9c198bf9"
+QPS: 1000
+Period: 3600
ValidDNSKeys:
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
diff --git a/test/observation/node_1/config.yaml b/test/observation/node_1/config.yaml
index c349b219a..6ff77b063 100644
--- a/test/observation/node_1/config.yaml
+++ b/test/observation/node_1/config.yaml
@@ -5,6 +5,8 @@ PrivateKeyFile: "private.key"
DHTFileName: "dht.db"
ListenAddr: "127.0.0.1:4121"
ThisNodeID: "00000381d46fd6cf7742d7fb94e2422033af989c0e348b5781b3219599a3af35"
+QPS: 1000
+Period: 3600
ValidDNSKeys:
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
diff --git a/test/observation/node_2/config.yaml b/test/observation/node_2/config.yaml
index ca1f0f475..416ba1fdd 100644
--- a/test/observation/node_2/config.yaml
+++ b/test/observation/node_2/config.yaml
@@ -5,6 +5,8 @@ PrivateKeyFile: "private.key"
DHTFileName: "dht.db"
ListenAddr: "127.0.0.1:4120"
ThisNodeID: "000000172580063ded88e010556b0aca2851265be8845b1ef397e8fce6ab5582"
+QPS: 1000
+Period: 3600
ValidDNSKeys:
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
diff --git a/test/observation/node_c/config.yaml b/test/observation/node_c/config.yaml
index 1cf22995e..26d606740 100644
--- a/test/observation/node_c/config.yaml
+++ b/test/observation/node_c/config.yaml
@@ -5,6 +5,8 @@ PrivateKeyFile: "private.key"
DHTFileName: "dht.db"
ListenAddr: "127.0.0.1:4120"
ThisNodeID: "00000f3b43288fe99831eb533ab77ec455d13e11fc38ec35a42d4edd17aa320d"
+QPS: 1000
+Period: 3600
ValidDNSKeys:
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
diff --git a/test/observation/node_miner_0/config.yaml b/test/observation/node_miner_0/config.yaml
index 16f15148e..47f203bb8 100644
--- a/test/observation/node_miner_0/config.yaml
+++ b/test/observation/node_miner_0/config.yaml
@@ -5,6 +5,8 @@ PrivateKeyFile: "private.key"
DHTFileName: "dht.db"
ListenAddr: "127.0.0.1:4144"
ThisNodeID: "000005aa62048f85da4ae9698ed59c14ec0d48a88a07c15a32265634e7e64ade"
+QPS: 1000
+Period: 3600
ValidDNSKeys:
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
diff --git a/test/observation/node_miner_1/config.yaml b/test/observation/node_miner_1/config.yaml
index cb442b22c..4aa4e8722 100644
--- a/test/observation/node_miner_1/config.yaml
+++ b/test/observation/node_miner_1/config.yaml
@@ -5,6 +5,8 @@ PrivateKeyFile: "private.key"
DHTFileName: "dht.db"
ListenAddr: "127.0.0.1:4145"
ThisNodeID: "000005f4f22c06f76c43c4f48d5a7ec1309cc94030cbf9ebae814172884ac8b5"
+QPS: 1000
+Period: 3600
ValidDNSKeys:
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
diff --git a/test/observation/node_miner_2/config.yaml b/test/observation/node_miner_2/config.yaml
index 3670c2309..5b12a8ce1 100644
--- a/test/observation/node_miner_2/config.yaml
+++ b/test/observation/node_miner_2/config.yaml
@@ -5,6 +5,8 @@ PrivateKeyFile: "private.key"
DHTFileName: "dht.db"
ListenAddr: "127.0.0.1:4146"
ThisNodeID: "000003f49592f83d0473bddb70d543f1096b4ffed5e5f942a3117e256b7052b8"
+QPS: 1000
+Period: 3600
ValidDNSKeys:
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
diff --git a/test/observation/node_observer/config.yaml b/test/observation/node_observer/config.yaml
index ecff98e3b..65d05449a 100644
--- a/test/observation/node_observer/config.yaml
+++ b/test/observation/node_observer/config.yaml
@@ -5,6 +5,8 @@ PrivateKeyFile: "private.key"
DHTFileName: "dht.db"
ListenAddr: "127.0.0.1:4123"
ThisNodeID: "0000037c786c744967bf536e58d51f24c074f14f693b1daedef88bf9efb92349"
+QPS: 1000
+Period: 3600
ValidDNSKeys:
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
diff --git a/test/pool/client.yaml b/test/pool/client.yaml
index 41b736b10..f13392735 100644
--- a/test/pool/client.yaml
+++ b/test/pool/client.yaml
@@ -5,6 +5,8 @@ PrivateKeyFile: "private.key"
DHTFileName: "dht.db"
ListenAddr: "127.0.0.1:2520"
ThisNodeID: "00000f3b43288fe99831eb533ab77ec455d13e11fc38ec35a42d4edd17aa320d"
+QPS: 1000
+Period: 3600
ValidDNSKeys:
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
diff --git a/test/pool/leader.yaml b/test/pool/leader.yaml
index 958dcc9b7..65e388daa 100644
--- a/test/pool/leader.yaml
+++ b/test/pool/leader.yaml
@@ -5,6 +5,8 @@ PrivateKeyFile: "private.key"
DHTFileName: "dht.db"
ListenAddr: "127.0.0.1:2530"
ThisNodeID: "00000bef611d346c0cbe1beaa76e7f0ed705a194fdf9ac3a248ec70e9c198bf9"
+QPS: 1000
+Period: 3600
ValidDNSKeys:
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
diff --git a/test/service/node_0/config.yaml b/test/service/node_0/config.yaml
index dd57bc509..438171132 100644
--- a/test/service/node_0/config.yaml
+++ b/test/service/node_0/config.yaml
@@ -5,6 +5,8 @@ PrivateKeyFile: "private.key"
DHTFileName: "dht.db"
ListenAddr: "172.254.1.2:4661"
ThisNodeID: "00000bef611d346c0cbe1beaa76e7f0ed705a194fdf9ac3a248ec70e9c198bf9"
+QPS: 1000
+Period: 3600
ValidDNSKeys:
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
diff --git a/test/service/node_1/config.yaml b/test/service/node_1/config.yaml
index 3ca889f83..a9a85f99b 100644
--- a/test/service/node_1/config.yaml
+++ b/test/service/node_1/config.yaml
@@ -5,6 +5,8 @@ PrivateKeyFile: "private.key"
DHTFileName: "dht.db"
ListenAddr: "172.254.1.3:4661"
ThisNodeID: "00000381d46fd6cf7742d7fb94e2422033af989c0e348b5781b3219599a3af35"
+QPS: 1000
+Period: 3600
ValidDNSKeys:
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
diff --git a/test/service/node_2/config.yaml b/test/service/node_2/config.yaml
index ad0b79f38..7108bb939 100644
--- a/test/service/node_2/config.yaml
+++ b/test/service/node_2/config.yaml
@@ -5,6 +5,8 @@ PrivateKeyFile: "private.key"
DHTFileName: "dht.db"
ListenAddr: "172.254.1.4:4661"
ThisNodeID: "000000172580063ded88e010556b0aca2851265be8845b1ef397e8fce6ab5582"
+QPS: 1000
+Period: 3600
ValidDNSKeys:
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
diff --git a/test/service/node_adapter/config.yaml b/test/service/node_adapter/config.yaml
index 330d0c0ed..1a6087e5e 100644
--- a/test/service/node_adapter/config.yaml
+++ b/test/service/node_adapter/config.yaml
@@ -5,6 +5,8 @@ PrivateKeyFile: "private.key"
DHTFileName: "dht.db"
ListenAddr: "172.254.1.4:4661"
ThisNodeID: "00000f3b43288fe99831eb533ab77ec455d13e11fc38ec35a42d4edd17aa320d"
+QPS: 1000
+Period: 3600
ValidDNSKeys:
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
diff --git a/test/service/node_c/config.yaml b/test/service/node_c/config.yaml
index 330d0c0ed..1a6087e5e 100644
--- a/test/service/node_c/config.yaml
+++ b/test/service/node_c/config.yaml
@@ -5,6 +5,8 @@ PrivateKeyFile: "private.key"
DHTFileName: "dht.db"
ListenAddr: "172.254.1.4:4661"
ThisNodeID: "00000f3b43288fe99831eb533ab77ec455d13e11fc38ec35a42d4edd17aa320d"
+QPS: 1000
+Period: 3600
ValidDNSKeys:
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
diff --git a/test/service/node_miner_0/config.yaml b/test/service/node_miner_0/config.yaml
index 5e12f7b45..e9be364da 100644
--- a/test/service/node_miner_0/config.yaml
+++ b/test/service/node_miner_0/config.yaml
@@ -5,6 +5,8 @@ PrivateKeyFile: "private.key"
DHTFileName: "dht.db"
ListenAddr: "172.254.1.5:4661"
ThisNodeID: "000005aa62048f85da4ae9698ed59c14ec0d48a88a07c15a32265634e7e64ade"
+QPS: 1000
+Period: 3600
ValidDNSKeys:
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
diff --git a/test/service/node_miner_1/config.yaml b/test/service/node_miner_1/config.yaml
index af7a115d6..1f187a4cc 100644
--- a/test/service/node_miner_1/config.yaml
+++ b/test/service/node_miner_1/config.yaml
@@ -5,6 +5,8 @@ PrivateKeyFile: "private.key"
DHTFileName: "dht.db"
ListenAddr: "172.254.1.6:4661"
ThisNodeID: "000005f4f22c06f76c43c4f48d5a7ec1309cc94030cbf9ebae814172884ac8b5"
+QPS: 1000
+Period: 3600
ValidDNSKeys:
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
diff --git a/test/service/node_miner_2/config.yaml b/test/service/node_miner_2/config.yaml
index 10cd6eee8..e3ee1f827 100644
--- a/test/service/node_miner_2/config.yaml
+++ b/test/service/node_miner_2/config.yaml
@@ -5,6 +5,8 @@ PrivateKeyFile: "private.key"
DHTFileName: "dht.db"
ListenAddr: "172.254.1.7:4661"
ThisNodeID: "000003f49592f83d0473bddb70d543f1096b4ffed5e5f942a3117e256b7052b8"
+QPS: 1000
+Period: 3600
ValidDNSKeys:
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
diff --git a/test/service/node_mysql_adapter/config.yaml b/test/service/node_mysql_adapter/config.yaml
index 65ee180e1..ae3edbda5 100644
--- a/test/service/node_mysql_adapter/config.yaml
+++ b/test/service/node_mysql_adapter/config.yaml
@@ -5,6 +5,8 @@ PrivateKeyFile: "private.key"
DHTFileName: "dht.db"
ListenAddr: "172.254.1.4:4661"
ThisNodeID: "00000f3b43288fe99831eb533ab77ec455d13e11fc38ec35a42d4edd17aa320d"
+QPS: 1000
+Period: 3600
ValidDNSKeys:
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
diff --git a/test/service/node_observer/config.yaml b/test/service/node_observer/config.yaml
index 3f1a8d884..f7e6af029 100644
--- a/test/service/node_observer/config.yaml
+++ b/test/service/node_observer/config.yaml
@@ -5,6 +5,8 @@ PrivateKeyFile: "private.key"
DHTFileName: "dht.db"
ListenAddr: "172.254.1.9:4661"
ThisNodeID: "0000037c786c744967bf536e58d51f24c074f14f693b1daedef88bf9efb92349"
+QPS: 1000
+Period: 3600
ValidDNSKeys:
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
diff --git a/types/account.go b/types/account.go
index f3840c1dc..346ca6be4 100644
--- a/types/account.go
+++ b/types/account.go
@@ -71,7 +71,7 @@ type SQLChainUser struct {
Permission UserPermission
AdvancePayment uint64
Arrears uint64
- Pledge uint64
+ Deposit uint64
Status Status
}
@@ -111,6 +111,9 @@ type ProviderProfile struct {
Memory uint64 // reserved memory in bytes
LoadAvgPerCPU uint64 // max loadAvg15 per CPU
TargetUser proto.AccountAddress
+ Deposit uint64 // default 10 Particle
+ GasPrice uint64
+ TokenType TokenType // default Particle
}
// Account store its balance, and other mate data.
diff --git a/types/account_gen.go b/types/account_gen.go
index aa51ff8d6..cffef3709 100644
--- a/types/account_gen.go
+++ b/types/account_gen.go
@@ -75,31 +75,41 @@ func (z *MinerInfo) Msgsize() (s int) {
func (z *ProviderProfile) MarshalHash() (o []byte, err error) {
var b []byte
o = hsp.Require(b, z.Msgsize())
- // map header, size 5
- o = append(o, 0x85, 0x85)
+ // map header, size 8
+ o = append(o, 0x88, 0x88)
+ if oTemp, err := z.TokenType.MarshalHash(); err != nil {
+ return nil, err
+ } else {
+ o = hsp.AppendBytes(o, oTemp)
+ }
+ o = append(o, 0x88)
if oTemp, err := z.Provider.MarshalHash(); err != nil {
return nil, err
} else {
o = hsp.AppendBytes(o, oTemp)
}
- o = append(o, 0x85)
+ o = append(o, 0x88)
if oTemp, err := z.TargetUser.MarshalHash(); err != nil {
return nil, err
} else {
o = hsp.AppendBytes(o, oTemp)
}
- o = append(o, 0x85)
- o = hsp.AppendUint64(o, z.Space)
- o = append(o, 0x85)
+ o = append(o, 0x88)
o = hsp.AppendUint64(o, z.Memory)
- o = append(o, 0x85)
+ o = append(o, 0x88)
o = hsp.AppendUint64(o, z.LoadAvgPerCPU)
+ o = append(o, 0x88)
+ o = hsp.AppendUint64(o, z.Deposit)
+ o = append(o, 0x88)
+ o = hsp.AppendUint64(o, z.GasPrice)
+ o = append(o, 0x88)
+ o = hsp.AppendUint64(o, z.Space)
return
}
// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (z *ProviderProfile) Msgsize() (s int) {
- s = 1 + 9 + z.Provider.Msgsize() + 11 + z.TargetUser.Msgsize() + 6 + hsp.Uint64Size + 7 + hsp.Uint64Size + 14 + hsp.Uint64Size
+ s = 1 + 10 + z.TokenType.Msgsize() + 9 + z.Provider.Msgsize() + 11 + z.TargetUser.Msgsize() + 7 + hsp.Uint64Size + 14 + hsp.Uint64Size + 8 + hsp.Uint64Size + 9 + hsp.Uint64Size + 6 + hsp.Uint64Size
return
}
@@ -237,13 +247,13 @@ func (z *SQLChainUser) MarshalHash() (o []byte, err error) {
o = append(o, 0x86)
o = hsp.AppendUint64(o, z.Arrears)
o = append(o, 0x86)
- o = hsp.AppendUint64(o, z.Pledge)
+ o = hsp.AppendUint64(o, z.Deposit)
return
}
// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (z *SQLChainUser) Msgsize() (s int) {
- s = 1 + 7 + hsp.Int32Size + 11 + hsp.Int32Size + 8 + z.Address.Msgsize() + 15 + hsp.Uint64Size + 8 + hsp.Uint64Size + 7 + hsp.Uint64Size
+ s = 1 + 7 + hsp.Int32Size + 11 + hsp.Int32Size + 8 + z.Address.Msgsize() + 15 + hsp.Uint64Size + 8 + hsp.Uint64Size + 8 + hsp.Uint64Size
return
}
diff --git a/types/createdb.go b/types/createdb.go
index 87c49d4ad..a7cf48a1c 100644
--- a/types/createdb.go
+++ b/types/createdb.go
@@ -30,6 +30,9 @@ import (
type CreateDatabaseHeader struct {
Owner proto.AccountAddress
ResourceMeta ResourceMeta
+ GasPrice uint64
+ AdvancePayment uint64
+ TokenType TokenType
Nonce pi.AccountNonce
}
diff --git a/types/createdb_gen.go b/types/createdb_gen.go
index 1728df429..f72127991 100644
--- a/types/createdb_gen.go
+++ b/types/createdb_gen.go
@@ -11,21 +11,8 @@ func (z *CreateDatabase) MarshalHash() (o []byte, err error) {
var b []byte
o = hsp.Require(b, z.Msgsize())
// map header, size 3
- // map header, size 3
- o = append(o, 0x83, 0x83, 0x83, 0x83)
- if oTemp, err := z.CreateDatabaseHeader.Owner.MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
- }
- o = append(o, 0x83)
- if oTemp, err := z.CreateDatabaseHeader.ResourceMeta.MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
- }
- o = append(o, 0x83)
- if oTemp, err := z.CreateDatabaseHeader.Nonce.MarshalHash(); err != nil {
+ o = append(o, 0x83, 0x83)
+ if oTemp, err := z.CreateDatabaseHeader.MarshalHash(); err != nil {
return nil, err
} else {
o = hsp.AppendBytes(o, oTemp)
@@ -47,7 +34,7 @@ func (z *CreateDatabase) MarshalHash() (o []byte, err error) {
// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (z *CreateDatabase) Msgsize() (s int) {
- s = 1 + 21 + 1 + 6 + z.CreateDatabaseHeader.Owner.Msgsize() + 13 + z.CreateDatabaseHeader.ResourceMeta.Msgsize() + 6 + z.CreateDatabaseHeader.Nonce.Msgsize() + 21 + z.TransactionTypeMixin.Msgsize() + 28 + z.DefaultHashSignVerifierImpl.Msgsize()
+ s = 1 + 21 + z.CreateDatabaseHeader.Msgsize() + 21 + z.TransactionTypeMixin.Msgsize() + 28 + z.DefaultHashSignVerifierImpl.Msgsize()
return
}
@@ -55,30 +42,40 @@ func (z *CreateDatabase) Msgsize() (s int) {
func (z *CreateDatabaseHeader) MarshalHash() (o []byte, err error) {
var b []byte
o = hsp.Require(b, z.Msgsize())
- // map header, size 3
- o = append(o, 0x83, 0x83)
+ // map header, size 6
+ o = append(o, 0x86, 0x86)
if oTemp, err := z.ResourceMeta.MarshalHash(); err != nil {
return nil, err
} else {
o = hsp.AppendBytes(o, oTemp)
}
- o = append(o, 0x83)
+ o = append(o, 0x86)
+ if oTemp, err := z.TokenType.MarshalHash(); err != nil {
+ return nil, err
+ } else {
+ o = hsp.AppendBytes(o, oTemp)
+ }
+ o = append(o, 0x86)
if oTemp, err := z.Nonce.MarshalHash(); err != nil {
return nil, err
} else {
o = hsp.AppendBytes(o, oTemp)
}
- o = append(o, 0x83)
+ o = append(o, 0x86)
if oTemp, err := z.Owner.MarshalHash(); err != nil {
return nil, err
} else {
o = hsp.AppendBytes(o, oTemp)
}
+ o = append(o, 0x86)
+ o = hsp.AppendUint64(o, z.GasPrice)
+ o = append(o, 0x86)
+ o = hsp.AppendUint64(o, z.AdvancePayment)
return
}
// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (z *CreateDatabaseHeader) Msgsize() (s int) {
- s = 1 + 13 + z.ResourceMeta.Msgsize() + 6 + z.Nonce.Msgsize() + 6 + z.Owner.Msgsize()
+ s = 1 + 13 + z.ResourceMeta.Msgsize() + 10 + z.TokenType.Msgsize() + 6 + z.Nonce.Msgsize() + 6 + z.Owner.Msgsize() + 9 + hsp.Uint64Size + 15 + hsp.Uint64Size
return
}
diff --git a/types/init_service_type_gen.go b/types/init_service_type_gen.go
index 7ff4eb63a..27008aa2e 100644
--- a/types/init_service_type_gen.go
+++ b/types/init_service_type_gen.go
@@ -31,19 +31,8 @@ func (z *InitServiceResponse) MarshalHash() (o []byte, err error) {
var b []byte
o = hsp.Require(b, z.Msgsize())
// map header, size 1
- // map header, size 2
- // map header, size 1
- o = append(o, 0x81, 0x81, 0x82, 0x82, 0x81, 0x81)
- o = hsp.AppendArrayHeader(o, uint32(len(z.Header.InitServiceResponseHeader.Instances)))
- for za0001 := range z.Header.InitServiceResponseHeader.Instances {
- if oTemp, err := z.Header.InitServiceResponseHeader.Instances[za0001].MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
- }
- }
- o = append(o, 0x82)
- if oTemp, err := z.Header.DefaultHashSignVerifierImpl.MarshalHash(); err != nil {
+ o = append(o, 0x81, 0x81)
+ if oTemp, err := z.Header.MarshalHash(); err != nil {
return nil, err
} else {
o = hsp.AppendBytes(o, oTemp)
@@ -53,11 +42,7 @@ func (z *InitServiceResponse) MarshalHash() (o []byte, err error) {
// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (z *InitServiceResponse) Msgsize() (s int) {
- s = 1 + 7 + 1 + 26 + 1 + 10 + hsp.ArrayHeaderSize
- for za0001 := range z.Header.InitServiceResponseHeader.Instances {
- s += z.Header.InitServiceResponseHeader.Instances[za0001].Msgsize()
- }
- s += 28 + z.Header.DefaultHashSignVerifierImpl.Msgsize()
+ s = 1 + 7 + z.Header.Msgsize()
return
}
diff --git a/types/no_ack_report_type_gen.go b/types/no_ack_report_type_gen.go
index e9e89abc6..daedbcdf6 100644
--- a/types/no_ack_report_type_gen.go
+++ b/types/no_ack_report_type_gen.go
@@ -57,7 +57,24 @@ func (z *AggrNoAckReportHeader) MarshalHash() (o []byte, err error) {
o = append(o, 0x84)
o = hsp.AppendArrayHeader(o, uint32(len(z.Reports)))
for za0001 := range z.Reports {
- if oTemp, err := z.Reports[za0001].MarshalHash(); err != nil {
+ // map header, size 2
+ // map header, size 3
+ o = append(o, 0x82, 0x82, 0x83, 0x83)
+ if oTemp, err := z.Reports[za0001].NoAckReportHeader.NodeID.MarshalHash(); err != nil {
+ return nil, err
+ } else {
+ o = hsp.AppendBytes(o, oTemp)
+ }
+ o = append(o, 0x83)
+ o = hsp.AppendTime(o, z.Reports[za0001].NoAckReportHeader.Timestamp)
+ o = append(o, 0x83)
+ if oTemp, err := z.Reports[za0001].NoAckReportHeader.Response.MarshalHash(); err != nil {
+ return nil, err
+ } else {
+ o = hsp.AppendBytes(o, oTemp)
+ }
+ o = append(o, 0x82)
+ if oTemp, err := z.Reports[za0001].DefaultHashSignVerifierImpl.MarshalHash(); err != nil {
return nil, err
} else {
o = hsp.AppendBytes(o, oTemp)
@@ -84,7 +101,7 @@ func (z *AggrNoAckReportHeader) Msgsize() (s int) {
}
s += 8 + hsp.ArrayHeaderSize
for za0001 := range z.Reports {
- s += z.Reports[za0001].Msgsize()
+ s += 1 + 18 + 1 + 7 + z.Reports[za0001].NoAckReportHeader.NodeID.Msgsize() + 10 + hsp.TimeSize + 9 + z.Reports[za0001].NoAckReportHeader.Response.Msgsize() + 28 + z.Reports[za0001].DefaultHashSignVerifierImpl.Msgsize()
}
s += 7 + z.NodeID.Msgsize() + 10 + hsp.TimeSize
return
@@ -95,8 +112,24 @@ func (z *NoAckReport) MarshalHash() (o []byte, err error) {
var b []byte
o = hsp.Require(b, z.Msgsize())
// map header, size 2
- o = append(o, 0x82, 0x82)
- if oTemp, err := z.Header.MarshalHash(); err != nil {
+ // map header, size 2
+ // map header, size 3
+ o = append(o, 0x82, 0x82, 0x82, 0x82, 0x83, 0x83)
+ if oTemp, err := z.Header.NoAckReportHeader.NodeID.MarshalHash(); err != nil {
+ return nil, err
+ } else {
+ o = hsp.AppendBytes(o, oTemp)
+ }
+ o = append(o, 0x83)
+ o = hsp.AppendTime(o, z.Header.NoAckReportHeader.Timestamp)
+ o = append(o, 0x83)
+ if oTemp, err := z.Header.NoAckReportHeader.Response.MarshalHash(); err != nil {
+ return nil, err
+ } else {
+ o = hsp.AppendBytes(o, oTemp)
+ }
+ o = append(o, 0x82)
+ if oTemp, err := z.Header.DefaultHashSignVerifierImpl.MarshalHash(); err != nil {
return nil, err
} else {
o = hsp.AppendBytes(o, oTemp)
@@ -112,7 +145,7 @@ func (z *NoAckReport) MarshalHash() (o []byte, err error) {
// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (z *NoAckReport) Msgsize() (s int) {
- s = 1 + 7 + z.Header.Msgsize() + 9 + z.Envelope.Msgsize()
+ s = 1 + 7 + 1 + 18 + 1 + 7 + z.Header.NoAckReportHeader.NodeID.Msgsize() + 10 + hsp.TimeSize + 9 + z.Header.NoAckReportHeader.Response.Msgsize() + 28 + z.Header.DefaultHashSignVerifierImpl.Msgsize() + 9 + z.Envelope.Msgsize()
return
}
diff --git a/types/provideservice.go b/types/provideservice.go
index 9fcd23adc..50698df82 100644
--- a/types/provideservice.go
+++ b/types/provideservice.go
@@ -28,11 +28,12 @@ import (
// ProvideServiceHeader define the miner providing service transaction header.
type ProvideServiceHeader struct {
- Contract proto.AccountAddress
Space uint64 // reserved storage space in bytes
Memory uint64 // reserved memory in bytes
LoadAvgPerCPU uint64 // max loadAvg15 per CPU
TargetUser proto.AccountAddress
+ GasPrice uint64
+ TokenType TokenType
Nonce interfaces.AccountNonce
}
diff --git a/types/provideservice_gen.go b/types/provideservice_gen.go
index fe1ec511d..d1528f271 100644
--- a/types/provideservice_gen.go
+++ b/types/provideservice_gen.go
@@ -42,36 +42,38 @@ func (z *ProvideService) Msgsize() (s int) {
func (z *ProvideServiceHeader) MarshalHash() (o []byte, err error) {
var b []byte
o = hsp.Require(b, z.Msgsize())
- // map header, size 6
- o = append(o, 0x86, 0x86)
- if oTemp, err := z.Nonce.MarshalHash(); err != nil {
+ // map header, size 7
+ o = append(o, 0x87, 0x87)
+ if oTemp, err := z.TokenType.MarshalHash(); err != nil {
return nil, err
} else {
o = hsp.AppendBytes(o, oTemp)
}
- o = append(o, 0x86)
- if oTemp, err := z.Contract.MarshalHash(); err != nil {
+ o = append(o, 0x87)
+ if oTemp, err := z.Nonce.MarshalHash(); err != nil {
return nil, err
} else {
o = hsp.AppendBytes(o, oTemp)
}
- o = append(o, 0x86)
+ o = append(o, 0x87)
if oTemp, err := z.TargetUser.MarshalHash(); err != nil {
return nil, err
} else {
o = hsp.AppendBytes(o, oTemp)
}
- o = append(o, 0x86)
- o = hsp.AppendUint64(o, z.Space)
- o = append(o, 0x86)
+ o = append(o, 0x87)
o = hsp.AppendUint64(o, z.Memory)
- o = append(o, 0x86)
+ o = append(o, 0x87)
o = hsp.AppendUint64(o, z.LoadAvgPerCPU)
+ o = append(o, 0x87)
+ o = hsp.AppendUint64(o, z.GasPrice)
+ o = append(o, 0x87)
+ o = hsp.AppendUint64(o, z.Space)
return
}
// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (z *ProvideServiceHeader) Msgsize() (s int) {
- s = 1 + 6 + z.Nonce.Msgsize() + 9 + z.Contract.Msgsize() + 11 + z.TargetUser.Msgsize() + 6 + hsp.Uint64Size + 7 + hsp.Uint64Size + 14 + hsp.Uint64Size
+ s = 1 + 10 + z.TokenType.Msgsize() + 6 + z.Nonce.Msgsize() + 11 + z.TargetUser.Msgsize() + 7 + hsp.Uint64Size + 14 + hsp.Uint64Size + 9 + hsp.Uint64Size + 6 + hsp.Uint64Size
return
}
diff --git a/types/request_type_gen.go b/types/request_type_gen.go
index 7033d7aa6..709e66bb9 100644
--- a/types/request_type_gen.go
+++ b/types/request_type_gen.go
@@ -106,20 +106,10 @@ func (z *Request) MarshalHash() (o []byte, err error) {
o = append(o, 0x83, 0x83, 0x81, 0x81)
o = hsp.AppendArrayHeader(o, uint32(len(z.Payload.Queries)))
for za0001 := range z.Payload.Queries {
- // map header, size 2
- o = append(o, 0x82, 0x82)
- o = hsp.AppendString(o, z.Payload.Queries[za0001].Pattern)
- o = append(o, 0x82)
- o = hsp.AppendArrayHeader(o, uint32(len(z.Payload.Queries[za0001].Args)))
- for za0002 := range z.Payload.Queries[za0001].Args {
- // map header, size 2
- o = append(o, 0x82, 0x82)
- o = hsp.AppendString(o, z.Payload.Queries[za0001].Args[za0002].Name)
- o = append(o, 0x82)
- o, err = hsp.AppendIntf(o, z.Payload.Queries[za0001].Args[za0002].Value)
- if err != nil {
- return
- }
+ if oTemp, err := z.Payload.Queries[za0001].MarshalHash(); err != nil {
+ return nil, err
+ } else {
+ o = hsp.AppendBytes(o, oTemp)
}
}
// map header, size 2
@@ -148,10 +138,7 @@ func (z *Request) MarshalHash() (o []byte, err error) {
func (z *Request) Msgsize() (s int) {
s = 1 + 8 + 1 + 8 + hsp.ArrayHeaderSize
for za0001 := range z.Payload.Queries {
- s += 1 + 8 + hsp.StringPrefixSize + len(z.Payload.Queries[za0001].Pattern) + 5 + hsp.ArrayHeaderSize
- for za0002 := range z.Payload.Queries[za0001].Args {
- s += 1 + 5 + hsp.StringPrefixSize + len(z.Payload.Queries[za0001].Args[za0002].Name) + 6 + hsp.GuessSize(z.Payload.Queries[za0001].Args[za0002].Value)
- }
+ s += z.Payload.Queries[za0001].Msgsize()
}
s += 7 + 1 + 14 + z.Header.RequestHeader.Msgsize() + 28 + z.Header.DefaultHashSignVerifierImpl.Msgsize() + 9 + z.Envelope.Msgsize()
return
From e80e8d7b60f6bf70173a9f91da98f0161e38746d Mon Sep 17 00:00:00 2001
From: leventeliu
Date: Wed, 12 Dec 2018 10:56:22 +0800
Subject: [PATCH 042/278] Refactor runtime constructor
---
blockproducer/chain.go | 92 +++++++++++++---------------------------
blockproducer/runtime.go | 50 +++++++++++++---------
blockproducer/storage.go | 4 +-
3 files changed, 63 insertions(+), 83 deletions(-)
diff --git a/blockproducer/chain.go b/blockproducer/chain.go
index 6ca0978c3..b1fa06e7f 100644
--- a/blockproducer/chain.go
+++ b/blockproducer/chain.go
@@ -66,81 +66,49 @@ type Chain struct {
// NewChain creates a new blockchain.
func NewChain(cfg *Config) (c *Chain, err error) {
- if fi, err := os.Stat(cfg.DataFile); err == nil && fi.Mode().IsRegular() {
- return LoadChain(cfg)
- }
-
var (
+ existed bool
+
+ st xi.Storage
+ irre *blockNode
+ heads []*blockNode
+ immutable *metaState
+ txPool map[hash.Hash]pi.Transaction
+
+ addr proto.AccountAddress
+ pubKey *asymmetric.PublicKey
+
+ inst *Chain
+ rt *rt
bus = chainbus.New()
caller = rpc.NewCaller()
ctx = context.Background()
- pubKey *asymmetric.PublicKey
- st xi.Storage
- addr proto.AccountAddress
- inst *Chain
)
- // Open storage
- if st, err = openStorage(fmt.Sprintf("file:%s", cfg.DataFile)); err != nil {
- return
+ if fi, err := os.Stat(cfg.DataFile); err == nil && fi.Mode().IsRegular() {
+ existed = true
}
- // get accountAddress
- if pubKey, err = kms.GetLocalPublicKey(); err != nil {
- return
- }
- if addr, err = crypto.PubKeyHash(pubKey); err != nil {
+ // Open storage
+ if st, err = openStorage(fmt.Sprintf("file:%s", cfg.DataFile)); err != nil {
return
}
- // create chain
- inst = &Chain{
- ctx: ctx,
- rt: newRuntime(ctx, cfg, addr),
- st: st,
- cl: caller,
- bs: bus,
-
- pendingBlocks: make(chan *types.BPBlock),
- pendingTxs: make(chan pi.Transaction),
- }
-
- // Push genesis block
- if err = inst.pushGenesisBlock(cfg.Genesis); err != nil {
- return
+ // Storage genesis
+ if !existed {
+ if err = store(st, []storageProcedure{
+ updateIrreversible(cfg.Genesis.SignedHeader.BlockHash),
+ addBlock(0, cfg.Genesis),
+ }, nil); err != nil {
+ return
+ }
}
- log.WithFields(log.Fields{
- "index": inst.rt.locSvIndex,
- "bp_number": inst.rt.serversNum,
- "period": inst.rt.period.String(),
- "tick": inst.rt.tick.String(),
- "height": inst.rt.head().height,
- }).Debug("current chain state")
-
- // sub chain events
- inst.bs.Subscribe(txEvent, inst.addTx)
-
- c = inst
- return
-}
-
-// LoadChain rebuilds the chain from db.
-func LoadChain(cfg *Config) (c *Chain, err error) {
- var (
- bus = chainbus.New()
- caller = rpc.NewCaller()
- ctx = context.Background()
- pubKey *asymmetric.PublicKey
- st xi.Storage
- addr proto.AccountAddress
- inst *Chain
- )
-
- // Open storage
- if st, err = openStorage(fmt.Sprintf("file:%s", cfg.DataFile)); err != nil {
+ // Load and create runtime
+ if irre, heads, immutable, txPool, err = loadDatabase(st); err != nil {
return
}
+ rt = newRuntime(ctx, cfg, addr, irre, heads, immutable, txPool)
// get accountAddress
if pubKey, err = kms.GetLocalPublicKey(); err != nil {
@@ -153,7 +121,7 @@ func LoadChain(cfg *Config) (c *Chain, err error) {
// create chain
inst = &Chain{
ctx: ctx,
- rt: newRuntime(ctx, cfg, addr),
+ rt: rt,
st: st,
cl: caller,
bs: bus,
@@ -162,8 +130,6 @@ func LoadChain(cfg *Config) (c *Chain, err error) {
pendingTxs: make(chan pi.Transaction),
}
- // Load chain state from database
-
log.WithFields(log.Fields{
"index": inst.rt.locSvIndex,
"bp_number": inst.rt.serversNum,
diff --git a/blockproducer/runtime.go b/blockproducer/runtime.go
index 209b4f4db..a90521cff 100644
--- a/blockproducer/runtime.go
+++ b/blockproducer/runtime.go
@@ -63,23 +63,23 @@ type rt struct {
txPool map[hash.Hash]pi.Transaction
}
-func newRuntime(ctx context.Context, cfg *Config, accountAddress proto.AccountAddress) *rt {
+func newRuntime(
+ ctx context.Context, cfg *Config, accountAddress proto.AccountAddress,
+ irre *blockNode, heads []*blockNode, immutable *metaState, txPool map[hash.Hash]pi.Transaction,
+) *rt {
var index uint32
for i, s := range cfg.Peers.Servers {
if cfg.NodeID.IsEqual(&s) {
index = uint32(i)
}
}
+
var (
cld, ccl = context.WithCancel(ctx)
l = float64(len(cfg.Peers.Servers))
t float64
m float64
err error
-
- genesis = newBlockNodeEx(0, cfg.Genesis, nil)
- immutable = newMetaState()
- headBranch *branch
)
if t = cfg.ComfirmThreshold; t <= 0.0 {
t = float64(2) / 3.0
@@ -87,18 +87,30 @@ func newRuntime(ctx context.Context, cfg *Config, accountAddress proto.AccountAd
if m = math.Ceil(l*t + 1); m > l {
m = l
}
- for _, tx := range genesis.block.Transactions {
- if err = immutable.apply(tx); err != nil {
- log.WithError(err).Fatal("Failed to initialize immutable state from genesis")
+
+ // Rebuild branches
+ var (
+ branches []*branch
+ br, head *branch
+ headIndex int
+ )
+ for _, v := range heads {
+ if v.hasAncestor(irre) {
+ if v.hasAncestor(irre) {
+ if br, err = fork(irre, v, immutable, txPool); err != nil {
+ log.WithError(err).Fatal("Failed to rebuild branch")
+ }
+ branches = append(branches, br)
+ }
}
}
- immutable.commit()
- headBranch = &branch{
- head: genesis,
- preview: immutable.makeCopy(),
- packed: make(map[hash.Hash]pi.Transaction),
- unpacked: make(map[hash.Hash]pi.Transaction),
+ for i, v := range branches {
+ if v.head.count > branches[headIndex].head.count {
+ headIndex = i
+ head = v
+ }
}
+
return &rt{
ctx: cld,
cancel: ccl,
@@ -118,12 +130,12 @@ func newRuntime(ctx context.Context, cfg *Config, accountAddress proto.AccountAd
nextTurn: 1,
offset: time.Duration(0),
- lastIrre: genesis,
+ lastIrre: irre,
immutable: immutable,
- headIndex: 0,
- headBranch: headBranch,
- branches: []*branch{headBranch},
- txPool: make(map[hash.Hash]pi.Transaction),
+ headIndex: headIndex,
+ headBranch: head,
+ branches: branches,
+ txPool: txPool,
}
}
diff --git a/blockproducer/storage.go b/blockproducer/storage.go
index 650cae327..9e5318ced 100644
--- a/blockproducer/storage.go
+++ b/blockproducer/storage.go
@@ -88,7 +88,9 @@ func store(st xi.Storage, sps []storageProcedure, cb storageCallback) (err error
}
}
// CALLBACK: MUST NOT FAIL
- cb()
+ if cb != nil {
+ cb()
+ }
// COMMIT
if err = tx.Commit(); err != nil {
log.WithError(err).Fatalf("Failed to commit storage transaction")
From 658ecc9a27ee8275283c9360cb63d2cb7f011953 Mon Sep 17 00:00:00 2001
From: leventeliu
Date: Wed, 12 Dec 2018 12:04:08 +0800
Subject: [PATCH 043/278] Add block node testing
---
blockproducer/blocknode.go | 42 +------
blockproducer/blocknode_test.go | 194 +++++++++++++++++++-------------
blockproducer/branch.go | 2 +-
blockproducer/branch_test.go | 17 +++
blockproducer/chain.go | 6 +-
blockproducer/chain_test.go | 5 +
blockproducer/runtime.go | 4 +-
blockproducer/storage.go | 4 +-
8 files changed, 152 insertions(+), 122 deletions(-)
create mode 100644 blockproducer/branch_test.go
diff --git a/blockproducer/blocknode.go b/blockproducer/blocknode.go
index faa8ae7fe..a44123be2 100644
--- a/blockproducer/blocknode.go
+++ b/blockproducer/blocknode.go
@@ -17,12 +17,8 @@
package blockproducer
import (
- "encoding/binary"
- "time"
-
"github.com/CovenantSQL/CovenantSQL/crypto/hash"
"github.com/CovenantSQL/CovenantSQL/types"
- "github.com/CovenantSQL/CovenantSQL/utils/log"
)
type blockNode struct {
@@ -35,7 +31,7 @@ type blockNode struct {
block *types.BPBlock
}
-func newBlockNodeEx(h uint32, b *types.BPBlock, p *blockNode) *blockNode {
+func newBlockNode(h uint32, b *types.BPBlock, p *blockNode) *blockNode {
return &blockNode{
parent: p,
@@ -52,36 +48,6 @@ func newBlockNodeEx(h uint32, b *types.BPBlock, p *blockNode) *blockNode {
}
}
-func newBlockNode(chainInitTime time.Time, period time.Duration, block *types.BPBlock, parent *blockNode) *blockNode {
- var count uint32
-
- h := uint32(block.Timestamp().Sub(chainInitTime) / period)
-
- log.Debugf("chain init time %s, block generation time %s, block height %d", chainInitTime.String(), block.Timestamp().String(), h)
-
- if parent != nil {
- count = parent.count + 1
- } else {
- count = 0
- }
- n := &blockNode{
- hash: *block.BlockHash(),
- parent: parent,
- height: h,
- count: count,
- block: block,
- }
-
- return n
-}
-
-func (n *blockNode) indexKey() (key []byte) {
- key = make([]byte, hash.HashSize+4)
- binary.BigEndian.PutUint32(key[0:4], n.height)
- copy(key[4:hash.HashSize], n.hash[:])
- return
-}
-
// fetchNodeList returns the block node list within range (from, n.count] from node head n.
func (n *blockNode) fetchNodeList(from uint32) (bl []*blockNode) {
if n.count <= from {
@@ -102,9 +68,13 @@ func (n *blockNode) ancestor(h uint32) *blockNode {
}
ancestor := n
- for ancestor != nil && ancestor.height != h {
+ for ancestor != nil && ancestor.height > h {
ancestor = ancestor.parent
}
+ if ancestor != nil && ancestor.height != h {
+ ancestor = nil
+ }
+
return ancestor
}
diff --git a/blockproducer/blocknode_test.go b/blockproducer/blocknode_test.go
index 40f6aa279..bd69934f7 100644
--- a/blockproducer/blocknode_test.go
+++ b/blockproducer/blocknode_test.go
@@ -17,97 +17,131 @@
package blockproducer
import (
- "encoding/binary"
"testing"
- "time"
"github.com/CovenantSQL/CovenantSQL/crypto/hash"
+ "github.com/CovenantSQL/CovenantSQL/types"
+ . "github.com/smartystreets/goconvey/convey"
)
-func TestNewBlockNodeAndIndexKey(t *testing.T) {
- chainInitTime := time.Now().UTC()
- period := time.Second
- block, err := generateRandomBlock(hash.Hash{}, true)
- if err != nil {
- t.Fatalf("Unexcepted error: %v", err)
- }
- parent := newBlockNode(chainInitTime, period, block, nil)
- if parent == nil {
- t.Fatal("unexpected result: nil")
- } else if parent.parent != nil {
- t.Fatalf("unexpected parent: %v", parent.parent)
- } else if parent.height != 0 {
- t.Fatalf("unexpected height: %d", parent.height)
- }
+func TestBlockNode(t *testing.T) {
+ Convey("Given a set of block nodes", t, func() {
+ var (
+ b0 = &types.BPBlock{
+ SignedHeader: types.BPSignedHeader{
+ BlockHash: hash.Hash{0x1},
+ },
+ }
+ b1 = &types.BPBlock{
+ SignedHeader: types.BPSignedHeader{
+ BPHeader: types.BPHeader{
+ ParentHash: b0.SignedHeader.BlockHash,
+ },
+ BlockHash: hash.Hash{0x2},
+ },
+ }
+ b2 = &types.BPBlock{
+ SignedHeader: types.BPSignedHeader{
+ BPHeader: types.BPHeader{
+ ParentHash: b1.SignedHeader.BlockHash,
+ },
+ BlockHash: hash.Hash{0x3},
+ },
+ }
+ b3 = &types.BPBlock{
+ SignedHeader: types.BPSignedHeader{
+ BPHeader: types.BPHeader{
+ ParentHash: b2.SignedHeader.BlockHash,
+ },
+ BlockHash: hash.Hash{0x4},
+ },
+ }
+ b4 = &types.BPBlock{
+ SignedHeader: types.BPSignedHeader{
+ BPHeader: types.BPHeader{
+ ParentHash: b3.SignedHeader.BlockHash,
+ },
+ BlockHash: hash.Hash{0x5},
+ },
+ }
+ n0 = newBlockNode(0, b0, nil)
+ n1 = newBlockNode(1, b1, n0)
+ n2 = newBlockNode(2, b2, n1)
+ n3 = newBlockNode(3, b3, n2)
+ n4 = newBlockNode(5, b4, n3)
- time.Sleep(time.Second)
+ b3p = &types.BPBlock{
+ SignedHeader: types.BPSignedHeader{
+ BPHeader: types.BPHeader{
+ ParentHash: b2.SignedHeader.BlockHash,
+ },
+ BlockHash: hash.Hash{0x6},
+ },
+ }
+ b4p = &types.BPBlock{
+ SignedHeader: types.BPSignedHeader{
+ BPHeader: types.BPHeader{
+ ParentHash: b3p.SignedHeader.BlockHash,
+ },
+ BlockHash: hash.Hash{0x7},
+ },
+ }
+ n3p = newBlockNode(3, b3p, n2)
+ n4p = newBlockNode(4, b4p, n3p)
+ )
- block2, err := generateRandomBlock(block.SignedHeader.BlockHash, false)
- if err != nil {
- t.Fatalf("Unexcepted error: %v", err)
- }
- child := newBlockNode(chainInitTime, period, block2, parent)
- if child == nil {
- t.Fatal("unexpected result: nil")
- } else if child.parent != parent {
- t.Fatalf("unexpected parent: %v", parent.parent)
- } else if child.height != parent.height+1 {
- t.Fatalf("unexpected height: %d", parent.height)
- }
+ /*
+ n0 --- n1 --- n2 --- n3 --- x ---- n4
+ \ (skip)
+ \
+ +---n3p -- n4p
+ */
- // index key
- key1Raw := parent.indexKey()
- key1 := binary.BigEndian.Uint32(key1Raw[0:4])
- key2Raw := child.indexKey()
- key2 := binary.BigEndian.Uint32(key2Raw[0:4])
- if key2 <= key1 {
- t.Fatalf("key2's first byte should be larger than key1's first byte: \n\tkey1[0]=%d\n\tkey2[0]=%d",
- key1, key2)
- }
-}
+ So(n0.count, ShouldEqual, 0)
+ So(n1.count, ShouldEqual, n0.count+1)
+
+ So(n0.fetchNodeList(0), ShouldBeEmpty)
+ So(n0.fetchNodeList(1), ShouldBeEmpty)
+ So(n0.fetchNodeList(2), ShouldBeEmpty)
+ So(n3.fetchNodeList(0), ShouldResemble, []*blockNode{n1, n2, n3})
+ So(n4p.fetchNodeList(2), ShouldResemble, []*blockNode{n3p, n4p})
+
+ So(n0.ancestor(1), ShouldBeNil)
+ So(n3.ancestor(3), ShouldEqual, n3)
+ So(n3.ancestor(0), ShouldEqual, n0)
+ So(n4.ancestor(4), ShouldBeNil)
-func TestAncestor(t *testing.T) {
- chainInitTime := time.Now()
- period := time.Second
- block, err := generateRandomBlock(hash.Hash{}, true)
- if err != nil {
- t.Fatalf("Unexcepted error: %v", err)
- }
- parent := newBlockNode(chainInitTime, period, block, nil)
- if parent == nil {
- t.Fatal("unexpected result: nil")
- } else if parent.parent != nil {
- t.Fatalf("unexpected parent: %v", parent.parent)
- } else if parent.height != 0 {
- t.Fatalf("unexpected height: %d", parent.height)
- }
+ So(n0.ancestorByCount(1), ShouldBeNil)
+ So(n3.ancestorByCount(3), ShouldEqual, n3)
+ So(n3.ancestorByCount(0), ShouldEqual, n0)
- time.Sleep(time.Second)
+ So(n3.lastIrreversible(0), ShouldEqual, n3)
+ So(n3.lastIrreversible(1), ShouldEqual, n2)
+ So(n3.lastIrreversible(3), ShouldEqual, n0)
+ So(n3.lastIrreversible(9), ShouldEqual, n0)
- block2, err := generateRandomBlock(block.SignedHeader.BlockHash, false)
- if err != nil {
- t.Fatalf("Unexcepted error: %v", err)
- }
+ So(n0.hasAncestor(n4), ShouldBeFalse)
+ So(n3.hasAncestor(n0), ShouldBeTrue)
+ So(n3p.hasAncestor(n0), ShouldBeTrue)
+ So(n4.hasAncestor(n3p), ShouldBeFalse)
+ So(n4p.hasAncestor(n3), ShouldBeFalse)
- child := newBlockNode(chainInitTime, period, block2, parent)
- if child == nil {
- t.Fatal("unexpected result: nil")
- } else if child.parent != parent {
- t.Fatalf("unexpected parent: %v", parent.parent)
- } else if child.height != parent.height+1 {
- t.Fatalf("unexpected height: %d", parent.height)
- }
+ var (
+ f *blockNode
+ ok bool
+ )
- bn := child.ancestor(2)
- if bn != nil {
- t.Fatalf("should return nil, but get a block node: %v", bn)
- }
- bn = child.ancestor(1)
- if bn == nil || bn.height != 1 {
- t.Fatal("block node should not be nil and its height should be 1")
- }
- bn = child.ancestor(0)
- if bn == nil || bn.height != 0 {
- t.Fatal("block node should not be nil and its height should be 0")
- }
+ f, ok = n4.canForkFrom(n2.hash, n0.count)
+ So(ok, ShouldBeTrue)
+ So(f, ShouldEqual, n2)
+ f, ok = n4.canForkFrom(n4.hash, n0.count)
+ So(ok, ShouldBeTrue)
+ So(f, ShouldEqual, n4)
+ f, ok = n4.canForkFrom(n0.hash, n2.count)
+ So(ok, ShouldBeFalse)
+ f, ok = n4.canForkFrom(n3p.hash, n2.count)
+ So(ok, ShouldBeFalse)
+ f, ok = n4p.canForkFrom(n3.hash, n2.count)
+ So(ok, ShouldBeFalse)
+ })
}
diff --git a/blockproducer/branch.go b/blockproducer/branch.go
index d03969608..8cbdf0107 100644
--- a/blockproducer/branch.go
+++ b/blockproducer/branch.go
@@ -186,7 +186,7 @@ func (b *branch) produceBlock(
if err = block.PackAndSignBlock(signer); err != nil {
return
}
- cpy.head = newBlockNodeEx(h, block, cpy.head)
+ cpy.head = newBlockNode(h, block, cpy.head)
br = cpy
bl = block
return
diff --git a/blockproducer/branch_test.go b/blockproducer/branch_test.go
new file mode 100644
index 000000000..2423efab2
--- /dev/null
+++ b/blockproducer/branch_test.go
@@ -0,0 +1,17 @@
+/*
+ * Copyright 2018 The CovenantSQL Authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package blockproducer
diff --git a/blockproducer/chain.go b/blockproducer/chain.go
index b1fa06e7f..fa1cafe42 100644
--- a/blockproducer/chain.go
+++ b/blockproducer/chain.go
@@ -66,6 +66,11 @@ type Chain struct {
// NewChain creates a new blockchain.
func NewChain(cfg *Config) (c *Chain, err error) {
+ return NewChainWithContext(context.Background(), cfg)
+}
+
+// NewChainWithContext creates a new blockchain with context.
+func NewChainWithContext(ctx context.Context, cfg *Config) (c *Chain, err error) {
var (
existed bool
@@ -82,7 +87,6 @@ func NewChain(cfg *Config) (c *Chain, err error) {
rt *rt
bus = chainbus.New()
caller = rpc.NewCaller()
- ctx = context.Background()
)
if fi, err := os.Stat(cfg.DataFile); err == nil && fi.Mode().IsRegular() {
diff --git a/blockproducer/chain_test.go b/blockproducer/chain_test.go
index ced66a539..bdbf709b7 100644
--- a/blockproducer/chain_test.go
+++ b/blockproducer/chain_test.go
@@ -17,6 +17,7 @@
package blockproducer
import (
+ "testing"
"time"
)
@@ -27,3 +28,7 @@ var (
testPeriodNumber uint32 = 10
testClientNumberPerChain = 10
)
+
+func TestChain(t *testing.T) {
+
+}
diff --git a/blockproducer/runtime.go b/blockproducer/runtime.go
index a90521cff..a3e0709ab 100644
--- a/blockproducer/runtime.go
+++ b/blockproducer/runtime.go
@@ -283,7 +283,7 @@ func (r *rt) applyBlock(st xi.Storage, bl *types.BPBlock) (err error) {
for i, v := range r.branches {
// Grow a branch
if v.head.hash.IsEqual(&bl.SignedHeader.ParentHash) {
- head = newBlockNodeEx(height, bl, v.head)
+ head = newBlockNode(height, bl, v.head)
if br, err = v.applyBlock(head); err != nil {
return
}
@@ -299,7 +299,7 @@ func (r *rt) applyBlock(st xi.Storage, bl *types.BPBlock) (err error) {
}
// Fork and create new branch
if parent, ok = v.head.canForkFrom(bl.SignedHeader.ParentHash, r.lastIrre.count); ok {
- head = newBlockNodeEx(height, bl, parent)
+ head = newBlockNode(height, bl, parent)
if br, err = fork(r.lastIrre, head, r.immutable, r.txPool); err != nil {
return
}
diff --git a/blockproducer/storage.go b/blockproducer/storage.go
index 9e5318ced..6ddb88655 100644
--- a/blockproducer/storage.go
+++ b/blockproducer/storage.go
@@ -350,7 +350,7 @@ func loadBlocks(
err = ErrMultipleGenesis
return
}
- bn = newBlockNodeEx(0, dec, nil)
+ bn = newBlockNode(0, dec, nil)
index[bh] = bn
headsIndex[bh] = bn
return
@@ -360,7 +360,7 @@ func loadBlocks(
err = ErrParentNotFound
return
}
- bn = newBlockNodeEx(v1, dec, pn)
+ bn = newBlockNode(v1, dec, pn)
index[bh] = bn
if _, ok = headsIndex[ph]; ok {
delete(headsIndex, ph)
From abd8cd580a36b61658d3ddca647f59718375a35c Mon Sep 17 00:00:00 2001
From: leventeliu
Date: Wed, 12 Dec 2018 16:04:12 +0800
Subject: [PATCH 044/278] Add basic testing, fix some issues
---
blockproducer/branch.go | 1 +
blockproducer/chain.go | 12 ++++--
blockproducer/chain_test.go | 61 ++++++++++++++++++++++++++++
blockproducer/metaindex_test.go | 2 +-
blockproducer/metastate_test.go | 2 +-
blockproducer/runtime.go | 19 ++++++---
blockproducer/storage.go | 66 +++++++++++++++++-------------
blockproducer/xxx_test.go | 72 +++++++++++++++++++++------------
8 files changed, 170 insertions(+), 65 deletions(-)
diff --git a/blockproducer/branch.go b/blockproducer/branch.go
index 8cbdf0107..33ac45c36 100644
--- a/blockproducer/branch.go
+++ b/blockproducer/branch.go
@@ -72,6 +72,7 @@ func fork(
}
}
inst.preview.commit()
+ br = inst
return
}
diff --git a/blockproducer/chain.go b/blockproducer/chain.go
index fa1cafe42..0ac19232d 100644
--- a/blockproducer/chain.go
+++ b/blockproducer/chain.go
@@ -73,6 +73,7 @@ func NewChain(cfg *Config) (c *Chain, err error) {
func NewChainWithContext(ctx context.Context, cfg *Config) (c *Chain, err error) {
var (
existed bool
+ ierr error
st xi.Storage
irre *blockNode
@@ -94,22 +95,25 @@ func NewChainWithContext(ctx context.Context, cfg *Config) (c *Chain, err error)
}
// Open storage
- if st, err = openStorage(fmt.Sprintf("file:%s", cfg.DataFile)); err != nil {
+ if st, ierr = openStorage(fmt.Sprintf("file:%s", cfg.DataFile)); ierr != nil {
+ err = errors.Wrap(ierr, "failed to open storage")
return
}
// Storage genesis
if !existed {
- if err = store(st, []storageProcedure{
+ if ierr = store(st, []storageProcedure{
updateIrreversible(cfg.Genesis.SignedHeader.BlockHash),
addBlock(0, cfg.Genesis),
- }, nil); err != nil {
+ }, nil); ierr != nil {
+ err = errors.Wrap(ierr, "failed to initialize storage")
return
}
}
// Load and create runtime
- if irre, heads, immutable, txPool, err = loadDatabase(st); err != nil {
+ if irre, heads, immutable, txPool, ierr = loadDatabase(st); ierr != nil {
+ err = errors.Wrap(ierr, "failed to load data from storage")
return
}
rt = newRuntime(ctx, cfg, addr, irre, heads, immutable, txPool)
diff --git a/blockproducer/chain_test.go b/blockproducer/chain_test.go
index bdbf709b7..dffea781f 100644
--- a/blockproducer/chain_test.go
+++ b/blockproducer/chain_test.go
@@ -17,8 +17,15 @@
package blockproducer
import (
+ "path"
"testing"
"time"
+
+ pi "github.com/CovenantSQL/CovenantSQL/blockproducer/interfaces"
+ "github.com/CovenantSQL/CovenantSQL/crypto/hash"
+ "github.com/CovenantSQL/CovenantSQL/proto"
+ "github.com/CovenantSQL/CovenantSQL/types"
+ . "github.com/smartystreets/goconvey/convey"
)
var (
@@ -30,5 +37,59 @@ var (
)
func TestChain(t *testing.T) {
+ Convey("Given a new chain", t, func() {
+ var (
+ rawids = [...]proto.RawNodeID{
+ {Hash: hash.Hash{0x0, 0x0, 0x0, 0x1}},
+ {Hash: hash.Hash{0x0, 0x0, 0x0, 0x2}},
+ {Hash: hash.Hash{0x0, 0x0, 0x0, 0x3}},
+ {Hash: hash.Hash{0x0, 0x0, 0x0, 0x4}},
+ {Hash: hash.Hash{0x0, 0x0, 0x0, 0x5}},
+ }
+
+ err error
+ config *Config
+ genesis *types.BPBlock
+ leader proto.NodeID
+ servers []proto.NodeID
+ chain *Chain
+ )
+
+ genesis = &types.BPBlock{
+ SignedHeader: types.BPSignedHeader{
+ BPHeader: types.BPHeader{
+ Timestamp: time.Time{},
+ },
+ },
+ Transactions: []pi.Transaction{
+ types.NewBaseAccount(&types.Account{}),
+ },
+ }
+ err = genesis.PackAndSignBlock(testingPrivateKey)
+ So(err, ShouldBeNil)
+
+ for _, v := range rawids {
+ servers = append(servers, v.ToNodeID())
+ }
+ leader = servers[0]
+
+ config = &Config{
+ Genesis: genesis,
+ DataFile: path.Join(testingDataDir, t.Name()),
+ Server: nil,
+ Peers: &proto.Peers{
+ PeersHeader: proto.PeersHeader{
+ Leader: leader,
+ Servers: servers,
+ },
+ },
+ NodeID: leader,
+ Period: time.Duration(1 * time.Second),
+ Tick: time.Duration(100 * time.Millisecond),
+ }
+ chain, err = NewChain(config)
+ So(err, ShouldBeNil)
+ So(chain, ShouldNotBeNil)
+ })
}
diff --git a/blockproducer/metaindex_test.go b/blockproducer/metaindex_test.go
index e5145feda..0fbed8a3f 100644
--- a/blockproducer/metaindex_test.go
+++ b/blockproducer/metaindex_test.go
@@ -39,7 +39,7 @@ func TestMetaIndex(t *testing.T) {
dbid1 = proto.DatabaseID("db#1")
dbid2 = proto.DatabaseID("db#2")
mi = newMetaIndex()
- fl = path.Join(testDataDir, t.Name())
+ fl = path.Join(testingDataDir, t.Name())
db, err = bolt.Open(fl, 0600, nil)
)
So(err, ShouldBeNil)
diff --git a/blockproducer/metastate_test.go b/blockproducer/metastate_test.go
index 46e14c880..95436aa81 100644
--- a/blockproducer/metastate_test.go
+++ b/blockproducer/metastate_test.go
@@ -56,7 +56,7 @@ func TestMetaState(t *testing.T) {
dbid2 = proto.DatabaseID("db#2")
dbid3 = proto.DatabaseID("db#3")
ms = newMetaState()
- fl = path.Join(testDataDir, t.Name())
+ fl = path.Join(testingDataDir, t.Name())
db, err = bolt.Open(fl, 0600, nil)
)
So(err, ShouldBeNil)
diff --git a/blockproducer/runtime.go b/blockproducer/runtime.go
index a3e0709ab..9c4e83ab2 100644
--- a/blockproducer/runtime.go
+++ b/blockproducer/runtime.go
@@ -94,18 +94,25 @@ func newRuntime(
br, head *branch
headIndex int
)
+ if len(heads) == 0 {
+ log.Fatal("At least one branch head is needed")
+ }
for _, v := range heads {
+ log.WithFields(log.Fields{
+ "irre_hash": irre.hash.ShortString(),
+ "irre_count": irre.count,
+ "head_hash": v.hash.ShortString(),
+ "head_count": v.count,
+ }).Debug("Checking head")
if v.hasAncestor(irre) {
- if v.hasAncestor(irre) {
- if br, err = fork(irre, v, immutable, txPool); err != nil {
- log.WithError(err).Fatal("Failed to rebuild branch")
- }
- branches = append(branches, br)
+ if br, err = fork(irre, v, immutable, txPool); err != nil {
+ log.WithError(err).Fatal("Failed to rebuild branch")
}
+ branches = append(branches, br)
}
}
for i, v := range branches {
- if v.head.count > branches[headIndex].head.count {
+ if head == nil || v.head.count > head.head.count {
headIndex = i
head = v
}
diff --git a/blockproducer/storage.go b/blockproducer/storage.go
index 6ddb88655..09e74af77 100644
--- a/blockproducer/storage.go
+++ b/blockproducer/storage.go
@@ -28,44 +28,46 @@ import (
"github.com/CovenantSQL/CovenantSQL/utils/log"
xi "github.com/CovenantSQL/CovenantSQL/xenomint/interfaces"
xs "github.com/CovenantSQL/CovenantSQL/xenomint/sqlite"
+ "github.com/pkg/errors"
)
var (
ddls = [...]string{
// Chain state tables
`CREATE TABLE IF NOT EXISTS "blocks" (
- "height" INT
- "hash" TEXT
- "parent" TEXT
- "encoded" BLOB
- UNIQUE INDEX ("hash")
+ "height" INT,
+ "hash" TEXT,
+ "parent" TEXT,
+ "encoded" BLOB,
+ UNIQUE ("hash")
)`,
`CREATE TABLE IF NOT EXISTS "txPool" (
- "type" INT
- "hash" TEXT
- "encoded" BLOB
- UNIQUE INDEX ("hash")
+ "type" INT,
+ "hash" TEXT,
+ "encoded" BLOB,
+ UNIQUE ("hash")
)`,
`CREATE TABLE IF NOT EXISTS "irreversible" (
- "id" INT
- "hash" TEXT
+ "id" INT,
+ "hash" TEXT,
+ UNIQUE ("id")
)`,
// Meta state tables
`CREATE TABLE IF NOT EXISTS "accounts" (
- "address" TEXT
- "encoded" BLOB
- UNIQUE INDEX ("address")
+ "address" TEXT,
+ "encoded" BLOB,
+ UNIQUE ("address")
)`,
`CREATE TABLE IF NOT EXISTS "shardChain" (
- "address" TEXT
- "id" TEXT
- "encoded" BLOB
- UNIQUE INDEX ("address", "id")
+ "address" TEXT,
+ "id" TEXT,
+ "encoded" BLOB,
+ UNIQUE ("address", "id")
)`,
`CREATE TABLE IF NOT EXISTS "provider" (
- "address" TEXT
- "encoded" BLOB
- UNIQUE INDEX ("address")
+ "address" TEXT,
+ "encoded" BLOB,
+ UNIQUE ("address")
)`,
}
)
@@ -105,11 +107,13 @@ func errPass(err error) storageProcedure {
}
func openStorage(path string) (st xi.Storage, err error) {
- if st, err = xs.NewSqlite(path); err != nil {
+ var ierr error
+ if st, ierr = xs.NewSqlite(path); ierr != nil {
return
}
for _, v := range ddls {
- if _, err = st.Writer().Exec(v); err != nil {
+ if _, ierr = st.Writer().Exec(v); ierr != nil {
+ err = errors.Wrap(ierr, v)
return
}
}
@@ -307,7 +311,7 @@ func loadBlocks(
var (
rows *sql.Rows
- genesis = hash.Hash{}
+ root = hash.Hash{}
index = make(map[hash.Hash]*blockNode)
headsIndex = make(map[hash.Hash]*blockNode)
@@ -344,16 +348,24 @@ func loadBlocks(
if err = utils.DecodeMsgPack(v4, dec); err != nil {
return
}
+ log.WithFields(log.Fields{
+ "hash": bh.String(),
+ "parent": ph.String(),
+ }).Debug("Loaded new block")
// Add genesis block
- if ph.IsEqual(&genesis) {
- if _, ok = index[ph]; ok {
+ if ph.IsEqual(&root) {
+ if len(index) != 0 {
err = ErrMultipleGenesis
return
}
bn = newBlockNode(0, dec, nil)
index[bh] = bn
headsIndex[bh] = bn
- return
+ log.WithFields(log.Fields{
+ "hash": bh.String(),
+ "parent": ph.String(),
+ }).Debug("Set genesis block")
+ continue
}
// Add normal block
if pn, ok = index[ph]; ok {
diff --git a/blockproducer/xxx_test.go b/blockproducer/xxx_test.go
index bea04f022..b5ce4e00c 100644
--- a/blockproducer/xxx_test.go
+++ b/blockproducer/xxx_test.go
@@ -20,13 +20,14 @@ import (
"io/ioutil"
"math/rand"
"os"
+ "path"
"sync"
"testing"
"time"
pi "github.com/CovenantSQL/CovenantSQL/blockproducer/interfaces"
"github.com/CovenantSQL/CovenantSQL/crypto"
- "github.com/CovenantSQL/CovenantSQL/crypto/asymmetric"
+ ca "github.com/CovenantSQL/CovenantSQL/crypto/asymmetric"
"github.com/CovenantSQL/CovenantSQL/crypto/hash"
"github.com/CovenantSQL/CovenantSQL/crypto/kms"
"github.com/CovenantSQL/CovenantSQL/pow/cpuminer"
@@ -40,13 +41,22 @@ var (
uuidLen = 32
peerNum uint32 = 32
- testAddress1 = proto.AccountAddress{0x0, 0x0, 0x0, 0x1}
- testAddress2 = proto.AccountAddress{0x0, 0x0, 0x0, 0x2}
- testInitBalance = uint64(10000)
- testDifficulty = 4
- testDataDir string
- testAddress1Nonce pi.AccountNonce
- testPrivKey *asymmetric.PrivateKey
+ testAddress1 = proto.AccountAddress{0x0, 0x0, 0x0, 0x1}
+ testAddress2 = proto.AccountAddress{0x0, 0x0, 0x0, 0x2}
+ testInitBalance = uint64(10000)
+ testDifficulty = 4
+
+ testAddress1Nonce pi.AccountNonce
+ testingDataDir string
+ testingTraceFile *os.File
+ testingPrivateKeyFile string
+ testingPublicKeyStoreFile string
+ testingNonceDifficulty int
+
+ testingPrivateKey *ca.PrivateKey
+ testingPublicKey *ca.PublicKey
+
+ testingMasterKey = []byte(`?08Rl%WUih4V0H+c`)
)
const (
@@ -84,7 +94,7 @@ func randStringBytes(n int) string {
func generateRandomBlock(parent hash.Hash, isGenesis bool) (b *types.BPBlock, err error) {
// Generate key pair
- priv, _, err := asymmetric.GenSecp256k1KeyPair()
+ priv, _, err := ca.GenSecp256k1KeyPair()
if err != nil {
return
@@ -128,10 +138,10 @@ func generateRandomBlock(parent hash.Hash, isGenesis bool) (b *types.BPBlock, er
},
)
)
- if err = ba1.Sign(testPrivKey); err != nil {
+ if err = ba1.Sign(testingPrivateKey); err != nil {
return
}
- if err = ba2.Sign(testPrivKey); err != nil {
+ if err = ba2.Sign(testingPrivateKey); err != nil {
return
}
b.Transactions = append(b.Transactions, ba1, ba2)
@@ -143,7 +153,7 @@ func generateRandomBlock(parent hash.Hash, isGenesis bool) (b *types.BPBlock, er
func generateRandomBlockWithTransactions(parent hash.Hash, tbs []pi.Transaction) (b *types.BPBlock, err error) {
// Generate key pair
- priv, _, err := asymmetric.GenSecp256k1KeyPair()
+ priv, _, err := ca.GenSecp256k1KeyPair()
if err != nil {
return
@@ -207,12 +217,12 @@ func generateRandomBillingRequest() (*types.BillingRequest, error) {
return nil, err
}
- signees := make([]*asymmetric.PublicKey, peerNum)
- signatures := make([]*asymmetric.Signature, peerNum)
+ signees := make([]*ca.PublicKey, peerNum)
+ signatures := make([]*ca.Signature, peerNum)
for i := range signees {
// Generate key pair
- priv, pub, err := asymmetric.GenSecp256k1KeyPair()
+ priv, pub, err := ca.GenSecp256k1KeyPair()
if err != nil {
return nil, err
}
@@ -235,8 +245,8 @@ func generateRandomBillingHeader() (tc *types.BillingHeader, err error) {
return
}
- var priv *asymmetric.PrivateKey
- if priv, _, err = asymmetric.GenSecp256k1KeyPair(); err != nil {
+ var priv *ca.PrivateKey
+ if priv, _, err = ca.GenSecp256k1KeyPair(); err != nil {
return
}
@@ -265,7 +275,7 @@ func generateRandomBillingAndBaseAccount() (*types.BaseAccount, *types.Billing,
if err != nil {
return nil, nil, err
}
- priv, _, err := asymmetric.GenSecp256k1KeyPair()
+ priv, _, err := ca.GenSecp256k1KeyPair()
header.Producer, _ = crypto.PubKeyHash(priv.PubKey())
txBilling := types.NewBilling(header)
@@ -298,7 +308,7 @@ func generateRandomAccountBilling() (*types.Billing, error) {
header.Nonce = testAddress1Nonce
txBilling := types.NewBilling(header)
- if err := txBilling.Sign(testPrivKey); err != nil {
+ if err := txBilling.Sign(testingPrivateKey); err != nil {
return nil, err
}
@@ -325,7 +335,7 @@ func generateRandomHash() hash.Hash {
return h
}
-func registerNodesWithPublicKey(pub *asymmetric.PublicKey, diff int, num int) (
+func registerNodesWithPublicKey(pub *ca.PublicKey, diff int, num int) (
nis []cpuminer.NonceInfo, err error) {
nis = make([]cpuminer.NonceInfo, num)
@@ -369,7 +379,7 @@ func createRandomString(offset, length int, s *string) {
*s = string(buff)
}
-func createTestPeersWithPrivKeys(priv *asymmetric.PrivateKey, num int) (nis []cpuminer.NonceInfo, p *proto.Peers, err error) {
+func createTestPeersWithPrivKeys(priv *ca.PrivateKey, num int) (nis []cpuminer.NonceInfo, p *proto.Peers, err error) {
if num <= 0 {
return
}
@@ -459,13 +469,23 @@ func setup() {
rand.Seed(time.Now().UnixNano())
rand.Read(genesisHash[:])
- // Create key pairs for test
- if testPrivKey, _, err = asymmetric.GenSecp256k1KeyPair(); err != nil {
+ // Create temp dir for test data
+ if testingDataDir, err = ioutil.TempDir("", "CovenantSQL"); err != nil {
panic(err)
}
- // Create temp dir for test data
- if testDataDir, err = ioutil.TempDir("", "covenantsql"); err != nil {
+ // Initialze kms
+ testingNonceDifficulty = 2
+ testingPrivateKeyFile = path.Join(testingDataDir, "private.key")
+ testingPublicKeyStoreFile = path.Join(testingDataDir, "public.keystore")
+ if testingPrivateKey, testingPublicKey, err = ca.GenSecp256k1KeyPair(); err != nil {
+ panic(err)
+ }
+ kms.Unittest = true
+ kms.SetLocalKeyPair(testingPrivateKey, testingPublicKey)
+ if err = kms.SavePrivateKey(
+ testingPrivateKeyFile, testingPrivateKey, testingMasterKey,
+ ); err != nil {
panic(err)
}
@@ -475,7 +495,7 @@ func setup() {
}
func teardown() {
- if err := os.RemoveAll(testDataDir); err != nil {
+ if err := os.RemoveAll(testingDataDir); err != nil {
panic(err)
}
}
From 51e12fd8eb4c96dd03e641d4e21d9187ec01ff08 Mon Sep 17 00:00:00 2001
From: leventeliu
Date: Wed, 12 Dec 2018 16:05:03 +0800
Subject: [PATCH 045/278] Fix hash stringer
---
blockproducer/runtime.go | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/blockproducer/runtime.go b/blockproducer/runtime.go
index 9c4e83ab2..34df9ded7 100644
--- a/blockproducer/runtime.go
+++ b/blockproducer/runtime.go
@@ -99,9 +99,9 @@ func newRuntime(
}
for _, v := range heads {
log.WithFields(log.Fields{
- "irre_hash": irre.hash.ShortString(),
+ "irre_hash": irre.hash.String(),
"irre_count": irre.count,
- "head_hash": v.hash.ShortString(),
+ "head_hash": v.hash.String(),
"head_count": v.count,
}).Debug("Checking head")
if v.hasAncestor(irre) {
From 18ca929f3bb9c393a29c5984ed38c76255f9acd5 Mon Sep 17 00:00:00 2001
From: leventeliu
Date: Wed, 12 Dec 2018 16:21:03 +0800
Subject: [PATCH 046/278] Add short string for clearer logging
---
blockproducer/runtime.go | 4 ++--
blockproducer/storage.go | 8 ++++----
crypto/hash/hash.go | 12 ++++++++++++
crypto/hash/hash_test.go | 11 +++++++++++
4 files changed, 29 insertions(+), 6 deletions(-)
diff --git a/blockproducer/runtime.go b/blockproducer/runtime.go
index 34df9ded7..41a6c30f7 100644
--- a/blockproducer/runtime.go
+++ b/blockproducer/runtime.go
@@ -99,9 +99,9 @@ func newRuntime(
}
for _, v := range heads {
log.WithFields(log.Fields{
- "irre_hash": irre.hash.String(),
+ "irre_hash": irre.hash.Short(4),
"irre_count": irre.count,
- "head_hash": v.hash.String(),
+ "head_hash": v.hash.Short(4),
"head_count": v.count,
}).Debug("Checking head")
if v.hasAncestor(irre) {
diff --git a/blockproducer/storage.go b/blockproducer/storage.go
index 09e74af77..103839e00 100644
--- a/blockproducer/storage.go
+++ b/blockproducer/storage.go
@@ -349,8 +349,8 @@ func loadBlocks(
return
}
log.WithFields(log.Fields{
- "hash": bh.String(),
- "parent": ph.String(),
+ "hash": bh.Short(4),
+ "parent": ph.Short(4),
}).Debug("Loaded new block")
// Add genesis block
if ph.IsEqual(&root) {
@@ -362,8 +362,8 @@ func loadBlocks(
index[bh] = bn
headsIndex[bh] = bn
log.WithFields(log.Fields{
- "hash": bh.String(),
- "parent": ph.String(),
+ "hash": bh.Short(4),
+ "parent": ph.Short(4),
}).Debug("Set genesis block")
continue
}
diff --git a/crypto/hash/hash.go b/crypto/hash/hash.go
index 74b9e49e4..75ad51858 100644
--- a/crypto/hash/hash.go
+++ b/crypto/hash/hash.go
@@ -48,6 +48,18 @@ func (h Hash) String() string {
return hex.EncodeToString(h[:])
}
+// Short returns the hexadecimal string of the first `n` reversed byte(s).
+func (h Hash) Short(n int) string {
+ for i := 0; i < HashSize/2; i++ {
+ h[i], h[HashSize-1-i] = h[HashSize-1-i], h[i]
+ }
+ var l = HashSize
+ if n < l {
+ l = n
+ }
+ return hex.EncodeToString(h[:l])
+}
+
// AsBytes returns internal bytes of hash.
func (h Hash) AsBytes() []byte {
return h[:]
diff --git a/crypto/hash/hash_test.go b/crypto/hash/hash_test.go
index 0ef77d42b..a99d17ccb 100644
--- a/crypto/hash/hash_test.go
+++ b/crypto/hash/hash_test.go
@@ -128,6 +128,17 @@ func TestHashString(t *testing.T) {
t.Errorf("String: wrong hash string - got %v, want %v",
hashStr, wantStr)
}
+ for n := 0; n < 2*HashSize; n++ {
+ var l = HashSize
+ if n < l {
+ l = n
+ }
+ expect := string([]byte(wantStr)[:2*l])
+ actual := hash.Short(n)
+ if expect != actual {
+ t.Errorf("Short result mismatched: expect=%s actual=%s", expect, actual)
+ }
+ }
}
// TestNewHashFromStr executes tests against the NewHashFromStr function.
From ee3e0c9e94343beb54f8e0f2db427e1d6d822c2b Mon Sep 17 00:00:00 2001
From: leventeliu
Date: Wed, 12 Dec 2018 17:23:20 +0800
Subject: [PATCH 047/278] Use common config to run local node testing
---
blockproducer/xxx_test.go | 20 ++++++++++++--------
1 file changed, 12 insertions(+), 8 deletions(-)
diff --git a/blockproducer/xxx_test.go b/blockproducer/xxx_test.go
index b5ce4e00c..26cca2a71 100644
--- a/blockproducer/xxx_test.go
+++ b/blockproducer/xxx_test.go
@@ -26,12 +26,14 @@ import (
"time"
pi "github.com/CovenantSQL/CovenantSQL/blockproducer/interfaces"
+ "github.com/CovenantSQL/CovenantSQL/conf"
"github.com/CovenantSQL/CovenantSQL/crypto"
ca "github.com/CovenantSQL/CovenantSQL/crypto/asymmetric"
"github.com/CovenantSQL/CovenantSQL/crypto/hash"
"github.com/CovenantSQL/CovenantSQL/crypto/kms"
"github.com/CovenantSQL/CovenantSQL/pow/cpuminer"
"github.com/CovenantSQL/CovenantSQL/proto"
+ "github.com/CovenantSQL/CovenantSQL/route"
"github.com/CovenantSQL/CovenantSQL/types"
"github.com/CovenantSQL/CovenantSQL/utils/log"
)
@@ -49,7 +51,8 @@ var (
testAddress1Nonce pi.AccountNonce
testingDataDir string
testingTraceFile *os.File
- testingPrivateKeyFile string
+ testingConfigFile = "../test/node_standalone/config.yaml"
+ testingPrivateKeyFile = "../test/node_standalone/private.key"
testingPublicKeyStoreFile string
testingNonceDifficulty int
@@ -476,18 +479,19 @@ func setup() {
// Initialze kms
testingNonceDifficulty = 2
- testingPrivateKeyFile = path.Join(testingDataDir, "private.key")
testingPublicKeyStoreFile = path.Join(testingDataDir, "public.keystore")
- if testingPrivateKey, testingPublicKey, err = ca.GenSecp256k1KeyPair(); err != nil {
+
+ if conf.GConf, err = conf.LoadConfig(testingConfigFile); err != nil {
+ panic(err)
+ }
+ route.InitKMS(testingPublicKeyStoreFile)
+ if err = kms.InitLocalKeyPair(testingPrivateKeyFile, []byte{}); err != nil {
panic(err)
}
- kms.Unittest = true
- kms.SetLocalKeyPair(testingPrivateKey, testingPublicKey)
- if err = kms.SavePrivateKey(
- testingPrivateKeyFile, testingPrivateKey, testingMasterKey,
- ); err != nil {
+ if testingPrivateKey, err = kms.GetLocalPrivateKey(); err != nil {
panic(err)
}
+ testingPublicKey = testingPrivateKey.PubKey()
// Setup logging
log.SetOutput(os.Stdout)
From 825f70f2f7189fecccba0fd29b1d871a691cb87c Mon Sep 17 00:00:00 2001
From: leventeliu
Date: Wed, 12 Dec 2018 18:15:07 +0800
Subject: [PATCH 048/278] Fix missing base account issue in initialization
---
blockproducer/chain.go | 41 ++++++++++++++++++++++++++---
blockproducer/chain_test.go | 51 ++++++++++++++++++++++++++++++++++---
2 files changed, 85 insertions(+), 7 deletions(-)
diff --git a/blockproducer/chain.go b/blockproducer/chain.go
index 0ac19232d..03f6cc998 100644
--- a/blockproducer/chain.go
+++ b/blockproducer/chain.go
@@ -102,10 +102,39 @@ func NewChainWithContext(ctx context.Context, cfg *Config) (c *Chain, err error)
// Storage genesis
if !existed {
- if ierr = store(st, []storageProcedure{
- updateIrreversible(cfg.Genesis.SignedHeader.BlockHash),
- addBlock(0, cfg.Genesis),
- }, nil); ierr != nil {
+ // TODO(leventeliu): reuse rt.switchBranch to construct initial state.
+ var init = newMetaState()
+ for _, v := range cfg.Genesis.Transactions {
+ if ierr = init.apply(v); ierr != nil {
+ err = errors.Wrap(ierr, "failed to initialize immutable state")
+ return
+ }
+ }
+ var sps []storageProcedure
+ sps = append(sps, addBlock(0, cfg.Genesis))
+ for k, v := range init.dirty.accounts {
+ if v != nil {
+ sps = append(sps, updateAccount(&v.Account))
+ } else {
+ sps = append(sps, deleteAccount(k))
+ }
+ }
+ for k, v := range init.dirty.databases {
+ if v != nil {
+ sps = append(sps, updateShardChain(&v.SQLChainProfile))
+ } else {
+ sps = append(sps, deleteShardChain(k))
+ }
+ }
+ for k, v := range init.dirty.provider {
+ if v != nil {
+ sps = append(sps, updateProvider(&v.ProviderProfile))
+ } else {
+ sps = append(sps, deleteProvider(k))
+ }
+ }
+ sps = append(sps, updateIrreversible(cfg.Genesis.SignedHeader.BlockHash))
+ if ierr = store(st, sps, nil); ierr != nil {
err = errors.Wrap(ierr, "failed to initialize storage")
return
}
@@ -464,6 +493,10 @@ func (c *Chain) addTx(tx pi.Transaction) {
}
func (c *Chain) processTx(tx pi.Transaction) {
+ if err := tx.Verify(); err != nil {
+ log.WithError(err).Error("Failed to verify transaction")
+ return
+ }
if err := c.rt.addTx(c.st, tx); err != nil {
log.WithError(err).Error("Failed to add transaction")
}
diff --git a/blockproducer/chain_test.go b/blockproducer/chain_test.go
index dffea781f..f482ed003 100644
--- a/blockproducer/chain_test.go
+++ b/blockproducer/chain_test.go
@@ -22,7 +22,10 @@ import (
"time"
pi "github.com/CovenantSQL/CovenantSQL/blockproducer/interfaces"
+ "github.com/CovenantSQL/CovenantSQL/crypto"
+ "github.com/CovenantSQL/CovenantSQL/crypto/asymmetric"
"github.com/CovenantSQL/CovenantSQL/crypto/hash"
+ "github.com/CovenantSQL/CovenantSQL/crypto/kms"
"github.com/CovenantSQL/CovenantSQL/proto"
"github.com/CovenantSQL/CovenantSQL/types"
. "github.com/smartystreets/goconvey/convey"
@@ -36,8 +39,24 @@ var (
testClientNumberPerChain = 10
)
+func newTransfer(
+ nonce pi.AccountNonce, signer *asymmetric.PrivateKey,
+ sender, receiver proto.AccountAddress, amount uint64,
+) (
+ t *types.Transfer, err error,
+) {
+ t = types.NewTransfer(&types.TransferHeader{
+ Sender: sender,
+ Receiver: receiver,
+ Nonce: nonce,
+ Amount: amount,
+ })
+ err = t.Sign(signer)
+ return
+}
+
func TestChain(t *testing.T) {
- Convey("Given a new chain", t, func() {
+ Convey("Given a new block producer chain", t, func() {
var (
rawids = [...]proto.RawNodeID{
{Hash: hash.Hash{0x0, 0x0, 0x0, 0x1}},
@@ -53,16 +72,30 @@ func TestChain(t *testing.T) {
leader proto.NodeID
servers []proto.NodeID
chain *Chain
+
+ priv1, priv2 *asymmetric.PrivateKey
+ addr1, addr2 proto.AccountAddress
)
+ priv1, err = kms.GetLocalPrivateKey()
+ So(err, ShouldBeNil)
+ priv2, _, err = asymmetric.GenSecp256k1KeyPair()
+ So(err, ShouldBeNil)
+ addr1, err = crypto.PubKeyHash(priv1.PubKey())
+ So(err, ShouldBeNil)
+ addr2, err = crypto.PubKeyHash(priv2.PubKey())
+
genesis = &types.BPBlock{
SignedHeader: types.BPSignedHeader{
BPHeader: types.BPHeader{
- Timestamp: time.Time{},
+ Timestamp: time.Now().UTC(),
},
},
Transactions: []pi.Transaction{
- types.NewBaseAccount(&types.Account{}),
+ types.NewBaseAccount(&types.Account{
+ Address: addr1,
+ TokenBalance: [5]uint64{1000, 1000, 1000, 1000, 1000},
+ }),
},
}
err = genesis.PackAndSignBlock(testingPrivateKey)
@@ -91,5 +124,17 @@ func TestChain(t *testing.T) {
chain, err = NewChain(config)
So(err, ShouldBeNil)
So(chain, ShouldNotBeNil)
+ Convey("When transfer transactions are added", func() {
+ var (
+ nonce pi.AccountNonce
+ t1 pi.Transaction
+ )
+ nonce, err = chain.rt.nextNonce(addr1)
+ So(err, ShouldBeNil)
+ t1, err = newTransfer(nonce, priv1, addr1, addr2, 1)
+ So(err, ShouldBeNil)
+ err = chain.rt.addTx(chain.st, t1)
+ So(err, ShouldBeNil)
+ })
})
}
From 6174fbef71d39ab2faada92bdb451dcd367a2b93 Mon Sep 17 00:00:00 2001
From: leventeliu
Date: Wed, 12 Dec 2018 20:32:30 +0800
Subject: [PATCH 049/278] Add testing cases and debug log
---
blockproducer/branch.go | 22 ++++++++++++++++++----
blockproducer/chain.go | 2 ++
blockproducer/chain_test.go | 35 +++++++++++++++++++++++++++++++++--
blockproducer/runtime.go | 34 +++++++++++++++++++++++-----------
4 files changed, 76 insertions(+), 17 deletions(-)
diff --git a/blockproducer/branch.go b/blockproducer/branch.go
index 33ac45c36..bf7d42a52 100644
--- a/blockproducer/branch.go
+++ b/blockproducer/branch.go
@@ -17,6 +17,7 @@ package blockproducer
import (
"bytes"
+ "fmt"
"sort"
"time"
@@ -148,10 +149,6 @@ func (b *branch) sortUnpackedTxs() (txs []pi.Transaction) {
return
}
-func newBlock(out []pi.Transaction) (bl *types.BPBlock) {
- return
-}
-
func (b *branch) produceBlock(
h uint32, ts time.Time, addr proto.AccountAddress, signer *ca.PrivateKey,
) (
@@ -198,3 +195,20 @@ func (b *branch) clearPackedTxs(txs []pi.Transaction) {
delete(b.packed, v.Hash())
}
}
+
+func (b *branch) sprint(from uint32) (buff string) {
+ var nodes = b.head.fetchNodeList(from)
+ for i, v := range nodes {
+ var hex = v.hash.Short(4)
+ if i == 0 {
+ buff += fmt.Sprintf("* %s <-- %s", v.parent.hash.Short(4), hex)
+ continue
+ }
+ if d := v.height - nodes[i-1].height; d > 1 {
+ buff += fmt.Sprintf(" <-- (skip %d blocks) <-- %s", d, hex)
+ } else {
+ buff += fmt.Sprintf(" <-- %s", hex)
+ }
+ }
+ return
+}
diff --git a/blockproducer/chain.go b/blockproducer/chain.go
index 03f6cc998..5373be880 100644
--- a/blockproducer/chain.go
+++ b/blockproducer/chain.go
@@ -601,6 +601,8 @@ func (c *Chain) Stop() (err error) {
log.WithFields(log.Fields{"peer": c.rt.peerInfo()}).Debug("Stopping chain")
c.rt.stop()
log.WithFields(log.Fields{"peer": c.rt.peerInfo()}).Debug("Chain service stopped")
+ c.st.Close()
+ log.WithFields(log.Fields{"peer": c.rt.peerInfo()}).Debug("Chain database closed")
close(c.pendingBlocks)
close(c.pendingTxs)
return
diff --git a/blockproducer/chain_test.go b/blockproducer/chain_test.go
index f482ed003..6458e5801 100644
--- a/blockproducer/chain_test.go
+++ b/blockproducer/chain_test.go
@@ -17,6 +17,7 @@
package blockproducer
import (
+ "os"
"path"
"testing"
"time"
@@ -124,17 +125,47 @@ func TestChain(t *testing.T) {
chain, err = NewChain(config)
So(err, ShouldBeNil)
So(chain, ShouldNotBeNil)
+
+ // Close chain on reset
+ Reset(func() {
+ err = chain.Stop()
+ So(err, ShouldBeNil)
+ err = os.Remove(config.DataFile)
+ So(err, ShouldBeNil)
+ })
+
Convey("When transfer transactions are added", func() {
var (
- nonce pi.AccountNonce
- t1 pi.Transaction
+ nonce pi.AccountNonce
+ t1, t2, t3 pi.Transaction
)
nonce, err = chain.rt.nextNonce(addr1)
So(err, ShouldBeNil)
+ So(nonce, ShouldEqual, 1)
t1, err = newTransfer(nonce, priv1, addr1, addr2, 1)
So(err, ShouldBeNil)
+ t2, err = newTransfer(nonce+1, priv1, addr1, addr2, 1)
+ So(err, ShouldBeNil)
+ t3, err = newTransfer(nonce+2, priv1, addr1, addr2, 1)
+ So(err, ShouldBeNil)
err = chain.rt.addTx(chain.st, t1)
So(err, ShouldBeNil)
+ err = chain.rt.addTx(chain.st, t1)
+ So(err, ShouldEqual, ErrExistedTx)
+ Convey("The chain should be able to produce new block", func() {
+ err = chain.produceBlock(chain.rt.genesisTime.Add(chain.rt.period))
+ So(err, ShouldBeNil)
+ Convey("The chain should be able to produce new block", func() {
+ err = chain.rt.addTx(chain.st, t2)
+ So(err, ShouldBeNil)
+ err = chain.produceBlock(chain.rt.genesisTime.Add(2 * chain.rt.period))
+ So(err, ShouldBeNil)
+ err = chain.rt.addTx(chain.st, t3)
+ So(err, ShouldBeNil)
+ err = chain.produceBlock(chain.rt.genesisTime.Add(3 * chain.rt.period))
+ So(err, ShouldBeNil)
+ })
+ })
})
})
}
diff --git a/blockproducer/runtime.go b/blockproducer/runtime.go
index 41a6c30f7..a5515fb79 100644
--- a/blockproducer/runtime.go
+++ b/blockproducer/runtime.go
@@ -32,6 +32,7 @@ import (
"github.com/CovenantSQL/CovenantSQL/types"
"github.com/CovenantSQL/CovenantSQL/utils/log"
xi "github.com/CovenantSQL/CovenantSQL/xenomint/interfaces"
+ "github.com/pkg/errors"
)
// rt defines the runtime of main chain.
@@ -147,13 +148,16 @@ func newRuntime(
}
func (r *rt) addTx(st xi.Storage, tx pi.Transaction) (err error) {
+ var k = tx.Hash()
+ r.Lock()
+ defer r.Unlock()
+ if _, ok := r.txPool[k]; ok {
+ err = ErrExistedTx
+ return
+ }
+
return store(st, []storageProcedure{addTx(tx)}, func() {
- var k = tx.Hash()
- r.Lock()
- defer r.Unlock()
- if _, ok := r.txPool[k]; !ok {
- r.txPool[k] = tx
- }
+ r.txPool[k] = tx
for _, v := range r.branches {
v.addTx(tx)
}
@@ -324,21 +328,29 @@ func (r *rt) produceBlock(
st xi.Storage, now time.Time, priv *asymmetric.PrivateKey) (out *types.BPBlock, err error,
) {
var (
- bl *types.BPBlock
- br *branch
+ bl *types.BPBlock
+ br *branch
+ ierr error
)
r.Lock()
defer r.Unlock()
// Try to produce new block
- if br, bl, err = r.headBranch.produceBlock(
+ if br, bl, ierr = r.headBranch.produceBlock(
r.height(now), now, r.address, priv,
- ); err != nil {
+ ); ierr != nil {
+ err = errors.Wrapf(ierr, "failed to produce block at head %s",
+ r.headBranch.head.hash.Short(4))
return
}
- if err = r.switchBranch(st, bl, r.headIndex, br); err != nil {
+ if ierr = r.switchBranch(st, bl, r.headIndex, br); ierr != nil {
+ err = errors.Wrapf(ierr, "failed to switch branch #%d:%s",
+ r.headIndex, r.headBranch.head.hash.Short(4))
return
}
out = bl
+ log.WithFields(log.Fields{
+ "head_branch": r.headBranch.sprint(r.lastIrre.count),
+ }).Debug("Produced new block on head branch")
return
}
From 45ceb7e3532087ef50f056d18f2fdafa885b7997 Mon Sep 17 00:00:00 2001
From: zeqing-guo
Date: Wed, 12 Dec 2018 20:56:57 +0800
Subject: [PATCH 050/278] modify test case
---
blockproducer/metastate_test.go | 40 ++++++++++++++++-----------------
conf/config.go | 4 ++--
2 files changed, 22 insertions(+), 22 deletions(-)
diff --git a/blockproducer/metastate_test.go b/blockproducer/metastate_test.go
index ade48805d..f736b152b 100644
--- a/blockproducer/metastate_test.go
+++ b/blockproducer/metastate_test.go
@@ -965,17 +965,17 @@ func TestMetaState(t *testing.T) {
invalidPs := types.ProvideService{
ProvideServiceHeader: types.ProvideServiceHeader{
TargetUser: addr1,
- Nonce: 1,
+ Nonce: 1,
},
}
err = invalidPs.Sign(privKey3)
So(err, ShouldBeNil)
invalidCd1 := types.CreateDatabase{
CreateDatabaseHeader: types.CreateDatabaseHeader{
- Owner: addr2,
- GasPrice: 1,
+ Owner: addr2,
+ GasPrice: 1,
TokenType: types.Particle,
- Nonce: 1,
+ Nonce: 1,
},
}
err = invalidCd1.Sign(privKey1)
@@ -986,10 +986,10 @@ func TestMetaState(t *testing.T) {
ResourceMeta: types.ResourceMeta{
TargetMiners: []proto.AccountAddress{addr2},
},
- GasPrice: 1,
+ GasPrice: 1,
AdvancePayment: uint64(conf.GConf.QPS) * uint64(conf.GConf.Period) * 1,
- TokenType: types.Particle,
- Nonce: 1,
+ TokenType: types.Particle,
+ Nonce: 1,
},
}
err = invalidCd2.Sign(privKey1)
@@ -1000,9 +1000,9 @@ func TestMetaState(t *testing.T) {
ResourceMeta: types.ResourceMeta{
TargetMiners: []proto.AccountAddress{addr2},
},
- GasPrice: 1,
+ GasPrice: 1,
TokenType: types.Particle,
- Nonce: 1,
+ Nonce: 1,
},
}
err = invalidCd3.Sign(privKey3)
@@ -1034,9 +1034,9 @@ func TestMetaState(t *testing.T) {
ps := types.ProvideService{
ProvideServiceHeader: types.ProvideServiceHeader{
TargetUser: addr1,
- GasPrice: 1,
- TokenType: types.Particle,
- Nonce: 1,
+ GasPrice: 1,
+ TokenType: types.Particle,
+ Nonce: 1,
},
}
err = ps.Sign(privKey2)
@@ -1047,10 +1047,10 @@ func TestMetaState(t *testing.T) {
ResourceMeta: types.ResourceMeta{
TargetMiners: []proto.AccountAddress{addr2},
},
- GasPrice: 1,
+ GasPrice: 1,
AdvancePayment: 3600000,
- TokenType: types.Particle,
- Nonce: 1,
+ TokenType: types.Particle,
+ Nonce: 1,
},
}
err = cd1.Sign(privKey1)
@@ -1061,10 +1061,10 @@ func TestMetaState(t *testing.T) {
ResourceMeta: types.ResourceMeta{
TargetMiners: []proto.AccountAddress{addr2},
},
- GasPrice: 1,
+ GasPrice: 1,
AdvancePayment: 3600000,
- TokenType: types.Particle,
- Nonce: 1,
+ TokenType: types.Particle,
+ Nonce: 1,
},
}
err = cd2.Sign(privKey3)
@@ -1077,7 +1077,7 @@ func TestMetaState(t *testing.T) {
So(err, ShouldBeNil)
b2, loaded = ms.loadAccountStableBalance(addr2)
So(loaded, ShouldBeTrue)
- So(b1 - b2, ShouldEqual, conf.GConf.MinProviderDeposit)
+ So(b1-b2, ShouldEqual, conf.GConf.MinProviderDeposit)
err = db.Update(ms.applyTransactionProcedure(&cd2))
So(errors.Cause(err), ShouldEqual, ErrMinerUserNotMatch)
b1, loaded = ms.loadAccountStableBalance(addr1)
@@ -1088,7 +1088,7 @@ func TestMetaState(t *testing.T) {
So(loaded, ShouldBeTrue)
minAdvancePayment := uint64(cd2.GasPrice) * uint64(conf.GConf.QPS) *
uint64(conf.GConf.Period) * uint64(len(cd2.ResourceMeta.TargetMiners))
- So(b1 - b2, ShouldEqual, cd1.AdvancePayment + minAdvancePayment)
+ So(b1-b2, ShouldEqual, cd1.AdvancePayment+minAdvancePayment)
dbID := proto.FromAccountAndNonce(cd1.Owner, uint32(cd1.Nonce))
co, loaded = ms.loadSQLChainObject(*dbID)
So(loaded, ShouldBeTrue)
diff --git a/conf/config.go b/conf/config.go
index 98ab90abd..caedc1c32 100644
--- a/conf/config.go
+++ b/conf/config.go
@@ -135,8 +135,8 @@ type Config struct {
KnownNodes []proto.Node `yaml:"KnownNodes"`
SeedBPNodes []proto.Node `yaml:"-"`
- QPS uint32 `yaml:"QPS"`
- Period uint32 `yaml:"Period"` // Period is for sql chain miners syncing billing with main chain
+ QPS uint32 `yaml:"QPS"`
+ Period uint32 `yaml:"Period"` // Period is for sql chain miners syncing billing with main chain
MinProviderDeposit uint64 `yaml:"MinProviderDeposit"`
}
From ddf32de29078d86b144829cf7206c453fd597619 Mon Sep 17 00:00:00 2001
From: leventeliu
Date: Thu, 13 Dec 2018 10:24:28 +0800
Subject: [PATCH 051/278] Fix comment format
---
blockproducer/blocknode_test.go | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/blockproducer/blocknode_test.go b/blockproducer/blocknode_test.go
index bd69934f7..08cb45a29 100644
--- a/blockproducer/blocknode_test.go
+++ b/blockproducer/blocknode_test.go
@@ -94,7 +94,7 @@ func TestBlockNode(t *testing.T) {
n0 --- n1 --- n2 --- n3 --- x ---- n4
\ (skip)
\
- +---n3p -- n4p
+ +---n3p -- n4p
*/
So(n0.count, ShouldEqual, 0)
From 302dbce91429e390cc033908ec0629d7b1114a4d Mon Sep 17 00:00:00 2001
From: leventeliu
Date: Thu, 13 Dec 2018 14:17:18 +0800
Subject: [PATCH 052/278] Fix issue at database reloading
---
blockproducer/branch.go | 15 +++++++--------
blockproducer/chain_test.go | 14 ++++++++++++--
blockproducer/runtime.go | 26 +++++++++++++++++++++++---
blockproducer/storage.go | 15 ++++++++++-----
4 files changed, 52 insertions(+), 18 deletions(-)
diff --git a/blockproducer/branch.go b/blockproducer/branch.go
index bf7d42a52..03c9a55a9 100644
--- a/blockproducer/branch.go
+++ b/blockproducer/branch.go
@@ -199,16 +199,15 @@ func (b *branch) clearPackedTxs(txs []pi.Transaction) {
func (b *branch) sprint(from uint32) (buff string) {
var nodes = b.head.fetchNodeList(from)
for i, v := range nodes {
- var hex = v.hash.Short(4)
if i == 0 {
- buff += fmt.Sprintf("* %s <-- %s", v.parent.hash.Short(4), hex)
- continue
- }
- if d := v.height - nodes[i-1].height; d > 1 {
- buff += fmt.Sprintf(" <-- (skip %d blocks) <-- %s", d, hex)
- } else {
- buff += fmt.Sprintf(" <-- %s", hex)
+ var p = v.parent
+ buff += fmt.Sprintf("* #%d:%d %s {%d}",
+ p.height, p.count, p.hash.Short(4), len(p.block.Transactions))
+ } else if d := v.height - nodes[i-1].height; d > 1 {
+ buff += fmt.Sprintf(" <-- (skip %d blocks)", d)
}
+ buff += fmt.Sprintf(" <-- #%d:%d %s {%d}",
+ v.height, v.count, v.hash.Short(4), len(v.block.Transactions))
}
return
}
diff --git a/blockproducer/chain_test.go b/blockproducer/chain_test.go
index 6458e5801..158150a25 100644
--- a/blockproducer/chain_test.go
+++ b/blockproducer/chain_test.go
@@ -128,8 +128,10 @@ func TestChain(t *testing.T) {
// Close chain on reset
Reset(func() {
- err = chain.Stop()
- So(err, ShouldBeNil)
+ if chain != nil {
+ err = chain.Stop()
+ So(err, ShouldBeNil)
+ }
err = os.Remove(config.DataFile)
So(err, ShouldBeNil)
})
@@ -164,6 +166,14 @@ func TestChain(t *testing.T) {
So(err, ShouldBeNil)
err = chain.produceBlock(chain.rt.genesisTime.Add(3 * chain.rt.period))
So(err, ShouldBeNil)
+ Convey("The chain should have same state after reloading", func() {
+ err = chain.Stop()
+ So(err, ShouldBeNil)
+ chain, err = NewChain(config)
+ So(err, ShouldBeNil)
+ So(chain, ShouldNotBeNil)
+ chain.rt.log()
+ })
})
})
})
diff --git a/blockproducer/runtime.go b/blockproducer/runtime.go
index a5515fb79..4ecf79844 100644
--- a/blockproducer/runtime.go
+++ b/blockproducer/runtime.go
@@ -280,6 +280,24 @@ func (r *rt) switchBranch(st xi.Storage, bl *types.BPBlock, origin int, head *br
return
}
+func (r *rt) log() {
+ r.RLock()
+ defer r.RUnlock()
+ for i, v := range r.branches {
+ var buff string
+ if i == r.headIndex {
+ buff += "[head] "
+ } else {
+ buff += fmt.Sprintf("[%04d] ", i)
+ }
+ buff += v.sprint(r.lastIrre.count)
+ log.WithFields(log.Fields{
+ "branch": buff,
+ }).Debug("Runtime state")
+ }
+ return
+}
+
func (r *rt) applyBlock(st xi.Storage, bl *types.BPBlock) (err error) {
var (
ok bool
@@ -288,6 +306,8 @@ func (r *rt) applyBlock(st xi.Storage, bl *types.BPBlock) (err error) {
head *blockNode
height = r.height(bl.Timestamp())
)
+
+ defer r.log()
r.Lock()
defer r.Unlock()
@@ -332,8 +352,11 @@ func (r *rt) produceBlock(
br *branch
ierr error
)
+
+ defer r.log()
r.Lock()
defer r.Unlock()
+
// Try to produce new block
if br, bl, ierr = r.headBranch.produceBlock(
r.height(now), now, r.address, priv,
@@ -348,9 +371,6 @@ func (r *rt) produceBlock(
return
}
out = bl
- log.WithFields(log.Fields{
- "head_branch": r.headBranch.sprint(r.lastIrre.count),
- }).Debug("Produced new block on head branch")
return
}
diff --git a/blockproducer/storage.go b/blockproducer/storage.go
index 103839e00..78ecd2190 100644
--- a/blockproducer/storage.go
+++ b/blockproducer/storage.go
@@ -316,6 +316,7 @@ func loadBlocks(
headsIndex = make(map[hash.Hash]*blockNode)
// Scan buffer
+ id uint32
v1 uint32
v2, v3 string
v4 []byte
@@ -327,7 +328,7 @@ func loadBlocks(
// Load blocks
if rows, err = st.Reader().Query(
- `SELECT "height", "hash", "parent", "encoded" FROM "blocks" ORDER BY "rowid"`,
+ `SELECT "rowid", "height", "hash", "parent", "encoded" FROM "blocks" ORDER BY "rowid"`,
); err != nil {
return
}
@@ -335,7 +336,7 @@ func loadBlocks(
for rows.Next() {
// Scan and decode block
- if err = rows.Scan(&v1, &v2, &v3, &v4); err != nil {
+ if err = rows.Scan(&id, &v1, &v2, &v3, &v4); err != nil {
return
}
if err = hash.Decode(&bh, v2); err != nil {
@@ -349,6 +350,8 @@ func loadBlocks(
return
}
log.WithFields(log.Fields{
+ "rowid": id,
+ "height": v1,
"hash": bh.Short(4),
"parent": ph.Short(4),
}).Debug("Loaded new block")
@@ -362,14 +365,16 @@ func loadBlocks(
index[bh] = bn
headsIndex[bh] = bn
log.WithFields(log.Fields{
+ "rowid": id,
+ "height": v1,
"hash": bh.Short(4),
"parent": ph.Short(4),
}).Debug("Set genesis block")
continue
}
// Add normal block
- if pn, ok = index[ph]; ok {
- err = ErrParentNotFound
+ if pn, ok = index[ph]; !ok {
+ err = errors.Wrapf(ErrParentNotFound, "parent %s not found", ph.Short(4))
return
}
bn = newBlockNode(v1, dec, pn)
@@ -381,7 +386,7 @@ func loadBlocks(
}
if irre, ok = index[irreHash]; !ok {
- err = ErrParentNotFound
+ err = errors.Wrapf(ErrParentNotFound, "irreversible block %s not found", ph.Short(4))
return
}
From 0d123a00144071925307a0ef21faac58026b619b Mon Sep 17 00:00:00 2001
From: leventeliu
Date: Thu, 13 Dec 2018 16:02:48 +0800
Subject: [PATCH 053/278] Fix an issue on branch forking
Check all branches for growing first. This will avoid to fork unnecessary
new branch.
---
blockproducer/branch.go | 18 +++---
blockproducer/chain_test.go | 107 ++++++++++++++++++++++++++++--------
blockproducer/runtime.go | 6 ++
3 files changed, 102 insertions(+), 29 deletions(-)
diff --git a/blockproducer/branch.go b/blockproducer/branch.go
index 03c9a55a9..cc1ad537c 100644
--- a/blockproducer/branch.go
+++ b/blockproducer/branch.go
@@ -26,6 +26,7 @@ import (
"github.com/CovenantSQL/CovenantSQL/crypto/hash"
"github.com/CovenantSQL/CovenantSQL/proto"
"github.com/CovenantSQL/CovenantSQL/types"
+ "github.com/pkg/errors"
)
type branch struct {
@@ -155,13 +156,14 @@ func (b *branch) produceBlock(
br *branch, bl *types.BPBlock, err error,
) {
var (
- cpy = b.makeCopy()
- txs = cpy.sortUnpackedTxs()
- out = make([]pi.Transaction, 0, len(txs))
+ cpy = b.makeCopy()
+ txs = cpy.sortUnpackedTxs()
+ out = make([]pi.Transaction, 0, len(txs))
+ ierr error
)
for _, v := range txs {
var k = v.Hash()
- if err = cpy.preview.apply(v); err != nil {
+ if ierr = cpy.preview.apply(v); ierr != nil {
continue
}
delete(cpy.unpacked, k)
@@ -181,7 +183,8 @@ func (b *branch) produceBlock(
},
Transactions: out,
}
- if err = block.PackAndSignBlock(signer); err != nil {
+ if ierr = block.PackAndSignBlock(signer); ierr != nil {
+ err = errors.Wrap(ierr, "failed to sign block")
return
}
cpy.head = newBlockNode(h, block, cpy.head)
@@ -203,8 +206,9 @@ func (b *branch) sprint(from uint32) (buff string) {
var p = v.parent
buff += fmt.Sprintf("* #%d:%d %s {%d}",
p.height, p.count, p.hash.Short(4), len(p.block.Transactions))
- } else if d := v.height - nodes[i-1].height; d > 1 {
- buff += fmt.Sprintf(" <-- (skip %d blocks)", d)
+ }
+ if d := v.height - v.parent.height; d > 1 {
+ buff += fmt.Sprintf(" <-- (skip %d blocks)", d-1)
}
buff += fmt.Sprintf(" <-- #%d:%d %s {%d}",
v.height, v.count, v.hash.Short(4), len(v.block.Transactions))
diff --git a/blockproducer/chain_test.go b/blockproducer/chain_test.go
index 158150a25..2dd47408e 100644
--- a/blockproducer/chain_test.go
+++ b/blockproducer/chain_test.go
@@ -70,6 +70,7 @@ func TestChain(t *testing.T) {
err error
config *Config
genesis *types.BPBlock
+ begin time.Time
leader proto.NodeID
servers []proto.NodeID
chain *Chain
@@ -101,6 +102,7 @@ func TestChain(t *testing.T) {
}
err = genesis.PackAndSignBlock(testingPrivateKey)
So(err, ShouldBeNil)
+ begin = genesis.Timestamp()
for _, v := range rawids {
servers = append(servers, v.ToNodeID())
@@ -140,6 +142,8 @@ func TestChain(t *testing.T) {
var (
nonce pi.AccountNonce
t1, t2, t3 pi.Transaction
+ f0, f1 *branch
+ bl *types.BPBlock
)
nonce, err = chain.rt.nextNonce(addr1)
So(err, ShouldBeNil)
@@ -150,31 +154,90 @@ func TestChain(t *testing.T) {
So(err, ShouldBeNil)
t3, err = newTransfer(nonce+2, priv1, addr1, addr2, 1)
So(err, ShouldBeNil)
+
+ // Fork from #0
+ f0 = chain.rt.headBranch.makeCopy()
+
err = chain.rt.addTx(chain.st, t1)
So(err, ShouldBeNil)
- err = chain.rt.addTx(chain.st, t1)
- So(err, ShouldEqual, ErrExistedTx)
- Convey("The chain should be able to produce new block", func() {
- err = chain.produceBlock(chain.rt.genesisTime.Add(chain.rt.period))
+ Convey("The chain should report error on duplicated transaction", func() {
+ err = chain.rt.addTx(chain.st, t1)
+ So(err, ShouldEqual, ErrExistedTx)
+ })
+ err = chain.produceBlock(begin.Add(chain.rt.period))
+ So(err, ShouldBeNil)
+ // Create a sibling block from fork#0 and apply
+ _, bl, err = f0.produceBlock(2, begin.Add(2*chain.rt.period), addr2, priv2)
+ So(err, ShouldBeNil)
+ So(bl, ShouldNotBeNil)
+ err = chain.pushBlock(bl)
+ So(err, ShouldBeNil)
+
+ // Fork from #1
+ f1 = chain.rt.headBranch.makeCopy()
+
+ err = chain.rt.addTx(chain.st, t2)
+ So(err, ShouldBeNil)
+ err = chain.produceBlock(begin.Add(2 * chain.rt.period))
+ So(err, ShouldBeNil)
+
+ err = chain.rt.addTx(chain.st, t3)
+ So(err, ShouldBeNil)
+ err = chain.produceBlock(begin.Add(3 * chain.rt.period))
+ So(err, ShouldBeNil)
+ // Create a sibling block from fork#1 and apply
+ f1, bl, err = f1.produceBlock(3, begin.Add(3*chain.rt.period), addr2, priv2)
+ So(err, ShouldBeNil)
+ So(bl, ShouldNotBeNil)
+ err = chain.pushBlock(bl)
+ So(err, ShouldBeNil)
+
+ err = chain.produceBlock(begin.Add(4 * chain.rt.period))
+ So(err, ShouldBeNil)
+ // Create a sibling block from fork#1 and apply
+ f1, bl, err = f1.produceBlock(4, begin.Add(4*chain.rt.period), addr2, priv2)
+ So(err, ShouldBeNil)
+ So(bl, ShouldNotBeNil)
+ err = chain.pushBlock(bl)
+ So(err, ShouldBeNil)
+
+ err = chain.produceBlock(begin.Add(5 * chain.rt.period))
+ So(err, ShouldBeNil)
+ // Create a sibling block from fork#1 and apply
+ f1, bl, err = f1.produceBlock(5, begin.Add(5*chain.rt.period), addr2, priv2)
+ So(err, ShouldBeNil)
+ So(bl, ShouldNotBeNil)
+ err = chain.pushBlock(bl)
+ So(err, ShouldBeNil)
+
+ err = chain.produceBlock(begin.Add(6 * chain.rt.period))
+ So(err, ShouldBeNil)
+ // Create a sibling block from fork#1 and apply
+ f1, bl, err = f1.produceBlock(6, begin.Add(6*chain.rt.period), addr2, priv2)
+ So(err, ShouldBeNil)
+ So(bl, ShouldNotBeNil)
+ err = chain.pushBlock(bl)
+ So(err, ShouldBeNil)
+
+ // Create a sibling block from fork#1 and apply
+ f1, bl, err = f1.produceBlock(7, begin.Add(8*chain.rt.period), addr2, priv2)
+ So(err, ShouldBeNil)
+ So(bl, ShouldNotBeNil)
+ err = chain.pushBlock(bl)
+ So(err, ShouldBeNil)
+ f1, bl, err = f1.produceBlock(8, begin.Add(9*chain.rt.period), addr2, priv2)
+ So(err, ShouldBeNil)
+ So(bl, ShouldNotBeNil)
+ err = chain.pushBlock(bl)
+ So(err, ShouldBeNil)
+
+ Convey("The chain should have same state after reloading", func() {
+ err = chain.Stop()
+ So(err, ShouldBeNil)
+ chain, err = NewChain(config)
So(err, ShouldBeNil)
- Convey("The chain should be able to produce new block", func() {
- err = chain.rt.addTx(chain.st, t2)
- So(err, ShouldBeNil)
- err = chain.produceBlock(chain.rt.genesisTime.Add(2 * chain.rt.period))
- So(err, ShouldBeNil)
- err = chain.rt.addTx(chain.st, t3)
- So(err, ShouldBeNil)
- err = chain.produceBlock(chain.rt.genesisTime.Add(3 * chain.rt.period))
- So(err, ShouldBeNil)
- Convey("The chain should have same state after reloading", func() {
- err = chain.Stop()
- So(err, ShouldBeNil)
- chain, err = NewChain(config)
- So(err, ShouldBeNil)
- So(chain, ShouldNotBeNil)
- chain.rt.log()
- })
- })
+ So(chain, ShouldNotBeNil)
+ chain.rt.log()
})
})
})
diff --git a/blockproducer/runtime.go b/blockproducer/runtime.go
index 4ecf79844..aa02d3d98 100644
--- a/blockproducer/runtime.go
+++ b/blockproducer/runtime.go
@@ -256,6 +256,10 @@ func (r *rt) switchBranch(st xi.Storage, bl *types.BPBlock, origin int, head *br
idx = len(brs) - 1
} else if b.head.hasAncestor(irre) {
brs = append(brs, b)
+ } else {
+ log.WithFields(log.Fields{
+ "branch": fmt.Sprintf("%04d", i),
+ }).Debugf("Pruning branch")
}
}
// Replace current branches
@@ -328,6 +332,8 @@ func (r *rt) applyBlock(st xi.Storage, bl *types.BPBlock) (err error) {
// Switch branch or grow current branch
return r.switchBranch(st, bl, i, br)
}
+ }
+ for _, v := range r.branches {
// Fork and create new branch
if parent, ok = v.head.canForkFrom(bl.SignedHeader.ParentHash, r.lastIrre.count); ok {
head = newBlockNode(height, bl, parent)
From 80ffb9819e60c8c9109dab36b94d2994739693c1 Mon Sep 17 00:00:00 2001
From: leventeliu
Date: Thu, 13 Dec 2018 16:30:32 +0800
Subject: [PATCH 054/278] Refactor testing case
---
blockproducer/chain_test.go | 41 +++++++++++++------------------------
blockproducer/runtime.go | 7 ++++++-
2 files changed, 20 insertions(+), 28 deletions(-)
diff --git a/blockproducer/chain_test.go b/blockproducer/chain_test.go
index 2dd47408e..4ef698325 100644
--- a/blockproducer/chain_test.go
+++ b/blockproducer/chain_test.go
@@ -166,6 +166,7 @@ func TestChain(t *testing.T) {
})
err = chain.produceBlock(begin.Add(chain.rt.period))
So(err, ShouldBeNil)
+
// Create a sibling block from fork#0 and apply
_, bl, err = f0.produceBlock(2, begin.Add(2*chain.rt.period), addr2, priv2)
So(err, ShouldBeNil)
@@ -192,34 +193,20 @@ func TestChain(t *testing.T) {
err = chain.pushBlock(bl)
So(err, ShouldBeNil)
- err = chain.produceBlock(begin.Add(4 * chain.rt.period))
- So(err, ShouldBeNil)
- // Create a sibling block from fork#1 and apply
- f1, bl, err = f1.produceBlock(4, begin.Add(4*chain.rt.period), addr2, priv2)
- So(err, ShouldBeNil)
- So(bl, ShouldNotBeNil)
- err = chain.pushBlock(bl)
- So(err, ShouldBeNil)
-
- err = chain.produceBlock(begin.Add(5 * chain.rt.period))
- So(err, ShouldBeNil)
- // Create a sibling block from fork#1 and apply
- f1, bl, err = f1.produceBlock(5, begin.Add(5*chain.rt.period), addr2, priv2)
- So(err, ShouldBeNil)
- So(bl, ShouldNotBeNil)
- err = chain.pushBlock(bl)
- So(err, ShouldBeNil)
-
- err = chain.produceBlock(begin.Add(6 * chain.rt.period))
- So(err, ShouldBeNil)
- // Create a sibling block from fork#1 and apply
- f1, bl, err = f1.produceBlock(6, begin.Add(6*chain.rt.period), addr2, priv2)
- So(err, ShouldBeNil)
- So(bl, ShouldNotBeNil)
- err = chain.pushBlock(bl)
- So(err, ShouldBeNil)
+ // This should trigger a branch pruning on fork #0
+ for i := uint32(4); i <= 6; i++ {
+ err = chain.produceBlock(begin.Add(time.Duration(i) * chain.rt.period))
+ So(err, ShouldBeNil)
+ // Create a sibling block from fork#1 and apply
+ f1, bl, err = f1.produceBlock(
+ i, begin.Add(time.Duration(i)*chain.rt.period), addr2, priv2)
+ So(err, ShouldBeNil)
+ So(bl, ShouldNotBeNil)
+ err = chain.pushBlock(bl)
+ So(err, ShouldBeNil)
+ }
- // Create a sibling block from fork#1 and apply
+ // Add 2 more blocks to fork #1, this should trigger a branch switch to fork #1
f1, bl, err = f1.produceBlock(7, begin.Add(8*chain.rt.period), addr2, priv2)
So(err, ShouldBeNil)
So(bl, ShouldNotBeNil)
diff --git a/blockproducer/runtime.go b/blockproducer/runtime.go
index aa02d3d98..f02df0168 100644
--- a/blockproducer/runtime.go
+++ b/blockproducer/runtime.go
@@ -258,7 +258,12 @@ func (r *rt) switchBranch(st xi.Storage, bl *types.BPBlock, origin int, head *br
brs = append(brs, b)
} else {
log.WithFields(log.Fields{
- "branch": fmt.Sprintf("%04d", i),
+ "branch": func() string {
+ if i == r.headIndex {
+ return "[head]"
+ }
+ return fmt.Sprintf("[%04d]", i)
+ }(),
}).Debugf("Pruning branch")
}
}
From 6a5eafc1dff72a1f073da6fbb45d9608a05a4493 Mon Sep 17 00:00:00 2001
From: leventeliu
Date: Thu, 13 Dec 2018 16:36:07 +0800
Subject: [PATCH 055/278] Remove deprecated billing codes
---
blockproducer/chain.go | 74 ------------------------------------------
blockproducer/rpc.go | 36 --------------------
2 files changed, 110 deletions(-)
diff --git a/blockproducer/chain.go b/blockproducer/chain.go
index 5373be880..56d076bcd 100644
--- a/blockproducer/chain.go
+++ b/blockproducer/chain.go
@@ -208,14 +208,6 @@ func (c *Chain) pushBlockWithoutCheck(b *types.BPBlock) (err error) {
return err
}
-func (c *Chain) pushGenesisBlock(b *types.BPBlock) (err error) {
- err = c.pushBlockWithoutCheck(b)
- if err != nil {
- log.WithError(err).Error("push genesis block failed")
- }
- return
-}
-
func (c *Chain) pushBlock(b *types.BPBlock) error {
err := c.checkBlock(b)
if err != nil {
@@ -281,72 +273,6 @@ func (c *Chain) produceBlock(now time.Time) (err error) {
return err
}
-func (c *Chain) produceBilling(br *types.BillingRequest) (_ *types.BillingRequest, err error) {
- // TODO(lambda): simplify the function
- if err = c.checkBillingRequest(br); err != nil {
- return
- }
-
- // update stable coin's balance
- // TODO(lambda): because there is no token distribution,
- // we only increase miners' balance but not decrease customer's balance
- var (
- accountNumber = len(br.Header.GasAmounts)
- receivers = make([]*proto.AccountAddress, accountNumber)
- fees = make([]uint64, accountNumber)
- rewards = make([]uint64, accountNumber)
- )
-
- for i, addrAndGas := range br.Header.GasAmounts {
- receivers[i] = &addrAndGas.AccountAddress
- fees[i] = addrAndGas.GasAmount * uint64(gasPrice)
- rewards[i] = 0
- }
-
- // add block producer signature
- var privKey *asymmetric.PrivateKey
- privKey, err = kms.GetLocalPrivateKey()
- if err != nil {
- return
- }
-
- if _, _, err = br.SignRequestHeader(privKey, false); err != nil {
- return
- }
-
- // generate and push the txbilling
- // 1. generate txbilling
- var nc pi.AccountNonce
- if nc, err = c.rt.nextNonce(accountAddress); err != nil {
- return
- }
- var (
- tc = types.NewBillingHeader(nc, br, accountAddress, receivers, fees, rewards)
- tb = types.NewBilling(tc)
- )
- if err = tb.Sign(privKey); err != nil {
- return
- }
- log.WithField("billingRequestHash", br.RequestHash).Debug("generated billing transaction")
-
- // 2. push tx
- c.pendingTxs <- tb
-
- return br, nil
-}
-
-// checkBillingRequest checks followings by order:
-// 1. period of sqlchain;
-// 2. request's hash
-// 3. miners' signatures.
-func (c *Chain) checkBillingRequest(br *types.BillingRequest) (err error) {
- // period of sqlchain;
- // TODO(lambda): get and check period and miner list of specific sqlchain
-
- err = br.VerifySignatures()
- return
-}
-
func (c *Chain) fetchBlock(h hash.Hash) (b *types.BPBlock, err error) {
var (
enc []byte
diff --git a/blockproducer/rpc.go b/blockproducer/rpc.go
index 93471eac3..c7b4e5906 100644
--- a/blockproducer/rpc.go
+++ b/blockproducer/rpc.go
@@ -38,17 +38,6 @@ type AdviseNewBlockResp struct {
proto.Envelope
}
-// AdviseTxBillingReq defines a request of the AdviseTxBilling RPC method.
-type AdviseTxBillingReq struct {
- proto.Envelope
- TxBilling *types.Billing
-}
-
-// AdviseTxBillingResp defines a response of the AdviseTxBilling RPC method.
-type AdviseTxBillingResp struct {
- proto.Envelope
-}
-
// FetchBlockReq defines a request of the FetchBlock RPC method.
type FetchBlockReq struct {
proto.Envelope
@@ -69,16 +58,6 @@ type FetchBlockByCountReq struct {
Count uint32
}
-// FetchTxBillingReq defines a request of the FetchTxBilling RPC method.
-type FetchTxBillingReq struct {
- proto.Envelope
-}
-
-// FetchTxBillingResp defines a response of the FetchTxBilling RPC method.
-type FetchTxBillingResp struct {
- proto.Envelope
-}
-
// NextAccountNonceReq defines a request of the NextAccountNonce RPC method.
type NextAccountNonceReq struct {
proto.Envelope
@@ -167,16 +146,6 @@ func (s *ChainRPCService) AdviseNewBlock(req *AdviseNewBlockReq, resp *AdviseNew
return nil
}
-// AdviseBillingRequest is the RPC method to advise a new billing request to main chain.
-func (s *ChainRPCService) AdviseBillingRequest(req *types.AdviseBillingReq, resp *types.AdviseBillingResp) error {
- response, err := s.chain.produceBilling(req.Req)
- if err != nil {
- return err
- }
- resp.Resp = response
- return nil
-}
-
// FetchBlock is the RPC method to fetch a known block from the target server.
func (s *ChainRPCService) FetchBlock(req *FetchBlockReq, resp *FetchBlockResp) error {
resp.Height = req.Height
@@ -201,11 +170,6 @@ func (s *ChainRPCService) FetchBlockByCount(req *FetchBlockByCountReq, resp *Fet
return err
}
-// FetchTxBilling is the RPC method to fetch a known billing tx from the target server.
-func (s *ChainRPCService) FetchTxBilling(req *FetchTxBillingReq, resp *FetchTxBillingResp) error {
- return nil
-}
-
// NextAccountNonce is the RPC method to query the next nonce of an account.
func (s *ChainRPCService) NextAccountNonce(
req *NextAccountNonceReq, resp *NextAccountNonceResp) (err error,
From 378cddad66eeb8dfbc26f9786b106f540c280681 Mon Sep 17 00:00:00 2001
From: leventeliu
Date: Thu, 13 Dec 2018 16:52:18 +0800
Subject: [PATCH 056/278] Add testing for chain APIs
---
blockproducer/chain_test.go | 35 +++++++++++++++++++++++++++++++++++
1 file changed, 35 insertions(+)
diff --git a/blockproducer/chain_test.go b/blockproducer/chain_test.go
index 4ef698325..1c5d03a83 100644
--- a/blockproducer/chain_test.go
+++ b/blockproducer/chain_test.go
@@ -226,6 +226,41 @@ func TestChain(t *testing.T) {
So(chain, ShouldNotBeNil)
chain.rt.log()
})
+
+ Convey("The chain APIs should return expected results", func() {
+ var (
+ bl *types.BPBlock
+ count, height uint32
+ )
+
+ _, _, err = chain.fetchBlockByHeight(100)
+ So(err, ShouldEqual, ErrNoSuchBlock)
+
+ _, _, err = chain.fetchBlockByCount(100)
+ So(err, ShouldEqual, ErrNoSuchBlock)
+
+ bl, count, err = chain.fetchBlockByHeight(0)
+ So(err, ShouldBeNil)
+ So(count, ShouldEqual, 0)
+ So(bl.BlockHash(), ShouldResemble, genesis.BlockHash())
+
+ bl, height, err = chain.fetchBlockByCount(0)
+ So(err, ShouldBeNil)
+ So(height, ShouldEqual, 0)
+ So(bl.BlockHash(), ShouldResemble, genesis.BlockHash())
+
+ // Try to use the no-cache version
+ var node = chain.rt.headBranch.head.ancestorByCount(5)
+ node.block = nil // Clear cached block
+ bl, count, err = chain.fetchBlockByHeight(node.height)
+ So(err, ShouldBeNil)
+ So(count, ShouldEqual, node.count)
+ So(bl.BlockHash(), ShouldResemble, &node.hash)
+ bl, height, err = chain.fetchBlockByCount(node.count)
+ So(err, ShouldBeNil)
+ So(height, ShouldEqual, node.height)
+ So(bl.BlockHash(), ShouldResemble, &node.hash)
+ })
})
})
}
From c7cd0b1439ff0a6cb5788e30318c525556b6537f Mon Sep 17 00:00:00 2001
From: leventeliu
Date: Thu, 13 Dec 2018 16:58:29 +0800
Subject: [PATCH 057/278] Minor fix for go linter
---
types/issuekeys.go | 2 ++
xenomint/types/block.go | 2 +-
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/types/issuekeys.go b/types/issuekeys.go
index 446a772b0..81f653e20 100644
--- a/types/issuekeys.go
+++ b/types/issuekeys.go
@@ -26,11 +26,13 @@ import (
//go:generate hsp
+// MinerKey defines an encryption key associated with miner address.
type MinerKey struct {
Miner proto.AccountAddress
EncryptionKey string
}
+// IssueKeysHeader defines an encryption key header.
type IssueKeysHeader struct {
TargetSQLChain proto.AccountAddress
MinerKeys []MinerKey
diff --git a/xenomint/types/block.go b/xenomint/types/block.go
index 91e851df2..2621786ab 100644
--- a/xenomint/types/block.go
+++ b/xenomint/types/block.go
@@ -54,7 +54,7 @@ func (h *SignedBlockHeader) Verify() error {
return h.DefaultHashSignVerifierImpl.Verify(&h.BlockHeader)
}
-// BPBlock defines a block including a signed block header and its query list.
+// Block defines a block including a signed block header and its query list.
type Block struct {
SignedBlockHeader
ReadQueries []*types.Ack
From 7552ccd15905725201cfc8a18205d8485e9bc164 Mon Sep 17 00:00:00 2001
From: leventeliu
Date: Thu, 13 Dec 2018 17:37:07 +0800
Subject: [PATCH 058/278] Fix mixin type mismatching
---
blockproducer/chain_test.go | 44 ++++++++++++++++++++++++++++++++-----
types/provideservice.go | 2 +-
2 files changed, 40 insertions(+), 6 deletions(-)
diff --git a/blockproducer/chain_test.go b/blockproducer/chain_test.go
index 1c5d03a83..b071df1bc 100644
--- a/blockproducer/chain_test.go
+++ b/blockproducer/chain_test.go
@@ -56,6 +56,34 @@ func newTransfer(
return
}
+func newCreateDatabase(
+ nonce pi.AccountNonce, signer *asymmetric.PrivateKey,
+ owner proto.AccountAddress,
+) (
+ t *types.CreateDatabase, err error,
+) {
+ t = types.NewCreateDatabase(&types.CreateDatabaseHeader{
+ Owner: owner,
+ Nonce: nonce,
+ })
+ err = t.Sign(signer)
+ return
+}
+
+func newProvideService(
+ nonce pi.AccountNonce, signer *asymmetric.PrivateKey,
+ contract proto.AccountAddress,
+) (
+ t *types.ProvideService, err error,
+) {
+ t = types.NewProvideService(&types.ProvideServiceHeader{
+ Contract: contract,
+ Nonce: nonce,
+ })
+ err = t.Sign(signer)
+ return
+}
+
func TestChain(t *testing.T) {
Convey("Given a new block producer chain", t, func() {
var (
@@ -140,11 +168,13 @@ func TestChain(t *testing.T) {
Convey("When transfer transactions are added", func() {
var (
- nonce pi.AccountNonce
- t1, t2, t3 pi.Transaction
- f0, f1 *branch
- bl *types.BPBlock
+ nonce pi.AccountNonce
+ t1, t2, t3, t4 pi.Transaction
+ f0, f1 *branch
+ bl *types.BPBlock
)
+
+ // Create transactions for testing
nonce, err = chain.rt.nextNonce(addr1)
So(err, ShouldBeNil)
So(nonce, ShouldEqual, 1)
@@ -152,7 +182,9 @@ func TestChain(t *testing.T) {
So(err, ShouldBeNil)
t2, err = newTransfer(nonce+1, priv1, addr1, addr2, 1)
So(err, ShouldBeNil)
- t3, err = newTransfer(nonce+2, priv1, addr1, addr2, 1)
+ t3, err = newCreateDatabase(nonce+2, priv1, addr1)
+ So(err, ShouldBeNil)
+ t4, err = newProvideService(nonce+3, priv1, addr1)
So(err, ShouldBeNil)
// Fork from #0
@@ -184,6 +216,8 @@ func TestChain(t *testing.T) {
err = chain.rt.addTx(chain.st, t3)
So(err, ShouldBeNil)
+ err = chain.rt.addTx(chain.st, t4)
+ So(err, ShouldBeNil)
err = chain.produceBlock(begin.Add(3 * chain.rt.period))
So(err, ShouldBeNil)
// Create a sibling block from fork#1 and apply
diff --git a/types/provideservice.go b/types/provideservice.go
index 9fcd23adc..fdbfbc6c0 100644
--- a/types/provideservice.go
+++ b/types/provideservice.go
@@ -52,7 +52,7 @@ type ProvideService struct {
func NewProvideService(h *ProvideServiceHeader) *ProvideService {
return &ProvideService{
ProvideServiceHeader: *h,
- TransactionTypeMixin: *interfaces.NewTransactionTypeMixin(interfaces.TransactionTypeProvideService),
+ TransactionTypeMixin: *interfaces.NewTransactionTypeMixin(interfaces.TransactionTypeCreateDatabase),
}
}
From d15ab00e80b5339ae669ac7114887e68b15dbb95 Mon Sep 17 00:00:00 2001
From: leventeliu
Date: Thu, 13 Dec 2018 17:40:35 +0800
Subject: [PATCH 059/278] Rename rt to runtime
---
blockproducer/chain.go | 4 +--
blockproducer/helper_test.go | 4 +--
blockproducer/runtime.go | 48 ++++++++++++++++++------------------
3 files changed, 28 insertions(+), 28 deletions(-)
diff --git a/blockproducer/chain.go b/blockproducer/chain.go
index 56d076bcd..c835a5e26 100644
--- a/blockproducer/chain.go
+++ b/blockproducer/chain.go
@@ -55,7 +55,7 @@ var (
// Chain defines the main chain.
type Chain struct {
ctx context.Context
- rt *rt
+ rt *runtime
st xi.Storage
cl *rpc.Caller
bs chainbus.Bus
@@ -85,7 +85,7 @@ func NewChainWithContext(ctx context.Context, cfg *Config) (c *Chain, err error)
pubKey *asymmetric.PublicKey
inst *Chain
- rt *rt
+ rt *runtime
bus = chainbus.New()
caller = rpc.NewCaller()
)
diff --git a/blockproducer/helper_test.go b/blockproducer/helper_test.go
index ce68aca12..0c2520636 100644
--- a/blockproducer/helper_test.go
+++ b/blockproducer/helper_test.go
@@ -23,7 +23,7 @@ import (
"math/rand"
"os"
"path/filepath"
- "runtime"
+ gort "runtime"
"strings"
"sync"
"time"
@@ -165,7 +165,7 @@ func initNode(confRP, privateKeyRP string) (cleanupFunc func(), dht *route.DHTSe
log.WithField("d", d).Debug("created temp dir")
// init conf
- _, testFile, _, _ := runtime.Caller(0)
+ _, testFile, _, _ := gort.Caller(0)
pubKeyStoreFile := filepath.Join(d, PubKeyStorePath)
os.Remove(pubKeyStoreFile)
clientPubKeyStoreFile := filepath.Join(d, PubKeyStorePath+"_c")
diff --git a/blockproducer/runtime.go b/blockproducer/runtime.go
index f02df0168..51e304cb6 100644
--- a/blockproducer/runtime.go
+++ b/blockproducer/runtime.go
@@ -35,8 +35,8 @@ import (
"github.com/pkg/errors"
)
-// rt defines the runtime of main chain.
-type rt struct {
+// runtime defines the runtime of main chain.
+type runtime struct {
ctx context.Context
cancel context.CancelFunc
wg *sync.WaitGroup
@@ -67,7 +67,7 @@ type rt struct {
func newRuntime(
ctx context.Context, cfg *Config, accountAddress proto.AccountAddress,
irre *blockNode, heads []*blockNode, immutable *metaState, txPool map[hash.Hash]pi.Transaction,
-) *rt {
+) *runtime {
var index uint32
for i, s := range cfg.Peers.Servers {
if cfg.NodeID.IsEqual(&s) {
@@ -119,7 +119,7 @@ func newRuntime(
}
}
- return &rt{
+ return &runtime{
ctx: cld,
cancel: ccl,
wg: &sync.WaitGroup{},
@@ -147,7 +147,7 @@ func newRuntime(
}
}
-func (r *rt) addTx(st xi.Storage, tx pi.Transaction) (err error) {
+func (r *runtime) addTx(st xi.Storage, tx pi.Transaction) (err error) {
var k = tx.Hash()
r.Lock()
defer r.Unlock()
@@ -164,25 +164,25 @@ func (r *rt) addTx(st xi.Storage, tx pi.Transaction) (err error) {
})
}
-func (r *rt) nextNonce(addr proto.AccountAddress) (n pi.AccountNonce, err error) {
+func (r *runtime) nextNonce(addr proto.AccountAddress) (n pi.AccountNonce, err error) {
r.RLock()
defer r.RUnlock()
return r.headBranch.preview.nextNonce(addr)
}
-func (r *rt) loadAccountCovenantBalance(addr proto.AccountAddress) (balance uint64, ok bool) {
+func (r *runtime) loadAccountCovenantBalance(addr proto.AccountAddress) (balance uint64, ok bool) {
r.RLock()
defer r.RUnlock()
return r.immutable.loadAccountCovenantBalance(addr)
}
-func (r *rt) loadAccountStableBalance(addr proto.AccountAddress) (balance uint64, ok bool) {
+func (r *runtime) loadAccountStableBalance(addr proto.AccountAddress) (balance uint64, ok bool) {
r.RLock()
defer r.RUnlock()
return r.immutable.loadAccountStableBalance(addr)
}
-func (r *rt) switchBranch(st xi.Storage, bl *types.BPBlock, origin int, head *branch) (err error) {
+func (r *runtime) switchBranch(st xi.Storage, bl *types.BPBlock, origin int, head *branch) (err error) {
var (
irre *blockNode
newIrres []*blockNode
@@ -289,7 +289,7 @@ func (r *rt) switchBranch(st xi.Storage, bl *types.BPBlock, origin int, head *br
return
}
-func (r *rt) log() {
+func (r *runtime) log() {
r.RLock()
defer r.RUnlock()
for i, v := range r.branches {
@@ -307,7 +307,7 @@ func (r *rt) log() {
return
}
-func (r *rt) applyBlock(st xi.Storage, bl *types.BPBlock) (err error) {
+func (r *runtime) applyBlock(st xi.Storage, bl *types.BPBlock) (err error) {
var (
ok bool
br *branch
@@ -355,7 +355,7 @@ func (r *rt) applyBlock(st xi.Storage, bl *types.BPBlock) (err error) {
return
}
-func (r *rt) produceBlock(
+func (r *runtime) produceBlock(
st xi.Storage, now time.Time, priv *asymmetric.PrivateKey) (out *types.BPBlock, err error,
) {
var (
@@ -386,20 +386,20 @@ func (r *rt) produceBlock(
}
// now returns the current coordinated chain time.
-func (r *rt) now() time.Time {
+func (r *runtime) now() time.Time {
r.RLock()
defer r.RUnlock()
return time.Now().UTC().Add(r.offset)
}
-func (r *rt) startService(chain *Chain) {
+func (r *runtime) startService(chain *Chain) {
r.server.RegisterService(route.BlockProducerRPCName, &ChainRPCService{chain: chain})
}
// nextTick returns the current clock reading and the duration till the next turn. If duration
// is less or equal to 0, use the clock reading to run the next cycle - this avoids some problem
// caused by concurrent time synchronization.
-func (r *rt) nextTick() (t time.Time, d time.Duration) {
+func (r *runtime) nextTick() (t time.Time, d time.Duration) {
var nt uint32
nt, t = func() (nt uint32, t time.Time) {
r.RLock()
@@ -415,20 +415,20 @@ func (r *rt) nextTick() (t time.Time, d time.Duration) {
return
}
-func (r *rt) isMyTurn() bool {
+func (r *runtime) isMyTurn() bool {
r.RLock()
defer r.RUnlock()
return r.nextTurn%r.serversNum == r.locSvIndex
}
// setNextTurn prepares the runtime state for the next turn.
-func (r *rt) setNextTurn() {
+func (r *runtime) setNextTurn() {
r.Lock()
defer r.Unlock()
r.nextTurn++
}
-func (r *rt) peerInfo() string {
+func (r *runtime) peerInfo() string {
var index, bpNum, nodeID = func() (uint32, uint32, proto.NodeID) {
r.RLock()
defer r.RUnlock()
@@ -438,35 +438,35 @@ func (r *rt) peerInfo() string {
}
// height calculates the height with this sql-chain config of a given time reading.
-func (r *rt) height(t time.Time) uint32 {
+func (r *runtime) height(t time.Time) uint32 {
return uint32(t.Sub(r.genesisTime) / r.period)
}
-func (r *rt) getNextTurn() uint32 {
+func (r *runtime) getNextTurn() uint32 {
r.RLock()
defer r.RUnlock()
return r.nextTurn
}
-func (r *rt) getPeers() *proto.Peers {
+func (r *runtime) getPeers() *proto.Peers {
r.RLock()
defer r.RUnlock()
var peers = r.peers.Clone()
return &peers
}
-func (r *rt) head() *blockNode {
+func (r *runtime) head() *blockNode {
r.RLock()
defer r.RUnlock()
return r.headBranch.head
}
-func (r *rt) stop() {
+func (r *runtime) stop() {
r.cancel()
r.wg.Wait()
}
-func (r *rt) goFunc(f func(ctx context.Context)) {
+func (r *runtime) goFunc(f func(ctx context.Context)) {
r.wg.Add(1)
go func() {
defer r.wg.Done()
From c951efd8993463555115330fc74be834da83e6b0 Mon Sep 17 00:00:00 2001
From: leventeliu
Date: Thu, 13 Dec 2018 17:54:19 +0800
Subject: [PATCH 060/278] Add a convey testing branch
This covers storage updating and reloading of some other state objects.
---
blockproducer/chain_test.go | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/blockproducer/chain_test.go b/blockproducer/chain_test.go
index b071df1bc..bafb6bdf4 100644
--- a/blockproducer/chain_test.go
+++ b/blockproducer/chain_test.go
@@ -240,6 +240,23 @@ func TestChain(t *testing.T) {
So(err, ShouldBeNil)
}
+ Convey("The chain immutable should be updated to irreversible block", func() {
+ // Add more blocks to trigger immutable updating
+ for i := uint32(7); i <= 12; i++ {
+ err = chain.produceBlock(begin.Add(time.Duration(i) * chain.rt.period))
+ So(err, ShouldBeNil)
+ }
+ Convey("The chain should have same state after reloading", func() {
+ err = chain.Stop()
+ So(err, ShouldBeNil)
+ chain, err = NewChain(config)
+ So(err, ShouldBeNil)
+ So(chain, ShouldNotBeNil)
+ chain.rt.log()
+ })
+
+ })
+
// Add 2 more blocks to fork #1, this should trigger a branch switch to fork #1
f1, bl, err = f1.produceBlock(7, begin.Add(8*chain.rt.period), addr2, priv2)
So(err, ShouldBeNil)
From 1cb67837ab1f4ab75a35487341372c5ce16962ba Mon Sep 17 00:00:00 2001
From: leventeliu
Date: Thu, 13 Dec 2018 20:27:10 +0800
Subject: [PATCH 061/278] Use block height to discover genesis
This avoids some problems in old testing data (such as using a
0x....0001 root hash).
---
blockproducer/storage.go | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/blockproducer/storage.go b/blockproducer/storage.go
index 78ecd2190..8bb779b6e 100644
--- a/blockproducer/storage.go
+++ b/blockproducer/storage.go
@@ -311,7 +311,6 @@ func loadBlocks(
var (
rows *sql.Rows
- root = hash.Hash{}
index = make(map[hash.Hash]*blockNode)
headsIndex = make(map[hash.Hash]*blockNode)
@@ -356,7 +355,7 @@ func loadBlocks(
"parent": ph.Short(4),
}).Debug("Loaded new block")
// Add genesis block
- if ph.IsEqual(&root) {
+ if v1 == 0 {
if len(index) != 0 {
err = ErrMultipleGenesis
return
From 80c1a2b56e5bfb7b225d683dc35729b36254bd55 Mon Sep 17 00:00:00 2001
From: zeqing-guo
Date: Fri, 14 Dec 2018 03:17:03 +0800
Subject: [PATCH 062/278] Create sqlchain using transaction
---
blockproducer/metastate.go | 13 ++++++
blockproducer/rpc.go | 18 +++++++-
blockproducer/runtime.go | 8 ++++
route/acl.go | 5 ++-
sqlchain/chainbusservice.go | 12 +++++
types/account.go | 4 +-
types/account_gen.go | 54 ++++++++++++++---------
types/bprpc.go | 13 ++++++
types/no_ack_report_type_gen.go | 43 +++---------------
types/provideservice.go | 1 +
types/provideservice_gen.go | 26 ++++++-----
worker/dbms.go | 78 +++++++++++++++++++++++++++++++++
worker/errors.go | 3 ++
13 files changed, 205 insertions(+), 73 deletions(-)
diff --git a/blockproducer/metastate.go b/blockproducer/metastate.go
index 46c3cf4e8..8b391c11b 100644
--- a/blockproducer/metastate.go
+++ b/blockproducer/metastate.go
@@ -873,6 +873,7 @@ func (s *metaState) updateProviderList(tx *pt.ProvideService) (err error) {
TargetUser: tx.TargetUser,
Deposit: minDeposit,
GasPrice: tx.GasPrice,
+ NodeID: tx.NodeID,
}
s.loadOrStoreProviderObject(sender, &providerObject{ProviderProfile: pp})
return
@@ -904,6 +905,10 @@ func (s *metaState) matchProvidersWithUser(tx *pt.CreateDatabase) (err error) {
return
}
+ var (
+ miners [len(tx.ResourceMeta.TargetMiners)]*pt.MinerInfo
+ )
+
for i := range tx.ResourceMeta.TargetMiners {
if po, loaded := s.loadProviderObject(tx.ResourceMeta.TargetMiners[i]); !loaded {
log.WithFields(log.Fields{
@@ -925,6 +930,11 @@ func (s *metaState) matchProvidersWithUser(tx *pt.CreateDatabase) (err error) {
err = ErrGasPriceMismatch
break
}
+ miners[i] = &pt.MinerInfo{
+ Address: po.Provider,
+ NodeID: po.NodeID,
+ Deposit: po.Deposit,
+ }
}
}
if err != nil {
@@ -964,6 +974,7 @@ func (s *metaState) matchProvidersWithUser(tx *pt.CreateDatabase) (err error) {
}).WithError(err).Error("unexpected error")
return err
}
+
// create sqlchain
sp := &pt.SQLChainProfile{
ID: *dbID,
@@ -974,7 +985,9 @@ func (s *metaState) matchProvidersWithUser(tx *pt.CreateDatabase) (err error) {
Owner: sender,
Users: users,
Genesis: gb,
+ Miners: miners[:],
}
+
if _, loaded := s.loadSQLChainObject(*dbID); loaded {
err = errors.Wrapf(ErrDatabaseExists, "database exists: %s", string(*dbID))
return
diff --git a/blockproducer/rpc.go b/blockproducer/rpc.go
index f776cd0bd..b62c58517 100644
--- a/blockproducer/rpc.go
+++ b/blockproducer/rpc.go
@@ -18,6 +18,7 @@ package blockproducer
import (
"github.com/CovenantSQL/CovenantSQL/types"
+ "github.com/pkg/errors"
)
// ChainRPCService defines a main chain RPC server.
@@ -103,7 +104,7 @@ func (s *ChainRPCService) AddTx(req *types.AddTxReq, resp *types.AddTxResp) (err
return
}
-// QueryAccountStableBalance is the RPC method to query acccount stable coin balance.
+// QueryAccountStableBalance is the RPC method to query account stable coin balance.
func (s *ChainRPCService) QueryAccountStableBalance(
req *types.QueryAccountStableBalanceReq, resp *types.QueryAccountStableBalanceResp) (err error,
) {
@@ -112,7 +113,7 @@ func (s *ChainRPCService) QueryAccountStableBalance(
return
}
-// QueryAccountCovenantBalance is the RPC method to query acccount covenant coin balance.
+// QueryAccountCovenantBalance is the RPC method to query account covenant coin balance.
func (s *ChainRPCService) QueryAccountCovenantBalance(
req *types.QueryAccountCovenantBalanceReq, resp *types.QueryAccountCovenantBalanceResp) (err error,
) {
@@ -121,6 +122,19 @@ func (s *ChainRPCService) QueryAccountCovenantBalance(
return
}
+// QuerySQLChainProfile is the RPC method to query SQLChainProfile.
+func (s *ChainRPCService) QuerySQLChainProfile(req *types.QuerySQLChainProfileReq,
+ resp *types.QuerySQLChainProfileResp) (err error) {
+ p, ok := s.chain.rt.loadSQLChainProfile(req.DBID)
+ if ok {
+ resp.Profile = *p
+ return
+ } else {
+ err = errors.Wrap(err, "rpc query sqlchain profile failed")
+ return
+ }
+}
+
// Sub is the RPC method to subscribe some event.
func (s *ChainRPCService) Sub(req *types.SubReq, resp *types.SubResp) (err error) {
return s.chain.bs.Subscribe(req.Topic, func(request interface{}, response interface{}) {
diff --git a/blockproducer/runtime.go b/blockproducer/runtime.go
index 277e5408b..c03e3685d 100644
--- a/blockproducer/runtime.go
+++ b/blockproducer/runtime.go
@@ -182,6 +182,14 @@ func (r *rt) loadAccountStableBalance(addr proto.AccountAddress) (balance uint64
return r.immutable.loadAccountStableBalance(addr)
}
+func (r *rt) loadSQLChainProfile(dbid proto.DatabaseID) (p *types.SQLChainProfile, ok bool) {
+ r.RLock()
+ defer r.RUnlock()
+ so, ok := r.immutable.loadSQLChainObject(dbid)
+ p = &so.SQLChainProfile
+ return
+}
+
func (r *rt) switchBranch(st xi.Storage, bl *types.BPBlock, origin int, head *branch) (err error) {
var (
irre *blockNode
diff --git a/route/acl.go b/route/acl.go
index e79065880..4705f9da3 100644
--- a/route/acl.go
+++ b/route/acl.go
@@ -127,7 +127,8 @@ const (
MCCQueryAccountStableBalance
// MCCQueryAccountCovenantBalance is used by block producer to provide account covenant coin balance
MCCQueryAccountCovenantBalance
-
+ // MCCQuerySQLChainProfile is used by nodes to to query SQLChainProfile.
+ MCCQuerySQLChainProfile
// DHTRPCName defines the block producer dh-rpc service name
DHTRPCName = "DHT"
// BlockProducerRPCName defines main chain rpc name
@@ -211,6 +212,8 @@ func (s RemoteFunc) String() string {
return "MCC.QueryAccountStableBalance"
case MCCQueryAccountCovenantBalance:
return "MCC.QueryAccountCovenantBalance"
+ case MCCQuerySQLChainProfile:
+ return "MCC.QuerySQLChainProfile"
}
return "Unknown"
}
diff --git a/sqlchain/chainbusservice.go b/sqlchain/chainbusservice.go
index 219f2e884..ec7bf62d6 100644
--- a/sqlchain/chainbusservice.go
+++ b/sqlchain/chainbusservice.go
@@ -107,6 +107,18 @@ func (bs *BusService) requestBlock(count uint32) (block *types.BPBlock) {
return
}
+func (bs *BusService) RequestSQLProfile(dbid *proto.DatabaseID) (p *types.SQLChainProfile) {
+ req := &types.QuerySQLChainProfileReq{DBID: *dbid}
+ resp := &types.QuerySQLChainProfileResp{}
+ if err := bs.requestBP(route.MCCQuerySQLChainProfile.String(), req, resp); err != nil {
+ log.WithError(err).Warning("fetch sqlchain profile failed")
+ return
+ }
+
+ p = &resp.Profile
+ return
+}
+
func (bs *BusService) requestBP(method string, request interface{}, response interface{}) (err error) {
var bpNodeID proto.NodeID
if bpNodeID, err = rpc.GetCurrentBP(); err != nil {
diff --git a/types/account.go b/types/account.go
index c00c7f53e..61f830973 100644
--- a/types/account.go
+++ b/types/account.go
@@ -78,10 +78,11 @@ type SQLChainUser struct {
// MinerInfo defines a miner.
type MinerInfo struct {
Address proto.AccountAddress
+ NodeID proto.NodeID
Name string
PendingIncome uint64
ReceivedIncome uint64
- Pledge uint64
+ Deposit uint64
Status Status
EncryptionKey string
}
@@ -114,6 +115,7 @@ type ProviderProfile struct {
Deposit uint64 // default 10 Particle
GasPrice uint64
TokenType TokenType // default Particle
+ NodeID proto.NodeID
}
// Account store its balance, and other mate data.
diff --git a/types/account_gen.go b/types/account_gen.go
index cffef3709..f8a039898 100644
--- a/types/account_gen.go
+++ b/types/account_gen.go
@@ -43,31 +43,37 @@ func (z *Account) Msgsize() (s int) {
func (z *MinerInfo) MarshalHash() (o []byte, err error) {
var b []byte
o = hsp.Require(b, z.Msgsize())
- // map header, size 7
- o = append(o, 0x87, 0x87)
+ // map header, size 8
+ o = append(o, 0x88, 0x88)
o = hsp.AppendInt32(o, int32(z.Status))
- o = append(o, 0x87)
+ o = append(o, 0x88)
if oTemp, err := z.Address.MarshalHash(); err != nil {
return nil, err
} else {
o = hsp.AppendBytes(o, oTemp)
}
- o = append(o, 0x87)
+ o = append(o, 0x88)
+ if oTemp, err := z.NodeID.MarshalHash(); err != nil {
+ return nil, err
+ } else {
+ o = hsp.AppendBytes(o, oTemp)
+ }
+ o = append(o, 0x88)
o = hsp.AppendString(o, z.Name)
- o = append(o, 0x87)
+ o = append(o, 0x88)
o = hsp.AppendString(o, z.EncryptionKey)
- o = append(o, 0x87)
+ o = append(o, 0x88)
o = hsp.AppendUint64(o, z.PendingIncome)
- o = append(o, 0x87)
+ o = append(o, 0x88)
o = hsp.AppendUint64(o, z.ReceivedIncome)
- o = append(o, 0x87)
- o = hsp.AppendUint64(o, z.Pledge)
+ o = append(o, 0x88)
+ o = hsp.AppendUint64(o, z.Deposit)
return
}
// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (z *MinerInfo) Msgsize() (s int) {
- s = 1 + 7 + hsp.Int32Size + 8 + z.Address.Msgsize() + 5 + hsp.StringPrefixSize + len(z.Name) + 14 + hsp.StringPrefixSize + len(z.EncryptionKey) + 14 + hsp.Uint64Size + 15 + hsp.Uint64Size + 7 + hsp.Uint64Size
+ s = 1 + 7 + hsp.Int32Size + 8 + z.Address.Msgsize() + 7 + z.NodeID.Msgsize() + 5 + hsp.StringPrefixSize + len(z.Name) + 14 + hsp.StringPrefixSize + len(z.EncryptionKey) + 14 + hsp.Uint64Size + 15 + hsp.Uint64Size + 8 + hsp.Uint64Size
return
}
@@ -75,41 +81,47 @@ func (z *MinerInfo) Msgsize() (s int) {
func (z *ProviderProfile) MarshalHash() (o []byte, err error) {
var b []byte
o = hsp.Require(b, z.Msgsize())
- // map header, size 8
- o = append(o, 0x88, 0x88)
+ // map header, size 9
+ o = append(o, 0x89, 0x89)
if oTemp, err := z.TokenType.MarshalHash(); err != nil {
return nil, err
} else {
o = hsp.AppendBytes(o, oTemp)
}
- o = append(o, 0x88)
+ o = append(o, 0x89)
if oTemp, err := z.Provider.MarshalHash(); err != nil {
return nil, err
} else {
o = hsp.AppendBytes(o, oTemp)
}
- o = append(o, 0x88)
+ o = append(o, 0x89)
if oTemp, err := z.TargetUser.MarshalHash(); err != nil {
return nil, err
} else {
o = hsp.AppendBytes(o, oTemp)
}
- o = append(o, 0x88)
- o = hsp.AppendUint64(o, z.Memory)
- o = append(o, 0x88)
+ o = append(o, 0x89)
+ if oTemp, err := z.NodeID.MarshalHash(); err != nil {
+ return nil, err
+ } else {
+ o = hsp.AppendBytes(o, oTemp)
+ }
+ o = append(o, 0x89)
o = hsp.AppendUint64(o, z.LoadAvgPerCPU)
- o = append(o, 0x88)
+ o = append(o, 0x89)
o = hsp.AppendUint64(o, z.Deposit)
- o = append(o, 0x88)
+ o = append(o, 0x89)
o = hsp.AppendUint64(o, z.GasPrice)
- o = append(o, 0x88)
+ o = append(o, 0x89)
o = hsp.AppendUint64(o, z.Space)
+ o = append(o, 0x89)
+ o = hsp.AppendUint64(o, z.Memory)
return
}
// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (z *ProviderProfile) Msgsize() (s int) {
- s = 1 + 10 + z.TokenType.Msgsize() + 9 + z.Provider.Msgsize() + 11 + z.TargetUser.Msgsize() + 7 + hsp.Uint64Size + 14 + hsp.Uint64Size + 8 + hsp.Uint64Size + 9 + hsp.Uint64Size + 6 + hsp.Uint64Size
+ s = 1 + 10 + z.TokenType.Msgsize() + 9 + z.Provider.Msgsize() + 11 + z.TargetUser.Msgsize() + 7 + z.NodeID.Msgsize() + 14 + hsp.Uint64Size + 8 + hsp.Uint64Size + 9 + hsp.Uint64Size + 6 + hsp.Uint64Size + 7 + hsp.Uint64Size
return
}
diff --git a/types/bprpc.go b/types/bprpc.go
index 76cc95487..59e1b9ad2 100644
--- a/types/bprpc.go
+++ b/types/bprpc.go
@@ -158,3 +158,16 @@ type QueryAccountCovenantBalanceResp struct {
OK bool
Balance uint64
}
+
+// QuerySQLChainProfileReq defines a request of the QuerySQLChainProfile RPC method.
+type QuerySQLChainProfileReq struct {
+ proto.Envelope
+ DBID proto.DatabaseID
+}
+
+// QuerySQLChainProfileResp defines a response of the QuerySQLChainProfile RPC method.
+type QuerySQLChainProfileResp struct {
+ proto.Envelope
+ Profile SQLChainProfile
+}
+
diff --git a/types/no_ack_report_type_gen.go b/types/no_ack_report_type_gen.go
index daedbcdf6..e9e89abc6 100644
--- a/types/no_ack_report_type_gen.go
+++ b/types/no_ack_report_type_gen.go
@@ -57,24 +57,7 @@ func (z *AggrNoAckReportHeader) MarshalHash() (o []byte, err error) {
o = append(o, 0x84)
o = hsp.AppendArrayHeader(o, uint32(len(z.Reports)))
for za0001 := range z.Reports {
- // map header, size 2
- // map header, size 3
- o = append(o, 0x82, 0x82, 0x83, 0x83)
- if oTemp, err := z.Reports[za0001].NoAckReportHeader.NodeID.MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
- }
- o = append(o, 0x83)
- o = hsp.AppendTime(o, z.Reports[za0001].NoAckReportHeader.Timestamp)
- o = append(o, 0x83)
- if oTemp, err := z.Reports[za0001].NoAckReportHeader.Response.MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
- }
- o = append(o, 0x82)
- if oTemp, err := z.Reports[za0001].DefaultHashSignVerifierImpl.MarshalHash(); err != nil {
+ if oTemp, err := z.Reports[za0001].MarshalHash(); err != nil {
return nil, err
} else {
o = hsp.AppendBytes(o, oTemp)
@@ -101,7 +84,7 @@ func (z *AggrNoAckReportHeader) Msgsize() (s int) {
}
s += 8 + hsp.ArrayHeaderSize
for za0001 := range z.Reports {
- s += 1 + 18 + 1 + 7 + z.Reports[za0001].NoAckReportHeader.NodeID.Msgsize() + 10 + hsp.TimeSize + 9 + z.Reports[za0001].NoAckReportHeader.Response.Msgsize() + 28 + z.Reports[za0001].DefaultHashSignVerifierImpl.Msgsize()
+ s += z.Reports[za0001].Msgsize()
}
s += 7 + z.NodeID.Msgsize() + 10 + hsp.TimeSize
return
@@ -112,24 +95,8 @@ func (z *NoAckReport) MarshalHash() (o []byte, err error) {
var b []byte
o = hsp.Require(b, z.Msgsize())
// map header, size 2
- // map header, size 2
- // map header, size 3
- o = append(o, 0x82, 0x82, 0x82, 0x82, 0x83, 0x83)
- if oTemp, err := z.Header.NoAckReportHeader.NodeID.MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
- }
- o = append(o, 0x83)
- o = hsp.AppendTime(o, z.Header.NoAckReportHeader.Timestamp)
- o = append(o, 0x83)
- if oTemp, err := z.Header.NoAckReportHeader.Response.MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
- }
- o = append(o, 0x82)
- if oTemp, err := z.Header.DefaultHashSignVerifierImpl.MarshalHash(); err != nil {
+ o = append(o, 0x82, 0x82)
+ if oTemp, err := z.Header.MarshalHash(); err != nil {
return nil, err
} else {
o = hsp.AppendBytes(o, oTemp)
@@ -145,7 +112,7 @@ func (z *NoAckReport) MarshalHash() (o []byte, err error) {
// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (z *NoAckReport) Msgsize() (s int) {
- s = 1 + 7 + 1 + 18 + 1 + 7 + z.Header.NoAckReportHeader.NodeID.Msgsize() + 10 + hsp.TimeSize + 9 + z.Header.NoAckReportHeader.Response.Msgsize() + 28 + z.Header.DefaultHashSignVerifierImpl.Msgsize() + 9 + z.Envelope.Msgsize()
+ s = 1 + 7 + z.Header.Msgsize() + 9 + z.Envelope.Msgsize()
return
}
diff --git a/types/provideservice.go b/types/provideservice.go
index 8d51cdcf4..9b7c8c4bb 100644
--- a/types/provideservice.go
+++ b/types/provideservice.go
@@ -34,6 +34,7 @@ type ProvideServiceHeader struct {
TargetUser proto.AccountAddress
GasPrice uint64
TokenType TokenType
+ NodeID proto.NodeID
Nonce interfaces.AccountNonce
}
diff --git a/types/provideservice_gen.go b/types/provideservice_gen.go
index d1528f271..d64e178d7 100644
--- a/types/provideservice_gen.go
+++ b/types/provideservice_gen.go
@@ -42,38 +42,44 @@ func (z *ProvideService) Msgsize() (s int) {
func (z *ProvideServiceHeader) MarshalHash() (o []byte, err error) {
var b []byte
o = hsp.Require(b, z.Msgsize())
- // map header, size 7
- o = append(o, 0x87, 0x87)
+ // map header, size 8
+ o = append(o, 0x88, 0x88)
if oTemp, err := z.TokenType.MarshalHash(); err != nil {
return nil, err
} else {
o = hsp.AppendBytes(o, oTemp)
}
- o = append(o, 0x87)
+ o = append(o, 0x88)
if oTemp, err := z.Nonce.MarshalHash(); err != nil {
return nil, err
} else {
o = hsp.AppendBytes(o, oTemp)
}
- o = append(o, 0x87)
+ o = append(o, 0x88)
if oTemp, err := z.TargetUser.MarshalHash(); err != nil {
return nil, err
} else {
o = hsp.AppendBytes(o, oTemp)
}
- o = append(o, 0x87)
- o = hsp.AppendUint64(o, z.Memory)
- o = append(o, 0x87)
+ o = append(o, 0x88)
+ if oTemp, err := z.NodeID.MarshalHash(); err != nil {
+ return nil, err
+ } else {
+ o = hsp.AppendBytes(o, oTemp)
+ }
+ o = append(o, 0x88)
o = hsp.AppendUint64(o, z.LoadAvgPerCPU)
- o = append(o, 0x87)
+ o = append(o, 0x88)
o = hsp.AppendUint64(o, z.GasPrice)
- o = append(o, 0x87)
+ o = append(o, 0x88)
o = hsp.AppendUint64(o, z.Space)
+ o = append(o, 0x88)
+ o = hsp.AppendUint64(o, z.Memory)
return
}
// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (z *ProvideServiceHeader) Msgsize() (s int) {
- s = 1 + 10 + z.TokenType.Msgsize() + 6 + z.Nonce.Msgsize() + 11 + z.TargetUser.Msgsize() + 7 + hsp.Uint64Size + 14 + hsp.Uint64Size + 9 + hsp.Uint64Size + 6 + hsp.Uint64Size
+ s = 1 + 10 + z.TokenType.Msgsize() + 6 + z.Nonce.Msgsize() + 11 + z.TargetUser.Msgsize() + 7 + z.NodeID.Msgsize() + 14 + hsp.Uint64Size + 9 + hsp.Uint64Size + 6 + hsp.Uint64Size + 7 + hsp.Uint64Size
return
}
diff --git a/worker/dbms.go b/worker/dbms.go
index 61e7e76aa..468d9227e 100644
--- a/worker/dbms.go
+++ b/worker/dbms.go
@@ -18,6 +18,10 @@ package worker
import (
"bytes"
+ "context"
+ "github.com/CovenantSQL/CovenantSQL/blockproducer/interfaces"
+ "github.com/CovenantSQL/CovenantSQL/crypto/asymmetric"
+ "github.com/CovenantSQL/CovenantSQL/crypto/kms"
"io/ioutil"
"os"
"path/filepath"
@@ -40,6 +44,8 @@ const (
// DBMetaFileName defines dbms meta file name.
DBMetaFileName = "db.meta"
+
+ CheckInterval = 1
)
// DBMS defines a database management instance.
@@ -51,6 +57,8 @@ type DBMS struct {
rpc *DBMSRPCService
// TODO(lambda): change it to chain bus after chain bus finished.
profileMap map[proto.DatabaseID]*types.SQLChainProfile
+ busService *sqlchain.BusService
+ address proto.AccountAddress
}
// NewDBMS returns new database management instance.
@@ -71,9 +79,30 @@ func NewDBMS(cfg *DBMSConfig) (dbms *DBMS, err error) {
return
}
+ // init chain bus service
+ ctx := context.Background()
+ bs := sqlchain.NewBusService(ctx, CheckInterval)
+ dbms.busService = bs
+
+ // cache address of node
+ var (
+ pk *asymmetric.PublicKey
+ addr proto.AccountAddress
+ )
+ if pk, err = kms.GetLocalPublicKey(); err != nil {
+ err = errors.Wrap(err, "failed to cache public key")
+ return
+ }
+ if addr, err = crypto.PubKeyHash(pk); err != nil {
+ err = errors.Wrap(err, "generate address failed")
+ return
+ }
+ dbms.address = addr
+
// init service
dbms.rpc = NewDBMSRPCService(route.DBRPCName, cfg.Server, dbms)
+
return
}
@@ -146,9 +175,56 @@ func (dbms *DBMS) Init() (err error) {
return
}
+ dbms.busService.Start()
+ if err = dbms.busService.Subscribe("CreateDatabase", dbms.createDatabase); err != nil {
+ err = errors.Wrap(err, "init chain bus failed")
+ return
+ }
+
return
}
+func (dbms *DBMS) createDatabase(tx interfaces.Transaction) {
+ var cd *types.CreateDatabase
+ switch t := tx.(type) {
+ case *types.CreateDatabase:
+ cd = t
+ default:
+ log.WithFields(log.Fields{
+ "tx_type": t.GetTransactionType().String(),
+ "tx_hash": t.Hash().String(),
+ "tx_addr": t.GetAccountAddress().String(),
+ }).WithError(ErrInvalidTransactionType)
+ }
+
+ if cd.Owner != dbms.address {
+ return
+ }
+
+ dbid := proto.FromAccountAndNonce(cd.Owner, uint32(cd.Nonce))
+ p := dbms.busService.RequestSQLProfile(dbid)
+ var nodeIDs [len(p.Miners)]proto.NodeID
+ for i, mi := range p.Miners {
+ nodeIDs[i] = mi.NodeID
+ }
+ peers := proto.Peers{
+ PeersHeader: proto.PeersHeader{
+ Leader: nodeIDs[0],
+ Servers: nodeIDs[:],
+ },
+ }
+ si := types.ServiceInstance{
+ DatabaseID: *dbid,
+ Peers: &peers,
+ ResourceMeta: cd.ResourceMeta,
+ GenesisBlock: p.Genesis,
+ }
+ err := dbms.Create(&si, true)
+ if err != nil {
+ log.WithError(err).Error("create database error")
+ }
+}
+
func (dbms *DBMS) initDatabases(meta *DBMSMeta, conf []types.ServiceInstance) (err error) {
currentInstance := make(map[proto.DatabaseID]bool)
@@ -397,5 +473,7 @@ func (dbms *DBMS) Shutdown() (err error) {
// persist meta
err = dbms.writeMeta()
+ dbms.busService.Stop()
+
return
}
diff --git a/worker/errors.go b/worker/errors.go
index cd754221f..56d6b7473 100644
--- a/worker/errors.go
+++ b/worker/errors.go
@@ -48,4 +48,7 @@ var (
// ErrInvalidPermission indicates that the requester sends a unrecognized permission.
ErrInvalidPermission = errors.New("invalid permission")
+
+ // ErrInvalidTransactionType indicates that the transaction type is invalid.
+ ErrInvalidTransactionType = errors.New("invalid transaction type")
)
From a8416e0e3a20f5f1b972c0ac1fcbd2543a39db0e Mon Sep 17 00:00:00 2001
From: leventeliu
Date: Fri, 14 Dec 2018 16:21:16 +0800
Subject: [PATCH 063/278] Avoid to create new branch on existed block
---
blockproducer/runtime.go | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/blockproducer/runtime.go b/blockproducer/runtime.go
index 51e304cb6..bdf7b0eb8 100644
--- a/blockproducer/runtime.go
+++ b/blockproducer/runtime.go
@@ -135,7 +135,7 @@ func newRuntime(
comfirms: uint32(m),
serversNum: uint32(len(cfg.Peers.Servers)),
locSvIndex: index,
- nextTurn: 1,
+ nextTurn: irre.height + 1,
offset: time.Duration(0),
lastIrre: irre,
@@ -310,6 +310,7 @@ func (r *runtime) log() {
func (r *runtime) applyBlock(st xi.Storage, bl *types.BPBlock) (err error) {
var (
ok bool
+ ierr error
br *branch
parent *blockNode
head *blockNode
@@ -324,7 +325,8 @@ func (r *runtime) applyBlock(st xi.Storage, bl *types.BPBlock) (err error) {
// Grow a branch
if v.head.hash.IsEqual(&bl.SignedHeader.ParentHash) {
head = newBlockNode(height, bl, v.head)
- if br, err = v.applyBlock(head); err != nil {
+ if br, ierr = v.applyBlock(head); ierr != nil {
+ err = errors.Wrapf(ierr, "failed to apply block %s", head.hash.Short(4))
return
}
// Grow a branch while the current branch is not changed
@@ -338,11 +340,17 @@ func (r *runtime) applyBlock(st xi.Storage, bl *types.BPBlock) (err error) {
return r.switchBranch(st, bl, i, br)
}
}
+
for _, v := range r.branches {
+ if n := v.head.ancestor(height); n != nil && n.hash.IsEqual(bl.BlockHash()) {
+ // Return silently if block exists in the current branch
+ return
+ }
// Fork and create new branch
if parent, ok = v.head.canForkFrom(bl.SignedHeader.ParentHash, r.lastIrre.count); ok {
head = newBlockNode(height, bl, parent)
- if br, err = fork(r.lastIrre, head, r.immutable, r.txPool); err != nil {
+ if br, ierr = fork(r.lastIrre, head, r.immutable, r.txPool); ierr != nil {
+ err = errors.Wrapf(ierr, "failed to fork from %s", parent.hash.Short(4))
return
}
return store(st,
@@ -352,6 +360,7 @@ func (r *runtime) applyBlock(st xi.Storage, bl *types.BPBlock) (err error) {
}
}
+ err = ErrParentNotFound
return
}
From 393a984b07cb440ad513775242ec8d5aa043b030 Mon Sep 17 00:00:00 2001
From: leventeliu
Date: Fri, 14 Dec 2018 16:21:53 +0800
Subject: [PATCH 064/278] Fetch head blocks parallelly
---
blockproducer/chain.go | 103 +++++++++++++++++-------------------
blockproducer/chain_test.go | 96 +++++++++++++++++----------------
2 files changed, 97 insertions(+), 102 deletions(-)
diff --git a/blockproducer/chain.go b/blockproducer/chain.go
index c835a5e26..56ce7f6b9 100644
--- a/blockproducer/chain.go
+++ b/blockproducer/chain.go
@@ -20,6 +20,7 @@ import (
"context"
"fmt"
"os"
+ "sync"
"time"
pi "github.com/CovenantSQL/CovenantSQL/blockproducer/interfaces"
@@ -352,7 +353,6 @@ func (c *Chain) sync() error {
"peer": c.rt.peerInfo(),
}).Debug("synchronizing chain state")
- // sync executes firstly alone, so it's ok to sync without locking runtime
for {
now := c.rt.now()
height := c.rt.height(now)
@@ -445,13 +445,13 @@ func (c *Chain) mainCycle(ctx context.Context) {
case <-ctx.Done():
return
default:
- c.syncHead()
+ c.syncHead(ctx)
if t, d := c.rt.nextTick(); d > 0 {
log.WithFields(log.Fields{
"peer": c.rt.peerInfo(),
"next_turn": c.rt.getNextTurn(),
"head_height": c.rt.head().height,
- "head_block": c.rt.head().hash.String(),
+ "head_block": c.rt.head().hash.Short(4),
"now_time": t.Format(time.RFC3339Nano),
"duration": d,
}).Debug("Main cycle")
@@ -463,60 +463,53 @@ func (c *Chain) mainCycle(ctx context.Context) {
}
}
-func (c *Chain) syncHead() {
- // Try to fetch if the the block of the current turn is not advised yet
- log.WithFields(log.Fields{
- "index": c.rt.locSvIndex,
- "next_turn": c.rt.getNextTurn(),
- "height": c.rt.head().height,
- }).Debug("sync header")
- if h := c.rt.getNextTurn() - 1; c.rt.head().height < h {
- log.Debugf("sync header with height %d", h)
- var err error
- req := &FetchBlockReq{
- Envelope: proto.Envelope{
- // TODO(lambda): Add fields.
- },
- Height: h,
- }
- resp := &FetchBlockResp{}
- peers := c.rt.getPeers()
- succ := false
-
- for i, s := range peers.Servers {
- if !s.IsEqual(&c.rt.nodeID) {
- err = c.cl.CallNode(s, route.MCCFetchBlock.String(), req, resp)
- if err != nil || resp.Block == nil {
- log.WithFields(log.Fields{
- "peer": c.rt.peerInfo(),
- "remote": fmt.Sprintf("[%d/%d] %s", i, len(peers.Servers), s),
- "curr_turn": c.rt.getNextTurn(),
- "head_height": c.rt.head().height,
- "head_block": c.rt.head().hash.String(),
- }).WithError(err).Debug("Failed to fetch block from peer")
- } else {
- c.pendingBlocks <- resp.Block
+func (c *Chain) syncHead(ctx context.Context) {
+ var (
+ nextHeight = c.rt.getNextTurn() - 1
+ cld, ccl = context.WithCancel(ctx)
+ wg = &sync.WaitGroup{}
+ )
+
+ defer func() {
+ ccl()
+ wg.Wait()
+ }()
+
+ if c.rt.head().height >= nextHeight {
+ return
+ }
+
+ for _, v := range c.rt.getPeers().Servers {
+ if !v.IsEqual(&c.rt.nodeID) {
+ wg.Add(1)
+ go func() {
+ defer wg.Done()
+ var (
+ err error
+ req = &FetchBlockReq{
+ Envelope: proto.Envelope{
+ // TODO(lambda): Add fields.
+ },
+ Height: nextHeight,
+ }
+ resp = &FetchBlockResp{}
+ )
+ if err = c.cl.CallNodeWithContext(
+ cld, v, route.MCCFetchBlock.String(), req, resp,
+ ); err != nil {
log.WithFields(log.Fields{
- "peer": c.rt.peerInfo(),
- "remote": fmt.Sprintf("[%d/%d] %s", i, len(peers.Servers), s),
- "curr_turn": c.rt.getNextTurn(),
- "head_height": c.rt.head().height,
- "head_block": c.rt.head().hash.String(),
- }).Debug("Fetch block from remote peer successfully")
- succ = true
- break
+ "remote": v,
+ "height": nextHeight,
+ }).WithError(err).Warn("Failed to fetch block")
}
- }
- }
-
- if !succ {
- log.WithFields(log.Fields{
- "peer": c.rt.peerInfo(),
- "curr_turn": c.rt.getNextTurn(),
- "head_height": c.rt.head().height,
- "head_block": c.rt.head().hash.String(),
- }).Debug(
- "Cannot get block from any peer")
+ log.WithFields(log.Fields{
+ "remote": v,
+ "height": nextHeight,
+ "parent": resp.Block.ParentHash().Short(4),
+ "hash": resp.Block.BlockHash().Short(4),
+ }).Debug("Fetched new block from remote peer")
+ c.pendingBlocks <- resp.Block
+ }()
}
}
}
diff --git a/blockproducer/chain_test.go b/blockproducer/chain_test.go
index bafb6bdf4..f00fdcacc 100644
--- a/blockproducer/chain_test.go
+++ b/blockproducer/chain_test.go
@@ -254,63 +254,65 @@ func TestChain(t *testing.T) {
So(chain, ShouldNotBeNil)
chain.rt.log()
})
-
})
- // Add 2 more blocks to fork #1, this should trigger a branch switch to fork #1
- f1, bl, err = f1.produceBlock(7, begin.Add(8*chain.rt.period), addr2, priv2)
- So(err, ShouldBeNil)
- So(bl, ShouldNotBeNil)
- err = chain.pushBlock(bl)
- So(err, ShouldBeNil)
- f1, bl, err = f1.produceBlock(8, begin.Add(9*chain.rt.period), addr2, priv2)
- So(err, ShouldBeNil)
- So(bl, ShouldNotBeNil)
- err = chain.pushBlock(bl)
- So(err, ShouldBeNil)
-
- Convey("The chain should have same state after reloading", func() {
- err = chain.Stop()
+ Convey("The chain head should switch to fork #1 if it grows to count 7", func() {
+ // Add 2 more blocks to fork #1, this should trigger a branch switch to fork #1
+ chain.rt.log()
+ f1, bl, err = f1.produceBlock(7, begin.Add(8*chain.rt.period), addr2, priv2)
So(err, ShouldBeNil)
- chain, err = NewChain(config)
+ So(bl, ShouldNotBeNil)
+ err = chain.pushBlock(bl)
+ So(err, ShouldBeNil)
+ f1, bl, err = f1.produceBlock(8, begin.Add(9*chain.rt.period), addr2, priv2)
+ So(err, ShouldBeNil)
+ So(bl, ShouldNotBeNil)
+ err = chain.pushBlock(bl)
So(err, ShouldBeNil)
- So(chain, ShouldNotBeNil)
- chain.rt.log()
- })
- Convey("The chain APIs should return expected results", func() {
- var (
- bl *types.BPBlock
- count, height uint32
- )
+ Convey("The chain should have same state after reloading", func() {
+ err = chain.Stop()
+ So(err, ShouldBeNil)
+ chain, err = NewChain(config)
+ So(err, ShouldBeNil)
+ So(chain, ShouldNotBeNil)
+ chain.rt.log()
+ })
- _, _, err = chain.fetchBlockByHeight(100)
- So(err, ShouldEqual, ErrNoSuchBlock)
+ Convey("The chain APIs should return expected results", func() {
+ var (
+ bl *types.BPBlock
+ count, height uint32
+ )
- _, _, err = chain.fetchBlockByCount(100)
- So(err, ShouldEqual, ErrNoSuchBlock)
+ _, _, err = chain.fetchBlockByHeight(100)
+ So(err, ShouldEqual, ErrNoSuchBlock)
- bl, count, err = chain.fetchBlockByHeight(0)
- So(err, ShouldBeNil)
- So(count, ShouldEqual, 0)
- So(bl.BlockHash(), ShouldResemble, genesis.BlockHash())
+ _, _, err = chain.fetchBlockByCount(100)
+ So(err, ShouldEqual, ErrNoSuchBlock)
- bl, height, err = chain.fetchBlockByCount(0)
- So(err, ShouldBeNil)
- So(height, ShouldEqual, 0)
- So(bl.BlockHash(), ShouldResemble, genesis.BlockHash())
+ bl, count, err = chain.fetchBlockByHeight(0)
+ So(err, ShouldBeNil)
+ So(count, ShouldEqual, 0)
+ So(bl.BlockHash(), ShouldResemble, genesis.BlockHash())
- // Try to use the no-cache version
- var node = chain.rt.headBranch.head.ancestorByCount(5)
- node.block = nil // Clear cached block
- bl, count, err = chain.fetchBlockByHeight(node.height)
- So(err, ShouldBeNil)
- So(count, ShouldEqual, node.count)
- So(bl.BlockHash(), ShouldResemble, &node.hash)
- bl, height, err = chain.fetchBlockByCount(node.count)
- So(err, ShouldBeNil)
- So(height, ShouldEqual, node.height)
- So(bl.BlockHash(), ShouldResemble, &node.hash)
+ bl, height, err = chain.fetchBlockByCount(0)
+ So(err, ShouldBeNil)
+ So(height, ShouldEqual, 0)
+ So(bl.BlockHash(), ShouldResemble, genesis.BlockHash())
+
+ // Try to use the no-cache version
+ var node = chain.rt.headBranch.head.ancestorByCount(5)
+ node.block = nil // Clear cached block
+ bl, count, err = chain.fetchBlockByHeight(node.height)
+ So(err, ShouldBeNil)
+ So(count, ShouldEqual, node.count)
+ So(bl.BlockHash(), ShouldResemble, &node.hash)
+ bl, height, err = chain.fetchBlockByCount(node.count)
+ So(err, ShouldBeNil)
+ So(height, ShouldEqual, node.height)
+ So(bl.BlockHash(), ShouldResemble, &node.hash)
+ })
})
})
})
From 2f8f4dcea33c73339c2a7a8b1be7928b1a634771 Mon Sep 17 00:00:00 2001
From: leventeliu
Date: Mon, 17 Dec 2018 11:25:59 +0800
Subject: [PATCH 065/278] Add RPC broadcast and context with timeout
---
blockproducer/chain.go | 73 ++++++++++++++++++++++++++++------------
blockproducer/rpc.go | 4 +--
blockproducer/runtime.go | 12 +++++++
3 files changed, 65 insertions(+), 24 deletions(-)
diff --git a/blockproducer/chain.go b/blockproducer/chain.go
index a68e86586..c1eea84f0 100644
--- a/blockproducer/chain.go
+++ b/blockproducer/chain.go
@@ -238,35 +238,30 @@ func (c *Chain) produceBlock(now time.Time) (err error) {
}
log.WithField("block", b).Debug("produced new block")
- var peers = c.rt.getPeers()
- for _, s := range peers.Servers {
+ for _, s := range c.rt.getPeers().Servers {
if !s.IsEqual(&c.rt.nodeID) {
// Bind NodeID to subroutine
func(id proto.NodeID) {
- c.rt.goFunc(func(ctx context.Context) {
+ c.rt.goFuncWithTimeout(func(ctx context.Context) {
var (
- blockReq = &AdviseNewBlockReq{
+ req = &AdviseNewBlockReq{
Envelope: proto.Envelope{
// TODO(lambda): Add fields.
},
Block: b,
}
- blockResp = &AdviseNewBlockResp{}
+ resp = &AdviseNewBlockResp{}
+ err = c.cl.CallNodeWithContext(
+ ctx, id, route.MCCAdviseNewBlock.String(), req, resp)
)
- if err := c.cl.CallNodeWithContext(
- ctx, id, route.MCCAdviseNewBlock.String(), blockReq, blockResp,
- ); err != nil {
- log.WithFields(log.Fields{
- "peer": c.rt.peerInfo(),
- "now_time": time.Now().UTC().Format(time.RFC3339Nano),
- "block_hash": b.BlockHash(),
- }).WithError(err).Error("failed to advise new block")
- } else {
- log.WithFields(log.Fields{
- "node": id,
- }).Debug("success advising block")
- }
- })
+ log.WithFields(log.Fields{
+ "local": c.rt.peerInfo(),
+ "remote": id,
+ "block_time": b.Timestamp(),
+ "block_hash": b.BlockHash().Short(4),
+ "parent_hash": b.ParentHash().Short(4),
+ }).WithError(err).Debug("Broadcasting new block to other peers")
+ }, c.rt.period)
}(s)
}
}
@@ -415,7 +410,39 @@ func (c *Chain) processBlocks(ctx context.Context) {
}
func (c *Chain) addTx(tx pi.Transaction) {
- c.pendingTxs <- tx
+ // Simple non-blocking broadcasting
+ for _, v := range c.rt.getPeers().Servers {
+ if !v.IsEqual(&c.rt.nodeID) {
+ // Bind NodeID to subroutine
+ func(id proto.NodeID) {
+ c.rt.goFuncWithTimeout(func(ctx context.Context) {
+ var (
+ req = &AddTxReq{
+ Envelope: proto.Envelope{
+ // TODO(lambda): Add fields.
+ },
+ Tx: tx,
+ }
+ resp = &AddTxResp{}
+ err = c.cl.CallNodeWithContext(
+ ctx, id, route.MCCAddTx.String(), req, resp)
+ )
+ log.WithFields(log.Fields{
+ "local": c.rt.peerInfo(),
+ "remote": id,
+ "tx_hash": tx.Hash().Short(4),
+ "tx_type": tx.GetTransactionType(),
+ }).WithError(err).Debug("Broadcasting transaction to other peers")
+ }, c.rt.period)
+ }(v)
+ }
+ }
+
+ select {
+ case c.pendingTxs <- tx:
+ case <-c.rt.ctx.Done():
+ log.WithError(c.rt.ctx.Err()).Error("Add transaction aborted")
+ }
}
func (c *Chain) processTx(tx pi.Transaction) {
@@ -509,7 +536,11 @@ func (c *Chain) syncHead(ctx context.Context) {
"parent": resp.Block.ParentHash().Short(4),
"hash": resp.Block.BlockHash().Short(4),
}).Debug("Fetched new block from remote peer")
- c.pendingBlocks <- resp.Block
+ select {
+ case c.pendingBlocks <- resp.Block:
+ case <-cld.Done():
+ log.WithError(cld.Err()).Warn("Add pending block aborted")
+ }
}(v)
}
}
diff --git a/blockproducer/rpc.go b/blockproducer/rpc.go
index c7b4e5906..ed44bf627 100644
--- a/blockproducer/rpc.go
+++ b/blockproducer/rpc.go
@@ -186,9 +186,7 @@ func (s *ChainRPCService) AddTx(req *AddTxReq, resp *AddTxResp) (err error) {
if req.Tx == nil {
return ErrUnknownTransactionType
}
-
- s.chain.pendingTxs <- req.Tx
-
+ s.chain.addTx(req.Tx)
return
}
diff --git a/blockproducer/runtime.go b/blockproducer/runtime.go
index bdf7b0eb8..beb47f130 100644
--- a/blockproducer/runtime.go
+++ b/blockproducer/runtime.go
@@ -482,3 +482,15 @@ func (r *runtime) goFunc(f func(ctx context.Context)) {
f(r.ctx)
}()
}
+
+func (r *runtime) goFuncWithTimeout(f func(ctx context.Context), timeout time.Duration) {
+ r.wg.Add(1)
+ go func() {
+ var ctx, ccl = context.WithTimeout(r.ctx, timeout)
+ defer func() {
+ ccl()
+ r.wg.Done()
+ }()
+ f(ctx)
+ }()
+}
From 3ef4e7b3c807ca3a68c9271303ef5e80c39edbab Mon Sep 17 00:00:00 2001
From: leventeliu
Date: Mon, 17 Dec 2018 12:11:05 +0800
Subject: [PATCH 066/278] Add single run testing branch
---
blockproducer/chain_test.go | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/blockproducer/chain_test.go b/blockproducer/chain_test.go
index f00fdcacc..5b8fb2787 100644
--- a/blockproducer/chain_test.go
+++ b/blockproducer/chain_test.go
@@ -28,6 +28,7 @@ import (
"github.com/CovenantSQL/CovenantSQL/crypto/hash"
"github.com/CovenantSQL/CovenantSQL/crypto/kms"
"github.com/CovenantSQL/CovenantSQL/proto"
+ "github.com/CovenantSQL/CovenantSQL/rpc"
"github.com/CovenantSQL/CovenantSQL/types"
. "github.com/smartystreets/goconvey/convey"
)
@@ -313,6 +314,22 @@ func TestChain(t *testing.T) {
So(height, ShouldEqual, node.height)
So(bl.BlockHash(), ShouldResemble, &node.hash)
})
+
+ Convey("Test run chain", func() {
+ var sv = rpc.NewServer()
+ err = sv.InitRPCServer("localhost:0", testingPrivateKeyFile, []byte{})
+ So(err, ShouldBeNil)
+ defer sv.Stop()
+
+ chain.rt.server = sv
+ err = chain.Start()
+ So(err, ShouldBeNil)
+ defer func() {
+ chain.Stop()
+ chain = nil
+ }()
+ time.Sleep(5 * chain.rt.period)
+ })
})
})
})
From e9af4f277d4e57edcec402062dc0310535f32003 Mon Sep 17 00:00:00 2001
From: leventeliu
Date: Mon, 17 Dec 2018 14:41:11 +0800
Subject: [PATCH 067/278] Fix transaction sorting: should be by account and
nonce
---
blockproducer/branch.go | 5 ++++-
blockproducer/chain_test.go | 2 +-
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/blockproducer/branch.go b/blockproducer/branch.go
index cc1ad537c..f28a9b727 100644
--- a/blockproducer/branch.go
+++ b/blockproducer/branch.go
@@ -142,7 +142,10 @@ func (b *branch) sortUnpackedTxs() (txs []pi.Transaction) {
txs = append(txs, v)
}
sort.Slice(txs, func(i, j int) bool {
- if cmp := bytes.Compare(txs[i].Hash().AsBytes(), txs[j].Hash().AsBytes()); cmp != 0 {
+ if cmp := bytes.Compare(
+ hash.Hash(txs[i].GetAccountAddress()).AsBytes(),
+ hash.Hash(txs[j].GetAccountAddress()).AsBytes(),
+ ); cmp != 0 {
return cmp < 0
}
return txs[i].GetAccountNonce() < txs[j].GetAccountNonce()
diff --git a/blockproducer/chain_test.go b/blockproducer/chain_test.go
index 5b8fb2787..1a47e6e26 100644
--- a/blockproducer/chain_test.go
+++ b/blockproducer/chain_test.go
@@ -119,7 +119,7 @@ func TestChain(t *testing.T) {
genesis = &types.BPBlock{
SignedHeader: types.BPSignedHeader{
BPHeader: types.BPHeader{
- Timestamp: time.Now().UTC(),
+ Timestamp: time.Now().Add(-30 * time.Second),
},
},
Transactions: []pi.Transaction{
From 9697a7856ef323436a0271ddea58718f4d54b0ce Mon Sep 17 00:00:00 2001
From: leventeliu
Date: Mon, 17 Dec 2018 15:40:17 +0800
Subject: [PATCH 068/278] Set log level in testing mode to reduce log length
---
cmd/cqld/main.go | 4 +++-
cmd/cqld/main_test.go | 7 ++++++-
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/cmd/cqld/main.go b/cmd/cqld/main.go
index 04d6d401b..effb33661 100644
--- a/cmd/cqld/main.go
+++ b/cmd/cqld/main.go
@@ -59,6 +59,8 @@ var (
clientMode bool
clientOperation string
+
+ logLevel = log.DebugLevel
)
const name = `cqld`
@@ -93,7 +95,7 @@ func initLogs() {
func main() {
// set random
rand.Seed(time.Now().UnixNano())
- log.SetLevel(log.DebugLevel)
+ log.SetLevel(logLevel)
flag.Parse()
if showVersion {
diff --git a/cmd/cqld/main_test.go b/cmd/cqld/main_test.go
index 03a7b6494..80fbe0d55 100644
--- a/cmd/cqld/main_test.go
+++ b/cmd/cqld/main_test.go
@@ -18,9 +18,14 @@
package main
-import "testing"
+import (
+ "testing"
+
+ "github.com/CovenantSQL/CovenantSQL/utils/log"
+)
func TestMain(m *testing.M) {
defer m.Run()
+ logLevel = log.ErrorLevel
main()
}
From 144b36717d5a33945c0cba629310b546322681b3 Mon Sep 17 00:00:00 2001
From: leventeliu
Date: Mon, 17 Dec 2018 15:40:44 +0800
Subject: [PATCH 069/278] Fix chain head synchronizing
---
blockproducer/chain.go | 54 +++++++++++++++----------------------
blockproducer/chain_test.go | 9 +++----
blockproducer/runtime.go | 2 +-
blockproducer/xxx_test.go | 2 +-
cmd/cqld/main.go | 4 +--
cmd/cqld/main_test.go | 7 +----
6 files changed, 30 insertions(+), 48 deletions(-)
diff --git a/blockproducer/chain.go b/blockproducer/chain.go
index c1eea84f0..bfbc293db 100644
--- a/blockproducer/chain.go
+++ b/blockproducer/chain.go
@@ -25,6 +25,7 @@ import (
pi "github.com/CovenantSQL/CovenantSQL/blockproducer/interfaces"
"github.com/CovenantSQL/CovenantSQL/chainbus"
+ "github.com/CovenantSQL/CovenantSQL/conf"
"github.com/CovenantSQL/CovenantSQL/crypto"
"github.com/CovenantSQL/CovenantSQL/crypto/asymmetric"
"github.com/CovenantSQL/CovenantSQL/crypto/hash"
@@ -342,53 +343,40 @@ func (c *Chain) runCurrentTurn(now time.Time) {
}
}
-// sync synchronizes blocks and queries from the other peers.
-func (c *Chain) sync() error {
- log.WithFields(log.Fields{
- "peer": c.rt.peerInfo(),
- }).Debug("synchronizing chain state")
-
+func (c *Chain) syncHeads() {
for {
- now := c.rt.now()
- height := c.rt.height(now)
-
- log.WithFields(log.Fields{
- "height": height,
- "nextTurn": c.rt.nextTurn,
- }).Info("try sync heights")
- if c.rt.nextTurn >= height {
- log.WithFields(log.Fields{
- "height": height,
- "nextTurn": c.rt.nextTurn,
- }).Info("return heights")
+ var h = c.rt.height(c.rt.now())
+ if c.rt.getNextTurn() > h {
break
}
-
- for c.rt.nextTurn <= height {
- // TODO(lambda): fetch blocks and txes.
- c.rt.nextTurn++
+ for c.rt.getNextTurn() <= h {
+ // TODO(leventeliu): use the test mode flag to bypass the long-running synchronizing
+ // on startup by now, need better solution here.
+ if !conf.GConf.IsTestMode {
+ log.WithFields(log.Fields{
+ "next_turn": c.rt.getNextTurn(),
+ "height": h,
+ }).Debug("Synchronizing head blocks")
+ c.syncHead(c.rt.ctx)
+ }
+ c.rt.setNextTurn()
}
}
-
- return nil
}
// Start starts the chain by step:
// 1. sync the chain
// 2. goroutine for getting blocks
// 3. goroutine for getting txes.
-func (c *Chain) Start() error {
- err := c.sync()
- if err != nil {
- return err
- }
-
+func (c *Chain) Start() {
+ // Start blocks/txs processing goroutines
c.rt.goFunc(c.processBlocks)
c.rt.goFunc(c.processTxs)
+ // Synchronize heads to current block period
+ c.syncHeads()
+ // Start main cycle and service
c.rt.goFunc(c.mainCycle)
c.rt.startService(c)
-
- return nil
}
func (c *Chain) processBlocks(ctx context.Context) {
@@ -525,12 +513,14 @@ func (c *Chain) syncHead(ctx context.Context) {
cld, id, route.MCCFetchBlock.String(), req, resp,
); err != nil {
log.WithFields(log.Fields{
+ "local": c.rt.peerInfo(),
"remote": id,
"height": nextHeight,
}).WithError(err).Warn("Failed to fetch block")
return
}
log.WithFields(log.Fields{
+ "local": c.rt.peerInfo(),
"remote": id,
"height": nextHeight,
"parent": resp.Block.ParentHash().Short(4),
diff --git a/blockproducer/chain_test.go b/blockproducer/chain_test.go
index 1a47e6e26..8752092f3 100644
--- a/blockproducer/chain_test.go
+++ b/blockproducer/chain_test.go
@@ -119,7 +119,7 @@ func TestChain(t *testing.T) {
genesis = &types.BPBlock{
SignedHeader: types.BPSignedHeader{
BPHeader: types.BPHeader{
- Timestamp: time.Now().Add(-30 * time.Second),
+ Timestamp: time.Now().Add(-10 * time.Second),
},
},
Transactions: []pi.Transaction{
@@ -150,7 +150,7 @@ func TestChain(t *testing.T) {
},
NodeID: leader,
Period: time.Duration(1 * time.Second),
- Tick: time.Duration(100 * time.Millisecond),
+ Tick: time.Duration(300 * time.Millisecond),
}
chain, err = NewChain(config)
@@ -322,13 +322,12 @@ func TestChain(t *testing.T) {
defer sv.Stop()
chain.rt.server = sv
- err = chain.Start()
- So(err, ShouldBeNil)
+ chain.Start()
defer func() {
chain.Stop()
chain = nil
}()
- time.Sleep(5 * chain.rt.period)
+ time.Sleep(15 * chain.rt.period)
})
})
})
diff --git a/blockproducer/runtime.go b/blockproducer/runtime.go
index beb47f130..91a76e332 100644
--- a/blockproducer/runtime.go
+++ b/blockproducer/runtime.go
@@ -302,7 +302,7 @@ func (r *runtime) log() {
buff += v.sprint(r.lastIrre.count)
log.WithFields(log.Fields{
"branch": buff,
- }).Debug("Runtime state")
+ }).Info("Runtime state")
}
return
}
diff --git a/blockproducer/xxx_test.go b/blockproducer/xxx_test.go
index 26cca2a71..2b5d919e1 100644
--- a/blockproducer/xxx_test.go
+++ b/blockproducer/xxx_test.go
@@ -495,7 +495,7 @@ func setup() {
// Setup logging
log.SetOutput(os.Stdout)
- log.SetLevel(log.DebugLevel)
+ log.SetLevel(log.FatalLevel)
}
func teardown() {
diff --git a/cmd/cqld/main.go b/cmd/cqld/main.go
index effb33661..04d6d401b 100644
--- a/cmd/cqld/main.go
+++ b/cmd/cqld/main.go
@@ -59,8 +59,6 @@ var (
clientMode bool
clientOperation string
-
- logLevel = log.DebugLevel
)
const name = `cqld`
@@ -95,7 +93,7 @@ func initLogs() {
func main() {
// set random
rand.Seed(time.Now().UnixNano())
- log.SetLevel(logLevel)
+ log.SetLevel(log.DebugLevel)
flag.Parse()
if showVersion {
diff --git a/cmd/cqld/main_test.go b/cmd/cqld/main_test.go
index 80fbe0d55..03a7b6494 100644
--- a/cmd/cqld/main_test.go
+++ b/cmd/cqld/main_test.go
@@ -18,14 +18,9 @@
package main
-import (
- "testing"
-
- "github.com/CovenantSQL/CovenantSQL/utils/log"
-)
+import "testing"
func TestMain(m *testing.M) {
defer m.Run()
- logLevel = log.ErrorLevel
main()
}
From f78fc33fb60fded837a4dec66136c386006491cb Mon Sep 17 00:00:00 2001
From: leventeliu
Date: Mon, 17 Dec 2018 21:13:45 +0800
Subject: [PATCH 070/278] Remove root context
---
blockproducer/chain.go | 18 ++++++++----------
1 file changed, 8 insertions(+), 10 deletions(-)
diff --git a/blockproducer/chain.go b/blockproducer/chain.go
index bfbc293db..807d76fe0 100644
--- a/blockproducer/chain.go
+++ b/blockproducer/chain.go
@@ -56,11 +56,10 @@ var (
// Chain defines the main chain.
type Chain struct {
- ctx context.Context
- rt *runtime
- st xi.Storage
- cl *rpc.Caller
- bs chainbus.Bus
+ rt *runtime
+ st xi.Storage
+ cl *rpc.Caller
+ bs chainbus.Bus
pendingBlocks chan *types.BPBlock
pendingTxs chan pi.Transaction
@@ -159,11 +158,10 @@ func NewChainWithContext(ctx context.Context, cfg *Config) (c *Chain, err error)
// create chain
inst = &Chain{
- ctx: ctx,
- rt: rt,
- st: st,
- cl: caller,
- bs: bus,
+ rt: rt,
+ st: st,
+ cl: caller,
+ bs: bus,
pendingBlocks: make(chan *types.BPBlock),
pendingTxs: make(chan pi.Transaction),
From a84ef4b029effe66b3e5fe5ccb446198690ab25e Mon Sep 17 00:00:00 2001
From: leventeliu
Date: Mon, 17 Dec 2018 22:20:12 +0800
Subject: [PATCH 071/278] Merge runtime struct to Chain
---
blockproducer/chain.go | 618 ++++++++++++++++++++++++++++++------
blockproducer/chain_test.go | 48 +--
blockproducer/errors.go | 4 +
blockproducer/rpc.go | 6 +-
blockproducer/runtime.go | 496 -----------------------------
5 files changed, 557 insertions(+), 615 deletions(-)
delete mode 100644 blockproducer/runtime.go
diff --git a/blockproducer/chain.go b/blockproducer/chain.go
index 807d76fe0..9454fc6bc 100644
--- a/blockproducer/chain.go
+++ b/blockproducer/chain.go
@@ -19,6 +19,7 @@ package blockproducer
import (
"context"
"fmt"
+ "math"
"os"
"sync"
"time"
@@ -56,13 +57,39 @@ var (
// Chain defines the main chain.
type Chain struct {
- rt *runtime
+ // Routine controlling components
+ ctx context.Context
+ cancel context.CancelFunc
+ wg *sync.WaitGroup
+ // RPC components
+ server *rpc.Server
+ cl *rpc.Caller
+ // Other components
st xi.Storage
- cl *rpc.Caller
bs chainbus.Bus
-
+ // Channels for incoming blocks and transactions
pendingBlocks chan *types.BPBlock
pendingTxs chan pi.Transaction
+ // The following fields are read-only in runtime
+ address proto.AccountAddress
+ genesisTime time.Time
+ period time.Duration
+ tick time.Duration
+
+ sync.RWMutex // protects following fields
+ peers *proto.Peers
+ nodeID proto.NodeID
+ comfirms uint32
+ serversNum uint32
+ locSvIndex uint32
+ nextTurn uint32
+ offset time.Duration
+ lastIrre *blockNode
+ immutable *metaState
+ headIndex int
+ headBranch *branch
+ branches []*branch
+ txPool map[hash.Hash]pi.Transaction
}
// NewChain creates a new blockchain.
@@ -74,21 +101,29 @@ func NewChain(cfg *Config) (c *Chain, err error) {
func NewChainWithContext(ctx context.Context, cfg *Config) (c *Chain, err error) {
var (
existed bool
+ ok bool
ierr error
+ cld, ccl = context.WithCancel(ctx)
+ l = float64(len(cfg.Peers.Servers))
+ t float64
+ m float64
+
st xi.Storage
irre *blockNode
heads []*blockNode
immutable *metaState
txPool map[hash.Hash]pi.Transaction
- addr proto.AccountAddress
- pubKey *asymmetric.PublicKey
+ branches []*branch
+ br, head *branch
+ headIndex int
+
+ pubKey *asymmetric.PublicKey
+ addr proto.AccountAddress
+ locSvIndex int32
- inst *Chain
- rt *runtime
- bus = chainbus.New()
- caller = rpc.NewCaller()
+ bus = chainbus.New()
)
if fi, err := os.Stat(cfg.DataFile); err == nil && fi.Mode().IsRegular() {
@@ -103,7 +138,7 @@ func NewChainWithContext(ctx context.Context, cfg *Config) (c *Chain, err error)
// Storage genesis
if !existed {
- // TODO(leventeliu): reuse rt.switchBranch to construct initial state.
+ // TODO(leventeliu): reuse chain.switchBranch to construct initial state.
var init = newMetaState()
for _, v := range cfg.Genesis.Transactions {
if ierr = init.apply(v); ierr != nil {
@@ -141,14 +176,39 @@ func NewChainWithContext(ctx context.Context, cfg *Config) (c *Chain, err error)
}
}
- // Load and create runtime
+ // Load from database and rebuild branches
if irre, heads, immutable, txPool, ierr = loadDatabase(st); ierr != nil {
err = errors.Wrap(ierr, "failed to load data from storage")
return
}
- rt = newRuntime(ctx, cfg, addr, irre, heads, immutable, txPool)
+ for _, v := range heads {
+ log.WithFields(log.Fields{
+ "irre_hash": irre.hash.Short(4),
+ "irre_count": irre.count,
+ "head_hash": v.hash.Short(4),
+ "head_count": v.count,
+ }).Debug("Checking head")
+ if v.hasAncestor(irre) {
+ if br, err = fork(irre, v, immutable, txPool); err != nil {
+ log.WithError(err).Fatal("Failed to rebuild branch")
+ }
+ branches = append(branches, br)
+ }
+ }
+ if len(branches) == 0 {
+ err = ErrNoAvailableBranch
+ return
+ }
- // get accountAddress
+ // Set head branch
+ for i, v := range branches {
+ if head == nil || v.head.count > head.head.count {
+ headIndex = i
+ head = v
+ }
+ }
+
+ // Get accountAddress
if pubKey, err = kms.GetLocalPublicKey(); err != nil {
return
}
@@ -156,29 +216,60 @@ func NewChainWithContext(ctx context.Context, cfg *Config) (c *Chain, err error)
return
}
+ // Setup peer list
+ if locSvIndex, ok = cfg.Peers.Find(cfg.NodeID); !ok {
+ err = ErrLocalNodeNotFound
+ return
+ }
+ if t = cfg.ComfirmThreshold; t <= 0.0 {
+ t = float64(2) / 3.0
+ }
+ if m = math.Ceil(l*t + 1); m > l {
+ m = l
+ }
+
// create chain
- inst = &Chain{
- rt: rt,
+ c = &Chain{
+ ctx: cld,
+ cancel: ccl,
+ wg: &sync.WaitGroup{},
+
+ server: cfg.Server,
+ cl: rpc.NewCaller(),
+
st: st,
- cl: caller,
bs: bus,
pendingBlocks: make(chan *types.BPBlock),
pendingTxs: make(chan pi.Transaction),
- }
+ address: addr,
+ genesisTime: cfg.Genesis.SignedHeader.Timestamp,
+ period: cfg.Period,
+ tick: cfg.Tick,
+
+ peers: cfg.Peers,
+ nodeID: cfg.NodeID,
+ comfirms: uint32(m),
+ serversNum: uint32(len(cfg.Peers.Servers)),
+ locSvIndex: uint32(locSvIndex),
+ nextTurn: head.head.height + 1,
+ offset: time.Duration(0), // TODO(leventeliu): initialize offset
+
+ lastIrre: irre,
+ immutable: immutable,
+ headIndex: headIndex,
+ headBranch: head,
+ branches: branches,
+ txPool: txPool,
+ }
log.WithFields(log.Fields{
- "index": inst.rt.locSvIndex,
- "bp_number": inst.rt.serversNum,
- "period": inst.rt.period.String(),
- "tick": inst.rt.tick.String(),
- "height": inst.rt.head().height,
+ "index": c.locSvIndex,
+ "bp_number": c.serversNum,
+ "period": c.period.String(),
+ "tick": c.tick.String(),
+ "height": c.head().height,
}).Debug("current chain state")
-
- // sub chain events
- inst.bs.Subscribe(txEvent, inst.addTx)
-
- c = inst
return
}
@@ -201,26 +292,17 @@ func (c *Chain) checkBlock(b *types.BPBlock) (err error) {
return nil
}
-func (c *Chain) pushBlockWithoutCheck(b *types.BPBlock) (err error) {
- if err = c.rt.applyBlock(c.st, b); err != nil {
- return err
- }
- return err
-}
-
-func (c *Chain) pushBlock(b *types.BPBlock) error {
- err := c.checkBlock(b)
- if err != nil {
- err = errors.Wrap(err, "check block failed")
- return err
+func (c *Chain) pushBlock(b *types.BPBlock) (err error) {
+ var ierr error
+ if ierr = c.checkBlock(b); ierr != nil {
+ err = errors.Wrap(ierr, "failed to check block")
+ return
}
-
- err = c.pushBlockWithoutCheck(b)
- if err != nil {
- return err
+ if ierr = c.applyBlock(b); ierr != nil {
+ err = errors.Wrap(ierr, "failed to apply block")
+ return
}
-
- return nil
+ return
}
func (c *Chain) produceBlock(now time.Time) (err error) {
@@ -232,16 +314,16 @@ func (c *Chain) produceBlock(now time.Time) (err error) {
if priv, err = kms.GetLocalPrivateKey(); err != nil {
return
}
- if b, err = c.rt.produceBlock(c.st, now, priv); err != nil {
+ if b, err = c.produceAndStoreBlock(now, priv); err != nil {
return
}
log.WithField("block", b).Debug("produced new block")
- for _, s := range c.rt.getPeers().Servers {
- if !s.IsEqual(&c.rt.nodeID) {
+ for _, s := range c.getPeers().Servers {
+ if !s.IsEqual(&c.nodeID) {
// Bind NodeID to subroutine
func(id proto.NodeID) {
- c.rt.goFuncWithTimeout(func(ctx context.Context) {
+ c.goFuncWithTimeout(func(ctx context.Context) {
var (
req = &AdviseNewBlockReq{
Envelope: proto.Envelope{
@@ -254,13 +336,13 @@ func (c *Chain) produceBlock(now time.Time) (err error) {
ctx, id, route.MCCAdviseNewBlock.String(), req, resp)
)
log.WithFields(log.Fields{
- "local": c.rt.peerInfo(),
+ "local": c.peerInfo(),
"remote": id,
"block_time": b.Timestamp(),
"block_hash": b.BlockHash().Short(4),
"parent_hash": b.ParentHash().Short(4),
}).WithError(err).Debug("Broadcasting new block to other peers")
- }, c.rt.period)
+ }, c.period)
}(s)
}
}
@@ -286,7 +368,7 @@ func (c *Chain) fetchBlock(h hash.Hash) (b *types.BPBlock, err error) {
}
func (c *Chain) fetchBlockByHeight(h uint32) (b *types.BPBlock, count uint32, err error) {
- var node = c.rt.head().ancestor(h)
+ var node = c.head().ancestor(h)
if node == nil {
err = ErrNoSuchBlock
return
@@ -304,7 +386,7 @@ func (c *Chain) fetchBlockByHeight(h uint32) (b *types.BPBlock, count uint32, er
}
func (c *Chain) fetchBlockByCount(count uint32) (b *types.BPBlock, height uint32, err error) {
- var node = c.rt.head().ancestorByCount(count)
+ var node = c.head().ancestorByCount(count)
if node == nil {
err = ErrNoSuchBlock
return
@@ -324,17 +406,17 @@ func (c *Chain) fetchBlockByCount(count uint32) (b *types.BPBlock, height uint32
// runCurrentTurn does the check and runs block producing if its my turn.
func (c *Chain) runCurrentTurn(now time.Time) {
log.WithFields(log.Fields{
- "next_turn": c.rt.getNextTurn(),
- "bp_number": c.rt.serversNum,
- "node_index": c.rt.locSvIndex,
+ "next_turn": c.getNextTurn(),
+ "bp_number": c.serversNum,
+ "node_index": c.locSvIndex,
}).Info("check turns")
- defer c.rt.setNextTurn()
+ defer c.setNextTurn()
- if !c.rt.isMyTurn() {
+ if !c.isMyTurn() {
return
}
- log.WithField("height", c.rt.getNextTurn()).Info("producing a new block")
+ log.WithField("height", c.getNextTurn()).Info("producing a new block")
if err := c.produceBlock(now); err != nil {
log.WithField("now", now.Format(time.RFC3339Nano)).WithError(err).Errorln(
"failed to produce block")
@@ -343,21 +425,21 @@ func (c *Chain) runCurrentTurn(now time.Time) {
func (c *Chain) syncHeads() {
for {
- var h = c.rt.height(c.rt.now())
- if c.rt.getNextTurn() > h {
+ var h = c.height(c.now())
+ if c.getNextTurn() > h {
break
}
- for c.rt.getNextTurn() <= h {
+ for c.getNextTurn() <= h {
// TODO(leventeliu): use the test mode flag to bypass the long-running synchronizing
// on startup by now, need better solution here.
if !conf.GConf.IsTestMode {
log.WithFields(log.Fields{
- "next_turn": c.rt.getNextTurn(),
+ "next_turn": c.getNextTurn(),
"height": h,
}).Debug("Synchronizing head blocks")
- c.syncHead(c.rt.ctx)
+ c.syncHead(c.ctx)
}
- c.rt.setNextTurn()
+ c.setNextTurn()
}
}
}
@@ -368,13 +450,15 @@ func (c *Chain) syncHeads() {
// 3. goroutine for getting txes.
func (c *Chain) Start() {
// Start blocks/txs processing goroutines
- c.rt.goFunc(c.processBlocks)
- c.rt.goFunc(c.processTxs)
+ c.goFunc(c.processBlocks)
+ c.goFunc(c.processTxs)
// Synchronize heads to current block period
c.syncHeads()
+ // TODO(leventeliu): subscribe ChainBus.
+ // ...
// Start main cycle and service
- c.rt.goFunc(c.mainCycle)
- c.rt.startService(c)
+ c.goFunc(c.mainCycle)
+ c.startService(c)
}
func (c *Chain) processBlocks(ctx context.Context) {
@@ -397,11 +481,11 @@ func (c *Chain) processBlocks(ctx context.Context) {
func (c *Chain) addTx(tx pi.Transaction) {
// Simple non-blocking broadcasting
- for _, v := range c.rt.getPeers().Servers {
- if !v.IsEqual(&c.rt.nodeID) {
+ for _, v := range c.getPeers().Servers {
+ if !v.IsEqual(&c.nodeID) {
// Bind NodeID to subroutine
func(id proto.NodeID) {
- c.rt.goFuncWithTimeout(func(ctx context.Context) {
+ c.goFuncWithTimeout(func(ctx context.Context) {
var (
req = &AddTxReq{
Envelope: proto.Envelope{
@@ -414,20 +498,20 @@ func (c *Chain) addTx(tx pi.Transaction) {
ctx, id, route.MCCAddTx.String(), req, resp)
)
log.WithFields(log.Fields{
- "local": c.rt.peerInfo(),
+ "local": c.peerInfo(),
"remote": id,
"tx_hash": tx.Hash().Short(4),
"tx_type": tx.GetTransactionType(),
}).WithError(err).Debug("Broadcasting transaction to other peers")
- }, c.rt.period)
+ }, c.period)
}(v)
}
}
select {
case c.pendingTxs <- tx:
- case <-c.rt.ctx.Done():
- log.WithError(c.rt.ctx.Err()).Error("Add transaction aborted")
+ case <-c.ctx.Done():
+ log.WithError(c.ctx.Err()).Error("Add transaction aborted")
}
}
@@ -436,7 +520,7 @@ func (c *Chain) processTx(tx pi.Transaction) {
log.WithError(err).Error("Failed to verify transaction")
return
}
- if err := c.rt.addTx(c.st, tx); err != nil {
+ if err := c.storeTx(tx); err != nil {
log.WithError(err).Error("Failed to add transaction")
}
}
@@ -459,12 +543,12 @@ func (c *Chain) mainCycle(ctx context.Context) {
return
default:
c.syncHead(ctx)
- if t, d := c.rt.nextTick(); d > 0 {
+ if t, d := c.nextTick(); d > 0 {
log.WithFields(log.Fields{
- "peer": c.rt.peerInfo(),
- "next_turn": c.rt.getNextTurn(),
- "head_height": c.rt.head().height,
- "head_block": c.rt.head().hash.Short(4),
+ "peer": c.peerInfo(),
+ "next_turn": c.getNextTurn(),
+ "head_height": c.head().height,
+ "head_block": c.head().hash.Short(4),
"now_time": t.Format(time.RFC3339Nano),
"duration": d,
}).Debug("Main cycle")
@@ -478,7 +562,7 @@ func (c *Chain) mainCycle(ctx context.Context) {
func (c *Chain) syncHead(ctx context.Context) {
var (
- nextHeight = c.rt.getNextTurn() - 1
+ nextHeight = c.getNextTurn() - 1
cld, ccl = context.WithCancel(ctx)
wg = &sync.WaitGroup{}
)
@@ -488,12 +572,12 @@ func (c *Chain) syncHead(ctx context.Context) {
wg.Wait()
}()
- if c.rt.head().height >= nextHeight {
+ if c.head().height >= nextHeight {
return
}
- for _, v := range c.rt.getPeers().Servers {
- if !v.IsEqual(&c.rt.nodeID) {
+ for _, v := range c.getPeers().Servers {
+ if !v.IsEqual(&c.nodeID) {
wg.Add(1)
go func(id proto.NodeID) {
defer wg.Done()
@@ -511,14 +595,14 @@ func (c *Chain) syncHead(ctx context.Context) {
cld, id, route.MCCFetchBlock.String(), req, resp,
); err != nil {
log.WithFields(log.Fields{
- "local": c.rt.peerInfo(),
+ "local": c.peerInfo(),
"remote": id,
"height": nextHeight,
}).WithError(err).Warn("Failed to fetch block")
return
}
log.WithFields(log.Fields{
- "local": c.rt.peerInfo(),
+ "local": c.peerInfo(),
"remote": id,
"height": nextHeight,
"parent": resp.Block.ParentHash().Short(4),
@@ -537,12 +621,362 @@ func (c *Chain) syncHead(ctx context.Context) {
// Stop stops the main process of the sql-chain.
func (c *Chain) Stop() (err error) {
// Stop main process
- log.WithFields(log.Fields{"peer": c.rt.peerInfo()}).Debug("Stopping chain")
- c.rt.stop()
- log.WithFields(log.Fields{"peer": c.rt.peerInfo()}).Debug("Chain service stopped")
+ log.WithFields(log.Fields{"peer": c.peerInfo()}).Debug("Stopping chain")
+ c.stop()
+ log.WithFields(log.Fields{"peer": c.peerInfo()}).Debug("Chain service stopped")
c.st.Close()
- log.WithFields(log.Fields{"peer": c.rt.peerInfo()}).Debug("Chain database closed")
+ log.WithFields(log.Fields{"peer": c.peerInfo()}).Debug("Chain database closed")
close(c.pendingBlocks)
close(c.pendingTxs)
return
}
+
+func (c *Chain) storeTx(tx pi.Transaction) (err error) {
+ var k = tx.Hash()
+ c.Lock()
+ defer c.Unlock()
+ if _, ok := c.txPool[k]; ok {
+ err = ErrExistedTx
+ return
+ }
+
+ return store(c.st, []storageProcedure{addTx(tx)}, func() {
+ c.txPool[k] = tx
+ for _, v := range c.branches {
+ v.addTx(tx)
+ }
+ })
+}
+
+func (c *Chain) nextNonce(addr proto.AccountAddress) (n pi.AccountNonce, err error) {
+ c.RLock()
+ defer c.RUnlock()
+ return c.headBranch.preview.nextNonce(addr)
+}
+
+func (c *Chain) loadAccountCovenantBalance(addr proto.AccountAddress) (balance uint64, ok bool) {
+ c.RLock()
+ defer c.RUnlock()
+ return c.immutable.loadAccountCovenantBalance(addr)
+}
+
+func (c *Chain) loadAccountStableBalance(addr proto.AccountAddress) (balance uint64, ok bool) {
+ c.RLock()
+ defer c.RUnlock()
+ return c.immutable.loadAccountStableBalance(addr)
+}
+
+func (c *Chain) switchBranch(bl *types.BPBlock, origin int, head *branch) (err error) {
+ var (
+ irre *blockNode
+ newIrres []*blockNode
+ sps []storageProcedure
+ up storageCallback
+ height = c.height(bl.Timestamp())
+ )
+
+ // Find new irreversible blocks
+ //
+ // NOTE(leventeliu):
+ // May have multiple new irreversible blocks here if peer list shrinks. May also have
+ // no new irreversible block at all if peer list expands.
+ irre = head.head.lastIrreversible(c.comfirms)
+ newIrres = irre.fetchNodeList(c.lastIrre.count)
+
+ // Apply irreversible blocks to create dirty map on immutable cache
+ //
+ // TODO(leventeliu): use old metaState for now, better use separated dirty cache.
+ for _, b := range newIrres {
+ for _, tx := range b.block.Transactions {
+ if err := c.immutable.apply(tx); err != nil {
+ log.WithError(err).Fatal("Failed to apply block to immutable database")
+ }
+ }
+ }
+
+ // Prepare storage procedures to update immutable database
+ sps = append(sps, addBlock(height, bl))
+ for k, v := range c.immutable.dirty.accounts {
+ if v != nil {
+ sps = append(sps, updateAccount(&v.Account))
+ } else {
+ sps = append(sps, deleteAccount(k))
+ }
+ }
+ for k, v := range c.immutable.dirty.databases {
+ if v != nil {
+ sps = append(sps, updateShardChain(&v.SQLChainProfile))
+ } else {
+ sps = append(sps, deleteShardChain(k))
+ }
+ }
+ for k, v := range c.immutable.dirty.provider {
+ if v != nil {
+ sps = append(sps, updateProvider(&v.ProviderProfile))
+ } else {
+ sps = append(sps, deleteProvider(k))
+ }
+ }
+ for _, n := range newIrres {
+ sps = append(sps, deleteTxs(n.block.Transactions))
+ }
+ sps = append(sps, updateIrreversible(irre.hash))
+
+ // Prepare callback to update cache
+ up = func() {
+ // Update last irreversible block
+ c.lastIrre = irre
+ // Apply irreversible blocks to immutable database
+ c.immutable.commit()
+ // Prune branches
+ var (
+ idx int
+ brs = make([]*branch, 0, len(c.branches))
+ )
+ for i, b := range c.branches {
+ if i == origin {
+ // Current branch
+ brs = append(brs, head)
+ idx = len(brs) - 1
+ } else if b.head.hasAncestor(irre) {
+ brs = append(brs, b)
+ } else {
+ log.WithFields(log.Fields{
+ "branch": func() string {
+ if i == c.headIndex {
+ return "[head]"
+ }
+ return fmt.Sprintf("[%04d]", i)
+ }(),
+ }).Debugf("Pruning branch")
+ }
+ }
+ // Replace current branches
+ c.headBranch = head
+ c.headIndex = idx
+ c.branches = brs
+ // Clear packed transactions
+ for _, b := range newIrres {
+ for _, br := range c.branches {
+ br.clearPackedTxs(b.block.Transactions)
+ }
+ for _, tx := range b.block.Transactions {
+ delete(c.txPool, tx.Hash())
+ }
+ }
+ }
+
+ // Write to immutable database and update cache
+ if err = store(c.st, sps, up); err != nil {
+ c.immutable.clean()
+ }
+ // TODO(leventeliu): trigger ChainBus.Publish.
+ // ...
+ return
+}
+
+func (c *Chain) stat() {
+ c.RLock()
+ defer c.RUnlock()
+ for i, v := range c.branches {
+ var buff string
+ if i == c.headIndex {
+ buff += "[head] "
+ } else {
+ buff += fmt.Sprintf("[%04d] ", i)
+ }
+ buff += v.sprint(c.lastIrre.count)
+ log.WithFields(log.Fields{
+ "branch": buff,
+ }).Info("Runtime state")
+ }
+ return
+}
+
+func (c *Chain) applyBlock(bl *types.BPBlock) (err error) {
+ var (
+ ok bool
+ ierr error
+ br *branch
+ parent *blockNode
+ head *blockNode
+ height = c.height(bl.Timestamp())
+ )
+
+ defer c.stat()
+ c.Lock()
+ defer c.Unlock()
+
+ for i, v := range c.branches {
+ // Grow a branch
+ if v.head.hash.IsEqual(&bl.SignedHeader.ParentHash) {
+ head = newBlockNode(height, bl, v.head)
+ if br, ierr = v.applyBlock(head); ierr != nil {
+ err = errors.Wrapf(ierr, "failed to apply block %s", head.hash.Short(4))
+ return
+ }
+ // Grow a branch while the current branch is not changed
+ if br.head.count <= c.headBranch.head.count {
+ return store(c.st,
+ []storageProcedure{addBlock(height, bl)},
+ func() { c.branches[i] = br },
+ )
+ }
+ // Switch branch or grow current branch
+ return c.switchBranch(bl, i, br)
+ }
+ }
+
+ for _, v := range c.branches {
+ if n := v.head.ancestor(height); n != nil && n.hash.IsEqual(bl.BlockHash()) {
+ // Return silently if block exists in the current branch
+ return
+ }
+ // Fork and create new branch
+ if parent, ok = v.head.canForkFrom(bl.SignedHeader.ParentHash, c.lastIrre.count); ok {
+ head = newBlockNode(height, bl, parent)
+ if br, ierr = fork(c.lastIrre, head, c.immutable, c.txPool); ierr != nil {
+ err = errors.Wrapf(ierr, "failed to fork from %s", parent.hash.Short(4))
+ return
+ }
+ return store(c.st,
+ []storageProcedure{addBlock(height, bl)},
+ func() { c.branches = append(c.branches, br) },
+ )
+ }
+ }
+
+ err = ErrParentNotFound
+ return
+}
+
+func (c *Chain) produceAndStoreBlock(
+ now time.Time, priv *asymmetric.PrivateKey) (out *types.BPBlock, err error,
+) {
+ var (
+ bl *types.BPBlock
+ br *branch
+ ierr error
+ )
+
+ defer c.stat()
+ c.Lock()
+ defer c.Unlock()
+
+ // Try to produce new block
+ if br, bl, ierr = c.headBranch.produceBlock(
+ c.height(now), now, c.address, priv,
+ ); ierr != nil {
+ err = errors.Wrapf(ierr, "failed to produce block at head %s",
+ c.headBranch.head.hash.Short(4))
+ return
+ }
+ if ierr = c.switchBranch(bl, c.headIndex, br); ierr != nil {
+ err = errors.Wrapf(ierr, "failed to switch branch #%d:%s",
+ c.headIndex, c.headBranch.head.hash.Short(4))
+ return
+ }
+ out = bl
+ return
+}
+
+// now returns the current coordinated chain time.
+func (c *Chain) now() time.Time {
+ c.RLock()
+ defer c.RUnlock()
+ return time.Now().UTC().Add(c.offset)
+}
+
+func (c *Chain) startService(chain *Chain) {
+ c.server.RegisterService(route.BlockProducerRPCName, &ChainRPCService{chain: chain})
+}
+
+// nextTick returns the current clock reading and the duration till the next turn. If duration
+// is less or equal to 0, use the clock reading to run the next cycle - this avoids some problem
+// caused by concurrent time synchronization.
+func (c *Chain) nextTick() (t time.Time, d time.Duration) {
+ var nt uint32
+ nt, t = func() (nt uint32, t time.Time) {
+ c.RLock()
+ defer c.RUnlock()
+ nt = c.nextTurn
+ t = time.Now().UTC().Add(c.offset)
+ return
+ }()
+ d = c.genesisTime.Add(time.Duration(nt) * c.period).Sub(t)
+ if d > c.tick {
+ d = c.tick
+ }
+ return
+}
+
+func (c *Chain) isMyTurn() bool {
+ c.RLock()
+ defer c.RUnlock()
+ return c.nextTurn%c.serversNum == c.locSvIndex
+}
+
+// setNextTurn prepares the chain state for the next turn.
+func (c *Chain) setNextTurn() {
+ c.Lock()
+ defer c.Unlock()
+ c.nextTurn++
+}
+
+func (c *Chain) peerInfo() string {
+ var index, bpNum, nodeID = func() (uint32, uint32, proto.NodeID) {
+ c.RLock()
+ defer c.RUnlock()
+ return c.locSvIndex, c.serversNum, c.nodeID
+ }()
+ return fmt.Sprintf("[%d/%d] %s", index, bpNum, nodeID)
+}
+
+// height calculates the height with this sql-chain config of a given time reading.
+func (c *Chain) height(t time.Time) uint32 {
+ return uint32(t.Sub(c.genesisTime) / c.period)
+}
+
+func (c *Chain) getNextTurn() uint32 {
+ c.RLock()
+ defer c.RUnlock()
+ return c.nextTurn
+}
+
+func (c *Chain) getPeers() *proto.Peers {
+ c.RLock()
+ defer c.RUnlock()
+ var peers = c.peers.Clone()
+ return &peers
+}
+
+func (c *Chain) head() *blockNode {
+ c.RLock()
+ defer c.RUnlock()
+ return c.headBranch.head
+}
+
+func (c *Chain) stop() {
+ c.cancel()
+ c.wg.Wait()
+}
+
+func (c *Chain) goFunc(f func(ctx context.Context)) {
+ c.wg.Add(1)
+ go func() {
+ defer c.wg.Done()
+ f(c.ctx)
+ }()
+}
+
+func (c *Chain) goFuncWithTimeout(f func(ctx context.Context), timeout time.Duration) {
+ c.wg.Add(1)
+ go func() {
+ var ctx, ccl = context.WithTimeout(c.ctx, timeout)
+ defer func() {
+ ccl()
+ c.wg.Done()
+ }()
+ f(ctx)
+ }()
+}
diff --git a/blockproducer/chain_test.go b/blockproducer/chain_test.go
index 8752092f3..6b76a3a3f 100644
--- a/blockproducer/chain_test.go
+++ b/blockproducer/chain_test.go
@@ -176,7 +176,7 @@ func TestChain(t *testing.T) {
)
// Create transactions for testing
- nonce, err = chain.rt.nextNonce(addr1)
+ nonce, err = chain.nextNonce(addr1)
So(err, ShouldBeNil)
So(nonce, ShouldEqual, 1)
t1, err = newTransfer(nonce, priv1, addr1, addr2, 1)
@@ -189,40 +189,40 @@ func TestChain(t *testing.T) {
So(err, ShouldBeNil)
// Fork from #0
- f0 = chain.rt.headBranch.makeCopy()
+ f0 = chain.headBranch.makeCopy()
- err = chain.rt.addTx(chain.st, t1)
+ err = chain.storeTx(t1)
So(err, ShouldBeNil)
Convey("The chain should report error on duplicated transaction", func() {
- err = chain.rt.addTx(chain.st, t1)
+ err = chain.storeTx(t1)
So(err, ShouldEqual, ErrExistedTx)
})
- err = chain.produceBlock(begin.Add(chain.rt.period))
+ err = chain.produceBlock(begin.Add(chain.period))
So(err, ShouldBeNil)
// Create a sibling block from fork#0 and apply
- _, bl, err = f0.produceBlock(2, begin.Add(2*chain.rt.period), addr2, priv2)
+ _, bl, err = f0.produceBlock(2, begin.Add(2*chain.period), addr2, priv2)
So(err, ShouldBeNil)
So(bl, ShouldNotBeNil)
err = chain.pushBlock(bl)
So(err, ShouldBeNil)
// Fork from #1
- f1 = chain.rt.headBranch.makeCopy()
+ f1 = chain.headBranch.makeCopy()
- err = chain.rt.addTx(chain.st, t2)
+ err = chain.storeTx(t2)
So(err, ShouldBeNil)
- err = chain.produceBlock(begin.Add(2 * chain.rt.period))
+ err = chain.produceBlock(begin.Add(2 * chain.period))
So(err, ShouldBeNil)
- err = chain.rt.addTx(chain.st, t3)
+ err = chain.storeTx(t3)
So(err, ShouldBeNil)
- err = chain.rt.addTx(chain.st, t4)
+ err = chain.storeTx(t4)
So(err, ShouldBeNil)
- err = chain.produceBlock(begin.Add(3 * chain.rt.period))
+ err = chain.produceBlock(begin.Add(3 * chain.period))
So(err, ShouldBeNil)
// Create a sibling block from fork#1 and apply
- f1, bl, err = f1.produceBlock(3, begin.Add(3*chain.rt.period), addr2, priv2)
+ f1, bl, err = f1.produceBlock(3, begin.Add(3*chain.period), addr2, priv2)
So(err, ShouldBeNil)
So(bl, ShouldNotBeNil)
err = chain.pushBlock(bl)
@@ -230,11 +230,11 @@ func TestChain(t *testing.T) {
// This should trigger a branch pruning on fork #0
for i := uint32(4); i <= 6; i++ {
- err = chain.produceBlock(begin.Add(time.Duration(i) * chain.rt.period))
+ err = chain.produceBlock(begin.Add(time.Duration(i) * chain.period))
So(err, ShouldBeNil)
// Create a sibling block from fork#1 and apply
f1, bl, err = f1.produceBlock(
- i, begin.Add(time.Duration(i)*chain.rt.period), addr2, priv2)
+ i, begin.Add(time.Duration(i)*chain.period), addr2, priv2)
So(err, ShouldBeNil)
So(bl, ShouldNotBeNil)
err = chain.pushBlock(bl)
@@ -244,7 +244,7 @@ func TestChain(t *testing.T) {
Convey("The chain immutable should be updated to irreversible block", func() {
// Add more blocks to trigger immutable updating
for i := uint32(7); i <= 12; i++ {
- err = chain.produceBlock(begin.Add(time.Duration(i) * chain.rt.period))
+ err = chain.produceBlock(begin.Add(time.Duration(i) * chain.period))
So(err, ShouldBeNil)
}
Convey("The chain should have same state after reloading", func() {
@@ -253,19 +253,19 @@ func TestChain(t *testing.T) {
chain, err = NewChain(config)
So(err, ShouldBeNil)
So(chain, ShouldNotBeNil)
- chain.rt.log()
+ chain.stat()
})
})
Convey("The chain head should switch to fork #1 if it grows to count 7", func() {
// Add 2 more blocks to fork #1, this should trigger a branch switch to fork #1
- chain.rt.log()
- f1, bl, err = f1.produceBlock(7, begin.Add(8*chain.rt.period), addr2, priv2)
+ chain.stat()
+ f1, bl, err = f1.produceBlock(7, begin.Add(8*chain.period), addr2, priv2)
So(err, ShouldBeNil)
So(bl, ShouldNotBeNil)
err = chain.pushBlock(bl)
So(err, ShouldBeNil)
- f1, bl, err = f1.produceBlock(8, begin.Add(9*chain.rt.period), addr2, priv2)
+ f1, bl, err = f1.produceBlock(8, begin.Add(9*chain.period), addr2, priv2)
So(err, ShouldBeNil)
So(bl, ShouldNotBeNil)
err = chain.pushBlock(bl)
@@ -277,7 +277,7 @@ func TestChain(t *testing.T) {
chain, err = NewChain(config)
So(err, ShouldBeNil)
So(chain, ShouldNotBeNil)
- chain.rt.log()
+ chain.stat()
})
Convey("The chain APIs should return expected results", func() {
@@ -303,7 +303,7 @@ func TestChain(t *testing.T) {
So(bl.BlockHash(), ShouldResemble, genesis.BlockHash())
// Try to use the no-cache version
- var node = chain.rt.headBranch.head.ancestorByCount(5)
+ var node = chain.headBranch.head.ancestorByCount(5)
node.block = nil // Clear cached block
bl, count, err = chain.fetchBlockByHeight(node.height)
So(err, ShouldBeNil)
@@ -321,13 +321,13 @@ func TestChain(t *testing.T) {
So(err, ShouldBeNil)
defer sv.Stop()
- chain.rt.server = sv
+ chain.server = sv
chain.Start()
defer func() {
chain.Stop()
chain = nil
}()
- time.Sleep(15 * chain.rt.period)
+ time.Sleep(15 * chain.period)
})
})
})
diff --git a/blockproducer/errors.go b/blockproducer/errors.go
index 387572979..5b43cbd0c 100644
--- a/blockproducer/errors.go
+++ b/blockproducer/errors.go
@@ -86,4 +86,8 @@ var (
ErrMinerUserNotMatch = errors.New("miner and user do not match")
// ErrMultipleGenesis indicates that there're multiple genesis blocks while loading.
ErrMultipleGenesis = errors.New("multiple genesis blocks")
+ // ErrLocalNodeNotFound indicates that the local node id is not found in the given peer list.
+ ErrLocalNodeNotFound = errors.New("local node id not found in peer list")
+ // ErrNoAvailableBranch indicates that there is no available branch from the state storage.
+ ErrNoAvailableBranch = errors.New("no available branch from state storage")
)
diff --git a/blockproducer/rpc.go b/blockproducer/rpc.go
index ed44bf627..7869d5f2e 100644
--- a/blockproducer/rpc.go
+++ b/blockproducer/rpc.go
@@ -174,7 +174,7 @@ func (s *ChainRPCService) FetchBlockByCount(req *FetchBlockByCountReq, resp *Fet
func (s *ChainRPCService) NextAccountNonce(
req *NextAccountNonceReq, resp *NextAccountNonceResp) (err error,
) {
- if resp.Nonce, err = s.chain.rt.nextNonce(req.Addr); err != nil {
+ if resp.Nonce, err = s.chain.nextNonce(req.Addr); err != nil {
return
}
resp.Addr = req.Addr
@@ -195,7 +195,7 @@ func (s *ChainRPCService) QueryAccountStableBalance(
req *QueryAccountStableBalanceReq, resp *QueryAccountStableBalanceResp) (err error,
) {
resp.Addr = req.Addr
- resp.Balance, resp.OK = s.chain.rt.loadAccountStableBalance(req.Addr)
+ resp.Balance, resp.OK = s.chain.loadAccountStableBalance(req.Addr)
return
}
@@ -204,7 +204,7 @@ func (s *ChainRPCService) QueryAccountCovenantBalance(
req *QueryAccountCovenantBalanceReq, resp *QueryAccountCovenantBalanceResp) (err error,
) {
resp.Addr = req.Addr
- resp.Balance, resp.OK = s.chain.rt.loadAccountCovenantBalance(req.Addr)
+ resp.Balance, resp.OK = s.chain.loadAccountCovenantBalance(req.Addr)
return
}
diff --git a/blockproducer/runtime.go b/blockproducer/runtime.go
deleted file mode 100644
index 91a76e332..000000000
--- a/blockproducer/runtime.go
+++ /dev/null
@@ -1,496 +0,0 @@
-/*
- * Copyright 2018 The CovenantSQL Authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package blockproducer
-
-import (
- "context"
- "fmt"
- "math"
- "sync"
- "time"
-
- pi "github.com/CovenantSQL/CovenantSQL/blockproducer/interfaces"
- "github.com/CovenantSQL/CovenantSQL/crypto/asymmetric"
- "github.com/CovenantSQL/CovenantSQL/crypto/hash"
- "github.com/CovenantSQL/CovenantSQL/proto"
- "github.com/CovenantSQL/CovenantSQL/route"
- "github.com/CovenantSQL/CovenantSQL/rpc"
- "github.com/CovenantSQL/CovenantSQL/types"
- "github.com/CovenantSQL/CovenantSQL/utils/log"
- xi "github.com/CovenantSQL/CovenantSQL/xenomint/interfaces"
- "github.com/pkg/errors"
-)
-
-// runtime defines the runtime of main chain.
-type runtime struct {
- ctx context.Context
- cancel context.CancelFunc
- wg *sync.WaitGroup
-
- // The following fields are read-only in runtime.
- server *rpc.Server
- address proto.AccountAddress
- genesisTime time.Time
- period time.Duration
- tick time.Duration
-
- sync.RWMutex // protects following fields
- peers *proto.Peers
- nodeID proto.NodeID
- comfirms uint32
- serversNum uint32
- locSvIndex uint32
- nextTurn uint32
- offset time.Duration
- lastIrre *blockNode
- immutable *metaState
- headIndex int
- headBranch *branch
- branches []*branch
- txPool map[hash.Hash]pi.Transaction
-}
-
-func newRuntime(
- ctx context.Context, cfg *Config, accountAddress proto.AccountAddress,
- irre *blockNode, heads []*blockNode, immutable *metaState, txPool map[hash.Hash]pi.Transaction,
-) *runtime {
- var index uint32
- for i, s := range cfg.Peers.Servers {
- if cfg.NodeID.IsEqual(&s) {
- index = uint32(i)
- }
- }
-
- var (
- cld, ccl = context.WithCancel(ctx)
- l = float64(len(cfg.Peers.Servers))
- t float64
- m float64
- err error
- )
- if t = cfg.ComfirmThreshold; t <= 0.0 {
- t = float64(2) / 3.0
- }
- if m = math.Ceil(l*t + 1); m > l {
- m = l
- }
-
- // Rebuild branches
- var (
- branches []*branch
- br, head *branch
- headIndex int
- )
- if len(heads) == 0 {
- log.Fatal("At least one branch head is needed")
- }
- for _, v := range heads {
- log.WithFields(log.Fields{
- "irre_hash": irre.hash.Short(4),
- "irre_count": irre.count,
- "head_hash": v.hash.Short(4),
- "head_count": v.count,
- }).Debug("Checking head")
- if v.hasAncestor(irre) {
- if br, err = fork(irre, v, immutable, txPool); err != nil {
- log.WithError(err).Fatal("Failed to rebuild branch")
- }
- branches = append(branches, br)
- }
- }
- for i, v := range branches {
- if head == nil || v.head.count > head.head.count {
- headIndex = i
- head = v
- }
- }
-
- return &runtime{
- ctx: cld,
- cancel: ccl,
- wg: &sync.WaitGroup{},
-
- server: cfg.Server,
- address: accountAddress,
- genesisTime: cfg.Genesis.SignedHeader.Timestamp,
- period: cfg.Period,
- tick: cfg.Tick,
-
- peers: cfg.Peers,
- nodeID: cfg.NodeID,
- comfirms: uint32(m),
- serversNum: uint32(len(cfg.Peers.Servers)),
- locSvIndex: index,
- nextTurn: irre.height + 1,
- offset: time.Duration(0),
-
- lastIrre: irre,
- immutable: immutable,
- headIndex: headIndex,
- headBranch: head,
- branches: branches,
- txPool: txPool,
- }
-}
-
-func (r *runtime) addTx(st xi.Storage, tx pi.Transaction) (err error) {
- var k = tx.Hash()
- r.Lock()
- defer r.Unlock()
- if _, ok := r.txPool[k]; ok {
- err = ErrExistedTx
- return
- }
-
- return store(st, []storageProcedure{addTx(tx)}, func() {
- r.txPool[k] = tx
- for _, v := range r.branches {
- v.addTx(tx)
- }
- })
-}
-
-func (r *runtime) nextNonce(addr proto.AccountAddress) (n pi.AccountNonce, err error) {
- r.RLock()
- defer r.RUnlock()
- return r.headBranch.preview.nextNonce(addr)
-}
-
-func (r *runtime) loadAccountCovenantBalance(addr proto.AccountAddress) (balance uint64, ok bool) {
- r.RLock()
- defer r.RUnlock()
- return r.immutable.loadAccountCovenantBalance(addr)
-}
-
-func (r *runtime) loadAccountStableBalance(addr proto.AccountAddress) (balance uint64, ok bool) {
- r.RLock()
- defer r.RUnlock()
- return r.immutable.loadAccountStableBalance(addr)
-}
-
-func (r *runtime) switchBranch(st xi.Storage, bl *types.BPBlock, origin int, head *branch) (err error) {
- var (
- irre *blockNode
- newIrres []*blockNode
- sps []storageProcedure
- up storageCallback
- height = r.height(bl.Timestamp())
- )
-
- // Find new irreversible blocks
- //
- // NOTE(leventeliu):
- // May have multiple new irreversible blocks here if peer list shrinks. May also have
- // no new irreversible block at all if peer list expands.
- irre = head.head.lastIrreversible(r.comfirms)
- newIrres = irre.fetchNodeList(r.lastIrre.count)
-
- // Apply irreversible blocks to create dirty map on immutable cache
- //
- // TODO(leventeliu): use old metaState for now, better use separated dirty cache.
- for _, b := range newIrres {
- for _, tx := range b.block.Transactions {
- if err := r.immutable.apply(tx); err != nil {
- log.WithError(err).Fatal("Failed to apply block to immutable database")
- }
- }
- }
-
- // Prepare storage procedures to update immutable database
- sps = append(sps, addBlock(height, bl))
- for k, v := range r.immutable.dirty.accounts {
- if v != nil {
- sps = append(sps, updateAccount(&v.Account))
- } else {
- sps = append(sps, deleteAccount(k))
- }
- }
- for k, v := range r.immutable.dirty.databases {
- if v != nil {
- sps = append(sps, updateShardChain(&v.SQLChainProfile))
- } else {
- sps = append(sps, deleteShardChain(k))
- }
- }
- for k, v := range r.immutable.dirty.provider {
- if v != nil {
- sps = append(sps, updateProvider(&v.ProviderProfile))
- } else {
- sps = append(sps, deleteProvider(k))
- }
- }
- for _, n := range newIrres {
- sps = append(sps, deleteTxs(n.block.Transactions))
- }
- sps = append(sps, updateIrreversible(irre.hash))
-
- // Prepare callback to update cache
- up = func() {
- // Update last irreversible block
- r.lastIrre = irre
- // Apply irreversible blocks to immutable database
- r.immutable.commit()
- // Prune branches
- var (
- idx int
- brs = make([]*branch, 0, len(r.branches))
- )
- for i, b := range r.branches {
- if i == origin {
- // Current branch
- brs = append(brs, head)
- idx = len(brs) - 1
- } else if b.head.hasAncestor(irre) {
- brs = append(brs, b)
- } else {
- log.WithFields(log.Fields{
- "branch": func() string {
- if i == r.headIndex {
- return "[head]"
- }
- return fmt.Sprintf("[%04d]", i)
- }(),
- }).Debugf("Pruning branch")
- }
- }
- // Replace current branches
- r.headBranch = head
- r.headIndex = idx
- r.branches = brs
- // Clear packed transactions
- for _, b := range newIrres {
- for _, br := range r.branches {
- br.clearPackedTxs(b.block.Transactions)
- }
- for _, tx := range b.block.Transactions {
- delete(r.txPool, tx.Hash())
- }
- }
- }
-
- // Write to immutable database and update cache
- if err = store(st, sps, up); err != nil {
- r.immutable.clean()
- }
- return
-}
-
-func (r *runtime) log() {
- r.RLock()
- defer r.RUnlock()
- for i, v := range r.branches {
- var buff string
- if i == r.headIndex {
- buff += "[head] "
- } else {
- buff += fmt.Sprintf("[%04d] ", i)
- }
- buff += v.sprint(r.lastIrre.count)
- log.WithFields(log.Fields{
- "branch": buff,
- }).Info("Runtime state")
- }
- return
-}
-
-func (r *runtime) applyBlock(st xi.Storage, bl *types.BPBlock) (err error) {
- var (
- ok bool
- ierr error
- br *branch
- parent *blockNode
- head *blockNode
- height = r.height(bl.Timestamp())
- )
-
- defer r.log()
- r.Lock()
- defer r.Unlock()
-
- for i, v := range r.branches {
- // Grow a branch
- if v.head.hash.IsEqual(&bl.SignedHeader.ParentHash) {
- head = newBlockNode(height, bl, v.head)
- if br, ierr = v.applyBlock(head); ierr != nil {
- err = errors.Wrapf(ierr, "failed to apply block %s", head.hash.Short(4))
- return
- }
- // Grow a branch while the current branch is not changed
- if br.head.count <= r.headBranch.head.count {
- return store(st,
- []storageProcedure{addBlock(height, bl)},
- func() { r.branches[i] = br },
- )
- }
- // Switch branch or grow current branch
- return r.switchBranch(st, bl, i, br)
- }
- }
-
- for _, v := range r.branches {
- if n := v.head.ancestor(height); n != nil && n.hash.IsEqual(bl.BlockHash()) {
- // Return silently if block exists in the current branch
- return
- }
- // Fork and create new branch
- if parent, ok = v.head.canForkFrom(bl.SignedHeader.ParentHash, r.lastIrre.count); ok {
- head = newBlockNode(height, bl, parent)
- if br, ierr = fork(r.lastIrre, head, r.immutable, r.txPool); ierr != nil {
- err = errors.Wrapf(ierr, "failed to fork from %s", parent.hash.Short(4))
- return
- }
- return store(st,
- []storageProcedure{addBlock(height, bl)},
- func() { r.branches = append(r.branches, br) },
- )
- }
- }
-
- err = ErrParentNotFound
- return
-}
-
-func (r *runtime) produceBlock(
- st xi.Storage, now time.Time, priv *asymmetric.PrivateKey) (out *types.BPBlock, err error,
-) {
- var (
- bl *types.BPBlock
- br *branch
- ierr error
- )
-
- defer r.log()
- r.Lock()
- defer r.Unlock()
-
- // Try to produce new block
- if br, bl, ierr = r.headBranch.produceBlock(
- r.height(now), now, r.address, priv,
- ); ierr != nil {
- err = errors.Wrapf(ierr, "failed to produce block at head %s",
- r.headBranch.head.hash.Short(4))
- return
- }
- if ierr = r.switchBranch(st, bl, r.headIndex, br); ierr != nil {
- err = errors.Wrapf(ierr, "failed to switch branch #%d:%s",
- r.headIndex, r.headBranch.head.hash.Short(4))
- return
- }
- out = bl
- return
-}
-
-// now returns the current coordinated chain time.
-func (r *runtime) now() time.Time {
- r.RLock()
- defer r.RUnlock()
- return time.Now().UTC().Add(r.offset)
-}
-
-func (r *runtime) startService(chain *Chain) {
- r.server.RegisterService(route.BlockProducerRPCName, &ChainRPCService{chain: chain})
-}
-
-// nextTick returns the current clock reading and the duration till the next turn. If duration
-// is less or equal to 0, use the clock reading to run the next cycle - this avoids some problem
-// caused by concurrent time synchronization.
-func (r *runtime) nextTick() (t time.Time, d time.Duration) {
- var nt uint32
- nt, t = func() (nt uint32, t time.Time) {
- r.RLock()
- defer r.RUnlock()
- nt = r.nextTurn
- t = time.Now().UTC().Add(r.offset)
- return
- }()
- d = r.genesisTime.Add(time.Duration(nt) * r.period).Sub(t)
- if d > r.tick {
- d = r.tick
- }
- return
-}
-
-func (r *runtime) isMyTurn() bool {
- r.RLock()
- defer r.RUnlock()
- return r.nextTurn%r.serversNum == r.locSvIndex
-}
-
-// setNextTurn prepares the runtime state for the next turn.
-func (r *runtime) setNextTurn() {
- r.Lock()
- defer r.Unlock()
- r.nextTurn++
-}
-
-func (r *runtime) peerInfo() string {
- var index, bpNum, nodeID = func() (uint32, uint32, proto.NodeID) {
- r.RLock()
- defer r.RUnlock()
- return r.locSvIndex, r.serversNum, r.nodeID
- }()
- return fmt.Sprintf("[%d/%d] %s", index, bpNum, nodeID)
-}
-
-// height calculates the height with this sql-chain config of a given time reading.
-func (r *runtime) height(t time.Time) uint32 {
- return uint32(t.Sub(r.genesisTime) / r.period)
-}
-
-func (r *runtime) getNextTurn() uint32 {
- r.RLock()
- defer r.RUnlock()
- return r.nextTurn
-}
-
-func (r *runtime) getPeers() *proto.Peers {
- r.RLock()
- defer r.RUnlock()
- var peers = r.peers.Clone()
- return &peers
-}
-
-func (r *runtime) head() *blockNode {
- r.RLock()
- defer r.RUnlock()
- return r.headBranch.head
-}
-
-func (r *runtime) stop() {
- r.cancel()
- r.wg.Wait()
-}
-
-func (r *runtime) goFunc(f func(ctx context.Context)) {
- r.wg.Add(1)
- go func() {
- defer r.wg.Done()
- f(r.ctx)
- }()
-}
-
-func (r *runtime) goFuncWithTimeout(f func(ctx context.Context), timeout time.Duration) {
- r.wg.Add(1)
- go func() {
- var ctx, ccl = context.WithTimeout(r.ctx, timeout)
- defer func() {
- ccl()
- r.wg.Done()
- }()
- f(ctx)
- }()
-}
From c3f7302be1c89de26215dd7091d47bab7fa833a0 Mon Sep 17 00:00:00 2001
From: leventeliu
Date: Tue, 18 Dec 2018 00:20:31 +0800
Subject: [PATCH 072/278] Add transactions to forked branch
---
blockproducer/chain_test.go | 11 +++--------
1 file changed, 3 insertions(+), 8 deletions(-)
diff --git a/blockproducer/chain_test.go b/blockproducer/chain_test.go
index 6b76a3a3f..353ebe2d5 100644
--- a/blockproducer/chain_test.go
+++ b/blockproducer/chain_test.go
@@ -33,14 +33,6 @@ import (
. "github.com/smartystreets/goconvey/convey"
)
-var (
- testPeersNumber = 1
- testPeriod = 1 * time.Second
- testTick = 100 * time.Millisecond
- testPeriodNumber uint32 = 10
- testClientNumberPerChain = 10
-)
-
func newTransfer(
nonce pi.AccountNonce, signer *asymmetric.PrivateKey,
sender, receiver proto.AccountAddress, amount uint64,
@@ -260,6 +252,9 @@ func TestChain(t *testing.T) {
Convey("The chain head should switch to fork #1 if it grows to count 7", func() {
// Add 2 more blocks to fork #1, this should trigger a branch switch to fork #1
chain.stat()
+ f1.addTx(t2)
+ f1.addTx(t3)
+ f1.addTx(t4)
f1, bl, err = f1.produceBlock(7, begin.Add(8*chain.period), addr2, priv2)
So(err, ShouldBeNil)
So(bl, ShouldNotBeNil)
From 7cab95afbe229d3f9d9b9859fd83e5833f00d1aa Mon Sep 17 00:00:00 2001
From: leventeliu
Date: Tue, 18 Dec 2018 11:29:10 +0800
Subject: [PATCH 073/278] Fix transaction type error
---
blockproducer/storage.go | 12 ++++--------
types/provideservice.go | 4 ++--
2 files changed, 6 insertions(+), 10 deletions(-)
diff --git a/blockproducer/storage.go b/blockproducer/storage.go
index 8bb779b6e..949673dfe 100644
--- a/blockproducer/storage.go
+++ b/blockproducer/storage.go
@@ -140,14 +140,10 @@ func addBlock(height uint32, b *types.BPBlock) storageProcedure {
func addTx(t pi.Transaction) storageProcedure {
var (
- tt = t
enc *bytes.Buffer
err error
)
- if _, ok := tt.(*pi.TransactionWrapper); !ok {
- tt = pi.WrapTransaction(tt)
- }
- if enc, err = utils.EncodeMsgPack(tt); err != nil {
+ if enc, err = utils.EncodeMsgPack(t); err != nil {
return errPass(err)
}
return func(tx *sql.Tx) (err error) {
@@ -294,11 +290,11 @@ func loadTxPool(st xi.Storage) (txPool map[hash.Hash]pi.Transaction, err error)
if err = hash.Decode(&th, hex); err != nil {
return
}
- var dec = &pi.TransactionWrapper{}
- if err = utils.DecodeMsgPack(enc, dec); err != nil {
+ var dec pi.Transaction
+ if err = utils.DecodeMsgPack(enc, &dec); err != nil {
return
}
- pool[th] = dec.Unwrap()
+ pool[th] = dec
}
txPool = pool
diff --git a/types/provideservice.go b/types/provideservice.go
index fdbfbc6c0..b172eda28 100644
--- a/types/provideservice.go
+++ b/types/provideservice.go
@@ -52,7 +52,7 @@ type ProvideService struct {
func NewProvideService(h *ProvideServiceHeader) *ProvideService {
return &ProvideService{
ProvideServiceHeader: *h,
- TransactionTypeMixin: *interfaces.NewTransactionTypeMixin(interfaces.TransactionTypeCreateDatabase),
+ TransactionTypeMixin: *interfaces.NewTransactionTypeMixin(interfaces.TransactionTypeProvideService),
}
}
@@ -73,5 +73,5 @@ func (ps *ProvideService) GetAccountAddress() proto.AccountAddress {
}
func init() {
- interfaces.RegisterTransaction(interfaces.TransactionTypeCreateDatabase, (*ProvideService)(nil))
+ interfaces.RegisterTransaction(interfaces.TransactionTypeProvideService, (*ProvideService)(nil))
}
From eff5e0a1fd517f702bdaa550550a1161a4d3ee9a Mon Sep 17 00:00:00 2001
From: auxten
Date: Tue, 18 Dec 2018 12:56:24 +0800
Subject: [PATCH 074/278] Add v0.0.6 changelog
---
CHANGELOG.md | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index ba8e0389b..52e4dcdce 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,23 @@
# Changelog
+## [v0.0.6](https://github.com/CovenantSQL/CovenantSQL/tree/v0.0.6) (2018-12-18)
+
+[Full Changelog](https://github.com/CovenantSQL/CovenantSQL/compare/v0.0.5...v0.0.6)
+
+**Closed issues:**
+
+- Could not run in docker based alpine image [\#134](https://github.com/CovenantSQL/CovenantSQL/issues/134)
+- Quickstart cli document 404 [\#97](https://github.com/CovenantSQL/CovenantSQL/issues/97)
+- Any plan to NodeJS support? [\#80](https://github.com/CovenantSQL/CovenantSQL/issues/80)
+
+**Merged pull requests:**
+
+- Add a Gitter chat badge to README.md [\#137](https://github.com/CovenantSQL/CovenantSQL/pull/137) ([gitter-badger](https://github.com/gitter-badger))
+- Add DSN options to enable SQL queries on follower nodes [\#136](https://github.com/CovenantSQL/CovenantSQL/pull/136) ([ggicci](https://github.com/ggicci))
+- If smux session dead, cancel the context passed to RPC through Envelope [\#133](https://github.com/CovenantSQL/CovenantSQL/pull/133) ([auxten](https://github.com/auxten))
+- Add new cloudflare.com DNSKEY [\#132](https://github.com/CovenantSQL/CovenantSQL/pull/132) ([auxten](https://github.com/auxten))
+- Prepare for auto bench in jenkins environment. [\#131](https://github.com/CovenantSQL/CovenantSQL/pull/131) ([laodouya](https://github.com/laodouya))
+
## [v0.0.5](https://github.com/CovenantSQL/CovenantSQL/tree/v0.0.5) (2018-11-23)
[Full Changelog](https://github.com/CovenantSQL/CovenantSQL/compare/v0.0.4...v0.0.5)
From cf370e96a199a9b684ca26fe871f48824749046a Mon Sep 17 00:00:00 2001
From: auxten
Date: Tue, 18 Dec 2018 13:13:15 +0800
Subject: [PATCH 075/278] Format code for new version goimports
---
blockproducer/chain.go | 2 +-
blockproducer/metaindex.go | 2 +-
blockproducer/metaindex_test.go | 2 +-
blockproducer/metastate.go | 4 ++--
blockproducer/metastate_test.go | 2 +-
cmd/cql-adapter/config/config.go | 2 +-
cmd/cql-adapter/storage/sqlite3.go | 1 +
cmd/cql-faucet/config.go | 2 +-
cmd/cql-faucet/persistence.go | 3 ++-
cmd/cql-minerd/integration_test.go | 2 +-
cmd/cql-minerd/main.go | 5 +++--
cmd/cql-observer/config.go | 2 +-
cmd/cql-observer/service.go | 2 +-
cmd/cql-utils/adapterconfgen.go | 2 +-
cmd/cql-utils/rpc.go | 2 +-
cmd/cql/main.go | 2 +-
cmd/cql/util.go | 2 +-
cmd/hotfix/observer-upgrade/main.go | 2 +-
conf/config.go | 2 +-
conf/config_test.go | 2 +-
crypto/asymmetric/keypair_test.go | 2 +-
crypto/hash/hash_test.go | 2 +-
crypto/hash/hashfuncs.go | 3 ++-
crypto/kms/pubkeystore.go | 2 +-
crypto/kms/pubkeystore_test.go | 2 +-
kayak/runtime_test.go | 2 +-
proto/nodeinfo_test.go | 2 +-
storage/storage.go | 1 +
xenomint/sqlite/sqlite.go | 2 +-
29 files changed, 34 insertions(+), 29 deletions(-)
diff --git a/blockproducer/chain.go b/blockproducer/chain.go
index bcb00161b..a3a2d06dc 100644
--- a/blockproducer/chain.go
+++ b/blockproducer/chain.go
@@ -34,7 +34,7 @@ import (
"github.com/CovenantSQL/CovenantSQL/rpc"
"github.com/CovenantSQL/CovenantSQL/utils"
"github.com/CovenantSQL/CovenantSQL/utils/log"
- "github.com/coreos/bbolt"
+ bolt "github.com/coreos/bbolt"
"github.com/pkg/errors"
)
diff --git a/blockproducer/metaindex.go b/blockproducer/metaindex.go
index da5c6d05b..3bd9c134d 100644
--- a/blockproducer/metaindex.go
+++ b/blockproducer/metaindex.go
@@ -23,7 +23,7 @@ import (
pt "github.com/CovenantSQL/CovenantSQL/blockproducer/types"
"github.com/CovenantSQL/CovenantSQL/proto"
"github.com/CovenantSQL/CovenantSQL/utils"
- "github.com/coreos/bbolt"
+ bolt "github.com/coreos/bbolt"
"github.com/ulule/deepcopier"
)
diff --git a/blockproducer/metaindex_test.go b/blockproducer/metaindex_test.go
index d85fc0d6c..a933b6d65 100644
--- a/blockproducer/metaindex_test.go
+++ b/blockproducer/metaindex_test.go
@@ -24,7 +24,7 @@ import (
pi "github.com/CovenantSQL/CovenantSQL/blockproducer/interfaces"
pt "github.com/CovenantSQL/CovenantSQL/blockproducer/types"
"github.com/CovenantSQL/CovenantSQL/proto"
- "github.com/coreos/bbolt"
+ bolt "github.com/coreos/bbolt"
. "github.com/smartystreets/goconvey/convey"
)
diff --git a/blockproducer/metastate.go b/blockproducer/metastate.go
index ec7814ae0..c9981fc87 100644
--- a/blockproducer/metastate.go
+++ b/blockproducer/metastate.go
@@ -25,7 +25,7 @@ import (
"github.com/CovenantSQL/CovenantSQL/proto"
"github.com/CovenantSQL/CovenantSQL/utils"
"github.com/CovenantSQL/CovenantSQL/utils/log"
- "github.com/coreos/bbolt"
+ bolt "github.com/coreos/bbolt"
"github.com/ulule/deepcopier"
)
@@ -84,7 +84,7 @@ func (s *metaState) loadAccountStableBalance(addr proto.AccountAddress) (b uint6
"loaded": loaded,
}).Debug("queried stable account")
}()
-
+
s.Lock()
defer s.Unlock()
diff --git a/blockproducer/metastate_test.go b/blockproducer/metastate_test.go
index e27cc13af..37b480b2c 100644
--- a/blockproducer/metastate_test.go
+++ b/blockproducer/metastate_test.go
@@ -25,7 +25,7 @@ import (
pi "github.com/CovenantSQL/CovenantSQL/blockproducer/interfaces"
pt "github.com/CovenantSQL/CovenantSQL/blockproducer/types"
"github.com/CovenantSQL/CovenantSQL/proto"
- "github.com/coreos/bbolt"
+ bolt "github.com/coreos/bbolt"
. "github.com/smartystreets/goconvey/convey"
)
diff --git a/cmd/cql-adapter/config/config.go b/cmd/cql-adapter/config/config.go
index debf4f5e7..f5a39ba62 100644
--- a/cmd/cql-adapter/config/config.go
+++ b/cmd/cql-adapter/config/config.go
@@ -29,7 +29,7 @@ import (
"github.com/CovenantSQL/CovenantSQL/cmd/cql-adapter/storage"
"github.com/CovenantSQL/CovenantSQL/conf"
"github.com/CovenantSQL/CovenantSQL/utils/log"
- "gopkg.in/yaml.v2"
+ yaml "gopkg.in/yaml.v2"
)
var (
diff --git a/cmd/cql-adapter/storage/sqlite3.go b/cmd/cql-adapter/storage/sqlite3.go
index aac13f94d..d9be539d8 100644
--- a/cmd/cql-adapter/storage/sqlite3.go
+++ b/cmd/cql-adapter/storage/sqlite3.go
@@ -24,6 +24,7 @@ import (
"math/rand"
"os"
"path/filepath"
+
// Import sqlite3 manually.
_ "github.com/CovenantSQL/go-sqlite3-encrypt"
)
diff --git a/cmd/cql-faucet/config.go b/cmd/cql-faucet/config.go
index 7f30ba25b..34b9c5ca8 100644
--- a/cmd/cql-faucet/config.go
+++ b/cmd/cql-faucet/config.go
@@ -21,7 +21,7 @@ import (
"time"
"github.com/CovenantSQL/CovenantSQL/utils/log"
- "gopkg.in/yaml.v2"
+ yaml "gopkg.in/yaml.v2"
)
// Config defines the configurable options for faucet application backend.
diff --git a/cmd/cql-faucet/persistence.go b/cmd/cql-faucet/persistence.go
index 91a009030..140a6c6d6 100644
--- a/cmd/cql-faucet/persistence.go
+++ b/cmd/cql-faucet/persistence.go
@@ -25,7 +25,8 @@ import (
"github.com/CovenantSQL/CovenantSQL/client"
"github.com/CovenantSQL/CovenantSQL/conf"
"github.com/CovenantSQL/CovenantSQL/utils/log"
- "github.com/satori/go.uuid"
+ uuid "github.com/satori/go.uuid"
+
// Load sqlite3 database driver.
_ "github.com/CovenantSQL/go-sqlite3-encrypt"
)
diff --git a/cmd/cql-minerd/integration_test.go b/cmd/cql-minerd/integration_test.go
index eacb16bce..c6997859f 100644
--- a/cmd/cql-minerd/integration_test.go
+++ b/cmd/cql-minerd/integration_test.go
@@ -41,7 +41,7 @@ import (
"github.com/CovenantSQL/CovenantSQL/rpc"
"github.com/CovenantSQL/CovenantSQL/utils"
"github.com/CovenantSQL/CovenantSQL/utils/log"
- "github.com/CovenantSQL/go-sqlite3-encrypt"
+ sqlite3 "github.com/CovenantSQL/go-sqlite3-encrypt"
. "github.com/smartystreets/goconvey/convey"
)
diff --git a/cmd/cql-minerd/main.go b/cmd/cql-minerd/main.go
index ed6c3abb5..adc2b0bfa 100644
--- a/cmd/cql-minerd/main.go
+++ b/cmd/cql-minerd/main.go
@@ -26,6 +26,7 @@ import (
"os"
"os/signal"
"runtime"
+
//"runtime/trace"
"syscall"
"time"
@@ -39,8 +40,8 @@ import (
"github.com/CovenantSQL/CovenantSQL/utils"
"github.com/CovenantSQL/CovenantSQL/utils/log"
"github.com/CovenantSQL/CovenantSQL/worker"
- "github.com/cyberdelia/go-metrics-graphite"
- "github.com/rcrowley/go-metrics"
+ graphite "github.com/cyberdelia/go-metrics-graphite"
+ metrics "github.com/rcrowley/go-metrics"
)
const logo = `
diff --git a/cmd/cql-observer/config.go b/cmd/cql-observer/config.go
index 4b68f44c4..0964fef0f 100644
--- a/cmd/cql-observer/config.go
+++ b/cmd/cql-observer/config.go
@@ -20,7 +20,7 @@ import (
"io/ioutil"
"github.com/CovenantSQL/CovenantSQL/utils/log"
- "gopkg.in/yaml.v2"
+ yaml "gopkg.in/yaml.v2"
)
// Database defines single database subscription status.
diff --git a/cmd/cql-observer/service.go b/cmd/cql-observer/service.go
index c9fbe25a9..32eb652f6 100644
--- a/cmd/cql-observer/service.go
+++ b/cmd/cql-observer/service.go
@@ -35,7 +35,7 @@ import (
"github.com/CovenantSQL/CovenantSQL/types"
"github.com/CovenantSQL/CovenantSQL/utils"
"github.com/CovenantSQL/CovenantSQL/utils/log"
- "github.com/coreos/bbolt"
+ bolt "github.com/coreos/bbolt"
)
const (
diff --git a/cmd/cql-utils/adapterconfgen.go b/cmd/cql-utils/adapterconfgen.go
index bcbad9273..fd789c88c 100644
--- a/cmd/cql-utils/adapterconfgen.go
+++ b/cmd/cql-utils/adapterconfgen.go
@@ -24,7 +24,7 @@ import (
"strings"
"github.com/CovenantSQL/CovenantSQL/utils/log"
- "gopkg.in/yaml.v2"
+ yaml "gopkg.in/yaml.v2"
)
type adapterConfig struct {
diff --git a/cmd/cql-utils/rpc.go b/cmd/cql-utils/rpc.go
index f3663fceb..e1f078b5c 100644
--- a/cmd/cql-utils/rpc.go
+++ b/cmd/cql-utils/rpc.go
@@ -35,7 +35,7 @@ import (
"github.com/CovenantSQL/CovenantSQL/sqlchain"
"github.com/CovenantSQL/CovenantSQL/utils/log"
"github.com/CovenantSQL/CovenantSQL/worker"
- "gopkg.in/yaml.v2"
+ yaml "gopkg.in/yaml.v2"
)
var (
diff --git a/cmd/cql/main.go b/cmd/cql/main.go
index 91791193e..cf9cb6d4c 100644
--- a/cmd/cql/main.go
+++ b/cmd/cql/main.go
@@ -29,7 +29,7 @@ import (
"strconv"
"strings"
- "github.com/CovenantSQL/go-sqlite3-encrypt"
+ sqlite3 "github.com/CovenantSQL/go-sqlite3-encrypt"
"github.com/xo/dburl"
"github.com/xo/usql/drivers"
"github.com/xo/usql/env"
diff --git a/cmd/cql/util.go b/cmd/cql/util.go
index 8622c372b..d20a87e20 100644
--- a/cmd/cql/util.go
+++ b/cmd/cql/util.go
@@ -24,7 +24,7 @@ import (
"reflect"
"time"
- "github.com/CovenantSQL/go-sqlite3-encrypt"
+ sqlite3 "github.com/CovenantSQL/go-sqlite3-encrypt"
)
// SqTime provides a type that will correctly scan the various timestamps
diff --git a/cmd/hotfix/observer-upgrade/main.go b/cmd/hotfix/observer-upgrade/main.go
index c650f306d..2f7322644 100644
--- a/cmd/hotfix/observer-upgrade/main.go
+++ b/cmd/hotfix/observer-upgrade/main.go
@@ -26,7 +26,7 @@ import (
ct "github.com/CovenantSQL/CovenantSQL/sqlchain/otypes"
"github.com/CovenantSQL/CovenantSQL/utils"
"github.com/CovenantSQL/CovenantSQL/utils/log"
- "github.com/coreos/bbolt"
+ bolt "github.com/coreos/bbolt"
)
type blockNode struct {
diff --git a/conf/config.go b/conf/config.go
index 29ae8f1da..f237db10b 100644
--- a/conf/config.go
+++ b/conf/config.go
@@ -26,7 +26,7 @@ import (
"github.com/CovenantSQL/CovenantSQL/pow/cpuminer"
"github.com/CovenantSQL/CovenantSQL/proto"
"github.com/CovenantSQL/CovenantSQL/utils/log"
- "gopkg.in/yaml.v2"
+ yaml "gopkg.in/yaml.v2"
)
// these const specify the role of this app, which can be "miner", "blockProducer"
diff --git a/conf/config_test.go b/conf/config_test.go
index 84d5d0103..1cdc590dd 100644
--- a/conf/config_test.go
+++ b/conf/config_test.go
@@ -29,7 +29,7 @@ import (
"github.com/CovenantSQL/CovenantSQL/proto"
"github.com/CovenantSQL/CovenantSQL/utils/log"
. "github.com/smartystreets/goconvey/convey"
- "gopkg.in/yaml.v2"
+ yaml "gopkg.in/yaml.v2"
)
const testFile = "./.configtest"
diff --git a/crypto/asymmetric/keypair_test.go b/crypto/asymmetric/keypair_test.go
index 34f95c230..b625407cd 100644
--- a/crypto/asymmetric/keypair_test.go
+++ b/crypto/asymmetric/keypair_test.go
@@ -25,7 +25,7 @@ import (
"github.com/CovenantSQL/CovenantSQL/utils/log"
ec "github.com/btcsuite/btcd/btcec"
. "github.com/smartystreets/goconvey/convey"
- "gopkg.in/yaml.v2"
+ yaml "gopkg.in/yaml.v2"
)
func TestGenSecp256k1Keypair(t *testing.T) {
diff --git a/crypto/hash/hash_test.go b/crypto/hash/hash_test.go
index 0ef77d42b..a3ade2af8 100644
--- a/crypto/hash/hash_test.go
+++ b/crypto/hash/hash_test.go
@@ -23,7 +23,7 @@ import (
"testing"
. "github.com/smartystreets/goconvey/convey"
- "gopkg.in/yaml.v2"
+ yaml "gopkg.in/yaml.v2"
)
// mainNetGenesisHash is the hash of the first block in the block chain for the
diff --git a/crypto/hash/hashfuncs.go b/crypto/hash/hashfuncs.go
index 6235c4964..af14cf46d 100644
--- a/crypto/hash/hashfuncs.go
+++ b/crypto/hash/hashfuncs.go
@@ -19,13 +19,14 @@ package hash
import (
"encoding/binary"
"hash/fnv"
+
// "crypto/sha256" benchmark is at least 10% faster on
// i7-4870HQ CPU @ 2.50GHz than "github.com/minio/sha256-simd"
"crypto/sha256"
// "minio/blake2b-simd" benchmark is at least 3% faster on
// i7-4870HQ CPU @ 2.50GHz than "golang.org/x/crypto/blake2b"
// and supports more CPU instructions
- "github.com/minio/blake2b-simd"
+ blake2b "github.com/minio/blake2b-simd"
)
// HashBSize is the size of HashB
diff --git a/crypto/kms/pubkeystore.go b/crypto/kms/pubkeystore.go
index 0c3e15e6f..8a3d284a8 100644
--- a/crypto/kms/pubkeystore.go
+++ b/crypto/kms/pubkeystore.go
@@ -31,7 +31,7 @@ import (
"github.com/CovenantSQL/CovenantSQL/proto"
"github.com/CovenantSQL/CovenantSQL/utils"
"github.com/CovenantSQL/CovenantSQL/utils/log"
- "github.com/coreos/bbolt"
+ bolt "github.com/coreos/bbolt"
)
// PublicKeyStore holds db and bucket name
diff --git a/crypto/kms/pubkeystore_test.go b/crypto/kms/pubkeystore_test.go
index eae61e309..707f839db 100644
--- a/crypto/kms/pubkeystore_test.go
+++ b/crypto/kms/pubkeystore_test.go
@@ -27,7 +27,7 @@ import (
"github.com/CovenantSQL/CovenantSQL/utils"
"github.com/CovenantSQL/CovenantSQL/utils/log"
. "github.com/smartystreets/goconvey/convey"
- "gopkg.in/yaml.v2"
+ yaml "gopkg.in/yaml.v2"
)
const dbFile = ".test.db"
diff --git a/kayak/runtime_test.go b/kayak/runtime_test.go
index 101883bab..f0070e905 100644
--- a/kayak/runtime_test.go
+++ b/kayak/runtime_test.go
@@ -38,7 +38,7 @@ import (
"github.com/CovenantSQL/CovenantSQL/storage"
"github.com/CovenantSQL/CovenantSQL/utils"
"github.com/CovenantSQL/CovenantSQL/utils/log"
- "github.com/jordwest/mock-conn"
+ mock_conn "github.com/jordwest/mock-conn"
"github.com/pkg/errors"
. "github.com/smartystreets/goconvey/convey"
)
diff --git a/proto/nodeinfo_test.go b/proto/nodeinfo_test.go
index b0ac900ab..75748b7d5 100644
--- a/proto/nodeinfo_test.go
+++ b/proto/nodeinfo_test.go
@@ -23,7 +23,7 @@ import (
"github.com/CovenantSQL/CovenantSQL/crypto/hash"
. "github.com/smartystreets/goconvey/convey"
- "gopkg.in/yaml.v2"
+ yaml "gopkg.in/yaml.v2"
)
func TestNode_InitNodeCryptoInfo(t *testing.T) {
diff --git a/storage/storage.go b/storage/storage.go
index 7e36bad0e..e059819af 100644
--- a/storage/storage.go
+++ b/storage/storage.go
@@ -26,6 +26,7 @@ import (
"github.com/CovenantSQL/CovenantSQL/twopc"
"github.com/CovenantSQL/CovenantSQL/utils/log"
+
// Register CovenantSQL/go-sqlite3-encrypt engine.
_ "github.com/CovenantSQL/go-sqlite3-encrypt"
)
diff --git a/xenomint/sqlite/sqlite.go b/xenomint/sqlite/sqlite.go
index 0c2780250..15718bacd 100644
--- a/xenomint/sqlite/sqlite.go
+++ b/xenomint/sqlite/sqlite.go
@@ -22,7 +22,7 @@ import (
"github.com/CovenantSQL/CovenantSQL/storage"
"github.com/CovenantSQL/CovenantSQL/utils/log"
- "github.com/CovenantSQL/go-sqlite3-encrypt"
+ sqlite3 "github.com/CovenantSQL/go-sqlite3-encrypt"
)
const (
From 039cb177c31a19578628b6dbc41e074be945be91 Mon Sep 17 00:00:00 2001
From: leventeliu
Date: Tue, 18 Dec 2018 13:26:50 +0800
Subject: [PATCH 076/278] Rename some functions to improve readability
---
blockproducer/chain.go | 95 ++++++++++++++++++++++--------------------
1 file changed, 50 insertions(+), 45 deletions(-)
diff --git a/blockproducer/chain.go b/blockproducer/chain.go
index 9454fc6bc..c5c125af4 100644
--- a/blockproducer/chain.go
+++ b/blockproducer/chain.go
@@ -82,7 +82,7 @@ type Chain struct {
comfirms uint32
serversNum uint32
locSvIndex uint32
- nextTurn uint32
+ nextHeight uint32
offset time.Duration
lastIrre *blockNode
immutable *metaState
@@ -189,8 +189,8 @@ func NewChainWithContext(ctx context.Context, cfg *Config) (c *Chain, err error)
"head_count": v.count,
}).Debug("Checking head")
if v.hasAncestor(irre) {
- if br, err = fork(irre, v, immutable, txPool); err != nil {
- log.WithError(err).Fatal("Failed to rebuild branch")
+ if br, ierr = fork(irre, v, immutable, txPool); ierr != nil {
+ err = errors.Wrapf(ierr, "failed to rebuild branch with head %s", v.hash.Short(4))
}
branches = append(branches, br)
}
@@ -253,7 +253,7 @@ func NewChainWithContext(ctx context.Context, cfg *Config) (c *Chain, err error)
comfirms: uint32(m),
serversNum: uint32(len(cfg.Peers.Servers)),
locSvIndex: uint32(locSvIndex),
- nextTurn: head.head.height + 1,
+ nextHeight: head.head.height + 1,
offset: time.Duration(0), // TODO(leventeliu): initialize offset
lastIrre: irre,
@@ -403,20 +403,20 @@ func (c *Chain) fetchBlockByCount(count uint32) (b *types.BPBlock, height uint32
return
}
-// runCurrentTurn does the check and runs block producing if its my turn.
-func (c *Chain) runCurrentTurn(now time.Time) {
+// advanceNextHeight does the check and runs block producing if its my turn.
+func (c *Chain) advanceNextHeight(now time.Time) {
log.WithFields(log.Fields{
- "next_turn": c.getNextTurn(),
- "bp_number": c.serversNum,
- "node_index": c.locSvIndex,
+ "next_height": c.getNextHeight(),
+ "bp_number": c.serversNum,
+ "node_index": c.locSvIndex,
}).Info("check turns")
- defer c.setNextTurn()
+ defer c.increaseNextHeight()
if !c.isMyTurn() {
return
}
- log.WithField("height", c.getNextTurn()).Info("producing a new block")
+ log.WithField("height", c.getNextHeight()).Info("producing a new block")
if err := c.produceBlock(now); err != nil {
log.WithField("now", now.Format(time.RFC3339Nano)).WithError(err).Errorln(
"failed to produce block")
@@ -425,21 +425,21 @@ func (c *Chain) runCurrentTurn(now time.Time) {
func (c *Chain) syncHeads() {
for {
- var h = c.height(c.now())
- if c.getNextTurn() > h {
+ var h = c.heightOfTime(c.now())
+ if c.getNextHeight() > h {
break
}
- for c.getNextTurn() <= h {
+ for c.getNextHeight() <= h {
// TODO(leventeliu): use the test mode flag to bypass the long-running synchronizing
// on startup by now, need better solution here.
if !conf.GConf.IsTestMode {
log.WithFields(log.Fields{
- "next_turn": c.getNextTurn(),
- "height": h,
+ "next_height": c.getNextHeight(),
+ "height": h,
}).Debug("Synchronizing head blocks")
- c.syncHead(c.ctx)
+ c.syncCurrentHead(c.ctx)
}
- c.setNextTurn()
+ c.increaseNextHeight()
}
}
}
@@ -540,13 +540,15 @@ func (c *Chain) mainCycle(ctx context.Context) {
for {
select {
case <-ctx.Done():
+ log.WithError(ctx.Err()).Debug("Abort main cycle")
return
default:
- c.syncHead(ctx)
+ c.syncCurrentHead(ctx) // Try to fetch block at height `nextHeight-1`
+
if t, d := c.nextTick(); d > 0 {
log.WithFields(log.Fields{
"peer": c.peerInfo(),
- "next_turn": c.getNextTurn(),
+ "next_height": c.getNextHeight(),
"head_height": c.head().height,
"head_block": c.head().hash.Short(4),
"now_time": t.Format(time.RFC3339Nano),
@@ -554,28 +556,31 @@ func (c *Chain) mainCycle(ctx context.Context) {
}).Debug("Main cycle")
time.Sleep(d)
} else {
- c.runCurrentTurn(t)
+ // Try to produce block at `nextHeight` if it's my turn, and increase height by 1
+ c.advanceNextHeight(t)
}
}
}
}
-func (c *Chain) syncHead(ctx context.Context) {
+func (c *Chain) syncCurrentHead(ctx context.Context) {
var (
- nextHeight = c.getNextTurn() - 1
- cld, ccl = context.WithCancel(ctx)
- wg = &sync.WaitGroup{}
+ h = c.getNextHeight() - 1
+ cld, ccl = context.WithTimeout(ctx, c.tick)
+ wg = &sync.WaitGroup{}
)
defer func() {
- ccl()
wg.Wait()
+ ccl()
}()
- if c.head().height >= nextHeight {
+ if c.head().height >= h {
return
}
+ // Initiate blocking gossip calls to fetch block of the current height,
+ // with timeout of one tick.
for _, v := range c.getPeers().Servers {
if !v.IsEqual(&c.nodeID) {
wg.Add(1)
@@ -587,7 +592,7 @@ func (c *Chain) syncHead(ctx context.Context) {
Envelope: proto.Envelope{
// TODO(lambda): Add fields.
},
- Height: nextHeight,
+ Height: h,
}
resp = &FetchBlockResp{}
)
@@ -597,14 +602,14 @@ func (c *Chain) syncHead(ctx context.Context) {
log.WithFields(log.Fields{
"local": c.peerInfo(),
"remote": id,
- "height": nextHeight,
+ "height": h,
}).WithError(err).Warn("Failed to fetch block")
return
}
log.WithFields(log.Fields{
"local": c.peerInfo(),
"remote": id,
- "height": nextHeight,
+ "height": h,
"parent": resp.Block.ParentHash().Short(4),
"hash": resp.Block.BlockHash().Short(4),
}).Debug("Fetched new block from remote peer")
@@ -672,7 +677,7 @@ func (c *Chain) switchBranch(bl *types.BPBlock, origin int, head *branch) (err e
newIrres []*blockNode
sps []storageProcedure
up storageCallback
- height = c.height(bl.Timestamp())
+ height = c.heightOfTime(bl.Timestamp())
)
// Find new irreversible blocks
@@ -800,7 +805,7 @@ func (c *Chain) applyBlock(bl *types.BPBlock) (err error) {
br *branch
parent *blockNode
head *blockNode
- height = c.height(bl.Timestamp())
+ height = c.heightOfTime(bl.Timestamp())
)
defer c.stat()
@@ -865,7 +870,7 @@ func (c *Chain) produceAndStoreBlock(
// Try to produce new block
if br, bl, ierr = c.headBranch.produceBlock(
- c.height(now), now, c.address, priv,
+ c.heightOfTime(now), now, c.address, priv,
); ierr != nil {
err = errors.Wrapf(ierr, "failed to produce block at head %s",
c.headBranch.head.hash.Short(4))
@@ -895,15 +900,15 @@ func (c *Chain) startService(chain *Chain) {
// is less or equal to 0, use the clock reading to run the next cycle - this avoids some problem
// caused by concurrent time synchronization.
func (c *Chain) nextTick() (t time.Time, d time.Duration) {
- var nt uint32
- nt, t = func() (nt uint32, t time.Time) {
+ var h uint32
+ h, t = func() (nt uint32, t time.Time) {
c.RLock()
defer c.RUnlock()
- nt = c.nextTurn
+ nt = c.nextHeight
t = time.Now().UTC().Add(c.offset)
return
}()
- d = c.genesisTime.Add(time.Duration(nt) * c.period).Sub(t)
+ d = c.genesisTime.Add(time.Duration(h) * c.period).Sub(t)
if d > c.tick {
d = c.tick
}
@@ -913,14 +918,14 @@ func (c *Chain) nextTick() (t time.Time, d time.Duration) {
func (c *Chain) isMyTurn() bool {
c.RLock()
defer c.RUnlock()
- return c.nextTurn%c.serversNum == c.locSvIndex
+ return c.nextHeight%c.serversNum == c.locSvIndex
}
-// setNextTurn prepares the chain state for the next turn.
-func (c *Chain) setNextTurn() {
+// increaseNextHeight prepares the chain state for the next turn.
+func (c *Chain) increaseNextHeight() {
c.Lock()
defer c.Unlock()
- c.nextTurn++
+ c.nextHeight++
}
func (c *Chain) peerInfo() string {
@@ -932,15 +937,15 @@ func (c *Chain) peerInfo() string {
return fmt.Sprintf("[%d/%d] %s", index, bpNum, nodeID)
}
-// height calculates the height with this sql-chain config of a given time reading.
-func (c *Chain) height(t time.Time) uint32 {
+// heightOfTime calculates the heightOfTime with this sql-chain config of a given time reading.
+func (c *Chain) heightOfTime(t time.Time) uint32 {
return uint32(t.Sub(c.genesisTime) / c.period)
}
-func (c *Chain) getNextTurn() uint32 {
+func (c *Chain) getNextHeight() uint32 {
c.RLock()
defer c.RUnlock()
- return c.nextTurn
+ return c.nextHeight
}
func (c *Chain) getPeers() *proto.Peers {
From 6c8cccf61264cac71c8618c57c0fadf11c622d62 Mon Sep 17 00:00:00 2001
From: ConnorLi <41864925+ConnorLi96@users.noreply.github.com>
Date: Tue, 18 Dec 2018 15:17:27 +0800
Subject: [PATCH 077/278] Create README-zh.md
---
README-zh.md | 118 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 118 insertions(+)
create mode 100644 README-zh.md
diff --git a/README-zh.md b/README-zh.md
new file mode 100644
index 000000000..7ba82ea42
--- /dev/null
+++ b/README-zh.md
@@ -0,0 +1,118 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+CovenantSQL是一个基于区块链技术的去中心化众筹式SQL数据库,并具备以下特点:
+
+- **SQL**:大多支持SQL-92
+- **去中心化**:使用我们的共识算法DH-RPC和Kayak去中心化
+- **隐私**:通过加密和授权许可进行访问
+- **不可篡改**:CovenantSQL中的查询历史记录是不可变但是可跟踪的
+
+我们相信[在下一个互联网时代,每个人都会有完整的**数据权利**](https://medium.com/@covenant_labs/covenantsql-the-sql-database-on-blockchain-db027aaf1e0e)
+
+#### 一行代码接入区块链数据
+```go
+sql.Open("CovenantSQL", dbURI)
+```
+
+##
+
+
+
+- 第一层: **全局共识层**(主链,架构图中的中间环):
+ - 整个网络中只有一个主链。
+ - 主要负责数据库矿工与用户的合同匹配,交易结算,反作弊,子链哈希锁定等全局共识事宜。
+- 第二层: **SQL共识层**(子链,架构图中的两边环):
+ - 每个数据库都有自己独立的子链。
+ - 主要负责数据库各种事务的签名,交付和一致性。这里主要实现永久可追溯性的数据历史,并且在主链中执行哈希锁定。
+- 第三层: **数据储存层**(支持SQL-92的数据库引擎):
+ - 每个数据库都有自己独立的分布式引擎。
+ - 主要负责:数据库存储和加密;查询处理和签名;高效索引。
+
+## 文章
+团队成员发表过的论文
+
+- [迅雷水晶:一种新颖的基于众筹的内容分发平台](https://dl.acm.org/citation.cfm?id=2736085)
+- [基于众筹的视频服务系统性能分析](https://ieeexplore.ieee.org/abstract/document/7114727/)
+- [迅雷水晶性能分析:基于众筹的视频分发平台](https://ieeexplore.ieee.org/abstract/document/7762143/)
+
+这些启发了我们:
+
+- [比特币:P2P电子现金系统](https://bitcoin.org/bitcoin.pdf)
+- [S/Kademlia](https://github.com/thunderdb/research/wiki/Secure-Kademlia)
+ - [S/Kademlia: 一种针对密钥的实用方法](https://ieeexplore.ieee.org/document/4447808/)
+- [vSQL: 验证动态外包数据库上的任意SQL查询](https://ieeexplore.ieee.org/abstract/document/7958614/)
+
+## Libs
+
+### 网络栈
+
+[DH-RPC](rpc/) := TLS - Cert + DHT
+
+| 层 | 应用 |
+|:-------------------|:--------------:|
+| 远程调用协议 | `net/rpc` |
+| 寻址 | [**C**onsistent **S**ecure **DHT**](https://godoc.org/github.com/CovenantSQL/CovenantSQL/consistent) |
+| 会话池 | Session Pool |
+| 多路复用 | [smux](https://github.com/xtaci/smux) |
+| 传输安全 | [**E**nhanced **TLS**](https://github.com/CovenantSQL/research/wiki/ETLS(Enhanced-Transport-Layer-Security)) |
+| 网络 | TCP or KCP for optional later |
+
+
+#### 测试工具
+ - [全球网络拓扑模拟器(GNTE)](https://github.com/CovenantSQL/GNTE) 用于网络模拟
+ - [线性一致性测试](https://github.com/anishathalye/porcupine)
+
+
+#### 接口
+
+CovenantSQL仍在建设中,测试网已经发布,[尝试一下](https://testnet.covenantsql.io/).
+
+
+- [Golang](client/)
+- [Java](https://github.com/CovenantSQL/covenant-connector)
+- [NodeJS](https://github.com/CovenantSQL/node-covenantsql)
+- [Python](https://github.com/CovenantSQL/python-driver)
+- Coding for more……
+
+关注我们或[](https://twitter.com/intent/follow?screen_name=CovenantLabs) 保持更新
+
+## 测试网
+
+- [快捷入口](https://testnet.covenantsql.io/quickstart)
+- [测试网水龙头](https://testnet.covenantsql.io/)
+
+## 联系我们
+
+- [邮箱地址](mailto:webmaster@covenantsql.io)
+-
+
+
+- [](https://gitter.im/CovenantSQL/CovenantSQL?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
From bb90325be5bdc346f9d25574db157de48b1fd744 Mon Sep 17 00:00:00 2001
From: ConnorLi <41864925+ConnorLi96@users.noreply.github.com>
Date: Tue, 18 Dec 2018 15:19:18 +0800
Subject: [PATCH 078/278] Update README.md
add Chinese version link
---
README.md | 1 +
1 file changed, 1 insertion(+)
diff --git a/README.md b/README.md
index 39cd41040..d5f98546c 100644
--- a/README.md
+++ b/README.md
@@ -26,6 +26,7 @@
alt="Join the chat at https://gitter.im/CovenantSQL/CovenantSQL">
+[中文简介](https://github.com/ConnorLi96/CovenantSQL/blob/develop/README-zh.md)
CovenantSQL is a decentralized, crowdsourcing SQL database on blockchain with features:
From 4ceddd5c08666c465383d5bfcfd161f8627ab275 Mon Sep 17 00:00:00 2001
From: auxten
Date: Tue, 18 Dec 2018 16:28:29 +0800
Subject: [PATCH 079/278] Try to set ulimit -n to 8192 for Travis MacOS
---
.travis.yml | 1 +
worker/dbms_rpc.go | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/.travis.yml b/.travis.yml
index 93a905397..9feddb01f 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -28,6 +28,7 @@ before_script:
- echo $TRAVIS_PULL_REQUEST_SHA
- echo $TRAVIS_REPO_SLUG
- echo $TRAVIS_SECURE_ENV_VARS
+ - ulimit -n 8192
script:
- bash build.sh
- go test -v -race -failfast -parallel 16 -cpu 16 $(go list ./... | grep -v "/vendor/") -coverprofile cover.out
diff --git a/worker/dbms_rpc.go b/worker/dbms_rpc.go
index 0bd8a5deb..e01bd8628 100644
--- a/worker/dbms_rpc.go
+++ b/worker/dbms_rpc.go
@@ -24,7 +24,7 @@ import (
"github.com/CovenantSQL/CovenantSQL/rpc"
"github.com/CovenantSQL/CovenantSQL/types"
"github.com/pkg/errors"
- "github.com/rcrowley/go-metrics"
+ metrics "github.com/rcrowley/go-metrics"
)
var (
From 0da1761d99bfa242194cba56120d9743ae676c3a Mon Sep 17 00:00:00 2001
From: ConnorLi <41864925+ConnorLi96@users.noreply.github.com>
Date: Tue, 18 Dec 2018 17:00:07 +0800
Subject: [PATCH 080/278] Update README-zh.md
---
README-zh.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README-zh.md b/README-zh.md
index 7ba82ea42..2bbce633b 100644
--- a/README-zh.md
+++ b/README-zh.md
@@ -34,7 +34,7 @@ CovenantSQL是一个基于区块链技术的去中心化众筹式SQL数据库,
- **隐私**:通过加密和授权许可进行访问
- **不可篡改**:CovenantSQL中的查询历史记录是不可变但是可跟踪的
-我们相信[在下一个互联网时代,每个人都会有完整的**数据权利**](https://medium.com/@covenant_labs/covenantsql-the-sql-database-on-blockchain-db027aaf1e0e)
+我们相信[在下一个互联网时代,每个人都应该有完整的**数据权利**](https://medium.com/@covenant_labs/covenantsql-the-sql-database-on-blockchain-db027aaf1e0e)
#### 一行代码接入区块链数据
```go
From 52589d02655317045016fa6592c4ca62028ea95d Mon Sep 17 00:00:00 2001
From: auxten
Date: Tue, 18 Dec 2018 17:36:49 +0800
Subject: [PATCH 081/278] Fix readme-zh link
---
README-zh.md | 14 +++++++-------
README.md | 2 +-
2 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/README-zh.md b/README-zh.md
index 2bbce633b..9705570f6 100644
--- a/README-zh.md
+++ b/README-zh.md
@@ -27,12 +27,12 @@
-CovenantSQL是一个基于区块链技术的去中心化众筹式SQL数据库,并具备以下特点:
+CovenantSQL 是一个基于区块链技术的去中心化众筹式 SQL 数据库,并具备以下特点:
-- **SQL**:大多支持SQL-92
-- **去中心化**:使用我们的共识算法DH-RPC和Kayak去中心化
-- **隐私**:通过加密和授权许可进行访问
-- **不可篡改**:CovenantSQL中的查询历史记录是不可变但是可跟踪的
+- **SQL**: 支持 SQL-92 标准
+- **去中心化**: 使用我们的共识算法 DH-RPC 和 Kayak 去中心化
+- **隐私**: 通过加密和授权许可进行访问
+- **不可篡改**: CovenantSQL 中的查询历史记录是不可变且可跟踪的
我们相信[在下一个互联网时代,每个人都应该有完整的**数据权利**](https://medium.com/@covenant_labs/covenantsql-the-sql-database-on-blockchain-db027aaf1e0e)
@@ -48,10 +48,10 @@ sql.Open("CovenantSQL", dbURI)
- 第一层: **全局共识层**(主链,架构图中的中间环):
- 整个网络中只有一个主链。
- 主要负责数据库矿工与用户的合同匹配,交易结算,反作弊,子链哈希锁定等全局共识事宜。
-- 第二层: **SQL共识层**(子链,架构图中的两边环):
+- 第二层: **SQL 共识层**(子链,架构图中的两边环):
- 每个数据库都有自己独立的子链。
- 主要负责数据库各种事务的签名,交付和一致性。这里主要实现永久可追溯性的数据历史,并且在主链中执行哈希锁定。
-- 第三层: **数据储存层**(支持SQL-92的数据库引擎):
+- 第三层: **数据储存层**(支持 SQL-92 的数据库引擎):
- 每个数据库都有自己独立的分布式引擎。
- 主要负责:数据库存储和加密;查询处理和签名;高效索引。
diff --git a/README.md b/README.md
index 70eac80c5..a47354134 100644
--- a/README.md
+++ b/README.md
@@ -26,7 +26,7 @@
alt="Join the chat at https://gitter.im/CovenantSQL/CovenantSQL">
-[中文简介](https://github.com/ConnorLi96/CovenantSQL/blob/develop/README-zh.md)
+[中文简介](https://github.com/CovenantSQL/CovenantSQL/blob/develop/README-zh.md)
CovenantSQL is a decentralized, crowdsourcing SQL database on blockchain with features:
From 6fcb7a2f2daf48ce5940046d9f4eb8814c2b58eb Mon Sep 17 00:00:00 2001
From: auxten
Date: Tue, 18 Dec 2018 17:39:30 +0800
Subject: [PATCH 082/278] Fix some translation
---
README-zh.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README-zh.md b/README-zh.md
index 9705570f6..db5c06f7f 100644
--- a/README-zh.md
+++ b/README-zh.md
@@ -30,7 +30,7 @@
CovenantSQL 是一个基于区块链技术的去中心化众筹式 SQL 数据库,并具备以下特点:
- **SQL**: 支持 SQL-92 标准
-- **去中心化**: 使用我们的共识算法 DH-RPC 和 Kayak 去中心化
+- **去中心化**: 基于独有的高效共识算法 DH-RPC 和 Kayak 实现的中心化
- **隐私**: 通过加密和授权许可进行访问
- **不可篡改**: CovenantSQL 中的查询历史记录是不可变且可跟踪的
From d9a472e8de79eed26086e339530139a956946eaa Mon Sep 17 00:00:00 2001
From: leventeliu
Date: Tue, 18 Dec 2018 19:29:47 +0800
Subject: [PATCH 083/278] Remove unused codes
---
blockproducer/chain_test.go | 4 +
blockproducer/metaindex.go | 222 ------------------
blockproducer/metaindex_test.go | 158 -------------
blockproducer/metastate.go | 379 +-----------------------------
blockproducer/metastate_test.go | 402 +++-----------------------------
blockproducer/xxx_test.go | 2 +-
6 files changed, 40 insertions(+), 1127 deletions(-)
diff --git a/blockproducer/chain_test.go b/blockproducer/chain_test.go
index 353ebe2d5..e8f89f275 100644
--- a/blockproducer/chain_test.go
+++ b/blockproducer/chain_test.go
@@ -322,6 +322,10 @@ func TestChain(t *testing.T) {
chain.Stop()
chain = nil
}()
+ chain.addTx(t1)
+ chain.addTx(t2)
+ chain.addTx(t3)
+ chain.addTx(t4)
time.Sleep(15 * chain.period)
})
})
diff --git a/blockproducer/metaindex.go b/blockproducer/metaindex.go
index 7d7796cc6..170994ffe 100644
--- a/blockproducer/metaindex.go
+++ b/blockproducer/metaindex.go
@@ -17,13 +17,10 @@
package blockproducer
import (
- "bytes"
"sync"
"github.com/CovenantSQL/CovenantSQL/proto"
"github.com/CovenantSQL/CovenantSQL/types"
- "github.com/CovenantSQL/CovenantSQL/utils"
- "github.com/coreos/bbolt"
"github.com/ulule/deepcopier"
)
@@ -46,17 +43,14 @@ func safeSub(x, y *uint64) (err error) {
}
type accountObject struct {
- sync.RWMutex
types.Account
}
type sqlchainObject struct {
- sync.RWMutex
types.SQLChainProfile
}
type providerObject struct {
- sync.RWMutex
types.ProviderProfile
}
@@ -75,42 +69,6 @@ func newMetaIndex() *metaIndex {
}
}
-func (i *metaIndex) storeAccountObject(o *accountObject) {
- i.Lock()
- defer i.Unlock()
- i.accounts[o.Address] = o
-}
-
-func (i *metaIndex) deleteAccountObject(k proto.AccountAddress) {
- i.Lock()
- defer i.Unlock()
- delete(i.accounts, k)
-}
-
-func (i *metaIndex) storeSQLChainObject(o *sqlchainObject) {
- i.Lock()
- defer i.Unlock()
- i.databases[o.ID] = o
-}
-
-func (i *metaIndex) deleteSQLChainObject(k proto.DatabaseID) {
- i.Lock()
- defer i.Unlock()
- delete(i.databases, k)
-}
-
-func (i *metaIndex) storeProviderObject(o *providerObject) {
- i.Lock()
- defer i.Unlock()
- i.provider[o.Provider] = o
-}
-
-func (i *metaIndex) deleteProviderObject(k proto.AccountAddress) {
- i.Lock()
- defer i.Unlock()
- delete(i.provider, k)
-}
-
func (i *metaIndex) deepCopy() (cpy *metaIndex) {
cpy = newMetaIndex()
for k, v := range i.accounts {
@@ -130,183 +88,3 @@ func (i *metaIndex) deepCopy() (cpy *metaIndex) {
}
return
}
-
-// IncreaseAccountStableBalance increases account stable coin balance and write persistence within
-// a boltdb transaction.
-func (i *metaIndex) IncreaseAccountStableBalance(
- addr proto.AccountAddress, amount uint64) (_ func(*bolt.Tx) error,
-) {
- return func(tx *bolt.Tx) (err error) {
- var (
- ao *accountObject
- ok bool
- bk = tx.Bucket(metaBucket[:]).Bucket(metaAccountIndexBucket)
- enc *bytes.Buffer
- )
-
- i.Lock()
- defer i.Unlock()
- if ao, ok = i.accounts[addr]; !ok {
- err = ErrAccountNotFound
- return
- }
- if err = safeAdd(&ao.TokenBalance[types.Particle], &amount); err != nil {
- return
- }
- ao.NextNonce++
-
- if enc, err = utils.EncodeMsgPack(&ao.Account); err != nil {
- return
- }
- if err = bk.Put(ao.Address[:], enc.Bytes()); err != nil {
- return
- }
-
- return
- }
-}
-
-// DecreaseAccountStableBalance decreases account stable coin balance and write persistence within
-// a boltdb transaction.
-func (i *metaIndex) DecreaseAccountStableBalance(
- addr proto.AccountAddress, amount uint64) (_ func(*bolt.Tx) error,
-) {
- return func(tx *bolt.Tx) (err error) {
- var (
- ao *accountObject
- ok bool
- bk = tx.Bucket(metaBucket[:]).Bucket(metaAccountIndexBucket)
- enc *bytes.Buffer
- )
-
- i.Lock()
- defer i.Unlock()
- if ao, ok = i.accounts[addr]; !ok {
- err = ErrAccountNotFound
- return
- }
- if err = safeSub(&ao.TokenBalance[types.Particle], &amount); err != nil {
- return
- }
- ao.NextNonce++
-
- if enc, err = utils.EncodeMsgPack(&ao.Account); err != nil {
- return
- }
- if err = bk.Put(ao.Address[:], enc.Bytes()); err != nil {
- return
- }
-
- return
- }
-}
-
-// IncreaseAccountCovenantBalance increases account covenant coin balance and write persistence
-// within a boltdb transaction.
-func (i *metaIndex) IncreaseAccountCovenantBalance(
- addr proto.AccountAddress, amount uint64) (_ func(*bolt.Tx) error,
-) {
- return func(tx *bolt.Tx) (err error) {
- var (
- ao *accountObject
- ok bool
- bk = tx.Bucket(metaBucket[:]).Bucket(metaAccountIndexBucket)
- enc *bytes.Buffer
- )
-
- i.Lock()
- defer i.Unlock()
- if ao, ok = i.accounts[addr]; !ok {
- err = ErrAccountNotFound
- return
- }
- if err = safeAdd(&ao.TokenBalance[types.Wave], &amount); err != nil {
- return
- }
- ao.NextNonce++
-
- if enc, err = utils.EncodeMsgPack(&ao.Account); err != nil {
- return
- }
- if err = bk.Put(ao.Address[:], enc.Bytes()); err != nil {
- return
- }
-
- return
- }
-}
-
-// DecreaseAccountCovenantBalance decreases account covenant coin balance and write persistence
-// within a boltdb transaction.
-func (i *metaIndex) DecreaseAccountCovenantBalance(
- addr proto.AccountAddress, amount uint64) (_ func(*bolt.Tx) error,
-) {
- return func(tx *bolt.Tx) (err error) {
- var (
- ao *accountObject
- ok bool
- bk = tx.Bucket(metaBucket[:]).Bucket(metaAccountIndexBucket)
- enc *bytes.Buffer
- )
-
- i.Lock()
- defer i.Unlock()
- if ao, ok = i.accounts[addr]; !ok {
- err = ErrAccountNotFound
- return
- }
- if err = safeSub(&ao.TokenBalance[types.Wave], &amount); err != nil {
- return
- }
- ao.NextNonce++
-
- if enc, err = utils.EncodeMsgPack(&ao.Account); err != nil {
- return
- }
- if err = bk.Put(ao.Address[:], enc.Bytes()); err != nil {
- return
- }
-
- return
- }
-}
-
-func (i *metaIndex) CreateSQLChain(
- addr proto.AccountAddress, id proto.DatabaseID) (_ func(*bolt.Tx) error,
-) {
- return func(tx *bolt.Tx) (err error) {
- var (
- ao *accountObject
- co *sqlchainObject
- ok bool
- bk = tx.Bucket(metaBucket[:]).Bucket(metaSQLChainIndexBucket)
- enc *bytes.Buffer
- )
-
- i.Lock()
- defer i.Unlock()
- // Make sure that the target account exists
- if ao, ok = i.accounts[addr]; !ok {
- err = ErrAccountNotFound
- return
- }
- // Create new sqlchainProfile
- co = &sqlchainObject{
- SQLChainProfile: types.SQLChainProfile{
- ID: id,
- Owner: addr,
- },
- }
- i.databases[id] = co
- ao.NextNonce++
-
- if enc, err = utils.EncodeMsgPack(co); err != nil {
- return
- }
- if err = bk.Put([]byte(id), enc.Bytes()); err != nil {
- return
- }
-
- return
- }
-}
diff --git a/blockproducer/metaindex_test.go b/blockproducer/metaindex_test.go
index 0fbed8a3f..2423efab2 100644
--- a/blockproducer/metaindex_test.go
+++ b/blockproducer/metaindex_test.go
@@ -15,161 +15,3 @@
*/
package blockproducer
-
-import (
- "os"
- "path"
- "testing"
-
- pi "github.com/CovenantSQL/CovenantSQL/blockproducer/interfaces"
- "github.com/CovenantSQL/CovenantSQL/proto"
- "github.com/CovenantSQL/CovenantSQL/types"
- "github.com/coreos/bbolt"
- . "github.com/smartystreets/goconvey/convey"
-)
-
-func TestMetaIndex(t *testing.T) {
- Convey("Given a new metaIndex object and persistence db instance", t, func() {
- var (
- ao *accountObject
- co *sqlchainObject
- loaded bool
- addr1 = proto.AccountAddress{0x0, 0x0, 0x0, 0x1}
- addr2 = proto.AccountAddress{0x0, 0x0, 0x0, 0x2}
- dbid1 = proto.DatabaseID("db#1")
- dbid2 = proto.DatabaseID("db#2")
- mi = newMetaIndex()
- fl = path.Join(testingDataDir, t.Name())
- db, err = bolt.Open(fl, 0600, nil)
- )
- So(err, ShouldBeNil)
- Reset(func() {
- // Clean database file after each pass
- err = db.Close()
- So(err, ShouldBeNil)
- err = os.Truncate(fl, 0)
- So(err, ShouldBeNil)
- })
- err = db.Update(func(tx *bolt.Tx) (err error) {
- var meta, txbk *bolt.Bucket
- if meta, err = tx.CreateBucket(metaBucket[:]); err != nil {
- return
- }
- if _, err = meta.CreateBucket(metaAccountIndexBucket); err != nil {
- return
- }
- if _, err = meta.CreateBucket(metaSQLChainIndexBucket); err != nil {
- return
- }
- if _, err = meta.CreateBucket(metaProviderIndexBucket); err != nil {
- return
- }
- if txbk, err = meta.CreateBucket(metaTransactionBucket); err != nil {
- return
- }
- for i := pi.TransactionType(0); i < pi.TransactionTypeNumber; i++ {
- if _, err = txbk.CreateBucket(i.Bytes()); err != nil {
- return
- }
- }
- return
- })
- So(err, ShouldBeNil)
- Convey("The metaIndex should be empty", func() {
- err = db.Update(mi.IncreaseAccountStableBalance(addr1, 1))
- So(err, ShouldEqual, ErrAccountNotFound)
- err = db.Update(mi.DecreaseAccountStableBalance(addr1, 1))
- So(err, ShouldEqual, ErrAccountNotFound)
- err = db.Update(mi.IncreaseAccountCovenantBalance(addr1, 1))
- So(err, ShouldEqual, ErrAccountNotFound)
- err = db.Update(mi.DecreaseAccountCovenantBalance(addr1, 1))
- So(err, ShouldEqual, ErrAccountNotFound)
- err = db.Update(mi.CreateSQLChain(addr1, dbid1))
- So(err, ShouldEqual, ErrAccountNotFound)
- })
- Convey("When database objects are stored", func() {
- mi.storeSQLChainObject(&sqlchainObject{
- SQLChainProfile: types.SQLChainProfile{
- ID: dbid1,
- },
- })
- mi.storeSQLChainObject(&sqlchainObject{
- SQLChainProfile: types.SQLChainProfile{
- ID: dbid2,
- },
- })
- Convey("The database objects should be retrievable", func() {
- co, loaded = mi.databases[dbid1]
- So(loaded, ShouldBeTrue)
- So(co, ShouldNotBeNil)
- So(co.ID, ShouldEqual, dbid1)
- co, loaded = mi.databases[dbid2]
- So(loaded, ShouldBeTrue)
- So(co, ShouldNotBeNil)
- So(co.ID, ShouldEqual, dbid2)
- })
- Convey("When database objects are deleted", func() {
- mi.deleteSQLChainObject(dbid1)
- mi.deleteSQLChainObject(dbid2)
- Convey("The acount objects should not be retrievable anymore", func() {
- co, loaded = mi.databases[dbid1]
- So(loaded, ShouldBeFalse)
- So(co, ShouldBeNil)
- co, loaded = mi.databases[dbid2]
- So(loaded, ShouldBeFalse)
- So(co, ShouldBeNil)
- })
- })
- })
- Convey("When account objects are stored", func() {
- mi.storeAccountObject(&accountObject{
- Account: types.Account{
- Address: addr1,
- TokenBalance: [types.SupportTokenNumber]uint64{10, 10},
- },
- })
- mi.storeAccountObject(&accountObject{
- Account: types.Account{
- Address: addr2,
- TokenBalance: [types.SupportTokenNumber]uint64{10, 10},
- },
- })
- Convey("The account objects should be retrievable", func() {
- ao, loaded = mi.accounts[addr1]
- So(loaded, ShouldBeTrue)
- So(ao, ShouldNotBeNil)
- So(ao.Address, ShouldEqual, addr1)
- ao, loaded = mi.accounts[addr2]
- So(loaded, ShouldBeTrue)
- So(ao, ShouldNotBeNil)
- So(ao.Address, ShouldEqual, addr2)
- })
- Convey("When account objects are deleted", func() {
- mi.deleteAccountObject(addr1)
- mi.deleteAccountObject(addr2)
- Convey("The acount objects should not be retrievable anymore", func() {
- ao, loaded = mi.accounts[addr1]
- So(loaded, ShouldBeFalse)
- So(ao, ShouldBeNil)
- ao, loaded = mi.accounts[addr2]
- So(loaded, ShouldBeFalse)
- So(ao, ShouldBeNil)
- })
- })
- Convey("The account objects should keep track of the their own balances", func() {
- err = db.Update(mi.IncreaseAccountStableBalance(addr1, 1))
- So(err, ShouldBeNil)
- err = db.Update(mi.DecreaseAccountStableBalance(addr1, 1))
- So(err, ShouldBeNil)
- err = db.Update(mi.IncreaseAccountCovenantBalance(addr1, 1))
- So(err, ShouldBeNil)
- err = db.Update(mi.DecreaseAccountCovenantBalance(addr1, 1))
- So(err, ShouldBeNil)
- })
- Convey("The metaIndex should be ok to add SQLChain objects", func() {
- err = db.Update(mi.CreateSQLChain(addr1, dbid1))
- So(err, ShouldBeNil)
- })
- })
- })
-}
diff --git a/blockproducer/metastate.go b/blockproducer/metastate.go
index 71f1489ae..f87811545 100644
--- a/blockproducer/metastate.go
+++ b/blockproducer/metastate.go
@@ -17,8 +17,6 @@
package blockproducer
import (
- "bytes"
- "sync"
"time"
pi "github.com/CovenantSQL/CovenantSQL/blockproducer/interfaces"
@@ -28,9 +26,7 @@ import (
"github.com/CovenantSQL/CovenantSQL/crypto/kms"
"github.com/CovenantSQL/CovenantSQL/proto"
pt "github.com/CovenantSQL/CovenantSQL/types"
- "github.com/CovenantSQL/CovenantSQL/utils"
"github.com/CovenantSQL/CovenantSQL/utils/log"
- "github.com/coreos/bbolt"
"github.com/pkg/errors"
"github.com/ulule/deepcopier"
)
@@ -43,22 +39,17 @@ var (
// TODO(leventeliu): lock optimization.
type metaState struct {
- sync.RWMutex
dirty, readonly *metaIndex
- pool *txPool
}
func newMetaState() *metaState {
return &metaState{
dirty: newMetaIndex(),
readonly: newMetaIndex(),
- pool: newTxPool(),
}
}
func (s *metaState) loadAccountObject(k proto.AccountAddress) (o *accountObject, loaded bool) {
- s.RLock()
- defer s.RUnlock()
if o, loaded = s.dirty.accounts[k]; loaded {
if o == nil {
loaded = false
@@ -74,8 +65,6 @@ func (s *metaState) loadAccountObject(k proto.AccountAddress) (o *accountObject,
func (s *metaState) loadOrStoreAccountObject(
k proto.AccountAddress, v *accountObject) (o *accountObject, loaded bool,
) {
- s.Lock()
- defer s.Unlock()
if o, loaded = s.dirty.accounts[k]; loaded && o != nil {
return
}
@@ -96,9 +85,6 @@ func (s *metaState) loadAccountStableBalance(addr proto.AccountAddress) (b uint6
}).Debug("queried stable account")
}()
- s.Lock()
- defer s.Unlock()
-
if o, loaded = s.dirty.accounts[addr]; loaded && o != nil {
b = o.TokenBalance[pt.Particle]
return
@@ -120,9 +106,6 @@ func (s *metaState) loadAccountCovenantBalance(addr proto.AccountAddress) (b uin
}).Debug("queried covenant account")
}()
- s.Lock()
- defer s.Unlock()
-
if o, loaded = s.dirty.accounts[addr]; loaded && o != nil {
b = o.TokenBalance[pt.Wave]
return
@@ -142,8 +125,6 @@ func (s *metaState) storeBaseAccount(k proto.AccountAddress, v *accountObject) (
// Since a transfer tx may create an empty receiver account, this method should try to cover
// the side effect.
if ao, ok := s.loadOrStoreAccountObject(k, v); ok {
- ao.Lock()
- defer ao.Unlock()
if ao.Account.NextNonce != 0 {
err = ErrAccountExists
return
@@ -165,8 +146,6 @@ func (s *metaState) storeBaseAccount(k proto.AccountAddress, v *accountObject) (
}
func (s *metaState) loadSQLChainObject(k proto.DatabaseID) (o *sqlchainObject, loaded bool) {
- s.RLock()
- defer s.RUnlock()
if o, loaded = s.dirty.databases[k]; loaded {
if o == nil {
loaded = false
@@ -182,8 +161,6 @@ func (s *metaState) loadSQLChainObject(k proto.DatabaseID) (o *sqlchainObject, l
func (s *metaState) loadOrStoreSQLChainObject(
k proto.DatabaseID, v *sqlchainObject) (o *sqlchainObject, loaded bool,
) {
- s.Lock()
- defer s.Unlock()
if o, loaded = s.dirty.databases[k]; loaded && o != nil {
return
}
@@ -195,8 +172,6 @@ func (s *metaState) loadOrStoreSQLChainObject(
}
func (s *metaState) loadProviderObject(k proto.AccountAddress) (o *providerObject, loaded bool) {
- s.RLock()
- defer s.RUnlock()
if o, loaded = s.dirty.provider[k]; loaded {
if o == nil {
loaded = false
@@ -210,8 +185,6 @@ func (s *metaState) loadProviderObject(k proto.AccountAddress) (o *providerObjec
}
func (s *metaState) loadOrStoreProviderObject(k proto.AccountAddress, v *providerObject) (o *providerObject, loaded bool) {
- s.Lock()
- defer s.Unlock()
if o, loaded = s.dirty.provider[k]; loaded && o != nil {
return
}
@@ -223,29 +196,21 @@ func (s *metaState) loadOrStoreProviderObject(k proto.AccountAddress, v *provide
}
func (s *metaState) deleteAccountObject(k proto.AccountAddress) {
- s.Lock()
- defer s.Unlock()
// Use a nil pointer to mark a deletion, which will be later used by commit procedure.
s.dirty.accounts[k] = nil
}
func (s *metaState) deleteSQLChainObject(k proto.DatabaseID) {
- s.Lock()
- defer s.Unlock()
// Use a nil pointer to mark a deletion, which will be later used by commit procedure.
s.dirty.databases[k] = nil
}
func (s *metaState) deleteProviderObject(k proto.AccountAddress) {
- s.Lock()
- defer s.Unlock()
// Use a nil pointer to mark a deletion, which will be later used by commit procedure.
s.dirty.provider[k] = nil
}
func (s *metaState) commit() {
- s.Lock()
- defer s.Unlock()
for k, v := range s.dirty.accounts {
if v != nil {
// New/update object
@@ -273,245 +238,16 @@ func (s *metaState) commit() {
delete(s.readonly.provider, k)
}
}
- // Clean dirty map and tx pool
+ // Clean dirty map
s.dirty = newMetaIndex()
- s.pool = newTxPool()
return
}
-func (s *metaState) commitProcedure() (_ func(*bolt.Tx) error) {
- return func(tx *bolt.Tx) (err error) {
- var (
- enc *bytes.Buffer
- ab = tx.Bucket(metaBucket[:]).Bucket(metaAccountIndexBucket)
- cb = tx.Bucket(metaBucket[:]).Bucket(metaSQLChainIndexBucket)
- pb = tx.Bucket(metaBucket[:]).Bucket(metaProviderIndexBucket)
- )
- s.Lock()
- defer s.Unlock()
- for k, v := range s.dirty.accounts {
- if v != nil {
- // New/update object
- s.readonly.accounts[k] = v
- if enc, err = utils.EncodeMsgPack(v.Account); err != nil {
- return
- }
- if err = ab.Put(k[:], enc.Bytes()); err != nil {
- return
- }
- } else {
- // Delete object
- delete(s.readonly.accounts, k)
- if err = ab.Delete(k[:]); err != nil {
- return
- }
- }
- }
- for k, v := range s.dirty.databases {
- if v != nil {
- // New/update object
- s.readonly.databases[k] = v
- if enc, err = utils.EncodeMsgPack(v.SQLChainProfile); err != nil {
- return
- }
- if err = cb.Put([]byte(k), enc.Bytes()); err != nil {
- return
- }
- } else {
- // Delete object
- delete(s.readonly.databases, k)
- if err = cb.Delete([]byte(k)); err != nil {
- return
- }
- }
- }
- for k, v := range s.dirty.provider {
- if v != nil {
- // New/update object
- s.readonly.provider[k] = v
- if enc, err = utils.EncodeMsgPack(v.ProviderProfile); err != nil {
- return
- }
- if err = pb.Put(k[:], enc.Bytes()); err != nil {
- return
- }
- } else {
- // Delete object
- delete(s.readonly.provider, k)
- if err = pb.Delete(k[:]); err != nil {
- return
- }
- }
- }
- // Clean dirty map and tx pool
- s.dirty = newMetaIndex()
- s.pool = newTxPool()
- return
- }
-}
-
-// partialCommitProcedure compares txs with pooled items, replays and commits the state due to txs
-// if txs matches part of or all the pooled items. Not committed txs will be left in the pool.
-func (s *metaState) partialCommitProcedure(txs []pi.Transaction) (_ func(*bolt.Tx) error) {
- return func(tx *bolt.Tx) (err error) {
- var (
- enc *bytes.Buffer
- ab = tx.Bucket(metaBucket[:]).Bucket(metaAccountIndexBucket)
- cb = tx.Bucket(metaBucket[:]).Bucket(metaSQLChainIndexBucket)
- pb = tx.Bucket(metaBucket[:]).Bucket(metaProviderIndexBucket)
- )
- s.Lock()
- defer s.Unlock()
-
- // Make a half-deep copy of pool (txs are not copied, readonly) and deep copy of readonly
- // state
- var (
- cp = s.pool.halfDeepCopy()
- cm = &metaState{
- dirty: newMetaIndex(),
- readonly: s.readonly.deepCopy(),
- }
- )
- // Compare and replay commits, stop whenever a tx has mismatched
- for _, v := range txs {
- if !cp.cmpAndMoveNextTx(v) {
- err = ErrTransactionMismatch
- return
- }
- if err = cm.applyTransaction(v); err != nil {
- return
- }
- }
-
- for k, v := range cm.dirty.accounts {
- if v != nil {
- // New/update object
- cm.readonly.accounts[k] = v
- if enc, err = utils.EncodeMsgPack(v.Account); err != nil {
- return
- }
- if err = ab.Put(k[:], enc.Bytes()); err != nil {
- return
- }
- } else {
- // Delete object
- delete(cm.readonly.accounts, k)
- if err = ab.Delete(k[:]); err != nil {
- return
- }
- }
- }
- for k, v := range cm.dirty.databases {
- if v != nil {
- // New/update object
- cm.readonly.databases[k] = v
- if enc, err = utils.EncodeMsgPack(v.SQLChainProfile); err != nil {
- return
- }
- if err = cb.Put([]byte(k), enc.Bytes()); err != nil {
- return
- }
- } else {
- // Delete object
- delete(cm.readonly.databases, k)
- if err = cb.Delete([]byte(k)); err != nil {
- return
- }
- }
- }
- for k, v := range cm.dirty.provider {
- if v != nil {
- // New/update object
- cm.readonly.provider[k] = v
- if enc, err = utils.EncodeMsgPack(v.Provider); err != nil {
- return
- }
- if err = pb.Put(k[:], enc.Bytes()); err != nil {
- return
- }
- } else {
- // Delete object
- delete(cm.readonly.provider, k)
- if err = pb.Delete(k[:]); err != nil {
- return
- }
- }
- }
-
- // Rebuild dirty map
- cm.dirty = newMetaIndex()
- for _, v := range cp.entries {
- for _, tx := range v.transactions {
- if err = cm.applyTransaction(tx); err != nil {
- return
- }
- }
- }
-
- // Clean dirty map and tx pool
- s.pool = cp
- s.readonly = cm.readonly
- s.dirty = cm.dirty
- return
- }
-}
-
-func (s *metaState) reloadProcedure() (_ func(*bolt.Tx) error) {
- return func(tx *bolt.Tx) (err error) {
- s.Lock()
- defer s.Unlock()
- // Clean state
- s.dirty = newMetaIndex()
- s.readonly = newMetaIndex()
- // Reload state
- var (
- ab = tx.Bucket(metaBucket[:]).Bucket(metaAccountIndexBucket)
- cb = tx.Bucket(metaBucket[:]).Bucket(metaSQLChainIndexBucket)
- pb = tx.Bucket(metaBucket[:]).Bucket(metaProviderIndexBucket)
- )
- if err = ab.ForEach(func(k, v []byte) (err error) {
- ao := &accountObject{}
- if err = utils.DecodeMsgPack(v, &ao.Account); err != nil {
- return
- }
- s.readonly.accounts[ao.Account.Address] = ao
- return
- }); err != nil {
- return
- }
- if err = cb.ForEach(func(k, v []byte) (err error) {
- co := &sqlchainObject{}
- if err = utils.DecodeMsgPack(v, &co.SQLChainProfile); err != nil {
- return
- }
- s.readonly.databases[co.SQLChainProfile.ID] = co
- return
- }); err != nil {
- return
- }
- if err = pb.ForEach(func(k, v []byte) (err error) {
- ao := &providerObject{}
- if err = utils.DecodeMsgPack(v, &ao.Provider); err != nil {
- return
- }
- s.readonly.provider[ao.ProviderProfile.Provider] = ao
- return
- }); err != nil {
- return
- }
- return
- }
-}
-
func (s *metaState) clean() {
- s.Lock()
- defer s.Unlock()
s.dirty = newMetaIndex()
}
func (s *metaState) increaseAccountStableBalance(k proto.AccountAddress, amount uint64) error {
- s.Lock()
- defer s.Unlock()
var (
src, dst *accountObject
ok bool
@@ -529,8 +265,6 @@ func (s *metaState) increaseAccountStableBalance(k proto.AccountAddress, amount
}
func (s *metaState) decreaseAccountStableBalance(k proto.AccountAddress, amount uint64) error {
- s.Lock()
- defer s.Unlock()
var (
src, dst *accountObject
ok bool
@@ -556,8 +290,6 @@ func (s *metaState) transferAccountStableBalance(
// Create empty receiver account if not found
s.loadOrStoreAccountObject(receiver, &accountObject{Account: pt.Account{Address: receiver}})
- s.Lock()
- defer s.Unlock()
var (
so, ro *accountObject
sd, rd, ok bool
@@ -608,8 +340,6 @@ func (s *metaState) transferAccountStableBalance(
}
func (s *metaState) increaseAccountCovenantBalance(k proto.AccountAddress, amount uint64) error {
- s.Lock()
- defer s.Unlock()
var (
src, dst *accountObject
ok bool
@@ -627,8 +357,6 @@ func (s *metaState) increaseAccountCovenantBalance(k proto.AccountAddress, amoun
}
func (s *metaState) decreaseAccountCovenantBalance(k proto.AccountAddress, amount uint64) error {
- s.Lock()
- defer s.Unlock()
var (
src, dst *accountObject
ok bool
@@ -645,8 +373,6 @@ func (s *metaState) decreaseAccountCovenantBalance(k proto.AccountAddress, amoun
}
func (s *metaState) createSQLChain(addr proto.AccountAddress, id proto.DatabaseID) error {
- s.Lock()
- defer s.Unlock()
if _, ok := s.dirty.accounts[addr]; !ok {
if _, ok := s.readonly.accounts[addr]; !ok {
return ErrAccountNotFound
@@ -676,8 +402,6 @@ func (s *metaState) createSQLChain(addr proto.AccountAddress, id proto.DatabaseI
func (s *metaState) addSQLChainUser(
k proto.DatabaseID, addr proto.AccountAddress, perm pt.UserPermission) (_ error,
) {
- s.Lock()
- defer s.Unlock()
var (
src, dst *sqlchainObject
ok bool
@@ -703,8 +427,6 @@ func (s *metaState) addSQLChainUser(
}
func (s *metaState) deleteSQLChainUser(k proto.DatabaseID, addr proto.AccountAddress) error {
- s.Lock()
- defer s.Unlock()
var (
src, dst *sqlchainObject
ok bool
@@ -731,8 +453,6 @@ func (s *metaState) deleteSQLChainUser(k proto.DatabaseID, addr proto.AccountAdd
func (s *metaState) alterSQLChainUser(
k proto.DatabaseID, addr proto.AccountAddress, perm pt.UserPermission) (_ error,
) {
- s.Lock()
- defer s.Unlock()
var (
src, dst *sqlchainObject
ok bool
@@ -754,12 +474,6 @@ func (s *metaState) alterSQLChainUser(
}
func (s *metaState) nextNonce(addr proto.AccountAddress) (nonce pi.AccountNonce, err error) {
- s.Lock()
- defer s.Unlock()
- if e, ok := s.pool.getTxEntries(addr); ok {
- nonce = e.nextNonce()
- return
- }
var (
o *accountObject
loaded bool
@@ -778,8 +492,6 @@ func (s *metaState) nextNonce(addr proto.AccountAddress) (nonce pi.AccountNonce,
}
func (s *metaState) increaseNonce(addr proto.AccountAddress) (err error) {
- s.Lock()
- defer s.Unlock()
var (
src, dst *accountObject
ok bool
@@ -1054,94 +766,6 @@ func (s *metaState) applyTransaction(tx pi.Transaction) (err error) {
return
}
-// applyTransaction tries to apply t to the metaState and push t to the memory pool if and
-// only if it can be applied correctly.
-func (s *metaState) applyTransactionProcedure(t pi.Transaction) (_ func(*bolt.Tx) error) {
- var (
- err error
- errPass = func(*bolt.Tx) error {
- return err
- }
- )
-
- log.WithField("tx", t).Debug("try applying transaction")
-
- // Static checks, which have no relation with metaState
- if err = t.Verify(); err != nil {
- return errPass
- }
-
- var (
- enc *bytes.Buffer
- hash = t.Hash()
- addr = t.GetAccountAddress()
- nonce = t.GetAccountNonce()
- ttype = t.GetTransactionType()
- )
- if enc, err = utils.EncodeMsgPack(t); err != nil {
- log.WithField("tx", t).WithError(err).Debug("encode failed on applying transaction")
- return errPass
- }
-
- // metaState-related checks will be performed within bolt.Tx to guarantee consistency
- return func(tx *bolt.Tx) (err error) {
- log.WithField("tx", t).Debug("processing transaction")
-
- // Check tx existense
- // TODO(leventeliu): maybe move outside?
- if s.pool.hasTx(t) {
- log.Debug("transaction already in pool, apply failed")
- return
- }
- // Check account nonce
- var nextNonce pi.AccountNonce
- if nextNonce, err = s.nextNonce(addr); err != nil {
- if t.GetTransactionType() != pi.TransactionTypeBaseAccount {
- return
- }
- // Consider the first nonce 0
- err = nil
- }
- if nextNonce != nonce {
- err = ErrInvalidAccountNonce
- log.WithFields(log.Fields{
- "actual": nonce,
- "expected": nextNonce,
- }).WithError(err).Debug("nonce not match during transaction apply")
- return
- }
- // Try to put transaction before any state change, will be rolled back later
- // if transaction doesn't apply
- tb := tx.Bucket(metaBucket[:]).Bucket(metaTransactionBucket).Bucket(ttype.Bytes())
- if err = tb.Put(hash[:], enc.Bytes()); err != nil {
- log.WithError(err).Debug("store transaction to bucket failed")
- return
- }
- // Try to apply transaction to metaState
- if err = s.applyTransaction(t); err != nil {
- log.WithError(err).Debug("apply transaction failed")
- return
- }
- if err = s.increaseNonce(addr); err != nil {
- // FIXME(leventeliu): should not fail here.
- return
- }
- // Push to pool
- s.pool.addTx(t, nextNonce)
- return
- }
-}
-
-func (s *metaState) pullTxs() (txs []pi.Transaction) {
- s.Lock()
- defer s.Unlock()
- for _, v := range s.pool.entries {
- // TODO(leventeliu): check race condition.
- txs = append(txs, v.transactions...)
- }
- return
-}
-
func (s *metaState) generateGenesisBlock(dbID proto.DatabaseID, resourceMeta pt.ResourceMeta) (genesisBlock *pt.Block, err error) {
// TODO(xq262144): following is stub code, real logic should be implemented in the future
emptyHash := hash.Hash{}
@@ -1210,6 +834,5 @@ func (s *metaState) makeCopy() *metaState {
return &metaState{
dirty: newMetaIndex(),
readonly: s.readonly.deepCopy(),
- pool: newTxPool(),
}
}
diff --git a/blockproducer/metastate_test.go b/blockproducer/metastate_test.go
index 95436aa81..a1fd12f6d 100644
--- a/blockproducer/metastate_test.go
+++ b/blockproducer/metastate_test.go
@@ -19,7 +19,6 @@ package blockproducer
import (
"math"
"os"
- "path"
"sync"
"testing"
@@ -31,7 +30,6 @@ import (
"github.com/CovenantSQL/CovenantSQL/proto"
"github.com/CovenantSQL/CovenantSQL/route"
"github.com/CovenantSQL/CovenantSQL/types"
- "github.com/coreos/bbolt"
"github.com/pkg/errors"
. "github.com/smartystreets/goconvey/convey"
)
@@ -44,6 +42,7 @@ func TestMetaState(t *testing.T) {
po *providerObject
bl uint64
loaded bool
+ err error
privKey1 *asymmetric.PrivateKey
privKey2 *asymmetric.PrivateKey
privKey3 *asymmetric.PrivateKey
@@ -56,8 +55,6 @@ func TestMetaState(t *testing.T) {
dbid2 = proto.DatabaseID("db#2")
dbid3 = proto.DatabaseID("db#3")
ms = newMetaState()
- fl = path.Join(testingDataDir, t.Name())
- db, err = bolt.Open(fl, 0600, nil)
)
So(err, ShouldBeNil)
@@ -79,38 +76,6 @@ func TestMetaState(t *testing.T) {
addr4, err = crypto.PubKeyHash(privKey4.PubKey())
So(err, ShouldBeNil)
- Reset(func() {
- // Clean database file after each pass
- err = db.Close()
- So(err, ShouldBeNil)
- err = os.Truncate(fl, 0)
- So(err, ShouldBeNil)
- })
- err = db.Update(func(tx *bolt.Tx) (err error) {
- var meta, txbk *bolt.Bucket
- if meta, err = tx.CreateBucket(metaBucket[:]); err != nil {
- return
- }
- if _, err = meta.CreateBucket(metaAccountIndexBucket); err != nil {
- return
- }
- if _, err = meta.CreateBucket(metaSQLChainIndexBucket); err != nil {
- return
- }
- if _, err = meta.CreateBucket(metaProviderIndexBucket); err != nil {
- return
- }
- if txbk, err = meta.CreateBucket(metaTransactionBucket); err != nil {
- return
- }
- for i := pi.TransactionType(0); i < pi.TransactionTypeNumber; i++ {
- if _, err = txbk.CreateBucket(i.Bytes()); err != nil {
- return
- }
- }
- return
- })
- So(err, ShouldBeNil)
Convey("The account state should be empty", func() {
ao, loaded = ms.loadAccountObject(addr1)
So(ao, ShouldBeNil)
@@ -224,8 +189,7 @@ func TestMetaState(t *testing.T) {
So(err, ShouldBeNil)
})
Convey("When metaState change is committed", func() {
- err = db.Update(ms.commitProcedure())
- So(err, ShouldBeNil)
+ ms.commit()
Convey("The metaState object should be ok to delete user", func() {
err = ms.deleteSQLChainUser(dbid3, addr2)
So(err, ShouldBeNil)
@@ -241,8 +205,7 @@ func TestMetaState(t *testing.T) {
})
})
Convey("When metaState change is committed", func() {
- err = db.Update(ms.commitProcedure())
- So(err, ShouldBeNil)
+ ms.commit()
Convey("The metaState object should be ok to add users for database", func() {
err = ms.addSQLChainUser(dbid3, addr2, types.Write)
So(err, ShouldBeNil)
@@ -329,8 +292,7 @@ func TestMetaState(t *testing.T) {
)
})
Convey("When metaState changes are committed", func() {
- err = db.Update(ms.commitProcedure())
- So(err, ShouldBeNil)
+ ms.commit()
Convey(
"The account balance should be kept correctly in account object",
func() {
@@ -387,8 +349,8 @@ func TestMetaState(t *testing.T) {
So(err, ShouldBeNil)
err = ms.increaseAccountStableBalance(addr2, math.MaxUint64)
So(err, ShouldBeNil)
- err = db.Update(ms.commitProcedure())
- So(err, ShouldBeNil)
+
+ ms.commit()
err = ms.transferAccountStableBalance(addr2, addr1, math.MaxUint64)
So(err, ShouldEqual, ErrBalanceOverflow)
err = ms.transferAccountStableBalance(addr2, addr3, 1)
@@ -404,43 +366,8 @@ func TestMetaState(t *testing.T) {
)
})
})
- Convey("When a new account key slot is overwritten", func() {
- err = db.Update(func(tx *bolt.Tx) (err error) {
- var bucket = tx.Bucket(metaBucket[:]).Bucket(metaAccountIndexBucket)
- if err = bucket.Delete(addr1[:]); err != nil {
- return
- }
- if _, err = bucket.CreateBucket(addr1[:]); err != nil {
- return
- }
- return
- })
- So(err, ShouldBeNil)
- Convey("The reloadProcedure should report error", func() {
- err = db.Update(ms.commitProcedure())
- So(err, ShouldNotBeNil)
- })
- })
- Convey("When a new database key slot is overwritten", func() {
- err = db.Update(func(tx *bolt.Tx) (err error) {
- var bucket = tx.Bucket(metaBucket[:]).Bucket(metaSQLChainIndexBucket)
- if err = bucket.Delete([]byte(dbid1)); err != nil {
- return
- }
- if _, err = bucket.CreateBucket([]byte(dbid1)); err != nil {
- return
- }
- return
- })
- So(err, ShouldBeNil)
- Convey("The reloadProcedure should report error", func() {
- err = db.Update(ms.commitProcedure())
- So(err, ShouldNotBeNil)
- })
- })
Convey("When metaState changes are committed", func() {
- err = db.Update(ms.commitProcedure())
- So(err, ShouldBeNil)
+ ms.commit()
Convey("The cached object should be retrievable from readonly map", func() {
var loaded bool
_, loaded = ms.loadAccountObject(addr1)
@@ -452,74 +379,6 @@ func TestMetaState(t *testing.T) {
_, loaded = ms.loadOrStoreSQLChainObject(dbid2, nil)
So(loaded, ShouldBeTrue)
})
- Convey("The metaState should be reproducible from the persistence db", func() {
- var (
- oa1, oa2, ra1, ra2 *accountObject
- oc1, oc2, rc1, rc2 *sqlchainObject
- loaded bool
- rms = newMetaState()
- err = db.View(rms.reloadProcedure())
- )
- So(err, ShouldBeNil)
- oa1, loaded = ms.loadAccountObject(addr1)
- So(loaded, ShouldBeTrue)
- So(oa1, ShouldNotBeNil)
- oa2, loaded = ms.loadAccountObject(addr2)
- So(loaded, ShouldBeTrue)
- So(oa2, ShouldNotBeNil)
- ra1, loaded = rms.loadAccountObject(addr1)
- So(loaded, ShouldBeTrue)
- So(ra1, ShouldNotBeNil)
- ra2, loaded = rms.loadAccountObject(addr2)
- So(loaded, ShouldBeTrue)
- So(ra2, ShouldNotBeNil)
- So(&oa1.Account, ShouldResemble, &ra1.Account)
- So(&oa2.Account, ShouldResemble, &ra2.Account)
- oc1, loaded = ms.loadSQLChainObject(dbid1)
- So(loaded, ShouldBeTrue)
- So(oc1, ShouldNotBeNil)
- oc2, loaded = ms.loadSQLChainObject(dbid2)
- So(loaded, ShouldBeTrue)
- So(oc2, ShouldNotBeNil)
- rc1, loaded = rms.loadSQLChainObject(dbid1)
- So(loaded, ShouldBeTrue)
- So(rc1, ShouldNotBeNil)
- rc2, loaded = rms.loadSQLChainObject(dbid2)
- So(loaded, ShouldBeTrue)
- So(rc2, ShouldNotBeNil)
- So(&oc1.SQLChainProfile, ShouldResemble, &rc1.SQLChainProfile)
- So(&oc2.SQLChainProfile, ShouldResemble, &rc2.SQLChainProfile)
- })
- Convey("When the some accountObject is corrupted", func() {
- err = db.Update(func(tx *bolt.Tx) (err error) {
- return tx.Bucket(metaBucket[:]).Bucket(metaAccountIndexBucket).Put(
- addr1[:], []byte{0x1, 0x2, 0x3, 0x4a},
- )
- })
- So(err, ShouldBeNil)
- Convey("The reloadProcedure should report error", func() {
- var (
- rms = newMetaState()
- err = db.View(rms.reloadProcedure())
- )
- So(err, ShouldNotBeNil)
- })
- })
- Convey("When the some sqlchainObject is corrupted", func() {
- err = db.Update(func(tx *bolt.Tx) (err error) {
- return tx.Bucket(metaBucket[:]).Bucket(metaSQLChainIndexBucket).Put(
- []byte(dbid1), []byte{0x1, 0x2, 0x3, 0x4a},
- )
- })
- So(err, ShouldBeNil)
- Convey("The reloadProcedure should report error", func() {
- var (
- rms = newMetaState()
- err = db.View(rms.reloadProcedure())
- )
- So(err, ShouldNotBeNil)
- })
- })
Convey("When some objects are deleted", func() {
ms.deleteAccountObject(addr1)
ms.deleteSQLChainObject(dbid1)
@@ -529,83 +388,6 @@ func TestMetaState(t *testing.T) {
_, loaded = ms.loadSQLChainObject(dbid1)
So(loaded, ShouldBeFalse)
})
- Convey("When the deleted account key slot is overwritten", func() {
- err = db.Update(func(tx *bolt.Tx) (err error) {
- var bucket = tx.Bucket(metaBucket[:]).Bucket(metaAccountIndexBucket)
- if err = bucket.Delete(addr1[:]); err != nil {
- return
- }
- if _, err = bucket.CreateBucket(addr1[:]); err != nil {
- return
- }
- return
- })
- So(err, ShouldBeNil)
- Convey("The commitProcedure should report error", func() {
- var err = db.Update(ms.commitProcedure())
- So(err, ShouldNotBeNil)
- })
- })
- Convey("When the deleted database key slot is overwritten", func() {
- err = db.Update(func(tx *bolt.Tx) (err error) {
- var bucket = tx.Bucket(metaBucket[:]).Bucket(metaSQLChainIndexBucket)
- if err = bucket.Delete([]byte(dbid1)); err != nil {
- return
- }
- if _, err = bucket.CreateBucket([]byte(dbid1)); err != nil {
- return
- }
- return
- })
- So(err, ShouldBeNil)
- Convey("The commitProcedure should report error", func() {
- var err = db.Update(ms.commitProcedure())
- So(err, ShouldNotBeNil)
- })
- })
- Convey("When metaState changes are committed again", func() {
- err = db.Update(ms.commitProcedure())
- So(err, ShouldBeNil)
- Convey(
- "The metaState should also be reproducible from the persistence db",
- func() {
- var (
- rms = newMetaState()
- err = db.View(rms.reloadProcedure())
- oa1, oa2, ra1, ra2 *accountObject
- oc1, oc2, rc1, rc2 *sqlchainObject
- loaded bool
- )
- So(err, ShouldBeNil)
- oa1, loaded = ms.loadAccountObject(addr1)
- So(loaded, ShouldBeFalse)
- So(oa1, ShouldBeNil)
- oa2, loaded = ms.loadAccountObject(addr2)
- So(loaded, ShouldBeTrue)
- So(oa2, ShouldNotBeNil)
- ra1, loaded = rms.loadAccountObject(addr1)
- So(loaded, ShouldBeFalse)
- So(ra1, ShouldBeNil)
- ra2, loaded = rms.loadAccountObject(addr2)
- So(loaded, ShouldBeTrue)
- So(ra2, ShouldNotBeNil)
- So(&oa2.Account, ShouldResemble, &ra2.Account)
- oc1, loaded = ms.loadSQLChainObject(dbid1)
- So(loaded, ShouldBeFalse)
- So(oc1, ShouldBeNil)
- oc2, loaded = ms.loadSQLChainObject(dbid2)
- So(loaded, ShouldBeTrue)
- So(oc2, ShouldNotBeNil)
- rc1, loaded = rms.loadSQLChainObject(dbid1)
- So(loaded, ShouldBeFalse)
- So(rc1, ShouldBeNil)
- rc2, loaded = rms.loadSQLChainObject(dbid2)
- So(loaded, ShouldBeTrue)
- So(rc2, ShouldNotBeNil)
- So(&oc2.SQLChainProfile, ShouldResemble, &rc2.SQLChainProfile)
- },
- )
- })
})
})
Convey("When transactions are added", func() {
@@ -636,45 +418,25 @@ func TestMetaState(t *testing.T) {
So(err, ShouldBeNil)
err = t2.Sign(privKey1)
So(err, ShouldBeNil)
- err = db.Update(ms.applyTransactionProcedure(t0))
+ err = ms.apply(t0)
So(err, ShouldBeNil)
- So(len(ms.pool.entries[addr1].transactions), ShouldEqual, 1)
- err = db.Update(ms.applyTransactionProcedure(t1))
+ ms.commit()
+ err = ms.apply(t1)
So(err, ShouldBeNil)
- _, loaded = ms.pool.entries[t1.GetAccountAddress()]
- So(loaded, ShouldBeTrue)
- So(ms.pool.hasTx(t0), ShouldBeTrue)
- So(len(ms.pool.entries[addr1].transactions), ShouldEqual, 2)
- _, loaded = ms.pool.entries[t1.GetAccountAddress()]
- So(loaded, ShouldBeTrue)
- So(ms.pool.hasTx(t0), ShouldBeTrue)
- So(ms.pool.hasTx(t1), ShouldBeTrue)
- err = db.Update(ms.applyTransactionProcedure(t2))
+ ms.commit()
+ err = ms.apply(t2)
So(err, ShouldBeNil)
- So(len(ms.pool.entries[addr1].transactions), ShouldEqual, 3)
- _, loaded = ms.pool.entries[t1.GetAccountAddress()]
- So(loaded, ShouldBeTrue)
- _, loaded = ms.pool.entries[t2.GetAccountAddress()]
- So(loaded, ShouldBeTrue)
- So(ms.pool.hasTx(t0), ShouldBeTrue)
- So(ms.pool.hasTx(t1), ShouldBeTrue)
- So(ms.pool.hasTx(t2), ShouldBeTrue)
Convey("The metaState should report error if tx fails verification", func() {
t1.Nonce = pi.AccountNonce(10)
err = t1.Sign(privKey1)
So(err, ShouldBeNil)
- err = db.Update(ms.applyTransactionProcedure(t1))
+ err = ms.apply(t1)
So(err, ShouldEqual, ErrInvalidAccountNonce)
t1.Nonce, err = ms.nextNonce(addr1)
So(err, ShouldBeNil)
So(t1.Nonce, ShouldEqual, ms.dirty.accounts[addr1].NextNonce)
- err = db.Update(ms.applyTransactionProcedure(t1))
- So(err, ShouldNotBeNil)
- err = t1.Sign(privKey1)
- So(err, ShouldBeNil)
- err = db.Update(ms.applyTransactionProcedure(t1))
- So(err, ShouldBeNil)
+ ms.commit()
})
Convey("The metaState should automatically increase nonce", func() {
n, err = ms.nextNonce(addr1)
@@ -685,48 +447,6 @@ func TestMetaState(t *testing.T) {
err = ms.applyTransaction(nil)
So(err, ShouldEqual, ErrUnknownTransactionType)
})
- Convey("The txs should be able to be pulled from pool", func() {
- var txs = ms.pullTxs()
- So(len(txs), ShouldEqual, 3)
- for _, tx := range txs {
- So(ms.pool.hasTx(tx), ShouldBeTrue)
- }
- })
- Convey("The partial commit procedure should be appliable for empty txs", func() {
- err = db.Update(ms.partialCommitProcedure([]pi.Transaction{}))
- So(err, ShouldBeNil)
- So(ms.pool.entries[addr1].baseNonce, ShouldEqual, 0)
- So(len(ms.pool.entries[addr1].transactions), ShouldEqual, 3)
- })
- Convey("The partial commit procedure should be appliable for tx0", func() {
- err = db.Update(ms.partialCommitProcedure([]pi.Transaction{t0}))
- So(err, ShouldBeNil)
- So(ms.pool.entries[addr1].baseNonce, ShouldEqual, 1)
- So(len(ms.pool.entries[addr1].transactions), ShouldEqual, 2)
- })
- Convey("The partial commit procedure should be appliable for tx0-1", func() {
- err = db.Update(ms.partialCommitProcedure([]pi.Transaction{t0, t1}))
- So(err, ShouldBeNil)
- So(ms.pool.entries[addr1].baseNonce, ShouldEqual, 2)
- So(len(ms.pool.entries[addr1].transactions), ShouldEqual, 1)
- })
- Convey("The partial commit procedure should be appliable for all tx", func() {
- err = db.Update(ms.partialCommitProcedure([]pi.Transaction{t0, t1, t2}))
- So(err, ShouldBeNil)
- So(ms.pool.entries[addr1].baseNonce, ShouldEqual, 3)
- So(len(ms.pool.entries[addr1].transactions), ShouldEqual, 0)
- })
- Convey(
- "The partial commit procedure should not be appliable for modified tx",
- func() {
- t1.Nonce = pi.AccountNonce(10)
- err = t1.Sign(privKey1)
- So(err, ShouldBeNil)
- err = db.Update(ms.partialCommitProcedure([]pi.Transaction{t0, t1, t2}))
- So(err, ShouldEqual, ErrTransactionMismatch)
- So(len(ms.pool.entries[addr1].transactions), ShouldEqual, 3)
- },
- )
})
})
Convey("When base account txs are added", func() {
@@ -814,9 +534,10 @@ func TestMetaState(t *testing.T) {
txs[7].Sign(privKey2)
txs[8].Sign(privKey2)
for _, tx := range txs {
- err = db.Update(ms.applyTransactionProcedure(tx))
+ err = ms.apply(tx)
So(err, ShouldBeNil)
}
+ ms.commit()
Convey("The state should match the update result", func() {
bl, loaded = ms.loadAccountStableBalance(addr1)
So(loaded, ShouldBeTrue)
@@ -825,66 +546,6 @@ func TestMetaState(t *testing.T) {
So(loaded, ShouldBeTrue)
So(bl, ShouldEqual, 118)
})
- Convey("When state change is partial committed #0", func() {
- err = db.Update(ms.partialCommitProcedure(nil))
- So(err, ShouldBeNil)
- Convey("The state should still match the update result", func() {
- bl, loaded = ms.loadAccountStableBalance(addr1)
- So(loaded, ShouldBeTrue)
- So(bl, ShouldEqual, 84)
- bl, loaded = ms.loadAccountStableBalance(addr2)
- So(loaded, ShouldBeTrue)
- So(bl, ShouldEqual, 118)
- })
- })
- Convey("When state change is partial committed #1", func() {
- err = db.Update(ms.partialCommitProcedure(txs[:2]))
- So(err, ShouldBeNil)
- Convey("The state should still match the update result", func() {
- bl, loaded = ms.loadAccountStableBalance(addr1)
- So(loaded, ShouldBeTrue)
- So(bl, ShouldEqual, 84)
- bl, loaded = ms.loadAccountStableBalance(addr2)
- So(loaded, ShouldBeTrue)
- So(bl, ShouldEqual, 118)
- })
- })
- Convey("When state change is partial committed #2", func() {
- err = db.Update(ms.partialCommitProcedure(txs[:3]))
- So(err, ShouldBeNil)
- Convey("The state should still match the update result", func() {
- bl, loaded = ms.loadAccountStableBalance(addr1)
- So(loaded, ShouldBeTrue)
- So(bl, ShouldEqual, 84)
- bl, loaded = ms.loadAccountStableBalance(addr2)
- So(loaded, ShouldBeTrue)
- So(bl, ShouldEqual, 118)
- })
- })
- Convey("When state change is partial committed #3", func() {
- err = db.Update(ms.partialCommitProcedure(txs[:6]))
- So(err, ShouldBeNil)
- Convey("The state should still match the update result", func() {
- bl, loaded = ms.loadAccountStableBalance(addr1)
- So(loaded, ShouldBeTrue)
- So(bl, ShouldEqual, 84)
- bl, loaded = ms.loadAccountStableBalance(addr2)
- So(loaded, ShouldBeTrue)
- So(bl, ShouldEqual, 118)
- })
- })
- Convey("When state change is partial committed #4", func() {
- err = db.Update(ms.partialCommitProcedure(txs))
- So(err, ShouldBeNil)
- Convey("The state should still match the update result", func() {
- bl, loaded = ms.loadAccountStableBalance(addr1)
- So(loaded, ShouldBeTrue)
- So(bl, ShouldEqual, 84)
- bl, loaded = ms.loadAccountStableBalance(addr2)
- So(loaded, ShouldBeTrue)
- So(bl, ShouldEqual, 118)
- })
- })
})
Convey("When SQLChain are created", func() {
conf.GConf, err = conf.LoadConfig("../test/node_standalone/config.yaml")
@@ -950,11 +611,11 @@ func TestMetaState(t *testing.T) {
}
invalidCd2.Sign(privKey1)
- err = db.Update(ms.applyTransactionProcedure(&invalidPs))
+ err = ms.apply(&invalidPs)
So(errors.Cause(err), ShouldEqual, ErrInvalidSender)
- err = db.Update(ms.applyTransactionProcedure(&invalidCd1))
+ err = ms.apply(&invalidCd1)
So(errors.Cause(err), ShouldEqual, ErrInvalidSender)
- err = db.Update(ms.applyTransactionProcedure(&invalidCd2))
+ err = ms.apply(&invalidCd2)
So(errors.Cause(err), ShouldEqual, ErrNoSuchMiner)
})
Convey("When SQLChain create", func() {
@@ -987,12 +648,14 @@ func TestMetaState(t *testing.T) {
cd2.Sign(privKey3)
So(err, ShouldBeNil)
- err = db.Update(ms.applyTransactionProcedure(&ps))
+ err = ms.apply(&ps)
So(err, ShouldBeNil)
- err = db.Update(ms.applyTransactionProcedure(&cd2))
+ ms.commit()
+ err = ms.apply(&cd2)
So(errors.Cause(err), ShouldEqual, ErrMinerUserNotMatch)
- err = db.Update(ms.applyTransactionProcedure(&cd1))
+ err = ms.apply(&cd1)
So(err, ShouldBeNil)
+ ms.commit()
dbID := proto.FromAccountAndNonce(cd1.Owner, uint32(cd1.Nonce))
co, loaded = ms.loadSQLChainObject(*dbID)
So(loaded, ShouldBeTrue)
@@ -1008,13 +671,13 @@ func TestMetaState(t *testing.T) {
},
}
up.Sign(privKey1)
- err = db.Update(ms.applyTransactionProcedure(&up))
+ err = ms.apply(&up)
So(errors.Cause(err), ShouldEqual, ErrDatabaseNotFound)
up.Permission = 4
up.TargetSQLChain = dbAccount
err = up.Sign(privKey1)
So(err, ShouldBeNil)
- err = db.Update(ms.applyTransactionProcedure(&up))
+ err = ms.apply(&up)
So(errors.Cause(err), ShouldEqual, ErrInvalidPermission)
// test permission update
// addr1(admin) update addr3 as admin
@@ -1022,35 +685,38 @@ func TestMetaState(t *testing.T) {
up.Permission = types.Admin
err = up.Sign(privKey1)
So(err, ShouldBeNil)
- err = db.Update(ms.applyTransactionProcedure(&up))
+ err = ms.apply(&up)
So(err, ShouldBeNil)
+ ms.commit()
// addr3(admin) update addr4 as read
up.TargetUser = addr4
up.Nonce = 0
up.Permission = types.Read
err = up.Sign(privKey3)
So(err, ShouldBeNil)
- err = db.Update(ms.applyTransactionProcedure(&up))
+ err = ms.apply(&up)
So(err, ShouldBeNil)
+ ms.commit()
// addr3(admin) update addr1(admin) as read
up.TargetUser = addr1
up.Nonce = up.Nonce + 1
err = up.Sign(privKey3)
So(err, ShouldBeNil)
- err = db.Update(ms.applyTransactionProcedure(&up))
+ err = ms.apply(&up)
So(err, ShouldBeNil)
+ ms.commit()
// addr3(admin) update addr3(admin) as read fail
up.TargetUser = addr3
up.Permission = types.Read
up.Nonce = up.Nonce + 1
err = up.Sign(privKey3)
So(err, ShouldBeNil)
- err = db.Update(ms.applyTransactionProcedure(&up))
+ err = ms.apply(&up)
So(errors.Cause(err), ShouldEqual, ErrInvalidSender)
// addr1(read) update addr3(admin) fail
up.Nonce = cd1.Nonce + 2
err = up.Sign(privKey1)
- err = db.Update(ms.applyTransactionProcedure(&up))
+ err = ms.apply(&up)
So(errors.Cause(err), ShouldEqual, ErrAccountPermissionDeny)
co, loaded = ms.loadSQLChainObject(*dbID)
diff --git a/blockproducer/xxx_test.go b/blockproducer/xxx_test.go
index 2b5d919e1..26cca2a71 100644
--- a/blockproducer/xxx_test.go
+++ b/blockproducer/xxx_test.go
@@ -495,7 +495,7 @@ func setup() {
// Setup logging
log.SetOutput(os.Stdout)
- log.SetLevel(log.FatalLevel)
+ log.SetLevel(log.DebugLevel)
}
func teardown() {
From 442fb78e5e885d2c674f7e363cf2303dbffc8260 Mon Sep 17 00:00:00 2001
From: laodouya
Date: Fri, 7 Dec 2018 14:23:36 +0800
Subject: [PATCH 084/278] Combine run.sh code lines.
---
test/GNTE/run.sh | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/test/GNTE/run.sh b/test/GNTE/run.sh
index 69ca7800a..3afb4739d 100755
--- a/test/GNTE/run.sh
+++ b/test/GNTE/run.sh
@@ -1,11 +1,8 @@
#!/bin/bash -x
-yaml[0]=./scripts/gnte_0ms.yaml
-yaml[1]=./scripts/gnte_5ms.yaml
-yaml[2]=./scripts/gnte_20ms.yaml
-yaml[3]=./scripts/gnte_100ms.yaml
-yaml[4]=./scripts/gnte_200ms.yaml
-
+yaml=(
+ ./scripts/gnte_{0,5,20,100,200}ms.yaml
+)
TEST_WD=$(cd $(dirname $0)/; pwd)
PROJECT_DIR=$(cd ${TEST_WD}/../../; pwd)
From 4e009bdcfe965392587f12b8d270cc4dd10a0d42 Mon Sep 17 00:00:00 2001
From: laodouya
Date: Tue, 18 Dec 2018 16:14:29 +0800
Subject: [PATCH 085/278] Reduce build.sh lines length by adding var
---
build.sh | 33 +++++++++++++++++++++------------
1 file changed, 21 insertions(+), 12 deletions(-)
diff --git a/build.sh b/build.sh
index fc39ea309..a43c4bbf9 100755
--- a/build.sh
+++ b/build.sh
@@ -19,38 +19,47 @@ cd `dirname $0`
version=`getversion`
+tags="${platform} sqlite_omit_load_extension"
+testtags="${platform} sqlite_omit_load_extension testbinary"
+
+ldflags_role_bp="-X main.version=${version} -X github.com/CovenantSQL/CovenantSQL/conf.RoleTag=B ${GOLDFLAGS}"
+ldflags_role_miner="-X main.version=${version} -X github.com/CovenantSQL/CovenantSQL/conf.RoleTag=M ${GOLDFLAGS}"
+ldflags_role_client="-X main.version=${version} -X github.com/CovenantSQL/CovenantSQL/conf.RoleTag=C ${GOLDFLAGS}"
+
+test_flags="-coverpkg github.com/CovenantSQL/CovenantSQL/... -cover -race -c"
+
cql_utils_pkgpath="github.com/CovenantSQL/CovenantSQL/cmd/cql-utils"
go build -ldflags "-X main.version=${version} ${GOLDFLAGS}" -o bin/cql-utils ${cql_utils_pkgpath}
cqld_pkgpath="github.com/CovenantSQL/CovenantSQL/cmd/cqld"
-CGO_ENABLED=1 go build -ldflags "-X main.version=${version} -X github.com/CovenantSQL/CovenantSQL/conf.RoleTag=B ${GOLDFLAGS}" -tags "${platform} sqlite_omit_load_extension" -o bin/cqld ${cqld_pkgpath}
-CGO_ENABLED=1 go test -coverpkg github.com/CovenantSQL/CovenantSQL/... -cover -race -c -tags "${platform} sqlite_omit_load_extension testbinary" -ldflags "-X main.version=${version} -X github.com/CovenantSQL/CovenantSQL/conf.RoleTag=B ${GOLDFLAGS}" -o bin/cqld.test ${cqld_pkgpath}
+CGO_ENABLED=1 go build -ldflags "${ldflags_role_bp}" --tags "${tags}" -o bin/cqld ${cqld_pkgpath}
+CGO_ENABLED=1 go test ${test_flags} -tags "${testtags}" -ldflags "${ldflags_role_bp}" -o bin/cqld.test ${cqld_pkgpath}
cql_minerd_pkgpath="github.com/CovenantSQL/CovenantSQL/cmd/cql-minerd"
-CGO_ENABLED=1 go build -ldflags "-X main.version=${version} -X github.com/CovenantSQL/CovenantSQL/conf.RoleTag=M ${GOLDFLAGS}" --tags ${platform}" sqlite_omit_load_extension" -o bin/cql-minerd ${cql_minerd_pkgpath}
-CGO_ENABLED=1 go test -coverpkg github.com/CovenantSQL/CovenantSQL/... -cover -race -c -tags "${platform} sqlite_omit_load_extension testbinary" -ldflags "-X main.version=${version} -X github.com/CovenantSQL/CovenantSQL/conf.RoleTag=M ${GOLDFLAGS}" -o bin/cql-minerd.test ${cql_minerd_pkgpath}
+CGO_ENABLED=1 go build -ldflags "${ldflags_role_miner}" --tags "${tags}" -o bin/cql-minerd ${cql_minerd_pkgpath}
+CGO_ENABLED=1 go test ${test_flags} -tags "${testtags}" -ldflags "${ldflags_role_miner}" -o bin/cql-minerd.test ${cql_minerd_pkgpath}
cql_observer_pkgpath="github.com/CovenantSQL/CovenantSQL/cmd/cql-observer"
-go build -ldflags "-X main.version=${version} -X github.com/CovenantSQL/CovenantSQL/conf.RoleTag=C ${GOLDFLAGS}" -o bin/cql-observer ${cql_observer_pkgpath}
-go test -coverpkg github.com/CovenantSQL/CovenantSQL/... -cover -race -c -tags 'testbinary' -ldflags "-X main.version=${version} -X github.com/CovenantSQL/CovenantSQL/conf.RoleTag=C ${GOLDFLAGS}" -o bin/cql-observer.test ${cql_observer_pkgpath}
+go build -ldflags "${ldflags_role_client}" -o bin/cql-observer ${cql_observer_pkgpath}
+go test ${test_flags} -tags 'testbinary' -ldflags "${ldflags_role_client}" -o bin/cql-observer.test ${cql_observer_pkgpath}
cli_pkgpath="github.com/CovenantSQL/CovenantSQL/cmd/cql"
-CGO_ENABLED=1 go build -ldflags "-X main.version=${version} -X github.com/CovenantSQL/CovenantSQL/conf.RoleTag=C ${GOLDFLAGS}" --tags ${platform}" sqlite_omit_load_extension" -o bin/cql ${cli_pkgpath}
+CGO_ENABLED=1 go build -ldflags "${ldflags_role_client}" --tags "${tags}" -o bin/cql ${cli_pkgpath}
fuse_pkgpath="github.com/CovenantSQL/CovenantSQL/cmd/cql-fuse"
-CGO_ENABLED=1 go build -ldflags "-X main.version=${version} -X github.com/CovenantSQL/CovenantSQL/conf.RoleTag=C ${GOLDFLAGS}" --tags ${platform}" sqlite_omit_load_extension" -o bin/cql-fuse ${fuse_pkgpath}
+CGO_ENABLED=1 go build -ldflags "${ldflags_role_client}" --tags "${tags}" -o bin/cql-fuse ${fuse_pkgpath}
cql_adapter_pkgpath="github.com/CovenantSQL/CovenantSQL/cmd/cql-adapter"
-CGO_ENABLED=1 go build -ldflags "-X main.version=${version} -X github.com/CovenantSQL/CovenantSQL/conf.RoleTag=C ${GOLDFLAGS}" --tags ${platform}" sqlite_omit_load_extension" -o bin/cql-adapter ${cql_adapter_pkgpath}
+CGO_ENABLED=1 go build -ldflags "${ldflags_role_client}" --tags "${tags}" -o bin/cql-adapter ${cql_adapter_pkgpath}
cql_faucet_pkgpath="github.com/CovenantSQL/CovenantSQL/cmd/cql-faucet"
-CGO_ENABLED=1 go build -ldflags "-X main.version=${version} -X github.com/CovenantSQL/CovenantSQL/conf.RoleTag=C ${GOLDFLAGS}" --tags ${platform}" sqlite_omit_load_extension" -o bin/cql-faucet ${cql_faucet_pkgpath}
+CGO_ENABLED=1 go build -ldflags "${ldflags_role_client}" --tags "${tags}" -o bin/cql-faucet ${cql_faucet_pkgpath}
cql_mysql_adapter_pkgpath="github.com/CovenantSQL/CovenantSQL/cmd/cql-mysql-adapter"
-CGO_ENABLED=1 go build -ldflags "-X main.version=${version} -X github.com/CovenantSQL/CovenantSQL/conf.RoleTag=C ${GOLDFLAGS}" --tags ${platform}" sqlite_omit_load_extension" -o bin/cql-mysql-adapter ${cql_mysql_adapter_pkgpath}
+CGO_ENABLED=1 go build -ldflags "${ldflags_role_client}" --tags "${tags}" -o bin/cql-mysql-adapter ${cql_mysql_adapter_pkgpath}
cql_explorer_pkgpath="github.com/CovenantSQL/CovenantSQL/cmd/cql-explorer"
-CGO_ENABLED=1 go build -ldflags "-X main.version=${version} -X github.com/CovenantSQL/CovenantSQL/conf.RoleTag=C ${GOLDFLAGS}" --tags ${platform}" sqlite_omit_load_extension" -o bin/cql-explorer ${cql_explorer_pkgpath}
+CGO_ENABLED=1 go build -ldflags "${ldflags_role_client}" --tags "${tags}" -o bin/cql-explorer ${cql_explorer_pkgpath}
echo "done"
From d6d36bfd71c2bb6d50df4a3e5a00fb3271a38d58 Mon Sep 17 00:00:00 2001
From: laodouya
Date: Tue, 18 Dec 2018 16:18:20 +0800
Subject: [PATCH 086/278] export CGO_ENABLED=1 before go build
---
build.sh | 30 ++++++++++++++++--------------
1 file changed, 16 insertions(+), 14 deletions(-)
diff --git a/build.sh b/build.sh
index a43c4bbf9..906c6f876 100755
--- a/build.sh
+++ b/build.sh
@@ -31,35 +31,37 @@ test_flags="-coverpkg github.com/CovenantSQL/CovenantSQL/... -cover -race -c"
cql_utils_pkgpath="github.com/CovenantSQL/CovenantSQL/cmd/cql-utils"
go build -ldflags "-X main.version=${version} ${GOLDFLAGS}" -o bin/cql-utils ${cql_utils_pkgpath}
-cqld_pkgpath="github.com/CovenantSQL/CovenantSQL/cmd/cqld"
-CGO_ENABLED=1 go build -ldflags "${ldflags_role_bp}" --tags "${tags}" -o bin/cqld ${cqld_pkgpath}
-CGO_ENABLED=1 go test ${test_flags} -tags "${testtags}" -ldflags "${ldflags_role_bp}" -o bin/cqld.test ${cqld_pkgpath}
-
-cql_minerd_pkgpath="github.com/CovenantSQL/CovenantSQL/cmd/cql-minerd"
-CGO_ENABLED=1 go build -ldflags "${ldflags_role_miner}" --tags "${tags}" -o bin/cql-minerd ${cql_minerd_pkgpath}
-CGO_ENABLED=1 go test ${test_flags} -tags "${testtags}" -ldflags "${ldflags_role_miner}" -o bin/cql-minerd.test ${cql_minerd_pkgpath}
-
cql_observer_pkgpath="github.com/CovenantSQL/CovenantSQL/cmd/cql-observer"
go build -ldflags "${ldflags_role_client}" -o bin/cql-observer ${cql_observer_pkgpath}
go test ${test_flags} -tags 'testbinary' -ldflags "${ldflags_role_client}" -o bin/cql-observer.test ${cql_observer_pkgpath}
+export CGO_ENABLED=1
+
+cqld_pkgpath="github.com/CovenantSQL/CovenantSQL/cmd/cqld"
+go build -ldflags "${ldflags_role_bp}" --tags "${tags}" -o bin/cqld ${cqld_pkgpath}
+go test ${test_flags} -tags "${testtags}" -ldflags "${ldflags_role_bp}" -o bin/cqld.test ${cqld_pkgpath}
+
+cql_minerd_pkgpath="github.com/CovenantSQL/CovenantSQL/cmd/cql-minerd"
+go build -ldflags "${ldflags_role_miner}" --tags "${tags}" -o bin/cql-minerd ${cql_minerd_pkgpath}
+go test ${test_flags} -tags "${testtags}" -ldflags "${ldflags_role_miner}" -o bin/cql-minerd.test ${cql_minerd_pkgpath}
+
cli_pkgpath="github.com/CovenantSQL/CovenantSQL/cmd/cql"
-CGO_ENABLED=1 go build -ldflags "${ldflags_role_client}" --tags "${tags}" -o bin/cql ${cli_pkgpath}
+go build -ldflags "${ldflags_role_client}" --tags "${tags}" -o bin/cql ${cli_pkgpath}
fuse_pkgpath="github.com/CovenantSQL/CovenantSQL/cmd/cql-fuse"
-CGO_ENABLED=1 go build -ldflags "${ldflags_role_client}" --tags "${tags}" -o bin/cql-fuse ${fuse_pkgpath}
+go build -ldflags "${ldflags_role_client}" --tags "${tags}" -o bin/cql-fuse ${fuse_pkgpath}
cql_adapter_pkgpath="github.com/CovenantSQL/CovenantSQL/cmd/cql-adapter"
-CGO_ENABLED=1 go build -ldflags "${ldflags_role_client}" --tags "${tags}" -o bin/cql-adapter ${cql_adapter_pkgpath}
+go build -ldflags "${ldflags_role_client}" --tags "${tags}" -o bin/cql-adapter ${cql_adapter_pkgpath}
cql_faucet_pkgpath="github.com/CovenantSQL/CovenantSQL/cmd/cql-faucet"
-CGO_ENABLED=1 go build -ldflags "${ldflags_role_client}" --tags "${tags}" -o bin/cql-faucet ${cql_faucet_pkgpath}
+go build -ldflags "${ldflags_role_client}" --tags "${tags}" -o bin/cql-faucet ${cql_faucet_pkgpath}
cql_mysql_adapter_pkgpath="github.com/CovenantSQL/CovenantSQL/cmd/cql-mysql-adapter"
-CGO_ENABLED=1 go build -ldflags "${ldflags_role_client}" --tags "${tags}" -o bin/cql-mysql-adapter ${cql_mysql_adapter_pkgpath}
+go build -ldflags "${ldflags_role_client}" --tags "${tags}" -o bin/cql-mysql-adapter ${cql_mysql_adapter_pkgpath}
cql_explorer_pkgpath="github.com/CovenantSQL/CovenantSQL/cmd/cql-explorer"
-CGO_ENABLED=1 go build -ldflags "${ldflags_role_client}" --tags "${tags}" -o bin/cql-explorer ${cql_explorer_pkgpath}
+go build -ldflags "${ldflags_role_client}" --tags "${tags}" -o bin/cql-explorer ${cql_explorer_pkgpath}
echo "done"
From ace6fa58872b71b6cbccdfc1be9917c1a0622611 Mon Sep 17 00:00:00 2001
From: laodouya
Date: Wed, 19 Dec 2018 01:09:26 +0800
Subject: [PATCH 087/278] Add glibc in running docker
---
Dockerfile | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/Dockerfile b/Dockerfile
index 626ca9619..b2f1a82f5 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -3,11 +3,11 @@ FROM golang:1.11-stretch as builder
WORKDIR /go/src/github.com/CovenantSQL/CovenantSQL
COPY . .
-RUN CGO_ENABLED=1 GOOS=linux GOLDFLAGS="-linkmode external -extldflags -static" ./build.sh
+RUN GOOS=linux GOLDFLAGS="-linkmode external -extldflags -static" ./build.sh
RUN rm -f bin/*.test
# Stage: runner
-FROM alpine:3.7
+FROM frolvlad/alpine-glibc:latest
ARG COMMIT
ARG VERSION
From 8b4a70a4f1fbd79aa1ff69baae70f79ea2f0c8c6 Mon Sep 17 00:00:00 2001
From: leventeliu
Date: Tue, 18 Dec 2018 21:32:23 +0800
Subject: [PATCH 088/278] Format logging messages
find . -name '*.go' ! -path './vendor/*' ! -path './test/GNTE/*' -exec sed -i \
's/\.\(Debug\|Info\|Warn\|Warning\|Error\|Fatal\|Panicf\?\)("\([[:upper:]]\)\([[:lower:]]\+[^[:alnum:]]\)/.\1("\L\2\3/' {} +
---
blockproducer/chain.go | 36 +++++-----
blockproducer/storage.go | 6 +-
cmd/cql-adapter/main.go | 2 +-
cmd/cql-explorer/main.go | 2 +-
cmd/cql-faucet/main.go | 2 +-
cmd/cql-fuse/block_test.go | 12 ++--
cmd/cql-minerd/integration_test.go | 12 ++--
cmd/cql-minerd/main.go | 2 +-
cmd/cql-mysql-adapter/main.go | 2 +-
cmd/cql-observer/config.go | 4 +-
cmd/cql-observer/main.go | 2 +-
cmd/cql-observer/service.go | 2 +-
cmd/cql/main.go | 2 +-
cmd/cqld/adapter.go | 6 +-
cmd/cqld/client.go | 2 +-
cmd/cqld/main.go | 2 +-
cmd/hotfix/observer-upgrade/main.go | 18 ++---
consistent/consistent.go | 2 +-
crypto/asymmetric/signature_test.go | 24 +++----
crypto/cipher_test.go | 2 +-
crypto/etls/conn_test.go | 6 +-
crypto/hash/hash_test.go | 8 +--
crypto/kms/pubkeystore.go | 2 +-
metric/covenantmetric_test.go | 2 +-
metric/diskstats_linux.go | 2 +-
metric/filesystem_bsd.go | 4 +-
metric/filesystem_freebsd.go | 4 +-
metric/filesystem_linux.go | 6 +-
metric/filesystem_linux_test.go | 2 +-
metric/meminfo.go | 2 +-
metric/meminfo_darwin.go | 2 +-
metric/metric.go | 2 +-
metric/nodemetricmap.go | 2 +-
metric/nodemetricmap_test.go | 4 +-
metric/rpc.go | 2 +-
pow/cpuminer/miner.go | 4 +-
proto/nodeinfo.go | 4 +-
route/bootstrap_test.go | 8 +--
rpc/server.go | 4 +-
sqlchain/ackindex.go | 10 +--
sqlchain/chain.go | 54 +++++++--------
sqlchain/chain_test.go | 44 ++++++------
sqlchain/otypes/block_test.go | 80 ++++++++++-----------
sqlchain/state_test.go | 8 +--
sqlchain/storageproof_test.go | 26 +++----
storage/dsn_test.go | 2 +-
storage/storage_test.go | 104 ++++++++++++++--------------
twopc/twopc_test.go | 20 +++---
types/billing_test.go | 48 ++++++-------
types/block.go | 2 +-
types/block_test.go | 80 ++++++++++-----------
types/bp_block_test.go | 32 ++++-----
types/marshalhash_test.go | 4 +-
utils/big_test.go | 14 ++--
utils/log/logwrapper_test.go | 28 ++++----
xenomint/chain_test.go | 30 ++++----
xenomint/mux_test.go | 42 +++++------
xenomint/sqlite/sqlite_test.go | 94 ++++++++++++-------------
xenomint/state.go | 2 +-
59 files changed, 468 insertions(+), 468 deletions(-)
diff --git a/blockproducer/chain.go b/blockproducer/chain.go
index c5c125af4..8dba8a454 100644
--- a/blockproducer/chain.go
+++ b/blockproducer/chain.go
@@ -187,7 +187,7 @@ func NewChainWithContext(ctx context.Context, cfg *Config) (c *Chain, err error)
"irre_count": irre.count,
"head_hash": v.hash.Short(4),
"head_count": v.count,
- }).Debug("Checking head")
+ }).Debug("checking head")
if v.hasAncestor(irre) {
if br, ierr = fork(irre, v, immutable, txPool); ierr != nil {
err = errors.Wrapf(ierr, "failed to rebuild branch with head %s", v.hash.Short(4))
@@ -341,7 +341,7 @@ func (c *Chain) produceBlock(now time.Time) (err error) {
"block_time": b.Timestamp(),
"block_hash": b.BlockHash().Short(4),
"parent_hash": b.ParentHash().Short(4),
- }).WithError(err).Debug("Broadcasting new block to other peers")
+ }).WithError(err).Debug("broadcasting new block to other peers")
}, c.period)
}(s)
}
@@ -436,7 +436,7 @@ func (c *Chain) syncHeads() {
log.WithFields(log.Fields{
"next_height": c.getNextHeight(),
"height": h,
- }).Debug("Synchronizing head blocks")
+ }).Debug("synchronizing head blocks")
c.syncCurrentHead(c.ctx)
}
c.increaseNextHeight()
@@ -502,7 +502,7 @@ func (c *Chain) addTx(tx pi.Transaction) {
"remote": id,
"tx_hash": tx.Hash().Short(4),
"tx_type": tx.GetTransactionType(),
- }).WithError(err).Debug("Broadcasting transaction to other peers")
+ }).WithError(err).Debug("broadcasting transaction to other peers")
}, c.period)
}(v)
}
@@ -511,17 +511,17 @@ func (c *Chain) addTx(tx pi.Transaction) {
select {
case c.pendingTxs <- tx:
case <-c.ctx.Done():
- log.WithError(c.ctx.Err()).Error("Add transaction aborted")
+ log.WithError(c.ctx.Err()).Error("add transaction aborted")
}
}
func (c *Chain) processTx(tx pi.Transaction) {
if err := tx.Verify(); err != nil {
- log.WithError(err).Error("Failed to verify transaction")
+ log.WithError(err).Error("failed to verify transaction")
return
}
if err := c.storeTx(tx); err != nil {
- log.WithError(err).Error("Failed to add transaction")
+ log.WithError(err).Error("failed to add transaction")
}
}
@@ -540,7 +540,7 @@ func (c *Chain) mainCycle(ctx context.Context) {
for {
select {
case <-ctx.Done():
- log.WithError(ctx.Err()).Debug("Abort main cycle")
+ log.WithError(ctx.Err()).Debug("abort main cycle")
return
default:
c.syncCurrentHead(ctx) // Try to fetch block at height `nextHeight-1`
@@ -553,7 +553,7 @@ func (c *Chain) mainCycle(ctx context.Context) {
"head_block": c.head().hash.Short(4),
"now_time": t.Format(time.RFC3339Nano),
"duration": d,
- }).Debug("Main cycle")
+ }).Debug("main cycle")
time.Sleep(d)
} else {
// Try to produce block at `nextHeight` if it's my turn, and increase height by 1
@@ -603,7 +603,7 @@ func (c *Chain) syncCurrentHead(ctx context.Context) {
"local": c.peerInfo(),
"remote": id,
"height": h,
- }).WithError(err).Warn("Failed to fetch block")
+ }).WithError(err).Warn("failed to fetch block")
return
}
log.WithFields(log.Fields{
@@ -612,11 +612,11 @@ func (c *Chain) syncCurrentHead(ctx context.Context) {
"height": h,
"parent": resp.Block.ParentHash().Short(4),
"hash": resp.Block.BlockHash().Short(4),
- }).Debug("Fetched new block from remote peer")
+ }).Debug("fetched new block from remote peer")
select {
case c.pendingBlocks <- resp.Block:
case <-cld.Done():
- log.WithError(cld.Err()).Warn("Add pending block aborted")
+ log.WithError(cld.Err()).Warn("add pending block aborted")
}
}(v)
}
@@ -626,11 +626,11 @@ func (c *Chain) syncCurrentHead(ctx context.Context) {
// Stop stops the main process of the sql-chain.
func (c *Chain) Stop() (err error) {
// Stop main process
- log.WithFields(log.Fields{"peer": c.peerInfo()}).Debug("Stopping chain")
+ log.WithFields(log.Fields{"peer": c.peerInfo()}).Debug("stopping chain")
c.stop()
- log.WithFields(log.Fields{"peer": c.peerInfo()}).Debug("Chain service stopped")
+ log.WithFields(log.Fields{"peer": c.peerInfo()}).Debug("chain service stopped")
c.st.Close()
- log.WithFields(log.Fields{"peer": c.peerInfo()}).Debug("Chain database closed")
+ log.WithFields(log.Fields{"peer": c.peerInfo()}).Debug("chain database closed")
close(c.pendingBlocks)
close(c.pendingTxs)
return
@@ -694,7 +694,7 @@ func (c *Chain) switchBranch(bl *types.BPBlock, origin int, head *branch) (err e
for _, b := range newIrres {
for _, tx := range b.block.Transactions {
if err := c.immutable.apply(tx); err != nil {
- log.WithError(err).Fatal("Failed to apply block to immutable database")
+ log.WithError(err).Fatal("failed to apply block to immutable database")
}
}
}
@@ -753,7 +753,7 @@ func (c *Chain) switchBranch(bl *types.BPBlock, origin int, head *branch) (err e
}
return fmt.Sprintf("[%04d]", i)
}(),
- }).Debugf("Pruning branch")
+ }).Debugf("pruning branch")
}
}
// Replace current branches
@@ -793,7 +793,7 @@ func (c *Chain) stat() {
buff += v.sprint(c.lastIrre.count)
log.WithFields(log.Fields{
"branch": buff,
- }).Info("Runtime state")
+ }).Info("runtime state")
}
return
}
diff --git a/blockproducer/storage.go b/blockproducer/storage.go
index 949673dfe..3ec95f7c3 100644
--- a/blockproducer/storage.go
+++ b/blockproducer/storage.go
@@ -95,7 +95,7 @@ func store(st xi.Storage, sps []storageProcedure, cb storageCallback) (err error
}
// COMMIT
if err = tx.Commit(); err != nil {
- log.WithError(err).Fatalf("Failed to commit storage transaction")
+ log.WithError(err).Fatalf("failed to commit storage transaction")
}
return
}
@@ -349,7 +349,7 @@ func loadBlocks(
"height": v1,
"hash": bh.Short(4),
"parent": ph.Short(4),
- }).Debug("Loaded new block")
+ }).Debug("loaded new block")
// Add genesis block
if v1 == 0 {
if len(index) != 0 {
@@ -364,7 +364,7 @@ func loadBlocks(
"height": v1,
"hash": bh.Short(4),
"parent": ph.Short(4),
- }).Debug("Set genesis block")
+ }).Debug("set genesis block")
continue
}
// Add normal block
diff --git a/cmd/cql-adapter/main.go b/cmd/cql-adapter/main.go
index 570937371..9259a5704 100644
--- a/cmd/cql-adapter/main.go
+++ b/cmd/cql-adapter/main.go
@@ -56,7 +56,7 @@ func main() {
}
flag.Visit(func(f *flag.Flag) {
- log.Infof("Args %#v : %s", f.Name, f.Value)
+ log.Infof("args %#v : %s", f.Name, f.Value)
})
server, err := NewHTTPAdapter(configFile, password)
diff --git a/cmd/cql-explorer/main.go b/cmd/cql-explorer/main.go
index 171138d40..318764389 100644
--- a/cmd/cql-explorer/main.go
+++ b/cmd/cql-explorer/main.go
@@ -66,7 +66,7 @@ func main() {
}
flag.Visit(func(f *flag.Flag) {
- log.Infof("Args %#v : %s", f.Name, f.Value)
+ log.Infof("args %#v : %s", f.Name, f.Value)
})
// init client
diff --git a/cmd/cql-faucet/main.go b/cmd/cql-faucet/main.go
index 7f580285f..d1f67bd1e 100644
--- a/cmd/cql-faucet/main.go
+++ b/cmd/cql-faucet/main.go
@@ -58,7 +58,7 @@ func main() {
}
flag.Visit(func(f *flag.Flag) {
- log.Infof("Args %#v : %s", f.Name, f.Value)
+ log.Infof("args %#v : %s", f.Name, f.Value)
})
// init client
diff --git a/cmd/cql-fuse/block_test.go b/cmd/cql-fuse/block_test.go
index 13ec53664..836b15132 100644
--- a/cmd/cql-fuse/block_test.go
+++ b/cmd/cql-fuse/block_test.go
@@ -445,7 +445,7 @@ func TestReadWriteBlocks(t *testing.T) {
log.Fatal(err)
}
if !bytes.Equal(part1, readData) {
- t.Errorf("Bytes differ. lengths: %d, expected %d", len(readData), len(part1))
+ t.Errorf("bytes differ. lengths: %d, expected %d", len(readData), len(part1))
}
verboseData, err := getAllBlocks(db, id)
@@ -453,7 +453,7 @@ func TestReadWriteBlocks(t *testing.T) {
log.Fatal(err)
}
if !bytes.Equal(verboseData, part1) {
- t.Errorf("Bytes differ. lengths: %d, expected %d", len(verboseData), len(part1))
+ t.Errorf("bytes differ. lengths: %d, expected %d", len(verboseData), len(part1))
}
// Write with hole in the middle.
@@ -469,7 +469,7 @@ func TestReadWriteBlocks(t *testing.T) {
log.Fatal(err)
}
if !bytes.Equal(fullData, readData) {
- t.Errorf("Bytes differ. lengths: %d, expected %d", len(readData), len(fullData))
+ t.Errorf("bytes differ. lengths: %d, expected %d", len(readData), len(fullData))
}
verboseData, err = getAllBlocks(db, id)
@@ -477,7 +477,7 @@ func TestReadWriteBlocks(t *testing.T) {
log.Fatal(err)
}
if !bytes.Equal(verboseData, fullData) {
- t.Errorf("Bytes differ. lengths: %d, expected %d", len(verboseData), len(fullData))
+ t.Errorf("bytes differ. lengths: %d, expected %d", len(verboseData), len(fullData))
}
// Now write into the middle of the file.
@@ -492,7 +492,7 @@ func TestReadWriteBlocks(t *testing.T) {
log.Fatal(err)
}
if !bytes.Equal(fullData, readData) {
- t.Errorf("Bytes differ. lengths: %d, expected %d", len(readData), len(fullData))
+ t.Errorf("bytes differ. lengths: %d, expected %d", len(readData), len(fullData))
}
verboseData, err = getAllBlocks(db, id)
@@ -500,7 +500,7 @@ func TestReadWriteBlocks(t *testing.T) {
log.Fatal(err)
}
if !bytes.Equal(verboseData, fullData) {
- t.Errorf("Bytes differ. lengths: %d, expected %d", len(verboseData), len(fullData))
+ t.Errorf("bytes differ. lengths: %d, expected %d", len(verboseData), len(fullData))
}
// New file.
diff --git a/cmd/cql-minerd/integration_test.go b/cmd/cql-minerd/integration_test.go
index eacb16bce..4a441053f 100644
--- a/cmd/cql-minerd/integration_test.go
+++ b/cmd/cql-minerd/integration_test.go
@@ -497,7 +497,7 @@ func benchDB(b *testing.B, db *sql.DB, createDB bool) {
_, err = db.Exec("INSERT INTO "+TABLENAME+" ( k, v1 ) VALUES"+
"(?, ?)", index, ii,
)
- //log.Warnf("Insert index = %d %v", index, time.Since(start))
+ //log.Warnf("insert index = %d %v", index, time.Since(start))
for err != nil && err.Error() == sqlite3.ErrBusy.Error() {
// retry forever
log.Warnf("index = %d retried", index)
@@ -525,7 +525,7 @@ func benchDB(b *testing.B, db *sql.DB, createDB bool) {
if err != nil {
b.Fatal(err)
}
- log.Warnf("Row Count: %v", count)
+ log.Warnf("row Count: %v", count)
b.Run("benchmark SELECT", func(b *testing.B) {
b.ResetTimer()
@@ -540,7 +540,7 @@ func benchDB(b *testing.B, db *sql.DB, createDB bool) {
//log.Debugf("index = %d", index)
//start := time.Now()
row := db.QueryRow("SELECT v1 FROM "+TABLENAME+" WHERE k = ? LIMIT 1", index)
- //log.Warnf("Select index = %d %v", index, time.Since(start))
+ //log.Warnf("select index = %d %v", index, time.Since(start))
var result []byte
err = row.Scan(&result)
if err != nil || (len(result) == 0) {
@@ -570,7 +570,7 @@ func benchDB(b *testing.B, db *sql.DB, createDB bool) {
}
func benchMiner(b *testing.B, minerCount uint16, bypassSign bool) {
- log.Warnf("Benchmark for %d Miners, BypassSignature: %v", minerCount, bypassSign)
+ log.Warnf("benchmark for %d Miners, BypassSignature: %v", minerCount, bypassSign)
asymmetric.BypassSignature = bypassSign
if minerCount > 0 {
startNodesProfile(bypassSign)
@@ -647,7 +647,7 @@ func BenchmarkSQLite(b *testing.B) {
} else {
f.Close()
db, err = sql.Open("sqlite3", millionFile+"?_journal_mode=WAL&_synchronous=NORMAL&cache=shared")
- log.Infof("Testing sqlite3 million data exist file %v", millionFile)
+ log.Infof("testing sqlite3 million data exist file %v", millionFile)
if err != nil {
log.Fatal(err)
}
@@ -661,7 +661,7 @@ func BenchmarkSQLite(b *testing.B) {
}
func benchGNTEMiner(b *testing.B, minerCount uint16, bypassSign bool) {
- log.Warnf("Benchmark GNTE for %d Miners, BypassSignature: %v", minerCount, bypassSign)
+ log.Warnf("benchmark GNTE for %d Miners, BypassSignature: %v", minerCount, bypassSign)
asymmetric.BypassSignature = bypassSign
// Create temp directory
diff --git a/cmd/cql-minerd/main.go b/cmd/cql-minerd/main.go
index ed6c3abb5..6c39744f7 100644
--- a/cmd/cql-minerd/main.go
+++ b/cmd/cql-minerd/main.go
@@ -127,7 +127,7 @@ func main() {
}
flag.Visit(func(f *flag.Flag) {
- log.Infof("Args %#v : %s", f.Name, f.Value)
+ log.Infof("args %#v : %s", f.Name, f.Value)
})
var err error
diff --git a/cmd/cql-mysql-adapter/main.go b/cmd/cql-mysql-adapter/main.go
index ada223bd1..a0322c9ee 100644
--- a/cmd/cql-mysql-adapter/main.go
+++ b/cmd/cql-mysql-adapter/main.go
@@ -63,7 +63,7 @@ func main() {
}
flag.Visit(func(f *flag.Flag) {
- log.Infof("Args %#v : %s", f.Name, f.Value)
+ log.Infof("args %#v : %s", f.Name, f.Value)
})
// init client
diff --git a/cmd/cql-observer/config.go b/cmd/cql-observer/config.go
index 4b68f44c4..f23eecfe8 100644
--- a/cmd/cql-observer/config.go
+++ b/cmd/cql-observer/config.go
@@ -44,11 +44,11 @@ func loadConfig(path string) (config *Config, err error) {
wrapper = &configWrapper{}
)
if content, err = ioutil.ReadFile(path); err != nil {
- log.WithError(err).Error("Failed to read config file")
+ log.WithError(err).Error("failed to read config file")
return
}
if err = yaml.Unmarshal(content, wrapper); err != nil {
- log.WithError(err).Error("Failed to unmarshal config file")
+ log.WithError(err).Error("failed to unmarshal config file")
return
}
config = wrapper.Observer
diff --git a/cmd/cql-observer/main.go b/cmd/cql-observer/main.go
index 4fb15e7be..c21f9875a 100644
--- a/cmd/cql-observer/main.go
+++ b/cmd/cql-observer/main.go
@@ -69,7 +69,7 @@ func main() {
}
flag.Visit(func(f *flag.Flag) {
- log.Infof("Args %#v : %s", f.Name, f.Value)
+ log.Infof("args %#v : %s", f.Name, f.Value)
})
var err error
diff --git a/cmd/cql-observer/service.go b/cmd/cql-observer/service.go
index c9fbe25a9..d489e14dd 100644
--- a/cmd/cql-observer/service.go
+++ b/cmd/cql-observer/service.go
@@ -384,7 +384,7 @@ func (s *Service) addBlock(dbID proto.DatabaseID, count int32, b *types.Block) (
"height": h,
"producer": b.Producer(),
"block": b,
- }).Debugf("Add new block %v -> %v", b.BlockHash(), b.ParentHash())
+ }).Debugf("add new block %v -> %v", b.BlockHash(), b.ParentHash())
if err = s.db.Update(func(tx *bolt.Tx) (err error) {
bb, err := tx.Bucket(blockBucket).CreateBucketIfNotExists([]byte(dbID))
diff --git a/cmd/cql/main.go b/cmd/cql/main.go
index 4a23f6a87..4b335a462 100644
--- a/cmd/cql/main.go
+++ b/cmd/cql/main.go
@@ -293,7 +293,7 @@ func main() {
for name := range available {
bindings = append(bindings, name)
}
- log.Infof("Available drivers are: %#v", bindings)
+ log.Infof("available drivers are: %#v", bindings)
return
}
}
diff --git a/cmd/cqld/adapter.go b/cmd/cqld/adapter.go
index eec701a13..047d3b726 100644
--- a/cmd/cqld/adapter.go
+++ b/cmd/cqld/adapter.go
@@ -275,7 +275,7 @@ func (s *KayakKVServer) SetNode(node *proto.Node) (err error) {
_, _, err = s.Runtime.Apply(context.Background(), payload)
if err != nil {
- log.Errorf("Apply set node failed: %#v\nPayload:\n %#v", err, payload)
+ log.Errorf("apply set node failed: %#v\nPayload:\n %#v", err, payload)
}
return
@@ -340,7 +340,7 @@ func (s *KayakKVServer) SetDatabase(meta types.ServiceInstance) (err error) {
_, _, err = s.Runtime.Apply(context.Background(), payload)
if err != nil {
- log.Errorf("Apply set database failed: %#v\nPayload:\n %#v", err, payload)
+ log.Errorf("apply set database failed: %#v\nPayload:\n %#v", err, payload)
}
return
@@ -363,7 +363,7 @@ func (s *KayakKVServer) DeleteDatabase(dbID proto.DatabaseID) (err error) {
_, _, err = s.Runtime.Apply(context.Background(), payload)
if err != nil {
- log.Errorf("Apply set database failed: %#v\nPayload:\n %#v", err, payload)
+ log.Errorf("apply set database failed: %#v\nPayload:\n %#v", err, payload)
}
return
diff --git a/cmd/cqld/client.go b/cmd/cqld/client.go
index f70b2a411..39a18c47c 100644
--- a/cmd/cqld/client.go
+++ b/cmd/cqld/client.go
@@ -124,7 +124,7 @@ func clientRequest(reqType string, sql string) (err error) {
if client, err = rpc.InitClientConn(conn); err != nil {
return
}
- log.WithField("bp", bp.ID).Debug("Calling BP")
+ log.WithField("bp", bp.ID).Debug("calling BP")
reqType = "FindNeighbor"
req := &proto.FindNeighborReq{
ID: proto.NodeID(flag.Arg(0)),
diff --git a/cmd/cqld/main.go b/cmd/cqld/main.go
index 04d6d401b..e0f3065f7 100644
--- a/cmd/cqld/main.go
+++ b/cmd/cqld/main.go
@@ -103,7 +103,7 @@ func main() {
}
flag.Visit(func(f *flag.Flag) {
- log.Infof("Args %#v : %s", f.Name, f.Value)
+ log.Infof("args %#v : %s", f.Name, f.Value)
})
var err error
diff --git a/cmd/hotfix/observer-upgrade/main.go b/cmd/hotfix/observer-upgrade/main.go
index c650f306d..a0aa0193f 100644
--- a/cmd/hotfix/observer-upgrade/main.go
+++ b/cmd/hotfix/observer-upgrade/main.go
@@ -98,21 +98,21 @@ func process() (err error) {
if dbbk = cur.Bucket().Bucket(k); dbbk == nil {
log.WithFields(log.Fields{
"k": string(k),
- }).Warn("Failed to get bucket")
+ }).Warn("failed to get bucket")
continue
}
// Start processing a new database bucket
log.WithFields(log.Fields{
"database": string(k),
- }).Info("Start processing a new database bucket")
+ }).Info("start processing a new database bucket")
var (
fb bool
bi = make(blockIndex)
)
if err = dbbk.ForEach(func(k, v []byte) (err error) {
if k == nil || v == nil {
- log.Warn("Unexpected nil value of key or value")
+ log.Warn("unexpected nil value of key or value")
return
}
var (
@@ -125,7 +125,7 @@ func process() (err error) {
log.WithFields(log.Fields{
"height": height,
"block": block,
- }).WithError(err).Warn("Failed to decode block data")
+ }).WithError(err).Warn("failed to decode block data")
// Do not return error and keep `ForEach` running
err = nil
return
@@ -145,7 +145,7 @@ func process() (err error) {
log.WithFields(log.Fields{
"height": height,
"block": block,
- }).Warn("Failed to lookup parent node")
+ }).Warn("failed to lookup parent node")
this = &blockNode{
// Temporary set to height for unrecoverable chain
count: height,
@@ -166,7 +166,7 @@ func process() (err error) {
"height": this.height,
"parent": this.block.SignedHeader.ParentHash.String(),
"block": this.block.SignedHeader.BlockHash.String(),
- }).Info("Add new block to index")
+ }).Info("add new block to index")
bi[block.SignedHeader.BlockHash] = this
return
}); err != nil {
@@ -189,7 +189,7 @@ func process() (err error) {
// Start processing a new database bucket
log.WithFields(log.Fields{
"database": dbid,
- }).Info("Start adding count2height index for a new database bucket")
+ }).Info("start adding count2height index for a new database bucket")
if dbbk, err = bk.CreateBucketIfNotExists([]byte(dbid)); err != nil {
return
}
@@ -203,7 +203,7 @@ func process() (err error) {
"height": v.height,
"parent": v.block.SignedHeader.ParentHash.String(),
"block": v.block.SignedHeader.BlockHash.String(),
- }).Info("Add new block count2height index")
+ }).Info("add new block count2height index")
}
}
return
@@ -216,7 +216,7 @@ func process() (err error) {
func main() {
if err := process(); err != nil {
- log.WithError(err).Error("Failed to process data file")
+ log.WithError(err).Error("failed to process data file")
os.Exit(1)
}
}
diff --git a/consistent/consistent.go b/consistent/consistent.go
index 22166a250..a69bdde4b 100644
--- a/consistent/consistent.go
+++ b/consistent/consistent.go
@@ -84,7 +84,7 @@ func InitConsistent(storePath string, persistImpl Persistence, initBP bool) (c *
// Load BlockProducer public key, set it in public key store
// as all kms.BP stuff is initialized on kms init()
if conf.GConf == nil {
- log.Fatal("Must call conf.LoadConfig first")
+ log.Fatal("must call conf.LoadConfig first")
}
BPNodes = conf.GConf.SeedBPNodes
}
diff --git a/crypto/asymmetric/signature_test.go b/crypto/asymmetric/signature_test.go
index 3c2c81052..0eec6af0a 100644
--- a/crypto/asymmetric/signature_test.go
+++ b/crypto/asymmetric/signature_test.go
@@ -159,7 +159,7 @@ func BenchmarkGenKey(b *testing.B) {
b.ResetTimer()
for i := 0; i < b.N; i++ {
if _, _, err := GenSecp256k1KeyPair(); err != nil {
- b.Fatalf("Error occurred: %v", err)
+ b.Fatalf("error occurred: %v", err)
}
}
}
@@ -175,14 +175,14 @@ func BenchmarkGenKeySignVerify(b *testing.B) {
hash := []byte("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
priv, pub, err := GenSecp256k1KeyPair()
if err != nil {
- b.Fatalf("Error occurred: %v", err)
+ b.Fatalf("error occurred: %v", err)
}
sig, err := priv.Sign(hash[:])
if err != nil {
- b.Fatalf("Error occurred: %d, %v", i, err)
+ b.Fatalf("error occurred: %d, %v", i, err)
}
if !sig.Verify(hash[:], pub) {
- b.Fatalf("Error occurred: %d", i)
+ b.Fatalf("error occurred: %d", i)
}
}
}
@@ -211,7 +211,7 @@ func BenchmarkSign(b *testing.B) {
for i := 0; i < b.N; i++ {
_, err := priv.Sign(hash[:])
if err != nil {
- b.Fatalf("Error occurred: %v", err)
+ b.Fatalf("error occurred: %v", err)
}
}
})
@@ -226,7 +226,7 @@ func BenchmarkSign(b *testing.B) {
for i := 0; i < b.N; i++ {
_, err := secp256k1.Sign(hash, privP)
if err != nil {
- b.Fatalf("Error occurred: %v", err)
+ b.Fatalf("error occurred: %v", err)
}
}
})
@@ -297,7 +297,7 @@ func BenchmarkVerify(b *testing.B) {
hash := []byte("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
sig, err := priv.Sign(hash[:])
if err != nil {
- b.Fatalf("Error occurred: %v", err)
+ b.Fatalf("error occurred: %v", err)
}
b.ReportAllocs()
@@ -314,7 +314,7 @@ func BenchmarkVerify(b *testing.B) {
s, err := secp256k1.Sign(hash, privP)
if err != nil {
- b.Fatalf("Error occurred: %v", err)
+ b.Fatalf("error occurred: %v", err)
}
b.ReportAllocs()
@@ -441,7 +441,7 @@ func BenchmarkParsePublicKey(b *testing.B) {
_, err := ParsePubKey(buffer)
if err != nil {
- b.Fatalf("Error occurred: %v", err)
+ b.Fatalf("error occurred: %v", err)
}
}
}
@@ -453,7 +453,7 @@ func BenchmarkSignatureSerialization(b *testing.B) {
sig, err := priv.Sign(hash[:])
if err != nil {
- b.Fatalf("Error occurred: %v", err)
+ b.Fatalf("error occurred: %v", err)
}
b.ReportAllocs()
@@ -471,7 +471,7 @@ func BenchmarkParseSignature(b *testing.B) {
buffer := sig.Serialize()
if err != nil {
- b.Fatalf("Error occurred: %v", err)
+ b.Fatalf("error occurred: %v", err)
}
b.ReportAllocs()
@@ -480,7 +480,7 @@ func BenchmarkParseSignature(b *testing.B) {
_, err := ParseSignature(buffer)
if err != nil {
- b.Fatalf("Error occurred: %v", err)
+ b.Fatalf("error occurred: %v", err)
}
}
}
diff --git a/crypto/cipher_test.go b/crypto/cipher_test.go
index 482627ccb..bcc838c80 100644
--- a/crypto/cipher_test.go
+++ b/crypto/cipher_test.go
@@ -124,7 +124,7 @@ func TestCipheringErrors(t *testing.T) {
for i, test := range tests1 {
_, err = DecryptAndCheck(privkey, test.ciphertext)
if err == nil {
- t.Errorf("Decrypt #%d did not get error", i)
+ t.Errorf("decrypt #%d did not get error", i)
}
}
diff --git a/crypto/etls/conn_test.go b/crypto/etls/conn_test.go
index e9aa09224..4778c12b8 100644
--- a/crypto/etls/conn_test.go
+++ b/crypto/etls/conn_test.go
@@ -35,7 +35,7 @@ type Result struct {
func (f *Foo) Bar(args *string, res *Result) error {
res.Data = len(*args)
log.Printf("Received %q, its length is %d", *args, res.Data)
- //return fmt.Error("Whoops, error happened")
+ //return fmt.Error("whoops, error happened")
return nil
}
@@ -51,7 +51,7 @@ var simpleCipherHandler CipherHandler = func(conn net.Conn) (cryptoConn *CryptoC
func server() *CryptoListener {
if err := rpc.Register(new(Foo)); err != nil {
- log.Error("Failed to register RPC method")
+ log.Error("failed to register RPC method")
}
listener, err := NewCryptoListener("tcp", service, simpleCipherHandler)
@@ -95,7 +95,7 @@ func client(pass string) (ret int, err error) {
res := new(Result)
args := strings.Repeat("a", contentLength)
if err := rpcClient.Call("Foo.Bar", args, &res); err != nil {
- log.Error("Failed to call RPC", err)
+ log.Error("failed to call RPC", err)
return 0, err
}
log.Printf("Returned result is %d", res.Data)
diff --git a/crypto/hash/hash_test.go b/crypto/hash/hash_test.go
index a99d17ccb..72c9e96f1 100644
--- a/crypto/hash/hash_test.go
+++ b/crypto/hash/hash_test.go
@@ -125,7 +125,7 @@ func TestHashString(t *testing.T) {
hashStr := hash.String()
if hashStr != wantStr {
- t.Errorf("String: wrong hash string - got %v, want %v",
+ t.Errorf("string: wrong hash string - got %v, want %v",
hashStr, wantStr)
}
for n := 0; n < 2*HashSize; n++ {
@@ -136,7 +136,7 @@ func TestHashString(t *testing.T) {
expect := string([]byte(wantStr)[:2*l])
actual := hash.Short(n)
if expect != actual {
- t.Errorf("Short result mismatched: expect=%s actual=%s", expect, actual)
+ t.Errorf("short result mismatched: expect=%s actual=%s", expect, actual)
}
}
}
@@ -271,12 +271,12 @@ func TestHash_Difficulty(t *testing.T) {
nilDifficulty := (*Hash)(nil).Difficulty()
if nilDifficulty != -1 {
- t.Errorf("Difficulty test nil expect -1 got %d", nilDifficulty)
+ t.Errorf("difficulty test nil expect -1 got %d", nilDifficulty)
}
newDifficulty := new(Hash).Difficulty()
if newDifficulty != 256 {
- t.Errorf("Difficulty test new(Hash) expect 256 got %d", newDifficulty)
+ t.Errorf("difficulty test new(Hash) expect 256 got %d", newDifficulty)
}
}
diff --git a/crypto/kms/pubkeystore.go b/crypto/kms/pubkeystore.go
index 0c3e15e6f..6cd634666 100644
--- a/crypto/kms/pubkeystore.go
+++ b/crypto/kms/pubkeystore.go
@@ -82,7 +82,7 @@ func init() {
// InitBP initializes kms.BP struct with conf.GConf
func InitBP() {
if conf.GConf == nil {
- log.Fatal("Must call conf.LoadConfig first")
+ log.Fatal("must call conf.LoadConfig first")
}
BP = conf.GConf.BP
diff --git a/metric/covenantmetric_test.go b/metric/covenantmetric_test.go
index 90d8646e2..9f2594e08 100644
--- a/metric/covenantmetric_test.go
+++ b/metric/covenantmetric_test.go
@@ -31,7 +31,7 @@ func TestMetrics(t *testing.T) {
log.SetLevel(log.DebugLevel)
reg := prometheus.NewRegistry()
reg.MustRegister(NewCovenantSQLCollector())
- log.Debug("Gauge Collector 'CovenantSQLCollector' registered.")
+ log.Debug("gauge Collector 'CovenantSQLCollector' registered.")
time.Sleep(1100 * time.Millisecond)
Convey("get metric", t, func() {
diff --git a/metric/diskstats_linux.go b/metric/diskstats_linux.go
index a94d692a4..0d87edaaa 100644
--- a/metric/diskstats_linux.go
+++ b/metric/diskstats_linux.go
@@ -166,7 +166,7 @@ func (c *diskstatsCollector) Update(ch chan<- prometheus.Metric) error {
for dev, stats := range diskStats {
if c.ignoredDevicesPattern.MatchString(dev) {
- log.Debugf("Ignoring device: %s", dev)
+ log.Debugf("ignoring device: %s", dev)
continue
}
diff --git a/metric/filesystem_bsd.go b/metric/filesystem_bsd.go
index 06f62a1f9..5c95fc154 100644
--- a/metric/filesystem_bsd.go
+++ b/metric/filesystem_bsd.go
@@ -50,14 +50,14 @@ func (c *filesystemCollector) GetStats() (stats []filesystemStats, err error) {
for i := 0; i < int(count); i++ {
mountpoint := C.GoString(&mnt[i].f_mntonname[0])
if c.ignoredMountPointsPattern.MatchString(mountpoint) {
- log.Debugf("Ignoring mount point: %s", mountpoint)
+ log.Debugf("ignoring mount point: %s", mountpoint)
continue
}
device := C.GoString(&mnt[i].f_mntfromname[0])
fstype := C.GoString(&mnt[i].f_fstypename[0])
if c.ignoredFSTypesPattern.MatchString(fstype) {
- log.Debugf("Ignoring fs type: %s", fstype)
+ log.Debugf("ignoring fs type: %s", fstype)
continue
}
diff --git a/metric/filesystem_freebsd.go b/metric/filesystem_freebsd.go
index 4f20cbc0e..bda7443a4 100644
--- a/metric/filesystem_freebsd.go
+++ b/metric/filesystem_freebsd.go
@@ -54,14 +54,14 @@ func (c *filesystemCollector) GetStats() ([]filesystemStats, error) {
for _, fs := range buf {
mountpoint := gostring(fs.Mntonname[:])
if c.ignoredMountPointsPattern.MatchString(mountpoint) {
- log.Debugf("Ignoring mount point: %s", mountpoint)
+ log.Debugf("ignoring mount point: %s", mountpoint)
continue
}
device := gostring(fs.Mntfromname[:])
fstype := gostring(fs.Fstypename[:])
if c.ignoredFSTypesPattern.MatchString(fstype) {
- log.Debugf("Ignoring fs type: %s", fstype)
+ log.Debugf("ignoring fs type: %s", fstype)
continue
}
diff --git a/metric/filesystem_linux.go b/metric/filesystem_linux.go
index 849d66307..ecd913edc 100644
--- a/metric/filesystem_linux.go
+++ b/metric/filesystem_linux.go
@@ -39,11 +39,11 @@ func (c *filesystemCollector) GetStats() ([]filesystemStats, error) {
stats := []filesystemStats{}
for _, labels := range mps {
if c.ignoredMountPointsPattern.MatchString(labels.mountPoint) {
- log.Debugf("Ignoring mount point: %s", labels.mountPoint)
+ log.Debugf("ignoring mount point: %s", labels.mountPoint)
continue
}
if c.ignoredFSTypesPattern.MatchString(labels.fsType) {
- log.Debugf("Ignoring fs type: %s", labels.fsType)
+ log.Debugf("ignoring fs type: %s", labels.fsType)
continue
}
@@ -54,7 +54,7 @@ func (c *filesystemCollector) GetStats() ([]filesystemStats, error) {
labels: labels,
deviceError: 1,
})
- log.Debugf("Error on statfs() system call for %q: %s", labels.mountPoint, err)
+ log.Debugf("error on statfs() system call for %q: %s", labels.mountPoint, err)
continue
}
diff --git a/metric/filesystem_linux_test.go b/metric/filesystem_linux_test.go
index e51374311..3ba7fa04d 100644
--- a/metric/filesystem_linux_test.go
+++ b/metric/filesystem_linux_test.go
@@ -64,7 +64,7 @@ func TestMountPointDetails(t *testing.T) {
for _, fs := range filesystems {
if _, ok := expected[fs.mountPoint]; !ok {
- t.Errorf("Got unexpected %s", fs.mountPoint)
+ t.Errorf("got unexpected %s", fs.mountPoint)
}
}
}
diff --git a/metric/meminfo.go b/metric/meminfo.go
index 8865ff16f..7ff720501 100644
--- a/metric/meminfo.go
+++ b/metric/meminfo.go
@@ -48,7 +48,7 @@ func (c *meminfoCollector) Update(ch chan<- prometheus.Metric) error {
if err != nil {
return fmt.Errorf("couldn't get meminfo: %s", err)
}
- log.Debugf("Set node_mem: %#v", memInfo)
+ log.Debugf("set node_mem: %#v", memInfo)
for k, v := range memInfo {
ch <- prometheus.MustNewConstMetric(
prometheus.NewDesc(
diff --git a/metric/meminfo_darwin.go b/metric/meminfo_darwin.go
index b969b49ba..121479495 100644
--- a/metric/meminfo_darwin.go
+++ b/metric/meminfo_darwin.go
@@ -24,7 +24,7 @@ func (c *meminfoCollector) getMemInfo() (map[string]float64, error) {
&infoCount,
)
if ret != C.KERN_SUCCESS {
- return nil, fmt.Errorf("Couldn't get memory statistics, host_statistics returned %d", ret)
+ return nil, fmt.Errorf("couldn't get memory statistics, host_statistics returned %d", ret)
}
totalb, err := unix.Sysctl("hw.memsize")
if err != nil {
diff --git a/metric/metric.go b/metric/metric.go
index 10895dc41..36a55eb29 100644
--- a/metric/metric.go
+++ b/metric/metric.go
@@ -60,7 +60,7 @@ func StartMetricCollector() (registry *prometheus.Registry) {
return nil
}
- log.Info("Enabled collectors:")
+ log.Info("enabled collectors:")
var collectors []string
for n := range nc.Collectors {
collectors = append(collectors, n)
diff --git a/metric/nodemetricmap.go b/metric/nodemetricmap.go
index 5cdd94245..8d8875570 100644
--- a/metric/nodemetricmap.go
+++ b/metric/nodemetricmap.go
@@ -115,7 +115,7 @@ func (mfm *MetricMap) FilterCrucialMetrics() (ret map[string]float64) {
ret[newName] = metricVal
}
}
- log.Debugf("Crucial Metric added: %v", ret)
+ log.Debugf("crucial Metric added: %v", ret)
return
}
diff --git a/metric/nodemetricmap_test.go b/metric/nodemetricmap_test.go
index e8897606b..f8ae9103a 100644
--- a/metric/nodemetricmap_test.go
+++ b/metric/nodemetricmap_test.go
@@ -58,7 +58,7 @@ func TestCollectServer_FilterNode(t *testing.T) {
mm := make(MetricMap, 0)
for _, mf := range mfs {
mm[*mf.Name] = mf
- log.Debugf("Gathered node: %v", mf)
+ log.Debugf("gathered node: %v", mf)
}
nmm := NodeMetricMap{}
nmm.Store(proto.NodeID("node1"), mm)
@@ -82,7 +82,7 @@ func TestCollectServer_FilterNode(t *testing.T) {
mm := make(MetricMap, 0)
for _, mf := range mfs {
mm[*mf.Name] = mf
- log.Debugf("Gathered node: %v", mf)
+ log.Debugf("gathered node: %v", mf)
}
nmm := NodeMetricMap{}
nmm.Store(proto.NodeID("node1"), mm)
diff --git a/metric/rpc.go b/metric/rpc.go
index 57ee7eb2e..94f98da54 100644
--- a/metric/rpc.go
+++ b/metric/rpc.go
@@ -137,7 +137,7 @@ func (cc *CollectClient) UploadMetrics(BPNodeID proto.NodeID) (err error) {
log.Errorf("GatherMetricBytes failed: %s", err)
return
}
- log.Debugf("Calling BP: %s", BPNodeID)
+ log.Debugf("calling BP: %s", BPNodeID)
reqType := MetricServiceName + ".UploadMetrics"
req := &proto.UploadMetricsReq{
MFBytes: mfb,
diff --git a/pow/cpuminer/miner.go b/pow/cpuminer/miner.go
index c8317f5f4..44cd8e615 100644
--- a/pow/cpuminer/miner.go
+++ b/pow/cpuminer/miner.go
@@ -75,11 +75,11 @@ func (miner *CPUMiner) ComputeBlockNonce(
for i := startNonce; ; i.Inc() {
select {
case <-block.Stop:
- log.Info("Stop block nonce job")
+ log.Info("stop block nonce job")
block.NonceChan <- bestNonce
return errors.New("mining job stopped")
case <-miner.quit:
- log.Info("Stop block nonce worker")
+ log.Info("stop block nonce worker")
block.NonceChan <- bestNonce
return errors.New("miner interrupted")
default:
diff --git a/proto/nodeinfo.go b/proto/nodeinfo.go
index d342c24d9..b066b6950 100644
--- a/proto/nodeinfo.go
+++ b/proto/nodeinfo.go
@@ -167,13 +167,13 @@ func (id *NodeID) UnmarshalBinary(keyBytes []byte) (err error) {
func (node *Node) InitNodeCryptoInfo(timeThreshold time.Duration) (err error) {
_, node.PublicKey, err = asymmetric.GenSecp256k1KeyPair()
if err != nil {
- log.Error("Failed to generate key pair")
+ log.Error("failed to generate key pair")
}
nonce := asymmetric.GetPubKeyNonce(node.PublicKey, NewNodeIDDifficulty, timeThreshold, nil)
node.ID = NodeID(nonce.Hash.String())
node.Nonce = nonce.Nonce
- log.Debugf("Node: %#v", node)
+ log.Debugf("node: %#v", node)
return
}
diff --git a/route/bootstrap_test.go b/route/bootstrap_test.go
index 85604af35..4433d6244 100644
--- a/route/bootstrap_test.go
+++ b/route/bootstrap_test.go
@@ -88,7 +88,7 @@ func TestGetBP(t *testing.T) {
dc := NewDNSClient()
ips, err := dc.GetBPFromDNSSeed(BPDomain)
if err != nil {
- t.Fatalf("Error: %v", err)
+ t.Fatalf("error: %v", err)
} else {
log.Debugf("BP addresses: %v", ips)
}
@@ -98,7 +98,7 @@ func TestGetBP(t *testing.T) {
if conf.GConf.DNSSeed.EnforcedDNSSEC && (err == nil || !strings.Contains(err.Error(), "not DNSSEC record")) {
t.Fatal("should be error")
} else {
- log.Debugf("Error: %v", err)
+ log.Debugf("error: %v", err)
}
}
@@ -113,7 +113,7 @@ func TestGetBPEnforced(t *testing.T) {
dc := NewDNSClient()
ips, err := dc.GetBPFromDNSSeed(BPDomain)
if err != nil {
- t.Fatalf("Error: %v", err)
+ t.Fatalf("error: %v", err)
} else {
log.Debugf("BP addresses: %v", ips)
}
@@ -123,6 +123,6 @@ func TestGetBPEnforced(t *testing.T) {
if conf.GConf.DNSSeed.EnforcedDNSSEC && (err == nil || !strings.Contains(err.Error(), "not DNSSEC record")) {
t.Fatal("should be error")
} else {
- log.Debugf("Error: %v", err)
+ log.Debugf("error: %v", err)
}
}
diff --git a/rpc/server.go b/rpc/server.go
index 3a56db669..571203884 100644
--- a/rpc/server.go
+++ b/rpc/server.go
@@ -103,7 +103,7 @@ serverLoop:
for {
select {
case <-s.stopCh:
- log.Info("Stopping Server Loop")
+ log.Info("stopping Server Loop")
break serverLoop
default:
conn, err := s.Listener.Accept()
@@ -138,7 +138,7 @@ sessionLoop:
for {
select {
case <-s.stopCh:
- log.Info("Stopping Session Loop")
+ log.Info("stopping Session Loop")
break sessionLoop
default:
muxConn, err := sess.AcceptStream()
diff --git a/sqlchain/ackindex.go b/sqlchain/ackindex.go
index 8e84d8bf5..1e596db45 100644
--- a/sqlchain/ackindex.go
+++ b/sqlchain/ackindex.go
@@ -45,7 +45,7 @@ type multiAckIndex struct {
func (i *multiAckIndex) addResponse(resp *types.SignedResponseHeader) (err error) {
var key = resp.ResponseHeader.Request.GetQueryKey()
- log.Debugf("Adding key %s <-- resp %s", &key, resp.Hash())
+ log.Debugf("adding key %s <-- resp %s", &key, resp.Hash())
i.Lock()
defer i.Unlock()
if oresp, ok := i.ri[key]; ok {
@@ -66,7 +66,7 @@ func (i *multiAckIndex) register(ack *types.SignedAckHeader) (err error) {
ok bool
key = ack.SignedRequestHeader().GetQueryKey()
)
- log.Debugf("Registering key %s <-- ack %s", &key, ack.Hash())
+ log.Debugf("registering key %s <-- ack %s", &key, ack.Hash())
i.Lock()
defer i.Unlock()
@@ -86,7 +86,7 @@ func (i *multiAckIndex) register(ack *types.SignedAckHeader) (err error) {
func (i *multiAckIndex) remove(ack *types.SignedAckHeader) (err error) {
var key = ack.SignedRequestHeader().GetQueryKey()
- log.Debugf("Removing key %s -x- ack %s", &key, ack.Hash())
+ log.Debugf("removing key %s -x- ack %s", &key, ack.Hash())
i.Lock()
defer i.Unlock()
if _, ok := i.ri[key]; ok {
@@ -130,7 +130,7 @@ func (i *multiAckIndex) expire() {
"response_hash": v.Hash(),
"response_node": v.NodeID,
"response_time": v.Timestamp,
- }).Warn("Query expires without acknowledgement")
+ }).Warn("query expires without acknowledgement")
}
for _, v := range i.qi {
log.WithFields(log.Fields{
@@ -144,7 +144,7 @@ func (i *multiAckIndex) expire() {
"ack_hash": v.ack.Hash(),
"ack_node": v.ack.NodeID,
"ack_time": v.ack.Timestamp,
- }).Warn("Query expires without block producing")
+ }).Warn("query expires without block producing")
}
}
diff --git a/sqlchain/chain.go b/sqlchain/chain.go
index e849a62be..4834e3a6b 100644
--- a/sqlchain/chain.go
+++ b/sqlchain/chain.go
@@ -166,7 +166,7 @@ func NewChainWithContext(ctx context.Context, c *Config) (chain *Chain, err erro
return
}
- log.Debugf("Create new chain bdb %s", bdbFile)
+ log.Debugf("create new chain bdb %s", bdbFile)
// Open LevelDB for ack/request/response
tdbFile := c.ChainFilePrefix + "-ack-req-resp.ldb"
@@ -176,7 +176,7 @@ func NewChainWithContext(ctx context.Context, c *Config) (chain *Chain, err erro
return
}
- log.Debugf("Create new chain tdb %s", tdbFile)
+ log.Debugf("create new chain tdb %s", tdbFile)
// Open x.State
var (
@@ -312,7 +312,7 @@ func LoadChainWithContext(ctx context.Context, c *Config) (chain *Chain, err err
log.WithFields(log.Fields{
"peer": chain.rt.getPeerInfoString(),
"state": st,
- }).Debug("Loading state from database")
+ }).Debug("loading state from database")
// Read blocks and rebuild memory index
var (
@@ -339,7 +339,7 @@ func LoadChainWithContext(ctx context.Context, c *Config) (chain *Chain, err err
log.WithFields(log.Fields{
"peer": chain.rt.getPeerInfoString(),
"block": block.BlockHash().String(),
- }).Debug("Loading block from database")
+ }).Debug("loading block from database")
if last == nil {
if err = block.VerifyAsGenesis(); err != nil {
@@ -397,7 +397,7 @@ func LoadChainWithContext(ctx context.Context, c *Config) (chain *Chain, err err
log.WithFields(log.Fields{
"height": h,
"header": resp.Hash().String(),
- }).Debug("Loaded new resp header")
+ }).Debug("loaded new resp header")
}
if err = respIter.Error(); err != nil {
err = errors.Wrap(err, "load resp")
@@ -418,7 +418,7 @@ func LoadChainWithContext(ctx context.Context, c *Config) (chain *Chain, err err
log.WithFields(log.Fields{
"height": h,
"header": ack.Hash().String(),
- }).Debug("Loaded new ack header")
+ }).Debug("loaded new ack header")
}
if err = respIter.Error(); err != nil {
err = errors.Wrap(err, "load ack")
@@ -477,7 +477,7 @@ func (c *Chain) pushBlock(b *types.Block) (err error) {
"index": i,
"producer": b.Producer(),
"block_hash": b.BlockHash(),
- }).WithError(ierr).Warn("Failed to add response to ackIndex")
+ }).WithError(ierr).Warn("failed to add response to ackIndex")
}
}
for i, v := range b.Acks {
@@ -486,7 +486,7 @@ func (c *Chain) pushBlock(b *types.Block) (err error) {
"index": i,
"producer": b.Producer(),
"block_hash": b.BlockHash(),
- }).WithError(ierr).Warn("Failed to remove Ack from ackIndex")
+ }).WithError(ierr).Warn("failed to remove Ack from ackIndex")
}
}
@@ -508,7 +508,7 @@ func (c *Chain) pushBlock(b *types.Block) (err error) {
return "|"
}(), st.Head.String()[:8]),
"headHeight": c.rt.getHead().Height,
- }).Info("Pushed new block")
+ }).Info("pushed new block")
}
return
@@ -593,7 +593,7 @@ func (c *Chain) produceBlockV2(now time.Time) (err error) {
"curr_turn": c.rt.getNextTurn(),
"using_timestamp": now.Format(time.RFC3339Nano),
"block_hash": block.BlockHash().String(),
- }).Debug("Produced new block")
+ }).Debug("produced new block")
// Advise new block to the other peers
var (
req = &MuxAdviseNewBlockReq{
@@ -632,7 +632,7 @@ func (c *Chain) produceBlockV2(now time.Time) (err error) {
"curr_turn": c.rt.getNextTurn(),
"using_timestamp": now.Format(time.RFC3339Nano),
"block_hash": block.BlockHash().String(),
- }).WithError(err).Error("Failed to advise new block")
+ }).WithError(err).Error("failed to advise new block")
}
}(s)
}
@@ -729,7 +729,7 @@ func (c *Chain) runCurrentTurn(now time.Time) {
"head_height": c.rt.getHead().Height,
"head_block": c.rt.getHead().Head.String(),
"using_timestamp": now.Format(time.RFC3339Nano),
- }).Debug("Run current turn")
+ }).Debug("run current turn")
if c.rt.getHead().Height < c.rt.getNextTurn()-1 {
log.WithFields(log.Fields{
@@ -775,7 +775,7 @@ func (c *Chain) mainCycle(ctx context.Context) {
// "head_block": c.rt.getHead().Head.String(),
// "using_timestamp": t.Format(time.RFC3339Nano),
// "duration": d,
- //}).Debug("Main cycle")
+ //}).Debug("main cycle")
time.Sleep(d)
} else {
c.runCurrentTurn(t)
@@ -789,7 +789,7 @@ func (c *Chain) sync() (err error) {
log.WithFields(log.Fields{
"peer": c.rt.getPeerInfoString(),
"time": c.rt.getChainTimeString(),
- }).Debug("Synchronizing chain state")
+ }).Debug("synchronizing chain state")
for {
now := c.rt.now()
@@ -838,7 +838,7 @@ func (c *Chain) processBlocks(ctx context.Context) {
log.WithFields(log.Fields{
"height": h,
"stashs": len(stash),
- }).Debug("Read new height from channel")
+ }).Debug("read new height from channel")
if stash != nil {
wg.Add(1)
go returnStash(stash)
@@ -854,7 +854,7 @@ func (c *Chain) processBlocks(ctx context.Context) {
"head_block": c.rt.getHead().Head.String(),
"block_height": height,
"block_hash": block.BlockHash().String(),
- }).Debug("Processing new block")
+ }).Debug("processing new block")
if height > c.rt.getNextTurn()-1 {
// Stash newer blocks for later check
@@ -873,7 +873,7 @@ func (c *Chain) processBlocks(ctx context.Context) {
"head_block": c.rt.getHead().Head.String(),
"block_height": height,
"block_hash": block.BlockHash().String(),
- }).WithError(err).Error("Failed to check and push new block")
+ }).WithError(err).Error("failed to check and push new block")
}
}
}
@@ -904,12 +904,12 @@ func (c *Chain) Stop() (err error) {
log.WithFields(log.Fields{
"peer": c.rt.getPeerInfoString(),
"time": c.rt.getChainTimeString(),
- }).Debug("Stopping chain")
+ }).Debug("stopping chain")
c.rt.stop()
log.WithFields(log.Fields{
"peer": c.rt.getPeerInfoString(),
"time": c.rt.getChainTimeString(),
- }).Debug("Chain service and workers stopped")
+ }).Debug("chain service and workers stopped")
// Close LevelDB file
var ierr error
if ierr = c.bdb.Close(); ierr != nil && err == nil {
@@ -918,14 +918,14 @@ func (c *Chain) Stop() (err error) {
log.WithFields(log.Fields{
"peer": c.rt.getPeerInfoString(),
"time": c.rt.getChainTimeString(),
- }).WithError(ierr).Debug("Chain database closed")
+ }).WithError(ierr).Debug("chain database closed")
if ierr = c.tdb.Close(); ierr != nil && err == nil {
err = ierr
}
log.WithFields(log.Fields{
"peer": c.rt.getPeerInfoString(),
"time": c.rt.getChainTimeString(),
- }).WithError(ierr).Debug("Chain database closed")
+ }).WithError(ierr).Debug("chain database closed")
// Close state
if ierr = c.st.Close(false); ierr != nil && err == nil {
err = ierr
@@ -933,7 +933,7 @@ func (c *Chain) Stop() (err error) {
log.WithFields(log.Fields{
"peer": c.rt.getPeerInfoString(),
"time": c.rt.getChainTimeString(),
- }).WithError(ierr).Debug("Chain state storage closed")
+ }).WithError(ierr).Debug("chain state storage closed")
return
}
@@ -982,7 +982,7 @@ func (c *Chain) CheckAndPushNewBlock(block *types.Block) (err error) {
"blockparent": block.ParentHash().String(),
"headblock": head.Head.String(),
"headheight": head.Height,
- }).WithError(err).Debug("Checking new block from other peer")
+ }).WithError(err).Debug("checking new block from other peer")
if head.Height == height && head.Head.IsEqual(block.BlockHash()) {
// Maybe already set by FetchBlock
@@ -1225,7 +1225,7 @@ func (c *Chain) collectBillingSignatures(ctx context.Context, billings *types.Bi
log.WithFields(log.Fields{
"peer": c.rt.getPeerInfoString(),
"time": c.rt.getChainTimeString(),
- }).WithError(err).Error("Failed to send sign billing request")
+ }).WithError(err).Error("failed to send sign billing request")
}
respC <- &resp.SignBillingResp
@@ -1246,7 +1246,7 @@ func (c *Chain) LaunchBilling(low, high int32) (err error) {
"time": c.rt.getChainTimeString(),
"low": low,
"high": high,
- }).WithError(err).Debug("Launched billing process")
+ }).WithError(err).Debug("launched billing process")
if req, err = c.getBilling(low, high); err != nil {
return
@@ -1272,7 +1272,7 @@ func (c *Chain) SignBilling(req *types.BillingRequest) (
"time": c.rt.getChainTimeString(),
"low": req.Header.LowHeight,
"high": req.Header.HighHeight,
- }).WithError(err).Debug("Processing sign billing request")
+ }).WithError(err).Debug("processing sign billing request")
// Verify billing results
if err = req.VerifySignatures(); err != nil {
@@ -1440,7 +1440,7 @@ func (c *Chain) stat() {
"response_header_count": rc,
"query_tracker_count": tc,
"cached_block_count": bc,
- }).Info("Chain mem stats")
+ }).Info("chain mem stats")
// Print xeno stats
c.st.Stat(c.rt.databaseID)
}
diff --git a/sqlchain/chain_test.go b/sqlchain/chain_test.go
index 798854417..72273af51 100644
--- a/sqlchain/chain_test.go
+++ b/sqlchain/chain_test.go
@@ -59,13 +59,13 @@ func TestIndexKey(t *testing.T) {
b1, err := createRandomBlock(genesisHash, false)
if err != nil {
- t.Fatalf("Error occurred: %v", err)
+ t.Fatalf("error occurred: %v", err)
}
b2, err := createRandomBlock(genesisHash, false)
if err != nil {
- t.Fatalf("Error occurred: %v", err)
+ t.Fatalf("error occurred: %v", err)
}
// Test partial order
@@ -75,12 +75,12 @@ func TestIndexKey(t *testing.T) {
k2 := bi2.indexKey()
if c1, c2 := bytes.Compare(k1, k2) < 0, bi1.height < bi2.height; c1 != c2 {
- t.Fatalf("Unexpected compare result: heights=%d,%d keys=%s,%s",
+ t.Fatalf("unexpected compare result: heights=%d,%d keys=%s,%s",
bi1.height, bi2.height, hex.EncodeToString(k1), hex.EncodeToString(k2))
}
if c1, c2 := bytes.Compare(k1, k2) > 0, bi1.height > bi2.height; c1 != c2 {
- t.Fatalf("Unexpected compare result: heights=%d,%d keys=%s,%s",
+ t.Fatalf("unexpected compare result: heights=%d,%d keys=%s,%s",
bi1.height, bi2.height, hex.EncodeToString(k1), hex.EncodeToString(k2))
}
}
@@ -92,20 +92,20 @@ func TestMultiChain(t *testing.T) {
genesis, err := createRandomBlock(genesisHash, true)
if err != nil {
- t.Fatalf("Error occurred: %v", err)
+ t.Fatalf("error occurred: %v", err)
}
gnonce, err := kms.GetNodeInfo(genesis.Producer())
if err != nil {
- t.Fatalf("Error occurred: %v", err)
+ t.Fatalf("error occurred: %v", err)
}
// Create peer list: `testPeersNumber` miners + 1 block producer
nis, peers, err := createTestPeers(testPeersNumber + 1)
if err != nil {
- t.Fatalf("Error occurred: %v", err)
+ t.Fatalf("error occurred: %v", err)
}
for i, p := range peers.Servers {
@@ -149,7 +149,7 @@ func TestMultiChain(t *testing.T) {
server := rpc.NewServer()
if err = server.InitRPCServer("127.0.0.1:0", testPrivKeyFile, testMasterKey); err != nil {
- t.Fatalf("Error occurred: %v", err)
+ t.Fatalf("error occurred: %v", err)
}
go server.Serve()
@@ -159,7 +159,7 @@ func TestMultiChain(t *testing.T) {
mux, err := NewMuxService(route.SQLChainRPCName, server)
if err != nil {
- t.Fatalf("Error occurred: %v", err)
+ t.Fatalf("error occurred: %v", err)
}
// Create chain instance
@@ -178,7 +178,7 @@ func TestMultiChain(t *testing.T) {
chain, err := NewChain(config)
if err != nil {
- t.Fatalf("Error occurred: %v", err)
+ t.Fatalf("error occurred: %v", err)
}
// Set chain parameters
@@ -238,13 +238,13 @@ func TestMultiChain(t *testing.T) {
// Start BP
if dht, err := route.NewDHTService(testDHTStoreFile, new(consistent.KMSStorage), true); err != nil {
- t.Fatalf("Error occurred: %v", err)
+ t.Fatalf("error occurred: %v", err)
} else if err = bpsvr.RegisterService(route.DHTRPCName, dht); err != nil {
- t.Fatalf("Error occurred: %v", err)
+ t.Fatalf("error occurred: %v", err)
}
if err = bpsvr.RegisterService(metric.MetricServiceName, metric.NewCollectServer()); err != nil {
- t.Fatalf("Error occurred: %v", err)
+ t.Fatalf("error occurred: %v", err)
}
for _, n := range conf.GConf.KnownNodes {
@@ -259,7 +259,7 @@ func TestMultiChain(t *testing.T) {
}
if err = kms.SetNode(node); err != nil {
- t.Fatalf("Error occurred: %v", err)
+ t.Fatalf("error occurred: %v", err)
}
if n.ID == conf.GConf.ThisNodeID {
@@ -272,12 +272,12 @@ func TestMultiChain(t *testing.T) {
defer func(p *chainParams) {
if _, err := kms.GetPublicKey(genesis.Producer()); err != nil {
if err = kms.SetPublicKey(genesis.Producer(), gnonce.Nonce, genesis.Signee()); err != nil {
- t.Errorf("Error occurred: %v", err)
+ t.Errorf("error occurred: %v", err)
}
}
if chain, err := NewChain(p.config); err != nil {
- t.Errorf("Error occurred: %v", err)
+ t.Errorf("error occurred: %v", err)
} else {
t.Logf("Load chain from file %s: head = %s height = %d",
p.dbfile, chain.rt.getHead().Head, chain.rt.getHead().Height)
@@ -288,7 +288,7 @@ func TestMultiChain(t *testing.T) {
// Start all chain instances
for _, v := range chains {
if err = v.chain.Start(); err != nil {
- t.Fatalf("Error occurred: %v", err)
+ t.Fatalf("error occurred: %v", err)
}
defer func(c *Chain) {
@@ -330,7 +330,7 @@ func TestMultiChain(t *testing.T) {
cli, err := newRandomNode()
if err != nil {
- t.Fatalf("Error occurred: %v", err)
+ t.Fatalf("error occurred: %v", err)
}
wg.Add(1)
@@ -346,18 +346,18 @@ func TestMultiChain(t *testing.T) {
resp, err := createRandomQueryResponse(p, wk)
if err != nil {
- t.Errorf("Error occurred: %v", err)
+ t.Errorf("error occurred: %v", err)
} else if err = c.addResponse(resp); err != nil {
- t.Errorf("Error occurred: %v", err)
+ t.Errorf("error occurred: %v", err)
}
time.Sleep(time.Duration(rand.Int63n(500)+1) * time.Millisecond)
ack, err := createRandomQueryAckWithResponse(resp, p)
if err != nil {
- t.Errorf("Error occurred: %v", err)
+ t.Errorf("error occurred: %v", err)
} else if err = c.VerifyAndPushAckedQuery(ack); err != nil {
- t.Errorf("Error occurred: %v", err)
+ t.Errorf("error occurred: %v", err)
}
}
}
diff --git a/sqlchain/otypes/block_test.go b/sqlchain/otypes/block_test.go
index a3dfdb1fe..84715bfd9 100644
--- a/sqlchain/otypes/block_test.go
+++ b/sqlchain/otypes/block_test.go
@@ -31,24 +31,24 @@ func TestSignAndVerify(t *testing.T) {
block, err := createRandomBlock(genesisHash, true)
if err != nil {
- t.Fatalf("Error occurred: %v", err)
+ t.Fatalf("error occurred: %v", err)
}
if err = block.Verify(); err != nil {
- t.Fatalf("Error occurred: %v", err)
+ t.Fatalf("error occurred: %v", err)
}
block.SignedHeader.BlockHash[0]++
if err = block.Verify(); err != ErrHashVerification {
- t.Fatalf("Unexpected error: %v", err)
+ t.Fatalf("unexpected error: %v", err)
}
h := &hash.Hash{}
block.PushAckedQuery(h)
if err = block.Verify(); err != ErrMerkleRootVerification {
- t.Fatalf("Unexpected error: %v", err)
+ t.Fatalf("unexpected error: %v", err)
}
}
@@ -56,29 +56,29 @@ func TestHeaderMarshalUnmarshaler(t *testing.T) {
block, err := createRandomBlock(genesisHash, false)
if err != nil {
- t.Fatalf("Error occurred: %v", err)
+ t.Fatalf("error occurred: %v", err)
}
origin := &block.SignedHeader.Header
enc, err := utils.EncodeMsgPack(origin)
if err != nil {
- t.Fatalf("Error occurred: %v", err)
+ t.Fatalf("error occurred: %v", err)
}
dec := &Header{}
if err = utils.DecodeMsgPack(enc.Bytes(), dec); err != nil {
- t.Fatalf("Error occurred: %v", err)
+ t.Fatalf("error occurred: %v", err)
}
bts1, err := origin.MarshalHash()
if err != nil {
- t.Fatalf("Error occurred: %v", err)
+ t.Fatalf("error occurred: %v", err)
}
bts2, err := dec.MarshalHash()
if err != nil {
- t.Fatalf("Error occurred: %v", err)
+ t.Fatalf("error occurred: %v", err)
}
if !bytes.Equal(bts1, bts2) {
@@ -86,7 +86,7 @@ func TestHeaderMarshalUnmarshaler(t *testing.T) {
}
if !reflect.DeepEqual(origin, dec) {
- t.Fatalf("Values don't match:\n\tv1 = %+v\n\tv2 = %+v", origin, dec)
+ t.Fatalf("values don't match:\n\tv1 = %+v\n\tv2 = %+v", origin, dec)
}
}
@@ -94,30 +94,30 @@ func TestSignedHeaderMarshaleUnmarshaler(t *testing.T) {
block, err := createRandomBlock(genesisHash, true)
if err != nil {
- t.Fatalf("Error occurred: %v", err)
+ t.Fatalf("error occurred: %v", err)
}
origin := &block.SignedHeader
enc, err := utils.EncodeMsgPack(origin)
if err != nil {
- t.Fatalf("Error occurred: %v", err)
+ t.Fatalf("error occurred: %v", err)
}
dec := &SignedHeader{}
if err = utils.DecodeMsgPack(enc.Bytes(), dec); err != nil {
- t.Fatalf("Error occurred: %v", err)
+ t.Fatalf("error occurred: %v", err)
}
bts1, err := origin.MarshalHash()
if err != nil {
- t.Fatalf("Error occurred: %v", err)
+ t.Fatalf("error occurred: %v", err)
}
bts2, err := dec.MarshalHash()
if err != nil {
- t.Fatalf("Error occurred: %v", err)
+ t.Fatalf("error occurred: %v", err)
}
if !bytes.Equal(bts1, bts2) {
@@ -125,26 +125,26 @@ func TestSignedHeaderMarshaleUnmarshaler(t *testing.T) {
}
if !reflect.DeepEqual(origin.Header, dec.Header) {
- t.Fatalf("Values don't match:\n\tv1 = %+v\n\tv2 = %+v", origin.Header, dec.Header)
+ t.Fatalf("values don't match:\n\tv1 = %+v\n\tv2 = %+v", origin.Header, dec.Header)
}
if err = origin.Verify(); err != nil {
- t.Fatalf("Error occurred: %v", err)
+ t.Fatalf("error occurred: %v", err)
}
if err = dec.Verify(); err != nil {
- t.Fatalf("Error occurred: %v", err)
+ t.Fatalf("error occurred: %v", err)
}
}
func TestBlockMarshalUnmarshaler(t *testing.T) {
origin, err := createRandomBlock(genesisHash, false)
if err != nil {
- t.Fatalf("Error occurred: %v", err)
+ t.Fatalf("error occurred: %v", err)
}
origin2, err := createRandomBlock(genesisHash, false)
if err != nil {
- t.Fatalf("Error occurred: %v", err)
+ t.Fatalf("error occurred: %v", err)
}
blocks := make(Blocks, 0, 2)
@@ -159,12 +159,12 @@ func TestBlockMarshalUnmarshaler(t *testing.T) {
bts1, err := blocks.MarshalHash()
if err != nil {
- t.Fatalf("Error occurred: %v", err)
+ t.Fatalf("error occurred: %v", err)
}
bts2, err := blocks2.MarshalHash()
if err != nil {
- t.Fatalf("Error occurred: %v", err)
+ t.Fatalf("error occurred: %v", err)
}
if !bytes.Equal(bts1, bts2) {
@@ -174,23 +174,23 @@ func TestBlockMarshalUnmarshaler(t *testing.T) {
enc, err := utils.EncodeMsgPack(origin)
if err != nil {
- t.Fatalf("Error occurred: %v", err)
+ t.Fatalf("error occurred: %v", err)
}
dec := &Block{}
if err = utils.DecodeMsgPack(enc.Bytes(), dec); err != nil {
- t.Fatalf("Error occurred: %v", err)
+ t.Fatalf("error occurred: %v", err)
}
bts1, err = origin.MarshalHash()
if err != nil {
- t.Fatalf("Error occurred: %v", err)
+ t.Fatalf("error occurred: %v", err)
}
bts2, err = dec.MarshalHash()
if err != nil {
- t.Fatalf("Error occurred: %v", err)
+ t.Fatalf("error occurred: %v", err)
}
if !bytes.Equal(bts1, bts2) {
@@ -198,7 +198,7 @@ func TestBlockMarshalUnmarshaler(t *testing.T) {
}
if !reflect.DeepEqual(origin, dec) {
- t.Fatalf("Values don't match:\n\tv1 = %+v\n\tv2 = %+v", origin, dec)
+ t.Fatalf("values don't match:\n\tv1 = %+v\n\tv2 = %+v", origin, dec)
}
}
@@ -206,47 +206,47 @@ func TestGenesis(t *testing.T) {
genesis, err := createRandomBlock(genesisHash, true)
if err != nil {
- t.Fatalf("Error occurred: %v", err)
+ t.Fatalf("error occurred: %v", err)
}
if err = genesis.VerifyAsGenesis(); err != nil {
- t.Fatalf("Error occurred: %v", err)
+ t.Fatalf("error occurred: %v", err)
}
if err = genesis.SignedHeader.VerifyAsGenesis(); err != nil {
- t.Fatalf("Error occurred: %v", err)
+ t.Fatalf("error occurred: %v", err)
}
// Test non-genesis block
genesis, err = createRandomBlock(genesisHash, false)
if err != nil {
- t.Fatalf("Error occurred: %v", err)
+ t.Fatalf("error occurred: %v", err)
}
if err = genesis.VerifyAsGenesis(); err != nil {
t.Logf("Error occurred as expected: %v", err)
} else {
- t.Fatal("Unexpected result: returned nil while expecting an error")
+ t.Fatal("unexpected result: returned nil while expecting an error")
}
if err = genesis.SignedHeader.VerifyAsGenesis(); err != nil {
t.Logf("Error occurred as expected: %v", err)
} else {
- t.Fatal("Unexpected result: returned nil while expecting an error")
+ t.Fatal("unexpected result: returned nil while expecting an error")
}
// Test altered public key block
genesis, err = createRandomBlock(genesisHash, true)
if err != nil {
- t.Fatalf("Error occurred: %v", err)
+ t.Fatalf("error occurred: %v", err)
}
_, pub, err := asymmetric.GenSecp256k1KeyPair()
if err != nil {
- t.Fatalf("Error occurred: %v", err)
+ t.Fatalf("error occurred: %v", err)
}
genesis.SignedHeader.Signee = pub
@@ -254,20 +254,20 @@ func TestGenesis(t *testing.T) {
if err = genesis.VerifyAsGenesis(); err != nil {
t.Logf("Error occurred as expected: %v", err)
} else {
- t.Fatal("Unexpected result: returned nil while expecting an error")
+ t.Fatal("unexpected result: returned nil while expecting an error")
}
if err = genesis.SignedHeader.VerifyAsGenesis(); err != nil {
t.Logf("Error occurred as expected: %v", err)
} else {
- t.Fatal("Unexpected result: returned nil while expecting an error")
+ t.Fatal("unexpected result: returned nil while expecting an error")
}
// Test altered signature
genesis, err = createRandomBlock(genesisHash, true)
if err != nil {
- t.Fatalf("Error occurred: %v", err)
+ t.Fatalf("error occurred: %v", err)
}
genesis.SignedHeader.Signature.R.Add(genesis.SignedHeader.Signature.R, big.NewInt(int64(1)))
@@ -276,12 +276,12 @@ func TestGenesis(t *testing.T) {
if err = genesis.VerifyAsGenesis(); err != nil {
t.Logf("Error occurred as expected: %v", err)
} else {
- t.Fatalf("Unexpected error: %v", err)
+ t.Fatalf("unexpected error: %v", err)
}
if err = genesis.SignedHeader.VerifyAsGenesis(); err != nil {
t.Logf("Error occurred as expected: %v", err)
} else {
- t.Fatal("Unexpected result: returned nil while expecting an error")
+ t.Fatal("unexpected result: returned nil while expecting an error")
}
}
diff --git a/sqlchain/state_test.go b/sqlchain/state_test.go
index 817d92186..622e8bce1 100644
--- a/sqlchain/state_test.go
+++ b/sqlchain/state_test.go
@@ -36,14 +36,14 @@ func TestState(t *testing.T) {
buffer, err := utils.EncodeMsgPack(st)
if err != nil {
- t.Fatalf("Error occurred: %v", err)
+ t.Fatalf("error occurred: %v", err)
}
rState := &state{}
err = utils.DecodeMsgPack(buffer.Bytes(), rState)
if err != nil {
- t.Fatalf("Error occurred: %v", err)
+ t.Fatalf("error occurred: %v", err)
}
//err = rState.UnmarshalBinary(nil)
@@ -51,10 +51,10 @@ func TestState(t *testing.T) {
//if err != nil {
// t.Logf("Error occurred as expected: %v", err)
//} else {
- // t.Fatal("Unexpected result: returned nil while expecting an error")
+ // t.Fatal("unexpected result: returned nil while expecting an error")
//}
if !reflect.DeepEqual(st, rState) {
- t.Fatalf("Values don't match: v1 = %v, v2 = %v", st, rState)
+ t.Fatalf("values don't match: v1 = %v, v2 = %v", st, rState)
}
}
diff --git a/sqlchain/storageproof_test.go b/sqlchain/storageproof_test.go
index 17594bd01..cbcee4fbe 100644
--- a/sqlchain/storageproof_test.go
+++ b/sqlchain/storageproof_test.go
@@ -44,7 +44,7 @@ func TestNewAnswer(t *testing.T) {
answer := NewAnswer("aaa", "bbb", hash.HashH([]byte{1, 2, 3, 4, 5}))
if !reflect.DeepEqual(*answer, wantedAnswer) {
- t.Errorf("The answer is %+v, should be %+v", answer, wantedAnswer)
+ t.Errorf("the answer is %+v, should be %+v", answer, wantedAnswer)
}
}
@@ -61,7 +61,7 @@ func TestGetNextPuzzle(t *testing.T) {
wantedIndex += int32(hash.FNVHash32uint([]byte(previousBlock.ID)))
wantedIndex %= totalRecordsInSQLChain
if index != wantedIndex {
- t.Errorf("The next sql index is %+v, should be %+v. "+
+ t.Errorf("the next sql index is %+v, should be %+v. "+
"Answers are %+v, and the previous block is %+v",
index, wantedIndex, answers, previousBlock)
}
@@ -69,13 +69,13 @@ func TestGetNextPuzzle(t *testing.T) {
// void answer
index, err = getNextPuzzle(voidAnswer, previousBlock)
if err == nil {
- t.Errorf("Index is %d, but should be failed", index)
+ t.Errorf("index is %d, but should be failed", index)
}
// void block
index, err = getNextPuzzle(answers, voidBlock)
if err == nil {
- t.Errorf("Index is %d, but should be failed", index)
+ t.Errorf("index is %d, but should be failed", index)
}
}
@@ -86,31 +86,31 @@ func TestGetNextVerifier(t *testing.T) {
}
wantedVerifier := int32(hash.FNVHash32uint([]byte(previousBlock.ID))) % int32(len(currentBlock.Nodes))
if verifier != wantedVerifier {
- t.Errorf("The next verifier is %d, should be %d", verifier, wantedVerifier)
+ t.Errorf("the next verifier is %d, should be %d", verifier, wantedVerifier)
}
// void previousBlock
verifier, err = getNextVerifier(voidBlock, currentBlock)
if err == nil {
- t.Errorf("Verifier is %d, but should be failed", verifier)
+ t.Errorf("verifier is %d, but should be failed", verifier)
}
// void currentBlock
verifier, err = getNextVerifier(previousBlock, voidBlock)
if err == nil {
- t.Errorf("Verifier is %d, but should be failed", verifier)
+ t.Errorf("verifier is %d, but should be failed", verifier)
}
}
func TestSelectRecord(t *testing.T) {
if strings.Compare(selectRecord(0), "hello world") != 0 {
- t.Error("It should be hello world")
+ t.Error("it should be hello world")
}
}
func TestCheckValid(t *testing.T) {
if !CheckValid(answers) {
- t.Error("It should be true")
+ t.Error("it should be true")
}
}
@@ -127,25 +127,25 @@ func TestGenerateAnswer(t *testing.T) {
answerHash := hash.HashH(append(record, []byte(currentNode.ID)...))
wantedAnswer := NewAnswer(previousBlock.ID, currentNode.ID, answerHash)
if !reflect.DeepEqual(*answer, *wantedAnswer) {
- t.Errorf("Answer is %s, should be %s", *answer, *wantedAnswer)
+ t.Errorf("answer is %s, should be %s", *answer, *wantedAnswer)
}
// void answers
answer, err = GenerateAnswer(voidAnswer, previousBlock, currentNode)
if err == nil {
- t.Errorf("Answer is %+v, should be failed", answer)
+ t.Errorf("answer is %+v, should be failed", answer)
}
// void block
answer, err = GenerateAnswer(answers, voidBlock, currentNode)
if err == nil {
- t.Errorf("Answer is %+v, should be failed", answer)
+ t.Errorf("answer is %+v, should be failed", answer)
}
// void node
answer, err = GenerateAnswer(answers, previousBlock, voidNode)
if err == nil {
- t.Errorf("Answer is %+v, should be failed", answer)
+ t.Errorf("answer is %+v, should be failed", answer)
}
}
diff --git a/storage/dsn_test.go b/storage/dsn_test.go
index 988f6ab3b..ffb919aee 100644
--- a/storage/dsn_test.go
+++ b/storage/dsn_test.go
@@ -32,7 +32,7 @@ func TestDSN(t *testing.T) {
dsn, err := NewDSN(s)
if err != nil {
- t.Errorf("Error occurred: %v", err)
+ t.Errorf("error occurred: %v", err)
continue
}
diff --git a/storage/storage_test.go b/storage/storage_test.go
index 0cda67128..08f096234 100644
--- a/storage/storage_test.go
+++ b/storage/storage_test.go
@@ -56,29 +56,29 @@ func TestBadType(t *testing.T) {
fl, err := ioutil.TempFile("", "sqlite3-")
if err != nil {
- t.Fatalf("Error occurred: %v", err)
+ t.Fatalf("error occurred: %v", err)
}
st, err := New(fmt.Sprintf("file:%s", fl.Name()))
if err != nil {
- t.Fatalf("Error occurred: %v", err)
+ t.Fatalf("error occurred: %v", err)
}
if err = st.Prepare(context.Background(), struct{}{}); err == nil {
- t.Fatal("Unexpected result: returned nil while expecting an error")
+ t.Fatal("unexpected result: returned nil while expecting an error")
} else {
t.Logf("Error occurred as expected: %v", err)
}
if _, err = st.Commit(context.Background(), struct{}{}); err == nil {
- t.Fatal("Unexpected result: returned nil while expecting an error")
+ t.Fatal("unexpected result: returned nil while expecting an error")
} else {
t.Logf("Error occurred as expected: %v", err)
}
if err = st.Rollback(context.Background(), struct{}{}); err == nil {
- t.Fatal("Unexpected result: returned nil while expecting an error")
+ t.Fatal("unexpected result: returned nil while expecting an error")
} else {
t.Logf("Error occurred as expected: %v", err)
}
@@ -88,13 +88,13 @@ func TestStorage(t *testing.T) {
fl, err := ioutil.TempFile("", "sqlite3-")
if err != nil {
- t.Fatalf("Error occurred: %v", err)
+ t.Fatalf("error occurred: %v", err)
}
st, err := New(fmt.Sprintf("file:%s", fl.Name()))
if err != nil {
- t.Fatalf("Error occurred: %v", err)
+ t.Fatalf("error occurred: %v", err)
}
el1 := &ExecLog{
@@ -122,34 +122,34 @@ func TestStorage(t *testing.T) {
}
if err = st.Prepare(context.Background(), el1); err != nil {
- t.Fatalf("Error occurred: %v", err)
+ t.Fatalf("error occurred: %v", err)
}
if err = st.Prepare(context.Background(), el1); err != nil {
- t.Fatalf("Error occurred: %v", err)
+ t.Fatalf("error occurred: %v", err)
}
if err = st.Prepare(context.Background(), el2); err == nil {
- t.Fatal("Unexpected result: returned nil while expecting an error")
+ t.Fatal("unexpected result: returned nil while expecting an error")
} else {
t.Logf("Error occurred as expected: %v", err)
}
if _, err = st.Commit(context.Background(), el2); err == nil {
- t.Fatal("Unexpected result: returned nil while expecting an error")
+ t.Fatal("unexpected result: returned nil while expecting an error")
} else {
t.Logf("Error occurred as expected: %v", err)
}
if err = st.Rollback(context.Background(), el2); err == nil {
- t.Fatal("Unexpected result: returned nil while expecting an error")
+ t.Fatal("unexpected result: returned nil while expecting an error")
} else {
t.Logf("Error occurred as expected: %v", err)
}
var res interface{}
if res, err = st.Commit(context.Background(), el1); err != nil {
- t.Fatalf("Error occurred: %v", err)
+ t.Fatalf("error occurred: %v", err)
} else {
result := res.(ExecResult)
t.Logf("Result: %v", result)
@@ -160,16 +160,16 @@ func TestStorage(t *testing.T) {
[]Query{newQuery("SELECT * FROM `kv` ORDER BY `key` ASC")})
if err != nil {
- t.Fatalf("Query failed: %v", err.Error())
+ t.Fatalf("query failed: %v", err.Error())
}
if !reflect.DeepEqual(columns, []string{"key", "value"}) {
- t.Fatalf("Error column result: %v", columns)
+ t.Fatalf("error column result: %v", columns)
}
if !reflect.DeepEqual(types, []string{"TEXT", "BLOB"}) {
- t.Fatalf("Error types result: %v", types)
+ t.Fatalf("error types result: %v", types)
}
if len(data) != 3 {
- t.Fatalf("Error result count: %v, should be 3", len(data))
+ t.Fatalf("error result count: %v, should be 3", len(data))
} else {
// compare rows
should1 := []interface{}{[]byte("k0"), nil}
@@ -177,13 +177,13 @@ func TestStorage(t *testing.T) {
should3 := []interface{}{[]byte("k3"), []byte("v3-2")}
t.Logf("Rows: %v", data)
if !reflect.DeepEqual(data[0], should1) {
- t.Fatalf("Error result row: %v, should: %v", data[0], should1)
+ t.Fatalf("error result row: %v, should: %v", data[0], should1)
}
if !reflect.DeepEqual(data[1], should2) {
- t.Fatalf("Error result row: %v, should: %v", data[1], should2)
+ t.Fatalf("error result row: %v, should: %v", data[1], should2)
}
if !reflect.DeepEqual(data[2], should3) {
- t.Fatalf("Error result row: %v, should: %v", data[2], should2)
+ t.Fatalf("error result row: %v, should: %v", data[2], should2)
}
}
@@ -192,16 +192,16 @@ func TestStorage(t *testing.T) {
[]Query{newQuery("SELECT `key` FROM `kv` ORDER BY `key` ASC")})
if err != nil {
- t.Fatalf("Query failed: %v", err.Error())
+ t.Fatalf("query failed: %v", err.Error())
}
if !reflect.DeepEqual(columns, []string{"key"}) {
- t.Fatalf("Error column result: %v", columns)
+ t.Fatalf("error column result: %v", columns)
}
if !reflect.DeepEqual(types, []string{"TEXT"}) {
- t.Fatalf("Error types result: %v", types)
+ t.Fatalf("error types result: %v", types)
}
if len(data) != 3 {
- t.Fatalf("Error result count: %v, should be 3", len(data))
+ t.Fatalf("error result count: %v, should be 3", len(data))
} else {
// compare rows
should1 := []interface{}{[]byte("k0")}
@@ -209,13 +209,13 @@ func TestStorage(t *testing.T) {
should3 := []interface{}{[]byte("k3")}
t.Logf("Rows: %v", data)
if !reflect.DeepEqual(data[0], should1) {
- t.Fatalf("Error result row: %v, should: %v", data[0], should1)
+ t.Fatalf("error result row: %v, should: %v", data[0], should1)
}
if !reflect.DeepEqual(data[1], should2) {
- t.Fatalf("Error result row: %v, should: %v", data[1], should2)
+ t.Fatalf("error result row: %v, should: %v", data[1], should2)
}
if !reflect.DeepEqual(data[2], should3) {
- t.Fatalf("Error result row: %v, should: %v", data[2], should2)
+ t.Fatalf("error result row: %v, should: %v", data[2], should2)
}
}
@@ -224,26 +224,26 @@ func TestStorage(t *testing.T) {
[]Query{newQuery("SELECT `key` FROM `kv` WHERE `value` IS NOT NULL ORDER BY `key` ASC")})
if err != nil {
- t.Fatalf("Query failed: %v", err.Error())
+ t.Fatalf("query failed: %v", err.Error())
}
if !reflect.DeepEqual(columns, []string{"key"}) {
- t.Fatalf("Error column result: %v", columns)
+ t.Fatalf("error column result: %v", columns)
}
if !reflect.DeepEqual(types, []string{"TEXT"}) {
- t.Fatalf("Error types result: %v", types)
+ t.Fatalf("error types result: %v", types)
}
if len(data) != 2 {
- t.Fatalf("Error result count: %v, should be 3", len(data))
+ t.Fatalf("error result count: %v, should be 3", len(data))
} else {
// compare rows
should1 := []interface{}{[]byte("k1")}
should2 := []interface{}{[]byte("k3")}
t.Logf("Rows: %v", data)
if !reflect.DeepEqual(data[0], should1) {
- t.Fatalf("Error result row: %v, should: %v", data[0], should1)
+ t.Fatalf("error result row: %v, should: %v", data[0], should1)
}
if !reflect.DeepEqual(data[1], should2) {
- t.Fatalf("Error result row: %v, should: %v", data[1], should2)
+ t.Fatalf("error result row: %v, should: %v", data[1], should2)
}
}
@@ -251,7 +251,7 @@ func TestStorage(t *testing.T) {
columns, types, data, err = st.Query(context.Background(), []Query{newQuery("SQL???? WHAT!!!!")})
if err == nil {
- t.Fatal("Query should failed")
+ t.Fatal("query should failed")
} else {
t.Logf("Query failed as expected with: %v", err.Error())
}
@@ -263,25 +263,25 @@ func TestStorage(t *testing.T) {
execResult, err := st.Exec(context.Background(),
[]Query{newQuery("INSERT OR REPLACE INTO `kv` VALUES ('k4', 'v4')")})
if err != nil || execResult.RowsAffected != 1 {
- t.Fatalf("Exec INSERT failed: %v", err)
+ t.Fatalf("exec INSERT failed: %v", err)
}
// test with arguments
execResult, err = st.Exec(context.Background(), []Query{newQuery("DELETE FROM `kv` WHERE `key`='k4'")})
if err != nil || execResult.RowsAffected != 1 {
- t.Fatalf("Exec DELETE failed: %v", err)
+ t.Fatalf("exec DELETE failed: %v", err)
}
execResult, err = st.Exec(context.Background(),
[]Query{newQuery("DELETE FROM `kv` WHERE `key`=?", "not_exist")})
if err != nil || execResult.RowsAffected != 0 {
- t.Fatalf("Exec DELETE failed: %v", err)
+ t.Fatalf("exec DELETE failed: %v", err)
}
// test again
columns, types, data, err = st.Query(context.Background(), []Query{newQuery("SELECT `key` FROM `kv`")})
if err != nil {
- t.Fatalf("Query failed: %v", err.Error())
+ t.Fatalf("query failed: %v", err.Error())
} else if len(data) != 3 {
- t.Fatalf("Last write query should not take any effect, row count: %v", len(data))
+ t.Fatalf("last write query should not take any effect, row count: %v", len(data))
} else {
t.Logf("Rows: %v", data)
}
@@ -290,9 +290,9 @@ func TestStorage(t *testing.T) {
columns, types, data, err = st.Query(context.Background(),
[]Query{newQuery("SELECT `key` FROM `kv` WHERE `key` IN (?)", "k1")})
if err != nil {
- t.Fatalf("Query failed: %v", err.Error())
+ t.Fatalf("query failed: %v", err.Error())
} else if len(data) != 1 {
- t.Fatalf("Should only have one record, but actually %v", len(data))
+ t.Fatalf("should only have one record, but actually %v", len(data))
} else {
t.Logf("Rows: %v", data)
}
@@ -304,9 +304,9 @@ func TestStorage(t *testing.T) {
"test2": "k3",
})})
if err != nil {
- t.Fatalf("Query failed: %v", err.Error())
+ t.Fatalf("query failed: %v", err.Error())
} else if len(data) != 2 {
- t.Fatalf("Should only have two records, but actually %v", len(data))
+ t.Fatalf("should only have two records, but actually %v", len(data))
} else {
t.Logf("Rows: %v", data)
}
@@ -315,22 +315,22 @@ func TestStorage(t *testing.T) {
columns, types, data, err = st.Query(context.Background(),
[]Query{newQuery("SELECT COUNT(1) AS `c` FROM `kv`")})
if err != nil {
- t.Fatalf("Query failed: %v", err.Error())
+ t.Fatalf("query failed: %v", err.Error())
} else {
if len(columns) != 1 {
- t.Fatalf("Query result should contain only one column, now %v", len(columns))
+ t.Fatalf("query result should contain only one column, now %v", len(columns))
} else if columns[0] != "c" {
- t.Fatalf("Query result column name is not defined alias, but :%v", columns[0])
+ t.Fatalf("query result column name is not defined alias, but :%v", columns[0])
}
if len(types) != 1 {
- t.Fatalf("Query result should contain only one column, now %v", len(types))
+ t.Fatalf("query result should contain only one column, now %v", len(types))
} else {
t.Logf("Query result type is: %v", types[0])
}
if len(data) != 1 || len(data[0]) != 1 {
- t.Fatalf("Query result should contain only one row and one column, now %v", data)
+ t.Fatalf("query result should contain only one row and one column, now %v", data)
} else if !reflect.DeepEqual(data[0][0], int64(3)) {
- t.Fatalf("Query result should be table row count 3, but: %v", data[0])
+ t.Fatalf("query result should be table row count 3, but: %v", data[0])
}
}
@@ -340,14 +340,14 @@ func TestStorage(t *testing.T) {
newQuery("INSERT INTO `tm` VALUES(DATE('NOW'))"),
})
if err != nil {
- t.Fatalf("Query failed: %v", err.Error())
+ t.Fatalf("query failed: %v", err.Error())
} else {
// query for values
_, _, data, err = st.Query(context.Background(), []Query{newQuery("SELECT `tm` FROM `tm`")})
if len(data) != 1 || len(data[0]) != 1 {
- t.Fatalf("Query result should contain only one row and one column, now %v", data)
+ t.Fatalf("query result should contain only one row and one column, now %v", data)
} else if !reflect.TypeOf(data[0][0]).AssignableTo(reflect.TypeOf(time.Time{})) {
- t.Fatalf("Query result should be time.Time type, but: %v", reflect.TypeOf(data[0][0]).String())
+ t.Fatalf("query result should be time.Time type, but: %v", reflect.TypeOf(data[0][0]).String())
}
}
}
diff --git a/twopc/twopc_test.go b/twopc/twopc_test.go
index 9cb6dd0ba..e8e26d5dd 100644
--- a/twopc/twopc_test.go
+++ b/twopc/twopc_test.go
@@ -425,7 +425,7 @@ func TestTwoPhaseCommit(t *testing.T) {
res, err := c.Put(nodes, &RaftWriteBatchReq{TxID: 0, Cmds: []string{"+1", "-3", "+10"}})
if err != nil {
- t.Fatalf("Error occurred: %s", err.Error())
+ t.Fatalf("error occurred: %s", err.Error())
}
if res.(int64) != 8 {
@@ -438,7 +438,7 @@ func TestTwoPhaseCommit(t *testing.T) {
res, err = c.Put(nodes, &RaftWriteBatchReq{TxID: 1, Cmds: []string{"-3", "-4", "+1"}})
if err == nil {
- t.Fatal("Unexpected result: returned nil while expecting an error")
+ t.Fatal("unexpected result: returned nil while expecting an error")
} else {
t.Logf("Error occurred as expected: %s", err.Error())
}
@@ -449,7 +449,7 @@ func TestTwoPhaseCommit(t *testing.T) {
res, err = c.Put(nodes, &RaftWriteBatchReq{TxID: 2, Cmds: []string{"-5", "+9", "+1"}})
if err == nil {
- t.Fatal("Unexpected result: returned nil while expecting an error")
+ t.Fatal("unexpected result: returned nil while expecting an error")
} else {
t.Logf("Error occurred as expected: %s", err.Error())
}
@@ -492,7 +492,7 @@ func TestTwoPhaseCommit_WithHooks(t *testing.T) {
res, err := c.Put(nodes, &RaftWriteBatchReq{TxID: 0, Cmds: []string{"+1", "-3", "+10"}})
if err != nil {
- t.Fatalf("Error occurred: %s", err.Error())
+ t.Fatalf("error occurred: %s", err.Error())
}
if res.(int64) != 8 {
@@ -508,9 +508,9 @@ func TestTwoPhaseCommit_WithHooks(t *testing.T) {
res, err = c.Put(nodes, &RaftWriteBatchReq{TxID: 1, Cmds: []string{"+1", "-3", "+10"}})
if err == nil {
- t.Fatal("Unexpected result: returned nil while expecting an error")
+ t.Fatal("unexpected result: returned nil while expecting an error")
} else if err != beforePrepareError {
- t.Fatal("Unexpected result: beforePrepare error is expected")
+ t.Fatal("unexpected result: beforePrepare error is expected")
} else {
t.Logf("Error occurred as expected: %s", err.Error())
}
@@ -524,9 +524,9 @@ func TestTwoPhaseCommit_WithHooks(t *testing.T) {
res, err = c.Put(nodes, &RaftWriteBatchReq{TxID: 2, Cmds: []string{"+1", "-3", "+10"}})
if err == nil {
- t.Fatal("Unexpected result: returned nil while expecting an error")
+ t.Fatal("unexpected result: returned nil while expecting an error")
} else if err != beforeCommitError {
- t.Fatal("Unexpected result: beforeCommit error is expected")
+ t.Fatal("unexpected result: beforeCommit error is expected")
} else {
t.Logf("Error occurred as expected: %s", err.Error())
}
@@ -540,9 +540,9 @@ func TestTwoPhaseCommit_WithHooks(t *testing.T) {
res, err = c.Put(nodes, &RaftWriteBatchReq{TxID: 3, Cmds: []string{"+1", "-3", "+10"}})
if err == nil {
- t.Fatal("Unexpected result: returned nil while expecting an error")
+ t.Fatal("unexpected result: returned nil while expecting an error")
} else if err != beforeCommitError {
- t.Fatal("Unexpected result: beforeCommit error is expected")
+ t.Fatal("unexpected result: beforeCommit error is expected")
} else {
t.Logf("Error occurred as expected: %s", err.Error())
}
diff --git a/types/billing_test.go b/types/billing_test.go
index 1c3d6e0c2..7fb674003 100644
--- a/types/billing_test.go
+++ b/types/billing_test.go
@@ -28,38 +28,38 @@ import (
func TestBillingHeader_MarshalUnmarshalBinary(t *testing.T) {
tc, err := generateRandomBillingHeader()
if err != nil {
- t.Fatalf("Unexpeted error: %v", err)
+ t.Fatalf("unexpeted error: %v", err)
}
enc, err := utils.EncodeMsgPack(tc)
if err != nil {
- t.Fatalf("Unexpeted error: %v", err)
+ t.Fatalf("unexpeted error: %v", err)
}
dec := &BillingHeader{}
err = utils.DecodeMsgPack(enc.Bytes(), dec)
if err != nil {
- t.Fatalf("Unexpeted error: %v", err)
+ t.Fatalf("unexpeted error: %v", err)
}
if tc.Nonce != dec.Nonce {
- t.Fatalf("Value not match: \n\tv1=%v\n\tv2=%v", tc.Nonce, tc.Nonce)
+ t.Fatalf("value not match: \n\tv1=%v\n\tv2=%v", tc.Nonce, tc.Nonce)
}
if tc.BillingRequest.RequestHash != dec.BillingRequest.RequestHash {
- t.Fatalf("Value not match: \n\tv1=%v\n\tv2=%v", tc.BillingRequest.RequestHash, tc.BillingRequest.RequestHash)
+ t.Fatalf("value not match: \n\tv1=%v\n\tv2=%v", tc.BillingRequest.RequestHash, tc.BillingRequest.RequestHash)
}
if !tc.BillingRequest.Signatures[0].IsEqual(dec.BillingRequest.Signatures[0]) {
- t.Fatalf("Value not match: \n\tv1=%v\n\tv2=%v", tc.BillingRequest.Signatures[0], dec.BillingRequest.Signatures[0])
+ t.Fatalf("value not match: \n\tv1=%v\n\tv2=%v", tc.BillingRequest.Signatures[0], dec.BillingRequest.Signatures[0])
}
for i := range tc.Receivers {
if !reflect.DeepEqual(tc.Receivers[i], dec.Receivers[i]) {
- t.Fatalf("Value not match: \n\ttc.Receivers[%d]=%v\n\tReceive[%d]=%v", i, i, tc.Receivers[i], tc.Receivers[0])
+ t.Fatalf("value not match: \n\ttc.Receivers[%d]=%v\n\tReceive[%d]=%v", i, i, tc.Receivers[i], tc.Receivers[0])
}
if tc.Rewards[i] != dec.Rewards[i] {
- t.Fatalf("Value not match: \n\ttc.Rewards[%d]=%v\n\tRewards[%d]=%v", i, i, tc.Rewards[i], tc.Rewards[0])
+ t.Fatalf("value not match: \n\ttc.Rewards[%d]=%v\n\tRewards[%d]=%v", i, i, tc.Rewards[i], tc.Rewards[0])
}
if tc.Fees[i] != dec.Fees[i] {
- t.Fatalf("Value not match: \n\ttc.Fees[%d]=%v\n\tFees[%d]=%v", i, i, tc.Fees[i], tc.Fees[0])
+ t.Fatalf("value not match: \n\ttc.Fees[%d]=%v\n\tFees[%d]=%v", i, i, tc.Fees[i], tc.Fees[0])
}
}
}
@@ -67,75 +67,75 @@ func TestBillingHeader_MarshalUnmarshalBinary(t *testing.T) {
func TestBilling_SerializeDeserialize(t *testing.T) {
tb, err := generateRandomBilling()
if err != nil {
- t.Fatalf("Unexpeted error: %v", err)
+ t.Fatalf("unexpeted error: %v", err)
}
enc, err := utils.EncodeMsgPack(tb)
if err != nil {
- t.Fatalf("Unexpeted error: %v", err)
+ t.Fatalf("unexpeted error: %v", err)
}
dec := Billing{}
err = utils.DecodeMsgPack(enc.Bytes(), &dec)
if err != nil {
- t.Fatalf("Unexpeted error: %v", err)
+ t.Fatalf("unexpeted error: %v", err)
}
if !tb.Signature.IsEqual(dec.Signature) {
- t.Fatalf("Value not match: \n\tv1=%v\n\tv2=%v", tb.Signature, dec.Signature)
+ t.Fatalf("value not match: \n\tv1=%v\n\tv2=%v", tb.Signature, dec.Signature)
}
if !tb.Signee.IsEqual(dec.Signee) {
- t.Fatalf("Value not match: \n\tv1=%v\n\tv2=%v", tb.Signee, dec.Signee)
+ t.Fatalf("value not match: \n\tv1=%v\n\tv2=%v", tb.Signee, dec.Signee)
}
if tb.Hash() != dec.Hash() {
- t.Fatalf("Value not match: \n\tv1=%v\n\tv2=%v", tb.Hash(), dec.Hash())
+ t.Fatalf("value not match: \n\tv1=%v\n\tv2=%v", tb.Hash(), dec.Hash())
}
}
func TestBilling_PackAndSignTx(t *testing.T) {
tb, err := generateRandomBilling()
if err != nil {
- t.Fatalf("Unexpeted error: %v", err)
+ t.Fatalf("unexpeted error: %v", err)
}
priv, _, err := asymmetric.GenSecp256k1KeyPair()
if err != nil {
- t.Fatalf("Unexpeted error: %v", err)
+ t.Fatalf("unexpeted error: %v", err)
}
tb.Sign(priv)
enc, err := tb.BillingHeader.MarshalHash()
if err != nil {
- t.Fatalf("Unexpeted error: %v", err)
+ t.Fatalf("unexpeted error: %v", err)
}
h := hash.THashH(enc[:])
sign, err := priv.Sign(h[:])
if err != nil {
- t.Fatalf("Unexpeted error: %v", err)
+ t.Fatalf("unexpeted error: %v", err)
}
if !sign.IsEqual(tb.Signature) {
- t.Fatalf("Value not match: \n\tv1=%v\n\tv2=%v", sign, tb.Signature)
+ t.Fatalf("value not match: \n\tv1=%v\n\tv2=%v", sign, tb.Signature)
}
err = tb.Verify()
if err != nil {
- t.Fatalf("Verify signature failed: %v", err)
+ t.Fatalf("verify signature failed: %v", err)
}
// get
addr := hash.Hash(tb.GetAccountAddress())
if addr.IsEqual(&hash.Hash{}) {
- t.Fatal("Get hash failed")
+ t.Fatal("get hash failed")
}
tb.GetAccountNonce()
if tb.GetDatabaseID() == nil {
- t.Fatal("Get nil DatabaseID")
+ t.Fatal("get nil DatabaseID")
}
tb.Signature = nil
err = tb.Verify()
if err == nil {
- t.Fatal("Verify signature should failed")
+ t.Fatal("verify signature should failed")
}
}
diff --git a/types/block.go b/types/block.go
index e66e688e4..27ec40b3b 100644
--- a/types/block.go
+++ b/types/block.go
@@ -65,7 +65,7 @@ func (s *SignedHeader) VerifyAsGenesis() (err error) {
"parent": s.ParentHash.String(),
"merkle": s.MerkleRoot.String(),
"block": s.HSV.Hash().String(),
- }).Debug("Verifying genesis block header")
+ }).Debug("verifying genesis block header")
if pk, err = kms.GetPublicKey(s.Producer); err != nil {
return
}
diff --git a/types/block_test.go b/types/block_test.go
index e028babde..70e42c4ed 100644
--- a/types/block_test.go
+++ b/types/block_test.go
@@ -34,17 +34,17 @@ func TestSignAndVerify(t *testing.T) {
block, err := createRandomBlock(genesisHash, true)
if err != nil {
- t.Fatalf("Error occurred: %v", err)
+ t.Fatalf("error occurred: %v", err)
}
if err = block.Verify(); err != nil {
- t.Fatalf("Error occurred: %v", err)
+ t.Fatalf("error occurred: %v", err)
}
block.SignedHeader.HSV.DataHash[0]++
if err = errors.Cause(block.Verify()); err != verifier.ErrHashValueNotMatch {
- t.Fatalf("Unexpected error: %v", err)
+ t.Fatalf("unexpected error: %v", err)
}
block.Acks = append(block.Acks, &SignedAckHeader{
@@ -54,7 +54,7 @@ func TestSignAndVerify(t *testing.T) {
})
if err = block.Verify(); err != ErrMerkleRootVerification {
- t.Fatalf("Unexpected error: %v", err)
+ t.Fatalf("unexpected error: %v", err)
}
}
@@ -62,29 +62,29 @@ func TestHeaderMarshalUnmarshaler(t *testing.T) {
block, err := createRandomBlock(genesisHash, false)
if err != nil {
- t.Fatalf("Error occurred: %v", err)
+ t.Fatalf("error occurred: %v", err)
}
origin := &block.SignedHeader.Header
enc, err := utils.EncodeMsgPack(origin)
if err != nil {
- t.Fatalf("Error occurred: %v", err)
+ t.Fatalf("error occurred: %v", err)
}
dec := &Header{}
if err = utils.DecodeMsgPack(enc.Bytes(), dec); err != nil {
- t.Fatalf("Error occurred: %v", err)
+ t.Fatalf("error occurred: %v", err)
}
bts1, err := origin.MarshalHash()
if err != nil {
- t.Fatalf("Error occurred: %v", err)
+ t.Fatalf("error occurred: %v", err)
}
bts2, err := dec.MarshalHash()
if err != nil {
- t.Fatalf("Error occurred: %v", err)
+ t.Fatalf("error occurred: %v", err)
}
if !bytes.Equal(bts1, bts2) {
@@ -92,7 +92,7 @@ func TestHeaderMarshalUnmarshaler(t *testing.T) {
}
if !reflect.DeepEqual(origin, dec) {
- t.Fatalf("Values don't match:\n\tv1 = %+v\n\tv2 = %+v", origin, dec)
+ t.Fatalf("values don't match:\n\tv1 = %+v\n\tv2 = %+v", origin, dec)
}
}
@@ -100,30 +100,30 @@ func TestSignedHeaderMarshaleUnmarshaler(t *testing.T) {
block, err := createRandomBlock(genesisHash, true)
if err != nil {
- t.Fatalf("Error occurred: %v", err)
+ t.Fatalf("error occurred: %v", err)
}
origin := &block.SignedHeader
enc, err := utils.EncodeMsgPack(origin)
if err != nil {
- t.Fatalf("Error occurred: %v", err)
+ t.Fatalf("error occurred: %v", err)
}
dec := &SignedHeader{}
if err = utils.DecodeMsgPack(enc.Bytes(), dec); err != nil {
- t.Fatalf("Error occurred: %v", err)
+ t.Fatalf("error occurred: %v", err)
}
bts1, err := origin.MarshalHash()
if err != nil {
- t.Fatalf("Error occurred: %v", err)
+ t.Fatalf("error occurred: %v", err)
}
bts2, err := dec.MarshalHash()
if err != nil {
- t.Fatalf("Error occurred: %v", err)
+ t.Fatalf("error occurred: %v", err)
}
if !bytes.Equal(bts1, bts2) {
@@ -131,26 +131,26 @@ func TestSignedHeaderMarshaleUnmarshaler(t *testing.T) {
}
if !reflect.DeepEqual(origin.Header, dec.Header) {
- t.Fatalf("Values don't match:\n\tv1 = %+v\n\tv2 = %+v", origin.Header, dec.Header)
+ t.Fatalf("values don't match:\n\tv1 = %+v\n\tv2 = %+v", origin.Header, dec.Header)
}
if err = origin.Verify(); err != nil {
- t.Fatalf("Error occurred: %v", err)
+ t.Fatalf("error occurred: %v", err)
}
if err = dec.Verify(); err != nil {
- t.Fatalf("Error occurred: %v", err)
+ t.Fatalf("error occurred: %v", err)
}
}
func TestBlockMarshalUnmarshaler(t *testing.T) {
origin, err := createRandomBlock(genesisHash, false)
if err != nil {
- t.Fatalf("Error occurred: %v", err)
+ t.Fatalf("error occurred: %v", err)
}
origin2, err := createRandomBlock(genesisHash, false)
if err != nil {
- t.Fatalf("Error occurred: %v", err)
+ t.Fatalf("error occurred: %v", err)
}
blocks := make(Blocks, 0, 2)
@@ -165,12 +165,12 @@ func TestBlockMarshalUnmarshaler(t *testing.T) {
bts1, err := blocks.MarshalHash()
if err != nil {
- t.Fatalf("Error occurred: %v", err)
+ t.Fatalf("error occurred: %v", err)
}
bts2, err := blocks2.MarshalHash()
if err != nil {
- t.Fatalf("Error occurred: %v", err)
+ t.Fatalf("error occurred: %v", err)
}
if !bytes.Equal(bts1, bts2) {
@@ -180,23 +180,23 @@ func TestBlockMarshalUnmarshaler(t *testing.T) {
enc, err := utils.EncodeMsgPack(origin)
if err != nil {
- t.Fatalf("Error occurred: %v", err)
+ t.Fatalf("error occurred: %v", err)
}
dec := &Block{}
if err = utils.DecodeMsgPack(enc.Bytes(), dec); err != nil {
- t.Fatalf("Error occurred: %v", err)
+ t.Fatalf("error occurred: %v", err)
}
bts1, err = origin.MarshalHash()
if err != nil {
- t.Fatalf("Error occurred: %v", err)
+ t.Fatalf("error occurred: %v", err)
}
bts2, err = dec.MarshalHash()
if err != nil {
- t.Fatalf("Error occurred: %v", err)
+ t.Fatalf("error occurred: %v", err)
}
if !bytes.Equal(bts1, bts2) {
@@ -204,7 +204,7 @@ func TestBlockMarshalUnmarshaler(t *testing.T) {
}
if !reflect.DeepEqual(origin, dec) {
- t.Fatalf("Values don't match:\n\tv1 = %+v\n\tv2 = %+v", origin, dec)
+ t.Fatalf("values don't match:\n\tv1 = %+v\n\tv2 = %+v", origin, dec)
}
}
@@ -212,47 +212,47 @@ func TestGenesis(t *testing.T) {
genesis, err := createRandomBlock(genesisHash, true)
if err != nil {
- t.Fatalf("Error occurred: %v", err)
+ t.Fatalf("error occurred: %v", err)
}
if err = genesis.VerifyAsGenesis(); err != nil {
- t.Fatalf("Error occurred: %v", err)
+ t.Fatalf("error occurred: %v", err)
}
if err = genesis.SignedHeader.VerifyAsGenesis(); err != nil {
- t.Fatalf("Error occurred: %v", err)
+ t.Fatalf("error occurred: %v", err)
}
// Test non-genesis block
genesis, err = createRandomBlock(genesisHash, false)
if err != nil {
- t.Fatalf("Error occurred: %v", err)
+ t.Fatalf("error occurred: %v", err)
}
if err = genesis.VerifyAsGenesis(); err != nil {
t.Logf("Error occurred as expected: %v", err)
} else {
- t.Fatal("Unexpected result: returned nil while expecting an error")
+ t.Fatal("unexpected result: returned nil while expecting an error")
}
if err = genesis.SignedHeader.VerifyAsGenesis(); err != nil {
t.Logf("Error occurred as expected: %v", err)
} else {
- t.Fatal("Unexpected result: returned nil while expecting an error")
+ t.Fatal("unexpected result: returned nil while expecting an error")
}
// Test altered public key block
genesis, err = createRandomBlock(genesisHash, true)
if err != nil {
- t.Fatalf("Error occurred: %v", err)
+ t.Fatalf("error occurred: %v", err)
}
_, pub, err := asymmetric.GenSecp256k1KeyPair()
if err != nil {
- t.Fatalf("Error occurred: %v", err)
+ t.Fatalf("error occurred: %v", err)
}
genesis.SignedHeader.HSV.Signee = pub
@@ -260,20 +260,20 @@ func TestGenesis(t *testing.T) {
if err = genesis.VerifyAsGenesis(); err != nil {
t.Logf("Error occurred as expected: %v", err)
} else {
- t.Fatal("Unexpected result: returned nil while expecting an error")
+ t.Fatal("unexpected result: returned nil while expecting an error")
}
if err = genesis.SignedHeader.VerifyAsGenesis(); err != nil {
t.Logf("Error occurred as expected: %v", err)
} else {
- t.Fatal("Unexpected result: returned nil while expecting an error")
+ t.Fatal("unexpected result: returned nil while expecting an error")
}
// Test altered signature
genesis, err = createRandomBlock(genesisHash, true)
if err != nil {
- t.Fatalf("Error occurred: %v", err)
+ t.Fatalf("error occurred: %v", err)
}
genesis.SignedHeader.HSV.Signature.R.Add(genesis.SignedHeader.HSV.Signature.R, big.NewInt(int64(1)))
@@ -282,13 +282,13 @@ func TestGenesis(t *testing.T) {
if err = genesis.VerifyAsGenesis(); err != nil {
t.Logf("Error occurred as expected: %v", err)
} else {
- t.Fatalf("Unexpected error: %v", err)
+ t.Fatalf("unexpected error: %v", err)
}
if err = genesis.SignedHeader.VerifyAsGenesis(); err != nil {
t.Logf("Error occurred as expected: %v", err)
} else {
- t.Fatal("Unexpected result: returned nil while expecting an error")
+ t.Fatal("unexpected result: returned nil while expecting an error")
}
}
diff --git a/types/bp_block_test.go b/types/bp_block_test.go
index fb9e8548d..60bf2d793 100644
--- a/types/bp_block_test.go
+++ b/types/bp_block_test.go
@@ -30,22 +30,22 @@ func TestHeader_MarshalUnmarshalBinary(t *testing.T) {
block, err := generateRandomBlock(genesisHash, false)
header := &block.SignedHeader.BPHeader
if err != nil {
- t.Fatalf("Failed to generate block: %v", err)
+ t.Fatalf("failed to generate block: %v", err)
}
enc, err := utils.EncodeMsgPack(header)
if err != nil {
- t.Fatalf("Failed to mashal binary: %v", err)
+ t.Fatalf("failed to mashal binary: %v", err)
}
dec := &BPHeader{}
err = utils.DecodeMsgPack(enc.Bytes(), dec)
if err != nil {
- t.Fatalf("Failed to unmashal binary: %v", err)
+ t.Fatalf("failed to unmashal binary: %v", err)
}
if !reflect.DeepEqual(header, dec) {
- t.Fatalf("Value not math:\n\tv1 = %+v\n\tv2 = %+v", block, dec)
+ t.Fatalf("value not math:\n\tv1 = %+v\n\tv2 = %+v", block, dec)
}
}
@@ -53,22 +53,22 @@ func TestSignedHeader_MarshalUnmashalBinary(t *testing.T) {
block, err := generateRandomBlock(genesisHash, false)
signedHeader := &block.SignedHeader
if err != nil {
- t.Fatalf("Failed to generate block: %v", err)
+ t.Fatalf("failed to generate block: %v", err)
}
enc, err := utils.EncodeMsgPack(signedHeader)
if err != nil {
- t.Fatalf("Failed to mashal binary: %v", err)
+ t.Fatalf("failed to mashal binary: %v", err)
}
dec := &BPSignedHeader{}
err = utils.DecodeMsgPack(enc.Bytes(), dec)
if err != nil {
- t.Fatalf("Failed to unmashal binary: %v", err)
+ t.Fatalf("failed to unmashal binary: %v", err)
}
if !reflect.DeepEqual(signedHeader, dec) {
- t.Fatalf("Value not math:\n\tv1 = %+v\n\tv2 = %+v", signedHeader, dec)
+ t.Fatalf("value not math:\n\tv1 = %+v\n\tv2 = %+v", signedHeader, dec)
}
}
@@ -76,7 +76,7 @@ func TestSignedHeader_MarshalUnmashalBinary(t *testing.T) {
func TestBlock_MarshalUnmarshalBinary(t *testing.T) {
block, err := generateRandomBlock(genesisHash, false)
if err != nil {
- t.Fatalf("Failed to generate block: %v", err)
+ t.Fatalf("failed to generate block: %v", err)
}
h := reflect.TypeOf(block)
_, ok := h.(encoding.BinaryMarshaler)
@@ -86,13 +86,13 @@ func TestBlock_MarshalUnmarshalBinary(t *testing.T) {
enc, err := utils.EncodeMsgPack(block)
if err != nil {
- t.Fatalf("Failed to mashal binary: %v", err)
+ t.Fatalf("failed to mashal binary: %v", err)
}
dec := &BPBlock{}
err = utils.DecodeMsgPack(enc.Bytes(), dec)
if err != nil {
- t.Fatalf("Failed to unmashal binary: %v", err)
+ t.Fatalf("failed to unmashal binary: %v", err)
}
bts1, err := block.MarshalHash()
@@ -111,27 +111,27 @@ func TestBlock_MarshalUnmarshalBinary(t *testing.T) {
func TestBlock_PackAndSignBlock(t *testing.T) {
block, err := generateRandomBlock(genesisHash, false)
if err != nil {
- t.Fatalf("Failed to generate block: %v", err)
+ t.Fatalf("failed to generate block: %v", err)
}
err = block.Verify()
if err != nil {
- t.Fatalf("Failed to verify: %v", err)
+ t.Fatalf("failed to verify: %v", err)
}
block.SignedHeader.BlockHash[0]++
err = block.Verify()
if err != ErrHashVerification {
- t.Fatalf("Unexpected error: %v", err)
+ t.Fatalf("unexpected error: %v", err)
}
tb, err := generateRandomBilling()
if err != nil {
- t.Fatalf("Unexpected error: %v", err)
+ t.Fatalf("unexpected error: %v", err)
}
block.Transactions = append(block.Transactions, tb)
err = block.Verify()
if err != ErrMerkleRootVerification {
- t.Fatalf("Unexpected error: %v", err)
+ t.Fatalf("unexpected error: %v", err)
}
}
diff --git a/types/marshalhash_test.go b/types/marshalhash_test.go
index 85f3d6508..1f3bf6c6d 100644
--- a/types/marshalhash_test.go
+++ b/types/marshalhash_test.go
@@ -53,11 +53,11 @@ func TestMarshalHashAccountStable2(t *testing.T) {
}
enc, err := utils.EncodeMsgPack(&v1)
if err != nil {
- t.Fatalf("Error occurred: %v", err)
+ t.Fatalf("error occurred: %v", err)
}
v2 := Account{}
if err = utils.DecodeMsgPack(enc.Bytes(), &v2); err != nil {
- t.Fatalf("Error occurred: %v", err)
+ t.Fatalf("error occurred: %v", err)
}
bts1, err := v1.MarshalHash()
if err != nil {
diff --git a/utils/big_test.go b/utils/big_test.go
index ff58168cd..40f46a1c6 100644
--- a/utils/big_test.go
+++ b/utils/big_test.go
@@ -74,12 +74,12 @@ func TestBigMax(t *testing.T) {
max1 := BigMax(a, b)
if max1 != a {
- t.Errorf("Expected %d got %d", a, max1)
+ t.Errorf("expected %d got %d", a, max1)
}
max2 := BigMax(b, a)
if max2 != a {
- t.Errorf("Expected %d got %d", a, max2)
+ t.Errorf("expected %d got %d", a, max2)
}
}
@@ -89,12 +89,12 @@ func TestBigMin(t *testing.T) {
min1 := BigMin(a, b)
if min1 != b {
- t.Errorf("Expected %d got %d", b, min1)
+ t.Errorf("expected %d got %d", b, min1)
}
min2 := BigMin(b, a)
if min2 != b {
- t.Errorf("Expected %d got %d", b, min2)
+ t.Errorf("expected %d got %d", b, min2)
}
}
@@ -231,7 +231,7 @@ func TestBigEndianByteAt(t *testing.T) {
v := new(big.Int).SetBytes(b)
actual := bigEndianByteAt(v, test.y)
if actual != test.exp {
- t.Fatalf("Expected [%v] %v:th byte to be %v, was %v.", test.x, test.y, test.exp, actual)
+ t.Fatalf("expected [%v] %v:th byte to be %v, was %v.", test.x, test.y, test.exp, actual)
}
}
@@ -265,7 +265,7 @@ func TestLittleEndianByteAt(t *testing.T) {
v := new(big.Int).SetBytes(b)
actual := Byte(v, 32, test.y)
if actual != test.exp {
- t.Fatalf("Expected [%v] %v:th byte to be %v, was %v.", test.x, test.y, test.exp, actual)
+ t.Fatalf("expected [%v] %v:th byte to be %v, was %v.", test.x, test.y, test.exp, actual)
}
}
@@ -311,7 +311,7 @@ func TestExp(t *testing.T) {
}
for _, test := range tests {
if result := Exp(test.base, test.exponent); result.Cmp(test.result) != 0 {
- t.Errorf("Exp(%d, %d) = %d, want %d", test.base, test.exponent, result, test.result)
+ t.Errorf("exp(%d, %d) = %d, want %d", test.base, test.exponent, result, test.result)
}
}
}
diff --git a/utils/log/logwrapper_test.go b/utils/log/logwrapper_test.go
index 26fbfe485..c52d9eed9 100644
--- a/utils/log/logwrapper_test.go
+++ b/utils/log/logwrapper_test.go
@@ -90,7 +90,7 @@ func call1() {
}
func call2() {
- WithField("k", "v").Error("Error")
+ WithField("k", "v").Error("error")
Error("call2 error")
}
@@ -103,31 +103,31 @@ func TestWithField(t *testing.T) {
call0()
f := new(Fields)
- WithError(errors.New("new")).WithFields(*f).WithTime(time.Now()).Debug("Debug")
+ WithError(errors.New("new")).WithFields(*f).WithTime(time.Now()).Debug("debug")
- WithFields(*f).Debug("Debug")
- WithTime(time.Now()).WithError(errors.New("new")).Debug("Debug")
+ WithFields(*f).Debug("debug")
+ WithTime(time.Now()).WithError(errors.New("new")).Debug("debug")
NewEntry(StandardLogger()).WithTime(time.Now()).String()
- WithField("k", "v").Debug("Debug")
+ WithField("k", "v").Debug("debug")
WithField("k", "v").Debugln("Debugln")
- WithField("k", "v").Debugf("Debugf %d", 1)
+ WithField("k", "v").Debugf("debugf %d", 1)
WithField("k", "v").Print("Print")
WithField("k", "v").Println("Println")
WithField("k", "v").Printf("Printf %d", 1)
- WithField("k", "v").Info("Info")
+ WithField("k", "v").Info("info")
WithField("k", "v").Infoln("Infoln")
- WithField("k", "v").Infof("Infof %d", 1)
+ WithField("k", "v").Infof("infof %d", 1)
WithField("k", "v").Warning("Warning")
WithField("k", "v").Warningln("Warningln")
WithField("k", "v").Warningf("Warningf %d", 1)
- WithField("k", "v").Warn("Warn")
+ WithField("k", "v").Warn("warn")
WithField("k", "v").Warnln("Warnln")
WithField("k", "v").Warnln("Warnln")
- WithField("k", "v").Warnf("Warnf %d", 1)
- WithField("k", "v").Error("Error")
+ WithField("k", "v").Warnf("warnf %d", 1)
+ WithField("k", "v").Error("error")
WithField("k", "v").Errorln("Errorln")
- WithField("k", "v").Errorf("Errorf %d", 1)
+ WithField("k", "v").Errorf("errorf %d", 1)
defer func() {
if r := recover(); r != nil {
fmt.Println("Recovered in f", r)
@@ -146,10 +146,10 @@ func TestWithField(t *testing.T) {
t.Fail()
}
}()
- WithField("k", "v").Panicf("Panicf %d", 1)
+ WithField("k", "v").Panicf("panicf %d", 1)
}()
WithField("k", "v").Panicln("Panicln")
}()
- WithField("k", "v").Panic("Panic")
+ WithField("k", "v").Panic("panic")
}
diff --git a/xenomint/chain_test.go b/xenomint/chain_test.go
index a20fa4fa1..44c0f2609 100644
--- a/xenomint/chain_test.go
+++ b/xenomint/chain_test.go
@@ -37,17 +37,17 @@ func setupBenchmarkChain(b *testing.B) (c *Chain, n int, r []*types.Request) {
stmt *sql.Stmt
)
if c, err = NewChain(fmt.Sprint("file:", fl)); err != nil {
- b.Fatalf("Failed to setup bench environment: %v", err)
+ b.Fatalf("failed to setup bench environment: %v", err)
}
if _, err = c.state.strg.Writer().Exec(
`CREATE TABLE "bench" ("k" INT, "v1" TEXT, "v2" TEXT, "v3" TEXT, PRIMARY KEY("k"))`,
); err != nil {
- b.Fatalf("Failed to setup bench environment: %v", err)
+ b.Fatalf("failed to setup bench environment: %v", err)
}
if stmt, err = c.state.strg.Writer().Prepare(
`INSERT INTO "bench" VALUES (?, ?, ?, ?)`,
); err != nil {
- b.Fatalf("Failed to setup bench environment: %v", err)
+ b.Fatalf("failed to setup bench environment: %v", err)
}
for i := 0; i < benchmarkKeySpace; i++ {
var (
@@ -60,7 +60,7 @@ func setupBenchmarkChain(b *testing.B) (c *Chain, n int, r []*types.Request) {
args[i+1] = string(vals[i][:])
}
if _, err = stmt.Exec(args[:]...); err != nil {
- b.Fatalf("Failed to setup bench environment: %v", err)
+ b.Fatalf("failed to setup bench environment: %v", err)
}
}
n = benchmarkKeySpace
@@ -77,7 +77,7 @@ func setupBenchmarkChain(b *testing.B) (c *Chain, n int, r []*types.Request) {
src = make([][]interface{}, benchmarkKeySpace)
)
if priv, err = kms.GetLocalPrivateKey(); err != nil {
- b.Fatalf("Failed to setup bench environment: %v", err)
+ b.Fatalf("failed to setup bench environment: %v", err)
}
r = make([]*types.Request, 2*benchmarkKeySpace)
// Read query key space [0, n-1]
@@ -86,7 +86,7 @@ func setupBenchmarkChain(b *testing.B) (c *Chain, n int, r []*types.Request) {
buildQuery(sel, i),
})
if err = r[i].Sign(priv); err != nil {
- b.Fatalf("Failed to setup bench environment: %v", err)
+ b.Fatalf("failed to setup bench environment: %v", err)
}
}
// Write query key space [n, 2n-1]
@@ -104,7 +104,7 @@ func setupBenchmarkChain(b *testing.B) (c *Chain, n int, r []*types.Request) {
buildQuery(ins, src[i]...),
})
if err = r[i+benchmarkKeySpace].Sign(priv); err != nil {
- b.Fatalf("Failed to setup bench environment: %v", err)
+ b.Fatalf("failed to setup bench environment: %v", err)
}
}
@@ -120,16 +120,16 @@ func teardownBenchmarkChain(b *testing.B, c *Chain) {
err error
)
if err = c.Stop(); err != nil {
- b.Fatalf("Failed to teardown bench environment: %v", err)
+ b.Fatalf("failed to teardown bench environment: %v", err)
}
if err = os.Remove(fl); err != nil {
- b.Fatalf("Failed to teardown bench environment: %v", err)
+ b.Fatalf("failed to teardown bench environment: %v", err)
}
if err = os.Remove(fmt.Sprint(fl, "-shm")); err != nil && !os.IsNotExist(err) {
- b.Fatalf("Failed to teardown bench environment: %v", err)
+ b.Fatalf("failed to teardown bench environment: %v", err)
}
if err = os.Remove(fmt.Sprint(fl, "-wal")); err != nil && !os.IsNotExist(err) {
- b.Fatalf("Failed to teardown bench environment: %v", err)
+ b.Fatalf("failed to teardown bench environment: %v", err)
}
}
@@ -139,11 +139,11 @@ func BenchmarkChainParallelWrite(b *testing.B) {
var err error
for i := 0; pb.Next(); i++ {
if _, err = c.Query(r[n+rand.Intn(n)]); err != nil {
- b.Fatalf("Failed to execute: %v", err)
+ b.Fatalf("failed to execute: %v", err)
}
if (i+1)%benchmarkQueriesPerBlock == 0 {
if err = c.state.commit(); err != nil {
- b.Fatalf("Failed to commit block: %v", err)
+ b.Fatalf("failed to commit block: %v", err)
}
}
}
@@ -157,11 +157,11 @@ func BenchmarkChainParallelMixRW(b *testing.B) {
var err error
for i := 0; pb.Next(); i++ {
if _, err = c.Query(r[rand.Intn(2*n)]); err != nil {
- b.Fatalf("Failed to execute: %v", err)
+ b.Fatalf("failed to execute: %v", err)
}
if (i+1)%benchmarkQueriesPerBlock == 0 {
if err = c.state.commit(); err != nil {
- b.Fatalf("Failed to commit block: %v", err)
+ b.Fatalf("failed to commit block: %v", err)
}
}
}
diff --git a/xenomint/mux_test.go b/xenomint/mux_test.go
index e4385ac5a..4f89df42f 100644
--- a/xenomint/mux_test.go
+++ b/xenomint/mux_test.go
@@ -52,19 +52,19 @@ func setupBenchmarkMuxParallel(b *testing.B) (
)
// Use testing private key to create several nodes
if priv, err = kms.GetLocalPrivateKey(); err != nil {
- b.Fatalf("Failed to setup bench environment: %v", err)
+ b.Fatalf("failed to setup bench environment: %v", err)
}
if nis, err = createNodesWithPublicKey(priv.PubKey(), testingNonceDifficulty, 3); err != nil {
- b.Fatalf("Failed to setup bench environment: %v", err)
+ b.Fatalf("failed to setup bench environment: %v", err)
} else if l := len(nis); l != 3 {
- b.Fatalf("Failed to setup bench environment: unexpected length %d", l)
+ b.Fatalf("failed to setup bench environment: unexpected length %d", l)
}
// Setup block producer RPC and register server address
bpSv = rpc.NewServer()
if err = bpSv.InitRPCServer(
"localhost:0", testingPrivateKeyFile, testingMasterKey,
); err != nil {
- b.Fatalf("Failed to setup bench environment: %v", err)
+ b.Fatalf("failed to setup bench environment: %v", err)
}
nis[0].Addr = bpSv.Listener.Addr().String()
nis[0].Role = proto.Leader
@@ -73,7 +73,7 @@ func setupBenchmarkMuxParallel(b *testing.B) (
if err = mnSv.InitRPCServer(
"localhost:0", testingPrivateKeyFile, testingMasterKey,
); err != nil {
- b.Fatalf("Failed to setup bench environment: %v", err)
+ b.Fatalf("failed to setup bench environment: %v", err)
}
nis[1].Addr = mnSv.Listener.Addr().String()
nis[1].Role = proto.Miner
@@ -95,9 +95,9 @@ func setupBenchmarkMuxParallel(b *testing.B) (
if dht, err = route.NewDHTService(
testingPublicKeyStoreFile, &con.KMSStorage{}, true,
); err != nil {
- b.Fatalf("Failed to setup bench environment: %v", err)
+ b.Fatalf("failed to setup bench environment: %v", err)
} else if err = bpSv.RegisterService(route.DHTRPCName, dht); err != nil {
- b.Fatalf("Failed to setup bench environment: %v", err)
+ b.Fatalf("failed to setup bench environment: %v", err)
}
kms.SetLocalNodeIDNonce(nis[2].ID.ToRawNodeID().CloneBytes(), &nis[2].Nonce)
for i := range nis {
@@ -106,7 +106,7 @@ func setupBenchmarkMuxParallel(b *testing.B) (
}
// Register mux service
if ms, err = NewMuxService(benchmarkRPCName, mnSv); err != nil {
- b.Fatalf("Failed to setup bench environment: %v", err)
+ b.Fatalf("failed to setup bench environment: %v", err)
}
// Setup query requests
@@ -127,7 +127,7 @@ func setupBenchmarkMuxParallel(b *testing.B) (
buildQuery(sel, i),
})
if err = req.Sign(priv); err != nil {
- b.Fatalf("Failed to setup bench environment: %v", err)
+ b.Fatalf("failed to setup bench environment: %v", err)
}
r[i] = &MuxQueryRequest{
DatabaseID: benchmarkDatabaseID,
@@ -149,7 +149,7 @@ func setupBenchmarkMuxParallel(b *testing.B) (
buildQuery(ins, src[i]...),
})
if err = req.Sign(priv); err != nil {
- b.Fatalf("Failed to setup bench environment: %v", err)
+ b.Fatalf("failed to setup bench environment: %v", err)
}
r[benchmarkKeySpace+i] = &MuxQueryRequest{
DatabaseID: benchmarkDatabaseID,
@@ -186,17 +186,17 @@ func setupSubBenchmarkMuxParallel(b *testing.B, ms *MuxService) (c *Chain) {
stmt *sql.Stmt
)
if c, err = NewChain(fmt.Sprint("file:", fl)); err != nil {
- b.Fatalf("Failed to setup bench environment: %v", err)
+ b.Fatalf("failed to setup bench environment: %v", err)
}
if _, err = c.state.strg.Writer().Exec(
`CREATE TABLE "bench" ("k" INT, "v1" TEXT, "v2" TEXT, "v3" TEXT, PRIMARY KEY("k"))`,
); err != nil {
- b.Fatalf("Failed to setup bench environment: %v", err)
+ b.Fatalf("failed to setup bench environment: %v", err)
}
if stmt, err = c.state.strg.Writer().Prepare(
`INSERT INTO "bench" VALUES (?, ?, ?, ?)`,
); err != nil {
- b.Fatalf("Failed to setup bench environment: %v", err)
+ b.Fatalf("failed to setup bench environment: %v", err)
}
for i := 0; i < benchmarkKeySpace; i++ {
var (
@@ -209,7 +209,7 @@ func setupSubBenchmarkMuxParallel(b *testing.B, ms *MuxService) (c *Chain) {
args[i+1] = string(vals[i][:])
}
if _, err = stmt.Exec(args[:]...); err != nil {
- b.Fatalf("Failed to setup bench environment: %v", err)
+ b.Fatalf("failed to setup bench environment: %v", err)
}
}
ms.register(benchmarkDatabaseID, c)
@@ -228,21 +228,21 @@ func teardownSubBenchmarkMuxParallel(b *testing.B, ms *MuxService) {
)
// Stop RPC server
if c, err = ms.route(benchmarkDatabaseID); err != nil {
- b.Fatalf("Failed to teardown bench environment: %v", err)
+ b.Fatalf("failed to teardown bench environment: %v", err)
}
ms.unregister(benchmarkDatabaseID)
// Close chain
if err = c.Stop(); err != nil {
- b.Fatalf("Failed to teardown bench environment: %v", err)
+ b.Fatalf("failed to teardown bench environment: %v", err)
}
if err = os.Remove(fl); err != nil {
- b.Fatalf("Failed to teardown bench environment: %v", err)
+ b.Fatalf("failed to teardown bench environment: %v", err)
}
if err = os.Remove(fmt.Sprint(fl, "-shm")); err != nil && !os.IsNotExist(err) {
- b.Fatalf("Failed to teardown bench environment: %v", err)
+ b.Fatalf("failed to teardown bench environment: %v", err)
}
if err = os.Remove(fmt.Sprint(fl, "-wal")); err != nil && !os.IsNotExist(err) {
- b.Fatalf("Failed to teardown bench environment: %v", err)
+ b.Fatalf("failed to teardown bench environment: %v", err)
}
}
@@ -275,11 +275,11 @@ func BenchmarkMuxParallel(b *testing.B) {
if err = caller.Call(
method, &r[bm.randkey(benchmarkKeySpace)], &MuxQueryResponse{},
); err != nil {
- b.Fatalf("Failed to execute: %v", err)
+ b.Fatalf("failed to execute: %v", err)
}
if (i+1)%benchmarkQueriesPerBlock == 0 {
if err = c.state.commit(); err != nil {
- b.Fatalf("Failed to commit block: %v", err)
+ b.Fatalf("failed to commit block: %v", err)
}
}
}
diff --git a/xenomint/sqlite/sqlite_test.go b/xenomint/sqlite/sqlite_test.go
index 6288b8f51..1dd9a2334 100644
--- a/xenomint/sqlite/sqlite_test.go
+++ b/xenomint/sqlite/sqlite_test.go
@@ -305,17 +305,17 @@ func setupBenchmarkStorage(b *testing.B) (
stmt *sql.Stmt
)
if st, err = NewSqlite(fmt.Sprint("file:", fl)); err != nil {
- b.Fatalf("Failed to setup bench environment: %v", err)
+ b.Fatalf("failed to setup bench environment: %v", err)
}
if _, err = st.Writer().Exec(
`CREATE TABLE "t2" ("k" INT, "v1" TEXT, "v2" TEXT, "v3" TEXT, PRIMARY KEY("k"))`,
); err != nil {
- b.Fatalf("Failed to setup bench environment: %v", err)
+ b.Fatalf("failed to setup bench environment: %v", err)
}
if stmt, err = st.Writer().Prepare(
`INSERT INTO "t2" VALUES (?, ?, ?, ?)`,
); err != nil {
- b.Fatalf("Failed to setup bench environment: %v", err)
+ b.Fatalf("failed to setup bench environment: %v", err)
}
for i := 0; i < benchmarkKeySubspaceLength; i++ {
var (
@@ -328,7 +328,7 @@ func setupBenchmarkStorage(b *testing.B) (
args[i+1] = string(vals[i][:])
}
if _, err = stmt.Exec(args[:]...); err != nil {
- b.Fatalf("Failed to setup bench environment: %v", err)
+ b.Fatalf("failed to setup bench environment: %v", err)
}
if i%10000 == 0 {
fmt.Printf("Done setup key at %v\n", i)
@@ -377,16 +377,16 @@ func teardownBenchmarkStorage(b *testing.B, st xi.Storage) {
err error
)
if err = st.Close(); err != nil {
- b.Fatalf("Failed to teardown bench environment: %v", err)
+ b.Fatalf("failed to teardown bench environment: %v", err)
}
if err = os.Remove(fl); err != nil {
- b.Fatalf("Failed to teardown bench environment: %v", err)
+ b.Fatalf("failed to teardown bench environment: %v", err)
}
if err = os.Remove(fmt.Sprint(fl, "-shm")); err != nil && !os.IsNotExist(err) {
- b.Fatalf("Failed to teardown bench environment: %v", err)
+ b.Fatalf("failed to teardown bench environment: %v", err)
}
if err = os.Remove(fmt.Sprint(fl, "-wal")); err != nil && !os.IsNotExist(err) {
- b.Fatalf("Failed to teardown bench environment: %v", err)
+ b.Fatalf("failed to teardown bench environment: %v", err)
}
}
@@ -405,7 +405,7 @@ func teardownSubBenchmarkStorage(b *testing.B, st xi.Storage) {
err error
)
if _, err = st.Writer().Exec(d, benchmarkNewKeyOffset); err != nil {
- b.Fatalf("Failed to teardown sub bench environment: %v", err)
+ b.Fatalf("failed to teardown sub bench environment: %v", err)
}
}
@@ -426,45 +426,45 @@ func BenchmarkStorage(b *testing.B) {
read = func(b *testing.B, conn *sql.DB, dest []interface{}) {
var err error
if err = conn.QueryRow(q, rrkg.next()).Scan(dest...); err != nil {
- b.Fatalf("Failed to query values: %v", err)
+ b.Fatalf("failed to query values: %v", err)
}
}
readTx = func(b *testing.B, i int, conn *sql.DB, dest []interface{}) {
var err error
if i%benchmarkQueriesPerTx == 0 {
if tx, err = conn.Begin(); err != nil {
- b.Fatalf("Failed to begin transaction: %v", err)
+ b.Fatalf("failed to begin transaction: %v", err)
}
}
// Query in [n, 2n-1] key space
if err = tx.QueryRow(q, nrkg.next()).Scan(dest...); err != nil && err != sql.ErrNoRows {
- b.Fatalf("Failed to query values: %v", err)
+ b.Fatalf("failed to query values: %v", err)
}
if (i+1)%benchmarkQueriesPerTx == 0 || i == b.N-1 {
if err = tx.Rollback(); err != nil {
- b.Fatalf("Failed to close transaction: %v", err)
+ b.Fatalf("failed to close transaction: %v", err)
}
}
}
write = func(b *testing.B, conn *sql.DB) {
var err error
if _, err = conn.Exec(e, src[ipkg.next()]...); err != nil {
- b.Errorf("Failed to execute: %v", err)
+ b.Errorf("failed to execute: %v", err)
}
}
writeTx = func(b *testing.B, i int, conn *sql.DB) {
var err error
if i%benchmarkQueriesPerTx == 0 {
if tx, err = st.Writer().Begin(); err != nil {
- b.Errorf("Failed to begin transaction: %v", err)
+ b.Errorf("failed to begin transaction: %v", err)
}
}
if _, err = tx.Exec(e, src[ipkg.next()]...); err != nil {
- b.Errorf("Failed to execute: %v", err)
+ b.Errorf("failed to execute: %v", err)
}
if (i+1)%benchmarkQueriesPerTx == 0 || i == b.N-1 {
if err = tx.Commit(); err != nil {
- b.Errorf("Failed to commit transaction: %v", err)
+ b.Errorf("failed to commit transaction: %v", err)
}
}
}
@@ -636,7 +636,7 @@ func BenchmarkStorage(b *testing.B) {
// )
// for i := 0; i < b.N; i++ {
// if err = st.DirtyReader().QueryRow(q, rrkg.next()).Scan(dest...); err != nil {
-// b.Fatalf("Failed to query values: %v", err)
+// b.Fatalf("failed to query values: %v", err)
// }
// }
// teardownBenchmarkStorage(b, st)
@@ -650,7 +650,7 @@ func BenchmarkStorage(b *testing.B) {
// )
// for i := 0; i < b.N; i++ {
// if err = st.Reader().QueryRow(q, rrkg.next()).Scan(dest...); err != nil {
-// b.Fatalf("Failed to query values: %v", err)
+// b.Fatalf("failed to query values: %v", err)
// }
// }
// teardownBenchmarkStorage(b, st)
@@ -666,7 +666,7 @@ func BenchmarkStorage(b *testing.B) {
// b.ResetTimer()
// for i := 0; i < b.N; i++ {
// if _, err = st.Writer().Exec(e, src[ipkg.next()]...); err != nil {
-// b.Errorf("Failed to execute: %v", err)
+// b.Errorf("failed to execute: %v", err)
// }
// }
// })
@@ -682,15 +682,15 @@ func BenchmarkStorage(b *testing.B) {
// for i := 0; i < b.N; i++ {
// if i%benchmarkQueriesPerTx == 0 {
// if tx, err = st.Writer().Begin(); err != nil {
-// b.Errorf("Failed to begin transaction: %v", err)
+// b.Errorf("failed to begin transaction: %v", err)
// }
// }
// if _, err = tx.Exec(e, src[ipkg.next()]...); err != nil {
-// b.Errorf("Failed to execute: %v", err)
+// b.Errorf("failed to execute: %v", err)
// }
// if (i+1)%benchmarkQueriesPerTx == 0 || i == b.N-1 {
// if err = tx.Commit(); err != nil {
-// b.Errorf("Failed to commit transaction: %v", err)
+// b.Errorf("failed to commit transaction: %v", err)
// }
// }
// }
@@ -715,7 +715,7 @@ func busyWrite(
return
default:
if _, err = st.Writer().Exec(e, src[kg.next()]...); err != nil {
- b.Errorf("Failed to execute: %v", err)
+ b.Errorf("failed to execute: %v", err)
}
}
}
@@ -735,7 +735,7 @@ func busyWriteTx(
// Begin
if i%benchmarkQueriesPerTx == 0 {
if tx, err = st.Writer().Begin(); err != nil {
- b.Errorf("Failed to begin transaction: %v", err)
+ b.Errorf("failed to begin transaction: %v", err)
}
}
// Exec
@@ -744,7 +744,7 @@ func busyWriteTx(
// Also commit on exiting
if tx != nil {
if err = tx.Commit(); err != nil {
- b.Errorf("Failed to commit transaction: %v", err)
+ b.Errorf("failed to commit transaction: %v", err)
}
tx = nil
}
@@ -752,13 +752,13 @@ func busyWriteTx(
default:
// Exec
if _, err = tx.Exec(e, src[kg.next()]...); err != nil {
- b.Errorf("Failed to execute: %v", err)
+ b.Errorf("failed to execute: %v", err)
}
}
// Commit
if (i+1)%benchmarkQueriesPerTx == 0 {
if err = tx.Commit(); err != nil {
- b.Errorf("Failed to commit transaction: %v", err)
+ b.Errorf("failed to commit transaction: %v", err)
}
tx = nil
}
@@ -784,7 +784,7 @@ func idleWriteTx(
// Begin
if i%benchmarkQueriesPerTx == 0 {
if tx, err = st.Writer().Begin(); err != nil {
- b.Errorf("Failed to begin transaction: %v", err)
+ b.Errorf("failed to begin transaction: %v", err)
}
}
// Exec
@@ -792,13 +792,13 @@ func idleWriteTx(
case <-ticker.C:
// Exec
if _, err = tx.Exec(e, src[kg.next()]...); err != nil {
- b.Errorf("Failed to execute: %v", err)
+ b.Errorf("failed to execute: %v", err)
}
case <-sc:
// Also commit on exiting
if tx != nil {
if err = tx.Commit(); err != nil {
- b.Errorf("Failed to commit transaction: %v", err)
+ b.Errorf("failed to commit transaction: %v", err)
}
tx = nil
}
@@ -807,7 +807,7 @@ func idleWriteTx(
// Commit
if (i+1)%benchmarkQueriesPerTx == 0 {
if err = tx.Commit(); err != nil {
- b.Errorf("Failed to commit transaction: %v", err)
+ b.Errorf("failed to commit transaction: %v", err)
}
tx = nil
}
@@ -839,7 +839,7 @@ func idleWriteTx(
// if err = getReader(st).QueryRow(
// q, trkg.next(),
// ).Scan(dest...); err != nil && err != sql.ErrNoRows {
-// b.Fatalf("Failed to query values: %v", err)
+// b.Fatalf("failed to query values: %v", err)
// }
// }
//
@@ -893,16 +893,16 @@ func idleWriteTx(
// for i := 0; i < b.N; i++ {
// if i%benchmarkQueriesPerTx == 0 {
// if tx, err = getReader(st).Begin(); err != nil {
-// b.Fatalf("Failed to begin transaction: %v", err)
+// b.Fatalf("failed to begin transaction: %v", err)
// }
// }
// // Query in [n, 2n-1] key space
// if err = tx.QueryRow(q, nrkg.next()).Scan(dest...); err != nil && err != sql.ErrNoRows {
-// b.Fatalf("Failed to query values: %v", err)
+// b.Fatalf("failed to query values: %v", err)
// }
// if (i+1)%benchmarkQueriesPerTx == 0 || i == b.N-1 {
// if err = tx.Rollback(); err != nil {
-// b.Fatalf("Failed to close transaction: %v", err)
+// b.Fatalf("failed to close transaction: %v", err)
// }
// }
// }
@@ -947,11 +947,11 @@ func idleWriteTx(
// for i := 0; i < b.N; i++ {
// if rand.Int()%2 == 0 {
// if err = st.DirtyReader().QueryRow(q, rrkg.next()).Scan(dest...); err != nil {
-// b.Fatalf("Failed to query values: %v", err)
+// b.Fatalf("failed to query values: %v", err)
// }
// } else {
// if _, err = st.Writer().Exec(e, src[ipkg.next()]...); err != nil {
-// b.Fatalf("Failed to execute: %v", err)
+// b.Fatalf("failed to execute: %v", err)
// }
// }
// }
@@ -967,11 +967,11 @@ func idleWriteTx(
// for i := 0; i < b.N; i++ {
// if rand.Int()%2 == 0 {
// if err = st.Reader().QueryRow(q, rrkg.next()).Scan(dest...); err != nil {
-// b.Fatalf("Failed to query values: %v", err)
+// b.Fatalf("failed to query values: %v", err)
// }
// } else {
// if _, err = st.Writer().Exec(e, src[ipkg.next()]...); err != nil {
-// b.Fatalf("Failed to execute: %v", err)
+// b.Fatalf("failed to execute: %v", err)
// }
// }
// }
@@ -989,7 +989,7 @@ func idleWriteTx(
// )
// for pb.Next() {
// if err = st.DirtyReader().QueryRow(q, rrkg.next()).Scan(dest...); err != nil {
-// b.Fatalf("Failed to query values: %v", err)
+// b.Fatalf("failed to query values: %v", err)
// }
// }
// })
@@ -1007,7 +1007,7 @@ func idleWriteTx(
// )
// for pb.Next() {
// if err = st.DirtyReader().QueryRow(q, rrkg.next()).Scan(dest...); err != nil {
-// b.Fatalf("Failed to query values: %v", err)
+// b.Fatalf("failed to query values: %v", err)
// }
// }
// })
@@ -1020,7 +1020,7 @@ func idleWriteTx(
// var err error
// for pb.Next() {
// if _, err = st.Writer().Exec(e, src[ipkg.next()]...); err != nil {
-// b.Fatalf("Failed to execute: %v", err)
+// b.Fatalf("failed to execute: %v", err)
// }
// }
// })
@@ -1037,11 +1037,11 @@ func idleWriteTx(
// for pb.Next() {
// if rand.Int()%2 == 0 {
// if err = st.DirtyReader().QueryRow(q, rrkg.next()).Scan(dest...); err != nil {
-// b.Fatalf("Failed to query values: %v", err)
+// b.Fatalf("failed to query values: %v", err)
// }
// } else {
// if _, err = st.Writer().Exec(e, src[ipkg.next()]...); err != nil {
-// b.Fatalf("Failed to execute: %v", err)
+// b.Fatalf("failed to execute: %v", err)
// }
// }
// }
@@ -1059,11 +1059,11 @@ func idleWriteTx(
// for pb.Next() {
// if rand.Int()%2 == 0 {
// if err = st.Reader().QueryRow(q, rrkg.next()).Scan(dest...); err != nil {
-// b.Fatalf("Failed to query values: %v", err)
+// b.Fatalf("failed to query values: %v", err)
// }
// } else {
// if _, err = st.Writer().Exec(e, src[ipkg.next()]...); err != nil {
-// b.Fatalf("Failed to execute: %v", err)
+// b.Fatalf("failed to execute: %v", err)
// }
// }
// }
diff --git a/xenomint/state.go b/xenomint/state.go
index d6a986d61..cd146260c 100644
--- a/xenomint/state.go
+++ b/xenomint/state.go
@@ -699,5 +699,5 @@ func (s *State) Stat(id proto.DatabaseID) {
"database_id": id,
"pooled_fail_request_count": fc,
"pooled_query_tracker": tc,
- }).Info("Xeno pool stats")
+ }).Info("xeno pool stats")
}
From ed5918043144c09366bbafb7f7e23ebe98288060 Mon Sep 17 00:00:00 2001
From: leventeliu
Date: Tue, 18 Dec 2018 21:54:28 +0800
Subject: [PATCH 089/278] Add column names in insert statement
---
blockproducer/storage.go | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)
diff --git a/blockproducer/storage.go b/blockproducer/storage.go
index 3ec95f7c3..b5b9775da 100644
--- a/blockproducer/storage.go
+++ b/blockproducer/storage.go
@@ -129,7 +129,8 @@ func addBlock(height uint32, b *types.BPBlock) storageProcedure {
return errPass(err)
}
return func(tx *sql.Tx) (err error) {
- _, err = tx.Exec(`INSERT OR REPLACE INTO "blocks" VALUES (?, ?, ?, ?)`,
+ _, err = tx.Exec(`INSERT OR REPLACE INTO "blocks" ("height", "hash", "parent", "encoded")
+ VALUES (?, ?, ?, ?)`,
height,
b.BlockHash().String(),
b.ParentHash().String(),
@@ -147,7 +148,8 @@ func addTx(t pi.Transaction) storageProcedure {
return errPass(err)
}
return func(tx *sql.Tx) (err error) {
- _, err = tx.Exec(`INSERT OR REPLACE INTO "txPool" VALUES (?, ?, ?)`,
+ _, err = tx.Exec(`INSERT OR REPLACE INTO "txPool" ("type", "hash", "encoded")
+ VALUES (?, ?, ?)`,
uint32(t.GetTransactionType()),
t.Hash().String(),
enc.Bytes())
@@ -157,7 +159,8 @@ func addTx(t pi.Transaction) storageProcedure {
func updateIrreversible(h hash.Hash) storageProcedure {
return func(tx *sql.Tx) (err error) {
- _, err = tx.Exec(`INSERT OR REPLACE INTO "irreversible" VALUES (?, ?)`, 0, h.String())
+ _, err = tx.Exec(`INSERT OR REPLACE INTO "irreversible" ("id", "hash")
+ VALUES (?, ?)`, 0, h.String())
return
}
}
@@ -191,7 +194,8 @@ func updateAccount(account *types.Account) storageProcedure {
return errPass(err)
}
return func(tx *sql.Tx) (err error) {
- _, err = tx.Exec(`INSERT OR REPLACE INTO "accounts" VALUES (?, ?)`,
+ _, err = tx.Exec(`INSERT OR REPLACE INTO "accounts" ("address", "encoded")
+ VALUES (?, ?)`,
account.Address.String(),
enc.Bytes())
return
@@ -214,7 +218,8 @@ func updateShardChain(profile *types.SQLChainProfile) storageProcedure {
return errPass(err)
}
return func(tx *sql.Tx) (err error) {
- _, err = tx.Exec(`INSERT OR REPLACE INTO "shardChain" VALUES (?, ?, ?)`,
+ _, err = tx.Exec(`INSERT OR REPLACE INTO "shardChain" ("address", "id", "encoded")
+ VALUES (?, ?, ?)`,
profile.Address.String(),
string(profile.ID),
enc.Bytes())
@@ -238,7 +243,7 @@ func updateProvider(profile *types.ProviderProfile) storageProcedure {
return errPass(err)
}
return func(tx *sql.Tx) (err error) {
- _, err = tx.Exec(`INSERT OR REPLACE INTO "provider" VALUES (?, ?)`,
+ _, err = tx.Exec(`INSERT OR REPLACE INTO "provider" ("address", "encoded") VALUES (?, ?)`,
profile.Provider.String(),
enc.Bytes())
return
From bb1f3f61fc42b1d56c4105aefc90ba2392dfbd6b Mon Sep 17 00:00:00 2001
From: leventeliu
Date: Tue, 18 Dec 2018 21:58:32 +0800
Subject: [PATCH 090/278] Fix typo
---
blockproducer/chain.go | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/blockproducer/chain.go b/blockproducer/chain.go
index 8dba8a454..4313e73ab 100644
--- a/blockproducer/chain.go
+++ b/blockproducer/chain.go
@@ -79,7 +79,7 @@ type Chain struct {
sync.RWMutex // protects following fields
peers *proto.Peers
nodeID proto.NodeID
- comfirms uint32
+ confirms uint32
serversNum uint32
locSvIndex uint32
nextHeight uint32
@@ -250,7 +250,7 @@ func NewChainWithContext(ctx context.Context, cfg *Config) (c *Chain, err error)
peers: cfg.Peers,
nodeID: cfg.NodeID,
- comfirms: uint32(m),
+ confirms: uint32(m),
serversNum: uint32(len(cfg.Peers.Servers)),
locSvIndex: uint32(locSvIndex),
nextHeight: head.head.height + 1,
@@ -685,7 +685,7 @@ func (c *Chain) switchBranch(bl *types.BPBlock, origin int, head *branch) (err e
// NOTE(leventeliu):
// May have multiple new irreversible blocks here if peer list shrinks. May also have
// no new irreversible block at all if peer list expands.
- irre = head.head.lastIrreversible(c.comfirms)
+ irre = head.head.lastIrreversible(c.confirms)
newIrres = irre.fetchNodeList(c.lastIrre.count)
// Apply irreversible blocks to create dirty map on immutable cache
From b7672e75a51ff51b80c9df43c4a002b68e74c04b Mon Sep 17 00:00:00 2001
From: leventeliu
Date: Tue, 18 Dec 2018 22:23:11 +0800
Subject: [PATCH 091/278] Set testing log level
---
blockproducer/xxx_test.go | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/blockproducer/xxx_test.go b/blockproducer/xxx_test.go
index 26cca2a71..2b5d919e1 100644
--- a/blockproducer/xxx_test.go
+++ b/blockproducer/xxx_test.go
@@ -495,7 +495,7 @@ func setup() {
// Setup logging
log.SetOutput(os.Stdout)
- log.SetLevel(log.DebugLevel)
+ log.SetLevel(log.FatalLevel)
}
func teardown() {
From 231555cbc839c4af4f4fdc4cbbd31ff759f1f67f Mon Sep 17 00:00:00 2001
From: leventeliu
Date: Tue, 18 Dec 2018 22:26:16 +0800
Subject: [PATCH 092/278] Remove transaction pool codes
---
blockproducer/txpool.go | 130 -----------------------------------
blockproducer/txpool_test.go | 17 -----
2 files changed, 147 deletions(-)
delete mode 100644 blockproducer/txpool.go
delete mode 100644 blockproducer/txpool_test.go
diff --git a/blockproducer/txpool.go b/blockproducer/txpool.go
deleted file mode 100644
index 41b714ae7..000000000
--- a/blockproducer/txpool.go
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Copyright 2018 The CovenantSQL Authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package blockproducer
-
-import (
- pi "github.com/CovenantSQL/CovenantSQL/blockproducer/interfaces"
- "github.com/CovenantSQL/CovenantSQL/proto"
- "github.com/CovenantSQL/CovenantSQL/utils/log"
-)
-
-type accountTxEntries struct {
- account proto.AccountAddress
- baseNonce pi.AccountNonce
- transactions []pi.Transaction
-}
-
-func newAccountTxEntries(
- addr proto.AccountAddress, baseNonce pi.AccountNonce) (_ *accountTxEntries,
-) {
- return &accountTxEntries{
- account: addr,
- baseNonce: baseNonce,
- transactions: nil,
- }
-}
-
-func (e *accountTxEntries) nextNonce() pi.AccountNonce {
- return e.baseNonce + pi.AccountNonce(len(e.transactions))
-}
-
-func (e *accountTxEntries) addTx(tx pi.Transaction) {
- e.transactions = append(e.transactions, tx)
-}
-
-func (e *accountTxEntries) halfDeepCopy() (cpy *accountTxEntries) {
- return &accountTxEntries{
- account: e.account,
- baseNonce: e.baseNonce,
- transactions: e.transactions[:],
- }
-}
-
-type txPool struct {
- entries map[proto.AccountAddress]*accountTxEntries
-}
-
-func newTxPool() *txPool {
- return &txPool{
- entries: make(map[proto.AccountAddress]*accountTxEntries),
- }
-}
-
-func (p *txPool) addTx(tx pi.Transaction, baseNonce pi.AccountNonce) {
- addr := tx.GetAccountAddress()
- e, ok := p.entries[addr]
- if !ok {
- e = newAccountTxEntries(addr, baseNonce)
- p.entries[addr] = e
- }
- e.addTx(tx)
-}
-
-func (p *txPool) getTxEntries(addr proto.AccountAddress) (e *accountTxEntries, ok bool) {
- e, ok = p.entries[addr]
- return
-}
-
-func (p *txPool) hasTx(tx pi.Transaction) (ok bool) {
- var te *accountTxEntries
- if te, ok = p.entries[tx.GetAccountAddress()]; !ok {
- return
- }
- // Out of range
- var (
- nonce = tx.GetAccountNonce()
- index = int(nonce - te.baseNonce)
- )
- if ok = (nonce >= te.baseNonce && index < len(te.transactions)); !ok {
- log.Debug("transaction nonce or index already exists")
- return
- }
- // Check transaction hash
- if ok = (tx.Hash() == te.transactions[index].Hash()); !ok {
- log.Debug("transaction hash already exists")
- return
- }
-
- return
-}
-
-func (p *txPool) cmpAndMoveNextTx(tx pi.Transaction) (ok bool) {
- var te *accountTxEntries
- if te, ok = p.entries[tx.GetAccountAddress()]; !ok {
- return
- }
- // Out of range
- if ok = (tx.GetAccountNonce() == te.baseNonce && len(te.transactions) > 0); !ok {
- return
- }
- // Check transaction hash
- if ok = (tx.Hash() == te.transactions[0].Hash()); !ok {
- return
- }
- // Move forward
- te.transactions = te.transactions[1:]
- te.baseNonce++
- return
-}
-
-func (p *txPool) halfDeepCopy() (cpy *txPool) {
- cpy = newTxPool()
- for k, v := range p.entries {
- cpy.entries[k] = v.halfDeepCopy()
- }
- return
-}
diff --git a/blockproducer/txpool_test.go b/blockproducer/txpool_test.go
deleted file mode 100644
index 2423efab2..000000000
--- a/blockproducer/txpool_test.go
+++ /dev/null
@@ -1,17 +0,0 @@
-/*
- * Copyright 2018 The CovenantSQL Authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package blockproducer
From bb4995a50b0d679e75542ec1c3f52233e7b05020 Mon Sep 17 00:00:00 2001
From: leventeliu
Date: Tue, 18 Dec 2018 22:27:23 +0800
Subject: [PATCH 093/278] Remove blank files
---
blockproducer/branch_test.go | 17 -----------------
blockproducer/metaindex_test.go | 17 -----------------
2 files changed, 34 deletions(-)
delete mode 100644 blockproducer/branch_test.go
delete mode 100644 blockproducer/metaindex_test.go
diff --git a/blockproducer/branch_test.go b/blockproducer/branch_test.go
deleted file mode 100644
index 2423efab2..000000000
--- a/blockproducer/branch_test.go
+++ /dev/null
@@ -1,17 +0,0 @@
-/*
- * Copyright 2018 The CovenantSQL Authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package blockproducer
diff --git a/blockproducer/metaindex_test.go b/blockproducer/metaindex_test.go
deleted file mode 100644
index 2423efab2..000000000
--- a/blockproducer/metaindex_test.go
+++ /dev/null
@@ -1,17 +0,0 @@
-/*
- * Copyright 2018 The CovenantSQL Authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package blockproducer
From e34e9c95d4e7fddbbcd4189a7bd128d2f8aac00b Mon Sep 17 00:00:00 2001
From: leventeliu
Date: Wed, 19 Dec 2018 01:09:02 +0800
Subject: [PATCH 094/278] Minor fix
---
blockproducer/chain.go | 43 ++++++++------
blockproducer/helper_test.go | 4 +-
blockproducer/metastate.go | 112 +++++++++++++++++------------------
3 files changed, 83 insertions(+), 76 deletions(-)
diff --git a/blockproducer/chain.go b/blockproducer/chain.go
index 4313e73ab..84c1cfa21 100644
--- a/blockproducer/chain.go
+++ b/blockproducer/chain.go
@@ -105,9 +105,9 @@ func NewChainWithContext(ctx context.Context, cfg *Config) (c *Chain, err error)
ierr error
cld, ccl = context.WithCancel(ctx)
- l = float64(len(cfg.Peers.Servers))
+ l = uint32(len(cfg.Peers.Servers))
t float64
- m float64
+ m uint32
st xi.Storage
irre *blockNode
@@ -224,7 +224,7 @@ func NewChainWithContext(ctx context.Context, cfg *Config) (c *Chain, err error)
if t = cfg.ComfirmThreshold; t <= 0.0 {
t = float64(2) / 3.0
}
- if m = math.Ceil(l*t + 1); m > l {
+ if m = uint32(math.Ceil(float64(l)*t + 1)); m > l {
m = l
}
@@ -250,8 +250,8 @@ func NewChainWithContext(ctx context.Context, cfg *Config) (c *Chain, err error)
peers: cfg.Peers,
nodeID: cfg.NodeID,
- confirms: uint32(m),
- serversNum: uint32(len(cfg.Peers.Servers)),
+ confirms: m,
+ serversNum: l,
locSvIndex: uint32(locSvIndex),
nextHeight: head.head.height + 1,
offset: time.Duration(0), // TODO(leventeliu): initialize offset
@@ -474,6 +474,7 @@ func (c *Chain) processBlocks(ctx context.Context) {
}).Debug(err)
}
case <-ctx.Done():
+ log.WithError(c.ctx.Err()).Info("abort block processing")
return
}
}
@@ -511,7 +512,7 @@ func (c *Chain) addTx(tx pi.Transaction) {
select {
case c.pendingTxs <- tx:
case <-c.ctx.Done():
- log.WithError(c.ctx.Err()).Error("add transaction aborted")
+ log.WithError(c.ctx.Err()).Warn("add transaction aborted")
}
}
@@ -531,21 +532,28 @@ func (c *Chain) processTxs(ctx context.Context) {
case tx := <-c.pendingTxs:
c.processTx(tx)
case <-ctx.Done():
+ log.WithError(c.ctx.Err()).Info("abort transaction processing")
return
}
}
}
func (c *Chain) mainCycle(ctx context.Context) {
+ var timer = time.NewTimer(0)
+ defer func() {
+ if !timer.Stop() {
+ <-timer.C
+ }
+ }()
for {
select {
- case <-ctx.Done():
- log.WithError(ctx.Err()).Debug("abort main cycle")
- return
- default:
+ case <-timer.C:
c.syncCurrentHead(ctx) // Try to fetch block at height `nextHeight-1`
-
- if t, d := c.nextTick(); d > 0 {
+ var t, d = c.nextTick()
+ if d <= 0 {
+ // Try to produce block at `nextHeight` if it's my turn, and increase height by 1
+ c.advanceNextHeight(t)
+ } else {
log.WithFields(log.Fields{
"peer": c.peerInfo(),
"next_height": c.getNextHeight(),
@@ -554,11 +562,11 @@ func (c *Chain) mainCycle(ctx context.Context) {
"now_time": t.Format(time.RFC3339Nano),
"duration": d,
}).Debug("main cycle")
- time.Sleep(d)
- } else {
- // Try to produce block at `nextHeight` if it's my turn, and increase height by 1
- c.advanceNextHeight(t)
}
+ timer.Reset(d)
+ case <-ctx.Done():
+ log.WithError(ctx.Err()).Info("abort main cycle")
+ return
}
}
}
@@ -795,7 +803,6 @@ func (c *Chain) stat() {
"branch": buff,
}).Info("runtime state")
}
- return
}
func (c *Chain) applyBlock(bl *types.BPBlock) (err error) {
@@ -814,7 +821,7 @@ func (c *Chain) applyBlock(bl *types.BPBlock) (err error) {
for i, v := range c.branches {
// Grow a branch
- if v.head.hash.IsEqual(&bl.SignedHeader.ParentHash) {
+ if v.head.hash.IsEqual(bl.ParentHash()) {
head = newBlockNode(height, bl, v.head)
if br, ierr = v.applyBlock(head); ierr != nil {
err = errors.Wrapf(ierr, "failed to apply block %s", head.hash.Short(4))
diff --git a/blockproducer/helper_test.go b/blockproducer/helper_test.go
index 0c2520636..ce68aca12 100644
--- a/blockproducer/helper_test.go
+++ b/blockproducer/helper_test.go
@@ -23,7 +23,7 @@ import (
"math/rand"
"os"
"path/filepath"
- gort "runtime"
+ "runtime"
"strings"
"sync"
"time"
@@ -165,7 +165,7 @@ func initNode(confRP, privateKeyRP string) (cleanupFunc func(), dht *route.DHTSe
log.WithField("d", d).Debug("created temp dir")
// init conf
- _, testFile, _, _ := gort.Caller(0)
+ _, testFile, _, _ := runtime.Caller(0)
pubKeyStoreFile := filepath.Join(d, PubKeyStorePath)
os.Remove(pubKeyStoreFile)
clientPubKeyStoreFile := filepath.Join(d, PubKeyStorePath+"_c")
diff --git a/blockproducer/metastate.go b/blockproducer/metastate.go
index f87811545..0808cf074 100644
--- a/blockproducer/metastate.go
+++ b/blockproducer/metastate.go
@@ -25,7 +25,7 @@ import (
"github.com/CovenantSQL/CovenantSQL/crypto/hash"
"github.com/CovenantSQL/CovenantSQL/crypto/kms"
"github.com/CovenantSQL/CovenantSQL/proto"
- pt "github.com/CovenantSQL/CovenantSQL/types"
+ "github.com/CovenantSQL/CovenantSQL/types"
"github.com/CovenantSQL/CovenantSQL/utils/log"
"github.com/pkg/errors"
"github.com/ulule/deepcopier"
@@ -86,11 +86,11 @@ func (s *metaState) loadAccountStableBalance(addr proto.AccountAddress) (b uint6
}()
if o, loaded = s.dirty.accounts[addr]; loaded && o != nil {
- b = o.TokenBalance[pt.Particle]
+ b = o.TokenBalance[types.Particle]
return
}
if o, loaded = s.readonly.accounts[addr]; loaded {
- b = o.TokenBalance[pt.Particle]
+ b = o.TokenBalance[types.Particle]
return
}
return
@@ -107,11 +107,11 @@ func (s *metaState) loadAccountCovenantBalance(addr proto.AccountAddress) (b uin
}()
if o, loaded = s.dirty.accounts[addr]; loaded && o != nil {
- b = o.TokenBalance[pt.Wave]
+ b = o.TokenBalance[types.Wave]
return
}
if o, loaded = s.readonly.accounts[addr]; loaded {
- b = o.TokenBalance[pt.Wave]
+ b = o.TokenBalance[types.Wave]
return
}
return
@@ -130,17 +130,17 @@ func (s *metaState) storeBaseAccount(k proto.AccountAddress, v *accountObject) (
return
}
var (
- cb = ao.TokenBalance[pt.Wave]
- sb = ao.TokenBalance[pt.Particle]
+ cb = ao.TokenBalance[types.Wave]
+ sb = ao.TokenBalance[types.Particle]
)
- if err = safeAdd(&cb, &v.Account.TokenBalance[pt.Wave]); err != nil {
+ if err = safeAdd(&cb, &v.Account.TokenBalance[types.Wave]); err != nil {
return
}
- if err = safeAdd(&sb, &v.Account.TokenBalance[pt.Particle]); err != nil {
+ if err = safeAdd(&sb, &v.Account.TokenBalance[types.Particle]); err != nil {
return
}
- ao.TokenBalance[pt.Wave] = cb
- ao.TokenBalance[pt.Particle] = sb
+ ao.TokenBalance[types.Wave] = cb
+ ao.TokenBalance[types.Particle] = sb
}
return
}
@@ -261,7 +261,7 @@ func (s *metaState) increaseAccountStableBalance(k proto.AccountAddress, amount
deepcopier.Copy(&src.Account).To(&dst.Account)
s.dirty.accounts[k] = dst
}
- return safeAdd(&dst.Account.TokenBalance[pt.Particle], &amount)
+ return safeAdd(&dst.Account.TokenBalance[types.Particle], &amount)
}
func (s *metaState) decreaseAccountStableBalance(k proto.AccountAddress, amount uint64) error {
@@ -277,7 +277,7 @@ func (s *metaState) decreaseAccountStableBalance(k proto.AccountAddress, amount
deepcopier.Copy(&src.Account).To(&dst.Account)
s.dirty.accounts[k] = dst
}
- return safeSub(&dst.Account.TokenBalance[pt.Particle], &amount)
+ return safeSub(&dst.Account.TokenBalance[types.Particle], &amount)
}
func (s *metaState) transferAccountStableBalance(
@@ -288,7 +288,7 @@ func (s *metaState) transferAccountStableBalance(
}
// Create empty receiver account if not found
- s.loadOrStoreAccountObject(receiver, &accountObject{Account: pt.Account{Address: receiver}})
+ s.loadOrStoreAccountObject(receiver, &accountObject{Account: types.Account{Address: receiver}})
var (
so, ro *accountObject
@@ -311,8 +311,8 @@ func (s *metaState) transferAccountStableBalance(
// Try transfer
var (
- sb = so.TokenBalance[pt.Particle]
- rb = ro.TokenBalance[pt.Particle]
+ sb = so.TokenBalance[types.Particle]
+ rb = ro.TokenBalance[types.Particle]
)
if err = safeSub(&sb, &amount); err != nil {
return
@@ -334,8 +334,8 @@ func (s *metaState) transferAccountStableBalance(
ro = cpy
s.dirty.accounts[receiver] = cpy
}
- so.TokenBalance[pt.Particle] = sb
- ro.TokenBalance[pt.Particle] = rb
+ so.TokenBalance[types.Particle] = sb
+ ro.TokenBalance[types.Particle] = rb
return
}
@@ -353,7 +353,7 @@ func (s *metaState) increaseAccountCovenantBalance(k proto.AccountAddress, amoun
deepcopier.Copy(&src.Account).To(&dst.Account)
s.dirty.accounts[k] = dst
}
- return safeAdd(&dst.Account.TokenBalance[pt.Wave], &amount)
+ return safeAdd(&dst.Account.TokenBalance[types.Wave], &amount)
}
func (s *metaState) decreaseAccountCovenantBalance(k proto.AccountAddress, amount uint64) error {
@@ -369,7 +369,7 @@ func (s *metaState) decreaseAccountCovenantBalance(k proto.AccountAddress, amoun
deepcopier.Copy(&src.Account).To(&dst.Account)
s.dirty.accounts[k] = dst
}
- return safeSub(&dst.Account.TokenBalance[pt.Wave], &amount)
+ return safeSub(&dst.Account.TokenBalance[types.Wave], &amount)
}
func (s *metaState) createSQLChain(addr proto.AccountAddress, id proto.DatabaseID) error {
@@ -384,14 +384,14 @@ func (s *metaState) createSQLChain(addr proto.AccountAddress, id proto.DatabaseI
return ErrDatabaseExists
}
s.dirty.databases[id] = &sqlchainObject{
- SQLChainProfile: pt.SQLChainProfile{
+ SQLChainProfile: types.SQLChainProfile{
ID: id,
Owner: addr,
- Miners: make([]*pt.MinerInfo, 0),
- Users: []*pt.SQLChainUser{
+ Miners: make([]*types.MinerInfo, 0),
+ Users: []*types.SQLChainUser{
{
Address: addr,
- Permission: pt.Admin,
+ Permission: types.Admin,
},
},
},
@@ -400,7 +400,7 @@ func (s *metaState) createSQLChain(addr proto.AccountAddress, id proto.DatabaseI
}
func (s *metaState) addSQLChainUser(
- k proto.DatabaseID, addr proto.AccountAddress, perm pt.UserPermission) (_ error,
+ k proto.DatabaseID, addr proto.AccountAddress, perm types.UserPermission) (_ error,
) {
var (
src, dst *sqlchainObject
@@ -419,7 +419,7 @@ func (s *metaState) addSQLChainUser(
return ErrDatabaseUserExists
}
}
- dst.SQLChainProfile.Users = append(dst.SQLChainProfile.Users, &pt.SQLChainUser{
+ dst.SQLChainProfile.Users = append(dst.SQLChainProfile.Users, &types.SQLChainUser{
Address: addr,
Permission: perm,
})
@@ -451,7 +451,7 @@ func (s *metaState) deleteSQLChainUser(k proto.DatabaseID, addr proto.AccountAdd
}
func (s *metaState) alterSQLChainUser(
- k proto.DatabaseID, addr proto.AccountAddress, perm pt.UserPermission) (_ error,
+ k proto.DatabaseID, addr proto.AccountAddress, perm types.UserPermission) (_ error,
) {
var (
src, dst *sqlchainObject
@@ -508,10 +508,10 @@ func (s *metaState) increaseNonce(addr proto.AccountAddress) (err error) {
return
}
-func (s *metaState) applyBilling(tx *pt.Billing) (err error) {
+func (s *metaState) applyBilling(tx *types.Billing) (err error) {
for i, v := range tx.Receivers {
// Create empty receiver account if not found
- s.loadOrStoreAccountObject(*v, &accountObject{Account: pt.Account{Address: *v}})
+ s.loadOrStoreAccountObject(*v, &accountObject{Account: types.Account{Address: *v}})
if err = s.increaseAccountCovenantBalance(*v, tx.Fees[i]); err != nil {
return
@@ -523,7 +523,7 @@ func (s *metaState) applyBilling(tx *pt.Billing) (err error) {
return
}
-func (s *metaState) updateProviderList(tx *pt.ProvideService) (err error) {
+func (s *metaState) updateProviderList(tx *types.ProvideService) (err error) {
sender, err := crypto.PubKeyHash(tx.Signee)
if err != nil {
err = errors.Wrap(err, "updateProviderList failed")
@@ -533,7 +533,7 @@ func (s *metaState) updateProviderList(tx *pt.ProvideService) (err error) {
err = errors.Wrap(ErrInvalidSender, "updateProviderList failed")
return
}
- pp := pt.ProviderProfile{
+ pp := types.ProviderProfile{
Provider: sender,
Space: tx.Space,
Memory: tx.Memory,
@@ -544,7 +544,7 @@ func (s *metaState) updateProviderList(tx *pt.ProvideService) (err error) {
return
}
-func (s *metaState) matchProvidersWithUser(tx *pt.CreateDatabase) (err error) {
+func (s *metaState) matchProvidersWithUser(tx *types.CreateDatabase) (err error) {
sender, err := crypto.PubKeyHash(tx.Signee)
if err != nil {
err = errors.Wrap(err, "matchProviders failed")
@@ -586,10 +586,10 @@ func (s *metaState) matchProvidersWithUser(tx *pt.CreateDatabase) (err error) {
return
}
// generate userinfo
- users := make([]*pt.SQLChainUser, 1)
- users[0] = &pt.SQLChainUser{
+ users := make([]*types.SQLChainUser, 1)
+ users[0] = &types.SQLChainUser{
Address: sender,
- Permission: pt.Admin,
+ Permission: types.Admin,
}
// generate genesis block
gb, err := s.generateGenesisBlock(*dbID, tx.ResourceMeta)
@@ -601,12 +601,12 @@ func (s *metaState) matchProvidersWithUser(tx *pt.CreateDatabase) (err error) {
return err
}
// create sqlchain
- sp := &pt.SQLChainProfile{
+ sp := &types.SQLChainProfile{
ID: *dbID,
Address: dbAddr,
Period: sqlchainPeriod,
GasPrice: sqlchainGasPrice,
- TokenType: pt.Particle,
+ TokenType: types.Particle,
Owner: sender,
Users: users,
Genesis: gb,
@@ -616,7 +616,7 @@ func (s *metaState) matchProvidersWithUser(tx *pt.CreateDatabase) (err error) {
return
}
s.loadOrStoreAccountObject(dbAddr, &accountObject{
- Account: pt.Account{Address: dbAddr},
+ Account: types.Account{Address: dbAddr},
})
s.loadOrStoreSQLChainObject(*dbID, &sqlchainObject{SQLChainProfile: *sp})
for _, miner := range tx.ResourceMeta.TargetMiners {
@@ -625,7 +625,7 @@ func (s *metaState) matchProvidersWithUser(tx *pt.CreateDatabase) (err error) {
return
}
-func (s *metaState) updatePermission(tx *pt.UpdatePermission) (err error) {
+func (s *metaState) updatePermission(tx *types.UpdatePermission) (err error) {
sender, err := crypto.PubKeyHash(tx.Signee)
if err != nil {
log.WithFields(log.Fields{
@@ -644,7 +644,7 @@ func (s *metaState) updatePermission(tx *pt.UpdatePermission) (err error) {
}).WithError(ErrDatabaseNotFound).Error("unexpected error in updatePermission")
return ErrDatabaseNotFound
}
- if tx.Permission >= pt.NumberOfUserPermission {
+ if tx.Permission >= types.NumberOfUserPermission {
log.WithFields(log.Fields{
"permission": tx.Permission,
"dbID": tx.TargetSQLChain.DatabaseID(),
@@ -656,7 +656,7 @@ func (s *metaState) updatePermission(tx *pt.UpdatePermission) (err error) {
isAdmin := false
targetUserIndex := -1
for i, u := range so.Users {
- isAdmin = isAdmin || (sender == u.Address && u.Permission == pt.Admin)
+ isAdmin = isAdmin || (sender == u.Address && u.Permission == types.Admin)
if tx.TargetUser == u.Address {
targetUserIndex = i
}
@@ -672,10 +672,10 @@ func (s *metaState) updatePermission(tx *pt.UpdatePermission) (err error) {
// update targetUser's permission
if targetUserIndex == -1 {
- u := pt.SQLChainUser{
+ u := types.SQLChainUser{
Address: tx.TargetUser,
Permission: tx.Permission,
- Status: pt.Normal,
+ Status: types.Normal,
}
so.Users = append(so.Users, &u)
} else {
@@ -684,7 +684,7 @@ func (s *metaState) updatePermission(tx *pt.UpdatePermission) (err error) {
return
}
-func (s *metaState) updateKeys(tx *pt.IssueKeys) (err error) {
+func (s *metaState) updateKeys(tx *types.IssueKeys) (err error) {
sender := tx.GetAccountAddress()
so, loaded := s.loadSQLChainObject(tx.TargetSQLChain.DatabaseID())
if !loaded {
@@ -704,7 +704,7 @@ func (s *metaState) updateKeys(tx *pt.IssueKeys) (err error) {
}
isAdmin := false
for _, user := range so.Users {
- if sender == user.Address && user.Permission == pt.Admin {
+ if sender == user.Address && user.Permission == types.Admin {
isAdmin = true
break
}
@@ -732,7 +732,7 @@ func (s *metaState) updateKeys(tx *pt.IssueKeys) (err error) {
func (s *metaState) applyTransaction(tx pi.Transaction) (err error) {
switch t := tx.(type) {
- case *pt.Transfer:
+ case *types.Transfer:
realSender, err := crypto.PubKeyHash(t.Signee)
if err != nil {
err = errors.Wrap(err, "applyTx failed")
@@ -745,17 +745,17 @@ func (s *metaState) applyTransaction(tx pi.Transaction) (err error) {
log.Debug(err)
}
err = s.transferAccountStableBalance(t.Sender, t.Receiver, t.Amount)
- case *pt.Billing:
+ case *types.Billing:
err = s.applyBilling(t)
- case *pt.BaseAccount:
+ case *types.BaseAccount:
err = s.storeBaseAccount(t.Address, &accountObject{Account: t.Account})
- case *pt.ProvideService:
+ case *types.ProvideService:
err = s.updateProviderList(t)
- case *pt.CreateDatabase:
+ case *types.CreateDatabase:
err = s.matchProvidersWithUser(t)
- case *pt.UpdatePermission:
+ case *types.UpdatePermission:
err = s.updatePermission(t)
- case *pt.IssueKeys:
+ case *types.IssueKeys:
err = s.updateKeys(t)
case *pi.TransactionWrapper:
// call again using unwrapped transaction
@@ -766,7 +766,7 @@ func (s *metaState) applyTransaction(tx pi.Transaction) (err error) {
return
}
-func (s *metaState) generateGenesisBlock(dbID proto.DatabaseID, resourceMeta pt.ResourceMeta) (genesisBlock *pt.Block, err error) {
+func (s *metaState) generateGenesisBlock(dbID proto.DatabaseID, resourceMeta types.ResourceMeta) (genesisBlock *types.Block, err error) {
// TODO(xq262144): following is stub code, real logic should be implemented in the future
emptyHash := hash.Hash{}
@@ -779,9 +779,9 @@ func (s *metaState) generateGenesisBlock(dbID proto.DatabaseID, resourceMeta pt.
return
}
- genesisBlock = &pt.Block{
- SignedHeader: pt.SignedHeader{
- Header: pt.Header{
+ genesisBlock = &types.Block{
+ SignedHeader: types.SignedHeader{
+ Header: types.Header{
Version: 0x01000000,
Producer: nodeID,
GenesisHash: emptyHash,
From 3ded3446c61043d2055e7fd23ddbd9667087fb31 Mon Sep 17 00:00:00 2001
From: leventeliu
Date: Wed, 19 Dec 2018 03:05:51 +0800
Subject: [PATCH 095/278] Minor fix
---
utils/log/logwrapper_test.go | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/utils/log/logwrapper_test.go b/utils/log/logwrapper_test.go
index c52d9eed9..54c15b619 100644
--- a/utils/log/logwrapper_test.go
+++ b/utils/log/logwrapper_test.go
@@ -118,7 +118,7 @@ func TestWithField(t *testing.T) {
WithField("k", "v").Info("info")
WithField("k", "v").Infoln("Infoln")
WithField("k", "v").Infof("infof %d", 1)
- WithField("k", "v").Warning("Warning")
+ WithField("k", "v").Warning("warning")
WithField("k", "v").Warningln("Warningln")
WithField("k", "v").Warningf("Warningf %d", 1)
WithField("k", "v").Warn("warn")
From 6ab477ea516465873fcd70e56002462cff032db4 Mon Sep 17 00:00:00 2001
From: leventeliu
Date: Wed, 19 Dec 2018 03:24:55 +0800
Subject: [PATCH 096/278] Remove more unused codes
---
blockproducer/chain.go | 13 -------------
blockproducer/storage.go | 2 +-
2 files changed, 1 insertion(+), 14 deletions(-)
diff --git a/blockproducer/chain.go b/blockproducer/chain.go
index 84c1cfa21..034e7c0ee 100644
--- a/blockproducer/chain.go
+++ b/blockproducer/chain.go
@@ -42,19 +42,6 @@ import (
"github.com/pkg/errors"
)
-var (
- metaBucket = [4]byte{0x0, 0x0, 0x0, 0x0}
- metaStateKey = []byte("covenantsql-state")
- metaBlockIndexBucket = []byte("covenantsql-block-index-bucket")
- metaTransactionBucket = []byte("covenantsql-tx-index-bucket")
- metaAccountIndexBucket = []byte("covenantsql-account-index-bucket")
- metaSQLChainIndexBucket = []byte("covenantsql-sqlchain-index-bucket")
- metaProviderIndexBucket = []byte("covenantsql-provider-index-bucket")
- gasPrice uint32 = 1
- accountAddress proto.AccountAddress
- txEvent = "/BP/Tx"
-)
-
// Chain defines the main chain.
type Chain struct {
// Routine controlling components
diff --git a/blockproducer/storage.go b/blockproducer/storage.go
index b5b9775da..105e492f9 100644
--- a/blockproducer/storage.go
+++ b/blockproducer/storage.go
@@ -95,7 +95,7 @@ func store(st xi.Storage, sps []storageProcedure, cb storageCallback) (err error
}
// COMMIT
if err = tx.Commit(); err != nil {
- log.WithError(err).Fatalf("failed to commit storage transaction")
+ log.WithError(err).Fatal("failed to commit storage transaction")
}
return
}
From d08b448a73f3810132a81fb66b249bc7d7fed77f Mon Sep 17 00:00:00 2001
From: zeqing-guo
Date: Wed, 19 Dec 2018 12:11:47 +0800
Subject: [PATCH 097/278] Add billing function
---
blockproducer/interfaces/transaction.go | 4 +
blockproducer/metastate.go | 61 +++++++-
sqlchain/chain.go | 192 +++++++++++++++++++++++-
sqlchain/config.go | 1 +
sqlchain/errors.go | 3 +
sqlchain/runtime.go | 2 +-
sqlchain/state.go | 3 +
types/account.go | 10 +-
types/account_gen.go | 93 +++++++++---
types/account_gen_test.go | 37 +++++
types/bprpc.go | 1 -
types/chainstate.go | 118 +++++++++++++++
types/errors.go | 8 +
types/init_service_type.go | 1 +
types/init_service_type_gen.go | 26 +++-
types/provideservice.go | 2 +-
types/request_type_gen.go | 23 ++-
types/updatebilling.go | 87 +++++++++++
types/updatebilling_gen.go | 155 +++++++++++++++++++
types/updatebilling_gen_test.go | 158 +++++++++++++++++++
utils/request.go | 30 ++++
worker/db.go | 11 +-
worker/dbms.go | 163 ++++++++++++++------
worker/dbms_meta.go | 7 +-
24 files changed, 1101 insertions(+), 95 deletions(-)
create mode 100644 types/chainstate.go
create mode 100644 types/updatebilling.go
create mode 100644 types/updatebilling_gen.go
create mode 100644 types/updatebilling_gen_test.go
create mode 100644 utils/request.go
diff --git a/blockproducer/interfaces/transaction.go b/blockproducer/interfaces/transaction.go
index d7ed71e9d..bd936c414 100644
--- a/blockproducer/interfaces/transaction.go
+++ b/blockproducer/interfaces/transaction.go
@@ -69,6 +69,8 @@ const (
TransactionTypeUpdatePermission
// TransactionTypeIssueKeys defines SQLChain owner assign symmetric key.
TransactionTypeIssueKeys
+ // TransactionTypeUpdateBilling defines SQLChain update billing information.
+ TransactionTypeUpdateBilling
// TransactionTypeNumber defines transaction types number.
TransactionTypeNumber
)
@@ -99,6 +101,8 @@ func (t TransactionType) String() string {
return "UpdatePermission"
case TransactionTypeIssueKeys:
return "IssueKeys"
+ case TransactionTypeUpdateBilling:
+ return "UpdateBilling"
default:
return "Unknown"
}
diff --git a/blockproducer/metastate.go b/blockproducer/metastate.go
index 8b391c11b..111767874 100644
--- a/blockproducer/metastate.go
+++ b/blockproducer/metastate.go
@@ -873,7 +873,7 @@ func (s *metaState) updateProviderList(tx *pt.ProvideService) (err error) {
TargetUser: tx.TargetUser,
Deposit: minDeposit,
GasPrice: tx.GasPrice,
- NodeID: tx.NodeID,
+ NodeID: tx.NodeID,
}
s.loadOrStoreProviderObject(sender, &providerObject{ProviderProfile: pp})
return
@@ -932,7 +932,7 @@ func (s *metaState) matchProvidersWithUser(tx *pt.CreateDatabase) (err error) {
}
miners[i] = &pt.MinerInfo{
Address: po.Provider,
- NodeID: po.NodeID,
+ NodeID: po.NodeID,
Deposit: po.Deposit,
}
}
@@ -985,7 +985,7 @@ func (s *metaState) matchProvidersWithUser(tx *pt.CreateDatabase) (err error) {
Owner: sender,
Users: users,
Genesis: gb,
- Miners: miners[:],
+ Miners: miners[:],
}
if _, loaded := s.loadSQLChainObject(*dbID); loaded {
@@ -1107,6 +1107,59 @@ func (s *metaState) updateKeys(tx *pt.IssueKeys) (err error) {
return
}
+func (s *metaState) updateBilling(tx *pt.UpdateBilling) (err error) {
+ sqlchainObj, loaded := s.loadSQLChainObject(tx.Receiver.DatabaseID())
+ if !loaded {
+ err = errors.Wrap(ErrDatabaseNotFound, "update billing failed")
+ return
+ }
+
+ sqlchainObj.Lock()
+ defer sqlchainObj.Unlock()
+
+ if sqlchainObj.GasPrice == 0 {
+ return
+ }
+
+ // pending income to income
+ for _, miner := range sqlchainObj.Miners {
+ miner.ReceivedIncome += miner.PendingIncome
+ }
+
+ var (
+ costMap = make(map[proto.AccountAddress]uint64)
+ userMap = make(map[proto.AccountAddress]map[proto.AccountAddress]uint64)
+ )
+ for _, userCost := range tx.Users {
+ costMap[userCost.User] = userCost.Cost
+ if _, ok := userMap[userCost.User]; !ok {
+ userMap[userCost.User] = make(map[proto.AccountAddress]uint64)
+ }
+ for _, minerIncome := range userCost.Miners {
+ userMap[userCost.User][minerIncome.Miner] += minerIncome.Income
+ }
+ }
+ for _, user := range sqlchainObj.Users {
+ if user.AdvancePayment >= costMap[user.Address] * sqlchainObj.GasPrice {
+ user.AdvancePayment -= costMap[user.Address] * sqlchainObj.GasPrice
+ for _, miner := range sqlchainObj.Miners {
+ miner.PendingIncome += userMap[user.Address][miner.Address] * sqlchainObj.GasPrice
+ }
+ } else {
+ rate := 1 - float64(user.AdvancePayment) / float64(costMap[user.Address] * sqlchainObj.GasPrice)
+ user.AdvancePayment = 0
+ for _, miner := range sqlchainObj.Miners {
+ income := userMap[user.Address][miner.Address] * sqlchainObj.GasPrice
+ minerIncome := uint64(float64(income) * rate)
+ miner.PendingIncome += minerIncome
+ for i := range miner.UserArrears {
+ miner.UserArrears[i].Arrears += (income - minerIncome)
+ }
+ }
+ }
+ }
+}
+
func (s *metaState) applyTransaction(tx pi.Transaction) (err error) {
switch t := tx.(type) {
case *pt.Transfer:
@@ -1134,6 +1187,8 @@ func (s *metaState) applyTransaction(tx pi.Transaction) (err error) {
err = s.updatePermission(t)
case *pt.IssueKeys:
err = s.updateKeys(t)
+ case *pt.UpdateBilling:
+ err = s.updateBilling(t)
case *pi.TransactionWrapper:
// call again using unwrapped transaction
err = s.applyTransaction(t.Unwrap())
diff --git a/sqlchain/chain.go b/sqlchain/chain.go
index e6f51d8a2..79d4af54d 100644
--- a/sqlchain/chain.go
+++ b/sqlchain/chain.go
@@ -20,6 +20,7 @@ import (
"bytes"
"encoding/binary"
"fmt"
+ "github.com/CovenantSQL/CovenantSQL/blockproducer/interfaces"
"os"
rt "runtime"
"sync"
@@ -102,7 +103,7 @@ func keyWithSymbolToHeight(k []byte) int32 {
// Chain represents a sql-chain.
type Chain struct {
- // bdb stores state and block
+ // bdb stores state, profile and block
bdb *leveldb.DB
// tdb stores ack/request/response
tdb *leveldb.DB
@@ -119,6 +120,7 @@ type Chain struct {
acks chan *types.AckHeader
// DBAccount info
+ databaseID proto.DatabaseID
tokenType types.TokenType
gasPrice uint64
updatePeriod uint64
@@ -138,15 +140,18 @@ type Chain struct {
//
// pk is the private key of the local miner.
pk *asymmetric.PrivateKey
+
+ // bus service for SQLChain
+ busService *BusService
}
// NewChain creates a new sql-chain struct.
-func NewChain(c *Config) (chain *Chain, err error) {
+func NewChain(c *Config, busService *BusService) (chain *Chain, err error) {
// TODO(leventeliu): this is a rough solution, you may also want to clean database file and
// force rebuilding.
var fi os.FileInfo
if fi, err = os.Stat(c.ChainFilePrefix + "-block-state.ldb"); err == nil && fi.Mode().IsDir() {
- return LoadChain(c)
+ return LoadChain(c, busService)
}
err = c.Genesis.VerifyAsGenesis()
@@ -193,6 +198,10 @@ func NewChain(c *Config) (chain *Chain, err error) {
return
}
+ // subscribe events
+ busService.Subscribe("/Transfer/", chain.updateAdvancePayment)
+ busService.Subscribe("/UpdatePermission/", chain.updatePermission)
+
// Create chain state
chain = &Chain{
bdb: bdb,
@@ -207,9 +216,11 @@ func NewChain(c *Config) (chain *Chain, err error) {
heights: make(chan int32, 1),
responses: make(chan *types.ResponseHeader),
acks: make(chan *types.AckHeader),
+
tokenType: c.TokenType,
gasPrice: c.GasPrice,
updatePeriod: c.UpdatePeriod,
+ databaseID: c.Profile.ID,
// Observer related
observers: make(map[proto.NodeID]int32),
@@ -217,6 +228,8 @@ func NewChain(c *Config) (chain *Chain, err error) {
replCh: make(chan struct{}),
pk: pk,
+
+ busService: busService,
}
if err = chain.pushBlock(c.Genesis); err != nil {
@@ -227,7 +240,7 @@ func NewChain(c *Config) (chain *Chain, err error) {
}
// LoadChain loads the chain state from the specified database and rebuilds a memory index.
-func LoadChain(c *Config) (chain *Chain, err error) {
+func LoadChain(c *Config, busService *BusService) (chain *Chain, err error) {
// Open LevelDB for block and state
bdbFile := c.ChainFilePrefix + "-block-state.ldb"
bdb, err := leveldb.OpenFile(bdbFile, &leveldbConf)
@@ -263,6 +276,10 @@ func LoadChain(c *Config) (chain *Chain, err error) {
return
}
+ // subscribe events
+ busService.Subscribe("/Transfer/", chain.updateAdvancePayment)
+ busService.Subscribe("/UpdatePermission/", chain.updatePermission)
+
// Create chain state
chain = &Chain{
bdb: bdb,
@@ -277,9 +294,11 @@ func LoadChain(c *Config) (chain *Chain, err error) {
heights: make(chan int32, 1),
responses: make(chan *types.ResponseHeader),
acks: make(chan *types.AckHeader),
+
tokenType: c.TokenType,
gasPrice: c.GasPrice,
updatePeriod: c.UpdatePeriod,
+ databaseID: c.Profile.ID,
// Observer related
observers: make(map[proto.NodeID]int32),
@@ -287,6 +306,8 @@ func LoadChain(c *Config) (chain *Chain, err error) {
replCh: make(chan struct{}),
pk: pk,
+
+ busService: busService,
}
// Read state struct
@@ -623,6 +644,7 @@ func (c *Chain) produceBlockV2(now time.Time) (err error) {
}
}
wg.Wait()
+
// fire replication to observers
c.startStopReplication()
return
@@ -814,7 +836,9 @@ func (c *Chain) processBlocks() {
c.rt.wg.Done()
}()
- var stash []*types.Block
+ var (
+ stash []*types.Block
+ )
for {
select {
case h := <-c.heights:
@@ -858,6 +882,38 @@ func (c *Chain) processBlocks() {
"block_height": height,
"block_hash": block.BlockHash().String(),
}).WithError(err).Error("Failed to check and push new block")
+ } else {
+ head := c.rt.getHead()
+ currentCount := uint64(head.node.count)
+ if currentCount % c.updatePeriod == 0 {
+ ub, err := c.billing(head.node)
+ if err != nil {
+ log.WithError(err).Error("billing failed")
+ }
+ go func(ub *types.UpdateBilling) {
+ // allocate nonce
+ nonceReq := &types.NextAccountNonceReq{}
+ nonceResp := &types.NextAccountNonceResp{}
+ nonceReq.Addr = ub.Receiver
+ if err = utils.RequestBP(route.MCCNextAccountNonce.String(), nonceReq, nonceResp); err != nil {
+ // allocate nonce failed
+ log.WithError(err).Warning("allocate nonce for transaction failed")
+ return
+ }
+ ub.Nonce = nonceResp.Nonce
+ if err = ub.Sign(c.pk); err != nil {
+ log.WithError(err).Warning("sign tx failed")
+ return
+ }
+ addTxReq := types.AddTxReq{}
+ addTxResp := types.AddTxResp{}
+ addTxReq.Tx = ub
+ if err = utils.RequestBP(route.MCCAddTx.String(), addTxReq, addTxResp); err != nil {
+ log.WithError(err).Warning("send tx failed")
+ return
+ }
+ }(ub)
+ }
}
}
}
@@ -1460,3 +1516,129 @@ func (c *Chain) stat() {
// Print xeno stats
c.st.Stat(c.rt.databaseID)
}
+
+func (c *Chain) billing(node *blockNode) (ub *types.UpdateBilling, err error) {
+ var (
+ i, j uint64
+ minerAddr proto.AccountAddress
+ userAddr proto.AccountAddress
+ usersMap = make(map[proto.AccountAddress]uint64)
+ minersMap = make(map[proto.AccountAddress]map[proto.AccountAddress]uint64)
+ )
+
+ for i = 0; i < c.updatePeriod && node != nil; i++ {
+ for _, ack := range node.block.Acks {
+ if minerAddr, err = crypto.PubKeyHash(ack.Signee); err != nil {
+ err = errors.Wrap(err, "billing fail: miner addr")
+ return
+ }
+ if userAddr, err = crypto.PubKeyHash(ack.Signee); err != nil {
+ err = errors.Wrap(err, "billing fail: user addr")
+ return
+ }
+
+ if ack.SignedRequestHeader().QueryType == types.ReadQuery {
+ if _, ok := minersMap[userAddr]; !ok {
+ minersMap[userAddr] = make(map[proto.AccountAddress]uint64)
+ }
+ minersMap[userAddr][minerAddr] += 1
+ usersMap[userAddr] += 1
+ } else {
+ if _, ok := minersMap[userAddr]; !ok {
+ minersMap[userAddr] = make(map[proto.AccountAddress]uint64)
+ }
+ minersMap[userAddr][minerAddr] += uint64(ack.SignedResponseHeader().AffectedRows)
+ usersMap[userAddr] += uint64(ack.SignedResponseHeader().AffectedRows)
+ }
+ }
+ node = node.parent
+ }
+
+ ub = types.NewUpdateBilling(&types.UpdateBillingHeader{
+ Users: make([]*types.UserCost, len(usersMap)),
+ })
+
+ i = 0
+ j = 0
+ for userAddr, cost := range usersMap {
+ ub.Users[i].User = userAddr
+ ub.Users[i].Cost = cost
+ miners := minersMap[userAddr]
+ ub.Users[i].Miners = make([]*types.MinerIncome, len(miners))
+
+ for k1, v1 := range miners {
+ ub.Users[i].Miners[j].Miner = k1
+ ub.Users[i].Miners[j].Income = v1
+ j += 1
+ }
+ j = 0
+ i += 1
+ }
+ ub.Receiver, err = c.databaseID.AccountAddress()
+ return
+}
+
+func (c *Chain) updateAdvancePayment(tx interfaces.Transaction, count uint32) {
+ var transfer *types.Transfer
+ switch t := tx.(type) {
+ case *types.Transfer:
+ transfer = t
+ default:
+ log.WithFields(log.Fields{
+ "tx_type": t.GetTransactionType().String(),
+ "tx_hash": t.Hash().String(),
+ "tx_addr": t.GetAccountAddress().String(),
+ }).WithError(ErrInvalidTransactionType)
+ return
+ }
+ if transfer.Receiver.DatabaseID() != c.databaseID {
+ return
+ }
+
+ head := c.rt.getHead()
+ for _, user := range head.Profile.Users {
+ // TODO(lambda): add token type in types.Transfer
+ if user.Address == transfer.Sender {
+ res, flow := utils.SafeAdd(user.AdvancePayment, transfer.Amount)
+ if !flow {
+ user.AdvancePayment = res
+ head.BlockHeight = int32(count)
+ }
+ }
+ }
+}
+
+func (c *Chain) updatePermission(tx interfaces.Transaction, count uint32) {
+ var up *types.UpdatePermission
+ switch t := tx.(type) {
+ case *types.UpdatePermission:
+ up = t
+ default:
+ log.WithFields(log.Fields{
+ "tx_type": t.GetTransactionType().String(),
+ "tx_hash": t.Hash().String(),
+ "tx_addr": t.GetAccountAddress().String(),
+ }).WithError(ErrInvalidTransactionType)
+ return
+ }
+ if up.TargetSQLChain.DatabaseID() != c.databaseID {
+ return
+ }
+
+ // BP checks the sender's permission on main, so it is unnecessary to do it again
+ head := c.rt.getHead()
+ newUser := true
+ for _, user := range head.Profile.Users {
+ if user.Address == up.TargetUser {
+ user.Permission = up.Permission
+ newUser = false
+ }
+ }
+ if newUser {
+ head.Profile.Users = append(head.Profile.Users, &types.SQLChainUser{
+ Address: up.TargetUser,
+ Permission: up.Permission,
+ })
+ }
+}
+
diff --git a/sqlchain/config.go b/sqlchain/config.go
index 4de594ca8..920b56df7 100644
--- a/sqlchain/config.go
+++ b/sqlchain/config.go
@@ -38,6 +38,7 @@ type Config struct {
Server proto.NodeID
// Price sets query price in gases.
+ Profile *types.SQLChainProfile
Price map[types.QueryType]uint64
ProducingReward uint64
BillingPeriods int32
diff --git a/sqlchain/errors.go b/sqlchain/errors.go
index 10fa9cde8..7ed223777 100644
--- a/sqlchain/errors.go
+++ b/sqlchain/errors.go
@@ -99,4 +99,7 @@ var (
// ErrResponseSeqNotMatch indicates that a response sequence id doesn't match the original one
// in the index.
ErrResponseSeqNotMatch = errors.New("response sequence id doesn't match")
+
+ // ErrInvalidTransactionType indicates that the transaction type is invalid.
+ ErrInvalidTransactionType = errors.New("invalid transaction type")
)
diff --git a/sqlchain/runtime.go b/sqlchain/runtime.go
index b1935558d..5f190d1ca 100644
--- a/sqlchain/runtime.go
+++ b/sqlchain/runtime.go
@@ -118,7 +118,7 @@ func newRunTime(c *Config) (r *runtime) {
}(),
total: int32(len(c.Peers.Servers)),
nextTurn: 1,
- head: &state{},
+ head: &state{Profile: c.Profile},
offset: time.Duration(0),
}
diff --git a/sqlchain/state.go b/sqlchain/state.go
index 9f7c00593..c511deda5 100644
--- a/sqlchain/state.go
+++ b/sqlchain/state.go
@@ -18,6 +18,7 @@ package sqlchain
import (
"github.com/CovenantSQL/CovenantSQL/crypto/hash"
+ "github.com/CovenantSQL/CovenantSQL/types"
)
// state represents a snapshot of current best chain.
@@ -25,6 +26,8 @@ type state struct {
node *blockNode
Head hash.Hash
Height int32
+ Profile *types.SQLChainProfile
+ BlockHeight int32
}
//// MarshalHash marshals for hash
diff --git a/types/account.go b/types/account.go
index 61f830973..34f53ba81 100644
--- a/types/account.go
+++ b/types/account.go
@@ -75,6 +75,12 @@ type SQLChainUser struct {
Status Status
}
+// UserArrears defines user's arrears.
+type UserArrears struct {
+ User proto.AccountAddress
+ Arrears uint64
+}
+
// MinerInfo defines a miner.
type MinerInfo struct {
Address proto.AccountAddress
@@ -82,6 +88,7 @@ type MinerInfo struct {
Name string
PendingIncome uint64
ReceivedIncome uint64
+ UserArrears []*UserArrears
Deposit uint64
Status Status
EncryptionKey string
@@ -93,6 +100,7 @@ type SQLChainProfile struct {
Address proto.AccountAddress
Period uint64
GasPrice uint64
+ LastUpdatedHeight uint32
TokenType TokenType
@@ -115,7 +123,7 @@ type ProviderProfile struct {
Deposit uint64 // default 10 Particle
GasPrice uint64
TokenType TokenType // default Particle
- NodeID proto.NodeID
+ NodeID proto.NodeID
}
// Account store its balance, and other mate data.
diff --git a/types/account_gen.go b/types/account_gen.go
index f8a039898..239aa9912 100644
--- a/types/account_gen.go
+++ b/types/account_gen.go
@@ -43,37 +43,62 @@ func (z *Account) Msgsize() (s int) {
func (z *MinerInfo) MarshalHash() (o []byte, err error) {
var b []byte
o = hsp.Require(b, z.Msgsize())
- // map header, size 8
- o = append(o, 0x88, 0x88)
+ // map header, size 9
+ o = append(o, 0x89, 0x89)
o = hsp.AppendInt32(o, int32(z.Status))
- o = append(o, 0x88)
+ o = append(o, 0x89)
+ o = hsp.AppendArrayHeader(o, uint32(len(z.UserArrears)))
+ for za0001 := range z.UserArrears {
+ if z.UserArrears[za0001] == nil {
+ o = hsp.AppendNil(o)
+ } else {
+ // map header, size 2
+ o = append(o, 0x82, 0x82)
+ if oTemp, err := z.UserArrears[za0001].User.MarshalHash(); err != nil {
+ return nil, err
+ } else {
+ o = hsp.AppendBytes(o, oTemp)
+ }
+ o = append(o, 0x82)
+ o = hsp.AppendUint64(o, z.UserArrears[za0001].Arrears)
+ }
+ }
+ o = append(o, 0x89)
if oTemp, err := z.Address.MarshalHash(); err != nil {
return nil, err
} else {
o = hsp.AppendBytes(o, oTemp)
}
- o = append(o, 0x88)
+ o = append(o, 0x89)
if oTemp, err := z.NodeID.MarshalHash(); err != nil {
return nil, err
} else {
o = hsp.AppendBytes(o, oTemp)
}
- o = append(o, 0x88)
+ o = append(o, 0x89)
o = hsp.AppendString(o, z.Name)
- o = append(o, 0x88)
+ o = append(o, 0x89)
o = hsp.AppendString(o, z.EncryptionKey)
- o = append(o, 0x88)
+ o = append(o, 0x89)
o = hsp.AppendUint64(o, z.PendingIncome)
- o = append(o, 0x88)
+ o = append(o, 0x89)
o = hsp.AppendUint64(o, z.ReceivedIncome)
- o = append(o, 0x88)
+ o = append(o, 0x89)
o = hsp.AppendUint64(o, z.Deposit)
return
}
// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (z *MinerInfo) Msgsize() (s int) {
- s = 1 + 7 + hsp.Int32Size + 8 + z.Address.Msgsize() + 7 + z.NodeID.Msgsize() + 5 + hsp.StringPrefixSize + len(z.Name) + 14 + hsp.StringPrefixSize + len(z.EncryptionKey) + 14 + hsp.Uint64Size + 15 + hsp.Uint64Size + 8 + hsp.Uint64Size
+ s = 1 + 7 + hsp.Int32Size + 12 + hsp.ArrayHeaderSize
+ for za0001 := range z.UserArrears {
+ if z.UserArrears[za0001] == nil {
+ s += hsp.NilSize
+ } else {
+ s += 1 + 5 + z.UserArrears[za0001].User.Msgsize() + 8 + hsp.Uint64Size
+ }
+ }
+ s += 8 + z.Address.Msgsize() + 7 + z.NodeID.Msgsize() + 5 + hsp.StringPrefixSize + len(z.Name) + 14 + hsp.StringPrefixSize + len(z.EncryptionKey) + 14 + hsp.Uint64Size + 15 + hsp.Uint64Size + 8 + hsp.Uint64Size
return
}
@@ -129,8 +154,8 @@ func (z *ProviderProfile) Msgsize() (s int) {
func (z *SQLChainProfile) MarshalHash() (o []byte, err error) {
var b []byte
o = hsp.Require(b, z.Msgsize())
- // map header, size 9
- o = append(o, 0x89, 0x89)
+ // map header, size 10
+ o = append(o, 0x8a, 0x8a)
if z.Genesis == nil {
o = hsp.AppendNil(o)
} else {
@@ -140,13 +165,13 @@ func (z *SQLChainProfile) MarshalHash() (o []byte, err error) {
o = hsp.AppendBytes(o, oTemp)
}
}
- o = append(o, 0x89)
+ o = append(o, 0x8a)
if oTemp, err := z.TokenType.MarshalHash(); err != nil {
return nil, err
} else {
o = hsp.AppendBytes(o, oTemp)
}
- o = append(o, 0x89)
+ o = append(o, 0x8a)
o = hsp.AppendArrayHeader(o, uint32(len(z.Miners)))
for za0001 := range z.Miners {
if z.Miners[za0001] == nil {
@@ -159,7 +184,7 @@ func (z *SQLChainProfile) MarshalHash() (o []byte, err error) {
}
}
}
- o = append(o, 0x89)
+ o = append(o, 0x8a)
o = hsp.AppendArrayHeader(o, uint32(len(z.Users)))
for za0002 := range z.Users {
if z.Users[za0002] == nil {
@@ -172,28 +197,30 @@ func (z *SQLChainProfile) MarshalHash() (o []byte, err error) {
}
}
}
- o = append(o, 0x89)
+ o = append(o, 0x8a)
if oTemp, err := z.Owner.MarshalHash(); err != nil {
return nil, err
} else {
o = hsp.AppendBytes(o, oTemp)
}
- o = append(o, 0x89)
+ o = append(o, 0x8a)
if oTemp, err := z.Address.MarshalHash(); err != nil {
return nil, err
} else {
o = hsp.AppendBytes(o, oTemp)
}
- o = append(o, 0x89)
+ o = append(o, 0x8a)
if oTemp, err := z.ID.MarshalHash(); err != nil {
return nil, err
} else {
o = hsp.AppendBytes(o, oTemp)
}
- o = append(o, 0x89)
- o = hsp.AppendUint64(o, z.GasPrice)
- o = append(o, 0x89)
+ o = append(o, 0x8a)
+ o = hsp.AppendUint32(o, z.LastUpdatedHeight)
+ o = append(o, 0x8a)
o = hsp.AppendUint64(o, z.Period)
+ o = append(o, 0x8a)
+ o = hsp.AppendUint64(o, z.GasPrice)
return
}
@@ -221,7 +248,7 @@ func (z *SQLChainProfile) Msgsize() (s int) {
s += z.Users[za0002].Msgsize()
}
}
- s += 6 + z.Owner.Msgsize() + 8 + z.Address.Msgsize() + 3 + z.ID.Msgsize() + 9 + hsp.Uint64Size + 7 + hsp.Uint64Size
+ s += 6 + z.Owner.Msgsize() + 8 + z.Address.Msgsize() + 3 + z.ID.Msgsize() + 18 + hsp.Uint32Size + 7 + hsp.Uint64Size + 9 + hsp.Uint64Size
return
}
@@ -283,6 +310,28 @@ func (z Status) Msgsize() (s int) {
return
}
+// MarshalHash marshals for hash
+func (z *UserArrears) MarshalHash() (o []byte, err error) {
+ var b []byte
+ o = hsp.Require(b, z.Msgsize())
+ // map header, size 2
+ o = append(o, 0x82, 0x82)
+ if oTemp, err := z.User.MarshalHash(); err != nil {
+ return nil, err
+ } else {
+ o = hsp.AppendBytes(o, oTemp)
+ }
+ o = append(o, 0x82)
+ o = hsp.AppendUint64(o, z.Arrears)
+ return
+}
+
+// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
+func (z *UserArrears) Msgsize() (s int) {
+ s = 1 + 5 + z.User.Msgsize() + 8 + hsp.Uint64Size
+ return
+}
+
// MarshalHash marshals for hash
func (z UserPermission) MarshalHash() (o []byte, err error) {
var b []byte
diff --git a/types/account_gen_test.go b/types/account_gen_test.go
index 57a2feee1..30e9ad803 100644
--- a/types/account_gen_test.go
+++ b/types/account_gen_test.go
@@ -193,3 +193,40 @@ func BenchmarkAppendMsgSQLChainUser(b *testing.B) {
bts, _ = v.MarshalHash()
}
}
+
+func TestMarshalHashUserArrears(t *testing.T) {
+ v := UserArrears{}
+ binary.Read(rand.Reader, binary.BigEndian, &v)
+ bts1, err := v.MarshalHash()
+ if err != nil {
+ t.Fatal(err)
+ }
+ bts2, err := v.MarshalHash()
+ if err != nil {
+ t.Fatal(err)
+ }
+ if !bytes.Equal(bts1, bts2) {
+ t.Fatal("hash not stable")
+ }
+}
+
+func BenchmarkMarshalHashUserArrears(b *testing.B) {
+ v := UserArrears{}
+ b.ReportAllocs()
+ b.ResetTimer()
+ for i := 0; i < b.N; i++ {
+ v.MarshalHash()
+ }
+}
+
+func BenchmarkAppendMsgUserArrears(b *testing.B) {
+ v := UserArrears{}
+ bts := make([]byte, 0, v.Msgsize())
+ bts, _ = v.MarshalHash()
+ b.SetBytes(int64(len(bts)))
+ b.ReportAllocs()
+ b.ResetTimer()
+ for i := 0; i < b.N; i++ {
+ bts, _ = v.MarshalHash()
+ }
+}
diff --git a/types/bprpc.go b/types/bprpc.go
index 59e1b9ad2..71a748ff7 100644
--- a/types/bprpc.go
+++ b/types/bprpc.go
@@ -170,4 +170,3 @@ type QuerySQLChainProfileResp struct {
proto.Envelope
Profile SQLChainProfile
}
-
diff --git a/types/chainstate.go b/types/chainstate.go
new file mode 100644
index 000000000..d77bbe82b
--- /dev/null
+++ b/types/chainstate.go
@@ -0,0 +1,118 @@
+/*
+ * Copyright 2018 The CovenantSQL Authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package types
+
+import (
+ "github.com/CovenantSQL/CovenantSQL/crypto/hash"
+ "github.com/CovenantSQL/CovenantSQL/proto"
+ "github.com/CovenantSQL/CovenantSQL/utils"
+ "github.com/pkg/errors"
+)
+
+type ChainState struct {
+ DatabaseID proto.DatabaseID
+ Users []*SQLChainUser
+ Miner []*MinerInfo
+ GasPrice uint64
+ TokenType TokenType
+ MCHeight uint32
+ HeightTx []*hash.Hash
+}
+
+func NewChainState(profile *SQLChainProfile, height uint32, createDB hash.Hash) *ChainState {
+ return &ChainState{
+ DatabaseID: profile.ID,
+ Users: profile.Users,
+ Miner: profile.Miners,
+ GasPrice: profile.GasPrice,
+ TokenType: profile.TokenType,
+ MCHeight: height,
+ HeightTx: []*hash.Hash{ &createDB },
+ }
+}
+
+func (cs *ChainState) AddAdvancePayment(transfer *Transfer, count uint32) (err error) {
+ if transfer.Receiver.DatabaseID() != cs.DatabaseID {
+ err = errors.Wrap(ErrNotExists, "mismatch databaseID when add advance payment")
+ return
+ }
+
+ exist := false
+ for _, user := range cs.Users {
+ // TODO(lambda): add token type in types.Transfer
+ if user.Address == transfer.Sender {
+ res, flow := utils.SafeAdd(user.AdvancePayment, transfer.Amount)
+ if !flow {
+ exist = true
+ user.AdvancePayment = res
+ err = cs.updateHeightAndTx(count, transfer.Hash())
+ if err != nil {
+ return
+ }
+ break
+ } else {
+ err = errors.Wrap(ErrOverflow, "add advance payment overflow")
+ return
+ }
+ }
+ }
+
+ if !exist {
+ err = errors.Wrap(ErrNoSuchUser, "add advance payment for non-existing user")
+ }
+ return
+}
+
+func (cs *ChainState) UpdatePermission(up *UpdatePermission, count uint32) (err error) {
+ if up.TargetSQLChain.DatabaseID() != cs.DatabaseID {
+ err = errors.Wrap(ErrNotExists, "mismatch databaseID when update permission")
+ return
+ }
+
+ newUser := true
+ for _, user := range cs.Users {
+ if user.Address == up.TargetUser {
+ user.Permission = up.Permission
+ newUser = false
+ return cs.updateHeightAndTx(count, up.Hash())
+ }
+ }
+ if newUser {
+ cs.Users = append(cs.Users, &SQLChainUser{
+ Address: up.TargetUser,
+ Permission: up.Permission,
+ })
+ return cs.updateHeightAndTx(count, up.Hash())
+ }
+
+ return
+}
+
+func (cs *ChainState) updateHeightAndTx(count uint32, tx hash.Hash) (err error) {
+ if cs.MCHeight == count {
+ cs.HeightTx = append(cs.HeightTx, &tx)
+ } else if cs.MCHeight > count {
+ err = errors.Wrap(ErrInvalidHeight, "receive old height when update height")
+ return
+ } else {
+ cs.HeightTx = []*hash.Hash{
+ &tx,
+ }
+ cs.MCHeight = count
+ }
+ return
+}
diff --git a/types/errors.go b/types/errors.go
index 3f7726ba2..882074aa9 100644
--- a/types/errors.go
+++ b/types/errors.go
@@ -34,4 +34,12 @@ var (
ErrBillingNotMatch = errors.New("billing request doesn't match")
// ErrHashVerification indicates a failed hash verification.
ErrHashVerification = errors.New("hash verification failed")
+ // ErrNotExists defines errors on manipulating a non-exists database instance.
+ ErrNotExists = errors.New("database instance not exists")
+ // ErrNoSuchUser indicates that user do not exist.
+ ErrNoSuchUser = errors.New("user not exist")
+ // ErrOverflow indicates computing overflow.
+ ErrOverflow = errors.New("computing overflow")
+ // ErrInvalidHeight indicates that received height is smaller than current height.
+ ErrInvalidHeight = errors.New("received height is smaller than current height")
)
diff --git a/types/init_service_type.go b/types/init_service_type.go
index acaf5eb7d..64686e9fa 100644
--- a/types/init_service_type.go
+++ b/types/init_service_type.go
@@ -45,6 +45,7 @@ type ServiceInstance struct {
Peers *proto.Peers
ResourceMeta ResourceMeta
GenesisBlock *Block
+ Profile *SQLChainProfile
}
// InitServiceResponseHeader defines worker service init response header.
diff --git a/types/init_service_type_gen.go b/types/init_service_type_gen.go
index 27008aa2e..b3a118987 100644
--- a/types/init_service_type_gen.go
+++ b/types/init_service_type_gen.go
@@ -111,8 +111,8 @@ func (z *ResourceMeta) Msgsize() (s int) {
func (z *ServiceInstance) MarshalHash() (o []byte, err error) {
var b []byte
o = hsp.Require(b, z.Msgsize())
- // map header, size 4
- o = append(o, 0x84, 0x84)
+ // map header, size 5
+ o = append(o, 0x85, 0x85)
if z.GenesisBlock == nil {
o = hsp.AppendNil(o)
} else {
@@ -122,7 +122,17 @@ func (z *ServiceInstance) MarshalHash() (o []byte, err error) {
o = hsp.AppendBytes(o, oTemp)
}
}
- o = append(o, 0x84)
+ o = append(o, 0x85)
+ if z.Profile == nil {
+ o = hsp.AppendNil(o)
+ } else {
+ if oTemp, err := z.Profile.MarshalHash(); err != nil {
+ return nil, err
+ } else {
+ o = hsp.AppendBytes(o, oTemp)
+ }
+ }
+ o = append(o, 0x85)
if z.Peers == nil {
o = hsp.AppendNil(o)
} else {
@@ -132,13 +142,13 @@ func (z *ServiceInstance) MarshalHash() (o []byte, err error) {
o = hsp.AppendBytes(o, oTemp)
}
}
- o = append(o, 0x84)
+ o = append(o, 0x85)
if oTemp, err := z.ResourceMeta.MarshalHash(); err != nil {
return nil, err
} else {
o = hsp.AppendBytes(o, oTemp)
}
- o = append(o, 0x84)
+ o = append(o, 0x85)
if oTemp, err := z.DatabaseID.MarshalHash(); err != nil {
return nil, err
} else {
@@ -155,6 +165,12 @@ func (z *ServiceInstance) Msgsize() (s int) {
} else {
s += z.GenesisBlock.Msgsize()
}
+ s += 8
+ if z.Profile == nil {
+ s += hsp.NilSize
+ } else {
+ s += z.Profile.Msgsize()
+ }
s += 6
if z.Peers == nil {
s += hsp.NilSize
diff --git a/types/provideservice.go b/types/provideservice.go
index 9b7c8c4bb..4dbc0ddeb 100644
--- a/types/provideservice.go
+++ b/types/provideservice.go
@@ -34,7 +34,7 @@ type ProvideServiceHeader struct {
TargetUser proto.AccountAddress
GasPrice uint64
TokenType TokenType
- NodeID proto.NodeID
+ NodeID proto.NodeID
Nonce interfaces.AccountNonce
}
diff --git a/types/request_type_gen.go b/types/request_type_gen.go
index 709e66bb9..7033d7aa6 100644
--- a/types/request_type_gen.go
+++ b/types/request_type_gen.go
@@ -106,10 +106,20 @@ func (z *Request) MarshalHash() (o []byte, err error) {
o = append(o, 0x83, 0x83, 0x81, 0x81)
o = hsp.AppendArrayHeader(o, uint32(len(z.Payload.Queries)))
for za0001 := range z.Payload.Queries {
- if oTemp, err := z.Payload.Queries[za0001].MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
+ // map header, size 2
+ o = append(o, 0x82, 0x82)
+ o = hsp.AppendString(o, z.Payload.Queries[za0001].Pattern)
+ o = append(o, 0x82)
+ o = hsp.AppendArrayHeader(o, uint32(len(z.Payload.Queries[za0001].Args)))
+ for za0002 := range z.Payload.Queries[za0001].Args {
+ // map header, size 2
+ o = append(o, 0x82, 0x82)
+ o = hsp.AppendString(o, z.Payload.Queries[za0001].Args[za0002].Name)
+ o = append(o, 0x82)
+ o, err = hsp.AppendIntf(o, z.Payload.Queries[za0001].Args[za0002].Value)
+ if err != nil {
+ return
+ }
}
}
// map header, size 2
@@ -138,7 +148,10 @@ func (z *Request) MarshalHash() (o []byte, err error) {
func (z *Request) Msgsize() (s int) {
s = 1 + 8 + 1 + 8 + hsp.ArrayHeaderSize
for za0001 := range z.Payload.Queries {
- s += z.Payload.Queries[za0001].Msgsize()
+ s += 1 + 8 + hsp.StringPrefixSize + len(z.Payload.Queries[za0001].Pattern) + 5 + hsp.ArrayHeaderSize
+ for za0002 := range z.Payload.Queries[za0001].Args {
+ s += 1 + 5 + hsp.StringPrefixSize + len(z.Payload.Queries[za0001].Args[za0002].Name) + 6 + hsp.GuessSize(z.Payload.Queries[za0001].Args[za0002].Value)
+ }
}
s += 7 + 1 + 14 + z.Header.RequestHeader.Msgsize() + 28 + z.Header.DefaultHashSignVerifierImpl.Msgsize() + 9 + z.Envelope.Msgsize()
return
diff --git a/types/updatebilling.go b/types/updatebilling.go
new file mode 100644
index 000000000..731ec82df
--- /dev/null
+++ b/types/updatebilling.go
@@ -0,0 +1,87 @@
+/*
+ * Copyright 2018 The CovenantSQL Authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package types
+
+import (
+ pi "github.com/CovenantSQL/CovenantSQL/blockproducer/interfaces"
+ "github.com/CovenantSQL/CovenantSQL/crypto"
+ "github.com/CovenantSQL/CovenantSQL/crypto/asymmetric"
+ "github.com/CovenantSQL/CovenantSQL/crypto/verifier"
+ "github.com/CovenantSQL/CovenantSQL/proto"
+)
+
+//go:generate hsp
+
+// MinerIncome defines the income of miner.
+type MinerIncome struct {
+ Miner proto.AccountAddress
+ Income uint64
+}
+
+// UserCost defines the cost of user.
+type UserCost struct {
+ User proto.AccountAddress
+ Cost uint64
+ Miners []*MinerIncome
+}
+
+// UpdateBillingHeader defines the UpdateBilling transaction header.
+type UpdateBillingHeader struct {
+ Receiver proto.AccountAddress
+ Nonce pi.AccountNonce
+ Users []*UserCost
+}
+
+// UpdateBilling defines the UpdateBilling transaction.
+type UpdateBilling struct {
+ UpdateBillingHeader
+ pi.TransactionTypeMixin
+ verifier.DefaultHashSignVerifierImpl
+}
+
+// NewUpdateBilling returns new instance.
+func NewUpdateBilling(header *UpdateBillingHeader) *UpdateBilling {
+ return &UpdateBilling{
+ UpdateBillingHeader: *header,
+ TransactionTypeMixin: *pi.NewTransactionTypeMixin(pi.TransactionTypeTransfer),
+ }
+}
+
+// GetAccountAddress implements interfaces/Transaction.GetAccountAddress.
+func (ub *UpdateBilling) GetAccountAddress() proto.AccountAddress {
+ addr, _ := crypto.PubKeyHash(ub.Signee)
+ return addr
+}
+
+// GetAccountNonce implements interfaces/Transaction.GetAccountNonce.
+func (ub *UpdateBilling) GetAccountNonce() pi.AccountNonce {
+ return ub.Nonce
+}
+
+// Sign implements interfaces/Transaction.Sign.
+func (ub *UpdateBilling) Sign(signer *asymmetric.PrivateKey) (err error) {
+ return ub.DefaultHashSignVerifierImpl.Sign(&ub.UpdateBillingHeader, signer)
+}
+
+// Verify implements interfaces/Transaction.Verify.
+func (ub *UpdateBilling) Verify() (err error) {
+ return ub.DefaultHashSignVerifierImpl.Verify(&ub.UpdateBillingHeader)
+}
+
+func init() {
+ pi.RegisterTransaction(pi.TransactionTypeUpdateBilling, (*Transfer)(nil))
+}
diff --git a/types/updatebilling_gen.go b/types/updatebilling_gen.go
new file mode 100644
index 000000000..fb471f34f
--- /dev/null
+++ b/types/updatebilling_gen.go
@@ -0,0 +1,155 @@
+package types
+
+// Code generated by github.com/CovenantSQL/HashStablePack DO NOT EDIT.
+
+import (
+ hsp "github.com/CovenantSQL/HashStablePack/marshalhash"
+)
+
+// MarshalHash marshals for hash
+func (z *MinerIncome) MarshalHash() (o []byte, err error) {
+ var b []byte
+ o = hsp.Require(b, z.Msgsize())
+ // map header, size 2
+ o = append(o, 0x82, 0x82)
+ if oTemp, err := z.Miner.MarshalHash(); err != nil {
+ return nil, err
+ } else {
+ o = hsp.AppendBytes(o, oTemp)
+ }
+ o = append(o, 0x82)
+ o = hsp.AppendUint64(o, z.Income)
+ return
+}
+
+// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
+func (z *MinerIncome) Msgsize() (s int) {
+ s = 1 + 6 + z.Miner.Msgsize() + 7 + hsp.Uint64Size
+ return
+}
+
+// MarshalHash marshals for hash
+func (z *UpdateBilling) MarshalHash() (o []byte, err error) {
+ var b []byte
+ o = hsp.Require(b, z.Msgsize())
+ // map header, size 3
+ o = append(o, 0x83, 0x83)
+ if oTemp, err := z.UpdateBillingHeader.MarshalHash(); err != nil {
+ return nil, err
+ } else {
+ o = hsp.AppendBytes(o, oTemp)
+ }
+ o = append(o, 0x83)
+ if oTemp, err := z.TransactionTypeMixin.MarshalHash(); err != nil {
+ return nil, err
+ } else {
+ o = hsp.AppendBytes(o, oTemp)
+ }
+ o = append(o, 0x83)
+ if oTemp, err := z.DefaultHashSignVerifierImpl.MarshalHash(); err != nil {
+ return nil, err
+ } else {
+ o = hsp.AppendBytes(o, oTemp)
+ }
+ return
+}
+
+// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
+func (z *UpdateBilling) Msgsize() (s int) {
+ s = 1 + 20 + z.UpdateBillingHeader.Msgsize() + 21 + z.TransactionTypeMixin.Msgsize() + 28 + z.DefaultHashSignVerifierImpl.Msgsize()
+ return
+}
+
+// MarshalHash marshals for hash
+func (z *UpdateBillingHeader) MarshalHash() (o []byte, err error) {
+ var b []byte
+ o = hsp.Require(b, z.Msgsize())
+ // map header, size 3
+ o = append(o, 0x83, 0x83)
+ o = hsp.AppendArrayHeader(o, uint32(len(z.Users)))
+ for za0001 := range z.Users {
+ if z.Users[za0001] == nil {
+ o = hsp.AppendNil(o)
+ } else {
+ if oTemp, err := z.Users[za0001].MarshalHash(); err != nil {
+ return nil, err
+ } else {
+ o = hsp.AppendBytes(o, oTemp)
+ }
+ }
+ }
+ o = append(o, 0x83)
+ if oTemp, err := z.Nonce.MarshalHash(); err != nil {
+ return nil, err
+ } else {
+ o = hsp.AppendBytes(o, oTemp)
+ }
+ o = append(o, 0x83)
+ if oTemp, err := z.Receiver.MarshalHash(); err != nil {
+ return nil, err
+ } else {
+ o = hsp.AppendBytes(o, oTemp)
+ }
+ return
+}
+
+// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
+func (z *UpdateBillingHeader) Msgsize() (s int) {
+ s = 1 + 6 + hsp.ArrayHeaderSize
+ for za0001 := range z.Users {
+ if z.Users[za0001] == nil {
+ s += hsp.NilSize
+ } else {
+ s += z.Users[za0001].Msgsize()
+ }
+ }
+ s += 6 + z.Nonce.Msgsize() + 9 + z.Receiver.Msgsize()
+ return
+}
+
+// MarshalHash marshals for hash
+func (z *UserCost) MarshalHash() (o []byte, err error) {
+ var b []byte
+ o = hsp.Require(b, z.Msgsize())
+ // map header, size 3
+ o = append(o, 0x83, 0x83)
+ o = hsp.AppendArrayHeader(o, uint32(len(z.Miners)))
+ for za0001 := range z.Miners {
+ if z.Miners[za0001] == nil {
+ o = hsp.AppendNil(o)
+ } else {
+ // map header, size 2
+ o = append(o, 0x82, 0x82)
+ if oTemp, err := z.Miners[za0001].Miner.MarshalHash(); err != nil {
+ return nil, err
+ } else {
+ o = hsp.AppendBytes(o, oTemp)
+ }
+ o = append(o, 0x82)
+ o = hsp.AppendUint64(o, z.Miners[za0001].Income)
+ }
+ }
+ o = append(o, 0x83)
+ if oTemp, err := z.User.MarshalHash(); err != nil {
+ return nil, err
+ } else {
+ o = hsp.AppendBytes(o, oTemp)
+ }
+ o = append(o, 0x83)
+ o = hsp.AppendUint64(o, z.Cost)
+ return
+}
+
+// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
+func (z *UserCost) Msgsize() (s int) {
+ s = 1 + 7 + hsp.ArrayHeaderSize
+ for za0001 := range z.Miners {
+ if z.Miners[za0001] == nil {
+ s += hsp.NilSize
+ } else {
+ s += 1 + 6 + z.Miners[za0001].Miner.Msgsize() + 7 + hsp.Uint64Size
+ }
+ }
+ s += 5 + z.User.Msgsize() + 5 + hsp.Uint64Size
+ return
+}
diff --git a/types/updatebilling_gen_test.go b/types/updatebilling_gen_test.go
new file mode 100644
index 000000000..d6ab30c03
--- /dev/null
+++ b/types/updatebilling_gen_test.go
@@ -0,0 +1,158 @@
+package types
+
+// Code generated by github.com/CovenantSQL/HashStablePack DO NOT EDIT.
+
+import (
+ "bytes"
+ "crypto/rand"
+ "encoding/binary"
+ "testing"
+)
+
+func TestMarshalHashMinerIncome(t *testing.T) {
+ v := MinerIncome{}
+ binary.Read(rand.Reader, binary.BigEndian, &v)
+ bts1, err := v.MarshalHash()
+ if err != nil {
+ t.Fatal(err)
+ }
+ bts2, err := v.MarshalHash()
+ if err != nil {
+ t.Fatal(err)
+ }
+ if !bytes.Equal(bts1, bts2) {
+ t.Fatal("hash not stable")
+ }
+}
+
+func BenchmarkMarshalHashMinerIncome(b *testing.B) {
+ v := MinerIncome{}
+ b.ReportAllocs()
+ b.ResetTimer()
+ for i := 0; i < b.N; i++ {
+ v.MarshalHash()
+ }
+}
+
+func BenchmarkAppendMsgMinerIncome(b *testing.B) {
+ v := MinerIncome{}
+ bts := make([]byte, 0, v.Msgsize())
+ bts, _ = v.MarshalHash()
+ b.SetBytes(int64(len(bts)))
+ b.ReportAllocs()
+ b.ResetTimer()
+ for i := 0; i < b.N; i++ {
+ bts, _ = v.MarshalHash()
+ }
+}
+
+func TestMarshalHashUpdateBilling(t *testing.T) {
+ v := UpdateBilling{}
+ binary.Read(rand.Reader, binary.BigEndian, &v)
+ bts1, err := v.MarshalHash()
+ if err != nil {
+ t.Fatal(err)
+ }
+ bts2, err := v.MarshalHash()
+ if err != nil {
+ t.Fatal(err)
+ }
+ if !bytes.Equal(bts1, bts2) {
+ t.Fatal("hash not stable")
+ }
+}
+
+func BenchmarkMarshalHashUpdateBilling(b *testing.B) {
+ v := UpdateBilling{}
+ b.ReportAllocs()
+ b.ResetTimer()
+ for i := 0; i < b.N; i++ {
+ v.MarshalHash()
+ }
+}
+
+func BenchmarkAppendMsgUpdateBilling(b *testing.B) {
+ v := UpdateBilling{}
+ bts := make([]byte, 0, v.Msgsize())
+ bts, _ = v.MarshalHash()
+ b.SetBytes(int64(len(bts)))
+ b.ReportAllocs()
+ b.ResetTimer()
+ for i := 0; i < b.N; i++ {
+ bts, _ = v.MarshalHash()
+ }
+}
+
+func TestMarshalHashUpdateBillingHeader(t *testing.T) {
+ v := UpdateBillingHeader{}
+ binary.Read(rand.Reader, binary.BigEndian, &v)
+ bts1, err := v.MarshalHash()
+ if err != nil {
+ t.Fatal(err)
+ }
+ bts2, err := v.MarshalHash()
+ if err != nil {
+ t.Fatal(err)
+ }
+ if !bytes.Equal(bts1, bts2) {
+ t.Fatal("hash not stable")
+ }
+}
+
+func BenchmarkMarshalHashUpdateBillingHeader(b *testing.B) {
+ v := UpdateBillingHeader{}
+ b.ReportAllocs()
+ b.ResetTimer()
+ for i := 0; i < b.N; i++ {
+ v.MarshalHash()
+ }
+}
+
+func BenchmarkAppendMsgUpdateBillingHeader(b *testing.B) {
+ v := UpdateBillingHeader{}
+ bts := make([]byte, 0, v.Msgsize())
+ bts, _ = v.MarshalHash()
+ b.SetBytes(int64(len(bts)))
+ b.ReportAllocs()
+ b.ResetTimer()
+ for i := 0; i < b.N; i++ {
+ bts, _ = v.MarshalHash()
+ }
+}
+
+func TestMarshalHashUserCost(t *testing.T) {
+ v := UserCost{}
+ binary.Read(rand.Reader, binary.BigEndian, &v)
+ bts1, err := v.MarshalHash()
+ if err != nil {
+ t.Fatal(err)
+ }
+ bts2, err := v.MarshalHash()
+ if err != nil {
+ t.Fatal(err)
+ }
+ if !bytes.Equal(bts1, bts2) {
+ t.Fatal("hash not stable")
+ }
+}
+
+func BenchmarkMarshalHashUserCost(b *testing.B) {
+ v := UserCost{}
+ b.ReportAllocs()
+ b.ResetTimer()
+ for i := 0; i < b.N; i++ {
+ v.MarshalHash()
+ }
+}
+
+func BenchmarkAppendMsgUserCost(b *testing.B) {
+ v := UserCost{}
+ bts := make([]byte, 0, v.Msgsize())
+ bts, _ = v.MarshalHash()
+ b.SetBytes(int64(len(bts)))
+ b.ReportAllocs()
+ b.ResetTimer()
+ for i := 0; i < b.N; i++ {
+ bts, _ = v.MarshalHash()
+ }
+}
diff --git a/utils/request.go b/utils/request.go
new file mode 100644
index 000000000..cc758c4e9
--- /dev/null
+++ b/utils/request.go
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2018 The CovenantSQL Authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package utils
+
+import (
+ "github.com/CovenantSQL/CovenantSQL/proto"
+ "github.com/CovenantSQL/CovenantSQL/rpc"
+)
+
+func RequestBP(method string, req interface{}, resp interface{}) (err error) {
+ var bp proto.NodeID
+ if bp, err = rpc.GetCurrentBP(); err != nil {
+ return err
+ }
+ return rpc.NewCaller().CallNode(bp, method, req, resp)
+}
diff --git a/worker/db.go b/worker/db.go
index ba2c7289f..7b039e4fe 100644
--- a/worker/db.go
+++ b/worker/db.go
@@ -70,13 +70,14 @@ type Database struct {
}
// NewDatabase create a single database instance using config.
-func NewDatabase(cfg *DBConfig, peers *proto.Peers, genesisBlock *types.Block) (db *Database, err error) {
+func NewDatabase(cfg *DBConfig, peers *proto.Peers,
+ profile *types.SQLChainProfile, busService *sqlchain.BusService) (db *Database, err error) {
// ensure dir exists
if err = os.MkdirAll(cfg.DataDir, 0755); err != nil {
return
}
- if peers == nil || genesisBlock == nil {
+ if peers == nil || profile.Genesis == nil {
err = ErrInvalidDBConfig
return
}
@@ -126,7 +127,7 @@ func NewDatabase(cfg *DBConfig, peers *proto.Peers, genesisBlock *types.Block) (
DatabaseID: cfg.DatabaseID,
ChainFilePrefix: chainFile,
DataFile: storageDSN.Format(),
- Genesis: genesisBlock,
+ Genesis: profile.Genesis,
Peers: peers,
// TODO(xq262144): should refactor server/node definition to conf/proto package
@@ -138,8 +139,10 @@ func NewDatabase(cfg *DBConfig, peers *proto.Peers, genesisBlock *types.Block) (
Period: 60 * time.Second,
Tick: 10 * time.Second,
QueryTTL: 10,
+
+ Profile: profile,
}
- if db.chain, err = sqlchain.NewChain(chainCfg); err != nil {
+ if db.chain, err = sqlchain.NewChain(chainCfg, busService); err != nil {
return
} else if err = db.chain.Start(); err != nil {
return
diff --git a/worker/dbms.go b/worker/dbms.go
index 468d9227e..920093358 100644
--- a/worker/dbms.go
+++ b/worker/dbms.go
@@ -19,15 +19,15 @@ package worker
import (
"bytes"
"context"
- "github.com/CovenantSQL/CovenantSQL/blockproducer/interfaces"
- "github.com/CovenantSQL/CovenantSQL/crypto/asymmetric"
- "github.com/CovenantSQL/CovenantSQL/crypto/kms"
"io/ioutil"
"os"
"path/filepath"
"sync"
+ "github.com/CovenantSQL/CovenantSQL/blockproducer/interfaces"
"github.com/CovenantSQL/CovenantSQL/crypto"
+ "github.com/CovenantSQL/CovenantSQL/crypto/asymmetric"
+ "github.com/CovenantSQL/CovenantSQL/crypto/kms"
"github.com/CovenantSQL/CovenantSQL/proto"
"github.com/CovenantSQL/CovenantSQL/route"
"github.com/CovenantSQL/CovenantSQL/rpc"
@@ -52,13 +52,12 @@ const (
type DBMS struct {
cfg *DBMSConfig
dbMap sync.Map
+ chainMap sync.Map
kayakMux *DBKayakMuxService
chainMux *sqlchain.MuxService
rpc *DBMSRPCService
- // TODO(lambda): change it to chain bus after chain bus finished.
- profileMap map[proto.DatabaseID]*types.SQLChainProfile
busService *sqlchain.BusService
- address proto.AccountAddress
+ address proto.AccountAddress
}
// NewDBMS returns new database management instance.
@@ -86,7 +85,7 @@ func NewDBMS(cfg *DBMSConfig) (dbms *DBMS, err error) {
// cache address of node
var (
- pk *asymmetric.PublicKey
+ pk *asymmetric.PublicKey
addr proto.AccountAddress
)
if pk, err = kms.GetLocalPublicKey(); err != nil {
@@ -102,7 +101,6 @@ func NewDBMS(cfg *DBMSConfig) (dbms *DBMS, err error) {
// init service
dbms.rpc = NewDBMSRPCService(route.DBRPCName, cfg.Server, dbms)
-
return
}
@@ -142,6 +140,12 @@ func (dbms *DBMS) writeMeta() (err error) {
return true
})
+ dbms.chainMap.Range(func(key, value interface{}) bool {
+ dbID := key.(proto.DatabaseID)
+ meta.ChainState[dbID] = value.(types.ChainState)
+ return true
+ })
+
var buf *bytes.Buffer
if buf, err = utils.EncodeMsgPack(meta); err != nil {
return
@@ -176,7 +180,11 @@ func (dbms *DBMS) Init() (err error) {
}
dbms.busService.Start()
- if err = dbms.busService.Subscribe("CreateDatabase", dbms.createDatabase); err != nil {
+ if err = dbms.busService.Subscribe("/CreateDatabase/", dbms.createDatabase); err != nil {
+ err = errors.Wrap(err, "init chain bus failed")
+ return
+ }
+ if err = dbms.busService.Subscribe("/UpdatePermission/", dbms.updatePermission); err != nil {
err = errors.Wrap(err, "init chain bus failed")
return
}
@@ -184,7 +192,7 @@ func (dbms *DBMS) Init() (err error) {
return
}
-func (dbms *DBMS) createDatabase(tx interfaces.Transaction) {
+func (dbms *DBMS) createDatabase(tx interfaces.Transaction, count uint32) {
var cd *types.CreateDatabase
switch t := tx.(type) {
case *types.CreateDatabase:
@@ -194,30 +202,39 @@ func (dbms *DBMS) createDatabase(tx interfaces.Transaction) {
"tx_type": t.GetTransactionType().String(),
"tx_hash": t.Hash().String(),
"tx_addr": t.GetAccountAddress().String(),
- }).WithError(ErrInvalidTransactionType)
- }
-
- if cd.Owner != dbms.address {
+ }).WithError(ErrInvalidTransactionType).Debug("unexpected error")
return
}
- dbid := proto.FromAccountAndNonce(cd.Owner, uint32(cd.Nonce))
- p := dbms.busService.RequestSQLProfile(dbid)
- var nodeIDs [len(p.Miners)]proto.NodeID
+ var (
+ dbid = proto.FromAccountAndNonce(cd.Owner, uint32(cd.Nonce))
+ p = dbms.busService.RequestSQLProfile(dbid)
+ nodeIDs [len(p.Miners)]proto.NodeID
+ isTargetMiner = false
+ )
+
for i, mi := range p.Miners {
+ if mi.Address == dbms.address {
+ isTargetMiner = true
+ }
nodeIDs[i] = mi.NodeID
}
+ if !isTargetMiner {
+ return
+ }
+
peers := proto.Peers{
PeersHeader: proto.PeersHeader{
- Leader: nodeIDs[0],
+ Leader: nodeIDs[0],
Servers: nodeIDs[:],
},
}
si := types.ServiceInstance{
- DatabaseID: *dbid,
- Peers: &peers,
+ DatabaseID: *dbid,
+ Peers: &peers,
ResourceMeta: cd.ResourceMeta,
GenesisBlock: p.Genesis,
+ Profile: p,
}
err := dbms.Create(&si, true)
if err != nil {
@@ -225,6 +242,38 @@ func (dbms *DBMS) createDatabase(tx interfaces.Transaction) {
}
}
+func (dbms *DBMS) updatePermission(tx interfaces.Transaction, count uint32) {
+ var up *types.UpdatePermission
+ switch t := tx.(type) {
+ case *types.UpdatePermission:
+ up = t
+ default:
+ log.WithFields(log.Fields{
+ "tx_type": t.GetTransactionType().String(),
+ "tx_hash": t.Hash().String(),
+ "tx_addr": t.GetAccountAddress().String(),
+ }).WithError(ErrInvalidTransactionType).Debug("unexpected error")
+ return
+ }
+
+ state, loaded := dbms.chainMap.Load(up.TargetSQLChain.DatabaseID())
+ if !loaded {
+ return
+ }
+
+ newState := state.(types.ChainState)
+ err := newState.UpdatePermission(up, count)
+ if err != nil {
+ log.WithError(err).Debug("unexpected error")
+ return
+ }
+ dbms.chainMap.Store(up.TargetSQLChain.DatabaseID(), newState)
+ err = dbms.writeMeta()
+ if err != nil {
+ log.WithError(err).Debug("unexpected error")
+ }
+}
+
func (dbms *DBMS) initDatabases(meta *DBMSMeta, conf []types.ServiceInstance) (err error) {
currentInstance := make(map[proto.DatabaseID]bool)
@@ -244,6 +293,15 @@ func (dbms *DBMS) initDatabases(meta *DBMSMeta, conf []types.ServiceInstance) (e
}
}
+ // init chain state
+ for dbID, state := range meta.ChainState {
+ dbms.chainMap.Store(dbID, state)
+ }
+ err = dbms.writeMeta()
+ if err != nil {
+ return
+ }
+
// drop database
for dbID := range toDropInstance {
if err = dbms.Drop(dbID); err != nil {
@@ -294,7 +352,7 @@ func (dbms *DBMS) Create(instance *types.ServiceInstance, cleanup bool) (err err
SpaceLimit: instance.ResourceMeta.Space,
}
- if db, err = NewDatabase(dbCfg, instance.Peers, instance.GenesisBlock); err != nil {
+ if db, err = NewDatabase(dbCfg, instance.Peers, instance.Profile, dbms.busService); err != nil {
return
}
@@ -356,7 +414,6 @@ func (dbms *DBMS) Query(req *types.Request) (res *types.Response, err error) {
return
}
- // send query
return db.Query(req)
}
@@ -395,6 +452,14 @@ func (dbms *DBMS) addMeta(dbID proto.DatabaseID, db *Database) (err error) {
return dbms.writeMeta()
}
+func (dbms *DBMS) addState(dbID proto.DatabaseID, state *types.ChainState) (err error) {
+ if _, alreadyExists := dbms.chainMap.LoadOrStore(dbID, state); alreadyExists {
+ return ErrAlreadyExists
+ }
+
+ return dbms.writeMeta()
+}
+
func (dbms *DBMS) removeMeta(dbID proto.DatabaseID) (err error) {
dbms.dbMap.Delete(dbID)
return dbms.writeMeta()
@@ -424,36 +489,42 @@ func (dbms *DBMS) getMappedInstances() (instances []types.ServiceInstance, err e
}
func (dbms *DBMS) checkPermission(addr proto.AccountAddress, req *types.Request) (err error) {
- // TODO(lambda): change it to chain bus after chain bus finished.
- profile := dbms.profileMap[req.Header.DatabaseID]
- if profile != nil {
- var i int
- var user *types.SQLChainUser
- for i, user = range profile.Users {
- if user.Address == addr {
- break
- }
+ state, loaded := dbms.chainMap.Load(req.Header.DatabaseID)
+ if !loaded {
+ err = errors.Wrap(ErrNotExists, "check permission failed")
+ return
+ }
+
+ var (
+ i int
+ user *types.SQLChainUser
+ s = state.(types.ChainState)
+ )
+
+ for i, user = range s.Users {
+ if user.Address == addr {
+ break
}
- profileLen := len(profile.Users)
- if i < profileLen && profileLen > 0 {
- if req.Header.QueryType == types.ReadQuery {
- if profile.Users[i].Permission > types.Read {
- err = ErrPermissionDeny
- return
- }
- } else if req.Header.QueryType == types.WriteQuery {
- if profile.Users[i].Permission > types.Write {
- err = ErrPermissionDeny
- return
- }
- } else {
- err = ErrInvalidPermission
+ }
+ profileLen := len(s.Users)
+ if i < profileLen && profileLen > 0 {
+ if req.Header.QueryType == types.ReadQuery {
+ if s.Users[i].Permission > types.Read {
+ err = ErrPermissionDeny
+ return
+ }
+ } else if req.Header.QueryType == types.WriteQuery {
+ if s.Users[i].Permission > types.Write {
+ err = ErrPermissionDeny
return
}
} else {
- err = ErrPermissionDeny
+ err = ErrInvalidPermission
return
}
+ } else {
+ err = ErrPermissionDeny
+ return
}
return
}
diff --git a/worker/dbms_meta.go b/worker/dbms_meta.go
index 76644482e..4e9d469a5 100644
--- a/worker/dbms_meta.go
+++ b/worker/dbms_meta.go
@@ -16,16 +16,21 @@
package worker
-import "github.com/CovenantSQL/CovenantSQL/proto"
+import (
+ "github.com/CovenantSQL/CovenantSQL/proto"
+ "github.com/CovenantSQL/CovenantSQL/types"
+)
// DBMSMeta defines the meta structure.
type DBMSMeta struct {
DBS map[proto.DatabaseID]bool
+ ChainState map[proto.DatabaseID]types.ChainState
}
// NewDBMSMeta returns new DBMSMeta struct.
func NewDBMSMeta() (meta *DBMSMeta) {
return &DBMSMeta{
DBS: make(map[proto.DatabaseID]bool),
+ ChainState: make(map[proto.DatabaseID]types.ChainState),
}
}
From 3b1c6b7c77284883efe02e3a6fc31b575f9a11b1 Mon Sep 17 00:00:00 2001
From: zeqing-guo
Date: Wed, 19 Dec 2018 12:18:11 +0800
Subject: [PATCH 098/278] Format code
---
blockproducer/metastate.go | 4 +--
sqlchain/chain.go | 67 +++++++++++++++++++-------------------
sqlchain/config.go | 2 +-
sqlchain/state.go | 8 ++---
types/account.go | 12 +++----
types/chainstate.go | 28 ++++++++--------
types/init_service_type.go | 2 +-
types/updatebilling.go | 12 +++----
worker/dbms.go | 24 +++++++-------
worker/dbms_meta.go | 4 +--
10 files changed, 81 insertions(+), 82 deletions(-)
diff --git a/blockproducer/metastate.go b/blockproducer/metastate.go
index 111767874..f9efcf41e 100644
--- a/blockproducer/metastate.go
+++ b/blockproducer/metastate.go
@@ -1140,13 +1140,13 @@ func (s *metaState) updateBilling(tx *pt.UpdateBilling) (err error) {
}
}
for _, user := range sqlchainObj.Users {
- if user.AdvancePayment >= costMap[user.Address] * sqlchainObj.GasPrice {
+ if user.AdvancePayment >= costMap[user.Address]*sqlchainObj.GasPrice {
user.AdvancePayment -= costMap[user.Address] * sqlchainObj.GasPrice
for _, miner := range sqlchainObj.Miners {
miner.PendingIncome += userMap[user.Address][miner.Address] * sqlchainObj.GasPrice
}
} else {
- rate := 1 - float64(user.AdvancePayment) / float64(costMap[user.Address] * sqlchainObj.GasPrice)
+ rate := 1 - float64(user.AdvancePayment)/float64(costMap[user.Address]*sqlchainObj.GasPrice)
user.AdvancePayment = 0
for _, miner := range sqlchainObj.Miners {
income := userMap[user.Address][miner.Address] * sqlchainObj.GasPrice
diff --git a/sqlchain/chain.go b/sqlchain/chain.go
index 79d4af54d..31290fa73 100644
--- a/sqlchain/chain.go
+++ b/sqlchain/chain.go
@@ -20,13 +20,13 @@ import (
"bytes"
"encoding/binary"
"fmt"
- "github.com/CovenantSQL/CovenantSQL/blockproducer/interfaces"
"os"
rt "runtime"
"sync"
"sync/atomic"
"time"
+ "github.com/CovenantSQL/CovenantSQL/blockproducer/interfaces"
"github.com/CovenantSQL/CovenantSQL/crypto"
"github.com/CovenantSQL/CovenantSQL/crypto/asymmetric"
"github.com/CovenantSQL/CovenantSQL/crypto/kms"
@@ -120,7 +120,7 @@ type Chain struct {
acks chan *types.AckHeader
// DBAccount info
- databaseID proto.DatabaseID
+ databaseID proto.DatabaseID
tokenType types.TokenType
gasPrice uint64
updatePeriod uint64
@@ -204,23 +204,23 @@ func NewChain(c *Config, busService *BusService) (chain *Chain, err error) {
// Create chain state
chain = &Chain{
- bdb: bdb,
- tdb: tdb,
- bi: newBlockIndex(),
- ai: newAckIndex(),
- st: state,
- cl: rpc.NewCaller(),
- rt: newRunTime(c),
- stopCh: make(chan struct{}),
- blocks: make(chan *types.Block),
- heights: make(chan int32, 1),
- responses: make(chan *types.ResponseHeader),
- acks: make(chan *types.AckHeader),
+ bdb: bdb,
+ tdb: tdb,
+ bi: newBlockIndex(),
+ ai: newAckIndex(),
+ st: state,
+ cl: rpc.NewCaller(),
+ rt: newRunTime(c),
+ stopCh: make(chan struct{}),
+ blocks: make(chan *types.Block),
+ heights: make(chan int32, 1),
+ responses: make(chan *types.ResponseHeader),
+ acks: make(chan *types.AckHeader),
tokenType: c.TokenType,
gasPrice: c.GasPrice,
updatePeriod: c.UpdatePeriod,
- databaseID: c.Profile.ID,
+ databaseID: c.Profile.ID,
// Observer related
observers: make(map[proto.NodeID]int32),
@@ -282,23 +282,23 @@ func LoadChain(c *Config, busService *BusService) (chain *Chain, err error) {
// Create chain state
chain = &Chain{
- bdb: bdb,
- tdb: tdb,
- bi: newBlockIndex(),
- ai: newAckIndex(),
- st: xstate,
- cl: rpc.NewCaller(),
- rt: newRunTime(c),
- stopCh: make(chan struct{}),
- blocks: make(chan *types.Block),
- heights: make(chan int32, 1),
- responses: make(chan *types.ResponseHeader),
- acks: make(chan *types.AckHeader),
+ bdb: bdb,
+ tdb: tdb,
+ bi: newBlockIndex(),
+ ai: newAckIndex(),
+ st: xstate,
+ cl: rpc.NewCaller(),
+ rt: newRunTime(c),
+ stopCh: make(chan struct{}),
+ blocks: make(chan *types.Block),
+ heights: make(chan int32, 1),
+ responses: make(chan *types.ResponseHeader),
+ acks: make(chan *types.AckHeader),
tokenType: c.TokenType,
gasPrice: c.GasPrice,
updatePeriod: c.UpdatePeriod,
- databaseID: c.Profile.ID,
+ databaseID: c.Profile.ID,
// Observer related
observers: make(map[proto.NodeID]int32),
@@ -885,7 +885,7 @@ func (c *Chain) processBlocks() {
} else {
head := c.rt.getHead()
currentCount := uint64(head.node.count)
- if currentCount % c.updatePeriod == 0 {
+ if currentCount%c.updatePeriod == 0 {
ub, err := c.billing(head.node)
if err != nil {
log.WithError(err).Error("billing failed")
@@ -1519,10 +1519,10 @@ func (c *Chain) stat() {
func (c *Chain) billing(node *blockNode) (ub *types.UpdateBilling, err error) {
var (
- i, j uint64
+ i, j uint64
minerAddr proto.AccountAddress
- userAddr proto.AccountAddress
- usersMap = make(map[proto.AccountAddress]uint64)
+ userAddr proto.AccountAddress
+ usersMap = make(map[proto.AccountAddress]uint64)
minersMap = make(map[proto.AccountAddress]map[proto.AccountAddress]uint64)
)
@@ -1636,9 +1636,8 @@ func (c *Chain) updatePermission(tx interfaces.Transaction, count uint32) {
}
if newUser {
head.Profile.Users = append(head.Profile.Users, &types.SQLChainUser{
- Address: up.TargetUser,
+ Address: up.TargetUser,
Permission: up.Permission,
})
}
}
-
diff --git a/sqlchain/config.go b/sqlchain/config.go
index 920b56df7..8899b74e4 100644
--- a/sqlchain/config.go
+++ b/sqlchain/config.go
@@ -38,7 +38,7 @@ type Config struct {
Server proto.NodeID
// Price sets query price in gases.
- Profile *types.SQLChainProfile
+ Profile *types.SQLChainProfile
Price map[types.QueryType]uint64
ProducingReward uint64
BillingPeriods int32
diff --git a/sqlchain/state.go b/sqlchain/state.go
index c511deda5..1d5c271d7 100644
--- a/sqlchain/state.go
+++ b/sqlchain/state.go
@@ -23,10 +23,10 @@ import (
// state represents a snapshot of current best chain.
type state struct {
- node *blockNode
- Head hash.Hash
- Height int32
- Profile *types.SQLChainProfile
+ node *blockNode
+ Head hash.Hash
+ Height int32
+ Profile *types.SQLChainProfile
BlockHeight int32
}
diff --git a/types/account.go b/types/account.go
index 34f53ba81..a11e2b6ee 100644
--- a/types/account.go
+++ b/types/account.go
@@ -77,7 +77,7 @@ type SQLChainUser struct {
// UserArrears defines user's arrears.
type UserArrears struct {
- User proto.AccountAddress
+ User proto.AccountAddress
Arrears uint64
}
@@ -88,7 +88,7 @@ type MinerInfo struct {
Name string
PendingIncome uint64
ReceivedIncome uint64
- UserArrears []*UserArrears
+ UserArrears []*UserArrears
Deposit uint64
Status Status
EncryptionKey string
@@ -96,10 +96,10 @@ type MinerInfo struct {
// SQLChainProfile defines a SQLChainProfile related to an account.
type SQLChainProfile struct {
- ID proto.DatabaseID
- Address proto.AccountAddress
- Period uint64
- GasPrice uint64
+ ID proto.DatabaseID
+ Address proto.AccountAddress
+ Period uint64
+ GasPrice uint64
LastUpdatedHeight uint32
TokenType TokenType
diff --git a/types/chainstate.go b/types/chainstate.go
index d77bbe82b..be52547e8 100644
--- a/types/chainstate.go
+++ b/types/chainstate.go
@@ -25,23 +25,23 @@ import (
type ChainState struct {
DatabaseID proto.DatabaseID
- Users []*SQLChainUser
- Miner []*MinerInfo
- GasPrice uint64
- TokenType TokenType
- MCHeight uint32
- HeightTx []*hash.Hash
+ Users []*SQLChainUser
+ Miner []*MinerInfo
+ GasPrice uint64
+ TokenType TokenType
+ MCHeight uint32
+ HeightTx []*hash.Hash
}
func NewChainState(profile *SQLChainProfile, height uint32, createDB hash.Hash) *ChainState {
return &ChainState{
DatabaseID: profile.ID,
- Users: profile.Users,
- Miner: profile.Miners,
- GasPrice: profile.GasPrice,
- TokenType: profile.TokenType,
- MCHeight: height,
- HeightTx: []*hash.Hash{ &createDB },
+ Users: profile.Users,
+ Miner: profile.Miners,
+ GasPrice: profile.GasPrice,
+ TokenType: profile.TokenType,
+ MCHeight: height,
+ HeightTx: []*hash.Hash{&createDB},
}
}
@@ -88,12 +88,12 @@ func (cs *ChainState) UpdatePermission(up *UpdatePermission, count uint32) (err
if user.Address == up.TargetUser {
user.Permission = up.Permission
newUser = false
- return cs.updateHeightAndTx(count, up.Hash())
+ return cs.updateHeightAndTx(count, up.Hash())
}
}
if newUser {
cs.Users = append(cs.Users, &SQLChainUser{
- Address: up.TargetUser,
+ Address: up.TargetUser,
Permission: up.Permission,
})
return cs.updateHeightAndTx(count, up.Hash())
diff --git a/types/init_service_type.go b/types/init_service_type.go
index 64686e9fa..1f67ea945 100644
--- a/types/init_service_type.go
+++ b/types/init_service_type.go
@@ -45,7 +45,7 @@ type ServiceInstance struct {
Peers *proto.Peers
ResourceMeta ResourceMeta
GenesisBlock *Block
- Profile *SQLChainProfile
+ Profile *SQLChainProfile
}
// InitServiceResponseHeader defines worker service init response header.
diff --git a/types/updatebilling.go b/types/updatebilling.go
index 731ec82df..0d25a1a2a 100644
--- a/types/updatebilling.go
+++ b/types/updatebilling.go
@@ -28,22 +28,22 @@ import (
// MinerIncome defines the income of miner.
type MinerIncome struct {
- Miner proto.AccountAddress
+ Miner proto.AccountAddress
Income uint64
}
// UserCost defines the cost of user.
type UserCost struct {
- User proto.AccountAddress
- Cost uint64
+ User proto.AccountAddress
+ Cost uint64
Miners []*MinerIncome
}
// UpdateBillingHeader defines the UpdateBilling transaction header.
type UpdateBillingHeader struct {
Receiver proto.AccountAddress
- Nonce pi.AccountNonce
- Users []*UserCost
+ Nonce pi.AccountNonce
+ Users []*UserCost
}
// UpdateBilling defines the UpdateBilling transaction.
@@ -56,7 +56,7 @@ type UpdateBilling struct {
// NewUpdateBilling returns new instance.
func NewUpdateBilling(header *UpdateBillingHeader) *UpdateBilling {
return &UpdateBilling{
- UpdateBillingHeader: *header,
+ UpdateBillingHeader: *header,
TransactionTypeMixin: *pi.NewTransactionTypeMixin(pi.TransactionTypeTransfer),
}
}
diff --git a/worker/dbms.go b/worker/dbms.go
index 920093358..3485b347d 100644
--- a/worker/dbms.go
+++ b/worker/dbms.go
@@ -50,12 +50,12 @@ const (
// DBMS defines a database management instance.
type DBMS struct {
- cfg *DBMSConfig
- dbMap sync.Map
- chainMap sync.Map
- kayakMux *DBKayakMuxService
- chainMux *sqlchain.MuxService
- rpc *DBMSRPCService
+ cfg *DBMSConfig
+ dbMap sync.Map
+ chainMap sync.Map
+ kayakMux *DBKayakMuxService
+ chainMux *sqlchain.MuxService
+ rpc *DBMSRPCService
busService *sqlchain.BusService
address proto.AccountAddress
}
@@ -207,9 +207,9 @@ func (dbms *DBMS) createDatabase(tx interfaces.Transaction, count uint32) {
}
var (
- dbid = proto.FromAccountAndNonce(cd.Owner, uint32(cd.Nonce))
- p = dbms.busService.RequestSQLProfile(dbid)
- nodeIDs [len(p.Miners)]proto.NodeID
+ dbid = proto.FromAccountAndNonce(cd.Owner, uint32(cd.Nonce))
+ p = dbms.busService.RequestSQLProfile(dbid)
+ nodeIDs [len(p.Miners)]proto.NodeID
isTargetMiner = false
)
@@ -234,7 +234,7 @@ func (dbms *DBMS) createDatabase(tx interfaces.Transaction, count uint32) {
Peers: &peers,
ResourceMeta: cd.ResourceMeta,
GenesisBlock: p.Genesis,
- Profile: p,
+ Profile: p,
}
err := dbms.Create(&si, true)
if err != nil {
@@ -496,9 +496,9 @@ func (dbms *DBMS) checkPermission(addr proto.AccountAddress, req *types.Request)
}
var (
- i int
+ i int
user *types.SQLChainUser
- s = state.(types.ChainState)
+ s = state.(types.ChainState)
)
for i, user = range s.Users {
diff --git a/worker/dbms_meta.go b/worker/dbms_meta.go
index 4e9d469a5..405b6e34c 100644
--- a/worker/dbms_meta.go
+++ b/worker/dbms_meta.go
@@ -23,14 +23,14 @@ import (
// DBMSMeta defines the meta structure.
type DBMSMeta struct {
- DBS map[proto.DatabaseID]bool
+ DBS map[proto.DatabaseID]bool
ChainState map[proto.DatabaseID]types.ChainState
}
// NewDBMSMeta returns new DBMSMeta struct.
func NewDBMSMeta() (meta *DBMSMeta) {
return &DBMSMeta{
- DBS: make(map[proto.DatabaseID]bool),
+ DBS: make(map[proto.DatabaseID]bool),
ChainState: make(map[proto.DatabaseID]types.ChainState),
}
}
From 3a20fd0609741925221687eba8e282ba92503058 Mon Sep 17 00:00:00 2001
From: leventeliu
Date: Wed, 19 Dec 2018 15:03:56 +0800
Subject: [PATCH 099/278] Fix typo
---
blockproducer/chain.go | 2 +-
blockproducer/config.go | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/blockproducer/chain.go b/blockproducer/chain.go
index 034e7c0ee..ed33f38e4 100644
--- a/blockproducer/chain.go
+++ b/blockproducer/chain.go
@@ -208,7 +208,7 @@ func NewChainWithContext(ctx context.Context, cfg *Config) (c *Chain, err error)
err = ErrLocalNodeNotFound
return
}
- if t = cfg.ComfirmThreshold; t <= 0.0 {
+ if t = cfg.ConfirmThreshold; t <= 0.0 {
t = float64(2) / 3.0
}
if m = uint32(math.Ceil(float64(l)*t + 1)); m > l {
diff --git a/blockproducer/config.go b/blockproducer/config.go
index 2dea39005..ff56602e9 100644
--- a/blockproducer/config.go
+++ b/blockproducer/config.go
@@ -38,7 +38,7 @@ type Config struct {
Peers *proto.Peers
NodeID proto.NodeID
- ComfirmThreshold float64
+ ConfirmThreshold float64
Period time.Duration
Tick time.Duration
From e68cf73d6e2cd988ff1a5e0b3379af14bf5c85ac Mon Sep 17 00:00:00 2001
From: leventeliu
Date: Wed, 19 Dec 2018 17:57:28 +0800
Subject: [PATCH 100/278] Remove unused replay method
---
sqlchain/chain.go | 22 +++-------------------
test/GNTE/GNTE | 2 +-
2 files changed, 4 insertions(+), 20 deletions(-)
diff --git a/sqlchain/chain.go b/sqlchain/chain.go
index a95f81c45..7301cfc86 100644
--- a/sqlchain/chain.go
+++ b/sqlchain/chain.go
@@ -531,8 +531,8 @@ func (c *Chain) pushAckedQuery(ack *types.SignedAckHeader) (err error) {
return
}
-// produceBlockV2 prepares, signs and advises the pending block to the other peers.
-func (c *Chain) produceBlockV2(now time.Time) (err error) {
+// produceBlock prepares, signs and advises the pending block to the other peers.
+func (c *Chain) produceBlock(now time.Time) (err error) {
var (
frs []*types.Request
qts []*x.QueryTracker
@@ -727,7 +727,7 @@ func (c *Chain) runCurrentTurn(now time.Time) {
return
}
- if err := c.produceBlockV2(now); err != nil {
+ if err := c.produceBlock(now); err != nil {
log.WithFields(log.Fields{
"peer": c.rt.getPeerInfoString(),
"time": c.rt.getChainTimeString(),
@@ -1397,22 +1397,6 @@ func (c *Chain) Query(req *types.Request) (resp *types.Response, err error) {
return
}
-// Replay replays a write log from other peer to replicate storage state.
-func (c *Chain) Replay(req *types.Request, resp *types.Response) (err error) {
- switch req.Header.QueryType {
- case types.ReadQuery:
- return
- case types.WriteQuery:
- return c.st.Replay(req, resp)
- default:
- err = ErrInvalidRequest
- }
- if err = c.addResponse(&resp.Header); err != nil {
- return
- }
- return
-}
-
func (c *Chain) addResponse(resp *types.SignedResponseHeader) (err error) {
return c.ai.addResponse(c.rt.getHeightFromTime(resp.Request.Timestamp), resp)
}
diff --git a/test/GNTE/GNTE b/test/GNTE/GNTE
index 93e48d707..d34ad0da6 160000
--- a/test/GNTE/GNTE
+++ b/test/GNTE/GNTE
@@ -1 +1 @@
-Subproject commit 93e48d7072b002c3d070f9b712ff22b53c65c6b3
+Subproject commit d34ad0da6cf6fb07065da2fb8e050366adb58123
From 3168bc7f51649fbf6043150bdc6b2868f18fc3aa Mon Sep 17 00:00:00 2001
From: leventeliu
Date: Wed, 19 Dec 2018 21:24:40 +0800
Subject: [PATCH 101/278] Remove xenomint savepoint, use sequence number only
---
sqlchain/chain.go | 2 +-
xenomint/state.go | 189 ++++++++++++++++-------------------------
xenomint/state_test.go | 4 +-
3 files changed, 74 insertions(+), 121 deletions(-)
diff --git a/sqlchain/chain.go b/sqlchain/chain.go
index b7336ac80..a24a840d2 100644
--- a/sqlchain/chain.go
+++ b/sqlchain/chain.go
@@ -380,7 +380,7 @@ func LoadChainWithContext(ctx context.Context, c *Config) (chain *Chain, err err
// Set chain state
st.node = last
chain.rt.setHead(st)
- chain.st.InitTx(id)
+ chain.st.SetSeq(id)
chain.pruneBlockCache()
// Read queries and rebuild memory index
diff --git a/xenomint/state.go b/xenomint/state.go
index f968905b6..776860a47 100644
--- a/xenomint/state.go
+++ b/xenomint/state.go
@@ -41,14 +41,11 @@ type State struct {
closed bool
nodeID proto.NodeID
- // TODO(leventeliu): Reload savepoint from last block on chain initialization, and rollback
- // any ongoing transaction on exit.
- //
// unc is the uncommitted transaction.
unc *sql.Tx
- origin uint64 // origin is the original savepoint of the current transaction
- cmpoint uint64 // cmpoint is the last commit point of the current transaction
- current uint64 // current is the current savepoint of the current transaction
+ maxTx uint64
+ lastCommitPoint uint64
+ current uint64 // current is the current lastSeq of the current transaction
hasSchemaChange uint32 // indicates schema change happens in this uncommitted transaction
}
@@ -58,11 +55,11 @@ func NewState(nodeID proto.NodeID, strg xi.Storage) (s *State, err error) {
nodeID: nodeID,
strg: strg,
pool: newPool(),
+ maxTx: 100,
}
if t.unc, err = t.strg.Writer().Begin(); err != nil {
return
}
- t.setSavepoint()
s = t
return
}
@@ -71,54 +68,38 @@ func (s *State) incSeq() {
atomic.AddUint64(&s.current, 1)
}
-func (s *State) setNextTxID() {
- current := s.getID()
- s.origin = current
- s.cmpoint = current
-}
-
-func (s *State) setCommitPoint() {
- s.cmpoint = s.getID()
-}
-
-func (s *State) rollbackID(id uint64) {
+func (s *State) setSeq(id uint64) {
atomic.StoreUint64(&s.current, id)
}
-// InitTx sets the initial id of the current transaction. This method is not safe for concurrency
-// and should only be called at initialization.
-func (s *State) InitTx(id uint64) {
- s.origin = id
- s.cmpoint = id
- s.rollbackID(id)
- s.setSavepoint()
+// SetSeq sets the initial id of the current transaction.
+func (s *State) SetSeq(id uint64) {
+ s.setSeq(id)
}
-func (s *State) getID() uint64 {
+func (s *State) getSeq() uint64 {
return atomic.LoadUint64(&s.current)
}
+func (s *State) getLastCommitPoint() uint64 {
+ return atomic.LoadUint64(&s.lastCommitPoint)
+}
+
// Close commits any ongoing transaction if needed and closes the underlying storage.
func (s *State) Close(commit bool) (err error) {
+ s.Lock()
+ defer s.Unlock()
if s.closed {
return
}
if s.unc != nil {
if commit {
- s.Lock()
- defer s.Unlock()
if err = s.uncCommit(); err != nil {
- return
+ log.WithError(err).Fatal("failed to commit")
}
} else {
- // Only rollback to last commit point
- if err = s.rollback(); err != nil {
- return
- }
- s.Lock()
- defer s.Unlock()
- if err = s.uncCommit(); err != nil {
- return
+ if err = s.uncRollback(); err != nil {
+ log.WithError(err).Fatal("failed to rollback")
}
}
}
@@ -291,7 +272,7 @@ func (s *State) readWithContext(
NodeID: s.nodeID,
Timestamp: s.getLocalTime(),
RowCount: uint64(len(data)),
- LogOffset: s.getID(),
+ LogOffset: s.getSeq(),
},
},
Payload: types.ResponsePayload{
@@ -307,8 +288,7 @@ func (s *State) readTx(
ctx context.Context, req *types.Request) (ref *QueryTracker, resp *types.Response, err error,
) {
var (
- tx *sql.Tx
- id uint64
+ id = s.getSeq()
ierr error
cnames, ctypes []string
data [][]interface{}
@@ -318,14 +298,9 @@ func (s *State) readTx(
// lock transaction
s.Lock()
defer s.Unlock()
- id = s.getID()
- s.setSavepoint()
querier = s.unc
- defer s.rollbackTo(id)
-
- // TODO(): should detect query type, any timeout write query will cause underlying transaction to rollback
} else {
- id = s.getID()
+ var tx *sql.Tx
if tx, ierr = s.strg.DirtyReader().Begin(); ierr != nil {
err = errors.Wrap(ierr, "open tx failed")
return
@@ -387,7 +362,7 @@ func (s *State) writeSingle(
//defer func() {
// var fields = log.Fields{}
- // fields["savepoint"] = s.current
+ // fields["lastSeq"] = s.current
// if parsed > 0 {
// fields["1#parsed"] = float64(parsed.Nanoseconds()) / 1000
// }
@@ -410,22 +385,11 @@ func (s *State) writeSingle(
return
}
-func (s *State) setSavepoint() (savepoint uint64) {
- savepoint = s.getID()
- s.unc.Exec("SAVEPOINT \"?\"", savepoint)
- return
-}
-
-func (s *State) rollbackTo(savepoint uint64) {
- s.rollbackID(savepoint)
- s.unc.Exec("ROLLBACK TO \"?\"", savepoint)
-}
-
func (s *State) write(
ctx context.Context, req *types.Request) (ref *QueryTracker, resp *types.Response, err error,
) {
var (
- savepoint uint64
+ lastSeq uint64
query = &QueryTracker{Req: req}
totalAffectedRows int64
curAffectedRows int64
@@ -437,7 +401,7 @@ func (s *State) write(
defer func() {
var fields = log.Fields{}
- fields["savepoint"] = savepoint
+ fields["lastSeq"] = lastSeq
fields["1#lockAcquired"] = float64(lockAcquired.Nanoseconds()) / 1000
if writeDone > 0 {
fields["2#writeDone"] = float64((writeDone - lockAcquired).Nanoseconds()) / 1000
@@ -457,7 +421,6 @@ func (s *State) write(
}
}()
- // TODO(leventeliu): savepoint is a sqlite-specified solution for nested transaction.
if err = func() (err error) {
var ierr error
s.Lock()
@@ -466,14 +429,14 @@ func (s *State) write(
s.Unlock()
lockReleased = time.Since(start)
}()
- savepoint = s.getID()
+ lastSeq = s.getSeq()
for i, v := range req.Payload.Queries {
var res sql.Result
if res, ierr = s.writeSingle(ctx, &v); ierr != nil {
err = errors.Wrapf(ierr, "execute at #%d failed", i)
- // Add to failed pool list
+ // TODO(leventeliu): request may actually be partial successed without
+ // rolling back.
s.pool.setFailed(req)
- s.rollbackTo(savepoint)
return
}
@@ -481,9 +444,13 @@ func (s *State) write(
lastInsertID, _ = res.LastInsertId()
totalAffectedRows += curAffectedRows
}
- s.setSavepoint()
+ // Try to commit if the ongoing tx is too large or schema is changed
+ if s.getSeq()-s.getLastCommitPoint() > s.maxTx ||
+ atomic.LoadUint32(&s.hasSchemaChange) != 0 {
+ s.tryCommit()
+ }
writeDone = time.Since(start)
- s.pool.enqueue(savepoint, query)
+ s.pool.enqueue(lastSeq, query)
enqueued = time.Since(start)
return
}(); err != nil {
@@ -498,7 +465,7 @@ func (s *State) write(
NodeID: s.nodeID,
Timestamp: s.getLocalTime(),
RowCount: 0,
- LogOffset: savepoint,
+ LogOffset: lastSeq,
AffectedRows: totalAffectedRows,
LastInsertID: lastInsertID,
},
@@ -510,29 +477,32 @@ func (s *State) write(
func (s *State) replay(ctx context.Context, req *types.Request, resp *types.Response) (err error) {
var (
- ierr error
- savepoint uint64
- query = &QueryTracker{Req: req, Resp: resp}
+ ierr error
+ lastSeq uint64
+ query = &QueryTracker{Req: req, Resp: resp}
)
s.Lock()
defer s.Unlock()
- savepoint = s.getID()
- if resp.Header.ResponseHeader.LogOffset != savepoint {
+ lastSeq = s.getSeq()
+ if resp.Header.ResponseHeader.LogOffset != lastSeq {
err = errors.Wrapf(
ErrQueryConflict,
- "local id %d vs replaying id %d", savepoint, resp.Header.ResponseHeader.LogOffset,
+ "local id %d vs replaying id %d", lastSeq, resp.Header.ResponseHeader.LogOffset,
)
return
}
for i, v := range req.Payload.Queries {
if _, ierr = s.writeSingle(ctx, &v); ierr != nil {
err = errors.Wrapf(ierr, "execute at #%d failed", i)
- s.rollbackTo(savepoint)
return
}
}
- s.setSavepoint()
- s.pool.enqueue(savepoint, query)
+ // Try to commit if the ongoing tx is too large or schema is changed
+ if s.getSeq()-s.getLastCommitPoint() > s.maxTx ||
+ atomic.LoadUint32(&s.hasSchemaChange) != 0 {
+ s.tryCommit()
+ }
+ s.pool.enqueue(lastSeq, query)
return
}
@@ -547,13 +517,13 @@ func (s *State) ReplayBlock(block *types.Block) (err error) {
func (s *State) ReplayBlockWithContext(ctx context.Context, block *types.Block) (err error) {
var (
ierr error
- lastsp uint64 // Last savepoint
+ lastsp uint64 // Last lastSeq
)
s.Lock()
defer s.Unlock()
for i, q := range block.QueryTxs {
var query = &QueryTracker{Req: q.Request, Resp: &types.Response{Header: *q.Response}}
- lastsp = s.getID()
+ lastsp = s.getSeq()
if q.Response.ResponseHeader.LogOffset > lastsp {
err = ErrMissingParent
return
@@ -573,39 +543,21 @@ func (s *State) ReplayBlockWithContext(ctx context.Context, block *types.Block)
}
if q.Request.Header.QueryType != types.WriteQuery {
err = errors.Wrapf(ErrInvalidRequest, "replay block at %d:%d", i, j)
- s.rollbackTo(lastsp)
return
}
if _, ierr = s.writeSingle(ctx, &v); ierr != nil {
err = errors.Wrapf(ierr, "execute at %d:%d failed", i, j)
- s.rollbackTo(lastsp)
return
}
}
- s.setSavepoint()
s.pool.enqueue(lastsp, query)
}
+ // Always try to commit after a block is successfully replayed
+ s.tryCommit()
// Remove duplicate failed queries from local pool
for _, r := range block.FailedReqs {
s.pool.removeFailed(r)
}
- // Check if the current transaction is OK to commit
- if s.pool.matchLast(lastsp) {
- if err = s.uncCommit(); err != nil {
- // FATAL ERROR
- return
- }
- if s.unc, err = s.strg.Writer().Begin(); err != nil {
- // FATAL ERROR
- return
- }
- s.setNextTxID()
- } else {
- // Set commit point only, transaction is not actually committed. This commit point will be
- // used on exiting.
- s.setCommitPoint()
- }
- s.setSavepoint()
// Truncate pooled queries
s.pool.truncate(lastsp)
return
@@ -640,14 +592,12 @@ func (s *State) commit() (err error) {
}()
lockAcquired = time.Since(start)
if err = s.uncCommit(); err != nil {
- return
+ log.WithError(err).Fatal("failed to commit")
}
if s.unc, err = s.strg.Writer().Begin(); err != nil {
- return
+ log.WithError(err).Fatal("failed to begin")
}
committed = time.Since(start)
- s.setNextTxID()
- s.setSavepoint()
_ = s.pool.queries
s.pool = newPool()
poolCleaned = time.Since(start)
@@ -691,17 +641,9 @@ func (s *State) CommitExWithContext(
s.Unlock()
lockReleased = time.Since(start)
}()
- if err = s.uncCommit(); err != nil {
- // FATAL ERROR
- return
- }
- if s.unc, err = s.strg.Writer().BeginTx(ctx, nil); err != nil {
- // FATAL ERROR
- return
- }
+ // Always try to commit before the block is produced
+ s.tryCommit()
committed = time.Since(start)
- s.setNextTxID()
- s.setSavepoint()
// Return pooled items and reset
failed = s.pool.failedList()
queries = s.pool.queries
@@ -710,21 +652,32 @@ func (s *State) CommitExWithContext(
return
}
+func (s *State) tryCommit() {
+ var err error
+ if err = s.uncCommit(); err != nil {
+ log.WithError(err).Fatal("failed to commit")
+ }
+ if s.unc, err = s.strg.Writer().Begin(); err != nil {
+ log.WithError(err).Fatal("failed to begin")
+ }
+}
+
func (s *State) uncCommit() (err error) {
if err = s.unc.Commit(); err != nil {
return
}
-
// reset schema change flag
atomic.StoreUint32(&s.hasSchemaChange, 0)
-
+ atomic.StoreUint64(&s.lastCommitPoint, s.getSeq())
return
}
-func (s *State) rollback() (err error) {
- s.Lock()
- defer s.Unlock()
- s.rollbackTo(s.cmpoint)
+func (s *State) uncRollback() (err error) {
+ if err = s.unc.Rollback(); err != nil {
+ return
+ }
+ // reset schema change flag
+ atomic.StoreUint32(&s.hasSchemaChange, 0)
return
}
diff --git a/xenomint/state_test.go b/xenomint/state_test.go
index 783142a15..1d41ca1a3 100644
--- a/xenomint/state_test.go
+++ b/xenomint/state_test.go
@@ -163,7 +163,7 @@ func TestState(t *testing.T) {
}), &types.Response{
Header: types.SignedResponseHeader{
ResponseHeader: types.ResponseHeader{
- LogOffset: st1.getID(),
+ LogOffset: st1.getSeq(),
},
},
})
@@ -179,7 +179,7 @@ func TestState(t *testing.T) {
}), &types.Response{
Header: types.SignedResponseHeader{
ResponseHeader: types.ResponseHeader{
- LogOffset: st1.getID(),
+ LogOffset: st1.getSeq(),
},
},
})
From 835462fbb0f9d0f7cbfebba26af4e1b24b00a40b Mon Sep 17 00:00:00 2001
From: zeqing-guo
Date: Thu, 20 Dec 2018 01:49:47 +0800
Subject: [PATCH 102/278] Change ChainState to UserState
---
blockproducer/chain_test.go | 1 -
blockproducer/metastate.go | 1 +
cmd/cql-adapter/storage/sqlite3.go | 1 -
cmd/cql-faucet/persistence.go | 1 -
cmd/cql-minerd/main.go | 1 -
crypto/hash/hashfuncs.go | 1 -
rpc/rpcutil.go | 1 -
sqlchain/chain.go | 1 -
sqlchain/chainbusservice.go | 4 +-
storage/storage.go | 1 -
types/account.go | 20 +++++
types/chainstate.go | 108 +++++++--------------------
types/request_type.go | 2 +
worker/db.go | 1 -
worker/dbms.go | 115 +++++++++++++++++------------
worker/dbms_meta.go | 3 -
16 files changed, 120 insertions(+), 142 deletions(-)
diff --git a/blockproducer/chain_test.go b/blockproducer/chain_test.go
index e8f89f275..95634a440 100644
--- a/blockproducer/chain_test.go
+++ b/blockproducer/chain_test.go
@@ -70,7 +70,6 @@ func newProvideService(
t *types.ProvideService, err error,
) {
t = types.NewProvideService(&types.ProvideServiceHeader{
- Contract: contract,
Nonce: nonce,
})
err = t.Sign(signer)
diff --git a/blockproducer/metastate.go b/blockproducer/metastate.go
index a5dd49c7a..c46a7dbaa 100644
--- a/blockproducer/metastate.go
+++ b/blockproducer/metastate.go
@@ -852,6 +852,7 @@ func (s *metaState) updateBilling(tx *types.UpdateBilling) (err error) {
} else {
rate := 1 - float64(user.AdvancePayment)/float64(costMap[user.Address]*sqlchainObj.GasPrice)
user.AdvancePayment = 0
+ user.Status = types.Arrears
for _, miner := range sqlchainObj.Miners {
income := userMap[user.Address][miner.Address] * sqlchainObj.GasPrice
minerIncome := uint64(float64(income) * rate)
diff --git a/cmd/cql-adapter/storage/sqlite3.go b/cmd/cql-adapter/storage/sqlite3.go
index d9be539d8..aac13f94d 100644
--- a/cmd/cql-adapter/storage/sqlite3.go
+++ b/cmd/cql-adapter/storage/sqlite3.go
@@ -24,7 +24,6 @@ import (
"math/rand"
"os"
"path/filepath"
-
// Import sqlite3 manually.
_ "github.com/CovenantSQL/go-sqlite3-encrypt"
)
diff --git a/cmd/cql-faucet/persistence.go b/cmd/cql-faucet/persistence.go
index 140a6c6d6..dfdc3d458 100644
--- a/cmd/cql-faucet/persistence.go
+++ b/cmd/cql-faucet/persistence.go
@@ -26,7 +26,6 @@ import (
"github.com/CovenantSQL/CovenantSQL/conf"
"github.com/CovenantSQL/CovenantSQL/utils/log"
uuid "github.com/satori/go.uuid"
-
// Load sqlite3 database driver.
_ "github.com/CovenantSQL/go-sqlite3-encrypt"
)
diff --git a/cmd/cql-minerd/main.go b/cmd/cql-minerd/main.go
index f1fc11c16..eb8016255 100644
--- a/cmd/cql-minerd/main.go
+++ b/cmd/cql-minerd/main.go
@@ -26,7 +26,6 @@ import (
"os"
"os/signal"
"runtime"
-
//"runtime/trace"
"syscall"
"time"
diff --git a/crypto/hash/hashfuncs.go b/crypto/hash/hashfuncs.go
index af14cf46d..d3cd98561 100644
--- a/crypto/hash/hashfuncs.go
+++ b/crypto/hash/hashfuncs.go
@@ -19,7 +19,6 @@ package hash
import (
"encoding/binary"
"hash/fnv"
-
// "crypto/sha256" benchmark is at least 10% faster on
// i7-4870HQ CPU @ 2.50GHz than "github.com/minio/sha256-simd"
"crypto/sha256"
diff --git a/rpc/rpcutil.go b/rpc/rpcutil.go
index c9f2d9ac0..29ac19a91 100644
--- a/rpc/rpcutil.go
+++ b/rpc/rpcutil.go
@@ -354,7 +354,6 @@ func SetCurrentBP(bpNodeID proto.NodeID) {
currentBP = bpNodeID
}
-
// RequstBP sends request to main chain.
func RequestBP(method string, req interface{}, resp interface{}) (err error) {
var bp proto.NodeID
diff --git a/sqlchain/chain.go b/sqlchain/chain.go
index d1e214989..c23cb2c2f 100644
--- a/sqlchain/chain.go
+++ b/sqlchain/chain.go
@@ -1543,4 +1543,3 @@ func (c *Chain) billing(node *blockNode) (ub *types.UpdateBilling, err error) {
ub.Receiver, err = c.databaseID.AccountAddress()
return
}
-
diff --git a/sqlchain/chainbusservice.go b/sqlchain/chainbusservice.go
index ec7bf62d6..8ae9f3371 100644
--- a/sqlchain/chainbusservice.go
+++ b/sqlchain/chainbusservice.go
@@ -107,10 +107,10 @@ func (bs *BusService) requestBlock(count uint32) (block *types.BPBlock) {
return
}
-func (bs *BusService) RequestSQLProfile(dbid *proto.DatabaseID) (p *types.SQLChainProfile) {
+func (bs *BusService) RequestSQLProfile(dbid *proto.DatabaseID) (p *types.SQLChainProfile, err error) {
req := &types.QuerySQLChainProfileReq{DBID: *dbid}
resp := &types.QuerySQLChainProfileResp{}
- if err := bs.requestBP(route.MCCQuerySQLChainProfile.String(), req, resp); err != nil {
+ if err = bs.requestBP(route.MCCQuerySQLChainProfile.String(), req, resp); err != nil {
log.WithError(err).Warning("fetch sqlchain profile failed")
return
}
diff --git a/storage/storage.go b/storage/storage.go
index e059819af..7e36bad0e 100644
--- a/storage/storage.go
+++ b/storage/storage.go
@@ -26,7 +26,6 @@ import (
"github.com/CovenantSQL/CovenantSQL/twopc"
"github.com/CovenantSQL/CovenantSQL/utils/log"
-
// Register CovenantSQL/go-sqlite3-encrypt engine.
_ "github.com/CovenantSQL/go-sqlite3-encrypt"
)
diff --git a/types/account.go b/types/account.go
index a11e2b6ee..b4cad6f3e 100644
--- a/types/account.go
+++ b/types/account.go
@@ -49,6 +49,22 @@ const (
NumberOfUserPermission
)
+// CheckRead returns true if user owns read permission.
+func (up *UserPermission) CheckRead() bool {
+ return *up >= Admin && *up < NumberOfUserPermission
+}
+
+// CheckWrite returns true if user owns write permission.
+func (up *UserPermission) CheckWrite() bool {
+ return *up >= Admin && *up <= Write
+}
+
+
+// CheckAdmin returns true if user owns admin permission.
+func (up *UserPermission) CheckAdmin() bool {
+ return *up == Admin
+}
+
// Status defines status of a SQLChain user/miner.
type Status int32
@@ -65,6 +81,10 @@ const (
NumberOfStatus
)
+func (s *Status) EnableQuery() bool {
+ return *s >= Normal && *s <= Reminder
+}
+
// SQLChainUser defines a SQLChain user.
type SQLChainUser struct {
Address proto.AccountAddress
diff --git a/types/chainstate.go b/types/chainstate.go
index be52547e8..fffc4597c 100644
--- a/types/chainstate.go
+++ b/types/chainstate.go
@@ -17,102 +17,48 @@
package types
import (
- "github.com/CovenantSQL/CovenantSQL/crypto/hash"
"github.com/CovenantSQL/CovenantSQL/proto"
- "github.com/CovenantSQL/CovenantSQL/utils"
- "github.com/pkg/errors"
)
-type ChainState struct {
- DatabaseID proto.DatabaseID
- Users []*SQLChainUser
- Miner []*MinerInfo
- GasPrice uint64
- TokenType TokenType
- MCHeight uint32
- HeightTx []*hash.Hash
+type PermStat struct {
+ Permission UserPermission
+ Status Status
}
-func NewChainState(profile *SQLChainProfile, height uint32, createDB hash.Hash) *ChainState {
- return &ChainState{
- DatabaseID: profile.ID,
- Users: profile.Users,
- Miner: profile.Miners,
- GasPrice: profile.GasPrice,
- TokenType: profile.TokenType,
- MCHeight: height,
- HeightTx: []*hash.Hash{&createDB},
- }
+type UserState struct {
+ State map[proto.AccountAddress]*PermStat
}
-func (cs *ChainState) AddAdvancePayment(transfer *Transfer, count uint32) (err error) {
- if transfer.Receiver.DatabaseID() != cs.DatabaseID {
- err = errors.Wrap(ErrNotExists, "mismatch databaseID when add advance payment")
- return
+func NewUserState() *UserState {
+ return &UserState{
+ State: make(map[proto.AccountAddress]*PermStat),
}
+}
- exist := false
- for _, user := range cs.Users {
- // TODO(lambda): add token type in types.Transfer
- if user.Address == transfer.Sender {
- res, flow := utils.SafeAdd(user.AdvancePayment, transfer.Amount)
- if !flow {
- exist = true
- user.AdvancePayment = res
- err = cs.updateHeightAndTx(count, transfer.Hash())
- if err != nil {
- return
- }
- break
- } else {
- err = errors.Wrap(ErrOverflow, "add advance payment overflow")
- return
- }
- }
- }
+func (us *UserState) UpdatePermission(user proto.AccountAddress, perm UserPermission) {
+ us.State[user].Permission = perm
+}
- if !exist {
- err = errors.Wrap(ErrNoSuchUser, "add advance payment for non-existing user")
- }
- return
+func (us *UserState) AddPermission(user proto.AccountAddress, perm UserPermission) {
+ us.UpdatePermission(user, perm)
}
-func (cs *ChainState) UpdatePermission(up *UpdatePermission, count uint32) (err error) {
- if up.TargetSQLChain.DatabaseID() != cs.DatabaseID {
- err = errors.Wrap(ErrNotExists, "mismatch databaseID when update permission")
- return
- }
+func (us *UserState) UpdateStatus(user proto.AccountAddress, stat Status) {
+ us.State[user].Status = stat
+}
- newUser := true
- for _, user := range cs.Users {
- if user.Address == up.TargetUser {
- user.Permission = up.Permission
- newUser = false
- return cs.updateHeightAndTx(count, up.Hash())
- }
- }
- if newUser {
- cs.Users = append(cs.Users, &SQLChainUser{
- Address: up.TargetUser,
- Permission: up.Permission,
- })
- return cs.updateHeightAndTx(count, up.Hash())
- }
+func (us *UserState) AddStatus(user proto.AccountAddress, stat Status) {
+ us.UpdateStatus(user, stat)
+}
+func (us *UserState) GetPermission(user proto.AccountAddress) (up UserPermission, ok bool) {
+ permstat, ok := us.State[user]
+ up = permstat.Permission
return
}
-func (cs *ChainState) updateHeightAndTx(count uint32, tx hash.Hash) (err error) {
- if cs.MCHeight == count {
- cs.HeightTx = append(cs.HeightTx, &tx)
- } else if cs.MCHeight > count {
- err = errors.Wrap(ErrInvalidHeight, "receive old height when update height")
- return
- } else {
- cs.HeightTx = []*hash.Hash{
- &tx,
- }
- cs.MCHeight = count
- }
+func (us *UserState) GetStatus(user proto.AccountAddress) (stat Status, ok bool) {
+ permstat, ok := us.State[user]
+ stat = permstat.Status
return
-}
+}
\ No newline at end of file
diff --git a/types/request_type.go b/types/request_type.go
index 2105e641c..bf280a2f0 100644
--- a/types/request_type.go
+++ b/types/request_type.go
@@ -36,6 +36,8 @@ const (
ReadQuery QueryType = iota
// WriteQuery defines a write query type.
WriteQuery
+ // NumberOfPerm defines the number of query type.
+ NumberOfPerm
)
// NamedArg defines the named argument structure for database.
diff --git a/worker/db.go b/worker/db.go
index aa46e4daa..efb1764dd 100644
--- a/worker/db.go
+++ b/worker/db.go
@@ -19,7 +19,6 @@ package worker
import (
"os"
"path/filepath"
-
//"runtime/trace"
"sync"
"time"
diff --git a/worker/dbms.go b/worker/dbms.go
index d6d98393a..016a3790f 100644
--- a/worker/dbms.go
+++ b/worker/dbms.go
@@ -140,12 +140,6 @@ func (dbms *DBMS) writeMeta() (err error) {
return true
})
- dbms.chainMap.Range(func(key, value interface{}) bool {
- dbID := key.(proto.DatabaseID)
- meta.ChainState[dbID] = value.(types.ChainState)
- return true
- })
-
var buf *bytes.Buffer
if buf, err = utils.EncodeMsgPack(meta); err != nil {
return
@@ -188,10 +182,49 @@ func (dbms *DBMS) Init() (err error) {
err = errors.Wrap(err, "init chain bus failed")
return
}
+ if err = dbms.busService.Subscribe("/UpdateBilling/", dbms.updateBilling); err != nil {
+ err = errors.Wrap(err, "init chain bus failed")
+ return
+ }
return
}
+func (dbms *DBMS) updateBilling(tx interfaces.Transaction, count uint32) {
+ var ub *types.UpdateBilling
+ switch t := tx.(type) {
+ case *types.UpdateBilling:
+ ub = t
+ default:
+ log.WithError(ErrInvalidTransactionType).Warning("unexpected error")
+ return
+ }
+
+ s, ok := dbms.chainMap.Load(ub.Receiver.DatabaseID())
+ if !ok {
+ return
+ }
+
+ var (
+ dbid = ub.Receiver.DatabaseID()
+ state = s.(types.UserState)
+ )
+
+ p, err := dbms.busService.RequestSQLProfile(&dbid)
+ if err != nil {
+ log.WithError(err).Warning("failed to call bp")
+ return
+ }
+
+ for _, user := range p.Users {
+ state.State[user.Address] = &types.PermStat{
+ Permission: user.Permission,
+ Status: user.Status,
+ }
+ }
+ dbms.chainMap.Store(ub.Receiver.DatabaseID(), state)
+}
+
func (dbms *DBMS) createDatabase(tx interfaces.Transaction, count uint32) {
var cd *types.CreateDatabase
switch t := tx.(type) {
@@ -204,10 +237,15 @@ func (dbms *DBMS) createDatabase(tx interfaces.Transaction, count uint32) {
var (
dbid = proto.FromAccountAndNonce(cd.Owner, uint32(cd.Nonce))
- p = dbms.busService.RequestSQLProfile(dbid)
- nodeIDs = make([]proto.NodeID, len(p.Miners))
isTargetMiner = false
)
+ p, err := dbms.busService.RequestSQLProfile(dbid)
+ if err != nil {
+ log.WithError(err).Warning("failed to call bp")
+ return
+ }
+
+ nodeIDs := make([]proto.NodeID, len(p.Miners))
for i, mi := range p.Miners {
if mi.Address == dbms.address {
@@ -219,6 +257,16 @@ func (dbms *DBMS) createDatabase(tx interfaces.Transaction, count uint32) {
return
}
+ state := types.NewUserState()
+ for _, user := range p.Users {
+ state.State[user.Address] = &types.PermStat{
+ Permission: user.Permission,
+ Status: user.Status,
+ }
+ }
+
+ dbms.chainMap.Store(dbid, state)
+
peers := proto.Peers{
PeersHeader: proto.PeersHeader{
Leader: nodeIDs[0],
@@ -232,7 +280,7 @@ func (dbms *DBMS) createDatabase(tx interfaces.Transaction, count uint32) {
GenesisBlock: p.Genesis,
Profile: p,
}
- err := dbms.Create(&si, true)
+ err = dbms.Create(&si, true)
if err != nil {
log.WithError(err).Error("create database error")
}
@@ -253,17 +301,9 @@ func (dbms *DBMS) updatePermission(tx interfaces.Transaction, count uint32) {
return
}
- newState := state.(types.ChainState)
- err := newState.UpdatePermission(up, count)
- if err != nil {
- log.WithError(err).Debug("unexpected error")
- return
- }
+ newState := state.(types.UserState)
+ newState.UpdatePermission(up.TargetUser, up.Permission)
dbms.chainMap.Store(up.TargetSQLChain.DatabaseID(), newState)
- err = dbms.writeMeta()
- if err != nil {
- log.WithError(err).Debug("unexpected error")
- }
}
func (dbms *DBMS) initDatabases(meta *DBMSMeta, conf []types.ServiceInstance) (err error) {
@@ -285,15 +325,6 @@ func (dbms *DBMS) initDatabases(meta *DBMSMeta, conf []types.ServiceInstance) (e
}
}
- // init chain state
- for dbID, state := range meta.ChainState {
- dbms.chainMap.Store(dbID, state)
- }
- err = dbms.writeMeta()
- if err != nil {
- return
- }
-
// drop database
for dbID := range toDropInstance {
if err = dbms.Drop(dbID); err != nil {
@@ -444,14 +475,6 @@ func (dbms *DBMS) addMeta(dbID proto.DatabaseID, db *Database) (err error) {
return dbms.writeMeta()
}
-func (dbms *DBMS) addState(dbID proto.DatabaseID, state *types.ChainState) (err error) {
- if _, alreadyExists := dbms.chainMap.LoadOrStore(dbID, state); alreadyExists {
- return ErrAlreadyExists
- }
-
- return dbms.writeMeta()
-}
-
func (dbms *DBMS) removeMeta(dbID proto.DatabaseID) (err error) {
dbms.dbMap.Delete(dbID)
return dbms.writeMeta()
@@ -488,36 +511,34 @@ func (dbms *DBMS) checkPermission(addr proto.AccountAddress, req *types.Request)
}
var (
- i int
- user *types.SQLChainUser
- s = state.(types.ChainState)
+ s = state.(types.UserState)
)
- for i, user = range s.Users {
- if user.Address == addr {
- break
+ if permStat, ok := s.State[addr]; ok {
+ if !permStat.Status.EnableQuery() {
+ err = ErrPermissionDeny
+ return
}
- }
- profileLen := len(s.Users)
- if i < profileLen && profileLen > 0 {
if req.Header.QueryType == types.ReadQuery {
- if s.Users[i].Permission > types.Read {
+ if !permStat.Permission.CheckRead() {
err = ErrPermissionDeny
return
}
} else if req.Header.QueryType == types.WriteQuery {
- if s.Users[i].Permission > types.Write {
+ if !permStat.Permission.CheckWrite() {
err = ErrPermissionDeny
return
}
} else {
err = ErrInvalidPermission
return
+
}
} else {
err = ErrPermissionDeny
return
}
+
return
}
diff --git a/worker/dbms_meta.go b/worker/dbms_meta.go
index 405b6e34c..a8d5c90ef 100644
--- a/worker/dbms_meta.go
+++ b/worker/dbms_meta.go
@@ -18,19 +18,16 @@ package worker
import (
"github.com/CovenantSQL/CovenantSQL/proto"
- "github.com/CovenantSQL/CovenantSQL/types"
)
// DBMSMeta defines the meta structure.
type DBMSMeta struct {
DBS map[proto.DatabaseID]bool
- ChainState map[proto.DatabaseID]types.ChainState
}
// NewDBMSMeta returns new DBMSMeta struct.
func NewDBMSMeta() (meta *DBMSMeta) {
return &DBMSMeta{
DBS: make(map[proto.DatabaseID]bool),
- ChainState: make(map[proto.DatabaseID]types.ChainState),
}
}
From bf3fa4385099607bf8d8521edee6b59088ff41a2 Mon Sep 17 00:00:00 2001
From: laodouya
Date: Thu, 20 Dec 2018 10:06:05 +0800
Subject: [PATCH 103/278] Seperate bp, miner, client build process in params
while running build.sh
---
build.sh | 80 +++++++++++++++++++++++++++++++++++++-------------------
1 file changed, 53 insertions(+), 27 deletions(-)
diff --git a/build.sh b/build.sh
index 906c6f876..a403e9f12 100755
--- a/build.sh
+++ b/build.sh
@@ -1,6 +1,8 @@
#!/bin/bash -x
set -e
+param=$1
+
branch=`git rev-parse --abbrev-ref HEAD`
commitid=`git rev-parse --short HEAD`
builddate=`date +%Y%m%d%H%M%S`
@@ -28,40 +30,64 @@ ldflags_role_client="-X main.version=${version} -X github.com/CovenantSQL/Covena
test_flags="-coverpkg github.com/CovenantSQL/CovenantSQL/... -cover -race -c"
-cql_utils_pkgpath="github.com/CovenantSQL/CovenantSQL/cmd/cql-utils"
-go build -ldflags "-X main.version=${version} ${GOLDFLAGS}" -o bin/cql-utils ${cql_utils_pkgpath}
-
-cql_observer_pkgpath="github.com/CovenantSQL/CovenantSQL/cmd/cql-observer"
-go build -ldflags "${ldflags_role_client}" -o bin/cql-observer ${cql_observer_pkgpath}
-go test ${test_flags} -tags 'testbinary' -ldflags "${ldflags_role_client}" -o bin/cql-observer.test ${cql_observer_pkgpath}
-
export CGO_ENABLED=1
-cqld_pkgpath="github.com/CovenantSQL/CovenantSQL/cmd/cqld"
-go build -ldflags "${ldflags_role_bp}" --tags "${tags}" -o bin/cqld ${cqld_pkgpath}
-go test ${test_flags} -tags "${testtags}" -ldflags "${ldflags_role_bp}" -o bin/cqld.test ${cqld_pkgpath}
-
-cql_minerd_pkgpath="github.com/CovenantSQL/CovenantSQL/cmd/cql-minerd"
-go build -ldflags "${ldflags_role_miner}" --tags "${tags}" -o bin/cql-minerd ${cql_minerd_pkgpath}
-go test ${test_flags} -tags "${testtags}" -ldflags "${ldflags_role_miner}" -o bin/cql-minerd.test ${cql_minerd_pkgpath}
-
-cli_pkgpath="github.com/CovenantSQL/CovenantSQL/cmd/cql"
-go build -ldflags "${ldflags_role_client}" --tags "${tags}" -o bin/cql ${cli_pkgpath}
+cql_utils_pkgpath="github.com/CovenantSQL/CovenantSQL/cmd/cql-utils"
+go build -ldflags "-X main.version=${version} ${GOLDFLAGS}" -o bin/cql-utils ${cql_utils_pkgpath}
-fuse_pkgpath="github.com/CovenantSQL/CovenantSQL/cmd/cql-fuse"
-go build -ldflags "${ldflags_role_client}" --tags "${tags}" -o bin/cql-fuse ${fuse_pkgpath}
-cql_adapter_pkgpath="github.com/CovenantSQL/CovenantSQL/cmd/cql-adapter"
-go build -ldflags "${ldflags_role_client}" --tags "${tags}" -o bin/cql-adapter ${cql_adapter_pkgpath}
+build_bp() {
+ cqld_pkgpath="github.com/CovenantSQL/CovenantSQL/cmd/cqld"
+ go build -ldflags "${ldflags_role_bp}" --tags "${tags}" -o bin/cqld ${cqld_pkgpath}
+ go test ${test_flags} -tags "${testtags}" -ldflags "${ldflags_role_bp}" -o bin/cqld.test ${cqld_pkgpath}
+}
-cql_faucet_pkgpath="github.com/CovenantSQL/CovenantSQL/cmd/cql-faucet"
-go build -ldflags "${ldflags_role_client}" --tags "${tags}" -o bin/cql-faucet ${cql_faucet_pkgpath}
+build_miner() {
+ cql_minerd_pkgpath="github.com/CovenantSQL/CovenantSQL/cmd/cql-minerd"
+ go build -ldflags "${ldflags_role_miner}" --tags "${tags}" -o bin/cql-minerd ${cql_minerd_pkgpath}
+ go test ${test_flags} -tags "${testtags}" -ldflags "${ldflags_role_miner}" -o bin/cql-minerd.test ${cql_minerd_pkgpath}
+}
-cql_mysql_adapter_pkgpath="github.com/CovenantSQL/CovenantSQL/cmd/cql-mysql-adapter"
-go build -ldflags "${ldflags_role_client}" --tags "${tags}" -o bin/cql-mysql-adapter ${cql_mysql_adapter_pkgpath}
-cql_explorer_pkgpath="github.com/CovenantSQL/CovenantSQL/cmd/cql-explorer"
-go build -ldflags "${ldflags_role_client}" --tags "${tags}" -o bin/cql-explorer ${cql_explorer_pkgpath}
+build_client() {
+ cql_observer_pkgpath="github.com/CovenantSQL/CovenantSQL/cmd/cql-observer"
+ go build -ldflags "${ldflags_role_client}" -o bin/cql-observer ${cql_observer_pkgpath}
+ go test ${test_flags} -tags 'testbinary' -ldflags "${ldflags_role_client}" -o bin/cql-observer.test ${cql_observer_pkgpath}
+
+ cli_pkgpath="github.com/CovenantSQL/CovenantSQL/cmd/cql"
+ go build -ldflags "${ldflags_role_client}" --tags "${tags}" -o bin/cql ${cli_pkgpath}
+
+ fuse_pkgpath="github.com/CovenantSQL/CovenantSQL/cmd/cql-fuse"
+ go build -ldflags "${ldflags_role_client}" --tags "${tags}" -o bin/cql-fuse ${fuse_pkgpath}
+
+ cql_adapter_pkgpath="github.com/CovenantSQL/CovenantSQL/cmd/cql-adapter"
+ go build -ldflags "${ldflags_role_client}" --tags "${tags}" -o bin/cql-adapter ${cql_adapter_pkgpath}
+
+ cql_faucet_pkgpath="github.com/CovenantSQL/CovenantSQL/cmd/cql-faucet"
+ go build -ldflags "${ldflags_role_client}" --tags "${tags}" -o bin/cql-faucet ${cql_faucet_pkgpath}
+
+ cql_mysql_adapter_pkgpath="github.com/CovenantSQL/CovenantSQL/cmd/cql-mysql-adapter"
+ go build -ldflags "${ldflags_role_client}" --tags "${tags}" -o bin/cql-mysql-adapter ${cql_mysql_adapter_pkgpath}
+
+ cql_explorer_pkgpath="github.com/CovenantSQL/CovenantSQL/cmd/cql-explorer"
+ go build -ldflags "${ldflags_role_client}" --tags "${tags}" -o bin/cql-explorer ${cql_explorer_pkgpath}
+}
+case $param in
+ "bp")
+ build_bp
+ ;;
+ 'miner')
+ build_miner
+ ;;
+ 'client')
+ build_client
+ ;;
+ *)
+ build_bp
+ build_miner
+ build_client
+ ;;
+esac
echo "done"
From 7cddd8e192717fba4aa32977c2726c51118c349c Mon Sep 17 00:00:00 2001
From: laodouya
Date: Thu, 20 Dec 2018 10:17:32 +0800
Subject: [PATCH 104/278] Add bp, miner, client, stop params in Makefile.
---
Makefile | 21 ++++++++++++++++++---
build.sh | 1 +
2 files changed, 19 insertions(+), 3 deletions(-)
diff --git a/Makefile b/Makefile
index 43e9dbbe4..a8928efde 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-default: build
+default: docker
IMAGE := covenantsql/covenantsql
GIT_COMMIT ?= $(shell git rev-parse --short HEAD)
@@ -15,7 +15,7 @@ IMAGE_TAR_GZ := $(IMAGE_TAR).gz
status:
@echo "Commit: $(COMMIT) Version: $(VERSION) Ship Version: $(SHIP_VERSION)"
-build: status
+docker: status
docker build \
--tag $(IMAGE):$(VERSION) \
--tag $(IMAGE):latest \
@@ -35,6 +35,9 @@ start:
docker-compose up --no-start
docker-compose start
+stop:
+ docker-compose down
+
logs:
docker-compose logs -f --tail=10
@@ -42,4 +45,16 @@ push:
docker push $(IMAGE):$(VERSION)
docker push $(IMAGE):latest
-.PHONY: status build save start logs push
+bp:
+ ./build.sh bp
+
+miner:
+ ./build.sh miner
+
+client:
+ ./build.sh client
+
+all:
+ ./build.sh
+
+.PHONY: status docker save start stop logs push bp miner client all
diff --git a/build.sh b/build.sh
index a403e9f12..848608406 100755
--- a/build.sh
+++ b/build.sh
@@ -89,5 +89,6 @@ case $param in
build_client
;;
esac
+
echo "done"
From 15cd3790a80811086ec6f989448cb75617e238ca Mon Sep 17 00:00:00 2001
From: Qi Xiao
Date: Thu, 20 Dec 2018 10:45:17 +0800
Subject: [PATCH 105/278] Add switch for eventual consistency test
---
types/init_service_type.go | 11 ++++++-----
worker/db.go | 6 ++++++
worker/db_config.go | 15 ++++++++-------
worker/dbms.go | 15 ++++++++-------
4 files changed, 28 insertions(+), 19 deletions(-)
diff --git a/types/init_service_type.go b/types/init_service_type.go
index 9d5462788..46831a462 100644
--- a/types/init_service_type.go
+++ b/types/init_service_type.go
@@ -31,11 +31,12 @@ type InitService struct {
// ResourceMeta defines single database resource meta.
type ResourceMeta struct {
- Node uint16 // reserved node count
- Space uint64 // reserved storage space in bytes
- Memory uint64 // reserved memory in bytes
- LoadAvgPerCPU uint64 // max loadAvg15 per CPU
- EncryptionKey string `hspack:"-"` // encryption key for database instance
+ Node uint16 // reserved node count
+ Space uint64 // reserved storage space in bytes
+ Memory uint64 // reserved memory in bytes
+ LoadAvgPerCPU uint64 // max loadAvg15 per CPU
+ EncryptionKey string `hspack:"-"` // encryption key for database instance
+ EventualConsistency bool `hspack:"-"` // TODO, eventual consistency test, need later refactor
}
// ServiceInstance defines single instance to be initialized.
diff --git a/worker/db.go b/worker/db.go
index 96095d271..01fb9bd44 100644
--- a/worker/db.go
+++ b/worker/db.go
@@ -17,6 +17,7 @@
package worker
import (
+ "context"
"os"
"path/filepath"
@@ -203,6 +204,11 @@ func (db *Database) Query(request *types.Request) (response *types.Response, err
case types.ReadQuery:
return db.chain.Query(request)
case types.WriteQuery:
+ if db.cfg.EventualConsistency {
+ // reset context
+ request.SetContext(context.Background())
+ return db.chain.Query(request)
+ }
return db.writeQuery(request)
default:
// TODO(xq262144): verbose errors with custom error structure
diff --git a/worker/db_config.go b/worker/db_config.go
index 7a2b5b1dc..5d631ef62 100644
--- a/worker/db_config.go
+++ b/worker/db_config.go
@@ -25,11 +25,12 @@ import (
// DBConfig defines the database config.
type DBConfig struct {
- DatabaseID proto.DatabaseID
- DataDir string
- KayakMux *DBKayakMuxService
- ChainMux *sqlchain.MuxService
- MaxWriteTimeGap time.Duration
- EncryptionKey string
- SpaceLimit uint64
+ DatabaseID proto.DatabaseID
+ DataDir string
+ KayakMux *DBKayakMuxService
+ ChainMux *sqlchain.MuxService
+ MaxWriteTimeGap time.Duration
+ EncryptionKey string
+ SpaceLimit uint64
+ EventualConsistency bool
}
diff --git a/worker/dbms.go b/worker/dbms.go
index 647d4d786..a1651cb7d 100644
--- a/worker/dbms.go
+++ b/worker/dbms.go
@@ -206,13 +206,14 @@ func (dbms *DBMS) Create(instance *types.ServiceInstance, cleanup bool) (err err
// new db
dbCfg := &DBConfig{
- DatabaseID: instance.DatabaseID,
- DataDir: rootDir,
- KayakMux: dbms.kayakMux,
- ChainMux: dbms.chainMux,
- MaxWriteTimeGap: dbms.cfg.MaxReqTimeGap,
- EncryptionKey: instance.ResourceMeta.EncryptionKey,
- SpaceLimit: instance.ResourceMeta.Space,
+ DatabaseID: instance.DatabaseID,
+ DataDir: rootDir,
+ KayakMux: dbms.kayakMux,
+ ChainMux: dbms.chainMux,
+ MaxWriteTimeGap: dbms.cfg.MaxReqTimeGap,
+ EncryptionKey: instance.ResourceMeta.EncryptionKey,
+ SpaceLimit: instance.ResourceMeta.Space,
+ EventualConsistency: instance.ResourceMeta.EventualConsistency,
}
if db, err = NewDatabase(dbCfg, instance.Peers, instance.GenesisBlock); err != nil {
From 653d8c8b58a3301310d9b7eb242ce3e3c4d31af7 Mon Sep 17 00:00:00 2001
From: leventeliu
Date: Thu, 20 Dec 2018 11:02:40 +0800
Subject: [PATCH 106/278] Use savepoint for multiple-query request
---
xenomint/state.go | 20 +++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)
diff --git a/xenomint/state.go b/xenomint/state.go
index 776860a47..37af7a8b5 100644
--- a/xenomint/state.go
+++ b/xenomint/state.go
@@ -422,7 +422,10 @@ func (s *State) write(
}()
if err = func() (err error) {
- var ierr error
+ var (
+ ierr error
+ qcnt = len(req.Payload.Queries)
+ )
s.Lock()
lockAcquired = time.Since(start)
defer func() {
@@ -430,6 +433,14 @@ func (s *State) write(
lockReleased = time.Since(start)
}()
lastSeq = s.getSeq()
+ if qcnt > 1 {
+ // Set savepoint
+ if _, ierr = s.unc.Exec(`SAVEPOINT "?"`, lastSeq); ierr != nil {
+ err = errors.Wrapf(ierr, "failed to create savepoint %d", lastSeq)
+ return
+ }
+ defer s.unc.Exec(`ROLLBACK TO "?"`, lastSeq)
+ }
for i, v := range req.Payload.Queries {
var res sql.Result
if res, ierr = s.writeSingle(ctx, &v); ierr != nil {
@@ -444,6 +455,13 @@ func (s *State) write(
lastInsertID, _ = res.LastInsertId()
totalAffectedRows += curAffectedRows
}
+ if qcnt > 1 {
+ // Release savepoint
+ if _, ierr = s.unc.Exec(`RELEASE SAVEPOINT "?"`, lastSeq); ierr != nil {
+ err = errors.Wrapf(ierr, "failed to release savepoint %d", lastSeq)
+ return
+ }
+ }
// Try to commit if the ongoing tx is too large or schema is changed
if s.getSeq()-s.getLastCommitPoint() > s.maxTx ||
atomic.LoadUint32(&s.hasSchemaChange) != 0 {
From 3dc92d7f79c2932e96aa947ba1463632f41dd456 Mon Sep 17 00:00:00 2001
From: zeqing-guo
Date: Thu, 20 Dec 2018 11:11:12 +0800
Subject: [PATCH 107/278] Format code
---
blockproducer/chain_test.go | 2 +-
types/account.go | 1 -
types/chainstate.go | 4 ++--
worker/dbms.go | 8 ++++----
worker/dbms_meta.go | 4 ++--
5 files changed, 9 insertions(+), 10 deletions(-)
diff --git a/blockproducer/chain_test.go b/blockproducer/chain_test.go
index 95634a440..28a68c5b3 100644
--- a/blockproducer/chain_test.go
+++ b/blockproducer/chain_test.go
@@ -70,7 +70,7 @@ func newProvideService(
t *types.ProvideService, err error,
) {
t = types.NewProvideService(&types.ProvideServiceHeader{
- Nonce: nonce,
+ Nonce: nonce,
})
err = t.Sign(signer)
return
diff --git a/types/account.go b/types/account.go
index b4cad6f3e..7f07a8df6 100644
--- a/types/account.go
+++ b/types/account.go
@@ -59,7 +59,6 @@ func (up *UserPermission) CheckWrite() bool {
return *up >= Admin && *up <= Write
}
-
// CheckAdmin returns true if user owns admin permission.
func (up *UserPermission) CheckAdmin() bool {
return *up == Admin
diff --git a/types/chainstate.go b/types/chainstate.go
index fffc4597c..acd4b56b2 100644
--- a/types/chainstate.go
+++ b/types/chainstate.go
@@ -22,7 +22,7 @@ import (
type PermStat struct {
Permission UserPermission
- Status Status
+ Status Status
}
type UserState struct {
@@ -61,4 +61,4 @@ func (us *UserState) GetStatus(user proto.AccountAddress) (stat Status, ok bool)
permstat, ok := us.State[user]
stat = permstat.Status
return
-}
\ No newline at end of file
+}
diff --git a/worker/dbms.go b/worker/dbms.go
index 016a3790f..960c9a6be 100644
--- a/worker/dbms.go
+++ b/worker/dbms.go
@@ -206,7 +206,7 @@ func (dbms *DBMS) updateBilling(tx interfaces.Transaction, count uint32) {
}
var (
- dbid = ub.Receiver.DatabaseID()
+ dbid = ub.Receiver.DatabaseID()
state = s.(types.UserState)
)
@@ -219,7 +219,7 @@ func (dbms *DBMS) updateBilling(tx interfaces.Transaction, count uint32) {
for _, user := range p.Users {
state.State[user.Address] = &types.PermStat{
Permission: user.Permission,
- Status: user.Status,
+ Status: user.Status,
}
}
dbms.chainMap.Store(ub.Receiver.DatabaseID(), state)
@@ -261,7 +261,7 @@ func (dbms *DBMS) createDatabase(tx interfaces.Transaction, count uint32) {
for _, user := range p.Users {
state.State[user.Address] = &types.PermStat{
Permission: user.Permission,
- Status: user.Status,
+ Status: user.Status,
}
}
@@ -511,7 +511,7 @@ func (dbms *DBMS) checkPermission(addr proto.AccountAddress, req *types.Request)
}
var (
- s = state.(types.UserState)
+ s = state.(types.UserState)
)
if permStat, ok := s.State[addr]; ok {
diff --git a/worker/dbms_meta.go b/worker/dbms_meta.go
index a8d5c90ef..bf3033789 100644
--- a/worker/dbms_meta.go
+++ b/worker/dbms_meta.go
@@ -22,12 +22,12 @@ import (
// DBMSMeta defines the meta structure.
type DBMSMeta struct {
- DBS map[proto.DatabaseID]bool
+ DBS map[proto.DatabaseID]bool
}
// NewDBMSMeta returns new DBMSMeta struct.
func NewDBMSMeta() (meta *DBMSMeta) {
return &DBMSMeta{
- DBS: make(map[proto.DatabaseID]bool),
+ DBS: make(map[proto.DatabaseID]bool),
}
}
From e1e0d09cca40299256bcd0488a277673437e89ab Mon Sep 17 00:00:00 2001
From: zeqing-guo
Date: Thu, 20 Dec 2018 11:37:44 +0800
Subject: [PATCH 108/278] Increase check interval
---
worker/dbms.go | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/worker/dbms.go b/worker/dbms.go
index 960c9a6be..1c54448af 100644
--- a/worker/dbms.go
+++ b/worker/dbms.go
@@ -23,6 +23,7 @@ import (
"os"
"path/filepath"
"sync"
+ "time"
"github.com/CovenantSQL/CovenantSQL/blockproducer/interfaces"
"github.com/CovenantSQL/CovenantSQL/crypto"
@@ -45,7 +46,7 @@ const (
// DBMetaFileName defines dbms meta file name.
DBMetaFileName = "db.meta"
- CheckInterval = 1
+ CheckInterval = time.Second
)
// DBMS defines a database management instance.
From a0ab92e6d9299e34cffb53c66959e585185a7626 Mon Sep 17 00:00:00 2001
From: laodouya
Date: Thu, 20 Dec 2018 14:30:52 +0800
Subject: [PATCH 109/278] Update GNTE: Reduce bench docker size.
---
test/GNTE/GNTE | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/test/GNTE/GNTE b/test/GNTE/GNTE
index d34ad0da6..82ab29afb 160000
--- a/test/GNTE/GNTE
+++ b/test/GNTE/GNTE
@@ -1 +1 @@
-Subproject commit d34ad0da6cf6fb07065da2fb8e050366adb58123
+Subproject commit 82ab29afbb75cb89c196029d49d5df7aae74de4c
From f775461b8095ecafc875bc1b6ca0b76d80e20309 Mon Sep 17 00:00:00 2001
From: leventeliu
Date: Thu, 20 Dec 2018 21:12:29 +0800
Subject: [PATCH 110/278] Rename ambiguous variables
---
blockproducer/storage.go | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/blockproducer/storage.go b/blockproducer/storage.go
index 105e492f9..d4a4c993f 100644
--- a/blockproducer/storage.go
+++ b/blockproducer/storage.go
@@ -316,10 +316,10 @@ func loadBlocks(
headsIndex = make(map[hash.Hash]*blockNode)
// Scan buffer
- id uint32
- v1 uint32
- v2, v3 string
- v4 []byte
+ id uint32
+ height uint32
+ bnHex, pnHex string
+ enc []byte
ok bool
bh, ph hash.Hash
@@ -336,27 +336,27 @@ func loadBlocks(
for rows.Next() {
// Scan and decode block
- if err = rows.Scan(&id, &v1, &v2, &v3, &v4); err != nil {
+ if err = rows.Scan(&id, &height, &bnHex, &pnHex, &enc); err != nil {
return
}
- if err = hash.Decode(&bh, v2); err != nil {
+ if err = hash.Decode(&bh, bnHex); err != nil {
return
}
- if err = hash.Decode(&ph, v3); err != nil {
+ if err = hash.Decode(&ph, pnHex); err != nil {
return
}
var dec = &types.BPBlock{}
- if err = utils.DecodeMsgPack(v4, dec); err != nil {
+ if err = utils.DecodeMsgPack(enc, dec); err != nil {
return
}
log.WithFields(log.Fields{
"rowid": id,
- "height": v1,
+ "height": height,
"hash": bh.Short(4),
"parent": ph.Short(4),
}).Debug("loaded new block")
// Add genesis block
- if v1 == 0 {
+ if height == 0 {
if len(index) != 0 {
err = ErrMultipleGenesis
return
@@ -366,7 +366,7 @@ func loadBlocks(
headsIndex[bh] = bn
log.WithFields(log.Fields{
"rowid": id,
- "height": v1,
+ "height": height,
"hash": bh.Short(4),
"parent": ph.Short(4),
}).Debug("set genesis block")
@@ -377,7 +377,7 @@ func loadBlocks(
err = errors.Wrapf(ErrParentNotFound, "parent %s not found", ph.Short(4))
return
}
- bn = newBlockNode(v1, dec, pn)
+ bn = newBlockNode(height, dec, pn)
index[bh] = bn
if _, ok = headsIndex[ph]; ok {
delete(headsIndex, ph)
From d8545c9d4f525d7b0416399586567babc6bf0618 Mon Sep 17 00:00:00 2001
From: leventeliu
Date: Thu, 20 Dec 2018 21:14:21 +0800
Subject: [PATCH 111/278] Minor fix
---
blockproducer/chain.go | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/blockproducer/chain.go b/blockproducer/chain.go
index ed33f38e4..381f6b4f6 100644
--- a/blockproducer/chain.go
+++ b/blockproducer/chain.go
@@ -91,10 +91,11 @@ func NewChainWithContext(ctx context.Context, cfg *Config) (c *Chain, err error)
ok bool
ierr error
- cld, ccl = context.WithCancel(ctx)
- l = uint32(len(cfg.Peers.Servers))
- t float64
- m uint32
+ cld context.Context
+ ccl context.CancelFunc
+ l = uint32(len(cfg.Peers.Servers))
+ t float64
+ m uint32
st xi.Storage
irre *blockNode
@@ -178,6 +179,7 @@ func NewChainWithContext(ctx context.Context, cfg *Config) (c *Chain, err error)
if v.hasAncestor(irre) {
if br, ierr = fork(irre, v, immutable, txPool); ierr != nil {
err = errors.Wrapf(ierr, "failed to rebuild branch with head %s", v.hash.Short(4))
+ return
}
branches = append(branches, br)
}
@@ -216,6 +218,7 @@ func NewChainWithContext(ctx context.Context, cfg *Config) (c *Chain, err error)
}
// create chain
+ cld, ccl = context.WithCancel(ctx)
c = &Chain{
ctx: cld,
cancel: ccl,
From 03ab1906fc5274cad4a4ebdb7805299e312ee653 Mon Sep 17 00:00:00 2001
From: zeqing-guo
Date: Fri, 21 Dec 2018 09:53:13 +0800
Subject: [PATCH 112/278] Remove runtime.databaseID and add UpdatePeriod
---
blockproducer/metaindex.go | 3 ---
blockproducer/metastate_test.go | 2 +-
sqlchain/chain.go | 30 +++++++++++++++++-------------
sqlchain/chain_test.go | 2 ++
sqlchain/chainbusservice.go | 4 ++++
sqlchain/config.go | 1 -
sqlchain/observer.go | 2 +-
sqlchain/runtime.go | 21 +++++++++------------
sqlchain/state.go | 9 +++------
types/init_service_type.go | 1 -
types/init_service_type_gen.go | 26 +++++---------------------
types/no_ack_report_type_gen.go | 21 +++++++++++++++++++--
types/request_type_gen.go | 23 +++++------------------
worker/db.go | 8 ++++----
worker/db_config.go | 1 +
worker/db_test.go | 3 +++
worker/dbms.go | 7 +++++--
17 files changed, 79 insertions(+), 85 deletions(-)
diff --git a/blockproducer/metaindex.go b/blockproducer/metaindex.go
index 170994ffe..f43bf567f 100644
--- a/blockproducer/metaindex.go
+++ b/blockproducer/metaindex.go
@@ -17,8 +17,6 @@
package blockproducer
import (
- "sync"
-
"github.com/CovenantSQL/CovenantSQL/proto"
"github.com/CovenantSQL/CovenantSQL/types"
"github.com/ulule/deepcopier"
@@ -55,7 +53,6 @@ type providerObject struct {
}
type metaIndex struct {
- sync.RWMutex
accounts map[proto.AccountAddress]*accountObject
databases map[proto.DatabaseID]*sqlchainObject
provider map[proto.AccountAddress]*providerObject
diff --git a/blockproducer/metastate_test.go b/blockproducer/metastate_test.go
index dd15f6fb5..f0bf346c7 100644
--- a/blockproducer/metastate_test.go
+++ b/blockproducer/metastate_test.go
@@ -683,7 +683,7 @@ func TestMetaState(t *testing.T) {
So(err, ShouldBeNil)
err = ms.apply(&invalidPs)
- So(errors.Cause(err), ShouldEqual, ErrInvalidSender)
+ So(errors.Cause(err), ShouldEqual, ErrInsufficientBalance)
err = ms.apply(&invalidCd1)
So(errors.Cause(err), ShouldEqual, ErrInvalidSender)
err = ms.apply(&invalidCd2)
diff --git a/sqlchain/chain.go b/sqlchain/chain.go
index c23cb2c2f..66d0f8fe7 100644
--- a/sqlchain/chain.go
+++ b/sqlchain/chain.go
@@ -215,7 +215,7 @@ func NewChainWithContext(ctx context.Context, c *Config) (chain *Chain, err erro
tokenType: c.TokenType,
gasPrice: c.GasPrice,
updatePeriod: c.UpdatePeriod,
- databaseID: c.Profile.ID,
+ databaseID: c.DatabaseID,
// Observer related
observers: make(map[proto.NodeID]int32),
@@ -292,7 +292,7 @@ func LoadChainWithContext(ctx context.Context, c *Config) (chain *Chain, err err
tokenType: c.TokenType,
gasPrice: c.GasPrice,
updatePeriod: c.UpdatePeriod,
- databaseID: c.Profile.ID,
+ databaseID: c.DatabaseID,
// Observer related
observers: make(map[proto.NodeID]int32),
@@ -603,7 +603,7 @@ func (c *Chain) produceBlockV2(now time.Time) (err error) {
Envelope: proto.Envelope{
// TODO(leventeliu): Add fields.
},
- DatabaseID: c.rt.databaseID,
+ DatabaseID: c.databaseID,
AdviseNewBlockReq: AdviseNewBlockReq{
Block: block,
Count: func() int32 {
@@ -655,7 +655,7 @@ func (c *Chain) syncHead() {
Envelope: proto.Envelope{
// TODO(leventeliu): Add fields.
},
- DatabaseID: c.rt.databaseID,
+ DatabaseID: c.databaseID,
FetchBlockReq: FetchBlockReq{
Height: h,
},
@@ -943,7 +943,7 @@ func (c *Chain) Stop() (err error) {
"peer": c.rt.getPeerInfoString(),
"time": c.rt.getChainTimeString(),
}).Debug("stopping chain")
- c.rt.stop()
+ c.rt.stop(c.databaseID)
log.WithFields(log.Fields{
"peer": c.rt.getPeerInfoString(),
"time": c.rt.getChainTimeString(),
@@ -1172,7 +1172,7 @@ func (c *Chain) getBilling(low, high int32) (req *types.BillingRequest, err erro
req = &types.BillingRequest{
Header: types.BillingRequestHeader{
- DatabaseID: c.rt.databaseID,
+ DatabaseID: c.databaseID,
LowBlock: *lowBlock.BlockHash(),
LowHeight: low,
HighBlock: *highBlock.BlockHash(),
@@ -1190,7 +1190,7 @@ func (c *Chain) collectBillingSignatures(ctx context.Context, billings *types.Bi
Envelope: proto.Envelope{
// TODO(leventeliu): Add fields.
},
- DatabaseID: c.rt.databaseID,
+ DatabaseID: c.databaseID,
SignBillingReq: SignBillingReq{
BillingRequest: *billings,
},
@@ -1473,14 +1473,14 @@ func (c *Chain) stat() {
)
// Print chain stats
log.WithFields(log.Fields{
- "database_id": c.rt.databaseID,
+ "database_id": c.databaseID,
"multiIndex_count": ic,
"response_header_count": rc,
"query_tracker_count": tc,
"cached_block_count": bc,
}).Info("chain mem stats")
// Print xeno stats
- c.st.Stat(c.rt.databaseID)
+ c.st.Stat(c.databaseID)
}
func (c *Chain) billing(node *blockNode) (ub *types.UpdateBilling, err error) {
@@ -1527,14 +1527,18 @@ func (c *Chain) billing(node *blockNode) (ub *types.UpdateBilling, err error) {
i = 0
j = 0
for userAddr, cost := range usersMap {
- ub.Users[i].User = userAddr
- ub.Users[i].Cost = cost
+ ub.Users[i] = &types.UserCost{
+ User: userAddr,
+ Cost: cost,
+ }
miners := minersMap[userAddr]
ub.Users[i].Miners = make([]*types.MinerIncome, len(miners))
for k1, v1 := range miners {
- ub.Users[i].Miners[j].Miner = k1
- ub.Users[i].Miners[j].Income = v1
+ ub.Users[i].Miners[j] = &types.MinerIncome{
+ Miner: k1,
+ Income: v1,
+ }
j += 1
}
j = 0
diff --git a/sqlchain/chain_test.go b/sqlchain/chain_test.go
index 72273af51..6006d106a 100644
--- a/sqlchain/chain_test.go
+++ b/sqlchain/chain_test.go
@@ -44,6 +44,7 @@ var (
testDatabaseID proto.DatabaseID = "tdb-test"
testPeriodNumber int32 = 10
testClientNumberPerChain = 3
+ testUpdatePeriod uint64 = 2
)
type chainParams struct {
@@ -174,6 +175,7 @@ func TestMultiChain(t *testing.T) {
Server: peers.Servers[i],
Peers: peers,
QueryTTL: testQueryTTL,
+ UpdatePeriod: testUpdatePeriod,
}
chain, err := NewChain(config)
diff --git a/sqlchain/chainbusservice.go b/sqlchain/chainbusservice.go
index 8ae9f3371..68f35057d 100644
--- a/sqlchain/chainbusservice.go
+++ b/sqlchain/chainbusservice.go
@@ -72,7 +72,11 @@ func (bs *BusService) subscribeBlock(ctx context.Context) {
case <-time.After(bs.checkInterval):
// fetch block from remote block producer
c := atomic.LoadUint32(&bs.blockCount)
+ log.Info(c)
b := bs.requestBlock(c)
+ if b == nil {
+ continue
+ }
bs.extractTxs(b, c)
atomic.AddUint32(&bs.blockCount, 1)
}
diff --git a/sqlchain/config.go b/sqlchain/config.go
index 8899b74e4..4de594ca8 100644
--- a/sqlchain/config.go
+++ b/sqlchain/config.go
@@ -38,7 +38,6 @@ type Config struct {
Server proto.NodeID
// Price sets query price in gases.
- Profile *types.SQLChainProfile
Price map[types.QueryType]uint64
ProducingReward uint64
BillingPeriods int32
diff --git a/sqlchain/observer.go b/sqlchain/observer.go
index 5e293578c..169b4892d 100644
--- a/sqlchain/observer.go
+++ b/sqlchain/observer.go
@@ -202,7 +202,7 @@ func (r *observerReplicator) replicate() {
// send block
req := &MuxAdviseNewBlockReq{
Envelope: proto.Envelope{},
- DatabaseID: r.c.rt.databaseID,
+ DatabaseID: r.c.databaseID,
AdviseNewBlockReq: AdviseNewBlockReq{
Block: block,
Count: func() int32 {
diff --git a/sqlchain/runtime.go b/sqlchain/runtime.go
index 3a879f2b7..7042927f1 100644
--- a/sqlchain/runtime.go
+++ b/sqlchain/runtime.go
@@ -41,8 +41,6 @@ type runtime struct {
// The following fields are copied from config, and should be constant during whole runtime.
- // databaseID is the current runtime database ID.
- databaseID proto.DatabaseID
// period is the block producing cycle.
period time.Duration
// tick defines the maximum duration between each cycle.
@@ -94,10 +92,9 @@ func newRunTime(ctx context.Context, c *Config) (r *runtime) {
ctx: cld,
cancel: ccl,
- databaseID: c.DatabaseID,
- period: c.Period,
- tick: c.Tick,
- queryTTL: c.QueryTTL,
+ period: c.Period,
+ tick: c.Tick,
+ queryTTL: c.QueryTTL,
blockCacheTTL: func() int32 {
if c.BlockCacheTTL < minBlockCacheTTL {
return minBlockCacheTTL
@@ -124,7 +121,7 @@ func newRunTime(ctx context.Context, c *Config) (r *runtime) {
}(),
total: int32(len(c.Peers.Servers)),
nextTurn: 1,
- head: &state{Profile: c.Profile},
+ head: &state{},
offset: time.Duration(0),
}
@@ -208,8 +205,8 @@ func (r *runtime) getQueryGas(t types.QueryType) uint64 {
}
// stop sends a signal to the Runtime stop channel by closing it.
-func (r *runtime) stop() {
- r.stopService()
+func (r *runtime) stop(dbid proto.DatabaseID) {
+ r.stopService(dbid)
r.cancel()
r.wg.Wait()
}
@@ -291,11 +288,11 @@ func (r *runtime) getServer() proto.NodeID {
}
func (r *runtime) startService(chain *Chain) {
- r.muxService.register(r.databaseID, &ChainRPCService{chain: chain})
+ r.muxService.register(chain.databaseID, &ChainRPCService{chain: chain})
}
-func (r *runtime) stopService() {
- r.muxService.unregister(r.databaseID)
+func (r *runtime) stopService(dbid proto.DatabaseID) {
+ r.muxService.unregister(dbid)
}
func (r *runtime) isMyTurn() (ret bool) {
diff --git a/sqlchain/state.go b/sqlchain/state.go
index 1d5c271d7..9f7c00593 100644
--- a/sqlchain/state.go
+++ b/sqlchain/state.go
@@ -18,16 +18,13 @@ package sqlchain
import (
"github.com/CovenantSQL/CovenantSQL/crypto/hash"
- "github.com/CovenantSQL/CovenantSQL/types"
)
// state represents a snapshot of current best chain.
type state struct {
- node *blockNode
- Head hash.Hash
- Height int32
- Profile *types.SQLChainProfile
- BlockHeight int32
+ node *blockNode
+ Head hash.Hash
+ Height int32
}
//// MarshalHash marshals for hash
diff --git a/types/init_service_type.go b/types/init_service_type.go
index 1f67ea945..acaf5eb7d 100644
--- a/types/init_service_type.go
+++ b/types/init_service_type.go
@@ -45,7 +45,6 @@ type ServiceInstance struct {
Peers *proto.Peers
ResourceMeta ResourceMeta
GenesisBlock *Block
- Profile *SQLChainProfile
}
// InitServiceResponseHeader defines worker service init response header.
diff --git a/types/init_service_type_gen.go b/types/init_service_type_gen.go
index b3a118987..27008aa2e 100644
--- a/types/init_service_type_gen.go
+++ b/types/init_service_type_gen.go
@@ -111,8 +111,8 @@ func (z *ResourceMeta) Msgsize() (s int) {
func (z *ServiceInstance) MarshalHash() (o []byte, err error) {
var b []byte
o = hsp.Require(b, z.Msgsize())
- // map header, size 5
- o = append(o, 0x85, 0x85)
+ // map header, size 4
+ o = append(o, 0x84, 0x84)
if z.GenesisBlock == nil {
o = hsp.AppendNil(o)
} else {
@@ -122,17 +122,7 @@ func (z *ServiceInstance) MarshalHash() (o []byte, err error) {
o = hsp.AppendBytes(o, oTemp)
}
}
- o = append(o, 0x85)
- if z.Profile == nil {
- o = hsp.AppendNil(o)
- } else {
- if oTemp, err := z.Profile.MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
- }
- }
- o = append(o, 0x85)
+ o = append(o, 0x84)
if z.Peers == nil {
o = hsp.AppendNil(o)
} else {
@@ -142,13 +132,13 @@ func (z *ServiceInstance) MarshalHash() (o []byte, err error) {
o = hsp.AppendBytes(o, oTemp)
}
}
- o = append(o, 0x85)
+ o = append(o, 0x84)
if oTemp, err := z.ResourceMeta.MarshalHash(); err != nil {
return nil, err
} else {
o = hsp.AppendBytes(o, oTemp)
}
- o = append(o, 0x85)
+ o = append(o, 0x84)
if oTemp, err := z.DatabaseID.MarshalHash(); err != nil {
return nil, err
} else {
@@ -165,12 +155,6 @@ func (z *ServiceInstance) Msgsize() (s int) {
} else {
s += z.GenesisBlock.Msgsize()
}
- s += 8
- if z.Profile == nil {
- s += hsp.NilSize
- } else {
- s += z.Profile.Msgsize()
- }
s += 6
if z.Peers == nil {
s += hsp.NilSize
diff --git a/types/no_ack_report_type_gen.go b/types/no_ack_report_type_gen.go
index e9e89abc6..374a39fea 100644
--- a/types/no_ack_report_type_gen.go
+++ b/types/no_ack_report_type_gen.go
@@ -57,7 +57,24 @@ func (z *AggrNoAckReportHeader) MarshalHash() (o []byte, err error) {
o = append(o, 0x84)
o = hsp.AppendArrayHeader(o, uint32(len(z.Reports)))
for za0001 := range z.Reports {
- if oTemp, err := z.Reports[za0001].MarshalHash(); err != nil {
+ // map header, size 2
+ // map header, size 3
+ o = append(o, 0x82, 0x82, 0x83, 0x83)
+ if oTemp, err := z.Reports[za0001].NoAckReportHeader.NodeID.MarshalHash(); err != nil {
+ return nil, err
+ } else {
+ o = hsp.AppendBytes(o, oTemp)
+ }
+ o = append(o, 0x83)
+ o = hsp.AppendTime(o, z.Reports[za0001].NoAckReportHeader.Timestamp)
+ o = append(o, 0x83)
+ if oTemp, err := z.Reports[za0001].NoAckReportHeader.Response.MarshalHash(); err != nil {
+ return nil, err
+ } else {
+ o = hsp.AppendBytes(o, oTemp)
+ }
+ o = append(o, 0x82)
+ if oTemp, err := z.Reports[za0001].DefaultHashSignVerifierImpl.MarshalHash(); err != nil {
return nil, err
} else {
o = hsp.AppendBytes(o, oTemp)
@@ -84,7 +101,7 @@ func (z *AggrNoAckReportHeader) Msgsize() (s int) {
}
s += 8 + hsp.ArrayHeaderSize
for za0001 := range z.Reports {
- s += z.Reports[za0001].Msgsize()
+ s += 1 + 18 + 1 + 7 + z.Reports[za0001].NoAckReportHeader.NodeID.Msgsize() + 10 + hsp.TimeSize + 9 + z.Reports[za0001].NoAckReportHeader.Response.Msgsize() + 28 + z.Reports[za0001].DefaultHashSignVerifierImpl.Msgsize()
}
s += 7 + z.NodeID.Msgsize() + 10 + hsp.TimeSize
return
diff --git a/types/request_type_gen.go b/types/request_type_gen.go
index 7033d7aa6..709e66bb9 100644
--- a/types/request_type_gen.go
+++ b/types/request_type_gen.go
@@ -106,20 +106,10 @@ func (z *Request) MarshalHash() (o []byte, err error) {
o = append(o, 0x83, 0x83, 0x81, 0x81)
o = hsp.AppendArrayHeader(o, uint32(len(z.Payload.Queries)))
for za0001 := range z.Payload.Queries {
- // map header, size 2
- o = append(o, 0x82, 0x82)
- o = hsp.AppendString(o, z.Payload.Queries[za0001].Pattern)
- o = append(o, 0x82)
- o = hsp.AppendArrayHeader(o, uint32(len(z.Payload.Queries[za0001].Args)))
- for za0002 := range z.Payload.Queries[za0001].Args {
- // map header, size 2
- o = append(o, 0x82, 0x82)
- o = hsp.AppendString(o, z.Payload.Queries[za0001].Args[za0002].Name)
- o = append(o, 0x82)
- o, err = hsp.AppendIntf(o, z.Payload.Queries[za0001].Args[za0002].Value)
- if err != nil {
- return
- }
+ if oTemp, err := z.Payload.Queries[za0001].MarshalHash(); err != nil {
+ return nil, err
+ } else {
+ o = hsp.AppendBytes(o, oTemp)
}
}
// map header, size 2
@@ -148,10 +138,7 @@ func (z *Request) MarshalHash() (o []byte, err error) {
func (z *Request) Msgsize() (s int) {
s = 1 + 8 + 1 + 8 + hsp.ArrayHeaderSize
for za0001 := range z.Payload.Queries {
- s += 1 + 8 + hsp.StringPrefixSize + len(z.Payload.Queries[za0001].Pattern) + 5 + hsp.ArrayHeaderSize
- for za0002 := range z.Payload.Queries[za0001].Args {
- s += 1 + 5 + hsp.StringPrefixSize + len(z.Payload.Queries[za0001].Args[za0002].Name) + 6 + hsp.GuessSize(z.Payload.Queries[za0001].Args[za0002].Value)
- }
+ s += z.Payload.Queries[za0001].Msgsize()
}
s += 7 + 1 + 14 + z.Header.RequestHeader.Msgsize() + 28 + z.Header.DefaultHashSignVerifierImpl.Msgsize() + 9 + z.Envelope.Msgsize()
return
diff --git a/worker/db.go b/worker/db.go
index efb1764dd..c3053e6c2 100644
--- a/worker/db.go
+++ b/worker/db.go
@@ -70,13 +70,13 @@ type Database struct {
// NewDatabase create a single database instance using config.
func NewDatabase(cfg *DBConfig, peers *proto.Peers,
- profile *types.SQLChainProfile) (db *Database, err error) {
+ genesis *types.Block) (db *Database, err error) {
// ensure dir exists
if err = os.MkdirAll(cfg.DataDir, 0755); err != nil {
return
}
- if peers == nil || profile.Genesis == nil {
+ if peers == nil || genesis == nil {
err = ErrInvalidDBConfig
return
}
@@ -126,7 +126,7 @@ func NewDatabase(cfg *DBConfig, peers *proto.Peers,
DatabaseID: cfg.DatabaseID,
ChainFilePrefix: chainFile,
DataFile: storageDSN.Format(),
- Genesis: profile.Genesis,
+ Genesis: genesis,
Peers: peers,
// TODO(xq262144): should refactor server/node definition to conf/proto package
@@ -139,7 +139,7 @@ func NewDatabase(cfg *DBConfig, peers *proto.Peers,
Tick: 10 * time.Second,
QueryTTL: 10,
- Profile: profile,
+ UpdatePeriod: cfg.UpdatePeriod,
}
if db.chain, err = sqlchain.NewChain(chainCfg); err != nil {
return
diff --git a/worker/db_config.go b/worker/db_config.go
index 7a2b5b1dc..5f1f59d59 100644
--- a/worker/db_config.go
+++ b/worker/db_config.go
@@ -32,4 +32,5 @@ type DBConfig struct {
MaxWriteTimeGap time.Duration
EncryptionKey string
SpaceLimit uint64
+ UpdatePeriod uint64
}
diff --git a/worker/db_test.go b/worker/db_test.go
index e1689cb0e..29ecde74b 100644
--- a/worker/db_test.go
+++ b/worker/db_test.go
@@ -84,6 +84,7 @@ func TestSingleDatabase(t *testing.T) {
KayakMux: kayakMuxService,
ChainMux: chainMuxService,
MaxWriteTimeGap: time.Second * 5,
+ UpdatePeriod: 2,
}
// create genesis block
@@ -445,6 +446,7 @@ func TestInitFailed(t *testing.T) {
KayakMux: kayakMuxService,
ChainMux: chainMuxService,
MaxWriteTimeGap: time.Duration(5 * time.Second),
+ UpdatePeriod: 2,
}
// create genesis block
@@ -498,6 +500,7 @@ func TestDatabaseRecycle(t *testing.T) {
KayakMux: kayakMuxService,
ChainMux: chainMuxService,
MaxWriteTimeGap: time.Duration(5 * time.Second),
+ UpdatePeriod: 2,
}
// create genesis block
diff --git a/worker/dbms.go b/worker/dbms.go
index 1c54448af..650e54d70 100644
--- a/worker/dbms.go
+++ b/worker/dbms.go
@@ -46,7 +46,10 @@ const (
// DBMetaFileName defines dbms meta file name.
DBMetaFileName = "db.meta"
+ // CheckInterval defines the bus service period.
CheckInterval = time.Second
+
+ // UpdatePeriod defines the
)
// DBMS defines a database management instance.
@@ -279,7 +282,6 @@ func (dbms *DBMS) createDatabase(tx interfaces.Transaction, count uint32) {
Peers: &peers,
ResourceMeta: cd.ResourceMeta,
GenesisBlock: p.Genesis,
- Profile: p,
}
err = dbms.Create(&si, true)
if err != nil {
@@ -374,9 +376,10 @@ func (dbms *DBMS) Create(instance *types.ServiceInstance, cleanup bool) (err err
MaxWriteTimeGap: dbms.cfg.MaxReqTimeGap,
EncryptionKey: instance.ResourceMeta.EncryptionKey,
SpaceLimit: instance.ResourceMeta.Space,
+ UpdatePeriod: 2,
}
- if db, err = NewDatabase(dbCfg, instance.Peers, instance.Profile); err != nil {
+ if db, err = NewDatabase(dbCfg, instance.Peers, instance.GenesisBlock); err != nil {
return
}
From 442def2590b4fbaf4d2d1985d3177dc8ed5cd67a Mon Sep 17 00:00:00 2001
From: leventeliu
Date: Fri, 21 Dec 2018 09:56:56 +0800
Subject: [PATCH 113/278] Rename more things for readability
---
blockproducer/blocknode.go | 8 ++++----
blockproducer/blocknode_test.go | 10 +++++-----
blockproducer/branch.go | 8 +++++---
blockproducer/chain.go | 2 +-
4 files changed, 15 insertions(+), 13 deletions(-)
diff --git a/blockproducer/blocknode.go b/blockproducer/blocknode.go
index a44123be2..ab89df5ee 100644
--- a/blockproducer/blocknode.go
+++ b/blockproducer/blocknode.go
@@ -108,11 +108,11 @@ func (n *blockNode) hasAncestor(anc *blockNode) bool {
return match != nil && match.hash == anc.hash
}
-func (n *blockNode) canForkFrom(
- parent hash.Hash, lastIrreCount uint32) (match *blockNode, ok bool,
+func (n *blockNode) hasAncestorWithMinCount(
+ blockHash hash.Hash, minCount uint32) (match *blockNode, ok bool,
) {
- for match = n; match.count >= lastIrreCount; match = match.parent {
- if match.hash.IsEqual(&parent) {
+ for match = n; match.count >= minCount; match = match.parent {
+ if match.hash.IsEqual(&blockHash) {
ok = true
return
}
diff --git a/blockproducer/blocknode_test.go b/blockproducer/blocknode_test.go
index 08cb45a29..dcebfadb3 100644
--- a/blockproducer/blocknode_test.go
+++ b/blockproducer/blocknode_test.go
@@ -131,17 +131,17 @@ func TestBlockNode(t *testing.T) {
ok bool
)
- f, ok = n4.canForkFrom(n2.hash, n0.count)
+ f, ok = n4.hasAncestorWithMinCount(n2.hash, n0.count)
So(ok, ShouldBeTrue)
So(f, ShouldEqual, n2)
- f, ok = n4.canForkFrom(n4.hash, n0.count)
+ f, ok = n4.hasAncestorWithMinCount(n4.hash, n0.count)
So(ok, ShouldBeTrue)
So(f, ShouldEqual, n4)
- f, ok = n4.canForkFrom(n0.hash, n2.count)
+ f, ok = n4.hasAncestorWithMinCount(n0.hash, n2.count)
So(ok, ShouldBeFalse)
- f, ok = n4.canForkFrom(n3p.hash, n2.count)
+ f, ok = n4.hasAncestorWithMinCount(n3p.hash, n2.count)
So(ok, ShouldBeFalse)
- f, ok = n4p.canForkFrom(n3.hash, n2.count)
+ f, ok = n4p.hasAncestorWithMinCount(n3.hash, n2.count)
So(ok, ShouldBeFalse)
})
}
diff --git a/blockproducer/branch.go b/blockproducer/branch.go
index f28a9b727..40095755b 100644
--- a/blockproducer/branch.go
+++ b/blockproducer/branch.go
@@ -37,19 +37,21 @@ type branch struct {
}
func fork(
- from, to *blockNode, v *metaState, txPool map[hash.Hash]pi.Transaction) (br *branch, err error,
+ from, to *blockNode, initState *metaState, initPool map[hash.Hash]pi.Transaction,
+) (
+ br *branch, err error,
) {
var (
list = to.fetchNodeList(from.count)
inst = &branch{
head: to,
- preview: v.makeCopy(),
+ preview: initState.makeCopy(),
packed: make(map[hash.Hash]pi.Transaction),
unpacked: make(map[hash.Hash]pi.Transaction),
}
)
// Copy pool
- for k, v := range txPool {
+ for k, v := range initPool {
inst.unpacked[k] = v
}
// Apply new blocks to view and pool
diff --git a/blockproducer/chain.go b/blockproducer/chain.go
index 381f6b4f6..c3bccc4f5 100644
--- a/blockproducer/chain.go
+++ b/blockproducer/chain.go
@@ -835,7 +835,7 @@ func (c *Chain) applyBlock(bl *types.BPBlock) (err error) {
return
}
// Fork and create new branch
- if parent, ok = v.head.canForkFrom(bl.SignedHeader.ParentHash, c.lastIrre.count); ok {
+ if parent, ok = v.head.hasAncestorWithMinCount(bl.SignedHeader.ParentHash, c.lastIrre.count); ok {
head = newBlockNode(height, bl, parent)
if br, ierr = fork(c.lastIrre, head, c.immutable, c.txPool); ierr != nil {
err = errors.Wrapf(ierr, "failed to fork from %s", parent.hash.Short(4))
From 4baab96f37215488dc37fe8aeaed77d3f8215dbf Mon Sep 17 00:00:00 2001
From: leventeliu
Date: Fri, 21 Dec 2018 10:15:24 +0800
Subject: [PATCH 114/278] More renaming: use more specific function names
---
blockproducer/chain.go | 40 +++++++++++++++++++++++-----------------
1 file changed, 23 insertions(+), 17 deletions(-)
diff --git a/blockproducer/chain.go b/blockproducer/chain.go
index c3bccc4f5..5c804171c 100644
--- a/blockproducer/chain.go
+++ b/blockproducer/chain.go
@@ -126,7 +126,7 @@ func NewChainWithContext(ctx context.Context, cfg *Config) (c *Chain, err error)
// Storage genesis
if !existed {
- // TODO(leventeliu): reuse chain.switchBranch to construct initial state.
+ // TODO(leventeliu): reuse chain.replaceAndSwitchToBranch to construct initial state.
var init = newMetaState()
for _, v := range cfg.Genesis.Transactions {
if ierr = init.apply(v); ierr != nil {
@@ -669,13 +669,15 @@ func (c *Chain) loadAccountStableBalance(addr proto.AccountAddress) (balance uin
return c.immutable.loadAccountStableBalance(addr)
}
-func (c *Chain) switchBranch(bl *types.BPBlock, origin int, head *branch) (err error) {
+func (c *Chain) replaceAndSwitchToBranch(
+ newBlock *types.BPBlock, originBrIdx int, newBranch *branch) (err error,
+) {
var (
- irre *blockNode
+ lastIrre *blockNode
newIrres []*blockNode
sps []storageProcedure
up storageCallback
- height = c.heightOfTime(bl.Timestamp())
+ height = c.heightOfTime(newBlock.Timestamp())
)
// Find new irreversible blocks
@@ -683,8 +685,8 @@ func (c *Chain) switchBranch(bl *types.BPBlock, origin int, head *branch) (err e
// NOTE(leventeliu):
// May have multiple new irreversible blocks here if peer list shrinks. May also have
// no new irreversible block at all if peer list expands.
- irre = head.head.lastIrreversible(c.confirms)
- newIrres = irre.fetchNodeList(c.lastIrre.count)
+ lastIrre = newBranch.head.lastIrreversible(c.confirms)
+ newIrres = lastIrre.fetchNodeList(c.lastIrre.count)
// Apply irreversible blocks to create dirty map on immutable cache
//
@@ -698,7 +700,7 @@ func (c *Chain) switchBranch(bl *types.BPBlock, origin int, head *branch) (err e
}
// Prepare storage procedures to update immutable database
- sps = append(sps, addBlock(height, bl))
+ sps = append(sps, addBlock(height, newBlock))
for k, v := range c.immutable.dirty.accounts {
if v != nil {
sps = append(sps, updateAccount(&v.Account))
@@ -723,12 +725,12 @@ func (c *Chain) switchBranch(bl *types.BPBlock, origin int, head *branch) (err e
for _, n := range newIrres {
sps = append(sps, deleteTxs(n.block.Transactions))
}
- sps = append(sps, updateIrreversible(irre.hash))
+ sps = append(sps, updateIrreversible(lastIrre.hash))
// Prepare callback to update cache
up = func() {
// Update last irreversible block
- c.lastIrre = irre
+ c.lastIrre = lastIrre
// Apply irreversible blocks to immutable database
c.immutable.commit()
// Prune branches
@@ -737,13 +739,15 @@ func (c *Chain) switchBranch(bl *types.BPBlock, origin int, head *branch) (err e
brs = make([]*branch, 0, len(c.branches))
)
for i, b := range c.branches {
- if i == origin {
- // Current branch
- brs = append(brs, head)
+ if i == originBrIdx {
+ // Replace origin branch with new branch
+ brs = append(brs, newBranch)
idx = len(brs) - 1
- } else if b.head.hasAncestor(irre) {
+ } else if b.head.hasAncestor(lastIrre) {
+ // Move to new branches slice
brs = append(brs, b)
} else {
+ // Prune this branch
log.WithFields(log.Fields{
"branch": func() string {
if i == c.headIndex {
@@ -755,7 +759,7 @@ func (c *Chain) switchBranch(bl *types.BPBlock, origin int, head *branch) (err e
}
}
// Replace current branches
- c.headBranch = head
+ c.headBranch = newBranch
c.headIndex = idx
c.branches = brs
// Clear packed transactions
@@ -825,7 +829,7 @@ func (c *Chain) applyBlock(bl *types.BPBlock) (err error) {
)
}
// Switch branch or grow current branch
- return c.switchBranch(bl, i, br)
+ return c.replaceAndSwitchToBranch(bl, i, br)
}
}
@@ -835,7 +839,9 @@ func (c *Chain) applyBlock(bl *types.BPBlock) (err error) {
return
}
// Fork and create new branch
- if parent, ok = v.head.hasAncestorWithMinCount(bl.SignedHeader.ParentHash, c.lastIrre.count); ok {
+ if parent, ok = v.head.hasAncestorWithMinCount(
+ bl.SignedHeader.ParentHash, c.lastIrre.count,
+ ); ok {
head = newBlockNode(height, bl, parent)
if br, ierr = fork(c.lastIrre, head, c.immutable, c.txPool); ierr != nil {
err = errors.Wrapf(ierr, "failed to fork from %s", parent.hash.Short(4))
@@ -873,7 +879,7 @@ func (c *Chain) produceAndStoreBlock(
c.headBranch.head.hash.Short(4))
return
}
- if ierr = c.switchBranch(bl, c.headIndex, br); ierr != nil {
+ if ierr = c.replaceAndSwitchToBranch(bl, c.headIndex, br); ierr != nil {
err = errors.Wrapf(ierr, "failed to switch branch #%d:%s",
c.headIndex, c.headBranch.head.hash.Short(4))
return
From 8977e8cb845a0f03369fed9719f29b989ff969ca Mon Sep 17 00:00:00 2001
From: zeqing-guo
Date: Fri, 21 Dec 2018 11:11:29 +0800
Subject: [PATCH 115/278] Add test case for IssueKeys in metastate.go
---
blockproducer/metastate.go | 7 ---
blockproducer/metastate_test.go | 80 +++++++++++++++++++++++++++---
cmd/cql-adapter/storage/sqlite3.go | 1 -
cmd/cql-faucet/persistence.go | 1 -
cmd/cql-minerd/main.go | 1 -
crypto/hash/hashfuncs.go | 1 -
storage/storage.go | 1 -
worker/db.go | 1 -
8 files changed, 74 insertions(+), 19 deletions(-)
diff --git a/blockproducer/metastate.go b/blockproducer/metastate.go
index 0808cf074..de2e80154 100644
--- a/blockproducer/metastate.go
+++ b/blockproducer/metastate.go
@@ -695,13 +695,6 @@ func (s *metaState) updateKeys(tx *types.IssueKeys) (err error) {
}
// check sender's permission
- if so.Owner != sender {
- log.WithFields(log.Fields{
- "sender": sender,
- "dbID": tx.TargetSQLChain,
- }).WithError(ErrAccountPermissionDeny).Error("unexpected error in updateKeys")
- return ErrAccountPermissionDeny
- }
isAdmin := false
for _, user := range so.Users {
if sender == user.Address && user.Permission == types.Admin {
diff --git a/blockproducer/metastate_test.go b/blockproducer/metastate_test.go
index a1fd12f6d..7eeece7b3 100644
--- a/blockproducer/metastate_test.go
+++ b/blockproducer/metastate_test.go
@@ -594,13 +594,15 @@ func TestMetaState(t *testing.T) {
Contract: addr2,
},
}
- invalidPs.Sign(privKey1)
+ err = invalidPs.Sign(privKey1)
+ So(err, ShouldBeNil)
invalidCd1 := types.CreateDatabase{
CreateDatabaseHeader: types.CreateDatabaseHeader{
Owner: addr2,
},
}
- invalidCd1.Sign(privKey1)
+ err = invalidCd1.Sign(privKey1)
+ So(err, ShouldBeNil)
invalidCd2 := types.CreateDatabase{
CreateDatabaseHeader: types.CreateDatabaseHeader{
Owner: addr1,
@@ -609,7 +611,8 @@ func TestMetaState(t *testing.T) {
},
},
}
- invalidCd2.Sign(privKey1)
+ err = invalidCd2.Sign(privKey1)
+ So(err, ShouldBeNil)
err = ms.apply(&invalidPs)
So(errors.Cause(err), ShouldEqual, ErrInvalidSender)
@@ -635,7 +638,7 @@ func TestMetaState(t *testing.T) {
},
},
}
- cd1.Sign(privKey1)
+ err = cd1.Sign(privKey1)
So(err, ShouldBeNil)
cd2 := types.CreateDatabase{
CreateDatabaseHeader: types.CreateDatabaseHeader{
@@ -645,7 +648,7 @@ func TestMetaState(t *testing.T) {
},
},
}
- cd2.Sign(privKey3)
+ err = cd2.Sign(privKey3)
So(err, ShouldBeNil)
err = ms.apply(&ps)
@@ -670,7 +673,8 @@ func TestMetaState(t *testing.T) {
Nonce: cd1.Nonce + 1,
},
}
- up.Sign(privKey1)
+ err = up.Sign(privKey1)
+ So(err, ShouldBeNil)
err = ms.apply(&up)
So(errors.Cause(err), ShouldEqual, ErrDatabaseNotFound)
up.Permission = 4
@@ -716,6 +720,7 @@ func TestMetaState(t *testing.T) {
// addr1(read) update addr3(admin) fail
up.Nonce = cd1.Nonce + 2
err = up.Sign(privKey1)
+ So(err, ShouldBeNil)
err = ms.apply(&up)
So(errors.Cause(err), ShouldEqual, ErrAccountPermissionDeny)
@@ -734,6 +739,69 @@ func TestMetaState(t *testing.T) {
continue
}
}
+ Convey("Update key", func() {
+ invalidIk1 := &types.IssueKeys{}
+ err = invalidIk1.Sign(privKey1)
+ So(err, ShouldBeNil)
+ err = ms.apply(invalidIk1)
+ So(err, ShouldEqual, ErrInvalidAccountNonce)
+ invalidIk2 := &types.IssueKeys{
+ IssueKeysHeader: types.IssueKeysHeader{
+ TargetSQLChain: addr1,
+ Nonce: 2,
+ },
+ }
+ err = invalidIk2.Sign(privKey3)
+ So(err, ShouldBeNil)
+ err = ms.apply(invalidIk2)
+ So(err, ShouldEqual, ErrDatabaseNotFound)
+ invalidIk3 := &types.IssueKeys{
+ IssueKeysHeader: types.IssueKeysHeader{
+ TargetSQLChain: dbAccount,
+ Nonce: 2,
+ },
+ }
+ err = invalidIk3.Sign(privKey1)
+ So(err, ShouldBeNil)
+ err = ms.apply(invalidIk3)
+ So(err, ShouldEqual, ErrAccountPermissionDeny)
+ ik1 := &types.IssueKeys{
+ IssueKeysHeader: types.IssueKeysHeader{
+ TargetSQLChain: dbAccount,
+ Nonce: 2,
+ },
+ }
+ err = ik1.Sign(privKey3)
+ So(err, ShouldBeNil)
+ err = ms.apply(ik1)
+ So(err, ShouldBeNil)
+ ms.commit()
+ encryptKey := "12345"
+ ik2 := &types.IssueKeys{
+ IssueKeysHeader: types.IssueKeysHeader{
+ MinerKeys: []types.MinerKey{
+ {
+ Miner: addr1,
+ EncryptionKey: encryptKey,
+ },
+ },
+ TargetSQLChain: dbAccount,
+ Nonce: 3,
+ },
+ }
+ err = ik2.Sign(privKey3)
+ So(err, ShouldBeNil)
+ err = ms.apply(ik2)
+ So(err, ShouldBeNil)
+ ms.commit()
+
+ co, loaded = ms.loadSQLChainObject(*dbID)
+ for _, miner := range co.Miners {
+ if miner.Address == addr1 {
+ So(miner.EncryptionKey, ShouldEqual, encryptKey)
+ }
+ }
+ })
})
})
})
diff --git a/cmd/cql-adapter/storage/sqlite3.go b/cmd/cql-adapter/storage/sqlite3.go
index d9be539d8..aac13f94d 100644
--- a/cmd/cql-adapter/storage/sqlite3.go
+++ b/cmd/cql-adapter/storage/sqlite3.go
@@ -24,7 +24,6 @@ import (
"math/rand"
"os"
"path/filepath"
-
// Import sqlite3 manually.
_ "github.com/CovenantSQL/go-sqlite3-encrypt"
)
diff --git a/cmd/cql-faucet/persistence.go b/cmd/cql-faucet/persistence.go
index 140a6c6d6..dfdc3d458 100644
--- a/cmd/cql-faucet/persistence.go
+++ b/cmd/cql-faucet/persistence.go
@@ -26,7 +26,6 @@ import (
"github.com/CovenantSQL/CovenantSQL/conf"
"github.com/CovenantSQL/CovenantSQL/utils/log"
uuid "github.com/satori/go.uuid"
-
// Load sqlite3 database driver.
_ "github.com/CovenantSQL/go-sqlite3-encrypt"
)
diff --git a/cmd/cql-minerd/main.go b/cmd/cql-minerd/main.go
index f1fc11c16..eb8016255 100644
--- a/cmd/cql-minerd/main.go
+++ b/cmd/cql-minerd/main.go
@@ -26,7 +26,6 @@ import (
"os"
"os/signal"
"runtime"
-
//"runtime/trace"
"syscall"
"time"
diff --git a/crypto/hash/hashfuncs.go b/crypto/hash/hashfuncs.go
index af14cf46d..d3cd98561 100644
--- a/crypto/hash/hashfuncs.go
+++ b/crypto/hash/hashfuncs.go
@@ -19,7 +19,6 @@ package hash
import (
"encoding/binary"
"hash/fnv"
-
// "crypto/sha256" benchmark is at least 10% faster on
// i7-4870HQ CPU @ 2.50GHz than "github.com/minio/sha256-simd"
"crypto/sha256"
diff --git a/storage/storage.go b/storage/storage.go
index e059819af..7e36bad0e 100644
--- a/storage/storage.go
+++ b/storage/storage.go
@@ -26,7 +26,6 @@ import (
"github.com/CovenantSQL/CovenantSQL/twopc"
"github.com/CovenantSQL/CovenantSQL/utils/log"
-
// Register CovenantSQL/go-sqlite3-encrypt engine.
_ "github.com/CovenantSQL/go-sqlite3-encrypt"
)
diff --git a/worker/db.go b/worker/db.go
index 96095d271..cd69e7a63 100644
--- a/worker/db.go
+++ b/worker/db.go
@@ -19,7 +19,6 @@ package worker
import (
"os"
"path/filepath"
-
//"runtime/trace"
"sync"
"time"
From b72acd8a67017de3735317cba23b755f0531601e Mon Sep 17 00:00:00 2001
From: zeqing-guo
Date: Fri, 21 Dec 2018 11:13:48 +0800
Subject: [PATCH 116/278] Improve import format
---
xenomint/xxx_test.go | 1 -
1 file changed, 1 deletion(-)
diff --git a/xenomint/xxx_test.go b/xenomint/xxx_test.go
index 6e19f1b08..13a973878 100644
--- a/xenomint/xxx_test.go
+++ b/xenomint/xxx_test.go
@@ -22,7 +22,6 @@ import (
"os"
"path"
"sync/atomic"
-
//"runtime/trace"
"sync"
"syscall"
From 355e58288e787ba58edd985421332770fc0b3508 Mon Sep 17 00:00:00 2001
From: Qi Xiao
Date: Fri, 21 Dec 2018 11:20:43 +0800
Subject: [PATCH 117/278] Use adjustable consistency level config instead of
boolean eventual consistency config
---
types/init_service_type.go | 14 +++++++-------
worker/db.go | 3 ++-
worker/db_config.go | 16 ++++++++--------
worker/dbms.go | 16 ++++++++--------
4 files changed, 25 insertions(+), 24 deletions(-)
diff --git a/types/init_service_type.go b/types/init_service_type.go
index 73b32b059..ae1b9a608 100644
--- a/types/init_service_type.go
+++ b/types/init_service_type.go
@@ -31,13 +31,13 @@ type InitService struct {
// ResourceMeta defines single database resource meta.
type ResourceMeta struct {
- TargetMiners []proto.AccountAddress // designated miners
- Node uint16 // reserved node count
- Space uint64 // reserved storage space in bytes
- Memory uint64 // reserved memory in bytes
- LoadAvgPerCPU uint64 // max loadAvg15 per CPU
- EncryptionKey string `hspack:"-"` // encryption key for database instance
- EventualConsistency bool `hspack:"-"` // TODO, eventual consistency test, need later refactor
+ TargetMiners []proto.AccountAddress // designated miners
+ Node uint16 // reserved node count
+ Space uint64 // reserved storage space in bytes
+ Memory uint64 // reserved memory in bytes
+ LoadAvgPerCPU uint64 // max loadAvg15 per CPU
+ EncryptionKey string `hspack:"-"` // encryption key for database instance
+ ConsistencyLevel float64 `hspack:"-"` // TODO, eventual consistency test, need later refactor
}
// ServiceInstance defines single instance to be initialized.
diff --git a/worker/db.go b/worker/db.go
index ef8df5909..3edb26ba3 100644
--- a/worker/db.go
+++ b/worker/db.go
@@ -20,6 +20,7 @@ import (
"context"
"os"
"path/filepath"
+
//"runtime/trace"
"sync"
"time"
@@ -203,7 +204,7 @@ func (db *Database) Query(request *types.Request) (response *types.Response, err
case types.ReadQuery:
return db.chain.Query(request)
case types.WriteQuery:
- if db.cfg.EventualConsistency {
+ if db.cfg.ConsistencyLevel <= 0 {
// reset context
request.SetContext(context.Background())
return db.chain.Query(request)
diff --git a/worker/db_config.go b/worker/db_config.go
index 5d631ef62..46379d26e 100644
--- a/worker/db_config.go
+++ b/worker/db_config.go
@@ -25,12 +25,12 @@ import (
// DBConfig defines the database config.
type DBConfig struct {
- DatabaseID proto.DatabaseID
- DataDir string
- KayakMux *DBKayakMuxService
- ChainMux *sqlchain.MuxService
- MaxWriteTimeGap time.Duration
- EncryptionKey string
- SpaceLimit uint64
- EventualConsistency bool
+ DatabaseID proto.DatabaseID
+ DataDir string
+ KayakMux *DBKayakMuxService
+ ChainMux *sqlchain.MuxService
+ MaxWriteTimeGap time.Duration
+ EncryptionKey string
+ SpaceLimit uint64
+ ConsistencyLevel float64
}
diff --git a/worker/dbms.go b/worker/dbms.go
index 510e44879..e26cd3ffa 100644
--- a/worker/dbms.go
+++ b/worker/dbms.go
@@ -209,14 +209,14 @@ func (dbms *DBMS) Create(instance *types.ServiceInstance, cleanup bool) (err err
// new db
dbCfg := &DBConfig{
- DatabaseID: instance.DatabaseID,
- DataDir: rootDir,
- KayakMux: dbms.kayakMux,
- ChainMux: dbms.chainMux,
- MaxWriteTimeGap: dbms.cfg.MaxReqTimeGap,
- EncryptionKey: instance.ResourceMeta.EncryptionKey,
- SpaceLimit: instance.ResourceMeta.Space,
- EventualConsistency: instance.ResourceMeta.EventualConsistency,
+ DatabaseID: instance.DatabaseID,
+ DataDir: rootDir,
+ KayakMux: dbms.kayakMux,
+ ChainMux: dbms.chainMux,
+ MaxWriteTimeGap: dbms.cfg.MaxReqTimeGap,
+ EncryptionKey: instance.ResourceMeta.EncryptionKey,
+ SpaceLimit: instance.ResourceMeta.Space,
+ ConsistencyLevel: instance.ResourceMeta.ConsistencyLevel,
}
if db, err = NewDatabase(dbCfg, instance.Peers, instance.GenesisBlock); err != nil {
From 74c52f8607ef19515c9acb8491f9e8ec203a6cfa Mon Sep 17 00:00:00 2001
From: leventeliu
Date: Fri, 21 Dec 2018 11:34:14 +0800
Subject: [PATCH 118/278] Add a FIXME and comment out channel closing to fix a
DATARACE
---
blockproducer/chain.go | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/blockproducer/chain.go b/blockproducer/chain.go
index 5c804171c..b07768e23 100644
--- a/blockproducer/chain.go
+++ b/blockproducer/chain.go
@@ -629,8 +629,16 @@ func (c *Chain) Stop() (err error) {
log.WithFields(log.Fields{"peer": c.peerInfo()}).Debug("chain service stopped")
c.st.Close()
log.WithFields(log.Fields{"peer": c.peerInfo()}).Debug("chain database closed")
- close(c.pendingBlocks)
- close(c.pendingTxs)
+
+ // FIXME(leventeliu): RPC server should provide an `unregister` method to detach chain service
+ // instance. Add it to Chain.stop(), then working channels can be closed safely.
+ // Otherwise a DATARACE (while closing a channel with a blocking write from RPC service) or
+ // `write on closed channel` panic may occur.
+ // Comment this out for now, IT IS A RESOURCE LEAK.
+ //
+ //close(c.pendingBlocks)
+ //close(c.pendingTxs)
+
return
}
From 943ebc96a8485c94f4f08cb2ae6ecad89a56ca6e Mon Sep 17 00:00:00 2001
From: Qi Xiao
Date: Fri, 21 Dec 2018 13:23:50 +0800
Subject: [PATCH 119/278] Add UseEventualConsistency flag for eventual
consistency and use ConsistencyLevel for strong consistency confirmation
setting
---
types/init_service_type.go | 15 ++++++++-------
worker/db.go | 2 +-
worker/db_config.go | 17 +++++++++--------
worker/dbms.go | 17 +++++++++--------
4 files changed, 27 insertions(+), 24 deletions(-)
diff --git a/types/init_service_type.go b/types/init_service_type.go
index ae1b9a608..6cefba184 100644
--- a/types/init_service_type.go
+++ b/types/init_service_type.go
@@ -31,13 +31,14 @@ type InitService struct {
// ResourceMeta defines single database resource meta.
type ResourceMeta struct {
- TargetMiners []proto.AccountAddress // designated miners
- Node uint16 // reserved node count
- Space uint64 // reserved storage space in bytes
- Memory uint64 // reserved memory in bytes
- LoadAvgPerCPU uint64 // max loadAvg15 per CPU
- EncryptionKey string `hspack:"-"` // encryption key for database instance
- ConsistencyLevel float64 `hspack:"-"` // TODO, eventual consistency test, need later refactor
+ TargetMiners []proto.AccountAddress // designated miners
+ Node uint16 // reserved node count
+ Space uint64 // reserved storage space in bytes
+ Memory uint64 // reserved memory in bytes
+ LoadAvgPerCPU uint64 // max loadAvg15 per CPU
+ EncryptionKey string `hspack:"-"` // encryption key for database instance
+ UseEventualConsistency bool `hspack:"-"` // use eventual consistency replication if enabled
+ ConsistencyLevel float64 `hspack:"-"` // customized strong consistency level
}
// ServiceInstance defines single instance to be initialized.
diff --git a/worker/db.go b/worker/db.go
index 3edb26ba3..50293b7de 100644
--- a/worker/db.go
+++ b/worker/db.go
@@ -204,7 +204,7 @@ func (db *Database) Query(request *types.Request) (response *types.Response, err
case types.ReadQuery:
return db.chain.Query(request)
case types.WriteQuery:
- if db.cfg.ConsistencyLevel <= 0 {
+ if db.cfg.UseEventualConsistency {
// reset context
request.SetContext(context.Background())
return db.chain.Query(request)
diff --git a/worker/db_config.go b/worker/db_config.go
index 46379d26e..828bfb1de 100644
--- a/worker/db_config.go
+++ b/worker/db_config.go
@@ -25,12 +25,13 @@ import (
// DBConfig defines the database config.
type DBConfig struct {
- DatabaseID proto.DatabaseID
- DataDir string
- KayakMux *DBKayakMuxService
- ChainMux *sqlchain.MuxService
- MaxWriteTimeGap time.Duration
- EncryptionKey string
- SpaceLimit uint64
- ConsistencyLevel float64
+ DatabaseID proto.DatabaseID
+ DataDir string
+ KayakMux *DBKayakMuxService
+ ChainMux *sqlchain.MuxService
+ MaxWriteTimeGap time.Duration
+ EncryptionKey string
+ SpaceLimit uint64
+ UseEventualConsistency bool
+ ConsistencyLevel float64
}
diff --git a/worker/dbms.go b/worker/dbms.go
index e26cd3ffa..c2df28a04 100644
--- a/worker/dbms.go
+++ b/worker/dbms.go
@@ -209,14 +209,15 @@ func (dbms *DBMS) Create(instance *types.ServiceInstance, cleanup bool) (err err
// new db
dbCfg := &DBConfig{
- DatabaseID: instance.DatabaseID,
- DataDir: rootDir,
- KayakMux: dbms.kayakMux,
- ChainMux: dbms.chainMux,
- MaxWriteTimeGap: dbms.cfg.MaxReqTimeGap,
- EncryptionKey: instance.ResourceMeta.EncryptionKey,
- SpaceLimit: instance.ResourceMeta.Space,
- ConsistencyLevel: instance.ResourceMeta.ConsistencyLevel,
+ DatabaseID: instance.DatabaseID,
+ DataDir: rootDir,
+ KayakMux: dbms.kayakMux,
+ ChainMux: dbms.chainMux,
+ MaxWriteTimeGap: dbms.cfg.MaxReqTimeGap,
+ EncryptionKey: instance.ResourceMeta.EncryptionKey,
+ SpaceLimit: instance.ResourceMeta.Space,
+ UseEventualConsistency: instance.ResourceMeta.UseEventualConsistency,
+ ConsistencyLevel: instance.ResourceMeta.ConsistencyLevel,
}
if db, err = NewDatabase(dbCfg, instance.Peers, instance.GenesisBlock); err != nil {
From 5f1593ba4963d03d8718edf4b918b08ebc957e4e Mon Sep 17 00:00:00 2001
From: draveness
Date: Fri, 21 Dec 2018 14:38:24 +0800
Subject: [PATCH 120/278] feat: update privatekey file default perm to 0600
---
crypto/kms/privatekeystore.go | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/crypto/kms/privatekeystore.go b/crypto/kms/privatekeystore.go
index ef4daf926..1220ecc6b 100644
--- a/crypto/kms/privatekeystore.go
+++ b/crypto/kms/privatekeystore.go
@@ -79,7 +79,7 @@ func SavePrivateKey(keyFilePath string, key *asymmetric.PrivateKey, masterKey []
if err != nil {
return
}
- return ioutil.WriteFile(keyFilePath, encKey, 0400)
+ return ioutil.WriteFile(keyFilePath, encKey, 0600)
}
// InitLocalKeyPair initializes local private key
From 487493133d170ca76f3782097228827183f8a09a Mon Sep 17 00:00:00 2001
From: draveness
Date: Fri, 21 Dec 2018 19:05:30 +0800
Subject: [PATCH 121/278] feat: save & load private key in base58 format
close #144
---
crypto/kms/privatekeystore.go | 28 ++++++++++++++++++++++++++--
crypto/kms/privatekeystore_test.go | 25 +++++++++++++++++++++++++
2 files changed, 51 insertions(+), 2 deletions(-)
diff --git a/crypto/kms/privatekeystore.go b/crypto/kms/privatekeystore.go
index 1220ecc6b..64197d821 100644
--- a/crypto/kms/privatekeystore.go
+++ b/crypto/kms/privatekeystore.go
@@ -27,6 +27,7 @@ import (
"github.com/CovenantSQL/CovenantSQL/crypto/hash"
"github.com/CovenantSQL/CovenantSQL/crypto/symmetric"
"github.com/CovenantSQL/CovenantSQL/utils/log"
+ "github.com/btcsuite/btcutil/base58"
)
var (
@@ -34,6 +35,12 @@ var (
ErrNotKeyFile = errors.New("private key file empty")
// ErrHashNotMatch indicates specified key hash is wrong
ErrHashNotMatch = errors.New("private key hash not match")
+ // ErrPrivateKeyVersion indicates specified key is not base58 version
+ ErrInvalidBase58Version = errors.New("invalid base58 version")
+ // ErrPrivateKeyChecksum indicates specified key is not base58 checksum
+ ErrInvalidBase58Checksum = errors.New("invalid base58 checksum")
+
+ PrivateKeyStoreVersion byte = 0x23
)
// LoadPrivateKey loads private key from keyFilePath, and verifies the hash
@@ -45,7 +52,21 @@ func LoadPrivateKey(keyFilePath string, masterKey []byte) (key *asymmetric.Priva
return
}
- decData, err := symmetric.DecryptWithPassword(fileContent, masterKey)
+ encData, version, err := base58.CheckDecode(string(fileContent))
+ switch err {
+ case base58.ErrChecksum:
+ return
+
+ case base58.ErrInvalidFormat:
+ // be compatible with the original binary private key format
+ encData = fileContent
+ }
+
+ if version != 0 && version != PrivateKeyStoreVersion {
+ return nil, ErrInvalidBase58Version
+ }
+
+ decData, err := symmetric.DecryptWithPassword(encData, masterKey)
if err != nil {
log.Error("decrypt private key error")
return
@@ -79,7 +100,10 @@ func SavePrivateKey(keyFilePath string, key *asymmetric.PrivateKey, masterKey []
if err != nil {
return
}
- return ioutil.WriteFile(keyFilePath, encKey, 0600)
+
+ base58EncKey := base58.CheckEncode(encKey, PrivateKeyStoreVersion)
+
+ return ioutil.WriteFile(keyFilePath, []byte(base58EncKey), 0600)
}
// InitLocalKeyPair initializes local private key
diff --git a/crypto/kms/privatekeystore_test.go b/crypto/kms/privatekeystore_test.go
index 0485552af..32710e0df 100644
--- a/crypto/kms/privatekeystore_test.go
+++ b/crypto/kms/privatekeystore_test.go
@@ -25,7 +25,9 @@ import (
"github.com/CovenantSQL/CovenantSQL/conf"
"github.com/CovenantSQL/CovenantSQL/crypto/asymmetric"
+ "github.com/CovenantSQL/CovenantSQL/crypto/hash"
"github.com/CovenantSQL/CovenantSQL/crypto/symmetric"
+ "github.com/btcsuite/btcutil/base58"
. "github.com/smartystreets/goconvey/convey"
)
@@ -95,6 +97,29 @@ func TestLoadPrivateKey(t *testing.T) {
So(err, ShouldEqual, ErrHashNotMatch)
So(lk, ShouldBeNil)
})
+ Convey("invalid base58 version", t, func() {
+ defer os.Remove("./.Base58VersionNotMatch")
+ var invalidPrivateKeyStoreVersion byte = 0x1
+ privateKeyBytes, _ := hex.DecodeString("f7c0bc718eb0df81e796a11e6f62e23cd2be0a4bdcca30df40d4d915cc3be3ff")
+ privateKey, _ := asymmetric.PrivKeyFromBytes(privateKeyBytes)
+ serializedKey := privateKey.Serialize()
+ keyHash := hash.DoubleHashB(serializedKey)
+ rawData := append(keyHash, serializedKey...)
+ encKey, _ := symmetric.EncryptWithPassword(rawData, []byte(password))
+ invalidBase58EncKey := base58.CheckEncode(encKey, invalidPrivateKeyStoreVersion)
+ ioutil.WriteFile("./.Base58VersionNotMatch", []byte(invalidBase58EncKey), 0600)
+ lk, err := LoadPrivateKey("./.Base58VersionNotMatch", []byte(password))
+ So(err, ShouldEqual, ErrInvalidBase58Version)
+ So(lk, ShouldBeNil)
+ })
+ Convey("invalid base58 checksum", t, func() {
+ defer os.Remove("./.Base58InvalidChecksum")
+ invalidBase58Str := "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"
+ ioutil.WriteFile("./.Base58InvalidChecksum", []byte(invalidBase58Str), 0600)
+ lk, err := LoadPrivateKey("./.Base58InvalidChecksum", []byte(password))
+ So(err, ShouldEqual, base58.ErrChecksum)
+ So(lk, ShouldBeNil)
+ })
}
func TestInitLocalKeyPair(t *testing.T) {
From b6b4a9607d77911c8e596725c60d9a81394d4bf1 Mon Sep 17 00:00:00 2001
From: draveness
Date: Sun, 23 Dec 2018 12:22:26 +0800
Subject: [PATCH 122/278] chore: update default makefile task to all
---
Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Makefile b/Makefile
index a8928efde..02cb41327 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-default: docker
+default: all
IMAGE := covenantsql/covenantsql
GIT_COMMIT ?= $(shell git rev-parse --short HEAD)
From 53d13ab3341bd359a1ac3b036831fa0478068e69 Mon Sep 17 00:00:00 2001
From: auxten
Date: Sun, 23 Dec 2018 14:37:21 +0800
Subject: [PATCH 123/278] Use docker mapping port for node_c
---
test/service/node_c/config.yaml | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/test/service/node_c/config.yaml b/test/service/node_c/config.yaml
index 3070a5784..89561d9ce 100644
--- a/test/service/node_c/config.yaml
+++ b/test/service/node_c/config.yaml
@@ -3,7 +3,7 @@ WorkingRoot: "./"
PubKeyStoreFile: "public.keystore"
PrivateKeyFile: "private.key"
DHTFileName: "dht.db"
-ListenAddr: "172.254.1.4:4661"
+ListenAddr: "127.0.0.1:4661"
ThisNodeID: "00000f3b43288fe99831eb533ab77ec455d13e11fc38ec35a42d4edd17aa320d"
ValidDNSKeys:
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
@@ -41,7 +41,7 @@ KnownNodes:
b: 0
c: 0
d: 0
- Addr: 172.254.1.2:4661
+ Addr: 127.0.0.1:11099 #172.254.1.2:4661
PublicKey: "02c76216704d797c64c58bc11519fb68582e8e63de7e5b3b2dbbbe8733efe5fd24"
Role: Leader
- ID: 00000381d46fd6cf7742d7fb94e2422033af989c0e348b5781b3219599a3af35
@@ -50,7 +50,7 @@ KnownNodes:
b: 0
c: 0
d: 2305843009893772025
- Addr: 172.254.1.3:4661
+ Addr: 127.0.0.1:11100 #172.254.1.3:4661
PublicKey: "02c76216704d797c64c58bc11519fb68582e8e63de7e5b3b2dbbbe8733efe5fd24"
Role: Follower
- ID: 000000172580063ded88e010556b0aca2851265be8845b1ef397e8fce6ab5582
@@ -59,7 +59,7 @@ KnownNodes:
b: 0
c: 0
d: 2305843012544226372
- Addr: 172.254.1.4:4661
+ Addr: 127.0.0.1:11101 #172.254.1.4:4661
PublicKey: "02c76216704d797c64c58bc11519fb68582e8e63de7e5b3b2dbbbe8733efe5fd24"
Role: Follower
- ID: 00000f3b43288fe99831eb533ab77ec455d13e11fc38ec35a42d4edd17aa320d
@@ -77,7 +77,7 @@ KnownNodes:
b: 0
c: 0
d: 3104982049
- Addr: 172.254.1.5:4661
+ Addr: 127.0.0.1:11102 #172.254.1.5:4661
PublicKey: 0367aa51809a7c1dc0f82c02452fec9557b3e1d10ce7c919d8e73d90048df86d20
Role: Miner
- ID: 000005f4f22c06f76c43c4f48d5a7ec1309cc94030cbf9ebae814172884ac8b5
@@ -86,7 +86,7 @@ KnownNodes:
b: 0
c: 0
d: 2305843010430351476
- Addr: 172.254.1.6:4661
+ Addr: 127.0.0.1:11103 #172.254.1.6:4661
PublicKey: 02914bca0806f040dd842207c44474ab41ecd29deee7f2d355789c5c78d448ca16
Role: Miner
- ID: 000003f49592f83d0473bddb70d543f1096b4ffed5e5f942a3117e256b7052b8
@@ -95,7 +95,7 @@ KnownNodes:
b: 0
c: 0
d: 13835058056920509601
- Addr: 172.254.1.7:4661
+ Addr: 127.0.0.1:11104 #172.254.1.7:4661
PublicKey: 03ae859eac5b72ee428c7a85f10b2ce748d9de5e480aefbb70f6597dfa8b2175e5
Role: Miner
Adapter:
From 60897069cea0dc88d169bd9958edc316b524bbf6 Mon Sep 17 00:00:00 2001
From: auxten
Date: Sun, 23 Dec 2018 14:46:26 +0800
Subject: [PATCH 124/278] Format code
---
cmd/cql-adapter/storage/sqlite3.go | 1 +
cmd/cql-faucet/persistence.go | 1 +
cmd/cql-minerd/main.go | 1 +
crypto/hash/hashfuncs.go | 1 +
storage/storage.go | 1 +
xenomint/xxx_test.go | 1 +
6 files changed, 6 insertions(+)
diff --git a/cmd/cql-adapter/storage/sqlite3.go b/cmd/cql-adapter/storage/sqlite3.go
index aac13f94d..d9be539d8 100644
--- a/cmd/cql-adapter/storage/sqlite3.go
+++ b/cmd/cql-adapter/storage/sqlite3.go
@@ -24,6 +24,7 @@ import (
"math/rand"
"os"
"path/filepath"
+
// Import sqlite3 manually.
_ "github.com/CovenantSQL/go-sqlite3-encrypt"
)
diff --git a/cmd/cql-faucet/persistence.go b/cmd/cql-faucet/persistence.go
index dfdc3d458..140a6c6d6 100644
--- a/cmd/cql-faucet/persistence.go
+++ b/cmd/cql-faucet/persistence.go
@@ -26,6 +26,7 @@ import (
"github.com/CovenantSQL/CovenantSQL/conf"
"github.com/CovenantSQL/CovenantSQL/utils/log"
uuid "github.com/satori/go.uuid"
+
// Load sqlite3 database driver.
_ "github.com/CovenantSQL/go-sqlite3-encrypt"
)
diff --git a/cmd/cql-minerd/main.go b/cmd/cql-minerd/main.go
index eb8016255..f1fc11c16 100644
--- a/cmd/cql-minerd/main.go
+++ b/cmd/cql-minerd/main.go
@@ -26,6 +26,7 @@ import (
"os"
"os/signal"
"runtime"
+
//"runtime/trace"
"syscall"
"time"
diff --git a/crypto/hash/hashfuncs.go b/crypto/hash/hashfuncs.go
index d3cd98561..af14cf46d 100644
--- a/crypto/hash/hashfuncs.go
+++ b/crypto/hash/hashfuncs.go
@@ -19,6 +19,7 @@ package hash
import (
"encoding/binary"
"hash/fnv"
+
// "crypto/sha256" benchmark is at least 10% faster on
// i7-4870HQ CPU @ 2.50GHz than "github.com/minio/sha256-simd"
"crypto/sha256"
diff --git a/storage/storage.go b/storage/storage.go
index 7e36bad0e..e059819af 100644
--- a/storage/storage.go
+++ b/storage/storage.go
@@ -26,6 +26,7 @@ import (
"github.com/CovenantSQL/CovenantSQL/twopc"
"github.com/CovenantSQL/CovenantSQL/utils/log"
+
// Register CovenantSQL/go-sqlite3-encrypt engine.
_ "github.com/CovenantSQL/go-sqlite3-encrypt"
)
diff --git a/xenomint/xxx_test.go b/xenomint/xxx_test.go
index 13a973878..6e19f1b08 100644
--- a/xenomint/xxx_test.go
+++ b/xenomint/xxx_test.go
@@ -22,6 +22,7 @@ import (
"os"
"path"
"sync/atomic"
+
//"runtime/trace"
"sync"
"syscall"
From fba7a94a94339c1a47f3fd4eedd55e5f05a9725a Mon Sep 17 00:00:00 2001
From: zeqing-guo
Date: Mon, 24 Dec 2018 00:54:47 +0800
Subject: [PATCH 125/278] Add permission for Query and CreateDatabase by
transaction in integration test
---
blockproducer/chain.go | 2 +-
blockproducer/db_service_test.go | 27 ++++-
blockproducer/helper_test.go | 4 +-
blockproducer/rpc.go | 3 +
client/helper_test.go | 15 +++
cmd/cql-minerd/integration_test.go | 171 ++++++++++++++++++++++++++++-
types/account.go | 8 +-
types/chainstate.go | 16 ++-
worker/dbms.go | 19 +++-
worker/dbms_test.go | 36 +++++-
10 files changed, 281 insertions(+), 20 deletions(-)
diff --git a/blockproducer/chain.go b/blockproducer/chain.go
index ffeb755ce..f7b5f7cfb 100644
--- a/blockproducer/chain.go
+++ b/blockproducer/chain.go
@@ -528,7 +528,7 @@ func (c *Chain) addTx(tx pi.Transaction) {
func (c *Chain) processTx(tx pi.Transaction) {
if err := tx.Verify(); err != nil {
- log.WithError(err).Error("failed to verify transaction")
+ log.WithError(err).Errorf("failed to verify transaction with hash: %s, address: %s, tx type: %s", tx.Hash(), tx.GetAccountAddress(), tx.GetTransactionType().String())
return
}
if err := c.storeTx(tx); err != nil {
diff --git a/blockproducer/db_service_test.go b/blockproducer/db_service_test.go
index 14d5b4d95..fb1ca6b84 100644
--- a/blockproducer/db_service_test.go
+++ b/blockproducer/db_service_test.go
@@ -20,6 +20,7 @@ import (
"testing"
"time"
+ "github.com/CovenantSQL/CovenantSQL/crypto"
"github.com/CovenantSQL/CovenantSQL/crypto/asymmetric"
"github.com/CovenantSQL/CovenantSQL/crypto/kms"
"github.com/CovenantSQL/CovenantSQL/metric"
@@ -27,19 +28,23 @@ import (
"github.com/CovenantSQL/CovenantSQL/route"
"github.com/CovenantSQL/CovenantSQL/rpc"
"github.com/CovenantSQL/CovenantSQL/types"
+ "github.com/CovenantSQL/CovenantSQL/worker"
. "github.com/smartystreets/goconvey/convey"
)
func TestService(t *testing.T) {
Convey("test db service", t, func() {
// init node
- var cleanup func()
- var dht *route.DHTService
- var metricService *metric.CollectServer
- var server *rpc.Server
- var err error
+ var (
+ cleanup func()
+ dht *route.DHTService
+ metricService *metric.CollectServer
+ server *rpc.Server
+ dbms *worker.DBMS
+ err error
+ )
- cleanup, dht, metricService, server, err = initNode(
+ cleanup, dht, metricService, server, dbms, err = initNode(
"../test/node_standalone/config.yaml",
"../test/node_standalone/private.key",
)
@@ -130,6 +135,16 @@ func TestService(t *testing.T) {
createDBRes.Header.InstanceMeta.DatabaseID,
})
+ // update private key permission in dbms for query
+ addr, err := crypto.PubKeyHash(privateKey.PubKey())
+ So(err, ShouldBeNil)
+ permStat := &types.PermStat{
+ Permission: types.Admin,
+ Status: types.Normal,
+ }
+ err = dbms.UpdatePermission(createDBRes.Header.InstanceMeta.DatabaseID, proto.AccountAddress(addr), permStat)
+ So(err, ShouldBeNil)
+
// use the database
serverID := createDBRes.Header.InstanceMeta.Peers.Leader
dbID := createDBRes.Header.InstanceMeta.DatabaseID
diff --git a/blockproducer/helper_test.go b/blockproducer/helper_test.go
index ce68aca12..69456e817 100644
--- a/blockproducer/helper_test.go
+++ b/blockproducer/helper_test.go
@@ -157,7 +157,7 @@ func (p *stubDBMetaPersistence) getInstanceMeta(dbID proto.DatabaseID) (instance
return
}
-func initNode(confRP, privateKeyRP string) (cleanupFunc func(), dht *route.DHTService, metricService *metric.CollectServer, server *rpc.Server, err error) {
+func initNode(confRP, privateKeyRP string) (cleanupFunc func(), dht *route.DHTService, metricService *metric.CollectServer, server *rpc.Server, dbms *worker.DBMS, err error) {
var d string
if d, err = ioutil.TempDir("", "db_test_"); err != nil {
return
@@ -202,7 +202,7 @@ func initNode(confRP, privateKeyRP string) (cleanupFunc func(), dht *route.DHTSe
}
// register database service
- _, err = worker.NewDBMS(&worker.DBMSConfig{
+ dbms, err = worker.NewDBMS(&worker.DBMSConfig{
RootDir: d,
Server: server,
MaxReqTimeGap: worker.DefaultMaxReqTimeGap,
diff --git a/blockproducer/rpc.go b/blockproducer/rpc.go
index 09b917a55..b6a279ddc 100644
--- a/blockproducer/rpc.go
+++ b/blockproducer/rpc.go
@@ -18,6 +18,7 @@ package blockproducer
import (
"github.com/CovenantSQL/CovenantSQL/types"
+ "github.com/CovenantSQL/CovenantSQL/utils/log"
"github.com/pkg/errors"
)
@@ -88,6 +89,8 @@ func (s *ChainRPCService) AddTx(req *types.AddTxReq, resp *types.AddTxResp) (err
if req.Tx == nil {
return ErrUnknownTransactionType
}
+ log.Infof("transaction type: %s, hash: %s, address: %s",
+ (req.Tx).GetTransactionType().String(), req.Tx.Hash(), req.Tx.GetAccountAddress())
s.chain.addTx(req.Tx)
return
}
diff --git a/client/helper_test.go b/client/helper_test.go
index 58a60541f..824f1c055 100644
--- a/client/helper_test.go
+++ b/client/helper_test.go
@@ -30,6 +30,7 @@ import (
"github.com/CovenantSQL/CovenantSQL/conf"
"github.com/CovenantSQL/CovenantSQL/consistent"
+ "github.com/CovenantSQL/CovenantSQL/crypto"
"github.com/CovenantSQL/CovenantSQL/crypto/asymmetric"
"github.com/CovenantSQL/CovenantSQL/crypto/hash"
"github.com/CovenantSQL/CovenantSQL/crypto/kms"
@@ -224,6 +225,20 @@ func startTestService() (stopTestService func(), tempDir string, err error) {
return
}
+ // update private key permission in dbms for query
+ addr, err := crypto.PubKeyHash(privateKey.PubKey())
+ if err != nil {
+ return
+ }
+ permStat := &types.PermStat{
+ Permission: types.Admin,
+ Status: types.Normal,
+ }
+ err = dbms.UpdatePermission(dbID, proto.AccountAddress(addr), permStat)
+ if err != nil {
+ return
+ }
+
return
}
diff --git a/cmd/cql-minerd/integration_test.go b/cmd/cql-minerd/integration_test.go
index e608e22e4..564112fe3 100644
--- a/cmd/cql-minerd/integration_test.go
+++ b/cmd/cql-minerd/integration_test.go
@@ -34,21 +34,29 @@ import (
"testing"
"time"
+ "github.com/CovenantSQL/CovenantSQL/blockproducer/interfaces"
"github.com/CovenantSQL/CovenantSQL/client"
"github.com/CovenantSQL/CovenantSQL/conf"
+ "github.com/CovenantSQL/CovenantSQL/crypto"
"github.com/CovenantSQL/CovenantSQL/crypto/asymmetric"
+ "github.com/CovenantSQL/CovenantSQL/crypto/kms"
"github.com/CovenantSQL/CovenantSQL/proto"
+ "github.com/CovenantSQL/CovenantSQL/route"
"github.com/CovenantSQL/CovenantSQL/rpc"
+ "github.com/CovenantSQL/CovenantSQL/types"
"github.com/CovenantSQL/CovenantSQL/utils"
"github.com/CovenantSQL/CovenantSQL/utils/log"
- sqlite3 "github.com/CovenantSQL/go-sqlite3-encrypt"
+ "github.com/CovenantSQL/go-sqlite3-encrypt"
. "github.com/smartystreets/goconvey/convey"
)
var (
- baseDir = utils.GetProjectSrcDir()
- testWorkingDir = FJ(baseDir, "./test/")
- logDir = FJ(testWorkingDir, "./log/")
+ baseDir = utils.GetProjectSrcDir()
+ testWorkingDir = FJ(baseDir, "./test/")
+ logDir = FJ(testWorkingDir, "./log/")
+ testGasPrice uint64 = 1
+ testInitTokenAmount uint64 = 1000000000
+ testAdvancePayment uint64 = 10000000
)
var nodeCmds []*utils.CMD
@@ -173,6 +181,7 @@ func startNodes() {
log.Errorf("start node failed: %v", err)
}
}
+
func startNodesProfile(bypassSign bool) {
ctx := context.Background()
bypassArg := ""
@@ -331,6 +340,117 @@ func TestFullProcess(t *testing.T) {
err = client.Init(FJ(testWorkingDir, "./integration/node_c/config.yaml"), []byte(""))
So(err, ShouldBeNil)
+ var (
+ clientPrivKey *asymmetric.PrivateKey
+ clientAddr proto.AccountAddress
+
+ minersPrivKeys = make([]*asymmetric.PrivateKey, 3)
+ minersAddrs = make([]proto.AccountAddress, 3)
+ minersNodeID = make([]proto.NodeID, 3)
+ )
+
+ // get miners' private keys
+ minersPrivKeys[0], err = kms.LoadPrivateKey(FJ(testWorkingDir, "./integration/node_miner_0/private.key"), []byte{})
+ So(err, ShouldBeNil)
+ minersPrivKeys[1], err = kms.LoadPrivateKey(FJ(testWorkingDir, "./integration/node_miner_1/private.key"), []byte{})
+ So(err, ShouldBeNil)
+ minersPrivKeys[2], err = kms.LoadPrivateKey(FJ(testWorkingDir, "./integration/node_miner_2/private.key"), []byte{})
+ So(err, ShouldBeNil)
+ clientPrivKey, err = kms.LoadPrivateKey(FJ(testWorkingDir, "./integration/node_c/private.key"), []byte{})
+ So(err, ShouldBeNil)
+
+ // get miners' addr
+ minersAddrs[0], err = crypto.PubKeyHash(minersPrivKeys[0].PubKey())
+ So(err, ShouldBeNil)
+ minersAddrs[1], err = crypto.PubKeyHash(minersPrivKeys[1].PubKey())
+ So(err, ShouldBeNil)
+ minersAddrs[2], err = crypto.PubKeyHash(minersPrivKeys[2].PubKey())
+ So(err, ShouldBeNil)
+ clientAddr, err = crypto.PubKeyHash(clientPrivKey.PubKey())
+ So(err, ShouldBeNil)
+
+ // get miners' node id
+ cfg, err := conf.LoadConfig(FJ(testWorkingDir, "./integration/node_miner_0/config.yaml"))
+ So(err, ShouldBeNil)
+ minersNodeID[0] = cfg.ThisNodeID
+ cfg, err = conf.LoadConfig(FJ(testWorkingDir, "./integration/node_miner_1/config.yaml"))
+ So(err, ShouldBeNil)
+ minersNodeID[1] = cfg.ThisNodeID
+ cfg, err = conf.LoadConfig(FJ(testWorkingDir, "./integration/node_miner_2/config.yaml"))
+ So(err, ShouldBeNil)
+ minersNodeID[2] = cfg.ThisNodeID
+
+ // send miner and user with Particle
+ for i := range minersAddrs {
+ err = getToken(minersAddrs[i], minersPrivKeys[i], testInitTokenAmount, types.Particle)
+ So(err, ShouldBeNil)
+ }
+ err = getToken(clientAddr, clientPrivKey, testInitTokenAmount, types.Particle)
+ So(err, ShouldBeNil)
+
+ time.Sleep(10 * time.Second)
+ // miners provide service
+ for i := range minersAddrs {
+ nonce, err := getNonce(minersAddrs[i])
+ So(err, ShouldBeNil)
+
+ req := &types.AddTxReq{}
+ resp := &types.AddTxResp{}
+
+ req.Tx = types.NewProvideService(
+ &types.ProvideServiceHeader{
+ GasPrice: testGasPrice,
+ TokenType: types.Particle,
+ TargetUser: clientAddr,
+ NodeID: minersNodeID[i],
+ Nonce: nonce,
+ },
+ )
+ err = req.Tx.Sign(minersPrivKeys[i])
+ So(err, ShouldBeNil)
+ err = rpc.RequestBP(route.MCCAddTx.String(), req, resp)
+ So(err, ShouldBeNil)
+ }
+
+ // client send create database transaction
+ nonce, err := getNonce(clientAddr)
+ So(err, ShouldBeNil)
+ req := &types.AddTxReq{}
+ resp := &types.AddTxResp{}
+ req.Tx = types.NewCreateDatabase(
+ &types.CreateDatabaseHeader{
+ Owner: clientAddr,
+ ResourceMeta: types.ResourceMeta{
+ TargetMiners: minersAddrs,
+ },
+ GasPrice: testGasPrice,
+ AdvancePayment: testAdvancePayment,
+ TokenType: types.Particle,
+ Nonce: nonce,
+ },
+ )
+ So(err, ShouldBeNil)
+ err = rpc.RequestBP(route.MCCAddTx.String(), req, resp)
+ So(err, ShouldBeNil)
+
+ // check sqlchain profile exist
+ dbID := proto.FromAccountAndNonce(clientAddr, uint32(nonce))
+ profileReq := &types.QuerySQLChainProfileReq{}
+ profileResp := &types.QuerySQLChainProfileResp{}
+ profileReq.DBID = *dbID
+ err = rpc.RequestBP(route.MCCQuerySQLChainProfile.String(), profileReq, profileResp)
+ So(err, ShouldBeNil)
+ profile := profileResp.Profile
+ So(profile.Owner.String(), ShouldEqual, clientAddr.String())
+ So(profile.TokenType, ShouldEqual, types.Particle)
+ minersMap := make(map[proto.AccountAddress]bool)
+ for _, miner := range profile.Miners {
+ minersMap[miner.Address] = true
+ }
+ for _, miner := range minersAddrs {
+ So(minersMap[miner], ShouldBeTrue)
+ }
+
// create
dsn, err := client.Create(client.ResourceMeta{Node: 2})
So(err, ShouldBeNil)
@@ -778,3 +898,46 @@ func BenchmarkMinerGNTE8(b *testing.B) {
benchGNTEMiner(b, 8, false)
})
}
+
+func getToken(addr proto.AccountAddress, privKey *asymmetric.PrivateKey,
+ amount uint64, tokenType types.TokenType) (err error) {
+ tokenBalance := [types.SupportTokenNumber]uint64{}
+ tokenBalance[tokenType] = amount
+
+ req := &types.AddTxReq{}
+ resp := &types.AddTxResp{}
+ req.Tx = types.NewBaseAccount(
+ &types.Account{
+ Address: addr,
+ TokenBalance: tokenBalance,
+ },
+ )
+
+ err = req.Tx.Sign(privKey)
+ if err != nil {
+ log.WithError(err).Warning("sign tx failed in getToken")
+ return
+ }
+
+ err = rpc.RequestBP(route.MCCAddTx.String(), req, resp)
+ if err != nil {
+ log.WithError(err).Warning("send request failed in getToken")
+ }
+ return
+}
+
+func getNonce(addr proto.AccountAddress) (nonce interfaces.AccountNonce, err error) {
+ // allocate nonce
+ nonceReq := &types.NextAccountNonceReq{}
+ nonceResp := &types.NextAccountNonceResp{}
+ nonceReq.Addr = addr
+
+ if err = rpc.RequestBP(route.MCCNextAccountNonce.String(), nonceReq, nonceResp); err != nil {
+ // allocate nonce failed
+ log.WithError(err).Warning("allocate nonce for transaction failed")
+ return
+ }
+
+ nonce = nonceResp.Nonce
+ return
+}
diff --git a/types/account.go b/types/account.go
index 7f07a8df6..8d14af879 100644
--- a/types/account.go
+++ b/types/account.go
@@ -39,8 +39,10 @@ const (
type UserPermission int32
const (
+ // Unknown defines the initial permission.
+ UnknownPerm UserPermission = iota
// Admin defines the admin user permission.
- Admin UserPermission = iota
+ Admin
// Write defines the writer user permission.
Write
// Read defines the reader user permission.
@@ -68,8 +70,10 @@ func (up *UserPermission) CheckAdmin() bool {
type Status int32
const (
+ // Unknown defines initial status.
+ UnknownStatus Status = iota
// Normal defines no bad thing happens.
- Normal Status = iota
+ Normal
// Reminder defines the user needs to increase advance payment.
Reminder
// Arrears defines the user is in arrears.
diff --git a/types/chainstate.go b/types/chainstate.go
index acd4b56b2..70f657f8f 100644
--- a/types/chainstate.go
+++ b/types/chainstate.go
@@ -36,7 +36,13 @@ func NewUserState() *UserState {
}
func (us *UserState) UpdatePermission(user proto.AccountAddress, perm UserPermission) {
- us.State[user].Permission = perm
+ if state, ok := us.State[user]; ok {
+ state.Permission = perm
+ } else {
+ us.State[user] = &PermStat{
+ Permission: perm,
+ }
+ }
}
func (us *UserState) AddPermission(user proto.AccountAddress, perm UserPermission) {
@@ -44,7 +50,13 @@ func (us *UserState) AddPermission(user proto.AccountAddress, perm UserPermissio
}
func (us *UserState) UpdateStatus(user proto.AccountAddress, stat Status) {
- us.State[user].Status = stat
+ if state, ok := us.State[user]; ok {
+ state.Status = stat
+ } else {
+ us.State[user] = &PermStat{
+ Status: stat,
+ }
+ }
}
func (us *UserState) AddStatus(user proto.AccountAddress, stat Status) {
diff --git a/worker/dbms.go b/worker/dbms.go
index 3c54882aa..e14b6406f 100644
--- a/worker/dbms.go
+++ b/worker/dbms.go
@@ -305,10 +305,22 @@ func (dbms *DBMS) updatePermission(tx interfaces.Transaction, count uint32) {
}
newState := state.(types.UserState)
- newState.UpdatePermission(up.TargetUser, up.Permission)
+ newState.AddPermission(up.TargetUser, up.Permission)
dbms.chainMap.Store(up.TargetSQLChain.DatabaseID(), newState)
}
+// UpdatePermission export the update permission interface for test.
+func (dbms *DBMS) UpdatePermission(dbid proto.DatabaseID, user proto.AccountAddress, permStat *types.PermStat) (err error) {
+ s, loaded := dbms.chainMap.Load(dbid)
+ if !loaded {
+ err = errors.Wrap(ErrNotExists, "update permission failed")
+ return
+ }
+ state := s.(types.UserState)
+ state.State[user] = permStat
+ return
+}
+
func (dbms *DBMS) initDatabases(meta *DBMSMeta, conf []types.ServiceInstance) (err error) {
currentInstance := make(map[proto.DatabaseID]bool)
@@ -388,6 +400,11 @@ func (dbms *DBMS) Create(instance *types.ServiceInstance, cleanup bool) (err err
// add to meta
err = dbms.addMeta(instance.DatabaseID, db)
+ // init chainMap
+ dbms.chainMap.Store(instance.DatabaseID, types.UserState{
+ State: make(map[proto.AccountAddress]*types.PermStat),
+ })
+
return
}
diff --git a/worker/dbms_test.go b/worker/dbms_test.go
index a424828cf..70e06c7fc 100644
--- a/worker/dbms_test.go
+++ b/worker/dbms_test.go
@@ -22,7 +22,9 @@ import (
"testing"
"time"
+ "github.com/CovenantSQL/CovenantSQL/crypto"
"github.com/CovenantSQL/CovenantSQL/crypto/asymmetric"
+ "github.com/CovenantSQL/CovenantSQL/crypto/hash"
"github.com/CovenantSQL/CovenantSQL/crypto/kms"
"github.com/CovenantSQL/CovenantSQL/proto"
"github.com/CovenantSQL/CovenantSQL/route"
@@ -39,9 +41,13 @@ func TestDBMS(t *testing.T) {
cleanup, server, err = initNode()
So(err, ShouldBeNil)
- var privateKey *asymmetric.PrivateKey
+ var (
+ privateKey *asymmetric.PrivateKey
+ publicKey *asymmetric.PublicKey
+ )
privateKey, err = kms.GetLocalPrivateKey()
So(err, ShouldBeNil)
+ publicKey = privateKey.PubKey()
var rootDir string
rootDir, err = ioutil.TempDir("", "dbms_test_")
@@ -67,7 +73,10 @@ func TestDBMS(t *testing.T) {
var peers *proto.Peers
var block *types.Block
- dbID := proto.DatabaseID("db")
+ dbAddr := proto.AccountAddress(hash.HashH([]byte{'d', 'b'}))
+ dbID := dbAddr.DatabaseID()
+ userAddr, err := crypto.PubKeyHash(publicKey)
+ So(err, ShouldBeNil)
// create sqlchain block
block, err = createRandomBlock(rootHash, true)
@@ -93,6 +102,29 @@ func TestDBMS(t *testing.T) {
err = testRequest(route.DBSDeploy, req, &res)
So(err, ShouldBeNil)
+ // grant permission
+ up := &types.UpdatePermission{
+ UpdatePermissionHeader: types.UpdatePermissionHeader{
+ TargetSQLChain: dbAddr,
+ TargetUser: userAddr,
+ Permission: types.Admin,
+ },
+ }
+ err = up.Sign(privateKey)
+ So(err, ShouldBeNil)
+ dbms.updatePermission(up, 0)
+ us, ok := dbms.chainMap.Load(dbID)
+ So(ok, ShouldBeTrue)
+ userState := us.(types.UserState)
+ perm, ok := userState.GetPermission(userAddr)
+ So(ok, ShouldBeTrue)
+ So(perm, ShouldEqual, types.Admin)
+ stat, ok := userState.GetStatus(userAddr)
+ So(ok, ShouldBeTrue)
+ So(stat, ShouldEqual, types.UnknownStatus)
+ userState.UpdateStatus(userAddr, types.Normal)
+ dbms.chainMap.Store(dbID, userState)
+
Convey("queries", func() {
// sending write query
var writeQuery *types.Request
From 06734b7c1088f7bb410ff4b6f49e8c47d6785e07 Mon Sep 17 00:00:00 2001
From: leventeliu
Date: Mon, 24 Dec 2018 11:07:15 +0800
Subject: [PATCH 126/278] Move tx broadcast to processing function
---
blockproducer/chain.go | 36 +++++++++++++++++++++++-------------
1 file changed, 23 insertions(+), 13 deletions(-)
diff --git a/blockproducer/chain.go b/blockproducer/chain.go
index f7b5f7cfb..dc3e18b69 100644
--- a/blockproducer/chain.go
+++ b/blockproducer/chain.go
@@ -491,6 +491,29 @@ func (c *Chain) processBlocks(ctx context.Context) {
}
func (c *Chain) addTx(tx pi.Transaction) {
+ select {
+ case c.pendingTxs <- tx:
+ case <-c.ctx.Done():
+ log.WithError(c.ctx.Err()).Warn("add transaction aborted")
+ }
+}
+
+func (c *Chain) processTx(tx pi.Transaction) {
+ if err := tx.Verify(); err != nil {
+ log.WithError(err).Errorf("failed to verify transaction with hash: %s, address: %s, tx type: %s", tx.Hash(), tx.GetAccountAddress(), tx.GetTransactionType().String())
+ return
+ }
+ if ok := func() (ok bool) {
+ c.RLock()
+ defer c.RUnlock()
+ _, ok = c.txPool[tx.Hash()]
+ return
+ }(); ok {
+ log.WithFields(log.Fields{
+ "tx_hash": tx.Hash().Short(4),
+ }).Debugf("tx already exists, abort processing")
+ return
+ }
// Simple non-blocking broadcasting
for _, v := range c.getPeers().Servers {
if !v.IsEqual(&c.nodeID) {
@@ -518,19 +541,6 @@ func (c *Chain) addTx(tx pi.Transaction) {
}(v)
}
}
-
- select {
- case c.pendingTxs <- tx:
- case <-c.ctx.Done():
- log.WithError(c.ctx.Err()).Warn("add transaction aborted")
- }
-}
-
-func (c *Chain) processTx(tx pi.Transaction) {
- if err := tx.Verify(); err != nil {
- log.WithError(err).Errorf("failed to verify transaction with hash: %s, address: %s, tx type: %s", tx.Hash(), tx.GetAccountAddress(), tx.GetTransactionType().String())
- return
- }
if err := c.storeTx(tx); err != nil {
log.WithError(err).Error("failed to add transaction")
}
From 50f1ebb4edb8f780550393fe437e2870feabad8b Mon Sep 17 00:00:00 2001
From: zeqing-guo
Date: Mon, 24 Dec 2018 11:09:58 +0800
Subject: [PATCH 127/278] Add base account config
---
blockproducer/chain.go | 4 +++
blockproducer/metastate.go | 3 ++
blockproducer/rpc.go | 2 +-
cmd/cql-minerd/integration_test.go | 37 +----------------------
test/integration/node_0/config.yaml | 13 ++++++++
test/integration/node_1/config.yaml | 13 ++++++++
test/integration/node_2/config.yaml | 13 ++++++++
test/integration/node_c/config.yaml | 13 ++++++++
test/integration/node_miner_0/config.yaml | 13 ++++++++
test/integration/node_miner_1/config.yaml | 13 ++++++++
test/integration/node_miner_2/config.yaml | 13 ++++++++
11 files changed, 100 insertions(+), 37 deletions(-)
diff --git a/blockproducer/chain.go b/blockproducer/chain.go
index f7b5f7cfb..346ee386a 100644
--- a/blockproducer/chain.go
+++ b/blockproducer/chain.go
@@ -491,6 +491,7 @@ func (c *Chain) processBlocks(ctx context.Context) {
}
func (c *Chain) addTx(tx pi.Transaction) {
+
// Simple non-blocking broadcasting
for _, v := range c.getPeers().Servers {
if !v.IsEqual(&c.nodeID) {
@@ -701,6 +702,9 @@ func (c *Chain) loadSQLChainProfile(databaseID proto.DatabaseID) (profile *types
c.RLock()
defer c.RUnlock()
profileObj, ok := c.immutable.loadSQLChainObject(databaseID)
+ if !ok {
+ return
+ }
profile = &profileObj.SQLChainProfile
return
}
diff --git a/blockproducer/metastate.go b/blockproducer/metastate.go
index e9cf4f7a1..4e5e4d467 100644
--- a/blockproducer/metastate.go
+++ b/blockproducer/metastate.go
@@ -587,6 +587,7 @@ func (s *metaState) updateProviderList(tx *types.ProvideService) (err error) {
}
func (s *metaState) matchProvidersWithUser(tx *types.CreateDatabase) (err error) {
+ log.Infof("create database: %s", tx.Hash())
sender, err := crypto.PubKeyHash(tx.Signee)
if err != nil {
err = errors.Wrap(err, "matchProviders failed")
@@ -706,6 +707,7 @@ func (s *metaState) matchProvidersWithUser(tx *types.CreateDatabase) (err error)
for _, miner := range tx.ResourceMeta.TargetMiners {
s.deleteProviderObject(miner)
}
+ log.Infof("success create sqlchain with database ID: %s", dbID)
return
}
@@ -860,6 +862,7 @@ func (s *metaState) updateBilling(tx *types.UpdateBilling) (err error) {
}
func (s *metaState) applyTransaction(tx pi.Transaction) (err error) {
+ log.Infof("get tx: %s", tx.GetTransactionType().String())
switch t := tx.(type) {
case *types.Transfer:
realSender, err := crypto.PubKeyHash(t.Signee)
diff --git a/blockproducer/rpc.go b/blockproducer/rpc.go
index b6a279ddc..2e6d09d14 100644
--- a/blockproducer/rpc.go
+++ b/blockproducer/rpc.go
@@ -90,7 +90,7 @@ func (s *ChainRPCService) AddTx(req *types.AddTxReq, resp *types.AddTxResp) (err
return ErrUnknownTransactionType
}
log.Infof("transaction type: %s, hash: %s, address: %s",
- (req.Tx).GetTransactionType().String(), req.Tx.Hash(), req.Tx.GetAccountAddress())
+ req.Tx.GetTransactionType().String(), req.Tx.Hash(), req.Tx.GetAccountAddress())
s.chain.addTx(req.Tx)
return
}
diff --git a/cmd/cql-minerd/integration_test.go b/cmd/cql-minerd/integration_test.go
index 564112fe3..428117744 100644
--- a/cmd/cql-minerd/integration_test.go
+++ b/cmd/cql-minerd/integration_test.go
@@ -380,15 +380,6 @@ func TestFullProcess(t *testing.T) {
So(err, ShouldBeNil)
minersNodeID[2] = cfg.ThisNodeID
- // send miner and user with Particle
- for i := range minersAddrs {
- err = getToken(minersAddrs[i], minersPrivKeys[i], testInitTokenAmount, types.Particle)
- So(err, ShouldBeNil)
- }
- err = getToken(clientAddr, clientPrivKey, testInitTokenAmount, types.Particle)
- So(err, ShouldBeNil)
-
- time.Sleep(10 * time.Second)
// miners provide service
for i := range minersAddrs {
nonce, err := getNonce(minersAddrs[i])
@@ -429,6 +420,7 @@ func TestFullProcess(t *testing.T) {
Nonce: nonce,
},
)
+ err = req.Tx.Sign(clientPrivKey)
So(err, ShouldBeNil)
err = rpc.RequestBP(route.MCCAddTx.String(), req, resp)
So(err, ShouldBeNil)
@@ -899,33 +891,6 @@ func BenchmarkMinerGNTE8(b *testing.B) {
})
}
-func getToken(addr proto.AccountAddress, privKey *asymmetric.PrivateKey,
- amount uint64, tokenType types.TokenType) (err error) {
- tokenBalance := [types.SupportTokenNumber]uint64{}
- tokenBalance[tokenType] = amount
-
- req := &types.AddTxReq{}
- resp := &types.AddTxResp{}
- req.Tx = types.NewBaseAccount(
- &types.Account{
- Address: addr,
- TokenBalance: tokenBalance,
- },
- )
-
- err = req.Tx.Sign(privKey)
- if err != nil {
- log.WithError(err).Warning("sign tx failed in getToken")
- return
- }
-
- err = rpc.RequestBP(route.MCCAddTx.String(), req, resp)
- if err != nil {
- log.WithError(err).Warning("send request failed in getToken")
- }
- return
-}
-
func getNonce(addr proto.AccountAddress) (nonce interfaces.AccountNonce, err error) {
// allocate nonce
nonceReq := &types.NextAccountNonceReq{}
diff --git a/test/integration/node_0/config.yaml b/test/integration/node_0/config.yaml
index 723c957be..f71a9060c 100644
--- a/test/integration/node_0/config.yaml
+++ b/test/integration/node_0/config.yaml
@@ -38,6 +38,19 @@ BlockProducer:
MerkleRoot: 0000000000000000000000000000000000000000000000000000000000000001
ParentHash: 0000000000000000000000000000000000000000000000000000000000000001
Timestamp: 2018-08-13T21:59:59.12Z
+ BaseAccounts:
+ - Address: ba0ba731c7a76ccef2c1170f42038f7e228dfb474ef0190dfe35d9a37911ed37
+ StableCoinBalance: 1000000000
+ CovenantCoinBalance: 1000000000
+ - Address: 1a7b0959bbd0d0ec529278a61c0056c277bffe75b2646e1699b46b10a90210be
+ StableCoinBalance: 1000000000
+ CovenantCoinBalance: 1000000000
+ - Address: 9235bc4130a2ed4e6c35ea189dab35198ebb105640bedb97dd5269cc80863b16
+ StableCoinBalance: 1000000000
+ CovenantCoinBalance: 1000000000
+ - Address: 9e1618775cceeb19f110e04fbc6c5bca6c8e4e9b116e193a42fe69bf602e7bcd
+ StableCoinBalance: 1000000000
+ CovenantCoinBalance: 1000000000
KnownNodes:
- ID: 00000bef611d346c0cbe1beaa76e7f0ed705a194fdf9ac3a248ec70e9c198bf9
Nonce:
diff --git a/test/integration/node_1/config.yaml b/test/integration/node_1/config.yaml
index 75d9db2c0..48d12a7e8 100644
--- a/test/integration/node_1/config.yaml
+++ b/test/integration/node_1/config.yaml
@@ -38,6 +38,19 @@ BlockProducer:
MerkleRoot: 0000000000000000000000000000000000000000000000000000000000000001
ParentHash: 0000000000000000000000000000000000000000000000000000000000000001
Timestamp: 2018-08-13T21:59:59.12Z
+ BaseAccounts:
+ - Address: ba0ba731c7a76ccef2c1170f42038f7e228dfb474ef0190dfe35d9a37911ed37
+ StableCoinBalance: 1000000000
+ CovenantCoinBalance: 1000000000
+ - Address: 1a7b0959bbd0d0ec529278a61c0056c277bffe75b2646e1699b46b10a90210be
+ StableCoinBalance: 1000000000
+ CovenantCoinBalance: 1000000000
+ - Address: 9235bc4130a2ed4e6c35ea189dab35198ebb105640bedb97dd5269cc80863b16
+ StableCoinBalance: 1000000000
+ CovenantCoinBalance: 1000000000
+ - Address: 9e1618775cceeb19f110e04fbc6c5bca6c8e4e9b116e193a42fe69bf602e7bcd
+ StableCoinBalance: 1000000000
+ CovenantCoinBalance: 1000000000
KnownNodes:
- ID: 00000bef611d346c0cbe1beaa76e7f0ed705a194fdf9ac3a248ec70e9c198bf9
Nonce:
diff --git a/test/integration/node_2/config.yaml b/test/integration/node_2/config.yaml
index f878e7c7a..291d754aa 100644
--- a/test/integration/node_2/config.yaml
+++ b/test/integration/node_2/config.yaml
@@ -38,6 +38,19 @@ BlockProducer:
MerkleRoot: 0000000000000000000000000000000000000000000000000000000000000001
ParentHash: 0000000000000000000000000000000000000000000000000000000000000001
Timestamp: 2018-08-13T21:59:59.12Z
+ BaseAccounts:
+ - Address: ba0ba731c7a76ccef2c1170f42038f7e228dfb474ef0190dfe35d9a37911ed37
+ StableCoinBalance: 1000000000
+ CovenantCoinBalance: 1000000000
+ - Address: 1a7b0959bbd0d0ec529278a61c0056c277bffe75b2646e1699b46b10a90210be
+ StableCoinBalance: 1000000000
+ CovenantCoinBalance: 1000000000
+ - Address: 9235bc4130a2ed4e6c35ea189dab35198ebb105640bedb97dd5269cc80863b16
+ StableCoinBalance: 1000000000
+ CovenantCoinBalance: 1000000000
+ - Address: 9e1618775cceeb19f110e04fbc6c5bca6c8e4e9b116e193a42fe69bf602e7bcd
+ StableCoinBalance: 1000000000
+ CovenantCoinBalance: 1000000000
KnownNodes:
- ID: 00000bef611d346c0cbe1beaa76e7f0ed705a194fdf9ac3a248ec70e9c198bf9
Nonce:
diff --git a/test/integration/node_c/config.yaml b/test/integration/node_c/config.yaml
index f06f14adb..a151c72b9 100644
--- a/test/integration/node_c/config.yaml
+++ b/test/integration/node_c/config.yaml
@@ -38,6 +38,19 @@ BlockProducer:
MerkleRoot: 0000000000000000000000000000000000000000000000000000000000000001
ParentHash: 0000000000000000000000000000000000000000000000000000000000000001
Timestamp: 2018-08-13T21:59:59.12Z
+ BaseAccounts:
+ - Address: ba0ba731c7a76ccef2c1170f42038f7e228dfb474ef0190dfe35d9a37911ed37
+ StableCoinBalance: 1000000000
+ CovenantCoinBalance: 1000000000
+ - Address: 1a7b0959bbd0d0ec529278a61c0056c277bffe75b2646e1699b46b10a90210be
+ StableCoinBalance: 1000000000
+ CovenantCoinBalance: 1000000000
+ - Address: 9235bc4130a2ed4e6c35ea189dab35198ebb105640bedb97dd5269cc80863b16
+ StableCoinBalance: 1000000000
+ CovenantCoinBalance: 1000000000
+ - Address: 9e1618775cceeb19f110e04fbc6c5bca6c8e4e9b116e193a42fe69bf602e7bcd
+ StableCoinBalance: 1000000000
+ CovenantCoinBalance: 1000000000
KnownNodes:
- ID: 00000bef611d346c0cbe1beaa76e7f0ed705a194fdf9ac3a248ec70e9c198bf9
Nonce:
diff --git a/test/integration/node_miner_0/config.yaml b/test/integration/node_miner_0/config.yaml
index 560554b43..15c5b8e9d 100644
--- a/test/integration/node_miner_0/config.yaml
+++ b/test/integration/node_miner_0/config.yaml
@@ -29,6 +29,19 @@ BlockProducer:
MerkleRoot: 0000000000000000000000000000000000000000000000000000000000000001
ParentHash: 0000000000000000000000000000000000000000000000000000000000000001
Timestamp: 2018-08-13T21:59:59.12Z
+ BaseAccounts:
+ - Address: ba0ba731c7a76ccef2c1170f42038f7e228dfb474ef0190dfe35d9a37911ed37
+ StableCoinBalance: 1000000000
+ CovenantCoinBalance: 1000000000
+ - Address: 1a7b0959bbd0d0ec529278a61c0056c277bffe75b2646e1699b46b10a90210be
+ StableCoinBalance: 1000000000
+ CovenantCoinBalance: 1000000000
+ - Address: 9235bc4130a2ed4e6c35ea189dab35198ebb105640bedb97dd5269cc80863b16
+ StableCoinBalance: 1000000000
+ CovenantCoinBalance: 1000000000
+ - Address: 9e1618775cceeb19f110e04fbc6c5bca6c8e4e9b116e193a42fe69bf602e7bcd
+ StableCoinBalance: 1000000000
+ CovenantCoinBalance: 1000000000
Miner:
IsTestMode: true
RootDir: "./data"
diff --git a/test/integration/node_miner_1/config.yaml b/test/integration/node_miner_1/config.yaml
index a9a19ca5f..2beba3311 100644
--- a/test/integration/node_miner_1/config.yaml
+++ b/test/integration/node_miner_1/config.yaml
@@ -29,6 +29,19 @@ BlockProducer:
MerkleRoot: 0000000000000000000000000000000000000000000000000000000000000001
ParentHash: 0000000000000000000000000000000000000000000000000000000000000001
Timestamp: 2018-08-13T21:59:59.12Z
+ BaseAccounts:
+ - Address: ba0ba731c7a76ccef2c1170f42038f7e228dfb474ef0190dfe35d9a37911ed37
+ StableCoinBalance: 1000000000
+ CovenantCoinBalance: 1000000000
+ - Address: 1a7b0959bbd0d0ec529278a61c0056c277bffe75b2646e1699b46b10a90210be
+ StableCoinBalance: 1000000000
+ CovenantCoinBalance: 1000000000
+ - Address: 9235bc4130a2ed4e6c35ea189dab35198ebb105640bedb97dd5269cc80863b16
+ StableCoinBalance: 1000000000
+ CovenantCoinBalance: 1000000000
+ - Address: 9e1618775cceeb19f110e04fbc6c5bca6c8e4e9b116e193a42fe69bf602e7bcd
+ StableCoinBalance: 1000000000
+ CovenantCoinBalance: 1000000000
Miner:
IsTestMode: true
RootDir: "./data"
diff --git a/test/integration/node_miner_2/config.yaml b/test/integration/node_miner_2/config.yaml
index f3a42badb..5249fba42 100644
--- a/test/integration/node_miner_2/config.yaml
+++ b/test/integration/node_miner_2/config.yaml
@@ -29,6 +29,19 @@ BlockProducer:
MerkleRoot: 0000000000000000000000000000000000000000000000000000000000000001
ParentHash: 0000000000000000000000000000000000000000000000000000000000000001
Timestamp: 2018-08-13T21:59:59.12Z
+ BaseAccounts:
+ - Address: ba0ba731c7a76ccef2c1170f42038f7e228dfb474ef0190dfe35d9a37911ed37
+ StableCoinBalance: 1000000000
+ CovenantCoinBalance: 1000000000
+ - Address: 1a7b0959bbd0d0ec529278a61c0056c277bffe75b2646e1699b46b10a90210be
+ StableCoinBalance: 1000000000
+ CovenantCoinBalance: 1000000000
+ - Address: 9235bc4130a2ed4e6c35ea189dab35198ebb105640bedb97dd5269cc80863b16
+ StableCoinBalance: 1000000000
+ CovenantCoinBalance: 1000000000
+ - Address: 9e1618775cceeb19f110e04fbc6c5bca6c8e4e9b116e193a42fe69bf602e7bcd
+ StableCoinBalance: 1000000000
+ CovenantCoinBalance: 1000000000
Miner:
IsTestMode: true
RootDir: "./data"
From 27c7fc372b16c5084f0b9445be512c948eb605d7 Mon Sep 17 00:00:00 2001
From: leventeliu
Date: Mon, 24 Dec 2018 11:07:15 +0800
Subject: [PATCH 128/278] Move tx broadcast to processing function
---
blockproducer/chain.go | 173 +++++++++++++++++++-----------------
blockproducer/chain_test.go | 10 +--
2 files changed, 95 insertions(+), 88 deletions(-)
diff --git a/blockproducer/chain.go b/blockproducer/chain.go
index b07768e23..b1eea018a 100644
--- a/blockproducer/chain.go
+++ b/blockproducer/chain.go
@@ -295,7 +295,7 @@ func (c *Chain) pushBlock(b *types.BPBlock) (err error) {
return
}
-func (c *Chain) produceBlock(now time.Time) (err error) {
+func (c *Chain) produceBlock(ctx context.Context, now time.Time) (err error) {
var (
priv *asymmetric.PrivateKey
b *types.BPBlock
@@ -309,34 +309,40 @@ func (c *Chain) produceBlock(now time.Time) (err error) {
}
log.WithField("block", b).Debug("produced new block")
+ var (
+ wg = &sync.WaitGroup{}
+ cld, ccl = context.WithTimeout(ctx, c.period)
+ )
+ defer func() {
+ wg.Wait()
+ ccl()
+ }()
for _, s := range c.getPeers().Servers {
if !s.IsEqual(&c.nodeID) {
- // Bind NodeID to subroutine
- func(id proto.NodeID) {
- c.goFuncWithTimeout(func(ctx context.Context) {
- var (
- req = &AdviseNewBlockReq{
- Envelope: proto.Envelope{
- // TODO(lambda): Add fields.
- },
- Block: b,
- }
- resp = &AdviseNewBlockResp{}
- err = c.cl.CallNodeWithContext(
- ctx, id, route.MCCAdviseNewBlock.String(), req, resp)
- )
- log.WithFields(log.Fields{
- "local": c.peerInfo(),
- "remote": id,
- "block_time": b.Timestamp(),
- "block_hash": b.BlockHash().Short(4),
- "parent_hash": b.ParentHash().Short(4),
- }).WithError(err).Debug("broadcasting new block to other peers")
- }, c.period)
+ wg.Add(1)
+ go func(id proto.NodeID) {
+ defer wg.Done()
+ var (
+ req = &AdviseNewBlockReq{
+ Envelope: proto.Envelope{
+ // TODO(lambda): Add fields.
+ },
+ Block: b,
+ }
+ resp = &AdviseNewBlockResp{}
+ err = c.cl.CallNodeWithContext(
+ cld, id, route.MCCAdviseNewBlock.String(), req, resp)
+ )
+ log.WithFields(log.Fields{
+ "local": c.peerInfo(),
+ "remote": id,
+ "block_time": b.Timestamp(),
+ "block_hash": b.BlockHash().Short(4),
+ "parent_hash": b.ParentHash().Short(4),
+ }).WithError(err).Debug("broadcasting new block to other peers")
}(s)
}
}
-
return err
}
@@ -394,7 +400,7 @@ func (c *Chain) fetchBlockByCount(count uint32) (b *types.BPBlock, height uint32
}
// advanceNextHeight does the check and runs block producing if its my turn.
-func (c *Chain) advanceNextHeight(now time.Time) {
+func (c *Chain) advanceNextHeight(ctx context.Context, now time.Time) {
log.WithFields(log.Fields{
"next_height": c.getNextHeight(),
"bp_number": c.serversNum,
@@ -407,7 +413,7 @@ func (c *Chain) advanceNextHeight(now time.Time) {
}
log.WithField("height", c.getNextHeight()).Info("producing a new block")
- if err := c.produceBlock(now); err != nil {
+ if err := c.produceBlock(ctx, now); err != nil {
log.WithField("now", now.Format(time.RFC3339Nano)).WithError(err).Errorln(
"failed to produce block")
}
@@ -471,34 +477,6 @@ func (c *Chain) processBlocks(ctx context.Context) {
}
func (c *Chain) addTx(tx pi.Transaction) {
- // Simple non-blocking broadcasting
- for _, v := range c.getPeers().Servers {
- if !v.IsEqual(&c.nodeID) {
- // Bind NodeID to subroutine
- func(id proto.NodeID) {
- c.goFuncWithTimeout(func(ctx context.Context) {
- var (
- req = &AddTxReq{
- Envelope: proto.Envelope{
- // TODO(lambda): Add fields.
- },
- Tx: tx,
- }
- resp = &AddTxResp{}
- err = c.cl.CallNodeWithContext(
- ctx, id, route.MCCAddTx.String(), req, resp)
- )
- log.WithFields(log.Fields{
- "local": c.peerInfo(),
- "remote": id,
- "tx_hash": tx.Hash().Short(4),
- "tx_type": tx.GetTransactionType(),
- }).WithError(err).Debug("broadcasting transaction to other peers")
- }, c.period)
- }(v)
- }
- }
-
select {
case c.pendingTxs <- tx:
case <-c.ctx.Done():
@@ -506,10 +484,54 @@ func (c *Chain) addTx(tx pi.Transaction) {
}
}
-func (c *Chain) processTx(tx pi.Transaction) {
+func (c *Chain) processTx(ctx context.Context, tx pi.Transaction) {
if err := tx.Verify(); err != nil {
- log.WithError(err).Error("failed to verify transaction")
+ log.WithError(err).Errorf("failed to verify transaction with hash: %s, address: %s, tx type: %s", tx.Hash(), tx.GetAccountAddress(), tx.GetTransactionType().String())
+ return
+ }
+ if ok := func() (ok bool) {
+ c.RLock()
+ defer c.RUnlock()
+ _, ok = c.txPool[tx.Hash()]
return
+ }(); ok {
+ log.WithFields(log.Fields{
+ "tx_hash": tx.Hash().Short(4),
+ }).Debugf("tx already exists, abort processing")
+ return
+ }
+ var (
+ wg = &sync.WaitGroup{}
+ cld, ccl = context.WithTimeout(ctx, c.period)
+ )
+ defer func() {
+ wg.Wait()
+ ccl()
+ }()
+ for _, s := range c.getPeers().Servers {
+ if !s.IsEqual(&c.nodeID) {
+ wg.Add(1)
+ go func(id proto.NodeID) {
+ defer wg.Done()
+ var (
+ req = &AddTxReq{
+ Envelope: proto.Envelope{
+ // TODO(lambda): Add fields.
+ },
+ Tx: tx,
+ }
+ resp = &AddTxResp{}
+ err = c.cl.CallNodeWithContext(
+ cld, id, route.MCCAddTx.String(), req, resp)
+ )
+ log.WithFields(log.Fields{
+ "local": c.peerInfo(),
+ "remote": id,
+ "tx_hash": tx.Hash().Short(4),
+ "tx_type": tx.GetTransactionType(),
+ }).WithError(err).Debug("broadcasting transaction to other peers")
+ }(s)
+ }
}
if err := c.storeTx(tx); err != nil {
log.WithError(err).Error("failed to add transaction")
@@ -520,7 +542,7 @@ func (c *Chain) processTxs(ctx context.Context) {
for {
select {
case tx := <-c.pendingTxs:
- c.processTx(tx)
+ c.processTx(ctx, tx)
case <-ctx.Done():
log.WithError(c.ctx.Err()).Info("abort transaction processing")
return
@@ -542,7 +564,7 @@ func (c *Chain) mainCycle(ctx context.Context) {
var t, d = c.nextTick()
if d <= 0 {
// Try to produce block at `nextHeight` if it's my turn, and increase height by 1
- c.advanceNextHeight(t)
+ c.advanceNextHeight(ctx, t)
} else {
log.WithFields(log.Fields{
"peer": c.peerInfo(),
@@ -562,25 +584,22 @@ func (c *Chain) mainCycle(ctx context.Context) {
}
func (c *Chain) syncCurrentHead(ctx context.Context) {
+ var h = c.getNextHeight() - 1
+ if c.head().height >= h {
+ return
+ }
+ // Initiate blocking gossip calls to fetch block of the current height,
+ // with timeout of one tick.
var (
- h = c.getNextHeight() - 1
- cld, ccl = context.WithTimeout(ctx, c.tick)
wg = &sync.WaitGroup{}
+ cld, ccl = context.WithTimeout(ctx, c.tick)
)
-
defer func() {
wg.Wait()
ccl()
}()
-
- if c.head().height >= h {
- return
- }
-
- // Initiate blocking gossip calls to fetch block of the current height,
- // with timeout of one tick.
- for _, v := range c.getPeers().Servers {
- if !v.IsEqual(&c.nodeID) {
+ for _, s := range c.getPeers().Servers {
+ if !s.IsEqual(&c.nodeID) {
wg.Add(1)
go func(id proto.NodeID) {
defer wg.Done()
@@ -616,7 +635,7 @@ func (c *Chain) syncCurrentHead(ctx context.Context) {
case <-cld.Done():
log.WithError(cld.Err()).Warn("add pending block aborted")
}
- }(v)
+ }(s)
}
}
}
@@ -984,15 +1003,3 @@ func (c *Chain) goFunc(f func(ctx context.Context)) {
f(c.ctx)
}()
}
-
-func (c *Chain) goFuncWithTimeout(f func(ctx context.Context), timeout time.Duration) {
- c.wg.Add(1)
- go func() {
- var ctx, ccl = context.WithTimeout(c.ctx, timeout)
- defer func() {
- ccl()
- c.wg.Done()
- }()
- f(ctx)
- }()
-}
diff --git a/blockproducer/chain_test.go b/blockproducer/chain_test.go
index e8f89f275..ae6af5ba6 100644
--- a/blockproducer/chain_test.go
+++ b/blockproducer/chain_test.go
@@ -189,7 +189,7 @@ func TestChain(t *testing.T) {
err = chain.storeTx(t1)
So(err, ShouldEqual, ErrExistedTx)
})
- err = chain.produceBlock(begin.Add(chain.period))
+ err = chain.produceBlock(chain.ctx, begin.Add(chain.period))
So(err, ShouldBeNil)
// Create a sibling block from fork#0 and apply
@@ -204,14 +204,14 @@ func TestChain(t *testing.T) {
err = chain.storeTx(t2)
So(err, ShouldBeNil)
- err = chain.produceBlock(begin.Add(2 * chain.period))
+ err = chain.produceBlock(chain.ctx, begin.Add(2*chain.period))
So(err, ShouldBeNil)
err = chain.storeTx(t3)
So(err, ShouldBeNil)
err = chain.storeTx(t4)
So(err, ShouldBeNil)
- err = chain.produceBlock(begin.Add(3 * chain.period))
+ err = chain.produceBlock(chain.ctx, begin.Add(3*chain.period))
So(err, ShouldBeNil)
// Create a sibling block from fork#1 and apply
f1, bl, err = f1.produceBlock(3, begin.Add(3*chain.period), addr2, priv2)
@@ -222,7 +222,7 @@ func TestChain(t *testing.T) {
// This should trigger a branch pruning on fork #0
for i := uint32(4); i <= 6; i++ {
- err = chain.produceBlock(begin.Add(time.Duration(i) * chain.period))
+ err = chain.produceBlock(chain.ctx, begin.Add(time.Duration(i)*chain.period))
So(err, ShouldBeNil)
// Create a sibling block from fork#1 and apply
f1, bl, err = f1.produceBlock(
@@ -236,7 +236,7 @@ func TestChain(t *testing.T) {
Convey("The chain immutable should be updated to irreversible block", func() {
// Add more blocks to trigger immutable updating
for i := uint32(7); i <= 12; i++ {
- err = chain.produceBlock(begin.Add(time.Duration(i) * chain.period))
+ err = chain.produceBlock(chain.ctx, begin.Add(time.Duration(i)*chain.period))
So(err, ShouldBeNil)
}
Convey("The chain should have same state after reloading", func() {
From 707b05f3b15f37fe3ac00cbf63a9161b60064fc5 Mon Sep 17 00:00:00 2001
From: leventeliu
Date: Mon, 24 Dec 2018 11:41:05 +0800
Subject: [PATCH 129/278] Check nil signee or signature field in verifier
---
crypto/verifier/common.go | 2 +-
crypto/verifier/common_test.go | 14 ++++++++++++++
2 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/crypto/verifier/common.go b/crypto/verifier/common.go
index 41fa8ecb4..7885eb67a 100644
--- a/crypto/verifier/common.go
+++ b/crypto/verifier/common.go
@@ -75,7 +75,7 @@ func (i *DefaultHashSignVerifierImpl) Verify(mh MarshalHasher) (err error) {
err = errors.WithStack(ErrHashValueNotMatch)
return
}
- if !i.Signature.Verify(h[:], i.Signee) {
+ if i.Signature == nil || i.Signee == nil || !i.Signature.Verify(h[:], i.Signee) {
err = errors.WithStack(ErrSignatureNotMatch)
return
}
diff --git a/crypto/verifier/common_test.go b/crypto/verifier/common_test.go
index 953ce61f8..c9ab5fd84 100644
--- a/crypto/verifier/common_test.go
+++ b/crypto/verifier/common_test.go
@@ -79,6 +79,20 @@ func TestDefaultHashSignVerifierImpl(t *testing.T) {
So(err, ShouldEqual, ErrHashValueNotMatch)
})
})
+ Convey("When the signee is not set", func() {
+ obj.HSV.Signee = nil
+ Convey("The verifier should return signature not match error", func() {
+ err = errors.Cause(obj.Verify())
+ So(err, ShouldEqual, ErrSignatureNotMatch)
+ })
+ })
+ Convey("When the signature is not set", func() {
+ obj.HSV.Signature = nil
+ Convey("The verifier should return signature not match error", func() {
+ err = errors.Cause(obj.Verify())
+ So(err, ShouldEqual, ErrSignatureNotMatch)
+ })
+ })
Convey("When the signee is modified", func() {
var _, pub, err = asymmetric.GenSecp256k1KeyPair()
So(err, ShouldBeNil)
From 4981b5f0612d8e08ce0371f67ca961d5f4e37964 Mon Sep 17 00:00:00 2001
From: leventeliu
Date: Mon, 24 Dec 2018 13:24:06 +0800
Subject: [PATCH 130/278] Revert blocking broadcast changes
---
blockproducer/chain.go | 122 +++++++++++++++++-------------------
blockproducer/chain_test.go | 10 +--
2 files changed, 64 insertions(+), 68 deletions(-)
diff --git a/blockproducer/chain.go b/blockproducer/chain.go
index b1eea018a..1a8117f0a 100644
--- a/blockproducer/chain.go
+++ b/blockproducer/chain.go
@@ -295,7 +295,7 @@ func (c *Chain) pushBlock(b *types.BPBlock) (err error) {
return
}
-func (c *Chain) produceBlock(ctx context.Context, now time.Time) (err error) {
+func (c *Chain) produceBlock(now time.Time) (err error) {
var (
priv *asymmetric.PrivateKey
b *types.BPBlock
@@ -309,37 +309,29 @@ func (c *Chain) produceBlock(ctx context.Context, now time.Time) (err error) {
}
log.WithField("block", b).Debug("produced new block")
- var (
- wg = &sync.WaitGroup{}
- cld, ccl = context.WithTimeout(ctx, c.period)
- )
- defer func() {
- wg.Wait()
- ccl()
- }()
for _, s := range c.getPeers().Servers {
if !s.IsEqual(&c.nodeID) {
- wg.Add(1)
- go func(id proto.NodeID) {
- defer wg.Done()
- var (
- req = &AdviseNewBlockReq{
- Envelope: proto.Envelope{
- // TODO(lambda): Add fields.
- },
- Block: b,
- }
- resp = &AdviseNewBlockResp{}
- err = c.cl.CallNodeWithContext(
- cld, id, route.MCCAdviseNewBlock.String(), req, resp)
- )
- log.WithFields(log.Fields{
- "local": c.peerInfo(),
- "remote": id,
- "block_time": b.Timestamp(),
- "block_hash": b.BlockHash().Short(4),
- "parent_hash": b.ParentHash().Short(4),
- }).WithError(err).Debug("broadcasting new block to other peers")
+ func(id proto.NodeID) {
+ c.goFuncWithTimeout(func(ctx context.Context) {
+ var (
+ req = &AdviseNewBlockReq{
+ Envelope: proto.Envelope{
+ // TODO(lambda): Add fields.
+ },
+ Block: b,
+ }
+ resp = &AdviseNewBlockResp{}
+ err = c.cl.CallNodeWithContext(
+ ctx, id, route.MCCAdviseNewBlock.String(), req, resp)
+ )
+ log.WithFields(log.Fields{
+ "local": c.peerInfo(),
+ "remote": id,
+ "block_time": b.Timestamp(),
+ "block_hash": b.BlockHash().Short(4),
+ "parent_hash": b.ParentHash().Short(4),
+ }).WithError(err).Debug("broadcasting new block to other peers")
+ }, c.period)
}(s)
}
}
@@ -400,7 +392,7 @@ func (c *Chain) fetchBlockByCount(count uint32) (b *types.BPBlock, height uint32
}
// advanceNextHeight does the check and runs block producing if its my turn.
-func (c *Chain) advanceNextHeight(ctx context.Context, now time.Time) {
+func (c *Chain) advanceNextHeight(now time.Time) {
log.WithFields(log.Fields{
"next_height": c.getNextHeight(),
"bp_number": c.serversNum,
@@ -413,7 +405,7 @@ func (c *Chain) advanceNextHeight(ctx context.Context, now time.Time) {
}
log.WithField("height", c.getNextHeight()).Info("producing a new block")
- if err := c.produceBlock(ctx, now); err != nil {
+ if err := c.produceBlock(now); err != nil {
log.WithField("now", now.Format(time.RFC3339Nano)).WithError(err).Errorln(
"failed to produce block")
}
@@ -484,7 +476,7 @@ func (c *Chain) addTx(tx pi.Transaction) {
}
}
-func (c *Chain) processTx(ctx context.Context, tx pi.Transaction) {
+func (c *Chain) processTx(tx pi.Transaction) {
if err := tx.Verify(); err != nil {
log.WithError(err).Errorf("failed to verify transaction with hash: %s, address: %s, tx type: %s", tx.Hash(), tx.GetAccountAddress(), tx.GetTransactionType().String())
return
@@ -500,36 +492,28 @@ func (c *Chain) processTx(ctx context.Context, tx pi.Transaction) {
}).Debugf("tx already exists, abort processing")
return
}
- var (
- wg = &sync.WaitGroup{}
- cld, ccl = context.WithTimeout(ctx, c.period)
- )
- defer func() {
- wg.Wait()
- ccl()
- }()
for _, s := range c.getPeers().Servers {
if !s.IsEqual(&c.nodeID) {
- wg.Add(1)
- go func(id proto.NodeID) {
- defer wg.Done()
- var (
- req = &AddTxReq{
- Envelope: proto.Envelope{
- // TODO(lambda): Add fields.
- },
- Tx: tx,
- }
- resp = &AddTxResp{}
- err = c.cl.CallNodeWithContext(
- cld, id, route.MCCAddTx.String(), req, resp)
- )
- log.WithFields(log.Fields{
- "local": c.peerInfo(),
- "remote": id,
- "tx_hash": tx.Hash().Short(4),
- "tx_type": tx.GetTransactionType(),
- }).WithError(err).Debug("broadcasting transaction to other peers")
+ func(id proto.NodeID) {
+ c.goFuncWithTimeout(func(ctx context.Context) {
+ var (
+ req = &AddTxReq{
+ Envelope: proto.Envelope{
+ // TODO(lambda): Add fields.
+ },
+ Tx: tx,
+ }
+ resp = &AddTxResp{}
+ err = c.cl.CallNodeWithContext(
+ ctx, id, route.MCCAddTx.String(), req, resp)
+ )
+ log.WithFields(log.Fields{
+ "local": c.peerInfo(),
+ "remote": id,
+ "tx_hash": tx.Hash().Short(4),
+ "tx_type": tx.GetTransactionType(),
+ }).WithError(err).Debug("broadcasting transaction to other peers")
+ }, c.tick)
}(s)
}
}
@@ -542,7 +526,7 @@ func (c *Chain) processTxs(ctx context.Context) {
for {
select {
case tx := <-c.pendingTxs:
- c.processTx(ctx, tx)
+ c.processTx(tx)
case <-ctx.Done():
log.WithError(c.ctx.Err()).Info("abort transaction processing")
return
@@ -564,7 +548,7 @@ func (c *Chain) mainCycle(ctx context.Context) {
var t, d = c.nextTick()
if d <= 0 {
// Try to produce block at `nextHeight` if it's my turn, and increase height by 1
- c.advanceNextHeight(ctx, t)
+ c.advanceNextHeight(t)
} else {
log.WithFields(log.Fields{
"peer": c.peerInfo(),
@@ -1003,3 +987,15 @@ func (c *Chain) goFunc(f func(ctx context.Context)) {
f(c.ctx)
}()
}
+
+func (c *Chain) goFuncWithTimeout(f func(ctx context.Context), timeout time.Duration) {
+ c.wg.Add(1)
+ go func() {
+ var ctx, ccl = context.WithTimeout(c.ctx, timeout)
+ defer func() {
+ ccl()
+ c.wg.Done()
+ }()
+ f(ctx)
+ }()
+}
diff --git a/blockproducer/chain_test.go b/blockproducer/chain_test.go
index ae6af5ba6..e8f89f275 100644
--- a/blockproducer/chain_test.go
+++ b/blockproducer/chain_test.go
@@ -189,7 +189,7 @@ func TestChain(t *testing.T) {
err = chain.storeTx(t1)
So(err, ShouldEqual, ErrExistedTx)
})
- err = chain.produceBlock(chain.ctx, begin.Add(chain.period))
+ err = chain.produceBlock(begin.Add(chain.period))
So(err, ShouldBeNil)
// Create a sibling block from fork#0 and apply
@@ -204,14 +204,14 @@ func TestChain(t *testing.T) {
err = chain.storeTx(t2)
So(err, ShouldBeNil)
- err = chain.produceBlock(chain.ctx, begin.Add(2*chain.period))
+ err = chain.produceBlock(begin.Add(2 * chain.period))
So(err, ShouldBeNil)
err = chain.storeTx(t3)
So(err, ShouldBeNil)
err = chain.storeTx(t4)
So(err, ShouldBeNil)
- err = chain.produceBlock(chain.ctx, begin.Add(3*chain.period))
+ err = chain.produceBlock(begin.Add(3 * chain.period))
So(err, ShouldBeNil)
// Create a sibling block from fork#1 and apply
f1, bl, err = f1.produceBlock(3, begin.Add(3*chain.period), addr2, priv2)
@@ -222,7 +222,7 @@ func TestChain(t *testing.T) {
// This should trigger a branch pruning on fork #0
for i := uint32(4); i <= 6; i++ {
- err = chain.produceBlock(chain.ctx, begin.Add(time.Duration(i)*chain.period))
+ err = chain.produceBlock(begin.Add(time.Duration(i) * chain.period))
So(err, ShouldBeNil)
// Create a sibling block from fork#1 and apply
f1, bl, err = f1.produceBlock(
@@ -236,7 +236,7 @@ func TestChain(t *testing.T) {
Convey("The chain immutable should be updated to irreversible block", func() {
// Add more blocks to trigger immutable updating
for i := uint32(7); i <= 12; i++ {
- err = chain.produceBlock(chain.ctx, begin.Add(time.Duration(i)*chain.period))
+ err = chain.produceBlock(begin.Add(time.Duration(i) * chain.period))
So(err, ShouldBeNil)
}
Convey("The chain should have same state after reloading", func() {
From 27951d2873107246a81723986fb76000d1bcc72b Mon Sep 17 00:00:00 2001
From: leventeliu
Date: Mon, 24 Dec 2018 13:25:45 +0800
Subject: [PATCH 131/278] Minor fix
---
blockproducer/chain.go | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/blockproducer/chain.go b/blockproducer/chain.go
index 1a8117f0a..86d3bcd32 100644
--- a/blockproducer/chain.go
+++ b/blockproducer/chain.go
@@ -489,7 +489,7 @@ func (c *Chain) processTx(tx pi.Transaction) {
}(); ok {
log.WithFields(log.Fields{
"tx_hash": tx.Hash().Short(4),
- }).Debugf("tx already exists, abort processing")
+ }).Debug("tx already exists, abort processing")
return
}
for _, s := range c.getPeers().Servers {
@@ -766,7 +766,7 @@ func (c *Chain) replaceAndSwitchToBranch(
}
return fmt.Sprintf("[%04d]", i)
}(),
- }).Debugf("pruning branch")
+ }).Debug("pruning branch")
}
}
// Replace current branches
From 1cebeea24817c28e38f9f49b8db54f39bdfa0966 Mon Sep 17 00:00:00 2001
From: leventeliu
Date: Mon, 24 Dec 2018 13:28:13 +0800
Subject: [PATCH 132/278] Minor fix: done - cancel order
---
blockproducer/chain.go | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/blockproducer/chain.go b/blockproducer/chain.go
index 86d3bcd32..ac737d573 100644
--- a/blockproducer/chain.go
+++ b/blockproducer/chain.go
@@ -993,8 +993,8 @@ func (c *Chain) goFuncWithTimeout(f func(ctx context.Context), timeout time.Dura
go func() {
var ctx, ccl = context.WithTimeout(c.ctx, timeout)
defer func() {
- ccl()
c.wg.Done()
+ ccl()
}()
f(ctx)
}()
From 876504b426bc965b1d664ffb5bf04cd7a1484218 Mon Sep 17 00:00:00 2001
From: leventeliu
Date: Mon, 24 Dec 2018 14:13:19 +0800
Subject: [PATCH 133/278] Move some functions to chain_service
---
blockproducer/chain.go | 182 ++++++++-------------------------
blockproducer/chain_service.go | 126 +++++++++++++++++++++++
blockproducer/chain_test.go | 13 +++
blockproducer/rpc.go | 10 +-
route/acl.go | 7 +-
sqlchain/chainbusservice.go | 2 +-
6 files changed, 193 insertions(+), 147 deletions(-)
create mode 100644 blockproducer/chain_service.go
diff --git a/blockproducer/chain.go b/blockproducer/chain.go
index dc3e18b69..7bd528b57 100644
--- a/blockproducer/chain.go
+++ b/blockproducer/chain.go
@@ -36,7 +36,6 @@ import (
"github.com/CovenantSQL/CovenantSQL/route"
"github.com/CovenantSQL/CovenantSQL/rpc"
"github.com/CovenantSQL/CovenantSQL/types"
- "github.com/CovenantSQL/CovenantSQL/utils"
"github.com/CovenantSQL/CovenantSQL/utils/log"
xi "github.com/CovenantSQL/CovenantSQL/xenomint/interfaces"
"github.com/pkg/errors"
@@ -263,6 +262,44 @@ func NewChainWithContext(ctx context.Context, cfg *Config) (c *Chain, err error)
return
}
+// Start starts the chain by step:
+// 1. sync the chain
+// 2. goroutine for getting blocks
+// 3. goroutine for getting txes.
+func (c *Chain) Start() {
+ // Start blocks/txs processing goroutines
+ c.goFunc(c.processBlocks)
+ c.goFunc(c.processTxs)
+ // Synchronize heads to current block period
+ c.syncHeads()
+ // TODO(leventeliu): subscribe ChainBus.
+ // ...
+ // Start main cycle and service
+ c.goFunc(c.mainCycle)
+ c.startService(c)
+}
+
+// Stop stops the main process of the sql-chain.
+func (c *Chain) Stop() (err error) {
+ // Stop main process
+ log.WithFields(log.Fields{"peer": c.peerInfo()}).Debug("stopping chain")
+ c.stop()
+ log.WithFields(log.Fields{"peer": c.peerInfo()}).Debug("chain service stopped")
+ c.st.Close()
+ log.WithFields(log.Fields{"peer": c.peerInfo()}).Debug("chain database closed")
+
+ // FIXME(leventeliu): RPC server should provide an `unregister` method to detach chain service
+ // instance. Add it to Chain.stop(), then working channels can be closed safely.
+ // Otherwise a DATARACE (while closing a channel with a blocking write from RPC service) or
+ // `write on closed channel` panic may occur.
+ // Comment this out for now, IT IS A RESOURCE LEAK.
+ //
+ //close(c.pendingBlocks)
+ //close(c.pendingTxs)
+
+ return
+}
+
// checkBlock has following steps: 1. check parent block 2. checkTx 2. merkle tree 3. Hash 4. Signature.
func (c *Chain) checkBlock(b *types.BPBlock) (err error) {
rootHash := merkle.NewMerkle(b.GetTxHashes()).GetRoot()
@@ -340,79 +377,6 @@ func (c *Chain) produceBlock(now time.Time) (err error) {
return err
}
-func (c *Chain) fetchBlock(h hash.Hash) (b *types.BPBlock, err error) {
- var (
- enc []byte
- out = &types.BPBlock{}
- )
- if err = c.st.Reader().QueryRow(
- `SELECT "encoded" FROM "blocks" WHERE "hash"=?`, h.String(),
- ).Scan(&enc); err != nil {
- return
- }
- if err = utils.DecodeMsgPack(enc, out); err != nil {
- return
- }
- b = out
- return
-}
-
-func (c *Chain) fetchBlockByHeight(h uint32) (b *types.BPBlock, count uint32, err error) {
- var node = c.head().ancestor(h)
- if node == nil {
- err = ErrNoSuchBlock
- return
- } else if node.block != nil {
- b = node.block
- count = node.count
- return
- }
- // Not cached, read from database
- if b, err = c.fetchBlock(node.hash); err != nil {
- return
- }
- count = node.count
- return
-}
-
-func (c *Chain) fetchBlockByCount(count uint32) (b *types.BPBlock, height uint32, err error) {
- var node = c.head().ancestorByCount(count)
- if node == nil {
- err = ErrNoSuchBlock
- return
- } else if node.block != nil {
- b = node.block
- height = node.height
- return
- }
- // Not cached, read from database
- if b, err = c.fetchBlock(node.hash); err != nil {
- return
- }
- height = node.height
- return
-}
-
-func (c *Chain) fetchLastBlock() (b *types.BPBlock, count uint32, height uint32, err error) {
- var node = c.head()
- if node == nil {
- err = ErrNoSuchBlock
- return
- } else if node.block != nil {
- b = node.block
- height = node.height
- count = node.count
- return
- }
- // Not cached, read from database
- if b, err = c.fetchBlock(node.hash); err != nil {
- return
- }
- height = node.height
- count = node.count
- return
-}
-
// advanceNextHeight does the check and runs block producing if its my turn.
func (c *Chain) advanceNextHeight(now time.Time) {
log.WithFields(log.Fields{
@@ -454,23 +418,6 @@ func (c *Chain) syncHeads() {
}
}
-// Start starts the chain by step:
-// 1. sync the chain
-// 2. goroutine for getting blocks
-// 3. goroutine for getting txes.
-func (c *Chain) Start() {
- // Start blocks/txs processing goroutines
- c.goFunc(c.processBlocks)
- c.goFunc(c.processTxs)
- // Synchronize heads to current block period
- c.syncHeads()
- // TODO(leventeliu): subscribe ChainBus.
- // ...
- // Start main cycle and service
- c.goFunc(c.mainCycle)
- c.startService(c)
-}
-
func (c *Chain) processBlocks(ctx context.Context) {
for {
select {
@@ -651,27 +598,6 @@ func (c *Chain) syncCurrentHead(ctx context.Context) {
}
}
-// Stop stops the main process of the sql-chain.
-func (c *Chain) Stop() (err error) {
- // Stop main process
- log.WithFields(log.Fields{"peer": c.peerInfo()}).Debug("stopping chain")
- c.stop()
- log.WithFields(log.Fields{"peer": c.peerInfo()}).Debug("chain service stopped")
- c.st.Close()
- log.WithFields(log.Fields{"peer": c.peerInfo()}).Debug("chain database closed")
-
- // FIXME(leventeliu): RPC server should provide an `unregister` method to detach chain service
- // instance. Add it to Chain.stop(), then working channels can be closed safely.
- // Otherwise a DATARACE (while closing a channel with a blocking write from RPC service) or
- // `write on closed channel` panic may occur.
- // Comment this out for now, IT IS A RESOURCE LEAK.
- //
- //close(c.pendingBlocks)
- //close(c.pendingTxs)
-
- return
-}
-
func (c *Chain) storeTx(tx pi.Transaction) (err error) {
var k = tx.Hash()
c.Lock()
@@ -689,32 +615,6 @@ func (c *Chain) storeTx(tx pi.Transaction) (err error) {
})
}
-func (c *Chain) nextNonce(addr proto.AccountAddress) (n pi.AccountNonce, err error) {
- c.RLock()
- defer c.RUnlock()
- return c.headBranch.preview.nextNonce(addr)
-}
-
-func (c *Chain) loadAccountCovenantBalance(addr proto.AccountAddress) (balance uint64, ok bool) {
- c.RLock()
- defer c.RUnlock()
- return c.immutable.loadAccountCovenantBalance(addr)
-}
-
-func (c *Chain) loadAccountStableBalance(addr proto.AccountAddress) (balance uint64, ok bool) {
- c.RLock()
- defer c.RUnlock()
- return c.immutable.loadAccountStableBalance(addr)
-}
-
-func (c *Chain) loadSQLChainProfile(databaseID proto.DatabaseID) (profile *types.SQLChainProfile, ok bool) {
- c.RLock()
- defer c.RUnlock()
- profileObj, ok := c.immutable.loadSQLChainObject(databaseID)
- profile = &profileObj.SQLChainProfile
- return
-}
-
func (c *Chain) replaceAndSwitchToBranch(
newBlock *types.BPBlock, originBrIdx int, newBranch *branch) (err error,
) {
@@ -1004,6 +904,12 @@ func (c *Chain) getPeers() *proto.Peers {
return &peers
}
+func (c *Chain) lastIrreversibleBlock() *blockNode {
+ c.RLock()
+ defer c.RUnlock()
+ return c.lastIrre
+}
+
func (c *Chain) head() *blockNode {
c.RLock()
defer c.RUnlock()
diff --git a/blockproducer/chain_service.go b/blockproducer/chain_service.go
new file mode 100644
index 000000000..3c707038c
--- /dev/null
+++ b/blockproducer/chain_service.go
@@ -0,0 +1,126 @@
+/*
+ * Copyright 2018 The CovenantSQL Authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package blockproducer
+
+import (
+ pi "github.com/CovenantSQL/CovenantSQL/blockproducer/interfaces"
+ "github.com/CovenantSQL/CovenantSQL/crypto/hash"
+ "github.com/CovenantSQL/CovenantSQL/proto"
+ "github.com/CovenantSQL/CovenantSQL/types"
+ "github.com/CovenantSQL/CovenantSQL/utils"
+)
+
+// This file provides methods set for chain state read/write.
+
+// loadBlock loads a BPBlock from chain storage.
+func (c *Chain) loadBlock(h hash.Hash) (b *types.BPBlock, err error) {
+ var (
+ enc []byte
+ out = &types.BPBlock{}
+ )
+ if err = c.st.Reader().QueryRow(
+ `SELECT "encoded" FROM "blocks" WHERE "hash"=?`, h.String(),
+ ).Scan(&enc); err != nil {
+ return
+ }
+ if err = utils.DecodeMsgPack(enc, out); err != nil {
+ return
+ }
+ b = out
+ return
+}
+
+func (c *Chain) fetchLastIrreversibleBlock() (
+ b *types.BPBlock, count uint32, height uint32, err error,
+) {
+ var node = c.lastIrreversibleBlock()
+ if node.block != nil {
+ b = node.block
+ height = node.height
+ count = node.count
+ return
+ }
+ // Not cached, read from database
+ if b, err = c.loadBlock(node.hash); err != nil {
+ return
+ }
+ height = node.height
+ count = node.count
+ return
+}
+
+func (c *Chain) fetchBlockByHeight(h uint32) (b *types.BPBlock, count uint32, err error) {
+ var node = c.head().ancestor(h)
+ if node == nil {
+ err = ErrNoSuchBlock
+ return
+ } else if node.block != nil {
+ b = node.block
+ count = node.count
+ return
+ }
+ // Not cached, read from database
+ if b, err = c.loadBlock(node.hash); err != nil {
+ return
+ }
+ count = node.count
+ return
+}
+
+func (c *Chain) fetchBlockByCount(count uint32) (b *types.BPBlock, height uint32, err error) {
+ var node = c.head().ancestorByCount(count)
+ if node == nil {
+ err = ErrNoSuchBlock
+ return
+ } else if node.block != nil {
+ b = node.block
+ height = node.height
+ return
+ }
+ // Not cached, read from database
+ if b, err = c.loadBlock(node.hash); err != nil {
+ return
+ }
+ height = node.height
+ return
+}
+
+func (c *Chain) nextNonce(addr proto.AccountAddress) (n pi.AccountNonce, err error) {
+ c.RLock()
+ defer c.RUnlock()
+ return c.headBranch.preview.nextNonce(addr)
+}
+
+func (c *Chain) loadAccountCovenantBalance(addr proto.AccountAddress) (balance uint64, ok bool) {
+ c.RLock()
+ defer c.RUnlock()
+ return c.immutable.loadAccountCovenantBalance(addr)
+}
+
+func (c *Chain) loadAccountStableBalance(addr proto.AccountAddress) (balance uint64, ok bool) {
+ c.RLock()
+ defer c.RUnlock()
+ return c.immutable.loadAccountStableBalance(addr)
+}
+
+func (c *Chain) loadSQLChainProfile(databaseID proto.DatabaseID) (profile *types.SQLChainProfile, ok bool) {
+ c.RLock()
+ defer c.RUnlock()
+ profileObj, ok := c.immutable.loadSQLChainObject(databaseID)
+ profile = &profileObj.SQLChainProfile
+ return
+}
diff --git a/blockproducer/chain_test.go b/blockproducer/chain_test.go
index 28a68c5b3..daba7eaf6 100644
--- a/blockproducer/chain_test.go
+++ b/blockproducer/chain_test.go
@@ -296,6 +296,12 @@ func TestChain(t *testing.T) {
So(height, ShouldEqual, 0)
So(bl.BlockHash(), ShouldResemble, genesis.BlockHash())
+ bl, count, height, err = chain.fetchLastIrreversibleBlock()
+ So(err, ShouldBeNil)
+ So(count, ShouldEqual, chain.lastIrre.count)
+ So(height, ShouldEqual, chain.lastIrre.height)
+ So(bl.BlockHash(), ShouldResemble, chain.lastIrre.block)
+
// Try to use the no-cache version
var node = chain.headBranch.head.ancestorByCount(5)
node.block = nil // Clear cached block
@@ -307,6 +313,13 @@ func TestChain(t *testing.T) {
So(err, ShouldBeNil)
So(height, ShouldEqual, node.height)
So(bl.BlockHash(), ShouldResemble, &node.hash)
+
+ var irreBlock = chain.lastIrre.block
+ chain.lastIrre.block = nil // Clear cached block
+ bl, height, err = chain.fetchBlockByCount(0)
+ So(err, ShouldBeNil)
+ So(height, ShouldEqual, 0)
+ So(bl.BlockHash(), ShouldResemble, irreBlock)
})
Convey("Test run chain", func() {
diff --git a/blockproducer/rpc.go b/blockproducer/rpc.go
index b6a279ddc..e54a162f4 100644
--- a/blockproducer/rpc.go
+++ b/blockproducer/rpc.go
@@ -45,8 +45,9 @@ func (s *ChainRPCService) FetchBlock(req *types.FetchBlockReq, resp *types.Fetch
return err
}
-func (s *ChainRPCService) FetchLastBlock(req *types.FetchLastBlockReq, resp *types.FetchBlockResp) error {
- b, c, h, err := s.chain.fetchLastBlock()
+// FetchLastIrreversibleBlock fetches the last block irreversible block from block producer.
+func (s *ChainRPCService) FetchLastIrreversibleBlock(req *types.FetchLastBlockReq, resp *types.FetchBlockResp) error {
+ b, c, h, err := s.chain.fetchLastIrreversibleBlock()
if err != nil {
return err
}
@@ -120,10 +121,9 @@ func (s *ChainRPCService) QuerySQLChainProfile(req *types.QuerySQLChainProfileRe
if ok {
resp.Profile = *p
return
- } else {
- err = errors.Wrap(err, "rpc query sqlchain profile failed")
- return
}
+ err = errors.Wrap(err, "rpc query sqlchain profile failed")
+ return
}
// Sub is the RPC method to subscribe some event.
diff --git a/route/acl.go b/route/acl.go
index 4705f9da3..d75382512 100644
--- a/route/acl.go
+++ b/route/acl.go
@@ -115,8 +115,9 @@ const (
MCCFetchBlock
// MCCFetchBlockByCount is used by nodes to fetch block from block producer by block count since genesis
MCCFetchBlockByCount
- // MCCFetchLastBlock is used by nodes to fetch last block from block producer
- MCCFetchLastBlock
+ // MCCFetchLastIrreversibleBlock is used by nodes to fetch last irreversible block from
+ // block producer
+ MCCFetchLastIrreversibleBlock
// MCCFetchTxBilling is used by nodes to fetch billing transaction from block producer
MCCFetchTxBilling
// MCCNextAccountNonce is used by block producer main chain to allocate next nonce for transactions
@@ -200,7 +201,7 @@ func (s RemoteFunc) String() string {
return "MCC.FetchBlock"
case MCCFetchBlockByCount:
return "MCC.FetchBlockByCount"
- case MCCFetchLastBlock:
+ case MCCFetchLastIrreversibleBlock:
return "MCC.FetchLastBlock"
case MCCFetchTxBilling:
return "MCC.FetchTxBilling"
diff --git a/sqlchain/chainbusservice.go b/sqlchain/chainbusservice.go
index 68f35057d..f7e71373b 100644
--- a/sqlchain/chainbusservice.go
+++ b/sqlchain/chainbusservice.go
@@ -88,7 +88,7 @@ func (bs *BusService) requestLastBlock() (block *types.BPBlock, count uint32) {
req := &types.FetchLastBlockReq{}
resp := &types.FetchBlockResp{}
- if err := bs.requestBP(route.MCCFetchLastBlock.String(), req, resp); err != nil {
+ if err := bs.requestBP(route.MCCFetchLastIrreversibleBlock.String(), req, resp); err != nil {
log.WithError(err).Warning("fetch last block failed")
return
}
From bfcc9b804a40b89404a30b881c24496afbb488a2 Mon Sep 17 00:00:00 2001
From: leventeliu
Date: Mon, 24 Dec 2018 15:54:48 +0800
Subject: [PATCH 134/278] Fix block timestamp in testing
---
blockproducer/chain.go | 4 ++--
blockproducer/chain_test.go | 27 +++++++++++++--------------
2 files changed, 15 insertions(+), 16 deletions(-)
diff --git a/blockproducer/chain.go b/blockproducer/chain.go
index 7bd528b57..eeeed3bee 100644
--- a/blockproducer/chain.go
+++ b/blockproducer/chain.go
@@ -838,7 +838,7 @@ func (c *Chain) produceAndStoreBlock(
func (c *Chain) now() time.Time {
c.RLock()
defer c.RUnlock()
- return time.Now().UTC().Add(c.offset)
+ return time.Now().Add(c.offset).UTC()
}
func (c *Chain) startService(chain *Chain) {
@@ -854,7 +854,7 @@ func (c *Chain) nextTick() (t time.Time, d time.Duration) {
c.RLock()
defer c.RUnlock()
nt = c.nextHeight
- t = time.Now().UTC().Add(c.offset)
+ t = time.Now().Add(c.offset).UTC()
return
}()
d = c.genesisTime.Add(time.Duration(h) * c.period).Sub(t)
diff --git a/blockproducer/chain_test.go b/blockproducer/chain_test.go
index daba7eaf6..89bc31105 100644
--- a/blockproducer/chain_test.go
+++ b/blockproducer/chain_test.go
@@ -188,11 +188,11 @@ func TestChain(t *testing.T) {
err = chain.storeTx(t1)
So(err, ShouldEqual, ErrExistedTx)
})
- err = chain.produceBlock(begin.Add(chain.period))
+ err = chain.produceBlock(begin.Add(chain.period).UTC())
So(err, ShouldBeNil)
// Create a sibling block from fork#0 and apply
- _, bl, err = f0.produceBlock(2, begin.Add(2*chain.period), addr2, priv2)
+ _, bl, err = f0.produceBlock(2, begin.Add(2*chain.period).UTC(), addr2, priv2)
So(err, ShouldBeNil)
So(bl, ShouldNotBeNil)
err = chain.pushBlock(bl)
@@ -203,17 +203,17 @@ func TestChain(t *testing.T) {
err = chain.storeTx(t2)
So(err, ShouldBeNil)
- err = chain.produceBlock(begin.Add(2 * chain.period))
+ err = chain.produceBlock(begin.Add(2 * chain.period).UTC())
So(err, ShouldBeNil)
err = chain.storeTx(t3)
So(err, ShouldBeNil)
err = chain.storeTx(t4)
So(err, ShouldBeNil)
- err = chain.produceBlock(begin.Add(3 * chain.period))
+ err = chain.produceBlock(begin.Add(3 * chain.period).UTC())
So(err, ShouldBeNil)
// Create a sibling block from fork#1 and apply
- f1, bl, err = f1.produceBlock(3, begin.Add(3*chain.period), addr2, priv2)
+ f1, bl, err = f1.produceBlock(3, begin.Add(3*chain.period).UTC(), addr2, priv2)
So(err, ShouldBeNil)
So(bl, ShouldNotBeNil)
err = chain.pushBlock(bl)
@@ -221,11 +221,11 @@ func TestChain(t *testing.T) {
// This should trigger a branch pruning on fork #0
for i := uint32(4); i <= 6; i++ {
- err = chain.produceBlock(begin.Add(time.Duration(i) * chain.period))
+ err = chain.produceBlock(begin.Add(time.Duration(i) * chain.period).UTC())
So(err, ShouldBeNil)
// Create a sibling block from fork#1 and apply
f1, bl, err = f1.produceBlock(
- i, begin.Add(time.Duration(i)*chain.period), addr2, priv2)
+ i, begin.Add(time.Duration(i)*chain.period).UTC(), addr2, priv2)
So(err, ShouldBeNil)
So(bl, ShouldNotBeNil)
err = chain.pushBlock(bl)
@@ -235,7 +235,7 @@ func TestChain(t *testing.T) {
Convey("The chain immutable should be updated to irreversible block", func() {
// Add more blocks to trigger immutable updating
for i := uint32(7); i <= 12; i++ {
- err = chain.produceBlock(begin.Add(time.Duration(i) * chain.period))
+ err = chain.produceBlock(begin.Add(time.Duration(i) * chain.period).UTC())
So(err, ShouldBeNil)
}
Convey("The chain should have same state after reloading", func() {
@@ -254,12 +254,12 @@ func TestChain(t *testing.T) {
f1.addTx(t2)
f1.addTx(t3)
f1.addTx(t4)
- f1, bl, err = f1.produceBlock(7, begin.Add(8*chain.period), addr2, priv2)
+ f1, bl, err = f1.produceBlock(7, begin.Add(8*chain.period).UTC(), addr2, priv2)
So(err, ShouldBeNil)
So(bl, ShouldNotBeNil)
err = chain.pushBlock(bl)
So(err, ShouldBeNil)
- f1, bl, err = f1.produceBlock(8, begin.Add(9*chain.period), addr2, priv2)
+ f1, bl, err = f1.produceBlock(8, begin.Add(9*chain.period).UTC(), addr2, priv2)
So(err, ShouldBeNil)
So(bl, ShouldNotBeNil)
err = chain.pushBlock(bl)
@@ -300,7 +300,7 @@ func TestChain(t *testing.T) {
So(err, ShouldBeNil)
So(count, ShouldEqual, chain.lastIrre.count)
So(height, ShouldEqual, chain.lastIrre.height)
- So(bl.BlockHash(), ShouldResemble, chain.lastIrre.block)
+ So(bl, ShouldResemble, chain.lastIrre.block)
// Try to use the no-cache version
var node = chain.headBranch.head.ancestorByCount(5)
@@ -316,10 +316,9 @@ func TestChain(t *testing.T) {
var irreBlock = chain.lastIrre.block
chain.lastIrre.block = nil // Clear cached block
- bl, height, err = chain.fetchBlockByCount(0)
+ bl, count, height, err = chain.fetchLastIrreversibleBlock()
So(err, ShouldBeNil)
- So(height, ShouldEqual, 0)
- So(bl.BlockHash(), ShouldResemble, irreBlock)
+ So(bl, ShouldResemble, irreBlock)
})
Convey("Test run chain", func() {
From d5474b8f648e2743e9a1e9b4329cad1bce3020bb Mon Sep 17 00:00:00 2001
From: zeqing-guo
Date: Mon, 24 Dec 2018 16:29:26 +0800
Subject: [PATCH 135/278] Change the connect method on driver to use
CreateDatabase Transaction
---
blockproducer/metastate.go | 7 +++++--
client/driver.go | 27 ++++++++++++++-------------
cmd/cql-minerd/integration_test.go | 13 +++++++++----
cmd/cql-minerd/main.go | 2 +-
cmd/cqld/bootstrap.go | 4 ++--
sqlchain/chainbusservice.go | 9 +++++++--
6 files changed, 38 insertions(+), 24 deletions(-)
diff --git a/blockproducer/metastate.go b/blockproducer/metastate.go
index 4e5e4d467..b33f97753 100644
--- a/blockproducer/metastate.go
+++ b/blockproducer/metastate.go
@@ -610,6 +610,7 @@ func (s *metaState) matchProvidersWithUser(tx *types.CreateDatabase) (err error)
)
if tx.AdvancePayment < minAdvancePayment {
err = ErrInsufficientAdvancePayment
+ log.WithError(err).Warning("tx.AdvancePayment: %d, minAdvancePayment: %d", tx.AdvancePayment, minAdvancePayment)
return
}
@@ -636,6 +637,8 @@ func (s *metaState) matchProvidersWithUser(tx *types.CreateDatabase) (err error)
}
if po.GasPrice > tx.GasPrice {
err = ErrGasPriceMismatch
+ log.WithError(err).Warningf("miner's gas price: %d, user's gas price: %d",
+ po.GasPrice, tx.GasPrice)
break
}
miners[i] = &types.MinerInfo{
@@ -707,7 +710,7 @@ func (s *metaState) matchProvidersWithUser(tx *types.CreateDatabase) (err error)
for _, miner := range tx.ResourceMeta.TargetMiners {
s.deleteProviderObject(miner)
}
- log.Infof("success create sqlchain with database ID: %s", dbID)
+ log.Infof("success create sqlchain with database ID: %s", string(*dbID))
return
}
@@ -862,7 +865,6 @@ func (s *metaState) updateBilling(tx *types.UpdateBilling) (err error) {
}
func (s *metaState) applyTransaction(tx pi.Transaction) (err error) {
- log.Infof("get tx: %s", tx.GetTransactionType().String())
switch t := tx.(type) {
case *types.Transfer:
realSender, err := crypto.PubKeyHash(t.Signee)
@@ -931,6 +933,7 @@ func (s *metaState) generateGenesisBlock(dbID proto.DatabaseID, resourceMeta typ
}
func (s *metaState) apply(t pi.Transaction) (err error) {
+ log.Infof("get tx: %s", t.GetTransactionType().String())
// NOTE(leventeliu): bypass pool in this method.
var (
addr = t.GetAccountAddress()
diff --git a/client/driver.go b/client/driver.go
index dc5a8dfc8..51317e666 100644
--- a/client/driver.go
+++ b/client/driver.go
@@ -336,9 +336,6 @@ func cacheGetPeers(dbID proto.DatabaseID, privKey *asymmetric.PrivateKey) (peers
}
func getPeers(dbID proto.DatabaseID, privKey *asymmetric.PrivateKey) (peers *proto.Peers, err error) {
- req := new(types.GetDatabaseRequest)
- req.Header.DatabaseID = dbID
-
defer func() {
log.WithFields(log.Fields{
"db": dbID,
@@ -346,22 +343,26 @@ func getPeers(dbID proto.DatabaseID, privKey *asymmetric.PrivateKey) (peers *pro
}).WithError(err).Debug("get peers for database")
}()
- if err = req.Sign(privKey); err != nil {
+ profileReq := &types.QuerySQLChainProfileReq{}
+ profileResp := &types.QuerySQLChainProfileResp{}
+ profileReq.DBID = dbID
+ err = rpc.RequestBP(route.MCCQuerySQLChainProfile.String(), profileReq, profileResp)
+ if err != nil {
+ log.WithError(err).Warning("get sqlchain profile failed in getPeers")
return
}
- res := new(types.GetDatabaseResponse)
- if err = requestBP(route.BPDBGetDatabase, req, res); err != nil {
- return
+ nodeIDs := make([]proto.NodeID, len(profileResp.Profile.Miners))
+ for i, mi := range profileResp.Profile.Miners {
+ nodeIDs[i] = mi.NodeID
}
-
- // verify response
- if err = res.Verify(); err != nil {
- return
+ peers = &proto.Peers{
+ PeersHeader: proto.PeersHeader{
+ Leader: nodeIDs[0],
+ Servers: nodeIDs[:],
+ },
}
- peers = res.Header.InstanceMeta.Peers
-
// set peers in the updater cache
peerList.Store(dbID, peers)
diff --git a/cmd/cql-minerd/integration_test.go b/cmd/cql-minerd/integration_test.go
index 428117744..45a564487 100644
--- a/cmd/cql-minerd/integration_test.go
+++ b/cmd/cql-minerd/integration_test.go
@@ -56,7 +56,7 @@ var (
logDir = FJ(testWorkingDir, "./log/")
testGasPrice uint64 = 1
testInitTokenAmount uint64 = 1000000000
- testAdvancePayment uint64 = 10000000
+ testAdvancePayment uint64 = 20000000
)
var nodeCmds []*utils.CMD
@@ -403,6 +403,8 @@ func TestFullProcess(t *testing.T) {
So(err, ShouldBeNil)
}
+ time.Sleep(20 * time.Second)
+
// client send create database transaction
nonce, err := getNonce(clientAddr)
So(err, ShouldBeNil)
@@ -424,6 +426,7 @@ func TestFullProcess(t *testing.T) {
So(err, ShouldBeNil)
err = rpc.RequestBP(route.MCCAddTx.String(), req, resp)
So(err, ShouldBeNil)
+ time.Sleep(20 * time.Second)
// check sqlchain profile exist
dbID := proto.FromAccountAndNonce(clientAddr, uint32(nonce))
@@ -433,6 +436,7 @@ func TestFullProcess(t *testing.T) {
err = rpc.RequestBP(route.MCCQuerySQLChainProfile.String(), profileReq, profileResp)
So(err, ShouldBeNil)
profile := profileResp.Profile
+ So(profile.Address.DatabaseID(), ShouldEqual, *dbID)
So(profile.Owner.String(), ShouldEqual, clientAddr.String())
So(profile.TokenType, ShouldEqual, types.Particle)
minersMap := make(map[proto.AccountAddress]bool)
@@ -443,9 +447,10 @@ func TestFullProcess(t *testing.T) {
So(minersMap[miner], ShouldBeTrue)
}
- // create
- dsn, err := client.Create(client.ResourceMeta{Node: 2})
- So(err, ShouldBeNil)
+ // create dsn
+ dsncfg := client.NewConfig()
+ dsncfg.DatabaseID = string(*dbID)
+ dsn := dsncfg.FormatDSN()
log.Infof("the created database dsn is %v", dsn)
diff --git a/cmd/cql-minerd/main.go b/cmd/cql-minerd/main.go
index eb8016255..db032512b 100644
--- a/cmd/cql-minerd/main.go
+++ b/cmd/cql-minerd/main.go
@@ -117,7 +117,7 @@ func initLogs() {
func main() {
// set random
rand.Seed(time.Now().UnixNano())
- log.SetLevel(log.InfoLevel)
+ log.SetLevel(log.DebugLevel)
flag.Parse()
if showVersion {
diff --git a/cmd/cqld/bootstrap.go b/cmd/cqld/bootstrap.go
index 7b879eff7..f2f7971d4 100644
--- a/cmd/cqld/bootstrap.go
+++ b/cmd/cqld/bootstrap.go
@@ -153,8 +153,8 @@ func runNode(nodeID proto.NodeID, listenAddr string) (err error) {
server,
peers,
nodeID,
- time.Minute,
- 20*time.Second,
+ 3*time.Second,
+ 1*time.Second,
conf.GConf.QPS,
)
chain, err := bp.NewChain(chainConfig)
diff --git a/sqlchain/chainbusservice.go b/sqlchain/chainbusservice.go
index 68f35057d..df121b25d 100644
--- a/sqlchain/chainbusservice.go
+++ b/sqlchain/chainbusservice.go
@@ -72,11 +72,13 @@ func (bs *BusService) subscribeBlock(ctx context.Context) {
case <-time.After(bs.checkInterval):
// fetch block from remote block producer
c := atomic.LoadUint32(&bs.blockCount)
- log.Info(c)
+ log.Debugf("fetch block in count: %d", c)
b := bs.requestBlock(c)
if b == nil {
continue
}
+ log.Debugf("success fetch block in count: %d, block hash: %s, number of block tx: %d",
+ c, b.BlockHash().String(), len(b.GetTxHashes()))
bs.extractTxs(b, c)
atomic.AddUint32(&bs.blockCount, 1)
}
@@ -134,7 +136,7 @@ func (bs *BusService) requestBP(method string, request interface{}, response int
func (bs *BusService) extractTxs(blocks *types.BPBlock, count uint32) {
for _, tx := range blocks.Transactions {
eventName := bs.unwrapTx(tx)
- bs.Publish(eventName, blocks, count)
+ bs.Publish(eventName, tx, count)
}
}
@@ -143,6 +145,9 @@ func (bs *BusService) unwrapTx(tx interfaces.Transaction) string {
case *interfaces.TransactionWrapper:
return bs.unwrapTx(t.Unwrap())
default:
+ sender := tx.GetAccountAddress()
+ log.Debugf("get tx with transaction type: %s, hash: %s, sender: %s",
+ tx.GetTransactionType().String(), tx.Hash().String(), sender.String())
eventName := fmt.Sprintf("/%s/", t.GetTransactionType().String())
return eventName
}
From 245890c03acd6acc77779898d92a21ddbd910fab Mon Sep 17 00:00:00 2001
From: auxten
Date: Mon, 24 Dec 2018 17:07:11 +0800
Subject: [PATCH 136/278] Optimize sessionPool locks, fix TestNewSessionPool
---
rpc/pool.go | 18 ++++++------
rpc/pool_test.go | 71 ++++++++++++++++++++++++++++--------------------
2 files changed, 51 insertions(+), 38 deletions(-)
diff --git a/rpc/pool.go b/rpc/pool.go
index ae45102c0..c27f1d2e5 100644
--- a/rpc/pool.go
+++ b/rpc/pool.go
@@ -102,21 +102,20 @@ func toSession(id proto.NodeID, conn net.Conn) (sess *Session, err error) {
func (p *SessionPool) LoadOrStore(id proto.NodeID, newSess *Session) (sess *Session, loaded bool) {
// NO Blocking operation in this function
p.Lock()
- defer p.Unlock()
sess, exist := p.sessions[id]
if exist {
+ p.Unlock()
log.WithField("node", id).Debug("load session for target node")
loaded = true
} else {
- sess = newSess
p.sessions[id] = newSess
+ p.Unlock()
+ sess = newSess
}
return
}
func (p *SessionPool) getSessionFromPool(id proto.NodeID) (sess *Session, ok bool) {
- p.RLock()
- defer p.RUnlock()
sess, ok = p.sessions[id]
return
}
@@ -124,7 +123,9 @@ func (p *SessionPool) getSessionFromPool(id proto.NodeID) (sess *Session, ok boo
// Get returns existing session to the node, if not exist try best to create one
func (p *SessionPool) Get(id proto.NodeID) (conn net.Conn, err error) {
// first try to get one session from pool
+ p.Lock()
cachedConn, ok := p.getSessionFromPool(id)
+ p.Unlock()
if ok {
conn, err = cachedConn.Sess.OpenStream()
if err == nil {
@@ -168,14 +169,15 @@ func (p *SessionPool) Set(id proto.NodeID, conn net.Conn) (exist bool) {
// Remove the node sessions in the pool
func (p *SessionPool) Remove(id proto.NodeID) {
+ p.Lock()
sess, ok := p.getSessionFromPool(id)
if ok {
+ delete(p.sessions, id)
+ p.Unlock()
sess.Close()
+ } else {
+ p.Unlock()
}
-
- p.Lock()
- defer p.Unlock()
- delete(p.sessions, id)
}
// Close closes all sessions in the pool
diff --git a/rpc/pool_test.go b/rpc/pool_test.go
index 6e003e901..80912aa8d 100644
--- a/rpc/pool_test.go
+++ b/rpc/pool_test.go
@@ -22,11 +22,12 @@ import (
"sync"
"testing"
+ . "github.com/smartystreets/goconvey/convey"
+ mux "github.com/xtaci/smux"
+
"github.com/CovenantSQL/CovenantSQL/proto"
"github.com/CovenantSQL/CovenantSQL/utils"
"github.com/CovenantSQL/CovenantSQL/utils/log"
- . "github.com/smartystreets/goconvey/convey"
- mux "github.com/xtaci/smux"
)
const (
@@ -44,12 +45,10 @@ var (
var FJ = filepath.Join
-func server(c C, localAddr string, wg *sync.WaitGroup, p *SessionPool, n int) error {
+func server(c C, localAddr string, n int) error {
// Accept a TCP connection
listener, err := net.Listen("tcp", localAddr)
- wg.Add(1)
go func() {
- defer wg.Done()
conn, err := listener.Accept()
c.So(err, ShouldBeNil)
@@ -59,21 +58,22 @@ func server(c C, localAddr string, wg *sync.WaitGroup, p *SessionPool, n int) er
c.So(err, ShouldBeNil)
for i := 0; i < concurrency; i++ {
- wg.Add(1)
go func(i int, c2 C) {
// Accept a stream
//c2.So(err, ShouldBeNil)
// Stream implements net.Conn
// Listen for a message
//c2.So(string(buf1), ShouldEqual, "ping")
- defer wg.Done()
log.Println("accepting stream")
stream, err := session.AcceptStream()
if err == nil {
buf1 := make([]byte, 4)
- for i := 0; i < n; i++ {
- stream.Read(buf1)
- c2.So(string(buf1), ShouldEqual, "ping")
+ for i := 0; i < n; {
+ n, err := stream.Read(buf1)
+ if n == 4 && err == nil {
+ i++
+ c2.So(string(buf1), ShouldEqual, "ping")
+ }
}
log.Debugf("buf#%d read done", i)
}
@@ -93,18 +93,21 @@ func BenchmarkSessionPool_Get(b *testing.B) {
wg := &sync.WaitGroup{}
- server(c, localAddr, wg, p, b.N)
+ server(c, localAddr, b.N)
b.ResetTimer()
+ wg.Add(concurrency)
for i := 0; i < concurrency; i++ {
- wg.Add(1)
go func(c2 C, n int) {
// Open a new stream
// Stream implements net.Conn
defer wg.Done()
stream, err := p.Get(proto.NodeID(localAddr))
c2.So(err, ShouldBeNil)
- for i := 0; i < n; i++ {
- _, err = stream.Write([]byte("ping"))
+ for i := 0; i < n; {
+ n, err := stream.Write([]byte("ping"))
+ if n == 4 && err == nil {
+ i++
+ }
}
}(c, b.N)
}
@@ -122,9 +125,11 @@ func TestNewSessionPool(t *testing.T) {
wg := &sync.WaitGroup{}
- server(c, localAddr, wg, p, packetCount)
+ server(c, localAddr, packetCount)
+ p.Get(proto.NodeID(localAddr))
+
+ wg.Add(concurrency)
for i := 0; i < concurrency; i++ {
- wg.Add(1)
go func(c2 C, n int) {
// Open a new stream
// Stream implements net.Conn
@@ -135,26 +140,29 @@ func TestNewSessionPool(t *testing.T) {
return
}
c2.So(err, ShouldBeNil)
- for i := 0; i < n; i++ {
- _, err = stream.Write([]byte("ping"))
+ for i := 0; i < n; {
+ n, err := stream.Write([]byte("ping"))
+ if n == 4 && err == nil {
+ i++
+ }
}
}(c, packetCount)
}
wg.Wait()
- c.So(p.Len(), ShouldEqual, 1)
+ So(p.Len(), ShouldEqual, 1)
- wg2 := &sync.WaitGroup{}
- server(c, localAddr2, wg2, p, packetCount)
+ server(c, localAddr2, packetCount)
conn, _ := net.Dial("tcp", localAddr2)
exists := p.Set(proto.NodeID(localAddr2), conn)
- c.So(exists, ShouldBeFalse)
+ So(exists, ShouldBeFalse)
exists = p.Set(proto.NodeID(localAddr2), conn)
- c.So(exists, ShouldBeTrue)
- c.So(p.Len(), ShouldEqual, 2)
+ So(exists, ShouldBeTrue)
+ So(p.Len(), ShouldEqual, 2)
+ wg2 := &sync.WaitGroup{}
+ wg2.Add(concurrency)
for i := 0; i < concurrency; i++ {
- wg2.Add(1)
go func(c2 C, n int) {
// Open a new stream
// Stream implements net.Conn
@@ -165,20 +173,23 @@ func TestNewSessionPool(t *testing.T) {
return
}
c2.So(err, ShouldBeNil)
- for i := 0; i < n; i++ {
- _, err = stream.Write([]byte("ping"))
+ for i := 0; i < n; {
+ n, err := stream.Write([]byte("ping"))
+ if n == 4 && err == nil {
+ i++
+ }
}
}(c, packetCount)
}
wg2.Wait()
- c.So(p.Len(), ShouldEqual, 2)
+ So(p.Len(), ShouldEqual, 2)
p.Remove(proto.NodeID(localAddr2))
- c.So(p.Len(), ShouldEqual, 1)
+ So(p.Len(), ShouldEqual, 1)
p.Close()
- c.So(p.Len(), ShouldEqual, 0)
+ So(p.Len(), ShouldEqual, 0)
})
From 9d1cfff9d854a900020a61927296554c921a4177 Mon Sep 17 00:00:00 2001
From: zeqing-guo
Date: Mon, 24 Dec 2018 23:13:49 +0800
Subject: [PATCH 137/278] Integration test for CreateDatabase tx and query
permission check
---
blockproducer/metastate.go | 4 +-
cmd/cql-minerd/integration_test.go | 14 ++++++-
route/acl.go | 2 +-
sqlchain/chainbusservice.go | 13 +++---
worker/dbms.go | 64 ++++++++++++++++++++----------
5 files changed, 64 insertions(+), 33 deletions(-)
diff --git a/blockproducer/metastate.go b/blockproducer/metastate.go
index b33f97753..77d1cadfa 100644
--- a/blockproducer/metastate.go
+++ b/blockproducer/metastate.go
@@ -610,7 +610,8 @@ func (s *metaState) matchProvidersWithUser(tx *types.CreateDatabase) (err error)
)
if tx.AdvancePayment < minAdvancePayment {
err = ErrInsufficientAdvancePayment
- log.WithError(err).Warning("tx.AdvancePayment: %d, minAdvancePayment: %d", tx.AdvancePayment, minAdvancePayment)
+ log.WithError(err).Warningf("tx.AdvancePayment: %d, minAdvancePayment: %d",
+ tx.AdvancePayment, minAdvancePayment)
return
}
@@ -673,6 +674,7 @@ func (s *metaState) matchProvidersWithUser(tx *types.CreateDatabase) (err error)
users[0] = &types.SQLChainUser{
Address: sender,
Permission: types.Admin,
+ Status: types.Normal,
Deposit: minAdvancePayment,
AdvancePayment: tx.AdvancePayment,
}
diff --git a/cmd/cql-minerd/integration_test.go b/cmd/cql-minerd/integration_test.go
index 45a564487..ca45bc482 100644
--- a/cmd/cql-minerd/integration_test.go
+++ b/cmd/cql-minerd/integration_test.go
@@ -446,6 +446,17 @@ func TestFullProcess(t *testing.T) {
for _, miner := range minersAddrs {
So(minersMap[miner], ShouldBeTrue)
}
+ usersMap := make(map[proto.AccountAddress]types.PermStat)
+ for _, user := range profile.Users {
+ usersMap[user.Address] = types.PermStat{
+ Permission: user.Permission,
+ Status: user.Status,
+ }
+ }
+ permStat, ok := usersMap[clientAddr]
+ So(ok, ShouldBeTrue)
+ So(permStat.Permission, ShouldEqual, types.Admin)
+ So(permStat.Status, ShouldEqual, types.Normal)
// create dsn
dsncfg := client.NewConfig()
@@ -569,8 +580,7 @@ func TestFullProcess(t *testing.T) {
err = db.Close()
So(err, ShouldBeNil)
- err = client.Drop(dsn)
- So(err, ShouldBeNil)
+ // TODO(lambda): Drop database
})
}
diff --git a/route/acl.go b/route/acl.go
index d75382512..b28591630 100644
--- a/route/acl.go
+++ b/route/acl.go
@@ -202,7 +202,7 @@ func (s RemoteFunc) String() string {
case MCCFetchBlockByCount:
return "MCC.FetchBlockByCount"
case MCCFetchLastIrreversibleBlock:
- return "MCC.FetchLastBlock"
+ return "MCC.FetchLastIrreversibleBlock"
case MCCFetchTxBilling:
return "MCC.FetchTxBilling"
case MCCNextAccountNonce:
diff --git a/sqlchain/chainbusservice.go b/sqlchain/chainbusservice.go
index dfcf1d45c..bd8640727 100644
--- a/sqlchain/chainbusservice.go
+++ b/sqlchain/chainbusservice.go
@@ -125,21 +125,18 @@ func (bs *BusService) requestBP(method string, request interface{}, response int
func (bs *BusService) extractTxs(blocks *types.BPBlock, count uint32) {
for _, tx := range blocks.Transactions {
- eventName := bs.unwrapTx(tx)
- bs.Publish(eventName, tx, count)
+ t := bs.unwrapTx(tx)
+ eventName := fmt.Sprintf("/%s/", t.GetTransactionType().String())
+ bs.Publish(eventName, t, count)
}
}
-func (bs *BusService) unwrapTx(tx interfaces.Transaction) string {
+func (bs *BusService) unwrapTx(tx interfaces.Transaction) interfaces.Transaction {
switch t := tx.(type) {
case *interfaces.TransactionWrapper:
return bs.unwrapTx(t.Unwrap())
default:
- sender := tx.GetAccountAddress()
- log.Debugf("get tx with transaction type: %s, hash: %s, sender: %s",
- tx.GetTransactionType().String(), tx.Hash().String(), sender.String())
- eventName := fmt.Sprintf("/%s/", t.GetTransactionType().String())
- return eventName
+ return tx
}
}
diff --git a/worker/dbms.go b/worker/dbms.go
index e14b6406f..ca2d4e9f5 100644
--- a/worker/dbms.go
+++ b/worker/dbms.go
@@ -62,6 +62,7 @@ type DBMS struct {
rpc *DBMSRPCService
busService *sqlchain.BusService
address proto.AccountAddress
+ privKey *asymmetric.PrivateKey
}
// NewDBMS returns new database management instance.
@@ -102,6 +103,13 @@ func NewDBMS(cfg *DBMSConfig) (dbms *DBMS, err error) {
}
dbms.address = addr
+ // private key cache
+ dbms.privKey, err = kms.GetLocalPrivateKey()
+ if err != nil {
+ log.WithError(err).Warning("get private key failed")
+ return
+ }
+
// init service
dbms.rpc = NewDBMSRPCService(route.DBRPCName, cfg.Server, dbms)
@@ -195,12 +203,10 @@ func (dbms *DBMS) Init() (err error) {
}
func (dbms *DBMS) updateBilling(tx interfaces.Transaction, count uint32) {
- var ub *types.UpdateBilling
- switch t := tx.(type) {
- case *types.UpdateBilling:
- ub = t
- default:
- log.WithError(ErrInvalidTransactionType).Warning("unexpected error")
+ ub, ok := tx.(*types.UpdateBilling)
+ if !ok {
+ log.WithError(ErrInvalidTransactionType).Warningf("invalid tx type in updateBilling: %s",
+ tx.GetTransactionType().String())
return
}
@@ -230,15 +236,14 @@ func (dbms *DBMS) updateBilling(tx interfaces.Transaction, count uint32) {
}
func (dbms *DBMS) createDatabase(tx interfaces.Transaction, count uint32) {
- var cd *types.CreateDatabase
- switch t := tx.(type) {
- case *types.CreateDatabase:
- cd = t
- default:
- log.WithError(ErrInvalidTransactionType).Warning("unexpected error")
+ cd, ok := tx.(*types.CreateDatabase)
+ if !ok {
+ log.WithError(ErrInvalidTransactionType).Warningf("invalid tx type in createDatabase: %s",
+ tx.GetTransactionType().String())
return
}
+ log.Debugf("create database with owner: %s, nonce: %d", cd.Owner.String(), cd.Nonce)
var (
dbid = proto.FromAccountAndNonce(cd.Owner, uint32(cd.Nonce))
isTargetMiner = false
@@ -263,20 +268,33 @@ func (dbms *DBMS) createDatabase(tx interfaces.Transaction, count uint32) {
state := types.NewUserState()
for _, user := range p.Users {
+ log.Debugf("user address: %s, permission: %d, status: %d",
+ user.Address.String(), user.Permission, user.Status)
state.State[user.Address] = &types.PermStat{
Permission: user.Permission,
Status: user.Status,
}
}
- dbms.chainMap.Store(dbid, state)
-
peers := proto.Peers{
PeersHeader: proto.PeersHeader{
Leader: nodeIDs[0],
Servers: nodeIDs[:],
},
}
+ if dbms.privKey == nil {
+ dbms.privKey, err = kms.GetLocalPrivateKey()
+ if err != nil {
+ log.WithError(err).Warning("get private key failed in createDatabase")
+ return
+ }
+ }
+ err = peers.Sign(dbms.privKey)
+ if err != nil {
+ log.WithError(err).Warning("sign peers failed in createDatabase")
+ return
+ }
+
si := types.ServiceInstance{
DatabaseID: *dbid,
Peers: &peers,
@@ -287,15 +305,13 @@ func (dbms *DBMS) createDatabase(tx interfaces.Transaction, count uint32) {
if err != nil {
log.WithError(err).Error("create database error")
}
+ dbms.chainMap.Store(*dbid, *state)
}
func (dbms *DBMS) updatePermission(tx interfaces.Transaction, count uint32) {
- var up *types.UpdatePermission
- switch t := tx.(type) {
- case *types.UpdatePermission:
- up = t
- default:
- log.WithError(ErrInvalidTransactionType).Warning("unexpected error")
+ up, ok := tx.(*types.UpdatePermission)
+ if !ok {
+ log.WithError(ErrInvalidTransactionType).Warning("unexpected error in updatePermission")
return
}
@@ -309,7 +325,7 @@ func (dbms *DBMS) updatePermission(tx interfaces.Transaction, count uint32) {
dbms.chainMap.Store(up.TargetSQLChain.DatabaseID(), newState)
}
-// UpdatePermission export the update permission interface for test.
+// UpdatePermission exports the update permission interface for test.
func (dbms *DBMS) UpdatePermission(dbid proto.DatabaseID, user proto.AccountAddress, permStat *types.PermStat) (err error) {
s, loaded := dbms.chainMap.Load(dbid)
if !loaded {
@@ -527,6 +543,7 @@ func (dbms *DBMS) getMappedInstances() (instances []types.ServiceInstance, err e
}
func (dbms *DBMS) checkPermission(addr proto.AccountAddress, req *types.Request) (err error) {
+ log.Debugf("in checkPermission, database id: %s, user addr: %s", req.Header.DatabaseID, addr.String())
state, loaded := dbms.chainMap.Load(req.Header.DatabaseID)
if !loaded {
err = errors.Wrap(ErrNotExists, "check permission failed")
@@ -540,25 +557,30 @@ func (dbms *DBMS) checkPermission(addr proto.AccountAddress, req *types.Request)
if permStat, ok := s.State[addr]; ok {
if !permStat.Status.EnableQuery() {
err = ErrPermissionDeny
+ log.WithError(err).Debugf("cannot query, status: %d", permStat.Status)
return
}
if req.Header.QueryType == types.ReadQuery {
if !permStat.Permission.CheckRead() {
err = ErrPermissionDeny
+ log.WithError(err).Debugf("cannot read, permission: %d", permStat.Permission)
return
}
} else if req.Header.QueryType == types.WriteQuery {
if !permStat.Permission.CheckWrite() {
err = ErrPermissionDeny
+ log.WithError(err).Debugf("cannot write, permission: %d", permStat.Permission)
return
}
} else {
err = ErrInvalidPermission
+ log.WithError(err).Debugf("invalid permission, permission: %d", permStat.Permission)
return
}
} else {
err = ErrPermissionDeny
+ log.WithError(err).Debug("cannot find permission")
return
}
From 96ba2bc62ef4d7bc64d8a37f12438355e164b8bd Mon Sep 17 00:00:00 2001
From: leventeliu
Date: Mon, 24 Dec 2018 23:17:37 +0800
Subject: [PATCH 138/278] Add load SQLChain method for metaState
---
blockproducer/metastate.go | 13 +++++++++++++
blockproducer/metastate_test.go | 15 +++++++++++++++
2 files changed, 28 insertions(+)
diff --git a/blockproducer/metastate.go b/blockproducer/metastate.go
index 77d1cadfa..e6fa77411 100644
--- a/blockproducer/metastate.go
+++ b/blockproducer/metastate.go
@@ -866,6 +866,19 @@ func (s *metaState) updateBilling(tx *types.UpdateBilling) (err error) {
return
}
+func (s *metaState) loadROSQLChains(addr proto.AccountAddress) (dbs []*types.SQLChainProfile) {
+ for _, db := range s.readonly.databases {
+ for _, miner := range db.Miners {
+ if miner.Address == addr {
+ var dst = &types.SQLChainProfile{}
+ deepcopier.Copy(&db.SQLChainProfile).To(dst)
+ dbs = append(dbs, dst)
+ }
+ }
+ }
+ return
+}
+
func (s *metaState) applyTransaction(tx pi.Transaction) (err error) {
switch t := tx.(type) {
case *types.Transfer:
diff --git a/blockproducer/metastate_test.go b/blockproducer/metastate_test.go
index d8b21736f..53eefba3b 100644
--- a/blockproducer/metastate_test.go
+++ b/blockproducer/metastate_test.go
@@ -129,6 +129,10 @@ func TestMetaState(t *testing.T) {
co, loaded = ms.loadOrStoreSQLChainObject(dbid1, &sqlchainObject{
SQLChainProfile: types.SQLChainProfile{
ID: dbid1,
+ Miners: []*types.MinerInfo{
+ &types.MinerInfo{Address: addr1},
+ &types.MinerInfo{Address: addr2},
+ },
},
})
So(co, ShouldBeNil)
@@ -136,6 +140,10 @@ func TestMetaState(t *testing.T) {
co, loaded = ms.loadOrStoreSQLChainObject(dbid2, &sqlchainObject{
SQLChainProfile: types.SQLChainProfile{
ID: dbid2,
+ Miners: []*types.MinerInfo{
+ &types.MinerInfo{Address: addr2},
+ &types.MinerInfo{Address: addr3},
+ },
},
})
So(co, ShouldBeNil)
@@ -190,6 +198,13 @@ func TestMetaState(t *testing.T) {
})
Convey("When metaState change is committed", func() {
ms.commit()
+ Convey("The metaState object should return correct db list", func() {
+ var dbs []*types.SQLChainProfile
+ dbs = ms.loadROSQLChains(addr1)
+ So(len(dbs), ShouldEqual, 1)
+ dbs = ms.loadROSQLChains(addr2)
+ So(len(dbs), ShouldEqual, 2)
+ })
Convey("The metaState object should be ok to delete user", func() {
err = ms.deleteSQLChainUser(dbid3, addr2)
So(err, ShouldBeNil)
From 1a7f5fd713fb6ef30da97097f0659675fc77884f Mon Sep 17 00:00:00 2001
From: leventeliu
Date: Tue, 25 Dec 2018 10:18:49 +0800
Subject: [PATCH 139/278] Add more assertions in loadDatabases testing
---
blockproducer/metastate_test.go | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/blockproducer/metastate_test.go b/blockproducer/metastate_test.go
index 53eefba3b..d6fc2b3ae 100644
--- a/blockproducer/metastate_test.go
+++ b/blockproducer/metastate_test.go
@@ -202,8 +202,13 @@ func TestMetaState(t *testing.T) {
var dbs []*types.SQLChainProfile
dbs = ms.loadROSQLChains(addr1)
So(len(dbs), ShouldEqual, 1)
+ So(dbs[0].ID, ShouldEqual, dbid1)
dbs = ms.loadROSQLChains(addr2)
So(len(dbs), ShouldEqual, 2)
+ So(dbs[0].ID, ShouldEqual, dbid1)
+ So(dbs[1].ID, ShouldEqual, dbid2)
+ dbs = ms.loadROSQLChains(addr4)
+ So(dbs, ShouldBeEmpty)
})
Convey("The metaState object should be ok to delete user", func() {
err = ms.deleteSQLChainUser(dbid3, addr2)
From 8b2a9f0433e938133e43108275e8968950cb5754 Mon Sep 17 00:00:00 2001
From: auxten
Date: Tue, 25 Dec 2018 11:36:06 +0800
Subject: [PATCH 140/278] Fix RunCommandNB pipe issue
---
utils/exec.go | 27 ++++-----------------------
1 file changed, 4 insertions(+), 23 deletions(-)
diff --git a/utils/exec.go b/utils/exec.go
index 9509b538f..3f405668b 100644
--- a/utils/exec.go
+++ b/utils/exec.go
@@ -97,16 +97,13 @@ func RunCommandNB(bin string, args []string, processName string, workingDir stri
return
}
cmd.Cmd = exec.Command(bin, args...)
- stdoutIn, _ := cmd.Cmd.StdoutPipe()
- stderrIn, _ := cmd.Cmd.StderrPipe()
- var stdout, stderr io.Writer
if toStd {
- stdout = io.MultiWriter(os.Stdout, logFD)
- stderr = io.MultiWriter(os.Stderr, logFD)
+ cmd.Cmd.Stdout = io.MultiWriter(os.Stdout, logFD)
+ cmd.Cmd.Stderr = io.MultiWriter(os.Stderr, logFD)
} else {
- stdout = logFD
- stderr = logFD
+ cmd.Cmd.Stdout = logFD
+ cmd.Cmd.Stderr = logFD
}
err = cmd.Cmd.Start()
@@ -115,21 +112,5 @@ func RunCommandNB(bin string, args []string, processName string, workingDir stri
return
}
- go func() {
- _, err := io.Copy(stdout, stdoutIn)
- if err != nil {
- log.WithError(err).Error("failed to capture stdout")
- return
- }
- }()
-
- go func() {
- _, err := io.Copy(stderr, stderrIn)
- if err != nil {
- log.WithError(err).Error("failed to capture stderr")
- return
- }
- }()
-
return
}
From e05d2fc8959c5370caa79107db68171f083634c8 Mon Sep 17 00:00:00 2001
From: auxten
Date: Tue, 25 Dec 2018 13:06:44 +0800
Subject: [PATCH 141/278] Put LogFD in CMD struct for RunCommandNB defer close
---
cmd/cql-adapter/storage/sqlite3.go | 1 +
cmd/cql-faucet/persistence.go | 1 +
cmd/cql-minerd/main.go | 1 +
crypto/hash/hashfuncs.go | 1 +
rpc/leak_test.go | 20 ++++++++++++--------
storage/storage.go | 1 +
utils/exec.go | 25 ++++++++++++++++---------
xenomint/xxx_test.go | 1 +
8 files changed, 34 insertions(+), 17 deletions(-)
diff --git a/cmd/cql-adapter/storage/sqlite3.go b/cmd/cql-adapter/storage/sqlite3.go
index aac13f94d..d9be539d8 100644
--- a/cmd/cql-adapter/storage/sqlite3.go
+++ b/cmd/cql-adapter/storage/sqlite3.go
@@ -24,6 +24,7 @@ import (
"math/rand"
"os"
"path/filepath"
+
// Import sqlite3 manually.
_ "github.com/CovenantSQL/go-sqlite3-encrypt"
)
diff --git a/cmd/cql-faucet/persistence.go b/cmd/cql-faucet/persistence.go
index dfdc3d458..140a6c6d6 100644
--- a/cmd/cql-faucet/persistence.go
+++ b/cmd/cql-faucet/persistence.go
@@ -26,6 +26,7 @@ import (
"github.com/CovenantSQL/CovenantSQL/conf"
"github.com/CovenantSQL/CovenantSQL/utils/log"
uuid "github.com/satori/go.uuid"
+
// Load sqlite3 database driver.
_ "github.com/CovenantSQL/go-sqlite3-encrypt"
)
diff --git a/cmd/cql-minerd/main.go b/cmd/cql-minerd/main.go
index eb8016255..f1fc11c16 100644
--- a/cmd/cql-minerd/main.go
+++ b/cmd/cql-minerd/main.go
@@ -26,6 +26,7 @@ import (
"os"
"os/signal"
"runtime"
+
//"runtime/trace"
"syscall"
"time"
diff --git a/crypto/hash/hashfuncs.go b/crypto/hash/hashfuncs.go
index d3cd98561..af14cf46d 100644
--- a/crypto/hash/hashfuncs.go
+++ b/crypto/hash/hashfuncs.go
@@ -19,6 +19,7 @@ package hash
import (
"encoding/binary"
"hash/fnv"
+
// "crypto/sha256" benchmark is at least 10% faster on
// i7-4870HQ CPU @ 2.50GHz than "github.com/minio/sha256-simd"
"crypto/sha256"
diff --git a/rpc/leak_test.go b/rpc/leak_test.go
index 91b96159c..0ffe4d1e9 100644
--- a/rpc/leak_test.go
+++ b/rpc/leak_test.go
@@ -32,19 +32,22 @@ import (
func TestSessionPool_SessionBroken(t *testing.T) {
log.SetLevel(log.DebugLevel)
- utils.Build()
var err error
+ err = utils.Build()
+ if err != nil {
+ log.Errorf("build failed: %v", err)
+ }
conf.GConf, err = conf.LoadConfig(FJ(testWorkingDir, "./leak/client.yaml"))
if err != nil {
t.Errorf("load config from %s failed: %s", FJ(testWorkingDir, "./leak/client.yaml"), err)
}
log.Debugf("GConf: %##v", conf.GConf)
- os.Remove(conf.GConf.PubKeyStoreFile)
- os.Remove(FJ(testWorkingDir, "./leak/leader/dht.db"))
- os.Remove(FJ(testWorkingDir, "./leak/leader/dht.db-shm"))
- os.Remove(FJ(testWorkingDir, "./leak/leader/dht.db-wal"))
- os.Remove(FJ(testWorkingDir, "./leak/kayak.db"))
- os.RemoveAll(FJ(testWorkingDir, "./leak/kayak.ldb"))
+ _ = os.Remove(conf.GConf.PubKeyStoreFile)
+ _ = os.Remove(FJ(testWorkingDir, "./leak/leader/dht.db"))
+ _ = os.Remove(FJ(testWorkingDir, "./leak/leader/dht.db-shm"))
+ _ = os.Remove(FJ(testWorkingDir, "./leak/leader/dht.db-wal"))
+ _ = os.Remove(FJ(testWorkingDir, "./leak/kayak.db"))
+ _ = os.RemoveAll(FJ(testWorkingDir, "./leak/kayak.ldb"))
leader, err := utils.RunCommandNB(
FJ(baseDir, "./bin/cqld"),
@@ -53,7 +56,8 @@ func TestSessionPool_SessionBroken(t *testing.T) {
)
defer func() {
- leader.Cmd.Process.Signal(syscall.SIGKILL)
+ _ = leader.LogFD.Close()
+ _ = leader.Cmd.Process.Signal(syscall.SIGKILL)
}()
log.Debugf("leader pid %d", leader.Cmd.Process.Pid)
diff --git a/storage/storage.go b/storage/storage.go
index 7e36bad0e..e059819af 100644
--- a/storage/storage.go
+++ b/storage/storage.go
@@ -26,6 +26,7 @@ import (
"github.com/CovenantSQL/CovenantSQL/twopc"
"github.com/CovenantSQL/CovenantSQL/utils/log"
+
// Register CovenantSQL/go-sqlite3-encrypt engine.
_ "github.com/CovenantSQL/go-sqlite3-encrypt"
)
diff --git a/utils/exec.go b/utils/exec.go
index 3f405668b..c533cd3bc 100644
--- a/utils/exec.go
+++ b/utils/exec.go
@@ -33,6 +33,7 @@ var FJ = filepath.Join
type CMD struct {
Cmd *exec.Cmd
LogPath string
+ LogFD *os.File
}
// GetProjectSrcDir gets the src code root
@@ -70,6 +71,9 @@ func RunCommand(bin string, args []string, processName string, workingDir string
}).WithError(err).Error("start command failed")
return
}
+ defer func() {
+ _ = cmd.LogFD.Close()
+ }()
err = cmd.Cmd.Wait()
if err != nil {
log.WithFields(log.Fields{
@@ -84,31 +88,34 @@ func RunCommand(bin string, args []string, processName string, workingDir string
// RunCommandNB starts a non-blocking command
func RunCommandNB(bin string, args []string, processName string, workingDir string, logDir string, toStd bool) (cmd *CMD, err error) {
cmd = new(CMD)
- cmd.LogPath = FJ(logDir, processName+".log")
- logFD, err := os.Create(cmd.LogPath)
+ err = os.Chdir(workingDir)
if err != nil {
- log.WithField("path", cmd.LogPath).WithError(err).Error("create log file failed")
+ log.WithField("wd", workingDir).Error("change working dir failed")
return
}
- err = os.Chdir(workingDir)
+ cmd.LogPath = FJ(logDir, processName+".log")
+ cmd.LogFD, err = os.Create(cmd.LogPath)
if err != nil {
- log.WithField("wd", workingDir).Error("change working dir failed")
+ log.WithField("path", cmd.LogPath).WithError(err).Error("create log file failed")
return
}
+
cmd.Cmd = exec.Command(bin, args...)
if toStd {
- cmd.Cmd.Stdout = io.MultiWriter(os.Stdout, logFD)
- cmd.Cmd.Stderr = io.MultiWriter(os.Stderr, logFD)
+ cmd.Cmd.Stdout = io.MultiWriter(os.Stdout, cmd.LogFD)
+ cmd.Cmd.Stderr = io.MultiWriter(os.Stderr, cmd.LogFD)
} else {
- cmd.Cmd.Stdout = logFD
- cmd.Cmd.Stderr = logFD
+ cmd.Cmd.Stdout = cmd.LogFD
+ cmd.Cmd.Stderr = cmd.LogFD
}
err = cmd.Cmd.Start()
if err != nil {
log.WithError(err).Error("cmd.Start() failed")
+ _ = cmd.LogFD.Close()
+ cmd = nil
return
}
diff --git a/xenomint/xxx_test.go b/xenomint/xxx_test.go
index 13a973878..6e19f1b08 100644
--- a/xenomint/xxx_test.go
+++ b/xenomint/xxx_test.go
@@ -22,6 +22,7 @@ import (
"os"
"path"
"sync/atomic"
+
//"runtime/trace"
"sync"
"syscall"
From c9c94e9b20c735ce46d4b8779bf74f4b920c2b7b Mon Sep 17 00:00:00 2001
From: auxten
Date: Tue, 25 Dec 2018 13:33:12 +0800
Subject: [PATCH 142/278] Fix typo
---
rpc/leak_test.go | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/rpc/leak_test.go b/rpc/leak_test.go
index 0ffe4d1e9..5b4a4544d 100644
--- a/rpc/leak_test.go
+++ b/rpc/leak_test.go
@@ -35,7 +35,7 @@ func TestSessionPool_SessionBroken(t *testing.T) {
var err error
err = utils.Build()
if err != nil {
- log.Errorf("build failed: %v", err)
+ t.Errorf("build failed: %v", err)
}
conf.GConf, err = conf.LoadConfig(FJ(testWorkingDir, "./leak/client.yaml"))
if err != nil {
From 6205284d7adc8f0213bbcd005021d26ed43543d8 Mon Sep 17 00:00:00 2001
From: auxten
Date: Tue, 25 Dec 2018 14:51:28 +0800
Subject: [PATCH 143/278] Add ETLS raw socket magic header
---
rpc/client.go | 28 +++++++++++++++++++++++-----
rpc/client_test.go | 8 ++++----
rpc/server.go | 13 +++++++++----
3 files changed, 36 insertions(+), 13 deletions(-)
diff --git a/rpc/client.go b/rpc/client.go
index 0600d8dac..6a0dbea64 100644
--- a/rpc/client.go
+++ b/rpc/client.go
@@ -21,13 +21,20 @@ import (
"net"
"net/rpc"
+ "github.com/pkg/errors"
+ mux "github.com/xtaci/smux"
+
"github.com/CovenantSQL/CovenantSQL/crypto/etls"
+ "github.com/CovenantSQL/CovenantSQL/crypto/hash"
"github.com/CovenantSQL/CovenantSQL/crypto/kms"
"github.com/CovenantSQL/CovenantSQL/pow/cpuminer"
"github.com/CovenantSQL/CovenantSQL/proto"
"github.com/CovenantSQL/CovenantSQL/utils"
"github.com/CovenantSQL/CovenantSQL/utils/log"
- mux "github.com/xtaci/smux"
+)
+
+const (
+ ETLSHeaderSize = 2 + hash.HashBSize + 32
)
// Client is RPC client
@@ -38,6 +45,8 @@ type Client struct {
}
var (
+ // ETLSMagicBytes is the ETLS connection magic header
+ ETLSMagicBytes = []byte{0xC0, 0x4E}
// YamuxConfig holds the default Yamux config
YamuxConfig *mux.Config
// DefaultDialer holds the default dialer of SessionPool
@@ -57,9 +66,12 @@ func dial(network, address string, remoteNodeID *proto.RawNodeID, cipher *etls.C
log.WithField("addr", address).WithError(err).Error("connect to node failed")
return
}
- var writeBuf []byte
+ writeBuf := make([]byte, ETLSHeaderSize)
+ writeBuf[0] = ETLSMagicBytes[0]
+ writeBuf[1] = ETLSMagicBytes[1]
if isAnonymous {
- writeBuf = append(kms.AnonymousRawNodeID.CloneBytes(), (&cpuminer.Uint256{}).Bytes()...)
+ _ = kms.AnonymousRawNodeID.SetBytes(writeBuf[2 : 2+hash.HashSize])
+ copy(writeBuf[2+hash.HashSize:], (&cpuminer.Uint256{}).Bytes())
} else {
// send NodeID + Uint256 Nonce
var nodeIDBytes []byte
@@ -74,14 +86,20 @@ func dial(network, address string, remoteNodeID *proto.RawNodeID, cipher *etls.C
log.WithError(err).Error("get local nonce failed")
return
}
- writeBuf = append(nodeIDBytes, nonce.Bytes()...)
+ copy(writeBuf[2:2+hash.HashSize], nodeIDBytes)
+ copy(writeBuf[2+hash.HashSize:], nonce.Bytes())
}
wrote, err := conn.Write(writeBuf)
- if err != nil || wrote != len(writeBuf) {
+ if err != nil {
log.WithError(err).Error("write node id and nonce failed")
return
}
+ if wrote != ETLSHeaderSize {
+ err = errors.Errorf("write header size not match %d", wrote)
+ return
+ }
+
c = etls.NewConn(conn, cipher, remoteNodeID)
return
}
diff --git a/rpc/client_test.go b/rpc/client_test.go
index 9db547150..ecdf30f1b 100644
--- a/rpc/client_test.go
+++ b/rpc/client_test.go
@@ -39,25 +39,25 @@ func TestDial(t *testing.T) {
var l net.Listener
l, _ = net.Listen("tcp", "127.0.0.1:0")
c, err = dial("tcp", l.Addr().String(), nil, nil, false)
- So(c, ShouldBeNil)
So(err, ShouldNotBeNil)
+ So(c, ShouldBeNil)
kms.SetLocalNodeIDNonce([]byte(nodeID), nil)
c, err = dial("tcp", l.Addr().String(), nil, nil, false)
- So(c, ShouldBeNil)
So(err, ShouldNotBeNil)
+ So(c, ShouldBeNil)
kms.SetLocalNodeIDNonce([]byte(nodeID), &mine.Uint256{A: 1, B: 1, C: 1, D: 1})
c, err = dial("tcp", l.Addr().String(), nil, nil, false)
- So(c, ShouldNotBeNil)
So(err, ShouldBeNil)
+ So(c, ShouldNotBeNil)
go func() {
l.Accept()
}()
c, err = dial("tcp", l.Addr().String(), nil, nil, false)
- So(c, ShouldNotBeNil)
So(err, ShouldBeNil)
+ So(c, ShouldNotBeNil)
})
}
diff --git a/rpc/server.go b/rpc/server.go
index 571203884..18268f385 100644
--- a/rpc/server.go
+++ b/rpc/server.go
@@ -29,6 +29,7 @@ import (
"github.com/CovenantSQL/CovenantSQL/proto"
"github.com/CovenantSQL/CovenantSQL/utils"
"github.com/CovenantSQL/CovenantSQL/utils/log"
+ "github.com/pkg/errors"
mux "github.com/xtaci/smux"
)
@@ -176,18 +177,22 @@ func (s *Server) Stop() {
func handleCipher(conn net.Conn) (cryptoConn *etls.CryptoConn, err error) {
// NodeID + Uint256 Nonce
- headerBuf := make([]byte, hash.HashBSize+32)
+ headerBuf := make([]byte, ETLSHeaderSize)
rCount, err := conn.Read(headerBuf)
- if err != nil || rCount != hash.HashBSize+32 {
+ if err != nil || rCount != ETLSHeaderSize {
log.WithError(err).Error("read node header error")
return
}
+ if headerBuf[0] != ETLSMagicBytes[0] || headerBuf[1] != ETLSMagicBytes[1] {
+ err = errors.New("bad ETLS header")
+ return
+ }
// headerBuf len is hash.HashBSize, so there won't be any error
- idHash, _ := hash.NewHash(headerBuf[:hash.HashBSize])
+ idHash, _ := hash.NewHash(headerBuf[2 : 2+hash.HashBSize])
rawNodeID := &proto.RawNodeID{Hash: *idHash}
// TODO(auxten): compute the nonce and check difficulty
- cpuminer.Uint256FromBytes(headerBuf[hash.HashBSize:])
+ cpuminer.Uint256FromBytes(headerBuf[2+hash.HashBSize:])
symmetricKey, err := GetSharedSecretWith(
rawNodeID,
From 81b7042bc4aaf08596a66fd848db41efe00a67c4 Mon Sep 17 00:00:00 2001
From: zeqing-guo
Date: Tue, 25 Dec 2018 15:34:42 +0800
Subject: [PATCH 144/278] Add billing support
---
blockproducer/chain_service.go | 4 +-
blockproducer/metastate.go | 60 ++--------------
blockproducer/metastate_test.go | 4 +-
cmd/cql-minerd/integration_test.go | 15 ++++
sqlchain/chain.go | 111 +++++++++++++++++++----------
types/request_type_gen.go | 23 ++++--
types/updatebilling.go | 4 +-
worker/db.go | 4 +-
worker/dbms.go | 30 ++++----
9 files changed, 136 insertions(+), 119 deletions(-)
diff --git a/blockproducer/chain_service.go b/blockproducer/chain_service.go
index 20b9c9f6c..ec3788ba3 100644
--- a/blockproducer/chain_service.go
+++ b/blockproducer/chain_service.go
@@ -103,7 +103,9 @@ func (c *Chain) fetchBlockByCount(count uint32) (b *types.BPBlock, height uint32
func (c *Chain) nextNonce(addr proto.AccountAddress) (n pi.AccountNonce, err error) {
c.RLock()
defer c.RUnlock()
- return c.headBranch.preview.nextNonce(addr)
+ n, err = c.headBranch.preview.nextNonce(addr)
+ log.Debugf("nextNonce addr: %s, nonce %d", addr.String(), n)
+ return
}
func (c *Chain) loadAccountCovenantBalance(addr proto.AccountAddress) (balance uint64, ok bool) {
diff --git a/blockproducer/metastate.go b/blockproducer/metastate.go
index 77d1cadfa..9b54bab5b 100644
--- a/blockproducer/metastate.go
+++ b/blockproducer/metastate.go
@@ -283,36 +283,11 @@ func (s *metaState) decreaseAccountToken(k proto.AccountAddress, amount uint64,
}
func (s *metaState) increaseAccountStableBalance(k proto.AccountAddress, amount uint64) error {
- var (
- src, dst *accountObject
- ok bool
- )
- if dst, ok = s.dirty.accounts[k]; !ok {
- if src, ok = s.readonly.accounts[k]; !ok {
- err := errors.Wrap(ErrAccountNotFound, "increase stable balance fail")
- return err
- }
- dst = &accountObject{}
- deepcopier.Copy(&src.Account).To(&dst.Account)
- s.dirty.accounts[k] = dst
- }
- return safeAdd(&dst.Account.TokenBalance[types.Particle], &amount)
+ return s.increaseAccountToken(k, amount, types.Particle)
}
func (s *metaState) decreaseAccountStableBalance(k proto.AccountAddress, amount uint64) error {
- var (
- src, dst *accountObject
- ok bool
- )
- if dst, ok = s.dirty.accounts[k]; !ok {
- if src, ok = s.readonly.accounts[k]; !ok {
- return ErrAccountNotFound
- }
- dst = &accountObject{}
- deepcopier.Copy(&src.Account).To(&dst.Account)
- s.dirty.accounts[k] = dst
- }
- return safeSub(&dst.Account.TokenBalance[types.Particle], &amount)
+ return s.decreaseAccountToken(k, amount, types.Particle)
}
func (s *metaState) transferAccountStableBalance(
@@ -375,36 +350,11 @@ func (s *metaState) transferAccountStableBalance(
}
func (s *metaState) increaseAccountCovenantBalance(k proto.AccountAddress, amount uint64) error {
- var (
- src, dst *accountObject
- ok bool
- )
- if dst, ok = s.dirty.accounts[k]; !ok {
- if src, ok = s.readonly.accounts[k]; !ok {
- err := errors.Wrap(ErrAccountNotFound, "increase covenant balance fail")
- return err
- }
- dst = &accountObject{}
- deepcopier.Copy(&src.Account).To(&dst.Account)
- s.dirty.accounts[k] = dst
- }
- return safeAdd(&dst.Account.TokenBalance[types.Wave], &amount)
+ return s.increaseAccountToken(k, amount, types.Wave)
}
func (s *metaState) decreaseAccountCovenantBalance(k proto.AccountAddress, amount uint64) error {
- var (
- src, dst *accountObject
- ok bool
- )
- if dst, ok = s.dirty.accounts[k]; !ok {
- if src, ok = s.readonly.accounts[k]; !ok {
- return ErrAccountNotFound
- }
- dst = &accountObject{}
- deepcopier.Copy(&src.Account).To(&dst.Account)
- s.dirty.accounts[k] = dst
- }
- return safeSub(&dst.Account.TokenBalance[types.Wave], &amount)
+ return s.decreaseAccountToken(k, amount, types.Wave)
}
func (s *metaState) createSQLChain(addr proto.AccountAddress, id proto.DatabaseID) error {
@@ -820,6 +770,7 @@ func (s *metaState) updateBilling(tx *types.UpdateBilling) (err error) {
err = errors.Wrap(ErrDatabaseNotFound, "update billing failed")
return
}
+ log.Debugf("update billing addr: %s, tx: %v", tx.GetAccountAddress(), tx)
if sqlchainObj.GasPrice == 0 {
return
@@ -835,6 +786,7 @@ func (s *metaState) updateBilling(tx *types.UpdateBilling) (err error) {
userMap = make(map[proto.AccountAddress]map[proto.AccountAddress]uint64)
)
for _, userCost := range tx.Users {
+ log.Debugf("update billing user cost: %s, cost: %d", userCost.User.String(), userCost.Cost)
costMap[userCost.User] = userCost.Cost
if _, ok := userMap[userCost.User]; !ok {
userMap[userCost.User] = make(map[proto.AccountAddress]uint64)
diff --git a/blockproducer/metastate_test.go b/blockproducer/metastate_test.go
index d8b21736f..2d496c6f3 100644
--- a/blockproducer/metastate_test.go
+++ b/blockproducer/metastate_test.go
@@ -317,7 +317,7 @@ func TestMetaState(t *testing.T) {
"The metaState should copy object when stable balance decreased",
func() {
err = ms.decreaseAccountStableBalance(addr3, 1)
- So(err, ShouldEqual, ErrAccountNotFound)
+ So(errors.Cause(err), ShouldEqual, ErrAccountNotFound)
err = ms.decreaseAccountStableBalance(addr1, 1)
So(err, ShouldBeNil)
},
@@ -335,7 +335,7 @@ func TestMetaState(t *testing.T) {
"The metaState should copy object when covenant balance decreased",
func() {
err = ms.decreaseAccountCovenantBalance(addr3, 1)
- So(err, ShouldEqual, ErrAccountNotFound)
+ So(errors.Cause(err), ShouldEqual, ErrAccountNotFound)
err = ms.decreaseAccountCovenantBalance(addr1, 1)
So(err, ShouldBeNil)
},
diff --git a/cmd/cql-minerd/integration_test.go b/cmd/cql-minerd/integration_test.go
index ca45bc482..f490795c5 100644
--- a/cmd/cql-minerd/integration_test.go
+++ b/cmd/cql-minerd/integration_test.go
@@ -577,6 +577,21 @@ func TestFullProcess(t *testing.T) {
c.So(err, ShouldBeNil)
})
+ time.Sleep(20 * time.Second)
+
+ profileReq = &types.QuerySQLChainProfileReq{}
+ profileResp = &types.QuerySQLChainProfileResp{}
+ profileReq.DBID = *dbID
+ err = rpc.RequestBP(route.MCCQuerySQLChainProfile.String(), profileReq, profileResp)
+ So(err, ShouldBeNil)
+ for _, user := range profileResp.Profile.Users {
+ log.Infof("user (%s) left advance payment: %d", user.Address.String(), user.AdvancePayment)
+ So(user.AdvancePayment, ShouldNotEqual, testAdvancePayment)
+ }
+ for _, miner := range profileResp.Profile.Miners {
+ So(miner.PendingIncome != 0 || miner.ReceivedIncome != 0, ShouldBeTrue)
+ }
+
err = db.Close()
So(err, ShouldBeNil)
diff --git a/sqlchain/chain.go b/sqlchain/chain.go
index 3c45bbd22..efdb24208 100644
--- a/sqlchain/chain.go
+++ b/sqlchain/chain.go
@@ -138,6 +138,8 @@ type Chain struct {
//
// pk is the private key of the local miner.
pk *asymmetric.PrivateKey
+ // addr is the AccountAddress generate from public key.
+ addr *proto.AccountAddress
}
// NewChain creates a new sql-chain struct.
@@ -192,11 +194,19 @@ func NewChainWithContext(ctx context.Context, c *Config) (chain *Chain, err erro
}
// Cache local private key
- var pk *asymmetric.PrivateKey
+ var (
+ pk *asymmetric.PrivateKey
+ addr proto.AccountAddress
+ )
if pk, err = kms.GetLocalPrivateKey(); err != nil {
err = errors.Wrap(err, "failed to cache private key")
return
}
+ addr, err = crypto.PubKeyHash(pk.PubKey())
+ if err != nil {
+ log.WithError(err).Warning("failed to generate addr in NewChain")
+ return
+ }
// Create chain state
chain = &Chain{
@@ -222,7 +232,8 @@ func NewChainWithContext(ctx context.Context, c *Config) (chain *Chain, err erro
observerReplicators: make(map[proto.NodeID]*observerReplicator),
replCh: make(chan struct{}),
- pk: pk,
+ pk: pk,
+ addr: &addr,
}
if err = chain.pushBlock(c.Genesis); err != nil {
@@ -269,11 +280,19 @@ func LoadChainWithContext(ctx context.Context, c *Config) (chain *Chain, err err
}
// Cache local private key
- var pk *asymmetric.PrivateKey
+ var (
+ pk *asymmetric.PrivateKey
+ addr proto.AccountAddress
+ )
if pk, err = kms.GetLocalPrivateKey(); err != nil {
err = errors.Wrap(err, "failed to cache private key")
return
}
+ addr, err = crypto.PubKeyHash(pk.PubKey())
+ if err != nil {
+ log.WithError(err).Warning("failed to generate addr in LoadChain")
+ return
+ }
// Create chain state
chain = &Chain{
@@ -299,7 +318,8 @@ func LoadChainWithContext(ctx context.Context, c *Config) (chain *Chain, err err
observerReplicators: make(map[proto.NodeID]*observerReplicator),
replCh: make(chan struct{}),
- pk: pk,
+ pk: pk,
+ addr: &addr,
}
// Read state struct
@@ -888,29 +908,30 @@ func (c *Chain) processBlocks(ctx context.Context) {
if err != nil {
log.WithError(err).Error("billing failed")
}
- go func(ub *types.UpdateBilling) {
- // allocate nonce
- nonceReq := &types.NextAccountNonceReq{}
- nonceResp := &types.NextAccountNonceResp{}
- nonceReq.Addr = ub.Receiver
- if err = rpc.RequestBP(route.MCCNextAccountNonce.String(), nonceReq, nonceResp); err != nil {
- // allocate nonce failed
- log.WithError(err).Warning("allocate nonce for transaction failed")
- return
- }
- ub.Nonce = nonceResp.Nonce
- if err = ub.Sign(c.pk); err != nil {
- log.WithError(err).Warning("sign tx failed")
- return
- }
- addTxReq := types.AddTxReq{}
- addTxResp := types.AddTxResp{}
- addTxReq.Tx = ub
- if err = rpc.RequestBP(route.MCCAddTx.String(), addTxReq, addTxResp); err != nil {
- log.WithError(err).Warning("send tx failed")
- return
- }
- }(ub)
+ // allocate nonce
+ nonceReq := &types.NextAccountNonceReq{}
+ nonceResp := &types.NextAccountNonceResp{}
+ nonceReq.Addr = *c.addr
+ if err = rpc.RequestBP(route.MCCNextAccountNonce.String(), nonceReq, nonceResp); err != nil {
+ // allocate nonce failed
+ log.WithError(err).Warning("allocate nonce for transaction failed")
+ return
+ }
+ ub.Nonce = nonceResp.Nonce
+ if err = ub.Sign(c.pk); err != nil {
+ log.WithError(err).Warning("sign tx failed")
+ return
+ }
+
+ addTxReq := &types.AddTxReq{}
+ addTxResp := &types.AddTxResp{}
+ addTxReq.Tx = ub
+ log.Debugf("nonce in processBlocks: %d, addr: %s",
+ addTxReq.Tx.GetAccountNonce(), addTxReq.Tx.GetAccountAddress())
+ if err = rpc.RequestBP(route.MCCAddTx.String(), addTxReq, addTxResp); err != nil {
+ log.WithError(err).Warning("send tx failed")
+ return
+ }
}
}
}
@@ -1468,6 +1489,7 @@ func (c *Chain) stat() {
}
func (c *Chain) billing(node *blockNode) (ub *types.UpdateBilling, err error) {
+ log.Debugf("begin to billing from count %d", node.count)
var (
i, j uint64
minerAddr proto.AccountAddress
@@ -1477,29 +1499,43 @@ func (c *Chain) billing(node *blockNode) (ub *types.UpdateBilling, err error) {
)
for i = 0; i < c.updatePeriod && node != nil; i++ {
- for _, ack := range node.block.Acks {
- if minerAddr, err = crypto.PubKeyHash(ack.Signee); err != nil {
- err = errors.Wrap(err, "billing fail: miner addr")
+ for _, tx := range node.block.QueryTxs {
+ if minerAddr, err = crypto.PubKeyHash(tx.Response.Signee); err != nil {
+ log.WithError(err).Warning("billing fail: miner addr")
return
}
- if userAddr, err = crypto.PubKeyHash(ack.Signee); err != nil {
- err = errors.Wrap(err, "billing fail: user addr")
+ if userAddr, err = crypto.PubKeyHash(tx.Request.Header.Signee); err != nil {
+ log.WithError(err).Warning("billing fail: miner addr")
return
}
- if ack.SignedRequestHeader().QueryType == types.ReadQuery {
+ if tx.Request.Header.QueryType == types.ReadQuery {
if _, ok := minersMap[userAddr]; !ok {
minersMap[userAddr] = make(map[proto.AccountAddress]uint64)
}
- minersMap[userAddr][minerAddr] += 1
- usersMap[userAddr] += 1
+ minersMap[userAddr][minerAddr] += tx.Response.RowCount
+ usersMap[userAddr] += tx.Response.RowCount
} else {
if _, ok := minersMap[userAddr]; !ok {
minersMap[userAddr] = make(map[proto.AccountAddress]uint64)
}
- minersMap[userAddr][minerAddr] += uint64(ack.SignedResponseHeader().AffectedRows)
- usersMap[userAddr] += uint64(ack.SignedResponseHeader().AffectedRows)
+ minersMap[userAddr][minerAddr] += uint64(tx.Response.AffectedRows)
+ usersMap[userAddr] += uint64(tx.Response.AffectedRows)
+ }
+ }
+
+ for _, req := range node.block.FailedReqs {
+ if minerAddr, err = crypto.PubKeyHash(node.block.Signee()); err != nil {
+ log.WithError(err).Warning("billing fail: miner addr")
+ return
}
+ if userAddr, err = crypto.PubKeyHash(req.Header.Signee); err != nil {
+ log.WithError(err).Warning("billing fail: user addr")
+ return
+ }
+
+ minersMap[userAddr][minerAddr] += uint64(len(req.Payload.Queries))
+ usersMap[userAddr] += uint64(len(req.Payload.Queries))
}
node = node.parent
}
@@ -1511,6 +1547,7 @@ func (c *Chain) billing(node *blockNode) (ub *types.UpdateBilling, err error) {
i = 0
j = 0
for userAddr, cost := range usersMap {
+ log.Debugf("user %s, cost %d", userAddr.String(), cost)
ub.Users[i] = &types.UserCost{
User: userAddr,
Cost: cost,
diff --git a/types/request_type_gen.go b/types/request_type_gen.go
index 709e66bb9..7033d7aa6 100644
--- a/types/request_type_gen.go
+++ b/types/request_type_gen.go
@@ -106,10 +106,20 @@ func (z *Request) MarshalHash() (o []byte, err error) {
o = append(o, 0x83, 0x83, 0x81, 0x81)
o = hsp.AppendArrayHeader(o, uint32(len(z.Payload.Queries)))
for za0001 := range z.Payload.Queries {
- if oTemp, err := z.Payload.Queries[za0001].MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
+ // map header, size 2
+ o = append(o, 0x82, 0x82)
+ o = hsp.AppendString(o, z.Payload.Queries[za0001].Pattern)
+ o = append(o, 0x82)
+ o = hsp.AppendArrayHeader(o, uint32(len(z.Payload.Queries[za0001].Args)))
+ for za0002 := range z.Payload.Queries[za0001].Args {
+ // map header, size 2
+ o = append(o, 0x82, 0x82)
+ o = hsp.AppendString(o, z.Payload.Queries[za0001].Args[za0002].Name)
+ o = append(o, 0x82)
+ o, err = hsp.AppendIntf(o, z.Payload.Queries[za0001].Args[za0002].Value)
+ if err != nil {
+ return
+ }
}
}
// map header, size 2
@@ -138,7 +148,10 @@ func (z *Request) MarshalHash() (o []byte, err error) {
func (z *Request) Msgsize() (s int) {
s = 1 + 8 + 1 + 8 + hsp.ArrayHeaderSize
for za0001 := range z.Payload.Queries {
- s += z.Payload.Queries[za0001].Msgsize()
+ s += 1 + 8 + hsp.StringPrefixSize + len(z.Payload.Queries[za0001].Pattern) + 5 + hsp.ArrayHeaderSize
+ for za0002 := range z.Payload.Queries[za0001].Args {
+ s += 1 + 5 + hsp.StringPrefixSize + len(z.Payload.Queries[za0001].Args[za0002].Name) + 6 + hsp.GuessSize(z.Payload.Queries[za0001].Args[za0002].Value)
+ }
}
s += 7 + 1 + 14 + z.Header.RequestHeader.Msgsize() + 28 + z.Header.DefaultHashSignVerifierImpl.Msgsize() + 9 + z.Envelope.Msgsize()
return
diff --git a/types/updatebilling.go b/types/updatebilling.go
index 0d25a1a2a..366b59378 100644
--- a/types/updatebilling.go
+++ b/types/updatebilling.go
@@ -57,7 +57,7 @@ type UpdateBilling struct {
func NewUpdateBilling(header *UpdateBillingHeader) *UpdateBilling {
return &UpdateBilling{
UpdateBillingHeader: *header,
- TransactionTypeMixin: *pi.NewTransactionTypeMixin(pi.TransactionTypeTransfer),
+ TransactionTypeMixin: *pi.NewTransactionTypeMixin(pi.TransactionTypeUpdateBilling),
}
}
@@ -83,5 +83,5 @@ func (ub *UpdateBilling) Verify() (err error) {
}
func init() {
- pi.RegisterTransaction(pi.TransactionTypeUpdateBilling, (*Transfer)(nil))
+ pi.RegisterTransaction(pi.TransactionTypeUpdateBilling, (*UpdateBilling)(nil))
}
diff --git a/worker/db.go b/worker/db.go
index 4616d7f07..70d1e7281 100644
--- a/worker/db.go
+++ b/worker/db.go
@@ -136,8 +136,8 @@ func NewDatabase(cfg *DBConfig, peers *proto.Peers,
Server: db.nodeID,
// TODO(xq262144): currently using fixed period/resolution from sqlchain test case
- Period: 60 * time.Second,
- Tick: 10 * time.Second,
+ Period: 3 * time.Second,
+ Tick: 1 * time.Second,
QueryTTL: 10,
UpdatePeriod: cfg.UpdatePeriod,
diff --git a/worker/dbms.go b/worker/dbms.go
index ca2d4e9f5..0aee02e41 100644
--- a/worker/dbms.go
+++ b/worker/dbms.go
@@ -210,14 +210,11 @@ func (dbms *DBMS) updateBilling(tx interfaces.Transaction, count uint32) {
return
}
- s, ok := dbms.chainMap.Load(ub.Receiver.DatabaseID())
- if !ok {
- return
- }
-
var (
- dbid = ub.Receiver.DatabaseID()
- state = s.(types.UserState)
+ dbid = ub.Receiver.DatabaseID()
+ newState = types.UserState{
+ State: make(map[proto.AccountAddress]*types.PermStat),
+ }
)
p, err := dbms.busService.RequestSQLProfile(&dbid)
@@ -227,12 +224,12 @@ func (dbms *DBMS) updateBilling(tx interfaces.Transaction, count uint32) {
}
for _, user := range p.Users {
- state.State[user.Address] = &types.PermStat{
+ newState.State[user.Address] = &types.PermStat{
Permission: user.Permission,
Status: user.Status,
}
}
- dbms.chainMap.Store(ub.Receiver.DatabaseID(), state)
+ dbms.chainMap.Store(ub.Receiver.DatabaseID(), newState)
}
func (dbms *DBMS) createDatabase(tx interfaces.Transaction, count uint32) {
@@ -397,13 +394,14 @@ func (dbms *DBMS) Create(instance *types.ServiceInstance, cleanup bool) (err err
// new db
dbCfg := &DBConfig{
- DatabaseID: instance.DatabaseID,
- DataDir: rootDir,
- KayakMux: dbms.kayakMux,
- ChainMux: dbms.chainMux,
- MaxWriteTimeGap: dbms.cfg.MaxReqTimeGap,
- EncryptionKey: instance.ResourceMeta.EncryptionKey,
- SpaceLimit: instance.ResourceMeta.Space,
+ DatabaseID: instance.DatabaseID,
+ DataDir: rootDir,
+ KayakMux: dbms.kayakMux,
+ ChainMux: dbms.chainMux,
+ MaxWriteTimeGap: dbms.cfg.MaxReqTimeGap,
+ EncryptionKey: instance.ResourceMeta.EncryptionKey,
+ SpaceLimit: instance.ResourceMeta.Space,
+ // TODO(lambda): make UpdatePeriod Configurable
UpdatePeriod: 2,
UseEventualConsistency: instance.ResourceMeta.UseEventualConsistency,
ConsistencyLevel: instance.ResourceMeta.ConsistencyLevel,
From bce5f38d09fe03d2680e3d59ec2d48f34e9dd1c8 Mon Sep 17 00:00:00 2001
From: leventeliu
Date: Tue, 25 Dec 2018 15:47:51 +0800
Subject: [PATCH 145/278] Add resource meta to sqlchain profile
---
blockproducer/chain_service.go | 6 ++
blockproducer/rpc.go | 4 +-
sqlchain/chainbusservice.go | 100 ++++++++++++++++++++++++++-------
types/account.go | 2 +
types/bprpc.go | 13 ++++-
worker/dbms.go | 98 +++++++++++++++++++-------------
6 files changed, 162 insertions(+), 61 deletions(-)
diff --git a/blockproducer/chain_service.go b/blockproducer/chain_service.go
index 20b9c9f6c..faf56acf4 100644
--- a/blockproducer/chain_service.go
+++ b/blockproducer/chain_service.go
@@ -129,3 +129,9 @@ func (c *Chain) loadSQLChainProfile(databaseID proto.DatabaseID) (profile *types
profile = &profileObj.SQLChainProfile
return
}
+
+func (c *Chain) loadSQLChainProfiles(addr proto.AccountAddress) []*types.SQLChainProfile {
+ c.RLock()
+ defer c.RUnlock()
+ return c.immutable.loadROSQLChains(addr)
+}
diff --git a/blockproducer/rpc.go b/blockproducer/rpc.go
index f4c4a1117..2ff9c790f 100644
--- a/blockproducer/rpc.go
+++ b/blockproducer/rpc.go
@@ -46,7 +46,8 @@ func (s *ChainRPCService) FetchBlock(req *types.FetchBlockReq, resp *types.Fetch
}
// FetchLastIrreversibleBlock fetches the last block irreversible block from block producer.
-func (s *ChainRPCService) FetchLastIrreversibleBlock(req *types.FetchLastBlockReq, resp *types.FetchBlockResp) error {
+func (s *ChainRPCService) FetchLastIrreversibleBlock(
+ req *types.FetchLastIrreversibleBlockReq, resp *types.FetchLastIrreversibleBlockResp) error {
b, c, h, err := s.chain.fetchLastIrreversibleBlock()
if err != nil {
return err
@@ -54,6 +55,7 @@ func (s *ChainRPCService) FetchLastIrreversibleBlock(req *types.FetchLastBlockRe
resp.Block = b
resp.Count = c
resp.Height = h
+ resp.SQLChains = s.chain.loadSQLChainProfiles(req.Address)
return nil
}
diff --git a/sqlchain/chainbusservice.go b/sqlchain/chainbusservice.go
index bd8640727..5edf39348 100644
--- a/sqlchain/chainbusservice.go
+++ b/sqlchain/chainbusservice.go
@@ -37,29 +37,58 @@ type BusService struct {
caller *rpc.Caller
- lock sync.Mutex // a lock for the map
wg sync.WaitGroup
ctx context.Context
cancel context.CancelFunc
checkInterval time.Duration
- blockCount uint32
+ localAddress proto.AccountAddress
+
+ lock sync.Mutex // a lock for the map
+ blockCount uint32
+ sqlChainProfiles map[proto.DatabaseID]*types.SQLChainProfile
}
-func NewBusService(ctx context.Context, checkInterval time.Duration) *BusService {
+func NewBusService(
+ ctx context.Context, addr proto.AccountAddress, checkInterval time.Duration) (_ *BusService,
+) {
ctd, ccl := context.WithCancel(ctx)
bs := &BusService{
Bus: chainbus.New(),
- lock: sync.Mutex{},
wg: sync.WaitGroup{},
caller: rpc.NewCaller(),
ctx: ctd,
cancel: ccl,
checkInterval: checkInterval,
+ localAddress: addr,
}
+ // State initialization: fetch last block and update fields `blockCount` and `sqlChainProfiles`
+ var _, profiles, count = bs.requestLastBlock()
+ bs.updateState(count, profiles)
return bs
}
+func (bs *BusService) GetCurrentDBMapping() (dbMap map[proto.DatabaseID]*types.SQLChainProfile) {
+ dbMap = make(map[proto.DatabaseID]*types.SQLChainProfile)
+ bs.lock.Lock()
+ defer bs.lock.Unlock()
+ for k, v := range bs.sqlChainProfiles {
+ dbMap[k] = v
+ }
+ return
+}
+
+func (bs *BusService) updateState(count uint32, profiles []*types.SQLChainProfile) {
+ bs.lock.Lock()
+ defer bs.lock.Unlock()
+ var rebuilt = make(map[proto.DatabaseID]*types.SQLChainProfile)
+ for _, v := range profiles {
+ rebuilt[v.ID] = v
+ }
+ atomic.StoreUint32(&bs.blockCount, count)
+ bs.sqlChainProfiles = rebuilt
+}
+
func (bs *BusService) subscribeBlock(ctx context.Context) {
defer bs.wg.Done()
@@ -73,25 +102,62 @@ func (bs *BusService) subscribeBlock(ctx context.Context) {
// fetch block from remote block producer
c := atomic.LoadUint32(&bs.blockCount)
log.Debugf("fetch block in count: %d", c)
- b, newCount := bs.requestLastBlock()
+ b, profiles, newCount := bs.requestLastBlock()
if b == nil {
continue
}
- if newCount == c {
+ if newCount <= c {
continue
}
+
log.Debugf("success fetch block in count: %d, block hash: %s, number of block tx: %d",
c, b.BlockHash().String(), len(b.GetTxHashes()))
+
+ // Write sqlchain profile state first (bound to the last irreversible block)
+ bs.updateState(c, profiles)
+
+ // Fetch any intermediate irreversible blocks and extract txs
+ for i := c + 1; i < newCount; i++ {
+ var (
+ block *types.BPBlock
+ err error
+ )
+ if block, err = bs.fetchBlockByCount(i); err != nil {
+ log.WithError(err).WithFields(log.Fields{
+ "count": i,
+ }).Warn("failed to fetch block")
+ continue
+ }
+ bs.extractTxs(block, i)
+ }
+
+ // Extract txs in last irreversible block
bs.extractTxs(b, c)
- atomic.StoreUint32(&bs.blockCount, newCount)
}
}
+}
+func (bs *BusService) fetchBlockByCount(count uint32) (block *types.BPBlock, err error) {
+ var (
+ req = &types.FetchBlockByCountReq{
+ Count: count,
+ }
+ resp = &types.FetchBlockResp{}
+ )
+ if err = bs.requestBP(route.MCCFetchBlockByCount.String(), req, resp); err != nil {
+ return
+ }
+ block = resp.Block
+ return
}
-func (bs *BusService) requestLastBlock() (block *types.BPBlock, count uint32) {
- req := &types.FetchLastBlockReq{}
- resp := &types.FetchBlockResp{}
+func (bs *BusService) requestLastBlock() (
+ block *types.BPBlock, profiles []*types.SQLChainProfile, count uint32,
+) {
+ req := &types.FetchLastIrreversibleBlockReq{
+ Address: bs.localAddress,
+ }
+ resp := &types.FetchLastIrreversibleBlockResp{}
if err := bs.requestBP(route.MCCFetchLastIrreversibleBlock.String(), req, resp); err != nil {
log.WithError(err).Warning("fetch last block failed")
@@ -99,19 +165,15 @@ func (bs *BusService) requestLastBlock() (block *types.BPBlock, count uint32) {
}
block = resp.Block
+ profiles = resp.SQLChains
count = resp.Count
return
}
-func (bs *BusService) RequestSQLProfile(dbid *proto.DatabaseID) (p *types.SQLChainProfile, err error) {
- req := &types.QuerySQLChainProfileReq{DBID: *dbid}
- resp := &types.QuerySQLChainProfileResp{}
- if err = bs.requestBP(route.MCCQuerySQLChainProfile.String(), req, resp); err != nil {
- log.WithError(err).Warning("fetch sqlchain profile failed")
- return
- }
-
- p = &resp.Profile
+func (bs *BusService) RequestSQLProfile(dbid *proto.DatabaseID) (p *types.SQLChainProfile, ok bool) {
+ bs.lock.Lock()
+ defer bs.lock.Unlock()
+ p, ok = bs.sqlChainProfiles[*dbid]
return
}
diff --git a/types/account.go b/types/account.go
index 8d14af879..51a1e488f 100644
--- a/types/account.go
+++ b/types/account.go
@@ -134,6 +134,8 @@ type SQLChainProfile struct {
Users []*SQLChainUser
Genesis *Block
+
+ Meta ResourceMeta // dumped from db creation tx
}
// ProviderProfile defines a provider list.
diff --git a/types/bprpc.go b/types/bprpc.go
index 71a748ff7..786996d60 100644
--- a/types/bprpc.go
+++ b/types/bprpc.go
@@ -57,8 +57,19 @@ type FetchBlockResp struct {
Block *BPBlock
}
-type FetchLastBlockReq struct {
+// FetchLastIrreversibleBlockReq defines a request of the FetchLastIrreversibleBlock RPC method.
+type FetchLastIrreversibleBlockReq struct {
proto.Envelope
+ Address proto.AccountAddress
+}
+
+// FetchLastIrreversibleBlockResp defines a response of the FetchLastIrreversibleBlock RPC method.
+type FetchLastIrreversibleBlockResp struct {
+ proto.Envelope
+ Count uint32
+ Height uint32
+ Block *BPBlock
+ SQLChains []*SQLChainProfile
}
// FetchBlockByCountReq define a request of the FetchBlockByCount RPC method.
diff --git a/worker/dbms.go b/worker/dbms.go
index ca2d4e9f5..3917b087e 100644
--- a/worker/dbms.go
+++ b/worker/dbms.go
@@ -83,11 +83,6 @@ func NewDBMS(cfg *DBMSConfig) (dbms *DBMS, err error) {
return
}
- // init chain bus service
- ctx := context.Background()
- bs := sqlchain.NewBusService(ctx, CheckInterval)
- dbms.busService = bs
-
// cache address of node
var (
pk *asymmetric.PublicKey
@@ -103,6 +98,11 @@ func NewDBMS(cfg *DBMSConfig) (dbms *DBMS, err error) {
}
dbms.address = addr
+ // init chain bus service
+ ctx := context.Background()
+ bs := sqlchain.NewBusService(ctx, addr, CheckInterval)
+ dbms.busService = bs
+
// private key cache
dbms.privKey, err = kms.GetLocalPrivateKey()
if err != nil {
@@ -112,7 +112,6 @@ func NewDBMS(cfg *DBMSConfig) (dbms *DBMS, err error) {
// init service
dbms.rpc = NewDBMSRPCService(route.DBRPCName, cfg.Server, dbms)
-
return
}
@@ -173,11 +172,7 @@ func (dbms *DBMS) Init() (err error) {
}
// load current peers info from block producer
- var dbMapping []types.ServiceInstance
- if dbMapping, err = dbms.getMappedInstances(); err != nil {
- err = errors.Wrap(err, "get mapped instances failed")
- return
- }
+ var dbMapping = dbms.busService.GetCurrentDBMapping()
// init database
if err = dbms.initDatabases(localMeta, dbMapping); err != nil {
@@ -220,9 +215,11 @@ func (dbms *DBMS) updateBilling(tx interfaces.Transaction, count uint32) {
state = s.(types.UserState)
)
- p, err := dbms.busService.RequestSQLProfile(&dbid)
- if err != nil {
- log.WithError(err).Warning("failed to call bp")
+ p, ok := dbms.busService.RequestSQLProfile(&dbid)
+ if !ok {
+ log.WithFields(log.Fields{
+ "databaseid": dbid,
+ }).Warning("database profile not found")
return
}
@@ -248,9 +245,11 @@ func (dbms *DBMS) createDatabase(tx interfaces.Transaction, count uint32) {
dbid = proto.FromAccountAndNonce(cd.Owner, uint32(cd.Nonce))
isTargetMiner = false
)
- p, err := dbms.busService.RequestSQLProfile(dbid)
- if err != nil {
- log.WithError(err).Warning("failed to call bp")
+ p, ok := dbms.busService.RequestSQLProfile(dbid)
+ if !ok {
+ log.WithFields(log.Fields{
+ "databaseid": &dbid,
+ }).Warning("database profile not found")
return
}
@@ -276,36 +275,49 @@ func (dbms *DBMS) createDatabase(tx interfaces.Transaction, count uint32) {
}
}
- peers := proto.Peers{
+ var si, err = dbms.buildSQLChainServiceInstance(p)
+ if err != nil {
+ log.WithError(err).Warn("failed to build sqlchain service instance from profile")
+ }
+ err = dbms.Create(si, true)
+ if err != nil {
+ log.WithError(err).Error("create database error")
+ }
+ dbms.chainMap.Store(*dbid, *state)
+}
+
+func (dbms *DBMS) buildSQLChainServiceInstance(
+ profile *types.SQLChainProfile) (instance *types.ServiceInstance, err error,
+) {
+ var (
+ nodeids = make([]proto.NodeID, len(profile.Miners))
+ peers *proto.Peers
+ )
+ for i, v := range profile.Miners {
+ nodeids[i] = v.NodeID
+ }
+ peers = &proto.Peers{
PeersHeader: proto.PeersHeader{
- Leader: nodeIDs[0],
- Servers: nodeIDs[:],
+ Leader: nodeids[0],
+ Servers: nodeids[:],
},
}
if dbms.privKey == nil {
- dbms.privKey, err = kms.GetLocalPrivateKey()
- if err != nil {
+ if dbms.privKey, err = kms.GetLocalPrivateKey(); err != nil {
log.WithError(err).Warning("get private key failed in createDatabase")
return
}
}
- err = peers.Sign(dbms.privKey)
- if err != nil {
- log.WithError(err).Warning("sign peers failed in createDatabase")
+ if err = peers.Sign(dbms.privKey); err != nil {
return
}
-
- si := types.ServiceInstance{
- DatabaseID: *dbid,
- Peers: &peers,
- ResourceMeta: cd.ResourceMeta,
- GenesisBlock: p.Genesis,
- }
- err = dbms.Create(&si, true)
- if err != nil {
- log.WithError(err).Error("create database error")
+ instance = &types.ServiceInstance{
+ DatabaseID: profile.ID,
+ Peers: peers,
+ ResourceMeta: profile.Meta,
+ GenesisBlock: profile.Genesis,
}
- dbms.chainMap.Store(*dbid, *state)
+ return
}
func (dbms *DBMS) updatePermission(tx interfaces.Transaction, count uint32) {
@@ -337,12 +349,18 @@ func (dbms *DBMS) UpdatePermission(dbid proto.DatabaseID, user proto.AccountAddr
return
}
-func (dbms *DBMS) initDatabases(meta *DBMSMeta, conf []types.ServiceInstance) (err error) {
+func (dbms *DBMS) initDatabases(
+ meta *DBMSMeta, profiles map[proto.DatabaseID]*types.SQLChainProfile) (err error,
+) {
currentInstance := make(map[proto.DatabaseID]bool)
- for _, instanceConf := range conf {
- currentInstance[instanceConf.DatabaseID] = true
- if err = dbms.Create(&instanceConf, false); err != nil {
+ for id, profile := range profiles {
+ currentInstance[id] = true
+ var instance *types.ServiceInstance
+ if instance, err = dbms.buildSQLChainServiceInstance(profile); err != nil {
+ return
+ }
+ if err = dbms.Create(instance, false); err != nil {
return
}
}
From 597120423ba1b693a59fd63d53a6b6c145d8ddce Mon Sep 17 00:00:00 2001
From: leventeliu
Date: Tue, 25 Dec 2018 15:52:38 +0800
Subject: [PATCH 146/278] Update generated files
---
types/account_gen.go | 30 ++++++++++++++++++------------
types/no_ack_report_type_gen.go | 21 ++-------------------
types/request_type_gen.go | 23 ++++++++++++++++++-----
3 files changed, 38 insertions(+), 36 deletions(-)
diff --git a/types/account_gen.go b/types/account_gen.go
index 239aa9912..d3665ac94 100644
--- a/types/account_gen.go
+++ b/types/account_gen.go
@@ -154,8 +154,8 @@ func (z *ProviderProfile) Msgsize() (s int) {
func (z *SQLChainProfile) MarshalHash() (o []byte, err error) {
var b []byte
o = hsp.Require(b, z.Msgsize())
- // map header, size 10
- o = append(o, 0x8a, 0x8a)
+ // map header, size 11
+ o = append(o, 0x8b, 0x8b)
if z.Genesis == nil {
o = hsp.AppendNil(o)
} else {
@@ -165,13 +165,19 @@ func (z *SQLChainProfile) MarshalHash() (o []byte, err error) {
o = hsp.AppendBytes(o, oTemp)
}
}
- o = append(o, 0x8a)
+ o = append(o, 0x8b)
+ if oTemp, err := z.Meta.MarshalHash(); err != nil {
+ return nil, err
+ } else {
+ o = hsp.AppendBytes(o, oTemp)
+ }
+ o = append(o, 0x8b)
if oTemp, err := z.TokenType.MarshalHash(); err != nil {
return nil, err
} else {
o = hsp.AppendBytes(o, oTemp)
}
- o = append(o, 0x8a)
+ o = append(o, 0x8b)
o = hsp.AppendArrayHeader(o, uint32(len(z.Miners)))
for za0001 := range z.Miners {
if z.Miners[za0001] == nil {
@@ -184,7 +190,7 @@ func (z *SQLChainProfile) MarshalHash() (o []byte, err error) {
}
}
}
- o = append(o, 0x8a)
+ o = append(o, 0x8b)
o = hsp.AppendArrayHeader(o, uint32(len(z.Users)))
for za0002 := range z.Users {
if z.Users[za0002] == nil {
@@ -197,29 +203,29 @@ func (z *SQLChainProfile) MarshalHash() (o []byte, err error) {
}
}
}
- o = append(o, 0x8a)
+ o = append(o, 0x8b)
if oTemp, err := z.Owner.MarshalHash(); err != nil {
return nil, err
} else {
o = hsp.AppendBytes(o, oTemp)
}
- o = append(o, 0x8a)
+ o = append(o, 0x8b)
if oTemp, err := z.Address.MarshalHash(); err != nil {
return nil, err
} else {
o = hsp.AppendBytes(o, oTemp)
}
- o = append(o, 0x8a)
+ o = append(o, 0x8b)
if oTemp, err := z.ID.MarshalHash(); err != nil {
return nil, err
} else {
o = hsp.AppendBytes(o, oTemp)
}
- o = append(o, 0x8a)
+ o = append(o, 0x8b)
o = hsp.AppendUint32(o, z.LastUpdatedHeight)
- o = append(o, 0x8a)
+ o = append(o, 0x8b)
o = hsp.AppendUint64(o, z.Period)
- o = append(o, 0x8a)
+ o = append(o, 0x8b)
o = hsp.AppendUint64(o, z.GasPrice)
return
}
@@ -232,7 +238,7 @@ func (z *SQLChainProfile) Msgsize() (s int) {
} else {
s += z.Genesis.Msgsize()
}
- s += 10 + z.TokenType.Msgsize() + 7 + hsp.ArrayHeaderSize
+ s += 5 + z.Meta.Msgsize() + 10 + z.TokenType.Msgsize() + 7 + hsp.ArrayHeaderSize
for za0001 := range z.Miners {
if z.Miners[za0001] == nil {
s += hsp.NilSize
diff --git a/types/no_ack_report_type_gen.go b/types/no_ack_report_type_gen.go
index 374a39fea..e9e89abc6 100644
--- a/types/no_ack_report_type_gen.go
+++ b/types/no_ack_report_type_gen.go
@@ -57,24 +57,7 @@ func (z *AggrNoAckReportHeader) MarshalHash() (o []byte, err error) {
o = append(o, 0x84)
o = hsp.AppendArrayHeader(o, uint32(len(z.Reports)))
for za0001 := range z.Reports {
- // map header, size 2
- // map header, size 3
- o = append(o, 0x82, 0x82, 0x83, 0x83)
- if oTemp, err := z.Reports[za0001].NoAckReportHeader.NodeID.MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
- }
- o = append(o, 0x83)
- o = hsp.AppendTime(o, z.Reports[za0001].NoAckReportHeader.Timestamp)
- o = append(o, 0x83)
- if oTemp, err := z.Reports[za0001].NoAckReportHeader.Response.MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
- }
- o = append(o, 0x82)
- if oTemp, err := z.Reports[za0001].DefaultHashSignVerifierImpl.MarshalHash(); err != nil {
+ if oTemp, err := z.Reports[za0001].MarshalHash(); err != nil {
return nil, err
} else {
o = hsp.AppendBytes(o, oTemp)
@@ -101,7 +84,7 @@ func (z *AggrNoAckReportHeader) Msgsize() (s int) {
}
s += 8 + hsp.ArrayHeaderSize
for za0001 := range z.Reports {
- s += 1 + 18 + 1 + 7 + z.Reports[za0001].NoAckReportHeader.NodeID.Msgsize() + 10 + hsp.TimeSize + 9 + z.Reports[za0001].NoAckReportHeader.Response.Msgsize() + 28 + z.Reports[za0001].DefaultHashSignVerifierImpl.Msgsize()
+ s += z.Reports[za0001].Msgsize()
}
s += 7 + z.NodeID.Msgsize() + 10 + hsp.TimeSize
return
diff --git a/types/request_type_gen.go b/types/request_type_gen.go
index 709e66bb9..7033d7aa6 100644
--- a/types/request_type_gen.go
+++ b/types/request_type_gen.go
@@ -106,10 +106,20 @@ func (z *Request) MarshalHash() (o []byte, err error) {
o = append(o, 0x83, 0x83, 0x81, 0x81)
o = hsp.AppendArrayHeader(o, uint32(len(z.Payload.Queries)))
for za0001 := range z.Payload.Queries {
- if oTemp, err := z.Payload.Queries[za0001].MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
+ // map header, size 2
+ o = append(o, 0x82, 0x82)
+ o = hsp.AppendString(o, z.Payload.Queries[za0001].Pattern)
+ o = append(o, 0x82)
+ o = hsp.AppendArrayHeader(o, uint32(len(z.Payload.Queries[za0001].Args)))
+ for za0002 := range z.Payload.Queries[za0001].Args {
+ // map header, size 2
+ o = append(o, 0x82, 0x82)
+ o = hsp.AppendString(o, z.Payload.Queries[za0001].Args[za0002].Name)
+ o = append(o, 0x82)
+ o, err = hsp.AppendIntf(o, z.Payload.Queries[za0001].Args[za0002].Value)
+ if err != nil {
+ return
+ }
}
}
// map header, size 2
@@ -138,7 +148,10 @@ func (z *Request) MarshalHash() (o []byte, err error) {
func (z *Request) Msgsize() (s int) {
s = 1 + 8 + 1 + 8 + hsp.ArrayHeaderSize
for za0001 := range z.Payload.Queries {
- s += z.Payload.Queries[za0001].Msgsize()
+ s += 1 + 8 + hsp.StringPrefixSize + len(z.Payload.Queries[za0001].Pattern) + 5 + hsp.ArrayHeaderSize
+ for za0002 := range z.Payload.Queries[za0001].Args {
+ s += 1 + 5 + hsp.StringPrefixSize + len(z.Payload.Queries[za0001].Args[za0002].Name) + 6 + hsp.GuessSize(z.Payload.Queries[za0001].Args[za0002].Value)
+ }
}
s += 7 + 1 + 14 + z.Header.RequestHeader.Msgsize() + 28 + z.Header.DefaultHashSignVerifierImpl.Msgsize() + 9 + z.Envelope.Msgsize()
return
From f208e2126663afb49ce7da2f1a0d9ceca278b8bc Mon Sep 17 00:00:00 2001
From: auxten
Date: Tue, 25 Dec 2018 16:32:33 +0800
Subject: [PATCH 147/278] Mute kayak apply log
---
kayak/runtime.go | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/kayak/runtime.go b/kayak/runtime.go
index 1858a803f..ed8476bd4 100644
--- a/kayak/runtime.go
+++ b/kayak/runtime.go
@@ -288,7 +288,7 @@ func (r *Runtime) Apply(ctx context.Context, req interface{}) (result interface{
} else if !tmRollback.Before(tmStart) {
fields["t"] = tmRollback.Sub(tmStart).Nanoseconds()
}
- log.WithFields(fields).WithError(err).Info("kayak leader apply")
+ log.WithFields(fields).WithError(err).Debug("kayak leader apply")
}()
r.peersLock.RLock()
@@ -419,7 +419,7 @@ func (r *Runtime) FollowerApply(l *kt.Log) (err error) {
"t": l.Type.String(),
"i": l.Index,
"c": tmEnd.Sub(tmStart).Nanoseconds(),
- }).WithError(err).Info("kayak follower apply")
+ }).WithError(err).Debug("kayak follower apply")
}()
r.peersLock.RLock()
From 80262aa7d515310a54de7b009e20021d828fdaa1 Mon Sep 17 00:00:00 2001
From: auxten
Date: Tue, 25 Dec 2018 16:33:09 +0800
Subject: [PATCH 148/278] Add encrypted magic header for ETLS
---
crypto/etls/conn.go | 32 +++++++++++++++++++++++++-------
crypto/etls/encrypt.go | 13 +++++--------
rpc/client.go | 8 +++-----
rpc/server.go | 2 +-
4 files changed, 34 insertions(+), 21 deletions(-)
diff --git a/crypto/etls/conn.go b/crypto/etls/conn.go
index d3c81359d..150d85a3e 100644
--- a/crypto/etls/conn.go
+++ b/crypto/etls/conn.go
@@ -24,10 +24,17 @@ import (
"net"
"time"
+ "github.com/pkg/errors"
+
"github.com/CovenantSQL/CovenantSQL/proto"
"github.com/CovenantSQL/CovenantSQL/utils/log"
)
+var (
+ // ETLSMagicBytes is the ETLS connection magic header
+ ETLSMagicBytes = []byte{0xC0, 0x4E}
+)
+
// CryptoConn implements net.Conn and Cipher interface
type CryptoConn struct {
net.Conn
@@ -65,17 +72,24 @@ func (c *CryptoConn) RawRead(b []byte) (n int, err error) {
// Read iv and Encrypted data
func (c *CryptoConn) Read(b []byte) (n int, err error) {
if c.decStream == nil {
- iv := make([]byte, c.info.ivLen)
- if _, err = io.ReadFull(c.Conn, iv); err != nil {
+ buf := make([]byte, c.info.ivLen+len(ETLSMagicBytes))
+ if _, err = io.ReadFull(c.Conn, buf); err != nil {
log.WithError(err).Info("read full failed")
return
}
+ iv := buf[:c.info.ivLen]
+ header := buf[c.info.ivLen:]
if err = c.initDecrypt(iv); err != nil {
return
}
if len(c.iv) == 0 {
c.iv = iv
}
+ c.decrypt(header, header)
+ if header[0] != ETLSMagicBytes[0] || header[1] != ETLSMagicBytes[1] {
+ err = errors.New("bad stream ETLS header")
+ return
+ }
}
cipherData := make([]byte, len(b))
@@ -105,16 +119,20 @@ func (c *CryptoConn) Write(b []byte) (n int, err error) {
}
}
- dataSize := len(b) + len(iv)
- cipherData := make([]byte, dataSize)
-
if iv != nil {
+ ivHeader := make([]byte, len(iv)+len(ETLSMagicBytes))
// Put initialization vector in buffer, do a single write to send both
// iv and data.
- copy(cipherData, iv)
+ copy(ivHeader, iv)
+ c.encrypt(ivHeader[len(iv):], ETLSMagicBytes)
+ _, err = c.Conn.Write(ivHeader)
+ if err != nil {
+ return
+ }
}
- c.encrypt(cipherData[len(iv):], b)
+ cipherData := make([]byte, len(b))
+ c.encrypt(cipherData, b)
n, err = c.Conn.Write(cipherData)
return
}
diff --git a/crypto/etls/encrypt.go b/crypto/etls/encrypt.go
index 0eba7f8e4..c50fd9249 100644
--- a/crypto/etls/encrypt.go
+++ b/crypto/etls/encrypt.go
@@ -23,7 +23,6 @@ import (
"io"
"github.com/CovenantSQL/CovenantSQL/crypto/hash"
- ec "github.com/btcsuite/btcd/btcec"
)
// KeyDerivation .according to ANSI X9.63 we should do a key derivation before using
@@ -83,13 +82,11 @@ type cipherInfo struct {
// Cipher struct keeps cipher mode, key, iv
type Cipher struct {
- encStream cipher.Stream
- decStream cipher.Stream
- publicKey ec.PublicKey
- privateKey ec.PrivateKey
- key []byte
- info *cipherInfo
- iv []byte
+ encStream cipher.Stream
+ decStream cipher.Stream
+ key []byte
+ info *cipherInfo
+ iv []byte
}
// NewCipher creates a cipher that can be used in Dial(), Listen() etc.
diff --git a/rpc/client.go b/rpc/client.go
index 6a0dbea64..44e2d1b9b 100644
--- a/rpc/client.go
+++ b/rpc/client.go
@@ -45,8 +45,6 @@ type Client struct {
}
var (
- // ETLSMagicBytes is the ETLS connection magic header
- ETLSMagicBytes = []byte{0xC0, 0x4E}
// YamuxConfig holds the default Yamux config
YamuxConfig *mux.Config
// DefaultDialer holds the default dialer of SessionPool
@@ -67,10 +65,10 @@ func dial(network, address string, remoteNodeID *proto.RawNodeID, cipher *etls.C
return
}
writeBuf := make([]byte, ETLSHeaderSize)
- writeBuf[0] = ETLSMagicBytes[0]
- writeBuf[1] = ETLSMagicBytes[1]
+ writeBuf[0] = etls.ETLSMagicBytes[0]
+ writeBuf[1] = etls.ETLSMagicBytes[1]
if isAnonymous {
- _ = kms.AnonymousRawNodeID.SetBytes(writeBuf[2 : 2+hash.HashSize])
+ copy(writeBuf[2:], kms.AnonymousRawNodeID.AsBytes())
copy(writeBuf[2+hash.HashSize:], (&cpuminer.Uint256{}).Bytes())
} else {
// send NodeID + Uint256 Nonce
diff --git a/rpc/server.go b/rpc/server.go
index 18268f385..30d1291e7 100644
--- a/rpc/server.go
+++ b/rpc/server.go
@@ -183,7 +183,7 @@ func handleCipher(conn net.Conn) (cryptoConn *etls.CryptoConn, err error) {
log.WithError(err).Error("read node header error")
return
}
- if headerBuf[0] != ETLSMagicBytes[0] || headerBuf[1] != ETLSMagicBytes[1] {
+ if headerBuf[0] != etls.ETLSMagicBytes[0] || headerBuf[1] != etls.ETLSMagicBytes[1] {
err = errors.New("bad ETLS header")
return
}
From af41f29df503aa5e73eb6128b67fc8b4b36b177b Mon Sep 17 00:00:00 2001
From: auxten
Date: Tue, 25 Dec 2018 16:56:52 +0800
Subject: [PATCH 149/278] Add comment for golint
---
rpc/client.go | 1 +
1 file changed, 1 insertion(+)
diff --git a/rpc/client.go b/rpc/client.go
index 44e2d1b9b..4afb91055 100644
--- a/rpc/client.go
+++ b/rpc/client.go
@@ -34,6 +34,7 @@ import (
)
const (
+ // ETLSHeaderSize is the header size with ETLSHeader + NodeID + Nonce
ETLSHeaderSize = 2 + hash.HashBSize + 32
)
From eba1cb8c4840278afa325ba16458ad8f29bd64bb Mon Sep 17 00:00:00 2001
From: zeqing-guo
Date: Tue, 25 Dec 2018 16:59:18 +0800
Subject: [PATCH 150/278] Fix data race in loadSQLChainProfile metastete.go
---
blockproducer/metastate.go | 21 ++++++++-------------
blockproducer/metastate_test.go | 3 ---
cmd/cql-adapter/storage/sqlite3.go | 1 -
cmd/cql-faucet/persistence.go | 1 -
cmd/cql-minerd/main.go | 1 -
crypto/hash/hashfuncs.go | 1 -
rpc/pool_test.go | 5 ++---
storage/storage.go | 1 -
xenomint/xxx_test.go | 1 -
9 files changed, 10 insertions(+), 25 deletions(-)
diff --git a/blockproducer/metastate.go b/blockproducer/metastate.go
index 3fe77a9d5..0d9cbd7f8 100644
--- a/blockproducer/metastate.go
+++ b/blockproducer/metastate.go
@@ -148,16 +148,19 @@ func (s *metaState) storeBaseAccount(k proto.AccountAddress, v *accountObject) (
func (s *metaState) loadSQLChainObject(k proto.DatabaseID) (o *sqlchainObject, loaded bool) {
var old *sqlchainObject
- o = new(sqlchainObject)
if old, loaded = s.dirty.databases[k]; loaded {
- if o == nil {
+ if old == nil {
loaded = false
+ return
}
- deepcopier.Copy(old).To(o)
+ o = new(sqlchainObject)
+ deepcopier.Copy(&old.SQLChainProfile).To(&o.SQLChainProfile)
return
}
if old, loaded = s.readonly.databases[k]; loaded {
- deepcopier.Copy(old).To(o)
+ o = new(sqlchainObject)
+ deepcopier.Copy(&old.SQLChainProfile).To(&o.SQLChainProfile)
+ return
}
return
}
@@ -725,6 +728,7 @@ func (s *metaState) updatePermission(tx *types.UpdatePermission) (err error) {
} else {
so.Users[targetUserIndex].Permission = tx.Permission
}
+ s.dirty.databases[tx.TargetSQLChain.DatabaseID()] = so
return
}
@@ -834,15 +838,6 @@ func (s *metaState) loadROSQLChains(addr proto.AccountAddress) (dbs []*types.SQL
return
}
-func (s *metaState) loadROSQLChainsByDatabaseID(dbid proto.DatabaseID) (db *types.SQLChainProfile, ok bool) {
- var databaseObj *sqlchainObject
- db = &types.SQLChainProfile{}
- if databaseObj, ok = s.readonly.databases[dbid]; ok {
- deepcopier.Copy(databaseObj).To(db)
- }
- return
-}
-
func (s *metaState) applyTransaction(tx pi.Transaction) (err error) {
switch t := tx.(type) {
case *types.Transfer:
diff --git a/blockproducer/metastate_test.go b/blockproducer/metastate_test.go
index ce720d8fd..2e876dacf 100644
--- a/blockproducer/metastate_test.go
+++ b/blockproducer/metastate_test.go
@@ -202,11 +202,8 @@ func TestMetaState(t *testing.T) {
var dbs []*types.SQLChainProfile
dbs = ms.loadROSQLChains(addr1)
So(len(dbs), ShouldEqual, 1)
- So(dbs[0].ID, ShouldEqual, dbid1)
dbs = ms.loadROSQLChains(addr2)
So(len(dbs), ShouldEqual, 2)
- So(dbs[0].ID, ShouldEqual, dbid1)
- So(dbs[1].ID, ShouldEqual, dbid2)
dbs = ms.loadROSQLChains(addr4)
So(dbs, ShouldBeEmpty)
})
diff --git a/cmd/cql-adapter/storage/sqlite3.go b/cmd/cql-adapter/storage/sqlite3.go
index d9be539d8..aac13f94d 100644
--- a/cmd/cql-adapter/storage/sqlite3.go
+++ b/cmd/cql-adapter/storage/sqlite3.go
@@ -24,7 +24,6 @@ import (
"math/rand"
"os"
"path/filepath"
-
// Import sqlite3 manually.
_ "github.com/CovenantSQL/go-sqlite3-encrypt"
)
diff --git a/cmd/cql-faucet/persistence.go b/cmd/cql-faucet/persistence.go
index 140a6c6d6..dfdc3d458 100644
--- a/cmd/cql-faucet/persistence.go
+++ b/cmd/cql-faucet/persistence.go
@@ -26,7 +26,6 @@ import (
"github.com/CovenantSQL/CovenantSQL/conf"
"github.com/CovenantSQL/CovenantSQL/utils/log"
uuid "github.com/satori/go.uuid"
-
// Load sqlite3 database driver.
_ "github.com/CovenantSQL/go-sqlite3-encrypt"
)
diff --git a/cmd/cql-minerd/main.go b/cmd/cql-minerd/main.go
index 8bdb88863..db032512b 100644
--- a/cmd/cql-minerd/main.go
+++ b/cmd/cql-minerd/main.go
@@ -26,7 +26,6 @@ import (
"os"
"os/signal"
"runtime"
-
//"runtime/trace"
"syscall"
"time"
diff --git a/crypto/hash/hashfuncs.go b/crypto/hash/hashfuncs.go
index af14cf46d..d3cd98561 100644
--- a/crypto/hash/hashfuncs.go
+++ b/crypto/hash/hashfuncs.go
@@ -19,7 +19,6 @@ package hash
import (
"encoding/binary"
"hash/fnv"
-
// "crypto/sha256" benchmark is at least 10% faster on
// i7-4870HQ CPU @ 2.50GHz than "github.com/minio/sha256-simd"
"crypto/sha256"
diff --git a/rpc/pool_test.go b/rpc/pool_test.go
index 80912aa8d..6cac13b3b 100644
--- a/rpc/pool_test.go
+++ b/rpc/pool_test.go
@@ -22,12 +22,11 @@ import (
"sync"
"testing"
- . "github.com/smartystreets/goconvey/convey"
- mux "github.com/xtaci/smux"
-
"github.com/CovenantSQL/CovenantSQL/proto"
"github.com/CovenantSQL/CovenantSQL/utils"
"github.com/CovenantSQL/CovenantSQL/utils/log"
+ . "github.com/smartystreets/goconvey/convey"
+ mux "github.com/xtaci/smux"
)
const (
diff --git a/storage/storage.go b/storage/storage.go
index e059819af..7e36bad0e 100644
--- a/storage/storage.go
+++ b/storage/storage.go
@@ -26,7 +26,6 @@ import (
"github.com/CovenantSQL/CovenantSQL/twopc"
"github.com/CovenantSQL/CovenantSQL/utils/log"
-
// Register CovenantSQL/go-sqlite3-encrypt engine.
_ "github.com/CovenantSQL/go-sqlite3-encrypt"
)
diff --git a/xenomint/xxx_test.go b/xenomint/xxx_test.go
index 6e19f1b08..13a973878 100644
--- a/xenomint/xxx_test.go
+++ b/xenomint/xxx_test.go
@@ -22,7 +22,6 @@ import (
"os"
"path"
"sync/atomic"
-
//"runtime/trace"
"sync"
"syscall"
From 61e25fc4e7a8a19ce29565114d6eff6e121f1cdd Mon Sep 17 00:00:00 2001
From: zeqing-guo
Date: Tue, 25 Dec 2018 17:15:11 +0800
Subject: [PATCH 151/278] Use valid Database ID in test case
---
sqlchain/chain_test.go | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/sqlchain/chain_test.go b/sqlchain/chain_test.go
index 6006d106a..2a030d5ef 100644
--- a/sqlchain/chain_test.go
+++ b/sqlchain/chain_test.go
@@ -28,6 +28,7 @@ import (
"github.com/CovenantSQL/CovenantSQL/conf"
"github.com/CovenantSQL/CovenantSQL/consistent"
+ "github.com/CovenantSQL/CovenantSQL/crypto/hash"
"github.com/CovenantSQL/CovenantSQL/crypto/kms"
"github.com/CovenantSQL/CovenantSQL/metric"
"github.com/CovenantSQL/CovenantSQL/proto"
@@ -37,14 +38,14 @@ import (
)
var (
- testPeersNumber = 5
- testPeriod = 1 * time.Second
- testTick = 100 * time.Millisecond
- testQueryTTL int32 = 10
- testDatabaseID proto.DatabaseID = "tdb-test"
- testPeriodNumber int32 = 10
- testClientNumberPerChain = 3
- testUpdatePeriod uint64 = 2
+ testPeersNumber = 5
+ testPeriod = 1 * time.Second
+ testTick = 100 * time.Millisecond
+ testQueryTTL int32 = 10
+ testDatabaseID = proto.DatabaseID(hash.THashH([]byte{'d', 'b'}).String())
+ testPeriodNumber int32 = 10
+ testClientNumberPerChain = 3
+ testUpdatePeriod uint64 = 2
)
type chainParams struct {
From f604d3fed906f4c91a74301fbe92334565897fe0 Mon Sep 17 00:00:00 2001
From: zeqing-guo
Date: Tue, 25 Dec 2018 17:41:59 +0800
Subject: [PATCH 152/278] Change period of producing block
---
blockproducer/metastate.go | 2 +-
blockproducer/metastate_test.go | 4 ++--
cmd/cqld/bootstrap.go | 4 ++--
conf/config.go | 2 +-
worker/db.go | 4 ++--
worker/dbms.go | 3 ++-
6 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/blockproducer/metastate.go b/blockproducer/metastate.go
index 0d9cbd7f8..f5ddc221a 100644
--- a/blockproducer/metastate.go
+++ b/blockproducer/metastate.go
@@ -562,7 +562,7 @@ func (s *metaState) matchProvidersWithUser(tx *types.CreateDatabase) (err error)
var (
minAdvancePayment = uint64(tx.GasPrice) * uint64(conf.GConf.QPS) *
- uint64(conf.GConf.Period) * uint64(len(tx.ResourceMeta.TargetMiners))
+ uint64(conf.GConf.UpdatePeriod) * uint64(len(tx.ResourceMeta.TargetMiners))
)
if tx.AdvancePayment < minAdvancePayment {
err = ErrInsufficientAdvancePayment
diff --git a/blockproducer/metastate_test.go b/blockproducer/metastate_test.go
index 2e876dacf..4f3f6c662 100644
--- a/blockproducer/metastate_test.go
+++ b/blockproducer/metastate_test.go
@@ -667,7 +667,7 @@ func TestMetaState(t *testing.T) {
TargetMiners: []proto.AccountAddress{addr2},
},
GasPrice: 1,
- AdvancePayment: uint64(conf.GConf.QPS) * uint64(conf.GConf.Period) * 1,
+ AdvancePayment: uint64(conf.GConf.QPS) * uint64(conf.GConf.UpdatePeriod) * 1,
TokenType: types.Particle,
Nonce: 1,
},
@@ -768,7 +768,7 @@ func TestMetaState(t *testing.T) {
b2, loaded = ms.loadAccountStableBalance(addr1)
So(loaded, ShouldBeTrue)
minAdvancePayment := uint64(cd2.GasPrice) * uint64(conf.GConf.QPS) *
- uint64(conf.GConf.Period) * uint64(len(cd2.ResourceMeta.TargetMiners))
+ uint64(conf.GConf.UpdatePeriod) * uint64(len(cd2.ResourceMeta.TargetMiners))
So(b1-b2, ShouldEqual, cd1.AdvancePayment+minAdvancePayment)
dbID := proto.FromAccountAndNonce(cd1.Owner, uint32(cd1.Nonce))
co, loaded = ms.loadSQLChainObject(*dbID)
diff --git a/cmd/cqld/bootstrap.go b/cmd/cqld/bootstrap.go
index f2f7971d4..a47fa382e 100644
--- a/cmd/cqld/bootstrap.go
+++ b/cmd/cqld/bootstrap.go
@@ -153,8 +153,8 @@ func runNode(nodeID proto.NodeID, listenAddr string) (err error) {
server,
peers,
nodeID,
- 3*time.Second,
- 1*time.Second,
+ 60*time.Second,
+ 20*time.Second,
conf.GConf.QPS,
)
chain, err := bp.NewChain(chainConfig)
diff --git a/conf/config.go b/conf/config.go
index aa6a97fbc..6f1f60dd6 100644
--- a/conf/config.go
+++ b/conf/config.go
@@ -136,7 +136,7 @@ type Config struct {
SeedBPNodes []proto.Node `yaml:"-"`
QPS uint32 `yaml:"QPS"`
- Period uint32 `yaml:"Period"` // Period is for sql chain miners syncing billing with main chain
+ UpdatePeriod uint32 `yaml:"Period"` // UpdatePeriod is for sql chain miners syncing billing with main chain
MinProviderDeposit uint64 `yaml:"MinProviderDeposit"`
}
diff --git a/worker/db.go b/worker/db.go
index 70d1e7281..2b843b334 100644
--- a/worker/db.go
+++ b/worker/db.go
@@ -136,8 +136,8 @@ func NewDatabase(cfg *DBConfig, peers *proto.Peers,
Server: db.nodeID,
// TODO(xq262144): currently using fixed period/resolution from sqlchain test case
- Period: 3 * time.Second,
- Tick: 1 * time.Second,
+ Period: 60 * time.Second,
+ Tick: 20 * time.Second,
QueryTTL: 10,
UpdatePeriod: cfg.UpdatePeriod,
diff --git a/worker/dbms.go b/worker/dbms.go
index d428b98f1..c982eca6e 100644
--- a/worker/dbms.go
+++ b/worker/dbms.go
@@ -26,6 +26,7 @@ import (
"time"
"github.com/CovenantSQL/CovenantSQL/blockproducer/interfaces"
+ "github.com/CovenantSQL/CovenantSQL/conf"
"github.com/CovenantSQL/CovenantSQL/crypto"
"github.com/CovenantSQL/CovenantSQL/crypto/asymmetric"
"github.com/CovenantSQL/CovenantSQL/crypto/kms"
@@ -420,7 +421,7 @@ func (dbms *DBMS) Create(instance *types.ServiceInstance, cleanup bool) (err err
EncryptionKey: instance.ResourceMeta.EncryptionKey,
SpaceLimit: instance.ResourceMeta.Space,
// TODO(lambda): make UpdatePeriod Configurable
- UpdatePeriod: 2,
+ UpdatePeriod: uint64(conf.GConf.UpdatePeriod),
UseEventualConsistency: instance.ResourceMeta.UseEventualConsistency,
ConsistencyLevel: instance.ResourceMeta.ConsistencyLevel,
}
From e0eb736ed3bdeffdd43afef0e994574b666ff53d Mon Sep 17 00:00:00 2001
From: leventeliu
Date: Tue, 25 Dec 2018 18:19:38 +0800
Subject: [PATCH 153/278] Remove unused codes
---
worker/dbms.go | 24 ------------------------
1 file changed, 24 deletions(-)
diff --git a/worker/dbms.go b/worker/dbms.go
index d428b98f1..ddf493527 100644
--- a/worker/dbms.go
+++ b/worker/dbms.go
@@ -31,7 +31,6 @@ import (
"github.com/CovenantSQL/CovenantSQL/crypto/kms"
"github.com/CovenantSQL/CovenantSQL/proto"
"github.com/CovenantSQL/CovenantSQL/route"
- "github.com/CovenantSQL/CovenantSQL/rpc"
"github.com/CovenantSQL/CovenantSQL/sqlchain"
"github.com/CovenantSQL/CovenantSQL/types"
"github.com/CovenantSQL/CovenantSQL/utils"
@@ -535,29 +534,6 @@ func (dbms *DBMS) removeMeta(dbID proto.DatabaseID) (err error) {
return dbms.writeMeta()
}
-func (dbms *DBMS) getMappedInstances() (instances []types.ServiceInstance, err error) {
- var bpNodeID proto.NodeID
- if bpNodeID, err = rpc.GetCurrentBP(); err != nil {
- return
- }
-
- req := &types.InitService{}
- res := new(types.InitServiceResponse)
-
- if err = rpc.NewCaller().CallNode(bpNodeID, route.BPDBGetNodeDatabases.String(), req, res); err != nil {
- return
- }
-
- // verify response
- if err = res.Verify(); err != nil {
- return
- }
-
- instances = res.Header.Instances
-
- return
-}
-
func (dbms *DBMS) checkPermission(addr proto.AccountAddress, req *types.Request) (err error) {
log.Debugf("in checkPermission, database id: %s, user addr: %s", req.Header.DatabaseID, addr.String())
state, loaded := dbms.chainMap.Load(req.Header.DatabaseID)
From 62de3cbb7d08dc79dd200b30fdf17e54d3f28a76 Mon Sep 17 00:00:00 2001
From: zeqing-guo
Date: Tue, 25 Dec 2018 18:24:06 +0800
Subject: [PATCH 154/278] Make SQLChain quit safely
---
sqlchain/chain.go | 3 ---
1 file changed, 3 deletions(-)
diff --git a/sqlchain/chain.go b/sqlchain/chain.go
index efdb24208..7f73e4947 100644
--- a/sqlchain/chain.go
+++ b/sqlchain/chain.go
@@ -915,12 +915,10 @@ func (c *Chain) processBlocks(ctx context.Context) {
if err = rpc.RequestBP(route.MCCNextAccountNonce.String(), nonceReq, nonceResp); err != nil {
// allocate nonce failed
log.WithError(err).Warning("allocate nonce for transaction failed")
- return
}
ub.Nonce = nonceResp.Nonce
if err = ub.Sign(c.pk); err != nil {
log.WithError(err).Warning("sign tx failed")
- return
}
addTxReq := &types.AddTxReq{}
@@ -930,7 +928,6 @@ func (c *Chain) processBlocks(ctx context.Context) {
addTxReq.Tx.GetAccountNonce(), addTxReq.Tx.GetAccountAddress())
if err = rpc.RequestBP(route.MCCAddTx.String(), addTxReq, addTxResp); err != nil {
log.WithError(err).Warning("send tx failed")
- return
}
}
}
From cdb5da0c3ca5e70633a6a328e72a337c79e27cac Mon Sep 17 00:00:00 2001
From: zeqing-guo
Date: Tue, 25 Dec 2018 19:21:56 +0800
Subject: [PATCH 155/278] Use shorter period for test
---
cmd/cqld/bootstrap.go | 4 ++--
test/integration/node_0/config.yaml | 2 +-
test/integration/node_1/config.yaml | 2 +-
test/integration/node_2/config.yaml | 2 +-
test/integration/node_c/config.yaml | 2 +-
test/integration/node_miner_0/config.yaml | 2 +-
test/integration/node_miner_1/config.yaml | 2 +-
test/integration/node_miner_2/config.yaml | 2 +-
worker/db.go | 4 ++--
9 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/cmd/cqld/bootstrap.go b/cmd/cqld/bootstrap.go
index a47fa382e..f2f7971d4 100644
--- a/cmd/cqld/bootstrap.go
+++ b/cmd/cqld/bootstrap.go
@@ -153,8 +153,8 @@ func runNode(nodeID proto.NodeID, listenAddr string) (err error) {
server,
peers,
nodeID,
- 60*time.Second,
- 20*time.Second,
+ 3*time.Second,
+ 1*time.Second,
conf.GConf.QPS,
)
chain, err := bp.NewChain(chainConfig)
diff --git a/test/integration/node_0/config.yaml b/test/integration/node_0/config.yaml
index f71a9060c..d251a2e70 100644
--- a/test/integration/node_0/config.yaml
+++ b/test/integration/node_0/config.yaml
@@ -6,7 +6,7 @@ DHTFileName: "dht.db"
ListenAddr: "127.0.0.1:3122"
ThisNodeID: "00000bef611d346c0cbe1beaa76e7f0ed705a194fdf9ac3a248ec70e9c198bf9"
QPS: 1000
-Period: 3600
+Period: 2
MinProviderDeposit: 1000000
ValidDNSKeys:
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
diff --git a/test/integration/node_1/config.yaml b/test/integration/node_1/config.yaml
index 48d12a7e8..303441e1b 100644
--- a/test/integration/node_1/config.yaml
+++ b/test/integration/node_1/config.yaml
@@ -6,7 +6,7 @@ DHTFileName: "dht.db"
ListenAddr: "127.0.0.1:3121"
ThisNodeID: "00000381d46fd6cf7742d7fb94e2422033af989c0e348b5781b3219599a3af35"
QPS: 1000
-Period: 3600
+Period: 2
MinProviderDeposit: 1000000
ValidDNSKeys:
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
diff --git a/test/integration/node_2/config.yaml b/test/integration/node_2/config.yaml
index 291d754aa..ad88b23a0 100644
--- a/test/integration/node_2/config.yaml
+++ b/test/integration/node_2/config.yaml
@@ -6,7 +6,7 @@ DHTFileName: "dht.db"
ListenAddr: "127.0.0.1:3120"
ThisNodeID: "000000172580063ded88e010556b0aca2851265be8845b1ef397e8fce6ab5582"
QPS: 1000
-Period: 3600
+Period: 2
MinProviderDeposit: 1000000
ValidDNSKeys:
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
diff --git a/test/integration/node_c/config.yaml b/test/integration/node_c/config.yaml
index a151c72b9..d6ee71d47 100644
--- a/test/integration/node_c/config.yaml
+++ b/test/integration/node_c/config.yaml
@@ -6,7 +6,7 @@ DHTFileName: "dht.db"
ListenAddr: "127.0.0.1:3120"
ThisNodeID: "00000f3b43288fe99831eb533ab77ec455d13e11fc38ec35a42d4edd17aa320d"
QPS: 1000
-Period: 3600
+Period: 2
MinProviderDeposit: 1000000
ValidDNSKeys:
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
diff --git a/test/integration/node_miner_0/config.yaml b/test/integration/node_miner_0/config.yaml
index 15c5b8e9d..ae7e54b7a 100644
--- a/test/integration/node_miner_0/config.yaml
+++ b/test/integration/node_miner_0/config.yaml
@@ -6,7 +6,7 @@ DHTFileName: "dht.db"
ListenAddr: "127.0.0.1:2144"
ThisNodeID: "000005aa62048f85da4ae9698ed59c14ec0d48a88a07c15a32265634e7e64ade"
QPS: 1000
-Period: 3600
+Period: 2
MinProviderDeposit: 1000000
ValidDNSKeys:
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
diff --git a/test/integration/node_miner_1/config.yaml b/test/integration/node_miner_1/config.yaml
index 2beba3311..f0532cc34 100644
--- a/test/integration/node_miner_1/config.yaml
+++ b/test/integration/node_miner_1/config.yaml
@@ -6,7 +6,7 @@ DHTFileName: "dht.db"
ListenAddr: "127.0.0.1:2145"
ThisNodeID: "000005f4f22c06f76c43c4f48d5a7ec1309cc94030cbf9ebae814172884ac8b5"
QPS: 1000
-Period: 3600
+Period: 2
MinProviderDeposit: 1000000
ValidDNSKeys:
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
diff --git a/test/integration/node_miner_2/config.yaml b/test/integration/node_miner_2/config.yaml
index 5249fba42..14057643b 100644
--- a/test/integration/node_miner_2/config.yaml
+++ b/test/integration/node_miner_2/config.yaml
@@ -6,7 +6,7 @@ DHTFileName: "dht.db"
ListenAddr: "127.0.0.1:2146"
ThisNodeID: "000003f49592f83d0473bddb70d543f1096b4ffed5e5f942a3117e256b7052b8"
QPS: 1000
-Period: 3600
+Period: 2
MinProviderDeposit: 1000000
ValidDNSKeys:
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
diff --git a/worker/db.go b/worker/db.go
index 2b843b334..70d1e7281 100644
--- a/worker/db.go
+++ b/worker/db.go
@@ -136,8 +136,8 @@ func NewDatabase(cfg *DBConfig, peers *proto.Peers,
Server: db.nodeID,
// TODO(xq262144): currently using fixed period/resolution from sqlchain test case
- Period: 60 * time.Second,
- Tick: 20 * time.Second,
+ Period: 3 * time.Second,
+ Tick: 1 * time.Second,
QueryTTL: 10,
UpdatePeriod: cfg.UpdatePeriod,
From f5705812c295a7b251981ab81049ba7a426a2f14 Mon Sep 17 00:00:00 2001
From: leventeliu
Date: Tue, 25 Dec 2018 20:16:23 +0800
Subject: [PATCH 156/278] Fix fetch new block count
---
sqlchain/chainbusservice.go | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/sqlchain/chainbusservice.go b/sqlchain/chainbusservice.go
index 5edf39348..848a711d8 100644
--- a/sqlchain/chainbusservice.go
+++ b/sqlchain/chainbusservice.go
@@ -110,11 +110,15 @@ func (bs *BusService) subscribeBlock(ctx context.Context) {
continue
}
- log.Debugf("success fetch block in count: %d, block hash: %s, number of block tx: %d",
- c, b.BlockHash().String(), len(b.GetTxHashes()))
+ log.WithFields(log.Fields{
+ "last_count": c,
+ "new_count": newCount,
+ "block_hash": b.BlockHash().Short(4),
+ "tx_num": len(b.Transactions),
+ }).Debug("success fetch block")
// Write sqlchain profile state first (bound to the last irreversible block)
- bs.updateState(c, profiles)
+ bs.updateState(newCount, profiles)
// Fetch any intermediate irreversible blocks and extract txs
for i := c + 1; i < newCount; i++ {
From f44f256bcd6b3d23ca18d93b5365bee41008632d Mon Sep 17 00:00:00 2001
From: auxten
Date: Tue, 25 Dec 2018 20:32:48 +0800
Subject: [PATCH 157/278] Remove duplicated DNSKEY
---
cmd/cql-adapter/storage/sqlite3.go | 1 +
cmd/cql-faucet/persistence.go | 1 +
cmd/cql-minerd/integration_test.go | 2 +-
cmd/cql-minerd/main.go | 1 +
crypto/hash/hashfuncs.go | 1 +
storage/storage.go | 1 +
test/GNTE/conf/node_0/config.yaml | 1 -
test/GNTE/conf/node_1/config.yaml | 1 -
test/GNTE/conf/node_2/config.yaml | 1 -
test/GNTE/conf/node_c/config.yaml | 1 -
test/GNTE/conf/node_miner_10.250.100.2/config.yaml | 1 -
test/GNTE/conf/node_miner_10.250.100.3/config.yaml | 1 -
test/GNTE/conf/node_miner_10.250.100.4/config.yaml | 1 -
test/GNTE/conf/node_miner_10.250.100.5/config.yaml | 1 -
test/GNTE/conf/node_miner_10.250.100.6/config.yaml | 1 -
test/GNTE/conf/node_miner_10.250.100.7/config.yaml | 1 -
test/GNTE/conf/node_miner_10.250.100.8/config.yaml | 1 -
test/GNTE/conf/node_miner_10.250.100.9/config.yaml | 1 -
test/bootstrap.yaml | 1 -
test/fuse/node_0/config.yaml | 1 -
test/fuse/node_1/config.yaml | 1 -
test/fuse/node_2/config.yaml | 1 -
test/fuse/node_c/config.yaml | 1 -
test/fuse/node_miner_0/config.yaml | 1 -
test/fuse/node_miner_1/config.yaml | 1 -
test/fuse/node_miner_2/config.yaml | 1 -
test/integration/node_0/config.yaml | 1 -
test/integration/node_1/config.yaml | 1 -
test/integration/node_2/config.yaml | 1 -
test/integration/node_c/config.yaml | 1 -
test/integration/node_miner_0/config.yaml | 1 -
test/integration/node_miner_1/config.yaml | 1 -
test/integration/node_miner_2/config.yaml | 1 -
test/leak/client.yaml | 1 -
test/leak/leader.yaml | 1 -
test/mainchain/node_0/config.yaml | 1 -
test/mainchain/node_1/config.yaml | 1 -
test/mainchain/node_2/config.yaml | 1 -
test/mainchain/node_c/config.yaml | 1 -
test/mainchain/node_miner_0/config.yaml | 1 -
test/mainchain/node_miner_1/config.yaml | 1 -
test/mainchain/node_miner_2/config.yaml | 1 -
test/mainchain/node_multi_0/config.yaml | 1 -
test/mainchain/node_multi_1/config.yaml | 1 -
test/mainchain/node_multi_2/config.yaml | 1 -
test/mainchain/node_standalone/config.yaml | 1 -
test/node_0/config.yaml | 1 -
test/node_1/config.yaml | 1 -
test/node_2/config.yaml | 1 -
test/node_c/config.yaml | 1 -
test/node_standalone/config.yaml | 1 -
test/node_standalone/config2.yaml | 1 -
test/observation/node_0/config.yaml | 1 -
test/observation/node_1/config.yaml | 1 -
test/observation/node_2/config.yaml | 1 -
test/observation/node_c/config.yaml | 1 -
test/observation/node_miner_0/config.yaml | 1 -
test/observation/node_miner_1/config.yaml | 1 -
test/observation/node_miner_2/config.yaml | 1 -
test/observation/node_observer/config.yaml | 1 -
test/pool/client.yaml | 1 -
test/pool/leader.yaml | 1 -
test/service/node_0/config.yaml | 1 -
test/service/node_1/config.yaml | 1 -
test/service/node_2/config.yaml | 1 -
test/service/node_adapter/config.yaml | 1 -
test/service/node_c/config.yaml | 1 -
test/service/node_miner_0/config.yaml | 1 -
test/service/node_miner_1/config.yaml | 1 -
test/service/node_miner_2/config.yaml | 1 -
test/service/node_mysql_adapter/config.yaml | 1 -
test/service/node_observer/config.yaml | 1 -
worker/db.go | 1 +
xenomint/xxx_test.go | 1 +
74 files changed, 8 insertions(+), 67 deletions(-)
diff --git a/cmd/cql-adapter/storage/sqlite3.go b/cmd/cql-adapter/storage/sqlite3.go
index aac13f94d..d9be539d8 100644
--- a/cmd/cql-adapter/storage/sqlite3.go
+++ b/cmd/cql-adapter/storage/sqlite3.go
@@ -24,6 +24,7 @@ import (
"math/rand"
"os"
"path/filepath"
+
// Import sqlite3 manually.
_ "github.com/CovenantSQL/go-sqlite3-encrypt"
)
diff --git a/cmd/cql-faucet/persistence.go b/cmd/cql-faucet/persistence.go
index dfdc3d458..140a6c6d6 100644
--- a/cmd/cql-faucet/persistence.go
+++ b/cmd/cql-faucet/persistence.go
@@ -26,6 +26,7 @@ import (
"github.com/CovenantSQL/CovenantSQL/conf"
"github.com/CovenantSQL/CovenantSQL/utils/log"
uuid "github.com/satori/go.uuid"
+
// Load sqlite3 database driver.
_ "github.com/CovenantSQL/go-sqlite3-encrypt"
)
diff --git a/cmd/cql-minerd/integration_test.go b/cmd/cql-minerd/integration_test.go
index f490795c5..f98bfc23a 100644
--- a/cmd/cql-minerd/integration_test.go
+++ b/cmd/cql-minerd/integration_test.go
@@ -46,7 +46,7 @@ import (
"github.com/CovenantSQL/CovenantSQL/types"
"github.com/CovenantSQL/CovenantSQL/utils"
"github.com/CovenantSQL/CovenantSQL/utils/log"
- "github.com/CovenantSQL/go-sqlite3-encrypt"
+ sqlite3 "github.com/CovenantSQL/go-sqlite3-encrypt"
. "github.com/smartystreets/goconvey/convey"
)
diff --git a/cmd/cql-minerd/main.go b/cmd/cql-minerd/main.go
index db032512b..8bdb88863 100644
--- a/cmd/cql-minerd/main.go
+++ b/cmd/cql-minerd/main.go
@@ -26,6 +26,7 @@ import (
"os"
"os/signal"
"runtime"
+
//"runtime/trace"
"syscall"
"time"
diff --git a/crypto/hash/hashfuncs.go b/crypto/hash/hashfuncs.go
index d3cd98561..af14cf46d 100644
--- a/crypto/hash/hashfuncs.go
+++ b/crypto/hash/hashfuncs.go
@@ -19,6 +19,7 @@ package hash
import (
"encoding/binary"
"hash/fnv"
+
// "crypto/sha256" benchmark is at least 10% faster on
// i7-4870HQ CPU @ 2.50GHz than "github.com/minio/sha256-simd"
"crypto/sha256"
diff --git a/storage/storage.go b/storage/storage.go
index 7e36bad0e..e059819af 100644
--- a/storage/storage.go
+++ b/storage/storage.go
@@ -26,6 +26,7 @@ import (
"github.com/CovenantSQL/CovenantSQL/twopc"
"github.com/CovenantSQL/CovenantSQL/utils/log"
+
// Register CovenantSQL/go-sqlite3-encrypt engine.
_ "github.com/CovenantSQL/go-sqlite3-encrypt"
)
diff --git a/test/GNTE/conf/node_0/config.yaml b/test/GNTE/conf/node_0/config.yaml
index 576b10bf9..d689c9c56 100644
--- a/test/GNTE/conf/node_0/config.yaml
+++ b/test/GNTE/conf/node_0/config.yaml
@@ -9,7 +9,6 @@ QPS: 1000
Period: 3600
MinProviderDeposit: 1000000
ValidDNSKeys:
- oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
diff --git a/test/GNTE/conf/node_1/config.yaml b/test/GNTE/conf/node_1/config.yaml
index b672abc57..135a64a76 100644
--- a/test/GNTE/conf/node_1/config.yaml
+++ b/test/GNTE/conf/node_1/config.yaml
@@ -9,7 +9,6 @@ QPS: 1000
Period: 3600
MinProviderDeposit: 1000000
ValidDNSKeys:
- oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
diff --git a/test/GNTE/conf/node_2/config.yaml b/test/GNTE/conf/node_2/config.yaml
index d068d944f..2bb986350 100644
--- a/test/GNTE/conf/node_2/config.yaml
+++ b/test/GNTE/conf/node_2/config.yaml
@@ -9,7 +9,6 @@ QPS: 1000
Period: 3600
MinProviderDeposit: 1000000
ValidDNSKeys:
- oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
diff --git a/test/GNTE/conf/node_c/config.yaml b/test/GNTE/conf/node_c/config.yaml
index f38a50661..5a8343104 100644
--- a/test/GNTE/conf/node_c/config.yaml
+++ b/test/GNTE/conf/node_c/config.yaml
@@ -9,7 +9,6 @@ QPS: 1000
Period: 3600
MinProviderDeposit: 1000000
ValidDNSKeys:
- oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
diff --git a/test/GNTE/conf/node_miner_10.250.100.2/config.yaml b/test/GNTE/conf/node_miner_10.250.100.2/config.yaml
index def018666..a0725a050 100644
--- a/test/GNTE/conf/node_miner_10.250.100.2/config.yaml
+++ b/test/GNTE/conf/node_miner_10.250.100.2/config.yaml
@@ -9,7 +9,6 @@ QPS: 1000
Period: 3600
MinProviderDeposit: 1000000
ValidDNSKeys:
- oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
diff --git a/test/GNTE/conf/node_miner_10.250.100.3/config.yaml b/test/GNTE/conf/node_miner_10.250.100.3/config.yaml
index f758486f7..c364e088a 100644
--- a/test/GNTE/conf/node_miner_10.250.100.3/config.yaml
+++ b/test/GNTE/conf/node_miner_10.250.100.3/config.yaml
@@ -9,7 +9,6 @@ QPS: 1000
Period: 3600
MinProviderDeposit: 1000000
ValidDNSKeys:
- oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
diff --git a/test/GNTE/conf/node_miner_10.250.100.4/config.yaml b/test/GNTE/conf/node_miner_10.250.100.4/config.yaml
index b298cb0ca..21d80f03f 100644
--- a/test/GNTE/conf/node_miner_10.250.100.4/config.yaml
+++ b/test/GNTE/conf/node_miner_10.250.100.4/config.yaml
@@ -9,7 +9,6 @@ QPS: 1000
Period: 3600
MinProviderDeposit: 1000000
ValidDNSKeys:
- oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
diff --git a/test/GNTE/conf/node_miner_10.250.100.5/config.yaml b/test/GNTE/conf/node_miner_10.250.100.5/config.yaml
index 4a78082b9..c11af5241 100755
--- a/test/GNTE/conf/node_miner_10.250.100.5/config.yaml
+++ b/test/GNTE/conf/node_miner_10.250.100.5/config.yaml
@@ -9,7 +9,6 @@ QPS: 1000
Period: 3600
MinProviderDeposit: 1000000
ValidDNSKeys:
- oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
diff --git a/test/GNTE/conf/node_miner_10.250.100.6/config.yaml b/test/GNTE/conf/node_miner_10.250.100.6/config.yaml
index 85e9c1434..d31b0bd99 100755
--- a/test/GNTE/conf/node_miner_10.250.100.6/config.yaml
+++ b/test/GNTE/conf/node_miner_10.250.100.6/config.yaml
@@ -9,7 +9,6 @@ QPS: 1000
Period: 3600
MinProviderDeposit: 1000000
ValidDNSKeys:
- oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
diff --git a/test/GNTE/conf/node_miner_10.250.100.7/config.yaml b/test/GNTE/conf/node_miner_10.250.100.7/config.yaml
index e42674f29..2f7765d91 100755
--- a/test/GNTE/conf/node_miner_10.250.100.7/config.yaml
+++ b/test/GNTE/conf/node_miner_10.250.100.7/config.yaml
@@ -9,7 +9,6 @@ QPS: 1000
Period: 3600
MinProviderDeposit: 1000000
ValidDNSKeys:
- oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
diff --git a/test/GNTE/conf/node_miner_10.250.100.8/config.yaml b/test/GNTE/conf/node_miner_10.250.100.8/config.yaml
index 68c895838..f159fb3a2 100755
--- a/test/GNTE/conf/node_miner_10.250.100.8/config.yaml
+++ b/test/GNTE/conf/node_miner_10.250.100.8/config.yaml
@@ -9,7 +9,6 @@ QPS: 1000
Period: 3600
MinProviderDeposit: 1000000
ValidDNSKeys:
- oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
diff --git a/test/GNTE/conf/node_miner_10.250.100.9/config.yaml b/test/GNTE/conf/node_miner_10.250.100.9/config.yaml
index 3df879bff..dc4779563 100755
--- a/test/GNTE/conf/node_miner_10.250.100.9/config.yaml
+++ b/test/GNTE/conf/node_miner_10.250.100.9/config.yaml
@@ -9,7 +9,6 @@ QPS: 1000
Period: 3600
MinProviderDeposit: 1000000
ValidDNSKeys:
- oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
diff --git a/test/bootstrap.yaml b/test/bootstrap.yaml
index 9877c2653..52597a10e 100644
--- a/test/bootstrap.yaml
+++ b/test/bootstrap.yaml
@@ -9,7 +9,6 @@ QPS: 1000
Period: 3600
MinProviderDeposit: 1000000
ValidDNSKeys:
- oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
diff --git a/test/fuse/node_0/config.yaml b/test/fuse/node_0/config.yaml
index dd78ee413..d31d7fcbd 100644
--- a/test/fuse/node_0/config.yaml
+++ b/test/fuse/node_0/config.yaml
@@ -9,7 +9,6 @@ QPS: 1000
Period: 3600
MinProviderDeposit: 1000000
ValidDNSKeys:
- oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
diff --git a/test/fuse/node_1/config.yaml b/test/fuse/node_1/config.yaml
index 29fba3add..e8d1a2d9f 100644
--- a/test/fuse/node_1/config.yaml
+++ b/test/fuse/node_1/config.yaml
@@ -9,7 +9,6 @@ QPS: 1000
Period: 3600
MinProviderDeposit: 1000000
ValidDNSKeys:
- oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
diff --git a/test/fuse/node_2/config.yaml b/test/fuse/node_2/config.yaml
index c04ec8aa6..a25a254b4 100644
--- a/test/fuse/node_2/config.yaml
+++ b/test/fuse/node_2/config.yaml
@@ -9,7 +9,6 @@ QPS: 1000
Period: 3600
MinProviderDeposit: 1000000
ValidDNSKeys:
- oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
diff --git a/test/fuse/node_c/config.yaml b/test/fuse/node_c/config.yaml
index b6bd60b5b..a0f281d47 100644
--- a/test/fuse/node_c/config.yaml
+++ b/test/fuse/node_c/config.yaml
@@ -9,7 +9,6 @@ QPS: 1000
Period: 3600
MinProviderDeposit: 1000000
ValidDNSKeys:
- oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
diff --git a/test/fuse/node_miner_0/config.yaml b/test/fuse/node_miner_0/config.yaml
index 9d4be2dc7..ec9862ef7 100644
--- a/test/fuse/node_miner_0/config.yaml
+++ b/test/fuse/node_miner_0/config.yaml
@@ -9,7 +9,6 @@ QPS: 1000
Period: 3600
MinProviderDeposit: 1000000
ValidDNSKeys:
- oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
diff --git a/test/fuse/node_miner_1/config.yaml b/test/fuse/node_miner_1/config.yaml
index de72421d7..44b110d62 100644
--- a/test/fuse/node_miner_1/config.yaml
+++ b/test/fuse/node_miner_1/config.yaml
@@ -9,7 +9,6 @@ QPS: 1000
Period: 3600
MinProviderDeposit: 1000000
ValidDNSKeys:
- oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
diff --git a/test/fuse/node_miner_2/config.yaml b/test/fuse/node_miner_2/config.yaml
index 181d51fa1..e027b5b56 100644
--- a/test/fuse/node_miner_2/config.yaml
+++ b/test/fuse/node_miner_2/config.yaml
@@ -9,7 +9,6 @@ QPS: 1000
Period: 3600
MinProviderDeposit: 1000000
ValidDNSKeys:
- oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
diff --git a/test/integration/node_0/config.yaml b/test/integration/node_0/config.yaml
index d251a2e70..1a4ceeff2 100644
--- a/test/integration/node_0/config.yaml
+++ b/test/integration/node_0/config.yaml
@@ -9,7 +9,6 @@ QPS: 1000
Period: 2
MinProviderDeposit: 1000000
ValidDNSKeys:
- oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
diff --git a/test/integration/node_1/config.yaml b/test/integration/node_1/config.yaml
index 303441e1b..92459a1f4 100644
--- a/test/integration/node_1/config.yaml
+++ b/test/integration/node_1/config.yaml
@@ -9,7 +9,6 @@ QPS: 1000
Period: 2
MinProviderDeposit: 1000000
ValidDNSKeys:
- oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
diff --git a/test/integration/node_2/config.yaml b/test/integration/node_2/config.yaml
index ad88b23a0..85425960a 100644
--- a/test/integration/node_2/config.yaml
+++ b/test/integration/node_2/config.yaml
@@ -9,7 +9,6 @@ QPS: 1000
Period: 2
MinProviderDeposit: 1000000
ValidDNSKeys:
- oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
diff --git a/test/integration/node_c/config.yaml b/test/integration/node_c/config.yaml
index d6ee71d47..b89e398ee 100644
--- a/test/integration/node_c/config.yaml
+++ b/test/integration/node_c/config.yaml
@@ -9,7 +9,6 @@ QPS: 1000
Period: 2
MinProviderDeposit: 1000000
ValidDNSKeys:
- oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
diff --git a/test/integration/node_miner_0/config.yaml b/test/integration/node_miner_0/config.yaml
index ae7e54b7a..399addb89 100644
--- a/test/integration/node_miner_0/config.yaml
+++ b/test/integration/node_miner_0/config.yaml
@@ -9,7 +9,6 @@ QPS: 1000
Period: 2
MinProviderDeposit: 1000000
ValidDNSKeys:
- oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
diff --git a/test/integration/node_miner_1/config.yaml b/test/integration/node_miner_1/config.yaml
index f0532cc34..a29583f67 100644
--- a/test/integration/node_miner_1/config.yaml
+++ b/test/integration/node_miner_1/config.yaml
@@ -9,7 +9,6 @@ QPS: 1000
Period: 2
MinProviderDeposit: 1000000
ValidDNSKeys:
- oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
diff --git a/test/integration/node_miner_2/config.yaml b/test/integration/node_miner_2/config.yaml
index 14057643b..da6b5626c 100644
--- a/test/integration/node_miner_2/config.yaml
+++ b/test/integration/node_miner_2/config.yaml
@@ -9,7 +9,6 @@ QPS: 1000
Period: 2
MinProviderDeposit: 1000000
ValidDNSKeys:
- oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
diff --git a/test/leak/client.yaml b/test/leak/client.yaml
index 09feec302..d9025a97d 100644
--- a/test/leak/client.yaml
+++ b/test/leak/client.yaml
@@ -9,7 +9,6 @@ QPS: 1000
Period: 3600
MinProviderDeposit: 1000000
ValidDNSKeys:
- oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
diff --git a/test/leak/leader.yaml b/test/leak/leader.yaml
index 6e1c1ffc0..b70d4d8f2 100644
--- a/test/leak/leader.yaml
+++ b/test/leak/leader.yaml
@@ -9,7 +9,6 @@ QPS: 1000
Period: 3600
MinProviderDeposit: 1000000
ValidDNSKeys:
- oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
diff --git a/test/mainchain/node_0/config.yaml b/test/mainchain/node_0/config.yaml
index 5f6b61fe1..35d306250 100644
--- a/test/mainchain/node_0/config.yaml
+++ b/test/mainchain/node_0/config.yaml
@@ -9,7 +9,6 @@ QPS: 1000
Period: 3600
MinProviderDeposit: 1000000
ValidDNSKeys:
- oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
diff --git a/test/mainchain/node_1/config.yaml b/test/mainchain/node_1/config.yaml
index 65659910b..d430c85f7 100644
--- a/test/mainchain/node_1/config.yaml
+++ b/test/mainchain/node_1/config.yaml
@@ -9,7 +9,6 @@ QPS: 1000
Period: 3600
MinProviderDeposit: 1000000
ValidDNSKeys:
- oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
diff --git a/test/mainchain/node_2/config.yaml b/test/mainchain/node_2/config.yaml
index 46f4e5eec..6ec81c135 100644
--- a/test/mainchain/node_2/config.yaml
+++ b/test/mainchain/node_2/config.yaml
@@ -9,7 +9,6 @@ QPS: 1000
Period: 3600
MinProviderDeposit: 1000000
ValidDNSKeys:
- oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
diff --git a/test/mainchain/node_c/config.yaml b/test/mainchain/node_c/config.yaml
index 6ed8c4804..2ce956dc6 100644
--- a/test/mainchain/node_c/config.yaml
+++ b/test/mainchain/node_c/config.yaml
@@ -9,7 +9,6 @@ QPS: 1000
Period: 3600
MinProviderDeposit: 1000000
ValidDNSKeys:
- oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
diff --git a/test/mainchain/node_miner_0/config.yaml b/test/mainchain/node_miner_0/config.yaml
index af10983d8..3cccf8538 100644
--- a/test/mainchain/node_miner_0/config.yaml
+++ b/test/mainchain/node_miner_0/config.yaml
@@ -9,7 +9,6 @@ QPS: 1000
Period: 3600
MinProviderDeposit: 1000000
ValidDNSKeys:
- oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
diff --git a/test/mainchain/node_miner_1/config.yaml b/test/mainchain/node_miner_1/config.yaml
index 1d2244b96..b1808a116 100644
--- a/test/mainchain/node_miner_1/config.yaml
+++ b/test/mainchain/node_miner_1/config.yaml
@@ -9,7 +9,6 @@ QPS: 1000
Period: 3600
MinProviderDeposit: 1000000
ValidDNSKeys:
- oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
diff --git a/test/mainchain/node_miner_2/config.yaml b/test/mainchain/node_miner_2/config.yaml
index 697a3a989..a51d0796d 100644
--- a/test/mainchain/node_miner_2/config.yaml
+++ b/test/mainchain/node_miner_2/config.yaml
@@ -9,7 +9,6 @@ QPS: 1000
Period: 3600
MinProviderDeposit: 1000000
ValidDNSKeys:
- oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
diff --git a/test/mainchain/node_multi_0/config.yaml b/test/mainchain/node_multi_0/config.yaml
index f1bdea8e2..5e96be1dd 100644
--- a/test/mainchain/node_multi_0/config.yaml
+++ b/test/mainchain/node_multi_0/config.yaml
@@ -9,7 +9,6 @@ QPS: 1000
Period: 3600
MinProviderDeposit: 1000000
ValidDNSKeys:
- oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
diff --git a/test/mainchain/node_multi_1/config.yaml b/test/mainchain/node_multi_1/config.yaml
index 9a46bd708..1e46c99f4 100644
--- a/test/mainchain/node_multi_1/config.yaml
+++ b/test/mainchain/node_multi_1/config.yaml
@@ -9,7 +9,6 @@ QPS: 1000
Period: 3600
MinProviderDeposit: 1000000
ValidDNSKeys:
- oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
diff --git a/test/mainchain/node_multi_2/config.yaml b/test/mainchain/node_multi_2/config.yaml
index 7004da6bf..e779afc09 100644
--- a/test/mainchain/node_multi_2/config.yaml
+++ b/test/mainchain/node_multi_2/config.yaml
@@ -9,7 +9,6 @@ QPS: 1000
Period: 3600
MinProviderDeposit: 1000000
ValidDNSKeys:
- oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
diff --git a/test/mainchain/node_standalone/config.yaml b/test/mainchain/node_standalone/config.yaml
index f1bdea8e2..5e96be1dd 100644
--- a/test/mainchain/node_standalone/config.yaml
+++ b/test/mainchain/node_standalone/config.yaml
@@ -9,7 +9,6 @@ QPS: 1000
Period: 3600
MinProviderDeposit: 1000000
ValidDNSKeys:
- oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
diff --git a/test/node_0/config.yaml b/test/node_0/config.yaml
index 00e83e80d..236213c56 100644
--- a/test/node_0/config.yaml
+++ b/test/node_0/config.yaml
@@ -9,7 +9,6 @@ QPS: 1000
Period: 3600
MinProviderDeposit: 1000000
ValidDNSKeys:
- oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
diff --git a/test/node_1/config.yaml b/test/node_1/config.yaml
index 5ba551d8c..5e194d35a 100644
--- a/test/node_1/config.yaml
+++ b/test/node_1/config.yaml
@@ -9,7 +9,6 @@ QPS: 1000
Period: 3600
MinProviderDeposit: 1000000
ValidDNSKeys:
- oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
diff --git a/test/node_2/config.yaml b/test/node_2/config.yaml
index fad9ac0a8..6b7bf7490 100644
--- a/test/node_2/config.yaml
+++ b/test/node_2/config.yaml
@@ -9,7 +9,6 @@ QPS: 1000
Period: 3600
MinProviderDeposit: 1000000
ValidDNSKeys:
- oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
diff --git a/test/node_c/config.yaml b/test/node_c/config.yaml
index ac73cec05..bbd3f9c8e 100644
--- a/test/node_c/config.yaml
+++ b/test/node_c/config.yaml
@@ -9,7 +9,6 @@ QPS: 1000
Period: 3600
MinProviderDeposit: 1000000
ValidDNSKeys:
- oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
diff --git a/test/node_standalone/config.yaml b/test/node_standalone/config.yaml
index 392359339..200834fb2 100644
--- a/test/node_standalone/config.yaml
+++ b/test/node_standalone/config.yaml
@@ -9,7 +9,6 @@ QPS: 1000
Period: 3600
MinProviderDeposit: 1000000
ValidDNSKeys:
- oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
diff --git a/test/node_standalone/config2.yaml b/test/node_standalone/config2.yaml
index 6165aa674..c816ce191 100644
--- a/test/node_standalone/config2.yaml
+++ b/test/node_standalone/config2.yaml
@@ -9,7 +9,6 @@ QPS: 1000
Period: 3600
MinProviderDeposit: 1000000
ValidDNSKeys:
- oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
diff --git a/test/observation/node_0/config.yaml b/test/observation/node_0/config.yaml
index 17f74caee..a478926e9 100644
--- a/test/observation/node_0/config.yaml
+++ b/test/observation/node_0/config.yaml
@@ -9,7 +9,6 @@ QPS: 1000
Period: 3600
MinProviderDeposit: 1000000
ValidDNSKeys:
- oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
diff --git a/test/observation/node_1/config.yaml b/test/observation/node_1/config.yaml
index af526f9df..70d5c2b78 100644
--- a/test/observation/node_1/config.yaml
+++ b/test/observation/node_1/config.yaml
@@ -9,7 +9,6 @@ QPS: 1000
Period: 3600
MinProviderDeposit: 1000000
ValidDNSKeys:
- oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
diff --git a/test/observation/node_2/config.yaml b/test/observation/node_2/config.yaml
index 1c3d0058a..bd17c54d7 100644
--- a/test/observation/node_2/config.yaml
+++ b/test/observation/node_2/config.yaml
@@ -9,7 +9,6 @@ QPS: 1000
Period: 3600
MinProviderDeposit: 1000000
ValidDNSKeys:
- oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
diff --git a/test/observation/node_c/config.yaml b/test/observation/node_c/config.yaml
index 2c6d7d955..f8413b933 100644
--- a/test/observation/node_c/config.yaml
+++ b/test/observation/node_c/config.yaml
@@ -9,7 +9,6 @@ QPS: 1000
Period: 3600
MinProviderDeposit: 1000000
ValidDNSKeys:
- oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
diff --git a/test/observation/node_miner_0/config.yaml b/test/observation/node_miner_0/config.yaml
index 86f86c945..914f2de50 100644
--- a/test/observation/node_miner_0/config.yaml
+++ b/test/observation/node_miner_0/config.yaml
@@ -9,7 +9,6 @@ QPS: 1000
Period: 3600
MinProviderDeposit: 1000000
ValidDNSKeys:
- oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
diff --git a/test/observation/node_miner_1/config.yaml b/test/observation/node_miner_1/config.yaml
index fc7273572..29588515b 100644
--- a/test/observation/node_miner_1/config.yaml
+++ b/test/observation/node_miner_1/config.yaml
@@ -9,7 +9,6 @@ QPS: 1000
Period: 3600
MinProviderDeposit: 1000000
ValidDNSKeys:
- oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
diff --git a/test/observation/node_miner_2/config.yaml b/test/observation/node_miner_2/config.yaml
index b198fd0ef..280868cb0 100644
--- a/test/observation/node_miner_2/config.yaml
+++ b/test/observation/node_miner_2/config.yaml
@@ -9,7 +9,6 @@ QPS: 1000
Period: 3600
MinProviderDeposit: 1000000
ValidDNSKeys:
- oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
diff --git a/test/observation/node_observer/config.yaml b/test/observation/node_observer/config.yaml
index 495181bcd..73bbfad1a 100644
--- a/test/observation/node_observer/config.yaml
+++ b/test/observation/node_observer/config.yaml
@@ -9,7 +9,6 @@ QPS: 1000
Period: 3600
MinProviderDeposit: 1000000
ValidDNSKeys:
- oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
diff --git a/test/pool/client.yaml b/test/pool/client.yaml
index 4d2eebe19..d06068a0e 100644
--- a/test/pool/client.yaml
+++ b/test/pool/client.yaml
@@ -9,7 +9,6 @@ QPS: 1000
Period: 3600
MinProviderDeposit: 1000000
ValidDNSKeys:
- oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
diff --git a/test/pool/leader.yaml b/test/pool/leader.yaml
index bc95b24cd..d0432fc1d 100644
--- a/test/pool/leader.yaml
+++ b/test/pool/leader.yaml
@@ -9,7 +9,6 @@ QPS: 1000
Period: 3600
MinProviderDeposit: 1000000
ValidDNSKeys:
- oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
diff --git a/test/service/node_0/config.yaml b/test/service/node_0/config.yaml
index 72172eee5..7f252f42a 100644
--- a/test/service/node_0/config.yaml
+++ b/test/service/node_0/config.yaml
@@ -9,7 +9,6 @@ QPS: 1000
Period: 3600
MinProviderDeposit: 1000000
ValidDNSKeys:
- oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
diff --git a/test/service/node_1/config.yaml b/test/service/node_1/config.yaml
index 79f2224d2..06818bf09 100644
--- a/test/service/node_1/config.yaml
+++ b/test/service/node_1/config.yaml
@@ -9,7 +9,6 @@ QPS: 1000
Period: 3600
MinProviderDeposit: 1000000
ValidDNSKeys:
- oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
diff --git a/test/service/node_2/config.yaml b/test/service/node_2/config.yaml
index 9e359bb59..d354502d0 100644
--- a/test/service/node_2/config.yaml
+++ b/test/service/node_2/config.yaml
@@ -9,7 +9,6 @@ QPS: 1000
Period: 3600
MinProviderDeposit: 1000000
ValidDNSKeys:
- oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
diff --git a/test/service/node_adapter/config.yaml b/test/service/node_adapter/config.yaml
index 69189945f..ba194dd85 100644
--- a/test/service/node_adapter/config.yaml
+++ b/test/service/node_adapter/config.yaml
@@ -9,7 +9,6 @@ QPS: 1000
Period: 3600
MinProviderDeposit: 1000000
ValidDNSKeys:
- oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
diff --git a/test/service/node_c/config.yaml b/test/service/node_c/config.yaml
index ee5586119..a6df4c14d 100644
--- a/test/service/node_c/config.yaml
+++ b/test/service/node_c/config.yaml
@@ -9,7 +9,6 @@ QPS: 1000
Period: 3600
MinProviderDeposit: 1000000
ValidDNSKeys:
- oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
diff --git a/test/service/node_miner_0/config.yaml b/test/service/node_miner_0/config.yaml
index aa0910ce9..297b2ed13 100644
--- a/test/service/node_miner_0/config.yaml
+++ b/test/service/node_miner_0/config.yaml
@@ -9,7 +9,6 @@ QPS: 1000
Period: 3600
MinProviderDeposit: 1000000
ValidDNSKeys:
- oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
diff --git a/test/service/node_miner_1/config.yaml b/test/service/node_miner_1/config.yaml
index 2b7df1418..af08fc757 100644
--- a/test/service/node_miner_1/config.yaml
+++ b/test/service/node_miner_1/config.yaml
@@ -9,7 +9,6 @@ QPS: 1000
Period: 3600
MinProviderDeposit: 1000000
ValidDNSKeys:
- oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
diff --git a/test/service/node_miner_2/config.yaml b/test/service/node_miner_2/config.yaml
index fc016a508..d7385615d 100644
--- a/test/service/node_miner_2/config.yaml
+++ b/test/service/node_miner_2/config.yaml
@@ -9,7 +9,6 @@ QPS: 1000
Period: 3600
MinProviderDeposit: 1000000
ValidDNSKeys:
- oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
diff --git a/test/service/node_mysql_adapter/config.yaml b/test/service/node_mysql_adapter/config.yaml
index fea3011cf..75b6e8e56 100644
--- a/test/service/node_mysql_adapter/config.yaml
+++ b/test/service/node_mysql_adapter/config.yaml
@@ -9,7 +9,6 @@ QPS: 1000
Period: 3600
MinProviderDeposit: 1000000
ValidDNSKeys:
- oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
diff --git a/test/service/node_observer/config.yaml b/test/service/node_observer/config.yaml
index 4541249e4..818b3c4e7 100644
--- a/test/service/node_observer/config.yaml
+++ b/test/service/node_observer/config.yaml
@@ -9,7 +9,6 @@ QPS: 1000
Period: 3600
MinProviderDeposit: 1000000
ValidDNSKeys:
- oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
koPbw9wmYZ7ggcjnQ6ayHyhHaDNMYELKTqT+qRGrZpWSccr/lBcrm10Z1PuQHB3Azhii+sb0PYFkH1ruxLhe5g==: cloudflare.com
mdsswUyr3DPW132mOi8V9xESWE8jTo0dxCjjnopKl+GqJxpVXckHAeF+KkxLbxILfDLUT0rAK9iUzy1L53eKGQ==: cloudflare.com
oJMRESz5E4gYzS/q6XDrvU1qMPYIjCWzJaOau8XNEZeqCYKD5ar0IRd8KqXXFJkqmVfRvMGPmM1x8fGAa2XhSA==: cloudflare.com
diff --git a/worker/db.go b/worker/db.go
index 70d1e7281..c91b43b57 100644
--- a/worker/db.go
+++ b/worker/db.go
@@ -20,6 +20,7 @@ import (
"context"
"os"
"path/filepath"
+
//"runtime/trace"
"sync"
"time"
diff --git a/xenomint/xxx_test.go b/xenomint/xxx_test.go
index 13a973878..6e19f1b08 100644
--- a/xenomint/xxx_test.go
+++ b/xenomint/xxx_test.go
@@ -22,6 +22,7 @@ import (
"os"
"path"
"sync/atomic"
+
//"runtime/trace"
"sync"
"syscall"
From d21b58455a33ab958118cdcfc9de8445fa4cff61 Mon Sep 17 00:00:00 2001
From: leventeliu
Date: Tue, 25 Dec 2018 21:45:08 +0800
Subject: [PATCH 158/278] Remove meta object wrapper and alter deepcopier
---
blockproducer/chain.go | 12 ++--
blockproducer/chain_service.go | 3 +-
blockproducer/metaindex.go | 38 +++--------
blockproducer/metastate.go | 117 ++++++++++++++------------------
blockproducer/metastate_test.go | 66 ++++++------------
blockproducer/storage.go | 12 ++--
types/baseaccount_test.go | 16 +++++
7 files changed, 109 insertions(+), 155 deletions(-)
diff --git a/blockproducer/chain.go b/blockproducer/chain.go
index 56e2ac364..d588d3882 100644
--- a/blockproducer/chain.go
+++ b/blockproducer/chain.go
@@ -137,21 +137,21 @@ func NewChainWithContext(ctx context.Context, cfg *Config) (c *Chain, err error)
sps = append(sps, addBlock(0, cfg.Genesis))
for k, v := range init.dirty.accounts {
if v != nil {
- sps = append(sps, updateAccount(&v.Account))
+ sps = append(sps, updateAccount(v))
} else {
sps = append(sps, deleteAccount(k))
}
}
for k, v := range init.dirty.databases {
if v != nil {
- sps = append(sps, updateShardChain(&v.SQLChainProfile))
+ sps = append(sps, updateShardChain(v))
} else {
sps = append(sps, deleteShardChain(k))
}
}
for k, v := range init.dirty.provider {
if v != nil {
- sps = append(sps, updateProvider(&v.ProviderProfile))
+ sps = append(sps, updateProvider(v))
} else {
sps = append(sps, deleteProvider(k))
}
@@ -642,21 +642,21 @@ func (c *Chain) replaceAndSwitchToBranch(
sps = append(sps, addBlock(height, newBlock))
for k, v := range c.immutable.dirty.accounts {
if v != nil {
- sps = append(sps, updateAccount(&v.Account))
+ sps = append(sps, updateAccount(v))
} else {
sps = append(sps, deleteAccount(k))
}
}
for k, v := range c.immutable.dirty.databases {
if v != nil {
- sps = append(sps, updateShardChain(&v.SQLChainProfile))
+ sps = append(sps, updateShardChain(v))
} else {
sps = append(sps, deleteShardChain(k))
}
}
for k, v := range c.immutable.dirty.provider {
if v != nil {
- sps = append(sps, updateProvider(&v.ProviderProfile))
+ sps = append(sps, updateProvider(v))
} else {
sps = append(sps, deleteProvider(k))
}
diff --git a/blockproducer/chain_service.go b/blockproducer/chain_service.go
index 05e8facd1..0b94986b2 100644
--- a/blockproducer/chain_service.go
+++ b/blockproducer/chain_service.go
@@ -123,12 +123,11 @@ func (c *Chain) loadAccountStableBalance(addr proto.AccountAddress) (balance uin
func (c *Chain) loadSQLChainProfile(databaseID proto.DatabaseID) (profile *types.SQLChainProfile, ok bool) {
c.RLock()
defer c.RUnlock()
- profileObj, ok := c.immutable.loadSQLChainObject(databaseID)
+ profile, ok = c.immutable.loadSQLChainObject(databaseID)
if !ok {
log.Warnf("cannot load sqlchain profile with databaseID: %s", databaseID)
return
}
- profile = &profileObj.SQLChainProfile
return
}
diff --git a/blockproducer/metaindex.go b/blockproducer/metaindex.go
index f43bf567f..cbef46e66 100644
--- a/blockproducer/metaindex.go
+++ b/blockproducer/metaindex.go
@@ -19,7 +19,7 @@ package blockproducer
import (
"github.com/CovenantSQL/CovenantSQL/proto"
"github.com/CovenantSQL/CovenantSQL/types"
- "github.com/ulule/deepcopier"
+ "github.com/mohae/deepcopy"
)
// safeAdd provides a safe add method with upper overflow check for uint64.
@@ -40,48 +40,30 @@ func safeSub(x, y *uint64) (err error) {
return
}
-type accountObject struct {
- types.Account
-}
-
-type sqlchainObject struct {
- types.SQLChainProfile
-}
-
-type providerObject struct {
- types.ProviderProfile
-}
-
type metaIndex struct {
- accounts map[proto.AccountAddress]*accountObject
- databases map[proto.DatabaseID]*sqlchainObject
- provider map[proto.AccountAddress]*providerObject
+ accounts map[proto.AccountAddress]*types.Account
+ databases map[proto.DatabaseID]*types.SQLChainProfile
+ provider map[proto.AccountAddress]*types.ProviderProfile
}
func newMetaIndex() *metaIndex {
return &metaIndex{
- accounts: make(map[proto.AccountAddress]*accountObject),
- databases: make(map[proto.DatabaseID]*sqlchainObject),
- provider: make(map[proto.AccountAddress]*providerObject),
+ accounts: make(map[proto.AccountAddress]*types.Account),
+ databases: make(map[proto.DatabaseID]*types.SQLChainProfile),
+ provider: make(map[proto.AccountAddress]*types.ProviderProfile),
}
}
func (i *metaIndex) deepCopy() (cpy *metaIndex) {
cpy = newMetaIndex()
for k, v := range i.accounts {
- cpyv := &accountObject{}
- deepcopier.Copy(v).To(cpyv)
- cpy.accounts[k] = cpyv
+ cpy.accounts[k] = deepcopy.Copy(v).(*types.Account)
}
for k, v := range i.databases {
- cpyv := &sqlchainObject{}
- deepcopier.Copy(v).To(cpyv)
- cpy.databases[k] = cpyv
+ cpy.databases[k] = deepcopy.Copy(v).(*types.SQLChainProfile)
}
for k, v := range i.provider {
- cpyv := &providerObject{}
- deepcopier.Copy(v).To(cpyv)
- cpy.provider[k] = cpyv
+ cpy.provider[k] = deepcopy.Copy(v).(*types.ProviderProfile)
}
return
}
diff --git a/blockproducer/metastate.go b/blockproducer/metastate.go
index f5ddc221a..f7cec62ab 100644
--- a/blockproducer/metastate.go
+++ b/blockproducer/metastate.go
@@ -28,8 +28,8 @@ import (
"github.com/CovenantSQL/CovenantSQL/proto"
"github.com/CovenantSQL/CovenantSQL/types"
"github.com/CovenantSQL/CovenantSQL/utils/log"
+ "github.com/mohae/deepcopy"
"github.com/pkg/errors"
- "github.com/ulule/deepcopier"
)
var (
@@ -50,7 +50,7 @@ func newMetaState() *metaState {
}
}
-func (s *metaState) loadAccountObject(k proto.AccountAddress) (o *accountObject, loaded bool) {
+func (s *metaState) loadAccountObject(k proto.AccountAddress) (o *types.Account, loaded bool) {
if o, loaded = s.dirty.accounts[k]; loaded {
if o == nil {
loaded = false
@@ -64,7 +64,7 @@ func (s *metaState) loadAccountObject(k proto.AccountAddress) (o *accountObject,
}
func (s *metaState) loadOrStoreAccountObject(
- k proto.AccountAddress, v *accountObject) (o *accountObject, loaded bool,
+ k proto.AccountAddress, v *types.Account) (o *types.Account, loaded bool,
) {
if o, loaded = s.dirty.accounts[k]; loaded && o != nil {
return
@@ -77,7 +77,7 @@ func (s *metaState) loadOrStoreAccountObject(
}
func (s *metaState) loadAccountStableBalance(addr proto.AccountAddress) (b uint64, loaded bool) {
- var o *accountObject
+ var o *types.Account
defer func() {
log.WithFields(log.Fields{
"account": addr.String(),
@@ -98,7 +98,7 @@ func (s *metaState) loadAccountStableBalance(addr proto.AccountAddress) (b uint6
}
func (s *metaState) loadAccountCovenantBalance(addr proto.AccountAddress) (b uint64, loaded bool) {
- var o *accountObject
+ var o *types.Account
defer func() {
log.WithFields(log.Fields{
"account": addr.String(),
@@ -118,7 +118,7 @@ func (s *metaState) loadAccountCovenantBalance(addr proto.AccountAddress) (b uin
return
}
-func (s *metaState) storeBaseAccount(k proto.AccountAddress, v *accountObject) (err error) {
+func (s *metaState) storeBaseAccount(k proto.AccountAddress, v *types.Account) (err error) {
log.WithFields(log.Fields{
"addr": k.String(),
"account": v,
@@ -126,7 +126,7 @@ func (s *metaState) storeBaseAccount(k proto.AccountAddress, v *accountObject) (
// Since a transfer tx may create an empty receiver account, this method should try to cover
// the side effect.
if ao, ok := s.loadOrStoreAccountObject(k, v); ok {
- if ao.Account.NextNonce != 0 {
+ if ao.NextNonce != 0 {
err = ErrAccountExists
return
}
@@ -134,10 +134,10 @@ func (s *metaState) storeBaseAccount(k proto.AccountAddress, v *accountObject) (
cb = ao.TokenBalance[types.Wave]
sb = ao.TokenBalance[types.Particle]
)
- if err = safeAdd(&cb, &v.Account.TokenBalance[types.Wave]); err != nil {
+ if err = safeAdd(&cb, &v.TokenBalance[types.Wave]); err != nil {
return
}
- if err = safeAdd(&sb, &v.Account.TokenBalance[types.Particle]); err != nil {
+ if err = safeAdd(&sb, &v.TokenBalance[types.Particle]); err != nil {
return
}
ao.TokenBalance[types.Wave] = cb
@@ -146,27 +146,25 @@ func (s *metaState) storeBaseAccount(k proto.AccountAddress, v *accountObject) (
return
}
-func (s *metaState) loadSQLChainObject(k proto.DatabaseID) (o *sqlchainObject, loaded bool) {
- var old *sqlchainObject
+func (s *metaState) loadSQLChainObject(k proto.DatabaseID) (o *types.SQLChainProfile, loaded bool) {
+ var old *types.SQLChainProfile
if old, loaded = s.dirty.databases[k]; loaded {
if old == nil {
loaded = false
return
}
- o = new(sqlchainObject)
- deepcopier.Copy(&old.SQLChainProfile).To(&o.SQLChainProfile)
+ o = deepcopy.Copy(old).(*types.SQLChainProfile)
return
}
if old, loaded = s.readonly.databases[k]; loaded {
- o = new(sqlchainObject)
- deepcopier.Copy(&old.SQLChainProfile).To(&o.SQLChainProfile)
+ o = deepcopy.Copy(old).(*types.SQLChainProfile)
return
}
return
}
func (s *metaState) loadOrStoreSQLChainObject(
- k proto.DatabaseID, v *sqlchainObject) (o *sqlchainObject, loaded bool,
+ k proto.DatabaseID, v *types.SQLChainProfile) (o *types.SQLChainProfile, loaded bool,
) {
if o, loaded = s.dirty.databases[k]; loaded && o != nil {
return
@@ -178,7 +176,7 @@ func (s *metaState) loadOrStoreSQLChainObject(
return
}
-func (s *metaState) loadProviderObject(k proto.AccountAddress) (o *providerObject, loaded bool) {
+func (s *metaState) loadProviderObject(k proto.AccountAddress) (o *types.ProviderProfile, loaded bool) {
if o, loaded = s.dirty.provider[k]; loaded {
if o == nil {
loaded = false
@@ -191,7 +189,7 @@ func (s *metaState) loadProviderObject(k proto.AccountAddress) (o *providerObjec
return
}
-func (s *metaState) loadOrStoreProviderObject(k proto.AccountAddress, v *providerObject) (o *providerObject, loaded bool) {
+func (s *metaState) loadOrStoreProviderObject(k proto.AccountAddress, v *types.ProviderProfile) (o *types.ProviderProfile, loaded bool) {
if o, loaded = s.dirty.provider[k]; loaded && o != nil {
return
}
@@ -256,7 +254,7 @@ func (s *metaState) clean() {
func (s *metaState) increaseAccountToken(k proto.AccountAddress, amount uint64, tokenType types.TokenType) error {
var (
- src, dst *accountObject
+ src, dst *types.Account
ok bool
)
if dst, ok = s.dirty.accounts[k]; !ok {
@@ -264,16 +262,15 @@ func (s *metaState) increaseAccountToken(k proto.AccountAddress, amount uint64,
err := errors.Wrap(ErrAccountNotFound, "increase stable balance fail")
return err
}
- dst = &accountObject{}
- deepcopier.Copy(&src.Account).To(&dst.Account)
+ dst = deepcopy.Copy(src).(*types.Account)
s.dirty.accounts[k] = dst
}
- return safeAdd(&dst.Account.TokenBalance[tokenType], &amount)
+ return safeAdd(&dst.TokenBalance[tokenType], &amount)
}
func (s *metaState) decreaseAccountToken(k proto.AccountAddress, amount uint64, tokenType types.TokenType) error {
var (
- src, dst *accountObject
+ src, dst *types.Account
ok bool
)
if dst, ok = s.dirty.accounts[k]; !ok {
@@ -281,11 +278,10 @@ func (s *metaState) decreaseAccountToken(k proto.AccountAddress, amount uint64,
err := errors.Wrap(ErrAccountNotFound, "increase stable balance fail")
return err
}
- dst = &accountObject{}
- deepcopier.Copy(&src.Account).To(&dst.Account)
+ dst = deepcopy.Copy(src).(*types.Account)
s.dirty.accounts[k] = dst
}
- return safeSub(&dst.Account.TokenBalance[tokenType], &amount)
+ return safeSub(&dst.TokenBalance[tokenType], &amount)
}
func (s *metaState) increaseAccountStableBalance(k proto.AccountAddress, amount uint64) error {
@@ -304,10 +300,10 @@ func (s *metaState) transferAccountStableBalance(
}
// Create empty receiver account if not found
- s.loadOrStoreAccountObject(receiver, &accountObject{Account: types.Account{Address: receiver}})
+ s.loadOrStoreAccountObject(receiver, &types.Account{Address: receiver})
var (
- so, ro *accountObject
+ so, ro *types.Account
sd, rd, ok bool
)
@@ -339,14 +335,12 @@ func (s *metaState) transferAccountStableBalance(
// Proceed transfer
if !sd {
- var cpy = &accountObject{}
- deepcopier.Copy(&so.Account).To(&cpy.Account)
+ var cpy = deepcopy.Copy(so).(*types.Account)
so = cpy
s.dirty.accounts[sender] = cpy
}
if !rd {
- var cpy = &accountObject{}
- deepcopier.Copy(&ro.Account).To(&cpy.Account)
+ var cpy = deepcopy.Copy(ro).(*types.Account)
ro = cpy
s.dirty.accounts[receiver] = cpy
}
@@ -374,16 +368,14 @@ func (s *metaState) createSQLChain(addr proto.AccountAddress, id proto.DatabaseI
} else if _, ok := s.readonly.databases[id]; ok {
return ErrDatabaseExists
}
- s.dirty.databases[id] = &sqlchainObject{
- SQLChainProfile: types.SQLChainProfile{
- ID: id,
- Owner: addr,
- Miners: make([]*types.MinerInfo, 0),
- Users: []*types.SQLChainUser{
- {
- Address: addr,
- Permission: types.Admin,
- },
+ s.dirty.databases[id] = &types.SQLChainProfile{
+ ID: id,
+ Owner: addr,
+ Miners: make([]*types.MinerInfo, 0),
+ Users: []*types.SQLChainUser{
+ {
+ Address: addr,
+ Permission: types.Admin,
},
},
}
@@ -394,15 +386,14 @@ func (s *metaState) addSQLChainUser(
k proto.DatabaseID, addr proto.AccountAddress, perm types.UserPermission) (_ error,
) {
var (
- src, dst *sqlchainObject
+ src, dst *types.SQLChainProfile
ok bool
)
if dst, ok = s.dirty.databases[k]; !ok {
if src, ok = s.readonly.databases[k]; !ok {
return ErrDatabaseNotFound
}
- dst = &sqlchainObject{}
- deepcopier.Copy(&src.SQLChainProfile).To(&dst.SQLChainProfile)
+ dst = deepcopy.Copy(src).(*types.SQLChainProfile)
s.dirty.databases[k] = dst
}
for _, v := range dst.Users {
@@ -410,7 +401,7 @@ func (s *metaState) addSQLChainUser(
return ErrDatabaseUserExists
}
}
- dst.SQLChainProfile.Users = append(dst.SQLChainProfile.Users, &types.SQLChainUser{
+ dst.Users = append(dst.Users, &types.SQLChainUser{
Address: addr,
Permission: perm,
})
@@ -419,15 +410,14 @@ func (s *metaState) addSQLChainUser(
func (s *metaState) deleteSQLChainUser(k proto.DatabaseID, addr proto.AccountAddress) error {
var (
- src, dst *sqlchainObject
+ src, dst *types.SQLChainProfile
ok bool
)
if dst, ok = s.dirty.databases[k]; !ok {
if src, ok = s.readonly.databases[k]; !ok {
return ErrDatabaseNotFound
}
- dst = &sqlchainObject{}
- deepcopier.Copy(&src.SQLChainProfile).To(&dst.SQLChainProfile)
+ dst = deepcopy.Copy(src).(*types.SQLChainProfile)
s.dirty.databases[k] = dst
}
for i, v := range dst.Users {
@@ -445,15 +435,14 @@ func (s *metaState) alterSQLChainUser(
k proto.DatabaseID, addr proto.AccountAddress, perm types.UserPermission) (_ error,
) {
var (
- src, dst *sqlchainObject
+ src, dst *types.SQLChainProfile
ok bool
)
if dst, ok = s.dirty.databases[k]; !ok {
if src, ok = s.readonly.databases[k]; !ok {
return ErrDatabaseNotFound
}
- dst = &sqlchainObject{}
- deepcopier.Copy(&src.SQLChainProfile).To(&dst.SQLChainProfile)
+ dst = deepcopy.Copy(src).(*types.SQLChainProfile)
s.dirty.databases[k] = dst
}
for _, v := range dst.Users {
@@ -466,7 +455,7 @@ func (s *metaState) alterSQLChainUser(
func (s *metaState) nextNonce(addr proto.AccountAddress) (nonce pi.AccountNonce, err error) {
var (
- o *accountObject
+ o *types.Account
loaded bool
)
if o, loaded = s.dirty.accounts[addr]; !loaded {
@@ -478,21 +467,20 @@ func (s *metaState) nextNonce(addr proto.AccountAddress) (nonce pi.AccountNonce,
return
}
}
- nonce = o.Account.NextNonce
+ nonce = o.NextNonce
return
}
func (s *metaState) increaseNonce(addr proto.AccountAddress) (err error) {
var (
- src, dst *accountObject
+ src, dst *types.Account
ok bool
)
if dst, ok = s.dirty.accounts[addr]; !ok {
if src, ok = s.readonly.accounts[addr]; !ok {
return ErrAccountNotFound
}
- dst = &accountObject{}
- deepcopier.Copy(&src.Account).To(&dst.Account)
+ dst = deepcopy.Copy(src).(*types.Account)
s.dirty.accounts[addr] = dst
}
dst.NextNonce++
@@ -502,7 +490,7 @@ func (s *metaState) increaseNonce(addr proto.AccountAddress) (err error) {
func (s *metaState) applyBilling(tx *types.Billing) (err error) {
for i, v := range tx.Receivers {
// Create empty receiver account if not found
- s.loadOrStoreAccountObject(*v, &accountObject{Account: types.Account{Address: *v}})
+ s.loadOrStoreAccountObject(*v, &types.Account{Address: *v})
if err = s.increaseAccountCovenantBalance(*v, tx.Fees[i]); err != nil {
return
@@ -538,7 +526,7 @@ func (s *metaState) updateProviderList(tx *types.ProvideService) (err error) {
GasPrice: tx.GasPrice,
NodeID: tx.NodeID,
}
- s.loadOrStoreProviderObject(sender, &providerObject{ProviderProfile: pp})
+ s.loadOrStoreProviderObject(sender, &pp)
return
}
@@ -661,10 +649,8 @@ func (s *metaState) matchProvidersWithUser(tx *types.CreateDatabase) (err error)
err = errors.Wrapf(ErrDatabaseExists, "database exists: %s", string(*dbID))
return
}
- s.loadOrStoreAccountObject(dbAddr, &accountObject{
- Account: types.Account{Address: dbAddr},
- })
- s.loadOrStoreSQLChainObject(*dbID, &sqlchainObject{SQLChainProfile: *sp})
+ s.loadOrStoreAccountObject(dbAddr, &types.Account{Address: dbAddr})
+ s.loadOrStoreSQLChainObject(*dbID, sp)
for _, miner := range tx.ResourceMeta.TargetMiners {
s.deleteProviderObject(miner)
}
@@ -829,8 +815,7 @@ func (s *metaState) loadROSQLChains(addr proto.AccountAddress) (dbs []*types.SQL
for _, db := range s.readonly.databases {
for _, miner := range db.Miners {
if miner.Address == addr {
- var dst = &types.SQLChainProfile{}
- deepcopier.Copy(&db.SQLChainProfile).To(dst)
+ var dst = deepcopy.Copy(db).(*types.SQLChainProfile)
dbs = append(dbs, dst)
}
}
@@ -856,7 +841,7 @@ func (s *metaState) applyTransaction(tx pi.Transaction) (err error) {
case *types.Billing:
err = s.applyBilling(t)
case *types.BaseAccount:
- err = s.storeBaseAccount(t.Address, &accountObject{Account: t.Account})
+ err = s.storeBaseAccount(t.Address, &t.Account)
case *types.ProvideService:
err = s.updateProviderList(t)
case *types.CreateDatabase:
diff --git a/blockproducer/metastate_test.go b/blockproducer/metastate_test.go
index 4f3f6c662..f821dbf3c 100644
--- a/blockproducer/metastate_test.go
+++ b/blockproducer/metastate_test.go
@@ -37,9 +37,9 @@ import (
func TestMetaState(t *testing.T) {
Convey("Given a new metaState object and a persistence db instance", t, func() {
var (
- ao *accountObject
- co *sqlchainObject
- po *providerObject
+ ao *types.Account
+ co *types.SQLChainProfile
+ po *types.ProviderProfile
bl uint64
loaded bool
err error
@@ -112,38 +112,26 @@ func TestMetaState(t *testing.T) {
So(err, ShouldEqual, ErrDatabaseNotFound)
})
Convey("When new account and database objects are stored", func() {
- ao, loaded = ms.loadOrStoreAccountObject(addr1, &accountObject{
- Account: types.Account{
- Address: addr1,
- },
- })
+ ao, loaded = ms.loadOrStoreAccountObject(addr1, &types.Account{Address: addr1})
So(ao, ShouldBeNil)
So(loaded, ShouldBeFalse)
- ao, loaded = ms.loadOrStoreAccountObject(addr2, &accountObject{
- Account: types.Account{
- Address: addr2,
- },
- })
+ ao, loaded = ms.loadOrStoreAccountObject(addr2, &types.Account{Address: addr2})
So(ao, ShouldBeNil)
So(loaded, ShouldBeFalse)
- co, loaded = ms.loadOrStoreSQLChainObject(dbid1, &sqlchainObject{
- SQLChainProfile: types.SQLChainProfile{
- ID: dbid1,
- Miners: []*types.MinerInfo{
- &types.MinerInfo{Address: addr1},
- &types.MinerInfo{Address: addr2},
- },
+ co, loaded = ms.loadOrStoreSQLChainObject(dbid1, &types.SQLChainProfile{
+ ID: dbid1,
+ Miners: []*types.MinerInfo{
+ &types.MinerInfo{Address: addr1},
+ &types.MinerInfo{Address: addr2},
},
})
So(co, ShouldBeNil)
So(loaded, ShouldBeFalse)
- co, loaded = ms.loadOrStoreSQLChainObject(dbid2, &sqlchainObject{
- SQLChainProfile: types.SQLChainProfile{
- ID: dbid2,
- Miners: []*types.MinerInfo{
- &types.MinerInfo{Address: addr2},
- &types.MinerInfo{Address: addr3},
- },
+ co, loaded = ms.loadOrStoreSQLChainObject(dbid2, &types.SQLChainProfile{
+ ID: dbid2,
+ Miners: []*types.MinerInfo{
+ &types.MinerInfo{Address: addr2},
+ &types.MinerInfo{Address: addr3},
},
})
So(co, ShouldBeNil)
@@ -577,32 +565,16 @@ func TestMetaState(t *testing.T) {
err = kms.InitLocalKeyPair(privKeyFile, []byte(""))
So(err, ShouldBeNil)
- ao, loaded = ms.loadOrStoreAccountObject(addr1,
- &accountObject{Account: types.Account{
- Address: addr1,
- },
- })
+ ao, loaded = ms.loadOrStoreAccountObject(addr1, &types.Account{Address: addr1})
So(ao, ShouldBeNil)
So(loaded, ShouldBeFalse)
- ao, loaded = ms.loadOrStoreAccountObject(addr2, &accountObject{
- Account: types.Account{
- Address: addr2,
- },
- })
+ ao, loaded = ms.loadOrStoreAccountObject(addr2, &types.Account{Address: addr2})
So(ao, ShouldBeNil)
So(loaded, ShouldBeFalse)
- ao, loaded = ms.loadOrStoreAccountObject(addr3, &accountObject{
- Account: types.Account{
- Address: addr3,
- },
- })
+ ao, loaded = ms.loadOrStoreAccountObject(addr3, &types.Account{Address: addr3})
So(ao, ShouldBeNil)
So(loaded, ShouldBeFalse)
- ao, loaded = ms.loadOrStoreAccountObject(addr4, &accountObject{
- Account: types.Account{
- Address: addr4,
- },
- })
+ ao, loaded = ms.loadOrStoreAccountObject(addr4, &types.Account{Address: addr4})
So(ao, ShouldBeNil)
So(loaded, ShouldBeFalse)
diff --git a/blockproducer/storage.go b/blockproducer/storage.go
index d4a4c993f..8f2e9242c 100644
--- a/blockproducer/storage.go
+++ b/blockproducer/storage.go
@@ -417,8 +417,8 @@ func loadAndCacheAccounts(st xi.Storage, view *metaState) (err error) {
if err = hash.Decode(&addr, hex); err != nil {
return
}
- var dec = &accountObject{}
- if err = utils.DecodeMsgPack(enc, &dec.Account); err != nil {
+ var dec = &types.Account{}
+ if err = utils.DecodeMsgPack(enc, dec); err != nil {
return
}
view.readonly.accounts[proto.AccountAddress(addr)] = dec
@@ -443,8 +443,8 @@ func loadAndCacheShardChainProfiles(st xi.Storage, view *metaState) (err error)
if err = rows.Scan(&id, &enc); err != nil {
return
}
- var dec = &sqlchainObject{}
- if err = utils.DecodeMsgPack(enc, &dec.SQLChainProfile); err != nil {
+ var dec = &types.SQLChainProfile{}
+ if err = utils.DecodeMsgPack(enc, dec); err != nil {
return
}
view.readonly.databases[proto.DatabaseID(id)] = dec
@@ -473,8 +473,8 @@ func loadAndCacheProviders(st xi.Storage, view *metaState) (err error) {
if err = hash.Decode(&addr, hex); err != nil {
return
}
- var dec = &providerObject{}
- if err = utils.DecodeMsgPack(enc, &dec.ProviderProfile); err != nil {
+ var dec = &types.ProviderProfile{}
+ if err = utils.DecodeMsgPack(enc, dec); err != nil {
return
}
view.readonly.provider[proto.AccountAddress(addr)] = dec
diff --git a/types/baseaccount_test.go b/types/baseaccount_test.go
index fd1370735..1d1cd26d3 100644
--- a/types/baseaccount_test.go
+++ b/types/baseaccount_test.go
@@ -22,6 +22,7 @@ import (
"github.com/CovenantSQL/CovenantSQL/crypto/asymmetric"
"github.com/CovenantSQL/CovenantSQL/crypto/hash"
"github.com/CovenantSQL/CovenantSQL/proto"
+ "github.com/mohae/deepcopy"
. "github.com/smartystreets/goconvey/convey"
)
@@ -42,3 +43,18 @@ func TestBaseAccount(t *testing.T) {
So(ba.Verify(), ShouldBeNil)
})
}
+
+func TestDeepcopier(t *testing.T) {
+ Convey("base account", t, func() {
+ var p1 = &SQLChainProfile{
+ Miners: []*MinerInfo{
+ &MinerInfo{},
+ &MinerInfo{},
+ &MinerInfo{},
+ },
+ }
+ var p2 = deepcopy.Copy(p1).(*SQLChainProfile)
+ t.Logf("%p %p", p1.Miners[0], p2.Miners[0])
+ So(p1.Miners[0], ShouldNotEqual, p2.Miners[0])
+ })
+}
From 1f2b5cb640081aa17cbcd3a229502876059027f6 Mon Sep 17 00:00:00 2001
From: leventeliu
Date: Tue, 25 Dec 2018 21:53:00 +0800
Subject: [PATCH 159/278] Update vendor
---
Gopkg.lock | 118 +-
.../CovenantSQL/sqlparser/README.md | 104 +-
.../CovenantSQL/sqlparser/analyzer.go | 4 +-
.../github.com/CovenantSQL/sqlparser/ast.go | 187 +-
.../sqlparser/dependency/sqltypes/value.go | 7 +-
.../github.com/CovenantSQL/sqlparser/sql.go | 2793 ++++++-----
vendor/github.com/CovenantSQL/sqlparser/sql.y | 44 +-
.../github.com/CovenantSQL/sqlparser/token.go | 34 +-
vendor/github.com/alecthomas/chroma/README.md | 27 +-
.../github.com/alecthomas/chroma/coalesce.go | 10 +-
.../github.com/alecthomas/chroma/delegate.go | 34 +-
.../alecthomas/chroma/formatters/api.go | 2 +-
.../alecthomas/chroma/formatters/html/html.go | 64 +-
.../alecthomas/chroma/formatters/json.go | 2 +-
.../alecthomas/chroma/formatters/tokens.go | 2 +-
.../chroma/formatters/tty_indexed.go | 2 +-
.../chroma/formatters/tty_truecolour.go | 2 +-
vendor/github.com/alecthomas/chroma/go.mod | 14 +
vendor/github.com/alecthomas/chroma/go.sum | 26 +
.../github.com/alecthomas/chroma/iterator.go | 45 +-
vendor/github.com/alecthomas/chroma/lexer.go | 8 +-
.../alecthomas/chroma/lexers/b/bash.go | 2 +-
.../alecthomas/chroma/lexers/e/elixir.go | 6 +-
.../alecthomas/chroma/lexers/g/go.go | 1 +
.../alecthomas/chroma/lexers/h/http.go | 17 +-
.../alecthomas/chroma/lexers/r/rst.go | 4 +-
.../alecthomas/chroma/lexers/s/systemd.go | 29 +
.../alecthomas/chroma/lexers/t/tradingview.go | 36 +
.../alecthomas/chroma/lexers/v/vb.go | 75 +
.../alecthomas/chroma/lexers/y/yaml.go | 2 +-
.../github.com/alecthomas/chroma/mutators.go | 2 +-
vendor/github.com/alecthomas/chroma/regexp.go | 18 +-
vendor/github.com/alecthomas/chroma/remap.go | 14 +-
.../alecthomas/chroma/tokentype_string.go | 177 +-
vendor/github.com/alecthomas/chroma/types.go | 6 +-
.../btcsuite/btcd/btcec/signature.go | 4 +-
vendor/github.com/fortytw2/leaktest/README.md | 18 +-
.../github.com/fortytw2/leaktest/leaktest.go | 5 +-
vendor/github.com/jtolds/gls/stack_tags.go | 34 +
vendor/github.com/juju/errors/error.go | 4 +
vendor/github.com/knq/snaker/go.mod | 1 +
.../mattn/go-runewidth/runewidth.go | 838 ++--
.../mattn/go-runewidth/runewidth_appengine.go | 8 +
.../mattn/go-runewidth/runewidth_js.go | 1 +
.../mattn/go-runewidth/runewidth_posix.go | 4 +-
.../mattn/go-runewidth/runewidth_windows.go | 3 +
vendor/github.com/miekg/dns/README.md | 49 +-
vendor/github.com/miekg/dns/acceptfunc.go | 54 +
vendor/github.com/miekg/dns/client.go | 83 +-
.../github.com/miekg/dns/compress_generate.go | 198 -
vendor/github.com/miekg/dns/defaults.go | 2 +-
vendor/github.com/miekg/dns/dns.go | 28 +-
vendor/github.com/miekg/dns/dnssec.go | 4 +-
vendor/github.com/miekg/dns/doc.go | 107 +-
vendor/github.com/miekg/dns/edns.go | 33 +-
vendor/github.com/miekg/dns/msg.go | 602 +--
vendor/github.com/miekg/dns/msg_generate.go | 21 +-
vendor/github.com/miekg/dns/msg_helpers.go | 30 +-
vendor/github.com/miekg/dns/nsecx.go | 47 +-
vendor/github.com/miekg/dns/privaterr.go | 20 +-
vendor/github.com/miekg/dns/rawmsg.go | 49 -
vendor/github.com/miekg/dns/reverse.go | 5 +
vendor/github.com/miekg/dns/server.go | 75 +-
vendor/github.com/miekg/dns/sig0.go | 4 +-
vendor/github.com/miekg/dns/tsig.go | 2 +-
vendor/github.com/miekg/dns/types.go | 65 +-
vendor/github.com/miekg/dns/types_generate.go | 16 +-
vendor/github.com/miekg/dns/version.go | 2 +-
vendor/github.com/miekg/dns/zcompress.go | 152 -
vendor/github.com/miekg/dns/zmsg.go | 1156 ++---
vendor/github.com/miekg/dns/ztypes.go | 306 +-
.../deepcopier => mohae/deepcopy}/LICENSE | 3 +-
vendor/github.com/mohae/deepcopy/README.md | 8 +
vendor/github.com/mohae/deepcopy/deepcopy.go | 125 +
.../client_golang/prometheus/counter.go | 2 +-
.../client_golang/prometheus/desc.go | 4 +-
.../client_golang/prometheus/gauge.go | 2 +-
.../client_golang/prometheus/histogram.go | 2 +-
.../client_golang/prometheus/labels.go | 21 +-
.../client_golang/prometheus/registry.go | 50 +-
.../client_golang/prometheus/summary.go | 2 +-
.../client_golang/prometheus/timer.go | 11 +-
.../prometheus/common/expfmt/text_create.go | 12 +-
vendor/github.com/prometheus/procfs/Makefile | 57 +-
.../prometheus/procfs/Makefile.common | 223 +
vendor/github.com/prometheus/procfs/go.mod | 1 +
.../siddontang/go-mysql/server/auth.go | 8 +-
.../siddontang/go-mysql/server/conn.go | 23 +-
.../syndtr/goleveldb/leveldb/cache/cache.go | 1 -
.../leveldb/comparer/bytes_comparer.go | 4 +-
.../goleveldb/leveldb/comparer/comparer.go | 2 +-
.../github.com/syndtr/goleveldb/leveldb/db.go | 2 +-
.../syndtr/goleveldb/leveldb/db_compaction.go | 24 +-
.../syndtr/goleveldb/leveldb/db_util.go | 2 +-
.../syndtr/goleveldb/leveldb/opt/options.go | 13 +
.../syndtr/goleveldb/leveldb/session_util.go | 4 +-
.../syndtr/goleveldb/leveldb/table.go | 28 +-
vendor/github.com/ulule/deepcopier/Makefile | 5 -
vendor/github.com/ulule/deepcopier/README.md | 129 -
.../github.com/ulule/deepcopier/deepcopier.go | 362 --
vendor/github.com/xo/dburl/README.md | 2 +-
vendor/github.com/xo/dburl/dsn.go | 3 +-
vendor/github.com/xo/dburl/go.sum | 0
vendor/github.com/xo/tblfmt/go.mod | 5 +-
vendor/github.com/xo/tblfmt/go.sum | 2 -
vendor/github.com/xo/terminfo/go.mod | 1 +
.../golang.org/x/crypto/ssh/terminal/util.go | 4 +-
.../x/crypto/ssh/terminal/util_aix.go | 12 +
.../x/crypto/ssh/terminal/util_plan9.go | 2 +-
.../x/crypto/ssh/terminal/util_solaris.go | 2 +-
.../x/crypto/ssh/terminal/util_windows.go | 2 +-
.../golang.org/x/net/internal/socket/empty.s | 7 +
.../x/net/internal/socket/sys_bsdvar.go | 8 +-
.../net/internal/socket/sys_go1_11_darwin.go | 33 +
.../net/internal/socket/sys_go1_12_darwin.go | 42 +
.../x/net/internal/socket/sys_posix.go | 36 +-
.../x/net/internal/socket/sys_unix.go | 2 +-
vendor/golang.org/x/net/ipv4/doc.go | 3 +-
vendor/golang.org/x/net/ipv4/payload_cmsg.go | 2 +-
.../x/net/ipv4/payload_cmsg_go1_8.go | 2 +-
.../x/net/ipv4/payload_cmsg_go1_9.go | 2 +-
.../golang.org/x/net/ipv4/payload_nocmsg.go | 2 +-
vendor/golang.org/x/net/ipv6/doc.go | 3 +-
vendor/golang.org/x/net/ipv6/payload_cmsg.go | 2 +-
.../x/net/ipv6/payload_cmsg_go1_8.go | 2 +-
.../x/net/ipv6/payload_cmsg_go1_9.go | 2 +-
.../golang.org/x/net/ipv6/payload_nocmsg.go | 2 +-
vendor/golang.org/x/sys/unix/README.md | 4 +-
.../golang.org/x/sys/unix/asm_linux_ppc64x.s | 12 -
vendor/golang.org/x/sys/unix/mkall.sh | 45 +-
vendor/golang.org/x/sys/unix/mkasm_darwin.go | 61 +
vendor/golang.org/x/sys/unix/mkerrors.sh | 22 +-
vendor/golang.org/x/sys/unix/mkpost.go | 14 +-
vendor/golang.org/x/sys/unix/mksyscall.go | 398 ++
vendor/golang.org/x/sys/unix/mksyscall.pl | 341 --
vendor/golang.org/x/sys/unix/sockcmsg_unix.go | 25 +-
vendor/golang.org/x/sys/unix/syscall_aix.go | 16 +-
.../golang.org/x/sys/unix/syscall_darwin.go | 62 +-
.../x/sys/unix/syscall_darwin_386.go | 23 +-
.../x/sys/unix/syscall_darwin_amd64.go | 23 +-
.../x/sys/unix/syscall_darwin_arm.go | 26 +-
.../x/sys/unix/syscall_darwin_arm64.go | 26 +-
.../x/sys/unix/syscall_darwin_libSystem.go | 31 +
.../x/sys/unix/syscall_dragonfly.go | 7 +
.../golang.org/x/sys/unix/syscall_freebsd.go | 7 +
vendor/golang.org/x/sys/unix/syscall_linux.go | 94 +-
.../x/sys/unix/syscall_linux_amd64.go | 18 +-
.../x/sys/unix/syscall_linux_arm.go | 8 +
.../golang.org/x/sys/unix/syscall_netbsd.go | 15 +
.../golang.org/x/sys/unix/syscall_openbsd.go | 7 +
.../golang.org/x/sys/unix/syscall_solaris.go | 7 +
vendor/golang.org/x/sys/unix/syscall_unix.go | 15 -
.../golang.org/x/sys/unix/syscall_unix_gc.go | 2 +-
.../x/sys/unix/syscall_unix_gc_ppc64x.go | 24 +
vendor/golang.org/x/sys/unix/types_freebsd.go | 2 +-
vendor/golang.org/x/sys/unix/types_netbsd.go | 2 +
.../x/sys/unix/zerrors_linux_386.go | 34 +
.../x/sys/unix/zerrors_linux_amd64.go | 34 +
.../x/sys/unix/zerrors_linux_arm.go | 34 +
.../x/sys/unix/zerrors_linux_arm64.go | 34 +
.../x/sys/unix/zerrors_linux_mips.go | 34 +
.../x/sys/unix/zerrors_linux_mips64.go | 34 +
.../x/sys/unix/zerrors_linux_mips64le.go | 34 +
.../x/sys/unix/zerrors_linux_mipsle.go | 34 +
.../x/sys/unix/zerrors_linux_ppc64.go | 34 +
.../x/sys/unix/zerrors_linux_ppc64le.go | 34 +
.../x/sys/unix/zerrors_linux_riscv64.go | 34 +
.../x/sys/unix/zerrors_linux_s390x.go | 34 +
.../x/sys/unix/zerrors_linux_sparc64.go | 4196 ++++++++++-------
.../x/sys/unix/zsyscall_darwin_386.1_11.go | 1810 +++++++
.../x/sys/unix/zsyscall_darwin_386.go | 1174 ++++-
.../x/sys/unix/zsyscall_darwin_386.s | 284 ++
.../x/sys/unix/zsyscall_darwin_amd64.1_11.go | 1810 +++++++
.../x/sys/unix/zsyscall_darwin_amd64.go | 1174 ++++-
.../x/sys/unix/zsyscall_darwin_amd64.s | 284 ++
.../x/sys/unix/zsyscall_darwin_arm.1_11.go | 1793 +++++++
.../x/sys/unix/zsyscall_darwin_arm.go | 1152 ++++-
.../x/sys/unix/zsyscall_darwin_arm.s | 282 ++
.../x/sys/unix/zsyscall_darwin_arm64.1_11.go | 1793 +++++++
.../x/sys/unix/zsyscall_darwin_arm64.go | 1152 ++++-
.../x/sys/unix/zsyscall_darwin_arm64.s | 282 ++
.../x/sys/unix/zsyscall_dragonfly_amd64.go | 2 +-
.../x/sys/unix/zsyscall_freebsd_386.go | 2 +-
.../x/sys/unix/zsyscall_freebsd_amd64.go | 2 +-
.../x/sys/unix/zsyscall_freebsd_arm.go | 2 +-
.../x/sys/unix/zsyscall_linux_386.go | 2 +-
.../x/sys/unix/zsyscall_linux_amd64.go | 19 +-
.../x/sys/unix/zsyscall_linux_arm.go | 12 +-
.../x/sys/unix/zsyscall_linux_arm64.go | 2 +-
.../x/sys/unix/zsyscall_linux_mips.go | 2 +-
.../x/sys/unix/zsyscall_linux_mips64.go | 2 +-
.../x/sys/unix/zsyscall_linux_mips64le.go | 2 +-
.../x/sys/unix/zsyscall_linux_mipsle.go | 2 +-
.../x/sys/unix/zsyscall_linux_ppc64.go | 2 +-
.../x/sys/unix/zsyscall_linux_ppc64le.go | 2 +-
.../x/sys/unix/zsyscall_linux_riscv64.go | 2 +-
.../x/sys/unix/zsyscall_linux_s390x.go | 2 +-
.../x/sys/unix/zsyscall_linux_sparc64.go | 204 +-
.../x/sys/unix/zsyscall_netbsd_386.go | 2 +-
.../x/sys/unix/zsyscall_netbsd_amd64.go | 2 +-
.../x/sys/unix/zsyscall_netbsd_arm.go | 2 +-
.../x/sys/unix/zsyscall_openbsd_386.go | 2 +-
.../x/sys/unix/zsyscall_openbsd_amd64.go | 2 +-
.../x/sys/unix/zsyscall_openbsd_arm.go | 2 +-
.../x/sys/unix/zsysnum_linux_386.go | 2 +-
.../x/sys/unix/zsysnum_linux_amd64.go | 2 +-
.../x/sys/unix/zsysnum_linux_arm.go | 2 +-
.../x/sys/unix/zsysnum_linux_arm64.go | 2 +-
.../x/sys/unix/zsysnum_linux_mips.go | 2 +-
.../x/sys/unix/zsysnum_linux_mips64.go | 2 +-
.../x/sys/unix/zsysnum_linux_mips64le.go | 2 +-
.../x/sys/unix/zsysnum_linux_mipsle.go | 2 +-
.../x/sys/unix/zsysnum_linux_ppc64.go | 2 +-
.../x/sys/unix/zsysnum_linux_ppc64le.go | 2 +-
.../x/sys/unix/zsysnum_linux_riscv64.go | 2 +-
.../x/sys/unix/zsysnum_linux_s390x.go | 2 +-
.../x/sys/unix/zsysnum_linux_sparc64.go | 6 +-
.../x/sys/unix/ztypes_freebsd_386.go | 2 +-
.../x/sys/unix/ztypes_freebsd_amd64.go | 2 +-
.../x/sys/unix/ztypes_freebsd_arm.go | 2 +-
.../golang.org/x/sys/unix/ztypes_linux_386.go | 12 +-
.../x/sys/unix/ztypes_linux_amd64.go | 19 +-
.../golang.org/x/sys/unix/ztypes_linux_arm.go | 13 +-
.../x/sys/unix/ztypes_linux_arm64.go | 19 +-
.../x/sys/unix/ztypes_linux_mips.go | 10 +-
.../x/sys/unix/ztypes_linux_mips64.go | 19 +-
.../x/sys/unix/ztypes_linux_mips64le.go | 19 +-
.../x/sys/unix/ztypes_linux_mipsle.go | 10 +-
.../x/sys/unix/ztypes_linux_ppc64.go | 19 +-
.../x/sys/unix/ztypes_linux_ppc64le.go | 19 +-
.../x/sys/unix/ztypes_linux_riscv64.go | 19 +-
.../x/sys/unix/ztypes_linux_s390x.go | 24 +-
.../x/sys/unix/ztypes_linux_sparc64.go | 1487 +++++-
.../x/sys/unix/ztypes_netbsd_386.go | 7 +
.../x/sys/unix/ztypes_netbsd_amd64.go | 7 +
.../x/sys/unix/ztypes_netbsd_arm.go | 7 +
.../x/sys/unix/ztypes_openbsd_arm.go | 102 +-
vendor/gopkg.in/yaml.v2/encode.go | 28 +
238 files changed, 21896 insertions(+), 8449 deletions(-)
create mode 100644 vendor/github.com/alecthomas/chroma/go.mod
create mode 100644 vendor/github.com/alecthomas/chroma/go.sum
create mode 100644 vendor/github.com/alecthomas/chroma/lexers/s/systemd.go
create mode 100644 vendor/github.com/alecthomas/chroma/lexers/t/tradingview.go
create mode 100644 vendor/github.com/alecthomas/chroma/lexers/v/vb.go
create mode 100644 vendor/github.com/knq/snaker/go.mod
create mode 100644 vendor/github.com/mattn/go-runewidth/runewidth_appengine.go
create mode 100644 vendor/github.com/miekg/dns/acceptfunc.go
delete mode 100644 vendor/github.com/miekg/dns/compress_generate.go
delete mode 100644 vendor/github.com/miekg/dns/rawmsg.go
delete mode 100644 vendor/github.com/miekg/dns/zcompress.go
rename vendor/github.com/{ulule/deepcopier => mohae/deepcopy}/LICENSE (97%)
create mode 100644 vendor/github.com/mohae/deepcopy/README.md
create mode 100644 vendor/github.com/mohae/deepcopy/deepcopy.go
create mode 100644 vendor/github.com/prometheus/procfs/Makefile.common
create mode 100644 vendor/github.com/prometheus/procfs/go.mod
delete mode 100644 vendor/github.com/ulule/deepcopier/Makefile
delete mode 100644 vendor/github.com/ulule/deepcopier/README.md
delete mode 100644 vendor/github.com/ulule/deepcopier/deepcopier.go
create mode 100644 vendor/github.com/xo/dburl/go.sum
create mode 100644 vendor/github.com/xo/terminfo/go.mod
create mode 100644 vendor/golang.org/x/crypto/ssh/terminal/util_aix.go
create mode 100644 vendor/golang.org/x/net/internal/socket/empty.s
create mode 100644 vendor/golang.org/x/net/internal/socket/sys_go1_11_darwin.go
create mode 100644 vendor/golang.org/x/net/internal/socket/sys_go1_12_darwin.go
create mode 100644 vendor/golang.org/x/sys/unix/mkasm_darwin.go
create mode 100644 vendor/golang.org/x/sys/unix/mksyscall.go
delete mode 100755 vendor/golang.org/x/sys/unix/mksyscall.pl
create mode 100644 vendor/golang.org/x/sys/unix/syscall_darwin_libSystem.go
create mode 100644 vendor/golang.org/x/sys/unix/syscall_unix_gc_ppc64x.go
create mode 100644 vendor/golang.org/x/sys/unix/zsyscall_darwin_386.1_11.go
create mode 100644 vendor/golang.org/x/sys/unix/zsyscall_darwin_386.s
create mode 100644 vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.1_11.go
create mode 100644 vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.s
create mode 100644 vendor/golang.org/x/sys/unix/zsyscall_darwin_arm.1_11.go
create mode 100644 vendor/golang.org/x/sys/unix/zsyscall_darwin_arm.s
create mode 100644 vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.1_11.go
create mode 100644 vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.s
diff --git a/Gopkg.lock b/Gopkg.lock
index f938ce406..63a9e8e89 100644
--- a/Gopkg.lock
+++ b/Gopkg.lock
@@ -20,7 +20,7 @@
name = "github.com/CovenantSQL/HashStablePack"
packages = ["marshalhash"]
pruneopts = "UT"
- revision = "f5d7cc3bf3356c85eadcb0f66007f2f2b7ee81bc"
+ revision = "ea383e6c5f56c8db09130378d7eaf1631d14ecc0"
[[projects]]
branch = "develop"
@@ -32,7 +32,7 @@
[[projects]]
branch = "master"
- digest = "1:9552f97d556ffa281b8d5c23280aad519e9792a02222cded90467882ff675063"
+ digest = "1:747a4d23380a7186ac767b81dcba660e482ed9d82f02d12603147cf6e2b9f02f"
name = "github.com/CovenantSQL/sqlparser"
packages = [
".",
@@ -42,7 +42,7 @@
"dependency/sqltypes",
]
pruneopts = "UT"
- revision = "21a792a5b3b3ecddc9a836fb3da0468f0bd0434f"
+ revision = "8673c64d83a0954a21eaf0158bb2e1eb574304da"
[[projects]]
branch = "master"
@@ -53,7 +53,7 @@
revision = "b72b1571892216ba2a42fb8abeb726d082b4c4d1"
[[projects]]
- digest = "1:9253f97cfbbe049b631877c80badecc69620711b3e335f6cf97a7809681da388"
+ digest = "1:69fec5960ceb89bcb8d6a1ef8126d6e7cdfa9d7be70e41e56188c8c90015b2fe"
name = "github.com/alecthomas/chroma"
packages = [
".",
@@ -89,8 +89,8 @@
"styles",
]
pruneopts = "UT"
- revision = "5d7fef2ae60b501bbf28d476c3f273b8017d8261"
- version = "v0.5.0"
+ revision = "3b3f74c6a5979f78da47b884b3e3895c1df1465b"
+ version = "v0.6.1"
[[projects]]
digest = "1:a8d622a8049a4aa420e1c509873bb85d4c45c5107f420d922f919bfcb8d08694"
@@ -110,11 +110,11 @@
[[projects]]
branch = "master"
- digest = "1:c0decf632843204d2b8781de7b26e7038584e2dcccc7e2f401e88ae85b1df2b7"
+ digest = "1:093bf93a65962e8191e3e8cd8fc6c363f83d43caca9739c906531ba7210a9904"
name = "github.com/btcsuite/btcd"
packages = ["btcec"]
pruneopts = "UT"
- revision = "67e573d211ace594f1366b4ce9d39726c4b19bd0"
+ revision = "7d2daa5bfef28c5e282571bc06416516936115ee"
[[projects]]
branch = "master"
@@ -168,12 +168,12 @@
revision = "816b6608b3c8c1e871bc9cf777f390e2532081fe"
[[projects]]
- digest = "1:544229a3ca0fb2dd5ebc2896d3d2ff7ce096d9751635301e44e37e761349ee70"
+ digest = "1:547f5df5f708c880f0af507317c8d022b8d62053a5cb075e23c6eeed09eb2e4e"
name = "github.com/fortytw2/leaktest"
packages = ["."]
pruneopts = "UT"
- revision = "a5ef70473c97b71626b9abeda80ee92ba2a7de9e"
- version = "v1.2.0"
+ revision = "9a23578d06a26ec1b47bfc8965bf5e7011df8bd6"
+ version = "v1.3.0"
[[projects]]
branch = "master"
@@ -205,7 +205,7 @@
name = "github.com/gopherjs/gopherjs"
packages = ["js"]
pruneopts = "UT"
- revision = "0766667cb4d1cfb8d5fde1fe210ae41ead3cf589"
+ revision = "d547d1d9531ed93dbdebcbff7f83e7c876a1e0ee"
[[projects]]
digest = "1:c79fb010be38a59d657c48c6ba1d003a8aa651fa56b579d959d74573b7dff8e1"
@@ -248,28 +248,28 @@
revision = "4896c6bd164172da9f78789f233b470a3a6fb359"
[[projects]]
- digest = "1:1e15f4e455f94aeaedfcf9c75b3e1c449b5acba1551c58446b4b45be507c707b"
+ digest = "1:4b63210654b1f2b664f74ec434a1bb1cb442b3d75742cc064a10808d1cca6361"
name = "github.com/jtolds/gls"
packages = ["."]
pruneopts = "UT"
- revision = "77f18212c9c7edc9bd6a33d383a7b545ce62f064"
- version = "v4.2.1"
+ revision = "b4936e06046bbecbb94cae9c18127ebe510a2cb9"
+ version = "v4.20"
[[projects]]
branch = "master"
- digest = "1:cdc32003a67007f608c767cfbea5b7a07ed7418ec9aed579707e3185086a6878"
+ digest = "1:7d1a655e1f16ccaf1adb026bdeece28499ecb0ead32d32accc6ed6f2c40cacee"
name = "github.com/juju/errors"
packages = ["."]
pruneopts = "UT"
- revision = "a4583d0a56eac4bdd939e38050d0c69abe0a9b41"
+ revision = "089d3ea4e4d597bd98acac068193d341983326a3"
[[projects]]
branch = "master"
- digest = "1:901625a0300fa83074dcf2510424c26a19dc3edadf67b34ca45a78f879ac4b0c"
+ digest = "1:957b15d94d4771a424b6ccb959214fe8caafb7d791d0f588ac572b7cdc894457"
name = "github.com/knq/snaker"
packages = ["."]
pruneopts = "UT"
- revision = "d9ad1e7f342a5b58202aa92c5f1106d7bb8b9c73"
+ revision = "2bc8a4db468777180ca38d551094b83073bed25f"
[[projects]]
digest = "1:0a69a1c0db3591fcefb47f115b224592c8dfa4368b7ba9fae509d5e16cdc95c8"
@@ -296,12 +296,12 @@
version = "v0.0.4"
[[projects]]
- digest = "1:cdb899c199f907ac9fb50495ec71212c95cb5b0e0a8ee0800da0238036091033"
+ digest = "1:0356f3312c9bd1cbeda81505b7fd437501d8e778ab66998ef69f00d7f9b3a0d7"
name = "github.com/mattn/go-runewidth"
packages = ["."]
pruneopts = "UT"
- revision = "ce7b0b5c7b45a81508558cd1dba6bb1e4ddb51bb"
- version = "v0.0.3"
+ revision = "3ee7d812e62a0804a7d0a324e0249ca2db3476d3"
+ version = "v0.0.4"
[[projects]]
digest = "1:ff5ebae34cfbf047d505ee150de27e60570e8c394b3b8fdbb720ff6ac71985fc"
@@ -312,12 +312,12 @@
version = "v1.0.1"
[[projects]]
- digest = "1:c22d250c583ec1136ecad8b74a43f408c08ddbbcbae715341ec4a49f332628e0"
+ digest = "1:702ff5d8a0196ccb0627f35996efd1081be00c8ae1719402adbffc6e0f8f59ac"
name = "github.com/miekg/dns"
packages = ["."]
pruneopts = "UT"
- revision = "915ca3d5ffd945235828a097c917311a9d86ebb4"
- version = "v1.0.14"
+ revision = "7586a3cbe8ccfc63f82de3ab2ceeb08c9939af72"
+ version = "v1.1.1"
[[projects]]
branch = "master"
@@ -327,6 +327,14 @@
pruneopts = "UT"
revision = "3f5f724cb5b182a5c278d6d3d55b40e7f8c2efb4"
+[[projects]]
+ branch = "master"
+ digest = "1:84bd7f8a2e0bcd53ddc33c3b47c34c1fe340c8632cbe928f7f8ae10ec6ecdd62"
+ name = "github.com/mohae/deepcopy"
+ packages = ["."]
+ pruneopts = "UT"
+ revision = "c48cc78d482608239f6c4c92a4abd87eb8761c90"
+
[[projects]]
digest = "1:5e73b34a27d827212102605789de00bd411b2e434812133c83935fe9897c75e1"
name = "github.com/philhofer/fwd"
@@ -345,14 +353,14 @@
[[projects]]
branch = "master"
- digest = "1:f696f304d2a14745859a153f1041b66e0e2cf150eff731beb6431e93e27ddc5c"
+ digest = "1:4b7c4ceaf165e269b1ba0105773f0b58d7e85adc91789dcaee14a92295ebcf29"
name = "github.com/prometheus/client_golang"
packages = [
"prometheus",
"prometheus/internal",
]
pruneopts = "UT"
- revision = "f30f428035633da15d00d3dfefb0128c5e569ef4"
+ revision = "ec7db558bc4ce351daf4ecd5ac46f145abf62300"
[[projects]]
branch = "master"
@@ -364,7 +372,7 @@
[[projects]]
branch = "master"
- digest = "1:6366b518dc6e520027f67ad03792b99e370468aac47c4102bddd56ae6ce780e5"
+ digest = "1:8a22a0df1e95f3c208ccc9707d92fbb97a22783a45395aa4decf2c19fe8fd242"
name = "github.com/prometheus/common"
packages = [
"expfmt",
@@ -373,11 +381,11 @@
"version",
]
pruneopts = "UT"
- revision = "7e9e6cabbd393fc208072eedef99188d0ce788b6"
+ revision = "67670fe90761d7ff18ec1d640135e53b9198328f"
[[projects]]
branch = "master"
- digest = "1:ef74914912f99c79434d9c09658274678bc85080ebe3ab32bec3940ebce5e1fc"
+ digest = "1:d39e7c7677b161c2dd4c635a2ac196460608c7d8ba5337cc8cae5825a2681f8f"
name = "github.com/prometheus/procfs"
packages = [
".",
@@ -386,7 +394,7 @@
"xfs",
]
pruneopts = "UT"
- revision = "185b4288413d2a0dd0806f78c90dde719829e5ae"
+ revision = "1dc9a6cbc91aacc3e8b2d63db4d2e957a5394ac4"
[[projects]]
branch = "master"
@@ -428,7 +436,7 @@
[[projects]]
branch = "master"
- digest = "1:d3384958d1ace51e2187c9747d806eee27d1aebdb1a4df798058a8cacc19b379"
+ digest = "1:25913ccf8c947d80f59e211b41225a85bd8e491f22b61a8c7e04f5774b2c01d3"
name = "github.com/siddontang/go-mysql"
packages = [
"mysql",
@@ -436,7 +444,7 @@
"server",
]
pruneopts = "UT"
- revision = "7f644882a1f315e77bfda60b4f689a45a2eec228"
+ revision = "d8fba0f23b9b3abe91c6f01842c72edd925ccb93"
source = "github.com/CovenantSQL/go-mysql"
[[projects]]
@@ -473,7 +481,7 @@
[[projects]]
branch = "master"
- digest = "1:59483b8e8183f10ab21a85ba1f4cbb4a2335d48891801f79ed7b9499f44d383c"
+ digest = "1:685fdfea42d825ebd39ee0994354b46c374cf2c2b2d97a41a8dee1807c6a9b62"
name = "github.com/syndtr/goleveldb"
packages = [
"leveldb",
@@ -490,7 +498,7 @@
"leveldb/util",
]
pruneopts = "UT"
- revision = "6b91fda63f2e36186f1c9d0e48578defb69c5d43"
+ revision = "b001fa50d6b27f3f0bb175a87d0cb55426d0a0ae"
[[projects]]
digest = "1:d9eb1d964a449cf51455fdac2ec3451c664af8e8b93c23d9c31d22b84ea82fde"
@@ -510,35 +518,27 @@
[[projects]]
branch = "master"
- digest = "1:8fa03cb74ac5c89555750948a9f225a73bf34c9aa87ee9202b8e88c9f3b5d6fb"
- name = "github.com/ulule/deepcopier"
- packages = ["."]
- pruneopts = "UT"
- revision = "ca99b135e50f526fde9cd88705f0ff2f3f95b77c"
-
-[[projects]]
- branch = "master"
- digest = "1:4a2baa112d6e7d222e78fc4702796592a47c5a6341e34e9b0ee39582e32cdf99"
+ digest = "1:cbe0326a31e9351aa78c5ae05e90ee99beb7f1f9b4f0aa9438d8174cc91a08aa"
name = "github.com/xo/dburl"
packages = ["."]
pruneopts = "UT"
- revision = "e33971d4c1320eca4c3585875e410c1eeadc4c3a"
+ revision = "f3ca07bd6afccbc084c872c7b49d666f50d0a1f6"
[[projects]]
branch = "master"
- digest = "1:3863946ace74cbd518a33a2e8dd145a13aba1fc37a0e89788154083f183fca11"
+ digest = "1:2f33ea228f93fce4751f285a233ca262f51afa47336a1695f8967c9e83a1f42d"
name = "github.com/xo/tblfmt"
packages = ["."]
pruneopts = "UT"
- revision = "e82d5611beb24993cc6afc59cdacf6e598891d12"
+ revision = "0b109994b29d40a7e603c678b3d6823dbc0a1309"
[[projects]]
branch = "master"
- digest = "1:f7078a085c09e48542f25bd1e44e715bbfc6563972203c978456dc698ac6f886"
+ digest = "1:9614931ff8b2d0f729c231d2e3a0ba7aec965a1a1a424452245ac732f8b2b759"
name = "github.com/xo/terminfo"
packages = ["."]
pruneopts = "UT"
- revision = "be18a85ebefc4593a0920d4141c9bd2c9b3d8ef7"
+ revision = "9ba9fdd85c0deab43602b39254692af97d589b4c"
[[projects]]
branch = "master"
@@ -576,7 +576,7 @@
[[projects]]
branch = "master"
- digest = "1:583f2f436bab7b59a7bd3e759f1375b06f460760ed1f9235604d143eaab83009"
+ digest = "1:cfd661f1a52594117f2a753bb640a86d4dbf3e0d778c2641bfbc750e6a1c8be7"
name = "golang.org/x/crypto"
packages = [
"ed25519",
@@ -584,11 +584,11 @@
"ssh/terminal",
]
pruneopts = "UT"
- revision = "4d3f4d9ffa16a13f451c3b2999e9c49e9750bf06"
+ revision = "505ab145d0a99da450461ae2c1a9f6cd10d1f447"
[[projects]]
branch = "master"
- digest = "1:67ee3460c086005f76f49c4d5f38a80ce11d68986de22979c75bf04e8372db9c"
+ digest = "1:c079de57d24956ee13947278c02201b9cb478438b84d86fb2df5a891ea4a10c7"
name = "golang.org/x/net"
packages = [
"bpf",
@@ -601,26 +601,26 @@
"ipv6",
]
pruneopts = "UT"
- revision = "b7e296877c6e5e01665044d943c8e6d10ce72a99"
+ revision = "927f97764cc334a6575f4b7a1584a147864d5723"
[[projects]]
branch = "master"
- digest = "1:417d27a82efb8473554234a282be33d23b0d6adc121e636b55950f913ac071d6"
+ digest = "1:3d5e79e10549fd9119cbefd614b6d351ef5bd0be2f2b103a4199788e784cbc68"
name = "golang.org/x/sys"
packages = [
"unix",
"windows",
]
pruneopts = "UT"
- revision = "9b800f95dbbc54abff0acf7ee32d88ba4e328c89"
+ revision = "b4a75ba826a64a70990f11a225237acd6ef35c9f"
[[projects]]
- digest = "1:342378ac4dcb378a5448dd723f0784ae519383532f5e70ade24132c4c8693202"
+ digest = "1:4d2e5a73dc1500038e504a8d78b986630e3626dc027bc030ba5c75da257cdb96"
name = "gopkg.in/yaml.v2"
packages = ["."]
pruneopts = "UT"
- revision = "5420a8b6744d3b0345ab293f6fcba19c978f1183"
- version = "v2.2.1"
+ revision = "51d6538a90f86fe93ac480b35f37b2be17fef232"
+ version = "v2.2.2"
[solve-meta]
analyzer-name = "dep"
@@ -647,6 +647,7 @@
"github.com/lufia/iostat",
"github.com/miekg/dns",
"github.com/minio/blake2b-simd",
+ "github.com/mohae/deepcopy",
"github.com/pkg/errors",
"github.com/prometheus/client_golang/prometheus",
"github.com/prometheus/client_model/go",
@@ -665,7 +666,6 @@
"github.com/syndtr/goleveldb/leveldb/util",
"github.com/tchap/go-patricia/patricia",
"github.com/ugorji/go/codec",
- "github.com/ulule/deepcopier",
"github.com/xo/dburl",
"github.com/xo/usql/drivers",
"github.com/xo/usql/env",
diff --git a/vendor/github.com/CovenantSQL/sqlparser/README.md b/vendor/github.com/CovenantSQL/sqlparser/README.md
index 58d475967..d043b726a 100644
--- a/vendor/github.com/CovenantSQL/sqlparser/README.md
+++ b/vendor/github.com/CovenantSQL/sqlparser/README.md
@@ -1,6 +1,6 @@
-# sqlparser [](https://travis-ci.org/xwb1989/sqlparser) [](https://coveralls.io/github/xwb1989/sqlparser) [](https://goreportcard.com/report/github.com/xwb1989/sqlparser) [](https://godoc.org/github.com/xwb1989/sqlparser)
+# sqlparser [](https://goreportcard.com/report/github.com/CovenantSQL/sqlparser) [](https://godoc.org/github.com/CovenantSQL/sqlparser)
-Go package for parsing MySQL SQL queries.
+Go package for parsing SQLite or SQL-92 queries.
## Notice
@@ -13,7 +13,7 @@ It applies the same LICENSE as vitessio/vitess.
```go
import (
- "github.com/xwb1989/sqlparser"
+ "github.com/CovenantSQL/sqlparser"
)
```
@@ -49,102 +49,4 @@ for {
}
```
-See [parse_test.go](https://github.com/xwb1989/sqlparser/blob/master/parse_test.go) for more examples, or read the [godoc](https://godoc.org/github.com/xwb1989/sqlparser).
-
-## Porting Instructions
-
-You only need the below if you plan to try and keep this library up to date with [vitessio/vitess](https://github.com/vitessio/vitess).
-
-### Keeping up to date
-
-```bash
-shopt -s nullglob
-VITESS=${GOPATH?}/src/vitess.io/vitess/go/
-XWB1989=${GOPATH?}/src/github.com/xwb1989/sqlparser/
-
-# Create patches for everything that changed
-LASTIMPORT=1b7879cb91f1dfe1a2dfa06fea96e951e3a7aec5
-for path in ${VITESS?}/{vt/sqlparser,sqltypes,bytes2,hack}; do
- cd ${path}
- git format-patch ${LASTIMPORT?} .
-done;
-
-# Apply patches to the dependencies
-cd ${XWB1989?}
-git am --directory dependency -p2 ${VITESS?}/{sqltypes,bytes2,hack}/*.patch
-
-# Apply the main patches to the repo
-cd ${XWB1989?}
-git am -p4 ${VITESS?}/vt/sqlparser/*.patch
-
-# If you encounter diff failures, manually fix them with
-patch -p4 < .git/rebase-apply/patch
-...
-git add name_of_files
-git am --continue
-
-# Cleanup
-rm ${VITESS?}/{sqltypes,bytes2,hack}/*.patch ${VITESS?}/*.patch
-
-# and Finally update the LASTIMPORT in this README.
-```
-
-### Fresh install
-
-TODO: Change these instructions to use git to copy the files, that'll make later patching easier.
-
-```bash
-VITESS=${GOPATH?}/src/vitess.io/vitess/go/
-XWB1989=${GOPATH?}/src/github.com/xwb1989/sqlparser/
-
-cd ${XWB1989?}
-
-# Copy all the code
-cp -pr ${VITESS?}/vt/sqlparser/ .
-cp -pr ${VITESS?}/sqltypes dependency
-cp -pr ${VITESS?}/bytes2 dependency
-cp -pr ${VITESS?}/hack dependency
-
-# Delete some code we haven't ported
-rm dependency/sqltypes/arithmetic.go dependency/sqltypes/arithmetic_test.go dependency/sqltypes/event_token.go dependency/sqltypes/event_token_test.go dependency/sqltypes/proto3.go dependency/sqltypes/proto3_test.go dependency/sqltypes/query_response.go dependency/sqltypes/result.go dependency/sqltypes/result_test.go
-
-# Some automated fixes
-
-# Fix imports
-sed -i '.bak' 's_vitess.io/vitess/go/vt/proto/query_github.com/xwb1989/sqlparser/dependency/querypb_g' *.go dependency/sqltypes/*.go
-sed -i '.bak' 's_vitess.io/vitess/go/_github.com/xwb1989/sqlparser/dependency/_g' *.go dependency/sqltypes/*.go
-
-# Copy the proto, but basically drop everything we don't want
-cp -pr ${VITESS?}/vt/proto/query dependency/querypb
-
-sed -i '.bak' 's_.*Descriptor.*__g' dependency/querypb/*.go
-sed -i '.bak' 's_.*ProtoMessage.*__g' dependency/querypb/*.go
-
-sed -i '.bak' 's/proto.CompactTextString(m)/"TODO"/g' dependency/querypb/*.go
-sed -i '.bak' 's/proto.EnumName/EnumName/g' dependency/querypb/*.go
-
-sed -i '.bak' 's/proto.Equal/reflect.DeepEqual/g' dependency/sqltypes/*.go
-
-# Remove the error library
-sed -i '.bak' 's/vterrors.Errorf([^,]*, /fmt.Errorf(/g' *.go dependency/sqltypes/*.go
-sed -i '.bak' 's/vterrors.New([^,]*, /errors.New(/g' *.go dependency/sqltypes/*.go
-```
-
-### Testing
-
-```bash
-VITESS=${GOPATH?}/src/vitess.io/vitess/go/
-XWB1989=${GOPATH?}/src/github.com/xwb1989/sqlparser/
-
-cd ${XWB1989?}
-
-# Test, fix and repeat
-go test ./...
-
-# Finally make some diffs (for later reference)
-diff -u ${VITESS?}/sqltypes/ ${XWB1989?}/dependency/sqltypes/ > ${XWB1989?}/patches/sqltypes.patch
-diff -u ${VITESS?}/bytes2/ ${XWB1989?}/dependency/bytes2/ > ${XWB1989?}/patches/bytes2.patch
-diff -u ${VITESS?}/vt/proto/query/ ${XWB1989?}/dependency/querypb/ > ${XWB1989?}/patches/querypb.patch
-diff -u ${VITESS?}/vt/sqlparser/ ${XWB1989?}/ > ${XWB1989?}/patches/sqlparser.patch
-```
\ No newline at end of file
diff --git a/vendor/github.com/CovenantSQL/sqlparser/analyzer.go b/vendor/github.com/CovenantSQL/sqlparser/analyzer.go
index eff1c8f89..3a8471556 100644
--- a/vendor/github.com/CovenantSQL/sqlparser/analyzer.go
+++ b/vendor/github.com/CovenantSQL/sqlparser/analyzer.go
@@ -173,7 +173,7 @@ func IsValue(node Expr) bool {
switch v := node.(type) {
case *SQLVal:
switch v.Type {
- case StrVal, HexVal, IntVal, ValArg:
+ case StrVal, HexVal, IntVal, ValArg, PosArg:
return true
}
}
@@ -212,7 +212,7 @@ func NewPlanValue(node Expr) (sqltypes.PlanValue, error) {
switch node := node.(type) {
case *SQLVal:
switch node.Type {
- case ValArg:
+ case ValArg, PosArg:
return sqltypes.PlanValue{Key: string(node.Val[1:])}, nil
case IntVal:
n, err := sqltypes.NewIntegral(string(node.Val))
diff --git a/vendor/github.com/CovenantSQL/sqlparser/ast.go b/vendor/github.com/CovenantSQL/sqlparser/ast.go
index c850c5006..014d914af 100644
--- a/vendor/github.com/CovenantSQL/sqlparser/ast.go
+++ b/vendor/github.com/CovenantSQL/sqlparser/ast.go
@@ -94,6 +94,36 @@ func ParseNext(tokenizer *Tokenizer) (Statement, error) {
return tokenizer.ParseTree, nil
}
+// ParseMultiple returns multiple parsed original query and parsed statement.
+func ParseMultiple(tokenizer *Tokenizer) (queries []string, statements []Statement, err error) {
+ var lastPos int
+
+ for {
+ if tokenizer.lastChar == ';' {
+ tokenizer.next()
+ tokenizer.skipBlank()
+ lastPos = tokenizer.Position - 1
+ }
+ if tokenizer.lastChar == eofChar {
+ break
+ }
+
+ tokenizer.reset()
+ tokenizer.multi = true
+ if yyParse(tokenizer) != 0 && tokenizer.partialDDL == nil {
+ err = tokenizer.LastError
+ return
+ }
+ if tokenizer.partialDDL != nil {
+ statements = append(statements, tokenizer.partialDDL)
+ } else {
+ statements = append(statements, tokenizer.ParseTree)
+ }
+ queries = append(queries, string(tokenizer.buf[lastPos:tokenizer.Position-1]))
+ }
+ return
+}
+
// SplitStatement returns the first sql statement up to either a ; or EOF
// and the remainder from the given buffer
func SplitStatement(blob string) (string, string, error) {
@@ -207,16 +237,17 @@ type Statement interface {
SQLNode
}
-func (*Union) iStatement() {}
-func (*Select) iStatement() {}
-func (*Stream) iStatement() {}
-func (*Insert) iStatement() {}
-func (*Update) iStatement() {}
-func (*Delete) iStatement() {}
-func (*Set) iStatement() {}
-func (*DBDDL) iStatement() {}
-func (*DDL) iStatement() {}
-func (*Show) iStatement() {}
+func (*Union) iStatement() {}
+func (*Select) iStatement() {}
+func (*Stream) iStatement() {}
+func (*Insert) iStatement() {}
+func (*Update) iStatement() {}
+func (*Delete) iStatement() {}
+func (*Set) iStatement() {}
+func (*DBDDL) iStatement() {}
+func (*DDL) iStatement() {}
+func (*Show) iStatement() {}
+func (*Explain) iStatement() {}
// ParenSelect can actually not be a top level statement,
// but we have to allow it because it's a requirement
@@ -1273,6 +1304,19 @@ func (node *Show) walkSubtree(visit Visit) error {
return nil
}
+// Explain represents a explain statement.
+type Explain struct {
+}
+
+// Format formats the node.
+func (node *Explain) Format(buf *TrackedBuffer) {
+ buf.WriteString("explain")
+}
+
+func (node *Explain) walkSubtree(visit Visit) error {
+ return nil
+}
+
// Comments represents a list of comments.
type Comments [][]byte
@@ -1753,35 +1797,33 @@ type Expr interface {
SQLNode
}
-func (*AndExpr) iExpr() {}
-func (*OrExpr) iExpr() {}
-func (*NotExpr) iExpr() {}
-func (*ParenExpr) iExpr() {}
-func (*ComparisonExpr) iExpr() {}
-func (*RangeCond) iExpr() {}
-func (*IsExpr) iExpr() {}
-func (*ExistsExpr) iExpr() {}
-func (*SQLVal) iExpr() {}
-func (*NullVal) iExpr() {}
-func (BoolVal) iExpr() {}
-func (*ColName) iExpr() {}
-func (ValTuple) iExpr() {}
-func (*Subquery) iExpr() {}
-func (ListArg) iExpr() {}
-func (*BinaryExpr) iExpr() {}
-func (*UnaryExpr) iExpr() {}
-func (*IntervalExpr) iExpr() {}
-func (*CollateExpr) iExpr() {}
-func (*FuncExpr) iExpr() {}
-func (*CaseExpr) iExpr() {}
-func (*ValuesFuncExpr) iExpr() {}
-func (*ConvertExpr) iExpr() {}
-func (*SubstrExpr) iExpr() {}
-func (*ConvertUsingExpr) iExpr() {}
-func (*MatchExpr) iExpr() {}
-func (*GroupConcatExpr) iExpr() {}
-func (*Default) iExpr() {}
-func (*TimeExpr) iExpr() {}
+func (*AndExpr) iExpr() {}
+func (*OrExpr) iExpr() {}
+func (*NotExpr) iExpr() {}
+func (*ParenExpr) iExpr() {}
+func (*ComparisonExpr) iExpr() {}
+func (*RangeCond) iExpr() {}
+func (*IsExpr) iExpr() {}
+func (*ExistsExpr) iExpr() {}
+func (*SQLVal) iExpr() {}
+func (*NullVal) iExpr() {}
+func (BoolVal) iExpr() {}
+func (*ColName) iExpr() {}
+func (ValTuple) iExpr() {}
+func (*Subquery) iExpr() {}
+func (ListArg) iExpr() {}
+func (*BinaryExpr) iExpr() {}
+func (*UnaryExpr) iExpr() {}
+func (*IntervalExpr) iExpr() {}
+func (*CollateExpr) iExpr() {}
+func (*FuncExpr) iExpr() {}
+func (*CaseExpr) iExpr() {}
+func (*ValuesFuncExpr) iExpr() {}
+func (*ConvertExpr) iExpr() {}
+func (*MatchExpr) iExpr() {}
+func (*GroupConcatExpr) iExpr() {}
+func (*Default) iExpr() {}
+func (*TimeExpr) iExpr() {}
// ReplaceExpr finds the from expression from root
// and replaces it with to. If from matches root,
@@ -2108,6 +2150,7 @@ const (
HexVal
ValArg
BitVal
+ PosArg
)
// SQLVal represents a single value.
@@ -2151,6 +2194,11 @@ func NewValArg(in []byte) *SQLVal {
return &SQLVal{Type: ValArg, Val: in}
}
+// NewPosArg build a new PosArg.
+func NewPosArg(in []byte) *SQLVal {
+ return &SQLVal{Type: PosArg, Val: in}
+}
+
// Format formats the node.
func (node *SQLVal) Format(buf *TrackedBuffer) {
switch node.Type {
@@ -2164,6 +2212,8 @@ func (node *SQLVal) Format(buf *TrackedBuffer) {
buf.Myprintf("B'%s'", []byte(node.Val))
case ValArg:
buf.WriteArg(string(node.Val))
+ case PosArg:
+ buf.WriteArg("?")
default:
panic("unexpected")
}
@@ -2625,40 +2675,6 @@ func (node *ValuesFuncExpr) replace(from, to Expr) bool {
return false
}
-// SubstrExpr represents a call to SubstrExpr(column, value_expression) or SubstrExpr(column, value_expression,value_expression)
-// also supported syntax SubstrExpr(column from value_expression for value_expression)
-type SubstrExpr struct {
- Name *ColName
- From Expr
- To Expr
-}
-
-// Format formats the node.
-func (node *SubstrExpr) Format(buf *TrackedBuffer) {
-
- if node.To == nil {
- buf.Myprintf("substr(%v, %v)", node.Name, node.From)
- } else {
- buf.Myprintf("substr(%v, %v, %v)", node.Name, node.From, node.To)
- }
-}
-
-func (node *SubstrExpr) replace(from, to Expr) bool {
- return replaceExprs(from, to, &node.From, &node.To)
-}
-
-func (node *SubstrExpr) walkSubtree(visit Visit) error {
- if node == nil {
- return nil
- }
- return Walk(
- visit,
- node.Name,
- node.From,
- node.To,
- )
-}
-
// ConvertExpr represents a call to CONVERT(expr, type)
// or it's equivalent CAST(expr AS type). Both are rewritten to the former.
type ConvertExpr struct {
@@ -2686,31 +2702,6 @@ func (node *ConvertExpr) replace(from, to Expr) bool {
return replaceExprs(from, to, &node.Expr)
}
-// ConvertUsingExpr represents a call to CONVERT(expr USING charset).
-type ConvertUsingExpr struct {
- Expr Expr
- Type string
-}
-
-// Format formats the node.
-func (node *ConvertUsingExpr) Format(buf *TrackedBuffer) {
- buf.Myprintf("convert(%v using %s)", node.Expr, node.Type)
-}
-
-func (node *ConvertUsingExpr) walkSubtree(visit Visit) error {
- if node == nil {
- return nil
- }
- return Walk(
- visit,
- node.Expr,
- )
-}
-
-func (node *ConvertUsingExpr) replace(from, to Expr) bool {
- return replaceExprs(from, to, &node.Expr)
-}
-
// ConvertType represents the type in call to CONVERT(expr, type)
type ConvertType struct {
Type string
diff --git a/vendor/github.com/CovenantSQL/sqlparser/dependency/sqltypes/value.go b/vendor/github.com/CovenantSQL/sqlparser/dependency/sqltypes/value.go
index 126555d04..1fcc2810d 100644
--- a/vendor/github.com/CovenantSQL/sqlparser/dependency/sqltypes/value.go
+++ b/vendor/github.com/CovenantSQL/sqlparser/dependency/sqltypes/value.go
@@ -324,7 +324,11 @@ func encodeBytesSQL(val []byte, b BinWriter) {
if encodedChar := SQLEncodeMap[ch]; encodedChar == DontEscape {
buf.WriteByte(ch)
} else {
- buf.WriteByte('\\')
+ if ch == '\'' {
+ buf.WriteByte('\'')
+ } else {
+ buf.WriteByte('\\')
+ }
buf.WriteByte(encodedChar)
}
}
@@ -358,7 +362,6 @@ var encodeRef = map[byte]byte{
'\r': 'r',
'\t': 't',
26: 'Z', // ctl-Z
- '\\': '\\',
}
func init() {
diff --git a/vendor/github.com/CovenantSQL/sqlparser/sql.go b/vendor/github.com/CovenantSQL/sqlparser/sql.go
index 54f4cdef6..de19d4c40 100644
--- a/vendor/github.com/CovenantSQL/sqlparser/sql.go
+++ b/vendor/github.com/CovenantSQL/sqlparser/sql.go
@@ -130,97 +130,98 @@ const INTEGRAL = 57384
const FLOAT = 57385
const HEXNUM = 57386
const VALUE_ARG = 57387
-const LIST_ARG = 57388
-const COMMENT = 57389
-const NULL = 57390
-const TRUE = 57391
-const FALSE = 57392
-const FULL = 57393
-const COLUMNS = 57394
-const OR = 57395
-const AND = 57396
-const NOT = 57397
-const BETWEEN = 57398
-const CASE = 57399
-const WHEN = 57400
-const THEN = 57401
-const ELSE = 57402
-const END = 57403
-const LE = 57404
-const GE = 57405
-const NE = 57406
-const IS = 57407
-const LIKE = 57408
-const REGEXP = 57409
-const IN = 57410
-const NULL_SAFE_NOTEQUAL = 57411
-const SHIFT_LEFT = 57412
-const SHIFT_RIGHT = 57413
-const DIV = 57414
-const MOD = 57415
-const UNARY = 57416
-const INTERVAL = 57417
-const CREATE = 57418
-const ALTER = 57419
-const DROP = 57420
-const RENAME = 57421
-const ADD = 57422
-const TABLE = 57423
-const INDEX = 57424
-const TO = 57425
-const IGNORE = 57426
-const IF = 57427
-const UNIQUE = 57428
-const PRIMARY = 57429
-const COLUMN = 57430
-const CONSTRAINT = 57431
-const FOREIGN = 57432
-const SHOW = 57433
-const DESCRIBE = 57434
-const DATE = 57435
-const ESCAPE = 57436
-const TINYINT = 57437
-const SMALLINT = 57438
-const MEDIUMINT = 57439
-const INT = 57440
-const INTEGER = 57441
-const BIGINT = 57442
-const INTNUM = 57443
-const REAL = 57444
-const DOUBLE = 57445
-const FLOAT_TYPE = 57446
-const DECIMAL = 57447
-const NUMERIC = 57448
-const TIME = 57449
-const TIMESTAMP = 57450
-const DATETIME = 57451
-const YEAR = 57452
-const CHAR = 57453
-const VARCHAR = 57454
-const BOOL = 57455
-const NCHAR = 57456
-const TEXT = 57457
-const TINYTEXT = 57458
-const MEDIUMTEXT = 57459
-const LONGTEXT = 57460
-const BLOB = 57461
-const TINYBLOB = 57462
-const MEDIUMBLOB = 57463
-const LONGBLOB = 57464
-const AUTO_INCREMENT = 57465
-const SIGNED = 57466
-const UNSIGNED = 57467
-const ZEROFILL = 57468
-const TABLES = 57469
-const CURRENT_TIMESTAMP = 57470
-const CURRENT_DATE = 57471
-const CURRENT_TIME = 57472
-const REPLACE = 57473
-const CAST = 57474
-const SUBSTR = 57475
-const GROUP_CONCAT = 57476
-const SEPARATOR = 57477
-const UNUSED = 57478
+const POS_ARG = 57388
+const LIST_ARG = 57389
+const COMMENT = 57390
+const NULL = 57391
+const TRUE = 57392
+const FALSE = 57393
+const FULL = 57394
+const COLUMNS = 57395
+const OR = 57396
+const AND = 57397
+const NOT = 57398
+const BETWEEN = 57399
+const CASE = 57400
+const WHEN = 57401
+const THEN = 57402
+const ELSE = 57403
+const END = 57404
+const LE = 57405
+const GE = 57406
+const NE = 57407
+const IS = 57408
+const LIKE = 57409
+const REGEXP = 57410
+const IN = 57411
+const NULL_SAFE_NOTEQUAL = 57412
+const SHIFT_LEFT = 57413
+const SHIFT_RIGHT = 57414
+const DIV = 57415
+const MOD = 57416
+const UNARY = 57417
+const INTERVAL = 57418
+const CREATE = 57419
+const ALTER = 57420
+const DROP = 57421
+const RENAME = 57422
+const ADD = 57423
+const TABLE = 57424
+const INDEX = 57425
+const TO = 57426
+const IGNORE = 57427
+const IF = 57428
+const UNIQUE = 57429
+const PRIMARY = 57430
+const COLUMN = 57431
+const CONSTRAINT = 57432
+const FOREIGN = 57433
+const SHOW = 57434
+const DESCRIBE = 57435
+const DATE = 57436
+const ESCAPE = 57437
+const EXPLAIN = 57438
+const TINYINT = 57439
+const SMALLINT = 57440
+const MEDIUMINT = 57441
+const INT = 57442
+const INTEGER = 57443
+const BIGINT = 57444
+const INTNUM = 57445
+const REAL = 57446
+const DOUBLE = 57447
+const FLOAT_TYPE = 57448
+const DECIMAL = 57449
+const NUMERIC = 57450
+const TIME = 57451
+const TIMESTAMP = 57452
+const DATETIME = 57453
+const YEAR = 57454
+const CHAR = 57455
+const VARCHAR = 57456
+const BOOL = 57457
+const NCHAR = 57458
+const TEXT = 57459
+const TINYTEXT = 57460
+const MEDIUMTEXT = 57461
+const LONGTEXT = 57462
+const BLOB = 57463
+const TINYBLOB = 57464
+const MEDIUMBLOB = 57465
+const LONGBLOB = 57466
+const AUTO_INCREMENT = 57467
+const SIGNED = 57468
+const UNSIGNED = 57469
+const ZEROFILL = 57470
+const TABLES = 57471
+const CURRENT_TIMESTAMP = 57472
+const CURRENT_DATE = 57473
+const CURRENT_TIME = 57474
+const REPLACE = 57475
+const CAST = 57476
+const GROUP_CONCAT = 57477
+const SEPARATOR = 57478
+const UNUSED = 57479
var yyToknames = [...]string{
"$end",
@@ -271,6 +272,7 @@ var yyToknames = [...]string{
"FLOAT",
"HEXNUM",
"VALUE_ARG",
+ "POS_ARG",
"LIST_ARG",
"COMMENT",
"NULL",
@@ -334,6 +336,7 @@ var yyToknames = [...]string{
"DESCRIBE",
"DATE",
"ESCAPE",
+ "EXPLAIN",
"TINYINT",
"SMALLINT",
"MEDIUMINT",
@@ -372,7 +375,6 @@ var yyToknames = [...]string{
"CURRENT_TIME",
"REPLACE",
"CAST",
- "SUBSTR",
"GROUP_CONCAT",
"SEPARATOR",
"UNUSED",
@@ -392,610 +394,608 @@ var yyExca = [...]int{
-1, 3,
5, 17,
-2, 4,
- -1, 114,
- 1, 156,
- 5, 156,
- 11, 156,
- 12, 156,
- 13, 156,
- 14, 156,
- 16, 156,
- 27, 156,
- 30, 156,
- 31, 156,
- 33, 156,
- 35, 156,
- 36, 156,
- 37, 156,
- 38, 156,
- 40, 156,
- 41, 156,
- 154, 156,
- -2, 169,
- -1, 183,
- 92, 356,
- -2, 352,
+ -1, 116,
+ 1, 157,
+ 5, 157,
+ 11, 157,
+ 12, 157,
+ 13, 157,
+ 14, 157,
+ 16, 157,
+ 27, 157,
+ 30, 157,
+ 31, 157,
+ 33, 157,
+ 35, 157,
+ 36, 157,
+ 37, 157,
+ 38, 157,
+ 40, 157,
+ 41, 157,
+ 155, 157,
+ -2, 170,
-1, 184,
- 92, 357,
- -2, 353,
- -1, 402,
+ 93, 353,
+ -2, 349,
+ -1, 185,
+ 93, 354,
+ -2, 350,
+ -1, 400,
5, 17,
- -2, 325,
- -1, 519,
- 92, 359,
- -2, 355,
- -1, 551,
+ -2, 322,
+ -1, 516,
+ 93, 356,
+ -2, 352,
+ -1, 547,
5, 18,
- -2, 228,
- -1, 609,
+ -2, 226,
+ -1, 603,
5, 18,
- -2, 326,
- -1, 672,
+ -2, 323,
+ -1, 665,
5, 17,
- -2, 328,
- -1, 732,
+ -2, 325,
+ -1, 722,
5, 18,
- -2, 329,
+ -2, 326,
}
const yyPrivate = 57344
-const yyLast = 4079
+const yyLast = 4076
var yyAct = [...]int{
- 184, 381, 623, 136, 534, 429, 459, 514, 337, 535,
- 142, 99, 31, 587, 428, 434, 207, 3, 406, 46,
- 168, 526, 518, 94, 94, 489, 474, 147, 170, 440,
- 405, 206, 119, 464, 546, 430, 335, 455, 94, 44,
- 425, 210, 97, 186, 197, 134, 30, 111, 715, 138,
- 132, 516, 566, 116, 110, 447, 627, 628, 629, 630,
- 705, 122, 703, 466, 631, 684, 465, 123, 465, 109,
- 126, 107, 638, 442, 84, 85, 91, 95, 121, 258,
- 253, 252, 719, 128, 94, 83, 641, 353, 90, 94,
- 560, 352, 351, 361, 362, 354, 355, 356, 357, 358,
- 359, 360, 353, 612, 594, 125, 667, 94, 544, 139,
- 187, 478, 380, 133, 341, 188, 94, 94, 94, 171,
- 25, 189, 543, 94, 527, 588, 94, 86, 94, 94,
- 340, 339, 88, 87, 94, 251, 339, 124, 527, 131,
- 601, 444, 130, 685, 683, 25, 341, 441, 445, 262,
- 344, 341, 448, 104, 496, 442, 260, 115, 632, 98,
- 192, 374, 375, 376, 377, 378, 564, 494, 495, 493,
- 193, 214, 120, 580, 581, 582, 250, 687, 686, 254,
- 382, 256, 257, 249, 388, 569, 334, 24, 26, 15,
- 16, 127, 94, 398, 568, 596, 94, 94, 94, 94,
- 397, 340, 339, 28, 22, 94, 567, 402, 669, 94,
- 421, 422, 94, 492, 731, 408, 46, 341, 720, 721,
- 28, 625, 407, 137, 25, 423, 726, 395, 396, 441,
- 120, 340, 339, 439, 438, 208, 433, 356, 357, 358,
- 359, 360, 353, 561, 411, 404, 413, 341, 419, 435,
- 410, 512, 412, 424, 462, 461, 680, 679, 725, 94,
- 94, 340, 339, 371, 373, 354, 355, 356, 357, 358,
- 359, 360, 353, 633, 18, 19, 20, 341, 471, 137,
- 343, 636, 635, 457, 458, 611, 137, 467, 379, 21,
- 23, 383, 384, 385, 386, 520, 389, 482, 484, 485,
- 390, 391, 392, 342, 483, 520, 137, 195, 137, 607,
- 403, 195, 468, 469, 32, 115, 115, 115, 115, 340,
- 339, 216, 215, 472, 24, 426, 634, 542, 208, 27,
- 597, 471, 554, 393, 194, 341, 199, 202, 46, 200,
- 471, 201, 203, 547, 548, 400, 401, 195, 479, 480,
- 24, 486, 487, 471, 542, 28, 488, 28, 476, 497,
- 498, 499, 500, 501, 502, 503, 504, 505, 506, 507,
- 508, 509, 510, 511, 449, 490, 450, 451, 460, 46,
- 618, 24, 557, 28, 664, 521, 456, 452, 453, 454,
- 547, 548, 382, 522, 40, 570, 519, 418, 202, 513,
- 423, 433, 187, 671, 46, 12, 408, 416, 550, 415,
- 408, 417, 414, 523, 28, 563, 517, 528, 724, 723,
- 538, 408, 558, 463, 540, 255, 205, 551, 407, 46,
- 536, 533, 524, 135, 555, 553, 105, 532, 552, 103,
- 100, 694, 529, 530, 531, 101, 541, 549, 32, 433,
- 651, 693, 660, 661, 662, 659, 426, 663, 640, 259,
- 129, 117, 653, 34, 656, 658, 652, 94, 650, 559,
- 36, 654, 29, 94, 199, 202, 46, 200, 1, 201,
- 203, 655, 657, 89, 622, 437, 427, 118, 408, 39,
- 149, 436, 682, 25, 519, 573, 476, 571, 626, 433,
- 443, 579, 577, 383, 576, 584, 585, 586, 575, 565,
- 446, 574, 562, 219, 517, 220, 590, 218, 591, 583,
- 572, 537, 490, 25, 222, 221, 217, 649, 114, 595,
- 688, 204, 603, 604, 605, 606, 602, 209, 473, 41,
- 370, 608, 609, 610, 106, 677, 382, 600, 539, 394,
- 185, 692, 615, 639, 613, 46, 617, 46, 46, 599,
- 519, 614, 621, 408, 619, 433, 387, 592, 525, 620,
- 407, 94, 148, 481, 158, 433, 598, 433, 624, 155,
- 616, 351, 361, 362, 354, 355, 356, 357, 358, 359,
- 360, 353, 115, 157, 156, 46, 646, 145, 642, 644,
- 645, 647, 399, 345, 146, 140, 114, 113, 665, 190,
- 668, 666, 46, 46, 198, 433, 196, 670, 545, 46,
- 112, 46, 470, 714, 637, 676, 555, 672, 14, 33,
- 648, 108, 674, 675, 11, 372, 536, 593, 46, 678,
- 35, 433, 46, 10, 17, 9, 8, 169, 7, 6,
- 5, 697, 4, 698, 696, 102, 37, 38, 433, 408,
- 701, 13, 433, 2, 0, 96, 691, 713, 137, 712,
- 92, 92, 0, 690, 0, 0, 717, 648, 716, 0,
- 0, 46, 0, 722, 0, 92, 114, 114, 114, 114,
- 718, 0, 0, 0, 0, 0, 728, 0, 0, 114,
- 536, 624, 727, 382, 352, 351, 361, 362, 354, 355,
- 356, 357, 358, 359, 360, 353, 0, 0, 730, 0,
- 46, 46, 732, 0, 729, 0, 0, 537, 0, 0,
- 673, 92, 0, 735, 0, 0, 92, 0, 0, 0,
- 733, 734, 352, 351, 361, 362, 354, 355, 356, 357,
- 358, 359, 360, 353, 92, 0, 0, 689, 0, 0,
- 0, 0, 0, 92, 212, 92, 0, 0, 0, 0,
- 92, 0, 0, 92, 0, 92, 92, 681, 0, 0,
- 0, 261, 338, 137, 0, 0, 0, 0, 0, 0,
- 0, 537, 0, 25, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 699, 0, 700, 0, 702, 0, 704,
- 0, 706, 707, 708, 709, 710, 711, 0, 0, 352,
- 351, 361, 362, 354, 355, 356, 357, 358, 359, 360,
- 353, 0, 0, 0, 0, 0, 0, 491, 0, 92,
- 643, 0, 409, 92, 92, 92, 92, 0, 0, 0,
- 0, 0, 420, 0, 0, 0, 92, 0, 0, 212,
- 352, 351, 361, 362, 354, 355, 356, 357, 358, 359,
- 360, 353, 361, 362, 354, 355, 356, 357, 358, 359,
- 360, 353, 0, 67, 0, 515, 0, 144, 0, 0,
- 0, 0, 143, 0, 176, 59, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 28, 92, 92, 183, 160,
- 159, 161, 162, 163, 164, 589, 0, 165, 166, 167,
- 0, 0, 0, 0, 141, 153, 0, 175, 0, 0,
- 0, 0, 0, 0, 0, 352, 351, 361, 362, 354,
- 355, 356, 357, 358, 359, 360, 353, 150, 151, 336,
- 0, 0, 0, 181, 0, 152, 0, 154, 0, 0,
- 0, 0, 0, 114, 0, 0, 0, 0, 180, 0,
- 68, 0, 0, 56, 0, 0, 51, 0, 76, 71,
- 63, 57, 58, 47, 491, 69, 54, 55, 53, 66,
- 73, 74, 52, 81, 50, 80, 49, 65, 72, 77,
- 64, 61, 48, 75, 62, 60, 0, 70, 78, 82,
- 0, 177, 178, 179, 182, 172, 173, 174, 0, 79,
- 0, 0, 0, 0, 0, 0, 0, 338, 261, 0,
- 0, 0, 0, 409, 67, 0, 0, 409, 338, 338,
- 338, 0, 0, 0, 0, 0, 59, 0, 409, 0,
- 0, 233, 0, 238, 239, 240, 241, 242, 243, 45,
- 244, 245, 246, 247, 248, 234, 235, 236, 237, 223,
- 224, 0, 0, 225, 226, 227, 228, 229, 230, 231,
- 232, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 352, 351, 361, 362, 354, 355,
- 356, 357, 358, 359, 360, 353, 0, 0, 0, 0,
- 0, 0, 0, 0, 92, 409, 0, 0, 0, 338,
- 92, 68, 0, 0, 56, 0, 261, 51, 0, 76,
- 71, 63, 57, 58, 47, 0, 69, 54, 55, 53,
- 66, 73, 74, 52, 81, 50, 80, 49, 65, 72,
- 77, 64, 61, 48, 75, 62, 60, 0, 70, 78,
- 82, 0, 0, 338, 0, 0, 0, 0, 0, 0,
- 79, 0, 338, 0, 0, 0, 0, 0, 0, 0,
+ 185, 617, 530, 338, 380, 427, 172, 531, 511, 457,
+ 32, 170, 522, 487, 515, 583, 148, 208, 3, 47,
+ 404, 472, 207, 95, 95, 426, 101, 432, 438, 336,
+ 45, 423, 187, 136, 121, 542, 462, 428, 403, 95,
+ 453, 113, 211, 31, 99, 138, 706, 140, 173, 26,
+ 134, 198, 562, 513, 622, 623, 624, 445, 118, 621,
+ 124, 111, 625, 698, 696, 677, 112, 464, 463, 91,
+ 125, 128, 463, 109, 440, 26, 632, 85, 86, 123,
+ 259, 92, 96, 106, 130, 95, 84, 117, 254, 253,
+ 95, 122, 710, 353, 352, 362, 363, 355, 356, 357,
+ 358, 359, 360, 361, 354, 635, 141, 188, 87, 95,
+ 606, 589, 440, 89, 88, 189, 540, 476, 95, 95,
+ 95, 379, 135, 354, 190, 95, 446, 584, 95, 556,
+ 95, 95, 342, 127, 539, 660, 95, 340, 523, 523,
+ 133, 595, 252, 126, 678, 676, 494, 345, 132, 439,
+ 261, 100, 342, 437, 436, 26, 560, 626, 591, 492,
+ 493, 491, 344, 263, 194, 29, 209, 193, 355, 356,
+ 357, 358, 359, 360, 361, 354, 490, 381, 215, 680,
+ 386, 679, 565, 251, 250, 343, 255, 439, 257, 258,
+ 335, 564, 563, 95, 372, 341, 340, 95, 95, 95,
+ 95, 442, 341, 340, 721, 619, 95, 406, 443, 400,
+ 95, 342, 405, 95, 711, 712, 395, 47, 342, 378,
+ 129, 122, 382, 383, 384, 557, 387, 421, 431, 460,
+ 388, 389, 390, 341, 340, 139, 396, 673, 672, 409,
+ 401, 411, 658, 469, 139, 117, 117, 117, 117, 342,
+ 717, 402, 433, 419, 420, 422, 417, 716, 209, 459,
+ 95, 95, 150, 408, 627, 410, 517, 25, 27, 15,
+ 16, 353, 352, 362, 363, 355, 356, 357, 358, 359,
+ 360, 361, 354, 601, 22, 393, 394, 455, 456, 630,
+ 629, 465, 357, 358, 359, 360, 361, 354, 605, 139,
+ 29, 116, 25, 480, 482, 483, 576, 577, 578, 645,
+ 481, 196, 654, 655, 656, 653, 470, 657, 466, 467,
+ 341, 340, 647, 628, 650, 652, 646, 33, 644, 517,
+ 139, 648, 424, 341, 340, 29, 342, 196, 139, 47,
+ 662, 649, 651, 538, 477, 478, 469, 484, 485, 342,
+ 474, 448, 449, 469, 488, 18, 19, 20, 217, 216,
+ 195, 538, 450, 451, 452, 469, 550, 391, 25, 29,
+ 21, 23, 25, 196, 24, 447, 200, 203, 47, 201,
+ 116, 202, 204, 543, 544, 566, 381, 519, 458, 510,
+ 664, 431, 612, 398, 399, 188, 553, 543, 544, 406,
+ 421, 29, 47, 454, 524, 29, 532, 516, 371, 41,
+ 406, 28, 414, 536, 12, 405, 415, 514, 520, 534,
+ 546, 26, 416, 203, 528, 413, 518, 47, 549, 412,
+ 559, 382, 551, 715, 548, 537, 714, 529, 431, 144,
+ 554, 461, 525, 526, 527, 256, 545, 36, 533, 105,
+ 26, 200, 203, 206, 201, 137, 202, 204, 107, 116,
+ 116, 116, 116, 38, 39, 95, 555, 547, 102, 687,
+ 103, 95, 116, 98, 47, 33, 686, 406, 634, 424,
+ 260, 131, 569, 119, 35, 474, 37, 97, 431, 30,
+ 1, 575, 90, 572, 616, 573, 435, 567, 488, 571,
+ 570, 425, 120, 40, 516, 579, 434, 675, 620, 441,
+ 561, 444, 558, 220, 514, 221, 219, 223, 222, 117,
+ 218, 590, 643, 568, 681, 205, 210, 596, 471, 42,
+ 108, 670, 535, 392, 594, 186, 685, 381, 633, 593,
+ 385, 521, 149, 609, 479, 159, 156, 611, 607, 158,
+ 406, 47, 431, 47, 47, 405, 157, 586, 615, 608,
+ 146, 397, 431, 588, 431, 618, 587, 95, 516, 346,
+ 597, 598, 599, 600, 592, 613, 614, 147, 610, 602,
+ 603, 604, 142, 115, 191, 199, 197, 541, 114, 468,
+ 47, 373, 374, 375, 376, 377, 636, 641, 705, 661,
+ 14, 431, 34, 659, 110, 11, 47, 47, 532, 663,
+ 489, 10, 17, 47, 9, 47, 171, 667, 668, 8,
+ 551, 7, 665, 6, 671, 631, 431, 642, 5, 4,
+ 104, 13, 47, 640, 669, 2, 47, 0, 0, 93,
+ 93, 0, 0, 431, 406, 0, 0, 431, 0, 684,
+ 533, 0, 0, 666, 0, 93, 0, 694, 0, 0,
+ 0, 0, 0, 0, 0, 0, 707, 708, 0, 683,
+ 0, 532, 0, 642, 47, 713, 0, 0, 0, 0,
+ 682, 0, 0, 0, 709, 618, 0, 690, 0, 691,
+ 718, 381, 719, 0, 0, 0, 0, 0, 0, 0,
+ 0, 93, 0, 0, 0, 0, 93, 0, 0, 0,
+ 0, 47, 47, 533, 0, 26, 0, 0, 0, 0,
+ 0, 0, 723, 724, 0, 93, 0, 0, 0, 0,
+ 0, 0, 0, 116, 93, 213, 93, 637, 0, 0,
+ 0, 93, 0, 0, 93, 674, 93, 93, 0, 0,
+ 0, 720, 262, 339, 489, 722, 0, 353, 352, 362,
+ 363, 355, 356, 357, 358, 359, 360, 361, 354, 0,
+ 0, 692, 0, 693, 0, 695, 0, 697, 0, 699,
+ 700, 701, 702, 703, 704, 0, 486, 0, 0, 495,
+ 496, 497, 498, 499, 500, 501, 502, 503, 504, 505,
+ 506, 507, 508, 509, 0, 0, 0, 0, 0, 93,
+ 585, 0, 407, 93, 93, 93, 93, 0, 0, 0,
+ 0, 0, 418, 0, 0, 0, 93, 0, 0, 213,
+ 353, 352, 362, 363, 355, 356, 357, 358, 359, 360,
+ 361, 354, 352, 362, 363, 355, 356, 357, 358, 359,
+ 360, 361, 354, 68, 0, 512, 0, 145, 0, 0,
+ 0, 0, 0, 0, 177, 60, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 29, 93, 93, 184, 161,
+ 160, 162, 163, 164, 165, 166, 0, 0, 167, 168,
+ 169, 0, 0, 0, 0, 143, 154, 0, 176, 362,
+ 363, 355, 356, 357, 358, 359, 360, 361, 354, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 151, 152,
+ 337, 0, 0, 0, 182, 0, 153, 0, 155, 0,
+ 0, 0, 580, 581, 582, 0, 0, 0, 0, 181,
+ 0, 69, 0, 0, 57, 0, 0, 52, 0, 0,
+ 77, 72, 64, 58, 59, 48, 0, 70, 55, 56,
+ 54, 67, 74, 75, 53, 82, 51, 81, 50, 66,
+ 73, 78, 65, 62, 49, 76, 63, 61, 0, 71,
+ 79, 83, 0, 178, 179, 180, 183, 174, 175, 0,
+ 80, 0, 0, 0, 0, 339, 262, 68, 0, 0,
+ 0, 0, 0, 0, 407, 339, 339, 339, 0, 60,
+ 0, 0, 0, 0, 0, 407, 0, 0, 0, 0,
+ 0, 0, 46, 234, 638, 639, 239, 240, 241, 242,
+ 243, 244, 0, 245, 246, 247, 248, 249, 235, 236,
+ 237, 238, 224, 225, 0, 0, 226, 227, 228, 229,
+ 230, 231, 232, 233, 0, 0, 0, 0, 353, 352,
+ 362, 363, 355, 356, 357, 358, 359, 360, 361, 354,
+ 0, 0, 0, 0, 0, 0, 0, 689, 0, 0,
+ 0, 93, 407, 0, 0, 69, 339, 93, 57, 0,
+ 0, 52, 0, 262, 77, 72, 64, 58, 59, 48,
+ 0, 70, 55, 56, 54, 67, 74, 75, 53, 82,
+ 51, 81, 50, 66, 73, 78, 65, 62, 49, 76,
+ 63, 61, 0, 71, 79, 83, 0, 0, 0, 339,
+ 0, 0, 0, 0, 80, 0, 0, 339, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 409, 0, 261, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 327, 318, 297, 329, 278,
- 289, 333, 290, 291, 312, 269, 305, 67, 92, 281,
- 265, 287, 266, 279, 299, 302, 277, 320, 331, 59,
- 301, 303, 317, 296, 313, 272, 307, 310, 330, 0,
- 0, 338, 45, 0, 431, 432, 0, 0, 0, 0,
- 0, 309, 326, 288, 0, 0, 311, 264, 308, 0,
- 268, 270, 332, 324, 284, 285, 556, 0, 0, 0,
- 0, 0, 300, 304, 314, 294, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 282, 409, 306, 0, 0,
- 0, 298, 0, 271, 0, 283, 315, 263, 322, 295,
- 325, 293, 292, 328, 68, 0, 0, 56, 321, 280,
- 51, 286, 76, 71, 63, 57, 58, 47, 0, 69,
- 54, 55, 53, 66, 73, 74, 52, 81, 50, 80,
- 49, 65, 72, 77, 64, 61, 48, 75, 62, 60,
- 267, 70, 78, 82, 323, 275, 273, 274, 316, 0,
- 276, 0, 319, 79, 327, 318, 297, 329, 278, 289,
- 333, 290, 291, 312, 269, 305, 67, 0, 281, 265,
- 287, 266, 279, 299, 302, 277, 320, 331, 59, 301,
- 303, 317, 296, 313, 272, 307, 310, 330, 0, 0,
- 0, 45, 0, 431, 432, 0, 0, 0, 0, 0,
- 309, 326, 288, 0, 0, 311, 264, 308, 0, 268,
- 270, 332, 324, 284, 285, 0, 0, 0, 0, 0,
- 0, 300, 304, 314, 294, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 282, 0, 306, 0, 0, 0,
- 298, 0, 271, 0, 283, 315, 263, 322, 295, 325,
- 293, 292, 328, 68, 0, 0, 56, 321, 280, 51,
- 286, 76, 71, 63, 57, 58, 47, 0, 69, 54,
- 55, 53, 66, 73, 74, 52, 81, 50, 80, 49,
- 65, 72, 77, 64, 61, 48, 75, 62, 60, 267,
- 70, 78, 82, 323, 275, 273, 274, 316, 0, 276,
- 0, 319, 79, 327, 318, 297, 329, 278, 289, 333,
- 290, 291, 312, 269, 305, 67, 0, 281, 265, 287,
- 266, 279, 299, 302, 277, 320, 331, 59, 301, 303,
- 317, 296, 313, 272, 307, 310, 330, 0, 0, 0,
- 45, 0, 0, 0, 0, 0, 0, 0, 0, 309,
- 326, 288, 0, 0, 311, 264, 308, 0, 268, 270,
- 332, 324, 284, 285, 0, 0, 0, 0, 0, 0,
- 300, 304, 314, 294, 0, 0, 0, 0, 0, 0,
- 0, 695, 0, 282, 0, 306, 0, 0, 0, 298,
- 0, 271, 0, 283, 315, 263, 322, 295, 325, 293,
- 292, 328, 68, 0, 0, 56, 321, 280, 51, 286,
- 76, 71, 63, 57, 58, 47, 0, 69, 54, 55,
- 53, 66, 73, 74, 52, 81, 50, 80, 49, 65,
- 72, 77, 64, 61, 48, 75, 62, 60, 267, 70,
- 78, 82, 323, 275, 273, 274, 316, 0, 276, 0,
- 319, 79, 327, 318, 297, 329, 278, 289, 333, 290,
- 291, 312, 269, 305, 67, 0, 281, 265, 287, 266,
- 279, 299, 302, 277, 320, 331, 59, 301, 303, 317,
- 296, 313, 272, 307, 310, 330, 28, 0, 0, 45,
- 0, 0, 0, 0, 0, 0, 0, 0, 309, 326,
- 288, 0, 0, 311, 264, 308, 0, 268, 270, 332,
- 324, 284, 285, 0, 0, 0, 0, 0, 0, 300,
- 304, 314, 294, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 282, 0, 306, 0, 0, 0, 298, 0,
- 271, 0, 283, 315, 263, 322, 295, 325, 293, 292,
- 328, 68, 0, 0, 56, 321, 280, 51, 286, 76,
- 71, 63, 57, 58, 47, 0, 69, 54, 55, 53,
- 66, 73, 74, 52, 81, 50, 80, 49, 65, 72,
- 77, 64, 61, 48, 75, 62, 60, 267, 70, 78,
- 82, 323, 275, 273, 274, 316, 0, 276, 0, 319,
- 79, 327, 318, 297, 329, 278, 289, 333, 290, 291,
- 312, 269, 305, 67, 0, 281, 265, 287, 266, 279,
- 299, 302, 277, 320, 331, 59, 301, 303, 317, 296,
- 313, 272, 307, 310, 330, 0, 0, 0, 183, 0,
+ 0, 0, 0, 0, 0, 407, 0, 262, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 327, 318, 297, 329, 278, 289, 333, 290, 291, 312,
+ 270, 305, 68, 93, 281, 266, 287, 267, 279, 299,
+ 302, 277, 320, 331, 60, 301, 303, 317, 296, 313,
+ 273, 307, 310, 330, 0, 339, 0, 46, 0, 429,
+ 430, 0, 0, 0, 0, 0, 0, 309, 326, 288,
+ 0, 0, 311, 265, 308, 0, 269, 271, 332, 324,
+ 284, 285, 552, 0, 0, 0, 0, 0, 300, 304,
+ 314, 294, 0, 0, 0, 0, 0, 0, 0, 407,
+ 0, 282, 0, 306, 0, 0, 0, 298, 0, 272,
+ 0, 283, 315, 264, 322, 295, 325, 293, 292, 328,
+ 69, 0, 0, 57, 321, 280, 52, 286, 334, 77,
+ 72, 64, 58, 59, 48, 0, 70, 55, 56, 54,
+ 67, 74, 75, 53, 82, 51, 81, 50, 66, 73,
+ 78, 65, 62, 49, 76, 63, 61, 268, 71, 79,
+ 83, 323, 276, 274, 275, 316, 0, 0, 319, 80,
+ 327, 318, 297, 329, 278, 289, 333, 290, 291, 312,
+ 270, 305, 68, 0, 281, 266, 287, 267, 279, 299,
+ 302, 277, 320, 331, 60, 301, 303, 317, 296, 313,
+ 273, 307, 310, 330, 0, 0, 0, 46, 0, 429,
+ 430, 0, 0, 0, 0, 0, 0, 309, 326, 288,
+ 0, 0, 311, 265, 308, 0, 269, 271, 332, 324,
+ 284, 285, 0, 0, 0, 0, 0, 0, 300, 304,
+ 314, 294, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 282, 0, 306, 0, 0, 0, 298, 0, 272,
+ 0, 283, 315, 264, 322, 295, 325, 293, 292, 328,
+ 69, 0, 0, 57, 321, 280, 52, 286, 334, 77,
+ 72, 64, 58, 59, 48, 0, 70, 55, 56, 54,
+ 67, 74, 75, 53, 82, 51, 81, 50, 66, 73,
+ 78, 65, 62, 49, 76, 63, 61, 268, 71, 79,
+ 83, 323, 276, 274, 275, 316, 0, 0, 319, 80,
+ 327, 318, 297, 329, 278, 289, 333, 290, 291, 312,
+ 270, 305, 68, 0, 281, 266, 287, 267, 279, 299,
+ 302, 277, 320, 331, 60, 301, 303, 317, 296, 313,
+ 273, 307, 310, 330, 0, 0, 0, 46, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 309, 326, 288,
+ 0, 0, 311, 265, 308, 0, 269, 271, 332, 324,
+ 284, 285, 0, 0, 0, 0, 0, 0, 300, 304,
+ 314, 294, 0, 0, 0, 0, 0, 0, 0, 688,
+ 0, 282, 0, 306, 0, 0, 0, 298, 0, 272,
+ 0, 283, 315, 264, 322, 295, 325, 293, 292, 328,
+ 69, 0, 0, 57, 321, 280, 52, 286, 334, 77,
+ 72, 64, 58, 59, 48, 0, 70, 55, 56, 54,
+ 67, 74, 75, 53, 82, 51, 81, 50, 66, 73,
+ 78, 65, 62, 49, 76, 63, 61, 268, 71, 79,
+ 83, 323, 276, 274, 275, 316, 0, 0, 319, 80,
+ 327, 318, 297, 329, 278, 289, 333, 290, 291, 312,
+ 270, 305, 68, 0, 281, 266, 287, 267, 279, 299,
+ 302, 277, 320, 331, 60, 301, 303, 317, 296, 313,
+ 273, 307, 310, 330, 29, 0, 0, 46, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 309, 326, 288,
+ 0, 0, 311, 265, 308, 0, 269, 271, 332, 324,
+ 284, 285, 0, 0, 0, 0, 0, 0, 300, 304,
+ 314, 294, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 282, 0, 306, 0, 0, 0, 298, 0, 272,
+ 0, 283, 315, 264, 322, 295, 325, 293, 292, 328,
+ 69, 0, 0, 57, 321, 280, 52, 286, 334, 77,
+ 72, 64, 58, 59, 48, 0, 70, 55, 56, 54,
+ 67, 74, 75, 53, 82, 51, 81, 50, 66, 73,
+ 78, 65, 62, 49, 76, 63, 61, 268, 71, 79,
+ 83, 323, 276, 274, 275, 316, 0, 0, 319, 80,
+ 327, 318, 297, 329, 278, 289, 333, 290, 291, 312,
+ 270, 305, 68, 0, 281, 266, 287, 267, 279, 299,
+ 302, 277, 320, 331, 60, 301, 303, 317, 296, 313,
+ 273, 307, 310, 330, 0, 0, 0, 184, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 309, 326, 288,
+ 0, 0, 311, 265, 308, 0, 269, 271, 332, 324,
+ 284, 285, 0, 0, 0, 0, 0, 0, 300, 304,
+ 314, 294, 0, 0, 0, 0, 0, 0, 0, 574,
+ 0, 282, 0, 306, 0, 0, 0, 298, 0, 272,
+ 0, 283, 315, 264, 322, 295, 325, 293, 292, 328,
+ 69, 0, 0, 57, 321, 280, 52, 286, 334, 77,
+ 72, 64, 58, 59, 48, 0, 70, 55, 56, 54,
+ 67, 74, 75, 53, 82, 51, 81, 50, 66, 73,
+ 78, 65, 62, 49, 76, 63, 61, 268, 71, 79,
+ 83, 323, 276, 274, 275, 316, 0, 0, 319, 80,
+ 327, 318, 297, 329, 278, 289, 333, 290, 291, 312,
+ 270, 305, 68, 0, 281, 266, 287, 267, 279, 299,
+ 302, 277, 320, 331, 60, 301, 303, 317, 296, 313,
+ 273, 307, 310, 330, 0, 0, 0, 46, 0, 0,
0, 0, 0, 0, 0, 0, 0, 309, 326, 288,
- 0, 0, 311, 264, 308, 0, 268, 270, 332, 324,
+ 0, 0, 311, 265, 308, 0, 269, 271, 332, 324,
284, 285, 0, 0, 0, 0, 0, 0, 300, 304,
- 314, 294, 0, 0, 0, 0, 0, 0, 0, 578,
- 0, 282, 0, 306, 0, 0, 0, 298, 0, 271,
- 0, 283, 315, 263, 322, 295, 325, 293, 292, 328,
- 68, 0, 0, 56, 321, 280, 51, 286, 76, 71,
- 63, 57, 58, 47, 0, 69, 54, 55, 53, 66,
- 73, 74, 52, 81, 50, 80, 49, 65, 72, 77,
- 64, 61, 48, 75, 62, 60, 267, 70, 78, 82,
- 323, 275, 273, 274, 316, 0, 276, 0, 319, 79,
+ 314, 294, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 282, 0, 306, 0, 0, 0, 298, 0, 272,
+ 0, 283, 315, 264, 322, 295, 325, 293, 292, 328,
+ 69, 0, 0, 57, 321, 280, 52, 286, 334, 77,
+ 72, 64, 58, 59, 48, 0, 70, 55, 56, 54,
+ 67, 74, 75, 53, 82, 51, 81, 50, 66, 73,
+ 78, 65, 62, 49, 76, 63, 61, 268, 71, 79,
+ 83, 323, 276, 274, 275, 316, 0, 0, 319, 80,
327, 318, 297, 329, 278, 289, 333, 290, 291, 312,
- 269, 305, 67, 0, 281, 265, 287, 266, 279, 299,
- 302, 277, 320, 331, 59, 301, 303, 317, 296, 313,
- 272, 307, 310, 330, 0, 0, 0, 45, 0, 0,
- 0, 0, 0, 0, 0, 0, 309, 326, 288, 0,
- 0, 311, 264, 308, 0, 268, 270, 332, 324, 284,
- 285, 0, 0, 0, 0, 0, 0, 300, 304, 314,
- 294, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 282, 0, 306, 0, 0, 0, 298, 0, 271, 0,
- 283, 315, 263, 322, 295, 325, 293, 292, 328, 68,
- 0, 0, 56, 321, 280, 51, 286, 76, 71, 63,
- 57, 58, 47, 0, 69, 54, 55, 53, 66, 73,
- 74, 52, 81, 50, 80, 49, 65, 72, 77, 64,
- 61, 48, 75, 62, 60, 267, 70, 78, 82, 323,
- 275, 273, 274, 316, 0, 276, 0, 319, 79, 327,
- 318, 297, 329, 278, 289, 333, 290, 291, 312, 269,
- 305, 67, 0, 281, 265, 287, 266, 279, 299, 302,
- 277, 320, 331, 59, 301, 303, 317, 296, 313, 272,
- 307, 310, 330, 0, 0, 0, 183, 0, 0, 0,
- 0, 0, 0, 0, 0, 309, 326, 288, 0, 0,
- 311, 264, 308, 0, 268, 270, 332, 324, 284, 285,
- 0, 0, 0, 0, 0, 0, 300, 304, 314, 294,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 282,
- 0, 306, 0, 0, 0, 298, 0, 271, 0, 283,
- 315, 263, 322, 295, 325, 293, 292, 328, 68, 0,
- 0, 56, 321, 280, 51, 286, 76, 71, 63, 57,
- 58, 47, 0, 69, 54, 55, 53, 66, 73, 74,
- 52, 81, 50, 80, 49, 65, 72, 77, 64, 61,
- 48, 75, 62, 60, 267, 70, 78, 82, 323, 275,
- 273, 274, 316, 0, 276, 0, 319, 79, 327, 318,
- 297, 329, 278, 289, 333, 290, 291, 312, 269, 305,
- 67, 0, 281, 265, 287, 266, 279, 299, 302, 277,
- 320, 331, 59, 301, 303, 317, 296, 313, 272, 307,
- 310, 330, 0, 0, 0, 93, 0, 0, 0, 0,
- 0, 0, 0, 0, 309, 326, 288, 0, 0, 311,
- 264, 308, 0, 268, 270, 332, 324, 284, 285, 0,
- 0, 0, 0, 0, 0, 300, 304, 314, 294, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 282, 0,
- 306, 0, 0, 0, 298, 0, 271, 0, 283, 315,
- 263, 322, 295, 325, 293, 292, 328, 68, 0, 0,
- 56, 321, 280, 51, 286, 76, 71, 63, 57, 58,
- 47, 0, 69, 54, 55, 53, 66, 73, 74, 52,
- 81, 50, 80, 49, 65, 72, 77, 64, 61, 48,
- 75, 62, 60, 267, 70, 78, 82, 323, 275, 273,
- 274, 316, 0, 276, 67, 319, 79, 0, 144, 0,
- 0, 0, 0, 143, 0, 176, 59, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 28, 0, 0, 183,
- 160, 159, 161, 162, 163, 164, 0, 0, 165, 166,
- 167, 0, 0, 0, 0, 141, 153, 0, 175, 0,
+ 270, 305, 68, 0, 281, 266, 287, 267, 279, 299,
+ 302, 277, 320, 331, 60, 301, 303, 317, 296, 313,
+ 273, 307, 310, 330, 0, 0, 0, 184, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 309, 326, 288,
+ 0, 0, 311, 265, 308, 0, 269, 271, 332, 324,
+ 284, 285, 0, 0, 0, 0, 0, 0, 300, 304,
+ 314, 294, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 282, 0, 306, 0, 0, 0, 298, 0, 272,
+ 0, 283, 315, 264, 322, 295, 325, 293, 292, 328,
+ 69, 0, 0, 57, 321, 280, 52, 286, 334, 77,
+ 72, 64, 58, 59, 48, 0, 70, 55, 56, 54,
+ 67, 74, 75, 53, 82, 51, 81, 50, 66, 73,
+ 78, 65, 62, 49, 76, 63, 61, 268, 71, 79,
+ 83, 323, 276, 274, 275, 316, 0, 0, 319, 80,
+ 327, 318, 297, 329, 278, 289, 333, 290, 291, 312,
+ 270, 305, 68, 0, 281, 266, 287, 267, 279, 299,
+ 302, 277, 320, 331, 60, 301, 303, 317, 296, 313,
+ 273, 307, 310, 330, 0, 0, 0, 94, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 309, 326, 288,
+ 0, 0, 311, 265, 308, 0, 269, 271, 332, 324,
+ 284, 285, 0, 0, 0, 0, 0, 0, 300, 304,
+ 314, 294, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 282, 0, 306, 0, 0, 0, 298, 0, 272,
+ 0, 283, 315, 264, 322, 295, 325, 293, 292, 328,
+ 69, 0, 0, 57, 321, 280, 52, 286, 334, 77,
+ 72, 64, 58, 59, 48, 0, 70, 55, 56, 54,
+ 67, 74, 75, 53, 82, 51, 81, 50, 66, 73,
+ 78, 65, 62, 49, 76, 63, 61, 268, 71, 79,
+ 83, 323, 276, 274, 275, 316, 68, 0, 319, 80,
+ 145, 0, 0, 0, 0, 0, 0, 177, 60, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 29, 0,
+ 0, 184, 161, 160, 162, 163, 164, 165, 166, 0,
+ 0, 167, 168, 169, 0, 0, 0, 0, 143, 154,
+ 0, 176, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 151, 152, 337, 0, 0, 0, 182, 0, 153,
+ 0, 155, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 181, 0, 69, 0, 0, 57, 0, 0,
+ 52, 0, 0, 77, 72, 64, 58, 59, 48, 0,
+ 70, 55, 56, 54, 67, 74, 75, 53, 82, 51,
+ 81, 50, 66, 73, 78, 65, 62, 49, 76, 63,
+ 61, 0, 71, 79, 83, 0, 178, 179, 180, 183,
+ 174, 175, 68, 80, 0, 0, 145, 0, 0, 0,
+ 0, 0, 0, 177, 60, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 29, 0, 139, 184, 161, 160,
+ 162, 163, 164, 165, 166, 0, 0, 167, 168, 169,
+ 0, 0, 0, 0, 143, 154, 0, 176, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 150, 151,
- 336, 0, 0, 0, 181, 0, 152, 0, 154, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 180,
- 0, 68, 0, 0, 56, 0, 0, 51, 0, 76,
- 71, 63, 57, 58, 47, 0, 69, 54, 55, 53,
- 66, 73, 74, 52, 81, 50, 80, 49, 65, 72,
- 77, 64, 61, 48, 75, 62, 60, 0, 70, 78,
- 82, 0, 177, 178, 179, 182, 172, 173, 174, 67,
- 79, 0, 0, 144, 0, 0, 0, 0, 143, 0,
- 176, 59, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 28, 0, 137, 183, 160, 159, 161, 162, 163,
- 164, 0, 0, 165, 166, 167, 0, 0, 0, 0,
- 141, 153, 0, 175, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 151, 152, 0,
+ 0, 0, 0, 182, 0, 153, 0, 155, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 181, 0,
+ 69, 0, 0, 57, 0, 0, 52, 0, 0, 77,
+ 72, 64, 58, 59, 48, 0, 70, 55, 56, 54,
+ 67, 74, 75, 53, 82, 51, 81, 50, 66, 73,
+ 78, 65, 62, 49, 76, 63, 61, 25, 71, 79,
+ 83, 0, 178, 179, 180, 183, 174, 175, 68, 80,
+ 0, 0, 145, 0, 0, 0, 0, 0, 0, 177,
+ 60, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 29, 0, 0, 184, 161, 160, 162, 163, 164, 165,
+ 166, 0, 0, 167, 168, 169, 0, 0, 0, 0,
+ 143, 154, 0, 176, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 150, 151, 0, 0, 0, 0, 181,
- 0, 152, 0, 154, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 180, 0, 68, 0, 0, 56,
- 0, 0, 51, 0, 76, 71, 63, 57, 58, 47,
- 0, 69, 54, 55, 53, 66, 73, 74, 52, 81,
- 50, 80, 49, 65, 72, 77, 64, 61, 48, 75,
- 62, 60, 0, 70, 78, 82, 24, 177, 178, 179,
- 182, 172, 173, 174, 0, 79, 0, 67, 0, 0,
- 0, 144, 0, 0, 0, 0, 143, 0, 176, 59,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 28,
- 0, 0, 183, 160, 159, 161, 162, 163, 164, 0,
- 0, 165, 166, 167, 0, 0, 0, 0, 141, 153,
- 0, 175, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 151, 152, 0, 0, 0, 0, 182,
+ 0, 153, 0, 155, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 181, 0, 69, 0, 0, 57,
+ 0, 0, 52, 0, 0, 77, 72, 64, 58, 59,
+ 48, 0, 70, 55, 56, 54, 67, 74, 75, 53,
+ 82, 51, 81, 50, 66, 73, 78, 65, 62, 49,
+ 76, 63, 61, 0, 71, 79, 83, 0, 178, 179,
+ 180, 183, 174, 175, 68, 80, 0, 0, 145, 0,
+ 0, 0, 0, 0, 0, 177, 60, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 29, 0, 0, 184,
+ 161, 160, 162, 163, 164, 165, 166, 0, 0, 167,
+ 168, 169, 0, 0, 0, 0, 143, 154, 0, 176,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 150, 151, 0, 0, 0, 0, 181, 0, 152,
- 0, 154, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 180, 0, 68, 0, 0, 56, 0, 0,
- 51, 0, 76, 71, 63, 57, 58, 47, 0, 69,
- 54, 55, 53, 66, 73, 74, 52, 81, 50, 80,
- 49, 65, 72, 77, 64, 61, 48, 75, 62, 60,
- 0, 70, 78, 82, 0, 177, 178, 179, 182, 172,
- 173, 174, 67, 79, 0, 0, 144, 0, 0, 0,
- 0, 143, 0, 176, 59, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 28, 0, 0, 183, 160, 159,
- 161, 162, 163, 164, 0, 0, 165, 166, 167, 0,
- 0, 0, 0, 141, 153, 0, 175, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 151,
+ 152, 0, 0, 0, 0, 182, 0, 153, 0, 155,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 150, 151, 0, 0,
- 0, 0, 181, 0, 152, 0, 154, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 180, 0, 68,
- 0, 0, 56, 0, 0, 51, 0, 76, 71, 63,
- 57, 58, 47, 0, 69, 54, 55, 53, 66, 73,
- 74, 52, 81, 50, 80, 49, 65, 72, 77, 64,
- 61, 48, 75, 62, 60, 0, 70, 78, 82, 67,
- 177, 178, 179, 182, 172, 173, 174, 0, 79, 0,
- 176, 59, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 28, 0, 0, 183, 160, 159, 161, 162, 163,
- 164, 0, 0, 165, 166, 167, 0, 0, 0, 0,
- 0, 153, 0, 175, 0, 0, 0, 0, 0, 0,
+ 181, 0, 69, 0, 0, 57, 0, 0, 52, 0,
+ 0, 77, 72, 64, 58, 59, 48, 0, 70, 55,
+ 56, 54, 67, 74, 75, 53, 82, 51, 81, 50,
+ 66, 73, 78, 65, 62, 49, 76, 63, 61, 0,
+ 71, 79, 83, 68, 178, 179, 180, 183, 174, 175,
+ 0, 80, 0, 0, 177, 60, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 29, 0, 0, 184, 161,
+ 160, 162, 163, 164, 165, 166, 0, 0, 167, 168,
+ 169, 0, 0, 0, 0, 0, 154, 0, 176, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 150, 151, 0, 0, 0, 0, 181,
- 0, 152, 0, 154, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 180, 0, 68, 0, 0, 56,
- 0, 0, 51, 0, 76, 71, 63, 57, 58, 47,
- 0, 69, 54, 55, 53, 66, 73, 74, 52, 81,
- 50, 80, 49, 65, 72, 77, 64, 61, 48, 75,
- 62, 60, 0, 70, 78, 82, 0, 177, 178, 179,
- 182, 172, 173, 174, 67, 79, 0, 475, 0, 0,
- 0, 0, 0, 0, 0, 0, 59, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 45,
- 0, 477, 0, 0, 0, 24, 0, 0, 0, 0,
- 0, 0, 0, 340, 339, 0, 67, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 59, 341,
- 0, 0, 0, 0, 0, 0, 0, 0, 28, 0,
- 0, 45, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 151, 152,
+ 0, 0, 0, 0, 182, 0, 153, 0, 155, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 181,
+ 0, 69, 0, 0, 57, 0, 0, 52, 0, 0,
+ 77, 72, 64, 58, 59, 48, 0, 70, 55, 56,
+ 54, 67, 74, 75, 53, 82, 51, 81, 50, 66,
+ 73, 78, 65, 62, 49, 76, 63, 61, 0, 71,
+ 79, 83, 0, 178, 179, 180, 183, 174, 175, 68,
+ 80, 0, 473, 0, 0, 0, 0, 0, 0, 0,
+ 0, 60, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 46, 0, 475, 0, 0, 0,
+ 25, 0, 0, 0, 0, 0, 0, 0, 0, 341,
+ 340, 68, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 60, 0, 342, 0, 0, 0, 0,
+ 0, 0, 0, 29, 0, 0, 46, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 68, 0, 0, 56, 0, 0, 51, 0, 76,
- 71, 63, 57, 58, 47, 0, 69, 54, 55, 53,
- 66, 73, 74, 52, 81, 50, 80, 49, 65, 72,
- 77, 64, 61, 48, 75, 62, 60, 0, 70, 78,
- 82, 0, 0, 68, 0, 0, 56, 0, 0, 51,
- 79, 76, 71, 63, 57, 58, 47, 0, 69, 54,
- 55, 53, 66, 73, 74, 52, 81, 50, 80, 49,
- 65, 72, 77, 64, 61, 48, 75, 62, 60, 24,
- 70, 78, 82, 0, 0, 0, 0, 0, 0, 0,
- 67, 0, 79, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 59, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 28, 0, 0, 93, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 69, 0, 0,
+ 57, 0, 0, 52, 0, 0, 77, 72, 64, 58,
+ 59, 48, 0, 70, 55, 56, 54, 67, 74, 75,
+ 53, 82, 51, 81, 50, 66, 73, 78, 65, 62,
+ 49, 76, 63, 61, 0, 71, 79, 83, 0, 69,
+ 0, 0, 57, 0, 0, 52, 80, 0, 77, 72,
+ 64, 58, 59, 48, 0, 70, 55, 56, 54, 67,
+ 74, 75, 53, 82, 51, 81, 50, 66, 73, 78,
+ 65, 62, 49, 76, 63, 61, 25, 71, 79, 83,
+ 0, 0, 0, 0, 0, 0, 0, 68, 80, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 60,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 29,
+ 0, 0, 94, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 68, 0,
+ 0, 212, 0, 0, 0, 0, 0, 0, 0, 0,
+ 60, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 94, 0, 214, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 67, 0, 0, 211, 0, 0, 0, 0,
- 0, 0, 0, 0, 59, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 93, 0, 213,
+ 0, 0, 0, 0, 0, 69, 0, 0, 57, 0,
+ 0, 52, 0, 0, 77, 72, 64, 58, 59, 48,
+ 0, 70, 55, 56, 54, 67, 74, 75, 53, 82,
+ 51, 81, 50, 66, 73, 78, 65, 62, 49, 76,
+ 63, 61, 0, 71, 79, 83, 69, 0, 0, 57,
+ 0, 0, 52, 0, 80, 77, 72, 64, 58, 59,
+ 48, 0, 70, 55, 56, 54, 67, 74, 75, 53,
+ 82, 51, 81, 50, 66, 73, 78, 65, 62, 49,
+ 76, 63, 61, 0, 71, 79, 83, 68, 0, 0,
+ 0, 0, 0, 0, 0, 80, 0, 0, 0, 60,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 68, 0, 0,
- 56, 0, 0, 51, 0, 76, 71, 63, 57, 58,
- 47, 0, 69, 54, 55, 53, 66, 73, 74, 52,
- 81, 50, 80, 49, 65, 72, 77, 64, 61, 48,
- 75, 62, 60, 0, 70, 78, 82, 0, 0, 68,
- 0, 0, 56, 0, 0, 51, 79, 76, 71, 63,
- 57, 58, 47, 0, 69, 54, 55, 53, 66, 73,
- 74, 52, 81, 50, 80, 49, 65, 72, 77, 64,
- 61, 48, 75, 62, 60, 67, 70, 78, 82, 0,
- 0, 0, 0, 0, 0, 0, 0, 59, 79, 0,
+ 0, 0, 46, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 68, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 45, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 67, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 59,
+ 60, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 46, 0, 475, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 43,
+ 0, 0, 0, 0, 44, 69, 0, 0, 57, 0,
+ 0, 52, 0, 0, 77, 72, 64, 58, 59, 48,
+ 0, 70, 55, 56, 54, 67, 74, 75, 53, 82,
+ 51, 81, 50, 66, 73, 78, 65, 62, 49, 76,
+ 63, 61, 0, 71, 79, 83, 69, 0, 0, 57,
+ 0, 0, 52, 0, 80, 77, 72, 64, 58, 59,
+ 48, 0, 70, 55, 56, 54, 67, 74, 75, 53,
+ 82, 51, 81, 50, 66, 73, 78, 65, 62, 49,
+ 76, 63, 61, 0, 71, 79, 83, 68, 0, 0,
+ 0, 0, 0, 0, 0, 80, 0, 0, 0, 60,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 29,
+ 0, 0, 94, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 68, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 45, 0, 477, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 42, 0, 0, 0,
- 0, 43, 68, 0, 0, 56, 0, 0, 51, 0,
- 76, 71, 63, 57, 58, 47, 0, 69, 54, 55,
- 53, 66, 73, 74, 52, 81, 50, 80, 49, 65,
- 72, 77, 64, 61, 48, 75, 62, 60, 0, 70,
- 78, 82, 0, 0, 68, 0, 0, 56, 0, 0,
- 51, 79, 76, 71, 63, 57, 58, 47, 0, 69,
- 54, 55, 53, 66, 73, 74, 52, 81, 50, 80,
- 49, 65, 72, 77, 64, 61, 48, 75, 62, 60,
- 67, 70, 78, 82, 0, 0, 0, 0, 0, 0,
- 0, 0, 59, 79, 0, 0, 0, 0, 0, 0,
- 0, 0, 28, 0, 0, 93, 0, 0, 0, 0,
+ 60, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 94, 0, 214, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 67, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 59, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 93, 0, 213,
+ 0, 0, 0, 0, 0, 69, 0, 0, 57, 0,
+ 0, 52, 0, 0, 77, 72, 64, 58, 59, 48,
+ 0, 70, 55, 56, 54, 67, 74, 75, 53, 82,
+ 51, 81, 50, 66, 73, 78, 65, 62, 49, 76,
+ 63, 61, 0, 71, 79, 83, 69, 0, 0, 57,
+ 0, 0, 52, 0, 80, 77, 72, 64, 58, 59,
+ 48, 0, 70, 55, 56, 54, 67, 74, 75, 53,
+ 82, 51, 81, 50, 66, 73, 78, 65, 62, 49,
+ 76, 63, 61, 0, 71, 79, 83, 68, 0, 0,
+ 0, 0, 0, 0, 192, 80, 0, 0, 0, 60,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 68, 0, 0,
- 56, 0, 0, 51, 0, 76, 71, 63, 57, 58,
- 47, 0, 69, 54, 55, 53, 66, 73, 74, 52,
- 81, 50, 80, 49, 65, 72, 77, 64, 61, 48,
- 75, 62, 60, 0, 70, 78, 82, 0, 0, 68,
- 0, 0, 56, 0, 0, 51, 79, 76, 71, 63,
- 57, 58, 47, 0, 69, 54, 55, 53, 66, 73,
- 74, 52, 81, 50, 80, 49, 65, 72, 77, 64,
- 61, 48, 75, 62, 60, 67, 70, 78, 82, 0,
- 0, 0, 191, 0, 0, 0, 0, 59, 79, 0,
+ 0, 0, 94, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 68, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 348,
+ 60, 351, 0, 0, 0, 0, 0, 364, 365, 366,
+ 367, 368, 369, 46, 349, 350, 347, 370, 353, 352,
+ 362, 363, 355, 356, 357, 358, 359, 360, 361, 354,
+ 0, 0, 0, 0, 0, 69, 0, 0, 57, 0,
+ 0, 52, 0, 0, 77, 72, 64, 58, 59, 48,
+ 0, 70, 55, 56, 54, 67, 74, 75, 53, 82,
+ 51, 81, 50, 66, 73, 78, 65, 62, 49, 76,
+ 63, 61, 0, 71, 79, 83, 69, 0, 0, 57,
+ 0, 0, 52, 0, 80, 77, 72, 64, 58, 59,
+ 48, 0, 70, 55, 56, 54, 67, 74, 75, 53,
+ 82, 51, 81, 50, 66, 73, 78, 65, 62, 49,
+ 76, 63, 61, 0, 71, 79, 83, 68, 0, 0,
+ 0, 0, 0, 0, 0, 80, 0, 0, 0, 60,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 93, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 67, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 347, 59,
- 350, 0, 0, 0, 0, 0, 363, 364, 365, 366,
- 367, 368, 45, 348, 349, 346, 369, 352, 351, 361,
- 362, 354, 355, 356, 357, 358, 359, 360, 353, 0,
- 0, 0, 68, 0, 0, 56, 0, 0, 51, 0,
- 76, 71, 63, 57, 58, 47, 0, 69, 54, 55,
- 53, 66, 73, 74, 52, 81, 50, 80, 49, 65,
- 72, 77, 64, 61, 48, 75, 62, 60, 0, 70,
- 78, 82, 0, 0, 68, 0, 0, 56, 0, 0,
- 51, 79, 76, 71, 63, 57, 58, 47, 0, 69,
- 54, 55, 53, 66, 73, 74, 52, 81, 50, 80,
- 49, 65, 72, 77, 64, 61, 48, 75, 62, 60,
- 67, 70, 78, 82, 0, 0, 0, 0, 0, 0,
- 0, 0, 59, 79, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 183, 0, 0, 0, 0,
+ 0, 0, 184, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 68, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 67, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 59, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 93, 0, 0,
+ 60, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 94, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 68, 0, 0,
- 56, 0, 0, 51, 0, 76, 71, 63, 57, 58,
- 47, 0, 69, 54, 55, 53, 66, 73, 74, 52,
- 81, 50, 80, 49, 65, 72, 77, 64, 61, 48,
- 75, 62, 60, 0, 70, 78, 82, 0, 0, 68,
- 0, 0, 56, 0, 0, 51, 79, 76, 71, 63,
- 57, 58, 47, 0, 69, 54, 55, 53, 66, 73,
- 74, 52, 81, 50, 80, 49, 65, 72, 77, 64,
- 61, 48, 75, 62, 60, 0, 70, 78, 82, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 79,
+ 0, 0, 0, 0, 0, 69, 0, 0, 57, 0,
+ 0, 52, 0, 0, 77, 72, 64, 58, 59, 48,
+ 0, 70, 55, 56, 54, 67, 74, 75, 53, 82,
+ 51, 81, 50, 66, 73, 78, 65, 62, 49, 76,
+ 63, 61, 0, 71, 79, 83, 69, 0, 0, 57,
+ 0, 0, 52, 0, 80, 77, 72, 64, 58, 59,
+ 48, 0, 70, 55, 56, 54, 67, 74, 75, 53,
+ 82, 51, 81, 50, 66, 73, 78, 65, 62, 49,
+ 76, 63, 61, 0, 71, 79, 83, 0, 0, 0,
+ 0, 0, 0, 0, 0, 80,
}
var yyPact = [...]int{
- 181, -1000, -108, -1000, -1000, -1000, -1000, -1000, -1000, -1000,
- -1000, -1000, 434, 458, -1000, -1000, -1000, 355, 3388, -13,
- -24, 34, 3925, 3925, -1000, 344, 103, -1000, -1000, -1000,
- -1000, 424, 430, 344, 418, -30, -1000, 3553, 451, -1000,
- 188, -21, -35, -1000, -1000, -1000, -1000, -1000, -1000, -1000,
+ 261, -1000, -112, -1000, -1000, -1000, -1000, -1000, -1000, -1000,
+ -1000, -1000, 461, 479, -1000, -1000, -1000, 370, 3370, -13,
+ -22, 14, 3921, 3921, -1000, -1000, 296, 94, -1000, -1000,
+ -1000, -1000, 452, 455, 296, 440, -29, -1000, 3540, 473,
+ -1000, 179, -21, -33, -1000, -1000, -1000, -1000, -1000, -1000,
-1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000,
-1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000,
-1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000,
- -1000, -1000, -1000, 3925, -32, -32, -15, 450, 3925, -5,
- -1000, -1000, 21, -1000, -1000, -1000, 414, 182, -99, -1000,
- 2785, 2785, 434, -1000, 344, -1000, 3718, -1000, 120, 307,
- 444, -1000, -1000, -1000, 406, 3223, 3265, 3925, 281, -1000,
- 941, -35, 3925, 77, -16, 3925, 404, 3925, 3925, -19,
- -1000, -1000, 449, 2243, 2377, -1000, -1000, -1000, -1000, 263,
- -1000, 2785, 3730, 316, 316, -1000, -1000, -1000, -1000, -1000,
- 2912, 2912, 2912, 2912, 2912, -1000, -1000, -1000, -1000, -1000,
- -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, 316, 20,
- -1000, 2650, 316, 316, 316, 2785, 316, -1000, -1000, -1000,
- 316, 316, 316, -1000, -1000, 293, -1000, 205, 424, 182,
- 318, 3925, -1000, -1000, 3883, 3553, 3553, 3553, 3553, -1000,
- 382, 379, 377, 367, 3925, -1000, 267, 182, 3223, -1000,
- -1000, 3595, -1000, -1000, 445, 1349, 130, 90, -87, -1000,
- -1000, 335, -1000, 335, 335, -1000, -1000, -1000, -1000, -1000,
- -1000, -1000, -1000, -1000, 335, 335, 335, -1000, -1000, -1000,
- -1000, -1000, -1000, -1000, 347, 347, 347, 339, 339, 212,
- -1000, 402, -39, -37, -1000, -1000, -1000, -1000, 3925, 3925,
+ -1000, -1000, -1000, -1000, 3921, -32, -32, -15, 471, 3921,
+ -6, -1000, -1000, 29, -1000, -1000, -1000, -1000, 436, 194,
+ -103, -1000, 2757, 2757, 461, -1000, 296, -1000, 3710, -1000,
+ 113, 333, 421, -1000, -1000, -1000, 433, 3200, 3241, 3921,
+ 318, -1000, 912, -33, 3921, 83, -9, 3921, 424, 3921,
+ 3921, -19, -1000, -1000, 470, 2215, 2349, -1000, -1000, -1000,
+ -1000, 145, -1000, 2757, 3720, 330, -1000, -1000, -1000, -1000,
+ -1000, 2886, 2886, 2886, 2886, 2886, -1000, -1000, -1000, -1000,
-1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000,
+ 330, 28, -1000, 2621, 330, 330, 2757, 330, -1000, -1000,
+ -1000, 330, 330, 330, -1000, -1000, 327, -1000, 263, 452,
+ 194, 366, 3921, -1000, -1000, 3880, 3540, 3540, 3540, 3540,
+ -1000, 399, 395, 382, 392, 3921, -1000, 297, 194, 3200,
+ -1000, -1000, 3581, -1000, -1000, 468, 1315, 49, 149, -87,
+ -1000, -1000, 336, -1000, 336, 336, -1000, -1000, -1000, -1000,
+ -1000, -1000, -1000, -1000, -1000, 336, 336, 336, -1000, -1000,
+ -1000, -1000, -1000, -1000, -1000, 364, 364, 364, 349, 349,
+ 187, -1000, 420, -38, -34, -1000, -1000, -1000, -1000, 3921,
+ 3921, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000,
-1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000,
-1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000,
-1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000,
-1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000,
-1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000,
-1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000,
- -1000, -1000, -1000, -1000, 313, -1000, -1000, 3047, 19, 2785,
- 2785, 246, 2785, 2785, 42, 2912, 164, 94, 2912, 2912,
- 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912,
- 2912, 2912, 2912, -1000, -1000, -1000, -1000, -1000, -1000, -1000,
- -1000, 209, -1000, 344, -1000, -1000, -1000, -1000, 1017, 866,
- 2094, 265, 74, 2650, 2785, 3883, 414, 62, 74, 3883,
- 2377, 2377, 2377, 2785, -1000, -1000, -1000, -1000, -1000, -1000,
- 3883, 316, -1000, 3089, -1000, 314, -1000, 56, -1000, 16,
- 444, 353, 306, -1000, -1000, -1000, -1000, 378, -1000, -1000,
- -1000, -1000, -1000, 182, -1000, 434, 2785, 292, 1200, -1000,
- -1000, -1000, -1000, -1000, -1000, -1000, -1000, 343, 397, 48,
- 201, -1000, -1000, 389, -1000, 115, -91, -1000, -1000, 161,
- -1000, -1000, -1000, -1000, -1000, -1000, 149, -1000, -1000, -1000,
- 140, -1000, 358, -1000, 188, -1000, 3925, 3883, -1000, -1000,
- 445, 2377, 3553, -1000, -1000, 3430, -1000, -1000, 1796, 42,
- 79, -1000, -1000, 122, -1000, -1000, 74, 74, 665, -1000,
- -1000, -1000, -1000, 164, 2912, 2912, 2912, 14, 665, 858,
- 793, 503, -1000, 154, 154, -1, -1, -1, -1, -1,
- 184, 184, 182, -1000, 182, 2377, 291, 316, 12, -1000,
- 2785, -1000, 175, 290, 2377, 76, -1000, 2785, 182, 238,
- 238, 238, -1000, 287, 269, -1000, -1000, 2512, 182, 245,
- 11, 434, 3883, 2785, 2094, -1000, -1000, 2785, 341, -1000,
- -1000, -1000, 424, 74, 1349, -1000, 1349, 3760, -1000, 179,
- -1000, -1000, -84, 13, -1000, -1000, -1000, 232, 286, 241,
- 3925, -1000, -1000, -28, 446, -1000, 271, -1000, -1000, -6,
- -1000, -1000, -1000, -1000, 14, 665, 783, -1000, 2912, 2912,
- -1000, -1000, 238, 2377, 1945, 74, 340, 2912, 300, 41,
- -1000, 2785, 145, -1000, -1000, -1000, -1000, 316, -1000, -1000,
- 375, 3760, 3760, 424, -1000, 74, -1000, 74, 3760, -1000,
- 1200, -1000, 216, -1000, 335, -1000, 40, -1000, -1000, -1000,
- -1000, -1000, -1000, -1000, 133, -1000, 132, 1647, 3883, 438,
- 426, 1498, -1000, 2912, 665, 665, -1000, 182, -1000, 182,
- 335, -1000, 335, 339, 335, -54, 335, -56, 335, 335,
- 335, 335, 335, 335, -1000, 627, -104, -1000, 74, 2785,
- -1000, 316, -1000, 344, -10, -1000, -1000, 178, -1000, -1000,
- 3760, -1000, -1000, 394, -1000, 393, 217, 185, -1000, -1000,
- -1000, -1000, -1000, 2785, 2785, -1000, 665, -1000, -1000, -1000,
+ -1000, -1000, -1000, -1000, -1000, 306, -1000, -1000, 3022, 24,
+ 2757, 2757, 251, 2757, 2757, 59, 2886, 126, 85, 2886,
+ 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886,
+ 2886, 2886, 2886, 2886, -1000, -1000, -1000, -1000, -1000, -1000,
+ -1000, -1000, 296, -1000, -1000, -1000, -1000, 980, 836, 2065,
+ 289, 176, 2621, 2757, 436, 75, 176, 3880, 2349, 2349,
+ 2349, 2757, -1000, -1000, -1000, -1000, -1000, -1000, 3880, 330,
+ -1000, 3064, -1000, 321, -1000, 67, -1000, 23, 421, 360,
+ 346, -1000, -1000, -1000, -1000, 390, -1000, -1000, -1000, -1000,
+ -1000, 194, -1000, 461, 2757, 326, 1165, -1000, -1000, -1000,
+ -1000, -1000, -1000, -1000, -1000, 357, 415, 87, 183, -1000,
+ -1000, 404, -1000, 104, -93, -1000, -1000, 147, -1000, -1000,
+ -1000, -1000, -1000, -1000, 146, -1000, -1000, -1000, 137, -1000,
+ 348, -1000, 179, -1000, 3921, 3880, -1000, -1000, 468, 2349,
+ 3540, -1000, -1000, 3411, -1000, -1000, 1765, 59, 79, -1000,
+ -1000, 254, -1000, -1000, 176, 176, 193, -1000, -1000, -1000,
+ -1000, 126, 2886, 2886, 2886, 15, 193, 752, 819, 763,
+ -1000, 208, 208, 34, 34, 34, 34, 34, 86, 86,
+ -1000, 194, 2349, 325, 330, 18, -1000, 2757, -1000, 138,
+ 2349, 76, -1000, 2757, 194, 203, 203, 203, -1000, 303,
+ 243, -1000, -1000, 2485, 194, 258, 17, 461, 3880, 2757,
+ 2065, -1000, -1000, 2757, 353, -1000, -1000, -1000, 452, 176,
+ 1315, -1000, 1315, 3751, -1000, 163, -1000, -1000, -83, 10,
+ -1000, -1000, -1000, 223, 283, 249, 3921, -1000, -1000, -25,
+ 466, -1000, 271, -1000, -1000, 12, -1000, -1000, -1000, -1000,
+ 15, 193, 679, -1000, 2886, 2886, -1000, 203, 2349, 1915,
+ 176, 198, 313, 69, -1000, 2757, 276, -1000, -1000, -1000,
+ -1000, 330, -1000, -1000, 362, 3751, 3751, 452, -1000, 176,
+ -1000, 176, 3751, -1000, 1165, -1000, 197, -1000, 336, -1000,
+ 40, -1000, -1000, -1000, -1000, -1000, -1000, -1000, 136, -1000,
+ 134, 1615, 3880, 463, 454, 1465, -1000, 2886, 193, 193,
+ -1000, 194, -1000, 194, 336, -1000, 336, 349, 336, -54,
+ 336, -55, 336, 336, 336, 336, 336, 336, -1000, -107,
+ -1000, 176, 2757, -1000, 330, -1000, 296, -1, -1000, -1000,
+ 174, -1000, -1000, 3751, -1000, -1000, 411, -1000, 408, 216,
+ 209, -1000, -1000, -1000, -1000, -1000, 2757, 2757, -1000, 193,
-1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000,
- -1000, -1000, -1000, 2912, 182, 170, 74, 269, 182, 3760,
- 3760, -1000, -1000, -1000, -1000, -1000, -1000, 74, 255, 742,
- -1000, -1000, -1000, -1000, -1000, -1000,
+ -1000, -1000, -1000, -1000, -1000, 194, 160, 176, 243, 194,
+ 3751, 3751, -1000, -1000, -1000, -1000, -1000, -1000, 176, 226,
+ -1000, -1000, -1000, -1000, -1000,
}
var yyPgo = [...]int{
- 0, 663, 16, 405, 661, 655, 652, 650, 649, 648,
- 646, 645, 644, 643, 634, 640, 631, 629, 628, 45,
- 623, 13, 51, 7, 36, 8, 622, 31, 54, 47,
- 620, 34, 618, 616, 44, 614, 53, 609, 607, 40,
- 605, 604, 603, 602, 597, 10, 594, 593, 579, 574,
- 573, 25, 1, 4, 28, 9, 572, 490, 27, 568,
- 21, 566, 559, 553, 551, 12, 550, 43, 549, 11,
- 548, 545, 30, 18, 544, 540, 105, 61, 539, 15,
- 0, 20, 35, 26, 538, 647, 22, 41, 537, 531,
- 530, 527, 526, 525, 524, 517, 515, 513, 152, 512,
- 510, 509, 37, 6, 500, 498, 492, 32, 491, 29,
- 489, 487, 486, 14, 5, 485, 2, 484, 33, 483,
- 478, 472, 119, 3, 470,
+ 0, 635, 17, 414, 631, 630, 629, 628, 623, 621,
+ 619, 614, 612, 611, 605, 447, 604, 602, 600, 33,
+ 598, 15, 53, 8, 29, 3, 589, 22, 66, 41,
+ 588, 35, 587, 586, 51, 585, 58, 584, 583, 31,
+ 582, 577, 569, 561, 560, 439, 556, 549, 546, 545,
+ 544, 13, 4, 2, 6, 7, 542, 262, 16, 541,
+ 12, 540, 539, 538, 536, 10, 535, 32, 533, 26,
+ 532, 531, 38, 20, 530, 133, 60, 529, 27, 0,
+ 11, 37, 21, 528, 616, 14, 42, 526, 525, 524,
+ 522, 520, 518, 517, 516, 515, 513, 126, 512, 511,
+ 510, 40, 9, 509, 508, 507, 34, 506, 28, 503,
+ 502, 501, 25, 5, 496, 1, 494, 36, 492, 490,
+ 489, 48, 45, 487, 486,
}
var yyR1 = [...]int{
- 0, 120, 121, 121, 1, 1, 1, 1, 1, 1,
+ 0, 119, 120, 120, 1, 1, 1, 1, 1, 1,
1, 1, 1, 2, 2, 3, 3, 4, 4, 5,
5, 6, 6, 18, 18, 18, 7, 8, 9, 9,
- 12, 110, 111, 111, 111, 107, 92, 92, 92, 95,
- 95, 93, 93, 93, 93, 93, 93, 94, 94, 94,
- 94, 94, 96, 96, 96, 96, 96, 97, 97, 97,
- 97, 97, 97, 97, 97, 97, 97, 98, 98, 102,
- 102, 103, 103, 103, 100, 100, 101, 101, 104, 104,
- 104, 99, 99, 99, 99, 99, 99, 105, 105, 106,
- 106, 106, 106, 106, 108, 115, 115, 115, 115, 109,
- 109, 117, 117, 116, 112, 112, 112, 113, 113, 113,
- 114, 114, 114, 10, 10, 10, 118, 118, 11, 11,
- 13, 13, 13, 13, 13, 119, 119, 14, 14, 124,
- 15, 16, 16, 17, 17, 19, 19, 23, 23, 22,
- 22, 24, 24, 24, 24, 84, 84, 84, 83, 83,
- 26, 27, 27, 28, 28, 29, 29, 29, 29, 38,
- 71, 71, 30, 30, 30, 31, 31, 32, 32, 89,
- 89, 88, 88, 88, 87, 87, 33, 33, 33, 34,
- 34, 35, 35, 37, 37, 36, 36, 39, 39, 25,
- 25, 25, 25, 25, 25, 25, 75, 75, 41, 41,
- 40, 40, 40, 40, 40, 40, 40, 40, 40, 40,
- 50, 50, 50, 50, 50, 50, 42, 42, 42, 42,
- 42, 42, 42, 21, 21, 51, 51, 51, 57, 52,
- 52, 45, 45, 45, 45, 45, 45, 45, 45, 45,
+ 12, 109, 110, 110, 110, 106, 91, 91, 91, 94,
+ 94, 92, 92, 92, 92, 92, 92, 93, 93, 93,
+ 93, 93, 95, 95, 95, 95, 95, 96, 96, 96,
+ 96, 96, 96, 96, 96, 96, 96, 97, 97, 101,
+ 101, 102, 102, 102, 99, 99, 100, 100, 103, 103,
+ 103, 98, 98, 98, 98, 98, 98, 104, 104, 105,
+ 105, 105, 105, 105, 107, 114, 114, 114, 114, 108,
+ 108, 116, 116, 115, 111, 111, 111, 112, 112, 112,
+ 113, 113, 113, 10, 10, 10, 117, 117, 11, 11,
+ 13, 13, 13, 13, 13, 118, 118, 14, 14, 14,
+ 124, 15, 16, 16, 17, 17, 19, 19, 23, 23,
+ 22, 22, 24, 24, 24, 24, 83, 83, 83, 82,
+ 82, 26, 27, 27, 28, 28, 29, 29, 29, 29,
+ 38, 71, 71, 30, 30, 30, 31, 31, 32, 32,
+ 88, 88, 87, 87, 87, 86, 86, 33, 33, 33,
+ 34, 34, 35, 35, 37, 37, 36, 36, 39, 39,
+ 25, 25, 25, 25, 25, 25, 41, 41, 40, 40,
+ 40, 40, 40, 40, 40, 40, 40, 40, 50, 50,
+ 50, 50, 50, 50, 42, 42, 42, 42, 42, 42,
+ 42, 21, 21, 51, 51, 51, 57, 52, 52, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
- 45, 45, 45, 45, 45, 45, 45, 48, 48, 48,
- 46, 46, 46, 46, 46, 46, 47, 47, 47, 49,
- 49, 49, 91, 91, 91, 91, 91, 91, 91, 91,
- 91, 91, 91, 91, 91, 91, 91, 91, 91, 61,
- 61, 20, 20, 59, 59, 60, 62, 62, 58, 58,
- 58, 44, 44, 44, 44, 44, 44, 44, 63, 63,
- 64, 64, 65, 65, 66, 66, 67, 68, 68, 68,
- 69, 69, 69, 69, 43, 43, 43, 43, 43, 43,
- 70, 70, 70, 70, 53, 53, 55, 55, 54, 56,
- 72, 72, 73, 76, 76, 77, 77, 74, 74, 78,
- 78, 78, 81, 81, 82, 82, 85, 85, 86, 86,
- 79, 79, 79, 79, 79, 79, 79, 79, 79, 79,
- 79, 79, 79, 79, 79, 79, 79, 79, 79, 79,
- 79, 79, 79, 79, 79, 79, 79, 79, 79, 79,
- 79, 79, 79, 79, 79, 79, 79, 79, 79, 79,
+ 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
+ 45, 45, 45, 45, 45, 48, 48, 48, 46, 46,
+ 46, 46, 47, 47, 47, 49, 49, 49, 90, 90,
+ 90, 90, 90, 90, 90, 90, 90, 90, 90, 90,
+ 90, 90, 90, 90, 90, 61, 61, 20, 20, 59,
+ 59, 60, 62, 62, 58, 58, 58, 44, 44, 44,
+ 44, 44, 44, 44, 44, 63, 63, 64, 64, 65,
+ 65, 66, 66, 67, 68, 68, 68, 69, 69, 69,
+ 69, 43, 43, 43, 43, 43, 43, 70, 70, 70,
+ 70, 53, 53, 55, 55, 54, 56, 72, 72, 73,
+ 75, 75, 76, 76, 74, 74, 77, 77, 77, 80,
+ 80, 81, 81, 84, 84, 85, 85, 78, 78, 78,
+ 78, 78, 78, 78, 78, 78, 78, 78, 78, 78,
+ 78, 78, 78, 78, 78, 78, 78, 78, 78, 78,
+ 78, 78, 78, 78, 78, 78, 78, 78, 78, 78,
+ 78, 78, 78, 78, 78, 78, 78, 78, 78, 78,
+ 78, 78, 78, 78, 78, 78, 78, 78, 78, 78,
+ 78, 78, 78, 78, 78, 78, 78, 78, 78, 78,
+ 78, 78, 78, 78, 78, 78, 78, 78, 79, 79,
79, 79, 79, 79, 79, 79, 79, 79, 79, 79,
79, 79, 79, 79, 79, 79, 79, 79, 79, 79,
79, 79, 79, 79, 79, 79, 79, 79, 79, 79,
- 79, 80, 80, 80, 80, 80, 80, 80, 80, 80,
- 80, 80, 80, 80, 80, 80, 80, 80, 80, 80,
- 80, 80, 80, 80, 80, 80, 80, 80, 80, 80,
- 80, 80, 80, 80, 80, 80, 80, 122, 123, 90,
- 90, 90,
+ 79, 79, 79, 79, 121, 122, 123, 89, 89, 89,
}
var yyR2 = [...]int{
@@ -1011,29 +1011,29 @@ var yyR2 = [...]int{
2, 1, 2, 1, 4, 2, 3, 2, 2, 1,
1, 1, 3, 2, 0, 1, 3, 1, 2, 3,
1, 1, 1, 6, 6, 8, 0, 1, 4, 4,
- 4, 5, 3, 3, 5, 0, 1, 2, 2, 0,
- 2, 0, 2, 1, 2, 0, 1, 0, 1, 1,
- 3, 1, 2, 3, 5, 0, 1, 2, 1, 1,
- 2, 1, 3, 1, 1, 1, 1, 3, 3, 2,
- 1, 3, 4, 4, 3, 2, 4, 0, 1, 0,
- 1, 0, 1, 2, 1, 1, 1, 2, 2, 2,
- 3, 2, 2, 2, 1, 1, 3, 0, 2, 1,
- 3, 3, 2, 3, 1, 2, 0, 3, 1, 1,
- 3, 3, 4, 4, 5, 3, 4, 5, 6, 2,
- 1, 2, 1, 2, 1, 2, 1, 1, 1, 1,
- 1, 1, 1, 0, 2, 1, 1, 1, 3, 1,
- 3, 1, 1, 1, 1, 1, 3, 3, 3, 3,
- 3, 3, 3, 3, 3, 3, 3, 3, 2, 2,
- 2, 2, 3, 1, 1, 1, 1, 4, 5, 6,
- 6, 6, 8, 7, 5, 4, 1, 1, 1, 4,
- 4, 4, 2, 1, 2, 2, 2, 1, 2, 2,
- 1, 2, 2, 2, 2, 2, 2, 2, 1, 0,
- 1, 0, 2, 1, 2, 4, 0, 2, 1, 3,
- 5, 1, 1, 1, 1, 1, 1, 1, 0, 3,
- 0, 2, 0, 3, 1, 3, 2, 0, 1, 1,
- 0, 2, 4, 4, 2, 1, 3, 5, 4, 6,
- 1, 3, 3, 5, 1, 3, 1, 2, 3, 1,
- 1, 3, 3, 0, 2, 0, 3, 0, 1, 0,
+ 4, 5, 3, 3, 5, 0, 1, 2, 2, 2,
+ 0, 2, 0, 2, 1, 2, 0, 1, 0, 1,
+ 1, 3, 1, 2, 3, 5, 0, 1, 2, 1,
+ 1, 2, 1, 3, 1, 1, 1, 1, 3, 3,
+ 2, 1, 3, 4, 4, 3, 2, 4, 0, 1,
+ 0, 1, 0, 1, 2, 1, 1, 1, 2, 2,
+ 2, 3, 2, 2, 2, 1, 1, 3, 0, 2,
+ 1, 3, 3, 2, 3, 1, 1, 1, 3, 3,
+ 4, 4, 5, 3, 4, 5, 6, 2, 1, 2,
+ 1, 2, 1, 2, 1, 1, 1, 1, 1, 1,
+ 1, 0, 2, 1, 1, 1, 3, 1, 3, 1,
+ 1, 1, 1, 1, 3, 3, 3, 3, 3, 3,
+ 3, 3, 3, 3, 3, 3, 2, 2, 2, 2,
+ 3, 1, 1, 1, 1, 4, 5, 6, 6, 7,
+ 5, 4, 1, 1, 1, 4, 4, 4, 2, 1,
+ 2, 2, 2, 1, 2, 2, 1, 2, 2, 2,
+ 2, 2, 2, 2, 1, 0, 1, 0, 2, 1,
+ 2, 4, 0, 2, 1, 3, 5, 1, 1, 1,
+ 1, 1, 1, 1, 1, 0, 3, 0, 2, 0,
+ 3, 1, 3, 2, 0, 1, 1, 0, 2, 4,
+ 4, 2, 1, 3, 5, 4, 6, 1, 3, 3,
+ 5, 1, 3, 1, 2, 3, 1, 1, 3, 3,
+ 0, 2, 0, 3, 0, 1, 0, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
@@ -1045,178 +1045,175 @@ var yyR2 = [...]int{
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 0,
- 1, 1,
+ 1, 1, 1, 1, 1, 1, 0, 0, 1, 1,
}
var yyChk = [...]int{
- -1000, -120, -1, -2, -6, -7, -8, -9, -10, -11,
- -13, -14, -3, -4, -18, 8, 9, -12, 93, 94,
- 95, 108, 23, 109, 6, -122, 7, 148, 39, -121,
- 154, -65, 14, -17, 5, -15, -124, -15, -15, -110,
- 39, -78, 98, 103, -81, 42, -80, 117, 136, 130,
- 128, 110, 126, 122, 120, 121, 107, 115, 116, 29,
- 139, 135, 138, 114, 134, 131, 123, 17, 104, 119,
- 141, 113, 132, 124, 125, 137, 112, 133, 142, 153,
- 129, 127, 143, 98, 98, 99, 93, 99, 98, -119,
- 54, -36, -85, 42, -80, -36, -15, -2, 56, -69,
- 16, 15, -5, -3, -122, 18, -74, 101, -16, -27,
- -28, -29, -30, -38, -57, -122, -36, 10, -111, -107,
- 42, 99, -77, 102, -36, -76, 102, -76, 98, 10,
- -36, 144, 55, 92, -19, 19, -123, 41, 148, -25,
- -40, 58, -45, 26, 21, -44, -41, -58, -56, -57,
- 81, 82, 89, 59, 91, -48, -46, -47, -49, 44,
- 43, 45, 46, 47, 48, 51, 52, 53, -81, -85,
- -54, -122, 149, 150, 151, 61, 28, 145, 146, 147,
- 102, 87, 148, 42, -80, -66, -67, -25, -65, -2,
- -37, 24, -36, 50, 27, 40, -33, -34, -35, 30,
- 33, 35, 31, 36, -89, 20, -27, -2, -122, -88,
- -87, 20, -85, 44, -36, 41, 40, -92, -95, -97,
- -96, -93, -94, 128, 129, 132, 133, 134, 135, 136,
- 137, 138, 139, 110, 124, 125, 126, 127, 112, 113,
- 114, 115, 116, 117, 119, 120, 121, 122, 123, -77,
- -36, 58, 97, 96, -36, 21, -36, -36, 98, 10,
- -86, -85, -79, 97, 57, 20, 22, 140, 60, 15,
- 61, 93, 35, 146, 147, 145, 150, 26, 9, 23,
- 109, 19, 85, 95, 64, 65, 111, 21, 53, 10,
- 12, 13, 102, 101, 75, 99, 33, 7, 91, 24,
- 72, 30, 25, 31, 73, 16, 87, 36, 58, 51,
- 37, 56, 14, 34, 74, 96, 148, 32, 6, 152,
- 27, 108, 98, 144, 63, 100, 52, 5, 103, 8,
- 38, 28, 62, 11, -22, -24, 83, -25, -85, 57,
- 56, 72, 40, 17, -25, -42, 75, 58, 73, 74,
- 60, 78, 77, 88, 81, 82, 83, 84, 85, 86,
- 87, 79, 80, 66, 67, 68, 69, 70, 71, 76,
- -75, -122, -57, -122, -45, -45, -45, -45, -45, -122,
- 92, -52, -25, -122, -122, -122, -122, -61, -25, -122,
- -122, -122, -122, 40, -68, 22, 23, -69, -123, -43,
- 27, 28, -2, -122, -36, -72, -73, -58, -81, -85,
- -28, -29, -28, -29, 30, 30, 30, 34, 30, -34,
- -85, -123, -123, -2, -87, -39, 11, -112, -113, -114,
- -82, 44, 45, -81, -79, -107, -108, -115, 104, 103,
- -109, 99, 25, -104, 51, 58, -100, 142, -98, 39,
- -98, -98, -98, -98, -98, -102, 39, -102, -102, -103,
- 39, -103, 42, 21, -118, 105, 100, -118, -36, -36,
- -26, 40, 10, -84, -83, 20, -81, 44, 92, -25,
- -25, -50, 51, 58, 52, 53, -25, -25, -45, -51,
- -54, -57, 49, 75, 73, 74, 60, -45, -45, -45,
+ -1000, -119, -1, -2, -6, -7, -8, -9, -10, -11,
+ -13, -14, -3, -4, -18, 8, 9, -12, 94, 95,
+ 96, 109, 23, 110, 113, 6, -121, 7, 150, 39,
+ -120, 155, -65, 14, -17, 5, -15, -124, -15, -15,
+ -109, 39, -77, 99, 104, -80, 42, -79, 119, 138,
+ 132, 130, 111, 128, 124, 122, 123, 108, 117, 118,
+ 29, 141, 137, 140, 116, 136, 133, 125, 17, 105,
+ 121, 143, 115, 134, 126, 127, 139, 114, 135, 144,
+ 154, 131, 129, 145, 99, 99, 100, 94, 100, 99,
+ -118, 55, -36, -84, 42, -79, -36, -123, -15, -2,
+ 57, -69, 16, 15, -5, -3, -121, 18, -74, 102,
+ -16, -27, -28, -29, -30, -38, -57, -121, -36, 10,
+ -110, -106, 42, 100, -76, 103, -36, -75, 103, -75,
+ 99, 10, -36, 146, 56, 93, -19, 19, -122, 41,
+ 150, -25, -40, 59, -45, 21, -44, -41, -58, -56,
+ -57, 82, 83, 90, 60, 92, -48, -46, -47, -49,
+ 44, 43, 45, 46, 47, 48, 49, 52, 53, 54,
+ -80, -84, -54, -121, 151, 152, 62, 28, 147, 148,
+ 149, 103, 88, 150, 42, -79, -66, -67, -25, -65,
+ -2, -37, 24, -36, 51, 27, 40, -33, -34, -35,
+ 30, 33, 35, 31, 36, -88, 20, -27, -2, -121,
+ -87, -86, 20, -84, 44, -36, 41, 40, -91, -94,
+ -96, -95, -92, -93, 130, 131, 134, 135, 136, 137,
+ 138, 139, 140, 141, 111, 126, 127, 128, 129, 114,
+ 115, 116, 117, 118, 119, 121, 122, 123, 124, 125,
+ -76, -36, 59, 98, 97, -36, 21, -36, -36, 99,
+ 10, -85, -84, -78, 98, 58, 20, 22, 142, 61,
+ 15, 62, 94, 35, 148, 149, 147, 26, 9, 23,
+ 110, 19, 86, 96, 65, 66, 112, 21, 54, 10,
+ 12, 13, 103, 102, 76, 100, 33, 7, 92, 24,
+ 73, 30, 25, 31, 74, 16, 88, 36, 59, 52,
+ 37, 57, 14, 34, 75, 97, 150, 32, 6, 153,
+ 27, 109, 99, 146, 64, 101, 53, 5, 104, 8,
+ 38, 28, 63, 11, 113, -22, -24, 84, -25, -84,
+ 58, 57, 73, 40, 17, -25, -42, 76, 59, 74,
+ 75, 61, 79, 78, 89, 82, 83, 84, 85, 86,
+ 87, 88, 80, 81, 67, 68, 69, 70, 71, 72,
+ 77, -57, -121, -45, -45, -45, -45, -45, -121, 93,
+ -52, -25, -121, -121, -121, -61, -25, -121, -121, -121,
+ -121, 40, -68, 22, 23, -69, -122, -43, 27, 28,
+ -2, -121, -36, -72, -73, -58, -80, -84, -28, -29,
+ -28, -29, 30, 30, 30, 34, 30, -34, -84, -122,
+ -122, -2, -86, -39, 11, -111, -112, -113, -81, 44,
+ 45, -80, -78, -106, -107, -114, 105, 104, -108, 100,
+ 25, -103, 52, 59, -99, 144, -97, 39, -97, -97,
+ -97, -97, -97, -101, 39, -101, -101, -102, 39, -102,
+ 42, 21, -117, 106, 101, -117, -36, -36, -26, 40,
+ 10, -83, -82, 20, -80, 44, 93, -25, -25, -50,
+ 52, 59, 53, 54, -25, -25, -45, -51, -54, -57,
+ 50, 76, 74, 75, 61, -45, -45, -45, -45, -45,
-45, -45, -45, -45, -45, -45, -45, -45, -45, -45,
- -45, -45, 42, -81, -23, 19, -22, -82, -86, -79,
- 40, -123, -25, -58, -19, -59, -60, 62, -58, -22,
- -22, -22, -67, -72, -53, -55, -54, -122, -2, -70,
- -81, -39, 40, 66, 92, -32, -31, 37, 38, -31,
- 30, -123, -65, -25, 40, -114, 66, 39, 25, -109,
- 42, 42, -99, 26, 51, -101, 143, 45, 45, 45,
- 37, -107, -36, -58, -39, -24, -27, -83, 83, -86,
- 51, 52, 53, -51, -45, -45, -45, -21, 111, 57,
- -123, -123, -22, -122, 92, -25, 20, 40, -22, -62,
- -60, 64, -25, -123, -123, -123, -123, 40, -123, -123,
- -123, 40, 92, -65, -73, -25, -82, -25, 39, -69,
- -113, -114, -117, -116, -81, 42, -105, 140, 44, 45,
- 46, 51, 145, 41, 40, 41, 40, -36, 100, -63,
- 12, 92, -21, 57, -45, -45, -123, -23, -82, -91,
- 128, 110, 126, 122, 131, 141, 124, 142, 125, 115,
- 112, 113, 114, 117, 44, -45, -65, 65, -25, 63,
- -55, 28, -2, -122, -81, -81, -69, -71, -81, 41,
- 40, -98, -106, 104, 25, 103, 45, 45, -90, -122,
- -82, -58, -64, 13, 15, 83, -45, -123, -123, -98,
- -98, -103, -98, 116, -98, 116, -98, -98, -98, -98,
- -98, -98, -123, 40, -20, 152, -25, -53, -2, 92,
- 40, 41, -116, 25, 25, 41, 41, -25, -52, -45,
- -123, 44, -123, -81, -81, -123,
+ -80, -23, 19, -22, -81, -85, -78, 40, -122, -25,
+ -19, -59, -60, 63, -58, -22, -22, -22, -67, -72,
+ -53, -55, -54, -121, -2, -70, -80, -39, 40, 67,
+ 93, -32, -31, 37, 38, -31, 30, -122, -65, -25,
+ 40, -113, 67, 39, 25, -108, 42, 42, -98, 26,
+ 52, -100, 145, 45, 45, 45, 37, -106, -36, -58,
+ -39, -24, -27, -82, 84, -85, 52, 53, 54, -51,
+ -45, -45, -45, -21, 112, 58, -122, -22, -121, 93,
+ -25, 20, -22, -62, -60, 65, -25, -122, -122, -122,
+ -122, 40, -122, -122, -122, 40, 93, -65, -73, -25,
+ -81, -25, 39, -69, -112, -113, -116, -115, -80, 42,
+ -104, 142, 44, 45, 46, 52, 147, 41, 40, 41,
+ 40, -36, 101, -63, 12, 93, -21, 58, -45, -45,
+ -122, -23, -81, -90, 130, 111, 128, 124, 133, 143,
+ 126, 144, 127, 117, 114, 115, 116, 119, 44, -65,
+ 66, -25, 64, -55, 28, -2, -121, -80, -80, -69,
+ -71, -80, 41, 40, -97, -105, 105, 25, 104, 45,
+ 45, -89, -121, -81, -58, -64, 13, 15, 84, -45,
+ -122, -122, -97, -97, -102, -97, 118, -97, 118, -97,
+ -97, -97, -97, -97, -97, -20, 153, -25, -53, -2,
+ 93, 40, 41, -115, 25, 25, 41, 41, -25, -52,
+ -122, 44, -122, -80, -80,
}
var yyDef = [...]int{
0, -2, 2, -2, 5, 6, 7, 8, 9, 10,
- 11, 12, 312, 0, 129, 129, 129, 0, 349, 0,
- 0, 125, 0, 0, 129, 0, 23, 24, 467, 1,
- 3, 320, 0, 0, 133, 347, 131, 0, 0, 28,
- 0, 0, 345, 350, 351, 352, 353, 431, 432, 433,
- 434, 435, 436, 437, 438, 439, 440, 441, 442, 443,
- 444, 445, 446, 447, 448, 449, 450, 451, 452, 453,
- 454, 455, 456, 457, 458, 459, 460, 461, 462, 463,
- 464, 465, 466, 0, 343, 343, 0, 0, 0, 0,
- 126, 127, 185, 356, 357, 128, 135, 17, 0, 13,
- 0, 0, 312, 19, 0, 134, 0, 348, 130, 0,
- 151, 153, 154, 155, -2, 0, 171, 0, 0, 32,
- 0, 345, 0, 0, 0, 0, 0, 0, 0, 0,
- 122, 123, 0, 0, 0, 136, 18, 468, 25, 321,
- 189, 0, 194, 196, 0, 231, 232, 233, 234, 235,
- 0, 0, 0, 0, 0, 253, 254, 255, 256, 301,
- 302, 303, 304, 305, 306, 307, 198, 199, 298, 0,
- 339, 0, 0, 0, 0, 289, 0, 266, 267, 268,
- 0, 0, 0, -2, -2, 313, 314, 317, 320, 17,
- 0, 0, 184, 132, 0, 0, 0, 0, 0, 176,
- 0, 0, 0, 0, 0, 170, 0, 17, 0, 159,
- 172, 0, 174, 175, 187, 104, 0, 78, 74, 37,
- 38, 67, 40, 67, 67, 59, 60, 61, 62, 63,
- 64, 65, 66, 52, 67, 67, 67, 56, 41, 42,
- 43, 44, 45, 46, 69, 69, 69, 71, 71, 0,
- 30, 0, 116, 116, 118, 344, 119, 120, 0, 0,
- 186, 358, 359, 360, 361, 362, 363, 364, 365, 366,
- 367, 368, 369, 370, 371, 372, 373, 374, 375, 376,
- 377, 378, 379, 380, 381, 382, 383, 384, 385, 386,
- 387, 388, 389, 390, 391, 392, 393, 394, 395, 396,
- 397, 398, 399, 400, 401, 402, 403, 404, 405, 406,
- 407, 408, 409, 410, 411, 412, 413, 414, 415, 416,
- 417, 418, 419, 420, 421, 422, 423, 424, 425, 426,
- 427, 428, 429, 430, 16, 139, 141, 145, 0, 0,
- 0, 0, 0, 0, 192, 0, 0, 0, 0, 0,
+ 11, 12, 309, 0, 130, 130, 130, 0, 346, 0,
+ 0, 125, 0, 0, 466, 130, 0, 23, 24, 464,
+ 1, 3, 317, 0, 0, 134, 344, 132, 0, 0,
+ 28, 0, 0, 342, 347, 348, 349, 350, 428, 429,
+ 430, 431, 432, 433, 434, 435, 436, 437, 438, 439,
+ 440, 441, 442, 443, 444, 445, 446, 447, 448, 449,
+ 450, 451, 452, 453, 454, 455, 456, 457, 458, 459,
+ 460, 461, 462, 463, 0, 340, 340, 0, 0, 0,
+ 0, 126, 127, 186, 353, 354, 128, 129, 136, 17,
+ 0, 13, 0, 0, 309, 19, 0, 135, 0, 345,
+ 131, 0, 152, 154, 155, 156, -2, 0, 172, 0,
+ 0, 32, 0, 342, 0, 0, 0, 0, 0, 0,
+ 0, 0, 122, 123, 0, 0, 0, 137, 18, 465,
+ 25, 318, 190, 0, 195, 0, 229, 230, 231, 232,
+ 233, 0, 0, 0, 0, 0, 251, 252, 253, 254,
+ 297, 298, 299, 300, 301, 302, 303, 304, 196, 197,
+ 294, 0, 336, 0, 0, 0, 285, 0, 262, 263,
+ 264, 0, 0, 0, -2, -2, 310, 311, 314, 317,
+ 17, 0, 0, 185, 133, 0, 0, 0, 0, 0,
+ 177, 0, 0, 0, 0, 0, 171, 0, 17, 0,
+ 160, 173, 0, 175, 176, 188, 104, 0, 78, 74,
+ 37, 38, 67, 40, 67, 67, 59, 60, 61, 62,
+ 63, 64, 65, 66, 52, 67, 67, 67, 56, 41,
+ 42, 43, 44, 45, 46, 69, 69, 69, 71, 71,
+ 0, 30, 0, 116, 116, 118, 341, 119, 120, 0,
+ 0, 187, 355, 356, 357, 358, 359, 360, 361, 362,
+ 363, 364, 365, 366, 367, 368, 369, 370, 371, 372,
+ 373, 374, 375, 376, 377, 378, 379, 380, 381, 382,
+ 383, 384, 385, 386, 387, 388, 389, 390, 391, 392,
+ 393, 394, 395, 396, 397, 398, 399, 400, 401, 402,
+ 403, 404, 405, 406, 407, 408, 409, 410, 411, 412,
+ 413, 414, 415, 416, 417, 418, 419, 420, 421, 422,
+ 423, 424, 425, 426, 427, 16, 140, 142, 146, 0,
+ 0, 0, 0, 0, 0, 193, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 216, 217, 218, 219, 220, 221, 222,
- 195, 0, 209, 0, 248, 249, 250, 251, 0, 137,
- 0, 0, 229, 0, 0, 0, 135, 0, 290, 0,
- 0, 0, 0, 0, 316, 318, 319, 14, 20, 21,
- 0, 0, -2, 0, 183, 187, 340, 0, 298, 0,
- 152, 167, 0, 164, 177, 178, 179, 0, 181, 182,
- 157, 158, 228, 17, 173, 312, 0, 31, 105, 107,
- 110, 111, 112, 354, 355, 33, 34, 0, 0, 0,
- 0, 99, 100, 81, 79, 0, 76, 75, 39, 0,
- 57, 58, 53, 54, 55, 47, 0, 48, 49, 50,
- 0, 51, 0, 346, 0, 117, 0, 0, 121, 124,
- 187, 0, 0, 142, 146, 0, 148, 149, 0, 190,
- 191, 193, 210, 0, 212, 214, 322, 323, 200, 201,
- 225, 226, 227, 0, 0, 0, 0, 223, 205, 0,
+ 0, 0, 0, 0, 214, 215, 216, 217, 218, 219,
+ 220, 207, 0, 246, 247, 248, 249, 0, 138, 0,
+ 0, 227, 0, 0, 136, 0, 286, 0, 0, 0,
+ 0, 0, 313, 315, 316, 14, 20, 21, 0, 0,
+ -2, 0, 184, 188, 337, 0, 294, 0, 153, 168,
+ 0, 165, 178, 179, 180, 0, 182, 183, 158, 159,
+ 226, 17, 174, 309, 0, 31, 105, 107, 110, 111,
+ 112, 351, 352, 33, 34, 0, 0, 0, 0, 99,
+ 100, 81, 79, 0, 76, 75, 39, 0, 57, 58,
+ 53, 54, 55, 47, 0, 48, 49, 50, 0, 51,
+ 0, 343, 0, 117, 0, 0, 121, 124, 188, 0,
+ 0, 143, 147, 0, 149, 150, 0, 191, 192, 194,
+ 208, 0, 210, 212, 319, 320, 198, 199, 223, 224,
+ 225, 0, 0, 0, 0, 221, 203, 0, 234, 235,
236, 237, 238, 239, 240, 241, 242, 243, 244, 245,
- 246, 247, 0, 252, 0, 0, 138, 299, 0, -2,
- 0, 338, 0, 0, 0, 296, 293, 0, 0, 0,
- 0, 0, 315, 22, 324, 334, 336, 0, 17, 0,
- 330, 312, 0, 0, 0, 162, 168, 0, 0, 163,
- 180, -2, 320, 188, 0, 108, 0, 0, 95, 0,
- 97, 98, 87, 0, 80, 36, 77, 0, 0, 0,
- 0, 113, 114, 0, 308, 140, 150, 147, 143, 0,
- 211, 213, 215, 202, 223, 206, 0, 203, 0, 0,
- 197, 257, 0, 137, 0, 230, 0, 0, 312, 0,
- 294, 0, 0, 265, 269, 270, 271, 0, 337, -2,
- 0, 0, 0, 320, 341, 342, 299, 165, 0, 27,
- 106, 109, 0, 101, 67, 96, 89, 88, 82, 83,
- 84, 85, 86, 68, 0, 72, 0, 469, 0, 310,
- 0, 0, 204, 0, 224, 207, 258, 0, 300, 0,
- 67, 273, 67, 71, 67, 277, 67, 280, 67, 67,
- 67, 67, 67, 67, 288, 0, 291, 264, 297, 0,
- 335, 0, -2, 0, 332, 331, 26, 0, 160, 94,
- 0, 103, 35, 0, 91, 93, 0, 0, 29, 470,
- 471, 115, 15, 0, 0, 144, 208, 259, 260, 272,
- 274, 275, 276, 278, 279, 281, 282, 283, 284, 285,
- 286, 287, 261, 0, 0, 0, 295, 327, 17, 0,
- 0, 166, 102, 90, 92, 70, 73, 311, 309, 0,
- 263, 292, -2, 333, 161, 262,
+ 250, 0, 0, 139, 295, 0, -2, 0, 335, 0,
+ 0, 292, 289, 0, 0, 0, 0, 0, 312, 22,
+ 321, 331, 333, 0, 17, 0, 327, 309, 0, 0,
+ 0, 163, 169, 0, 0, 164, 181, -2, 317, 189,
+ 0, 108, 0, 0, 95, 0, 97, 98, 87, 0,
+ 80, 36, 77, 0, 0, 0, 0, 113, 114, 0,
+ 305, 141, 151, 148, 144, 0, 209, 211, 213, 200,
+ 221, 204, 0, 201, 0, 0, 255, 0, 138, 0,
+ 228, 0, 309, 0, 290, 0, 0, 261, 265, 266,
+ 267, 0, 334, -2, 0, 0, 0, 317, 338, 339,
+ 295, 166, 0, 27, 106, 109, 0, 101, 67, 96,
+ 89, 88, 82, 83, 84, 85, 86, 68, 0, 72,
+ 0, 467, 0, 307, 0, 0, 202, 0, 222, 205,
+ 256, 0, 296, 0, 67, 269, 67, 71, 67, 273,
+ 67, 276, 67, 67, 67, 67, 67, 67, 284, 287,
+ 260, 293, 0, 332, 0, -2, 0, 329, 328, 26,
+ 0, 161, 94, 0, 103, 35, 0, 91, 93, 0,
+ 0, 29, 468, 469, 115, 15, 0, 0, 145, 206,
+ 257, 258, 268, 270, 271, 272, 274, 275, 277, 278,
+ 279, 280, 281, 282, 283, 0, 0, 291, 324, 17,
+ 0, 0, 167, 102, 90, 92, 70, 73, 308, 306,
+ 259, 288, -2, 330, 162,
}
var yyTok1 = [...]int{
1, 3, 3, 3, 3, 3, 3, 3, 3, 3,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
- 3, 3, 3, 59, 3, 3, 3, 86, 78, 3,
- 39, 41, 83, 81, 40, 82, 92, 84, 3, 3,
- 3, 3, 3, 3, 3, 3, 3, 3, 3, 154,
- 67, 66, 68, 3, 3, 3, 3, 3, 3, 3,
+ 3, 3, 3, 60, 3, 3, 3, 87, 79, 3,
+ 39, 41, 84, 82, 40, 83, 93, 85, 3, 3,
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 155,
+ 68, 67, 69, 3, 3, 3, 3, 3, 3, 3,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
- 3, 3, 3, 3, 88, 3, 3, 3, 3, 3,
+ 3, 3, 3, 3, 89, 3, 3, 3, 3, 3,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
- 3, 3, 3, 3, 77, 3, 89,
+ 3, 3, 3, 3, 78, 3, 90,
}
var yyTok2 = [...]int{
@@ -1225,15 +1222,15 @@ var yyTok2 = [...]int{
22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
32, 33, 34, 35, 36, 37, 38, 42, 43, 44,
45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
- 55, 56, 57, 58, 60, 61, 62, 63, 64, 65,
- 69, 70, 71, 72, 73, 74, 75, 76, 79, 80,
- 85, 87, 90, 91, 93, 94, 95, 96, 97, 98,
+ 55, 56, 57, 58, 59, 61, 62, 63, 64, 65,
+ 66, 70, 71, 72, 73, 74, 75, 76, 77, 80,
+ 81, 86, 88, 91, 92, 94, 95, 96, 97, 98,
99, 100, 101, 102, 103, 104, 105, 106, 107, 108,
109, 110, 111, 112, 113, 114, 115, 116, 117, 118,
119, 120, 121, 122, 123, 124, 125, 126, 127, 128,
129, 130, 131, 132, 133, 134, 135, 136, 137, 138,
139, 140, 141, 142, 143, 144, 145, 146, 147, 148,
- 149, 150, 151, 152, 153,
+ 149, 150, 151, 152, 153, 154,
}
var yyTok3 = [...]int{
0,
@@ -1578,29 +1575,29 @@ yydefault:
case 1:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:244
+ //line sql.y:243
{
setParseTree(yylex, yyDollar[1].statement)
}
case 2:
yyDollar = yyS[yypt-0 : yypt+1]
- //line sql.y:249
+ //line sql.y:248
{
}
case 3:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:250
+ //line sql.y:249
{
}
case 4:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:254
+ //line sql.y:253
{
yyVAL.statement = yyDollar[1].selStmt
}
case 13:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:268
+ //line sql.y:267
{
sel := yyDollar[1].selStmt.(*Select)
sel.OrderBy = yyDollar[2].orderBy
@@ -1609,49 +1606,49 @@ yydefault:
}
case 14:
yyDollar = yyS[yypt-5 : yypt+1]
- //line sql.y:275
+ //line sql.y:274
{
yyVAL.selStmt = &Union{Type: yyDollar[2].str, Left: yyDollar[1].selStmt, Right: yyDollar[3].selStmt, OrderBy: yyDollar[4].orderBy, Limit: yyDollar[5].limit}
}
case 15:
yyDollar = yyS[yypt-8 : yypt+1]
- //line sql.y:282
+ //line sql.y:281
{
yyVAL.selStmt = &Select{Comments: Comments(yyDollar[2].bytes2), Distinct: yyDollar[3].str, SelectExprs: yyDollar[4].selectExprs, From: yyDollar[5].tableExprs, Where: NewWhere(WhereStr, yyDollar[6].expr), GroupBy: GroupBy(yyDollar[7].exprs), Having: NewWhere(HavingStr, yyDollar[8].expr)}
}
case 16:
yyDollar = yyS[yypt-4 : yypt+1]
- //line sql.y:286
+ //line sql.y:285
{
yyVAL.selStmt = &Select{Comments: Comments(yyDollar[2].bytes2), Distinct: yyDollar[3].str, SelectExprs: yyDollar[4].selectExprs}
}
case 17:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:292
+ //line sql.y:291
{
yyVAL.selStmt = yyDollar[1].selStmt
}
case 18:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:296
+ //line sql.y:295
{
yyVAL.selStmt = &ParenSelect{Select: yyDollar[2].selStmt}
}
case 19:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:302
+ //line sql.y:301
{
yyVAL.selStmt = yyDollar[1].selStmt
}
case 20:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:306
+ //line sql.y:305
{
yyVAL.selStmt = &ParenSelect{Select: yyDollar[2].selStmt}
}
case 21:
yyDollar = yyS[yypt-5 : yypt+1]
- //line sql.y:313
+ //line sql.y:312
{
// insert_data returns a *Insert pre-filled with Columns & Values
ins := yyDollar[5].ins
@@ -1663,7 +1660,7 @@ yydefault:
}
case 22:
yyDollar = yyS[yypt-6 : yypt+1]
- //line sql.y:323
+ //line sql.y:322
{
cols := make(Columns, 0, len(yyDollar[6].updateExprs))
vals := make(ValTuple, 0, len(yyDollar[6].updateExprs))
@@ -1675,84 +1672,84 @@ yydefault:
}
case 23:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:335
+ //line sql.y:334
{
yyVAL.str = InsertStr
}
case 24:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:339
+ //line sql.y:338
{
yyVAL.str = ReplaceStr
}
case 25:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:343
+ //line sql.y:342
{
yyVAL.str = ReplaceStr
}
case 26:
yyDollar = yyS[yypt-8 : yypt+1]
- //line sql.y:349
+ //line sql.y:348
{
yyVAL.statement = &Update{Comments: Comments(yyDollar[2].bytes2), TableExprs: yyDollar[3].tableExprs, Exprs: yyDollar[5].updateExprs, Where: NewWhere(WhereStr, yyDollar[6].expr), OrderBy: yyDollar[7].orderBy, Limit: yyDollar[8].limit}
}
case 27:
yyDollar = yyS[yypt-7 : yypt+1]
- //line sql.y:355
+ //line sql.y:354
{
yyVAL.statement = &Delete{Comments: Comments(yyDollar[2].bytes2), TableExprs: TableExprs{&AliasedTableExpr{Expr: yyDollar[4].tableName}}, Where: NewWhere(WhereStr, yyDollar[5].expr), OrderBy: yyDollar[6].orderBy, Limit: yyDollar[7].limit}
}
case 28:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:361
+ //line sql.y:360
{
yyDollar[1].ddl.TableSpec = yyDollar[2].TableSpec
yyVAL.statement = yyDollar[1].ddl
}
case 29:
yyDollar = yyS[yypt-8 : yypt+1]
- //line sql.y:366
+ //line sql.y:365
{
// Change this to an alter statement
yyVAL.statement = &DDL{Action: CreateIndexStr, Table: yyDollar[7].tableName, NewName: yyDollar[7].tableName}
}
case 30:
yyDollar = yyS[yypt-4 : yypt+1]
- //line sql.y:373
+ //line sql.y:372
{
yyVAL.ddl = &DDL{Action: CreateStr, NewName: yyDollar[4].tableName}
setDDL(yylex, yyVAL.ddl)
}
case 31:
yyDollar = yyS[yypt-4 : yypt+1]
- //line sql.y:380
+ //line sql.y:379
{
yyVAL.TableSpec = yyDollar[2].TableSpec
yyVAL.TableSpec.Options = yyDollar[4].str
}
case 32:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:387
+ //line sql.y:386
{
yyVAL.TableSpec = &TableSpec{}
yyVAL.TableSpec.AddColumn(yyDollar[1].columnDefinition)
}
case 33:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:392
+ //line sql.y:391
{
yyVAL.TableSpec.AddColumn(yyDollar[3].columnDefinition)
}
case 34:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:396
+ //line sql.y:395
{
yyVAL.TableSpec.AddIndex(yyDollar[3].indexDefinition)
}
case 35:
yyDollar = yyS[yypt-6 : yypt+1]
- //line sql.y:402
+ //line sql.y:401
{
yyDollar[2].columnType.NotNull = yyDollar[3].boolVal
yyDollar[2].columnType.Default = yyDollar[4].optVal
@@ -1762,7 +1759,7 @@ yydefault:
}
case 36:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:411
+ //line sql.y:410
{
yyVAL.columnType = yyDollar[1].columnType
yyVAL.columnType.Unsigned = yyDollar[2].boolVal
@@ -1770,56 +1767,56 @@ yydefault:
}
case 39:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:421
+ //line sql.y:420
{
yyVAL.columnType = yyDollar[1].columnType
yyVAL.columnType.Length = yyDollar[2].optVal
}
case 40:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:426
+ //line sql.y:425
{
yyVAL.columnType = yyDollar[1].columnType
}
case 41:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:432
+ //line sql.y:431
{
yyVAL.columnType = ColumnType{Type: string(yyDollar[1].bytes)}
}
case 42:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:436
+ //line sql.y:435
{
yyVAL.columnType = ColumnType{Type: string(yyDollar[1].bytes)}
}
case 43:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:440
+ //line sql.y:439
{
yyVAL.columnType = ColumnType{Type: string(yyDollar[1].bytes)}
}
case 44:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:444
+ //line sql.y:443
{
yyVAL.columnType = ColumnType{Type: string(yyDollar[1].bytes)}
}
case 45:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:448
+ //line sql.y:447
{
yyVAL.columnType = ColumnType{Type: string(yyDollar[1].bytes)}
}
case 46:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:452
+ //line sql.y:451
{
yyVAL.columnType = ColumnType{Type: string(yyDollar[1].bytes)}
}
case 47:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:458
+ //line sql.y:457
{
yyVAL.columnType = ColumnType{Type: string(yyDollar[1].bytes)}
yyVAL.columnType.Length = yyDollar[2].LengthScaleOption.Length
@@ -1827,7 +1824,7 @@ yydefault:
}
case 48:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:464
+ //line sql.y:463
{
yyVAL.columnType = ColumnType{Type: string(yyDollar[1].bytes)}
yyVAL.columnType.Length = yyDollar[2].LengthScaleOption.Length
@@ -1835,7 +1832,7 @@ yydefault:
}
case 49:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:470
+ //line sql.y:469
{
yyVAL.columnType = ColumnType{Type: string(yyDollar[1].bytes)}
yyVAL.columnType.Length = yyDollar[2].LengthScaleOption.Length
@@ -1843,7 +1840,7 @@ yydefault:
}
case 50:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:476
+ //line sql.y:475
{
yyVAL.columnType = ColumnType{Type: string(yyDollar[1].bytes)}
yyVAL.columnType.Length = yyDollar[2].LengthScaleOption.Length
@@ -1851,7 +1848,7 @@ yydefault:
}
case 51:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:482
+ //line sql.y:481
{
yyVAL.columnType = ColumnType{Type: string(yyDollar[1].bytes)}
yyVAL.columnType.Length = yyDollar[2].LengthScaleOption.Length
@@ -1859,115 +1856,115 @@ yydefault:
}
case 52:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:490
+ //line sql.y:489
{
yyVAL.columnType = ColumnType{Type: string(yyDollar[1].bytes)}
}
case 53:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:494
+ //line sql.y:493
{
yyVAL.columnType = ColumnType{Type: string(yyDollar[1].bytes), Length: yyDollar[2].optVal}
}
case 54:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:498
+ //line sql.y:497
{
yyVAL.columnType = ColumnType{Type: string(yyDollar[1].bytes), Length: yyDollar[2].optVal}
}
case 55:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:502
+ //line sql.y:501
{
yyVAL.columnType = ColumnType{Type: string(yyDollar[1].bytes), Length: yyDollar[2].optVal}
}
case 56:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:506
+ //line sql.y:505
{
yyVAL.columnType = ColumnType{Type: string(yyDollar[1].bytes)}
}
case 57:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:512
+ //line sql.y:511
{
yyVAL.columnType = ColumnType{Type: string(yyDollar[1].bytes), Length: yyDollar[2].optVal}
}
case 58:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:516
+ //line sql.y:515
{
yyVAL.columnType = ColumnType{Type: string(yyDollar[1].bytes), Length: yyDollar[2].optVal}
}
case 59:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:520
+ //line sql.y:519
{
yyVAL.columnType = ColumnType{Type: string(yyDollar[1].bytes)}
}
case 60:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:524
+ //line sql.y:523
{
yyVAL.columnType = ColumnType{Type: string(yyDollar[1].bytes)}
}
case 61:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:528
+ //line sql.y:527
{
yyVAL.columnType = ColumnType{Type: string(yyDollar[1].bytes)}
}
case 62:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:532
+ //line sql.y:531
{
yyVAL.columnType = ColumnType{Type: string(yyDollar[1].bytes)}
}
case 63:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:536
+ //line sql.y:535
{
yyVAL.columnType = ColumnType{Type: string(yyDollar[1].bytes)}
}
case 64:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:540
+ //line sql.y:539
{
yyVAL.columnType = ColumnType{Type: string(yyDollar[1].bytes)}
}
case 65:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:544
+ //line sql.y:543
{
yyVAL.columnType = ColumnType{Type: string(yyDollar[1].bytes)}
}
case 66:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:548
+ //line sql.y:547
{
yyVAL.columnType = ColumnType{Type: string(yyDollar[1].bytes)}
}
case 67:
yyDollar = yyS[yypt-0 : yypt+1]
- //line sql.y:553
+ //line sql.y:552
{
yyVAL.optVal = nil
}
case 68:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:557
+ //line sql.y:556
{
yyVAL.optVal = NewIntVal(yyDollar[2].bytes)
}
case 69:
yyDollar = yyS[yypt-0 : yypt+1]
- //line sql.y:562
+ //line sql.y:561
{
yyVAL.LengthScaleOption = LengthScaleOption{}
}
case 70:
yyDollar = yyS[yypt-5 : yypt+1]
- //line sql.y:566
+ //line sql.y:565
{
yyVAL.LengthScaleOption = LengthScaleOption{
Length: NewIntVal(yyDollar[2].bytes),
@@ -1976,13 +1973,13 @@ yydefault:
}
case 71:
yyDollar = yyS[yypt-0 : yypt+1]
- //line sql.y:574
+ //line sql.y:573
{
yyVAL.LengthScaleOption = LengthScaleOption{}
}
case 72:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:578
+ //line sql.y:577
{
yyVAL.LengthScaleOption = LengthScaleOption{
Length: NewIntVal(yyDollar[2].bytes),
@@ -1990,7 +1987,7 @@ yydefault:
}
case 73:
yyDollar = yyS[yypt-5 : yypt+1]
- //line sql.y:584
+ //line sql.y:583
{
yyVAL.LengthScaleOption = LengthScaleOption{
Length: NewIntVal(yyDollar[2].bytes),
@@ -1999,266 +1996,266 @@ yydefault:
}
case 74:
yyDollar = yyS[yypt-0 : yypt+1]
- //line sql.y:592
+ //line sql.y:591
{
yyVAL.boolVal = BoolVal(false)
}
case 75:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:596
+ //line sql.y:595
{
yyVAL.boolVal = BoolVal(true)
}
case 76:
yyDollar = yyS[yypt-0 : yypt+1]
- //line sql.y:601
+ //line sql.y:600
{
yyVAL.boolVal = BoolVal(false)
}
case 77:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:605
+ //line sql.y:604
{
yyVAL.boolVal = BoolVal(true)
}
case 78:
yyDollar = yyS[yypt-0 : yypt+1]
- //line sql.y:611
+ //line sql.y:610
{
yyVAL.boolVal = BoolVal(false)
}
case 79:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:615
+ //line sql.y:614
{
yyVAL.boolVal = BoolVal(false)
}
case 80:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:619
+ //line sql.y:618
{
yyVAL.boolVal = BoolVal(true)
}
case 81:
yyDollar = yyS[yypt-0 : yypt+1]
- //line sql.y:624
+ //line sql.y:623
{
yyVAL.optVal = nil
}
case 82:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:628
+ //line sql.y:627
{
yyVAL.optVal = NewStrVal(yyDollar[2].bytes)
}
case 83:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:632
+ //line sql.y:631
{
yyVAL.optVal = NewIntVal(yyDollar[2].bytes)
}
case 84:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:636
+ //line sql.y:635
{
yyVAL.optVal = NewFloatVal(yyDollar[2].bytes)
}
case 85:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:640
+ //line sql.y:639
{
yyVAL.optVal = NewValArg(yyDollar[2].bytes)
}
case 86:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:644
+ //line sql.y:643
{
yyVAL.optVal = NewValArg(yyDollar[2].bytes)
}
case 87:
yyDollar = yyS[yypt-0 : yypt+1]
- //line sql.y:649
+ //line sql.y:648
{
yyVAL.boolVal = BoolVal(false)
}
case 88:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:653
+ //line sql.y:652
{
yyVAL.boolVal = BoolVal(true)
}
case 89:
yyDollar = yyS[yypt-0 : yypt+1]
- //line sql.y:658
+ //line sql.y:657
{
yyVAL.colKeyOpt = colKeyNone
}
case 90:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:662
+ //line sql.y:661
{
yyVAL.colKeyOpt = colKeyPrimary
}
case 91:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:666
+ //line sql.y:665
{
yyVAL.colKeyOpt = colKey
}
case 92:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:670
+ //line sql.y:669
{
yyVAL.colKeyOpt = colKeyUniqueKey
}
case 93:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:674
+ //line sql.y:673
{
yyVAL.colKeyOpt = colKeyUnique
}
case 94:
yyDollar = yyS[yypt-4 : yypt+1]
- //line sql.y:680
+ //line sql.y:679
{
yyVAL.indexDefinition = &IndexDefinition{Info: yyDollar[1].indexInfo, Columns: yyDollar[3].indexColumns}
}
case 95:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:686
+ //line sql.y:685
{
yyVAL.indexInfo = &IndexInfo{Type: string(yyDollar[1].bytes) + " " + string(yyDollar[2].bytes), Name: NewColIdent("PRIMARY"), Primary: true, Unique: true}
}
case 96:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:690
+ //line sql.y:689
{
yyVAL.indexInfo = &IndexInfo{Type: string(yyDollar[1].bytes) + " " + string(yyDollar[2].str), Name: NewColIdent(string(yyDollar[3].bytes)), Unique: true}
}
case 97:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:694
+ //line sql.y:693
{
yyVAL.indexInfo = &IndexInfo{Type: string(yyDollar[1].bytes), Name: NewColIdent(string(yyDollar[2].bytes)), Unique: true}
}
case 98:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:698
+ //line sql.y:697
{
yyVAL.indexInfo = &IndexInfo{Type: string(yyDollar[1].str), Name: NewColIdent(string(yyDollar[2].bytes)), Unique: false}
}
case 99:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:704
+ //line sql.y:703
{
yyVAL.str = string(yyDollar[1].bytes)
}
case 100:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:708
+ //line sql.y:707
{
yyVAL.str = string(yyDollar[1].bytes)
}
case 101:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:714
+ //line sql.y:713
{
yyVAL.indexColumns = []*IndexColumn{yyDollar[1].indexColumn}
}
case 102:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:718
+ //line sql.y:717
{
yyVAL.indexColumns = append(yyVAL.indexColumns, yyDollar[3].indexColumn)
}
case 103:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:724
+ //line sql.y:723
{
yyVAL.indexColumn = &IndexColumn{Column: yyDollar[1].colIdent, Length: yyDollar[2].optVal}
}
case 104:
yyDollar = yyS[yypt-0 : yypt+1]
- //line sql.y:729
+ //line sql.y:728
{
yyVAL.str = ""
}
case 105:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:733
+ //line sql.y:732
{
yyVAL.str = " " + string(yyDollar[1].str)
}
case 106:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:737
+ //line sql.y:736
{
yyVAL.str = string(yyDollar[1].str) + ", " + string(yyDollar[3].str)
}
case 107:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:745
+ //line sql.y:744
{
yyVAL.str = yyDollar[1].str
}
case 108:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:749
+ //line sql.y:748
{
yyVAL.str = yyDollar[1].str + " " + yyDollar[2].str
}
case 109:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:753
+ //line sql.y:752
{
yyVAL.str = yyDollar[1].str + "=" + yyDollar[3].str
}
case 110:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:759
+ //line sql.y:758
{
yyVAL.str = yyDollar[1].colIdent.String()
}
case 111:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:763
+ //line sql.y:762
{
yyVAL.str = "'" + string(yyDollar[1].bytes) + "'"
}
case 112:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:767
+ //line sql.y:766
{
yyVAL.str = string(yyDollar[1].bytes)
}
case 113:
yyDollar = yyS[yypt-6 : yypt+1]
- //line sql.y:773
+ //line sql.y:772
{
yyVAL.statement = &DDL{Action: AlterStr, Table: yyDollar[3].tableName, NewName: yyDollar[3].tableName}
}
case 114:
yyDollar = yyS[yypt-6 : yypt+1]
- //line sql.y:777
+ //line sql.y:776
{
// Change this to a rename statement
yyVAL.statement = &DDL{Action: RenameStr, Table: yyDollar[3].tableName, NewName: yyDollar[6].tableName}
}
case 115:
yyDollar = yyS[yypt-8 : yypt+1]
- //line sql.y:782
+ //line sql.y:781
{
// Rename an index can just be an alter
yyVAL.statement = &DDL{Action: AlterStr, Table: yyDollar[3].tableName, NewName: yyDollar[3].tableName}
}
case 116:
yyDollar = yyS[yypt-0 : yypt+1]
- //line sql.y:788
+ //line sql.y:787
{
}
case 118:
yyDollar = yyS[yypt-4 : yypt+1]
- //line sql.y:792
+ //line sql.y:791
{
var exists bool
if yyDollar[3].byt != 0 {
@@ -2268,7 +2265,7 @@ yydefault:
}
case 119:
yyDollar = yyS[yypt-4 : yypt+1]
- //line sql.y:800
+ //line sql.y:799
{
var exists bool
if yyDollar[3].byt != 0 {
@@ -2278,752 +2275,740 @@ yydefault:
}
case 120:
yyDollar = yyS[yypt-4 : yypt+1]
- //line sql.y:810
+ //line sql.y:809
{
yyVAL.statement = &Show{Type: string(yyDollar[3].bytes), ShowCreate: true, OnTable: yyDollar[4].tableName}
}
case 121:
yyDollar = yyS[yypt-5 : yypt+1]
- //line sql.y:814
+ //line sql.y:813
{
yyVAL.statement = &Show{Type: string(yyDollar[2].bytes), OnTable: yyDollar[5].tableName}
}
case 122:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:818
+ //line sql.y:817
{
yyVAL.statement = &Show{Type: string(yyDollar[2].bytes), OnTable: yyDollar[3].tableName}
}
case 123:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:822
+ //line sql.y:821
{
yyVAL.statement = &Show{Type: string(yyDollar[3].bytes)}
}
case 124:
yyDollar = yyS[yypt-5 : yypt+1]
- //line sql.y:826
+ //line sql.y:825
{
yyVAL.statement = &Show{Type: "table", OnTable: yyDollar[5].tableName}
}
case 125:
yyDollar = yyS[yypt-0 : yypt+1]
- //line sql.y:831
+ //line sql.y:830
{
yyVAL.bytes = nil
}
case 126:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:835
+ //line sql.y:834
{
yyVAL.bytes = nil
}
case 127:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:841
+ //line sql.y:840
{
yyVAL.statement = &Show{Type: "table", OnTable: yyDollar[2].tableName}
}
case 128:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:845
+ //line sql.y:844
{
yyVAL.statement = &Show{Type: "table", OnTable: yyDollar[2].tableName}
}
case 129:
+ yyDollar = yyS[yypt-2 : yypt+1]
+ //line sql.y:848
+ {
+ yyVAL.statement = &Explain{}
+ }
+ case 130:
yyDollar = yyS[yypt-0 : yypt+1]
- //line sql.y:850
+ //line sql.y:853
{
setAllowComments(yylex, true)
}
- case 130:
+ case 131:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:854
+ //line sql.y:857
{
yyVAL.bytes2 = yyDollar[2].bytes2
setAllowComments(yylex, false)
}
- case 131:
+ case 132:
yyDollar = yyS[yypt-0 : yypt+1]
- //line sql.y:860
+ //line sql.y:863
{
yyVAL.bytes2 = nil
}
- case 132:
+ case 133:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:864
+ //line sql.y:867
{
yyVAL.bytes2 = append(yyDollar[1].bytes2, yyDollar[2].bytes)
}
- case 133:
+ case 134:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:870
+ //line sql.y:873
{
yyVAL.str = UnionStr
}
- case 134:
+ case 135:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:874
+ //line sql.y:877
{
yyVAL.str = UnionAllStr
}
- case 135:
+ case 136:
yyDollar = yyS[yypt-0 : yypt+1]
- //line sql.y:879
+ //line sql.y:882
{
yyVAL.str = ""
}
- case 136:
+ case 137:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:883
+ //line sql.y:886
{
yyVAL.str = DistinctStr
}
- case 137:
+ case 138:
yyDollar = yyS[yypt-0 : yypt+1]
- //line sql.y:888
+ //line sql.y:891
{
yyVAL.selectExprs = nil
}
- case 138:
+ case 139:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:892
+ //line sql.y:895
{
yyVAL.selectExprs = yyDollar[1].selectExprs
}
- case 139:
+ case 140:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:898
+ //line sql.y:901
{
yyVAL.selectExprs = SelectExprs{yyDollar[1].selectExpr}
}
- case 140:
+ case 141:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:902
+ //line sql.y:905
{
yyVAL.selectExprs = append(yyVAL.selectExprs, yyDollar[3].selectExpr)
}
- case 141:
+ case 142:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:908
+ //line sql.y:911
{
yyVAL.selectExpr = &StarExpr{}
}
- case 142:
+ case 143:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:912
+ //line sql.y:915
{
yyVAL.selectExpr = &AliasedExpr{Expr: yyDollar[1].expr, As: yyDollar[2].colIdent}
}
- case 143:
+ case 144:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:916
+ //line sql.y:919
{
yyVAL.selectExpr = &StarExpr{TableName: TableName{Name: yyDollar[1].tableIdent}}
}
- case 144:
+ case 145:
yyDollar = yyS[yypt-5 : yypt+1]
- //line sql.y:920
+ //line sql.y:923
{
yyVAL.selectExpr = &StarExpr{TableName: TableName{Qualifier: yyDollar[1].tableIdent, Name: yyDollar[3].tableIdent}}
}
- case 145:
+ case 146:
yyDollar = yyS[yypt-0 : yypt+1]
- //line sql.y:925
+ //line sql.y:928
{
yyVAL.colIdent = ColIdent{}
}
- case 146:
+ case 147:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:929
+ //line sql.y:932
{
yyVAL.colIdent = yyDollar[1].colIdent
}
- case 147:
+ case 148:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:933
+ //line sql.y:936
{
yyVAL.colIdent = yyDollar[2].colIdent
}
- case 149:
+ case 150:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:940
+ //line sql.y:943
{
yyVAL.colIdent = NewColIdent(string(yyDollar[1].bytes))
}
- case 150:
+ case 151:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:946
+ //line sql.y:949
{
yyVAL.tableExprs = yyDollar[2].tableExprs
}
- case 151:
+ case 152:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:952
+ //line sql.y:955
{
yyVAL.tableExprs = TableExprs{yyDollar[1].tableExpr}
}
- case 152:
+ case 153:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:956
+ //line sql.y:959
{
yyVAL.tableExprs = append(yyVAL.tableExprs, yyDollar[3].tableExpr)
}
- case 155:
+ case 156:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:966
+ //line sql.y:969
{
yyVAL.tableExpr = yyDollar[1].aliasedTableName
}
- case 156:
+ case 157:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:970
+ //line sql.y:973
{
yyVAL.tableExpr = &AliasedTableExpr{Expr: yyDollar[1].subquery}
}
- case 157:
+ case 158:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:974
+ //line sql.y:977
{
yyVAL.tableExpr = &AliasedTableExpr{Expr: yyDollar[1].subquery, As: yyDollar[3].tableIdent}
}
- case 158:
+ case 159:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:978
+ //line sql.y:981
{
yyVAL.tableExpr = &ParenTableExpr{Exprs: yyDollar[2].tableExprs}
}
- case 159:
+ case 160:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:984
+ //line sql.y:987
{
yyVAL.aliasedTableName = &AliasedTableExpr{Expr: yyDollar[1].tableName, As: yyDollar[2].tableIdent}
}
- case 160:
+ case 161:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:990
+ //line sql.y:993
{
yyVAL.columns = Columns{yyDollar[1].colIdent}
}
- case 161:
+ case 162:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:994
+ //line sql.y:997
{
yyVAL.columns = append(yyVAL.columns, yyDollar[3].colIdent)
}
- case 162:
+ case 163:
yyDollar = yyS[yypt-4 : yypt+1]
- //line sql.y:1000
+ //line sql.y:1003
{
yyVAL.tableExpr = &JoinTableExpr{LeftExpr: yyDollar[1].tableExpr, Join: yyDollar[2].str, RightExpr: yyDollar[3].tableExpr, Condition: yyDollar[4].joinCondition}
}
- case 163:
+ case 164:
yyDollar = yyS[yypt-4 : yypt+1]
- //line sql.y:1004
+ //line sql.y:1007
{
yyVAL.tableExpr = &JoinTableExpr{LeftExpr: yyDollar[1].tableExpr, Join: yyDollar[2].str, RightExpr: yyDollar[3].tableExpr, Condition: yyDollar[4].joinCondition}
}
- case 164:
+ case 165:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:1008
+ //line sql.y:1011
{
yyVAL.tableExpr = &JoinTableExpr{LeftExpr: yyDollar[1].tableExpr, Join: yyDollar[2].str, RightExpr: yyDollar[3].tableExpr}
}
- case 165:
+ case 166:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:1014
+ //line sql.y:1017
{
yyVAL.joinCondition = JoinCondition{On: yyDollar[2].expr}
}
- case 166:
+ case 167:
yyDollar = yyS[yypt-4 : yypt+1]
- //line sql.y:1016
+ //line sql.y:1019
{
yyVAL.joinCondition = JoinCondition{Using: yyDollar[3].columns}
}
- case 167:
+ case 168:
yyDollar = yyS[yypt-0 : yypt+1]
- //line sql.y:1020
+ //line sql.y:1023
{
yyVAL.joinCondition = JoinCondition{}
}
- case 168:
+ case 169:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1022
+ //line sql.y:1025
{
yyVAL.joinCondition = yyDollar[1].joinCondition
}
- case 169:
+ case 170:
yyDollar = yyS[yypt-0 : yypt+1]
- //line sql.y:1025
+ //line sql.y:1028
{
yyVAL.empty = struct{}{}
}
- case 170:
+ case 171:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1027
+ //line sql.y:1030
{
yyVAL.empty = struct{}{}
}
- case 171:
+ case 172:
yyDollar = yyS[yypt-0 : yypt+1]
- //line sql.y:1030
+ //line sql.y:1033
{
yyVAL.tableIdent = NewTableIdent("")
}
- case 172:
+ case 173:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1034
+ //line sql.y:1037
{
yyVAL.tableIdent = yyDollar[1].tableIdent
}
- case 173:
+ case 174:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:1038
+ //line sql.y:1041
{
yyVAL.tableIdent = yyDollar[2].tableIdent
}
- case 175:
+ case 176:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1045
+ //line sql.y:1048
{
yyVAL.tableIdent = NewTableIdent(string(yyDollar[1].bytes))
}
- case 176:
+ case 177:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1051
+ //line sql.y:1054
{
yyVAL.str = JoinStr
}
- case 177:
+ case 178:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:1055
+ //line sql.y:1058
{
yyVAL.str = InnerJoinStr
}
- case 178:
+ case 179:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:1059
+ //line sql.y:1062
{
yyVAL.str = CrossJoinStr
}
- case 179:
+ case 180:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:1065
+ //line sql.y:1068
{
yyVAL.str = LeftJoinStr
}
- case 180:
+ case 181:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:1069
+ //line sql.y:1072
{
yyVAL.str = LeftJoinStr
}
- case 181:
+ case 182:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:1075
+ //line sql.y:1078
{
yyVAL.str = NaturalJoinStr
}
- case 182:
+ case 183:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:1079
+ //line sql.y:1082
{
yyVAL.str = NaturalLeftJoinStr
}
- case 183:
+ case 184:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:1085
+ //line sql.y:1088
{
yyVAL.tableName = yyDollar[2].tableName
}
- case 184:
+ case 185:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1089
+ //line sql.y:1092
{
yyVAL.tableName = yyDollar[1].tableName
}
- case 185:
+ case 186:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1095
+ //line sql.y:1098
{
yyVAL.tableName = TableName{Name: yyDollar[1].tableIdent}
}
- case 186:
+ case 187:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:1099
+ //line sql.y:1102
{
yyVAL.tableName = TableName{Qualifier: yyDollar[1].tableIdent, Name: yyDollar[3].tableIdent}
}
- case 187:
+ case 188:
yyDollar = yyS[yypt-0 : yypt+1]
- //line sql.y:1104
+ //line sql.y:1107
{
yyVAL.expr = nil
}
- case 188:
+ case 189:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:1108
+ //line sql.y:1111
{
yyVAL.expr = yyDollar[2].expr
}
- case 189:
+ case 190:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1114
+ //line sql.y:1117
{
yyVAL.expr = yyDollar[1].expr
}
- case 190:
+ case 191:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:1118
+ //line sql.y:1121
{
yyVAL.expr = &AndExpr{Left: yyDollar[1].expr, Right: yyDollar[3].expr}
}
- case 191:
+ case 192:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:1122
+ //line sql.y:1125
{
yyVAL.expr = &OrExpr{Left: yyDollar[1].expr, Right: yyDollar[3].expr}
}
- case 192:
+ case 193:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:1126
+ //line sql.y:1129
{
yyVAL.expr = &NotExpr{Expr: yyDollar[2].expr}
}
- case 193:
+ case 194:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:1130
+ //line sql.y:1133
{
yyVAL.expr = &IsExpr{Operator: yyDollar[3].str, Expr: yyDollar[1].expr}
}
- case 194:
+ case 195:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1134
+ //line sql.y:1137
{
yyVAL.expr = yyDollar[1].expr
}
- case 195:
- yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:1138
- {
- yyVAL.expr = &Default{ColName: yyDollar[2].str}
- }
case 196:
- yyDollar = yyS[yypt-0 : yypt+1]
- //line sql.y:1144
- {
- yyVAL.str = ""
- }
- case 197:
- yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:1148
- {
- yyVAL.str = string(yyDollar[2].bytes)
- }
- case 198:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1154
+ //line sql.y:1143
{
yyVAL.boolVal = BoolVal(true)
}
- case 199:
+ case 197:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1158
+ //line sql.y:1147
{
yyVAL.boolVal = BoolVal(false)
}
- case 200:
+ case 198:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:1164
+ //line sql.y:1153
{
yyVAL.expr = &ComparisonExpr{Left: yyDollar[1].expr, Operator: yyDollar[2].str, Right: yyDollar[3].expr}
}
- case 201:
+ case 199:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:1168
+ //line sql.y:1157
{
yyVAL.expr = &ComparisonExpr{Left: yyDollar[1].expr, Operator: InStr, Right: yyDollar[3].colTuple}
}
- case 202:
+ case 200:
yyDollar = yyS[yypt-4 : yypt+1]
- //line sql.y:1172
+ //line sql.y:1161
{
yyVAL.expr = &ComparisonExpr{Left: yyDollar[1].expr, Operator: NotInStr, Right: yyDollar[4].colTuple}
}
- case 203:
+ case 201:
yyDollar = yyS[yypt-4 : yypt+1]
- //line sql.y:1176
+ //line sql.y:1165
{
yyVAL.expr = &ComparisonExpr{Left: yyDollar[1].expr, Operator: LikeStr, Right: yyDollar[3].expr, Escape: yyDollar[4].expr}
}
- case 204:
+ case 202:
yyDollar = yyS[yypt-5 : yypt+1]
- //line sql.y:1180
+ //line sql.y:1169
{
yyVAL.expr = &ComparisonExpr{Left: yyDollar[1].expr, Operator: NotLikeStr, Right: yyDollar[4].expr, Escape: yyDollar[5].expr}
}
- case 205:
+ case 203:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:1184
+ //line sql.y:1173
{
yyVAL.expr = &ComparisonExpr{Left: yyDollar[1].expr, Operator: RegexpStr, Right: yyDollar[3].expr}
}
- case 206:
+ case 204:
yyDollar = yyS[yypt-4 : yypt+1]
- //line sql.y:1188
+ //line sql.y:1177
{
yyVAL.expr = &ComparisonExpr{Left: yyDollar[1].expr, Operator: NotRegexpStr, Right: yyDollar[4].expr}
}
- case 207:
+ case 205:
yyDollar = yyS[yypt-5 : yypt+1]
- //line sql.y:1192
+ //line sql.y:1181
{
yyVAL.expr = &RangeCond{Left: yyDollar[1].expr, Operator: BetweenStr, From: yyDollar[3].expr, To: yyDollar[5].expr}
}
- case 208:
+ case 206:
yyDollar = yyS[yypt-6 : yypt+1]
- //line sql.y:1196
+ //line sql.y:1185
{
yyVAL.expr = &RangeCond{Left: yyDollar[1].expr, Operator: NotBetweenStr, From: yyDollar[4].expr, To: yyDollar[6].expr}
}
- case 209:
+ case 207:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:1200
+ //line sql.y:1189
{
yyVAL.expr = &ExistsExpr{Subquery: yyDollar[2].subquery}
}
- case 210:
+ case 208:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1206
+ //line sql.y:1195
{
yyVAL.str = IsNullStr
}
- case 211:
+ case 209:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:1210
+ //line sql.y:1199
{
yyVAL.str = IsNotNullStr
}
- case 212:
+ case 210:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1214
+ //line sql.y:1203
{
yyVAL.str = IsTrueStr
}
- case 213:
+ case 211:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:1218
+ //line sql.y:1207
{
yyVAL.str = IsNotTrueStr
}
- case 214:
+ case 212:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1222
+ //line sql.y:1211
{
yyVAL.str = IsFalseStr
}
- case 215:
+ case 213:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:1226
+ //line sql.y:1215
{
yyVAL.str = IsNotFalseStr
}
- case 216:
+ case 214:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1232
+ //line sql.y:1221
{
yyVAL.str = EqualStr
}
- case 217:
+ case 215:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1236
+ //line sql.y:1225
{
yyVAL.str = LessThanStr
}
- case 218:
+ case 216:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1240
+ //line sql.y:1229
{
yyVAL.str = GreaterThanStr
}
- case 219:
+ case 217:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1244
+ //line sql.y:1233
{
yyVAL.str = LessEqualStr
}
- case 220:
+ case 218:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1248
+ //line sql.y:1237
{
yyVAL.str = GreaterEqualStr
}
- case 221:
+ case 219:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1252
+ //line sql.y:1241
{
yyVAL.str = NotEqualStr
}
- case 222:
+ case 220:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1256
+ //line sql.y:1245
{
yyVAL.str = NullSafeNotEqualStr
}
- case 223:
+ case 221:
yyDollar = yyS[yypt-0 : yypt+1]
- //line sql.y:1261
+ //line sql.y:1250
{
yyVAL.expr = nil
}
- case 224:
+ case 222:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:1265
+ //line sql.y:1254
{
yyVAL.expr = yyDollar[2].expr
}
- case 225:
+ case 223:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1271
+ //line sql.y:1260
{
yyVAL.colTuple = yyDollar[1].valTuple
}
- case 226:
+ case 224:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1275
+ //line sql.y:1264
{
yyVAL.colTuple = yyDollar[1].subquery
}
- case 227:
+ case 225:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1279
+ //line sql.y:1268
{
yyVAL.colTuple = ListArg(yyDollar[1].bytes)
}
- case 228:
+ case 226:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:1285
+ //line sql.y:1274
{
yyVAL.subquery = &Subquery{yyDollar[2].selStmt}
}
- case 229:
+ case 227:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1291
+ //line sql.y:1280
{
yyVAL.exprs = Exprs{yyDollar[1].expr}
}
- case 230:
+ case 228:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:1295
+ //line sql.y:1284
{
yyVAL.exprs = append(yyDollar[1].exprs, yyDollar[3].expr)
}
- case 231:
+ case 229:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1301
+ //line sql.y:1290
{
yyVAL.expr = yyDollar[1].expr
}
- case 232:
+ case 230:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1305
+ //line sql.y:1294
{
yyVAL.expr = yyDollar[1].boolVal
}
- case 233:
+ case 231:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1309
+ //line sql.y:1298
{
yyVAL.expr = yyDollar[1].colName
}
- case 234:
+ case 232:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1313
+ //line sql.y:1302
{
yyVAL.expr = yyDollar[1].expr
}
- case 235:
+ case 233:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1317
+ //line sql.y:1306
{
yyVAL.expr = yyDollar[1].subquery
}
- case 236:
+ case 234:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:1321
+ //line sql.y:1310
{
yyVAL.expr = &BinaryExpr{Left: yyDollar[1].expr, Operator: BitAndStr, Right: yyDollar[3].expr}
}
- case 237:
+ case 235:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:1325
+ //line sql.y:1314
{
yyVAL.expr = &BinaryExpr{Left: yyDollar[1].expr, Operator: BitOrStr, Right: yyDollar[3].expr}
}
- case 238:
+ case 236:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:1329
+ //line sql.y:1318
{
yyVAL.expr = &BinaryExpr{Left: yyDollar[1].expr, Operator: BitXorStr, Right: yyDollar[3].expr}
}
- case 239:
+ case 237:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:1333
+ //line sql.y:1322
{
yyVAL.expr = &BinaryExpr{Left: yyDollar[1].expr, Operator: PlusStr, Right: yyDollar[3].expr}
}
- case 240:
+ case 238:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:1337
+ //line sql.y:1326
{
yyVAL.expr = &BinaryExpr{Left: yyDollar[1].expr, Operator: MinusStr, Right: yyDollar[3].expr}
}
- case 241:
+ case 239:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:1341
+ //line sql.y:1330
{
yyVAL.expr = &BinaryExpr{Left: yyDollar[1].expr, Operator: MultStr, Right: yyDollar[3].expr}
}
- case 242:
+ case 240:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:1345
+ //line sql.y:1334
{
yyVAL.expr = &BinaryExpr{Left: yyDollar[1].expr, Operator: DivStr, Right: yyDollar[3].expr}
}
- case 243:
+ case 241:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:1349
+ //line sql.y:1338
{
yyVAL.expr = &BinaryExpr{Left: yyDollar[1].expr, Operator: IntDivStr, Right: yyDollar[3].expr}
}
- case 244:
+ case 242:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:1353
+ //line sql.y:1342
{
yyVAL.expr = &BinaryExpr{Left: yyDollar[1].expr, Operator: ModStr, Right: yyDollar[3].expr}
}
- case 245:
+ case 243:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:1357
+ //line sql.y:1346
{
yyVAL.expr = &BinaryExpr{Left: yyDollar[1].expr, Operator: ModStr, Right: yyDollar[3].expr}
}
- case 246:
+ case 244:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:1361
+ //line sql.y:1350
{
yyVAL.expr = &BinaryExpr{Left: yyDollar[1].expr, Operator: ShiftLeftStr, Right: yyDollar[3].expr}
}
- case 247:
+ case 245:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:1365
+ //line sql.y:1354
{
yyVAL.expr = &BinaryExpr{Left: yyDollar[1].expr, Operator: ShiftRightStr, Right: yyDollar[3].expr}
}
- case 248:
+ case 246:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:1369
+ //line sql.y:1358
{
if num, ok := yyDollar[2].expr.(*SQLVal); ok && num.Type == IntVal {
yyVAL.expr = num
@@ -3031,9 +3016,9 @@ yydefault:
yyVAL.expr = &UnaryExpr{Operator: UPlusStr, Expr: yyDollar[2].expr}
}
}
- case 249:
+ case 247:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:1377
+ //line sql.y:1366
{
if num, ok := yyDollar[2].expr.(*SQLVal); ok && num.Type == IntVal {
// Handle double negative
@@ -3047,21 +3032,21 @@ yydefault:
yyVAL.expr = &UnaryExpr{Operator: UMinusStr, Expr: yyDollar[2].expr}
}
}
- case 250:
+ case 248:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:1391
+ //line sql.y:1380
{
yyVAL.expr = &UnaryExpr{Operator: TildaStr, Expr: yyDollar[2].expr}
}
- case 251:
+ case 249:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:1395
+ //line sql.y:1384
{
yyVAL.expr = &UnaryExpr{Operator: BangStr, Expr: yyDollar[2].expr}
}
- case 252:
+ case 250:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:1399
+ //line sql.y:1388
{
// This rule prevents the usage of INTERVAL
// as a function. If support is needed for that,
@@ -3069,505 +3054,499 @@ yydefault:
// will be non-trivial because of grammar conflicts.
yyVAL.expr = &IntervalExpr{Expr: yyDollar[2].expr, Unit: yyDollar[3].colIdent.String()}
}
- case 257:
+ case 255:
yyDollar = yyS[yypt-4 : yypt+1]
- //line sql.y:1417
+ //line sql.y:1406
{
yyVAL.expr = &FuncExpr{Name: yyDollar[1].colIdent, Exprs: yyDollar[3].selectExprs}
}
- case 258:
+ case 256:
yyDollar = yyS[yypt-5 : yypt+1]
- //line sql.y:1421
+ //line sql.y:1410
{
yyVAL.expr = &FuncExpr{Name: yyDollar[1].colIdent, Distinct: true, Exprs: yyDollar[4].selectExprs}
}
- case 259:
+ case 257:
yyDollar = yyS[yypt-6 : yypt+1]
- //line sql.y:1425
+ //line sql.y:1414
{
yyVAL.expr = &FuncExpr{Qualifier: yyDollar[1].tableIdent, Name: yyDollar[3].colIdent, Exprs: yyDollar[5].selectExprs}
}
- case 260:
+ case 258:
yyDollar = yyS[yypt-6 : yypt+1]
- //line sql.y:1435
+ //line sql.y:1424
{
yyVAL.expr = &ConvertExpr{Expr: yyDollar[3].expr, Type: yyDollar[5].convertType}
}
- case 261:
- yyDollar = yyS[yypt-6 : yypt+1]
- //line sql.y:1439
- {
- yyVAL.expr = &SubstrExpr{Name: yyDollar[3].colName, From: yyDollar[5].expr, To: nil}
- }
- case 262:
- yyDollar = yyS[yypt-8 : yypt+1]
- //line sql.y:1443
- {
- yyVAL.expr = &SubstrExpr{Name: yyDollar[3].colName, From: yyDollar[5].expr, To: yyDollar[7].expr}
- }
- case 263:
+ case 259:
yyDollar = yyS[yypt-7 : yypt+1]
- //line sql.y:1447
+ //line sql.y:1428
{
yyVAL.expr = &GroupConcatExpr{Distinct: yyDollar[3].str, Exprs: yyDollar[4].selectExprs, OrderBy: yyDollar[5].orderBy, Separator: yyDollar[6].str}
}
- case 264:
+ case 260:
yyDollar = yyS[yypt-5 : yypt+1]
- //line sql.y:1451
+ //line sql.y:1432
{
yyVAL.expr = &CaseExpr{Expr: yyDollar[2].expr, Whens: yyDollar[3].whens, Else: yyDollar[4].expr}
}
- case 265:
+ case 261:
yyDollar = yyS[yypt-4 : yypt+1]
- //line sql.y:1455
+ //line sql.y:1436
{
yyVAL.expr = &ValuesFuncExpr{Name: yyDollar[3].colName}
}
- case 266:
+ case 262:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1465
+ //line sql.y:1446
{
yyVAL.expr = &TimeExpr{Expr: NewColIdent("current_timestamp")}
}
- case 267:
+ case 263:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1470
+ //line sql.y:1451
{
yyVAL.expr = &TimeExpr{Expr: NewColIdent("current_date")}
}
- case 268:
+ case 264:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1475
+ //line sql.y:1456
{
yyVAL.expr = &TimeExpr{Expr: NewColIdent("current_time")}
}
- case 269:
+ case 265:
yyDollar = yyS[yypt-4 : yypt+1]
- //line sql.y:1485
+ //line sql.y:1466
{
yyVAL.expr = &FuncExpr{Name: NewColIdent("if"), Exprs: yyDollar[3].selectExprs}
}
- case 270:
+ case 266:
yyDollar = yyS[yypt-4 : yypt+1]
- //line sql.y:1489
+ //line sql.y:1470
{
yyVAL.expr = &FuncExpr{Name: NewColIdent("mod"), Exprs: yyDollar[3].selectExprs}
}
- case 271:
+ case 267:
yyDollar = yyS[yypt-4 : yypt+1]
- //line sql.y:1493
+ //line sql.y:1474
{
yyVAL.expr = &FuncExpr{Name: NewColIdent("replace"), Exprs: yyDollar[3].selectExprs}
}
- case 272:
+ case 268:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:1499
+ //line sql.y:1480
{
yyVAL.convertType = &ConvertType{Type: string(yyDollar[1].bytes), Length: yyDollar[2].optVal}
}
- case 273:
+ case 269:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1503
+ //line sql.y:1484
{
yyVAL.convertType = &ConvertType{Type: string(yyDollar[1].bytes)}
}
- case 274:
+ case 270:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:1507
+ //line sql.y:1488
{
yyVAL.convertType = &ConvertType{Type: string(yyDollar[1].bytes), Length: yyDollar[2].optVal}
}
- case 275:
+ case 271:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:1511
+ //line sql.y:1492
{
yyVAL.convertType = &ConvertType{Type: string(yyDollar[1].bytes)}
yyVAL.convertType.Length = yyDollar[2].LengthScaleOption.Length
yyVAL.convertType.Scale = yyDollar[2].LengthScaleOption.Scale
}
- case 276:
+ case 272:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:1517
+ //line sql.y:1498
{
yyVAL.convertType = &ConvertType{Type: string(yyDollar[1].bytes), Length: yyDollar[2].optVal}
}
- case 277:
+ case 273:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1521
+ //line sql.y:1502
{
yyVAL.convertType = &ConvertType{Type: string(yyDollar[1].bytes)}
}
- case 278:
+ case 274:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:1525
+ //line sql.y:1506
{
yyVAL.convertType = &ConvertType{Type: string(yyDollar[1].bytes)}
}
- case 279:
+ case 275:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:1529
+ //line sql.y:1510
{
yyVAL.convertType = &ConvertType{Type: string(yyDollar[1].bytes), Length: yyDollar[2].optVal}
}
- case 280:
+ case 276:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1533
+ //line sql.y:1514
{
yyVAL.convertType = &ConvertType{Type: string(yyDollar[1].bytes)}
}
- case 281:
+ case 277:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:1537
+ //line sql.y:1518
{
yyVAL.convertType = &ConvertType{Type: string(yyDollar[1].bytes)}
}
- case 282:
+ case 278:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:1541
+ //line sql.y:1522
{
yyVAL.convertType = &ConvertType{Type: string(yyDollar[1].bytes), Length: yyDollar[2].optVal}
}
- case 283:
+ case 279:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:1545
+ //line sql.y:1526
{
yyVAL.convertType = &ConvertType{Type: string(yyDollar[1].bytes), Length: yyDollar[2].optVal}
}
- case 284:
+ case 280:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:1549
+ //line sql.y:1530
{
yyVAL.convertType = &ConvertType{Type: string(yyDollar[1].bytes), Length: yyDollar[2].optVal}
}
- case 285:
+ case 281:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:1553
+ //line sql.y:1534
{
yyVAL.convertType = &ConvertType{Type: string(yyDollar[1].bytes), Length: yyDollar[2].optVal}
}
- case 286:
+ case 282:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:1557
+ //line sql.y:1538
{
yyVAL.convertType = &ConvertType{Type: string(yyDollar[1].bytes), Length: yyDollar[2].optVal}
}
- case 287:
+ case 283:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:1561
+ //line sql.y:1542
{
yyVAL.convertType = &ConvertType{Type: string(yyDollar[1].bytes), Length: yyDollar[2].optVal}
}
- case 288:
+ case 284:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1565
+ //line sql.y:1546
{
yyVAL.convertType = &ConvertType{Type: string(yyDollar[1].bytes)}
}
- case 289:
+ case 285:
yyDollar = yyS[yypt-0 : yypt+1]
- //line sql.y:1570
+ //line sql.y:1551
{
yyVAL.expr = nil
}
- case 290:
+ case 286:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1574
+ //line sql.y:1555
{
yyVAL.expr = yyDollar[1].expr
}
- case 291:
+ case 287:
yyDollar = yyS[yypt-0 : yypt+1]
- //line sql.y:1579
+ //line sql.y:1560
{
yyVAL.str = string("")
}
- case 292:
+ case 288:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:1583
+ //line sql.y:1564
{
yyVAL.str = " separator '" + string(yyDollar[2].bytes) + "'"
}
- case 293:
+ case 289:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1589
+ //line sql.y:1570
{
yyVAL.whens = []*When{yyDollar[1].when}
}
- case 294:
+ case 290:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:1593
+ //line sql.y:1574
{
yyVAL.whens = append(yyDollar[1].whens, yyDollar[2].when)
}
- case 295:
+ case 291:
yyDollar = yyS[yypt-4 : yypt+1]
- //line sql.y:1599
+ //line sql.y:1580
{
yyVAL.when = &When{Cond: yyDollar[2].expr, Val: yyDollar[4].expr}
}
- case 296:
+ case 292:
yyDollar = yyS[yypt-0 : yypt+1]
- //line sql.y:1604
+ //line sql.y:1585
{
yyVAL.expr = nil
}
- case 297:
+ case 293:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:1608
+ //line sql.y:1589
{
yyVAL.expr = yyDollar[2].expr
}
- case 298:
+ case 294:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1614
+ //line sql.y:1595
{
yyVAL.colName = &ColName{Name: yyDollar[1].colIdent}
}
- case 299:
+ case 295:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:1618
+ //line sql.y:1599
{
yyVAL.colName = &ColName{Qualifier: TableName{Name: yyDollar[1].tableIdent}, Name: yyDollar[3].colIdent}
}
- case 300:
+ case 296:
yyDollar = yyS[yypt-5 : yypt+1]
- //line sql.y:1622
+ //line sql.y:1603
{
yyVAL.colName = &ColName{Qualifier: TableName{Qualifier: yyDollar[1].tableIdent, Name: yyDollar[3].tableIdent}, Name: yyDollar[5].colIdent}
}
- case 301:
+ case 297:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1628
+ //line sql.y:1609
{
yyVAL.expr = NewStrVal(yyDollar[1].bytes)
}
- case 302:
+ case 298:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1632
+ //line sql.y:1613
{
yyVAL.expr = NewHexVal(yyDollar[1].bytes)
}
- case 303:
+ case 299:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1636
+ //line sql.y:1617
{
yyVAL.expr = NewIntVal(yyDollar[1].bytes)
}
- case 304:
+ case 300:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1640
+ //line sql.y:1621
{
yyVAL.expr = NewFloatVal(yyDollar[1].bytes)
}
- case 305:
+ case 301:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1644
+ //line sql.y:1625
{
yyVAL.expr = NewHexNum(yyDollar[1].bytes)
}
- case 306:
+ case 302:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1648
+ //line sql.y:1629
{
yyVAL.expr = NewValArg(yyDollar[1].bytes)
}
- case 307:
+ case 303:
+ yyDollar = yyS[yypt-1 : yypt+1]
+ //line sql.y:1633
+ {
+ yyVAL.expr = NewPosArg(yyDollar[1].bytes)
+ }
+ case 304:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1652
+ //line sql.y:1637
{
yyVAL.expr = &NullVal{}
}
- case 308:
+ case 305:
yyDollar = yyS[yypt-0 : yypt+1]
- //line sql.y:1657
+ //line sql.y:1642
{
yyVAL.exprs = nil
}
- case 309:
+ case 306:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:1661
+ //line sql.y:1646
{
yyVAL.exprs = yyDollar[3].exprs
}
- case 310:
+ case 307:
yyDollar = yyS[yypt-0 : yypt+1]
- //line sql.y:1666
+ //line sql.y:1651
{
yyVAL.expr = nil
}
- case 311:
+ case 308:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:1670
+ //line sql.y:1655
{
yyVAL.expr = yyDollar[2].expr
}
- case 312:
+ case 309:
yyDollar = yyS[yypt-0 : yypt+1]
- //line sql.y:1675
+ //line sql.y:1660
{
yyVAL.orderBy = nil
}
- case 313:
+ case 310:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:1679
+ //line sql.y:1664
{
yyVAL.orderBy = yyDollar[3].orderBy
}
- case 314:
+ case 311:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1685
+ //line sql.y:1670
{
yyVAL.orderBy = OrderBy{yyDollar[1].order}
}
- case 315:
+ case 312:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:1689
+ //line sql.y:1674
{
yyVAL.orderBy = append(yyDollar[1].orderBy, yyDollar[3].order)
}
- case 316:
+ case 313:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:1695
+ //line sql.y:1680
{
yyVAL.order = &Order{Expr: yyDollar[1].expr, Direction: yyDollar[2].str}
}
- case 317:
+ case 314:
yyDollar = yyS[yypt-0 : yypt+1]
- //line sql.y:1700
+ //line sql.y:1685
{
yyVAL.str = AscScr
}
- case 318:
+ case 315:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1704
+ //line sql.y:1689
{
yyVAL.str = AscScr
}
- case 319:
+ case 316:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1708
+ //line sql.y:1693
{
yyVAL.str = DescScr
}
- case 320:
+ case 317:
yyDollar = yyS[yypt-0 : yypt+1]
- //line sql.y:1713
+ //line sql.y:1698
{
yyVAL.limit = nil
}
- case 321:
+ case 318:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:1717
+ //line sql.y:1702
{
yyVAL.limit = &Limit{Rowcount: yyDollar[2].expr}
}
- case 322:
+ case 319:
yyDollar = yyS[yypt-4 : yypt+1]
- //line sql.y:1721
+ //line sql.y:1706
{
yyVAL.limit = &Limit{Offset: yyDollar[2].expr, Rowcount: yyDollar[4].expr}
}
- case 323:
+ case 320:
yyDollar = yyS[yypt-4 : yypt+1]
- //line sql.y:1725
+ //line sql.y:1710
{
yyVAL.limit = &Limit{Offset: yyDollar[4].expr, Rowcount: yyDollar[2].expr}
}
- case 324:
+ case 321:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:1738
+ //line sql.y:1723
{
yyVAL.ins = &Insert{Rows: yyDollar[2].values}
}
- case 325:
+ case 322:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1742
+ //line sql.y:1727
{
yyVAL.ins = &Insert{Rows: yyDollar[1].selStmt}
}
- case 326:
+ case 323:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:1746
+ //line sql.y:1731
{
// Drop the redundant parenthesis.
yyVAL.ins = &Insert{Rows: yyDollar[2].selStmt}
}
- case 327:
+ case 324:
yyDollar = yyS[yypt-5 : yypt+1]
- //line sql.y:1751
+ //line sql.y:1736
{
yyVAL.ins = &Insert{Columns: yyDollar[2].columns, Rows: yyDollar[5].values}
}
- case 328:
+ case 325:
yyDollar = yyS[yypt-4 : yypt+1]
- //line sql.y:1755
+ //line sql.y:1740
{
yyVAL.ins = &Insert{Columns: yyDollar[2].columns, Rows: yyDollar[4].selStmt}
}
- case 329:
+ case 326:
yyDollar = yyS[yypt-6 : yypt+1]
- //line sql.y:1759
+ //line sql.y:1744
{
// Drop the redundant parenthesis.
yyVAL.ins = &Insert{Columns: yyDollar[2].columns, Rows: yyDollar[5].selStmt}
}
- case 330:
+ case 327:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1766
+ //line sql.y:1751
{
yyVAL.columns = Columns{yyDollar[1].colIdent}
}
- case 331:
+ case 328:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:1770
+ //line sql.y:1755
{
yyVAL.columns = Columns{yyDollar[3].colIdent}
}
- case 332:
+ case 329:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:1774
+ //line sql.y:1759
{
yyVAL.columns = append(yyVAL.columns, yyDollar[3].colIdent)
}
- case 333:
+ case 330:
yyDollar = yyS[yypt-5 : yypt+1]
- //line sql.y:1778
+ //line sql.y:1763
{
yyVAL.columns = append(yyVAL.columns, yyDollar[5].colIdent)
}
- case 334:
+ case 331:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1784
+ //line sql.y:1769
{
yyVAL.values = Values{yyDollar[1].valTuple}
}
- case 335:
+ case 332:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:1788
+ //line sql.y:1773
{
yyVAL.values = append(yyDollar[1].values, yyDollar[3].valTuple)
}
- case 336:
+ case 333:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1794
+ //line sql.y:1779
{
yyVAL.valTuple = yyDollar[1].valTuple
}
- case 337:
+ case 334:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:1798
+ //line sql.y:1783
{
yyVAL.valTuple = ValTuple{}
}
- case 338:
+ case 335:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:1804
+ //line sql.y:1789
{
yyVAL.valTuple = ValTuple(yyDollar[2].exprs)
}
- case 339:
+ case 336:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1810
+ //line sql.y:1795
{
if len(yyDollar[1].valTuple) == 1 {
yyVAL.expr = &ParenExpr{yyDollar[1].valTuple[0]}
@@ -3575,144 +3554,150 @@ yydefault:
yyVAL.expr = yyDollar[1].valTuple
}
}
- case 340:
+ case 337:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1820
+ //line sql.y:1805
{
yyVAL.updateExprs = UpdateExprs{yyDollar[1].updateExpr}
}
- case 341:
+ case 338:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:1824
+ //line sql.y:1809
{
yyVAL.updateExprs = append(yyDollar[1].updateExprs, yyDollar[3].updateExpr)
}
- case 342:
+ case 339:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:1830
+ //line sql.y:1815
{
yyVAL.updateExpr = &UpdateExpr{Name: yyDollar[1].colName, Expr: yyDollar[3].expr}
}
- case 343:
+ case 340:
yyDollar = yyS[yypt-0 : yypt+1]
- //line sql.y:1835
+ //line sql.y:1820
{
yyVAL.byt = 0
}
- case 344:
+ case 341:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:1837
+ //line sql.y:1822
{
yyVAL.byt = 1
}
- case 345:
+ case 342:
yyDollar = yyS[yypt-0 : yypt+1]
- //line sql.y:1840
+ //line sql.y:1825
{
yyVAL.empty = struct{}{}
}
- case 346:
+ case 343:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:1842
+ //line sql.y:1827
{
yyVAL.empty = struct{}{}
}
- case 347:
+ case 344:
yyDollar = yyS[yypt-0 : yypt+1]
- //line sql.y:1845
+ //line sql.y:1830
{
yyVAL.str = ""
}
- case 348:
+ case 345:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1847
+ //line sql.y:1832
{
yyVAL.str = IgnoreStr
}
- case 349:
+ case 346:
yyDollar = yyS[yypt-0 : yypt+1]
- //line sql.y:1850
+ //line sql.y:1835
{
yyVAL.empty = struct{}{}
}
- case 350:
+ case 347:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1852
+ //line sql.y:1837
{
yyVAL.empty = struct{}{}
}
- case 351:
+ case 348:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1854
+ //line sql.y:1839
{
yyVAL.empty = struct{}{}
}
- case 352:
+ case 349:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1858
+ //line sql.y:1843
{
yyVAL.colIdent = NewColIdent(string(yyDollar[1].bytes))
}
- case 353:
+ case 350:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1862
+ //line sql.y:1847
{
yyVAL.colIdent = NewColIdent(string(yyDollar[1].bytes))
}
- case 355:
+ case 352:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1869
+ //line sql.y:1854
{
yyVAL.colIdent = NewColIdent(string(yyDollar[1].bytes))
}
- case 356:
+ case 353:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1875
+ //line sql.y:1860
{
yyVAL.tableIdent = NewTableIdent(string(yyDollar[1].bytes))
}
- case 357:
+ case 354:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1879
+ //line sql.y:1864
{
yyVAL.tableIdent = NewTableIdent(string(yyDollar[1].bytes))
}
- case 359:
+ case 356:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1886
+ //line sql.y:1871
{
yyVAL.tableIdent = NewTableIdent(string(yyDollar[1].bytes))
}
- case 467:
+ case 464:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:2019
+ //line sql.y:2004
{
if incNesting(yylex) {
yylex.Error("max nesting level reached")
return 1
}
}
- case 468:
+ case 465:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:2028
+ //line sql.y:2013
{
decNesting(yylex)
}
- case 469:
+ case 466:
+ yyDollar = yyS[yypt-0 : yypt+1]
+ //line sql.y:2018
+ {
+ forceEOF(yylex)
+ }
+ case 467:
yyDollar = yyS[yypt-0 : yypt+1]
- //line sql.y:2033
+ //line sql.y:2023
{
forceEOF(yylex)
}
- case 470:
+ case 468:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:2037
+ //line sql.y:2027
{
forceEOF(yylex)
}
- case 471:
+ case 469:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:2041
+ //line sql.y:2031
{
forceEOF(yylex)
}
diff --git a/vendor/github.com/CovenantSQL/sqlparser/sql.y b/vendor/github.com/CovenantSQL/sqlparser/sql.y
index 6e70d8a16..37d4b0fe8 100644
--- a/vendor/github.com/CovenantSQL/sqlparser/sql.y
+++ b/vendor/github.com/CovenantSQL/sqlparser/sql.y
@@ -110,7 +110,7 @@ func forceEOF(yylex interface{}) {
%left JOIN LEFT RIGHT INNER OUTER CROSS NATURAL
%left ON USING
%token '(' ',' ')'
-%token ID HEX STRING INTEGRAL FLOAT HEXNUM VALUE_ARG LIST_ARG COMMENT
+%token ID HEX STRING INTEGRAL FLOAT HEXNUM VALUE_ARG POS_ARG LIST_ARG COMMENT
%token NULL TRUE FALSE
%token FULL COLUMNS
@@ -136,7 +136,7 @@ func forceEOF(yylex interface{}) {
// DDL Tokens
%token CREATE ALTER DROP RENAME ADD
%token TABLE INDEX TO IGNORE IF UNIQUE PRIMARY COLUMN CONSTRAINT FOREIGN
-%token SHOW DESCRIBE DATE ESCAPE
+%token SHOW DESCRIBE DATE ESCAPE EXPLAIN
// Type Tokens
%token TINYINT SMALLINT MEDIUMINT INT INTEGER BIGINT INTNUM
@@ -156,7 +156,6 @@ func forceEOF(yylex interface{}) {
%token CURRENT_TIMESTAMP CURRENT_DATE CURRENT_TIME
%token REPLACE
%token CAST
-%token SUBSTR
%token GROUP_CONCAT SEPARATOR
// MySQL reserved words that are unused by this grammar will map to this token.
@@ -208,7 +207,7 @@ func forceEOF(yylex interface{}) {
%type ins_column_list column_list
%type update_list
%type update_expression
-%type ignore_opt default_opt
+%type ignore_opt
%type exists_opt
%type not_exists_opt constraint_opt
%type reserved_keyword non_reserved_keyword
@@ -845,6 +844,10 @@ other_statement:
{
$$ = &Show{Type: "table", OnTable: $2}
}
+| EXPLAIN force_eof
+ {
+ $$ = &Explain{}
+ }
comment_opt:
{
@@ -1134,20 +1137,6 @@ expression:
{
$$ = $1
}
-| DEFAULT default_opt
- {
- $$ = &Default{ColName: $2}
- }
-
-default_opt:
- /* empty */
- {
- $$ = ""
- }
-| openb ID closeb
- {
- $$ = string($2)
- }
boolean_value:
TRUE
@@ -1435,14 +1424,6 @@ function_call_keyword:
{
$$ = &ConvertExpr{Expr: $3, Type: $5}
}
-| SUBSTR openb column_name ',' value_expression closeb
- {
- $$ = &SubstrExpr{Name: $3, From: $5, To: nil}
- }
-| SUBSTR openb column_name ',' value_expression ',' value_expression closeb
- {
- $$ = &SubstrExpr{Name: $3, From: $5, To: $7}
- }
| GROUP_CONCAT openb distinct_opt select_expression_list order_by_opt separator_opt closeb
{
$$ = &GroupConcatExpr{Distinct: $3, Exprs: $4, OrderBy: $5, Separator: $6}
@@ -1648,6 +1629,10 @@ value:
{
$$ = NewValArg($1)
}
+| POS_ARG
+ {
+ $$ = NewPosArg($1)
+ }
| NULL
{
$$ = &NullVal{}
@@ -1910,7 +1895,6 @@ reserved_keyword:
| CURRENT_DATE
| CURRENT_TIME
| CURRENT_TIMESTAMP
-| SUBSTR
| DEFAULT
| DELETE
| DESC
@@ -1968,6 +1952,7 @@ reserved_keyword:
| VALUES
| WHEN
| WHERE
+| EXPLAIN
/*
These are non-reserved Vitess, because they don't cause conflicts in the grammar.
@@ -2029,6 +2014,11 @@ closeb:
decNesting(yylex)
}
+force_eof:
+ {
+ forceEOF(yylex)
+ }
+
ddl_force_eof:
{
forceEOF(yylex)
diff --git a/vendor/github.com/CovenantSQL/sqlparser/token.go b/vendor/github.com/CovenantSQL/sqlparser/token.go
index 74ed904e6..36b556569 100644
--- a/vendor/github.com/CovenantSQL/sqlparser/token.go
+++ b/vendor/github.com/CovenantSQL/sqlparser/token.go
@@ -34,20 +34,21 @@ const (
// Tokenizer is the struct used to generate SQL
// tokens for the parser.
type Tokenizer struct {
- InStream io.Reader
- AllowComments bool
- AllowBackSlashEscape bool
- ForceEOF bool
- lastChar uint16
- Position int
- lastToken []byte
- LastError error
- posVarIndex int
- ParseTree Statement
- partialDDL *DDL
- nesting int
- multi bool
- specialComment *Tokenizer
+ InStream io.Reader
+ AllowComments bool
+ AllowBackSlashEscape bool
+ SeparatePositionalArgs bool
+ ForceEOF bool
+ lastChar uint16
+ Position int
+ lastToken []byte
+ LastError error
+ posVarIndex int
+ ParseTree Statement
+ partialDDL *DDL
+ nesting int
+ multi bool
+ specialComment *Tokenizer
buf []byte
bufPos int
@@ -112,7 +113,6 @@ var keywords = map[string]int{
"condition": UNUSED,
"constraint": CONSTRAINT,
"continue": UNUSED,
- "substr": SUBSTR,
"create": CREATE,
"cross": CROSS,
"current_date": CURRENT_DATE,
@@ -304,6 +304,7 @@ var keywords = map[string]int{
"year": YEAR,
"year_month": UNUSED,
"zerofill": ZEROFILL,
+ "explain": EXPLAIN,
}
// keywordStrings contains the reverse mapping of token to keyword strings
@@ -426,6 +427,9 @@ func (tkn *Tokenizer) Scan() (int, []byte) {
tkn.posVarIndex++
buf := new(bytes2.Buffer)
fmt.Fprintf(buf, ":v%d", tkn.posVarIndex)
+ if tkn.SeparatePositionalArgs {
+ return POS_ARG, buf.Bytes()
+ }
return VALUE_ARG, buf.Bytes()
case '.':
if isDigit(tkn.lastChar) {
diff --git a/vendor/github.com/alecthomas/chroma/README.md b/vendor/github.com/alecthomas/chroma/README.md
index 681f10ab8..b33272155 100644
--- a/vendor/github.com/alecthomas/chroma/README.md
+++ b/vendor/github.com/alecthomas/chroma/README.md
@@ -29,7 +29,32 @@ translators for Pygments lexers and styles.
## Supported languages
-ABNF, ANTLR, APL, ActionScript, ActionScript 3, Ada, Angular2, ApacheConf, AppleScript, Awk, BNF, Ballerina, Base Makefile, Bash, Batchfile, BlitzBasic, Brainfuck, C, C#, C++, CFEngine3, CMake, COBOL, CSS, Cap'n Proto, Ceylon, ChaiScript, Cheetah, Clojure, CoffeeScript, Common Lisp, Coq, Crystal, Cython, DTD, Dart, Diff, Django/Jinja, Docker, EBNF, Elixir, Elm, EmacsLisp, Erlang, FSharp, Factor, Fish, Forth, Fortran, GAS, GDScript, GLSL, Genshi, Genshi HTML, Genshi Text, Gnuplot, Go, Go HTML Template, Go Text Template, Groovy, HTML, HTTP, Handlebars, Haskell, Haxe, Hexdump, Hy, INI, Idris, Io, JSON, JSX, Java, JavaScript, Julia, Kotlin, LLVM, Lighttpd configuration file, Lua, Mako, Mason, Mathematica, MiniZinc, Modula-2, MorrowindScript, MySQL, Myghty, NASM, Newspeak, Nginx configuration file, Nim, Nix, OCaml, Objective-C, Octave, Org Mode, PHP, PL/pgSQL, POVRay, PacmanConf, Perl, Pig, PkgConfig, PostScript, PostgreSQL SQL dialect, PowerShell, Prolog, Protocol Buffer, Puppet, Python, Python 3, QBasic, R, Racket, Ragel, Rexx, Ruby, Rust, SCSS, SPARQL, SQL, Sass, Scala, Scheme, Scilab, Smalltalk, Smarty, Snobol, Solidity, SquidConf, Swift, TASM, TOML, Tcl, Tcsh, TeX, Termcap, Terminfo, Terraform, Thrift, Transact-SQL, Turtle, Twig, TypeScript, TypoScript, TypoScriptCssData, TypoScriptHtmlData, VHDL, VimL, WDTE, XML, Xorg, YAML, cfstatement, markdown, reStructuredText, reg, systemverilog, verilog
+Prefix | Language
+:----: | --------
+A | ABNF, ActionScript, ActionScript 3, Ada, Angular2, ANTLR, ApacheConf, APL, AppleScript, Awk
+B | Ballerina, Base Makefile, Bash, Batchfile, BlitzBasic, BNF, Brainfuck
+C | C, C#, C++, Cassandra CQL, CFEngine3, cfstatement/ColdFusion, CMake, COBOL, CSS, Cap'n Proto, Ceylon, ChaiScript, Cheetah, Clojure, CoffeeScript, Common Lisp, Coq, Crystal, Cython
+D | Dart, Diff, Django/Jinja, Docker, DTD
+E | EBNF, Elixir, Elm, EmacsLisp, Erlang
+F | Factor, Fish, Forth, Fortran, FSharp
+G | GAS, GDScript, GLSL, Genshi, Genshi HTML, Genshi Text, Gnuplot, Go, Go HTML Template, Go Text Template, Groovy
+H | Handlebars, Haskell, Haxe, Hexdump, HTML, HTTP, Hy
+I | Idris, INI, Io
+J | Java, JavaScript, JSON, Jsx, Julia, Jungle
+K | Kotlin
+L | Lighttpd configuration file, LLVM, Lua
+M | Mako, Markdown, Mason, Mathematica, MiniZinc, Modula-2, MonkeyC, MorrowindScript, Myghty, MySQL
+N | NASM, Newspeak, Nginx configuration file, Nim, Nix
+O | Objective-C, OCaml, Octave, OpenSCAD, Org Mode
+P | PacmanConf, Perl, PHP, Pig, PkgConfig, Plaintext, PL/pgSQL, PostgreSQL SQL dialect, PostScript, POVRay, PowerShell, Prolog, Protocol Buffer, Puppet, Python, Python 3
+Q | QBasic
+R | R, Racket, Ragel, reg, reStructuredText, Rexx, Ruby, Rust
+S | Sass, Scala, Scheme, Scilab, SCSS, Smalltalk, Smarty, Snobol, Solidity, SPARQL, SQL, SquidConf, Swift, systemd, Systemverilog
+T | TASM, Tcl, Tcsh, Termcap, Terminfo, Terraform, TeX, Thrift, TOML, TradingView, Transact-SQL, Turtle, Twig, TypeScript, TypoScript, TypoScriptCssData, TypoScriptHtmlData
+V | verilog, VHDL, VimL
+W | WDTE
+X | XML, Xorg
+Y | YAML
_I will attempt to keep this section up to date, but an authoritative list can be
displayed with `chroma --list`._
diff --git a/vendor/github.com/alecthomas/chroma/coalesce.go b/vendor/github.com/alecthomas/chroma/coalesce.go
index 5af0a7c6d..f5048951a 100644
--- a/vendor/github.com/alecthomas/chroma/coalesce.go
+++ b/vendor/github.com/alecthomas/chroma/coalesce.go
@@ -6,17 +6,17 @@ func Coalesce(lexer Lexer) Lexer { return &coalescer{lexer} }
type coalescer struct{ Lexer }
func (d *coalescer) Tokenise(options *TokeniseOptions, text string) (Iterator, error) {
- var prev *Token
+ var prev Token
it, err := d.Lexer.Tokenise(options, text)
if err != nil {
return nil, err
}
- return func() *Token {
- for token := it(); token != nil; token = it() {
+ return func() Token {
+ for token := it(); token != (EOF); token = it() {
if len(token.Value) == 0 {
continue
}
- if prev == nil {
+ if prev == EOF {
prev = token
} else {
if prev.Type == token.Type && len(prev.Value) < 8192 {
@@ -29,7 +29,7 @@ func (d *coalescer) Tokenise(options *TokeniseOptions, text string) (Iterator, e
}
}
out := prev
- prev = nil
+ prev = EOF
return out
}, nil
}
diff --git a/vendor/github.com/alecthomas/chroma/delegate.go b/vendor/github.com/alecthomas/chroma/delegate.go
index 06f55dbc9..021aeef57 100644
--- a/vendor/github.com/alecthomas/chroma/delegate.go
+++ b/vendor/github.com/alecthomas/chroma/delegate.go
@@ -31,7 +31,7 @@ func (d *delegatingLexer) Config() *Config {
// An insertion is the character range where language tokens should be inserted.
type insertion struct {
start, end int
- tokens []*Token
+ tokens []Token
}
func (d *delegatingLexer) Tokenise(options *TokeniseOptions, text string) (Iterator, error) {
@@ -44,15 +44,15 @@ func (d *delegatingLexer) Tokenise(options *TokeniseOptions, text string) (Itera
insertions := []*insertion{}
var insert *insertion
offset := 0
- var last *Token
+ var last Token
for _, t := range tokens {
if t.Type == Other {
- if last != nil && insert != nil && last.Type != Other {
+ if last != EOF && insert != nil && last.Type != Other {
insert.end = offset
}
others.WriteString(t.Value)
} else {
- if last == nil || last.Type == Other {
+ if last == EOF || last.Type == Other {
insert = &insertion{start: offset}
insertions = append(insertions, insert)
}
@@ -73,12 +73,12 @@ func (d *delegatingLexer) Tokenise(options *TokeniseOptions, text string) (Itera
}
// Interleave the two sets of tokens.
- out := []*Token{}
+ var out []Token
offset = 0 // Offset into text.
tokenIndex := 0
- nextToken := func() *Token {
+ nextToken := func() Token {
if tokenIndex >= len(rootTokens) {
- return nil
+ return EOF
}
t := rootTokens[tokenIndex]
tokenIndex++
@@ -95,18 +95,18 @@ func (d *delegatingLexer) Tokenise(options *TokeniseOptions, text string) (Itera
}
t := nextToken()
i := nextInsertion()
- for t != nil || i != nil {
+ for t != EOF || i != nil {
// fmt.Printf("%d->%d:%q %d->%d:%q\n", offset, offset+len(t.Value), t.Value, i.start, i.end, Stringify(i.tokens...))
- if t == nil || (i != nil && i.start < offset+len(t.Value)) {
- var l *Token
+ if t == EOF || (i != nil && i.start < offset+len(t.Value)) {
+ var l Token
l, t = splitToken(t, i.start-offset)
- if l != nil {
+ if l != EOF {
out = append(out, l)
offset += len(l.Value)
}
out = append(out, i.tokens...)
offset += i.end - i.start
- if t == nil {
+ if t == EOF {
t = nextToken()
}
i = nextInsertion()
@@ -119,15 +119,15 @@ func (d *delegatingLexer) Tokenise(options *TokeniseOptions, text string) (Itera
return Literator(out...), nil
}
-func splitToken(t *Token, offset int) (l *Token, r *Token) {
- if t == nil {
- return nil, nil
+func splitToken(t Token, offset int) (l Token, r Token) {
+ if t == EOF {
+ return EOF, EOF
}
if offset == 0 {
- return nil, t
+ return EOF, t
}
if offset == len(t.Value) {
- return t, nil
+ return t, EOF
}
l = t.Clone()
r = t.Clone()
diff --git a/vendor/github.com/alecthomas/chroma/formatters/api.go b/vendor/github.com/alecthomas/chroma/formatters/api.go
index d5fe28ad5..c161fd45e 100644
--- a/vendor/github.com/alecthomas/chroma/formatters/api.go
+++ b/vendor/github.com/alecthomas/chroma/formatters/api.go
@@ -11,7 +11,7 @@ import (
var (
// NoOp formatter.
NoOp = Register("noop", chroma.FormatterFunc(func(w io.Writer, s *chroma.Style, iterator chroma.Iterator) error {
- for t := iterator(); t != nil; t = iterator() {
+ for t := iterator(); t != chroma.EOF; t = iterator() {
if _, err := io.WriteString(w, t.Value); err != nil {
return err
}
diff --git a/vendor/github.com/alecthomas/chroma/formatters/html/html.go b/vendor/github.com/alecthomas/chroma/formatters/html/html.go
index 806721cca..1fbe0c8b6 100644
--- a/vendor/github.com/alecthomas/chroma/formatters/html/html.go
+++ b/vendor/github.com/alecthomas/chroma/formatters/html/html.go
@@ -25,6 +25,9 @@ func WithClasses() Option { return func(f *Formatter) { f.Classes = true } }
// TabWidth sets the number of characters for a tab. Defaults to 8.
func TabWidth(width int) Option { return func(f *Formatter) { f.tabWidth = width } }
+// PreventSurroundingPre prevents the surrounding pre tags around the generated code
+func PreventSurroundingPre() Option { return func(f *Formatter) { f.preventSurroundingPre = true } }
+
// WithLineNumbers formats output with line numbers.
func WithLineNumbers() Option {
return func(f *Formatter) {
@@ -70,14 +73,15 @@ func New(options ...Option) *Formatter {
// Formatter that generates HTML.
type Formatter struct {
- standalone bool
- prefix string
- Classes bool // Exported field to detect when classes are being used
- tabWidth int
- lineNumbers bool
- lineNumbersInTable bool
- highlightRanges highlightRanges
- baseLineNumber int
+ standalone bool
+ prefix string
+ Classes bool // Exported field to detect when classes are being used
+ preventSurroundingPre bool
+ tabWidth int
+ lineNumbers bool
+ lineNumbersInTable bool
+ highlightRanges highlightRanges
+ baseLineNumber int
}
type highlightRanges [][2]int
@@ -125,7 +129,7 @@ func (f *Formatter) restyle(style *chroma.Style) (*chroma.Style, error) {
// We deliberately don't use html/template here because it is two orders of magnitude slower (benchmarked).
//
// OTOH we need to be super careful about correct escaping...
-func (f *Formatter) writeHTML(w io.Writer, style *chroma.Style, tokens []*chroma.Token) (err error) { // nolint: gocyclo
+func (f *Formatter) writeHTML(w io.Writer, style *chroma.Style, tokens []chroma.Token) (err error) { // nolint: gocyclo
style, err = f.restyle(style)
if err != nil {
return err
@@ -149,7 +153,7 @@ func (f *Formatter) writeHTML(w io.Writer, style *chroma.Style, tokens []*chroma
wrapInTable := f.lineNumbers && f.lineNumbersInTable
- lines := splitTokensIntoLines(tokens)
+ lines := chroma.SplitTokensIntoLines(tokens)
lineDigits := len(fmt.Sprintf("%d", len(lines)))
highlightIndex := 0
@@ -158,7 +162,9 @@ func (f *Formatter) writeHTML(w io.Writer, style *chroma.Style, tokens []*chroma
fmt.Fprintf(w, "\n", f.styleAttr(css, chroma.Background))
fmt.Fprintf(w, "
", f.styleAttr(css, chroma.LineTable))
fmt.Fprintf(w, "\n", f.styleAttr(css, chroma.LineTableTD))
- fmt.Fprintf(w, "", f.styleAttr(css, chroma.Background))
+ if !f.preventSurroundingPre {
+ fmt.Fprintf(w, "", f.styleAttr(css, chroma.Background))
+ }
for index := range lines {
line := f.baseLineNumber + index
highlight, next := f.shouldHighlight(highlightIndex, line)
@@ -175,11 +181,16 @@ func (f *Formatter) writeHTML(w io.Writer, style *chroma.Style, tokens []*chroma
fmt.Fprintf(w, "")
}
}
- fmt.Fprint(w, " | \n")
+ if !f.preventSurroundingPre {
+ fmt.Fprint(w, "")
+ }
+ fmt.Fprint(w, "\n")
fmt.Fprintf(w, "\n", f.styleAttr(css, chroma.LineTableTD))
}
- fmt.Fprintf(w, "", f.styleAttr(css, chroma.Background))
+ if !f.preventSurroundingPre {
+ fmt.Fprintf(w, "", f.styleAttr(css, chroma.Background))
+ }
highlightIndex = 0
for index, tokens := range lines {
// 1-based line number.
@@ -209,7 +220,9 @@ func (f *Formatter) writeHTML(w io.Writer, style *chroma.Style, tokens []*chroma
}
}
- fmt.Fprint(w, " ")
+ if !f.preventSurroundingPre {
+ fmt.Fprint(w, " ")
+ }
if wrapInTable {
fmt.Fprint(w, " |
\n")
@@ -377,26 +390,3 @@ func compressStyle(s string) string {
}
return strings.Join(out, ";")
}
-
-func splitTokensIntoLines(tokens []*chroma.Token) (out [][]*chroma.Token) {
- line := []*chroma.Token{}
- for _, token := range tokens {
- for strings.Contains(token.Value, "\n") {
- parts := strings.SplitAfterN(token.Value, "\n", 2)
- // Token becomes the tail.
- token.Value = parts[1]
-
- // Append the head to the line and flush the line.
- clone := token.Clone()
- clone.Value = parts[0]
- line = append(line, clone)
- out = append(out, line)
- line = nil
- }
- line = append(line, token)
- }
- if len(line) > 0 {
- out = append(out, line)
- }
- return
-}
diff --git a/vendor/github.com/alecthomas/chroma/formatters/json.go b/vendor/github.com/alecthomas/chroma/formatters/json.go
index 4ba1dd46b..95df4bb67 100644
--- a/vendor/github.com/alecthomas/chroma/formatters/json.go
+++ b/vendor/github.com/alecthomas/chroma/formatters/json.go
@@ -12,7 +12,7 @@ import (
var JSON = Register("json", chroma.FormatterFunc(func(w io.Writer, s *chroma.Style, it chroma.Iterator) error {
fmt.Fprintln(w, "[")
i := 0
- for t := it(); t != nil; t = it() {
+ for t := it(); t != chroma.EOF; t = it() {
if i > 0 {
fmt.Fprintln(w, ",")
}
diff --git a/vendor/github.com/alecthomas/chroma/formatters/tokens.go b/vendor/github.com/alecthomas/chroma/formatters/tokens.go
index 614987e2c..91d80d146 100644
--- a/vendor/github.com/alecthomas/chroma/formatters/tokens.go
+++ b/vendor/github.com/alecthomas/chroma/formatters/tokens.go
@@ -9,7 +9,7 @@ import (
// Tokens formatter outputs the raw token structures.
var Tokens = Register("tokens", chroma.FormatterFunc(func(w io.Writer, s *chroma.Style, it chroma.Iterator) error {
- for t := it(); t != nil; t = it() {
+ for t := it(); t != chroma.EOF; t = it() {
if _, err := fmt.Fprintln(w, t.GoString()); err != nil {
return err
}
diff --git a/vendor/github.com/alecthomas/chroma/formatters/tty_indexed.go b/vendor/github.com/alecthomas/chroma/formatters/tty_indexed.go
index a068cc594..4046e973a 100644
--- a/vendor/github.com/alecthomas/chroma/formatters/tty_indexed.go
+++ b/vendor/github.com/alecthomas/chroma/formatters/tty_indexed.go
@@ -216,7 +216,7 @@ func (c *indexedTTYFormatter) Format(w io.Writer, style *chroma.Style, it chroma
}
}()
theme := styleToEscapeSequence(c.table, style)
- for token := it(); token != nil; token = it() {
+ for token := it(); token != chroma.EOF; token = it() {
// TODO: Cache token lookups?
clr, ok := theme[token.Type]
if !ok {
diff --git a/vendor/github.com/alecthomas/chroma/formatters/tty_truecolour.go b/vendor/github.com/alecthomas/chroma/formatters/tty_truecolour.go
index e9c264a71..723b5de5b 100644
--- a/vendor/github.com/alecthomas/chroma/formatters/tty_truecolour.go
+++ b/vendor/github.com/alecthomas/chroma/formatters/tty_truecolour.go
@@ -11,7 +11,7 @@ import (
var TTY16m = Register("terminal16m", chroma.FormatterFunc(trueColourFormatter))
func trueColourFormatter(w io.Writer, style *chroma.Style, it chroma.Iterator) error {
- for token := it(); token != nil; token = it() {
+ for token := it(); token != chroma.EOF; token = it() {
entry := style.Get(token.Type)
if !entry.IsZero() {
out := ""
diff --git a/vendor/github.com/alecthomas/chroma/go.mod b/vendor/github.com/alecthomas/chroma/go.mod
new file mode 100644
index 000000000..9d0aa86d1
--- /dev/null
+++ b/vendor/github.com/alecthomas/chroma/go.mod
@@ -0,0 +1,14 @@
+module github.com/alecthomas/chroma
+
+require (
+ github.com/alecthomas/assert v0.0.0-20170929043011-405dbfeb8e38
+ github.com/alecthomas/colour v0.0.0-20160524082231-60882d9e2721 // indirect
+ github.com/alecthomas/kong v0.1.15
+ github.com/alecthomas/repr v0.0.0-20180818092828-117648cd9897 // indirect
+ github.com/danwakefield/fnmatch v0.0.0-20160403171240-cbb64ac3d964
+ github.com/dlclark/regexp2 v1.1.6
+ github.com/mattn/go-colorable v0.0.9
+ github.com/mattn/go-isatty v0.0.4
+ github.com/sergi/go-diff v1.0.0 // indirect
+ golang.org/x/sys v0.0.0-20181128092732-4ed8d59d0b35 // indirect
+)
diff --git a/vendor/github.com/alecthomas/chroma/go.sum b/vendor/github.com/alecthomas/chroma/go.sum
new file mode 100644
index 000000000..27210bbb2
--- /dev/null
+++ b/vendor/github.com/alecthomas/chroma/go.sum
@@ -0,0 +1,26 @@
+github.com/alecthomas/assert v0.0.0-20170929043011-405dbfeb8e38 h1:smF2tmSOzy2Mm+0dGI2AIUHY+w0BUc+4tn40djz7+6U=
+github.com/alecthomas/assert v0.0.0-20170929043011-405dbfeb8e38/go.mod h1:r7bzyVFMNntcxPZXK3/+KdruV1H5KSlyVY0gc+NgInI=
+github.com/alecthomas/colour v0.0.0-20160524082231-60882d9e2721 h1:JHZL0hZKJ1VENNfmXvHbgYlbUOvpzYzvy2aZU5gXVeo=
+github.com/alecthomas/colour v0.0.0-20160524082231-60882d9e2721/go.mod h1:QO9JBoKquHd+jz9nshCh40fOfO+JzsoXy8qTHF68zU0=
+github.com/alecthomas/kong v0.1.15 h1:IWBg+KrLvoHBicD50OzMI8fKjrtAa1okMR9g38HVM/s=
+github.com/alecthomas/kong v0.1.15/go.mod h1:0m2VYms8rH0qbCqVB2gvGHk74bqLIq0HXjCs5bNbNQU=
+github.com/alecthomas/repr v0.0.0-20180818092828-117648cd9897 h1:p9Sln00KOTlrYkxI1zYWl1QLnEqAqEARBEYa8FQnQcY=
+github.com/alecthomas/repr v0.0.0-20180818092828-117648cd9897/go.mod h1:xTS7Pm1pD1mvyM075QCDSRqH6qRLXylzS24ZTpRiSzQ=
+github.com/danwakefield/fnmatch v0.0.0-20160403171240-cbb64ac3d964 h1:y5HC9v93H5EPKqaS1UYVg1uYah5Xf51mBfIoWehClUQ=
+github.com/danwakefield/fnmatch v0.0.0-20160403171240-cbb64ac3d964/go.mod h1:Xd9hchkHSWYkEqJwUGisez3G1QY8Ryz0sdWrLPMGjLk=
+github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
+github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
+github.com/dlclark/regexp2 v1.1.6 h1:CqB4MjHw0MFCDj+PHHjiESmHX+N7t0tJzKvC6M97BRg=
+github.com/dlclark/regexp2 v1.1.6/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc=
+github.com/mattn/go-colorable v0.0.9 h1:UVL0vNpWh04HeJXV0KLcaT7r06gOH2l4OW6ddYRUIY4=
+github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
+github.com/mattn/go-isatty v0.0.4 h1:bnP0vzxcAdeI1zdubAl5PjU6zsERjGZb7raWodagDYs=
+github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
+github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
+github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
+github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ=
+github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
+github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
+github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
+golang.org/x/sys v0.0.0-20181128092732-4ed8d59d0b35 h1:YAFjXN64LMvktoUZH9zgY4lGc/msGN7HQfoSuKCgaDU=
+golang.org/x/sys v0.0.0-20181128092732-4ed8d59d0b35/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
diff --git a/vendor/github.com/alecthomas/chroma/iterator.go b/vendor/github.com/alecthomas/chroma/iterator.go
index 43861c8a4..f54037280 100644
--- a/vendor/github.com/alecthomas/chroma/iterator.go
+++ b/vendor/github.com/alecthomas/chroma/iterator.go
@@ -1,16 +1,18 @@
package chroma
+import "strings"
+
// An Iterator across tokens.
//
// nil will be returned at the end of the Token stream.
//
// If an error occurs within an Iterator, it may propagate this in a panic. Formatters should recover.
-type Iterator func() *Token
+type Iterator func() Token
// Tokens consumes all tokens from the iterator and returns them as a slice.
-func (i Iterator) Tokens() []*Token {
- out := []*Token{}
- for t := i(); t != nil; t = i() {
+func (i Iterator) Tokens() []Token {
+ var out []Token
+ for t := i(); t != EOF; t = i() {
out = append(out, t)
}
return out
@@ -18,26 +20,49 @@ func (i Iterator) Tokens() []*Token {
// Concaterator concatenates tokens from a series of iterators.
func Concaterator(iterators ...Iterator) Iterator {
- return func() *Token {
+ return func() Token {
for len(iterators) > 0 {
t := iterators[0]()
- if t != nil {
+ if t != EOF {
return t
}
iterators = iterators[1:]
}
- return nil
+ return EOF
}
}
// Literator converts a sequence of literal Tokens into an Iterator.
-func Literator(tokens ...*Token) Iterator {
- return func() (out *Token) {
+func Literator(tokens ...Token) Iterator {
+ return func() Token {
if len(tokens) == 0 {
- return nil
+ return EOF
}
token := tokens[0]
tokens = tokens[1:]
return token
}
}
+
+func SplitTokensIntoLines(tokens []Token) (out [][]Token) {
+ var line []Token
+ for _, token := range tokens {
+ for strings.Contains(token.Value, "\n") {
+ parts := strings.SplitAfterN(token.Value, "\n", 2)
+ // Token becomes the tail.
+ token.Value = parts[1]
+
+ // Append the head to the line and flush the line.
+ clone := token.Clone()
+ clone.Value = parts[0]
+ line = append(line, clone)
+ out = append(out, line)
+ line = nil
+ }
+ line = append(line, token)
+ }
+ if len(line) > 0 {
+ out = append(out, line)
+ }
+ return
+}
diff --git a/vendor/github.com/alecthomas/chroma/lexer.go b/vendor/github.com/alecthomas/chroma/lexer.go
index 6a13f082e..cc461fadb 100644
--- a/vendor/github.com/alecthomas/chroma/lexer.go
+++ b/vendor/github.com/alecthomas/chroma/lexer.go
@@ -66,12 +66,12 @@ type Token struct {
func (t *Token) String() string { return t.Value }
func (t *Token) GoString() string { return fmt.Sprintf("&Token{%s, %q}", t.Type, t.Value) }
-func (t *Token) Clone() *Token {
- clone := &Token{}
- *clone = *t
- return clone
+func (t *Token) Clone() Token {
+ return *t
}
+var EOF Token
+
type TokeniseOptions struct {
// State to start tokenisation in. Defaults to "root".
State string
diff --git a/vendor/github.com/alecthomas/chroma/lexers/b/bash.go b/vendor/github.com/alecthomas/chroma/lexers/b/bash.go
index ff4e4a809..131e432f7 100644
--- a/vendor/github.com/alecthomas/chroma/lexers/b/bash.go
+++ b/vendor/github.com/alecthomas/chroma/lexers/b/bash.go
@@ -36,7 +36,7 @@ var Bash = internal.Register(MustNewLexer(
{`\b(if|fi|else|while|do|done|for|then|return|function|case|select|continue|until|esac|elif)(\s*)\b`, ByGroups(Keyword, Text), nil},
{"\\b(alias|bg|bind|break|builtin|caller|cd|command|compgen|complete|declare|dirs|disown|echo|enable|eval|exec|exit|export|false|fc|fg|getopts|hash|help|history|jobs|kill|let|local|logout|popd|printf|pushd|pwd|read|readonly|set|shift|shopt|source|suspend|test|time|times|trap|true|type|typeset|ulimit|umask|unalias|unset|wait)(?=[\\s)`])", NameBuiltin, nil},
{`\A#!.+\n`, CommentPreproc, nil},
- {`#.*\n`, CommentSingle, nil},
+ {`#.*\S`, CommentSingle, nil},
{`\\[\w\W]`, LiteralStringEscape, nil},
{`(\b\w+)(\s*)(\+?=)`, ByGroups(NameVariable, Text, Operator), nil},
{`[\[\]{}()=]`, Operator, nil},
diff --git a/vendor/github.com/alecthomas/chroma/lexers/e/elixir.go b/vendor/github.com/alecthomas/chroma/lexers/e/elixir.go
index 23fa8af6c..40730290b 100644
--- a/vendor/github.com/alecthomas/chroma/lexers/e/elixir.go
+++ b/vendor/github.com/alecthomas/chroma/lexers/e/elixir.go
@@ -36,9 +36,9 @@ var Elixir = internal.Register(MustNewLexer(
{`\\\\|\<\<|\>\>|\=\>|\(|\)|\:|\;|\,|\[|\]`, Punctuation, nil},
{`&\d`, NameEntity, nil},
{`\<|\>|\+|\-|\*|\/|\!|\^|\&`, Operator, nil},
- {`0b[01]+`, LiteralNumberBin, nil},
- {`0o[0-7]+`, LiteralNumberOct, nil},
- {`0x[\da-fA-F]+`, LiteralNumberHex, nil},
+ {`0b[01](_?[01])*`, LiteralNumberBin, nil},
+ {`0o[0-7](_?[0-7])*`, LiteralNumberOct, nil},
+ {`0x[\da-fA-F](_?[\dA-Fa-f])*`, LiteralNumberHex, nil},
{`\d(_?\d)*\.\d(_?\d)*([eE][-+]?\d(_?\d)*)?`, LiteralNumberFloat, nil},
{`\d(_?\d)*`, LiteralNumberInteger, nil},
{`"""\s*`, LiteralStringHeredoc, Push("heredoc_double")},
diff --git a/vendor/github.com/alecthomas/chroma/lexers/g/go.go b/vendor/github.com/alecthomas/chroma/lexers/g/go.go
index 54c23c3cf..a93fa8bbb 100644
--- a/vendor/github.com/alecthomas/chroma/lexers/g/go.go
+++ b/vendor/github.com/alecthomas/chroma/lexers/g/go.go
@@ -42,6 +42,7 @@ var Go = internal.Register(MustNewLexer(
{"(`)([^`]*)(`)", ByGroups(LiteralString, Using(TypeRemappingLexer(GoTextTemplate, TypeMapping{{Other, LiteralString, nil}})), LiteralString), nil},
{`"(\\\\|\\"|[^"])*"`, LiteralString, nil},
{`(<<=|>>=|<<|>>|<=|>=|&\^=|&\^|\+=|-=|\*=|/=|%=|&=|\|=|&&|\|\||<-|\+\+|--|==|!=|:=|\.\.\.|[+\-*/%&])`, Operator, nil},
+ {`([a-zA-Z_]\w*)(\s*)(\()`, ByGroups(NameFunction, UsingSelf("root"), Punctuation), nil},
{`[|^<>=!()\[\]{}.,;:]`, Punctuation, nil},
{`[^\W\d]\w*`, NameOther, nil},
},
diff --git a/vendor/github.com/alecthomas/chroma/lexers/h/http.go b/vendor/github.com/alecthomas/chroma/lexers/h/http.go
index 67bc71a45..e0ada970f 100644
--- a/vendor/github.com/alecthomas/chroma/lexers/h/http.go
+++ b/vendor/github.com/alecthomas/chroma/lexers/h/http.go
@@ -34,7 +34,7 @@ var HTTP = internal.Register(httpBodyContentTypeLexer(MustNewLexer(
)))
func httpContentBlock(groups []string, lexer Lexer) Iterator {
- tokens := []*Token{
+ tokens := []Token{
{Generic, groups[0]},
}
return Literator(tokens...)
@@ -42,7 +42,7 @@ func httpContentBlock(groups []string, lexer Lexer) Iterator {
}
func httpHeaderBlock(groups []string, lexer Lexer) Iterator {
- tokens := []*Token{
+ tokens := []Token{
{Name, groups[1]},
{Text, groups[2]},
{Operator, groups[3]},
@@ -54,7 +54,7 @@ func httpHeaderBlock(groups []string, lexer Lexer) Iterator {
}
func httpContinuousHeaderBlock(groups []string, lexer Lexer) Iterator {
- tokens := []*Token{
+ tokens := []Token{
{Text, groups[1]},
{Literal, groups[2]},
{Text, groups[3]},
@@ -76,8 +76,8 @@ func (d *httpBodyContentTyper) Tokenise(options *TokeniseOptions, text string) (
return nil, err
}
- return func() *Token {
- for token := it(); token != nil; token = it() {
+ return func() Token {
+ for token := it(); token != EOF; token = it() {
switch {
case token.Type == Name && strings.ToLower(token.Value) == "content-type":
{
@@ -85,6 +85,7 @@ func (d *httpBodyContentTyper) Tokenise(options *TokeniseOptions, text string) (
}
case token.Type == Literal && isContentType:
{
+ isContentType = false
contentType = strings.TrimSpace(token.Value)
pos := strings.Index(contentType, ";")
if pos > 0 {
@@ -111,7 +112,7 @@ func (d *httpBodyContentTyper) Tokenise(options *TokeniseOptions, text string) (
if err != nil {
panic(err)
}
- return nil
+ return EOF
}
}
@@ -121,11 +122,11 @@ func (d *httpBodyContentTyper) Tokenise(options *TokeniseOptions, text string) (
}
if subIterator != nil {
- for token := subIterator(); token != nil; token = subIterator() {
+ for token := subIterator(); token != EOF; token = subIterator() {
return token
}
}
- return nil
+ return EOF
}, nil
}
diff --git a/vendor/github.com/alecthomas/chroma/lexers/r/rst.go b/vendor/github.com/alecthomas/chroma/lexers/r/rst.go
index d5159d7ec..f09dad092 100644
--- a/vendor/github.com/alecthomas/chroma/lexers/r/rst.go
+++ b/vendor/github.com/alecthomas/chroma/lexers/r/rst.go
@@ -61,7 +61,7 @@ var Restructuredtext = internal.Register(MustNewLexer(
func rstCodeBlock(groups []string, lexer Lexer) Iterator {
iterators := []Iterator{}
- tokens := []*Token{
+ tokens := []Token{
{Punctuation, groups[1]},
{Text, groups[2]},
{OperatorWord, groups[3]},
@@ -73,7 +73,7 @@ func rstCodeBlock(groups []string, lexer Lexer) Iterator {
code := strings.Join(groups[8:], "")
lexer = internal.Get(groups[6])
if lexer == nil {
- tokens = append(tokens, &Token{String, code})
+ tokens = append(tokens, Token{String, code})
iterators = append(iterators, Literator(tokens...))
} else {
sub, err := lexer.Tokenise(nil, code)
diff --git a/vendor/github.com/alecthomas/chroma/lexers/s/systemd.go b/vendor/github.com/alecthomas/chroma/lexers/s/systemd.go
new file mode 100644
index 000000000..e2f7e9b7d
--- /dev/null
+++ b/vendor/github.com/alecthomas/chroma/lexers/s/systemd.go
@@ -0,0 +1,29 @@
+package s
+
+import (
+ . "github.com/alecthomas/chroma" // nolint
+ "github.com/alecthomas/chroma/lexers/internal"
+)
+
+var SYSTEMD = internal.Register(MustNewLexer(
+ &Config{
+ Name: "SYSTEMD",
+ Aliases: []string{"systemd"},
+ Filenames: []string{"*.service"},
+ MimeTypes: []string{"text/plain"},
+ },
+ Rules {
+ "root": {
+ {`\s+`, Text, nil},
+ {`[;#].*`, Comment, nil},
+ {`\[.*?\]$`, Keyword, nil},
+ {`(.*?)(=)(.*)(\\\n)`, ByGroups(NameAttribute, Operator, LiteralString, Text), Push("continuation")},
+ {`(.*?)(=)(.*)`, ByGroups(NameAttribute, Operator, LiteralString), nil},
+ },
+ "continuation": {
+ {`(.*?)(\\\n)`, ByGroups(LiteralString, Text), nil},
+ {`(.*)`, LiteralString, Pop(1)},
+ },
+ },
+))
+
diff --git a/vendor/github.com/alecthomas/chroma/lexers/t/tradingview.go b/vendor/github.com/alecthomas/chroma/lexers/t/tradingview.go
new file mode 100644
index 000000000..e411411e3
--- /dev/null
+++ b/vendor/github.com/alecthomas/chroma/lexers/t/tradingview.go
@@ -0,0 +1,36 @@
+package t
+
+import (
+ . "github.com/alecthomas/chroma" // nolint
+ "github.com/alecthomas/chroma/lexers/internal"
+)
+
+// TradingView lexer.
+var TradingView = internal.Register(MustNewLexer(
+ &Config{
+ Name: "TradingView",
+ Aliases: []string{"tradingview", "tv"},
+ Filenames: []string{"*.tv"},
+ MimeTypes: []string{"text/x-tradingview"},
+ DotAll: true,
+ },
+ Rules{
+ "root": {
+ {`[^\S\n]+|\n|[()]`, Text, nil},
+ {`(//.*?)(\n)`, ByGroups(CommentSingle, Text), nil},
+ {`>=|<=|==|!=|>|<|\?|-|\+|\*|\/|%|\[|\]`, Operator, nil},
+ {`[:,.]`, Punctuation, nil},
+ {`=`, KeywordPseudo, nil},
+ {`"(\\\\|\\"|[^"\n])*["\n]`, LiteralString, nil},
+ {`'\\.'|'[^\\]'`, LiteralString, nil},
+ {`[0-9](\.[0-9]*)?([eE][+-][0-9]+)?`, LiteralNumber, nil},
+ {`(abs|acos|alertcondition|alma|asin|atan|atr|avg|barcolor|barssince|bgcolor|cci|ceil|change|cog|correlation|cos|crossover|crossunder|cum|dev|ema|exp|falling|fill|fixnan|floor|heikinashi|highest|highestbars|hline|iff|input|kagi|linebreak|linreg|log|log10|lowest|lowestbars|macd|max|min|mom|nz|percentile_linear_interpolation|percentile_nearest_rank|percentrank|pivothigh|pivotlow|plot|plotarrow|plotbar|plotcandle|plotchar|plotshape|pointfigure|pow|renko|rising|rma|roc|round|rsi|sar|security|sign|sin|sma|sqrt|stdev|stoch|study|sum|swma|tan|tostring|tsi|valuewhen|variance|vwma|wma|strategy\.(cancel|cancel_all|close|close_all|entry|exit|order)|strategy\.risk\.(allow_entry_in|max_cons_loss_days|max_drawdown|max_intraday_filled_orders|max_intraday_loss|max_position_size))\b`, NameFunction, nil},
+ {`\b(cross|dayofmonth|dayofweek|hour|minute|month|na|offset|second|tickerid|time|tr|vwap|weekofyear|year)(\()`, ByGroups(NameFunction, Text), nil}, // functions that can also be variable
+ {`(accdist|aqua|area|areabr|black|blue|bool|circles|close|columns|currency\.(AUD|CAD|CHF|EUR|GBP|HKD|JPY|NOK|NONE|NZD|SEK|SGD|TRY|USD|ZAR)|dashed|dotted|float|friday|fuchsia|gray|green|high|histogram|hl2|hlc3|integer|interval|isdaily|isdwm|isintraday|ismonthly|isweekly|lime|line|linebr|location\.(abovebar|belowbar|bottom|top)|low|maroon|monday|n|navy|ohlc4|olive|open|orange|period|purple|red|resolution|saturday|scale\.(left|none|right)|session|session\.(extended|regular)|silver|size\.(auto|huge|large|normal|small|tiny)|solid|source|string|sunday|symbol|syminfo\.(mintick|pointvalue|prefix|root|session)|teal|thursday|ticker|tuesday|volume|wednesday|white|yellow|strategy\.(cash|position_size|closedtrades|direction\.(all|long|short)|equity|eventrades|fixed|grossloss|grossprofit|initial_capital|long|losstrades|max_contracts_held_all|max_contracts_held_long|max_contracts_held_short|max_drawdown|netprofit|oca\.(cancel|none|reduce)|openprofit|opentrades|percent_of_equity|position_avg_price|position_entry_name|short|wintrades)|shape\.(arrowdown|arrowup|circle|cross|diamond|flag|labeldown|labelup|square|triangledown|triangleup|xcross)|barstate\.is(first|history|last|new|realtime)|barmerge\.(gaps_on|gaps_off|lookahead_on|lookahead_off)|strategy\.commission\.(cash_per_contract|cash_per_order|percent))\b`, NameVariable, nil},
+ {`(cross|dayofmonth|dayofweek|hour|minute|month|na|second|tickerid|time|tr|vwap|weekofyear|year)(\b[^\(])`, ByGroups(NameVariable, Text), nil}, // variables that can also be function
+ {`(true|false)\b`, KeywordConstant, nil},
+ {`(and|or|not|if|else|for|to)\b`, OperatorWord, nil},
+ {`@?[_a-zA-Z]\w*`, Text, nil},
+ },
+ },
+))
diff --git a/vendor/github.com/alecthomas/chroma/lexers/v/vb.go b/vendor/github.com/alecthomas/chroma/lexers/v/vb.go
new file mode 100644
index 000000000..38a9185c8
--- /dev/null
+++ b/vendor/github.com/alecthomas/chroma/lexers/v/vb.go
@@ -0,0 +1,75 @@
+
+package v
+
+import (
+ . "github.com/alecthomas/chroma" // nolint
+ "github.com/alecthomas/chroma/lexers/internal"
+)
+
+const vbName = `[_\w][\w]*`
+
+// VB.Net lexer.
+var VBNet = internal.Register(MustNewLexer(
+ &Config{
+ Name: "VB.net",
+ Aliases: []string{ "vb.net", "vbnet", },
+ Filenames: []string{ "*.vb", "*.bas", },
+ MimeTypes: []string{ "text/x-vbnet", "text/x-vba", },
+ CaseInsensitive: true,
+ },
+ Rules{
+ "root": {
+ { `^\s*<.*?>`, NameAttribute, nil },
+ { `\s+`, Text, nil },
+ { `\n`, Text, nil },
+ { `rem\b.*?\n`, Comment, nil },
+ { `'.*?\n`, Comment, nil },
+ { `#If\s.*?\sThen|#ElseIf\s.*?\sThen|#Else|#End\s+If|#Const|#ExternalSource.*?\n|#End\s+ExternalSource|#Region.*?\n|#End\s+Region|#ExternalChecksum`, CommentPreproc, nil },
+ { `[(){}!#,.:]`, Punctuation, nil },
+ { `Option\s+(Strict|Explicit|Compare)\s+(On|Off|Binary|Text)`, KeywordDeclaration, nil },
+ { Words(`(?>=|<<|>>|:=|<=|>=|<>|[-&*/\\^+=<>\[\]]`, Operator, nil },
+ { `"`, LiteralString, Push("string") },
+ { `_\n`, Text, nil },
+ { vbName, Name, nil },
+ { `#.*?#`, LiteralDate, nil },
+ { `(\d+\.\d*|\d*\.\d+)(F[+-]?[0-9]+)?`, LiteralNumberFloat, nil },
+ { `\d+([SILDFR]|US|UI|UL)?`, LiteralNumberInteger, nil },
+ { `&H[0-9a-f]+([SILDFR]|US|UI|UL)?`, LiteralNumberInteger, nil },
+ { `&O[0-7]+([SILDFR]|US|UI|UL)?`, LiteralNumberInteger, nil },
+ },
+ "string": {
+ { `""`, LiteralString, nil },
+ { `"C?`, LiteralString, Pop(1) },
+ { `[^"]+`, LiteralString, nil },
+ },
+ "dim": {
+ { vbName, NameVariable, Pop(1) },
+ Default(Pop(1)),
+ },
+ "funcname": {
+ { vbName, NameFunction, Pop(1) },
+ },
+ "classname": {
+ { vbName, NameClass, Pop(1) },
+ },
+ "namespace": {
+ { vbName, NameNamespace, nil },
+ { `\.`, NameNamespace, nil },
+ Default(Pop(1)),
+ },
+ "end": {
+ { `\s+`, Text, nil },
+ { `(Function|Sub|Property|Class|Structure|Enum|Module|Namespace)\b`, Keyword, Pop(1) },
+ Default(Pop(1)),
+ },
+ },
+))
+
diff --git a/vendor/github.com/alecthomas/chroma/lexers/y/yaml.go b/vendor/github.com/alecthomas/chroma/lexers/y/yaml.go
index 0d73bacea..130c065f7 100644
--- a/vendor/github.com/alecthomas/chroma/lexers/y/yaml.go
+++ b/vendor/github.com/alecthomas/chroma/lexers/y/yaml.go
@@ -20,7 +20,7 @@ var YAML = internal.Register(MustNewLexer(
{`&[^\s]+`, CommentPreproc, nil},
{`\*[^\s]+`, CommentPreproc, nil},
{`^%include\s+[^\n\r]+`, CommentPreproc, nil},
- {`([>|])(\s+)((?:(?:.*?$)(?:[\n\r]*?\2)?)*)`, ByGroups(StringDoc, StringDoc, StringDoc), nil},
+ {`([>|+-]\s+)(\s+)((?:(?:.*?$)(?:[\n\r]*?)?)*)`, ByGroups(StringDoc, StringDoc, StringDoc), nil},
Include("value"),
{`[?:,\[\]]`, Punctuation, nil},
{`.`, Text, nil},
diff --git a/vendor/github.com/alecthomas/chroma/mutators.go b/vendor/github.com/alecthomas/chroma/mutators.go
index 30f1eedb6..05aede93f 100644
--- a/vendor/github.com/alecthomas/chroma/mutators.go
+++ b/vendor/github.com/alecthomas/chroma/mutators.go
@@ -122,7 +122,7 @@ func Default(mutators ...Mutator) Rule {
}
// Stringify returns the raw string for a set of tokens.
-func Stringify(tokens ...*Token) string {
+func Stringify(tokens ...Token) string {
out := []string{}
for _, t := range tokens {
out = append(out, t.Value)
diff --git a/vendor/github.com/alecthomas/chroma/regexp.go b/vendor/github.com/alecthomas/chroma/regexp.go
index 7c0586b63..607e37446 100644
--- a/vendor/github.com/alecthomas/chroma/regexp.go
+++ b/vendor/github.com/alecthomas/chroma/regexp.go
@@ -140,13 +140,13 @@ func Words(prefix, suffix string, words ...string) string {
}
// Tokenise text using lexer, returning tokens as a slice.
-func Tokenise(lexer Lexer, options *TokeniseOptions, text string) ([]*Token, error) {
- out := []*Token{}
+func Tokenise(lexer Lexer, options *TokeniseOptions, text string) ([]Token, error) {
+ var out []Token
it, err := lexer.Tokenise(options, text)
if err != nil {
return nil, err
}
- for t := it(); t != nil; t = it() {
+ for t := it(); t != EOF; t = it() {
out = append(out, t)
}
return out, nil
@@ -246,13 +246,13 @@ func (l *LexerState) Get(key interface{}) interface{} {
return l.MutatorContext[key]
}
-func (l *LexerState) Iterator() *Token {
+func (l *LexerState) Iterator() Token {
for l.Pos < len(l.Text) && len(l.Stack) > 0 {
// Exhaust the iterator stack, if any.
for len(l.iteratorStack) > 0 {
n := len(l.iteratorStack) - 1
t := l.iteratorStack[n]()
- if t == nil {
+ if t == EOF {
l.iteratorStack = l.iteratorStack[:n]
continue
}
@@ -271,7 +271,7 @@ func (l *LexerState) Iterator() *Token {
// No match.
if groups == nil {
l.Pos++
- return &Token{Error, string(l.Text[l.Pos-1 : l.Pos])}
+ return Token{Error, string(l.Text[l.Pos-1 : l.Pos])}
}
l.Rule = ruleIndex
l.Groups = groups
@@ -290,7 +290,7 @@ func (l *LexerState) Iterator() *Token {
for len(l.iteratorStack) > 0 {
n := len(l.iteratorStack) - 1
t := l.iteratorStack[n]()
- if t == nil {
+ if t == EOF {
l.iteratorStack = l.iteratorStack[:n]
continue
}
@@ -301,9 +301,9 @@ func (l *LexerState) Iterator() *Token {
if l.Pos != len(l.Text) && len(l.Stack) == 0 {
value := string(l.Text[l.Pos:])
l.Pos = len(l.Text)
- return &Token{Type: Error, Value: value}
+ return Token{Type: Error, Value: value}
}
- return nil
+ return EOF
}
type RegexLexer struct {
diff --git a/vendor/github.com/alecthomas/chroma/remap.go b/vendor/github.com/alecthomas/chroma/remap.go
index 223b5c607..e6484f775 100644
--- a/vendor/github.com/alecthomas/chroma/remap.go
+++ b/vendor/github.com/alecthomas/chroma/remap.go
@@ -2,11 +2,11 @@ package chroma
type remappingLexer struct {
lexer Lexer
- mapper func(*Token) []*Token
+ mapper func(Token) []Token
}
// RemappingLexer remaps a token to a set of, potentially empty, tokens.
-func RemappingLexer(lexer Lexer, mapper func(*Token) []*Token) Lexer {
+func RemappingLexer(lexer Lexer, mapper func(Token) []Token) Lexer {
return &remappingLexer{lexer, mapper}
}
@@ -19,8 +19,8 @@ func (r *remappingLexer) Tokenise(options *TokeniseOptions, text string) (Iterat
if err != nil {
return nil, err
}
- buffer := []*Token{}
- return func() *Token {
+ var buffer []Token
+ return func() Token {
for {
if len(buffer) > 0 {
t := buffer[0]
@@ -28,7 +28,7 @@ func (r *remappingLexer) Tokenise(options *TokeniseOptions, text string) (Iterat
return t
}
t := it()
- if t == nil {
+ if t == EOF {
return t
}
buffer = r.mapper(t)
@@ -67,7 +67,7 @@ func TypeRemappingLexer(lexer Lexer, mapping TypeMapping) Lexer {
}
}
- return RemappingLexer(lexer, func(t *Token) []*Token {
+ return RemappingLexer(lexer, func(t Token) []Token {
if k, ok := lut[t.Type]; ok {
if tt, ok := k[t.Value]; ok {
t.Type = tt
@@ -75,6 +75,6 @@ func TypeRemappingLexer(lexer Lexer, mapping TypeMapping) Lexer {
t.Type = tt
}
}
- return []*Token{t}
+ return []Token{t}
})
}
diff --git a/vendor/github.com/alecthomas/chroma/tokentype_string.go b/vendor/github.com/alecthomas/chroma/tokentype_string.go
index 44135dc99..92ebb9cd9 100644
--- a/vendor/github.com/alecthomas/chroma/tokentype_string.go
+++ b/vendor/github.com/alecthomas/chroma/tokentype_string.go
@@ -2,9 +2,9 @@
package chroma
-import "fmt"
+import "strconv"
-const _TokenType_name = "NoneOtherErrorLineTableTDLineTableLineHighlightLineNumbersTableLineNumbersBackgroundKeywordKeywordConstantKeywordDeclarationKeywordNamespaceKeywordPseudoKeywordReservedKeywordTypeNameNameAttributeNameBuiltinNameBuiltinPseudoNameClassNameConstantNameDecoratorNameEntityNameExceptionNameFunctionNameFunctionMagicNameKeywordNameLabelNameNamespaceNameOperatorNameOtherNamePseudoNamePropertyNameTagNameVariableNameVariableAnonymousNameVariableClassNameVariableGlobalNameVariableInstanceNameVariableMagicLiteralLiteralDateLiteralOtherLiteralStringLiteralStringAffixLiteralStringAtomLiteralStringBacktickLiteralStringBooleanLiteralStringCharLiteralStringDelimiterLiteralStringDocLiteralStringDoubleLiteralStringEscapeLiteralStringHeredocLiteralStringInterpolLiteralStringNameLiteralStringOtherLiteralStringRegexLiteralStringSingleLiteralStringSymbolLiteralNumberLiteralNumberBinLiteralNumberFloatLiteralNumberHexLiteralNumberIntegerLiteralNumberIntegerLongLiteralNumberOctOperatorOperatorWordPunctuationCommentCommentHashbangCommentMultilineCommentSingleCommentSpecialCommentPreprocCommentPreprocFileGenericGenericDeletedGenericEmphGenericErrorGenericHeadingGenericInsertedGenericOutputGenericPromptGenericStrongGenericSubheadingGenericTracebackGenericUnderlineTextTextWhitespaceTextSymbolTextPunctuation"
+const _TokenType_name = "NoneOtherErrorLineTableTDLineTableLineHighlightLineNumbersTableLineNumbersBackgroundEOFTypeKeywordKeywordConstantKeywordDeclarationKeywordNamespaceKeywordPseudoKeywordReservedKeywordTypeNameNameAttributeNameBuiltinNameBuiltinPseudoNameClassNameConstantNameDecoratorNameEntityNameExceptionNameFunctionNameFunctionMagicNameKeywordNameLabelNameNamespaceNameOperatorNameOtherNamePseudoNamePropertyNameTagNameVariableNameVariableAnonymousNameVariableClassNameVariableGlobalNameVariableInstanceNameVariableMagicLiteralLiteralDateLiteralOtherLiteralStringLiteralStringAffixLiteralStringAtomLiteralStringBacktickLiteralStringBooleanLiteralStringCharLiteralStringDelimiterLiteralStringDocLiteralStringDoubleLiteralStringEscapeLiteralStringHeredocLiteralStringInterpolLiteralStringNameLiteralStringOtherLiteralStringRegexLiteralStringSingleLiteralStringSymbolLiteralNumberLiteralNumberBinLiteralNumberFloatLiteralNumberHexLiteralNumberIntegerLiteralNumberIntegerLongLiteralNumberOctOperatorOperatorWordPunctuationCommentCommentHashbangCommentMultilineCommentSingleCommentSpecialCommentPreprocCommentPreprocFileGenericGenericDeletedGenericEmphGenericErrorGenericHeadingGenericInsertedGenericOutputGenericPromptGenericStrongGenericSubheadingGenericTracebackGenericUnderlineTextTextWhitespaceTextSymbolTextPunctuation"
var _TokenType_map = map[TokenType]string{
-9: _TokenType_name[0:4],
@@ -16,96 +16,97 @@ var _TokenType_map = map[TokenType]string{
-3: _TokenType_name[47:63],
-2: _TokenType_name[63:74],
-1: _TokenType_name[74:84],
- 1000: _TokenType_name[84:91],
- 1001: _TokenType_name[91:106],
- 1002: _TokenType_name[106:124],
- 1003: _TokenType_name[124:140],
- 1004: _TokenType_name[140:153],
- 1005: _TokenType_name[153:168],
- 1006: _TokenType_name[168:179],
- 2000: _TokenType_name[179:183],
- 2001: _TokenType_name[183:196],
- 2002: _TokenType_name[196:207],
- 2003: _TokenType_name[207:224],
- 2004: _TokenType_name[224:233],
- 2005: _TokenType_name[233:245],
- 2006: _TokenType_name[245:258],
- 2007: _TokenType_name[258:268],
- 2008: _TokenType_name[268:281],
- 2009: _TokenType_name[281:293],
- 2010: _TokenType_name[293:310],
- 2011: _TokenType_name[310:321],
- 2012: _TokenType_name[321:330],
- 2013: _TokenType_name[330:343],
- 2014: _TokenType_name[343:355],
- 2015: _TokenType_name[355:364],
- 2016: _TokenType_name[364:374],
- 2017: _TokenType_name[374:386],
- 2018: _TokenType_name[386:393],
- 2019: _TokenType_name[393:405],
- 2020: _TokenType_name[405:426],
- 2021: _TokenType_name[426:443],
- 2022: _TokenType_name[443:461],
- 2023: _TokenType_name[461:481],
- 2024: _TokenType_name[481:498],
- 3000: _TokenType_name[498:505],
- 3001: _TokenType_name[505:516],
- 3002: _TokenType_name[516:528],
- 3100: _TokenType_name[528:541],
- 3101: _TokenType_name[541:559],
- 3102: _TokenType_name[559:576],
- 3103: _TokenType_name[576:597],
- 3104: _TokenType_name[597:617],
- 3105: _TokenType_name[617:634],
- 3106: _TokenType_name[634:656],
- 3107: _TokenType_name[656:672],
- 3108: _TokenType_name[672:691],
- 3109: _TokenType_name[691:710],
- 3110: _TokenType_name[710:730],
- 3111: _TokenType_name[730:751],
- 3112: _TokenType_name[751:768],
- 3113: _TokenType_name[768:786],
- 3114: _TokenType_name[786:804],
- 3115: _TokenType_name[804:823],
- 3116: _TokenType_name[823:842],
- 3200: _TokenType_name[842:855],
- 3201: _TokenType_name[855:871],
- 3202: _TokenType_name[871:889],
- 3203: _TokenType_name[889:905],
- 3204: _TokenType_name[905:925],
- 3205: _TokenType_name[925:949],
- 3206: _TokenType_name[949:965],
- 4000: _TokenType_name[965:973],
- 4001: _TokenType_name[973:985],
- 5000: _TokenType_name[985:996],
- 6000: _TokenType_name[996:1003],
- 6001: _TokenType_name[1003:1018],
- 6002: _TokenType_name[1018:1034],
- 6003: _TokenType_name[1034:1047],
- 6004: _TokenType_name[1047:1061],
- 6100: _TokenType_name[1061:1075],
- 6101: _TokenType_name[1075:1093],
- 7000: _TokenType_name[1093:1100],
- 7001: _TokenType_name[1100:1114],
- 7002: _TokenType_name[1114:1125],
- 7003: _TokenType_name[1125:1137],
- 7004: _TokenType_name[1137:1151],
- 7005: _TokenType_name[1151:1166],
- 7006: _TokenType_name[1166:1179],
- 7007: _TokenType_name[1179:1192],
- 7008: _TokenType_name[1192:1205],
- 7009: _TokenType_name[1205:1222],
- 7010: _TokenType_name[1222:1238],
- 7011: _TokenType_name[1238:1254],
- 8000: _TokenType_name[1254:1258],
- 8001: _TokenType_name[1258:1272],
- 8002: _TokenType_name[1272:1282],
- 8003: _TokenType_name[1282:1297],
+ 0: _TokenType_name[84:91],
+ 1000: _TokenType_name[91:98],
+ 1001: _TokenType_name[98:113],
+ 1002: _TokenType_name[113:131],
+ 1003: _TokenType_name[131:147],
+ 1004: _TokenType_name[147:160],
+ 1005: _TokenType_name[160:175],
+ 1006: _TokenType_name[175:186],
+ 2000: _TokenType_name[186:190],
+ 2001: _TokenType_name[190:203],
+ 2002: _TokenType_name[203:214],
+ 2003: _TokenType_name[214:231],
+ 2004: _TokenType_name[231:240],
+ 2005: _TokenType_name[240:252],
+ 2006: _TokenType_name[252:265],
+ 2007: _TokenType_name[265:275],
+ 2008: _TokenType_name[275:288],
+ 2009: _TokenType_name[288:300],
+ 2010: _TokenType_name[300:317],
+ 2011: _TokenType_name[317:328],
+ 2012: _TokenType_name[328:337],
+ 2013: _TokenType_name[337:350],
+ 2014: _TokenType_name[350:362],
+ 2015: _TokenType_name[362:371],
+ 2016: _TokenType_name[371:381],
+ 2017: _TokenType_name[381:393],
+ 2018: _TokenType_name[393:400],
+ 2019: _TokenType_name[400:412],
+ 2020: _TokenType_name[412:433],
+ 2021: _TokenType_name[433:450],
+ 2022: _TokenType_name[450:468],
+ 2023: _TokenType_name[468:488],
+ 2024: _TokenType_name[488:505],
+ 3000: _TokenType_name[505:512],
+ 3001: _TokenType_name[512:523],
+ 3002: _TokenType_name[523:535],
+ 3100: _TokenType_name[535:548],
+ 3101: _TokenType_name[548:566],
+ 3102: _TokenType_name[566:583],
+ 3103: _TokenType_name[583:604],
+ 3104: _TokenType_name[604:624],
+ 3105: _TokenType_name[624:641],
+ 3106: _TokenType_name[641:663],
+ 3107: _TokenType_name[663:679],
+ 3108: _TokenType_name[679:698],
+ 3109: _TokenType_name[698:717],
+ 3110: _TokenType_name[717:737],
+ 3111: _TokenType_name[737:758],
+ 3112: _TokenType_name[758:775],
+ 3113: _TokenType_name[775:793],
+ 3114: _TokenType_name[793:811],
+ 3115: _TokenType_name[811:830],
+ 3116: _TokenType_name[830:849],
+ 3200: _TokenType_name[849:862],
+ 3201: _TokenType_name[862:878],
+ 3202: _TokenType_name[878:896],
+ 3203: _TokenType_name[896:912],
+ 3204: _TokenType_name[912:932],
+ 3205: _TokenType_name[932:956],
+ 3206: _TokenType_name[956:972],
+ 4000: _TokenType_name[972:980],
+ 4001: _TokenType_name[980:992],
+ 5000: _TokenType_name[992:1003],
+ 6000: _TokenType_name[1003:1010],
+ 6001: _TokenType_name[1010:1025],
+ 6002: _TokenType_name[1025:1041],
+ 6003: _TokenType_name[1041:1054],
+ 6004: _TokenType_name[1054:1068],
+ 6100: _TokenType_name[1068:1082],
+ 6101: _TokenType_name[1082:1100],
+ 7000: _TokenType_name[1100:1107],
+ 7001: _TokenType_name[1107:1121],
+ 7002: _TokenType_name[1121:1132],
+ 7003: _TokenType_name[1132:1144],
+ 7004: _TokenType_name[1144:1158],
+ 7005: _TokenType_name[1158:1173],
+ 7006: _TokenType_name[1173:1186],
+ 7007: _TokenType_name[1186:1199],
+ 7008: _TokenType_name[1199:1212],
+ 7009: _TokenType_name[1212:1229],
+ 7010: _TokenType_name[1229:1245],
+ 7011: _TokenType_name[1245:1261],
+ 8000: _TokenType_name[1261:1265],
+ 8001: _TokenType_name[1265:1279],
+ 8002: _TokenType_name[1279:1289],
+ 8003: _TokenType_name[1289:1304],
}
func (i TokenType) String() string {
if str, ok := _TokenType_map[i]; ok {
return str
}
- return fmt.Sprintf("TokenType(%d)", i)
+ return "TokenType(" + strconv.FormatInt(int64(i), 10) + ")"
}
diff --git a/vendor/github.com/alecthomas/chroma/types.go b/vendor/github.com/alecthomas/chroma/types.go
index 0e4a75065..b102f308a 100644
--- a/vendor/github.com/alecthomas/chroma/types.go
+++ b/vendor/github.com/alecthomas/chroma/types.go
@@ -12,7 +12,7 @@ import (
// It is also an Emitter, emitting a single token of itself
type TokenType int
-func (t *TokenType) MarshalJSON() ([]byte, error) { return json.Marshal(t.String()) }
+func (t TokenType) MarshalJSON() ([]byte, error) { return json.Marshal(t.String()) }
func (t *TokenType) UnmarshalJSON(data []byte) error {
key := ""
err := json.Unmarshal(data, &key)
@@ -54,6 +54,8 @@ const (
Other
// No highlighting.
None
+ // Used as an EOF marker / nil token
+ EOFType TokenType = 0
)
// Keywords.
@@ -341,5 +343,5 @@ func (t TokenType) InSubCategory(other TokenType) bool {
}
func (t TokenType) Emit(groups []string, lexer Lexer) Iterator {
- return Literator(&Token{Type: t, Value: groups[0]})
+ return Literator(Token{Type: t, Value: groups[0]})
}
diff --git a/vendor/github.com/btcsuite/btcd/btcec/signature.go b/vendor/github.com/btcsuite/btcd/btcec/signature.go
index a4781b00f..bddb22831 100644
--- a/vendor/github.com/btcsuite/btcd/btcec/signature.go
+++ b/vendor/github.com/btcsuite/btcd/btcec/signature.go
@@ -427,9 +427,7 @@ func signRFC6979(privateKey *PrivateKey, hash []byte) (*Signature, error) {
k := nonceRFC6979(privkey.D, hash)
inv := new(big.Int).ModInverse(k, N)
r, _ := privkey.Curve.ScalarBaseMult(k.Bytes())
- if r.Cmp(N) == 1 {
- r.Sub(r, N)
- }
+ r.Mod(r, N)
if r.Sign() == 0 {
return nil, errors.New("calculated R is zero")
diff --git a/vendor/github.com/fortytw2/leaktest/README.md b/vendor/github.com/fortytw2/leaktest/README.md
index 2ce6c52c5..82822bf0a 100644
--- a/vendor/github.com/fortytw2/leaktest/README.md
+++ b/vendor/github.com/fortytw2/leaktest/README.md
@@ -1,11 +1,10 @@
-Leaktest [](https://travis-ci.org/fortytw2/leaktest) [](https://codecov.io/gh/fortytw2/leaktest) [](https://sourcegraph.com/github.com/fortytw2/leaktest?badge)
-------
+## Leaktest [](https://travis-ci.org/fortytw2/leaktest) [](https://codecov.io/gh/fortytw2/leaktest) [](https://sourcegraph.com/github.com/fortytw2/leaktest?badge) [](http://godoc.org/github.com/fortytw2/leaktest)
-Refactored, tested variant of the goroutine leak detector found in both
+Refactored, tested variant of the goroutine leak detector found in both
`net/http` tests and the `cockroachdb` source tree.
Takes a snapshot of running goroutines at the start of a test, and at the end -
-compares the two and *voila*. Ignores runtime/sys goroutines. Doesn't play nice
+compares the two and _voila_. Ignores runtime/sys goroutines. Doesn't play nice
with `t.Parallel()` right now, but there are plans to do so.
### Installation
@@ -17,7 +16,7 @@ go get -u github.com/fortytw2/leaktest
```
Go 1.5/1.6 need to use the tag `v1.0.0`, as newer versions depend on
-`context.Context`.
+`context.Context`.
### Example
@@ -27,7 +26,7 @@ These tests fail, because they leak a goroutine
// Default "Check" will poll for 5 seconds to check that all
// goroutines are cleaned up
func TestPool(t *testing.T) {
- defer leaktest.Check(t)()
+ defer leaktest.Check(t)()
go func() {
for {
@@ -38,7 +37,7 @@ func TestPool(t *testing.T) {
// Helper function to timeout after X duration
func TestPoolTimeout(t *testing.T) {
- defer leaktest.CheckTimeout(t, time.Second)()
+ defer leaktest.CheckTimeout(t, time.Second)()
go func() {
for {
@@ -50,7 +49,7 @@ func TestPoolTimeout(t *testing.T) {
// Use Go 1.7+ context.Context for cancellation
func TestPoolContext(t *testing.T) {
ctx, _ := context.WithTimeout(context.Background(), time.Second)
- defer leaktest.CheckContext(ctx, t)()
+ defer leaktest.CheckContext(ctx, t)()
go func() {
for {
@@ -60,7 +59,6 @@ func TestPoolContext(t *testing.T) {
}
```
+## LICENSE
-LICENSE
-------
Same BSD-style as Go, see LICENSE
diff --git a/vendor/github.com/fortytw2/leaktest/leaktest.go b/vendor/github.com/fortytw2/leaktest/leaktest.go
index f2dd985eb..219e9307d 100644
--- a/vendor/github.com/fortytw2/leaktest/leaktest.go
+++ b/vendor/github.com/fortytw2/leaktest/leaktest.go
@@ -3,7 +3,7 @@
// license that can be found in the LICENSE file.
// Package leaktest provides tools to detect leaked goroutines in tests.
-// To use it, call "defer util.Check(t)()" at the beginning of each
+// To use it, call "defer leaktest.Check(t)()" at the beginning of each
// test that may use goroutines.
// copied out of the cockroachdb source tree with slight modifications to be
// more re-useable
@@ -41,6 +41,9 @@ func interestingGoroutine(g string) (*goroutine, error) {
}
if stack == "" ||
+ // Ignore HTTP keep alives
+ strings.Contains(stack, ").readLoop(") ||
+ strings.Contains(stack, ").writeLoop(") ||
// Below are the stacks ignored by the upstream leaktest code.
strings.Contains(stack, "testing.Main(") ||
strings.Contains(stack, "testing.(*T).Run(") ||
diff --git a/vendor/github.com/jtolds/gls/stack_tags.go b/vendor/github.com/jtolds/gls/stack_tags.go
index cc95dcd8e..37bbd3347 100644
--- a/vendor/github.com/jtolds/gls/stack_tags.go
+++ b/vendor/github.com/jtolds/gls/stack_tags.go
@@ -51,22 +51,56 @@ func addStackTag(tag uint, context_call func()) {
// these private methods are named this horrendous name so gopherjs support
// is easier. it shouldn't add any runtime cost in non-js builds.
+
+//go:noinline
func github_com_jtolds_gls_markS(tag uint, cb func()) { _m(tag, cb) }
+
+//go:noinline
func github_com_jtolds_gls_mark0(tag uint, cb func()) { _m(tag, cb) }
+
+//go:noinline
func github_com_jtolds_gls_mark1(tag uint, cb func()) { _m(tag, cb) }
+
+//go:noinline
func github_com_jtolds_gls_mark2(tag uint, cb func()) { _m(tag, cb) }
+
+//go:noinline
func github_com_jtolds_gls_mark3(tag uint, cb func()) { _m(tag, cb) }
+
+//go:noinline
func github_com_jtolds_gls_mark4(tag uint, cb func()) { _m(tag, cb) }
+
+//go:noinline
func github_com_jtolds_gls_mark5(tag uint, cb func()) { _m(tag, cb) }
+
+//go:noinline
func github_com_jtolds_gls_mark6(tag uint, cb func()) { _m(tag, cb) }
+
+//go:noinline
func github_com_jtolds_gls_mark7(tag uint, cb func()) { _m(tag, cb) }
+
+//go:noinline
func github_com_jtolds_gls_mark8(tag uint, cb func()) { _m(tag, cb) }
+
+//go:noinline
func github_com_jtolds_gls_mark9(tag uint, cb func()) { _m(tag, cb) }
+
+//go:noinline
func github_com_jtolds_gls_markA(tag uint, cb func()) { _m(tag, cb) }
+
+//go:noinline
func github_com_jtolds_gls_markB(tag uint, cb func()) { _m(tag, cb) }
+
+//go:noinline
func github_com_jtolds_gls_markC(tag uint, cb func()) { _m(tag, cb) }
+
+//go:noinline
func github_com_jtolds_gls_markD(tag uint, cb func()) { _m(tag, cb) }
+
+//go:noinline
func github_com_jtolds_gls_markE(tag uint, cb func()) { _m(tag, cb) }
+
+//go:noinline
func github_com_jtolds_gls_markF(tag uint, cb func()) { _m(tag, cb) }
func _m(tag_remainder uint, cb func()) {
diff --git a/vendor/github.com/juju/errors/error.go b/vendor/github.com/juju/errors/error.go
index d67e33863..169e3a4e3 100644
--- a/vendor/github.com/juju/errors/error.go
+++ b/vendor/github.com/juju/errors/error.go
@@ -143,6 +143,10 @@ func (e *Err) Format(s fmt.State, verb rune) {
fallthrough
case 's':
fmt.Fprintf(s, "%s", e.Error())
+ case 'q':
+ fmt.Fprintf(s, "%q", e.Error())
+ default:
+ fmt.Fprintf(s, "%%!%c(%T=%s)", verb, e, e.Error())
}
}
diff --git a/vendor/github.com/knq/snaker/go.mod b/vendor/github.com/knq/snaker/go.mod
new file mode 100644
index 000000000..1434cd2f1
--- /dev/null
+++ b/vendor/github.com/knq/snaker/go.mod
@@ -0,0 +1 @@
+module github.com/knq/snaker
diff --git a/vendor/github.com/mattn/go-runewidth/runewidth.go b/vendor/github.com/mattn/go-runewidth/runewidth.go
index 82568a1bb..3cb94106f 100644
--- a/vendor/github.com/mattn/go-runewidth/runewidth.go
+++ b/vendor/github.com/mattn/go-runewidth/runewidth.go
@@ -1,22 +1,34 @@
package runewidth
-import "os"
+import (
+ "os"
+)
var (
// EastAsianWidth will be set true if the current locale is CJK
EastAsianWidth bool
+ // ZeroWidthJoiner is flag to set to use UTR#51 ZWJ
+ ZeroWidthJoiner bool
+
// DefaultCondition is a condition in current locale
- DefaultCondition = &Condition{EastAsianWidth}
+ DefaultCondition = &Condition{}
)
func init() {
+ handleEnv()
+}
+
+func handleEnv() {
env := os.Getenv("RUNEWIDTH_EASTASIAN")
if env == "" {
EastAsianWidth = IsEastAsian()
} else {
EastAsianWidth = env == "1"
}
+ // update DefaultCondition
+ DefaultCondition.EastAsianWidth = EastAsianWidth
+ DefaultCondition.ZeroWidthJoiner = ZeroWidthJoiner
}
type interval struct {
@@ -44,7 +56,7 @@ func inTable(r rune, t table) bool {
bot := 0
top := len(t) - 1
for top >= bot {
- mid := (bot + top) / 2
+ mid := (bot + top) >> 1
switch {
case t[mid].last < r:
@@ -66,8 +78,7 @@ var private = table{
var nonprint = table{
{0x0000, 0x001F}, {0x007F, 0x009F}, {0x00AD, 0x00AD},
{0x070F, 0x070F}, {0x180B, 0x180E}, {0x200B, 0x200F},
- {0x2028, 0x2029},
- {0x202A, 0x202E}, {0x206A, 0x206F}, {0xD800, 0xDFFF},
+ {0x2028, 0x202E}, {0x206A, 0x206F}, {0xD800, 0xDFFF},
{0xFEFF, 0xFEFF}, {0xFFF9, 0xFFFB}, {0xFFFE, 0xFFFF},
}
@@ -261,19 +272,54 @@ var ambiguous = table{
}
var emoji = table{
- {0x1F1E6, 0x1F1FF}, {0x1F321, 0x1F321}, {0x1F324, 0x1F32C},
- {0x1F336, 0x1F336}, {0x1F37D, 0x1F37D}, {0x1F396, 0x1F397},
- {0x1F399, 0x1F39B}, {0x1F39E, 0x1F39F}, {0x1F3CB, 0x1F3CE},
- {0x1F3D4, 0x1F3DF}, {0x1F3F3, 0x1F3F5}, {0x1F3F7, 0x1F3F7},
- {0x1F43F, 0x1F43F}, {0x1F441, 0x1F441}, {0x1F4FD, 0x1F4FD},
- {0x1F549, 0x1F54A}, {0x1F56F, 0x1F570}, {0x1F573, 0x1F579},
+ {0x203C, 0x203C}, {0x2049, 0x2049}, {0x2122, 0x2122},
+ {0x2139, 0x2139}, {0x2194, 0x2199}, {0x21A9, 0x21AA},
+ {0x231A, 0x231B}, {0x2328, 0x2328}, {0x23CF, 0x23CF},
+ {0x23E9, 0x23F3}, {0x23F8, 0x23FA}, {0x24C2, 0x24C2},
+ {0x25AA, 0x25AB}, {0x25B6, 0x25B6}, {0x25C0, 0x25C0},
+ {0x25FB, 0x25FE}, {0x2600, 0x2604}, {0x260E, 0x260E},
+ {0x2611, 0x2611}, {0x2614, 0x2615}, {0x2618, 0x2618},
+ {0x261D, 0x261D}, {0x2620, 0x2620}, {0x2622, 0x2623},
+ {0x2626, 0x2626}, {0x262A, 0x262A}, {0x262E, 0x262F},
+ {0x2638, 0x263A}, {0x2640, 0x2640}, {0x2642, 0x2642},
+ {0x2648, 0x2653}, {0x265F, 0x2660}, {0x2663, 0x2663},
+ {0x2665, 0x2666}, {0x2668, 0x2668}, {0x267B, 0x267B},
+ {0x267E, 0x267F}, {0x2692, 0x2697}, {0x2699, 0x2699},
+ {0x269B, 0x269C}, {0x26A0, 0x26A1}, {0x26AA, 0x26AB},
+ {0x26B0, 0x26B1}, {0x26BD, 0x26BE}, {0x26C4, 0x26C5},
+ {0x26C8, 0x26C8}, {0x26CE, 0x26CF}, {0x26D1, 0x26D1},
+ {0x26D3, 0x26D4}, {0x26E9, 0x26EA}, {0x26F0, 0x26F5},
+ {0x26F7, 0x26FA}, {0x26FD, 0x26FD}, {0x2702, 0x2702},
+ {0x2705, 0x2705}, {0x2708, 0x270D}, {0x270F, 0x270F},
+ {0x2712, 0x2712}, {0x2714, 0x2714}, {0x2716, 0x2716},
+ {0x271D, 0x271D}, {0x2721, 0x2721}, {0x2728, 0x2728},
+ {0x2733, 0x2734}, {0x2744, 0x2744}, {0x2747, 0x2747},
+ {0x274C, 0x274C}, {0x274E, 0x274E}, {0x2753, 0x2755},
+ {0x2757, 0x2757}, {0x2763, 0x2764}, {0x2795, 0x2797},
+ {0x27A1, 0x27A1}, {0x27B0, 0x27B0}, {0x27BF, 0x27BF},
+ {0x2934, 0x2935}, {0x2B05, 0x2B07}, {0x2B1B, 0x2B1C},
+ {0x2B50, 0x2B50}, {0x2B55, 0x2B55}, {0x3030, 0x3030},
+ {0x303D, 0x303D}, {0x3297, 0x3297}, {0x3299, 0x3299},
+ {0x1F004, 0x1F004}, {0x1F0CF, 0x1F0CF}, {0x1F170, 0x1F171},
+ {0x1F17E, 0x1F17F}, {0x1F18E, 0x1F18E}, {0x1F191, 0x1F19A},
+ {0x1F1E6, 0x1F1FF}, {0x1F201, 0x1F202}, {0x1F21A, 0x1F21A},
+ {0x1F22F, 0x1F22F}, {0x1F232, 0x1F23A}, {0x1F250, 0x1F251},
+ {0x1F300, 0x1F321}, {0x1F324, 0x1F393}, {0x1F396, 0x1F397},
+ {0x1F399, 0x1F39B}, {0x1F39E, 0x1F3F0}, {0x1F3F3, 0x1F3F5},
+ {0x1F3F7, 0x1F4FD}, {0x1F4FF, 0x1F53D}, {0x1F549, 0x1F54E},
+ {0x1F550, 0x1F567}, {0x1F56F, 0x1F570}, {0x1F573, 0x1F57A},
{0x1F587, 0x1F587}, {0x1F58A, 0x1F58D}, {0x1F590, 0x1F590},
- {0x1F5A5, 0x1F5A5}, {0x1F5A8, 0x1F5A8}, {0x1F5B1, 0x1F5B2},
- {0x1F5BC, 0x1F5BC}, {0x1F5C2, 0x1F5C4}, {0x1F5D1, 0x1F5D3},
- {0x1F5DC, 0x1F5DE}, {0x1F5E1, 0x1F5E1}, {0x1F5E3, 0x1F5E3},
- {0x1F5E8, 0x1F5E8}, {0x1F5EF, 0x1F5EF}, {0x1F5F3, 0x1F5F3},
- {0x1F5FA, 0x1F5FA}, {0x1F6CB, 0x1F6CF}, {0x1F6E0, 0x1F6E5},
- {0x1F6E9, 0x1F6E9}, {0x1F6F0, 0x1F6F0}, {0x1F6F3, 0x1F6F3},
+ {0x1F595, 0x1F596}, {0x1F5A4, 0x1F5A5}, {0x1F5A8, 0x1F5A8},
+ {0x1F5B1, 0x1F5B2}, {0x1F5BC, 0x1F5BC}, {0x1F5C2, 0x1F5C4},
+ {0x1F5D1, 0x1F5D3}, {0x1F5DC, 0x1F5DE}, {0x1F5E1, 0x1F5E1},
+ {0x1F5E3, 0x1F5E3}, {0x1F5E8, 0x1F5E8}, {0x1F5EF, 0x1F5EF},
+ {0x1F5F3, 0x1F5F3}, {0x1F5FA, 0x1F64F}, {0x1F680, 0x1F6C5},
+ {0x1F6CB, 0x1F6D2}, {0x1F6E0, 0x1F6E5}, {0x1F6E9, 0x1F6E9},
+ {0x1F6EB, 0x1F6EC}, {0x1F6F0, 0x1F6F0}, {0x1F6F3, 0x1F6F9},
+ {0x1F910, 0x1F93A}, {0x1F93C, 0x1F93E}, {0x1F940, 0x1F945},
+ {0x1F947, 0x1F970}, {0x1F973, 0x1F976}, {0x1F97A, 0x1F97A},
+ {0x1F97C, 0x1F9A2}, {0x1F9B0, 0x1F9B9}, {0x1F9C0, 0x1F9C2},
+ {0x1F9D0, 0x1F9FF},
}
var notassigned = table{
@@ -493,314 +539,141 @@ var notassigned = table{
}
var neutral = table{
- {0x0000, 0x001F}, {0x007F, 0x007F}, {0x0080, 0x009F},
- {0x00A0, 0x00A0}, {0x00A9, 0x00A9}, {0x00AB, 0x00AB},
- {0x00B5, 0x00B5}, {0x00BB, 0x00BB}, {0x00C0, 0x00C5},
- {0x00C7, 0x00CF}, {0x00D1, 0x00D6}, {0x00D9, 0x00DD},
- {0x00E2, 0x00E5}, {0x00E7, 0x00E7}, {0x00EB, 0x00EB},
- {0x00EE, 0x00EF}, {0x00F1, 0x00F1}, {0x00F4, 0x00F6},
- {0x00FB, 0x00FB}, {0x00FD, 0x00FD}, {0x00FF, 0x00FF},
- {0x0100, 0x0100}, {0x0102, 0x0110}, {0x0112, 0x0112},
+ {0x0000, 0x001F}, {0x007F, 0x00A0}, {0x00A9, 0x00A9},
+ {0x00AB, 0x00AB}, {0x00B5, 0x00B5}, {0x00BB, 0x00BB},
+ {0x00C0, 0x00C5}, {0x00C7, 0x00CF}, {0x00D1, 0x00D6},
+ {0x00D9, 0x00DD}, {0x00E2, 0x00E5}, {0x00E7, 0x00E7},
+ {0x00EB, 0x00EB}, {0x00EE, 0x00EF}, {0x00F1, 0x00F1},
+ {0x00F4, 0x00F6}, {0x00FB, 0x00FB}, {0x00FD, 0x00FD},
+ {0x00FF, 0x0100}, {0x0102, 0x0110}, {0x0112, 0x0112},
{0x0114, 0x011A}, {0x011C, 0x0125}, {0x0128, 0x012A},
{0x012C, 0x0130}, {0x0134, 0x0137}, {0x0139, 0x013E},
{0x0143, 0x0143}, {0x0145, 0x0147}, {0x014C, 0x014C},
{0x014E, 0x0151}, {0x0154, 0x0165}, {0x0168, 0x016A},
- {0x016C, 0x017F}, {0x0180, 0x01BA}, {0x01BB, 0x01BB},
- {0x01BC, 0x01BF}, {0x01C0, 0x01C3}, {0x01C4, 0x01CD},
- {0x01CF, 0x01CF}, {0x01D1, 0x01D1}, {0x01D3, 0x01D3},
- {0x01D5, 0x01D5}, {0x01D7, 0x01D7}, {0x01D9, 0x01D9},
- {0x01DB, 0x01DB}, {0x01DD, 0x024F}, {0x0250, 0x0250},
- {0x0252, 0x0260}, {0x0262, 0x0293}, {0x0294, 0x0294},
- {0x0295, 0x02AF}, {0x02B0, 0x02C1}, {0x02C2, 0x02C3},
- {0x02C5, 0x02C5}, {0x02C6, 0x02C6}, {0x02C8, 0x02C8},
- {0x02CC, 0x02CC}, {0x02CE, 0x02CF}, {0x02D1, 0x02D1},
- {0x02D2, 0x02D7}, {0x02DC, 0x02DC}, {0x02DE, 0x02DE},
- {0x02E0, 0x02E4}, {0x02E5, 0x02EB}, {0x02EC, 0x02EC},
- {0x02ED, 0x02ED}, {0x02EE, 0x02EE}, {0x02EF, 0x02FF},
- {0x0370, 0x0373}, {0x0374, 0x0374}, {0x0375, 0x0375},
- {0x0376, 0x0377}, {0x037A, 0x037A}, {0x037B, 0x037D},
- {0x037E, 0x037E}, {0x037F, 0x037F}, {0x0384, 0x0385},
- {0x0386, 0x0386}, {0x0387, 0x0387}, {0x0388, 0x038A},
- {0x038C, 0x038C}, {0x038E, 0x0390}, {0x03AA, 0x03B0},
- {0x03C2, 0x03C2}, {0x03CA, 0x03F5}, {0x03F6, 0x03F6},
- {0x03F7, 0x03FF}, {0x0400, 0x0400}, {0x0402, 0x040F},
- {0x0450, 0x0450}, {0x0452, 0x0481}, {0x0482, 0x0482},
- {0x0483, 0x0487}, {0x0488, 0x0489}, {0x048A, 0x04FF},
- {0x0500, 0x052F}, {0x0531, 0x0556}, {0x0559, 0x0559},
- {0x055A, 0x055F}, {0x0561, 0x0587}, {0x0589, 0x0589},
- {0x058A, 0x058A}, {0x058D, 0x058E}, {0x058F, 0x058F},
- {0x0591, 0x05BD}, {0x05BE, 0x05BE}, {0x05BF, 0x05BF},
- {0x05C0, 0x05C0}, {0x05C1, 0x05C2}, {0x05C3, 0x05C3},
- {0x05C4, 0x05C5}, {0x05C6, 0x05C6}, {0x05C7, 0x05C7},
- {0x05D0, 0x05EA}, {0x05F0, 0x05F2}, {0x05F3, 0x05F4},
- {0x0600, 0x0605}, {0x0606, 0x0608}, {0x0609, 0x060A},
- {0x060B, 0x060B}, {0x060C, 0x060D}, {0x060E, 0x060F},
- {0x0610, 0x061A}, {0x061B, 0x061B}, {0x061C, 0x061C},
- {0x061E, 0x061F}, {0x0620, 0x063F}, {0x0640, 0x0640},
- {0x0641, 0x064A}, {0x064B, 0x065F}, {0x0660, 0x0669},
- {0x066A, 0x066D}, {0x066E, 0x066F}, {0x0670, 0x0670},
- {0x0671, 0x06D3}, {0x06D4, 0x06D4}, {0x06D5, 0x06D5},
- {0x06D6, 0x06DC}, {0x06DD, 0x06DD}, {0x06DE, 0x06DE},
- {0x06DF, 0x06E4}, {0x06E5, 0x06E6}, {0x06E7, 0x06E8},
- {0x06E9, 0x06E9}, {0x06EA, 0x06ED}, {0x06EE, 0x06EF},
- {0x06F0, 0x06F9}, {0x06FA, 0x06FC}, {0x06FD, 0x06FE},
- {0x06FF, 0x06FF}, {0x0700, 0x070D}, {0x070F, 0x070F},
- {0x0710, 0x0710}, {0x0711, 0x0711}, {0x0712, 0x072F},
- {0x0730, 0x074A}, {0x074D, 0x074F}, {0x0750, 0x077F},
- {0x0780, 0x07A5}, {0x07A6, 0x07B0}, {0x07B1, 0x07B1},
- {0x07C0, 0x07C9}, {0x07CA, 0x07EA}, {0x07EB, 0x07F3},
- {0x07F4, 0x07F5}, {0x07F6, 0x07F6}, {0x07F7, 0x07F9},
- {0x07FA, 0x07FA}, {0x0800, 0x0815}, {0x0816, 0x0819},
- {0x081A, 0x081A}, {0x081B, 0x0823}, {0x0824, 0x0824},
- {0x0825, 0x0827}, {0x0828, 0x0828}, {0x0829, 0x082D},
- {0x0830, 0x083E}, {0x0840, 0x0858}, {0x0859, 0x085B},
- {0x085E, 0x085E}, {0x08A0, 0x08B4}, {0x08B6, 0x08BD},
- {0x08D4, 0x08E1}, {0x08E2, 0x08E2}, {0x08E3, 0x08FF},
- {0x0900, 0x0902}, {0x0903, 0x0903}, {0x0904, 0x0939},
- {0x093A, 0x093A}, {0x093B, 0x093B}, {0x093C, 0x093C},
- {0x093D, 0x093D}, {0x093E, 0x0940}, {0x0941, 0x0948},
- {0x0949, 0x094C}, {0x094D, 0x094D}, {0x094E, 0x094F},
- {0x0950, 0x0950}, {0x0951, 0x0957}, {0x0958, 0x0961},
- {0x0962, 0x0963}, {0x0964, 0x0965}, {0x0966, 0x096F},
- {0x0970, 0x0970}, {0x0971, 0x0971}, {0x0972, 0x097F},
- {0x0980, 0x0980}, {0x0981, 0x0981}, {0x0982, 0x0983},
- {0x0985, 0x098C}, {0x098F, 0x0990}, {0x0993, 0x09A8},
- {0x09AA, 0x09B0}, {0x09B2, 0x09B2}, {0x09B6, 0x09B9},
- {0x09BC, 0x09BC}, {0x09BD, 0x09BD}, {0x09BE, 0x09C0},
- {0x09C1, 0x09C4}, {0x09C7, 0x09C8}, {0x09CB, 0x09CC},
- {0x09CD, 0x09CD}, {0x09CE, 0x09CE}, {0x09D7, 0x09D7},
- {0x09DC, 0x09DD}, {0x09DF, 0x09E1}, {0x09E2, 0x09E3},
- {0x09E6, 0x09EF}, {0x09F0, 0x09F1}, {0x09F2, 0x09F3},
- {0x09F4, 0x09F9}, {0x09FA, 0x09FA}, {0x09FB, 0x09FB},
- {0x0A01, 0x0A02}, {0x0A03, 0x0A03}, {0x0A05, 0x0A0A},
- {0x0A0F, 0x0A10}, {0x0A13, 0x0A28}, {0x0A2A, 0x0A30},
- {0x0A32, 0x0A33}, {0x0A35, 0x0A36}, {0x0A38, 0x0A39},
- {0x0A3C, 0x0A3C}, {0x0A3E, 0x0A40}, {0x0A41, 0x0A42},
- {0x0A47, 0x0A48}, {0x0A4B, 0x0A4D}, {0x0A51, 0x0A51},
- {0x0A59, 0x0A5C}, {0x0A5E, 0x0A5E}, {0x0A66, 0x0A6F},
- {0x0A70, 0x0A71}, {0x0A72, 0x0A74}, {0x0A75, 0x0A75},
- {0x0A81, 0x0A82}, {0x0A83, 0x0A83}, {0x0A85, 0x0A8D},
+ {0x016C, 0x01CD}, {0x01CF, 0x01CF}, {0x01D1, 0x01D1},
+ {0x01D3, 0x01D3}, {0x01D5, 0x01D5}, {0x01D7, 0x01D7},
+ {0x01D9, 0x01D9}, {0x01DB, 0x01DB}, {0x01DD, 0x0250},
+ {0x0252, 0x0260}, {0x0262, 0x02C3}, {0x02C5, 0x02C6},
+ {0x02C8, 0x02C8}, {0x02CC, 0x02CC}, {0x02CE, 0x02CF},
+ {0x02D1, 0x02D7}, {0x02DC, 0x02DC}, {0x02DE, 0x02DE},
+ {0x02E0, 0x02FF}, {0x0370, 0x0377}, {0x037A, 0x037F},
+ {0x0384, 0x038A}, {0x038C, 0x038C}, {0x038E, 0x0390},
+ {0x03AA, 0x03B0}, {0x03C2, 0x03C2}, {0x03CA, 0x0400},
+ {0x0402, 0x040F}, {0x0450, 0x0450}, {0x0452, 0x052F},
+ {0x0531, 0x0556}, {0x0559, 0x055F}, {0x0561, 0x0587},
+ {0x0589, 0x058A}, {0x058D, 0x058F}, {0x0591, 0x05C7},
+ {0x05D0, 0x05EA}, {0x05F0, 0x05F4}, {0x0600, 0x061C},
+ {0x061E, 0x070D}, {0x070F, 0x074A}, {0x074D, 0x07B1},
+ {0x07C0, 0x07FA}, {0x0800, 0x082D}, {0x0830, 0x083E},
+ {0x0840, 0x085B}, {0x085E, 0x085E}, {0x08A0, 0x08B4},
+ {0x08B6, 0x08BD}, {0x08D4, 0x0983}, {0x0985, 0x098C},
+ {0x098F, 0x0990}, {0x0993, 0x09A8}, {0x09AA, 0x09B0},
+ {0x09B2, 0x09B2}, {0x09B6, 0x09B9}, {0x09BC, 0x09C4},
+ {0x09C7, 0x09C8}, {0x09CB, 0x09CE}, {0x09D7, 0x09D7},
+ {0x09DC, 0x09DD}, {0x09DF, 0x09E3}, {0x09E6, 0x09FB},
+ {0x0A01, 0x0A03}, {0x0A05, 0x0A0A}, {0x0A0F, 0x0A10},
+ {0x0A13, 0x0A28}, {0x0A2A, 0x0A30}, {0x0A32, 0x0A33},
+ {0x0A35, 0x0A36}, {0x0A38, 0x0A39}, {0x0A3C, 0x0A3C},
+ {0x0A3E, 0x0A42}, {0x0A47, 0x0A48}, {0x0A4B, 0x0A4D},
+ {0x0A51, 0x0A51}, {0x0A59, 0x0A5C}, {0x0A5E, 0x0A5E},
+ {0x0A66, 0x0A75}, {0x0A81, 0x0A83}, {0x0A85, 0x0A8D},
{0x0A8F, 0x0A91}, {0x0A93, 0x0AA8}, {0x0AAA, 0x0AB0},
- {0x0AB2, 0x0AB3}, {0x0AB5, 0x0AB9}, {0x0ABC, 0x0ABC},
- {0x0ABD, 0x0ABD}, {0x0ABE, 0x0AC0}, {0x0AC1, 0x0AC5},
- {0x0AC7, 0x0AC8}, {0x0AC9, 0x0AC9}, {0x0ACB, 0x0ACC},
- {0x0ACD, 0x0ACD}, {0x0AD0, 0x0AD0}, {0x0AE0, 0x0AE1},
- {0x0AE2, 0x0AE3}, {0x0AE6, 0x0AEF}, {0x0AF0, 0x0AF0},
- {0x0AF1, 0x0AF1}, {0x0AF9, 0x0AF9}, {0x0B01, 0x0B01},
- {0x0B02, 0x0B03}, {0x0B05, 0x0B0C}, {0x0B0F, 0x0B10},
+ {0x0AB2, 0x0AB3}, {0x0AB5, 0x0AB9}, {0x0ABC, 0x0AC5},
+ {0x0AC7, 0x0AC9}, {0x0ACB, 0x0ACD}, {0x0AD0, 0x0AD0},
+ {0x0AE0, 0x0AE3}, {0x0AE6, 0x0AF1}, {0x0AF9, 0x0AF9},
+ {0x0B01, 0x0B03}, {0x0B05, 0x0B0C}, {0x0B0F, 0x0B10},
{0x0B13, 0x0B28}, {0x0B2A, 0x0B30}, {0x0B32, 0x0B33},
- {0x0B35, 0x0B39}, {0x0B3C, 0x0B3C}, {0x0B3D, 0x0B3D},
- {0x0B3E, 0x0B3E}, {0x0B3F, 0x0B3F}, {0x0B40, 0x0B40},
- {0x0B41, 0x0B44}, {0x0B47, 0x0B48}, {0x0B4B, 0x0B4C},
- {0x0B4D, 0x0B4D}, {0x0B56, 0x0B56}, {0x0B57, 0x0B57},
- {0x0B5C, 0x0B5D}, {0x0B5F, 0x0B61}, {0x0B62, 0x0B63},
- {0x0B66, 0x0B6F}, {0x0B70, 0x0B70}, {0x0B71, 0x0B71},
- {0x0B72, 0x0B77}, {0x0B82, 0x0B82}, {0x0B83, 0x0B83},
+ {0x0B35, 0x0B39}, {0x0B3C, 0x0B44}, {0x0B47, 0x0B48},
+ {0x0B4B, 0x0B4D}, {0x0B56, 0x0B57}, {0x0B5C, 0x0B5D},
+ {0x0B5F, 0x0B63}, {0x0B66, 0x0B77}, {0x0B82, 0x0B83},
{0x0B85, 0x0B8A}, {0x0B8E, 0x0B90}, {0x0B92, 0x0B95},
{0x0B99, 0x0B9A}, {0x0B9C, 0x0B9C}, {0x0B9E, 0x0B9F},
{0x0BA3, 0x0BA4}, {0x0BA8, 0x0BAA}, {0x0BAE, 0x0BB9},
- {0x0BBE, 0x0BBF}, {0x0BC0, 0x0BC0}, {0x0BC1, 0x0BC2},
- {0x0BC6, 0x0BC8}, {0x0BCA, 0x0BCC}, {0x0BCD, 0x0BCD},
- {0x0BD0, 0x0BD0}, {0x0BD7, 0x0BD7}, {0x0BE6, 0x0BEF},
- {0x0BF0, 0x0BF2}, {0x0BF3, 0x0BF8}, {0x0BF9, 0x0BF9},
- {0x0BFA, 0x0BFA}, {0x0C00, 0x0C00}, {0x0C01, 0x0C03},
- {0x0C05, 0x0C0C}, {0x0C0E, 0x0C10}, {0x0C12, 0x0C28},
- {0x0C2A, 0x0C39}, {0x0C3D, 0x0C3D}, {0x0C3E, 0x0C40},
- {0x0C41, 0x0C44}, {0x0C46, 0x0C48}, {0x0C4A, 0x0C4D},
- {0x0C55, 0x0C56}, {0x0C58, 0x0C5A}, {0x0C60, 0x0C61},
- {0x0C62, 0x0C63}, {0x0C66, 0x0C6F}, {0x0C78, 0x0C7E},
- {0x0C7F, 0x0C7F}, {0x0C80, 0x0C80}, {0x0C81, 0x0C81},
- {0x0C82, 0x0C83}, {0x0C85, 0x0C8C}, {0x0C8E, 0x0C90},
+ {0x0BBE, 0x0BC2}, {0x0BC6, 0x0BC8}, {0x0BCA, 0x0BCD},
+ {0x0BD0, 0x0BD0}, {0x0BD7, 0x0BD7}, {0x0BE6, 0x0BFA},
+ {0x0C00, 0x0C03}, {0x0C05, 0x0C0C}, {0x0C0E, 0x0C10},
+ {0x0C12, 0x0C28}, {0x0C2A, 0x0C39}, {0x0C3D, 0x0C44},
+ {0x0C46, 0x0C48}, {0x0C4A, 0x0C4D}, {0x0C55, 0x0C56},
+ {0x0C58, 0x0C5A}, {0x0C60, 0x0C63}, {0x0C66, 0x0C6F},
+ {0x0C78, 0x0C83}, {0x0C85, 0x0C8C}, {0x0C8E, 0x0C90},
{0x0C92, 0x0CA8}, {0x0CAA, 0x0CB3}, {0x0CB5, 0x0CB9},
- {0x0CBC, 0x0CBC}, {0x0CBD, 0x0CBD}, {0x0CBE, 0x0CBE},
- {0x0CBF, 0x0CBF}, {0x0CC0, 0x0CC4}, {0x0CC6, 0x0CC6},
- {0x0CC7, 0x0CC8}, {0x0CCA, 0x0CCB}, {0x0CCC, 0x0CCD},
- {0x0CD5, 0x0CD6}, {0x0CDE, 0x0CDE}, {0x0CE0, 0x0CE1},
- {0x0CE2, 0x0CE3}, {0x0CE6, 0x0CEF}, {0x0CF1, 0x0CF2},
- {0x0D01, 0x0D01}, {0x0D02, 0x0D03}, {0x0D05, 0x0D0C},
- {0x0D0E, 0x0D10}, {0x0D12, 0x0D3A}, {0x0D3D, 0x0D3D},
- {0x0D3E, 0x0D40}, {0x0D41, 0x0D44}, {0x0D46, 0x0D48},
- {0x0D4A, 0x0D4C}, {0x0D4D, 0x0D4D}, {0x0D4E, 0x0D4E},
- {0x0D4F, 0x0D4F}, {0x0D54, 0x0D56}, {0x0D57, 0x0D57},
- {0x0D58, 0x0D5E}, {0x0D5F, 0x0D61}, {0x0D62, 0x0D63},
- {0x0D66, 0x0D6F}, {0x0D70, 0x0D78}, {0x0D79, 0x0D79},
- {0x0D7A, 0x0D7F}, {0x0D82, 0x0D83}, {0x0D85, 0x0D96},
- {0x0D9A, 0x0DB1}, {0x0DB3, 0x0DBB}, {0x0DBD, 0x0DBD},
- {0x0DC0, 0x0DC6}, {0x0DCA, 0x0DCA}, {0x0DCF, 0x0DD1},
- {0x0DD2, 0x0DD4}, {0x0DD6, 0x0DD6}, {0x0DD8, 0x0DDF},
- {0x0DE6, 0x0DEF}, {0x0DF2, 0x0DF3}, {0x0DF4, 0x0DF4},
- {0x0E01, 0x0E30}, {0x0E31, 0x0E31}, {0x0E32, 0x0E33},
- {0x0E34, 0x0E3A}, {0x0E3F, 0x0E3F}, {0x0E40, 0x0E45},
- {0x0E46, 0x0E46}, {0x0E47, 0x0E4E}, {0x0E4F, 0x0E4F},
- {0x0E50, 0x0E59}, {0x0E5A, 0x0E5B}, {0x0E81, 0x0E82},
- {0x0E84, 0x0E84}, {0x0E87, 0x0E88}, {0x0E8A, 0x0E8A},
- {0x0E8D, 0x0E8D}, {0x0E94, 0x0E97}, {0x0E99, 0x0E9F},
- {0x0EA1, 0x0EA3}, {0x0EA5, 0x0EA5}, {0x0EA7, 0x0EA7},
- {0x0EAA, 0x0EAB}, {0x0EAD, 0x0EB0}, {0x0EB1, 0x0EB1},
- {0x0EB2, 0x0EB3}, {0x0EB4, 0x0EB9}, {0x0EBB, 0x0EBC},
- {0x0EBD, 0x0EBD}, {0x0EC0, 0x0EC4}, {0x0EC6, 0x0EC6},
- {0x0EC8, 0x0ECD}, {0x0ED0, 0x0ED9}, {0x0EDC, 0x0EDF},
- {0x0F00, 0x0F00}, {0x0F01, 0x0F03}, {0x0F04, 0x0F12},
- {0x0F13, 0x0F13}, {0x0F14, 0x0F14}, {0x0F15, 0x0F17},
- {0x0F18, 0x0F19}, {0x0F1A, 0x0F1F}, {0x0F20, 0x0F29},
- {0x0F2A, 0x0F33}, {0x0F34, 0x0F34}, {0x0F35, 0x0F35},
- {0x0F36, 0x0F36}, {0x0F37, 0x0F37}, {0x0F38, 0x0F38},
- {0x0F39, 0x0F39}, {0x0F3A, 0x0F3A}, {0x0F3B, 0x0F3B},
- {0x0F3C, 0x0F3C}, {0x0F3D, 0x0F3D}, {0x0F3E, 0x0F3F},
- {0x0F40, 0x0F47}, {0x0F49, 0x0F6C}, {0x0F71, 0x0F7E},
- {0x0F7F, 0x0F7F}, {0x0F80, 0x0F84}, {0x0F85, 0x0F85},
- {0x0F86, 0x0F87}, {0x0F88, 0x0F8C}, {0x0F8D, 0x0F97},
- {0x0F99, 0x0FBC}, {0x0FBE, 0x0FC5}, {0x0FC6, 0x0FC6},
- {0x0FC7, 0x0FCC}, {0x0FCE, 0x0FCF}, {0x0FD0, 0x0FD4},
- {0x0FD5, 0x0FD8}, {0x0FD9, 0x0FDA}, {0x1000, 0x102A},
- {0x102B, 0x102C}, {0x102D, 0x1030}, {0x1031, 0x1031},
- {0x1032, 0x1037}, {0x1038, 0x1038}, {0x1039, 0x103A},
- {0x103B, 0x103C}, {0x103D, 0x103E}, {0x103F, 0x103F},
- {0x1040, 0x1049}, {0x104A, 0x104F}, {0x1050, 0x1055},
- {0x1056, 0x1057}, {0x1058, 0x1059}, {0x105A, 0x105D},
- {0x105E, 0x1060}, {0x1061, 0x1061}, {0x1062, 0x1064},
- {0x1065, 0x1066}, {0x1067, 0x106D}, {0x106E, 0x1070},
- {0x1071, 0x1074}, {0x1075, 0x1081}, {0x1082, 0x1082},
- {0x1083, 0x1084}, {0x1085, 0x1086}, {0x1087, 0x108C},
- {0x108D, 0x108D}, {0x108E, 0x108E}, {0x108F, 0x108F},
- {0x1090, 0x1099}, {0x109A, 0x109C}, {0x109D, 0x109D},
- {0x109E, 0x109F}, {0x10A0, 0x10C5}, {0x10C7, 0x10C7},
- {0x10CD, 0x10CD}, {0x10D0, 0x10FA}, {0x10FB, 0x10FB},
- {0x10FC, 0x10FC}, {0x10FD, 0x10FF}, {0x1160, 0x11FF},
- {0x1200, 0x1248}, {0x124A, 0x124D}, {0x1250, 0x1256},
- {0x1258, 0x1258}, {0x125A, 0x125D}, {0x1260, 0x1288},
- {0x128A, 0x128D}, {0x1290, 0x12B0}, {0x12B2, 0x12B5},
- {0x12B8, 0x12BE}, {0x12C0, 0x12C0}, {0x12C2, 0x12C5},
- {0x12C8, 0x12D6}, {0x12D8, 0x1310}, {0x1312, 0x1315},
- {0x1318, 0x135A}, {0x135D, 0x135F}, {0x1360, 0x1368},
- {0x1369, 0x137C}, {0x1380, 0x138F}, {0x1390, 0x1399},
- {0x13A0, 0x13F5}, {0x13F8, 0x13FD}, {0x1400, 0x1400},
- {0x1401, 0x166C}, {0x166D, 0x166E}, {0x166F, 0x167F},
- {0x1680, 0x1680}, {0x1681, 0x169A}, {0x169B, 0x169B},
- {0x169C, 0x169C}, {0x16A0, 0x16EA}, {0x16EB, 0x16ED},
- {0x16EE, 0x16F0}, {0x16F1, 0x16F8}, {0x1700, 0x170C},
- {0x170E, 0x1711}, {0x1712, 0x1714}, {0x1720, 0x1731},
- {0x1732, 0x1734}, {0x1735, 0x1736}, {0x1740, 0x1751},
- {0x1752, 0x1753}, {0x1760, 0x176C}, {0x176E, 0x1770},
- {0x1772, 0x1773}, {0x1780, 0x17B3}, {0x17B4, 0x17B5},
- {0x17B6, 0x17B6}, {0x17B7, 0x17BD}, {0x17BE, 0x17C5},
- {0x17C6, 0x17C6}, {0x17C7, 0x17C8}, {0x17C9, 0x17D3},
- {0x17D4, 0x17D6}, {0x17D7, 0x17D7}, {0x17D8, 0x17DA},
- {0x17DB, 0x17DB}, {0x17DC, 0x17DC}, {0x17DD, 0x17DD},
- {0x17E0, 0x17E9}, {0x17F0, 0x17F9}, {0x1800, 0x1805},
- {0x1806, 0x1806}, {0x1807, 0x180A}, {0x180B, 0x180D},
- {0x180E, 0x180E}, {0x1810, 0x1819}, {0x1820, 0x1842},
- {0x1843, 0x1843}, {0x1844, 0x1877}, {0x1880, 0x1884},
- {0x1885, 0x1886}, {0x1887, 0x18A8}, {0x18A9, 0x18A9},
- {0x18AA, 0x18AA}, {0x18B0, 0x18F5}, {0x1900, 0x191E},
- {0x1920, 0x1922}, {0x1923, 0x1926}, {0x1927, 0x1928},
- {0x1929, 0x192B}, {0x1930, 0x1931}, {0x1932, 0x1932},
- {0x1933, 0x1938}, {0x1939, 0x193B}, {0x1940, 0x1940},
- {0x1944, 0x1945}, {0x1946, 0x194F}, {0x1950, 0x196D},
- {0x1970, 0x1974}, {0x1980, 0x19AB}, {0x19B0, 0x19C9},
- {0x19D0, 0x19D9}, {0x19DA, 0x19DA}, {0x19DE, 0x19DF},
- {0x19E0, 0x19FF}, {0x1A00, 0x1A16}, {0x1A17, 0x1A18},
- {0x1A19, 0x1A1A}, {0x1A1B, 0x1A1B}, {0x1A1E, 0x1A1F},
- {0x1A20, 0x1A54}, {0x1A55, 0x1A55}, {0x1A56, 0x1A56},
- {0x1A57, 0x1A57}, {0x1A58, 0x1A5E}, {0x1A60, 0x1A60},
- {0x1A61, 0x1A61}, {0x1A62, 0x1A62}, {0x1A63, 0x1A64},
- {0x1A65, 0x1A6C}, {0x1A6D, 0x1A72}, {0x1A73, 0x1A7C},
- {0x1A7F, 0x1A7F}, {0x1A80, 0x1A89}, {0x1A90, 0x1A99},
- {0x1AA0, 0x1AA6}, {0x1AA7, 0x1AA7}, {0x1AA8, 0x1AAD},
- {0x1AB0, 0x1ABD}, {0x1ABE, 0x1ABE}, {0x1B00, 0x1B03},
- {0x1B04, 0x1B04}, {0x1B05, 0x1B33}, {0x1B34, 0x1B34},
- {0x1B35, 0x1B35}, {0x1B36, 0x1B3A}, {0x1B3B, 0x1B3B},
- {0x1B3C, 0x1B3C}, {0x1B3D, 0x1B41}, {0x1B42, 0x1B42},
- {0x1B43, 0x1B44}, {0x1B45, 0x1B4B}, {0x1B50, 0x1B59},
- {0x1B5A, 0x1B60}, {0x1B61, 0x1B6A}, {0x1B6B, 0x1B73},
- {0x1B74, 0x1B7C}, {0x1B80, 0x1B81}, {0x1B82, 0x1B82},
- {0x1B83, 0x1BA0}, {0x1BA1, 0x1BA1}, {0x1BA2, 0x1BA5},
- {0x1BA6, 0x1BA7}, {0x1BA8, 0x1BA9}, {0x1BAA, 0x1BAA},
- {0x1BAB, 0x1BAD}, {0x1BAE, 0x1BAF}, {0x1BB0, 0x1BB9},
- {0x1BBA, 0x1BBF}, {0x1BC0, 0x1BE5}, {0x1BE6, 0x1BE6},
- {0x1BE7, 0x1BE7}, {0x1BE8, 0x1BE9}, {0x1BEA, 0x1BEC},
- {0x1BED, 0x1BED}, {0x1BEE, 0x1BEE}, {0x1BEF, 0x1BF1},
- {0x1BF2, 0x1BF3}, {0x1BFC, 0x1BFF}, {0x1C00, 0x1C23},
- {0x1C24, 0x1C2B}, {0x1C2C, 0x1C33}, {0x1C34, 0x1C35},
- {0x1C36, 0x1C37}, {0x1C3B, 0x1C3F}, {0x1C40, 0x1C49},
- {0x1C4D, 0x1C4F}, {0x1C50, 0x1C59}, {0x1C5A, 0x1C77},
- {0x1C78, 0x1C7D}, {0x1C7E, 0x1C7F}, {0x1C80, 0x1C88},
- {0x1CC0, 0x1CC7}, {0x1CD0, 0x1CD2}, {0x1CD3, 0x1CD3},
- {0x1CD4, 0x1CE0}, {0x1CE1, 0x1CE1}, {0x1CE2, 0x1CE8},
- {0x1CE9, 0x1CEC}, {0x1CED, 0x1CED}, {0x1CEE, 0x1CF1},
- {0x1CF2, 0x1CF3}, {0x1CF4, 0x1CF4}, {0x1CF5, 0x1CF6},
- {0x1CF8, 0x1CF9}, {0x1D00, 0x1D2B}, {0x1D2C, 0x1D6A},
- {0x1D6B, 0x1D77}, {0x1D78, 0x1D78}, {0x1D79, 0x1D7F},
- {0x1D80, 0x1D9A}, {0x1D9B, 0x1DBF}, {0x1DC0, 0x1DF5},
- {0x1DFB, 0x1DFF}, {0x1E00, 0x1EFF}, {0x1F00, 0x1F15},
+ {0x0CBC, 0x0CC4}, {0x0CC6, 0x0CC8}, {0x0CCA, 0x0CCD},
+ {0x0CD5, 0x0CD6}, {0x0CDE, 0x0CDE}, {0x0CE0, 0x0CE3},
+ {0x0CE6, 0x0CEF}, {0x0CF1, 0x0CF2}, {0x0D01, 0x0D03},
+ {0x0D05, 0x0D0C}, {0x0D0E, 0x0D10}, {0x0D12, 0x0D3A},
+ {0x0D3D, 0x0D44}, {0x0D46, 0x0D48}, {0x0D4A, 0x0D4F},
+ {0x0D54, 0x0D63}, {0x0D66, 0x0D7F}, {0x0D82, 0x0D83},
+ {0x0D85, 0x0D96}, {0x0D9A, 0x0DB1}, {0x0DB3, 0x0DBB},
+ {0x0DBD, 0x0DBD}, {0x0DC0, 0x0DC6}, {0x0DCA, 0x0DCA},
+ {0x0DCF, 0x0DD4}, {0x0DD6, 0x0DD6}, {0x0DD8, 0x0DDF},
+ {0x0DE6, 0x0DEF}, {0x0DF2, 0x0DF4}, {0x0E01, 0x0E3A},
+ {0x0E3F, 0x0E5B}, {0x0E81, 0x0E82}, {0x0E84, 0x0E84},
+ {0x0E87, 0x0E88}, {0x0E8A, 0x0E8A}, {0x0E8D, 0x0E8D},
+ {0x0E94, 0x0E97}, {0x0E99, 0x0E9F}, {0x0EA1, 0x0EA3},
+ {0x0EA5, 0x0EA5}, {0x0EA7, 0x0EA7}, {0x0EAA, 0x0EAB},
+ {0x0EAD, 0x0EB9}, {0x0EBB, 0x0EBD}, {0x0EC0, 0x0EC4},
+ {0x0EC6, 0x0EC6}, {0x0EC8, 0x0ECD}, {0x0ED0, 0x0ED9},
+ {0x0EDC, 0x0EDF}, {0x0F00, 0x0F47}, {0x0F49, 0x0F6C},
+ {0x0F71, 0x0F97}, {0x0F99, 0x0FBC}, {0x0FBE, 0x0FCC},
+ {0x0FCE, 0x0FDA}, {0x1000, 0x10C5}, {0x10C7, 0x10C7},
+ {0x10CD, 0x10CD}, {0x10D0, 0x10FF}, {0x1160, 0x1248},
+ {0x124A, 0x124D}, {0x1250, 0x1256}, {0x1258, 0x1258},
+ {0x125A, 0x125D}, {0x1260, 0x1288}, {0x128A, 0x128D},
+ {0x1290, 0x12B0}, {0x12B2, 0x12B5}, {0x12B8, 0x12BE},
+ {0x12C0, 0x12C0}, {0x12C2, 0x12C5}, {0x12C8, 0x12D6},
+ {0x12D8, 0x1310}, {0x1312, 0x1315}, {0x1318, 0x135A},
+ {0x135D, 0x137C}, {0x1380, 0x1399}, {0x13A0, 0x13F5},
+ {0x13F8, 0x13FD}, {0x1400, 0x169C}, {0x16A0, 0x16F8},
+ {0x1700, 0x170C}, {0x170E, 0x1714}, {0x1720, 0x1736},
+ {0x1740, 0x1753}, {0x1760, 0x176C}, {0x176E, 0x1770},
+ {0x1772, 0x1773}, {0x1780, 0x17DD}, {0x17E0, 0x17E9},
+ {0x17F0, 0x17F9}, {0x1800, 0x180E}, {0x1810, 0x1819},
+ {0x1820, 0x1877}, {0x1880, 0x18AA}, {0x18B0, 0x18F5},
+ {0x1900, 0x191E}, {0x1920, 0x192B}, {0x1930, 0x193B},
+ {0x1940, 0x1940}, {0x1944, 0x196D}, {0x1970, 0x1974},
+ {0x1980, 0x19AB}, {0x19B0, 0x19C9}, {0x19D0, 0x19DA},
+ {0x19DE, 0x1A1B}, {0x1A1E, 0x1A5E}, {0x1A60, 0x1A7C},
+ {0x1A7F, 0x1A89}, {0x1A90, 0x1A99}, {0x1AA0, 0x1AAD},
+ {0x1AB0, 0x1ABE}, {0x1B00, 0x1B4B}, {0x1B50, 0x1B7C},
+ {0x1B80, 0x1BF3}, {0x1BFC, 0x1C37}, {0x1C3B, 0x1C49},
+ {0x1C4D, 0x1C88}, {0x1CC0, 0x1CC7}, {0x1CD0, 0x1CF6},
+ {0x1CF8, 0x1CF9}, {0x1D00, 0x1DF5}, {0x1DFB, 0x1F15},
{0x1F18, 0x1F1D}, {0x1F20, 0x1F45}, {0x1F48, 0x1F4D},
{0x1F50, 0x1F57}, {0x1F59, 0x1F59}, {0x1F5B, 0x1F5B},
{0x1F5D, 0x1F5D}, {0x1F5F, 0x1F7D}, {0x1F80, 0x1FB4},
- {0x1FB6, 0x1FBC}, {0x1FBD, 0x1FBD}, {0x1FBE, 0x1FBE},
- {0x1FBF, 0x1FC1}, {0x1FC2, 0x1FC4}, {0x1FC6, 0x1FCC},
- {0x1FCD, 0x1FCF}, {0x1FD0, 0x1FD3}, {0x1FD6, 0x1FDB},
- {0x1FDD, 0x1FDF}, {0x1FE0, 0x1FEC}, {0x1FED, 0x1FEF},
- {0x1FF2, 0x1FF4}, {0x1FF6, 0x1FFC}, {0x1FFD, 0x1FFE},
- {0x2000, 0x200A}, {0x200B, 0x200F}, {0x2011, 0x2012},
- {0x2017, 0x2017}, {0x201A, 0x201A}, {0x201B, 0x201B},
- {0x201E, 0x201E}, {0x201F, 0x201F}, {0x2023, 0x2023},
- {0x2028, 0x2028}, {0x2029, 0x2029}, {0x202A, 0x202E},
- {0x202F, 0x202F}, {0x2031, 0x2031}, {0x2034, 0x2034},
- {0x2036, 0x2038}, {0x2039, 0x2039}, {0x203A, 0x203A},
- {0x203C, 0x203D}, {0x203F, 0x2040}, {0x2041, 0x2043},
- {0x2044, 0x2044}, {0x2045, 0x2045}, {0x2046, 0x2046},
- {0x2047, 0x2051}, {0x2052, 0x2052}, {0x2053, 0x2053},
- {0x2054, 0x2054}, {0x2055, 0x205E}, {0x205F, 0x205F},
- {0x2060, 0x2064}, {0x2066, 0x206F}, {0x2070, 0x2070},
- {0x2071, 0x2071}, {0x2075, 0x2079}, {0x207A, 0x207C},
- {0x207D, 0x207D}, {0x207E, 0x207E}, {0x2080, 0x2080},
- {0x2085, 0x2089}, {0x208A, 0x208C}, {0x208D, 0x208D},
- {0x208E, 0x208E}, {0x2090, 0x209C}, {0x20A0, 0x20A8},
- {0x20AA, 0x20AB}, {0x20AD, 0x20BE}, {0x20D0, 0x20DC},
- {0x20DD, 0x20E0}, {0x20E1, 0x20E1}, {0x20E2, 0x20E4},
- {0x20E5, 0x20F0}, {0x2100, 0x2101}, {0x2102, 0x2102},
- {0x2104, 0x2104}, {0x2106, 0x2106}, {0x2107, 0x2107},
- {0x2108, 0x2108}, {0x210A, 0x2112}, {0x2114, 0x2114},
- {0x2115, 0x2115}, {0x2117, 0x2117}, {0x2118, 0x2118},
- {0x2119, 0x211D}, {0x211E, 0x2120}, {0x2123, 0x2123},
- {0x2124, 0x2124}, {0x2125, 0x2125}, {0x2127, 0x2127},
- {0x2128, 0x2128}, {0x2129, 0x2129}, {0x212A, 0x212A},
- {0x212C, 0x212D}, {0x212E, 0x212E}, {0x212F, 0x2134},
- {0x2135, 0x2138}, {0x2139, 0x2139}, {0x213A, 0x213B},
- {0x213C, 0x213F}, {0x2140, 0x2144}, {0x2145, 0x2149},
- {0x214A, 0x214A}, {0x214B, 0x214B}, {0x214C, 0x214D},
- {0x214E, 0x214E}, {0x214F, 0x214F}, {0x2150, 0x2152},
+ {0x1FB6, 0x1FC4}, {0x1FC6, 0x1FD3}, {0x1FD6, 0x1FDB},
+ {0x1FDD, 0x1FEF}, {0x1FF2, 0x1FF4}, {0x1FF6, 0x1FFE},
+ {0x2000, 0x200F}, {0x2011, 0x2012}, {0x2017, 0x2017},
+ {0x201A, 0x201B}, {0x201E, 0x201F}, {0x2023, 0x2023},
+ {0x2028, 0x202F}, {0x2031, 0x2031}, {0x2034, 0x2034},
+ {0x2036, 0x203A}, {0x203C, 0x203D}, {0x203F, 0x2064},
+ {0x2066, 0x2071}, {0x2075, 0x207E}, {0x2080, 0x2080},
+ {0x2085, 0x208E}, {0x2090, 0x209C}, {0x20A0, 0x20A8},
+ {0x20AA, 0x20AB}, {0x20AD, 0x20BE}, {0x20D0, 0x20F0},
+ {0x2100, 0x2102}, {0x2104, 0x2104}, {0x2106, 0x2108},
+ {0x210A, 0x2112}, {0x2114, 0x2115}, {0x2117, 0x2120},
+ {0x2123, 0x2125}, {0x2127, 0x212A}, {0x212C, 0x2152},
{0x2155, 0x215A}, {0x215F, 0x215F}, {0x216C, 0x216F},
- {0x217A, 0x2182}, {0x2183, 0x2184}, {0x2185, 0x2188},
- {0x218A, 0x218B}, {0x219A, 0x219B}, {0x219C, 0x219F},
- {0x21A0, 0x21A0}, {0x21A1, 0x21A2}, {0x21A3, 0x21A3},
- {0x21A4, 0x21A5}, {0x21A6, 0x21A6}, {0x21A7, 0x21AD},
- {0x21AE, 0x21AE}, {0x21AF, 0x21B7}, {0x21BA, 0x21CD},
- {0x21CE, 0x21CF}, {0x21D0, 0x21D1}, {0x21D3, 0x21D3},
- {0x21D5, 0x21E6}, {0x21E8, 0x21F3}, {0x21F4, 0x21FF},
- {0x2201, 0x2201}, {0x2204, 0x2206}, {0x2209, 0x220A},
- {0x220C, 0x220E}, {0x2210, 0x2210}, {0x2212, 0x2214},
- {0x2216, 0x2219}, {0x221B, 0x221C}, {0x2221, 0x2222},
- {0x2224, 0x2224}, {0x2226, 0x2226}, {0x222D, 0x222D},
- {0x222F, 0x2233}, {0x2238, 0x223B}, {0x223E, 0x2247},
- {0x2249, 0x224B}, {0x224D, 0x2251}, {0x2253, 0x225F},
- {0x2262, 0x2263}, {0x2268, 0x2269}, {0x226C, 0x226D},
- {0x2270, 0x2281}, {0x2284, 0x2285}, {0x2288, 0x2294},
- {0x2296, 0x2298}, {0x229A, 0x22A4}, {0x22A6, 0x22BE},
- {0x22C0, 0x22FF}, {0x2300, 0x2307}, {0x2308, 0x2308},
- {0x2309, 0x2309}, {0x230A, 0x230A}, {0x230B, 0x230B},
- {0x230C, 0x2311}, {0x2313, 0x2319}, {0x231C, 0x231F},
- {0x2320, 0x2321}, {0x2322, 0x2328}, {0x232B, 0x237B},
- {0x237C, 0x237C}, {0x237D, 0x239A}, {0x239B, 0x23B3},
- {0x23B4, 0x23DB}, {0x23DC, 0x23E1}, {0x23E2, 0x23E8},
- {0x23ED, 0x23EF}, {0x23F1, 0x23F2}, {0x23F4, 0x23FE},
- {0x2400, 0x2426}, {0x2440, 0x244A}, {0x24EA, 0x24EA},
- {0x254C, 0x254F}, {0x2574, 0x257F}, {0x2590, 0x2591},
- {0x2596, 0x259F}, {0x25A2, 0x25A2}, {0x25AA, 0x25B1},
- {0x25B4, 0x25B5}, {0x25B8, 0x25BB}, {0x25BE, 0x25BF},
- {0x25C2, 0x25C5}, {0x25C9, 0x25CA}, {0x25CC, 0x25CD},
- {0x25D2, 0x25E1}, {0x25E6, 0x25EE}, {0x25F0, 0x25F7},
- {0x25F8, 0x25FC}, {0x25FF, 0x25FF}, {0x2600, 0x2604},
+ {0x217A, 0x2188}, {0x218A, 0x218B}, {0x219A, 0x21B7},
+ {0x21BA, 0x21D1}, {0x21D3, 0x21D3}, {0x21D5, 0x21E6},
+ {0x21E8, 0x21FF}, {0x2201, 0x2201}, {0x2204, 0x2206},
+ {0x2209, 0x220A}, {0x220C, 0x220E}, {0x2210, 0x2210},
+ {0x2212, 0x2214}, {0x2216, 0x2219}, {0x221B, 0x221C},
+ {0x2221, 0x2222}, {0x2224, 0x2224}, {0x2226, 0x2226},
+ {0x222D, 0x222D}, {0x222F, 0x2233}, {0x2238, 0x223B},
+ {0x223E, 0x2247}, {0x2249, 0x224B}, {0x224D, 0x2251},
+ {0x2253, 0x225F}, {0x2262, 0x2263}, {0x2268, 0x2269},
+ {0x226C, 0x226D}, {0x2270, 0x2281}, {0x2284, 0x2285},
+ {0x2288, 0x2294}, {0x2296, 0x2298}, {0x229A, 0x22A4},
+ {0x22A6, 0x22BE}, {0x22C0, 0x2311}, {0x2313, 0x2319},
+ {0x231C, 0x2328}, {0x232B, 0x23E8}, {0x23ED, 0x23EF},
+ {0x23F1, 0x23F2}, {0x23F4, 0x23FE}, {0x2400, 0x2426},
+ {0x2440, 0x244A}, {0x24EA, 0x24EA}, {0x254C, 0x254F},
+ {0x2574, 0x257F}, {0x2590, 0x2591}, {0x2596, 0x259F},
+ {0x25A2, 0x25A2}, {0x25AA, 0x25B1}, {0x25B4, 0x25B5},
+ {0x25B8, 0x25BB}, {0x25BE, 0x25BF}, {0x25C2, 0x25C5},
+ {0x25C9, 0x25CA}, {0x25CC, 0x25CD}, {0x25D2, 0x25E1},
+ {0x25E6, 0x25EE}, {0x25F0, 0x25FC}, {0x25FF, 0x2604},
{0x2607, 0x2608}, {0x260A, 0x260D}, {0x2610, 0x2613},
{0x2616, 0x261B}, {0x261D, 0x261D}, {0x261F, 0x263F},
{0x2641, 0x2641}, {0x2643, 0x2647}, {0x2654, 0x265F},
@@ -811,256 +684,98 @@ var neutral = table{
{0x26E4, 0x26E7}, {0x2700, 0x2704}, {0x2706, 0x2709},
{0x270C, 0x2727}, {0x2729, 0x273C}, {0x273E, 0x274B},
{0x274D, 0x274D}, {0x274F, 0x2752}, {0x2756, 0x2756},
- {0x2758, 0x2767}, {0x2768, 0x2768}, {0x2769, 0x2769},
- {0x276A, 0x276A}, {0x276B, 0x276B}, {0x276C, 0x276C},
- {0x276D, 0x276D}, {0x276E, 0x276E}, {0x276F, 0x276F},
- {0x2770, 0x2770}, {0x2771, 0x2771}, {0x2772, 0x2772},
- {0x2773, 0x2773}, {0x2774, 0x2774}, {0x2775, 0x2775},
- {0x2780, 0x2793}, {0x2794, 0x2794}, {0x2798, 0x27AF},
- {0x27B1, 0x27BE}, {0x27C0, 0x27C4}, {0x27C5, 0x27C5},
- {0x27C6, 0x27C6}, {0x27C7, 0x27E5}, {0x27EE, 0x27EE},
- {0x27EF, 0x27EF}, {0x27F0, 0x27FF}, {0x2800, 0x28FF},
- {0x2900, 0x297F}, {0x2980, 0x2982}, {0x2983, 0x2983},
- {0x2984, 0x2984}, {0x2987, 0x2987}, {0x2988, 0x2988},
- {0x2989, 0x2989}, {0x298A, 0x298A}, {0x298B, 0x298B},
- {0x298C, 0x298C}, {0x298D, 0x298D}, {0x298E, 0x298E},
- {0x298F, 0x298F}, {0x2990, 0x2990}, {0x2991, 0x2991},
- {0x2992, 0x2992}, {0x2993, 0x2993}, {0x2994, 0x2994},
- {0x2995, 0x2995}, {0x2996, 0x2996}, {0x2997, 0x2997},
- {0x2998, 0x2998}, {0x2999, 0x29D7}, {0x29D8, 0x29D8},
- {0x29D9, 0x29D9}, {0x29DA, 0x29DA}, {0x29DB, 0x29DB},
- {0x29DC, 0x29FB}, {0x29FC, 0x29FC}, {0x29FD, 0x29FD},
- {0x29FE, 0x29FF}, {0x2A00, 0x2AFF}, {0x2B00, 0x2B1A},
- {0x2B1D, 0x2B2F}, {0x2B30, 0x2B44}, {0x2B45, 0x2B46},
- {0x2B47, 0x2B4C}, {0x2B4D, 0x2B4F}, {0x2B51, 0x2B54},
+ {0x2758, 0x2775}, {0x2780, 0x2794}, {0x2798, 0x27AF},
+ {0x27B1, 0x27BE}, {0x27C0, 0x27E5}, {0x27EE, 0x2984},
+ {0x2987, 0x2B1A}, {0x2B1D, 0x2B4F}, {0x2B51, 0x2B54},
{0x2B5A, 0x2B73}, {0x2B76, 0x2B95}, {0x2B98, 0x2BB9},
{0x2BBD, 0x2BC8}, {0x2BCA, 0x2BD1}, {0x2BEC, 0x2BEF},
- {0x2C00, 0x2C2E}, {0x2C30, 0x2C5E}, {0x2C60, 0x2C7B},
- {0x2C7C, 0x2C7D}, {0x2C7E, 0x2C7F}, {0x2C80, 0x2CE4},
- {0x2CE5, 0x2CEA}, {0x2CEB, 0x2CEE}, {0x2CEF, 0x2CF1},
- {0x2CF2, 0x2CF3}, {0x2CF9, 0x2CFC}, {0x2CFD, 0x2CFD},
- {0x2CFE, 0x2CFF}, {0x2D00, 0x2D25}, {0x2D27, 0x2D27},
- {0x2D2D, 0x2D2D}, {0x2D30, 0x2D67}, {0x2D6F, 0x2D6F},
- {0x2D70, 0x2D70}, {0x2D7F, 0x2D7F}, {0x2D80, 0x2D96},
+ {0x2C00, 0x2C2E}, {0x2C30, 0x2C5E}, {0x2C60, 0x2CF3},
+ {0x2CF9, 0x2D25}, {0x2D27, 0x2D27}, {0x2D2D, 0x2D2D},
+ {0x2D30, 0x2D67}, {0x2D6F, 0x2D70}, {0x2D7F, 0x2D96},
{0x2DA0, 0x2DA6}, {0x2DA8, 0x2DAE}, {0x2DB0, 0x2DB6},
{0x2DB8, 0x2DBE}, {0x2DC0, 0x2DC6}, {0x2DC8, 0x2DCE},
- {0x2DD0, 0x2DD6}, {0x2DD8, 0x2DDE}, {0x2DE0, 0x2DFF},
- {0x2E00, 0x2E01}, {0x2E02, 0x2E02}, {0x2E03, 0x2E03},
- {0x2E04, 0x2E04}, {0x2E05, 0x2E05}, {0x2E06, 0x2E08},
- {0x2E09, 0x2E09}, {0x2E0A, 0x2E0A}, {0x2E0B, 0x2E0B},
- {0x2E0C, 0x2E0C}, {0x2E0D, 0x2E0D}, {0x2E0E, 0x2E16},
- {0x2E17, 0x2E17}, {0x2E18, 0x2E19}, {0x2E1A, 0x2E1A},
- {0x2E1B, 0x2E1B}, {0x2E1C, 0x2E1C}, {0x2E1D, 0x2E1D},
- {0x2E1E, 0x2E1F}, {0x2E20, 0x2E20}, {0x2E21, 0x2E21},
- {0x2E22, 0x2E22}, {0x2E23, 0x2E23}, {0x2E24, 0x2E24},
- {0x2E25, 0x2E25}, {0x2E26, 0x2E26}, {0x2E27, 0x2E27},
- {0x2E28, 0x2E28}, {0x2E29, 0x2E29}, {0x2E2A, 0x2E2E},
- {0x2E2F, 0x2E2F}, {0x2E30, 0x2E39}, {0x2E3A, 0x2E3B},
- {0x2E3C, 0x2E3F}, {0x2E40, 0x2E40}, {0x2E41, 0x2E41},
- {0x2E42, 0x2E42}, {0x2E43, 0x2E44}, {0x303F, 0x303F},
- {0x4DC0, 0x4DFF}, {0xA4D0, 0xA4F7}, {0xA4F8, 0xA4FD},
- {0xA4FE, 0xA4FF}, {0xA500, 0xA60B}, {0xA60C, 0xA60C},
- {0xA60D, 0xA60F}, {0xA610, 0xA61F}, {0xA620, 0xA629},
- {0xA62A, 0xA62B}, {0xA640, 0xA66D}, {0xA66E, 0xA66E},
- {0xA66F, 0xA66F}, {0xA670, 0xA672}, {0xA673, 0xA673},
- {0xA674, 0xA67D}, {0xA67E, 0xA67E}, {0xA67F, 0xA67F},
- {0xA680, 0xA69B}, {0xA69C, 0xA69D}, {0xA69E, 0xA69F},
- {0xA6A0, 0xA6E5}, {0xA6E6, 0xA6EF}, {0xA6F0, 0xA6F1},
- {0xA6F2, 0xA6F7}, {0xA700, 0xA716}, {0xA717, 0xA71F},
- {0xA720, 0xA721}, {0xA722, 0xA76F}, {0xA770, 0xA770},
- {0xA771, 0xA787}, {0xA788, 0xA788}, {0xA789, 0xA78A},
- {0xA78B, 0xA78E}, {0xA78F, 0xA78F}, {0xA790, 0xA7AE},
- {0xA7B0, 0xA7B7}, {0xA7F7, 0xA7F7}, {0xA7F8, 0xA7F9},
- {0xA7FA, 0xA7FA}, {0xA7FB, 0xA7FF}, {0xA800, 0xA801},
- {0xA802, 0xA802}, {0xA803, 0xA805}, {0xA806, 0xA806},
- {0xA807, 0xA80A}, {0xA80B, 0xA80B}, {0xA80C, 0xA822},
- {0xA823, 0xA824}, {0xA825, 0xA826}, {0xA827, 0xA827},
- {0xA828, 0xA82B}, {0xA830, 0xA835}, {0xA836, 0xA837},
- {0xA838, 0xA838}, {0xA839, 0xA839}, {0xA840, 0xA873},
- {0xA874, 0xA877}, {0xA880, 0xA881}, {0xA882, 0xA8B3},
- {0xA8B4, 0xA8C3}, {0xA8C4, 0xA8C5}, {0xA8CE, 0xA8CF},
- {0xA8D0, 0xA8D9}, {0xA8E0, 0xA8F1}, {0xA8F2, 0xA8F7},
- {0xA8F8, 0xA8FA}, {0xA8FB, 0xA8FB}, {0xA8FC, 0xA8FC},
- {0xA8FD, 0xA8FD}, {0xA900, 0xA909}, {0xA90A, 0xA925},
- {0xA926, 0xA92D}, {0xA92E, 0xA92F}, {0xA930, 0xA946},
- {0xA947, 0xA951}, {0xA952, 0xA953}, {0xA95F, 0xA95F},
- {0xA980, 0xA982}, {0xA983, 0xA983}, {0xA984, 0xA9B2},
- {0xA9B3, 0xA9B3}, {0xA9B4, 0xA9B5}, {0xA9B6, 0xA9B9},
- {0xA9BA, 0xA9BB}, {0xA9BC, 0xA9BC}, {0xA9BD, 0xA9C0},
- {0xA9C1, 0xA9CD}, {0xA9CF, 0xA9CF}, {0xA9D0, 0xA9D9},
- {0xA9DE, 0xA9DF}, {0xA9E0, 0xA9E4}, {0xA9E5, 0xA9E5},
- {0xA9E6, 0xA9E6}, {0xA9E7, 0xA9EF}, {0xA9F0, 0xA9F9},
- {0xA9FA, 0xA9FE}, {0xAA00, 0xAA28}, {0xAA29, 0xAA2E},
- {0xAA2F, 0xAA30}, {0xAA31, 0xAA32}, {0xAA33, 0xAA34},
- {0xAA35, 0xAA36}, {0xAA40, 0xAA42}, {0xAA43, 0xAA43},
- {0xAA44, 0xAA4B}, {0xAA4C, 0xAA4C}, {0xAA4D, 0xAA4D},
- {0xAA50, 0xAA59}, {0xAA5C, 0xAA5F}, {0xAA60, 0xAA6F},
- {0xAA70, 0xAA70}, {0xAA71, 0xAA76}, {0xAA77, 0xAA79},
- {0xAA7A, 0xAA7A}, {0xAA7B, 0xAA7B}, {0xAA7C, 0xAA7C},
- {0xAA7D, 0xAA7D}, {0xAA7E, 0xAA7F}, {0xAA80, 0xAAAF},
- {0xAAB0, 0xAAB0}, {0xAAB1, 0xAAB1}, {0xAAB2, 0xAAB4},
- {0xAAB5, 0xAAB6}, {0xAAB7, 0xAAB8}, {0xAAB9, 0xAABD},
- {0xAABE, 0xAABF}, {0xAAC0, 0xAAC0}, {0xAAC1, 0xAAC1},
- {0xAAC2, 0xAAC2}, {0xAADB, 0xAADC}, {0xAADD, 0xAADD},
- {0xAADE, 0xAADF}, {0xAAE0, 0xAAEA}, {0xAAEB, 0xAAEB},
- {0xAAEC, 0xAAED}, {0xAAEE, 0xAAEF}, {0xAAF0, 0xAAF1},
- {0xAAF2, 0xAAF2}, {0xAAF3, 0xAAF4}, {0xAAF5, 0xAAF5},
- {0xAAF6, 0xAAF6}, {0xAB01, 0xAB06}, {0xAB09, 0xAB0E},
+ {0x2DD0, 0x2DD6}, {0x2DD8, 0x2DDE}, {0x2DE0, 0x2E44},
+ {0x303F, 0x303F}, {0x4DC0, 0x4DFF}, {0xA4D0, 0xA62B},
+ {0xA640, 0xA6F7}, {0xA700, 0xA7AE}, {0xA7B0, 0xA7B7},
+ {0xA7F7, 0xA82B}, {0xA830, 0xA839}, {0xA840, 0xA877},
+ {0xA880, 0xA8C5}, {0xA8CE, 0xA8D9}, {0xA8E0, 0xA8FD},
+ {0xA900, 0xA953}, {0xA95F, 0xA95F}, {0xA980, 0xA9CD},
+ {0xA9CF, 0xA9D9}, {0xA9DE, 0xA9FE}, {0xAA00, 0xAA36},
+ {0xAA40, 0xAA4D}, {0xAA50, 0xAA59}, {0xAA5C, 0xAAC2},
+ {0xAADB, 0xAAF6}, {0xAB01, 0xAB06}, {0xAB09, 0xAB0E},
{0xAB11, 0xAB16}, {0xAB20, 0xAB26}, {0xAB28, 0xAB2E},
- {0xAB30, 0xAB5A}, {0xAB5B, 0xAB5B}, {0xAB5C, 0xAB5F},
- {0xAB60, 0xAB65}, {0xAB70, 0xABBF}, {0xABC0, 0xABE2},
- {0xABE3, 0xABE4}, {0xABE5, 0xABE5}, {0xABE6, 0xABE7},
- {0xABE8, 0xABE8}, {0xABE9, 0xABEA}, {0xABEB, 0xABEB},
- {0xABEC, 0xABEC}, {0xABED, 0xABED}, {0xABF0, 0xABF9},
- {0xD7B0, 0xD7C6}, {0xD7CB, 0xD7FB}, {0xD800, 0xDB7F},
- {0xDB80, 0xDBFF}, {0xDC00, 0xDFFF}, {0xFB00, 0xFB06},
- {0xFB13, 0xFB17}, {0xFB1D, 0xFB1D}, {0xFB1E, 0xFB1E},
- {0xFB1F, 0xFB28}, {0xFB29, 0xFB29}, {0xFB2A, 0xFB36},
+ {0xAB30, 0xAB65}, {0xAB70, 0xABED}, {0xABF0, 0xABF9},
+ {0xD7B0, 0xD7C6}, {0xD7CB, 0xD7FB}, {0xD800, 0xDFFF},
+ {0xFB00, 0xFB06}, {0xFB13, 0xFB17}, {0xFB1D, 0xFB36},
{0xFB38, 0xFB3C}, {0xFB3E, 0xFB3E}, {0xFB40, 0xFB41},
- {0xFB43, 0xFB44}, {0xFB46, 0xFB4F}, {0xFB50, 0xFBB1},
- {0xFBB2, 0xFBC1}, {0xFBD3, 0xFD3D}, {0xFD3E, 0xFD3E},
- {0xFD3F, 0xFD3F}, {0xFD50, 0xFD8F}, {0xFD92, 0xFDC7},
- {0xFDF0, 0xFDFB}, {0xFDFC, 0xFDFC}, {0xFDFD, 0xFDFD},
+ {0xFB43, 0xFB44}, {0xFB46, 0xFBC1}, {0xFBD3, 0xFD3F},
+ {0xFD50, 0xFD8F}, {0xFD92, 0xFDC7}, {0xFDF0, 0xFDFD},
{0xFE20, 0xFE2F}, {0xFE70, 0xFE74}, {0xFE76, 0xFEFC},
- {0xFEFF, 0xFEFF}, {0xFFF9, 0xFFFB}, {0xFFFC, 0xFFFC},
- {0x10000, 0x1000B}, {0x1000D, 0x10026}, {0x10028, 0x1003A},
- {0x1003C, 0x1003D}, {0x1003F, 0x1004D}, {0x10050, 0x1005D},
- {0x10080, 0x100FA}, {0x10100, 0x10102}, {0x10107, 0x10133},
- {0x10137, 0x1013F}, {0x10140, 0x10174}, {0x10175, 0x10178},
- {0x10179, 0x10189}, {0x1018A, 0x1018B}, {0x1018C, 0x1018E},
- {0x10190, 0x1019B}, {0x101A0, 0x101A0}, {0x101D0, 0x101FC},
- {0x101FD, 0x101FD}, {0x10280, 0x1029C}, {0x102A0, 0x102D0},
- {0x102E0, 0x102E0}, {0x102E1, 0x102FB}, {0x10300, 0x1031F},
- {0x10320, 0x10323}, {0x10330, 0x10340}, {0x10341, 0x10341},
- {0x10342, 0x10349}, {0x1034A, 0x1034A}, {0x10350, 0x10375},
- {0x10376, 0x1037A}, {0x10380, 0x1039D}, {0x1039F, 0x1039F},
- {0x103A0, 0x103C3}, {0x103C8, 0x103CF}, {0x103D0, 0x103D0},
- {0x103D1, 0x103D5}, {0x10400, 0x1044F}, {0x10450, 0x1047F},
- {0x10480, 0x1049D}, {0x104A0, 0x104A9}, {0x104B0, 0x104D3},
+ {0xFEFF, 0xFEFF}, {0xFFF9, 0xFFFC}, {0x10000, 0x1000B},
+ {0x1000D, 0x10026}, {0x10028, 0x1003A}, {0x1003C, 0x1003D},
+ {0x1003F, 0x1004D}, {0x10050, 0x1005D}, {0x10080, 0x100FA},
+ {0x10100, 0x10102}, {0x10107, 0x10133}, {0x10137, 0x1018E},
+ {0x10190, 0x1019B}, {0x101A0, 0x101A0}, {0x101D0, 0x101FD},
+ {0x10280, 0x1029C}, {0x102A0, 0x102D0}, {0x102E0, 0x102FB},
+ {0x10300, 0x10323}, {0x10330, 0x1034A}, {0x10350, 0x1037A},
+ {0x10380, 0x1039D}, {0x1039F, 0x103C3}, {0x103C8, 0x103D5},
+ {0x10400, 0x1049D}, {0x104A0, 0x104A9}, {0x104B0, 0x104D3},
{0x104D8, 0x104FB}, {0x10500, 0x10527}, {0x10530, 0x10563},
{0x1056F, 0x1056F}, {0x10600, 0x10736}, {0x10740, 0x10755},
{0x10760, 0x10767}, {0x10800, 0x10805}, {0x10808, 0x10808},
{0x1080A, 0x10835}, {0x10837, 0x10838}, {0x1083C, 0x1083C},
- {0x1083F, 0x1083F}, {0x10840, 0x10855}, {0x10857, 0x10857},
- {0x10858, 0x1085F}, {0x10860, 0x10876}, {0x10877, 0x10878},
- {0x10879, 0x1087F}, {0x10880, 0x1089E}, {0x108A7, 0x108AF},
- {0x108E0, 0x108F2}, {0x108F4, 0x108F5}, {0x108FB, 0x108FF},
- {0x10900, 0x10915}, {0x10916, 0x1091B}, {0x1091F, 0x1091F},
- {0x10920, 0x10939}, {0x1093F, 0x1093F}, {0x10980, 0x1099F},
- {0x109A0, 0x109B7}, {0x109BC, 0x109BD}, {0x109BE, 0x109BF},
- {0x109C0, 0x109CF}, {0x109D2, 0x109FF}, {0x10A00, 0x10A00},
- {0x10A01, 0x10A03}, {0x10A05, 0x10A06}, {0x10A0C, 0x10A0F},
- {0x10A10, 0x10A13}, {0x10A15, 0x10A17}, {0x10A19, 0x10A33},
- {0x10A38, 0x10A3A}, {0x10A3F, 0x10A3F}, {0x10A40, 0x10A47},
- {0x10A50, 0x10A58}, {0x10A60, 0x10A7C}, {0x10A7D, 0x10A7E},
- {0x10A7F, 0x10A7F}, {0x10A80, 0x10A9C}, {0x10A9D, 0x10A9F},
- {0x10AC0, 0x10AC7}, {0x10AC8, 0x10AC8}, {0x10AC9, 0x10AE4},
- {0x10AE5, 0x10AE6}, {0x10AEB, 0x10AEF}, {0x10AF0, 0x10AF6},
- {0x10B00, 0x10B35}, {0x10B39, 0x10B3F}, {0x10B40, 0x10B55},
- {0x10B58, 0x10B5F}, {0x10B60, 0x10B72}, {0x10B78, 0x10B7F},
- {0x10B80, 0x10B91}, {0x10B99, 0x10B9C}, {0x10BA9, 0x10BAF},
+ {0x1083F, 0x10855}, {0x10857, 0x1089E}, {0x108A7, 0x108AF},
+ {0x108E0, 0x108F2}, {0x108F4, 0x108F5}, {0x108FB, 0x1091B},
+ {0x1091F, 0x10939}, {0x1093F, 0x1093F}, {0x10980, 0x109B7},
+ {0x109BC, 0x109CF}, {0x109D2, 0x10A03}, {0x10A05, 0x10A06},
+ {0x10A0C, 0x10A13}, {0x10A15, 0x10A17}, {0x10A19, 0x10A33},
+ {0x10A38, 0x10A3A}, {0x10A3F, 0x10A47}, {0x10A50, 0x10A58},
+ {0x10A60, 0x10A9F}, {0x10AC0, 0x10AE6}, {0x10AEB, 0x10AF6},
+ {0x10B00, 0x10B35}, {0x10B39, 0x10B55}, {0x10B58, 0x10B72},
+ {0x10B78, 0x10B91}, {0x10B99, 0x10B9C}, {0x10BA9, 0x10BAF},
{0x10C00, 0x10C48}, {0x10C80, 0x10CB2}, {0x10CC0, 0x10CF2},
- {0x10CFA, 0x10CFF}, {0x10E60, 0x10E7E}, {0x11000, 0x11000},
- {0x11001, 0x11001}, {0x11002, 0x11002}, {0x11003, 0x11037},
- {0x11038, 0x11046}, {0x11047, 0x1104D}, {0x11052, 0x11065},
- {0x11066, 0x1106F}, {0x1107F, 0x1107F}, {0x11080, 0x11081},
- {0x11082, 0x11082}, {0x11083, 0x110AF}, {0x110B0, 0x110B2},
- {0x110B3, 0x110B6}, {0x110B7, 0x110B8}, {0x110B9, 0x110BA},
- {0x110BB, 0x110BC}, {0x110BD, 0x110BD}, {0x110BE, 0x110C1},
- {0x110D0, 0x110E8}, {0x110F0, 0x110F9}, {0x11100, 0x11102},
- {0x11103, 0x11126}, {0x11127, 0x1112B}, {0x1112C, 0x1112C},
- {0x1112D, 0x11134}, {0x11136, 0x1113F}, {0x11140, 0x11143},
- {0x11150, 0x11172}, {0x11173, 0x11173}, {0x11174, 0x11175},
- {0x11176, 0x11176}, {0x11180, 0x11181}, {0x11182, 0x11182},
- {0x11183, 0x111B2}, {0x111B3, 0x111B5}, {0x111B6, 0x111BE},
- {0x111BF, 0x111C0}, {0x111C1, 0x111C4}, {0x111C5, 0x111C9},
- {0x111CA, 0x111CC}, {0x111CD, 0x111CD}, {0x111D0, 0x111D9},
- {0x111DA, 0x111DA}, {0x111DB, 0x111DB}, {0x111DC, 0x111DC},
- {0x111DD, 0x111DF}, {0x111E1, 0x111F4}, {0x11200, 0x11211},
- {0x11213, 0x1122B}, {0x1122C, 0x1122E}, {0x1122F, 0x11231},
- {0x11232, 0x11233}, {0x11234, 0x11234}, {0x11235, 0x11235},
- {0x11236, 0x11237}, {0x11238, 0x1123D}, {0x1123E, 0x1123E},
+ {0x10CFA, 0x10CFF}, {0x10E60, 0x10E7E}, {0x11000, 0x1104D},
+ {0x11052, 0x1106F}, {0x1107F, 0x110C1}, {0x110D0, 0x110E8},
+ {0x110F0, 0x110F9}, {0x11100, 0x11134}, {0x11136, 0x11143},
+ {0x11150, 0x11176}, {0x11180, 0x111CD}, {0x111D0, 0x111DF},
+ {0x111E1, 0x111F4}, {0x11200, 0x11211}, {0x11213, 0x1123E},
{0x11280, 0x11286}, {0x11288, 0x11288}, {0x1128A, 0x1128D},
- {0x1128F, 0x1129D}, {0x1129F, 0x112A8}, {0x112A9, 0x112A9},
- {0x112B0, 0x112DE}, {0x112DF, 0x112DF}, {0x112E0, 0x112E2},
- {0x112E3, 0x112EA}, {0x112F0, 0x112F9}, {0x11300, 0x11301},
- {0x11302, 0x11303}, {0x11305, 0x1130C}, {0x1130F, 0x11310},
- {0x11313, 0x11328}, {0x1132A, 0x11330}, {0x11332, 0x11333},
- {0x11335, 0x11339}, {0x1133C, 0x1133C}, {0x1133D, 0x1133D},
- {0x1133E, 0x1133F}, {0x11340, 0x11340}, {0x11341, 0x11344},
+ {0x1128F, 0x1129D}, {0x1129F, 0x112A9}, {0x112B0, 0x112EA},
+ {0x112F0, 0x112F9}, {0x11300, 0x11303}, {0x11305, 0x1130C},
+ {0x1130F, 0x11310}, {0x11313, 0x11328}, {0x1132A, 0x11330},
+ {0x11332, 0x11333}, {0x11335, 0x11339}, {0x1133C, 0x11344},
{0x11347, 0x11348}, {0x1134B, 0x1134D}, {0x11350, 0x11350},
- {0x11357, 0x11357}, {0x1135D, 0x11361}, {0x11362, 0x11363},
- {0x11366, 0x1136C}, {0x11370, 0x11374}, {0x11400, 0x11434},
- {0x11435, 0x11437}, {0x11438, 0x1143F}, {0x11440, 0x11441},
- {0x11442, 0x11444}, {0x11445, 0x11445}, {0x11446, 0x11446},
- {0x11447, 0x1144A}, {0x1144B, 0x1144F}, {0x11450, 0x11459},
- {0x1145B, 0x1145B}, {0x1145D, 0x1145D}, {0x11480, 0x114AF},
- {0x114B0, 0x114B2}, {0x114B3, 0x114B8}, {0x114B9, 0x114B9},
- {0x114BA, 0x114BA}, {0x114BB, 0x114BE}, {0x114BF, 0x114C0},
- {0x114C1, 0x114C1}, {0x114C2, 0x114C3}, {0x114C4, 0x114C5},
- {0x114C6, 0x114C6}, {0x114C7, 0x114C7}, {0x114D0, 0x114D9},
- {0x11580, 0x115AE}, {0x115AF, 0x115B1}, {0x115B2, 0x115B5},
- {0x115B8, 0x115BB}, {0x115BC, 0x115BD}, {0x115BE, 0x115BE},
- {0x115BF, 0x115C0}, {0x115C1, 0x115D7}, {0x115D8, 0x115DB},
- {0x115DC, 0x115DD}, {0x11600, 0x1162F}, {0x11630, 0x11632},
- {0x11633, 0x1163A}, {0x1163B, 0x1163C}, {0x1163D, 0x1163D},
- {0x1163E, 0x1163E}, {0x1163F, 0x11640}, {0x11641, 0x11643},
- {0x11644, 0x11644}, {0x11650, 0x11659}, {0x11660, 0x1166C},
- {0x11680, 0x116AA}, {0x116AB, 0x116AB}, {0x116AC, 0x116AC},
- {0x116AD, 0x116AD}, {0x116AE, 0x116AF}, {0x116B0, 0x116B5},
- {0x116B6, 0x116B6}, {0x116B7, 0x116B7}, {0x116C0, 0x116C9},
- {0x11700, 0x11719}, {0x1171D, 0x1171F}, {0x11720, 0x11721},
- {0x11722, 0x11725}, {0x11726, 0x11726}, {0x11727, 0x1172B},
- {0x11730, 0x11739}, {0x1173A, 0x1173B}, {0x1173C, 0x1173E},
- {0x1173F, 0x1173F}, {0x118A0, 0x118DF}, {0x118E0, 0x118E9},
- {0x118EA, 0x118F2}, {0x118FF, 0x118FF}, {0x11AC0, 0x11AF8},
- {0x11C00, 0x11C08}, {0x11C0A, 0x11C2E}, {0x11C2F, 0x11C2F},
- {0x11C30, 0x11C36}, {0x11C38, 0x11C3D}, {0x11C3E, 0x11C3E},
- {0x11C3F, 0x11C3F}, {0x11C40, 0x11C40}, {0x11C41, 0x11C45},
- {0x11C50, 0x11C59}, {0x11C5A, 0x11C6C}, {0x11C70, 0x11C71},
- {0x11C72, 0x11C8F}, {0x11C92, 0x11CA7}, {0x11CA9, 0x11CA9},
- {0x11CAA, 0x11CB0}, {0x11CB1, 0x11CB1}, {0x11CB2, 0x11CB3},
- {0x11CB4, 0x11CB4}, {0x11CB5, 0x11CB6}, {0x12000, 0x12399},
+ {0x11357, 0x11357}, {0x1135D, 0x11363}, {0x11366, 0x1136C},
+ {0x11370, 0x11374}, {0x11400, 0x11459}, {0x1145B, 0x1145B},
+ {0x1145D, 0x1145D}, {0x11480, 0x114C7}, {0x114D0, 0x114D9},
+ {0x11580, 0x115B5}, {0x115B8, 0x115DD}, {0x11600, 0x11644},
+ {0x11650, 0x11659}, {0x11660, 0x1166C}, {0x11680, 0x116B7},
+ {0x116C0, 0x116C9}, {0x11700, 0x11719}, {0x1171D, 0x1172B},
+ {0x11730, 0x1173F}, {0x118A0, 0x118F2}, {0x118FF, 0x118FF},
+ {0x11AC0, 0x11AF8}, {0x11C00, 0x11C08}, {0x11C0A, 0x11C36},
+ {0x11C38, 0x11C45}, {0x11C50, 0x11C6C}, {0x11C70, 0x11C8F},
+ {0x11C92, 0x11CA7}, {0x11CA9, 0x11CB6}, {0x12000, 0x12399},
{0x12400, 0x1246E}, {0x12470, 0x12474}, {0x12480, 0x12543},
{0x13000, 0x1342E}, {0x14400, 0x14646}, {0x16800, 0x16A38},
{0x16A40, 0x16A5E}, {0x16A60, 0x16A69}, {0x16A6E, 0x16A6F},
- {0x16AD0, 0x16AED}, {0x16AF0, 0x16AF4}, {0x16AF5, 0x16AF5},
- {0x16B00, 0x16B2F}, {0x16B30, 0x16B36}, {0x16B37, 0x16B3B},
- {0x16B3C, 0x16B3F}, {0x16B40, 0x16B43}, {0x16B44, 0x16B44},
- {0x16B45, 0x16B45}, {0x16B50, 0x16B59}, {0x16B5B, 0x16B61},
- {0x16B63, 0x16B77}, {0x16B7D, 0x16B8F}, {0x16F00, 0x16F44},
- {0x16F50, 0x16F50}, {0x16F51, 0x16F7E}, {0x16F8F, 0x16F92},
- {0x16F93, 0x16F9F}, {0x1BC00, 0x1BC6A}, {0x1BC70, 0x1BC7C},
- {0x1BC80, 0x1BC88}, {0x1BC90, 0x1BC99}, {0x1BC9C, 0x1BC9C},
- {0x1BC9D, 0x1BC9E}, {0x1BC9F, 0x1BC9F}, {0x1BCA0, 0x1BCA3},
- {0x1D000, 0x1D0F5}, {0x1D100, 0x1D126}, {0x1D129, 0x1D164},
- {0x1D165, 0x1D166}, {0x1D167, 0x1D169}, {0x1D16A, 0x1D16C},
- {0x1D16D, 0x1D172}, {0x1D173, 0x1D17A}, {0x1D17B, 0x1D182},
- {0x1D183, 0x1D184}, {0x1D185, 0x1D18B}, {0x1D18C, 0x1D1A9},
- {0x1D1AA, 0x1D1AD}, {0x1D1AE, 0x1D1E8}, {0x1D200, 0x1D241},
- {0x1D242, 0x1D244}, {0x1D245, 0x1D245}, {0x1D300, 0x1D356},
- {0x1D360, 0x1D371}, {0x1D400, 0x1D454}, {0x1D456, 0x1D49C},
- {0x1D49E, 0x1D49F}, {0x1D4A2, 0x1D4A2}, {0x1D4A5, 0x1D4A6},
- {0x1D4A9, 0x1D4AC}, {0x1D4AE, 0x1D4B9}, {0x1D4BB, 0x1D4BB},
- {0x1D4BD, 0x1D4C3}, {0x1D4C5, 0x1D505}, {0x1D507, 0x1D50A},
- {0x1D50D, 0x1D514}, {0x1D516, 0x1D51C}, {0x1D51E, 0x1D539},
- {0x1D53B, 0x1D53E}, {0x1D540, 0x1D544}, {0x1D546, 0x1D546},
- {0x1D54A, 0x1D550}, {0x1D552, 0x1D6A5}, {0x1D6A8, 0x1D6C0},
- {0x1D6C1, 0x1D6C1}, {0x1D6C2, 0x1D6DA}, {0x1D6DB, 0x1D6DB},
- {0x1D6DC, 0x1D6FA}, {0x1D6FB, 0x1D6FB}, {0x1D6FC, 0x1D714},
- {0x1D715, 0x1D715}, {0x1D716, 0x1D734}, {0x1D735, 0x1D735},
- {0x1D736, 0x1D74E}, {0x1D74F, 0x1D74F}, {0x1D750, 0x1D76E},
- {0x1D76F, 0x1D76F}, {0x1D770, 0x1D788}, {0x1D789, 0x1D789},
- {0x1D78A, 0x1D7A8}, {0x1D7A9, 0x1D7A9}, {0x1D7AA, 0x1D7C2},
- {0x1D7C3, 0x1D7C3}, {0x1D7C4, 0x1D7CB}, {0x1D7CE, 0x1D7FF},
- {0x1D800, 0x1D9FF}, {0x1DA00, 0x1DA36}, {0x1DA37, 0x1DA3A},
- {0x1DA3B, 0x1DA6C}, {0x1DA6D, 0x1DA74}, {0x1DA75, 0x1DA75},
- {0x1DA76, 0x1DA83}, {0x1DA84, 0x1DA84}, {0x1DA85, 0x1DA86},
- {0x1DA87, 0x1DA8B}, {0x1DA9B, 0x1DA9F}, {0x1DAA1, 0x1DAAF},
- {0x1E000, 0x1E006}, {0x1E008, 0x1E018}, {0x1E01B, 0x1E021},
- {0x1E023, 0x1E024}, {0x1E026, 0x1E02A}, {0x1E800, 0x1E8C4},
- {0x1E8C7, 0x1E8CF}, {0x1E8D0, 0x1E8D6}, {0x1E900, 0x1E943},
- {0x1E944, 0x1E94A}, {0x1E950, 0x1E959}, {0x1E95E, 0x1E95F},
+ {0x16AD0, 0x16AED}, {0x16AF0, 0x16AF5}, {0x16B00, 0x16B45},
+ {0x16B50, 0x16B59}, {0x16B5B, 0x16B61}, {0x16B63, 0x16B77},
+ {0x16B7D, 0x16B8F}, {0x16F00, 0x16F44}, {0x16F50, 0x16F7E},
+ {0x16F8F, 0x16F9F}, {0x1BC00, 0x1BC6A}, {0x1BC70, 0x1BC7C},
+ {0x1BC80, 0x1BC88}, {0x1BC90, 0x1BC99}, {0x1BC9C, 0x1BCA3},
+ {0x1D000, 0x1D0F5}, {0x1D100, 0x1D126}, {0x1D129, 0x1D1E8},
+ {0x1D200, 0x1D245}, {0x1D300, 0x1D356}, {0x1D360, 0x1D371},
+ {0x1D400, 0x1D454}, {0x1D456, 0x1D49C}, {0x1D49E, 0x1D49F},
+ {0x1D4A2, 0x1D4A2}, {0x1D4A5, 0x1D4A6}, {0x1D4A9, 0x1D4AC},
+ {0x1D4AE, 0x1D4B9}, {0x1D4BB, 0x1D4BB}, {0x1D4BD, 0x1D4C3},
+ {0x1D4C5, 0x1D505}, {0x1D507, 0x1D50A}, {0x1D50D, 0x1D514},
+ {0x1D516, 0x1D51C}, {0x1D51E, 0x1D539}, {0x1D53B, 0x1D53E},
+ {0x1D540, 0x1D544}, {0x1D546, 0x1D546}, {0x1D54A, 0x1D550},
+ {0x1D552, 0x1D6A5}, {0x1D6A8, 0x1D7CB}, {0x1D7CE, 0x1DA8B},
+ {0x1DA9B, 0x1DA9F}, {0x1DAA1, 0x1DAAF}, {0x1E000, 0x1E006},
+ {0x1E008, 0x1E018}, {0x1E01B, 0x1E021}, {0x1E023, 0x1E024},
+ {0x1E026, 0x1E02A}, {0x1E800, 0x1E8C4}, {0x1E8C7, 0x1E8D6},
+ {0x1E900, 0x1E94A}, {0x1E950, 0x1E959}, {0x1E95E, 0x1E95F},
{0x1EE00, 0x1EE03}, {0x1EE05, 0x1EE1F}, {0x1EE21, 0x1EE22},
{0x1EE24, 0x1EE24}, {0x1EE27, 0x1EE27}, {0x1EE29, 0x1EE32},
{0x1EE34, 0x1EE37}, {0x1EE39, 0x1EE39}, {0x1EE3B, 0x1EE3B},
@@ -1091,12 +806,16 @@ var neutral = table{
// Condition have flag EastAsianWidth whether the current locale is CJK or not.
type Condition struct {
- EastAsianWidth bool
+ EastAsianWidth bool
+ ZeroWidthJoiner bool
}
// NewCondition return new instance of Condition which is current locale.
func NewCondition() *Condition {
- return &Condition{EastAsianWidth}
+ return &Condition{
+ EastAsianWidth: EastAsianWidth,
+ ZeroWidthJoiner: ZeroWidthJoiner,
+ }
}
// RuneWidth returns the number of cells in r.
@@ -1114,14 +833,37 @@ func (c *Condition) RuneWidth(r rune) int {
}
}
-// StringWidth return width as you can see
-func (c *Condition) StringWidth(s string) (width int) {
+func (c *Condition) stringWidth(s string) (width int) {
for _, r := range []rune(s) {
width += c.RuneWidth(r)
}
return width
}
+func (c *Condition) stringWidthZeroJoiner(s string) (width int) {
+ r1, r2 := rune(0), rune(0)
+ for _, r := range []rune(s) {
+ if r == 0xFE0E || r == 0xFE0F {
+ continue
+ }
+ w := c.RuneWidth(r)
+ if r2 == 0x200D && inTables(r, emoji) && inTables(r1, emoji) {
+ w = 0
+ }
+ width += w
+ r1, r2 = r2, r
+ }
+ return width
+}
+
+// StringWidth return width as you can see
+func (c *Condition) StringWidth(s string) (width int) {
+ if c.ZeroWidthJoiner {
+ return c.stringWidthZeroJoiner(s)
+ }
+ return c.stringWidth(s)
+}
+
// Truncate return string truncated with w cells
func (c *Condition) Truncate(s string, w int, tail string) string {
if c.StringWidth(s) <= w {
diff --git a/vendor/github.com/mattn/go-runewidth/runewidth_appengine.go b/vendor/github.com/mattn/go-runewidth/runewidth_appengine.go
new file mode 100644
index 000000000..7d99f6e52
--- /dev/null
+++ b/vendor/github.com/mattn/go-runewidth/runewidth_appengine.go
@@ -0,0 +1,8 @@
+// +build appengine
+
+package runewidth
+
+// IsEastAsian return true if the current locale is CJK
+func IsEastAsian() bool {
+ return false
+}
diff --git a/vendor/github.com/mattn/go-runewidth/runewidth_js.go b/vendor/github.com/mattn/go-runewidth/runewidth_js.go
index 0ce32c5e7..c5fdf40ba 100644
--- a/vendor/github.com/mattn/go-runewidth/runewidth_js.go
+++ b/vendor/github.com/mattn/go-runewidth/runewidth_js.go
@@ -1,4 +1,5 @@
// +build js
+// +build !appengine
package runewidth
diff --git a/vendor/github.com/mattn/go-runewidth/runewidth_posix.go b/vendor/github.com/mattn/go-runewidth/runewidth_posix.go
index c579e9a31..66a58b5d8 100644
--- a/vendor/github.com/mattn/go-runewidth/runewidth_posix.go
+++ b/vendor/github.com/mattn/go-runewidth/runewidth_posix.go
@@ -1,4 +1,6 @@
-// +build !windows,!js
+// +build !windows
+// +build !js
+// +build !appengine
package runewidth
diff --git a/vendor/github.com/mattn/go-runewidth/runewidth_windows.go b/vendor/github.com/mattn/go-runewidth/runewidth_windows.go
index 0258876b9..d6a61777d 100644
--- a/vendor/github.com/mattn/go-runewidth/runewidth_windows.go
+++ b/vendor/github.com/mattn/go-runewidth/runewidth_windows.go
@@ -1,3 +1,6 @@
+// +build windows
+// +build !appengine
+
package runewidth
import (
diff --git a/vendor/github.com/miekg/dns/README.md b/vendor/github.com/miekg/dns/README.md
index 7f1aaa5de..fd3a2f544 100644
--- a/vendor/github.com/miekg/dns/README.md
+++ b/vendor/github.com/miekg/dns/README.md
@@ -7,10 +7,10 @@
> Less is more.
-Complete and usable DNS library. All widely used Resource Records are supported, including the
-DNSSEC types. It follows a lean and mean philosophy. If there is stuff you should know as a DNS
-programmer there isn't a convenience function for it. Server side and client side programming is
-supported, i.e. you can build servers and resolvers with it.
+Complete and usable DNS library. All Resource Records are supported, including the DNSSEC types.
+It follows a lean and mean philosophy. If there is stuff you should know as a DNS programmer there
+isn't a convenience function for it. Server side and client side programming is supported, i.e. you
+can build servers and resolvers with it.
We try to keep the "master" branch as sane as possible and at the bleeding edge of standards,
avoiding breaking changes wherever reasonable. We support the last two versions of Go.
@@ -42,10 +42,9 @@ A not-so-up-to-date-list-that-may-be-actually-current:
* https://github.com/tianon/rawdns
* https://mesosphere.github.io/mesos-dns/
* https://pulse.turbobytes.com/
-* https://play.google.com/store/apps/details?id=com.turbobytes.dig
* https://github.com/fcambus/statzone
* https://github.com/benschw/dns-clb-go
-* https://github.com/corny/dnscheck for http://public-dns.info/
+* https://github.com/corny/dnscheck for
* https://namesmith.io
* https://github.com/miekg/unbound
* https://github.com/miekg/exdns
@@ -56,7 +55,7 @@ A not-so-up-to-date-list-that-may-be-actually-current:
* https://github.com/bamarni/dockness
* https://github.com/fffaraz/microdns
* http://kelda.io
-* https://github.com/ipdcode/hades (JD.COM)
+* https://github.com/ipdcode/hades
* https://github.com/StackExchange/dnscontrol/
* https://www.dnsperf.com/
* https://dnssectest.net/
@@ -73,24 +72,22 @@ Send pull request if you want to be listed here.
# Features
-* UDP/TCP queries, IPv4 and IPv6;
-* RFC 1035 zone file parsing ($INCLUDE, $ORIGIN, $TTL and $GENERATE (for all record types) are supported;
-* Fast:
- * Reply speed around ~ 80K qps (faster hardware results in more qps);
- * Parsing RRs ~ 100K RR/s, that's 5M records in about 50 seconds;
-* Server side programming (mimicking the net/http package);
-* Client side programming;
-* DNSSEC: signing, validating and key generation for DSA, RSA, ECDSA and Ed25519;
-* EDNS0, NSID, Cookies;
-* AXFR/IXFR;
-* TSIG, SIG(0);
-* DNS over TLS: optional encrypted connection between client and server;
-* DNS name compression;
-* Depends only on the standard library.
+* UDP/TCP queries, IPv4 and IPv6
+* RFC 1035 zone file parsing ($INCLUDE, $ORIGIN, $TTL and $GENERATE (for all record types) are supported
+* Fast
+* Server side programming (mimicking the net/http package)
+* Client side programming
+* DNSSEC: signing, validating and key generation for DSA, RSA, ECDSA and Ed25519
+* EDNS0, NSID, Cookies
+* AXFR/IXFR
+* TSIG, SIG(0)
+* DNS over TLS (DoT): encrypted connection between client and server over TCP
+* DNS name compression
Have fun!
Miek Gieben - 2010-2012 -
+DNS Authors 2012-
# Building
@@ -164,9 +161,9 @@ Example programs can be found in the `github.com/miekg/exdns` repository.
* 7873 - Domain Name System (DNS) Cookies (draft-ietf-dnsop-cookies)
* 8080 - EdDSA for DNSSEC
-## Loosely based upon
+## Loosely Based Upon
-* `ldns`
-* `NSD`
-* `Net::DNS`
-* `GRONG`
+* ldns -
+* NSD -
+* Net::DNS -
+* GRONG -
diff --git a/vendor/github.com/miekg/dns/acceptfunc.go b/vendor/github.com/miekg/dns/acceptfunc.go
new file mode 100644
index 000000000..fcc6104f2
--- /dev/null
+++ b/vendor/github.com/miekg/dns/acceptfunc.go
@@ -0,0 +1,54 @@
+package dns
+
+// MsgAcceptFunc is used early in the server code to accept or reject a message with RcodeFormatError.
+// It returns a MsgAcceptAction to indicate what should happen with the message.
+type MsgAcceptFunc func(dh Header) MsgAcceptAction
+
+// DefaultMsgAcceptFunc checks the request and will reject if:
+//
+// * isn't a request (don't respond in that case).
+// * opcode isn't OpcodeQuery or OpcodeNotify
+// * Zero bit isn't zero
+// * has more than 1 question in the question section
+// * has more than 0 RRs in the Answer section
+// * has more than 0 RRs in the Authority section
+// * has more than 2 RRs in the Additional section
+var DefaultMsgAcceptFunc MsgAcceptFunc = defaultMsgAcceptFunc
+
+// MsgAcceptAction represents the action to be taken.
+type MsgAcceptAction int
+
+const (
+ MsgAccept MsgAcceptAction = iota // Accept the message
+ MsgReject // Reject the message with a RcodeFormatError
+ MsgIgnore // Ignore the error and send nothing back.
+)
+
+var defaultMsgAcceptFunc = func(dh Header) MsgAcceptAction {
+ if isResponse := dh.Bits&_QR != 0; isResponse {
+ return MsgIgnore
+ }
+
+ // Don't allow dynamic updates, because then the sections can contain a whole bunch of RRs.
+ opcode := int(dh.Bits>>11) & 0xF
+ if opcode != OpcodeQuery && opcode != OpcodeNotify {
+ return MsgReject
+ }
+
+ if isZero := dh.Bits&_Z != 0; isZero {
+ return MsgReject
+ }
+ if dh.Qdcount != 1 {
+ return MsgReject
+ }
+ if dh.Ancount != 0 {
+ return MsgReject
+ }
+ if dh.Nscount != 0 {
+ return MsgReject
+ }
+ if dh.Arcount > 2 {
+ return MsgReject
+ }
+ return MsgAccept
+}
diff --git a/vendor/github.com/miekg/dns/client.go b/vendor/github.com/miekg/dns/client.go
index 63ced2bd0..770a946cd 100644
--- a/vendor/github.com/miekg/dns/client.go
+++ b/vendor/github.com/miekg/dns/client.go
@@ -7,11 +7,8 @@ import (
"context"
"crypto/tls"
"encoding/binary"
- "fmt"
"io"
- "io/ioutil"
"net"
- "net/http"
"strings"
"time"
)
@@ -19,8 +16,6 @@ import (
const (
dnsTimeout time.Duration = 2 * time.Second
tcpIdleTimeout time.Duration = 8 * time.Second
-
- dohMimeType = "application/dns-message"
)
// A Conn represents a connection to a DNS server.
@@ -44,7 +39,6 @@ type Client struct {
DialTimeout time.Duration // net.DialTimeout, defaults to 2 seconds, or net.Dialer.Timeout if expiring earlier - overridden by Timeout when that value is non-zero
ReadTimeout time.Duration // net.Conn.SetReadTimeout value for connections, defaults to 2 seconds - overridden by Timeout when that value is non-zero
WriteTimeout time.Duration // net.Conn.SetWriteTimeout value for connections, defaults to 2 seconds - overridden by Timeout when that value is non-zero
- HTTPClient *http.Client // The http.Client to use for DNS-over-HTTPS
TsigSecret map[string]string // secret(s) for Tsig map[], zonename must be in canonical form (lowercase, fqdn, see RFC 4034 Section 6.2)
SingleInflight bool // if true suppress multiple outstanding queries for the same Qname, Qtype and Qclass
group singleflight
@@ -132,11 +126,6 @@ func (c *Client) Dial(address string) (conn *Conn, err error) {
// attribute appropriately
func (c *Client) Exchange(m *Msg, address string) (r *Msg, rtt time.Duration, err error) {
if !c.SingleInflight {
- if c.Net == "https" {
- // TODO(tmthrgd): pipe timeouts into exchangeDOH
- return c.exchangeDOH(context.TODO(), m, address)
- }
-
return c.exchange(m, address)
}
@@ -149,11 +138,6 @@ func (c *Client) Exchange(m *Msg, address string) (r *Msg, rtt time.Duration, er
cl = cl1
}
r, rtt, err, shared := c.group.Do(m.Question[0].Name+t+cl, func() (*Msg, time.Duration, error) {
- if c.Net == "https" {
- // TODO(tmthrgd): pipe timeouts into exchangeDOH
- return c.exchangeDOH(context.TODO(), m, address)
- }
-
return c.exchange(m, address)
})
if r != nil && shared {
@@ -199,67 +183,6 @@ func (c *Client) exchange(m *Msg, a string) (r *Msg, rtt time.Duration, err erro
return r, rtt, err
}
-func (c *Client) exchangeDOH(ctx context.Context, m *Msg, a string) (r *Msg, rtt time.Duration, err error) {
- p, err := m.Pack()
- if err != nil {
- return nil, 0, err
- }
-
- req, err := http.NewRequest(http.MethodPost, a, bytes.NewReader(p))
- if err != nil {
- return nil, 0, err
- }
-
- req.Header.Set("Content-Type", dohMimeType)
- req.Header.Set("Accept", dohMimeType)
-
- hc := http.DefaultClient
- if c.HTTPClient != nil {
- hc = c.HTTPClient
- }
-
- if ctx != context.Background() && ctx != context.TODO() {
- req = req.WithContext(ctx)
- }
-
- t := time.Now()
-
- resp, err := hc.Do(req)
- if err != nil {
- return nil, 0, err
- }
- defer closeHTTPBody(resp.Body)
-
- if resp.StatusCode != http.StatusOK {
- return nil, 0, fmt.Errorf("dns: server returned HTTP %d error: %q", resp.StatusCode, resp.Status)
- }
-
- if ct := resp.Header.Get("Content-Type"); ct != dohMimeType {
- return nil, 0, fmt.Errorf("dns: unexpected Content-Type %q; expected %q", ct, dohMimeType)
- }
-
- p, err = ioutil.ReadAll(resp.Body)
- if err != nil {
- return nil, 0, err
- }
-
- rtt = time.Since(t)
-
- r = new(Msg)
- if err := r.Unpack(p); err != nil {
- return r, 0, err
- }
-
- // TODO: TSIG? Is it even supported over DoH?
-
- return r, rtt, nil
-}
-
-func closeHTTPBody(r io.ReadCloser) error {
- io.Copy(ioutil.Discard, io.LimitReader(r, 8<<20))
- return r.Close()
-}
-
// ReadMsg reads a message from the connection co.
// If the received message contains a TSIG record the transaction signature
// is verified. This method always tries to return the message, however if an
@@ -559,10 +482,6 @@ func DialTimeoutWithTLS(network, address string, tlsConfig *tls.Config, timeout
// context, if present. If there is both a context deadline and a configured
// timeout on the client, the earliest of the two takes effect.
func (c *Client) ExchangeContext(ctx context.Context, m *Msg, a string) (r *Msg, rtt time.Duration, err error) {
- if !c.SingleInflight && c.Net == "https" {
- return c.exchangeDOH(ctx, m, a)
- }
-
var timeout time.Duration
if deadline, ok := ctx.Deadline(); !ok {
timeout = 0
@@ -571,7 +490,7 @@ func (c *Client) ExchangeContext(ctx context.Context, m *Msg, a string) (r *Msg,
}
// not passing the context to the underlying calls, as the API does not support
// context. For timeouts you should set up Client.Dialer and call Client.Exchange.
- // TODO(tmthrgd): this is a race condition
+ // TODO(tmthrgd,miekg): this is a race condition.
c.Dialer = &net.Dialer{Timeout: timeout}
return c.Exchange(m, a)
}
diff --git a/vendor/github.com/miekg/dns/compress_generate.go b/vendor/github.com/miekg/dns/compress_generate.go
deleted file mode 100644
index 9a136c414..000000000
--- a/vendor/github.com/miekg/dns/compress_generate.go
+++ /dev/null
@@ -1,198 +0,0 @@
-//+build ignore
-
-// compression_generate.go is meant to run with go generate. It will use
-// go/{importer,types} to track down all the RR struct types. Then for each type
-// it will look to see if there are (compressible) names, if so it will add that
-// type to compressionLenHelperType and comressionLenSearchType which "fake" the
-// compression so that Len() is fast.
-package main
-
-import (
- "bytes"
- "fmt"
- "go/format"
- "go/importer"
- "go/types"
- "log"
- "os"
-)
-
-var packageHdr = `
-// Code generated by "go run compress_generate.go"; DO NOT EDIT.
-
-package dns
-
-`
-
-// getTypeStruct will take a type and the package scope, and return the
-// (innermost) struct if the type is considered a RR type (currently defined as
-// those structs beginning with a RR_Header, could be redefined as implementing
-// the RR interface). The bool return value indicates if embedded structs were
-// resolved.
-func getTypeStruct(t types.Type, scope *types.Scope) (*types.Struct, bool) {
- st, ok := t.Underlying().(*types.Struct)
- if !ok {
- return nil, false
- }
- if st.Field(0).Type() == scope.Lookup("RR_Header").Type() {
- return st, false
- }
- if st.Field(0).Anonymous() {
- st, _ := getTypeStruct(st.Field(0).Type(), scope)
- return st, true
- }
- return nil, false
-}
-
-func main() {
- // Import and type-check the package
- pkg, err := importer.Default().Import("github.com/miekg/dns")
- fatalIfErr(err)
- scope := pkg.Scope()
-
- var domainTypes []string // Types that have a domain name in them (either compressible or not).
- var cdomainTypes []string // Types that have a compressible domain name in them (subset of domainType)
-Names:
- for _, name := range scope.Names() {
- o := scope.Lookup(name)
- if o == nil || !o.Exported() {
- continue
- }
- st, _ := getTypeStruct(o.Type(), scope)
- if st == nil {
- continue
- }
- if name == "PrivateRR" {
- continue
- }
-
- if scope.Lookup("Type"+o.Name()) == nil && o.Name() != "RFC3597" {
- log.Fatalf("Constant Type%s does not exist.", o.Name())
- }
-
- for i := 1; i < st.NumFields(); i++ {
- if _, ok := st.Field(i).Type().(*types.Slice); ok {
- if st.Tag(i) == `dns:"domain-name"` {
- domainTypes = append(domainTypes, o.Name())
- continue Names
- }
- if st.Tag(i) == `dns:"cdomain-name"` {
- cdomainTypes = append(cdomainTypes, o.Name())
- domainTypes = append(domainTypes, o.Name())
- continue Names
- }
- continue
- }
-
- switch {
- case st.Tag(i) == `dns:"domain-name"`:
- domainTypes = append(domainTypes, o.Name())
- continue Names
- case st.Tag(i) == `dns:"cdomain-name"`:
- cdomainTypes = append(cdomainTypes, o.Name())
- domainTypes = append(domainTypes, o.Name())
- continue Names
- }
- }
- }
-
- b := &bytes.Buffer{}
- b.WriteString(packageHdr)
-
- // compressionLenHelperType - all types that have domain-name/cdomain-name can be used for compressing names
-
- fmt.Fprint(b, "func compressionLenHelperType(c map[string]int, r RR, initLen int) int {\n")
- fmt.Fprint(b, "currentLen := initLen\n")
- fmt.Fprint(b, "switch x := r.(type) {\n")
- for _, name := range domainTypes {
- o := scope.Lookup(name)
- st, _ := getTypeStruct(o.Type(), scope)
-
- fmt.Fprintf(b, "case *%s:\n", name)
- for i := 1; i < st.NumFields(); i++ {
- out := func(s string) {
- fmt.Fprintf(b, "currentLen -= len(x.%s) + 1\n", st.Field(i).Name())
- fmt.Fprintf(b, "currentLen += compressionLenHelper(c, x.%s, currentLen)\n", st.Field(i).Name())
- }
-
- if _, ok := st.Field(i).Type().(*types.Slice); ok {
- switch st.Tag(i) {
- case `dns:"domain-name"`:
- fallthrough
- case `dns:"cdomain-name"`:
- // For HIP we need to slice over the elements in this slice.
- fmt.Fprintf(b, `for i := range x.%s {
- currentLen -= len(x.%s[i]) + 1
-}
-`, st.Field(i).Name(), st.Field(i).Name())
- fmt.Fprintf(b, `for i := range x.%s {
- currentLen += compressionLenHelper(c, x.%s[i], currentLen)
-}
-`, st.Field(i).Name(), st.Field(i).Name())
- }
- continue
- }
-
- switch {
- case st.Tag(i) == `dns:"cdomain-name"`:
- fallthrough
- case st.Tag(i) == `dns:"domain-name"`:
- out(st.Field(i).Name())
- }
- }
- }
- fmt.Fprintln(b, "}\nreturn currentLen - initLen\n}\n\n")
-
- // compressionLenSearchType - search cdomain-tags types for compressible names.
-
- fmt.Fprint(b, "func compressionLenSearchType(c map[string]int, r RR) (int, bool, int) {\n")
- fmt.Fprint(b, "switch x := r.(type) {\n")
- for _, name := range cdomainTypes {
- o := scope.Lookup(name)
- st, _ := getTypeStruct(o.Type(), scope)
-
- fmt.Fprintf(b, "case *%s:\n", name)
- j := 1
- for i := 1; i < st.NumFields(); i++ {
- out := func(s string, j int) {
- fmt.Fprintf(b, "k%d, ok%d, sz%d := compressionLenSearch(c, x.%s)\n", j, j, j, st.Field(i).Name())
- }
-
- // There are no slice types with names that can be compressed.
-
- switch {
- case st.Tag(i) == `dns:"cdomain-name"`:
- out(st.Field(i).Name(), j)
- j++
- }
- }
- k := "k1"
- ok := "ok1"
- sz := "sz1"
- for i := 2; i < j; i++ {
- k += fmt.Sprintf(" + k%d", i)
- ok += fmt.Sprintf(" && ok%d", i)
- sz += fmt.Sprintf(" + sz%d", i)
- }
- fmt.Fprintf(b, "return %s, %s, %s\n", k, ok, sz)
- }
- fmt.Fprintln(b, "}\nreturn 0, false, 0\n}\n\n")
-
- // gofmt
- res, err := format.Source(b.Bytes())
- if err != nil {
- b.WriteTo(os.Stderr)
- log.Fatal(err)
- }
-
- f, err := os.Create("zcompress.go")
- fatalIfErr(err)
- defer f.Close()
- f.Write(res)
-}
-
-func fatalIfErr(err error) {
- if err != nil {
- log.Fatal(err)
- }
-}
diff --git a/vendor/github.com/miekg/dns/defaults.go b/vendor/github.com/miekg/dns/defaults.go
index 14e18b0b3..1778b1cad 100644
--- a/vendor/github.com/miekg/dns/defaults.go
+++ b/vendor/github.com/miekg/dns/defaults.go
@@ -166,7 +166,7 @@ func (dns *Msg) IsEdns0() *OPT {
// label fits in 63 characters, but there is no length check for the entire
// string s. I.e. a domain name longer than 255 characters is considered valid.
func IsDomainName(s string) (labels int, ok bool) {
- _, labels, err := packDomainName(s, nil, 0, nil, false)
+ _, labels, err := packDomainName(s, nil, 0, compressionMap{}, false)
return labels, err == nil
}
diff --git a/vendor/github.com/miekg/dns/dns.go b/vendor/github.com/miekg/dns/dns.go
index e7557f51a..aefffa793 100644
--- a/vendor/github.com/miekg/dns/dns.go
+++ b/vendor/github.com/miekg/dns/dns.go
@@ -34,10 +34,15 @@ type RR interface {
// copy returns a copy of the RR
copy() RR
- // len returns the length (in octets) of the uncompressed RR in wire format.
- len() int
+
+ // len returns the length (in octets) of the compressed or uncompressed RR in wire format.
+ //
+ // If compression is nil, the uncompressed size will be returned, otherwise the compressed
+ // size will be returned and domain names will be added to the map for future compression.
+ len(off int, compression map[string]struct{}) int
+
// pack packs an RR into wire format.
- pack([]byte, int, map[string]int, bool) (int, error)
+ pack(msg []byte, off int, compression compressionMap, compress bool) (headerEnd int, off1 int, err error)
}
// RR_Header is the header all DNS resource records share.
@@ -70,28 +75,29 @@ func (h *RR_Header) String() string {
return s
}
-func (h *RR_Header) len() int {
- l := len(h.Name) + 1
+func (h *RR_Header) len(off int, compression map[string]struct{}) int {
+ l := domainNameLen(h.Name, off, compression, true)
l += 10 // rrtype(2) + class(2) + ttl(4) + rdlength(2)
return l
}
// ToRFC3597 converts a known RR to the unknown RR representation from RFC 3597.
func (rr *RFC3597) ToRFC3597(r RR) error {
- buf := make([]byte, r.len()*2)
- off, err := PackRR(r, buf, 0, nil, false)
+ buf := make([]byte, Len(r)*2)
+ headerEnd, off, err := packRR(r, buf, 0, compressionMap{}, false)
if err != nil {
return err
}
buf = buf[:off]
- if int(r.Header().Rdlength) > off {
- return ErrBuf
- }
- rfc3597, _, err := unpackRFC3597(*r.Header(), buf, off-int(r.Header().Rdlength))
+ hdr := *r.Header()
+ hdr.Rdlength = uint16(off - headerEnd)
+
+ rfc3597, _, err := unpackRFC3597(hdr, buf, headerEnd)
if err != nil {
return err
}
+
*rr = *rfc3597.(*RFC3597)
return nil
}
diff --git a/vendor/github.com/miekg/dns/dnssec.go b/vendor/github.com/miekg/dns/dnssec.go
index 26b512e7d..9b39d4273 100644
--- a/vendor/github.com/miekg/dns/dnssec.go
+++ b/vendor/github.com/miekg/dns/dnssec.go
@@ -401,7 +401,7 @@ func (rr *RRSIG) Verify(k *DNSKEY, rrset []RR) error {
if rr.Algorithm != k.Algorithm {
return ErrKey
}
- if strings.ToLower(rr.SignerName) != strings.ToLower(k.Hdr.Name) {
+ if !strings.EqualFold(rr.SignerName, k.Hdr.Name) {
return ErrKey
}
if k.Protocol != 3 {
@@ -724,7 +724,7 @@ func rawSignatureData(rrset []RR, s *RRSIG) (buf []byte, err error) {
x.Target = strings.ToLower(x.Target)
}
// 6.2. Canonical RR Form. (5) - origTTL
- wire := make([]byte, r1.len()+1) // +1 to be safe(r)
+ wire := make([]byte, Len(r1)+1) // +1 to be safe(r)
off, err1 := PackRR(r1, wire, 0, nil, false)
if err1 != nil {
return nil, err1
diff --git a/vendor/github.com/miekg/dns/doc.go b/vendor/github.com/miekg/dns/doc.go
index 0389d7248..d3d7cec9e 100644
--- a/vendor/github.com/miekg/dns/doc.go
+++ b/vendor/github.com/miekg/dns/doc.go
@@ -1,20 +1,20 @@
/*
Package dns implements a full featured interface to the Domain Name System.
-Server- and client-side programming is supported.
-The package allows complete control over what is sent out to the DNS. The package
-API follows the less-is-more principle, by presenting a small, clean interface.
+Both server- and client-side programming is supported. The package allows
+complete control over what is sent out to the DNS. The API follows the
+less-is-more principle, by presenting a small, clean interface.
-The package dns supports (asynchronous) querying/replying, incoming/outgoing zone transfers,
+It supports (asynchronous) querying/replying, incoming/outgoing zone transfers,
TSIG, EDNS0, dynamic updates, notifies and DNSSEC validation/signing.
-Note that domain names MUST be fully qualified, before sending them, unqualified
+
+Note that domain names MUST be fully qualified before sending them, unqualified
names in a message will result in a packing failure.
-Resource records are native types. They are not stored in wire format.
-Basic usage pattern for creating a new resource record:
+Resource records are native types. They are not stored in wire format. Basic
+usage pattern for creating a new resource record:
r := new(dns.MX)
- r.Hdr = dns.RR_Header{Name: "miek.nl.", Rrtype: dns.TypeMX,
- Class: dns.ClassINET, Ttl: 3600}
+ r.Hdr = dns.RR_Header{Name: "miek.nl.", Rrtype: dns.TypeMX, Class: dns.ClassINET, Ttl: 3600}
r.Preference = 10
r.Mx = "mx.miek.nl."
@@ -30,8 +30,8 @@ Or even:
mx, err := dns.NewRR("$ORIGIN nl.\nmiek 1H IN MX 10 mx.miek")
-In the DNS messages are exchanged, these messages contain resource
-records (sets). Use pattern for creating a message:
+In the DNS messages are exchanged, these messages contain resource records
+(sets). Use pattern for creating a message:
m := new(dns.Msg)
m.SetQuestion("miek.nl.", dns.TypeMX)
@@ -40,8 +40,8 @@ Or when not certain if the domain name is fully qualified:
m.SetQuestion(dns.Fqdn("miek.nl"), dns.TypeMX)
-The message m is now a message with the question section set to ask
-the MX records for the miek.nl. zone.
+The message m is now a message with the question section set to ask the MX
+records for the miek.nl. zone.
The following is slightly more verbose, but more flexible:
@@ -51,9 +51,8 @@ The following is slightly more verbose, but more flexible:
m1.Question = make([]dns.Question, 1)
m1.Question[0] = dns.Question{"miek.nl.", dns.TypeMX, dns.ClassINET}
-After creating a message it can be sent.
-Basic use pattern for synchronous querying the DNS at a
-server configured on 127.0.0.1 and port 53:
+After creating a message it can be sent. Basic use pattern for synchronous
+querying the DNS at a server configured on 127.0.0.1 and port 53:
c := new(dns.Client)
in, rtt, err := c.Exchange(m1, "127.0.0.1:53")
@@ -99,25 +98,24 @@ the Answer section:
Domain Name and TXT Character String Representations
-Both domain names and TXT character strings are converted to presentation
-form both when unpacked and when converted to strings.
+Both domain names and TXT character strings are converted to presentation form
+both when unpacked and when converted to strings.
For TXT character strings, tabs, carriage returns and line feeds will be
-converted to \t, \r and \n respectively. Back slashes and quotations marks
-will be escaped. Bytes below 32 and above 127 will be converted to \DDD
-form.
+converted to \t, \r and \n respectively. Back slashes and quotations marks will
+be escaped. Bytes below 32 and above 127 will be converted to \DDD form.
-For domain names, in addition to the above rules brackets, periods,
-spaces, semicolons and the at symbol are escaped.
+For domain names, in addition to the above rules brackets, periods, spaces,
+semicolons and the at symbol are escaped.
DNSSEC
-DNSSEC (DNS Security Extension) adds a layer of security to the DNS. It
-uses public key cryptography to sign resource records. The
-public keys are stored in DNSKEY records and the signatures in RRSIG records.
+DNSSEC (DNS Security Extension) adds a layer of security to the DNS. It uses
+public key cryptography to sign resource records. The public keys are stored in
+DNSKEY records and the signatures in RRSIG records.
-Requesting DNSSEC information for a zone is done by adding the DO (DNSSEC OK) bit
-to a request.
+Requesting DNSSEC information for a zone is done by adding the DO (DNSSEC OK)
+bit to a request.
m := new(dns.Msg)
m.SetEdns0(4096, true)
@@ -126,9 +124,9 @@ Signature generation, signature verification and key generation are all supporte
DYNAMIC UPDATES
-Dynamic updates reuses the DNS message format, but renames three of
-the sections. Question is Zone, Answer is Prerequisite, Authority is
-Update, only the Additional is not renamed. See RFC 2136 for the gory details.
+Dynamic updates reuses the DNS message format, but renames three of the
+sections. Question is Zone, Answer is Prerequisite, Authority is Update, only
+the Additional is not renamed. See RFC 2136 for the gory details.
You can set a rather complex set of rules for the existence of absence of
certain resource records or names in a zone to specify if resource records
@@ -145,10 +143,9 @@ DNS function shows which functions exist to specify the prerequisites.
NONE rrset empty RRset does not exist dns.RRsetNotUsed
zone rrset rr RRset exists (value dep) dns.Used
-The prerequisite section can also be left empty.
-If you have decided on the prerequisites you can tell what RRs should
-be added or deleted. The next table shows the options you have and
-what functions to call.
+The prerequisite section can also be left empty. If you have decided on the
+prerequisites you can tell what RRs should be added or deleted. The next table
+shows the options you have and what functions to call.
3.4.2.6 - Table Of Metavalues Used In Update Section
@@ -181,10 +178,10 @@ changes to the RRset after calling SetTsig() the signature will be incorrect.
...
// When sending the TSIG RR is calculated and filled in before sending
-When requesting an zone transfer (almost all TSIG usage is when requesting zone transfers), with
-TSIG, this is the basic use pattern. In this example we request an AXFR for
-miek.nl. with TSIG key named "axfr." and secret "so6ZGir4GPAqINNh9U5c3A=="
-and using the server 176.58.119.54:
+When requesting an zone transfer (almost all TSIG usage is when requesting zone
+transfers), with TSIG, this is the basic use pattern. In this example we
+request an AXFR for miek.nl. with TSIG key named "axfr." and secret
+"so6ZGir4GPAqINNh9U5c3A==" and using the server 176.58.119.54:
t := new(dns.Transfer)
m := new(dns.Msg)
@@ -194,8 +191,8 @@ and using the server 176.58.119.54:
c, err := t.In(m, "176.58.119.54:53")
for r := range c { ... }
-You can now read the records from the transfer as they come in. Each envelope is checked with TSIG.
-If something is not correct an error is returned.
+You can now read the records from the transfer as they come in. Each envelope
+is checked with TSIG. If something is not correct an error is returned.
Basic use pattern validating and replying to a message that has TSIG set.
@@ -220,29 +217,30 @@ Basic use pattern validating and replying to a message that has TSIG set.
PRIVATE RRS
-RFC 6895 sets aside a range of type codes for private use. This range
-is 65,280 - 65,534 (0xFF00 - 0xFFFE). When experimenting with new Resource Records these
+RFC 6895 sets aside a range of type codes for private use. This range is 65,280
+- 65,534 (0xFF00 - 0xFFFE). When experimenting with new Resource Records these
can be used, before requesting an official type code from IANA.
-see http://miek.nl/2014/September/21/idn-and-private-rr-in-go-dns/ for more
+See https://miek.nl/2014/September/21/idn-and-private-rr-in-go-dns/ for more
information.
EDNS0
-EDNS0 is an extension mechanism for the DNS defined in RFC 2671 and updated
-by RFC 6891. It defines an new RR type, the OPT RR, which is then completely
+EDNS0 is an extension mechanism for the DNS defined in RFC 2671 and updated by
+RFC 6891. It defines an new RR type, the OPT RR, which is then completely
abused.
+
Basic use pattern for creating an (empty) OPT RR:
o := new(dns.OPT)
o.Hdr.Name = "." // MUST be the root zone, per definition.
o.Hdr.Rrtype = dns.TypeOPT
-The rdata of an OPT RR consists out of a slice of EDNS0 (RFC 6891)
-interfaces. Currently only a few have been standardized: EDNS0_NSID
-(RFC 5001) and EDNS0_SUBNET (draft-vandergaast-edns-client-subnet-02). Note
-that these options may be combined in an OPT RR.
-Basic use pattern for a server to check if (and which) options are set:
+The rdata of an OPT RR consists out of a slice of EDNS0 (RFC 6891) interfaces.
+Currently only a few have been standardized: EDNS0_NSID (RFC 5001) and
+EDNS0_SUBNET (draft-vandergaast-edns-client-subnet-02). Note that these options
+may be combined in an OPT RR. Basic use pattern for a server to check if (and
+which) options are set:
// o is a dns.OPT
for _, s := range o.Option {
@@ -262,10 +260,9 @@ From RFC 2931:
... protection for glue records, DNS requests, protection for message headers
on requests and responses, and protection of the overall integrity of a response.
-It works like TSIG, except that SIG(0) uses public key cryptography, instead of the shared
-secret approach in TSIG.
-Supported algorithms: DSA, ECDSAP256SHA256, ECDSAP384SHA384, RSASHA1, RSASHA256 and
-RSASHA512.
+It works like TSIG, except that SIG(0) uses public key cryptography, instead of
+the shared secret approach in TSIG. Supported algorithms: DSA, ECDSAP256SHA256,
+ECDSAP384SHA384, RSASHA1, RSASHA256 and RSASHA512.
Signing subsequent messages in multi-message sessions is not implemented.
*/
diff --git a/vendor/github.com/miekg/dns/edns.go b/vendor/github.com/miekg/dns/edns.go
index 18d054139..f8c60e616 100644
--- a/vendor/github.com/miekg/dns/edns.go
+++ b/vendor/github.com/miekg/dns/edns.go
@@ -78,8 +78,8 @@ func (rr *OPT) String() string {
return s
}
-func (rr *OPT) len() int {
- l := rr.Hdr.len()
+func (rr *OPT) len(off int, compression map[string]struct{}) int {
+ l := rr.Hdr.len(off, compression)
for i := 0; i < len(rr.Option); i++ {
l += 4 // Account for 2-byte option code and 2-byte option length.
lo, _ := rr.Option[i].pack()
@@ -102,15 +102,14 @@ func (rr *OPT) SetVersion(v uint8) {
// ExtendedRcode returns the EDNS extended RCODE field (the upper 8 bits of the TTL).
func (rr *OPT) ExtendedRcode() int {
- return int(rr.Hdr.Ttl&0xFF000000>>24) + 15
+ return int(rr.Hdr.Ttl&0xFF000000>>24) << 4
}
// SetExtendedRcode sets the EDNS extended RCODE field.
-func (rr *OPT) SetExtendedRcode(v uint8) {
- if v < RcodeBadVers { // Smaller than 16.. Use the 4 bits you have!
- return
- }
- rr.Hdr.Ttl = rr.Hdr.Ttl&0x00FFFFFF | uint32(v-15)<<24
+//
+// If the RCODE is not an extended RCODE, will reset the extended RCODE field to 0.
+func (rr *OPT) SetExtendedRcode(v uint16) {
+ rr.Hdr.Ttl = rr.Hdr.Ttl&0x00FFFFFF | uint32(v>>4)<<24
}
// UDPSize returns the UDP buffer size.
@@ -274,22 +273,16 @@ func (e *EDNS0_SUBNET) unpack(b []byte) error {
if e.SourceNetmask > net.IPv4len*8 || e.SourceScope > net.IPv4len*8 {
return errors.New("dns: bad netmask")
}
- addr := make([]byte, net.IPv4len)
- for i := 0; i < net.IPv4len && 4+i < len(b); i++ {
- addr[i] = b[4+i]
- }
- e.Address = net.IPv4(addr[0], addr[1], addr[2], addr[3])
+ addr := make(net.IP, net.IPv4len)
+ copy(addr, b[4:])
+ e.Address = addr.To16()
case 2:
if e.SourceNetmask > net.IPv6len*8 || e.SourceScope > net.IPv6len*8 {
return errors.New("dns: bad netmask")
}
- addr := make([]byte, net.IPv6len)
- for i := 0; i < net.IPv6len && 4+i < len(b); i++ {
- addr[i] = b[4+i]
- }
- e.Address = net.IP{addr[0], addr[1], addr[2], addr[3], addr[4],
- addr[5], addr[6], addr[7], addr[8], addr[9], addr[10],
- addr[11], addr[12], addr[13], addr[14], addr[15]}
+ addr := make(net.IP, net.IPv6len)
+ copy(addr, b[4:])
+ e.Address = addr
default:
return errors.New("dns: bad address family")
}
diff --git a/vendor/github.com/miekg/dns/msg.go b/vendor/github.com/miekg/dns/msg.go
index 47ac6cf28..33f14c489 100644
--- a/vendor/github.com/miekg/dns/msg.go
+++ b/vendor/github.com/miekg/dns/msg.go
@@ -9,7 +9,6 @@
package dns
//go:generate go run msg_generate.go
-//go:generate go run compress_generate.go
import (
crand "crypto/rand"
@@ -18,12 +17,35 @@ import (
"math/big"
"math/rand"
"strconv"
+ "strings"
"sync"
)
const (
maxCompressionOffset = 2 << 13 // We have 14 bits for the compression pointer
maxDomainNameWireOctets = 255 // See RFC 1035 section 2.3.4
+
+ // This is the maximum number of compression pointers that should occur in a
+ // semantically valid message. Each label in a domain name must be at least one
+ // octet and is separated by a period. The root label won't be represented by a
+ // compression pointer to a compression pointer, hence the -2 to exclude the
+ // smallest valid root label.
+ //
+ // It is possible to construct a valid message that has more compression pointers
+ // than this, and still doesn't loop, by pointing to a previous pointer. This is
+ // not something a well written implementation should ever do, so we leave them
+ // to trip the maximum compression pointer check.
+ maxCompressionPointers = (maxDomainNameWireOctets+1)/2 - 2
+
+ // This is the maximum length of a domain name in presentation format. The
+ // maximum wire length of a domain name is 255 octets (see above), with the
+ // maximum label length being 63. The wire format requires one extra byte over
+ // the presentation format, reducing the number of octets by 1. Each label in
+ // the name will be separated by a single period, with each octet in the label
+ // expanding to at most 4 bytes (\DDD). If all other labels are of the maximum
+ // length, then the final label can only be 61 octets long to not exceed the
+ // maximum allowed wire length.
+ maxDomainNamePresentationLength = 61*4 + 1 + 63*4 + 1 + 63*4 + 1 + 63*4 + 1
)
// Errors defined in this package.
@@ -46,10 +68,9 @@ var (
ErrRRset error = &Error{err: "bad rrset"}
ErrSecret error = &Error{err: "no secrets defined"}
ErrShortRead error = &Error{err: "short read"}
- ErrSig error = &Error{err: "bad signature"} // ErrSig indicates that a signature can not be cryptographically validated.
- ErrSoa error = &Error{err: "no SOA"} // ErrSOA indicates that no SOA RR was seen when doing zone transfers.
- ErrTime error = &Error{err: "bad time"} // ErrTime indicates a timing error in TSIG authentication.
- ErrTruncated error = &Error{err: "failed to unpack truncated message"} // ErrTruncated indicates that we failed to unpack a truncated message. We unpacked as much as we had so Msg can still be used, if desired.
+ ErrSig error = &Error{err: "bad signature"} // ErrSig indicates that a signature can not be cryptographically validated.
+ ErrSoa error = &Error{err: "no SOA"} // ErrSOA indicates that no SOA RR was seen when doing zone transfers.
+ ErrTime error = &Error{err: "bad time"} // ErrTime indicates a timing error in TSIG authentication.
)
// Id by default, returns a 16 bits random number to be used as a
@@ -151,7 +172,7 @@ var RcodeToString = map[int]string{
RcodeFormatError: "FORMERR",
RcodeServerFailure: "SERVFAIL",
RcodeNameError: "NXDOMAIN",
- RcodeNotImplemented: "NOTIMPL",
+ RcodeNotImplemented: "NOTIMP",
RcodeRefused: "REFUSED",
RcodeYXDomain: "YXDOMAIN", // See RFC 2136
RcodeYXRrset: "YXRRSET",
@@ -169,6 +190,39 @@ var RcodeToString = map[int]string{
RcodeBadCookie: "BADCOOKIE",
}
+// compressionMap is used to allow a more efficient compression map
+// to be used for internal packDomainName calls without changing the
+// signature or functionality of public API.
+//
+// In particular, map[string]uint16 uses 25% less per-entry memory
+// than does map[string]int.
+type compressionMap struct {
+ ext map[string]int // external callers
+ int map[string]uint16 // internal callers
+}
+
+func (m compressionMap) valid() bool {
+ return m.int != nil || m.ext != nil
+}
+
+func (m compressionMap) insert(s string, pos int) {
+ if m.ext != nil {
+ m.ext[s] = pos
+ } else {
+ m.int[s] = uint16(pos)
+ }
+}
+
+func (m compressionMap) find(s string) (int, bool) {
+ if m.ext != nil {
+ pos, ok := m.ext[s]
+ return pos, ok
+ }
+
+ pos, ok := m.int[s]
+ return int(pos), ok
+}
+
// Domain names are a sequence of counted strings
// split at the dots. They end with a zero-length string.
@@ -177,149 +231,168 @@ var RcodeToString = map[int]string{
// map needs to hold a mapping between domain names and offsets
// pointing into msg.
func PackDomainName(s string, msg []byte, off int, compression map[string]int, compress bool) (off1 int, err error) {
- off1, _, err = packDomainName(s, msg, off, compression, compress)
+ off1, _, err = packDomainName(s, msg, off, compressionMap{ext: compression}, compress)
return
}
-func packDomainName(s string, msg []byte, off int, compression map[string]int, compress bool) (off1 int, labels int, err error) {
+func packDomainName(s string, msg []byte, off int, compression compressionMap, compress bool) (off1 int, labels int, err error) {
// special case if msg == nil
lenmsg := 256
if msg != nil {
lenmsg = len(msg)
}
+
ls := len(s)
if ls == 0 { // Ok, for instance when dealing with update RR without any rdata.
return off, 0, nil
}
- // If not fully qualified, error out, but only if msg == nil #ugly
- switch {
- case msg == nil:
- if s[ls-1] != '.' {
- s += "."
- ls++
- }
- case msg != nil:
- if s[ls-1] != '.' {
+
+ // If not fully qualified, error out, but only if msg != nil #ugly
+ if s[ls-1] != '.' {
+ if msg != nil {
return lenmsg, 0, ErrFqdn
}
+ s += "."
+ ls++
}
+
// Each dot ends a segment of the name.
// We trade each dot byte for a length byte.
// Except for escaped dots (\.), which are normal dots.
// There is also a trailing zero.
// Compression
- nameoffset := -1
pointer := -1
+
// Emit sequence of counted strings, chopping at dots.
- begin := 0
- bs := []byte(s)
- roBs, bsFresh, escapedDot := s, true, false
+ var (
+ begin int
+ compBegin int
+ compOff int
+ bs []byte
+ wasDot bool
+ )
+loop:
for i := 0; i < ls; i++ {
- if bs[i] == '\\' {
- for j := i; j < ls-1; j++ {
- bs[j] = bs[j+1]
- }
- ls--
+ var c byte
+ if bs == nil {
+ c = s[i]
+ } else {
+ c = bs[i]
+ }
+
+ switch c {
+ case '\\':
if off+1 > lenmsg {
return lenmsg, labels, ErrBuf
}
+
+ if bs == nil {
+ bs = []byte(s)
+ }
+
// check for \DDD
- if i+2 < ls && isDigit(bs[i]) && isDigit(bs[i+1]) && isDigit(bs[i+2]) {
- bs[i] = dddToByte(bs[i:])
- for j := i + 1; j < ls-2; j++ {
- bs[j] = bs[j+2]
- }
- ls -= 2
+ if i+3 < ls && isDigit(bs[i+1]) && isDigit(bs[i+2]) && isDigit(bs[i+3]) {
+ bs[i] = dddToByte(bs[i+1:])
+ copy(bs[i+1:ls-3], bs[i+4:])
+ ls -= 3
+ compOff += 3
+ } else {
+ copy(bs[i:ls-1], bs[i+1:])
+ ls--
+ compOff++
}
- escapedDot = bs[i] == '.'
- bsFresh = false
- continue
- }
- if bs[i] == '.' {
- if i > 0 && bs[i-1] == '.' && !escapedDot {
+ wasDot = false
+ case '.':
+ if wasDot {
// two dots back to back is not legal
return lenmsg, labels, ErrRdata
}
- if i-begin >= 1<<6 { // top two bits of length must be clear
+ wasDot = true
+
+ labelLen := i - begin
+ if labelLen >= 1<<6 { // top two bits of length must be clear
return lenmsg, labels, ErrRdata
}
+
// off can already (we're in a loop) be bigger than len(msg)
// this happens when a name isn't fully qualified
- if off+1 > lenmsg {
+ if off+1+labelLen > lenmsg {
return lenmsg, labels, ErrBuf
}
- if msg != nil {
- msg[off] = byte(i - begin)
- }
- offset := off
- off++
- for j := begin; j < i; j++ {
- if off+1 > lenmsg {
- return lenmsg, labels, ErrBuf
- }
- if msg != nil {
- msg[off] = bs[j]
- }
- off++
- }
- if compress && !bsFresh {
- roBs = string(bs)
- bsFresh = true
- }
+
// Don't try to compress '.'
- // We should only compress when compress it true, but we should also still pick
+ // We should only compress when compress is true, but we should also still pick
// up names that can be used for *future* compression(s).
- if compression != nil && roBs[begin:] != "." {
- if p, ok := compression[roBs[begin:]]; !ok {
- // Only offsets smaller than this can be used.
- if offset < maxCompressionOffset {
- compression[roBs[begin:]] = offset
- }
- } else {
+ if compression.valid() && !isRootLabel(s, bs, begin, ls) {
+ if p, ok := compression.find(s[compBegin:]); ok {
// The first hit is the longest matching dname
// keep the pointer offset we get back and store
// the offset of the current name, because that's
// where we need to insert the pointer later
// If compress is true, we're allowed to compress this dname
- if pointer == -1 && compress {
- pointer = p // Where to point to
- nameoffset = offset // Where to point from
- break
+ if compress {
+ pointer = p // Where to point to
+ break loop
}
+ } else if off < maxCompressionOffset {
+ // Only offsets smaller than maxCompressionOffset can be used.
+ compression.insert(s[compBegin:], off)
+ }
+ }
+
+ // The following is covered by the length check above.
+ if msg != nil {
+ msg[off] = byte(labelLen)
+
+ if bs == nil {
+ copy(msg[off+1:], s[begin:i])
+ } else {
+ copy(msg[off+1:], bs[begin:i])
}
}
+ off += 1 + labelLen
+
labels++
begin = i + 1
+ compBegin = begin + compOff
+ default:
+ wasDot = false
}
- escapedDot = false
}
+
// Root label is special
- if len(bs) == 1 && bs[0] == '.' {
+ if isRootLabel(s, bs, 0, ls) {
return off, labels, nil
}
+
// If we did compression and we find something add the pointer here
if pointer != -1 {
- // Clear the msg buffer after the pointer location, otherwise
- // packDataNsec writes the wrong data to msg.
- tainted := msg[nameoffset:off]
- for i := range tainted {
- tainted[i] = 0
- }
// We have two bytes (14 bits) to put the pointer in
// if msg == nil, we will never do compression
- binary.BigEndian.PutUint16(msg[nameoffset:], uint16(pointer^0xC000))
- off = nameoffset + 1
- goto End
+ binary.BigEndian.PutUint16(msg[off:], uint16(pointer^0xC000))
+ return off + 2, labels, nil
}
- if msg != nil && off < len(msg) {
+
+ if msg != nil && off < lenmsg {
msg[off] = 0
}
-End:
- off++
- return off, labels, nil
+
+ return off + 1, labels, nil
+}
+
+// isRootLabel returns whether s or bs, from off to end, is the root
+// label ".".
+//
+// If bs is nil, s will be checked, otherwise bs will be checked.
+func isRootLabel(s string, bs []byte, off, end int) bool {
+ if bs == nil {
+ return s[off:end] == "."
+ }
+
+ return end-off == 1 && bs[off] == '.'
}
// Unpack a domain name.
@@ -336,12 +409,16 @@ End:
// In theory, the pointers are only allowed to jump backward.
// We let them jump anywhere and stop jumping after a while.
-// UnpackDomainName unpacks a domain name into a string.
+// UnpackDomainName unpacks a domain name into a string. It returns
+// the name, the new offset into msg and any error that occurred.
+//
+// When an error is encountered, the unpacked name will be discarded
+// and len(msg) will be returned as the offset.
func UnpackDomainName(msg []byte, off int) (string, int, error) {
- s := make([]byte, 0, 64)
+ s := make([]byte, 0, maxDomainNamePresentationLength)
off1 := 0
lenmsg := len(msg)
- maxLen := maxDomainNameWireOctets
+ budget := maxDomainNameWireOctets
ptr := 0 // number of pointers followed
Loop:
for {
@@ -360,25 +437,19 @@ Loop:
if off+c > lenmsg {
return "", lenmsg, ErrBuf
}
+ budget -= c + 1 // +1 for the label separator
+ if budget <= 0 {
+ return "", lenmsg, ErrLongDomain
+ }
for j := off; j < off+c; j++ {
switch b := msg[j]; b {
case '.', '(', ')', ';', ' ', '@':
fallthrough
case '"', '\\':
s = append(s, '\\', b)
- // presentation-format \X escapes add an extra byte
- maxLen++
default:
- if b < 32 || b >= 127 { // unprintable, use \DDD
- var buf [3]byte
- bufs := strconv.AppendInt(buf[:0], int64(b), 10)
- s = append(s, '\\')
- for i := len(bufs); i < 3; i++ {
- s = append(s, '0')
- }
- s = append(s, bufs...)
- // presentation-format \DDD escapes add 3 extra bytes
- maxLen += 3
+ if b < ' ' || b > '~' { // unprintable, use \DDD
+ s = append(s, escapeByte(b)...)
} else {
s = append(s, b)
}
@@ -400,7 +471,7 @@ Loop:
if ptr == 0 {
off1 = off
}
- if ptr++; ptr > 10 {
+ if ptr++; ptr > maxCompressionPointers {
return "", lenmsg, &Error{err: "too many compression pointers"}
}
// pointer should guarantee that it advances and points forwards at least
@@ -416,10 +487,7 @@ Loop:
off1 = off
}
if len(s) == 0 {
- s = []byte(".")
- } else if len(s) >= maxLen {
- // error if the name is too long, but don't throw it away
- return string(s), lenmsg, ErrLongDomain
+ return ".", off1, nil
}
return string(s), off1, nil
}
@@ -528,10 +596,12 @@ func unpackTxt(msg []byte, off0 int) (ss []string, off int, err error) {
func isDigit(b byte) bool { return b >= '0' && b <= '9' }
func dddToByte(s []byte) byte {
+ _ = s[2] // bounds check hint to compiler; see golang.org/issue/14808
return byte((s[0]-'0')*100 + (s[1]-'0')*10 + (s[2] - '0'))
}
func dddStringToByte(s string) byte {
+ _ = s[2] // bounds check hint to compiler; see golang.org/issue/14808
return byte((s[0]-'0')*100 + (s[1]-'0')*10 + (s[2] - '0'))
}
@@ -549,19 +619,33 @@ func intToBytes(i *big.Int, length int) []byte {
// PackRR packs a resource record rr into msg[off:].
// See PackDomainName for documentation about the compression.
func PackRR(rr RR, msg []byte, off int, compression map[string]int, compress bool) (off1 int, err error) {
+ headerEnd, off1, err := packRR(rr, msg, off, compressionMap{ext: compression}, compress)
+ if err == nil {
+ // packRR no longer sets the Rdlength field on the rr, but
+ // callers might be expecting it so we set it here.
+ rr.Header().Rdlength = uint16(off1 - headerEnd)
+ }
+ return off1, err
+}
+
+func packRR(rr RR, msg []byte, off int, compression compressionMap, compress bool) (headerEnd int, off1 int, err error) {
if rr == nil {
- return len(msg), &Error{err: "nil rr"}
+ return len(msg), len(msg), &Error{err: "nil rr"}
}
- off1, err = rr.pack(msg, off, compression, compress)
+ headerEnd, off1, err = rr.pack(msg, off, compression, compress)
if err != nil {
- return len(msg), err
+ return headerEnd, len(msg), err
}
- // TODO(miek): Not sure if this is needed? If removed we can remove rawmsg.go as well.
- if rawSetRdlength(msg, off, off1) {
- return off1, nil
+
+ rdlength := off1 - headerEnd
+ if int(uint16(rdlength)) != rdlength { // overflow
+ return headerEnd, len(msg), ErrRdata
}
- return off, ErrRdata
+
+ // The RDLENGTH field is the last field in the header and we set it here.
+ binary.BigEndian.PutUint16(msg[headerEnd-2:], uint16(rdlength))
+ return headerEnd, off1, nil
}
// UnpackRR unpacks msg[off:] into an RR.
@@ -668,32 +752,33 @@ func (dns *Msg) Pack() (msg []byte, err error) {
// PackBuffer packs a Msg, using the given buffer buf. If buf is too small a new buffer is allocated.
func (dns *Msg) PackBuffer(buf []byte) (msg []byte, err error) {
- var compression map[string]int
- if dns.Compress {
- compression = make(map[string]int) // Compression pointer mappings.
+ // If this message can't be compressed, avoid filling the
+ // compression map and creating garbage.
+ if dns.Compress && dns.isCompressible() {
+ compression := make(map[string]uint16) // Compression pointer mappings.
+ return dns.packBufferWithCompressionMap(buf, compressionMap{int: compression}, true)
}
- return dns.packBufferWithCompressionMap(buf, compression)
+
+ return dns.packBufferWithCompressionMap(buf, compressionMap{}, false)
}
// packBufferWithCompressionMap packs a Msg, using the given buffer buf.
-func (dns *Msg) packBufferWithCompressionMap(buf []byte, compression map[string]int) (msg []byte, err error) {
- // We use a similar function in tsig.go's stripTsig.
-
- var dh Header
-
+func (dns *Msg) packBufferWithCompressionMap(buf []byte, compression compressionMap, compress bool) (msg []byte, err error) {
if dns.Rcode < 0 || dns.Rcode > 0xFFF {
return nil, ErrRcode
}
- if dns.Rcode > 0xF {
- // Regular RCODE field is 4 bits
- opt := dns.IsEdns0()
- if opt == nil {
- return nil, ErrExtendedRcode
- }
- opt.SetExtendedRcode(uint8(dns.Rcode >> 4))
+
+ // Set extended rcode unconditionally if we have an opt, this will allow
+ // reseting the extended rcode bits if they need to.
+ if opt := dns.IsEdns0(); opt != nil {
+ opt.SetExtendedRcode(uint16(dns.Rcode))
+ } else if dns.Rcode > 0xF {
+ // If Rcode is an extended one and opt is nil, error out.
+ return nil, ErrExtendedRcode
}
// Convert convenient Msg into wire-like Header.
+ var dh Header
dh.Id = dns.Id
dh.Bits = uint16(dns.Opcode)<<11 | uint16(dns.Rcode&0xF)
if dns.Response {
@@ -721,50 +806,44 @@ func (dns *Msg) packBufferWithCompressionMap(buf []byte, compression map[string]
dh.Bits |= _CD
}
- // Prepare variable sized arrays.
- question := dns.Question
- answer := dns.Answer
- ns := dns.Ns
- extra := dns.Extra
-
- dh.Qdcount = uint16(len(question))
- dh.Ancount = uint16(len(answer))
- dh.Nscount = uint16(len(ns))
- dh.Arcount = uint16(len(extra))
+ dh.Qdcount = uint16(len(dns.Question))
+ dh.Ancount = uint16(len(dns.Answer))
+ dh.Nscount = uint16(len(dns.Ns))
+ dh.Arcount = uint16(len(dns.Extra))
// We need the uncompressed length here, because we first pack it and then compress it.
msg = buf
- uncompressedLen := compressedLen(dns, false)
+ uncompressedLen := msgLenWithCompressionMap(dns, nil)
if packLen := uncompressedLen + 1; len(msg) < packLen {
msg = make([]byte, packLen)
}
// Pack it in: header and then the pieces.
off := 0
- off, err = dh.pack(msg, off, compression, dns.Compress)
+ off, err = dh.pack(msg, off, compression, compress)
if err != nil {
return nil, err
}
- for i := 0; i < len(question); i++ {
- off, err = question[i].pack(msg, off, compression, dns.Compress)
+ for _, r := range dns.Question {
+ off, err = r.pack(msg, off, compression, compress)
if err != nil {
return nil, err
}
}
- for i := 0; i < len(answer); i++ {
- off, err = PackRR(answer[i], msg, off, compression, dns.Compress)
+ for _, r := range dns.Answer {
+ _, off, err = packRR(r, msg, off, compression, compress)
if err != nil {
return nil, err
}
}
- for i := 0; i < len(ns); i++ {
- off, err = PackRR(ns[i], msg, off, compression, dns.Compress)
+ for _, r := range dns.Ns {
+ _, off, err = packRR(r, msg, off, compression, compress)
if err != nil {
return nil, err
}
}
- for i := 0; i < len(extra); i++ {
- off, err = PackRR(extra[i], msg, off, compression, dns.Compress)
+ for _, r := range dns.Extra {
+ _, off, err = packRR(r, msg, off, compression, compress)
if err != nil {
return nil, err
}
@@ -772,28 +851,7 @@ func (dns *Msg) packBufferWithCompressionMap(buf []byte, compression map[string]
return msg[:off], nil
}
-// Unpack unpacks a binary message to a Msg structure.
-func (dns *Msg) Unpack(msg []byte) (err error) {
- var (
- dh Header
- off int
- )
- if dh, off, err = unpackMsgHdr(msg, off); err != nil {
- return err
- }
-
- dns.Id = dh.Id
- dns.Response = dh.Bits&_QR != 0
- dns.Opcode = int(dh.Bits>>11) & 0xF
- dns.Authoritative = dh.Bits&_AA != 0
- dns.Truncated = dh.Bits&_TC != 0
- dns.RecursionDesired = dh.Bits&_RD != 0
- dns.RecursionAvailable = dh.Bits&_RA != 0
- dns.Zero = dh.Bits&_Z != 0
- dns.AuthenticatedData = dh.Bits&_AD != 0
- dns.CheckingDisabled = dh.Bits&_CD != 0
- dns.Rcode = int(dh.Bits & 0xF)
-
+func (dns *Msg) unpack(dh Header, msg []byte, off int) (err error) {
// If we are at the end of the message we should return *just* the
// header. This can still be useful to the caller. 9.9.9.9 sends these
// when responding with REFUSED for instance.
@@ -812,8 +870,6 @@ func (dns *Msg) Unpack(msg []byte) (err error) {
var q Question
q, off, err = unpackQuestion(msg, off)
if err != nil {
- // Even if Truncated is set, we only will set ErrTruncated if we
- // actually got the questions
return err
}
if off1 == off { // Offset does not increase anymore, dh.Qdcount is a lie!
@@ -837,16 +893,29 @@ func (dns *Msg) Unpack(msg []byte) (err error) {
// The header counts might have been wrong so we need to update it
dh.Arcount = uint16(len(dns.Extra))
+ // Set extended Rcode
+ if opt := dns.IsEdns0(); opt != nil {
+ dns.Rcode |= opt.ExtendedRcode()
+ }
+
if off != len(msg) {
// TODO(miek) make this an error?
// use PackOpt to let people tell how detailed the error reporting should be?
// println("dns: extra bytes in dns packet", off, "<", len(msg))
- } else if dns.Truncated {
- // Whether we ran into a an error or not, we want to return that it
- // was truncated
- err = ErrTruncated
}
return err
+
+}
+
+// Unpack unpacks a binary message to a Msg structure.
+func (dns *Msg) Unpack(msg []byte) (err error) {
+ dh, off, err := unpackMsgHdr(msg, 0)
+ if err != nil {
+ return err
+ }
+
+ dns.setHdr(dh)
+ return dns.unpack(dh, msg, off)
}
// Convert a complete message to a string with dig-like output.
@@ -892,151 +961,117 @@ func (dns *Msg) String() string {
return s
}
+// isCompressible returns whether the msg may be compressible.
+func (dns *Msg) isCompressible() bool {
+ // If we only have one question, there is nothing we can ever compress.
+ return len(dns.Question) > 1 || len(dns.Answer) > 0 ||
+ len(dns.Ns) > 0 || len(dns.Extra) > 0
+}
+
// Len returns the message length when in (un)compressed wire format.
// If dns.Compress is true compression it is taken into account. Len()
// is provided to be a faster way to get the size of the resulting packet,
// than packing it, measuring the size and discarding the buffer.
-func (dns *Msg) Len() int { return compressedLen(dns, dns.Compress) }
-
-func compressedLenWithCompressionMap(dns *Msg, compression map[string]int) int {
- l := 12 // Message header is always 12 bytes
- for _, r := range dns.Question {
- compressionLenHelper(compression, r.Name, l)
- l += r.len()
+func (dns *Msg) Len() int {
+ // If this message can't be compressed, avoid filling the
+ // compression map and creating garbage.
+ if dns.Compress && dns.isCompressible() {
+ compression := make(map[string]struct{})
+ return msgLenWithCompressionMap(dns, compression)
}
- l += compressionLenSlice(l, compression, dns.Answer)
- l += compressionLenSlice(l, compression, dns.Ns)
- l += compressionLenSlice(l, compression, dns.Extra)
- return l
+
+ return msgLenWithCompressionMap(dns, nil)
}
-// compressedLen returns the message length when in compressed wire format
-// when compress is true, otherwise the uncompressed length is returned.
-func compressedLen(dns *Msg, compress bool) int {
- // We always return one more than needed.
- if compress {
- compression := map[string]int{}
- return compressedLenWithCompressionMap(dns, compression)
- }
+func msgLenWithCompressionMap(dns *Msg, compression map[string]struct{}) int {
l := 12 // Message header is always 12 bytes
for _, r := range dns.Question {
- l += r.len()
+ l += r.len(l, compression)
}
for _, r := range dns.Answer {
if r != nil {
- l += r.len()
+ l += r.len(l, compression)
}
}
for _, r := range dns.Ns {
if r != nil {
- l += r.len()
+ l += r.len(l, compression)
}
}
for _, r := range dns.Extra {
if r != nil {
- l += r.len()
+ l += r.len(l, compression)
}
}
return l
}
-func compressionLenSlice(lenp int, c map[string]int, rs []RR) int {
- initLen := lenp
- for _, r := range rs {
- if r == nil {
- continue
- }
- // TmpLen is to track len of record at 14bits boudaries
- tmpLen := lenp
-
- x := r.len()
- // track this length, and the global length in len, while taking compression into account for both.
- k, ok, _ := compressionLenSearch(c, r.Header().Name)
- if ok {
- // Size of x is reduced by k, but we add 1 since k includes the '.' and label descriptor take 2 bytes
- // so, basically x:= x - k - 1 + 2
- x += 1 - k
- }
+func domainNameLen(s string, off int, compression map[string]struct{}, compress bool) int {
+ if s == "" || s == "." {
+ return 1
+ }
- tmpLen += compressionLenHelper(c, r.Header().Name, tmpLen)
- k, ok, _ = compressionLenSearchType(c, r)
- if ok {
- x += 1 - k
+ escaped := strings.Contains(s, "\\")
+
+ if compression != nil && (compress || off < maxCompressionOffset) {
+ // compressionLenSearch will insert the entry into the compression
+ // map if it doesn't contain it.
+ if l, ok := compressionLenSearch(compression, s, off); ok && compress {
+ if escaped {
+ return escapedNameLen(s[:l]) + 2
+ }
+
+ return l + 2
}
- lenp += x
- tmpLen = lenp
- tmpLen += compressionLenHelperType(c, r, tmpLen)
+ }
+ if escaped {
+ return escapedNameLen(s) + 1
}
- return lenp - initLen
+
+ return len(s) + 1
}
-// Put the parts of the name in the compression map, return the size in bytes added in payload
-func compressionLenHelper(c map[string]int, s string, currentLen int) int {
- if currentLen > maxCompressionOffset {
- // We won't be able to add any label that could be re-used later anyway
- return 0
- }
- if _, ok := c[s]; ok {
- return 0
- }
- initLen := currentLen
- pref := ""
- prev := s
- lbs := Split(s)
- for j := 0; j < len(lbs); j++ {
- pref = s[lbs[j]:]
- currentLen += len(prev) - len(pref)
- prev = pref
- if _, ok := c[pref]; !ok {
- // If first byte label is within the first 14bits, it might be re-used later
- if currentLen < maxCompressionOffset {
- c[pref] = currentLen
- }
+func escapedNameLen(s string) int {
+ nameLen := len(s)
+ for i := 0; i < len(s); i++ {
+ if s[i] != '\\' {
+ continue
+ }
+
+ if i+3 < len(s) && isDigit(s[i+1]) && isDigit(s[i+2]) && isDigit(s[i+3]) {
+ nameLen -= 3
+ i += 3
} else {
- added := currentLen - initLen
- if j > 0 {
- // We added a new PTR
- added += 2
- }
- return added
+ nameLen--
+ i++
}
}
- return currentLen - initLen
+
+ return nameLen
}
-// Look for each part in the compression map and returns its length,
-// keep on searching so we get the longest match.
-// Will return the size of compression found, whether a match has been
-// found and the size of record if added in payload
-func compressionLenSearch(c map[string]int, s string) (int, bool, int) {
- off := 0
- end := false
- if s == "" { // don't bork on bogus data
- return 0, false, 0
- }
- fullSize := 0
- for {
+func compressionLenSearch(c map[string]struct{}, s string, msgOff int) (int, bool) {
+ for off, end := 0, false; !end; off, end = NextLabel(s, off) {
if _, ok := c[s[off:]]; ok {
- return len(s[off:]), true, fullSize + off
+ return off, true
}
- if end {
- break
+
+ if msgOff+off < maxCompressionOffset {
+ c[s[off:]] = struct{}{}
}
- // Each label descriptor takes 2 bytes, add it
- fullSize += 2
- off, end = NextLabel(s, off)
}
- return 0, false, fullSize + len(s)
+
+ return 0, false
}
// Copy returns a new RR which is a deep-copy of r.
func Copy(r RR) RR { r1 := r.copy(); return r1 }
// Len returns the length (in octets) of the uncompressed RR in wire format.
-func Len(r RR) int { return r.len() }
+func Len(r RR) int { return r.len(0, nil) }
// Copy returns a new *Msg which is a deep-copy of dns.
func (dns *Msg) Copy() *Msg { return dns.CopyTo(new(Msg)) }
@@ -1084,8 +1119,8 @@ func (dns *Msg) CopyTo(r1 *Msg) *Msg {
return r1
}
-func (q *Question) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
- off, err := PackDomainName(q.Name, msg, off, compression, compress)
+func (q *Question) pack(msg []byte, off int, compression compressionMap, compress bool) (int, error) {
+ off, _, err := packDomainName(q.Name, msg, off, compression, compress)
if err != nil {
return off, err
}
@@ -1126,7 +1161,7 @@ func unpackQuestion(msg []byte, off int) (Question, int, error) {
return q, off, err
}
-func (dh *Header) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
+func (dh *Header) pack(msg []byte, off int, compression compressionMap, compress bool) (int, error) {
off, err := packUint16(dh.Id, msg, off)
if err != nil {
return off, err
@@ -1179,3 +1214,18 @@ func unpackMsgHdr(msg []byte, off int) (Header, int, error) {
dh.Arcount, off, err = unpackUint16(msg, off)
return dh, off, err
}
+
+// setHdr set the header in the dns using the binary data in dh.
+func (dns *Msg) setHdr(dh Header) {
+ dns.Id = dh.Id
+ dns.Response = dh.Bits&_QR != 0
+ dns.Opcode = int(dh.Bits>>11) & 0xF
+ dns.Authoritative = dh.Bits&_AA != 0
+ dns.Truncated = dh.Bits&_TC != 0
+ dns.RecursionDesired = dh.Bits&_RD != 0
+ dns.RecursionAvailable = dh.Bits&_RA != 0
+ dns.Zero = dh.Bits&_Z != 0 // _Z covers the zero bit, which should be zero; not sure why we set it to the opposite.
+ dns.AuthenticatedData = dh.Bits&_AD != 0
+ dns.CheckingDisabled = dh.Bits&_CD != 0
+ dns.Rcode = int(dh.Bits & 0xF)
+}
diff --git a/vendor/github.com/miekg/dns/msg_generate.go b/vendor/github.com/miekg/dns/msg_generate.go
index 8ba609f72..86ed04fcb 100644
--- a/vendor/github.com/miekg/dns/msg_generate.go
+++ b/vendor/github.com/miekg/dns/msg_generate.go
@@ -80,18 +80,17 @@ func main() {
o := scope.Lookup(name)
st, _ := getTypeStruct(o.Type(), scope)
- fmt.Fprintf(b, "func (rr *%s) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {\n", name)
- fmt.Fprint(b, `off, err := rr.Hdr.pack(msg, off, compression, compress)
+ fmt.Fprintf(b, "func (rr *%s) pack(msg []byte, off int, compression compressionMap, compress bool) (int, int, error) {\n", name)
+ fmt.Fprint(b, `headerEnd, off, err := rr.Hdr.pack(msg, off, compression, compress)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
-headerEnd := off
`)
for i := 1; i < st.NumFields(); i++ {
o := func(s string) {
fmt.Fprintf(b, s, st.Field(i).Name())
fmt.Fprint(b, `if err != nil {
-return off, err
+return headerEnd, off, err
}
`)
}
@@ -106,7 +105,7 @@ return off, err
case `dns:"nsec"`:
o("off, err = packDataNsec(rr.%s, msg, off)\n")
case `dns:"domain-name"`:
- o("off, err = packDataDomainNames(rr.%s, msg, off, compression, compress)\n")
+ o("off, err = packDataDomainNames(rr.%s, msg, off, compression, false)\n")
default:
log.Fatalln(name, st.Field(i).Name(), st.Tag(i))
}
@@ -116,9 +115,9 @@ return off, err
switch {
case st.Tag(i) == `dns:"-"`: // ignored
case st.Tag(i) == `dns:"cdomain-name"`:
- o("off, err = PackDomainName(rr.%s, msg, off, compression, compress)\n")
+ o("off, _, err = packDomainName(rr.%s, msg, off, compression, compress)\n")
case st.Tag(i) == `dns:"domain-name"`:
- o("off, err = PackDomainName(rr.%s, msg, off, compression, false)\n")
+ o("off, _, err = packDomainName(rr.%s, msg, off, compression, false)\n")
case st.Tag(i) == `dns:"a"`:
o("off, err = packDataA(rr.%s, msg, off)\n")
case st.Tag(i) == `dns:"aaaa"`:
@@ -145,7 +144,7 @@ return off, err
if rr.%s != "-" {
off, err = packStringHex(rr.%s, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
}
`, field, field)
@@ -176,9 +175,7 @@ if rr.%s != "-" {
log.Fatalln(name, st.Field(i).Name(), st.Tag(i))
}
}
- // We have packed everything, only now we know the rdlength of this RR
- fmt.Fprintln(b, "rr.Header().Rdlength = uint16(off-headerEnd)")
- fmt.Fprintln(b, "return off, nil }\n")
+ fmt.Fprintln(b, "return headerEnd, off, nil }\n")
}
fmt.Fprint(b, "// unpack*() functions\n\n")
diff --git a/vendor/github.com/miekg/dns/msg_helpers.go b/vendor/github.com/miekg/dns/msg_helpers.go
index 81fc2b1be..36345e162 100644
--- a/vendor/github.com/miekg/dns/msg_helpers.go
+++ b/vendor/github.com/miekg/dns/msg_helpers.go
@@ -101,32 +101,32 @@ func unpackHeader(msg []byte, off int) (rr RR_Header, off1 int, truncmsg []byte,
// pack packs an RR header, returning the offset to the end of the header.
// See PackDomainName for documentation about the compression.
-func (hdr RR_Header) pack(msg []byte, off int, compression map[string]int, compress bool) (off1 int, err error) {
+func (hdr RR_Header) pack(msg []byte, off int, compression compressionMap, compress bool) (int, int, error) {
if off == len(msg) {
- return off, nil
+ return off, off, nil
}
- off, err = PackDomainName(hdr.Name, msg, off, compression, compress)
+ off, _, err := packDomainName(hdr.Name, msg, off, compression, compress)
if err != nil {
- return len(msg), err
+ return off, len(msg), err
}
off, err = packUint16(hdr.Rrtype, msg, off)
if err != nil {
- return len(msg), err
+ return off, len(msg), err
}
off, err = packUint16(hdr.Class, msg, off)
if err != nil {
- return len(msg), err
+ return off, len(msg), err
}
off, err = packUint32(hdr.Ttl, msg, off)
if err != nil {
- return len(msg), err
+ return off, len(msg), err
}
- off, err = packUint16(hdr.Rdlength, msg, off)
+ off, err = packUint16(0, msg, off) // The RDLENGTH field will be set later in packRR.
if err != nil {
- return len(msg), err
+ return off, len(msg), err
}
- return off, nil
+ return off, off, nil
}
// helper helper functions.
@@ -223,8 +223,8 @@ func unpackUint48(msg []byte, off int) (i uint64, off1 int, err error) {
return 0, len(msg), &Error{err: "overflow unpacking uint64 as uint48"}
}
// Used in TSIG where the last 48 bits are occupied, so for now, assume a uint48 (6 bytes)
- i = uint64(uint64(msg[off])<<40 | uint64(msg[off+1])<<32 | uint64(msg[off+2])<<24 | uint64(msg[off+3])<<16 |
- uint64(msg[off+4])<<8 | uint64(msg[off+5]))
+ i = uint64(msg[off])<<40 | uint64(msg[off+1])<<32 | uint64(msg[off+2])<<24 | uint64(msg[off+3])<<16 |
+ uint64(msg[off+4])<<8 | uint64(msg[off+5])
off += 6
return i, off, nil
}
@@ -275,7 +275,7 @@ func unpackString(msg []byte, off int) (string, int, error) {
s.WriteByte('\\')
s.WriteByte(b)
case b < ' ' || b > '~': // unprintable
- writeEscapedByte(&s, b)
+ s.WriteString(escapeByte(b))
default:
s.WriteByte(b)
}
@@ -621,10 +621,10 @@ func unpackDataDomainNames(msg []byte, off, end int) ([]string, int, error) {
return servers, off, nil
}
-func packDataDomainNames(names []string, msg []byte, off int, compression map[string]int, compress bool) (int, error) {
+func packDataDomainNames(names []string, msg []byte, off int, compression compressionMap, compress bool) (int, error) {
var err error
for j := 0; j < len(names); j++ {
- off, err = PackDomainName(names[j], msg, off, compression, false && compress)
+ off, _, err = packDomainName(names[j], msg, off, compression, compress)
if err != nil {
return len(msg), err
}
diff --git a/vendor/github.com/miekg/dns/nsecx.go b/vendor/github.com/miekg/dns/nsecx.go
index 9b908c447..8f071a473 100644
--- a/vendor/github.com/miekg/dns/nsecx.go
+++ b/vendor/github.com/miekg/dns/nsecx.go
@@ -2,49 +2,44 @@ package dns
import (
"crypto/sha1"
- "hash"
+ "encoding/hex"
"strings"
)
-type saltWireFmt struct {
- Salt string `dns:"size-hex"`
-}
-
// HashName hashes a string (label) according to RFC 5155. It returns the hashed string in uppercase.
func HashName(label string, ha uint8, iter uint16, salt string) string {
- saltwire := new(saltWireFmt)
- saltwire.Salt = salt
- wire := make([]byte, DefaultMsgSize)
- n, err := packSaltWire(saltwire, wire)
+ if ha != SHA1 {
+ return ""
+ }
+
+ wireSalt := make([]byte, hex.DecodedLen(len(salt)))
+ n, err := packStringHex(salt, wireSalt, 0)
if err != nil {
return ""
}
- wire = wire[:n]
+ wireSalt = wireSalt[:n]
+
name := make([]byte, 255)
off, err := PackDomainName(strings.ToLower(label), name, 0, nil, false)
if err != nil {
return ""
}
name = name[:off]
- var s hash.Hash
- switch ha {
- case SHA1:
- s = sha1.New()
- default:
- return ""
- }
+ s := sha1.New()
// k = 0
s.Write(name)
- s.Write(wire)
+ s.Write(wireSalt)
nsec3 := s.Sum(nil)
+
// k > 0
for k := uint16(0); k < iter; k++ {
s.Reset()
s.Write(nsec3)
- s.Write(wire)
+ s.Write(wireSalt)
nsec3 = s.Sum(nsec3[:0])
}
+
return toBase32(nsec3)
}
@@ -63,8 +58,10 @@ func (rr *NSEC3) Cover(name string) bool {
}
nextHash := rr.NextDomain
- if ownerHash == nextHash { // empty interval
- return false
+
+ // if empty interval found, try cover wildcard hashes so nameHash shouldn't match with ownerHash
+ if ownerHash == nextHash && nameHash != ownerHash { // empty interval
+ return true
}
if ownerHash > nextHash { // end of zone
if nameHash > ownerHash { // covered since there is nothing after ownerHash
@@ -96,11 +93,3 @@ func (rr *NSEC3) Match(name string) bool {
}
return false
}
-
-func packSaltWire(sw *saltWireFmt, msg []byte) (int, error) {
- off, err := packStringHex(sw.Salt, msg, 0)
- if err != nil {
- return off, err
- }
- return off, nil
-}
diff --git a/vendor/github.com/miekg/dns/privaterr.go b/vendor/github.com/miekg/dns/privaterr.go
index 74544a74e..18355f9be 100644
--- a/vendor/github.com/miekg/dns/privaterr.go
+++ b/vendor/github.com/miekg/dns/privaterr.go
@@ -52,7 +52,12 @@ func (r *PrivateRR) Header() *RR_Header { return &r.Hdr }
func (r *PrivateRR) String() string { return r.Hdr.String() + r.Data.String() }
// Private len and copy parts to satisfy RR interface.
-func (r *PrivateRR) len() int { return r.Hdr.len() + r.Data.Len() }
+func (r *PrivateRR) len(off int, compression map[string]struct{}) int {
+ l := r.Hdr.len(off, compression)
+ l += r.Data.Len()
+ return l
+}
+
func (r *PrivateRR) copy() RR {
// make new RR like this:
rr := mkPrivateRR(r.Hdr.Rrtype)
@@ -64,19 +69,18 @@ func (r *PrivateRR) copy() RR {
}
return rr
}
-func (r *PrivateRR) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
- off, err := r.Hdr.pack(msg, off, compression, compress)
+
+func (r *PrivateRR) pack(msg []byte, off int, compression compressionMap, compress bool) (int, int, error) {
+ headerEnd, off, err := r.Hdr.pack(msg, off, compression, compress)
if err != nil {
- return off, err
+ return off, off, err
}
- headerEnd := off
n, err := r.Data.Pack(msg[off:])
if err != nil {
- return len(msg), err
+ return headerEnd, len(msg), err
}
off += n
- r.Header().Rdlength = uint16(off - headerEnd)
- return off, nil
+ return headerEnd, off, nil
}
// PrivateHandle registers a private resource record type. It requires
diff --git a/vendor/github.com/miekg/dns/rawmsg.go b/vendor/github.com/miekg/dns/rawmsg.go
deleted file mode 100644
index 6e21fba7e..000000000
--- a/vendor/github.com/miekg/dns/rawmsg.go
+++ /dev/null
@@ -1,49 +0,0 @@
-package dns
-
-import "encoding/binary"
-
-// rawSetRdlength sets the rdlength in the header of
-// the RR. The offset 'off' must be positioned at the
-// start of the header of the RR, 'end' must be the
-// end of the RR.
-func rawSetRdlength(msg []byte, off, end int) bool {
- l := len(msg)
-Loop:
- for {
- if off+1 > l {
- return false
- }
- c := int(msg[off])
- off++
- switch c & 0xC0 {
- case 0x00:
- if c == 0x00 {
- // End of the domainname
- break Loop
- }
- if off+c > l {
- return false
- }
- off += c
-
- case 0xC0:
- // pointer, next byte included, ends domainname
- off++
- break Loop
- }
- }
- // The domainname has been seen, we at the start of the fixed part in the header.
- // Type is 2 bytes, class is 2 bytes, ttl 4 and then 2 bytes for the length.
- off += 2 + 2 + 4
- if off+2 > l {
- return false
- }
- //off+1 is the end of the header, 'end' is the end of the rr
- //so 'end' - 'off+2' is the length of the rdata
- rdatalen := end - (off + 2)
- if rdatalen > 0xFFFF {
- return false
- }
- binary.BigEndian.PutUint16(msg[off:], uint16(rdatalen))
- return true
-}
diff --git a/vendor/github.com/miekg/dns/reverse.go b/vendor/github.com/miekg/dns/reverse.go
index f6e7a47a6..1f0e2b2a4 100644
--- a/vendor/github.com/miekg/dns/reverse.go
+++ b/vendor/github.com/miekg/dns/reverse.go
@@ -12,6 +12,11 @@ var StringToOpcode = reverseInt(OpcodeToString)
// StringToRcode is a map of rcodes to strings.
var StringToRcode = reverseInt(RcodeToString)
+func init() {
+ // Preserve previous NOTIMP typo, see github.com/miekg/dns/issues/733.
+ StringToRcode["NOTIMPL"] = RcodeNotImplemented
+}
+
// Reverse a map
func reverseInt8(m map[uint8]string) map[string]uint8 {
n := make(map[string]uint8, len(m))
diff --git a/vendor/github.com/miekg/dns/server.go b/vendor/github.com/miekg/dns/server.go
index 4b4ec33c8..6abbed512 100644
--- a/vendor/github.com/miekg/dns/server.go
+++ b/vendor/github.com/miekg/dns/server.go
@@ -82,6 +82,7 @@ type ConnectionStater interface {
type response struct {
msg []byte
+ closed bool // connection has been closed
hijacked bool // connection has been hijacked by handler
tsigTimersOnly bool
tsigStatus error
@@ -202,9 +203,6 @@ type Server struct {
IdleTimeout func() time.Duration
// Secret(s) for Tsig map[]. The zonename must be in canonical form (lowercase, fqdn, see RFC 4034 Section 6.2).
TsigSecret map[string]string
- // Unsafe instructs the server to disregard any sanity checks and directly hand the message to
- // the handler. It will specifically not check if the query has the QR bit not set.
- Unsafe bool
// If NotifyStartedFunc is set it is called once the server has started listening.
NotifyStartedFunc func()
// DecorateReader is optional, allows customization of the process that reads raw DNS messages.
@@ -216,6 +214,9 @@ type Server struct {
// Whether to set the SO_REUSEPORT socket option, allowing multiple listeners to be bound to a single address.
// It is only supported on go1.11+ and when using ListenAndServe.
ReusePort bool
+ // AcceptMsgFunc will check the incoming message and will reject it early in the process.
+ // By default DefaultMsgAcceptFunc will be used.
+ MsgAcceptFunc MsgAcceptFunc
// UDP packet or TCP connection queue
queue chan *response
@@ -299,6 +300,9 @@ func (srv *Server) init() {
if srv.UDPSize == 0 {
srv.UDPSize = MinMsgSize
}
+ if srv.MsgAcceptFunc == nil {
+ srv.MsgAcceptFunc = defaultMsgAcceptFunc
+ }
srv.udpPool.New = makeUDPBuffer(srv.UDPSize)
}
@@ -629,14 +633,34 @@ func (srv *Server) disposeBuffer(w *response) {
}
func (srv *Server) serveDNS(w *response) {
+ dh, off, err := unpackMsgHdr(w.msg, 0)
+ if err != nil {
+ // Let client hang, they are sending crap; any reply can be used to amplify.
+ return
+ }
+
req := new(Msg)
- err := req.Unpack(w.msg)
- if err != nil { // Send a FormatError back
- x := new(Msg)
- x.SetRcodeFormatError(req)
- w.WriteMsg(x)
+ req.setHdr(dh)
+
+ switch srv.MsgAcceptFunc(dh) {
+ case MsgAccept:
+ case MsgIgnore:
+ return
+ case MsgReject:
+ req.SetRcodeFormatError(req)
+ // Are we allowed to delete any OPT records here?
+ req.Ns, req.Answer, req.Extra = nil, nil, nil
+
+ w.WriteMsg(req)
+ srv.disposeBuffer(w)
+ return
}
- if err != nil || !srv.Unsafe && req.Response {
+
+ if err := req.unpack(dh, w.msg, off); err != nil {
+ req.SetRcodeFormatError(req)
+ req.Ns, req.Answer, req.Extra = nil, nil, nil
+
+ w.WriteMsg(req)
srv.disposeBuffer(w)
return
}
@@ -728,6 +752,10 @@ func (srv *Server) readUDP(conn *net.UDPConn, timeout time.Duration) ([]byte, *S
// WriteMsg implements the ResponseWriter.WriteMsg method.
func (w *response) WriteMsg(m *Msg) (err error) {
+ if w.closed {
+ return &Error{err: "WriteMsg called after Close"}
+ }
+
var data []byte
if w.tsigSecret != nil { // if no secrets, dont check for the tsig (which is a longer check)
if t := m.IsTsig(); t != nil {
@@ -749,6 +777,10 @@ func (w *response) WriteMsg(m *Msg) (err error) {
// Write implements the ResponseWriter.Write method.
func (w *response) Write(m []byte) (int, error) {
+ if w.closed {
+ return 0, &Error{err: "Write called after Close"}
+ }
+
switch {
case w.udp != nil:
n, err := WriteToSessionUDP(w.udp, m, w.udpSession)
@@ -768,7 +800,7 @@ func (w *response) Write(m []byte) (int, error) {
n, err := io.Copy(w.tcp, bytes.NewReader(m))
return int(n), err
default:
- panic("dns: Write called after Close")
+ panic("dns: internal error: udp and tcp both nil")
}
}
@@ -780,7 +812,7 @@ func (w *response) LocalAddr() net.Addr {
case w.tcp != nil:
return w.tcp.LocalAddr()
default:
- panic("dns: LocalAddr called after Close")
+ panic("dns: internal error: udp and tcp both nil")
}
}
@@ -792,7 +824,7 @@ func (w *response) RemoteAddr() net.Addr {
case w.tcp != nil:
return w.tcp.RemoteAddr()
default:
- panic("dns: RemoteAddr called after Close")
+ panic("dns: internal error: udpSession and tcp both nil")
}
}
@@ -807,13 +839,20 @@ func (w *response) Hijack() { w.hijacked = true }
// Close implements the ResponseWriter.Close method
func (w *response) Close() error {
- // Can't close the udp conn, as that is actually the listener.
- if w.tcp != nil {
- e := w.tcp.Close()
- w.tcp = nil
- return e
+ if w.closed {
+ return &Error{err: "connection already closed"}
+ }
+ w.closed = true
+
+ switch {
+ case w.udp != nil:
+ // Can't close the udp conn, as that is actually the listener.
+ return nil
+ case w.tcp != nil:
+ return w.tcp.Close()
+ default:
+ panic("dns: internal error: udp and tcp both nil")
}
- return nil
}
// ConnectionState() implements the ConnectionStater.ConnectionState() interface.
diff --git a/vendor/github.com/miekg/dns/sig0.go b/vendor/github.com/miekg/dns/sig0.go
index 07c2acb19..e97f63968 100644
--- a/vendor/github.com/miekg/dns/sig0.go
+++ b/vendor/github.com/miekg/dns/sig0.go
@@ -29,7 +29,7 @@ func (rr *SIG) Sign(k crypto.Signer, m *Msg) ([]byte, error) {
rr.TypeCovered = 0
rr.Labels = 0
- buf := make([]byte, m.Len()+rr.len())
+ buf := make([]byte, m.Len()+Len(rr))
mbuf, err := m.PackBuffer(buf)
if err != nil {
return nil, err
@@ -167,7 +167,7 @@ func (rr *SIG) Verify(k *KEY, buf []byte) error {
}
// If key has come from the DNS name compression might
// have mangled the case of the name
- if strings.ToLower(signername) != strings.ToLower(k.Header().Name) {
+ if !strings.EqualFold(signername, k.Header().Name) {
return &Error{err: "signer name doesn't match key name"}
}
sigend := offset
diff --git a/vendor/github.com/miekg/dns/tsig.go b/vendor/github.com/miekg/dns/tsig.go
index 4837b4ab1..91b69d582 100644
--- a/vendor/github.com/miekg/dns/tsig.go
+++ b/vendor/github.com/miekg/dns/tsig.go
@@ -133,7 +133,7 @@ func TsigGenerate(m *Msg, secret, requestMAC string, timersOnly bool) ([]byte, s
t.Algorithm = rr.Algorithm
t.OrigId = m.Id
- tbuf := make([]byte, t.len())
+ tbuf := make([]byte, Len(t))
if off, err := PackRR(t, tbuf, 0, nil, false); err == nil {
tbuf = tbuf[:off] // reset to actual size used
} else {
diff --git a/vendor/github.com/miekg/dns/types.go b/vendor/github.com/miekg/dns/types.go
index 115f2c7bd..c8658b343 100644
--- a/vendor/github.com/miekg/dns/types.go
+++ b/vendor/github.com/miekg/dns/types.go
@@ -218,8 +218,10 @@ type Question struct {
Qclass uint16
}
-func (q *Question) len() int {
- return len(q.Name) + 1 + 2 + 2
+func (q *Question) len(off int, compression map[string]struct{}) int {
+ l := domainNameLen(q.Name, off, compression, true)
+ l += 2 + 2
+ return l
}
func (q *Question) String() (s string) {
@@ -351,7 +353,7 @@ func (rr *X25) String() string {
type RT struct {
Hdr RR_Header
Preference uint16
- Host string `dns:"cdomain-name"`
+ Host string `dns:"domain-name"` // RFC 3597 prohibits compressing records not defined in RFC 1035.
}
func (rr *RT) String() string {
@@ -460,7 +462,7 @@ func sprintTxtOctet(s string) string {
case b == '.':
dst.WriteByte('.')
case b < ' ' || b > '~':
- writeEscapedByte(&dst, b)
+ dst.WriteString(escapeByte(b))
default:
dst.WriteByte(b)
}
@@ -508,20 +510,44 @@ func writeTXTStringByte(s *strings.Builder, b byte) {
s.WriteByte('\\')
s.WriteByte(b)
case b < ' ' || b > '~':
- writeEscapedByte(s, b)
+ s.WriteString(escapeByte(b))
default:
s.WriteByte(b)
}
}
-func writeEscapedByte(s *strings.Builder, b byte) {
- var buf [3]byte
- bufs := strconv.AppendInt(buf[:0], int64(b), 10)
- s.WriteByte('\\')
- for i := len(bufs); i < 3; i++ {
- s.WriteByte('0')
+const (
+ escapedByteSmall = "" +
+ `\000\001\002\003\004\005\006\007\008\009` +
+ `\010\011\012\013\014\015\016\017\018\019` +
+ `\020\021\022\023\024\025\026\027\028\029` +
+ `\030\031`
+ escapedByteLarge = `\127\128\129` +
+ `\130\131\132\133\134\135\136\137\138\139` +
+ `\140\141\142\143\144\145\146\147\148\149` +
+ `\150\151\152\153\154\155\156\157\158\159` +
+ `\160\161\162\163\164\165\166\167\168\169` +
+ `\170\171\172\173\174\175\176\177\178\179` +
+ `\180\181\182\183\184\185\186\187\188\189` +
+ `\190\191\192\193\194\195\196\197\198\199` +
+ `\200\201\202\203\204\205\206\207\208\209` +
+ `\210\211\212\213\214\215\216\217\218\219` +
+ `\220\221\222\223\224\225\226\227\228\229` +
+ `\230\231\232\233\234\235\236\237\238\239` +
+ `\240\241\242\243\244\245\246\247\248\249` +
+ `\250\251\252\253\254\255`
+)
+
+// escapeByte returns the \DDD escaping of b which must
+// satisfy b < ' ' || b > '~'.
+func escapeByte(b byte) string {
+ if b < ' ' {
+ return escapedByteSmall[b*4 : b*4+4]
}
- s.Write(bufs)
+
+ b -= '~' + 1
+ // The cast here is needed as b*4 may overflow byte.
+ return escapedByteLarge[int(b)*4 : int(b)*4+4]
}
func nextByte(s string, offset int) (byte, int) {
@@ -809,8 +835,9 @@ func (rr *NSEC) String() string {
return s
}
-func (rr *NSEC) len() int {
- l := rr.Hdr.len() + len(rr.NextDomain) + 1
+func (rr *NSEC) len(off int, compression map[string]struct{}) int {
+ l := rr.Hdr.len(off, compression)
+ l += domainNameLen(rr.NextDomain, off+l, compression, false)
lastwindow := uint32(2 ^ 32 + 1)
for _, t := range rr.TypeBitMap {
window := t / 256
@@ -974,8 +1001,9 @@ func (rr *NSEC3) String() string {
return s
}
-func (rr *NSEC3) len() int {
- l := rr.Hdr.len() + 6 + len(rr.Salt)/2 + 1 + len(rr.NextDomain) + 1
+func (rr *NSEC3) len(off int, compression map[string]struct{}) int {
+ l := rr.Hdr.len(off, compression)
+ l += 6 + len(rr.Salt)/2 + 1 + len(rr.NextDomain) + 1
lastwindow := uint32(2 ^ 32 + 1)
for _, t := range rr.TypeBitMap {
window := t / 256
@@ -1291,8 +1319,9 @@ func (rr *CSYNC) String() string {
return s
}
-func (rr *CSYNC) len() int {
- l := rr.Hdr.len() + 4 + 2
+func (rr *CSYNC) len(off int, compression map[string]struct{}) int {
+ l := rr.Hdr.len(off, compression)
+ l += 4 + 2
lastwindow := uint32(2 ^ 32 + 1)
for _, t := range rr.TypeBitMap {
window := t / 256
diff --git a/vendor/github.com/miekg/dns/types_generate.go b/vendor/github.com/miekg/dns/types_generate.go
index b8db4f361..8c897ec11 100644
--- a/vendor/github.com/miekg/dns/types_generate.go
+++ b/vendor/github.com/miekg/dns/types_generate.go
@@ -153,8 +153,8 @@ func main() {
if isEmbedded {
continue
}
- fmt.Fprintf(b, "func (rr *%s) len() int {\n", name)
- fmt.Fprintf(b, "l := rr.Hdr.len()\n")
+ fmt.Fprintf(b, "func (rr *%s) len(off int, compression map[string]struct{}) int {\n", name)
+ fmt.Fprintf(b, "l := rr.Hdr.len(off, compression)\n")
for i := 1; i < st.NumFields(); i++ {
o := func(s string) { fmt.Fprintf(b, s, st.Field(i).Name()) }
@@ -162,7 +162,11 @@ func main() {
switch st.Tag(i) {
case `dns:"-"`:
// ignored
- case `dns:"cdomain-name"`, `dns:"domain-name"`, `dns:"txt"`:
+ case `dns:"cdomain-name"`:
+ o("for _, x := range rr.%s { l += domainNameLen(x, off+l, compression, true) }\n")
+ case `dns:"domain-name"`:
+ o("for _, x := range rr.%s { l += domainNameLen(x, off+l, compression, false) }\n")
+ case `dns:"txt"`:
o("for _, x := range rr.%s { l += len(x) + 1 }\n")
default:
log.Fatalln(name, st.Field(i).Name(), st.Tag(i))
@@ -173,8 +177,10 @@ func main() {
switch {
case st.Tag(i) == `dns:"-"`:
// ignored
- case st.Tag(i) == `dns:"cdomain-name"`, st.Tag(i) == `dns:"domain-name"`:
- o("l += len(rr.%s) + 1\n")
+ case st.Tag(i) == `dns:"cdomain-name"`:
+ o("l += domainNameLen(rr.%s, off+l, compression, true)\n")
+ case st.Tag(i) == `dns:"domain-name"`:
+ o("l += domainNameLen(rr.%s, off+l, compression, false)\n")
case st.Tag(i) == `dns:"octet"`:
o("l += len(rr.%s)\n")
case strings.HasPrefix(st.Tag(i), `dns:"size-base64`):
diff --git a/vendor/github.com/miekg/dns/version.go b/vendor/github.com/miekg/dns/version.go
index 0b0e9b6d8..257dee4d1 100644
--- a/vendor/github.com/miekg/dns/version.go
+++ b/vendor/github.com/miekg/dns/version.go
@@ -3,7 +3,7 @@ package dns
import "fmt"
// Version is current version of this library.
-var Version = V{1, 0, 14}
+var Version = V{1, 1, 1}
// V holds the version of this library.
type V struct {
diff --git a/vendor/github.com/miekg/dns/zcompress.go b/vendor/github.com/miekg/dns/zcompress.go
deleted file mode 100644
index 6391a3501..000000000
--- a/vendor/github.com/miekg/dns/zcompress.go
+++ /dev/null
@@ -1,152 +0,0 @@
-// Code generated by "go run compress_generate.go"; DO NOT EDIT.
-
-package dns
-
-func compressionLenHelperType(c map[string]int, r RR, initLen int) int {
- currentLen := initLen
- switch x := r.(type) {
- case *AFSDB:
- currentLen -= len(x.Hostname) + 1
- currentLen += compressionLenHelper(c, x.Hostname, currentLen)
- case *CNAME:
- currentLen -= len(x.Target) + 1
- currentLen += compressionLenHelper(c, x.Target, currentLen)
- case *DNAME:
- currentLen -= len(x.Target) + 1
- currentLen += compressionLenHelper(c, x.Target, currentLen)
- case *HIP:
- for i := range x.RendezvousServers {
- currentLen -= len(x.RendezvousServers[i]) + 1
- }
- for i := range x.RendezvousServers {
- currentLen += compressionLenHelper(c, x.RendezvousServers[i], currentLen)
- }
- case *KX:
- currentLen -= len(x.Exchanger) + 1
- currentLen += compressionLenHelper(c, x.Exchanger, currentLen)
- case *LP:
- currentLen -= len(x.Fqdn) + 1
- currentLen += compressionLenHelper(c, x.Fqdn, currentLen)
- case *MB:
- currentLen -= len(x.Mb) + 1
- currentLen += compressionLenHelper(c, x.Mb, currentLen)
- case *MD:
- currentLen -= len(x.Md) + 1
- currentLen += compressionLenHelper(c, x.Md, currentLen)
- case *MF:
- currentLen -= len(x.Mf) + 1
- currentLen += compressionLenHelper(c, x.Mf, currentLen)
- case *MG:
- currentLen -= len(x.Mg) + 1
- currentLen += compressionLenHelper(c, x.Mg, currentLen)
- case *MINFO:
- currentLen -= len(x.Rmail) + 1
- currentLen += compressionLenHelper(c, x.Rmail, currentLen)
- currentLen -= len(x.Email) + 1
- currentLen += compressionLenHelper(c, x.Email, currentLen)
- case *MR:
- currentLen -= len(x.Mr) + 1
- currentLen += compressionLenHelper(c, x.Mr, currentLen)
- case *MX:
- currentLen -= len(x.Mx) + 1
- currentLen += compressionLenHelper(c, x.Mx, currentLen)
- case *NAPTR:
- currentLen -= len(x.Replacement) + 1
- currentLen += compressionLenHelper(c, x.Replacement, currentLen)
- case *NS:
- currentLen -= len(x.Ns) + 1
- currentLen += compressionLenHelper(c, x.Ns, currentLen)
- case *NSAPPTR:
- currentLen -= len(x.Ptr) + 1
- currentLen += compressionLenHelper(c, x.Ptr, currentLen)
- case *NSEC:
- currentLen -= len(x.NextDomain) + 1
- currentLen += compressionLenHelper(c, x.NextDomain, currentLen)
- case *PTR:
- currentLen -= len(x.Ptr) + 1
- currentLen += compressionLenHelper(c, x.Ptr, currentLen)
- case *PX:
- currentLen -= len(x.Map822) + 1
- currentLen += compressionLenHelper(c, x.Map822, currentLen)
- currentLen -= len(x.Mapx400) + 1
- currentLen += compressionLenHelper(c, x.Mapx400, currentLen)
- case *RP:
- currentLen -= len(x.Mbox) + 1
- currentLen += compressionLenHelper(c, x.Mbox, currentLen)
- currentLen -= len(x.Txt) + 1
- currentLen += compressionLenHelper(c, x.Txt, currentLen)
- case *RRSIG:
- currentLen -= len(x.SignerName) + 1
- currentLen += compressionLenHelper(c, x.SignerName, currentLen)
- case *RT:
- currentLen -= len(x.Host) + 1
- currentLen += compressionLenHelper(c, x.Host, currentLen)
- case *SIG:
- currentLen -= len(x.SignerName) + 1
- currentLen += compressionLenHelper(c, x.SignerName, currentLen)
- case *SOA:
- currentLen -= len(x.Ns) + 1
- currentLen += compressionLenHelper(c, x.Ns, currentLen)
- currentLen -= len(x.Mbox) + 1
- currentLen += compressionLenHelper(c, x.Mbox, currentLen)
- case *SRV:
- currentLen -= len(x.Target) + 1
- currentLen += compressionLenHelper(c, x.Target, currentLen)
- case *TALINK:
- currentLen -= len(x.PreviousName) + 1
- currentLen += compressionLenHelper(c, x.PreviousName, currentLen)
- currentLen -= len(x.NextName) + 1
- currentLen += compressionLenHelper(c, x.NextName, currentLen)
- case *TKEY:
- currentLen -= len(x.Algorithm) + 1
- currentLen += compressionLenHelper(c, x.Algorithm, currentLen)
- case *TSIG:
- currentLen -= len(x.Algorithm) + 1
- currentLen += compressionLenHelper(c, x.Algorithm, currentLen)
- }
- return currentLen - initLen
-}
-
-func compressionLenSearchType(c map[string]int, r RR) (int, bool, int) {
- switch x := r.(type) {
- case *CNAME:
- k1, ok1, sz1 := compressionLenSearch(c, x.Target)
- return k1, ok1, sz1
- case *MB:
- k1, ok1, sz1 := compressionLenSearch(c, x.Mb)
- return k1, ok1, sz1
- case *MD:
- k1, ok1, sz1 := compressionLenSearch(c, x.Md)
- return k1, ok1, sz1
- case *MF:
- k1, ok1, sz1 := compressionLenSearch(c, x.Mf)
- return k1, ok1, sz1
- case *MG:
- k1, ok1, sz1 := compressionLenSearch(c, x.Mg)
- return k1, ok1, sz1
- case *MINFO:
- k1, ok1, sz1 := compressionLenSearch(c, x.Rmail)
- k2, ok2, sz2 := compressionLenSearch(c, x.Email)
- return k1 + k2, ok1 && ok2, sz1 + sz2
- case *MR:
- k1, ok1, sz1 := compressionLenSearch(c, x.Mr)
- return k1, ok1, sz1
- case *MX:
- k1, ok1, sz1 := compressionLenSearch(c, x.Mx)
- return k1, ok1, sz1
- case *NS:
- k1, ok1, sz1 := compressionLenSearch(c, x.Ns)
- return k1, ok1, sz1
- case *PTR:
- k1, ok1, sz1 := compressionLenSearch(c, x.Ptr)
- return k1, ok1, sz1
- case *RT:
- k1, ok1, sz1 := compressionLenSearch(c, x.Host)
- return k1, ok1, sz1
- case *SOA:
- k1, ok1, sz1 := compressionLenSearch(c, x.Ns)
- k2, ok2, sz2 := compressionLenSearch(c, x.Mbox)
- return k1 + k2, ok1 && ok2, sz1 + sz2
- }
- return 0, false, 0
-}
diff --git a/vendor/github.com/miekg/dns/zmsg.go b/vendor/github.com/miekg/dns/zmsg.go
index 1a68f74da..3e93a782f 100644
--- a/vendor/github.com/miekg/dns/zmsg.go
+++ b/vendor/github.com/miekg/dns/zmsg.go
@@ -4,1490 +4,1350 @@ package dns
// pack*() functions
-func (rr *A) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
- off, err := rr.Hdr.pack(msg, off, compression, compress)
+func (rr *A) pack(msg []byte, off int, compression compressionMap, compress bool) (int, int, error) {
+ headerEnd, off, err := rr.Hdr.pack(msg, off, compression, compress)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- headerEnd := off
off, err = packDataA(rr.A, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- rr.Header().Rdlength = uint16(off - headerEnd)
- return off, nil
+ return headerEnd, off, nil
}
-func (rr *AAAA) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
- off, err := rr.Hdr.pack(msg, off, compression, compress)
+func (rr *AAAA) pack(msg []byte, off int, compression compressionMap, compress bool) (int, int, error) {
+ headerEnd, off, err := rr.Hdr.pack(msg, off, compression, compress)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- headerEnd := off
off, err = packDataAAAA(rr.AAAA, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- rr.Header().Rdlength = uint16(off - headerEnd)
- return off, nil
+ return headerEnd, off, nil
}
-func (rr *AFSDB) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
- off, err := rr.Hdr.pack(msg, off, compression, compress)
+func (rr *AFSDB) pack(msg []byte, off int, compression compressionMap, compress bool) (int, int, error) {
+ headerEnd, off, err := rr.Hdr.pack(msg, off, compression, compress)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- headerEnd := off
off, err = packUint16(rr.Subtype, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- off, err = PackDomainName(rr.Hostname, msg, off, compression, false)
+ off, _, err = packDomainName(rr.Hostname, msg, off, compression, false)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- rr.Header().Rdlength = uint16(off - headerEnd)
- return off, nil
+ return headerEnd, off, nil
}
-func (rr *ANY) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
- off, err := rr.Hdr.pack(msg, off, compression, compress)
+func (rr *ANY) pack(msg []byte, off int, compression compressionMap, compress bool) (int, int, error) {
+ headerEnd, off, err := rr.Hdr.pack(msg, off, compression, compress)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- headerEnd := off
- rr.Header().Rdlength = uint16(off - headerEnd)
- return off, nil
+ return headerEnd, off, nil
}
-func (rr *AVC) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
- off, err := rr.Hdr.pack(msg, off, compression, compress)
+func (rr *AVC) pack(msg []byte, off int, compression compressionMap, compress bool) (int, int, error) {
+ headerEnd, off, err := rr.Hdr.pack(msg, off, compression, compress)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- headerEnd := off
off, err = packStringTxt(rr.Txt, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- rr.Header().Rdlength = uint16(off - headerEnd)
- return off, nil
+ return headerEnd, off, nil
}
-func (rr *CAA) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
- off, err := rr.Hdr.pack(msg, off, compression, compress)
+func (rr *CAA) pack(msg []byte, off int, compression compressionMap, compress bool) (int, int, error) {
+ headerEnd, off, err := rr.Hdr.pack(msg, off, compression, compress)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- headerEnd := off
off, err = packUint8(rr.Flag, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
off, err = packString(rr.Tag, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
off, err = packStringOctet(rr.Value, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- rr.Header().Rdlength = uint16(off - headerEnd)
- return off, nil
+ return headerEnd, off, nil
}
-func (rr *CDNSKEY) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
- off, err := rr.Hdr.pack(msg, off, compression, compress)
+func (rr *CDNSKEY) pack(msg []byte, off int, compression compressionMap, compress bool) (int, int, error) {
+ headerEnd, off, err := rr.Hdr.pack(msg, off, compression, compress)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- headerEnd := off
off, err = packUint16(rr.Flags, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
off, err = packUint8(rr.Protocol, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
off, err = packUint8(rr.Algorithm, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
off, err = packStringBase64(rr.PublicKey, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- rr.Header().Rdlength = uint16(off - headerEnd)
- return off, nil
+ return headerEnd, off, nil
}
-func (rr *CDS) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
- off, err := rr.Hdr.pack(msg, off, compression, compress)
+func (rr *CDS) pack(msg []byte, off int, compression compressionMap, compress bool) (int, int, error) {
+ headerEnd, off, err := rr.Hdr.pack(msg, off, compression, compress)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- headerEnd := off
off, err = packUint16(rr.KeyTag, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
off, err = packUint8(rr.Algorithm, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
off, err = packUint8(rr.DigestType, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
off, err = packStringHex(rr.Digest, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- rr.Header().Rdlength = uint16(off - headerEnd)
- return off, nil
+ return headerEnd, off, nil
}
-func (rr *CERT) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
- off, err := rr.Hdr.pack(msg, off, compression, compress)
+func (rr *CERT) pack(msg []byte, off int, compression compressionMap, compress bool) (int, int, error) {
+ headerEnd, off, err := rr.Hdr.pack(msg, off, compression, compress)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- headerEnd := off
off, err = packUint16(rr.Type, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
off, err = packUint16(rr.KeyTag, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
off, err = packUint8(rr.Algorithm, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
off, err = packStringBase64(rr.Certificate, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- rr.Header().Rdlength = uint16(off - headerEnd)
- return off, nil
+ return headerEnd, off, nil
}
-func (rr *CNAME) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
- off, err := rr.Hdr.pack(msg, off, compression, compress)
+func (rr *CNAME) pack(msg []byte, off int, compression compressionMap, compress bool) (int, int, error) {
+ headerEnd, off, err := rr.Hdr.pack(msg, off, compression, compress)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- headerEnd := off
- off, err = PackDomainName(rr.Target, msg, off, compression, compress)
+ off, _, err = packDomainName(rr.Target, msg, off, compression, compress)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- rr.Header().Rdlength = uint16(off - headerEnd)
- return off, nil
+ return headerEnd, off, nil
}
-func (rr *CSYNC) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
- off, err := rr.Hdr.pack(msg, off, compression, compress)
+func (rr *CSYNC) pack(msg []byte, off int, compression compressionMap, compress bool) (int, int, error) {
+ headerEnd, off, err := rr.Hdr.pack(msg, off, compression, compress)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- headerEnd := off
off, err = packUint32(rr.Serial, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
off, err = packUint16(rr.Flags, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
off, err = packDataNsec(rr.TypeBitMap, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- rr.Header().Rdlength = uint16(off - headerEnd)
- return off, nil
+ return headerEnd, off, nil
}
-func (rr *DHCID) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
- off, err := rr.Hdr.pack(msg, off, compression, compress)
+func (rr *DHCID) pack(msg []byte, off int, compression compressionMap, compress bool) (int, int, error) {
+ headerEnd, off, err := rr.Hdr.pack(msg, off, compression, compress)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- headerEnd := off
off, err = packStringBase64(rr.Digest, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- rr.Header().Rdlength = uint16(off - headerEnd)
- return off, nil
+ return headerEnd, off, nil
}
-func (rr *DLV) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
- off, err := rr.Hdr.pack(msg, off, compression, compress)
+func (rr *DLV) pack(msg []byte, off int, compression compressionMap, compress bool) (int, int, error) {
+ headerEnd, off, err := rr.Hdr.pack(msg, off, compression, compress)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- headerEnd := off
off, err = packUint16(rr.KeyTag, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
off, err = packUint8(rr.Algorithm, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
off, err = packUint8(rr.DigestType, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
off, err = packStringHex(rr.Digest, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- rr.Header().Rdlength = uint16(off - headerEnd)
- return off, nil
+ return headerEnd, off, nil
}
-func (rr *DNAME) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
- off, err := rr.Hdr.pack(msg, off, compression, compress)
+func (rr *DNAME) pack(msg []byte, off int, compression compressionMap, compress bool) (int, int, error) {
+ headerEnd, off, err := rr.Hdr.pack(msg, off, compression, compress)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- headerEnd := off
- off, err = PackDomainName(rr.Target, msg, off, compression, false)
+ off, _, err = packDomainName(rr.Target, msg, off, compression, false)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- rr.Header().Rdlength = uint16(off - headerEnd)
- return off, nil
+ return headerEnd, off, nil
}
-func (rr *DNSKEY) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
- off, err := rr.Hdr.pack(msg, off, compression, compress)
+func (rr *DNSKEY) pack(msg []byte, off int, compression compressionMap, compress bool) (int, int, error) {
+ headerEnd, off, err := rr.Hdr.pack(msg, off, compression, compress)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- headerEnd := off
off, err = packUint16(rr.Flags, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
off, err = packUint8(rr.Protocol, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
off, err = packUint8(rr.Algorithm, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
off, err = packStringBase64(rr.PublicKey, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- rr.Header().Rdlength = uint16(off - headerEnd)
- return off, nil
+ return headerEnd, off, nil
}
-func (rr *DS) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
- off, err := rr.Hdr.pack(msg, off, compression, compress)
+func (rr *DS) pack(msg []byte, off int, compression compressionMap, compress bool) (int, int, error) {
+ headerEnd, off, err := rr.Hdr.pack(msg, off, compression, compress)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- headerEnd := off
off, err = packUint16(rr.KeyTag, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
off, err = packUint8(rr.Algorithm, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
off, err = packUint8(rr.DigestType, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
off, err = packStringHex(rr.Digest, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- rr.Header().Rdlength = uint16(off - headerEnd)
- return off, nil
+ return headerEnd, off, nil
}
-func (rr *EID) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
- off, err := rr.Hdr.pack(msg, off, compression, compress)
+func (rr *EID) pack(msg []byte, off int, compression compressionMap, compress bool) (int, int, error) {
+ headerEnd, off, err := rr.Hdr.pack(msg, off, compression, compress)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- headerEnd := off
off, err = packStringHex(rr.Endpoint, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- rr.Header().Rdlength = uint16(off - headerEnd)
- return off, nil
+ return headerEnd, off, nil
}
-func (rr *EUI48) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
- off, err := rr.Hdr.pack(msg, off, compression, compress)
+func (rr *EUI48) pack(msg []byte, off int, compression compressionMap, compress bool) (int, int, error) {
+ headerEnd, off, err := rr.Hdr.pack(msg, off, compression, compress)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- headerEnd := off
off, err = packUint48(rr.Address, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- rr.Header().Rdlength = uint16(off - headerEnd)
- return off, nil
+ return headerEnd, off, nil
}
-func (rr *EUI64) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
- off, err := rr.Hdr.pack(msg, off, compression, compress)
+func (rr *EUI64) pack(msg []byte, off int, compression compressionMap, compress bool) (int, int, error) {
+ headerEnd, off, err := rr.Hdr.pack(msg, off, compression, compress)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- headerEnd := off
off, err = packUint64(rr.Address, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- rr.Header().Rdlength = uint16(off - headerEnd)
- return off, nil
+ return headerEnd, off, nil
}
-func (rr *GID) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
- off, err := rr.Hdr.pack(msg, off, compression, compress)
+func (rr *GID) pack(msg []byte, off int, compression compressionMap, compress bool) (int, int, error) {
+ headerEnd, off, err := rr.Hdr.pack(msg, off, compression, compress)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- headerEnd := off
off, err = packUint32(rr.Gid, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- rr.Header().Rdlength = uint16(off - headerEnd)
- return off, nil
+ return headerEnd, off, nil
}
-func (rr *GPOS) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
- off, err := rr.Hdr.pack(msg, off, compression, compress)
+func (rr *GPOS) pack(msg []byte, off int, compression compressionMap, compress bool) (int, int, error) {
+ headerEnd, off, err := rr.Hdr.pack(msg, off, compression, compress)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- headerEnd := off
off, err = packString(rr.Longitude, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
off, err = packString(rr.Latitude, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
off, err = packString(rr.Altitude, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- rr.Header().Rdlength = uint16(off - headerEnd)
- return off, nil
+ return headerEnd, off, nil
}
-func (rr *HINFO) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
- off, err := rr.Hdr.pack(msg, off, compression, compress)
+func (rr *HINFO) pack(msg []byte, off int, compression compressionMap, compress bool) (int, int, error) {
+ headerEnd, off, err := rr.Hdr.pack(msg, off, compression, compress)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- headerEnd := off
off, err = packString(rr.Cpu, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
off, err = packString(rr.Os, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- rr.Header().Rdlength = uint16(off - headerEnd)
- return off, nil
+ return headerEnd, off, nil
}
-func (rr *HIP) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
- off, err := rr.Hdr.pack(msg, off, compression, compress)
+func (rr *HIP) pack(msg []byte, off int, compression compressionMap, compress bool) (int, int, error) {
+ headerEnd, off, err := rr.Hdr.pack(msg, off, compression, compress)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- headerEnd := off
off, err = packUint8(rr.HitLength, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
off, err = packUint8(rr.PublicKeyAlgorithm, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
off, err = packUint16(rr.PublicKeyLength, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
off, err = packStringHex(rr.Hit, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
off, err = packStringBase64(rr.PublicKey, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- off, err = packDataDomainNames(rr.RendezvousServers, msg, off, compression, compress)
+ off, err = packDataDomainNames(rr.RendezvousServers, msg, off, compression, false)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- rr.Header().Rdlength = uint16(off - headerEnd)
- return off, nil
+ return headerEnd, off, nil
}
-func (rr *KEY) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
- off, err := rr.Hdr.pack(msg, off, compression, compress)
+func (rr *KEY) pack(msg []byte, off int, compression compressionMap, compress bool) (int, int, error) {
+ headerEnd, off, err := rr.Hdr.pack(msg, off, compression, compress)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- headerEnd := off
off, err = packUint16(rr.Flags, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
off, err = packUint8(rr.Protocol, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
off, err = packUint8(rr.Algorithm, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
off, err = packStringBase64(rr.PublicKey, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- rr.Header().Rdlength = uint16(off - headerEnd)
- return off, nil
+ return headerEnd, off, nil
}
-func (rr *KX) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
- off, err := rr.Hdr.pack(msg, off, compression, compress)
+func (rr *KX) pack(msg []byte, off int, compression compressionMap, compress bool) (int, int, error) {
+ headerEnd, off, err := rr.Hdr.pack(msg, off, compression, compress)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- headerEnd := off
off, err = packUint16(rr.Preference, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- off, err = PackDomainName(rr.Exchanger, msg, off, compression, false)
+ off, _, err = packDomainName(rr.Exchanger, msg, off, compression, false)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- rr.Header().Rdlength = uint16(off - headerEnd)
- return off, nil
+ return headerEnd, off, nil
}
-func (rr *L32) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
- off, err := rr.Hdr.pack(msg, off, compression, compress)
+func (rr *L32) pack(msg []byte, off int, compression compressionMap, compress bool) (int, int, error) {
+ headerEnd, off, err := rr.Hdr.pack(msg, off, compression, compress)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- headerEnd := off
off, err = packUint16(rr.Preference, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
off, err = packDataA(rr.Locator32, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- rr.Header().Rdlength = uint16(off - headerEnd)
- return off, nil
+ return headerEnd, off, nil
}
-func (rr *L64) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
- off, err := rr.Hdr.pack(msg, off, compression, compress)
+func (rr *L64) pack(msg []byte, off int, compression compressionMap, compress bool) (int, int, error) {
+ headerEnd, off, err := rr.Hdr.pack(msg, off, compression, compress)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- headerEnd := off
off, err = packUint16(rr.Preference, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
off, err = packUint64(rr.Locator64, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- rr.Header().Rdlength = uint16(off - headerEnd)
- return off, nil
+ return headerEnd, off, nil
}
-func (rr *LOC) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
- off, err := rr.Hdr.pack(msg, off, compression, compress)
+func (rr *LOC) pack(msg []byte, off int, compression compressionMap, compress bool) (int, int, error) {
+ headerEnd, off, err := rr.Hdr.pack(msg, off, compression, compress)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- headerEnd := off
off, err = packUint8(rr.Version, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
off, err = packUint8(rr.Size, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
off, err = packUint8(rr.HorizPre, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
off, err = packUint8(rr.VertPre, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
off, err = packUint32(rr.Latitude, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
off, err = packUint32(rr.Longitude, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
off, err = packUint32(rr.Altitude, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- rr.Header().Rdlength = uint16(off - headerEnd)
- return off, nil
+ return headerEnd, off, nil
}
-func (rr *LP) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
- off, err := rr.Hdr.pack(msg, off, compression, compress)
+func (rr *LP) pack(msg []byte, off int, compression compressionMap, compress bool) (int, int, error) {
+ headerEnd, off, err := rr.Hdr.pack(msg, off, compression, compress)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- headerEnd := off
off, err = packUint16(rr.Preference, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- off, err = PackDomainName(rr.Fqdn, msg, off, compression, false)
+ off, _, err = packDomainName(rr.Fqdn, msg, off, compression, false)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- rr.Header().Rdlength = uint16(off - headerEnd)
- return off, nil
+ return headerEnd, off, nil
}
-func (rr *MB) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
- off, err := rr.Hdr.pack(msg, off, compression, compress)
+func (rr *MB) pack(msg []byte, off int, compression compressionMap, compress bool) (int, int, error) {
+ headerEnd, off, err := rr.Hdr.pack(msg, off, compression, compress)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- headerEnd := off
- off, err = PackDomainName(rr.Mb, msg, off, compression, compress)
+ off, _, err = packDomainName(rr.Mb, msg, off, compression, compress)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- rr.Header().Rdlength = uint16(off - headerEnd)
- return off, nil
+ return headerEnd, off, nil
}
-func (rr *MD) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
- off, err := rr.Hdr.pack(msg, off, compression, compress)
+func (rr *MD) pack(msg []byte, off int, compression compressionMap, compress bool) (int, int, error) {
+ headerEnd, off, err := rr.Hdr.pack(msg, off, compression, compress)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- headerEnd := off
- off, err = PackDomainName(rr.Md, msg, off, compression, compress)
+ off, _, err = packDomainName(rr.Md, msg, off, compression, compress)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- rr.Header().Rdlength = uint16(off - headerEnd)
- return off, nil
+ return headerEnd, off, nil
}
-func (rr *MF) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
- off, err := rr.Hdr.pack(msg, off, compression, compress)
+func (rr *MF) pack(msg []byte, off int, compression compressionMap, compress bool) (int, int, error) {
+ headerEnd, off, err := rr.Hdr.pack(msg, off, compression, compress)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- headerEnd := off
- off, err = PackDomainName(rr.Mf, msg, off, compression, compress)
+ off, _, err = packDomainName(rr.Mf, msg, off, compression, compress)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- rr.Header().Rdlength = uint16(off - headerEnd)
- return off, nil
+ return headerEnd, off, nil
}
-func (rr *MG) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
- off, err := rr.Hdr.pack(msg, off, compression, compress)
+func (rr *MG) pack(msg []byte, off int, compression compressionMap, compress bool) (int, int, error) {
+ headerEnd, off, err := rr.Hdr.pack(msg, off, compression, compress)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- headerEnd := off
- off, err = PackDomainName(rr.Mg, msg, off, compression, compress)
+ off, _, err = packDomainName(rr.Mg, msg, off, compression, compress)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- rr.Header().Rdlength = uint16(off - headerEnd)
- return off, nil
+ return headerEnd, off, nil
}
-func (rr *MINFO) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
- off, err := rr.Hdr.pack(msg, off, compression, compress)
+func (rr *MINFO) pack(msg []byte, off int, compression compressionMap, compress bool) (int, int, error) {
+ headerEnd, off, err := rr.Hdr.pack(msg, off, compression, compress)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- headerEnd := off
- off, err = PackDomainName(rr.Rmail, msg, off, compression, compress)
+ off, _, err = packDomainName(rr.Rmail, msg, off, compression, compress)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- off, err = PackDomainName(rr.Email, msg, off, compression, compress)
+ off, _, err = packDomainName(rr.Email, msg, off, compression, compress)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- rr.Header().Rdlength = uint16(off - headerEnd)
- return off, nil
+ return headerEnd, off, nil
}
-func (rr *MR) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
- off, err := rr.Hdr.pack(msg, off, compression, compress)
+func (rr *MR) pack(msg []byte, off int, compression compressionMap, compress bool) (int, int, error) {
+ headerEnd, off, err := rr.Hdr.pack(msg, off, compression, compress)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- headerEnd := off
- off, err = PackDomainName(rr.Mr, msg, off, compression, compress)
+ off, _, err = packDomainName(rr.Mr, msg, off, compression, compress)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- rr.Header().Rdlength = uint16(off - headerEnd)
- return off, nil
+ return headerEnd, off, nil
}
-func (rr *MX) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
- off, err := rr.Hdr.pack(msg, off, compression, compress)
+func (rr *MX) pack(msg []byte, off int, compression compressionMap, compress bool) (int, int, error) {
+ headerEnd, off, err := rr.Hdr.pack(msg, off, compression, compress)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- headerEnd := off
off, err = packUint16(rr.Preference, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- off, err = PackDomainName(rr.Mx, msg, off, compression, compress)
+ off, _, err = packDomainName(rr.Mx, msg, off, compression, compress)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- rr.Header().Rdlength = uint16(off - headerEnd)
- return off, nil
+ return headerEnd, off, nil
}
-func (rr *NAPTR) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
- off, err := rr.Hdr.pack(msg, off, compression, compress)
+func (rr *NAPTR) pack(msg []byte, off int, compression compressionMap, compress bool) (int, int, error) {
+ headerEnd, off, err := rr.Hdr.pack(msg, off, compression, compress)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- headerEnd := off
off, err = packUint16(rr.Order, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
off, err = packUint16(rr.Preference, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
off, err = packString(rr.Flags, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
off, err = packString(rr.Service, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
off, err = packString(rr.Regexp, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- off, err = PackDomainName(rr.Replacement, msg, off, compression, false)
+ off, _, err = packDomainName(rr.Replacement, msg, off, compression, false)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- rr.Header().Rdlength = uint16(off - headerEnd)
- return off, nil
+ return headerEnd, off, nil
}
-func (rr *NID) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
- off, err := rr.Hdr.pack(msg, off, compression, compress)
+func (rr *NID) pack(msg []byte, off int, compression compressionMap, compress bool) (int, int, error) {
+ headerEnd, off, err := rr.Hdr.pack(msg, off, compression, compress)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- headerEnd := off
off, err = packUint16(rr.Preference, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
off, err = packUint64(rr.NodeID, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- rr.Header().Rdlength = uint16(off - headerEnd)
- return off, nil
+ return headerEnd, off, nil
}
-func (rr *NIMLOC) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
- off, err := rr.Hdr.pack(msg, off, compression, compress)
+func (rr *NIMLOC) pack(msg []byte, off int, compression compressionMap, compress bool) (int, int, error) {
+ headerEnd, off, err := rr.Hdr.pack(msg, off, compression, compress)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- headerEnd := off
off, err = packStringHex(rr.Locator, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- rr.Header().Rdlength = uint16(off - headerEnd)
- return off, nil
+ return headerEnd, off, nil
}
-func (rr *NINFO) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
- off, err := rr.Hdr.pack(msg, off, compression, compress)
+func (rr *NINFO) pack(msg []byte, off int, compression compressionMap, compress bool) (int, int, error) {
+ headerEnd, off, err := rr.Hdr.pack(msg, off, compression, compress)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- headerEnd := off
off, err = packStringTxt(rr.ZSData, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- rr.Header().Rdlength = uint16(off - headerEnd)
- return off, nil
+ return headerEnd, off, nil
}
-func (rr *NS) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
- off, err := rr.Hdr.pack(msg, off, compression, compress)
+func (rr *NS) pack(msg []byte, off int, compression compressionMap, compress bool) (int, int, error) {
+ headerEnd, off, err := rr.Hdr.pack(msg, off, compression, compress)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- headerEnd := off
- off, err = PackDomainName(rr.Ns, msg, off, compression, compress)
+ off, _, err = packDomainName(rr.Ns, msg, off, compression, compress)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- rr.Header().Rdlength = uint16(off - headerEnd)
- return off, nil
+ return headerEnd, off, nil
}
-func (rr *NSAPPTR) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
- off, err := rr.Hdr.pack(msg, off, compression, compress)
+func (rr *NSAPPTR) pack(msg []byte, off int, compression compressionMap, compress bool) (int, int, error) {
+ headerEnd, off, err := rr.Hdr.pack(msg, off, compression, compress)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- headerEnd := off
- off, err = PackDomainName(rr.Ptr, msg, off, compression, false)
+ off, _, err = packDomainName(rr.Ptr, msg, off, compression, false)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- rr.Header().Rdlength = uint16(off - headerEnd)
- return off, nil
+ return headerEnd, off, nil
}
-func (rr *NSEC) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
- off, err := rr.Hdr.pack(msg, off, compression, compress)
+func (rr *NSEC) pack(msg []byte, off int, compression compressionMap, compress bool) (int, int, error) {
+ headerEnd, off, err := rr.Hdr.pack(msg, off, compression, compress)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- headerEnd := off
- off, err = PackDomainName(rr.NextDomain, msg, off, compression, false)
+ off, _, err = packDomainName(rr.NextDomain, msg, off, compression, false)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
off, err = packDataNsec(rr.TypeBitMap, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- rr.Header().Rdlength = uint16(off - headerEnd)
- return off, nil
+ return headerEnd, off, nil
}
-func (rr *NSEC3) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
- off, err := rr.Hdr.pack(msg, off, compression, compress)
+func (rr *NSEC3) pack(msg []byte, off int, compression compressionMap, compress bool) (int, int, error) {
+ headerEnd, off, err := rr.Hdr.pack(msg, off, compression, compress)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- headerEnd := off
off, err = packUint8(rr.Hash, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
off, err = packUint8(rr.Flags, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
off, err = packUint16(rr.Iterations, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
off, err = packUint8(rr.SaltLength, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
// Only pack salt if value is not "-", i.e. empty
if rr.Salt != "-" {
off, err = packStringHex(rr.Salt, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
}
off, err = packUint8(rr.HashLength, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
off, err = packStringBase32(rr.NextDomain, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
off, err = packDataNsec(rr.TypeBitMap, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- rr.Header().Rdlength = uint16(off - headerEnd)
- return off, nil
+ return headerEnd, off, nil
}
-func (rr *NSEC3PARAM) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
- off, err := rr.Hdr.pack(msg, off, compression, compress)
+func (rr *NSEC3PARAM) pack(msg []byte, off int, compression compressionMap, compress bool) (int, int, error) {
+ headerEnd, off, err := rr.Hdr.pack(msg, off, compression, compress)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- headerEnd := off
off, err = packUint8(rr.Hash, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
off, err = packUint8(rr.Flags, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
off, err = packUint16(rr.Iterations, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
off, err = packUint8(rr.SaltLength, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
// Only pack salt if value is not "-", i.e. empty
if rr.Salt != "-" {
off, err = packStringHex(rr.Salt, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
}
- rr.Header().Rdlength = uint16(off - headerEnd)
- return off, nil
+ return headerEnd, off, nil
}
-func (rr *OPENPGPKEY) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
- off, err := rr.Hdr.pack(msg, off, compression, compress)
+func (rr *OPENPGPKEY) pack(msg []byte, off int, compression compressionMap, compress bool) (int, int, error) {
+ headerEnd, off, err := rr.Hdr.pack(msg, off, compression, compress)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- headerEnd := off
off, err = packStringBase64(rr.PublicKey, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- rr.Header().Rdlength = uint16(off - headerEnd)
- return off, nil
+ return headerEnd, off, nil
}
-func (rr *OPT) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
- off, err := rr.Hdr.pack(msg, off, compression, compress)
+func (rr *OPT) pack(msg []byte, off int, compression compressionMap, compress bool) (int, int, error) {
+ headerEnd, off, err := rr.Hdr.pack(msg, off, compression, compress)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- headerEnd := off
off, err = packDataOpt(rr.Option, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- rr.Header().Rdlength = uint16(off - headerEnd)
- return off, nil
+ return headerEnd, off, nil
}
-func (rr *PTR) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
- off, err := rr.Hdr.pack(msg, off, compression, compress)
+func (rr *PTR) pack(msg []byte, off int, compression compressionMap, compress bool) (int, int, error) {
+ headerEnd, off, err := rr.Hdr.pack(msg, off, compression, compress)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- headerEnd := off
- off, err = PackDomainName(rr.Ptr, msg, off, compression, compress)
+ off, _, err = packDomainName(rr.Ptr, msg, off, compression, compress)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- rr.Header().Rdlength = uint16(off - headerEnd)
- return off, nil
+ return headerEnd, off, nil
}
-func (rr *PX) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
- off, err := rr.Hdr.pack(msg, off, compression, compress)
+func (rr *PX) pack(msg []byte, off int, compression compressionMap, compress bool) (int, int, error) {
+ headerEnd, off, err := rr.Hdr.pack(msg, off, compression, compress)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- headerEnd := off
off, err = packUint16(rr.Preference, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- off, err = PackDomainName(rr.Map822, msg, off, compression, false)
+ off, _, err = packDomainName(rr.Map822, msg, off, compression, false)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- off, err = PackDomainName(rr.Mapx400, msg, off, compression, false)
+ off, _, err = packDomainName(rr.Mapx400, msg, off, compression, false)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- rr.Header().Rdlength = uint16(off - headerEnd)
- return off, nil
+ return headerEnd, off, nil
}
-func (rr *RFC3597) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
- off, err := rr.Hdr.pack(msg, off, compression, compress)
+func (rr *RFC3597) pack(msg []byte, off int, compression compressionMap, compress bool) (int, int, error) {
+ headerEnd, off, err := rr.Hdr.pack(msg, off, compression, compress)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- headerEnd := off
off, err = packStringHex(rr.Rdata, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- rr.Header().Rdlength = uint16(off - headerEnd)
- return off, nil
+ return headerEnd, off, nil
}
-func (rr *RKEY) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
- off, err := rr.Hdr.pack(msg, off, compression, compress)
+func (rr *RKEY) pack(msg []byte, off int, compression compressionMap, compress bool) (int, int, error) {
+ headerEnd, off, err := rr.Hdr.pack(msg, off, compression, compress)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- headerEnd := off
off, err = packUint16(rr.Flags, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
off, err = packUint8(rr.Protocol, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
off, err = packUint8(rr.Algorithm, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
off, err = packStringBase64(rr.PublicKey, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- rr.Header().Rdlength = uint16(off - headerEnd)
- return off, nil
+ return headerEnd, off, nil
}
-func (rr *RP) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
- off, err := rr.Hdr.pack(msg, off, compression, compress)
+func (rr *RP) pack(msg []byte, off int, compression compressionMap, compress bool) (int, int, error) {
+ headerEnd, off, err := rr.Hdr.pack(msg, off, compression, compress)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- headerEnd := off
- off, err = PackDomainName(rr.Mbox, msg, off, compression, false)
+ off, _, err = packDomainName(rr.Mbox, msg, off, compression, false)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- off, err = PackDomainName(rr.Txt, msg, off, compression, false)
+ off, _, err = packDomainName(rr.Txt, msg, off, compression, false)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- rr.Header().Rdlength = uint16(off - headerEnd)
- return off, nil
+ return headerEnd, off, nil
}
-func (rr *RRSIG) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
- off, err := rr.Hdr.pack(msg, off, compression, compress)
+func (rr *RRSIG) pack(msg []byte, off int, compression compressionMap, compress bool) (int, int, error) {
+ headerEnd, off, err := rr.Hdr.pack(msg, off, compression, compress)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- headerEnd := off
off, err = packUint16(rr.TypeCovered, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
off, err = packUint8(rr.Algorithm, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
off, err = packUint8(rr.Labels, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
off, err = packUint32(rr.OrigTtl, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
off, err = packUint32(rr.Expiration, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
off, err = packUint32(rr.Inception, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
off, err = packUint16(rr.KeyTag, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- off, err = PackDomainName(rr.SignerName, msg, off, compression, false)
+ off, _, err = packDomainName(rr.SignerName, msg, off, compression, false)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
off, err = packStringBase64(rr.Signature, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- rr.Header().Rdlength = uint16(off - headerEnd)
- return off, nil
+ return headerEnd, off, nil
}
-func (rr *RT) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
- off, err := rr.Hdr.pack(msg, off, compression, compress)
+func (rr *RT) pack(msg []byte, off int, compression compressionMap, compress bool) (int, int, error) {
+ headerEnd, off, err := rr.Hdr.pack(msg, off, compression, compress)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- headerEnd := off
off, err = packUint16(rr.Preference, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- off, err = PackDomainName(rr.Host, msg, off, compression, compress)
+ off, _, err = packDomainName(rr.Host, msg, off, compression, false)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- rr.Header().Rdlength = uint16(off - headerEnd)
- return off, nil
+ return headerEnd, off, nil
}
-func (rr *SIG) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
- off, err := rr.Hdr.pack(msg, off, compression, compress)
+func (rr *SIG) pack(msg []byte, off int, compression compressionMap, compress bool) (int, int, error) {
+ headerEnd, off, err := rr.Hdr.pack(msg, off, compression, compress)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- headerEnd := off
off, err = packUint16(rr.TypeCovered, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
off, err = packUint8(rr.Algorithm, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
off, err = packUint8(rr.Labels, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
off, err = packUint32(rr.OrigTtl, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
off, err = packUint32(rr.Expiration, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
off, err = packUint32(rr.Inception, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
off, err = packUint16(rr.KeyTag, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- off, err = PackDomainName(rr.SignerName, msg, off, compression, false)
+ off, _, err = packDomainName(rr.SignerName, msg, off, compression, false)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
off, err = packStringBase64(rr.Signature, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- rr.Header().Rdlength = uint16(off - headerEnd)
- return off, nil
+ return headerEnd, off, nil
}
-func (rr *SMIMEA) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
- off, err := rr.Hdr.pack(msg, off, compression, compress)
+func (rr *SMIMEA) pack(msg []byte, off int, compression compressionMap, compress bool) (int, int, error) {
+ headerEnd, off, err := rr.Hdr.pack(msg, off, compression, compress)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- headerEnd := off
off, err = packUint8(rr.Usage, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
off, err = packUint8(rr.Selector, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
off, err = packUint8(rr.MatchingType, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
off, err = packStringHex(rr.Certificate, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- rr.Header().Rdlength = uint16(off - headerEnd)
- return off, nil
+ return headerEnd, off, nil
}
-func (rr *SOA) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
- off, err := rr.Hdr.pack(msg, off, compression, compress)
+func (rr *SOA) pack(msg []byte, off int, compression compressionMap, compress bool) (int, int, error) {
+ headerEnd, off, err := rr.Hdr.pack(msg, off, compression, compress)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- headerEnd := off
- off, err = PackDomainName(rr.Ns, msg, off, compression, compress)
+ off, _, err = packDomainName(rr.Ns, msg, off, compression, compress)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- off, err = PackDomainName(rr.Mbox, msg, off, compression, compress)
+ off, _, err = packDomainName(rr.Mbox, msg, off, compression, compress)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
off, err = packUint32(rr.Serial, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
off, err = packUint32(rr.Refresh, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
off, err = packUint32(rr.Retry, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
off, err = packUint32(rr.Expire, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
off, err = packUint32(rr.Minttl, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- rr.Header().Rdlength = uint16(off - headerEnd)
- return off, nil
+ return headerEnd, off, nil
}
-func (rr *SPF) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
- off, err := rr.Hdr.pack(msg, off, compression, compress)
+func (rr *SPF) pack(msg []byte, off int, compression compressionMap, compress bool) (int, int, error) {
+ headerEnd, off, err := rr.Hdr.pack(msg, off, compression, compress)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- headerEnd := off
off, err = packStringTxt(rr.Txt, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- rr.Header().Rdlength = uint16(off - headerEnd)
- return off, nil
+ return headerEnd, off, nil
}
-func (rr *SRV) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
- off, err := rr.Hdr.pack(msg, off, compression, compress)
+func (rr *SRV) pack(msg []byte, off int, compression compressionMap, compress bool) (int, int, error) {
+ headerEnd, off, err := rr.Hdr.pack(msg, off, compression, compress)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- headerEnd := off
off, err = packUint16(rr.Priority, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
off, err = packUint16(rr.Weight, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
off, err = packUint16(rr.Port, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- off, err = PackDomainName(rr.Target, msg, off, compression, false)
+ off, _, err = packDomainName(rr.Target, msg, off, compression, false)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- rr.Header().Rdlength = uint16(off - headerEnd)
- return off, nil
+ return headerEnd, off, nil
}
-func (rr *SSHFP) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
- off, err := rr.Hdr.pack(msg, off, compression, compress)
+func (rr *SSHFP) pack(msg []byte, off int, compression compressionMap, compress bool) (int, int, error) {
+ headerEnd, off, err := rr.Hdr.pack(msg, off, compression, compress)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- headerEnd := off
off, err = packUint8(rr.Algorithm, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
off, err = packUint8(rr.Type, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
off, err = packStringHex(rr.FingerPrint, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- rr.Header().Rdlength = uint16(off - headerEnd)
- return off, nil
+ return headerEnd, off, nil
}
-func (rr *TA) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
- off, err := rr.Hdr.pack(msg, off, compression, compress)
+func (rr *TA) pack(msg []byte, off int, compression compressionMap, compress bool) (int, int, error) {
+ headerEnd, off, err := rr.Hdr.pack(msg, off, compression, compress)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- headerEnd := off
off, err = packUint16(rr.KeyTag, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
off, err = packUint8(rr.Algorithm, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
off, err = packUint8(rr.DigestType, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
off, err = packStringHex(rr.Digest, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- rr.Header().Rdlength = uint16(off - headerEnd)
- return off, nil
+ return headerEnd, off, nil
}
-func (rr *TALINK) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
- off, err := rr.Hdr.pack(msg, off, compression, compress)
+func (rr *TALINK) pack(msg []byte, off int, compression compressionMap, compress bool) (int, int, error) {
+ headerEnd, off, err := rr.Hdr.pack(msg, off, compression, compress)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- headerEnd := off
- off, err = PackDomainName(rr.PreviousName, msg, off, compression, false)
+ off, _, err = packDomainName(rr.PreviousName, msg, off, compression, false)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- off, err = PackDomainName(rr.NextName, msg, off, compression, false)
+ off, _, err = packDomainName(rr.NextName, msg, off, compression, false)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- rr.Header().Rdlength = uint16(off - headerEnd)
- return off, nil
+ return headerEnd, off, nil
}
-func (rr *TKEY) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
- off, err := rr.Hdr.pack(msg, off, compression, compress)
+func (rr *TKEY) pack(msg []byte, off int, compression compressionMap, compress bool) (int, int, error) {
+ headerEnd, off, err := rr.Hdr.pack(msg, off, compression, compress)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- headerEnd := off
- off, err = PackDomainName(rr.Algorithm, msg, off, compression, false)
+ off, _, err = packDomainName(rr.Algorithm, msg, off, compression, false)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
off, err = packUint32(rr.Inception, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
off, err = packUint32(rr.Expiration, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
off, err = packUint16(rr.Mode, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
off, err = packUint16(rr.Error, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
off, err = packUint16(rr.KeySize, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
off, err = packStringHex(rr.Key, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
off, err = packUint16(rr.OtherLen, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
off, err = packStringHex(rr.OtherData, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- rr.Header().Rdlength = uint16(off - headerEnd)
- return off, nil
+ return headerEnd, off, nil
}
-func (rr *TLSA) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
- off, err := rr.Hdr.pack(msg, off, compression, compress)
+func (rr *TLSA) pack(msg []byte, off int, compression compressionMap, compress bool) (int, int, error) {
+ headerEnd, off, err := rr.Hdr.pack(msg, off, compression, compress)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- headerEnd := off
off, err = packUint8(rr.Usage, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
off, err = packUint8(rr.Selector, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
off, err = packUint8(rr.MatchingType, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
off, err = packStringHex(rr.Certificate, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- rr.Header().Rdlength = uint16(off - headerEnd)
- return off, nil
+ return headerEnd, off, nil
}
-func (rr *TSIG) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
- off, err := rr.Hdr.pack(msg, off, compression, compress)
+func (rr *TSIG) pack(msg []byte, off int, compression compressionMap, compress bool) (int, int, error) {
+ headerEnd, off, err := rr.Hdr.pack(msg, off, compression, compress)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- headerEnd := off
- off, err = PackDomainName(rr.Algorithm, msg, off, compression, false)
+ off, _, err = packDomainName(rr.Algorithm, msg, off, compression, false)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
off, err = packUint48(rr.TimeSigned, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
off, err = packUint16(rr.Fudge, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
off, err = packUint16(rr.MACSize, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
off, err = packStringHex(rr.MAC, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
off, err = packUint16(rr.OrigId, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
off, err = packUint16(rr.Error, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
off, err = packUint16(rr.OtherLen, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
off, err = packStringHex(rr.OtherData, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- rr.Header().Rdlength = uint16(off - headerEnd)
- return off, nil
+ return headerEnd, off, nil
}
-func (rr *TXT) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
- off, err := rr.Hdr.pack(msg, off, compression, compress)
+func (rr *TXT) pack(msg []byte, off int, compression compressionMap, compress bool) (int, int, error) {
+ headerEnd, off, err := rr.Hdr.pack(msg, off, compression, compress)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- headerEnd := off
off, err = packStringTxt(rr.Txt, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- rr.Header().Rdlength = uint16(off - headerEnd)
- return off, nil
+ return headerEnd, off, nil
}
-func (rr *UID) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
- off, err := rr.Hdr.pack(msg, off, compression, compress)
+func (rr *UID) pack(msg []byte, off int, compression compressionMap, compress bool) (int, int, error) {
+ headerEnd, off, err := rr.Hdr.pack(msg, off, compression, compress)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- headerEnd := off
off, err = packUint32(rr.Uid, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- rr.Header().Rdlength = uint16(off - headerEnd)
- return off, nil
+ return headerEnd, off, nil
}
-func (rr *UINFO) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
- off, err := rr.Hdr.pack(msg, off, compression, compress)
+func (rr *UINFO) pack(msg []byte, off int, compression compressionMap, compress bool) (int, int, error) {
+ headerEnd, off, err := rr.Hdr.pack(msg, off, compression, compress)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- headerEnd := off
off, err = packString(rr.Uinfo, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- rr.Header().Rdlength = uint16(off - headerEnd)
- return off, nil
+ return headerEnd, off, nil
}
-func (rr *URI) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
- off, err := rr.Hdr.pack(msg, off, compression, compress)
+func (rr *URI) pack(msg []byte, off int, compression compressionMap, compress bool) (int, int, error) {
+ headerEnd, off, err := rr.Hdr.pack(msg, off, compression, compress)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- headerEnd := off
off, err = packUint16(rr.Priority, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
off, err = packUint16(rr.Weight, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
off, err = packStringOctet(rr.Target, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- rr.Header().Rdlength = uint16(off - headerEnd)
- return off, nil
+ return headerEnd, off, nil
}
-func (rr *X25) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
- off, err := rr.Hdr.pack(msg, off, compression, compress)
+func (rr *X25) pack(msg []byte, off int, compression compressionMap, compress bool) (int, int, error) {
+ headerEnd, off, err := rr.Hdr.pack(msg, off, compression, compress)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- headerEnd := off
off, err = packString(rr.PSDNAddress, msg, off)
if err != nil {
- return off, err
+ return headerEnd, off, err
}
- rr.Header().Rdlength = uint16(off - headerEnd)
- return off, nil
+ return headerEnd, off, nil
}
// unpack*() functions
diff --git a/vendor/github.com/miekg/dns/ztypes.go b/vendor/github.com/miekg/dns/ztypes.go
index 965753b11..71662b7b7 100644
--- a/vendor/github.com/miekg/dns/ztypes.go
+++ b/vendor/github.com/miekg/dns/ztypes.go
@@ -236,144 +236,144 @@ func (rr *URI) Header() *RR_Header { return &rr.Hdr }
func (rr *X25) Header() *RR_Header { return &rr.Hdr }
// len() functions
-func (rr *A) len() int {
- l := rr.Hdr.len()
+func (rr *A) len(off int, compression map[string]struct{}) int {
+ l := rr.Hdr.len(off, compression)
l += net.IPv4len // A
return l
}
-func (rr *AAAA) len() int {
- l := rr.Hdr.len()
+func (rr *AAAA) len(off int, compression map[string]struct{}) int {
+ l := rr.Hdr.len(off, compression)
l += net.IPv6len // AAAA
return l
}
-func (rr *AFSDB) len() int {
- l := rr.Hdr.len()
+func (rr *AFSDB) len(off int, compression map[string]struct{}) int {
+ l := rr.Hdr.len(off, compression)
l += 2 // Subtype
- l += len(rr.Hostname) + 1
+ l += domainNameLen(rr.Hostname, off+l, compression, false)
return l
}
-func (rr *ANY) len() int {
- l := rr.Hdr.len()
+func (rr *ANY) len(off int, compression map[string]struct{}) int {
+ l := rr.Hdr.len(off, compression)
return l
}
-func (rr *AVC) len() int {
- l := rr.Hdr.len()
+func (rr *AVC) len(off int, compression map[string]struct{}) int {
+ l := rr.Hdr.len(off, compression)
for _, x := range rr.Txt {
l += len(x) + 1
}
return l
}
-func (rr *CAA) len() int {
- l := rr.Hdr.len()
+func (rr *CAA) len(off int, compression map[string]struct{}) int {
+ l := rr.Hdr.len(off, compression)
l++ // Flag
l += len(rr.Tag) + 1
l += len(rr.Value)
return l
}
-func (rr *CERT) len() int {
- l := rr.Hdr.len()
+func (rr *CERT) len(off int, compression map[string]struct{}) int {
+ l := rr.Hdr.len(off, compression)
l += 2 // Type
l += 2 // KeyTag
l++ // Algorithm
l += base64.StdEncoding.DecodedLen(len(rr.Certificate))
return l
}
-func (rr *CNAME) len() int {
- l := rr.Hdr.len()
- l += len(rr.Target) + 1
+func (rr *CNAME) len(off int, compression map[string]struct{}) int {
+ l := rr.Hdr.len(off, compression)
+ l += domainNameLen(rr.Target, off+l, compression, true)
return l
}
-func (rr *DHCID) len() int {
- l := rr.Hdr.len()
+func (rr *DHCID) len(off int, compression map[string]struct{}) int {
+ l := rr.Hdr.len(off, compression)
l += base64.StdEncoding.DecodedLen(len(rr.Digest))
return l
}
-func (rr *DNAME) len() int {
- l := rr.Hdr.len()
- l += len(rr.Target) + 1
+func (rr *DNAME) len(off int, compression map[string]struct{}) int {
+ l := rr.Hdr.len(off, compression)
+ l += domainNameLen(rr.Target, off+l, compression, false)
return l
}
-func (rr *DNSKEY) len() int {
- l := rr.Hdr.len()
+func (rr *DNSKEY) len(off int, compression map[string]struct{}) int {
+ l := rr.Hdr.len(off, compression)
l += 2 // Flags
l++ // Protocol
l++ // Algorithm
l += base64.StdEncoding.DecodedLen(len(rr.PublicKey))
return l
}
-func (rr *DS) len() int {
- l := rr.Hdr.len()
+func (rr *DS) len(off int, compression map[string]struct{}) int {
+ l := rr.Hdr.len(off, compression)
l += 2 // KeyTag
l++ // Algorithm
l++ // DigestType
l += len(rr.Digest)/2 + 1
return l
}
-func (rr *EID) len() int {
- l := rr.Hdr.len()
+func (rr *EID) len(off int, compression map[string]struct{}) int {
+ l := rr.Hdr.len(off, compression)
l += len(rr.Endpoint)/2 + 1
return l
}
-func (rr *EUI48) len() int {
- l := rr.Hdr.len()
+func (rr *EUI48) len(off int, compression map[string]struct{}) int {
+ l := rr.Hdr.len(off, compression)
l += 6 // Address
return l
}
-func (rr *EUI64) len() int {
- l := rr.Hdr.len()
+func (rr *EUI64) len(off int, compression map[string]struct{}) int {
+ l := rr.Hdr.len(off, compression)
l += 8 // Address
return l
}
-func (rr *GID) len() int {
- l := rr.Hdr.len()
+func (rr *GID) len(off int, compression map[string]struct{}) int {
+ l := rr.Hdr.len(off, compression)
l += 4 // Gid
return l
}
-func (rr *GPOS) len() int {
- l := rr.Hdr.len()
+func (rr *GPOS) len(off int, compression map[string]struct{}) int {
+ l := rr.Hdr.len(off, compression)
l += len(rr.Longitude) + 1
l += len(rr.Latitude) + 1
l += len(rr.Altitude) + 1
return l
}
-func (rr *HINFO) len() int {
- l := rr.Hdr.len()
+func (rr *HINFO) len(off int, compression map[string]struct{}) int {
+ l := rr.Hdr.len(off, compression)
l += len(rr.Cpu) + 1
l += len(rr.Os) + 1
return l
}
-func (rr *HIP) len() int {
- l := rr.Hdr.len()
+func (rr *HIP) len(off int, compression map[string]struct{}) int {
+ l := rr.Hdr.len(off, compression)
l++ // HitLength
l++ // PublicKeyAlgorithm
l += 2 // PublicKeyLength
l += len(rr.Hit) / 2
l += base64.StdEncoding.DecodedLen(len(rr.PublicKey))
for _, x := range rr.RendezvousServers {
- l += len(x) + 1
+ l += domainNameLen(x, off+l, compression, false)
}
return l
}
-func (rr *KX) len() int {
- l := rr.Hdr.len()
+func (rr *KX) len(off int, compression map[string]struct{}) int {
+ l := rr.Hdr.len(off, compression)
l += 2 // Preference
- l += len(rr.Exchanger) + 1
+ l += domainNameLen(rr.Exchanger, off+l, compression, false)
return l
}
-func (rr *L32) len() int {
- l := rr.Hdr.len()
+func (rr *L32) len(off int, compression map[string]struct{}) int {
+ l := rr.Hdr.len(off, compression)
l += 2 // Preference
l += net.IPv4len // Locator32
return l
}
-func (rr *L64) len() int {
- l := rr.Hdr.len()
+func (rr *L64) len(off int, compression map[string]struct{}) int {
+ l := rr.Hdr.len(off, compression)
l += 2 // Preference
l += 8 // Locator64
return l
}
-func (rr *LOC) len() int {
- l := rr.Hdr.len()
+func (rr *LOC) len(off int, compression map[string]struct{}) int {
+ l := rr.Hdr.len(off, compression)
l++ // Version
l++ // Size
l++ // HorizPre
@@ -383,89 +383,89 @@ func (rr *LOC) len() int {
l += 4 // Altitude
return l
}
-func (rr *LP) len() int {
- l := rr.Hdr.len()
+func (rr *LP) len(off int, compression map[string]struct{}) int {
+ l := rr.Hdr.len(off, compression)
l += 2 // Preference
- l += len(rr.Fqdn) + 1
+ l += domainNameLen(rr.Fqdn, off+l, compression, false)
return l
}
-func (rr *MB) len() int {
- l := rr.Hdr.len()
- l += len(rr.Mb) + 1
+func (rr *MB) len(off int, compression map[string]struct{}) int {
+ l := rr.Hdr.len(off, compression)
+ l += domainNameLen(rr.Mb, off+l, compression, true)
return l
}
-func (rr *MD) len() int {
- l := rr.Hdr.len()
- l += len(rr.Md) + 1
+func (rr *MD) len(off int, compression map[string]struct{}) int {
+ l := rr.Hdr.len(off, compression)
+ l += domainNameLen(rr.Md, off+l, compression, true)
return l
}
-func (rr *MF) len() int {
- l := rr.Hdr.len()
- l += len(rr.Mf) + 1
+func (rr *MF) len(off int, compression map[string]struct{}) int {
+ l := rr.Hdr.len(off, compression)
+ l += domainNameLen(rr.Mf, off+l, compression, true)
return l
}
-func (rr *MG) len() int {
- l := rr.Hdr.len()
- l += len(rr.Mg) + 1
+func (rr *MG) len(off int, compression map[string]struct{}) int {
+ l := rr.Hdr.len(off, compression)
+ l += domainNameLen(rr.Mg, off+l, compression, true)
return l
}
-func (rr *MINFO) len() int {
- l := rr.Hdr.len()
- l += len(rr.Rmail) + 1
- l += len(rr.Email) + 1
+func (rr *MINFO) len(off int, compression map[string]struct{}) int {
+ l := rr.Hdr.len(off, compression)
+ l += domainNameLen(rr.Rmail, off+l, compression, true)
+ l += domainNameLen(rr.Email, off+l, compression, true)
return l
}
-func (rr *MR) len() int {
- l := rr.Hdr.len()
- l += len(rr.Mr) + 1
+func (rr *MR) len(off int, compression map[string]struct{}) int {
+ l := rr.Hdr.len(off, compression)
+ l += domainNameLen(rr.Mr, off+l, compression, true)
return l
}
-func (rr *MX) len() int {
- l := rr.Hdr.len()
+func (rr *MX) len(off int, compression map[string]struct{}) int {
+ l := rr.Hdr.len(off, compression)
l += 2 // Preference
- l += len(rr.Mx) + 1
+ l += domainNameLen(rr.Mx, off+l, compression, true)
return l
}
-func (rr *NAPTR) len() int {
- l := rr.Hdr.len()
+func (rr *NAPTR) len(off int, compression map[string]struct{}) int {
+ l := rr.Hdr.len(off, compression)
l += 2 // Order
l += 2 // Preference
l += len(rr.Flags) + 1
l += len(rr.Service) + 1
l += len(rr.Regexp) + 1
- l += len(rr.Replacement) + 1
+ l += domainNameLen(rr.Replacement, off+l, compression, false)
return l
}
-func (rr *NID) len() int {
- l := rr.Hdr.len()
+func (rr *NID) len(off int, compression map[string]struct{}) int {
+ l := rr.Hdr.len(off, compression)
l += 2 // Preference
l += 8 // NodeID
return l
}
-func (rr *NIMLOC) len() int {
- l := rr.Hdr.len()
+func (rr *NIMLOC) len(off int, compression map[string]struct{}) int {
+ l := rr.Hdr.len(off, compression)
l += len(rr.Locator)/2 + 1
return l
}
-func (rr *NINFO) len() int {
- l := rr.Hdr.len()
+func (rr *NINFO) len(off int, compression map[string]struct{}) int {
+ l := rr.Hdr.len(off, compression)
for _, x := range rr.ZSData {
l += len(x) + 1
}
return l
}
-func (rr *NS) len() int {
- l := rr.Hdr.len()
- l += len(rr.Ns) + 1
+func (rr *NS) len(off int, compression map[string]struct{}) int {
+ l := rr.Hdr.len(off, compression)
+ l += domainNameLen(rr.Ns, off+l, compression, true)
return l
}
-func (rr *NSAPPTR) len() int {
- l := rr.Hdr.len()
- l += len(rr.Ptr) + 1
+func (rr *NSAPPTR) len(off int, compression map[string]struct{}) int {
+ l := rr.Hdr.len(off, compression)
+ l += domainNameLen(rr.Ptr, off+l, compression, false)
return l
}
-func (rr *NSEC3PARAM) len() int {
- l := rr.Hdr.len()
+func (rr *NSEC3PARAM) len(off int, compression map[string]struct{}) int {
+ l := rr.Hdr.len(off, compression)
l++ // Hash
l++ // Flags
l += 2 // Iterations
@@ -473,44 +473,44 @@ func (rr *NSEC3PARAM) len() int {
l += len(rr.Salt) / 2
return l
}
-func (rr *OPENPGPKEY) len() int {
- l := rr.Hdr.len()
+func (rr *OPENPGPKEY) len(off int, compression map[string]struct{}) int {
+ l := rr.Hdr.len(off, compression)
l += base64.StdEncoding.DecodedLen(len(rr.PublicKey))
return l
}
-func (rr *PTR) len() int {
- l := rr.Hdr.len()
- l += len(rr.Ptr) + 1
+func (rr *PTR) len(off int, compression map[string]struct{}) int {
+ l := rr.Hdr.len(off, compression)
+ l += domainNameLen(rr.Ptr, off+l, compression, true)
return l
}
-func (rr *PX) len() int {
- l := rr.Hdr.len()
+func (rr *PX) len(off int, compression map[string]struct{}) int {
+ l := rr.Hdr.len(off, compression)
l += 2 // Preference
- l += len(rr.Map822) + 1
- l += len(rr.Mapx400) + 1
+ l += domainNameLen(rr.Map822, off+l, compression, false)
+ l += domainNameLen(rr.Mapx400, off+l, compression, false)
return l
}
-func (rr *RFC3597) len() int {
- l := rr.Hdr.len()
+func (rr *RFC3597) len(off int, compression map[string]struct{}) int {
+ l := rr.Hdr.len(off, compression)
l += len(rr.Rdata)/2 + 1
return l
}
-func (rr *RKEY) len() int {
- l := rr.Hdr.len()
+func (rr *RKEY) len(off int, compression map[string]struct{}) int {
+ l := rr.Hdr.len(off, compression)
l += 2 // Flags
l++ // Protocol
l++ // Algorithm
l += base64.StdEncoding.DecodedLen(len(rr.PublicKey))
return l
}
-func (rr *RP) len() int {
- l := rr.Hdr.len()
- l += len(rr.Mbox) + 1
- l += len(rr.Txt) + 1
+func (rr *RP) len(off int, compression map[string]struct{}) int {
+ l := rr.Hdr.len(off, compression)
+ l += domainNameLen(rr.Mbox, off+l, compression, false)
+ l += domainNameLen(rr.Txt, off+l, compression, false)
return l
}
-func (rr *RRSIG) len() int {
- l := rr.Hdr.len()
+func (rr *RRSIG) len(off int, compression map[string]struct{}) int {
+ l := rr.Hdr.len(off, compression)
l += 2 // TypeCovered
l++ // Algorithm
l++ // Labels
@@ -518,28 +518,28 @@ func (rr *RRSIG) len() int {
l += 4 // Expiration
l += 4 // Inception
l += 2 // KeyTag
- l += len(rr.SignerName) + 1
+ l += domainNameLen(rr.SignerName, off+l, compression, false)
l += base64.StdEncoding.DecodedLen(len(rr.Signature))
return l
}
-func (rr *RT) len() int {
- l := rr.Hdr.len()
+func (rr *RT) len(off int, compression map[string]struct{}) int {
+ l := rr.Hdr.len(off, compression)
l += 2 // Preference
- l += len(rr.Host) + 1
+ l += domainNameLen(rr.Host, off+l, compression, false)
return l
}
-func (rr *SMIMEA) len() int {
- l := rr.Hdr.len()
+func (rr *SMIMEA) len(off int, compression map[string]struct{}) int {
+ l := rr.Hdr.len(off, compression)
l++ // Usage
l++ // Selector
l++ // MatchingType
l += len(rr.Certificate)/2 + 1
return l
}
-func (rr *SOA) len() int {
- l := rr.Hdr.len()
- l += len(rr.Ns) + 1
- l += len(rr.Mbox) + 1
+func (rr *SOA) len(off int, compression map[string]struct{}) int {
+ l := rr.Hdr.len(off, compression)
+ l += domainNameLen(rr.Ns, off+l, compression, true)
+ l += domainNameLen(rr.Mbox, off+l, compression, true)
l += 4 // Serial
l += 4 // Refresh
l += 4 // Retry
@@ -547,45 +547,45 @@ func (rr *SOA) len() int {
l += 4 // Minttl
return l
}
-func (rr *SPF) len() int {
- l := rr.Hdr.len()
+func (rr *SPF) len(off int, compression map[string]struct{}) int {
+ l := rr.Hdr.len(off, compression)
for _, x := range rr.Txt {
l += len(x) + 1
}
return l
}
-func (rr *SRV) len() int {
- l := rr.Hdr.len()
+func (rr *SRV) len(off int, compression map[string]struct{}) int {
+ l := rr.Hdr.len(off, compression)
l += 2 // Priority
l += 2 // Weight
l += 2 // Port
- l += len(rr.Target) + 1
+ l += domainNameLen(rr.Target, off+l, compression, false)
return l
}
-func (rr *SSHFP) len() int {
- l := rr.Hdr.len()
+func (rr *SSHFP) len(off int, compression map[string]struct{}) int {
+ l := rr.Hdr.len(off, compression)
l++ // Algorithm
l++ // Type
l += len(rr.FingerPrint)/2 + 1
return l
}
-func (rr *TA) len() int {
- l := rr.Hdr.len()
+func (rr *TA) len(off int, compression map[string]struct{}) int {
+ l := rr.Hdr.len(off, compression)
l += 2 // KeyTag
l++ // Algorithm
l++ // DigestType
l += len(rr.Digest)/2 + 1
return l
}
-func (rr *TALINK) len() int {
- l := rr.Hdr.len()
- l += len(rr.PreviousName) + 1
- l += len(rr.NextName) + 1
+func (rr *TALINK) len(off int, compression map[string]struct{}) int {
+ l := rr.Hdr.len(off, compression)
+ l += domainNameLen(rr.PreviousName, off+l, compression, false)
+ l += domainNameLen(rr.NextName, off+l, compression, false)
return l
}
-func (rr *TKEY) len() int {
- l := rr.Hdr.len()
- l += len(rr.Algorithm) + 1
+func (rr *TKEY) len(off int, compression map[string]struct{}) int {
+ l := rr.Hdr.len(off, compression)
+ l += domainNameLen(rr.Algorithm, off+l, compression, false)
l += 4 // Inception
l += 4 // Expiration
l += 2 // Mode
@@ -596,17 +596,17 @@ func (rr *TKEY) len() int {
l += len(rr.OtherData) / 2
return l
}
-func (rr *TLSA) len() int {
- l := rr.Hdr.len()
+func (rr *TLSA) len(off int, compression map[string]struct{}) int {
+ l := rr.Hdr.len(off, compression)
l++ // Usage
l++ // Selector
l++ // MatchingType
l += len(rr.Certificate)/2 + 1
return l
}
-func (rr *TSIG) len() int {
- l := rr.Hdr.len()
- l += len(rr.Algorithm) + 1
+func (rr *TSIG) len(off int, compression map[string]struct{}) int {
+ l := rr.Hdr.len(off, compression)
+ l += domainNameLen(rr.Algorithm, off+l, compression, false)
l += 6 // TimeSigned
l += 2 // Fudge
l += 2 // MACSize
@@ -617,32 +617,32 @@ func (rr *TSIG) len() int {
l += len(rr.OtherData) / 2
return l
}
-func (rr *TXT) len() int {
- l := rr.Hdr.len()
+func (rr *TXT) len(off int, compression map[string]struct{}) int {
+ l := rr.Hdr.len(off, compression)
for _, x := range rr.Txt {
l += len(x) + 1
}
return l
}
-func (rr *UID) len() int {
- l := rr.Hdr.len()
+func (rr *UID) len(off int, compression map[string]struct{}) int {
+ l := rr.Hdr.len(off, compression)
l += 4 // Uid
return l
}
-func (rr *UINFO) len() int {
- l := rr.Hdr.len()
+func (rr *UINFO) len(off int, compression map[string]struct{}) int {
+ l := rr.Hdr.len(off, compression)
l += len(rr.Uinfo) + 1
return l
}
-func (rr *URI) len() int {
- l := rr.Hdr.len()
+func (rr *URI) len(off int, compression map[string]struct{}) int {
+ l := rr.Hdr.len(off, compression)
l += 2 // Priority
l += 2 // Weight
l += len(rr.Target)
return l
}
-func (rr *X25) len() int {
- l := rr.Hdr.len()
+func (rr *X25) len(off int, compression map[string]struct{}) int {
+ l := rr.Hdr.len(off, compression)
l += len(rr.PSDNAddress) + 1
return l
}
diff --git a/vendor/github.com/ulule/deepcopier/LICENSE b/vendor/github.com/mohae/deepcopy/LICENSE
similarity index 97%
rename from vendor/github.com/ulule/deepcopier/LICENSE
rename to vendor/github.com/mohae/deepcopy/LICENSE
index d5c4ea02c..419673f00 100644
--- a/vendor/github.com/ulule/deepcopier/LICENSE
+++ b/vendor/github.com/mohae/deepcopy/LICENSE
@@ -1,6 +1,6 @@
The MIT License (MIT)
-Copyright (c) 2015 Ulule
+Copyright (c) 2014 Joel
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@@ -19,4 +19,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
-
diff --git a/vendor/github.com/mohae/deepcopy/README.md b/vendor/github.com/mohae/deepcopy/README.md
new file mode 100644
index 000000000..f81841885
--- /dev/null
+++ b/vendor/github.com/mohae/deepcopy/README.md
@@ -0,0 +1,8 @@
+deepCopy
+========
+[](https://godoc.org/github.com/mohae/deepcopy)[](https://travis-ci.org/mohae/deepcopy)
+
+DeepCopy makes deep copies of things: unexported field values are not copied.
+
+## Usage
+ cpy := deepcopy.Copy(orig)
diff --git a/vendor/github.com/mohae/deepcopy/deepcopy.go b/vendor/github.com/mohae/deepcopy/deepcopy.go
new file mode 100644
index 000000000..ba763ad09
--- /dev/null
+++ b/vendor/github.com/mohae/deepcopy/deepcopy.go
@@ -0,0 +1,125 @@
+// deepcopy makes deep copies of things. A standard copy will copy the
+// pointers: deep copy copies the values pointed to. Unexported field
+// values are not copied.
+//
+// Copyright (c)2014-2016, Joel Scoble (github.com/mohae), all rights reserved.
+// License: MIT, for more details check the included LICENSE file.
+package deepcopy
+
+import (
+ "reflect"
+ "time"
+)
+
+// Interface for delegating copy process to type
+type Interface interface {
+ DeepCopy() interface{}
+}
+
+// Iface is an alias to Copy; this exists for backwards compatibility reasons.
+func Iface(iface interface{}) interface{} {
+ return Copy(iface)
+}
+
+// Copy creates a deep copy of whatever is passed to it and returns the copy
+// in an interface{}. The returned value will need to be asserted to the
+// correct type.
+func Copy(src interface{}) interface{} {
+ if src == nil {
+ return nil
+ }
+
+ // Make the interface a reflect.Value
+ original := reflect.ValueOf(src)
+
+ // Make a copy of the same type as the original.
+ cpy := reflect.New(original.Type()).Elem()
+
+ // Recursively copy the original.
+ copyRecursive(original, cpy)
+
+ // Return the copy as an interface.
+ return cpy.Interface()
+}
+
+// copyRecursive does the actual copying of the interface. It currently has
+// limited support for what it can handle. Add as needed.
+func copyRecursive(original, cpy reflect.Value) {
+ // check for implement deepcopy.Interface
+ if original.CanInterface() {
+ if copier, ok := original.Interface().(Interface); ok {
+ cpy.Set(reflect.ValueOf(copier.DeepCopy()))
+ return
+ }
+ }
+
+ // handle according to original's Kind
+ switch original.Kind() {
+ case reflect.Ptr:
+ // Get the actual value being pointed to.
+ originalValue := original.Elem()
+
+ // if it isn't valid, return.
+ if !originalValue.IsValid() {
+ return
+ }
+ cpy.Set(reflect.New(originalValue.Type()))
+ copyRecursive(originalValue, cpy.Elem())
+
+ case reflect.Interface:
+ // If this is a nil, don't do anything
+ if original.IsNil() {
+ return
+ }
+ // Get the value for the interface, not the pointer.
+ originalValue := original.Elem()
+
+ // Get the value by calling Elem().
+ copyValue := reflect.New(originalValue.Type()).Elem()
+ copyRecursive(originalValue, copyValue)
+ cpy.Set(copyValue)
+
+ case reflect.Struct:
+ t, ok := original.Interface().(time.Time)
+ if ok {
+ cpy.Set(reflect.ValueOf(t))
+ return
+ }
+ // Go through each field of the struct and copy it.
+ for i := 0; i < original.NumField(); i++ {
+ // The Type's StructField for a given field is checked to see if StructField.PkgPath
+ // is set to determine if the field is exported or not because CanSet() returns false
+ // for settable fields. I'm not sure why. -mohae
+ if original.Type().Field(i).PkgPath != "" {
+ continue
+ }
+ copyRecursive(original.Field(i), cpy.Field(i))
+ }
+
+ case reflect.Slice:
+ if original.IsNil() {
+ return
+ }
+ // Make a new slice and copy each element.
+ cpy.Set(reflect.MakeSlice(original.Type(), original.Len(), original.Cap()))
+ for i := 0; i < original.Len(); i++ {
+ copyRecursive(original.Index(i), cpy.Index(i))
+ }
+
+ case reflect.Map:
+ if original.IsNil() {
+ return
+ }
+ cpy.Set(reflect.MakeMap(original.Type()))
+ for _, key := range original.MapKeys() {
+ originalValue := original.MapIndex(key)
+ copyValue := reflect.New(originalValue.Type()).Elem()
+ copyRecursive(originalValue, copyValue)
+ copyKey := Copy(key.Interface())
+ cpy.SetMapIndex(reflect.ValueOf(copyKey), copyValue)
+ }
+
+ default:
+ cpy.Set(original)
+ }
+}
diff --git a/vendor/github.com/prometheus/client_golang/prometheus/counter.go b/vendor/github.com/prometheus/client_golang/prometheus/counter.go
index 765e4550c..d463e36d3 100644
--- a/vendor/github.com/prometheus/client_golang/prometheus/counter.go
+++ b/vendor/github.com/prometheus/client_golang/prometheus/counter.go
@@ -136,7 +136,7 @@ func NewCounterVec(opts CounterOpts, labelNames []string) *CounterVec {
return &CounterVec{
metricVec: newMetricVec(desc, func(lvs ...string) Metric {
if len(lvs) != len(desc.variableLabels) {
- panic(errInconsistentCardinality)
+ panic(makeInconsistentCardinalityError(desc.fqName, desc.variableLabels, lvs))
}
result := &counter{desc: desc, labelPairs: makeLabelPairs(desc, lvs)}
result.init(result) // Init self-collection.
diff --git a/vendor/github.com/prometheus/client_golang/prometheus/desc.go b/vendor/github.com/prometheus/client_golang/prometheus/desc.go
index 7b8827ffb..1d034f871 100644
--- a/vendor/github.com/prometheus/client_golang/prometheus/desc.go
+++ b/vendor/github.com/prometheus/client_golang/prometheus/desc.go
@@ -93,7 +93,7 @@ func NewDesc(fqName, help string, variableLabels []string, constLabels Labels) *
// First add only the const label names and sort them...
for labelName := range constLabels {
if !checkLabelName(labelName) {
- d.err = fmt.Errorf("%q is not a valid label name", labelName)
+ d.err = fmt.Errorf("%q is not a valid label name for metric %q", labelName, fqName)
return d
}
labelNames = append(labelNames, labelName)
@@ -115,7 +115,7 @@ func NewDesc(fqName, help string, variableLabels []string, constLabels Labels) *
// dimension with a different mix between preset and variable labels.
for _, labelName := range variableLabels {
if !checkLabelName(labelName) {
- d.err = fmt.Errorf("%q is not a valid label name", labelName)
+ d.err = fmt.Errorf("%q is not a valid label name for metric %q", labelName, fqName)
return d
}
labelNames = append(labelNames, "$"+labelName)
diff --git a/vendor/github.com/prometheus/client_golang/prometheus/gauge.go b/vendor/github.com/prometheus/client_golang/prometheus/gauge.go
index 17c72d7eb..71d406bd9 100644
--- a/vendor/github.com/prometheus/client_golang/prometheus/gauge.go
+++ b/vendor/github.com/prometheus/client_golang/prometheus/gauge.go
@@ -147,7 +147,7 @@ func NewGaugeVec(opts GaugeOpts, labelNames []string) *GaugeVec {
return &GaugeVec{
metricVec: newMetricVec(desc, func(lvs ...string) Metric {
if len(lvs) != len(desc.variableLabels) {
- panic(errInconsistentCardinality)
+ panic(makeInconsistentCardinalityError(desc.fqName, desc.variableLabels, lvs))
}
result := &gauge{desc: desc, labelPairs: makeLabelPairs(desc, lvs)}
result.init(result) // Init self-collection.
diff --git a/vendor/github.com/prometheus/client_golang/prometheus/histogram.go b/vendor/github.com/prometheus/client_golang/prometheus/histogram.go
index 4d7fa976e..f88da707b 100644
--- a/vendor/github.com/prometheus/client_golang/prometheus/histogram.go
+++ b/vendor/github.com/prometheus/client_golang/prometheus/histogram.go
@@ -165,7 +165,7 @@ func NewHistogram(opts HistogramOpts) Histogram {
func newHistogram(desc *Desc, opts HistogramOpts, labelValues ...string) Histogram {
if len(desc.variableLabels) != len(labelValues) {
- panic(errInconsistentCardinality)
+ panic(makeInconsistentCardinalityError(desc.fqName, desc.variableLabels, labelValues))
}
for _, n := range desc.variableLabels {
diff --git a/vendor/github.com/prometheus/client_golang/prometheus/labels.go b/vendor/github.com/prometheus/client_golang/prometheus/labels.go
index e68f132ec..2744443ac 100644
--- a/vendor/github.com/prometheus/client_golang/prometheus/labels.go
+++ b/vendor/github.com/prometheus/client_golang/prometheus/labels.go
@@ -37,9 +37,22 @@ const reservedLabelPrefix = "__"
var errInconsistentCardinality = errors.New("inconsistent label cardinality")
+func makeInconsistentCardinalityError(fqName string, labels, labelValues []string) error {
+ return fmt.Errorf(
+ "%s: %q has %d variable labels named %q but %d values %q were provided",
+ errInconsistentCardinality, fqName,
+ len(labels), labels,
+ len(labelValues), labelValues,
+ )
+}
+
func validateValuesInLabels(labels Labels, expectedNumberOfValues int) error {
if len(labels) != expectedNumberOfValues {
- return errInconsistentCardinality
+ return fmt.Errorf(
+ "%s: expected %d label values but got %d in %#v",
+ errInconsistentCardinality, expectedNumberOfValues,
+ len(labels), labels,
+ )
}
for name, val := range labels {
@@ -53,7 +66,11 @@ func validateValuesInLabels(labels Labels, expectedNumberOfValues int) error {
func validateLabelValues(vals []string, expectedNumberOfValues int) error {
if len(vals) != expectedNumberOfValues {
- return errInconsistentCardinality
+ return fmt.Errorf(
+ "%s: expected %d label values but got %d in %#v",
+ errInconsistentCardinality, expectedNumberOfValues,
+ len(vals), vals,
+ )
}
for _, val := range vals {
diff --git a/vendor/github.com/prometheus/client_golang/prometheus/registry.go b/vendor/github.com/prometheus/client_golang/prometheus/registry.go
index e422ef383..f2fb67aee 100644
--- a/vendor/github.com/prometheus/client_golang/prometheus/registry.go
+++ b/vendor/github.com/prometheus/client_golang/prometheus/registry.go
@@ -16,6 +16,9 @@ package prometheus
import (
"bytes"
"fmt"
+ "io/ioutil"
+ "os"
+ "path/filepath"
"runtime"
"sort"
"strings"
@@ -23,6 +26,7 @@ import (
"unicode/utf8"
"github.com/golang/protobuf/proto"
+ "github.com/prometheus/common/expfmt"
dto "github.com/prometheus/client_model/go"
@@ -533,6 +537,38 @@ func (r *Registry) Gather() ([]*dto.MetricFamily, error) {
return internal.NormalizeMetricFamilies(metricFamiliesByName), errs.MaybeUnwrap()
}
+// WriteToTextfile calls Gather on the provided Gatherer, encodes the result in the
+// Prometheus text format, and writes it to a temporary file. Upon success, the
+// temporary file is renamed to the provided filename.
+//
+// This is intended for use with the textfile collector of the node exporter.
+// Note that the node exporter expects the filename to be suffixed with ".prom".
+func WriteToTextfile(filename string, g Gatherer) error {
+ tmp, err := ioutil.TempFile(filepath.Dir(filename), filepath.Base(filename))
+ if err != nil {
+ return err
+ }
+ defer os.Remove(tmp.Name())
+
+ mfs, err := g.Gather()
+ if err != nil {
+ return err
+ }
+ for _, mf := range mfs {
+ if _, err := expfmt.MetricFamilyToText(tmp, mf); err != nil {
+ return err
+ }
+ }
+ if err := tmp.Close(); err != nil {
+ return err
+ }
+
+ if err := os.Chmod(tmp.Name(), 0644); err != nil {
+ return err
+ }
+ return os.Rename(tmp.Name(), filename)
+}
+
// processMetric is an internal helper method only used by the Gather method.
func processMetric(
metric Metric,
@@ -644,7 +680,7 @@ func processMetric(
// Gatherers is a slice of Gatherer instances that implements the Gatherer
// interface itself. Its Gather method calls Gather on all Gatherers in the
// slice in order and returns the merged results. Errors returned from the
-// Gather calles are all returned in a flattened MultiError. Duplicate and
+// Gather calls are all returned in a flattened MultiError. Duplicate and
// inconsistent Metrics are skipped (first occurrence in slice order wins) and
// reported in the returned error.
//
@@ -836,7 +872,13 @@ func checkMetricConsistency(
h = hashAddByte(h, separatorByte)
// Make sure label pairs are sorted. We depend on it for the consistency
// check.
- sort.Sort(labelPairSorter(dtoMetric.Label))
+ if !sort.IsSorted(labelPairSorter(dtoMetric.Label)) {
+ // We cannot sort dtoMetric.Label in place as it is immutable by contract.
+ copiedLabels := make([]*dto.LabelPair, len(dtoMetric.Label))
+ copy(copiedLabels, dtoMetric.Label)
+ sort.Sort(labelPairSorter(copiedLabels))
+ dtoMetric.Label = copiedLabels
+ }
for _, lp := range dtoMetric.Label {
h = hashAdd(h, lp.GetName())
h = hashAddByte(h, separatorByte)
@@ -867,8 +909,8 @@ func checkDescConsistency(
}
// Is the desc consistent with the content of the metric?
- lpsFromDesc := make([]*dto.LabelPair, 0, len(dtoMetric.Label))
- lpsFromDesc = append(lpsFromDesc, desc.constLabelPairs...)
+ lpsFromDesc := make([]*dto.LabelPair, len(desc.constLabelPairs), len(dtoMetric.Label))
+ copy(lpsFromDesc, desc.constLabelPairs)
for _, l := range desc.variableLabels {
lpsFromDesc = append(lpsFromDesc, &dto.LabelPair{
Name: proto.String(l),
diff --git a/vendor/github.com/prometheus/client_golang/prometheus/summary.go b/vendor/github.com/prometheus/client_golang/prometheus/summary.go
index f7e92d829..2980614df 100644
--- a/vendor/github.com/prometheus/client_golang/prometheus/summary.go
+++ b/vendor/github.com/prometheus/client_golang/prometheus/summary.go
@@ -181,7 +181,7 @@ func NewSummary(opts SummaryOpts) Summary {
func newSummary(desc *Desc, opts SummaryOpts, labelValues ...string) Summary {
if len(desc.variableLabels) != len(labelValues) {
- panic(errInconsistentCardinality)
+ panic(makeInconsistentCardinalityError(desc.fqName, desc.variableLabels, labelValues))
}
for _, n := range desc.variableLabels {
diff --git a/vendor/github.com/prometheus/client_golang/prometheus/timer.go b/vendor/github.com/prometheus/client_golang/prometheus/timer.go
index b8fc5f18c..8d5f10523 100644
--- a/vendor/github.com/prometheus/client_golang/prometheus/timer.go
+++ b/vendor/github.com/prometheus/client_golang/prometheus/timer.go
@@ -39,13 +39,16 @@ func NewTimer(o Observer) *Timer {
// ObserveDuration records the duration passed since the Timer was created with
// NewTimer. It calls the Observe method of the Observer provided during
-// construction with the duration in seconds as an argument. ObserveDuration is
-// usually called with a defer statement.
+// construction with the duration in seconds as an argument. The observed
+// duration is also returned. ObserveDuration is usually called with a defer
+// statement.
//
// Note that this method is only guaranteed to never observe negative durations
// if used with Go1.9+.
-func (t *Timer) ObserveDuration() {
+func (t *Timer) ObserveDuration() time.Duration {
+ d := time.Since(t.begin)
if t.observer != nil {
- t.observer.Observe(time.Since(t.begin).Seconds())
+ t.observer.Observe(d.Seconds())
}
+ return d
}
diff --git a/vendor/github.com/prometheus/common/expfmt/text_create.go b/vendor/github.com/prometheus/common/expfmt/text_create.go
index 8e473d0fe..16655d417 100644
--- a/vendor/github.com/prometheus/common/expfmt/text_create.go
+++ b/vendor/github.com/prometheus/common/expfmt/text_create.go
@@ -436,11 +436,11 @@ func writeEscapedString(w enhancedWriter, v string, includeDoubleQuote bool) (in
func writeFloat(w enhancedWriter, f float64) (int, error) {
switch {
case f == 1:
- return 1, w.WriteByte('1')
+ return w.WriteString("1.0")
case f == 0:
- return 1, w.WriteByte('0')
+ return w.WriteString("0.0")
case f == -1:
- return w.WriteString("-1")
+ return w.WriteString("-1.0")
case math.IsNaN(f):
return w.WriteString("NaN")
case math.IsInf(f, +1):
@@ -450,6 +450,12 @@ func writeFloat(w enhancedWriter, f float64) (int, error) {
default:
bp := numBufPool.Get().(*[]byte)
*bp = strconv.AppendFloat((*bp)[:0], f, 'g', -1, 64)
+ // Add a .0 if used fixed point and there is no decimal
+ // point already. This is for future proofing with OpenMetrics,
+ // where floats always contain either an exponent or decimal.
+ if !bytes.ContainsAny(*bp, "e.") {
+ *bp = append(*bp, '.', '0')
+ }
written, err := w.Write(*bp)
numBufPool.Put(bp)
return written, err
diff --git a/vendor/github.com/prometheus/procfs/Makefile b/vendor/github.com/prometheus/procfs/Makefile
index 4d1098394..947d7d8fa 100644
--- a/vendor/github.com/prometheus/procfs/Makefile
+++ b/vendor/github.com/prometheus/procfs/Makefile
@@ -11,49 +11,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-# Ensure GOBIN is not set during build so that promu is installed to the correct path
-unexport GOBIN
-
-GO ?= go
-GOFMT ?= $(GO)fmt
-FIRST_GOPATH := $(firstword $(subst :, ,$(shell $(GO) env GOPATH)))
-STATICCHECK := $(FIRST_GOPATH)/bin/staticcheck
-pkgs = $(shell $(GO) list ./... | grep -v /vendor/)
-
-PREFIX ?= $(shell pwd)
-BIN_DIR ?= $(shell pwd)
-
-ifdef DEBUG
- bindata_flags = -debug
-endif
-
-STATICCHECK_IGNORE =
-
-all: format staticcheck build test
-
-style:
- @echo ">> checking code style"
- @! $(GOFMT) -d $(shell find . -path ./vendor -prune -o -name '*.go' -print) | grep '^'
-
-check_license:
- @echo ">> checking license header"
- @./scripts/check_license.sh
-
-test: fixtures/.unpacked sysfs/fixtures/.unpacked
- @echo ">> running all tests"
- @$(GO) test -race $(shell $(GO) list ./... | grep -v /vendor/ | grep -v examples)
-
-format:
- @echo ">> formatting code"
- @$(GO) fmt $(pkgs)
-
-vet:
- @echo ">> vetting code"
- @$(GO) vet $(pkgs)
-
-staticcheck: $(STATICCHECK)
- @echo ">> running staticcheck"
- @$(STATICCHECK) -ignore "$(STATICCHECK_IGNORE)" $(pkgs)
+include Makefile.common
%/.unpacked: %.ttar
./ttar -C $(dir $*) -x -f $*.ttar
@@ -65,13 +23,8 @@ update_fixtures: fixtures.ttar sysfs/fixtures.ttar
rm -v $(dir $*)fixtures/.unpacked
./ttar -C $(dir $*) -c -f $*fixtures.ttar fixtures/
-$(FIRST_GOPATH)/bin/staticcheck:
- @GOOS= GOARCH= $(GO) get -u honnef.co/go/tools/cmd/staticcheck
-
-.PHONY: all style check_license format test vet staticcheck
+.PHONY: build
+build:
-# Declaring the binaries at their default locations as PHONY targets is a hack
-# to ensure the latest version is downloaded on every make execution.
-# If this is not desired, copy/symlink these binaries to a different path and
-# set the respective environment variables.
-.PHONY: $(GOPATH)/bin/staticcheck
+.PHONY: test
+test: fixtures/.unpacked sysfs/fixtures/.unpacked common-test
diff --git a/vendor/github.com/prometheus/procfs/Makefile.common b/vendor/github.com/prometheus/procfs/Makefile.common
new file mode 100644
index 000000000..741579e60
--- /dev/null
+++ b/vendor/github.com/prometheus/procfs/Makefile.common
@@ -0,0 +1,223 @@
+# Copyright 2018 The Prometheus Authors
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+
+# A common Makefile that includes rules to be reused in different prometheus projects.
+# !!! Open PRs only against the prometheus/prometheus/Makefile.common repository!
+
+# Example usage :
+# Create the main Makefile in the root project directory.
+# include Makefile.common
+# customTarget:
+# @echo ">> Running customTarget"
+#
+
+# Ensure GOBIN is not set during build so that promu is installed to the correct path
+unexport GOBIN
+
+GO ?= go
+GOFMT ?= $(GO)fmt
+FIRST_GOPATH := $(firstword $(subst :, ,$(shell $(GO) env GOPATH)))
+GOOPTS ?=
+
+GO_VERSION ?= $(shell $(GO) version)
+GO_VERSION_NUMBER ?= $(word 3, $(GO_VERSION))
+PRE_GO_111 ?= $(shell echo $(GO_VERSION_NUMBER) | grep -E 'go1\.(10|[0-9])\.')
+
+unexport GOVENDOR
+ifeq (, $(PRE_GO_111))
+ ifneq (,$(wildcard go.mod))
+ # Enforce Go modules support just in case the directory is inside GOPATH (and for Travis CI).
+ GO111MODULE := on
+
+ ifneq (,$(wildcard vendor))
+ # Always use the local vendor/ directory to satisfy the dependencies.
+ GOOPTS := $(GOOPTS) -mod=vendor
+ endif
+ endif
+else
+ ifneq (,$(wildcard go.mod))
+ ifneq (,$(wildcard vendor))
+$(warning This repository requires Go >= 1.11 because of Go modules)
+$(warning Some recipes may not work as expected as the current Go runtime is '$(GO_VERSION_NUMBER)')
+ endif
+ else
+ # This repository isn't using Go modules (yet).
+ GOVENDOR := $(FIRST_GOPATH)/bin/govendor
+ endif
+
+ unexport GO111MODULE
+endif
+PROMU := $(FIRST_GOPATH)/bin/promu
+STATICCHECK := $(FIRST_GOPATH)/bin/staticcheck
+pkgs = ./...
+
+GO_VERSION ?= $(shell $(GO) version)
+GO_BUILD_PLATFORM ?= $(subst /,-,$(lastword $(GO_VERSION)))
+
+PROMU_VERSION ?= 0.2.0
+PROMU_URL := https://github.com/prometheus/promu/releases/download/v$(PROMU_VERSION)/promu-$(PROMU_VERSION).$(GO_BUILD_PLATFORM).tar.gz
+
+PREFIX ?= $(shell pwd)
+BIN_DIR ?= $(shell pwd)
+DOCKER_IMAGE_TAG ?= $(subst /,-,$(shell git rev-parse --abbrev-ref HEAD))
+DOCKER_REPO ?= prom
+
+.PHONY: all
+all: precheck style staticcheck unused build test
+
+# This rule is used to forward a target like "build" to "common-build". This
+# allows a new "build" target to be defined in a Makefile which includes this
+# one and override "common-build" without override warnings.
+%: common-% ;
+
+.PHONY: common-style
+common-style:
+ @echo ">> checking code style"
+ @fmtRes=$$($(GOFMT) -d $$(find . -path ./vendor -prune -o -name '*.go' -print)); \
+ if [ -n "$${fmtRes}" ]; then \
+ echo "gofmt checking failed!"; echo "$${fmtRes}"; echo; \
+ echo "Please ensure you are using $$($(GO) version) for formatting code."; \
+ exit 1; \
+ fi
+
+.PHONY: common-check_license
+common-check_license:
+ @echo ">> checking license header"
+ @licRes=$$(for file in $$(find . -type f -iname '*.go' ! -path './vendor/*') ; do \
+ awk 'NR<=3' $$file | grep -Eq "(Copyright|generated|GENERATED)" || echo $$file; \
+ done); \
+ if [ -n "$${licRes}" ]; then \
+ echo "license header checking failed:"; echo "$${licRes}"; \
+ exit 1; \
+ fi
+
+.PHONY: common-test-short
+common-test-short:
+ @echo ">> running short tests"
+ GO111MODULE=$(GO111MODULE) $(GO) test -short $(GOOPTS) $(pkgs)
+
+.PHONY: common-test
+common-test:
+ @echo ">> running all tests"
+ GO111MODULE=$(GO111MODULE) $(GO) test -race $(GOOPTS) $(pkgs)
+
+.PHONY: common-format
+common-format:
+ @echo ">> formatting code"
+ GO111MODULE=$(GO111MODULE) $(GO) fmt $(GOOPTS) $(pkgs)
+
+.PHONY: common-vet
+common-vet:
+ @echo ">> vetting code"
+ GO111MODULE=$(GO111MODULE) $(GO) vet $(GOOPTS) $(pkgs)
+
+.PHONY: common-staticcheck
+common-staticcheck: $(STATICCHECK)
+ @echo ">> running staticcheck"
+ifdef GO111MODULE
+ GO111MODULE=$(GO111MODULE) $(STATICCHECK) -ignore "$(STATICCHECK_IGNORE)" -checks "SA*" $(pkgs)
+else
+ $(STATICCHECK) -ignore "$(STATICCHECK_IGNORE)" $(pkgs)
+endif
+
+.PHONY: common-unused
+common-unused: $(GOVENDOR)
+ifdef GOVENDOR
+ @echo ">> running check for unused packages"
+ @$(GOVENDOR) list +unused | grep . && exit 1 || echo 'No unused packages'
+else
+ifdef GO111MODULE
+ @echo ">> running check for unused/missing packages in go.mod"
+ GO111MODULE=$(GO111MODULE) $(GO) mod tidy
+ @git diff --exit-code -- go.sum go.mod
+ifneq (,$(wildcard vendor))
+ @echo ">> running check for unused packages in vendor/"
+ GO111MODULE=$(GO111MODULE) $(GO) mod vendor
+ @git diff --exit-code -- go.sum go.mod vendor/
+endif
+endif
+endif
+
+.PHONY: common-build
+common-build: promu
+ @echo ">> building binaries"
+ GO111MODULE=$(GO111MODULE) $(PROMU) build --prefix $(PREFIX)
+
+.PHONY: common-tarball
+common-tarball: promu
+ @echo ">> building release tarball"
+ $(PROMU) tarball --prefix $(PREFIX) $(BIN_DIR)
+
+.PHONY: common-docker
+common-docker:
+ docker build -t "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_TAG)" .
+
+.PHONY: common-docker-publish
+common-docker-publish:
+ docker push "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME)"
+
+.PHONY: common-docker-tag-latest
+common-docker-tag-latest:
+ docker tag "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_TAG)" "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME):latest"
+
+.PHONY: promu
+promu: $(PROMU)
+
+$(PROMU):
+ curl -s -L $(PROMU_URL) | tar -xvz -C /tmp
+ mkdir -v -p $(FIRST_GOPATH)/bin
+ cp -v /tmp/promu-$(PROMU_VERSION).$(GO_BUILD_PLATFORM)/promu $(PROMU)
+
+.PHONY: proto
+proto:
+ @echo ">> generating code from proto files"
+ @./scripts/genproto.sh
+
+.PHONY: $(STATICCHECK)
+$(STATICCHECK):
+ifdef GO111MODULE
+# Get staticcheck from a temporary directory to avoid modifying the local go.{mod,sum}.
+# See https://github.com/golang/go/issues/27643.
+# For now, we are using the next branch of staticcheck because master isn't compatible yet with Go modules.
+ tmpModule=$$(mktemp -d 2>&1) && \
+ mkdir -p $${tmpModule}/staticcheck && \
+ cd "$${tmpModule}"/staticcheck && \
+ GO111MODULE=on $(GO) mod init example.com/staticcheck && \
+ GO111MODULE=on GOOS= GOARCH= $(GO) get -u honnef.co/go/tools/cmd/staticcheck@next && \
+ rm -rf $${tmpModule};
+else
+ GOOS= GOARCH= GO111MODULE=off $(GO) get -u honnef.co/go/tools/cmd/staticcheck
+endif
+
+ifdef GOVENDOR
+.PHONY: $(GOVENDOR)
+$(GOVENDOR):
+ GOOS= GOARCH= $(GO) get -u github.com/kardianos/govendor
+endif
+
+.PHONY: precheck
+precheck::
+
+define PRECHECK_COMMAND_template =
+precheck:: $(1)_precheck
+
+
+PRECHECK_COMMAND_$(1) ?= $(1) $$(strip $$(PRECHECK_OPTIONS_$(1)))
+.PHONY: $(1)_precheck
+$(1)_precheck:
+ @if ! $$(PRECHECK_COMMAND_$(1)) 1>/dev/null 2>&1; then \
+ echo "Execution of '$$(PRECHECK_COMMAND_$(1))' command failed. Is $(1) installed?"; \
+ exit 1; \
+ fi
+endef
diff --git a/vendor/github.com/prometheus/procfs/go.mod b/vendor/github.com/prometheus/procfs/go.mod
new file mode 100644
index 000000000..e89ee6c90
--- /dev/null
+++ b/vendor/github.com/prometheus/procfs/go.mod
@@ -0,0 +1 @@
+module github.com/prometheus/procfs
diff --git a/vendor/github.com/siddontang/go-mysql/server/auth.go b/vendor/github.com/siddontang/go-mysql/server/auth.go
index cb6ca160f..ac71ce723 100644
--- a/vendor/github.com/siddontang/go-mysql/server/auth.go
+++ b/vendor/github.com/siddontang/go-mysql/server/auth.go
@@ -58,7 +58,7 @@ func (c *Conn) writeInitialHandshake() error {
return c.WritePacket(data)
}
-func (c *Conn) readHandshakeResponse(password string) error {
+func (c *Conn) readHandshakeResponse() error {
data, err := c.ReadPacket()
if err != nil {
@@ -85,10 +85,14 @@ func (c *Conn) readHandshakeResponse(password string) error {
user := string(data[pos : pos+bytes.IndexByte(data[pos:], 0)])
pos += len(user) + 1
- if c.user != user {
+ var password string
+ var userExists bool
+ if password, userExists = c.users[user]; !userExists {
return NewDefaultError(ER_NO_SUCH_USER, user, c.RemoteAddr().String())
}
+ c.user = user
+
var auth []byte
if c.capability&CLIENT_PLUGIN_AUTH_LENENC_CLIENT_DATA > 0 {
diff --git a/vendor/github.com/siddontang/go-mysql/server/conn.go b/vendor/github.com/siddontang/go-mysql/server/conn.go
index d6ea846ae..ba48123fc 100644
--- a/vendor/github.com/siddontang/go-mysql/server/conn.go
+++ b/vendor/github.com/siddontang/go-mysql/server/conn.go
@@ -23,6 +23,8 @@ type Conn struct {
user string
+ users map[string]string // user to password map
+
salt []byte
h Handler
@@ -36,11 +38,24 @@ type Conn struct {
var baseConnID uint32 = 10000
func NewConn(conn net.Conn, user string, password string, h Handler) (*Conn, error) {
+ userPasswords := map[string]string{
+ user: password,
+ }
+
+ return NewConnWithUsers(conn, userPasswords, h)
+}
+
+func NewConnWithUsers(conn net.Conn, userPasswords map[string]string, h Handler) (*Conn, error) {
c := new(Conn)
c.h = h
- c.user = user
+ c.users = make(map[string]string)
+
+ for u, p := range userPasswords {
+ c.users[u] = p
+ }
+
c.Conn = packet.NewConn(conn)
c.connectionID = atomic.AddUint32(&baseConnID, 1)
@@ -51,7 +66,7 @@ func NewConn(conn net.Conn, user string, password string, h Handler) (*Conn, err
c.closed.Set(false)
- if err := c.handshake(password); err != nil {
+ if err := c.handshake(); err != nil {
c.Close()
return nil, err
}
@@ -59,12 +74,12 @@ func NewConn(conn net.Conn, user string, password string, h Handler) (*Conn, err
return c, nil
}
-func (c *Conn) handshake(password string) error {
+func (c *Conn) handshake() error {
if err := c.writeInitialHandshake(); err != nil {
return err
}
- if err := c.readHandshakeResponse(password); err != nil {
+ if err := c.readHandshakeResponse(); err != nil {
c.writeError(err)
return err
diff --git a/vendor/github.com/syndtr/goleveldb/leveldb/cache/cache.go b/vendor/github.com/syndtr/goleveldb/leveldb/cache/cache.go
index c5940b232..c36ad3235 100644
--- a/vendor/github.com/syndtr/goleveldb/leveldb/cache/cache.go
+++ b/vendor/github.com/syndtr/goleveldb/leveldb/cache/cache.go
@@ -331,7 +331,6 @@ func (r *Cache) delete(n *Node) bool {
return deleted
}
}
- return false
}
// Nodes returns number of 'cache node' in the map.
diff --git a/vendor/github.com/syndtr/goleveldb/leveldb/comparer/bytes_comparer.go b/vendor/github.com/syndtr/goleveldb/leveldb/comparer/bytes_comparer.go
index 14dddf88d..abf9fb65c 100644
--- a/vendor/github.com/syndtr/goleveldb/leveldb/comparer/bytes_comparer.go
+++ b/vendor/github.com/syndtr/goleveldb/leveldb/comparer/bytes_comparer.go
@@ -29,7 +29,7 @@ func (bytesComparer) Separator(dst, a, b []byte) []byte {
// Do not shorten if one string is a prefix of the other
} else if c := a[i]; c < 0xff && c+1 < b[i] {
dst = append(dst, a[:i+1]...)
- dst[i]++
+ dst[len(dst)-1]++
return dst
}
return nil
@@ -39,7 +39,7 @@ func (bytesComparer) Successor(dst, b []byte) []byte {
for i, c := range b {
if c != 0xff {
dst = append(dst, b[:i+1]...)
- dst[i]++
+ dst[len(dst)-1]++
return dst
}
}
diff --git a/vendor/github.com/syndtr/goleveldb/leveldb/comparer/comparer.go b/vendor/github.com/syndtr/goleveldb/leveldb/comparer/comparer.go
index 14a28f16f..2c522db23 100644
--- a/vendor/github.com/syndtr/goleveldb/leveldb/comparer/comparer.go
+++ b/vendor/github.com/syndtr/goleveldb/leveldb/comparer/comparer.go
@@ -36,7 +36,7 @@ type Comparer interface {
// by any users of this package.
Name() string
- // Bellow are advanced functions used used to reduce the space requirements
+ // Bellow are advanced functions used to reduce the space requirements
// for internal data structures such as index blocks.
// Separator appends a sequence of bytes x to dst such that a <= x && x < b,
diff --git a/vendor/github.com/syndtr/goleveldb/leveldb/db.go b/vendor/github.com/syndtr/goleveldb/leveldb/db.go
index e7ac06541..b27c38d37 100644
--- a/vendor/github.com/syndtr/goleveldb/leveldb/db.go
+++ b/vendor/github.com/syndtr/goleveldb/leveldb/db.go
@@ -182,7 +182,7 @@ func Open(stor storage.Storage, o *opt.Options) (db *DB, err error) {
err = s.recover()
if err != nil {
- if !os.IsNotExist(err) || s.o.GetErrorIfMissing() {
+ if !os.IsNotExist(err) || s.o.GetErrorIfMissing() || s.o.GetReadOnly() {
return
}
err = s.create()
diff --git a/vendor/github.com/syndtr/goleveldb/leveldb/db_compaction.go b/vendor/github.com/syndtr/goleveldb/leveldb/db_compaction.go
index 28e50906a..0c1b9a53b 100644
--- a/vendor/github.com/syndtr/goleveldb/leveldb/db_compaction.go
+++ b/vendor/github.com/syndtr/goleveldb/leveldb/db_compaction.go
@@ -663,7 +663,7 @@ type cCmd interface {
}
type cAuto struct {
- // Note for table compaction, an empty ackC represents it's a compaction waiting command.
+ // Note for table compaction, an non-empty ackC represents it's a compaction waiting command.
ackC chan<- error
}
@@ -777,8 +777,8 @@ func (db *DB) mCompaction() {
func (db *DB) tCompaction() {
var (
- x cCmd
- ackQ, waitQ []cCmd
+ x cCmd
+ waitQ []cCmd
)
defer func() {
@@ -787,10 +787,6 @@ func (db *DB) tCompaction() {
panic(x)
}
}
- for i := range ackQ {
- ackQ[i].ack(ErrClosed)
- ackQ[i] = nil
- }
for i := range waitQ {
waitQ[i].ack(ErrClosed)
waitQ[i] = nil
@@ -821,11 +817,6 @@ func (db *DB) tCompaction() {
waitQ = waitQ[:0]
}
} else {
- for i := range ackQ {
- ackQ[i].ack(nil)
- ackQ[i] = nil
- }
- ackQ = ackQ[:0]
for i := range waitQ {
waitQ[i].ack(nil)
waitQ[i] = nil
@@ -844,9 +835,12 @@ func (db *DB) tCompaction() {
switch cmd := x.(type) {
case cAuto:
if cmd.ackC != nil {
- waitQ = append(waitQ, x)
- } else {
- ackQ = append(ackQ, x)
+ // Check the write pause state before caching it.
+ if db.resumeWrite() {
+ x.ack(nil)
+ } else {
+ waitQ = append(waitQ, x)
+ }
}
case cRange:
x.ack(db.tableRangeCompaction(cmd.level, cmd.min, cmd.max))
diff --git a/vendor/github.com/syndtr/goleveldb/leveldb/db_util.go b/vendor/github.com/syndtr/goleveldb/leveldb/db_util.go
index 7ecd960d2..3f0654894 100644
--- a/vendor/github.com/syndtr/goleveldb/leveldb/db_util.go
+++ b/vendor/github.com/syndtr/goleveldb/leveldb/db_util.go
@@ -84,7 +84,7 @@ func (db *DB) checkAndCleanFiles() error {
var mfds []storage.FileDesc
for num, present := range tmap {
if !present {
- mfds = append(mfds, storage.FileDesc{storage.TypeTable, num})
+ mfds = append(mfds, storage.FileDesc{Type: storage.TypeTable, Num: num})
db.logf("db@janitor table missing @%d", num)
}
}
diff --git a/vendor/github.com/syndtr/goleveldb/leveldb/opt/options.go b/vendor/github.com/syndtr/goleveldb/leveldb/opt/options.go
index 44e7d9adc..528b16423 100644
--- a/vendor/github.com/syndtr/goleveldb/leveldb/opt/options.go
+++ b/vendor/github.com/syndtr/goleveldb/leveldb/opt/options.go
@@ -158,6 +158,12 @@ type Options struct {
// The default value is 8MiB.
BlockCacheCapacity int
+ // BlockCacheEvictRemoved allows enable forced-eviction on cached block belonging
+ // to removed 'sorted table'.
+ //
+ // The default if false.
+ BlockCacheEvictRemoved bool
+
// BlockRestartInterval is the number of keys between restart points for
// delta encoding of keys.
//
@@ -384,6 +390,13 @@ func (o *Options) GetBlockCacheCapacity() int {
return o.BlockCacheCapacity
}
+func (o *Options) GetBlockCacheEvictRemoved() bool {
+ if o == nil {
+ return false
+ }
+ return o.BlockCacheEvictRemoved
+}
+
func (o *Options) GetBlockRestartInterval() int {
if o == nil || o.BlockRestartInterval <= 0 {
return DefaultBlockRestartInterval
diff --git a/vendor/github.com/syndtr/goleveldb/leveldb/session_util.go b/vendor/github.com/syndtr/goleveldb/leveldb/session_util.go
index 92328933c..40cb2cf95 100644
--- a/vendor/github.com/syndtr/goleveldb/leveldb/session_util.go
+++ b/vendor/github.com/syndtr/goleveldb/leveldb/session_util.go
@@ -36,7 +36,7 @@ func (s *session) logf(format string, v ...interface{}) { s.stor.Log(fmt.Sprintf
func (s *session) newTemp() storage.FileDesc {
num := atomic.AddInt64(&s.stTempFileNum, 1) - 1
- return storage.FileDesc{storage.TypeTemp, num}
+ return storage.FileDesc{Type: storage.TypeTemp, Num: num}
}
func (s *session) addFileRef(fd storage.FileDesc, ref int) int {
@@ -190,7 +190,7 @@ func (s *session) recordCommited(rec *sessionRecord) {
// Create a new manifest file; need external synchronization.
func (s *session) newManifest(rec *sessionRecord, v *version) (err error) {
- fd := storage.FileDesc{storage.TypeManifest, s.allocFileNum()}
+ fd := storage.FileDesc{Type: storage.TypeManifest, Num: s.allocFileNum()}
writer, err := s.stor.Create(fd)
if err != nil {
return
diff --git a/vendor/github.com/syndtr/goleveldb/leveldb/table.go b/vendor/github.com/syndtr/goleveldb/leveldb/table.go
index adf773f13..1fac60d05 100644
--- a/vendor/github.com/syndtr/goleveldb/leveldb/table.go
+++ b/vendor/github.com/syndtr/goleveldb/leveldb/table.go
@@ -78,7 +78,7 @@ func newTableFile(fd storage.FileDesc, size int64, imin, imax internalKey) *tFil
}
func tableFileFromRecord(r atRecord) *tFile {
- return newTableFile(storage.FileDesc{storage.TypeTable, r.num}, r.size, r.imin, r.imax)
+ return newTableFile(storage.FileDesc{Type: storage.TypeTable, Num: r.num}, r.size, r.imin, r.imax)
}
// tFiles hold multiple tFile.
@@ -290,16 +290,17 @@ func (x *tFilesSortByNum) Less(i, j int) bool {
// Table operations.
type tOps struct {
- s *session
- noSync bool
- cache *cache.Cache
- bcache *cache.Cache
- bpool *util.BufferPool
+ s *session
+ noSync bool
+ evictRemoved bool
+ cache *cache.Cache
+ bcache *cache.Cache
+ bpool *util.BufferPool
}
// Creates an empty table and returns table writer.
func (t *tOps) create() (*tWriter, error) {
- fd := storage.FileDesc{storage.TypeTable, t.s.allocFileNum()}
+ fd := storage.FileDesc{Type: storage.TypeTable, Num: t.s.allocFileNum()}
fw, err := t.s.stor.Create(fd)
if err != nil {
return nil, err
@@ -422,7 +423,7 @@ func (t *tOps) remove(f *tFile) {
} else {
t.s.logf("table@remove removed @%d", f.fd.Num)
}
- if t.bcache != nil {
+ if t.evictRemoved && t.bcache != nil {
t.bcache.EvictNS(uint64(f.fd.Num))
}
})
@@ -459,11 +460,12 @@ func newTableOps(s *session) *tOps {
bpool = util.NewBufferPool(s.o.GetBlockSize() + 5)
}
return &tOps{
- s: s,
- noSync: s.o.GetNoSync(),
- cache: cache.NewCache(cacher),
- bcache: bcache,
- bpool: bpool,
+ s: s,
+ noSync: s.o.GetNoSync(),
+ evictRemoved: s.o.GetBlockCacheEvictRemoved(),
+ cache: cache.NewCache(cacher),
+ bcache: bcache,
+ bpool: bpool,
}
}
diff --git a/vendor/github.com/ulule/deepcopier/Makefile b/vendor/github.com/ulule/deepcopier/Makefile
deleted file mode 100644
index af890e901..000000000
--- a/vendor/github.com/ulule/deepcopier/Makefile
+++ /dev/null
@@ -1,5 +0,0 @@
-.PHONY: test
-test:
- go test -race
- go test -cover
- go test -v
diff --git a/vendor/github.com/ulule/deepcopier/README.md b/vendor/github.com/ulule/deepcopier/README.md
deleted file mode 100644
index 25aafae8a..000000000
--- a/vendor/github.com/ulule/deepcopier/README.md
+++ /dev/null
@@ -1,129 +0,0 @@
-# Deepcopier
-
-[](http://travis-ci.org/ulule/deepcopier)
-
-This package is meant to make copying of structs to/from others structs a bit easier.
-
-## Installation
-
-```bash
-go get -u github.com/ulule/deepcopier
-```
-
-## Usage
-
-```golang
-// Deep copy instance1 into instance2
-Copy(instance1).To(instance2)
-
-// Deep copy instance1 into instance2 and passes the following context (which
-// is basically a map[string]interface{}) as first argument
-// to methods of instance2 that defined the struct tag "context".
-Copy(instance1).WithContext(map[string]interface{}{"foo": "bar"}).To(instance2)
-
-// Deep copy instance2 into instance1
-Copy(instance1).From(instance2)
-
-// Deep copy instance2 into instance1 and passes the following context (which
-// is basically a map[string]interface{}) as first argument
-// to methods of instance1 that defined the struct tag "context".
-Copy(instance1).WithContext(map[string]interface{}{"foo": "bar"}).From(instance2)
-```
-
-Available options for `deepcopier` struct tag:
-
-| Option | Description |
-| --------- | -------------------------------------------------------------------- |
-| `field` | Field or method name in source instance |
-| `skip` | Ignores the field |
-| `context` | Takes a `map[string]interface{}` as first argument (for methods) |
-| `force` | Set the value of a `sql.Null*` field (instead of copying the struct) |
-
-**Options example:**
-
-```golang
-type Source struct {
- Name string
- SkipMe string
- SQLNullStringToSQLNullString sql.NullString
- SQLNullStringToString sql.NullString
-
-}
-
-func (Source) MethodThatTakesContext(c map[string]interface{}) string {
- return "whatever"
-}
-
-type Destination struct {
- FieldWithAnotherNameInSource string `deepcopier:"field:Name"`
- SkipMe string `deepcopier:"skip"`
- MethodThatTakesContext string `deepcopier:"context"`
- SQLNullStringToSQLNullString sql.NullString
- SQLNullStringToString string `deepcopier:"force"`
-}
-
-```
-
-Example:
-
-```golang
-package main
-
-import (
- "fmt"
-
- "github.com/ulule/deepcopier"
-)
-
-// Model
-type User struct {
- // Basic string field
- Name string
- // Deepcopier supports https://golang.org/pkg/database/sql/driver/#Valuer
- Email sql.NullString
-}
-
-func (u *User) MethodThatTakesContext(ctx map[string]interface{}) string {
- // do whatever you want
- return "hello from this method"
-}
-
-// Resource
-type UserResource struct {
- DisplayName string `deepcopier:"field:Name"`
- SkipMe string `deepcopier:"skip"`
- MethodThatTakesContext string `deepcopier:"context"`
- Email string `deepcopier:"force"`
-
-}
-
-func main() {
- user := &User{
- Name: "gilles",
- Email: sql.NullString{
- Valid: true,
- String: "gilles@example.com",
- },
- }
-
- resource := &UserResource{}
-
- deepcopier.Copy(user).To(resource)
-
- fmt.Println(resource.DisplayName)
- fmt.Println(resource.Email)
-}
-```
-
-Looking for more information about the usage?
-
-We wrote [an introduction article](https://github.com/ulule/deepcopier/blob/master/examples/rest-usage/README.rst).
-Have a look and feel free to give us your feedback.
-
-## Contributing
-
-* Ping us on twitter [@oibafsellig](https://twitter.com/oibafsellig), [@thoas](https://twitter.com/thoas)
-* Fork the [project](https://github.com/ulule/deepcopier)
-* Help us improving and fixing [issues](https://github.com/ulule/deepcopier/issues)
-
-Don't hesitate ;)
diff --git a/vendor/github.com/ulule/deepcopier/deepcopier.go b/vendor/github.com/ulule/deepcopier/deepcopier.go
deleted file mode 100644
index 8a6c70b55..000000000
--- a/vendor/github.com/ulule/deepcopier/deepcopier.go
+++ /dev/null
@@ -1,362 +0,0 @@
-package deepcopier
-
-import (
- "database/sql/driver"
- "fmt"
- "reflect"
- "strings"
-)
-
-const (
- // TagName is the deepcopier struct tag name.
- TagName = "deepcopier"
- // FieldOptionName is the from field option name for struct tag.
- FieldOptionName = "field"
- // ContextOptionName is the context option name for struct tag.
- ContextOptionName = "context"
- // SkipOptionName is the skip option name for struct tag.
- SkipOptionName = "skip"
- // ForceOptionName is the skip option name for struct tag.
- ForceOptionName = "force"
-)
-
-type (
- // TagOptions is a map that contains extracted struct tag options.
- TagOptions map[string]string
-
- // Options are copier options.
- Options struct {
- // Context given to WithContext() method.
- Context map[string]interface{}
- // Reversed reverses struct tag checkings.
- Reversed bool
- }
-)
-
-// DeepCopier deep copies a struct to/from a struct.
-type DeepCopier struct {
- dst interface{}
- src interface{}
- ctx map[string]interface{}
-}
-
-// Copy sets source or destination.
-func Copy(src interface{}) *DeepCopier {
- return &DeepCopier{src: src}
-}
-
-// WithContext injects the given context into the builder instance.
-func (dc *DeepCopier) WithContext(ctx map[string]interface{}) *DeepCopier {
- dc.ctx = ctx
- return dc
-}
-
-// To sets the destination.
-func (dc *DeepCopier) To(dst interface{}) error {
- dc.dst = dst
- return process(dc.dst, dc.src, Options{Context: dc.ctx})
-}
-
-// From sets the given the source as destination and destination as source.
-func (dc *DeepCopier) From(src interface{}) error {
- dc.dst = dc.src
- dc.src = src
- return process(dc.dst, dc.src, Options{Context: dc.ctx, Reversed: true})
-}
-
-// process handles copy.
-func process(dst interface{}, src interface{}, args ...Options) error {
- var (
- options = Options{}
- srcValue = reflect.Indirect(reflect.ValueOf(src))
- dstValue = reflect.Indirect(reflect.ValueOf(dst))
- srcFieldNames = getFieldNames(src)
- srcMethodNames = getMethodNames(src)
- )
-
- if len(args) > 0 {
- options = args[0]
- }
-
- if !dstValue.CanAddr() {
- return fmt.Errorf("destination %+v is unaddressable", dstValue.Interface())
- }
-
- for _, f := range srcFieldNames {
- var (
- srcFieldValue = srcValue.FieldByName(f)
- srcFieldType, srcFieldFound = srcValue.Type().FieldByName(f)
- srcFieldName = srcFieldType.Name
- dstFieldName = srcFieldName
- tagOptions TagOptions
- )
-
- if !srcFieldFound {
- continue
- }
-
- if options.Reversed {
- tagOptions = getTagOptions(srcFieldType.Tag.Get(TagName))
- if v, ok := tagOptions[FieldOptionName]; ok && v != "" {
- dstFieldName = v
- }
- } else {
- if name, opts := getRelatedField(dst, srcFieldName); name != "" {
- dstFieldName, tagOptions = name, opts
- }
- }
-
- if _, ok := tagOptions[SkipOptionName]; ok {
- continue
- }
-
- var (
- dstFieldType, dstFieldFound = dstValue.Type().FieldByName(dstFieldName)
- dstFieldValue = dstValue.FieldByName(dstFieldName)
- )
-
- if !dstFieldFound {
- continue
- }
-
- // Force option for empty interfaces and nullable types
- _, force := tagOptions[ForceOptionName]
-
- // Valuer -> ptr
- if isNullableType(srcFieldType.Type) && dstFieldValue.Kind() == reflect.Ptr && force {
- // We have same nullable type on both sides
- if srcFieldValue.Type().AssignableTo(dstFieldType.Type) {
- dstFieldValue.Set(srcFieldValue)
- continue
- }
-
- v, _ := srcFieldValue.Interface().(driver.Valuer).Value()
- if v == nil {
- continue
- }
-
- valueType := reflect.TypeOf(v)
-
- ptr := reflect.New(valueType)
- ptr.Elem().Set(reflect.ValueOf(v))
-
- if valueType.AssignableTo(dstFieldType.Type.Elem()) {
- dstFieldValue.Set(ptr)
- }
-
- continue
- }
-
- // Valuer -> value
- if isNullableType(srcFieldType.Type) {
- // We have same nullable type on both sides
- if srcFieldValue.Type().AssignableTo(dstFieldType.Type) {
- dstFieldValue.Set(srcFieldValue)
- continue
- }
-
- if force {
- v, _ := srcFieldValue.Interface().(driver.Valuer).Value()
- if v == nil {
- continue
- }
-
- rv := reflect.ValueOf(v)
- if rv.Type().AssignableTo(dstFieldType.Type) {
- dstFieldValue.Set(rv)
- }
- }
-
- continue
- }
-
- if dstFieldValue.Kind() == reflect.Interface {
- if force {
- dstFieldValue.Set(srcFieldValue)
- }
- continue
- }
-
- // Ptr -> Value
- if srcFieldType.Type.Kind() == reflect.Ptr && !srcFieldValue.IsNil() && dstFieldType.Type.Kind() != reflect.Ptr {
- indirect := reflect.Indirect(srcFieldValue)
-
- if indirect.Type().AssignableTo(dstFieldType.Type) {
- dstFieldValue.Set(indirect)
- continue
- }
- }
-
- // Other types
- if srcFieldType.Type.AssignableTo(dstFieldType.Type) {
- dstFieldValue.Set(srcFieldValue)
- }
- }
-
- for _, m := range srcMethodNames {
- name, opts := getRelatedField(dst, m)
- if name == "" {
- continue
- }
-
- if _, ok := opts[SkipOptionName]; ok {
- continue
- }
-
- method := reflect.ValueOf(src).MethodByName(m)
- if !method.IsValid() {
- return fmt.Errorf("method %s is invalid", m)
- }
-
- var (
- dstFieldType, _ = dstValue.Type().FieldByName(name)
- dstFieldValue = dstValue.FieldByName(name)
- _, withContext = opts[ContextOptionName]
- _, force = opts[ForceOptionName]
- )
-
- args := []reflect.Value{}
- if withContext {
- args = []reflect.Value{reflect.ValueOf(options.Context)}
- }
-
- var (
- result = method.Call(args)[0]
- resultInterface = result.Interface()
- resultValue = reflect.ValueOf(resultInterface)
- resultType = resultValue.Type()
- )
-
- // Value -> Ptr
- if dstFieldValue.Kind() == reflect.Ptr && force {
- ptr := reflect.New(resultType)
- ptr.Elem().Set(resultValue)
-
- if ptr.Type().AssignableTo(dstFieldType.Type) {
- dstFieldValue.Set(ptr)
- }
-
- continue
- }
-
- // Ptr -> value
- if resultValue.Kind() == reflect.Ptr && force {
- if resultValue.Elem().Type().AssignableTo(dstFieldType.Type) {
- dstFieldValue.Set(resultValue.Elem())
- }
-
- continue
- }
-
- if resultType.AssignableTo(dstFieldType.Type) && result.IsValid() {
- dstFieldValue.Set(result)
- }
- }
-
- return nil
-}
-
-// getTagOptions parses deepcopier tag field and returns options.
-func getTagOptions(value string) TagOptions {
- options := TagOptions{}
-
- for _, opt := range strings.Split(value, ";") {
- o := strings.Split(opt, ":")
-
- // deepcopier:"keyword; without; value;"
- if len(o) == 1 {
- options[o[0]] = ""
- }
-
- // deepcopier:"key:value; anotherkey:anothervalue"
- if len(o) == 2 {
- options[strings.TrimSpace(o[0])] = strings.TrimSpace(o[1])
- }
- }
-
- return options
-}
-
-// getRelatedField returns first matching field.
-func getRelatedField(instance interface{}, name string) (string, TagOptions) {
- var (
- value = reflect.Indirect(reflect.ValueOf(instance))
- fieldName string
- tagOptions TagOptions
- )
-
- for i := 0; i < value.NumField(); i++ {
- var (
- vField = value.Field(i)
- tField = value.Type().Field(i)
- tagOptions = getTagOptions(tField.Tag.Get(TagName))
- )
-
- if tField.Type.Kind() == reflect.Struct && tField.Anonymous {
- if n, o := getRelatedField(vField.Interface(), name); n != "" {
- return n, o
- }
- }
-
- if v, ok := tagOptions[FieldOptionName]; ok && v == name {
- return tField.Name, tagOptions
- }
-
- if tField.Name == name {
- return tField.Name, tagOptions
- }
- }
-
- return fieldName, tagOptions
-}
-
-// getMethodNames returns instance's method names.
-func getMethodNames(instance interface{}) []string {
- var methods []string
-
- t := reflect.TypeOf(instance)
- for i := 0; i < t.NumMethod(); i++ {
- methods = append(methods, t.Method(i).Name)
- }
-
- return methods
-}
-
-// getFieldNames returns instance's field names.
-func getFieldNames(instance interface{}) []string {
- var (
- fields []string
- v = reflect.Indirect(reflect.ValueOf(instance))
- t = v.Type()
- )
-
- if t.Kind() != reflect.Struct {
- return nil
- }
-
- for i := 0; i < v.NumField(); i++ {
- var (
- vField = v.Field(i)
- tField = v.Type().Field(i)
- )
-
- // Is exportable?
- if tField.PkgPath != "" {
- continue
- }
-
- if tField.Type.Kind() == reflect.Struct && tField.Anonymous {
- fields = append(fields, getFieldNames(vField.Interface())...)
- continue
- }
-
- fields = append(fields, tField.Name)
- }
-
- return fields
-}
-
-// isNullableType returns true if the given type is a nullable one.
-func isNullableType(t reflect.Type) bool {
- return t.ConvertibleTo(reflect.TypeOf((*driver.Valuer)(nil)).Elem())
-}
diff --git a/vendor/github.com/xo/dburl/README.md b/vendor/github.com/xo/dburl/README.md
index 9d30c5436..cb156c1d4 100644
--- a/vendor/github.com/xo/dburl/README.md
+++ b/vendor/github.com/xo/dburl/README.md
@@ -174,7 +174,7 @@ standard library's `net/url.Parse`.
A full example for reference:
```go
-// example/example.go
+// _example/example.go
package main
import (
diff --git a/vendor/github.com/xo/dburl/dsn.go b/vendor/github.com/xo/dburl/dsn.go
index e386f4bc3..6d462c64f 100644
--- a/vendor/github.com/xo/dburl/dsn.go
+++ b/vendor/github.com/xo/dburl/dsn.go
@@ -330,8 +330,7 @@ func GenFirebird(u *URL) (string, error) {
RawQuery: u.RawQuery,
Fragment: u.Fragment,
}
-
- return z.String(), nil
+ return strings.TrimPrefix(z.String(), "//"), nil
}
// GenADODB generates a adodb DSN from the passed URL.
diff --git a/vendor/github.com/xo/dburl/go.sum b/vendor/github.com/xo/dburl/go.sum
new file mode 100644
index 000000000..e69de29bb
diff --git a/vendor/github.com/xo/tblfmt/go.mod b/vendor/github.com/xo/tblfmt/go.mod
index f66af95c8..b8dc613f2 100644
--- a/vendor/github.com/xo/tblfmt/go.mod
+++ b/vendor/github.com/xo/tblfmt/go.mod
@@ -1,6 +1,3 @@
module github.com/xo/tblfmt
-require (
- github.com/mattn/go-runewidth v0.0.3
- github.com/xo/dburl v0.0.0-20180921222126-e33971d4c132
-)
+require github.com/mattn/go-runewidth v0.0.3
diff --git a/vendor/github.com/xo/tblfmt/go.sum b/vendor/github.com/xo/tblfmt/go.sum
index 977b1d669..1c1891604 100644
--- a/vendor/github.com/xo/tblfmt/go.sum
+++ b/vendor/github.com/xo/tblfmt/go.sum
@@ -1,4 +1,2 @@
github.com/mattn/go-runewidth v0.0.3 h1:a+kO+98RDGEfo6asOGMmpodZq4FNtnGP54yps8BzLR4=
github.com/mattn/go-runewidth v0.0.3/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
-github.com/xo/dburl v0.0.0-20180921222126-e33971d4c132 h1:cRKJ4yZeCZbCEXJmjZMa9s2z+3eavo2a4qu/usvVopI=
-github.com/xo/dburl v0.0.0-20180921222126-e33971d4c132/go.mod h1:g6rdekR8vgfVZrkLWfobLTm0kVez7GAN23mWtkGCJ14=
diff --git a/vendor/github.com/xo/terminfo/go.mod b/vendor/github.com/xo/terminfo/go.mod
new file mode 100644
index 000000000..331ee37d1
--- /dev/null
+++ b/vendor/github.com/xo/terminfo/go.mod
@@ -0,0 +1 @@
+module github.com/xo/terminfo
diff --git a/vendor/golang.org/x/crypto/ssh/terminal/util.go b/vendor/golang.org/x/crypto/ssh/terminal/util.go
index 731c89a28..391104084 100644
--- a/vendor/golang.org/x/crypto/ssh/terminal/util.go
+++ b/vendor/golang.org/x/crypto/ssh/terminal/util.go
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// +build darwin dragonfly freebsd linux,!appengine netbsd openbsd
+// +build aix darwin dragonfly freebsd linux,!appengine netbsd openbsd
// Package terminal provides support functions for dealing with terminals, as
// commonly found on UNIX systems.
@@ -25,7 +25,7 @@ type State struct {
termios unix.Termios
}
-// IsTerminal returns true if the given file descriptor is a terminal.
+// IsTerminal returns whether the given file descriptor is a terminal.
func IsTerminal(fd int) bool {
_, err := unix.IoctlGetTermios(fd, ioctlReadTermios)
return err == nil
diff --git a/vendor/golang.org/x/crypto/ssh/terminal/util_aix.go b/vendor/golang.org/x/crypto/ssh/terminal/util_aix.go
new file mode 100644
index 000000000..dfcd62785
--- /dev/null
+++ b/vendor/golang.org/x/crypto/ssh/terminal/util_aix.go
@@ -0,0 +1,12 @@
+// Copyright 2018 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build aix
+
+package terminal
+
+import "golang.org/x/sys/unix"
+
+const ioctlReadTermios = unix.TCGETS
+const ioctlWriteTermios = unix.TCSETS
diff --git a/vendor/golang.org/x/crypto/ssh/terminal/util_plan9.go b/vendor/golang.org/x/crypto/ssh/terminal/util_plan9.go
index 799f049f0..9317ac7ed 100644
--- a/vendor/golang.org/x/crypto/ssh/terminal/util_plan9.go
+++ b/vendor/golang.org/x/crypto/ssh/terminal/util_plan9.go
@@ -21,7 +21,7 @@ import (
type State struct{}
-// IsTerminal returns true if the given file descriptor is a terminal.
+// IsTerminal returns whether the given file descriptor is a terminal.
func IsTerminal(fd int) bool {
return false
}
diff --git a/vendor/golang.org/x/crypto/ssh/terminal/util_solaris.go b/vendor/golang.org/x/crypto/ssh/terminal/util_solaris.go
index 9e41b9f43..3d5f06a9f 100644
--- a/vendor/golang.org/x/crypto/ssh/terminal/util_solaris.go
+++ b/vendor/golang.org/x/crypto/ssh/terminal/util_solaris.go
@@ -17,7 +17,7 @@ type State struct {
termios unix.Termios
}
-// IsTerminal returns true if the given file descriptor is a terminal.
+// IsTerminal returns whether the given file descriptor is a terminal.
func IsTerminal(fd int) bool {
_, err := unix.IoctlGetTermio(fd, unix.TCGETA)
return err == nil
diff --git a/vendor/golang.org/x/crypto/ssh/terminal/util_windows.go b/vendor/golang.org/x/crypto/ssh/terminal/util_windows.go
index 8618955df..6cb8a9503 100644
--- a/vendor/golang.org/x/crypto/ssh/terminal/util_windows.go
+++ b/vendor/golang.org/x/crypto/ssh/terminal/util_windows.go
@@ -26,7 +26,7 @@ type State struct {
mode uint32
}
-// IsTerminal returns true if the given file descriptor is a terminal.
+// IsTerminal returns whether the given file descriptor is a terminal.
func IsTerminal(fd int) bool {
var st uint32
err := windows.GetConsoleMode(windows.Handle(fd), &st)
diff --git a/vendor/golang.org/x/net/internal/socket/empty.s b/vendor/golang.org/x/net/internal/socket/empty.s
new file mode 100644
index 000000000..bff0231c7
--- /dev/null
+++ b/vendor/golang.org/x/net/internal/socket/empty.s
@@ -0,0 +1,7 @@
+// Copyright 2018 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build darwin,go1.12
+
+// This exists solely so we can linkname in symbols from syscall.
diff --git a/vendor/golang.org/x/net/internal/socket/sys_bsdvar.go b/vendor/golang.org/x/net/internal/socket/sys_bsdvar.go
index f723fa36a..164ddfce8 100644
--- a/vendor/golang.org/x/net/internal/socket/sys_bsdvar.go
+++ b/vendor/golang.org/x/net/internal/socket/sys_bsdvar.go
@@ -6,9 +6,15 @@
package socket
-import "unsafe"
+import (
+ "runtime"
+ "unsafe"
+)
func probeProtocolStack() int {
+ if runtime.GOOS == "openbsd" && runtime.GOARCH == "arm" {
+ return 8
+ }
var p uintptr
return int(unsafe.Sizeof(p))
}
diff --git a/vendor/golang.org/x/net/internal/socket/sys_go1_11_darwin.go b/vendor/golang.org/x/net/internal/socket/sys_go1_11_darwin.go
new file mode 100644
index 000000000..02d2b3cc8
--- /dev/null
+++ b/vendor/golang.org/x/net/internal/socket/sys_go1_11_darwin.go
@@ -0,0 +1,33 @@
+// Copyright 2018 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build !go1.12
+
+package socket
+
+import (
+ "syscall"
+ "unsafe"
+)
+
+func getsockopt(s uintptr, level, name int, b []byte) (int, error) {
+ l := uint32(len(b))
+ _, _, errno := syscall.Syscall6(syscall.SYS_GETSOCKOPT, s, uintptr(level), uintptr(name), uintptr(unsafe.Pointer(&b[0])), uintptr(unsafe.Pointer(&l)), 0)
+ return int(l), errnoErr(errno)
+}
+
+func setsockopt(s uintptr, level, name int, b []byte) error {
+ _, _, errno := syscall.Syscall6(syscall.SYS_SETSOCKOPT, s, uintptr(level), uintptr(name), uintptr(unsafe.Pointer(&b[0])), uintptr(len(b)), 0)
+ return errnoErr(errno)
+}
+
+func recvmsg(s uintptr, h *msghdr, flags int) (int, error) {
+ n, _, errno := syscall.Syscall(syscall.SYS_RECVMSG, s, uintptr(unsafe.Pointer(h)), uintptr(flags))
+ return int(n), errnoErr(errno)
+}
+
+func sendmsg(s uintptr, h *msghdr, flags int) (int, error) {
+ n, _, errno := syscall.Syscall(syscall.SYS_SENDMSG, s, uintptr(unsafe.Pointer(h)), uintptr(flags))
+ return int(n), errnoErr(errno)
+}
diff --git a/vendor/golang.org/x/net/internal/socket/sys_go1_12_darwin.go b/vendor/golang.org/x/net/internal/socket/sys_go1_12_darwin.go
new file mode 100644
index 000000000..0999a19fb
--- /dev/null
+++ b/vendor/golang.org/x/net/internal/socket/sys_go1_12_darwin.go
@@ -0,0 +1,42 @@
+// Copyright 2018 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build go1.12
+
+package socket
+
+import (
+ "syscall"
+ "unsafe"
+)
+
+//go:linkname syscall_getsockopt syscall.getsockopt
+func syscall_getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *uint32) error
+
+func getsockopt(s uintptr, level, name int, b []byte) (int, error) {
+ l := uint32(len(b))
+ err := syscall_getsockopt(int(s), level, name, unsafe.Pointer(&b[0]), &l)
+ return int(l), err
+}
+
+//go:linkname syscall_setsockopt syscall.setsockopt
+func syscall_setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) error
+
+func setsockopt(s uintptr, level, name int, b []byte) error {
+ return syscall_setsockopt(int(s), level, name, unsafe.Pointer(&b[0]), uintptr(len(b)))
+}
+
+//go:linkname syscall_recvmsg syscall.recvmsg
+func syscall_recvmsg(s int, msg *syscall.Msghdr, flags int) (n int, err error)
+
+func recvmsg(s uintptr, h *msghdr, flags int) (int, error) {
+ return syscall_recvmsg(int(s), (*syscall.Msghdr)(unsafe.Pointer(h)), flags)
+}
+
+//go:linkname syscall_sendmsg syscall.sendmsg
+func syscall_sendmsg(s int, msg *syscall.Msghdr, flags int) (n int, err error)
+
+func sendmsg(s uintptr, h *msghdr, flags int) (int, error) {
+ return syscall_sendmsg(int(s), (*syscall.Msghdr)(unsafe.Pointer(h)), flags)
+}
diff --git a/vendor/golang.org/x/net/internal/socket/sys_posix.go b/vendor/golang.org/x/net/internal/socket/sys_posix.go
index dc130c27e..9a9bc4762 100644
--- a/vendor/golang.org/x/net/internal/socket/sys_posix.go
+++ b/vendor/golang.org/x/net/internal/socket/sys_posix.go
@@ -121,18 +121,21 @@ var zoneCache = ipv6ZoneCache{
toName: make(map[int]string),
}
-func (zc *ipv6ZoneCache) update(ift []net.Interface) {
+// update refreshes the network interface information if the cache was last
+// updated more than 1 minute ago, or if force is set. It returns whether the
+// cache was updated.
+func (zc *ipv6ZoneCache) update(ift []net.Interface, force bool) (updated bool) {
zc.Lock()
defer zc.Unlock()
now := time.Now()
- if zc.lastFetched.After(now.Add(-60 * time.Second)) {
- return
+ if !force && zc.lastFetched.After(now.Add(-60*time.Second)) {
+ return false
}
zc.lastFetched = now
if len(ift) == 0 {
var err error
if ift, err = net.Interfaces(); err != nil {
- return
+ return false
}
}
zc.toIndex = make(map[string]int, len(ift))
@@ -143,25 +146,38 @@ func (zc *ipv6ZoneCache) update(ift []net.Interface) {
zc.toName[ifi.Index] = ifi.Name
}
}
+ return true
}
func (zc *ipv6ZoneCache) name(zone int) string {
- zoneCache.update(nil)
+ updated := zoneCache.update(nil, false)
zoneCache.RLock()
- defer zoneCache.RUnlock()
name, ok := zoneCache.toName[zone]
- if !ok {
+ zoneCache.RUnlock()
+ if !ok && !updated {
+ zoneCache.update(nil, true)
+ zoneCache.RLock()
+ name, ok = zoneCache.toName[zone]
+ zoneCache.RUnlock()
+ }
+ if !ok { // last resort
name = strconv.Itoa(zone)
}
return name
}
func (zc *ipv6ZoneCache) index(zone string) int {
- zoneCache.update(nil)
+ updated := zoneCache.update(nil, false)
zoneCache.RLock()
- defer zoneCache.RUnlock()
index, ok := zoneCache.toIndex[zone]
- if !ok {
+ zoneCache.RUnlock()
+ if !ok && !updated {
+ zoneCache.update(nil, true)
+ zoneCache.RLock()
+ index, ok = zoneCache.toIndex[zone]
+ zoneCache.RUnlock()
+ }
+ if !ok { // last resort
index, _ = strconv.Atoi(zone)
}
return index
diff --git a/vendor/golang.org/x/net/internal/socket/sys_unix.go b/vendor/golang.org/x/net/internal/socket/sys_unix.go
index 18eba3085..0eb71283f 100644
--- a/vendor/golang.org/x/net/internal/socket/sys_unix.go
+++ b/vendor/golang.org/x/net/internal/socket/sys_unix.go
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// +build darwin dragonfly freebsd linux,!s390x,!386 netbsd openbsd
+// +build dragonfly freebsd linux,!s390x,!386 netbsd openbsd
package socket
diff --git a/vendor/golang.org/x/net/ipv4/doc.go b/vendor/golang.org/x/net/ipv4/doc.go
index 3efa29037..863d55b8d 100644
--- a/vendor/golang.org/x/net/ipv4/doc.go
+++ b/vendor/golang.org/x/net/ipv4/doc.go
@@ -241,4 +241,5 @@
// IncludeSourceSpecificGroup may return an error.
package ipv4 // import "golang.org/x/net/ipv4"
-// BUG(mikio): This package is not implemented on JS, NaCl and Plan 9.
+// BUG(mikio): This package is not implemented on AIX, JS, NaCl and
+// Plan 9.
diff --git a/vendor/golang.org/x/net/ipv4/payload_cmsg.go b/vendor/golang.org/x/net/ipv4/payload_cmsg.go
index 204a49fea..a7c892dc4 100644
--- a/vendor/golang.org/x/net/ipv4/payload_cmsg.go
+++ b/vendor/golang.org/x/net/ipv4/payload_cmsg.go
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// +build !js,!nacl,!plan9,!windows
+// +build darwin dragonfly freebsd linux netbsd openbsd solaris
package ipv4
diff --git a/vendor/golang.org/x/net/ipv4/payload_cmsg_go1_8.go b/vendor/golang.org/x/net/ipv4/payload_cmsg_go1_8.go
index 8d45599f4..15a27b7a0 100644
--- a/vendor/golang.org/x/net/ipv4/payload_cmsg_go1_8.go
+++ b/vendor/golang.org/x/net/ipv4/payload_cmsg_go1_8.go
@@ -3,7 +3,7 @@
// license that can be found in the LICENSE file.
// +build !go1.9
-// +build !js,!nacl,!plan9,!windows
+// +build darwin dragonfly freebsd linux netbsd openbsd solaris
package ipv4
diff --git a/vendor/golang.org/x/net/ipv4/payload_cmsg_go1_9.go b/vendor/golang.org/x/net/ipv4/payload_cmsg_go1_9.go
index 4081aad8b..aab3b224e 100644
--- a/vendor/golang.org/x/net/ipv4/payload_cmsg_go1_9.go
+++ b/vendor/golang.org/x/net/ipv4/payload_cmsg_go1_9.go
@@ -3,7 +3,7 @@
// license that can be found in the LICENSE file.
// +build go1.9
-// +build !js,!nacl,!plan9,!windows
+// +build darwin dragonfly freebsd linux netbsd openbsd solaris
package ipv4
diff --git a/vendor/golang.org/x/net/ipv4/payload_nocmsg.go b/vendor/golang.org/x/net/ipv4/payload_nocmsg.go
index 1d434c61a..d57f05c10 100644
--- a/vendor/golang.org/x/net/ipv4/payload_nocmsg.go
+++ b/vendor/golang.org/x/net/ipv4/payload_nocmsg.go
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// +build js nacl plan9 windows
+// +build !darwin,!dragonfly,!freebsd,!linux,!netbsd,!openbsd,!solaris
package ipv4
diff --git a/vendor/golang.org/x/net/ipv6/doc.go b/vendor/golang.org/x/net/ipv6/doc.go
index e0be9d50d..d38ea0da6 100644
--- a/vendor/golang.org/x/net/ipv6/doc.go
+++ b/vendor/golang.org/x/net/ipv6/doc.go
@@ -240,4 +240,5 @@
// IncludeSourceSpecificGroup may return an error.
package ipv6 // import "golang.org/x/net/ipv6"
-// BUG(mikio): This package is not implemented on JS, NaCl and Plan 9.
+// BUG(mikio): This package is not implemented on AIX, JS, NaCl and
+// Plan 9.
diff --git a/vendor/golang.org/x/net/ipv6/payload_cmsg.go b/vendor/golang.org/x/net/ipv6/payload_cmsg.go
index 3f23b5d21..e17847d0b 100644
--- a/vendor/golang.org/x/net/ipv6/payload_cmsg.go
+++ b/vendor/golang.org/x/net/ipv6/payload_cmsg.go
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// +build !js,!nacl,!plan9,!windows
+// +build darwin dragonfly freebsd linux netbsd openbsd solaris
package ipv6
diff --git a/vendor/golang.org/x/net/ipv6/payload_cmsg_go1_8.go b/vendor/golang.org/x/net/ipv6/payload_cmsg_go1_8.go
index bc4209db7..a48a6ed64 100644
--- a/vendor/golang.org/x/net/ipv6/payload_cmsg_go1_8.go
+++ b/vendor/golang.org/x/net/ipv6/payload_cmsg_go1_8.go
@@ -3,7 +3,7 @@
// license that can be found in the LICENSE file.
// +build !go1.9
-// +build !js,!nacl,!plan9,!windows
+// +build darwin dragonfly freebsd linux netbsd openbsd solaris
package ipv6
diff --git a/vendor/golang.org/x/net/ipv6/payload_cmsg_go1_9.go b/vendor/golang.org/x/net/ipv6/payload_cmsg_go1_9.go
index 7dd650480..fb196ed80 100644
--- a/vendor/golang.org/x/net/ipv6/payload_cmsg_go1_9.go
+++ b/vendor/golang.org/x/net/ipv6/payload_cmsg_go1_9.go
@@ -3,7 +3,7 @@
// license that can be found in the LICENSE file.
// +build go1.9
-// +build !js,!nacl,!plan9,!windows
+// +build darwin dragonfly freebsd linux netbsd openbsd solaris
package ipv6
diff --git a/vendor/golang.org/x/net/ipv6/payload_nocmsg.go b/vendor/golang.org/x/net/ipv6/payload_nocmsg.go
index 459142d26..bfb544784 100644
--- a/vendor/golang.org/x/net/ipv6/payload_nocmsg.go
+++ b/vendor/golang.org/x/net/ipv6/payload_nocmsg.go
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// +build js nacl plan9 windows
+// +build !darwin,!dragonfly,!freebsd,!linux,!netbsd,!openbsd,!solaris
package ipv6
diff --git a/vendor/golang.org/x/sys/unix/README.md b/vendor/golang.org/x/sys/unix/README.md
index bc6f6031f..2bf415fb1 100644
--- a/vendor/golang.org/x/sys/unix/README.md
+++ b/vendor/golang.org/x/sys/unix/README.md
@@ -14,7 +14,7 @@ migrating the build system to use containers so the builds are reproducible.
This is being done on an OS-by-OS basis. Please update this documentation as
components of the build system change.
-### Old Build System (currently for `GOOS != "Linux" || GOARCH == "sparc64"`)
+### Old Build System (currently for `GOOS != "linux"`)
The old build system generates the Go files based on the C header files
present on your system. This means that files
@@ -34,7 +34,7 @@ your specific system. Running `mkall.sh -n` shows the commands that will be run.
Requirements: bash, perl, go
-### New Build System (currently for `GOOS == "Linux" && GOARCH != "sparc64"`)
+### New Build System (currently for `GOOS == "linux"`)
The new build system uses a Docker container to generate the go files directly
from source checkouts of the kernel and various system libraries. This means
diff --git a/vendor/golang.org/x/sys/unix/asm_linux_ppc64x.s b/vendor/golang.org/x/sys/unix/asm_linux_ppc64x.s
index 649e58714..88f712557 100644
--- a/vendor/golang.org/x/sys/unix/asm_linux_ppc64x.s
+++ b/vendor/golang.org/x/sys/unix/asm_linux_ppc64x.s
@@ -15,12 +15,6 @@
// Just jump to package syscall's implementation for all these functions.
// The runtime may know about them.
-TEXT ·Syscall(SB),NOSPLIT,$0-56
- BR syscall·Syscall(SB)
-
-TEXT ·Syscall6(SB),NOSPLIT,$0-80
- BR syscall·Syscall6(SB)
-
TEXT ·SyscallNoError(SB),NOSPLIT,$0-48
BL runtime·entersyscall(SB)
MOVD a1+8(FP), R3
@@ -36,12 +30,6 @@ TEXT ·SyscallNoError(SB),NOSPLIT,$0-48
BL runtime·exitsyscall(SB)
RET
-TEXT ·RawSyscall(SB),NOSPLIT,$0-56
- BR syscall·RawSyscall(SB)
-
-TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
- BR syscall·RawSyscall6(SB)
-
TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48
MOVD a1+8(FP), R3
MOVD a2+16(FP), R4
diff --git a/vendor/golang.org/x/sys/unix/mkall.sh b/vendor/golang.org/x/sys/unix/mkall.sh
index 9b76ad669..b21f0118e 100755
--- a/vendor/golang.org/x/sys/unix/mkall.sh
+++ b/vendor/golang.org/x/sys/unix/mkall.sh
@@ -10,13 +10,14 @@
GOOSARCH="${GOOS}_${GOARCH}"
# defaults
-mksyscall="./mksyscall.pl"
+mksyscall="go run mksyscall.go"
mkerrors="./mkerrors.sh"
zerrors="zerrors_$GOOSARCH.go"
mksysctl=""
zsysctl="zsysctl_$GOOSARCH.go"
mksysnum=
mktypes=
+mkasm=
run="sh"
cmd=""
@@ -45,8 +46,8 @@ case "$#" in
exit 2
esac
-if [[ "$GOOS" = "linux" ]] && [[ "$GOARCH" != "sparc64" ]]; then
- # Use then new build system
+if [[ "$GOOS" = "linux" ]]; then
+ # Use the Docker-based build system
# Files generated through docker (use $cmd so you can Ctl-C the build or run)
$cmd docker build --tag generate:$GOOS $GOOS
$cmd docker run --interactive --tty --volume $(dirname "$(readlink -f "$0")"):/build generate:$GOOS
@@ -71,34 +72,39 @@ aix_ppc64)
;;
darwin_386)
mkerrors="$mkerrors -m32"
- mksyscall="./mksyscall.pl -l32"
+ mksyscall="go run mksyscall.go -l32"
mksysnum="./mksysnum_darwin.pl $(xcrun --show-sdk-path --sdk macosx)/usr/include/sys/syscall.h"
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
+ mkasm="go run mkasm_darwin.go"
;;
darwin_amd64)
mkerrors="$mkerrors -m64"
mksysnum="./mksysnum_darwin.pl $(xcrun --show-sdk-path --sdk macosx)/usr/include/sys/syscall.h"
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
+ mkasm="go run mkasm_darwin.go"
;;
darwin_arm)
mkerrors="$mkerrors"
+ mksyscall="go run mksyscall.go -l32"
mksysnum="./mksysnum_darwin.pl $(xcrun --show-sdk-path --sdk iphoneos)/usr/include/sys/syscall.h"
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
+ mkasm="go run mkasm_darwin.go"
;;
darwin_arm64)
mkerrors="$mkerrors -m64"
mksysnum="./mksysnum_darwin.pl $(xcrun --show-sdk-path --sdk iphoneos)/usr/include/sys/syscall.h"
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
+ mkasm="go run mkasm_darwin.go"
;;
dragonfly_amd64)
mkerrors="$mkerrors -m64"
- mksyscall="./mksyscall.pl -dragonfly"
+ mksyscall="go run mksyscall.go -dragonfly"
mksysnum="curl -s 'http://gitweb.dragonflybsd.org/dragonfly.git/blob_plain/HEAD:/sys/kern/syscalls.master' | ./mksysnum_dragonfly.pl"
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
;;
freebsd_386)
mkerrors="$mkerrors -m32"
- mksyscall="./mksyscall.pl -l32"
+ mksyscall="go run mksyscall.go -l32"
mksysnum="curl -s 'http://svn.freebsd.org/base/stable/10/sys/kern/syscalls.master' | ./mksysnum_freebsd.pl"
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
;;
@@ -109,34 +115,27 @@ freebsd_amd64)
;;
freebsd_arm)
mkerrors="$mkerrors"
- mksyscall="./mksyscall.pl -l32 -arm"
+ mksyscall="go run mksyscall.go -l32 -arm"
mksysnum="curl -s 'http://svn.freebsd.org/base/stable/10/sys/kern/syscalls.master' | ./mksysnum_freebsd.pl"
# Let the type of C char be signed for making the bare syscall
# API consistent across platforms.
mktypes="GOARCH=$GOARCH go tool cgo -godefs -- -fsigned-char"
;;
-linux_sparc64)
- GOOSARCH_in=syscall_linux_sparc64.go
- unistd_h=/usr/include/sparc64-linux-gnu/asm/unistd.h
- mkerrors="$mkerrors -m64"
- mksysnum="./mksysnum_linux.pl $unistd_h"
- mktypes="GOARCH=$GOARCH go tool cgo -godefs"
- ;;
netbsd_386)
mkerrors="$mkerrors -m32"
- mksyscall="./mksyscall.pl -l32 -netbsd"
+ mksyscall="go run mksyscall.go -l32 -netbsd"
mksysnum="curl -s 'http://cvsweb.netbsd.org/bsdweb.cgi/~checkout~/src/sys/kern/syscalls.master' | ./mksysnum_netbsd.pl"
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
;;
netbsd_amd64)
mkerrors="$mkerrors -m64"
- mksyscall="./mksyscall.pl -netbsd"
+ mksyscall="go run mksyscall.go -netbsd"
mksysnum="curl -s 'http://cvsweb.netbsd.org/bsdweb.cgi/~checkout~/src/sys/kern/syscalls.master' | ./mksysnum_netbsd.pl"
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
;;
netbsd_arm)
mkerrors="$mkerrors"
- mksyscall="./mksyscall.pl -l32 -netbsd -arm"
+ mksyscall="go run mksyscall.go -l32 -netbsd -arm"
mksysnum="curl -s 'http://cvsweb.netbsd.org/bsdweb.cgi/~checkout~/src/sys/kern/syscalls.master' | ./mksysnum_netbsd.pl"
# Let the type of C char be signed for making the bare syscall
# API consistent across platforms.
@@ -144,21 +143,21 @@ netbsd_arm)
;;
openbsd_386)
mkerrors="$mkerrors -m32"
- mksyscall="./mksyscall.pl -l32 -openbsd"
+ mksyscall="go run mksyscall.go -l32 -openbsd"
mksysctl="./mksysctl_openbsd.pl"
mksysnum="curl -s 'http://cvsweb.openbsd.org/cgi-bin/cvsweb/~checkout~/src/sys/kern/syscalls.master' | ./mksysnum_openbsd.pl"
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
;;
openbsd_amd64)
mkerrors="$mkerrors -m64"
- mksyscall="./mksyscall.pl -openbsd"
+ mksyscall="go run mksyscall.go -openbsd"
mksysctl="./mksysctl_openbsd.pl"
mksysnum="curl -s 'http://cvsweb.openbsd.org/cgi-bin/cvsweb/~checkout~/src/sys/kern/syscalls.master' | ./mksysnum_openbsd.pl"
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
;;
openbsd_arm)
mkerrors="$mkerrors"
- mksyscall="./mksyscall.pl -l32 -openbsd -arm"
+ mksyscall="go run mksyscall.go -l32 -openbsd -arm"
mksysctl="./mksysctl_openbsd.pl"
mksysnum="curl -s 'http://cvsweb.openbsd.org/cgi-bin/cvsweb/~checkout~/src/sys/kern/syscalls.master' | ./mksysnum_openbsd.pl"
# Let the type of C char be signed for making the bare syscall
@@ -191,6 +190,11 @@ esac
if [ "$GOOSARCH" == "aix_ppc64" ]; then
# aix/ppc64 script generates files instead of writing to stdin.
echo "$mksyscall -tags $GOOS,$GOARCH $syscall_goos $GOOSARCH_in && gofmt -w zsyscall_$GOOSARCH.go && gofmt -w zsyscall_"$GOOSARCH"_gccgo.go && gofmt -w zsyscall_"$GOOSARCH"_gc.go " ;
+ elif [ "$GOOS" == "darwin" ]; then
+ # pre-1.12, direct syscalls
+ echo "$mksyscall -tags $GOOS,$GOARCH,!go1.12 $syscall_goos $GOOSARCH_in |gofmt >zsyscall_$GOOSARCH.1_11.go";
+ # 1.12 and later, syscalls via libSystem
+ echo "$mksyscall -tags $GOOS,$GOARCH,go1.12 $syscall_goos $GOOSARCH_in |gofmt >zsyscall_$GOOSARCH.go";
else
echo "$mksyscall -tags $GOOS,$GOARCH $syscall_goos $GOOSARCH_in |gofmt >zsyscall_$GOOSARCH.go";
fi
@@ -200,5 +204,6 @@ esac
if [ -n "$mksysnum" ]; then echo "$mksysnum |gofmt >zsysnum_$GOOSARCH.go"; fi
if [ -n "$mktypes" ]; then
echo "$mktypes types_$GOOS.go | go run mkpost.go > ztypes_$GOOSARCH.go";
+ if [ -n "$mkasm" ]; then echo "$mkasm $GOARCH"; fi
fi
) | $run
diff --git a/vendor/golang.org/x/sys/unix/mkasm_darwin.go b/vendor/golang.org/x/sys/unix/mkasm_darwin.go
new file mode 100644
index 000000000..4548b993d
--- /dev/null
+++ b/vendor/golang.org/x/sys/unix/mkasm_darwin.go
@@ -0,0 +1,61 @@
+// Copyright 2018 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build ignore
+
+// mkasm_darwin.go generates assembly trampolines to call libSystem routines from Go.
+//This program must be run after mksyscall.go.
+package main
+
+import (
+ "bytes"
+ "fmt"
+ "io/ioutil"
+ "log"
+ "os"
+ "strings"
+)
+
+func main() {
+ in1, err := ioutil.ReadFile("syscall_darwin.go")
+ if err != nil {
+ log.Fatalf("can't open syscall_darwin.go: %s", err)
+ }
+ arch := os.Args[1]
+ in2, err := ioutil.ReadFile(fmt.Sprintf("syscall_darwin_%s.go", arch))
+ if err != nil {
+ log.Fatalf("can't open syscall_darwin_%s.go: %s", arch, err)
+ }
+ in3, err := ioutil.ReadFile(fmt.Sprintf("zsyscall_darwin_%s.go", arch))
+ if err != nil {
+ log.Fatalf("can't open zsyscall_darwin_%s.go: %s", arch, err)
+ }
+ in := string(in1) + string(in2) + string(in3)
+
+ trampolines := map[string]bool{}
+
+ var out bytes.Buffer
+
+ fmt.Fprintf(&out, "// go run mkasm_darwin.go %s\n", strings.Join(os.Args[1:], " "))
+ fmt.Fprintf(&out, "// Code generated by the command above; DO NOT EDIT.\n")
+ fmt.Fprintf(&out, "\n")
+ fmt.Fprintf(&out, "// +build go1.12\n")
+ fmt.Fprintf(&out, "\n")
+ fmt.Fprintf(&out, "#include \"textflag.h\"\n")
+ for _, line := range strings.Split(in, "\n") {
+ if !strings.HasPrefix(line, "func ") || !strings.HasSuffix(line, "_trampoline()") {
+ continue
+ }
+ fn := line[5 : len(line)-13]
+ if !trampolines[fn] {
+ trampolines[fn] = true
+ fmt.Fprintf(&out, "TEXT ·%s_trampoline(SB),NOSPLIT,$0-0\n", fn)
+ fmt.Fprintf(&out, "\tJMP\t%s(SB)\n", fn)
+ }
+ }
+ err = ioutil.WriteFile(fmt.Sprintf("zsyscall_darwin_%s.s", arch), out.Bytes(), 0644)
+ if err != nil {
+ log.Fatalf("can't write zsyscall_darwin_%s.s: %s", arch, err)
+ }
+}
diff --git a/vendor/golang.org/x/sys/unix/mkerrors.sh b/vendor/golang.org/x/sys/unix/mkerrors.sh
index 73e179a89..178077f47 100755
--- a/vendor/golang.org/x/sys/unix/mkerrors.sh
+++ b/vendor/golang.org/x/sys/unix/mkerrors.sh
@@ -17,12 +17,10 @@ if test -z "$GOARCH" -o -z "$GOOS"; then
fi
# Check that we are using the new build system if we should
-if [[ "$GOOS" = "linux" ]] && [[ "$GOARCH" != "sparc64" ]]; then
- if [[ "$GOLANG_SYS_BUILD" != "docker" ]]; then
- echo 1>&2 "In the new build system, mkerrors should not be called directly."
- echo 1>&2 "See README.md"
- exit 1
- fi
+if [[ "$GOOS" = "linux" ]] && [[ "$GOLANG_SYS_BUILD" != "docker" ]]; then
+ echo 1>&2 "In the Docker based build system, mkerrors should not be called directly."
+ echo 1>&2 "See README.md"
+ exit 1
fi
if [[ "$GOOS" = "aix" ]]; then
@@ -101,7 +99,7 @@ includes_DragonFly='
'
includes_FreeBSD='
-#include
+#include
#include
#include
#include
@@ -187,6 +185,7 @@ struct ltchars {
#include
#include
#include
+#include
#include
#include
#include
@@ -222,7 +221,15 @@ struct ltchars {
#include
#include
#include
+
+#if defined(__sparc__)
+// On sparc{,64}, the kernel defines struct termios2 itself which clashes with the
+// definition in glibc. As only the error constants are needed here, include the
+// generic termibits.h (which is included by termbits.h on sparc).
+#include
+#else
#include
+#endif
#ifndef MSG_FASTOPEN
#define MSG_FASTOPEN 0x20000000
@@ -500,6 +507,7 @@ ccflags="$@"
$2 ~ /^(HDIO|WIN|SMART)_/ ||
$2 !~ "WMESGLEN" &&
$2 ~ /^W[A-Z0-9]+$/ ||
+ $2 ~/^PPPIOC/ ||
$2 ~ /^BLK[A-Z]*(GET$|SET$|BUF$|PART$|SIZE)/ {printf("\t%s = C.%s\n", $2, $2)}
$2 ~ /^__WCOREFLAG$/ {next}
$2 ~ /^__W[A-Z0-9]+$/ {printf("\t%s = C.%s\n", substr($2,3), $2)}
diff --git a/vendor/golang.org/x/sys/unix/mkpost.go b/vendor/golang.org/x/sys/unix/mkpost.go
index 7e5c22c47..9feddd00c 100644
--- a/vendor/golang.org/x/sys/unix/mkpost.go
+++ b/vendor/golang.org/x/sys/unix/mkpost.go
@@ -28,10 +28,10 @@ func main() {
if goarch == "" {
goarch = os.Getenv("GOARCH")
}
- // Check that we are using the new build system if we should be.
- if goos == "linux" && goarch != "sparc64" {
+ // Check that we are using the Docker-based build system if we should be.
+ if goos == "linux" {
if os.Getenv("GOLANG_SYS_BUILD") != "docker" {
- os.Stderr.WriteString("In the new build system, mkpost should not be called directly.\n")
+ os.Stderr.WriteString("In the Docker-based build system, mkpost should not be called directly.\n")
os.Stderr.WriteString("See README.md\n")
os.Exit(1)
}
@@ -46,6 +46,10 @@ func main() {
valRegex := regexp.MustCompile(`type (Fsid|Sigset_t) struct {(\s+)X__val(\s+\S+\s+)}`)
b = valRegex.ReplaceAll(b, []byte("type $1 struct {${2}Val$3}"))
+ // Intentionally export __fds_bits field in FdSet
+ fdSetRegex := regexp.MustCompile(`type (FdSet) struct {(\s+)X__fds_bits(\s+\S+\s+)}`)
+ b = fdSetRegex.ReplaceAll(b, []byte("type $1 struct {${2}Bits$3}"))
+
// If we have empty Ptrace structs, we should delete them. Only s390x emits
// nonempty Ptrace structs.
ptraceRexexp := regexp.MustCompile(`type Ptrace((Psw|Fpregs|Per) struct {\s*})`)
@@ -65,6 +69,10 @@ func main() {
convertUtsnameRegex := regexp.MustCompile(`((Sys|Node|Domain)name|Release|Version|Machine)(\s+)\[(\d+)\]u?int8`)
b = convertUtsnameRegex.ReplaceAll(b, []byte("$1$3[$4]byte"))
+ // Convert [1024]int8 to [1024]byte in Ptmget members
+ convertPtmget := regexp.MustCompile(`([SC]n)(\s+)\[(\d+)\]u?int8`)
+ b = convertPtmget.ReplaceAll(b, []byte("$1[$3]byte"))
+
// Remove spare fields (e.g. in Statx_t)
spareFieldsRegex := regexp.MustCompile(`X__spare\S*`)
b = spareFieldsRegex.ReplaceAll(b, []byte("_"))
diff --git a/vendor/golang.org/x/sys/unix/mksyscall.go b/vendor/golang.org/x/sys/unix/mksyscall.go
new file mode 100644
index 000000000..890652ca8
--- /dev/null
+++ b/vendor/golang.org/x/sys/unix/mksyscall.go
@@ -0,0 +1,398 @@
+// Copyright 2018 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build ignore
+
+/*
+This program reads a file containing function prototypes
+(like syscall_darwin.go) and generates system call bodies.
+The prototypes are marked by lines beginning with "//sys"
+and read like func declarations if //sys is replaced by func, but:
+ * The parameter lists must give a name for each argument.
+ This includes return parameters.
+ * The parameter lists must give a type for each argument:
+ the (x, y, z int) shorthand is not allowed.
+ * If the return parameter is an error number, it must be named errno.
+
+A line beginning with //sysnb is like //sys, except that the
+goroutine will not be suspended during the execution of the system
+call. This must only be used for system calls which can never
+block, as otherwise the system call could cause all goroutines to
+hang.
+*/
+package main
+
+import (
+ "bufio"
+ "flag"
+ "fmt"
+ "os"
+ "regexp"
+ "strings"
+)
+
+var (
+ b32 = flag.Bool("b32", false, "32bit big-endian")
+ l32 = flag.Bool("l32", false, "32bit little-endian")
+ plan9 = flag.Bool("plan9", false, "plan9")
+ openbsd = flag.Bool("openbsd", false, "openbsd")
+ netbsd = flag.Bool("netbsd", false, "netbsd")
+ dragonfly = flag.Bool("dragonfly", false, "dragonfly")
+ arm = flag.Bool("arm", false, "arm") // 64-bit value should use (even, odd)-pair
+ tags = flag.String("tags", "", "build tags")
+ filename = flag.String("output", "", "output file name (standard output if omitted)")
+)
+
+// cmdLine returns this programs's commandline arguments
+func cmdLine() string {
+ return "go run mksyscall.go " + strings.Join(os.Args[1:], " ")
+}
+
+// buildTags returns build tags
+func buildTags() string {
+ return *tags
+}
+
+// Param is function parameter
+type Param struct {
+ Name string
+ Type string
+}
+
+// usage prints the program usage
+func usage() {
+ fmt.Fprintf(os.Stderr, "usage: go run mksyscall.go [-b32 | -l32] [-tags x,y] [file ...]\n")
+ os.Exit(1)
+}
+
+// parseParamList parses parameter list and returns a slice of parameters
+func parseParamList(list string) []string {
+ list = strings.TrimSpace(list)
+ if list == "" {
+ return []string{}
+ }
+ return regexp.MustCompile(`\s*,\s*`).Split(list, -1)
+}
+
+// parseParam splits a parameter into name and type
+func parseParam(p string) Param {
+ ps := regexp.MustCompile(`^(\S*) (\S*)$`).FindStringSubmatch(p)
+ if ps == nil {
+ fmt.Fprintf(os.Stderr, "malformed parameter: %s\n", p)
+ os.Exit(1)
+ }
+ return Param{ps[1], ps[2]}
+}
+
+func main() {
+ // Get the OS and architecture (using GOARCH_TARGET if it exists)
+ goos := os.Getenv("GOOS")
+ goarch := os.Getenv("GOARCH_TARGET")
+ if goarch == "" {
+ goarch = os.Getenv("GOARCH")
+ }
+
+ // Check that we are using the Docker-based build system if we should
+ if goos == "linux" {
+ if os.Getenv("GOLANG_SYS_BUILD") != "docker" {
+ fmt.Fprintf(os.Stderr, "In the Docker-based build system, mksyscall should not be called directly.\n")
+ fmt.Fprintf(os.Stderr, "See README.md\n")
+ os.Exit(1)
+ }
+ }
+
+ flag.Usage = usage
+ flag.Parse()
+ if len(flag.Args()) <= 0 {
+ fmt.Fprintf(os.Stderr, "no files to parse provided\n")
+ usage()
+ }
+
+ endianness := ""
+ if *b32 {
+ endianness = "big-endian"
+ } else if *l32 {
+ endianness = "little-endian"
+ }
+
+ libc := false
+ if goos == "darwin" && strings.Contains(buildTags(), ",go1.12") {
+ libc = true
+ }
+ trampolines := map[string]bool{}
+
+ text := ""
+ for _, path := range flag.Args() {
+ file, err := os.Open(path)
+ if err != nil {
+ fmt.Fprintf(os.Stderr, err.Error())
+ os.Exit(1)
+ }
+ s := bufio.NewScanner(file)
+ for s.Scan() {
+ t := s.Text()
+ t = strings.TrimSpace(t)
+ t = regexp.MustCompile(`\s+`).ReplaceAllString(t, ` `)
+ nonblock := regexp.MustCompile(`^\/\/sysnb `).FindStringSubmatch(t)
+ if regexp.MustCompile(`^\/\/sys `).FindStringSubmatch(t) == nil && nonblock == nil {
+ continue
+ }
+
+ // Line must be of the form
+ // func Open(path string, mode int, perm int) (fd int, errno error)
+ // Split into name, in params, out params.
+ f := regexp.MustCompile(`^\/\/sys(nb)? (\w+)\(([^()]*)\)\s*(?:\(([^()]+)\))?\s*(?:=\s*((?i)SYS_[A-Z0-9_]+))?$`).FindStringSubmatch(t)
+ if f == nil {
+ fmt.Fprintf(os.Stderr, "%s:%s\nmalformed //sys declaration\n", path, t)
+ os.Exit(1)
+ }
+ funct, inps, outps, sysname := f[2], f[3], f[4], f[5]
+
+ // Split argument lists on comma.
+ in := parseParamList(inps)
+ out := parseParamList(outps)
+
+ // Try in vain to keep people from editing this file.
+ // The theory is that they jump into the middle of the file
+ // without reading the header.
+ text += "// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT\n\n"
+
+ // Go function header.
+ outDecl := ""
+ if len(out) > 0 {
+ outDecl = fmt.Sprintf(" (%s)", strings.Join(out, ", "))
+ }
+ text += fmt.Sprintf("func %s(%s)%s {\n", funct, strings.Join(in, ", "), outDecl)
+
+ // Check if err return available
+ errvar := ""
+ for _, param := range out {
+ p := parseParam(param)
+ if p.Type == "error" {
+ errvar = p.Name
+ break
+ }
+ }
+
+ // Prepare arguments to Syscall.
+ var args []string
+ n := 0
+ for _, param := range in {
+ p := parseParam(param)
+ if regexp.MustCompile(`^\*`).FindStringSubmatch(p.Type) != nil {
+ args = append(args, "uintptr(unsafe.Pointer("+p.Name+"))")
+ } else if p.Type == "string" && errvar != "" {
+ text += fmt.Sprintf("\tvar _p%d *byte\n", n)
+ text += fmt.Sprintf("\t_p%d, %s = BytePtrFromString(%s)\n", n, errvar, p.Name)
+ text += fmt.Sprintf("\tif %s != nil {\n\t\treturn\n\t}\n", errvar)
+ args = append(args, fmt.Sprintf("uintptr(unsafe.Pointer(_p%d))", n))
+ n++
+ } else if p.Type == "string" {
+ fmt.Fprintf(os.Stderr, path+":"+funct+" uses string arguments, but has no error return\n")
+ text += fmt.Sprintf("\tvar _p%d *byte\n", n)
+ text += fmt.Sprintf("\t_p%d, _ = BytePtrFromString(%s)\n", n, p.Name)
+ args = append(args, fmt.Sprintf("uintptr(unsafe.Pointer(_p%d))", n))
+ n++
+ } else if regexp.MustCompile(`^\[\](.*)`).FindStringSubmatch(p.Type) != nil {
+ // Convert slice into pointer, length.
+ // Have to be careful not to take address of &a[0] if len == 0:
+ // pass dummy pointer in that case.
+ // Used to pass nil, but some OSes or simulators reject write(fd, nil, 0).
+ text += fmt.Sprintf("\tvar _p%d unsafe.Pointer\n", n)
+ text += fmt.Sprintf("\tif len(%s) > 0 {\n\t\t_p%d = unsafe.Pointer(&%s[0])\n\t}", p.Name, n, p.Name)
+ text += fmt.Sprintf(" else {\n\t\t_p%d = unsafe.Pointer(&_zero)\n\t}\n", n)
+ args = append(args, fmt.Sprintf("uintptr(_p%d)", n), fmt.Sprintf("uintptr(len(%s))", p.Name))
+ n++
+ } else if p.Type == "int64" && (*openbsd || *netbsd) {
+ args = append(args, "0")
+ if endianness == "big-endian" {
+ args = append(args, fmt.Sprintf("uintptr(%s>>32)", p.Name), fmt.Sprintf("uintptr(%s)", p.Name))
+ } else if endianness == "little-endian" {
+ args = append(args, fmt.Sprintf("uintptr(%s)", p.Name), fmt.Sprintf("uintptr(%s>>32)", p.Name))
+ } else {
+ args = append(args, fmt.Sprintf("uintptr(%s)", p.Name))
+ }
+ } else if p.Type == "int64" && *dragonfly {
+ if regexp.MustCompile(`^(?i)extp(read|write)`).FindStringSubmatch(funct) == nil {
+ args = append(args, "0")
+ }
+ if endianness == "big-endian" {
+ args = append(args, fmt.Sprintf("uintptr(%s>>32)", p.Name), fmt.Sprintf("uintptr(%s)", p.Name))
+ } else if endianness == "little-endian" {
+ args = append(args, fmt.Sprintf("uintptr(%s)", p.Name), fmt.Sprintf("uintptr(%s>>32)", p.Name))
+ } else {
+ args = append(args, fmt.Sprintf("uintptr(%s)", p.Name))
+ }
+ } else if p.Type == "int64" && endianness != "" {
+ if len(args)%2 == 1 && *arm {
+ // arm abi specifies 64-bit argument uses
+ // (even, odd) pair
+ args = append(args, "0")
+ }
+ if endianness == "big-endian" {
+ args = append(args, fmt.Sprintf("uintptr(%s>>32)", p.Name), fmt.Sprintf("uintptr(%s)", p.Name))
+ } else {
+ args = append(args, fmt.Sprintf("uintptr(%s)", p.Name), fmt.Sprintf("uintptr(%s>>32)", p.Name))
+ }
+ } else {
+ args = append(args, fmt.Sprintf("uintptr(%s)", p.Name))
+ }
+ }
+
+ // Determine which form to use; pad args with zeros.
+ asm := "Syscall"
+ if nonblock != nil {
+ if errvar == "" && goos == "linux" {
+ asm = "RawSyscallNoError"
+ } else {
+ asm = "RawSyscall"
+ }
+ } else {
+ if errvar == "" && goos == "linux" {
+ asm = "SyscallNoError"
+ }
+ }
+ if len(args) <= 3 {
+ for len(args) < 3 {
+ args = append(args, "0")
+ }
+ } else if len(args) <= 6 {
+ asm += "6"
+ for len(args) < 6 {
+ args = append(args, "0")
+ }
+ } else if len(args) <= 9 {
+ asm += "9"
+ for len(args) < 9 {
+ args = append(args, "0")
+ }
+ } else {
+ fmt.Fprintf(os.Stderr, "%s:%s too many arguments to system call\n", path, funct)
+ }
+
+ // System call number.
+ if sysname == "" {
+ sysname = "SYS_" + funct
+ sysname = regexp.MustCompile(`([a-z])([A-Z])`).ReplaceAllString(sysname, `${1}_$2`)
+ sysname = strings.ToUpper(sysname)
+ }
+
+ var libcFn string
+ if libc {
+ asm = "syscall_" + strings.ToLower(asm[:1]) + asm[1:] // internal syscall call
+ sysname = strings.TrimPrefix(sysname, "SYS_") // remove SYS_
+ sysname = strings.ToLower(sysname) // lowercase
+ if sysname == "getdirentries64" {
+ // Special case - libSystem name and
+ // raw syscall name don't match.
+ sysname = "__getdirentries64"
+ }
+ libcFn = sysname
+ sysname = "funcPC(libc_" + sysname + "_trampoline)"
+ }
+
+ // Actual call.
+ arglist := strings.Join(args, ", ")
+ call := fmt.Sprintf("%s(%s, %s)", asm, sysname, arglist)
+
+ // Assign return values.
+ body := ""
+ ret := []string{"_", "_", "_"}
+ doErrno := false
+ for i := 0; i < len(out); i++ {
+ p := parseParam(out[i])
+ reg := ""
+ if p.Name == "err" && !*plan9 {
+ reg = "e1"
+ ret[2] = reg
+ doErrno = true
+ } else if p.Name == "err" && *plan9 {
+ ret[0] = "r0"
+ ret[2] = "e1"
+ break
+ } else {
+ reg = fmt.Sprintf("r%d", i)
+ ret[i] = reg
+ }
+ if p.Type == "bool" {
+ reg = fmt.Sprintf("%s != 0", reg)
+ }
+ if p.Type == "int64" && endianness != "" {
+ // 64-bit number in r1:r0 or r0:r1.
+ if i+2 > len(out) {
+ fmt.Fprintf(os.Stderr, "%s:%s not enough registers for int64 return\n", path, funct)
+ }
+ if endianness == "big-endian" {
+ reg = fmt.Sprintf("int64(r%d)<<32 | int64(r%d)", i, i+1)
+ } else {
+ reg = fmt.Sprintf("int64(r%d)<<32 | int64(r%d)", i+1, i)
+ }
+ ret[i] = fmt.Sprintf("r%d", i)
+ ret[i+1] = fmt.Sprintf("r%d", i+1)
+ }
+ if reg != "e1" || *plan9 {
+ body += fmt.Sprintf("\t%s = %s(%s)\n", p.Name, p.Type, reg)
+ }
+ }
+ if ret[0] == "_" && ret[1] == "_" && ret[2] == "_" {
+ text += fmt.Sprintf("\t%s\n", call)
+ } else {
+ if errvar == "" && goos == "linux" {
+ // raw syscall without error on Linux, see golang.org/issue/22924
+ text += fmt.Sprintf("\t%s, %s := %s\n", ret[0], ret[1], call)
+ } else {
+ text += fmt.Sprintf("\t%s, %s, %s := %s\n", ret[0], ret[1], ret[2], call)
+ }
+ }
+ text += body
+
+ if *plan9 && ret[2] == "e1" {
+ text += "\tif int32(r0) == -1 {\n"
+ text += "\t\terr = e1\n"
+ text += "\t}\n"
+ } else if doErrno {
+ text += "\tif e1 != 0 {\n"
+ text += "\t\terr = errnoErr(e1)\n"
+ text += "\t}\n"
+ }
+ text += "\treturn\n"
+ text += "}\n\n"
+
+ if libc && !trampolines[libcFn] {
+ // some system calls share a trampoline, like read and readlen.
+ trampolines[libcFn] = true
+ // Declare assembly trampoline.
+ text += fmt.Sprintf("func libc_%s_trampoline()\n", libcFn)
+ // Assembly trampoline calls the libc_* function, which this magic
+ // redirects to use the function from libSystem.
+ text += fmt.Sprintf("//go:linkname libc_%s libc_%s\n", libcFn, libcFn)
+ text += fmt.Sprintf("//go:cgo_import_dynamic libc_%s %s \"/usr/lib/libSystem.B.dylib\"\n", libcFn, libcFn)
+ text += "\n"
+ }
+ }
+ if err := s.Err(); err != nil {
+ fmt.Fprintf(os.Stderr, err.Error())
+ os.Exit(1)
+ }
+ file.Close()
+ }
+ fmt.Printf(srcTemplate, cmdLine(), buildTags(), text)
+}
+
+const srcTemplate = `// %s
+// Code generated by the command above; see README.md. DO NOT EDIT.
+
+// +build %s
+
+package unix
+
+import (
+ "syscall"
+ "unsafe"
+)
+
+var _ syscall.Errno
+
+%s
+`
diff --git a/vendor/golang.org/x/sys/unix/mksyscall.pl b/vendor/golang.org/x/sys/unix/mksyscall.pl
deleted file mode 100755
index 1f6b926f8..000000000
--- a/vendor/golang.org/x/sys/unix/mksyscall.pl
+++ /dev/null
@@ -1,341 +0,0 @@
-#!/usr/bin/env perl
-# Copyright 2009 The Go Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style
-# license that can be found in the LICENSE file.
-
-# This program reads a file containing function prototypes
-# (like syscall_darwin.go) and generates system call bodies.
-# The prototypes are marked by lines beginning with "//sys"
-# and read like func declarations if //sys is replaced by func, but:
-# * The parameter lists must give a name for each argument.
-# This includes return parameters.
-# * The parameter lists must give a type for each argument:
-# the (x, y, z int) shorthand is not allowed.
-# * If the return parameter is an error number, it must be named errno.
-
-# A line beginning with //sysnb is like //sys, except that the
-# goroutine will not be suspended during the execution of the system
-# call. This must only be used for system calls which can never
-# block, as otherwise the system call could cause all goroutines to
-# hang.
-
-use strict;
-
-my $cmdline = "mksyscall.pl " . join(' ', @ARGV);
-my $errors = 0;
-my $_32bit = "";
-my $plan9 = 0;
-my $openbsd = 0;
-my $netbsd = 0;
-my $dragonfly = 0;
-my $arm = 0; # 64-bit value should use (even, odd)-pair
-my $tags = ""; # build tags
-
-if($ARGV[0] eq "-b32") {
- $_32bit = "big-endian";
- shift;
-} elsif($ARGV[0] eq "-l32") {
- $_32bit = "little-endian";
- shift;
-}
-if($ARGV[0] eq "-plan9") {
- $plan9 = 1;
- shift;
-}
-if($ARGV[0] eq "-openbsd") {
- $openbsd = 1;
- shift;
-}
-if($ARGV[0] eq "-netbsd") {
- $netbsd = 1;
- shift;
-}
-if($ARGV[0] eq "-dragonfly") {
- $dragonfly = 1;
- shift;
-}
-if($ARGV[0] eq "-arm") {
- $arm = 1;
- shift;
-}
-if($ARGV[0] eq "-tags") {
- shift;
- $tags = $ARGV[0];
- shift;
-}
-
-if($ARGV[0] =~ /^-/) {
- print STDERR "usage: mksyscall.pl [-b32 | -l32] [-tags x,y] [file ...]\n";
- exit 1;
-}
-
-# Check that we are using the new build system if we should
-if($ENV{'GOOS'} eq "linux" && $ENV{'GOARCH'} ne "sparc64") {
- if($ENV{'GOLANG_SYS_BUILD'} ne "docker") {
- print STDERR "In the new build system, mksyscall should not be called directly.\n";
- print STDERR "See README.md\n";
- exit 1;
- }
-}
-
-
-sub parseparamlist($) {
- my ($list) = @_;
- $list =~ s/^\s*//;
- $list =~ s/\s*$//;
- if($list eq "") {
- return ();
- }
- return split(/\s*,\s*/, $list);
-}
-
-sub parseparam($) {
- my ($p) = @_;
- if($p !~ /^(\S*) (\S*)$/) {
- print STDERR "$ARGV:$.: malformed parameter: $p\n";
- $errors = 1;
- return ("xx", "int");
- }
- return ($1, $2);
-}
-
-my $text = "";
-while(<>) {
- chomp;
- s/\s+/ /g;
- s/^\s+//;
- s/\s+$//;
- my $nonblock = /^\/\/sysnb /;
- next if !/^\/\/sys / && !$nonblock;
-
- # Line must be of the form
- # func Open(path string, mode int, perm int) (fd int, errno error)
- # Split into name, in params, out params.
- if(!/^\/\/sys(nb)? (\w+)\(([^()]*)\)\s*(?:\(([^()]+)\))?\s*(?:=\s*((?i)SYS_[A-Z0-9_]+))?$/) {
- print STDERR "$ARGV:$.: malformed //sys declaration\n";
- $errors = 1;
- next;
- }
- my ($func, $in, $out, $sysname) = ($2, $3, $4, $5);
-
- # Split argument lists on comma.
- my @in = parseparamlist($in);
- my @out = parseparamlist($out);
-
- # Try in vain to keep people from editing this file.
- # The theory is that they jump into the middle of the file
- # without reading the header.
- $text .= "// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT\n\n";
-
- # Go function header.
- my $out_decl = @out ? sprintf(" (%s)", join(', ', @out)) : "";
- $text .= sprintf "func %s(%s)%s {\n", $func, join(', ', @in), $out_decl;
-
- # Check if err return available
- my $errvar = "";
- foreach my $p (@out) {
- my ($name, $type) = parseparam($p);
- if($type eq "error") {
- $errvar = $name;
- last;
- }
- }
-
- # Prepare arguments to Syscall.
- my @args = ();
- my $n = 0;
- foreach my $p (@in) {
- my ($name, $type) = parseparam($p);
- if($type =~ /^\*/) {
- push @args, "uintptr(unsafe.Pointer($name))";
- } elsif($type eq "string" && $errvar ne "") {
- $text .= "\tvar _p$n *byte\n";
- $text .= "\t_p$n, $errvar = BytePtrFromString($name)\n";
- $text .= "\tif $errvar != nil {\n\t\treturn\n\t}\n";
- push @args, "uintptr(unsafe.Pointer(_p$n))";
- $n++;
- } elsif($type eq "string") {
- print STDERR "$ARGV:$.: $func uses string arguments, but has no error return\n";
- $text .= "\tvar _p$n *byte\n";
- $text .= "\t_p$n, _ = BytePtrFromString($name)\n";
- push @args, "uintptr(unsafe.Pointer(_p$n))";
- $n++;
- } elsif($type =~ /^\[\](.*)/) {
- # Convert slice into pointer, length.
- # Have to be careful not to take address of &a[0] if len == 0:
- # pass dummy pointer in that case.
- # Used to pass nil, but some OSes or simulators reject write(fd, nil, 0).
- $text .= "\tvar _p$n unsafe.Pointer\n";
- $text .= "\tif len($name) > 0 {\n\t\t_p$n = unsafe.Pointer(\&${name}[0])\n\t}";
- $text .= " else {\n\t\t_p$n = unsafe.Pointer(&_zero)\n\t}";
- $text .= "\n";
- push @args, "uintptr(_p$n)", "uintptr(len($name))";
- $n++;
- } elsif($type eq "int64" && ($openbsd || $netbsd)) {
- push @args, "0";
- if($_32bit eq "big-endian") {
- push @args, "uintptr($name>>32)", "uintptr($name)";
- } elsif($_32bit eq "little-endian") {
- push @args, "uintptr($name)", "uintptr($name>>32)";
- } else {
- push @args, "uintptr($name)";
- }
- } elsif($type eq "int64" && $dragonfly) {
- if ($func !~ /^extp(read|write)/i) {
- push @args, "0";
- }
- if($_32bit eq "big-endian") {
- push @args, "uintptr($name>>32)", "uintptr($name)";
- } elsif($_32bit eq "little-endian") {
- push @args, "uintptr($name)", "uintptr($name>>32)";
- } else {
- push @args, "uintptr($name)";
- }
- } elsif($type eq "int64" && $_32bit ne "") {
- if(@args % 2 && $arm) {
- # arm abi specifies 64-bit argument uses
- # (even, odd) pair
- push @args, "0"
- }
- if($_32bit eq "big-endian") {
- push @args, "uintptr($name>>32)", "uintptr($name)";
- } else {
- push @args, "uintptr($name)", "uintptr($name>>32)";
- }
- } else {
- push @args, "uintptr($name)";
- }
- }
-
- # Determine which form to use; pad args with zeros.
- my $asm = "Syscall";
- if ($nonblock) {
- if ($errvar eq "" && $ENV{'GOOS'} eq "linux") {
- $asm = "RawSyscallNoError";
- } else {
- $asm = "RawSyscall";
- }
- } else {
- if ($errvar eq "" && $ENV{'GOOS'} eq "linux") {
- $asm = "SyscallNoError";
- }
- }
- if(@args <= 3) {
- while(@args < 3) {
- push @args, "0";
- }
- } elsif(@args <= 6) {
- $asm .= "6";
- while(@args < 6) {
- push @args, "0";
- }
- } elsif(@args <= 9) {
- $asm .= "9";
- while(@args < 9) {
- push @args, "0";
- }
- } else {
- print STDERR "$ARGV:$.: too many arguments to system call\n";
- }
-
- # System call number.
- if($sysname eq "") {
- $sysname = "SYS_$func";
- $sysname =~ s/([a-z])([A-Z])/${1}_$2/g; # turn FooBar into Foo_Bar
- $sysname =~ y/a-z/A-Z/;
- }
-
- # Actual call.
- my $args = join(', ', @args);
- my $call = "$asm($sysname, $args)";
-
- # Assign return values.
- my $body = "";
- my @ret = ("_", "_", "_");
- my $do_errno = 0;
- for(my $i=0; $i<@out; $i++) {
- my $p = $out[$i];
- my ($name, $type) = parseparam($p);
- my $reg = "";
- if($name eq "err" && !$plan9) {
- $reg = "e1";
- $ret[2] = $reg;
- $do_errno = 1;
- } elsif($name eq "err" && $plan9) {
- $ret[0] = "r0";
- $ret[2] = "e1";
- next;
- } else {
- $reg = sprintf("r%d", $i);
- $ret[$i] = $reg;
- }
- if($type eq "bool") {
- $reg = "$reg != 0";
- }
- if($type eq "int64" && $_32bit ne "") {
- # 64-bit number in r1:r0 or r0:r1.
- if($i+2 > @out) {
- print STDERR "$ARGV:$.: not enough registers for int64 return\n";
- }
- if($_32bit eq "big-endian") {
- $reg = sprintf("int64(r%d)<<32 | int64(r%d)", $i, $i+1);
- } else {
- $reg = sprintf("int64(r%d)<<32 | int64(r%d)", $i+1, $i);
- }
- $ret[$i] = sprintf("r%d", $i);
- $ret[$i+1] = sprintf("r%d", $i+1);
- }
- if($reg ne "e1" || $plan9) {
- $body .= "\t$name = $type($reg)\n";
- }
- }
- if ($ret[0] eq "_" && $ret[1] eq "_" && $ret[2] eq "_") {
- $text .= "\t$call\n";
- } else {
- if ($errvar eq "" && $ENV{'GOOS'} eq "linux") {
- # raw syscall without error on Linux, see golang.org/issue/22924
- $text .= "\t$ret[0], $ret[1] := $call\n";
- } else {
- $text .= "\t$ret[0], $ret[1], $ret[2] := $call\n";
- }
- }
- $text .= $body;
-
- if ($plan9 && $ret[2] eq "e1") {
- $text .= "\tif int32(r0) == -1 {\n";
- $text .= "\t\terr = e1\n";
- $text .= "\t}\n";
- } elsif ($do_errno) {
- $text .= "\tif e1 != 0 {\n";
- $text .= "\t\terr = errnoErr(e1)\n";
- $text .= "\t}\n";
- }
- $text .= "\treturn\n";
- $text .= "}\n\n";
-}
-
-chomp $text;
-chomp $text;
-
-if($errors) {
- exit 1;
-}
-
-print <>32), uintptr(unsafe.Pointer(&length)), 0, 0, 0, 0)
-
- written = int(length)
-
- if e1 != 0 {
- err = e1
- }
- return
-}
-
func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno)
// SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions
// of darwin/386 the syscall is called sysctl instead of __sysctl.
const SYS___SYSCTL = SYS_SYSCTL
+
+//sys Fstat(fd int, stat *Stat_t) (err error) = SYS_FSTAT64
+//sys Fstatat(fd int, path string, stat *Stat_t, flags int) (err error) = SYS_FSTATAT64
+//sys Fstatfs(fd int, stat *Statfs_t) (err error) = SYS_FSTATFS64
+//sys Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) = SYS_GETDIRENTRIES64
+//sys getfsstat(buf unsafe.Pointer, size uintptr, flags int) (n int, err error) = SYS_GETFSSTAT64
+//sys Lstat(path string, stat *Stat_t) (err error) = SYS_LSTAT64
+//sys Stat(path string, stat *Stat_t) (err error) = SYS_STAT64
+//sys Statfs(path string, stat *Statfs_t) (err error) = SYS_STATFS64
diff --git a/vendor/golang.org/x/sys/unix/syscall_darwin_amd64.go b/vendor/golang.org/x/sys/unix/syscall_darwin_amd64.go
index 75219444a..914b89bde 100644
--- a/vendor/golang.org/x/sys/unix/syscall_darwin_amd64.go
+++ b/vendor/golang.org/x/sys/unix/syscall_darwin_amd64.go
@@ -8,7 +8,6 @@ package unix
import (
"syscall"
- "unsafe"
)
func setTimespec(sec, nsec int64) Timespec {
@@ -48,21 +47,17 @@ func (cmsg *Cmsghdr) SetLen(length int) {
cmsg.Len = uint32(length)
}
-func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
- var length = uint64(count)
-
- _, _, e1 := Syscall6(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(unsafe.Pointer(&length)), 0, 0)
-
- written = int(length)
-
- if e1 != 0 {
- err = e1
- }
- return
-}
-
func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno)
// SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions
// of darwin/amd64 the syscall is called sysctl instead of __sysctl.
const SYS___SYSCTL = SYS_SYSCTL
+
+//sys Fstat(fd int, stat *Stat_t) (err error) = SYS_FSTAT64
+//sys Fstatat(fd int, path string, stat *Stat_t, flags int) (err error) = SYS_FSTATAT64
+//sys Fstatfs(fd int, stat *Statfs_t) (err error) = SYS_FSTATFS64
+//sys Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) = SYS_GETDIRENTRIES64
+//sys getfsstat(buf unsafe.Pointer, size uintptr, flags int) (n int, err error) = SYS_GETFSSTAT64
+//sys Lstat(path string, stat *Stat_t) (err error) = SYS_LSTAT64
+//sys Stat(path string, stat *Stat_t) (err error) = SYS_STAT64
+//sys Statfs(path string, stat *Statfs_t) (err error) = SYS_STATFS64
diff --git a/vendor/golang.org/x/sys/unix/syscall_darwin_arm.go b/vendor/golang.org/x/sys/unix/syscall_darwin_arm.go
index faae207a4..4a284cf50 100644
--- a/vendor/golang.org/x/sys/unix/syscall_darwin_arm.go
+++ b/vendor/golang.org/x/sys/unix/syscall_darwin_arm.go
@@ -6,7 +6,6 @@ package unix
import (
"syscall"
- "unsafe"
)
func setTimespec(sec, nsec int64) Timespec {
@@ -46,21 +45,20 @@ func (cmsg *Cmsghdr) SetLen(length int) {
cmsg.Len = uint32(length)
}
-func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
- var length = uint64(count)
-
- _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(*offset>>32), uintptr(unsafe.Pointer(&length)), 0, 0, 0, 0)
-
- written = int(length)
-
- if e1 != 0 {
- err = e1
- }
- return
-}
-
func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) // sic
// SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions
// of darwin/arm the syscall is called sysctl instead of __sysctl.
const SYS___SYSCTL = SYS_SYSCTL
+
+//sys Fstat(fd int, stat *Stat_t) (err error)
+//sys Fstatat(fd int, path string, stat *Stat_t, flags int) (err error)
+//sys Fstatfs(fd int, stat *Statfs_t) (err error)
+//sys getfsstat(buf unsafe.Pointer, size uintptr, flags int) (n int, err error) = SYS_GETFSSTAT
+//sys Lstat(path string, stat *Stat_t) (err error)
+//sys Stat(path string, stat *Stat_t) (err error)
+//sys Statfs(path string, stat *Statfs_t) (err error)
+
+func Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) {
+ return 0, ENOSYS
+}
diff --git a/vendor/golang.org/x/sys/unix/syscall_darwin_arm64.go b/vendor/golang.org/x/sys/unix/syscall_darwin_arm64.go
index d6d962801..52dcd88f6 100644
--- a/vendor/golang.org/x/sys/unix/syscall_darwin_arm64.go
+++ b/vendor/golang.org/x/sys/unix/syscall_darwin_arm64.go
@@ -8,7 +8,6 @@ package unix
import (
"syscall"
- "unsafe"
)
func setTimespec(sec, nsec int64) Timespec {
@@ -48,21 +47,20 @@ func (cmsg *Cmsghdr) SetLen(length int) {
cmsg.Len = uint32(length)
}
-func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
- var length = uint64(count)
-
- _, _, e1 := Syscall6(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(unsafe.Pointer(&length)), 0, 0)
-
- written = int(length)
-
- if e1 != 0 {
- err = e1
- }
- return
-}
-
func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) // sic
// SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions
// of darwin/arm64 the syscall is called sysctl instead of __sysctl.
const SYS___SYSCTL = SYS_SYSCTL
+
+//sys Fstat(fd int, stat *Stat_t) (err error)
+//sys Fstatat(fd int, path string, stat *Stat_t, flags int) (err error)
+//sys Fstatfs(fd int, stat *Statfs_t) (err error)
+//sys getfsstat(buf unsafe.Pointer, size uintptr, flags int) (n int, err error) = SYS_GETFSSTAT
+//sys Lstat(path string, stat *Stat_t) (err error)
+//sys Stat(path string, stat *Stat_t) (err error)
+//sys Statfs(path string, stat *Statfs_t) (err error)
+
+func Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) {
+ return 0, ENOSYS
+}
diff --git a/vendor/golang.org/x/sys/unix/syscall_darwin_libSystem.go b/vendor/golang.org/x/sys/unix/syscall_darwin_libSystem.go
new file mode 100644
index 000000000..4b4ae460f
--- /dev/null
+++ b/vendor/golang.org/x/sys/unix/syscall_darwin_libSystem.go
@@ -0,0 +1,31 @@
+// Copyright 2018 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build darwin,go1.12
+
+package unix
+
+import "unsafe"
+
+// Implemented in the runtime package (runtime/sys_darwin.go)
+func syscall_syscall(fn, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno)
+func syscall_syscall6(fn, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno)
+func syscall_syscall6X(fn, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno)
+func syscall_syscall9(fn, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err Errno) // 32-bit only
+func syscall_rawSyscall(fn, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno)
+func syscall_rawSyscall6(fn, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno)
+
+//go:linkname syscall_syscall syscall.syscall
+//go:linkname syscall_syscall6 syscall.syscall6
+//go:linkname syscall_syscall6X syscall.syscall6X
+//go:linkname syscall_syscall9 syscall.syscall9
+//go:linkname syscall_rawSyscall syscall.rawSyscall
+//go:linkname syscall_rawSyscall6 syscall.rawSyscall6
+
+// Find the entry point for f. See comments in runtime/proc.go for the
+// function of the same name.
+//go:nosplit
+func funcPC(f func()) uintptr {
+ return **(**uintptr)(unsafe.Pointer(&f))
+}
diff --git a/vendor/golang.org/x/sys/unix/syscall_dragonfly.go b/vendor/golang.org/x/sys/unix/syscall_dragonfly.go
index 756510575..891c94d7e 100644
--- a/vendor/golang.org/x/sys/unix/syscall_dragonfly.go
+++ b/vendor/golang.org/x/sys/unix/syscall_dragonfly.go
@@ -234,6 +234,13 @@ func Uname(uname *Utsname) error {
return nil
}
+func Sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
+ if raceenabled {
+ raceReleaseMerge(unsafe.Pointer(&ioSync))
+ }
+ return sendfile(outfd, infd, offset, count)
+}
+
/*
* Exposed directly
*/
diff --git a/vendor/golang.org/x/sys/unix/syscall_freebsd.go b/vendor/golang.org/x/sys/unix/syscall_freebsd.go
index 085a808cc..a7ca1ebea 100644
--- a/vendor/golang.org/x/sys/unix/syscall_freebsd.go
+++ b/vendor/golang.org/x/sys/unix/syscall_freebsd.go
@@ -500,6 +500,13 @@ func convertFromDirents11(buf []byte, old []byte) int {
return dstPos
}
+func Sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
+ if raceenabled {
+ raceReleaseMerge(unsafe.Pointer(&ioSync))
+ }
+ return sendfile(outfd, infd, offset, count)
+}
+
/*
* Exposed directly
*/
diff --git a/vendor/golang.org/x/sys/unix/syscall_linux.go b/vendor/golang.org/x/sys/unix/syscall_linux.go
index 84aa8ea03..776040233 100644
--- a/vendor/golang.org/x/sys/unix/syscall_linux.go
+++ b/vendor/golang.org/x/sys/unix/syscall_linux.go
@@ -12,6 +12,8 @@
package unix
import (
+ "encoding/binary"
+ "net"
"syscall"
"unsafe"
)
@@ -55,6 +57,15 @@ func Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) {
// ioctl itself should not be exposed directly, but additional get/set
// functions for specific types are permissible.
+// IoctlSetPointerInt performs an ioctl operation which sets an
+// integer value on fd, using the specified request number. The ioctl
+// argument is called with a pointer to the integer value, rather than
+// passing the integer value directly.
+func IoctlSetPointerInt(fd int, req uint, value int) error {
+ v := int32(value)
+ return ioctl(fd, req, uintptr(unsafe.Pointer(&v)))
+}
+
// IoctlSetInt performs an ioctl operation which sets an integer value
// on fd, using the specified request number.
func IoctlSetInt(fd int, req uint, value int) error {
@@ -710,6 +721,51 @@ func (sa *SockaddrXDP) sockaddr() (unsafe.Pointer, _Socklen, error) {
return unsafe.Pointer(&sa.raw), SizeofSockaddrXDP, nil
}
+// This constant mirrors the #define of PX_PROTO_OE in
+// linux/if_pppox.h. We're defining this by hand here instead of
+// autogenerating through mkerrors.sh because including
+// linux/if_pppox.h causes some declaration conflicts with other
+// includes (linux/if_pppox.h includes linux/in.h, which conflicts
+// with netinet/in.h). Given that we only need a single zero constant
+// out of that file, it's cleaner to just define it by hand here.
+const px_proto_oe = 0
+
+type SockaddrPPPoE struct {
+ SID uint16
+ Remote net.HardwareAddr
+ Dev string
+ raw RawSockaddrPPPoX
+}
+
+func (sa *SockaddrPPPoE) sockaddr() (unsafe.Pointer, _Socklen, error) {
+ if len(sa.Remote) != 6 {
+ return nil, 0, EINVAL
+ }
+ if len(sa.Dev) > IFNAMSIZ-1 {
+ return nil, 0, EINVAL
+ }
+
+ *(*uint16)(unsafe.Pointer(&sa.raw[0])) = AF_PPPOX
+ // This next field is in host-endian byte order. We can't use the
+ // same unsafe pointer cast as above, because this value is not
+ // 32-bit aligned and some architectures don't allow unaligned
+ // access.
+ //
+ // However, the value of px_proto_oe is 0, so we can use
+ // encoding/binary helpers to write the bytes without worrying
+ // about the ordering.
+ binary.BigEndian.PutUint32(sa.raw[2:6], px_proto_oe)
+ // This field is deliberately big-endian, unlike the previous
+ // one. The kernel expects SID to be in network byte order.
+ binary.BigEndian.PutUint16(sa.raw[6:8], sa.SID)
+ copy(sa.raw[8:14], sa.Remote)
+ for i := 14; i < 14+IFNAMSIZ; i++ {
+ sa.raw[i] = 0
+ }
+ copy(sa.raw[14:], sa.Dev)
+ return unsafe.Pointer(&sa.raw), SizeofSockaddrPPPoX, nil
+}
+
func anyToSockaddr(fd int, rsa *RawSockaddrAny) (Sockaddr, error) {
switch rsa.Addr.Family {
case AF_NETLINK:
@@ -820,6 +876,22 @@ func anyToSockaddr(fd int, rsa *RawSockaddrAny) (Sockaddr, error) {
SharedUmemFD: pp.Shared_umem_fd,
}
return sa, nil
+ case AF_PPPOX:
+ pp := (*RawSockaddrPPPoX)(unsafe.Pointer(rsa))
+ if binary.BigEndian.Uint32(pp[2:6]) != px_proto_oe {
+ return nil, EINVAL
+ }
+ sa := &SockaddrPPPoE{
+ SID: binary.BigEndian.Uint16(pp[6:8]),
+ Remote: net.HardwareAddr(pp[8:14]),
+ }
+ for i := 14; i < 14+IFNAMSIZ; i++ {
+ if pp[i] == 0 {
+ sa.Dev = string(pp[14:i])
+ break
+ }
+ }
+ return sa, nil
}
return nil, EAFNOSUPPORT
}
@@ -1288,6 +1360,13 @@ func Mount(source string, target string, fstype string, flags uintptr, data stri
return mount(source, target, fstype, flags, datap)
}
+func Sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
+ if raceenabled {
+ raceReleaseMerge(unsafe.Pointer(&ioSync))
+ }
+ return sendfile(outfd, infd, offset, count)
+}
+
// Sendto
// Recvfrom
// Socketpair
@@ -1431,15 +1510,12 @@ func Munmap(b []byte) (err error) {
// Vmsplice splices user pages from a slice of Iovecs into a pipe specified by fd,
// using the specified flags.
func Vmsplice(fd int, iovs []Iovec, flags int) (int, error) {
- n, _, errno := Syscall6(
- SYS_VMSPLICE,
- uintptr(fd),
- uintptr(unsafe.Pointer(&iovs[0])),
- uintptr(len(iovs)),
- uintptr(flags),
- 0,
- 0,
- )
+ var p unsafe.Pointer
+ if len(iovs) > 0 {
+ p = unsafe.Pointer(&iovs[0])
+ }
+
+ n, _, errno := Syscall6(SYS_VMSPLICE, uintptr(fd), uintptr(p), uintptr(len(iovs)), uintptr(flags), 0, 0)
if errno != 0 {
return 0, syscall.Errno(errno)
}
diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_amd64.go b/vendor/golang.org/x/sys/unix/syscall_linux_amd64.go
index 5247d9f90..615f2918a 100644
--- a/vendor/golang.org/x/sys/unix/syscall_linux_amd64.go
+++ b/vendor/golang.org/x/sys/unix/syscall_linux_amd64.go
@@ -20,12 +20,26 @@ package unix
//sysnb Getgid() (gid int)
//sysnb Getrlimit(resource int, rlim *Rlimit) (err error)
//sysnb Getuid() (uid int)
-//sysnb InotifyInit() (fd int, err error)
+//sysnb inotifyInit() (fd int, err error)
+
+func InotifyInit() (fd int, err error) {
+ // First try inotify_init1, because Android's seccomp policy blocks the latter.
+ fd, err = InotifyInit1(0)
+ if err == ENOSYS {
+ fd, err = inotifyInit()
+ }
+ return
+}
+
//sys Ioperm(from int, num int, on int) (err error)
//sys Iopl(level int) (err error)
//sys Lchown(path string, uid int, gid int) (err error)
//sys Listen(s int, n int) (err error)
-//sys Lstat(path string, stat *Stat_t) (err error)
+
+func Lstat(path string, stat *Stat_t) (err error) {
+ return Fstatat(AT_FDCWD, path, stat, AT_SYMLINK_NOFOLLOW)
+}
+
//sys Pause() (err error)
//sys Pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64
//sys Pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64
diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_arm.go b/vendor/golang.org/x/sys/unix/syscall_linux_arm.go
index 3ec7a9329..ad2bd2582 100644
--- a/vendor/golang.org/x/sys/unix/syscall_linux_arm.go
+++ b/vendor/golang.org/x/sys/unix/syscall_linux_arm.go
@@ -257,3 +257,11 @@ func Poll(fds []PollFd, timeout int) (n int, err error) {
}
return poll(&fds[0], len(fds), timeout)
}
+
+//sys armSyncFileRange(fd int, flags int, off int64, n int64) (err error) = SYS_ARM_SYNC_FILE_RANGE
+
+func SyncFileRange(fd int, off int64, n int64, flags int) error {
+ // The sync_file_range and arm_sync_file_range syscalls differ only in the
+ // order of their arguments.
+ return armSyncFileRange(fd, flags, off, n)
+}
diff --git a/vendor/golang.org/x/sys/unix/syscall_netbsd.go b/vendor/golang.org/x/sys/unix/syscall_netbsd.go
index b711aca82..5240e16e4 100644
--- a/vendor/golang.org/x/sys/unix/syscall_netbsd.go
+++ b/vendor/golang.org/x/sys/unix/syscall_netbsd.go
@@ -13,6 +13,7 @@
package unix
import (
+ "runtime"
"syscall"
"unsafe"
)
@@ -190,6 +191,13 @@ func IoctlGetTermios(fd int, req uint) (*Termios, error) {
return &value, err
}
+func IoctlGetPtmget(fd int, req uint) (*Ptmget, error) {
+ var value Ptmget
+ err := ioctl(fd, req, uintptr(unsafe.Pointer(&value)))
+ runtime.KeepAlive(value)
+ return &value, err
+}
+
func Uname(uname *Utsname) error {
mib := []_C_int{CTL_KERN, KERN_OSTYPE}
n := unsafe.Sizeof(uname.Sysname)
@@ -236,6 +244,13 @@ func Uname(uname *Utsname) error {
return nil
}
+func Sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
+ if raceenabled {
+ raceReleaseMerge(unsafe.Pointer(&ioSync))
+ }
+ return sendfile(outfd, infd, offset, count)
+}
+
/*
* Exposed directly
*/
diff --git a/vendor/golang.org/x/sys/unix/syscall_openbsd.go b/vendor/golang.org/x/sys/unix/syscall_openbsd.go
index 5a398f817..687999549 100644
--- a/vendor/golang.org/x/sys/unix/syscall_openbsd.go
+++ b/vendor/golang.org/x/sys/unix/syscall_openbsd.go
@@ -94,6 +94,13 @@ func Getwd() (string, error) {
return string(buf[:n]), nil
}
+func Sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
+ if raceenabled {
+ raceReleaseMerge(unsafe.Pointer(&ioSync))
+ }
+ return sendfile(outfd, infd, offset, count)
+}
+
// TODO
func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
return -1, ENOSYS
diff --git a/vendor/golang.org/x/sys/unix/syscall_solaris.go b/vendor/golang.org/x/sys/unix/syscall_solaris.go
index 53b807828..e47801275 100644
--- a/vendor/golang.org/x/sys/unix/syscall_solaris.go
+++ b/vendor/golang.org/x/sys/unix/syscall_solaris.go
@@ -585,6 +585,13 @@ func Poll(fds []PollFd, timeout int) (n int, err error) {
return poll(&fds[0], len(fds), timeout)
}
+func Sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
+ if raceenabled {
+ raceReleaseMerge(unsafe.Pointer(&ioSync))
+ }
+ return sendfile(outfd, infd, offset, count)
+}
+
/*
* Exposed directly
*/
diff --git a/vendor/golang.org/x/sys/unix/syscall_unix.go b/vendor/golang.org/x/sys/unix/syscall_unix.go
index 64fcda4ae..33583a22b 100644
--- a/vendor/golang.org/x/sys/unix/syscall_unix.go
+++ b/vendor/golang.org/x/sys/unix/syscall_unix.go
@@ -8,7 +8,6 @@ package unix
import (
"bytes"
- "runtime"
"sort"
"sync"
"syscall"
@@ -21,13 +20,6 @@ var (
Stderr = 2
)
-const (
- darwin64Bit = runtime.GOOS == "darwin" && SizeofPtr == 8
- dragonfly64Bit = runtime.GOOS == "dragonfly" && SizeofPtr == 8
- netbsd32Bit = runtime.GOOS == "netbsd" && SizeofPtr == 4
- solaris64Bit = runtime.GOOS == "solaris" && SizeofPtr == 8
-)
-
// Do the interface allocations only once for common
// Errno values.
var (
@@ -359,13 +351,6 @@ func Socketpair(domain, typ, proto int) (fd [2]int, err error) {
return
}
-func Sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
- if raceenabled {
- raceReleaseMerge(unsafe.Pointer(&ioSync))
- }
- return sendfile(outfd, infd, offset, count)
-}
-
var ioSync int64
func CloseOnExec(fd int) { fcntl(fd, F_SETFD, FD_CLOEXEC) }
diff --git a/vendor/golang.org/x/sys/unix/syscall_unix_gc.go b/vendor/golang.org/x/sys/unix/syscall_unix_gc.go
index 4cb8e8edf..1c70d1b69 100644
--- a/vendor/golang.org/x/sys/unix/syscall_unix_gc.go
+++ b/vendor/golang.org/x/sys/unix/syscall_unix_gc.go
@@ -3,7 +3,7 @@
// license that can be found in the LICENSE file.
// +build darwin dragonfly freebsd linux netbsd openbsd solaris
-// +build !gccgo
+// +build !gccgo,!ppc64le,!ppc64
package unix
diff --git a/vendor/golang.org/x/sys/unix/syscall_unix_gc_ppc64x.go b/vendor/golang.org/x/sys/unix/syscall_unix_gc_ppc64x.go
new file mode 100644
index 000000000..86dc765ab
--- /dev/null
+++ b/vendor/golang.org/x/sys/unix/syscall_unix_gc_ppc64x.go
@@ -0,0 +1,24 @@
+// Copyright 2018 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build linux
+// +build ppc64le ppc64
+// +build !gccgo
+
+package unix
+
+import "syscall"
+
+func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) {
+ return syscall.Syscall(trap, a1, a2, a3)
+}
+func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) {
+ return syscall.Syscall6(trap, a1, a2, a3, a4, a5, a6)
+}
+func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) {
+ return syscall.RawSyscall(trap, a1, a2, a3)
+}
+func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) {
+ return syscall.RawSyscall6(trap, a1, a2, a3, a4, a5, a6)
+}
diff --git a/vendor/golang.org/x/sys/unix/types_freebsd.go b/vendor/golang.org/x/sys/unix/types_freebsd.go
index 8421ccf1c..747079895 100644
--- a/vendor/golang.org/x/sys/unix/types_freebsd.go
+++ b/vendor/golang.org/x/sys/unix/types_freebsd.go
@@ -26,7 +26,7 @@ package unix
#include
#include
#include
-#include
+#include
#include
#include
#include
diff --git a/vendor/golang.org/x/sys/unix/types_netbsd.go b/vendor/golang.org/x/sys/unix/types_netbsd.go
index 1edbf1ba7..2dd4f9542 100644
--- a/vendor/golang.org/x/sys/unix/types_netbsd.go
+++ b/vendor/golang.org/x/sys/unix/types_netbsd.go
@@ -248,6 +248,8 @@ type Termios C.struct_termios
type Winsize C.struct_winsize
+type Ptmget C.struct_ptmget
+
// fchmodat-like syscalls.
const (
diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_386.go b/vendor/golang.org/x/sys/unix/zerrors_linux_386.go
index 673152b94..db3c31ef8 100644
--- a/vendor/golang.org/x/sys/unix/zerrors_linux_386.go
+++ b/vendor/golang.org/x/sys/unix/zerrors_linux_386.go
@@ -1293,6 +1293,36 @@ const (
PERF_EVENT_IOC_SET_FILTER = 0x40042406
PERF_EVENT_IOC_SET_OUTPUT = 0x2405
PIPEFS_MAGIC = 0x50495045
+ PPPIOCATTACH = 0x4004743d
+ PPPIOCATTCHAN = 0x40047438
+ PPPIOCCONNECT = 0x4004743a
+ PPPIOCDETACH = 0x4004743c
+ PPPIOCDISCONN = 0x7439
+ PPPIOCGASYNCMAP = 0x80047458
+ PPPIOCGCHAN = 0x80047437
+ PPPIOCGDEBUG = 0x80047441
+ PPPIOCGFLAGS = 0x8004745a
+ PPPIOCGIDLE = 0x8008743f
+ PPPIOCGL2TPSTATS = 0x80487436
+ PPPIOCGMRU = 0x80047453
+ PPPIOCGNPMODE = 0xc008744c
+ PPPIOCGRASYNCMAP = 0x80047455
+ PPPIOCGUNIT = 0x80047456
+ PPPIOCGXASYNCMAP = 0x80207450
+ PPPIOCNEWUNIT = 0xc004743e
+ PPPIOCSACTIVE = 0x40087446
+ PPPIOCSASYNCMAP = 0x40047457
+ PPPIOCSCOMPRESS = 0x400c744d
+ PPPIOCSDEBUG = 0x40047440
+ PPPIOCSFLAGS = 0x40047459
+ PPPIOCSMAXCID = 0x40047451
+ PPPIOCSMRRU = 0x4004743b
+ PPPIOCSMRU = 0x40047452
+ PPPIOCSNPMODE = 0x4008744b
+ PPPIOCSPASS = 0x40087447
+ PPPIOCSRASYNCMAP = 0x40047454
+ PPPIOCSXASYNCMAP = 0x4020744f
+ PPPIOCXFERUNIT = 0x744e
PRIO_PGRP = 0x1
PRIO_PROCESS = 0x0
PRIO_USER = 0x2
@@ -1696,6 +1726,7 @@ const (
SCM_TIMESTAMPNS = 0x23
SCM_TXTIME = 0x3d
SCM_WIFI_STATUS = 0x29
+ SC_LOG_FLUSH = 0x100000
SECCOMP_MODE_DISABLED = 0x0
SECCOMP_MODE_FILTER = 0x2
SECCOMP_MODE_STRICT = 0x1
@@ -1751,6 +1782,9 @@ const (
SIOCGMIIPHY = 0x8947
SIOCGMIIREG = 0x8948
SIOCGPGRP = 0x8904
+ SIOCGPPPCSTATS = 0x89f2
+ SIOCGPPPSTATS = 0x89f0
+ SIOCGPPPVER = 0x89f1
SIOCGRARP = 0x8961
SIOCGSKNS = 0x894c
SIOCGSTAMP = 0x8906
diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go
index 5735bcf3c..4785835b6 100644
--- a/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go
+++ b/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go
@@ -1293,6 +1293,36 @@ const (
PERF_EVENT_IOC_SET_FILTER = 0x40082406
PERF_EVENT_IOC_SET_OUTPUT = 0x2405
PIPEFS_MAGIC = 0x50495045
+ PPPIOCATTACH = 0x4004743d
+ PPPIOCATTCHAN = 0x40047438
+ PPPIOCCONNECT = 0x4004743a
+ PPPIOCDETACH = 0x4004743c
+ PPPIOCDISCONN = 0x7439
+ PPPIOCGASYNCMAP = 0x80047458
+ PPPIOCGCHAN = 0x80047437
+ PPPIOCGDEBUG = 0x80047441
+ PPPIOCGFLAGS = 0x8004745a
+ PPPIOCGIDLE = 0x8010743f
+ PPPIOCGL2TPSTATS = 0x80487436
+ PPPIOCGMRU = 0x80047453
+ PPPIOCGNPMODE = 0xc008744c
+ PPPIOCGRASYNCMAP = 0x80047455
+ PPPIOCGUNIT = 0x80047456
+ PPPIOCGXASYNCMAP = 0x80207450
+ PPPIOCNEWUNIT = 0xc004743e
+ PPPIOCSACTIVE = 0x40107446
+ PPPIOCSASYNCMAP = 0x40047457
+ PPPIOCSCOMPRESS = 0x4010744d
+ PPPIOCSDEBUG = 0x40047440
+ PPPIOCSFLAGS = 0x40047459
+ PPPIOCSMAXCID = 0x40047451
+ PPPIOCSMRRU = 0x4004743b
+ PPPIOCSMRU = 0x40047452
+ PPPIOCSNPMODE = 0x4008744b
+ PPPIOCSPASS = 0x40107447
+ PPPIOCSRASYNCMAP = 0x40047454
+ PPPIOCSXASYNCMAP = 0x4020744f
+ PPPIOCXFERUNIT = 0x744e
PRIO_PGRP = 0x1
PRIO_PROCESS = 0x0
PRIO_USER = 0x2
@@ -1697,6 +1727,7 @@ const (
SCM_TIMESTAMPNS = 0x23
SCM_TXTIME = 0x3d
SCM_WIFI_STATUS = 0x29
+ SC_LOG_FLUSH = 0x100000
SECCOMP_MODE_DISABLED = 0x0
SECCOMP_MODE_FILTER = 0x2
SECCOMP_MODE_STRICT = 0x1
@@ -1752,6 +1783,9 @@ const (
SIOCGMIIPHY = 0x8947
SIOCGMIIREG = 0x8948
SIOCGPGRP = 0x8904
+ SIOCGPPPCSTATS = 0x89f2
+ SIOCGPPPSTATS = 0x89f0
+ SIOCGPPPVER = 0x89f1
SIOCGRARP = 0x8961
SIOCGSKNS = 0x894c
SIOCGSTAMP = 0x8906
diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go b/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go
index d8e8442e5..5e902423a 100644
--- a/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go
+++ b/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go
@@ -1291,6 +1291,36 @@ const (
PERF_EVENT_IOC_SET_FILTER = 0x40042406
PERF_EVENT_IOC_SET_OUTPUT = 0x2405
PIPEFS_MAGIC = 0x50495045
+ PPPIOCATTACH = 0x4004743d
+ PPPIOCATTCHAN = 0x40047438
+ PPPIOCCONNECT = 0x4004743a
+ PPPIOCDETACH = 0x4004743c
+ PPPIOCDISCONN = 0x7439
+ PPPIOCGASYNCMAP = 0x80047458
+ PPPIOCGCHAN = 0x80047437
+ PPPIOCGDEBUG = 0x80047441
+ PPPIOCGFLAGS = 0x8004745a
+ PPPIOCGIDLE = 0x8008743f
+ PPPIOCGL2TPSTATS = 0x80487436
+ PPPIOCGMRU = 0x80047453
+ PPPIOCGNPMODE = 0xc008744c
+ PPPIOCGRASYNCMAP = 0x80047455
+ PPPIOCGUNIT = 0x80047456
+ PPPIOCGXASYNCMAP = 0x80207450
+ PPPIOCNEWUNIT = 0xc004743e
+ PPPIOCSACTIVE = 0x40087446
+ PPPIOCSASYNCMAP = 0x40047457
+ PPPIOCSCOMPRESS = 0x400c744d
+ PPPIOCSDEBUG = 0x40047440
+ PPPIOCSFLAGS = 0x40047459
+ PPPIOCSMAXCID = 0x40047451
+ PPPIOCSMRRU = 0x4004743b
+ PPPIOCSMRU = 0x40047452
+ PPPIOCSNPMODE = 0x4008744b
+ PPPIOCSPASS = 0x40087447
+ PPPIOCSRASYNCMAP = 0x40047454
+ PPPIOCSXASYNCMAP = 0x4020744f
+ PPPIOCXFERUNIT = 0x744e
PRIO_PGRP = 0x1
PRIO_PROCESS = 0x0
PRIO_USER = 0x2
@@ -1703,6 +1733,7 @@ const (
SCM_TIMESTAMPNS = 0x23
SCM_TXTIME = 0x3d
SCM_WIFI_STATUS = 0x29
+ SC_LOG_FLUSH = 0x100000
SECCOMP_MODE_DISABLED = 0x0
SECCOMP_MODE_FILTER = 0x2
SECCOMP_MODE_STRICT = 0x1
@@ -1758,6 +1789,9 @@ const (
SIOCGMIIPHY = 0x8947
SIOCGMIIREG = 0x8948
SIOCGPGRP = 0x8904
+ SIOCGPPPCSTATS = 0x89f2
+ SIOCGPPPSTATS = 0x89f0
+ SIOCGPPPVER = 0x89f1
SIOCGRARP = 0x8961
SIOCGSKNS = 0x894c
SIOCGSTAMP = 0x8906
diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go
index 5d79b789b..ebe9d8b41 100644
--- a/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go
+++ b/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go
@@ -1294,6 +1294,36 @@ const (
PERF_EVENT_IOC_SET_FILTER = 0x40082406
PERF_EVENT_IOC_SET_OUTPUT = 0x2405
PIPEFS_MAGIC = 0x50495045
+ PPPIOCATTACH = 0x4004743d
+ PPPIOCATTCHAN = 0x40047438
+ PPPIOCCONNECT = 0x4004743a
+ PPPIOCDETACH = 0x4004743c
+ PPPIOCDISCONN = 0x7439
+ PPPIOCGASYNCMAP = 0x80047458
+ PPPIOCGCHAN = 0x80047437
+ PPPIOCGDEBUG = 0x80047441
+ PPPIOCGFLAGS = 0x8004745a
+ PPPIOCGIDLE = 0x8010743f
+ PPPIOCGL2TPSTATS = 0x80487436
+ PPPIOCGMRU = 0x80047453
+ PPPIOCGNPMODE = 0xc008744c
+ PPPIOCGRASYNCMAP = 0x80047455
+ PPPIOCGUNIT = 0x80047456
+ PPPIOCGXASYNCMAP = 0x80207450
+ PPPIOCNEWUNIT = 0xc004743e
+ PPPIOCSACTIVE = 0x40107446
+ PPPIOCSASYNCMAP = 0x40047457
+ PPPIOCSCOMPRESS = 0x4010744d
+ PPPIOCSDEBUG = 0x40047440
+ PPPIOCSFLAGS = 0x40047459
+ PPPIOCSMAXCID = 0x40047451
+ PPPIOCSMRRU = 0x4004743b
+ PPPIOCSMRU = 0x40047452
+ PPPIOCSNPMODE = 0x4008744b
+ PPPIOCSPASS = 0x40107447
+ PPPIOCSRASYNCMAP = 0x40047454
+ PPPIOCSXASYNCMAP = 0x4020744f
+ PPPIOCXFERUNIT = 0x744e
PRIO_PGRP = 0x1
PRIO_PROCESS = 0x0
PRIO_USER = 0x2
@@ -1687,6 +1717,7 @@ const (
SCM_TIMESTAMPNS = 0x23
SCM_TXTIME = 0x3d
SCM_WIFI_STATUS = 0x29
+ SC_LOG_FLUSH = 0x100000
SECCOMP_MODE_DISABLED = 0x0
SECCOMP_MODE_FILTER = 0x2
SECCOMP_MODE_STRICT = 0x1
@@ -1742,6 +1773,9 @@ const (
SIOCGMIIPHY = 0x8947
SIOCGMIIREG = 0x8948
SIOCGPGRP = 0x8904
+ SIOCGPPPCSTATS = 0x89f2
+ SIOCGPPPSTATS = 0x89f0
+ SIOCGPPPVER = 0x89f1
SIOCGRARP = 0x8961
SIOCGSKNS = 0x894c
SIOCGSTAMP = 0x8906
diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_mips.go b/vendor/golang.org/x/sys/unix/zerrors_linux_mips.go
index 3c91615c8..d467d211b 100644
--- a/vendor/golang.org/x/sys/unix/zerrors_linux_mips.go
+++ b/vendor/golang.org/x/sys/unix/zerrors_linux_mips.go
@@ -1291,6 +1291,36 @@ const (
PERF_EVENT_IOC_SET_FILTER = 0x80042406
PERF_EVENT_IOC_SET_OUTPUT = 0x20002405
PIPEFS_MAGIC = 0x50495045
+ PPPIOCATTACH = 0x8004743d
+ PPPIOCATTCHAN = 0x80047438
+ PPPIOCCONNECT = 0x8004743a
+ PPPIOCDETACH = 0x8004743c
+ PPPIOCDISCONN = 0x20007439
+ PPPIOCGASYNCMAP = 0x40047458
+ PPPIOCGCHAN = 0x40047437
+ PPPIOCGDEBUG = 0x40047441
+ PPPIOCGFLAGS = 0x4004745a
+ PPPIOCGIDLE = 0x4008743f
+ PPPIOCGL2TPSTATS = 0x40487436
+ PPPIOCGMRU = 0x40047453
+ PPPIOCGNPMODE = 0xc008744c
+ PPPIOCGRASYNCMAP = 0x40047455
+ PPPIOCGUNIT = 0x40047456
+ PPPIOCGXASYNCMAP = 0x40207450
+ PPPIOCNEWUNIT = 0xc004743e
+ PPPIOCSACTIVE = 0x80087446
+ PPPIOCSASYNCMAP = 0x80047457
+ PPPIOCSCOMPRESS = 0x800c744d
+ PPPIOCSDEBUG = 0x80047440
+ PPPIOCSFLAGS = 0x80047459
+ PPPIOCSMAXCID = 0x80047451
+ PPPIOCSMRRU = 0x8004743b
+ PPPIOCSMRU = 0x80047452
+ PPPIOCSNPMODE = 0x8008744b
+ PPPIOCSPASS = 0x80087447
+ PPPIOCSRASYNCMAP = 0x80047454
+ PPPIOCSXASYNCMAP = 0x8020744f
+ PPPIOCXFERUNIT = 0x2000744e
PRIO_PGRP = 0x1
PRIO_PROCESS = 0x0
PRIO_USER = 0x2
@@ -1696,6 +1726,7 @@ const (
SCM_TIMESTAMPNS = 0x23
SCM_TXTIME = 0x3d
SCM_WIFI_STATUS = 0x29
+ SC_LOG_FLUSH = 0x100000
SECCOMP_MODE_DISABLED = 0x0
SECCOMP_MODE_FILTER = 0x2
SECCOMP_MODE_STRICT = 0x1
@@ -1751,6 +1782,9 @@ const (
SIOCGMIIPHY = 0x8947
SIOCGMIIREG = 0x8948
SIOCGPGRP = 0x40047309
+ SIOCGPPPCSTATS = 0x89f2
+ SIOCGPPPSTATS = 0x89f0
+ SIOCGPPPVER = 0x89f1
SIOCGRARP = 0x8961
SIOCGSKNS = 0x894c
SIOCGSTAMP = 0x8906
diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go
index e1f86c1cd..9c293ed13 100644
--- a/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go
+++ b/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go
@@ -1291,6 +1291,36 @@ const (
PERF_EVENT_IOC_SET_FILTER = 0x80082406
PERF_EVENT_IOC_SET_OUTPUT = 0x20002405
PIPEFS_MAGIC = 0x50495045
+ PPPIOCATTACH = 0x8004743d
+ PPPIOCATTCHAN = 0x80047438
+ PPPIOCCONNECT = 0x8004743a
+ PPPIOCDETACH = 0x8004743c
+ PPPIOCDISCONN = 0x20007439
+ PPPIOCGASYNCMAP = 0x40047458
+ PPPIOCGCHAN = 0x40047437
+ PPPIOCGDEBUG = 0x40047441
+ PPPIOCGFLAGS = 0x4004745a
+ PPPIOCGIDLE = 0x4010743f
+ PPPIOCGL2TPSTATS = 0x40487436
+ PPPIOCGMRU = 0x40047453
+ PPPIOCGNPMODE = 0xc008744c
+ PPPIOCGRASYNCMAP = 0x40047455
+ PPPIOCGUNIT = 0x40047456
+ PPPIOCGXASYNCMAP = 0x40207450
+ PPPIOCNEWUNIT = 0xc004743e
+ PPPIOCSACTIVE = 0x80107446
+ PPPIOCSASYNCMAP = 0x80047457
+ PPPIOCSCOMPRESS = 0x8010744d
+ PPPIOCSDEBUG = 0x80047440
+ PPPIOCSFLAGS = 0x80047459
+ PPPIOCSMAXCID = 0x80047451
+ PPPIOCSMRRU = 0x8004743b
+ PPPIOCSMRU = 0x80047452
+ PPPIOCSNPMODE = 0x8008744b
+ PPPIOCSPASS = 0x80107447
+ PPPIOCSRASYNCMAP = 0x80047454
+ PPPIOCSXASYNCMAP = 0x8020744f
+ PPPIOCXFERUNIT = 0x2000744e
PRIO_PGRP = 0x1
PRIO_PROCESS = 0x0
PRIO_USER = 0x2
@@ -1696,6 +1726,7 @@ const (
SCM_TIMESTAMPNS = 0x23
SCM_TXTIME = 0x3d
SCM_WIFI_STATUS = 0x29
+ SC_LOG_FLUSH = 0x100000
SECCOMP_MODE_DISABLED = 0x0
SECCOMP_MODE_FILTER = 0x2
SECCOMP_MODE_STRICT = 0x1
@@ -1751,6 +1782,9 @@ const (
SIOCGMIIPHY = 0x8947
SIOCGMIIREG = 0x8948
SIOCGPGRP = 0x40047309
+ SIOCGPPPCSTATS = 0x89f2
+ SIOCGPPPSTATS = 0x89f0
+ SIOCGPPPVER = 0x89f1
SIOCGRARP = 0x8961
SIOCGSKNS = 0x894c
SIOCGSTAMP = 0x8906
diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go b/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go
index d09e3b68b..e2162508c 100644
--- a/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go
+++ b/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go
@@ -1291,6 +1291,36 @@ const (
PERF_EVENT_IOC_SET_FILTER = 0x80082406
PERF_EVENT_IOC_SET_OUTPUT = 0x20002405
PIPEFS_MAGIC = 0x50495045
+ PPPIOCATTACH = 0x8004743d
+ PPPIOCATTCHAN = 0x80047438
+ PPPIOCCONNECT = 0x8004743a
+ PPPIOCDETACH = 0x8004743c
+ PPPIOCDISCONN = 0x20007439
+ PPPIOCGASYNCMAP = 0x40047458
+ PPPIOCGCHAN = 0x40047437
+ PPPIOCGDEBUG = 0x40047441
+ PPPIOCGFLAGS = 0x4004745a
+ PPPIOCGIDLE = 0x4010743f
+ PPPIOCGL2TPSTATS = 0x40487436
+ PPPIOCGMRU = 0x40047453
+ PPPIOCGNPMODE = 0xc008744c
+ PPPIOCGRASYNCMAP = 0x40047455
+ PPPIOCGUNIT = 0x40047456
+ PPPIOCGXASYNCMAP = 0x40207450
+ PPPIOCNEWUNIT = 0xc004743e
+ PPPIOCSACTIVE = 0x80107446
+ PPPIOCSASYNCMAP = 0x80047457
+ PPPIOCSCOMPRESS = 0x8010744d
+ PPPIOCSDEBUG = 0x80047440
+ PPPIOCSFLAGS = 0x80047459
+ PPPIOCSMAXCID = 0x80047451
+ PPPIOCSMRRU = 0x8004743b
+ PPPIOCSMRU = 0x80047452
+ PPPIOCSNPMODE = 0x8008744b
+ PPPIOCSPASS = 0x80107447
+ PPPIOCSRASYNCMAP = 0x80047454
+ PPPIOCSXASYNCMAP = 0x8020744f
+ PPPIOCXFERUNIT = 0x2000744e
PRIO_PGRP = 0x1
PRIO_PROCESS = 0x0
PRIO_USER = 0x2
@@ -1696,6 +1726,7 @@ const (
SCM_TIMESTAMPNS = 0x23
SCM_TXTIME = 0x3d
SCM_WIFI_STATUS = 0x29
+ SC_LOG_FLUSH = 0x100000
SECCOMP_MODE_DISABLED = 0x0
SECCOMP_MODE_FILTER = 0x2
SECCOMP_MODE_STRICT = 0x1
@@ -1751,6 +1782,9 @@ const (
SIOCGMIIPHY = 0x8947
SIOCGMIIREG = 0x8948
SIOCGPGRP = 0x40047309
+ SIOCGPPPCSTATS = 0x89f2
+ SIOCGPPPSTATS = 0x89f0
+ SIOCGPPPVER = 0x89f1
SIOCGRARP = 0x8961
SIOCGSKNS = 0x894c
SIOCGSTAMP = 0x8906
diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go b/vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go
index f78108dfb..836c0c654 100644
--- a/vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go
+++ b/vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go
@@ -1291,6 +1291,36 @@ const (
PERF_EVENT_IOC_SET_FILTER = 0x80042406
PERF_EVENT_IOC_SET_OUTPUT = 0x20002405
PIPEFS_MAGIC = 0x50495045
+ PPPIOCATTACH = 0x8004743d
+ PPPIOCATTCHAN = 0x80047438
+ PPPIOCCONNECT = 0x8004743a
+ PPPIOCDETACH = 0x8004743c
+ PPPIOCDISCONN = 0x20007439
+ PPPIOCGASYNCMAP = 0x40047458
+ PPPIOCGCHAN = 0x40047437
+ PPPIOCGDEBUG = 0x40047441
+ PPPIOCGFLAGS = 0x4004745a
+ PPPIOCGIDLE = 0x4008743f
+ PPPIOCGL2TPSTATS = 0x40487436
+ PPPIOCGMRU = 0x40047453
+ PPPIOCGNPMODE = 0xc008744c
+ PPPIOCGRASYNCMAP = 0x40047455
+ PPPIOCGUNIT = 0x40047456
+ PPPIOCGXASYNCMAP = 0x40207450
+ PPPIOCNEWUNIT = 0xc004743e
+ PPPIOCSACTIVE = 0x80087446
+ PPPIOCSASYNCMAP = 0x80047457
+ PPPIOCSCOMPRESS = 0x800c744d
+ PPPIOCSDEBUG = 0x80047440
+ PPPIOCSFLAGS = 0x80047459
+ PPPIOCSMAXCID = 0x80047451
+ PPPIOCSMRRU = 0x8004743b
+ PPPIOCSMRU = 0x80047452
+ PPPIOCSNPMODE = 0x8008744b
+ PPPIOCSPASS = 0x80087447
+ PPPIOCSRASYNCMAP = 0x80047454
+ PPPIOCSXASYNCMAP = 0x8020744f
+ PPPIOCXFERUNIT = 0x2000744e
PRIO_PGRP = 0x1
PRIO_PROCESS = 0x0
PRIO_USER = 0x2
@@ -1696,6 +1726,7 @@ const (
SCM_TIMESTAMPNS = 0x23
SCM_TXTIME = 0x3d
SCM_WIFI_STATUS = 0x29
+ SC_LOG_FLUSH = 0x100000
SECCOMP_MODE_DISABLED = 0x0
SECCOMP_MODE_FILTER = 0x2
SECCOMP_MODE_STRICT = 0x1
@@ -1751,6 +1782,9 @@ const (
SIOCGMIIPHY = 0x8947
SIOCGMIIREG = 0x8948
SIOCGPGRP = 0x40047309
+ SIOCGPPPCSTATS = 0x89f2
+ SIOCGPPPSTATS = 0x89f0
+ SIOCGPPPVER = 0x89f1
SIOCGRARP = 0x8961
SIOCGSKNS = 0x894c
SIOCGSTAMP = 0x8906
diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go
index 8da57a99c..7ca618431 100644
--- a/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go
+++ b/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go
@@ -1292,6 +1292,36 @@ const (
PERF_EVENT_IOC_SET_FILTER = 0x80082406
PERF_EVENT_IOC_SET_OUTPUT = 0x20002405
PIPEFS_MAGIC = 0x50495045
+ PPPIOCATTACH = 0x8004743d
+ PPPIOCATTCHAN = 0x80047438
+ PPPIOCCONNECT = 0x8004743a
+ PPPIOCDETACH = 0x8004743c
+ PPPIOCDISCONN = 0x20007439
+ PPPIOCGASYNCMAP = 0x40047458
+ PPPIOCGCHAN = 0x40047437
+ PPPIOCGDEBUG = 0x40047441
+ PPPIOCGFLAGS = 0x4004745a
+ PPPIOCGIDLE = 0x4010743f
+ PPPIOCGL2TPSTATS = 0x40487436
+ PPPIOCGMRU = 0x40047453
+ PPPIOCGNPMODE = 0xc008744c
+ PPPIOCGRASYNCMAP = 0x40047455
+ PPPIOCGUNIT = 0x40047456
+ PPPIOCGXASYNCMAP = 0x40207450
+ PPPIOCNEWUNIT = 0xc004743e
+ PPPIOCSACTIVE = 0x80107446
+ PPPIOCSASYNCMAP = 0x80047457
+ PPPIOCSCOMPRESS = 0x8010744d
+ PPPIOCSDEBUG = 0x80047440
+ PPPIOCSFLAGS = 0x80047459
+ PPPIOCSMAXCID = 0x80047451
+ PPPIOCSMRRU = 0x8004743b
+ PPPIOCSMRU = 0x80047452
+ PPPIOCSNPMODE = 0x8008744b
+ PPPIOCSPASS = 0x80107447
+ PPPIOCSRASYNCMAP = 0x80047454
+ PPPIOCSXASYNCMAP = 0x8020744f
+ PPPIOCXFERUNIT = 0x2000744e
PRIO_PGRP = 0x1
PRIO_PROCESS = 0x0
PRIO_USER = 0x2
@@ -1752,6 +1782,7 @@ const (
SCM_TIMESTAMPNS = 0x23
SCM_TXTIME = 0x3d
SCM_WIFI_STATUS = 0x29
+ SC_LOG_FLUSH = 0x100000
SECCOMP_MODE_DISABLED = 0x0
SECCOMP_MODE_FILTER = 0x2
SECCOMP_MODE_STRICT = 0x1
@@ -1807,6 +1838,9 @@ const (
SIOCGMIIPHY = 0x8947
SIOCGMIIREG = 0x8948
SIOCGPGRP = 0x8904
+ SIOCGPPPCSTATS = 0x89f2
+ SIOCGPPPSTATS = 0x89f0
+ SIOCGPPPVER = 0x89f1
SIOCGRARP = 0x8961
SIOCGSKNS = 0x894c
SIOCGSTAMP = 0x8906
diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go b/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go
index 1832c0a7c..839ac214c 100644
--- a/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go
+++ b/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go
@@ -1292,6 +1292,36 @@ const (
PERF_EVENT_IOC_SET_FILTER = 0x80082406
PERF_EVENT_IOC_SET_OUTPUT = 0x20002405
PIPEFS_MAGIC = 0x50495045
+ PPPIOCATTACH = 0x8004743d
+ PPPIOCATTCHAN = 0x80047438
+ PPPIOCCONNECT = 0x8004743a
+ PPPIOCDETACH = 0x8004743c
+ PPPIOCDISCONN = 0x20007439
+ PPPIOCGASYNCMAP = 0x40047458
+ PPPIOCGCHAN = 0x40047437
+ PPPIOCGDEBUG = 0x40047441
+ PPPIOCGFLAGS = 0x4004745a
+ PPPIOCGIDLE = 0x4010743f
+ PPPIOCGL2TPSTATS = 0x40487436
+ PPPIOCGMRU = 0x40047453
+ PPPIOCGNPMODE = 0xc008744c
+ PPPIOCGRASYNCMAP = 0x40047455
+ PPPIOCGUNIT = 0x40047456
+ PPPIOCGXASYNCMAP = 0x40207450
+ PPPIOCNEWUNIT = 0xc004743e
+ PPPIOCSACTIVE = 0x80107446
+ PPPIOCSASYNCMAP = 0x80047457
+ PPPIOCSCOMPRESS = 0x8010744d
+ PPPIOCSDEBUG = 0x80047440
+ PPPIOCSFLAGS = 0x80047459
+ PPPIOCSMAXCID = 0x80047451
+ PPPIOCSMRRU = 0x8004743b
+ PPPIOCSMRU = 0x80047452
+ PPPIOCSNPMODE = 0x8008744b
+ PPPIOCSPASS = 0x80107447
+ PPPIOCSRASYNCMAP = 0x80047454
+ PPPIOCSXASYNCMAP = 0x8020744f
+ PPPIOCXFERUNIT = 0x2000744e
PRIO_PGRP = 0x1
PRIO_PROCESS = 0x0
PRIO_USER = 0x2
@@ -1752,6 +1782,7 @@ const (
SCM_TIMESTAMPNS = 0x23
SCM_TXTIME = 0x3d
SCM_WIFI_STATUS = 0x29
+ SC_LOG_FLUSH = 0x100000
SECCOMP_MODE_DISABLED = 0x0
SECCOMP_MODE_FILTER = 0x2
SECCOMP_MODE_STRICT = 0x1
@@ -1807,6 +1838,9 @@ const (
SIOCGMIIPHY = 0x8947
SIOCGMIIREG = 0x8948
SIOCGPGRP = 0x8904
+ SIOCGPPPCSTATS = 0x89f2
+ SIOCGPPPSTATS = 0x89f0
+ SIOCGPPPVER = 0x89f1
SIOCGRARP = 0x8961
SIOCGSKNS = 0x894c
SIOCGSTAMP = 0x8906
diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go
index c6bd4efff..a747aa1b7 100644
--- a/vendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go
+++ b/vendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go
@@ -1291,6 +1291,36 @@ const (
PERF_EVENT_IOC_SET_FILTER = 0x40082406
PERF_EVENT_IOC_SET_OUTPUT = 0x2405
PIPEFS_MAGIC = 0x50495045
+ PPPIOCATTACH = 0x4004743d
+ PPPIOCATTCHAN = 0x40047438
+ PPPIOCCONNECT = 0x4004743a
+ PPPIOCDETACH = 0x4004743c
+ PPPIOCDISCONN = 0x7439
+ PPPIOCGASYNCMAP = 0x80047458
+ PPPIOCGCHAN = 0x80047437
+ PPPIOCGDEBUG = 0x80047441
+ PPPIOCGFLAGS = 0x8004745a
+ PPPIOCGIDLE = 0x8010743f
+ PPPIOCGL2TPSTATS = 0x80487436
+ PPPIOCGMRU = 0x80047453
+ PPPIOCGNPMODE = 0xc008744c
+ PPPIOCGRASYNCMAP = 0x80047455
+ PPPIOCGUNIT = 0x80047456
+ PPPIOCGXASYNCMAP = 0x80207450
+ PPPIOCNEWUNIT = 0xc004743e
+ PPPIOCSACTIVE = 0x40107446
+ PPPIOCSASYNCMAP = 0x40047457
+ PPPIOCSCOMPRESS = 0x4010744d
+ PPPIOCSDEBUG = 0x40047440
+ PPPIOCSFLAGS = 0x40047459
+ PPPIOCSMAXCID = 0x40047451
+ PPPIOCSMRRU = 0x4004743b
+ PPPIOCSMRU = 0x40047452
+ PPPIOCSNPMODE = 0x4008744b
+ PPPIOCSPASS = 0x40107447
+ PPPIOCSRASYNCMAP = 0x40047454
+ PPPIOCSXASYNCMAP = 0x4020744f
+ PPPIOCXFERUNIT = 0x744e
PRIO_PGRP = 0x1
PRIO_PROCESS = 0x0
PRIO_USER = 0x2
@@ -1684,6 +1714,7 @@ const (
SCM_TIMESTAMPNS = 0x23
SCM_TXTIME = 0x3d
SCM_WIFI_STATUS = 0x29
+ SC_LOG_FLUSH = 0x100000
SECCOMP_MODE_DISABLED = 0x0
SECCOMP_MODE_FILTER = 0x2
SECCOMP_MODE_STRICT = 0x1
@@ -1739,6 +1770,9 @@ const (
SIOCGMIIPHY = 0x8947
SIOCGMIIREG = 0x8948
SIOCGPGRP = 0x8904
+ SIOCGPPPCSTATS = 0x89f2
+ SIOCGPPPSTATS = 0x89f0
+ SIOCGPPPVER = 0x89f1
SIOCGRARP = 0x8961
SIOCGSKNS = 0x894c
SIOCGSTAMP = 0x8906
diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go b/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go
index 8cdf353dc..96aff5083 100644
--- a/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go
+++ b/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go
@@ -1291,6 +1291,36 @@ const (
PERF_EVENT_IOC_SET_FILTER = 0x40082406
PERF_EVENT_IOC_SET_OUTPUT = 0x2405
PIPEFS_MAGIC = 0x50495045
+ PPPIOCATTACH = 0x4004743d
+ PPPIOCATTCHAN = 0x40047438
+ PPPIOCCONNECT = 0x4004743a
+ PPPIOCDETACH = 0x4004743c
+ PPPIOCDISCONN = 0x7439
+ PPPIOCGASYNCMAP = 0x80047458
+ PPPIOCGCHAN = 0x80047437
+ PPPIOCGDEBUG = 0x80047441
+ PPPIOCGFLAGS = 0x8004745a
+ PPPIOCGIDLE = 0x8010743f
+ PPPIOCGL2TPSTATS = 0x80487436
+ PPPIOCGMRU = 0x80047453
+ PPPIOCGNPMODE = 0xc008744c
+ PPPIOCGRASYNCMAP = 0x80047455
+ PPPIOCGUNIT = 0x80047456
+ PPPIOCGXASYNCMAP = 0x80207450
+ PPPIOCNEWUNIT = 0xc004743e
+ PPPIOCSACTIVE = 0x40107446
+ PPPIOCSASYNCMAP = 0x40047457
+ PPPIOCSCOMPRESS = 0x4010744d
+ PPPIOCSDEBUG = 0x40047440
+ PPPIOCSFLAGS = 0x40047459
+ PPPIOCSMAXCID = 0x40047451
+ PPPIOCSMRRU = 0x4004743b
+ PPPIOCSMRU = 0x40047452
+ PPPIOCSNPMODE = 0x4008744b
+ PPPIOCSPASS = 0x40107447
+ PPPIOCSRASYNCMAP = 0x40047454
+ PPPIOCSXASYNCMAP = 0x4020744f
+ PPPIOCXFERUNIT = 0x744e
PRIO_PGRP = 0x1
PRIO_PROCESS = 0x0
PRIO_USER = 0x2
@@ -1757,6 +1787,7 @@ const (
SCM_TIMESTAMPNS = 0x23
SCM_TXTIME = 0x3d
SCM_WIFI_STATUS = 0x29
+ SC_LOG_FLUSH = 0x100000
SECCOMP_MODE_DISABLED = 0x0
SECCOMP_MODE_FILTER = 0x2
SECCOMP_MODE_STRICT = 0x1
@@ -1812,6 +1843,9 @@ const (
SIOCGMIIPHY = 0x8947
SIOCGMIIREG = 0x8948
SIOCGPGRP = 0x8904
+ SIOCGPPPCSTATS = 0x89f2
+ SIOCGPPPSTATS = 0x89f0
+ SIOCGPPPVER = 0x89f1
SIOCGRARP = 0x8961
SIOCGSKNS = 0x894c
SIOCGSTAMP = 0x8906
diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go
index ba93f3e53..38cdd81a3 100644
--- a/vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go
+++ b/vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go
@@ -11,1782 +11,2426 @@ package unix
import "syscall"
const (
- AF_ALG = 0x26
- AF_APPLETALK = 0x5
- AF_ASH = 0x12
- AF_ATMPVC = 0x8
- AF_ATMSVC = 0x14
- AF_AX25 = 0x3
- AF_BLUETOOTH = 0x1f
- AF_BRIDGE = 0x7
- AF_CAIF = 0x25
- AF_CAN = 0x1d
- AF_DECnet = 0xc
- AF_ECONET = 0x13
- AF_FILE = 0x1
- AF_IB = 0x1b
- AF_IEEE802154 = 0x24
- AF_INET = 0x2
- AF_INET6 = 0xa
- AF_IPX = 0x4
- AF_IRDA = 0x17
- AF_ISDN = 0x22
- AF_IUCV = 0x20
- AF_KCM = 0x29
- AF_KEY = 0xf
- AF_LLC = 0x1a
- AF_LOCAL = 0x1
- AF_MAX = 0x2a
- AF_MPLS = 0x1c
- AF_NETBEUI = 0xd
- AF_NETLINK = 0x10
- AF_NETROM = 0x6
- AF_NFC = 0x27
- AF_PACKET = 0x11
- AF_PHONET = 0x23
- AF_PPPOX = 0x18
- AF_RDS = 0x15
- AF_ROSE = 0xb
- AF_ROUTE = 0x10
- AF_RXRPC = 0x21
- AF_SECURITY = 0xe
- AF_SNA = 0x16
- AF_TIPC = 0x1e
- AF_UNIX = 0x1
- AF_UNSPEC = 0x0
- AF_VSOCK = 0x28
- AF_WANPIPE = 0x19
- AF_X25 = 0x9
- ALG_OP_DECRYPT = 0x0
- ALG_OP_ENCRYPT = 0x1
- ALG_SET_AEAD_ASSOCLEN = 0x4
- ALG_SET_AEAD_AUTHSIZE = 0x5
- ALG_SET_IV = 0x2
- ALG_SET_KEY = 0x1
- ALG_SET_OP = 0x3
- ARPHRD_6LOWPAN = 0x339
- ARPHRD_ADAPT = 0x108
- ARPHRD_APPLETLK = 0x8
- ARPHRD_ARCNET = 0x7
- ARPHRD_ASH = 0x30d
- ARPHRD_ATM = 0x13
- ARPHRD_AX25 = 0x3
- ARPHRD_BIF = 0x307
- ARPHRD_CAIF = 0x336
- ARPHRD_CAN = 0x118
- ARPHRD_CHAOS = 0x5
- ARPHRD_CISCO = 0x201
- ARPHRD_CSLIP = 0x101
- ARPHRD_CSLIP6 = 0x103
- ARPHRD_DDCMP = 0x205
- ARPHRD_DLCI = 0xf
- ARPHRD_ECONET = 0x30e
- ARPHRD_EETHER = 0x2
- ARPHRD_ETHER = 0x1
- ARPHRD_EUI64 = 0x1b
- ARPHRD_FCAL = 0x311
- ARPHRD_FCFABRIC = 0x313
- ARPHRD_FCPL = 0x312
- ARPHRD_FCPP = 0x310
- ARPHRD_FDDI = 0x306
- ARPHRD_FRAD = 0x302
- ARPHRD_HDLC = 0x201
- ARPHRD_HIPPI = 0x30c
- ARPHRD_HWX25 = 0x110
- ARPHRD_IEEE1394 = 0x18
- ARPHRD_IEEE802 = 0x6
- ARPHRD_IEEE80211 = 0x321
- ARPHRD_IEEE80211_PRISM = 0x322
- ARPHRD_IEEE80211_RADIOTAP = 0x323
- ARPHRD_IEEE802154 = 0x324
- ARPHRD_IEEE802154_MONITOR = 0x325
- ARPHRD_IEEE802_TR = 0x320
- ARPHRD_INFINIBAND = 0x20
- ARPHRD_IP6GRE = 0x337
- ARPHRD_IPDDP = 0x309
- ARPHRD_IPGRE = 0x30a
- ARPHRD_IRDA = 0x30f
- ARPHRD_LAPB = 0x204
- ARPHRD_LOCALTLK = 0x305
- ARPHRD_LOOPBACK = 0x304
- ARPHRD_METRICOM = 0x17
- ARPHRD_NETLINK = 0x338
- ARPHRD_NETROM = 0x0
- ARPHRD_NONE = 0xfffe
- ARPHRD_PHONET = 0x334
- ARPHRD_PHONET_PIPE = 0x335
- ARPHRD_PIMREG = 0x30b
- ARPHRD_PPP = 0x200
- ARPHRD_PRONET = 0x4
- ARPHRD_RAWHDLC = 0x206
- ARPHRD_ROSE = 0x10e
- ARPHRD_RSRVD = 0x104
- ARPHRD_SIT = 0x308
- ARPHRD_SKIP = 0x303
- ARPHRD_SLIP = 0x100
- ARPHRD_SLIP6 = 0x102
- ARPHRD_TUNNEL = 0x300
- ARPHRD_TUNNEL6 = 0x301
- ARPHRD_VOID = 0xffff
- ARPHRD_X25 = 0x10f
- ASI_LEON_DFLUSH = 0x11
- ASI_LEON_IFLUSH = 0x10
- ASI_LEON_MMUFLUSH = 0x18
- B0 = 0x0
- B1000000 = 0x100c
- B110 = 0x3
- B115200 = 0x1002
- B1152000 = 0x100d
- B1200 = 0x9
- B134 = 0x4
- B150 = 0x5
- B1500000 = 0x100e
- B153600 = 0x1006
- B1800 = 0xa
- B19200 = 0xe
- B200 = 0x6
- B2000000 = 0x100f
- B230400 = 0x1003
- B2400 = 0xb
- B300 = 0x7
- B307200 = 0x1007
- B38400 = 0xf
- B460800 = 0x1004
- B4800 = 0xc
- B50 = 0x1
- B500000 = 0x100a
- B57600 = 0x1001
- B576000 = 0x100b
- B600 = 0x8
- B614400 = 0x1008
- B75 = 0x2
- B76800 = 0x1005
- B921600 = 0x1009
- B9600 = 0xd
- BLKBSZGET = 0x80081270
- BLKBSZSET = 0x40081271
- BLKFLSBUF = 0x1261
- BLKFRAGET = 0x1265
- BLKFRASET = 0x1264
- BLKGETSIZE = 0x1260
- BLKGETSIZE64 = 0x80081272
- BLKRAGET = 0x1263
- BLKRASET = 0x1262
- BLKROGET = 0x125e
- BLKROSET = 0x125d
- BLKRRPART = 0x125f
- BLKSECTGET = 0x1267
- BLKSECTSET = 0x1266
- BLKSSZGET = 0x1268
- BOTHER = 0x1000
- BPF_A = 0x10
- BPF_ABS = 0x20
- BPF_ADD = 0x0
- BPF_ALU = 0x4
- BPF_AND = 0x50
- BPF_B = 0x10
- BPF_DIV = 0x30
- BPF_H = 0x8
- BPF_IMM = 0x0
- BPF_IND = 0x40
- BPF_JA = 0x0
- BPF_JEQ = 0x10
- BPF_JGE = 0x30
- BPF_JGT = 0x20
- BPF_JMP = 0x5
- BPF_JSET = 0x40
- BPF_K = 0x0
- BPF_LD = 0x0
- BPF_LDX = 0x1
- BPF_LEN = 0x80
- BPF_LL_OFF = -0x200000
- BPF_LSH = 0x60
- BPF_MAJOR_VERSION = 0x1
- BPF_MAXINSNS = 0x1000
- BPF_MEM = 0x60
- BPF_MEMWORDS = 0x10
- BPF_MINOR_VERSION = 0x1
- BPF_MISC = 0x7
- BPF_MOD = 0x90
- BPF_MSH = 0xa0
- BPF_MUL = 0x20
- BPF_NEG = 0x80
- BPF_NET_OFF = -0x100000
- BPF_OR = 0x40
- BPF_RET = 0x6
- BPF_RSH = 0x70
- BPF_ST = 0x2
- BPF_STX = 0x3
- BPF_SUB = 0x10
- BPF_TAX = 0x0
- BPF_TXA = 0x80
- BPF_W = 0x0
- BPF_X = 0x8
- BPF_XOR = 0xa0
- BRKINT = 0x2
- BS0 = 0x0
- BS1 = 0x2000
- BSDLY = 0x2000
- CAN_BCM = 0x2
- CAN_EFF_FLAG = 0x80000000
- CAN_EFF_ID_BITS = 0x1d
- CAN_EFF_MASK = 0x1fffffff
- CAN_ERR_FLAG = 0x20000000
- CAN_ERR_MASK = 0x1fffffff
- CAN_INV_FILTER = 0x20000000
- CAN_ISOTP = 0x6
- CAN_MAX_DLC = 0x8
- CAN_MAX_DLEN = 0x8
- CAN_MCNET = 0x5
- CAN_MTU = 0x10
- CAN_NPROTO = 0x7
- CAN_RAW = 0x1
- CAN_RTR_FLAG = 0x40000000
- CAN_SFF_ID_BITS = 0xb
- CAN_SFF_MASK = 0x7ff
- CAN_TP16 = 0x3
- CAN_TP20 = 0x4
- CBAUD = 0x100f
- CBAUDEX = 0x1000
- CFLUSH = 0xf
- CIBAUD = 0x100f0000
- CLOCAL = 0x800
- CLOCK_BOOTTIME = 0x7
- CLOCK_BOOTTIME_ALARM = 0x9
- CLOCK_DEFAULT = 0x0
- CLOCK_EXT = 0x1
- CLOCK_INT = 0x2
- CLOCK_MONOTONIC = 0x1
- CLOCK_MONOTONIC_COARSE = 0x6
- CLOCK_MONOTONIC_RAW = 0x4
- CLOCK_PROCESS_CPUTIME_ID = 0x2
- CLOCK_REALTIME = 0x0
- CLOCK_REALTIME_ALARM = 0x8
- CLOCK_REALTIME_COARSE = 0x5
- CLOCK_TAI = 0xb
- CLOCK_THREAD_CPUTIME_ID = 0x3
- CLOCK_TXFROMRX = 0x4
- CLOCK_TXINT = 0x3
- CLONE_CHILD_CLEARTID = 0x200000
- CLONE_CHILD_SETTID = 0x1000000
- CLONE_DETACHED = 0x400000
- CLONE_FILES = 0x400
- CLONE_FS = 0x200
- CLONE_IO = 0x80000000
- CLONE_NEWCGROUP = 0x2000000
- CLONE_NEWIPC = 0x8000000
- CLONE_NEWNET = 0x40000000
- CLONE_NEWNS = 0x20000
- CLONE_NEWPID = 0x20000000
- CLONE_NEWUSER = 0x10000000
- CLONE_NEWUTS = 0x4000000
- CLONE_PARENT = 0x8000
- CLONE_PARENT_SETTID = 0x100000
- CLONE_PTRACE = 0x2000
- CLONE_SETTLS = 0x80000
- CLONE_SIGHAND = 0x800
- CLONE_SYSVSEM = 0x40000
- CLONE_THREAD = 0x10000
- CLONE_UNTRACED = 0x800000
- CLONE_VFORK = 0x4000
- CLONE_VM = 0x100
- CMSPAR = 0x40000000
- CR0 = 0x0
- CR1 = 0x200
- CR2 = 0x400
- CR3 = 0x600
- CRDLY = 0x600
- CREAD = 0x80
- CRTSCTS = 0x80000000
- CS5 = 0x0
- CS6 = 0x10
- CS7 = 0x20
- CS8 = 0x30
- CSIGNAL = 0xff
- CSIZE = 0x30
- CSTART = 0x11
- CSTATUS = 0x0
- CSTOP = 0x13
- CSTOPB = 0x40
- CSUSP = 0x1a
- DT_BLK = 0x6
- DT_CHR = 0x2
- DT_DIR = 0x4
- DT_FIFO = 0x1
- DT_LNK = 0xa
- DT_REG = 0x8
- DT_SOCK = 0xc
- DT_UNKNOWN = 0x0
- DT_WHT = 0xe
- ECHO = 0x8
- ECHOCTL = 0x200
- ECHOE = 0x10
- ECHOK = 0x20
- ECHOKE = 0x800
- ECHONL = 0x40
- ECHOPRT = 0x400
- EMT_TAGOVF = 0x1
- ENCODING_DEFAULT = 0x0
- ENCODING_FM_MARK = 0x3
- ENCODING_FM_SPACE = 0x4
- ENCODING_MANCHESTER = 0x5
- ENCODING_NRZ = 0x1
- ENCODING_NRZI = 0x2
- EPOLLERR = 0x8
- EPOLLET = 0x80000000
- EPOLLEXCLUSIVE = 0x10000000
- EPOLLHUP = 0x10
- EPOLLIN = 0x1
- EPOLLMSG = 0x400
- EPOLLONESHOT = 0x40000000
- EPOLLOUT = 0x4
- EPOLLPRI = 0x2
- EPOLLRDBAND = 0x80
- EPOLLRDHUP = 0x2000
- EPOLLRDNORM = 0x40
- EPOLLWAKEUP = 0x20000000
- EPOLLWRBAND = 0x200
- EPOLLWRNORM = 0x100
- EPOLL_CLOEXEC = 0x400000
- EPOLL_CTL_ADD = 0x1
- EPOLL_CTL_DEL = 0x2
- EPOLL_CTL_MOD = 0x3
- ETH_P_1588 = 0x88f7
- ETH_P_8021AD = 0x88a8
- ETH_P_8021AH = 0x88e7
- ETH_P_8021Q = 0x8100
- ETH_P_80221 = 0x8917
- ETH_P_802_2 = 0x4
- ETH_P_802_3 = 0x1
- ETH_P_802_3_MIN = 0x600
- ETH_P_802_EX1 = 0x88b5
- ETH_P_AARP = 0x80f3
- ETH_P_AF_IUCV = 0xfbfb
- ETH_P_ALL = 0x3
- ETH_P_AOE = 0x88a2
- ETH_P_ARCNET = 0x1a
- ETH_P_ARP = 0x806
- ETH_P_ATALK = 0x809b
- ETH_P_ATMFATE = 0x8884
- ETH_P_ATMMPOA = 0x884c
- ETH_P_AX25 = 0x2
- ETH_P_BATMAN = 0x4305
- ETH_P_BPQ = 0x8ff
- ETH_P_CAIF = 0xf7
- ETH_P_CAN = 0xc
- ETH_P_CANFD = 0xd
- ETH_P_CONTROL = 0x16
- ETH_P_CUST = 0x6006
- ETH_P_DDCMP = 0x6
- ETH_P_DEC = 0x6000
- ETH_P_DIAG = 0x6005
- ETH_P_DNA_DL = 0x6001
- ETH_P_DNA_RC = 0x6002
- ETH_P_DNA_RT = 0x6003
- ETH_P_DSA = 0x1b
- ETH_P_ECONET = 0x18
- ETH_P_EDSA = 0xdada
- ETH_P_FCOE = 0x8906
- ETH_P_FIP = 0x8914
- ETH_P_HDLC = 0x19
- ETH_P_HSR = 0x892f
- ETH_P_IEEE802154 = 0xf6
- ETH_P_IEEEPUP = 0xa00
- ETH_P_IEEEPUPAT = 0xa01
- ETH_P_IP = 0x800
- ETH_P_IPV6 = 0x86dd
- ETH_P_IPX = 0x8137
- ETH_P_IRDA = 0x17
- ETH_P_LAT = 0x6004
- ETH_P_LINK_CTL = 0x886c
- ETH_P_LOCALTALK = 0x9
- ETH_P_LOOP = 0x60
- ETH_P_LOOPBACK = 0x9000
- ETH_P_MACSEC = 0x88e5
- ETH_P_MOBITEX = 0x15
- ETH_P_MPLS_MC = 0x8848
- ETH_P_MPLS_UC = 0x8847
- ETH_P_MVRP = 0x88f5
- ETH_P_PAE = 0x888e
- ETH_P_PAUSE = 0x8808
- ETH_P_PHONET = 0xf5
- ETH_P_PPPTALK = 0x10
- ETH_P_PPP_DISC = 0x8863
- ETH_P_PPP_MP = 0x8
- ETH_P_PPP_SES = 0x8864
- ETH_P_PRP = 0x88fb
- ETH_P_PUP = 0x200
- ETH_P_PUPAT = 0x201
- ETH_P_QINQ1 = 0x9100
- ETH_P_QINQ2 = 0x9200
- ETH_P_QINQ3 = 0x9300
- ETH_P_RARP = 0x8035
- ETH_P_SCA = 0x6007
- ETH_P_SLOW = 0x8809
- ETH_P_SNAP = 0x5
- ETH_P_TDLS = 0x890d
- ETH_P_TEB = 0x6558
- ETH_P_TIPC = 0x88ca
- ETH_P_TRAILER = 0x1c
- ETH_P_TR_802_2 = 0x11
- ETH_P_TSN = 0x22f0
- ETH_P_WAN_PPP = 0x7
- ETH_P_WCCP = 0x883e
- ETH_P_X25 = 0x805
- ETH_P_XDSA = 0xf8
- EXTA = 0xe
- EXTB = 0xf
- EXTPROC = 0x10000
- FALLOC_FL_COLLAPSE_RANGE = 0x8
- FALLOC_FL_INSERT_RANGE = 0x20
- FALLOC_FL_KEEP_SIZE = 0x1
- FALLOC_FL_NO_HIDE_STALE = 0x4
- FALLOC_FL_PUNCH_HOLE = 0x2
- FALLOC_FL_ZERO_RANGE = 0x10
- FD_CLOEXEC = 0x1
- FD_SETSIZE = 0x400
- FF0 = 0x0
- FF1 = 0x8000
- FFDLY = 0x8000
- FLUSHO = 0x2000
- F_DUPFD = 0x0
- F_DUPFD_CLOEXEC = 0x406
- F_EXLCK = 0x4
- F_GETFD = 0x1
- F_GETFL = 0x3
- F_GETLEASE = 0x401
- F_GETLK = 0x7
- F_GETLK64 = 0x7
- F_GETOWN = 0x5
- F_GETOWN_EX = 0x10
- F_GETPIPE_SZ = 0x408
- F_GETSIG = 0xb
- F_LOCK = 0x1
- F_NOTIFY = 0x402
- F_OFD_GETLK = 0x24
- F_OFD_SETLK = 0x25
- F_OFD_SETLKW = 0x26
- F_OK = 0x0
- F_RDLCK = 0x1
- F_SETFD = 0x2
- F_SETFL = 0x4
- F_SETLEASE = 0x400
- F_SETLK = 0x8
- F_SETLK64 = 0x8
- F_SETLKW = 0x9
- F_SETLKW64 = 0x9
- F_SETOWN = 0x6
- F_SETOWN_EX = 0xf
- F_SETPIPE_SZ = 0x407
- F_SETSIG = 0xa
- F_SHLCK = 0x8
- F_TEST = 0x3
- F_TLOCK = 0x2
- F_ULOCK = 0x0
- F_UNLCK = 0x3
- F_WRLCK = 0x2
- GRND_NONBLOCK = 0x1
- GRND_RANDOM = 0x2
- HUPCL = 0x400
- IBSHIFT = 0x10
- ICANON = 0x2
- ICMPV6_FILTER = 0x1
- ICRNL = 0x100
- IEXTEN = 0x8000
- IFA_F_DADFAILED = 0x8
- IFA_F_DEPRECATED = 0x20
- IFA_F_HOMEADDRESS = 0x10
- IFA_F_MANAGETEMPADDR = 0x100
- IFA_F_MCAUTOJOIN = 0x400
- IFA_F_NODAD = 0x2
- IFA_F_NOPREFIXROUTE = 0x200
- IFA_F_OPTIMISTIC = 0x4
- IFA_F_PERMANENT = 0x80
- IFA_F_SECONDARY = 0x1
- IFA_F_STABLE_PRIVACY = 0x800
- IFA_F_TEMPORARY = 0x1
- IFA_F_TENTATIVE = 0x40
- IFA_MAX = 0x8
- IFF_ALLMULTI = 0x200
- IFF_ATTACH_QUEUE = 0x200
- IFF_AUTOMEDIA = 0x4000
- IFF_BROADCAST = 0x2
- IFF_DEBUG = 0x4
- IFF_DETACH_QUEUE = 0x400
- IFF_DORMANT = 0x20000
- IFF_DYNAMIC = 0x8000
- IFF_ECHO = 0x40000
- IFF_LOOPBACK = 0x8
- IFF_LOWER_UP = 0x10000
- IFF_MASTER = 0x400
- IFF_MULTICAST = 0x1000
- IFF_MULTI_QUEUE = 0x100
- IFF_NOARP = 0x80
- IFF_NOFILTER = 0x1000
- IFF_NOTRAILERS = 0x20
- IFF_NO_PI = 0x1000
- IFF_ONE_QUEUE = 0x2000
- IFF_PERSIST = 0x800
- IFF_POINTOPOINT = 0x10
- IFF_PORTSEL = 0x2000
- IFF_PROMISC = 0x100
- IFF_RUNNING = 0x40
- IFF_SLAVE = 0x800
- IFF_TAP = 0x2
- IFF_TUN = 0x1
- IFF_TUN_EXCL = 0x8000
- IFF_UP = 0x1
- IFF_VNET_HDR = 0x4000
- IFF_VOLATILE = 0x70c5a
- IFNAMSIZ = 0x10
- IGNBRK = 0x1
- IGNCR = 0x80
- IGNPAR = 0x4
- IMAXBEL = 0x2000
- INLCR = 0x40
- INPCK = 0x10
- IN_ACCESS = 0x1
- IN_ALL_EVENTS = 0xfff
- IN_ATTRIB = 0x4
- IN_CLASSA_HOST = 0xffffff
- IN_CLASSA_MAX = 0x80
- IN_CLASSA_NET = 0xff000000
- IN_CLASSA_NSHIFT = 0x18
- IN_CLASSB_HOST = 0xffff
- IN_CLASSB_MAX = 0x10000
- IN_CLASSB_NET = 0xffff0000
- IN_CLASSB_NSHIFT = 0x10
- IN_CLASSC_HOST = 0xff
- IN_CLASSC_NET = 0xffffff00
- IN_CLASSC_NSHIFT = 0x8
- IN_CLOEXEC = 0x400000
- IN_CLOSE = 0x18
- IN_CLOSE_NOWRITE = 0x10
- IN_CLOSE_WRITE = 0x8
- IN_CREATE = 0x100
- IN_DELETE = 0x200
- IN_DELETE_SELF = 0x400
- IN_DONT_FOLLOW = 0x2000000
- IN_EXCL_UNLINK = 0x4000000
- IN_IGNORED = 0x8000
- IN_ISDIR = 0x40000000
- IN_LOOPBACKNET = 0x7f
- IN_MASK_ADD = 0x20000000
- IN_MODIFY = 0x2
- IN_MOVE = 0xc0
- IN_MOVED_FROM = 0x40
- IN_MOVED_TO = 0x80
- IN_MOVE_SELF = 0x800
- IN_NONBLOCK = 0x4000
- IN_ONESHOT = 0x80000000
- IN_ONLYDIR = 0x1000000
- IN_OPEN = 0x20
- IN_Q_OVERFLOW = 0x4000
- IN_UNMOUNT = 0x2000
- IPPROTO_AH = 0x33
- IPPROTO_BEETPH = 0x5e
- IPPROTO_COMP = 0x6c
- IPPROTO_DCCP = 0x21
- IPPROTO_DSTOPTS = 0x3c
- IPPROTO_EGP = 0x8
- IPPROTO_ENCAP = 0x62
- IPPROTO_ESP = 0x32
- IPPROTO_FRAGMENT = 0x2c
- IPPROTO_GRE = 0x2f
- IPPROTO_HOPOPTS = 0x0
- IPPROTO_ICMP = 0x1
- IPPROTO_ICMPV6 = 0x3a
- IPPROTO_IDP = 0x16
- IPPROTO_IGMP = 0x2
- IPPROTO_IP = 0x0
- IPPROTO_IPIP = 0x4
- IPPROTO_IPV6 = 0x29
- IPPROTO_MH = 0x87
- IPPROTO_MPLS = 0x89
- IPPROTO_MTP = 0x5c
- IPPROTO_NONE = 0x3b
- IPPROTO_PIM = 0x67
- IPPROTO_PUP = 0xc
- IPPROTO_RAW = 0xff
- IPPROTO_ROUTING = 0x2b
- IPPROTO_RSVP = 0x2e
- IPPROTO_SCTP = 0x84
- IPPROTO_TCP = 0x6
- IPPROTO_TP = 0x1d
- IPPROTO_UDP = 0x11
- IPPROTO_UDPLITE = 0x88
- IPV6_2292DSTOPTS = 0x4
- IPV6_2292HOPLIMIT = 0x8
- IPV6_2292HOPOPTS = 0x3
- IPV6_2292PKTINFO = 0x2
- IPV6_2292PKTOPTIONS = 0x6
- IPV6_2292RTHDR = 0x5
- IPV6_ADDRFORM = 0x1
- IPV6_ADD_MEMBERSHIP = 0x14
- IPV6_AUTHHDR = 0xa
- IPV6_CHECKSUM = 0x7
- IPV6_DONTFRAG = 0x3e
- IPV6_DROP_MEMBERSHIP = 0x15
- IPV6_DSTOPTS = 0x3b
- IPV6_HDRINCL = 0x24
- IPV6_HOPLIMIT = 0x34
- IPV6_HOPOPTS = 0x36
- IPV6_IPSEC_POLICY = 0x22
- IPV6_JOIN_ANYCAST = 0x1b
- IPV6_JOIN_GROUP = 0x14
- IPV6_LEAVE_ANYCAST = 0x1c
- IPV6_LEAVE_GROUP = 0x15
- IPV6_MTU = 0x18
- IPV6_MTU_DISCOVER = 0x17
- IPV6_MULTICAST_HOPS = 0x12
- IPV6_MULTICAST_IF = 0x11
- IPV6_MULTICAST_LOOP = 0x13
- IPV6_NEXTHOP = 0x9
- IPV6_PATHMTU = 0x3d
- IPV6_PKTINFO = 0x32
- IPV6_PMTUDISC_DO = 0x2
- IPV6_PMTUDISC_DONT = 0x0
- IPV6_PMTUDISC_INTERFACE = 0x4
- IPV6_PMTUDISC_OMIT = 0x5
- IPV6_PMTUDISC_PROBE = 0x3
- IPV6_PMTUDISC_WANT = 0x1
- IPV6_RECVDSTOPTS = 0x3a
- IPV6_RECVERR = 0x19
- IPV6_RECVHOPLIMIT = 0x33
- IPV6_RECVHOPOPTS = 0x35
- IPV6_RECVPATHMTU = 0x3c
- IPV6_RECVPKTINFO = 0x31
- IPV6_RECVRTHDR = 0x38
- IPV6_RECVTCLASS = 0x42
- IPV6_ROUTER_ALERT = 0x16
- IPV6_RTHDR = 0x39
- IPV6_RTHDRDSTOPTS = 0x37
- IPV6_RTHDR_LOOSE = 0x0
- IPV6_RTHDR_STRICT = 0x1
- IPV6_RTHDR_TYPE_0 = 0x0
- IPV6_RXDSTOPTS = 0x3b
- IPV6_RXHOPOPTS = 0x36
- IPV6_TCLASS = 0x43
- IPV6_UNICAST_HOPS = 0x10
- IPV6_V6ONLY = 0x1a
- IPV6_XFRM_POLICY = 0x23
- IP_ADD_MEMBERSHIP = 0x23
- IP_ADD_SOURCE_MEMBERSHIP = 0x27
- IP_BIND_ADDRESS_NO_PORT = 0x18
- IP_BLOCK_SOURCE = 0x26
- IP_CHECKSUM = 0x17
- IP_DEFAULT_MULTICAST_LOOP = 0x1
- IP_DEFAULT_MULTICAST_TTL = 0x1
- IP_DF = 0x4000
- IP_DROP_MEMBERSHIP = 0x24
- IP_DROP_SOURCE_MEMBERSHIP = 0x28
- IP_FREEBIND = 0xf
- IP_HDRINCL = 0x3
- IP_IPSEC_POLICY = 0x10
- IP_MAXPACKET = 0xffff
- IP_MAX_MEMBERSHIPS = 0x14
- IP_MF = 0x2000
- IP_MINTTL = 0x15
- IP_MSFILTER = 0x29
- IP_MSS = 0x240
- IP_MTU = 0xe
- IP_MTU_DISCOVER = 0xa
- IP_MULTICAST_ALL = 0x31
- IP_MULTICAST_IF = 0x20
- IP_MULTICAST_LOOP = 0x22
- IP_MULTICAST_TTL = 0x21
- IP_NODEFRAG = 0x16
- IP_OFFMASK = 0x1fff
- IP_OPTIONS = 0x4
- IP_ORIGDSTADDR = 0x14
- IP_PASSSEC = 0x12
- IP_PKTINFO = 0x8
- IP_PKTOPTIONS = 0x9
- IP_PMTUDISC = 0xa
- IP_PMTUDISC_DO = 0x2
- IP_PMTUDISC_DONT = 0x0
- IP_PMTUDISC_INTERFACE = 0x4
- IP_PMTUDISC_OMIT = 0x5
- IP_PMTUDISC_PROBE = 0x3
- IP_PMTUDISC_WANT = 0x1
- IP_RECVERR = 0xb
- IP_RECVOPTS = 0x6
- IP_RECVORIGDSTADDR = 0x14
- IP_RECVRETOPTS = 0x7
- IP_RECVTOS = 0xd
- IP_RECVTTL = 0xc
- IP_RETOPTS = 0x7
- IP_RF = 0x8000
- IP_ROUTER_ALERT = 0x5
- IP_TOS = 0x1
- IP_TRANSPARENT = 0x13
- IP_TTL = 0x2
- IP_UNBLOCK_SOURCE = 0x25
- IP_UNICAST_IF = 0x32
- IP_XFRM_POLICY = 0x11
- ISIG = 0x1
- ISTRIP = 0x20
- IUCLC = 0x200
- IUTF8 = 0x4000
- IXANY = 0x800
- IXOFF = 0x1000
- IXON = 0x400
- LINUX_REBOOT_CMD_CAD_OFF = 0x0
- LINUX_REBOOT_CMD_CAD_ON = 0x89abcdef
- LINUX_REBOOT_CMD_HALT = 0xcdef0123
- LINUX_REBOOT_CMD_KEXEC = 0x45584543
- LINUX_REBOOT_CMD_POWER_OFF = 0x4321fedc
- LINUX_REBOOT_CMD_RESTART = 0x1234567
- LINUX_REBOOT_CMD_RESTART2 = 0xa1b2c3d4
- LINUX_REBOOT_CMD_SW_SUSPEND = 0xd000fce2
- LINUX_REBOOT_MAGIC1 = 0xfee1dead
- LINUX_REBOOT_MAGIC2 = 0x28121969
- LOCK_EX = 0x2
- LOCK_NB = 0x4
- LOCK_SH = 0x1
- LOCK_UN = 0x8
- MADV_DODUMP = 0x11
- MADV_DOFORK = 0xb
- MADV_DONTDUMP = 0x10
- MADV_DONTFORK = 0xa
- MADV_DONTNEED = 0x4
- MADV_FREE = 0x8
- MADV_HUGEPAGE = 0xe
- MADV_HWPOISON = 0x64
- MADV_MERGEABLE = 0xc
- MADV_NOHUGEPAGE = 0xf
- MADV_NORMAL = 0x0
- MADV_RANDOM = 0x1
- MADV_REMOVE = 0x9
- MADV_SEQUENTIAL = 0x2
- MADV_UNMERGEABLE = 0xd
- MADV_WILLNEED = 0x3
- MAP_ANON = 0x20
- MAP_ANONYMOUS = 0x20
- MAP_DENYWRITE = 0x800
- MAP_EXECUTABLE = 0x1000
- MAP_FILE = 0x0
- MAP_FIXED = 0x10
- MAP_GROWSDOWN = 0x200
- MAP_HUGETLB = 0x40000
- MAP_HUGE_MASK = 0x3f
- MAP_HUGE_SHIFT = 0x1a
- MAP_LOCKED = 0x100
- MAP_NONBLOCK = 0x10000
- MAP_NORESERVE = 0x40
- MAP_POPULATE = 0x8000
- MAP_PRIVATE = 0x2
- MAP_RENAME = 0x20
- MAP_SHARED = 0x1
- MAP_STACK = 0x20000
- MAP_TYPE = 0xf
- MCL_CURRENT = 0x2000
- MCL_FUTURE = 0x4000
- MCL_ONFAULT = 0x8000
- MNT_DETACH = 0x2
- MNT_EXPIRE = 0x4
- MNT_FORCE = 0x1
- MSG_BATCH = 0x40000
- MSG_CMSG_CLOEXEC = 0x40000000
- MSG_CONFIRM = 0x800
- MSG_CTRUNC = 0x8
- MSG_DONTROUTE = 0x4
- MSG_DONTWAIT = 0x40
- MSG_EOR = 0x80
- MSG_ERRQUEUE = 0x2000
- MSG_FASTOPEN = 0x20000000
- MSG_FIN = 0x200
- MSG_MORE = 0x8000
- MSG_NOSIGNAL = 0x4000
- MSG_OOB = 0x1
- MSG_PEEK = 0x2
- MSG_PROXY = 0x10
- MSG_RST = 0x1000
- MSG_SYN = 0x400
- MSG_TRUNC = 0x20
- MSG_TRYHARD = 0x4
- MSG_WAITALL = 0x100
- MSG_WAITFORONE = 0x10000
- MS_ACTIVE = 0x40000000
- MS_ASYNC = 0x1
- MS_BIND = 0x1000
- MS_DIRSYNC = 0x80
- MS_INVALIDATE = 0x2
- MS_I_VERSION = 0x800000
- MS_KERNMOUNT = 0x400000
- MS_LAZYTIME = 0x2000000
- MS_MANDLOCK = 0x40
- MS_MGC_MSK = 0xffff0000
- MS_MGC_VAL = 0xc0ed0000
- MS_MOVE = 0x2000
- MS_NOATIME = 0x400
- MS_NODEV = 0x4
- MS_NODIRATIME = 0x800
- MS_NOEXEC = 0x8
- MS_NOSUID = 0x2
- MS_NOUSER = -0x80000000
- MS_POSIXACL = 0x10000
- MS_PRIVATE = 0x40000
- MS_RDONLY = 0x1
- MS_REC = 0x4000
- MS_RELATIME = 0x200000
- MS_REMOUNT = 0x20
- MS_RMT_MASK = 0x2800051
- MS_SHARED = 0x100000
- MS_SILENT = 0x8000
- MS_SLAVE = 0x80000
- MS_STRICTATIME = 0x1000000
- MS_SYNC = 0x4
- MS_SYNCHRONOUS = 0x10
- MS_UNBINDABLE = 0x20000
- NAME_MAX = 0xff
- NETLINK_ADD_MEMBERSHIP = 0x1
- NETLINK_AUDIT = 0x9
- NETLINK_BROADCAST_ERROR = 0x4
- NETLINK_CAP_ACK = 0xa
- NETLINK_CONNECTOR = 0xb
- NETLINK_CRYPTO = 0x15
- NETLINK_DNRTMSG = 0xe
- NETLINK_DROP_MEMBERSHIP = 0x2
- NETLINK_ECRYPTFS = 0x13
- NETLINK_FIB_LOOKUP = 0xa
- NETLINK_FIREWALL = 0x3
- NETLINK_GENERIC = 0x10
- NETLINK_INET_DIAG = 0x4
- NETLINK_IP6_FW = 0xd
- NETLINK_ISCSI = 0x8
- NETLINK_KOBJECT_UEVENT = 0xf
- NETLINK_LISTEN_ALL_NSID = 0x8
- NETLINK_LIST_MEMBERSHIPS = 0x9
- NETLINK_NETFILTER = 0xc
- NETLINK_NFLOG = 0x5
- NETLINK_NO_ENOBUFS = 0x5
- NETLINK_PKTINFO = 0x3
- NETLINK_RDMA = 0x14
- NETLINK_ROUTE = 0x0
- NETLINK_RX_RING = 0x6
- NETLINK_SCSITRANSPORT = 0x12
- NETLINK_SELINUX = 0x7
- NETLINK_SOCK_DIAG = 0x4
- NETLINK_TX_RING = 0x7
- NETLINK_UNUSED = 0x1
- NETLINK_USERSOCK = 0x2
- NETLINK_XFRM = 0x6
- NL0 = 0x0
- NL1 = 0x100
- NLA_ALIGNTO = 0x4
- NLA_F_NESTED = 0x8000
- NLA_F_NET_BYTEORDER = 0x4000
- NLA_HDRLEN = 0x4
- NLDLY = 0x100
- NLMSG_ALIGNTO = 0x4
- NLMSG_DONE = 0x3
- NLMSG_ERROR = 0x2
- NLMSG_HDRLEN = 0x10
- NLMSG_MIN_TYPE = 0x10
- NLMSG_NOOP = 0x1
- NLMSG_OVERRUN = 0x4
- NLM_F_ACK = 0x4
- NLM_F_APPEND = 0x800
- NLM_F_ATOMIC = 0x400
- NLM_F_CREATE = 0x400
- NLM_F_DUMP = 0x300
- NLM_F_DUMP_FILTERED = 0x20
- NLM_F_DUMP_INTR = 0x10
- NLM_F_ECHO = 0x8
- NLM_F_EXCL = 0x200
- NLM_F_MATCH = 0x200
- NLM_F_MULTI = 0x2
- NLM_F_REPLACE = 0x100
- NLM_F_REQUEST = 0x1
- NLM_F_ROOT = 0x100
- NOFLSH = 0x80
- OCRNL = 0x8
- OFDEL = 0x80
- OFILL = 0x40
- OLCUC = 0x2
- ONLCR = 0x4
- ONLRET = 0x20
- ONOCR = 0x10
- OPOST = 0x1
- O_ACCMODE = 0x3
- O_APPEND = 0x8
- O_ASYNC = 0x40
- O_CLOEXEC = 0x400000
- O_CREAT = 0x200
- O_DIRECT = 0x100000
- O_DIRECTORY = 0x10000
- O_DSYNC = 0x2000
- O_EXCL = 0x800
- O_FSYNC = 0x802000
- O_LARGEFILE = 0x0
- O_NDELAY = 0x4004
- O_NOATIME = 0x200000
- O_NOCTTY = 0x8000
- O_NOFOLLOW = 0x20000
- O_NONBLOCK = 0x4000
- O_PATH = 0x1000000
- O_RDONLY = 0x0
- O_RDWR = 0x2
- O_RSYNC = 0x802000
- O_SYNC = 0x802000
- O_TMPFILE = 0x2010000
- O_TRUNC = 0x400
- O_WRONLY = 0x1
- PACKET_ADD_MEMBERSHIP = 0x1
- PACKET_AUXDATA = 0x8
- PACKET_BROADCAST = 0x1
- PACKET_COPY_THRESH = 0x7
- PACKET_DROP_MEMBERSHIP = 0x2
- PACKET_FANOUT = 0x12
- PACKET_FANOUT_CBPF = 0x6
- PACKET_FANOUT_CPU = 0x2
- PACKET_FANOUT_DATA = 0x16
- PACKET_FANOUT_EBPF = 0x7
- PACKET_FANOUT_FLAG_DEFRAG = 0x8000
- PACKET_FANOUT_FLAG_ROLLOVER = 0x1000
- PACKET_FANOUT_HASH = 0x0
- PACKET_FANOUT_LB = 0x1
- PACKET_FANOUT_QM = 0x5
- PACKET_FANOUT_RND = 0x4
- PACKET_FANOUT_ROLLOVER = 0x3
- PACKET_FASTROUTE = 0x6
- PACKET_HDRLEN = 0xb
- PACKET_HOST = 0x0
- PACKET_KERNEL = 0x7
- PACKET_LOOPBACK = 0x5
- PACKET_LOSS = 0xe
- PACKET_MR_ALLMULTI = 0x2
- PACKET_MR_MULTICAST = 0x0
- PACKET_MR_PROMISC = 0x1
- PACKET_MR_UNICAST = 0x3
- PACKET_MULTICAST = 0x2
- PACKET_ORIGDEV = 0x9
- PACKET_OTHERHOST = 0x3
- PACKET_OUTGOING = 0x4
- PACKET_QDISC_BYPASS = 0x14
- PACKET_RECV_OUTPUT = 0x3
- PACKET_RESERVE = 0xc
- PACKET_ROLLOVER_STATS = 0x15
- PACKET_RX_RING = 0x5
- PACKET_STATISTICS = 0x6
- PACKET_TIMESTAMP = 0x11
- PACKET_TX_HAS_OFF = 0x13
- PACKET_TX_RING = 0xd
- PACKET_TX_TIMESTAMP = 0x10
- PACKET_USER = 0x6
- PACKET_VERSION = 0xa
- PACKET_VNET_HDR = 0xf
- PARENB = 0x100
- PARITY_CRC16_PR0 = 0x2
- PARITY_CRC16_PR0_CCITT = 0x4
- PARITY_CRC16_PR1 = 0x3
- PARITY_CRC16_PR1_CCITT = 0x5
- PARITY_CRC32_PR0_CCITT = 0x6
- PARITY_CRC32_PR1_CCITT = 0x7
- PARITY_DEFAULT = 0x0
- PARITY_NONE = 0x1
- PARMRK = 0x8
- PARODD = 0x200
- PENDIN = 0x4000
- PRIO_PGRP = 0x1
- PRIO_PROCESS = 0x0
- PRIO_USER = 0x2
- PROT_EXEC = 0x4
- PROT_GROWSDOWN = 0x1000000
- PROT_GROWSUP = 0x2000000
- PROT_NONE = 0x0
- PROT_READ = 0x1
- PROT_WRITE = 0x2
- PR_CAPBSET_DROP = 0x18
- PR_CAPBSET_READ = 0x17
- PR_CAP_AMBIENT = 0x2f
- PR_CAP_AMBIENT_CLEAR_ALL = 0x4
- PR_CAP_AMBIENT_IS_SET = 0x1
- PR_CAP_AMBIENT_LOWER = 0x3
- PR_CAP_AMBIENT_RAISE = 0x2
- PR_ENDIAN_BIG = 0x0
- PR_ENDIAN_LITTLE = 0x1
- PR_ENDIAN_PPC_LITTLE = 0x2
- PR_FPEMU_NOPRINT = 0x1
- PR_FPEMU_SIGFPE = 0x2
- PR_FP_EXC_ASYNC = 0x2
- PR_FP_EXC_DISABLED = 0x0
- PR_FP_EXC_DIV = 0x10000
- PR_FP_EXC_INV = 0x100000
- PR_FP_EXC_NONRECOV = 0x1
- PR_FP_EXC_OVF = 0x20000
- PR_FP_EXC_PRECISE = 0x3
- PR_FP_EXC_RES = 0x80000
- PR_FP_EXC_SW_ENABLE = 0x80
- PR_FP_EXC_UND = 0x40000
- PR_FP_MODE_FR = 0x1
- PR_FP_MODE_FRE = 0x2
- PR_GET_CHILD_SUBREAPER = 0x25
- PR_GET_DUMPABLE = 0x3
- PR_GET_ENDIAN = 0x13
- PR_GET_FPEMU = 0x9
- PR_GET_FPEXC = 0xb
- PR_GET_FP_MODE = 0x2e
- PR_GET_KEEPCAPS = 0x7
- PR_GET_NAME = 0x10
- PR_GET_NO_NEW_PRIVS = 0x27
- PR_GET_PDEATHSIG = 0x2
- PR_GET_SECCOMP = 0x15
- PR_GET_SECUREBITS = 0x1b
- PR_GET_THP_DISABLE = 0x2a
- PR_GET_TID_ADDRESS = 0x28
- PR_GET_TIMERSLACK = 0x1e
- PR_GET_TIMING = 0xd
- PR_GET_TSC = 0x19
- PR_GET_UNALIGN = 0x5
- PR_MCE_KILL = 0x21
- PR_MCE_KILL_CLEAR = 0x0
- PR_MCE_KILL_DEFAULT = 0x2
- PR_MCE_KILL_EARLY = 0x1
- PR_MCE_KILL_GET = 0x22
- PR_MCE_KILL_LATE = 0x0
- PR_MCE_KILL_SET = 0x1
- PR_MPX_DISABLE_MANAGEMENT = 0x2c
- PR_MPX_ENABLE_MANAGEMENT = 0x2b
- PR_SET_CHILD_SUBREAPER = 0x24
- PR_SET_DUMPABLE = 0x4
- PR_SET_ENDIAN = 0x14
- PR_SET_FPEMU = 0xa
- PR_SET_FPEXC = 0xc
- PR_SET_FP_MODE = 0x2d
- PR_SET_KEEPCAPS = 0x8
- PR_SET_MM = 0x23
- PR_SET_MM_ARG_END = 0x9
- PR_SET_MM_ARG_START = 0x8
- PR_SET_MM_AUXV = 0xc
- PR_SET_MM_BRK = 0x7
- PR_SET_MM_END_CODE = 0x2
- PR_SET_MM_END_DATA = 0x4
- PR_SET_MM_ENV_END = 0xb
- PR_SET_MM_ENV_START = 0xa
- PR_SET_MM_EXE_FILE = 0xd
- PR_SET_MM_MAP = 0xe
- PR_SET_MM_MAP_SIZE = 0xf
- PR_SET_MM_START_BRK = 0x6
- PR_SET_MM_START_CODE = 0x1
- PR_SET_MM_START_DATA = 0x3
- PR_SET_MM_START_STACK = 0x5
- PR_SET_NAME = 0xf
- PR_SET_NO_NEW_PRIVS = 0x26
- PR_SET_PDEATHSIG = 0x1
- PR_SET_PTRACER = 0x59616d61
- PR_SET_PTRACER_ANY = -0x1
- PR_SET_SECCOMP = 0x16
- PR_SET_SECUREBITS = 0x1c
- PR_SET_THP_DISABLE = 0x29
- PR_SET_TIMERSLACK = 0x1d
- PR_SET_TIMING = 0xe
- PR_SET_TSC = 0x1a
- PR_SET_UNALIGN = 0x6
- PR_TASK_PERF_EVENTS_DISABLE = 0x1f
- PR_TASK_PERF_EVENTS_ENABLE = 0x20
- PR_TIMING_STATISTICAL = 0x0
- PR_TIMING_TIMESTAMP = 0x1
- PR_TSC_ENABLE = 0x1
- PR_TSC_SIGSEGV = 0x2
- PR_UNALIGN_NOPRINT = 0x1
- PR_UNALIGN_SIGBUS = 0x2
- PTRACE_ATTACH = 0x10
- PTRACE_CONT = 0x7
- PTRACE_DETACH = 0x11
- PTRACE_EVENT_CLONE = 0x3
- PTRACE_EVENT_EXEC = 0x4
- PTRACE_EVENT_EXIT = 0x6
- PTRACE_EVENT_FORK = 0x1
- PTRACE_EVENT_SECCOMP = 0x7
- PTRACE_EVENT_STOP = 0x80
- PTRACE_EVENT_VFORK = 0x2
- PTRACE_EVENT_VFORK_DONE = 0x5
- PTRACE_GETEVENTMSG = 0x4201
- PTRACE_GETFPAREGS = 0x14
- PTRACE_GETFPREGS = 0xe
- PTRACE_GETFPREGS64 = 0x19
- PTRACE_GETREGS = 0xc
- PTRACE_GETREGS64 = 0x16
- PTRACE_GETREGSET = 0x4204
- PTRACE_GETSIGINFO = 0x4202
- PTRACE_GETSIGMASK = 0x420a
- PTRACE_INTERRUPT = 0x4207
- PTRACE_KILL = 0x8
- PTRACE_LISTEN = 0x4208
- PTRACE_O_EXITKILL = 0x100000
- PTRACE_O_MASK = 0x3000ff
- PTRACE_O_SUSPEND_SECCOMP = 0x200000
- PTRACE_O_TRACECLONE = 0x8
- PTRACE_O_TRACEEXEC = 0x10
- PTRACE_O_TRACEEXIT = 0x40
- PTRACE_O_TRACEFORK = 0x2
- PTRACE_O_TRACESECCOMP = 0x80
- PTRACE_O_TRACESYSGOOD = 0x1
- PTRACE_O_TRACEVFORK = 0x4
- PTRACE_O_TRACEVFORKDONE = 0x20
- PTRACE_PEEKDATA = 0x2
- PTRACE_PEEKSIGINFO = 0x4209
- PTRACE_PEEKSIGINFO_SHARED = 0x1
- PTRACE_PEEKTEXT = 0x1
- PTRACE_PEEKUSR = 0x3
- PTRACE_POKEDATA = 0x5
- PTRACE_POKETEXT = 0x4
- PTRACE_POKEUSR = 0x6
- PTRACE_READDATA = 0x10
- PTRACE_READTEXT = 0x12
- PTRACE_SECCOMP_GET_FILTER = 0x420c
- PTRACE_SEIZE = 0x4206
- PTRACE_SETFPAREGS = 0x15
- PTRACE_SETFPREGS = 0xf
- PTRACE_SETFPREGS64 = 0x1a
- PTRACE_SETOPTIONS = 0x4200
- PTRACE_SETREGS = 0xd
- PTRACE_SETREGS64 = 0x17
- PTRACE_SETREGSET = 0x4205
- PTRACE_SETSIGINFO = 0x4203
- PTRACE_SETSIGMASK = 0x420b
- PTRACE_SINGLESTEP = 0x9
- PTRACE_SPARC_DETACH = 0xb
- PTRACE_SYSCALL = 0x18
- PTRACE_TRACEME = 0x0
- PTRACE_WRITEDATA = 0x11
- PTRACE_WRITETEXT = 0x13
- PT_FP = 0x48
- PT_G0 = 0x10
- PT_G1 = 0x14
- PT_G2 = 0x18
- PT_G3 = 0x1c
- PT_G4 = 0x20
- PT_G5 = 0x24
- PT_G6 = 0x28
- PT_G7 = 0x2c
- PT_I0 = 0x30
- PT_I1 = 0x34
- PT_I2 = 0x38
- PT_I3 = 0x3c
- PT_I4 = 0x40
- PT_I5 = 0x44
- PT_I6 = 0x48
- PT_I7 = 0x4c
- PT_NPC = 0x8
- PT_PC = 0x4
- PT_PSR = 0x0
- PT_REGS_MAGIC = 0x57ac6c00
- PT_TNPC = 0x90
- PT_TPC = 0x88
- PT_TSTATE = 0x80
- PT_V9_FP = 0x70
- PT_V9_G0 = 0x0
- PT_V9_G1 = 0x8
- PT_V9_G2 = 0x10
- PT_V9_G3 = 0x18
- PT_V9_G4 = 0x20
- PT_V9_G5 = 0x28
- PT_V9_G6 = 0x30
- PT_V9_G7 = 0x38
- PT_V9_I0 = 0x40
- PT_V9_I1 = 0x48
- PT_V9_I2 = 0x50
- PT_V9_I3 = 0x58
- PT_V9_I4 = 0x60
- PT_V9_I5 = 0x68
- PT_V9_I6 = 0x70
- PT_V9_I7 = 0x78
- PT_V9_MAGIC = 0x9c
- PT_V9_TNPC = 0x90
- PT_V9_TPC = 0x88
- PT_V9_TSTATE = 0x80
- PT_V9_Y = 0x98
- PT_WIM = 0x10
- PT_Y = 0xc
- RLIMIT_AS = 0x9
- RLIMIT_CORE = 0x4
- RLIMIT_CPU = 0x0
- RLIMIT_DATA = 0x2
- RLIMIT_FSIZE = 0x1
- RLIMIT_NOFILE = 0x6
- RLIMIT_STACK = 0x3
- RLIM_INFINITY = -0x1
- RTAX_ADVMSS = 0x8
- RTAX_CC_ALGO = 0x10
- RTAX_CWND = 0x7
- RTAX_FEATURES = 0xc
- RTAX_FEATURE_ALLFRAG = 0x8
- RTAX_FEATURE_ECN = 0x1
- RTAX_FEATURE_MASK = 0xf
- RTAX_FEATURE_SACK = 0x2
- RTAX_FEATURE_TIMESTAMP = 0x4
- RTAX_HOPLIMIT = 0xa
- RTAX_INITCWND = 0xb
- RTAX_INITRWND = 0xe
- RTAX_LOCK = 0x1
- RTAX_MAX = 0x10
- RTAX_MTU = 0x2
- RTAX_QUICKACK = 0xf
- RTAX_REORDERING = 0x9
- RTAX_RTO_MIN = 0xd
- RTAX_RTT = 0x4
- RTAX_RTTVAR = 0x5
- RTAX_SSTHRESH = 0x6
- RTAX_UNSPEC = 0x0
- RTAX_WINDOW = 0x3
- RTA_ALIGNTO = 0x4
- RTA_MAX = 0x18
- RTCF_DIRECTSRC = 0x4000000
- RTCF_DOREDIRECT = 0x1000000
- RTCF_LOG = 0x2000000
- RTCF_MASQ = 0x400000
- RTCF_NAT = 0x800000
- RTCF_VALVE = 0x200000
- RTF_ADDRCLASSMASK = 0xf8000000
- RTF_ADDRCONF = 0x40000
- RTF_ALLONLINK = 0x20000
- RTF_BROADCAST = 0x10000000
- RTF_CACHE = 0x1000000
- RTF_DEFAULT = 0x10000
- RTF_DYNAMIC = 0x10
- RTF_FLOW = 0x2000000
- RTF_GATEWAY = 0x2
- RTF_HOST = 0x4
- RTF_INTERFACE = 0x40000000
- RTF_IRTT = 0x100
- RTF_LINKRT = 0x100000
- RTF_LOCAL = 0x80000000
- RTF_MODIFIED = 0x20
- RTF_MSS = 0x40
- RTF_MTU = 0x40
- RTF_MULTICAST = 0x20000000
- RTF_NAT = 0x8000000
- RTF_NOFORWARD = 0x1000
- RTF_NONEXTHOP = 0x200000
- RTF_NOPMTUDISC = 0x4000
- RTF_POLICY = 0x4000000
- RTF_REINSTATE = 0x8
- RTF_REJECT = 0x200
- RTF_STATIC = 0x400
- RTF_THROW = 0x2000
- RTF_UP = 0x1
- RTF_WINDOW = 0x80
- RTF_XRESOLVE = 0x800
- RTM_BASE = 0x10
- RTM_DELACTION = 0x31
- RTM_DELADDR = 0x15
- RTM_DELADDRLABEL = 0x49
- RTM_DELLINK = 0x11
- RTM_DELMDB = 0x55
- RTM_DELNEIGH = 0x1d
- RTM_DELNSID = 0x59
- RTM_DELQDISC = 0x25
- RTM_DELROUTE = 0x19
- RTM_DELRULE = 0x21
- RTM_DELTCLASS = 0x29
- RTM_DELTFILTER = 0x2d
- RTM_F_CLONED = 0x200
- RTM_F_EQUALIZE = 0x400
- RTM_F_LOOKUP_TABLE = 0x1000
- RTM_F_NOTIFY = 0x100
- RTM_F_PREFIX = 0x800
- RTM_GETACTION = 0x32
- RTM_GETADDR = 0x16
- RTM_GETADDRLABEL = 0x4a
- RTM_GETANYCAST = 0x3e
- RTM_GETDCB = 0x4e
- RTM_GETLINK = 0x12
- RTM_GETMDB = 0x56
- RTM_GETMULTICAST = 0x3a
- RTM_GETNEIGH = 0x1e
- RTM_GETNEIGHTBL = 0x42
- RTM_GETNETCONF = 0x52
- RTM_GETNSID = 0x5a
- RTM_GETQDISC = 0x26
- RTM_GETROUTE = 0x1a
- RTM_GETRULE = 0x22
- RTM_GETSTATS = 0x5e
- RTM_GETTCLASS = 0x2a
- RTM_GETTFILTER = 0x2e
- RTM_MAX = 0x5f
- RTM_NEWACTION = 0x30
- RTM_NEWADDR = 0x14
- RTM_NEWADDRLABEL = 0x48
- RTM_NEWLINK = 0x10
- RTM_NEWMDB = 0x54
- RTM_NEWNDUSEROPT = 0x44
- RTM_NEWNEIGH = 0x1c
- RTM_NEWNEIGHTBL = 0x40
- RTM_NEWNETCONF = 0x50
- RTM_NEWNSID = 0x58
- RTM_NEWPREFIX = 0x34
- RTM_NEWQDISC = 0x24
- RTM_NEWROUTE = 0x18
- RTM_NEWRULE = 0x20
- RTM_NEWSTATS = 0x5c
- RTM_NEWTCLASS = 0x28
- RTM_NEWTFILTER = 0x2c
- RTM_NR_FAMILIES = 0x14
- RTM_NR_MSGTYPES = 0x50
- RTM_SETDCB = 0x4f
- RTM_SETLINK = 0x13
- RTM_SETNEIGHTBL = 0x43
- RTNH_ALIGNTO = 0x4
- RTNH_COMPARE_MASK = 0x11
- RTNH_F_DEAD = 0x1
- RTNH_F_LINKDOWN = 0x10
- RTNH_F_OFFLOAD = 0x8
- RTNH_F_ONLINK = 0x4
- RTNH_F_PERVASIVE = 0x2
- RTN_MAX = 0xb
- RTPROT_BABEL = 0x2a
- RTPROT_BIRD = 0xc
- RTPROT_BOOT = 0x3
- RTPROT_DHCP = 0x10
- RTPROT_DNROUTED = 0xd
- RTPROT_GATED = 0x8
- RTPROT_KERNEL = 0x2
- RTPROT_MROUTED = 0x11
- RTPROT_MRT = 0xa
- RTPROT_NTK = 0xf
- RTPROT_RA = 0x9
- RTPROT_REDIRECT = 0x1
- RTPROT_STATIC = 0x4
- RTPROT_UNSPEC = 0x0
- RTPROT_XORP = 0xe
- RTPROT_ZEBRA = 0xb
- RT_CLASS_DEFAULT = 0xfd
- RT_CLASS_LOCAL = 0xff
- RT_CLASS_MAIN = 0xfe
- RT_CLASS_MAX = 0xff
- RT_CLASS_UNSPEC = 0x0
- RUSAGE_CHILDREN = -0x1
- RUSAGE_SELF = 0x0
- RUSAGE_THREAD = 0x1
- SCM_CREDENTIALS = 0x2
- SCM_RIGHTS = 0x1
- SCM_TIMESTAMP = 0x1d
- SCM_TIMESTAMPING = 0x23
- SCM_TIMESTAMPNS = 0x21
- SCM_WIFI_STATUS = 0x25
- SHUT_RD = 0x0
- SHUT_RDWR = 0x2
- SHUT_WR = 0x1
- SIOCADDDLCI = 0x8980
- SIOCADDMULTI = 0x8931
- SIOCADDRT = 0x890b
- SIOCATMARK = 0x8905
- SIOCBONDCHANGEACTIVE = 0x8995
- SIOCBONDENSLAVE = 0x8990
- SIOCBONDINFOQUERY = 0x8994
- SIOCBONDRELEASE = 0x8991
- SIOCBONDSETHWADDR = 0x8992
- SIOCBONDSLAVEINFOQUERY = 0x8993
- SIOCBRADDBR = 0x89a0
- SIOCBRADDIF = 0x89a2
- SIOCBRDELBR = 0x89a1
- SIOCBRDELIF = 0x89a3
- SIOCDARP = 0x8953
- SIOCDELDLCI = 0x8981
- SIOCDELMULTI = 0x8932
- SIOCDELRT = 0x890c
- SIOCDEVPRIVATE = 0x89f0
- SIOCDIFADDR = 0x8936
- SIOCDRARP = 0x8960
- SIOCETHTOOL = 0x8946
- SIOCGARP = 0x8954
- SIOCGHWTSTAMP = 0x89b1
- SIOCGIFADDR = 0x8915
- SIOCGIFBR = 0x8940
- SIOCGIFBRDADDR = 0x8919
- SIOCGIFCONF = 0x8912
- SIOCGIFCOUNT = 0x8938
- SIOCGIFDSTADDR = 0x8917
- SIOCGIFENCAP = 0x8925
- SIOCGIFFLAGS = 0x8913
- SIOCGIFHWADDR = 0x8927
- SIOCGIFINDEX = 0x8933
- SIOCGIFMAP = 0x8970
- SIOCGIFMEM = 0x891f
- SIOCGIFMETRIC = 0x891d
- SIOCGIFMTU = 0x8921
- SIOCGIFNAME = 0x8910
- SIOCGIFNETMASK = 0x891b
- SIOCGIFPFLAGS = 0x8935
- SIOCGIFSLAVE = 0x8929
- SIOCGIFTXQLEN = 0x8942
- SIOCGIFVLAN = 0x8982
- SIOCGMIIPHY = 0x8947
- SIOCGMIIREG = 0x8948
- SIOCGPGRP = 0x8904
- SIOCGRARP = 0x8961
- SIOCGSTAMP = 0x8906
- SIOCGSTAMPNS = 0x8907
- SIOCINQ = 0x4004667f
- SIOCOUTQ = 0x40047473
- SIOCOUTQNSD = 0x894b
- SIOCPROTOPRIVATE = 0x89e0
- SIOCRTMSG = 0x890d
- SIOCSARP = 0x8955
- SIOCSHWTSTAMP = 0x89b0
- SIOCSIFADDR = 0x8916
- SIOCSIFBR = 0x8941
- SIOCSIFBRDADDR = 0x891a
- SIOCSIFDSTADDR = 0x8918
- SIOCSIFENCAP = 0x8926
- SIOCSIFFLAGS = 0x8914
- SIOCSIFHWADDR = 0x8924
- SIOCSIFHWBROADCAST = 0x8937
- SIOCSIFLINK = 0x8911
- SIOCSIFMAP = 0x8971
- SIOCSIFMEM = 0x8920
- SIOCSIFMETRIC = 0x891e
- SIOCSIFMTU = 0x8922
- SIOCSIFNAME = 0x8923
- SIOCSIFNETMASK = 0x891c
- SIOCSIFPFLAGS = 0x8934
- SIOCSIFSLAVE = 0x8930
- SIOCSIFTXQLEN = 0x8943
- SIOCSIFVLAN = 0x8983
- SIOCSMIIREG = 0x8949
- SIOCSPGRP = 0x8902
- SIOCSRARP = 0x8962
- SIOCWANDEV = 0x894a
- SOCK_CLOEXEC = 0x400000
- SOCK_DCCP = 0x6
- SOCK_DGRAM = 0x2
- SOCK_NONBLOCK = 0x4000
- SOCK_PACKET = 0xa
- SOCK_RAW = 0x3
- SOCK_RDM = 0x4
- SOCK_SEQPACKET = 0x5
- SOCK_STREAM = 0x1
- SOL_AAL = 0x109
- SOL_ALG = 0x117
- SOL_ATM = 0x108
- SOL_CAIF = 0x116
- SOL_DCCP = 0x10d
- SOL_DECNET = 0x105
- SOL_ICMPV6 = 0x3a
- SOL_IP = 0x0
- SOL_IPV6 = 0x29
- SOL_IRDA = 0x10a
- SOL_IUCV = 0x115
- SOL_KCM = 0x119
- SOL_LLC = 0x10c
- SOL_NETBEUI = 0x10b
- SOL_NETLINK = 0x10e
- SOL_NFC = 0x118
- SOL_PACKET = 0x107
- SOL_PNPIPE = 0x113
- SOL_PPPOL2TP = 0x111
- SOL_RAW = 0xff
- SOL_RDS = 0x114
- SOL_RXRPC = 0x110
- SOL_SOCKET = 0xffff
- SOL_TCP = 0x6
- SOL_TIPC = 0x10f
- SOL_X25 = 0x106
- SOMAXCONN = 0x80
- SO_ACCEPTCONN = 0x8000
- SO_ATTACH_BPF = 0x34
- SO_ATTACH_FILTER = 0x1a
- SO_ATTACH_REUSEPORT_CBPF = 0x35
- SO_ATTACH_REUSEPORT_EBPF = 0x36
- SO_BINDTODEVICE = 0xd
- SO_BPF_EXTENSIONS = 0x32
- SO_BROADCAST = 0x20
- SO_BSDCOMPAT = 0x400
- SO_BUSY_POLL = 0x30
- SO_CNX_ADVICE = 0x37
- SO_DEBUG = 0x1
- SO_DETACH_BPF = 0x1b
- SO_DETACH_FILTER = 0x1b
- SO_DOMAIN = 0x1029
- SO_DONTROUTE = 0x10
- SO_ERROR = 0x1007
- SO_GET_FILTER = 0x1a
- SO_INCOMING_CPU = 0x33
- SO_KEEPALIVE = 0x8
- SO_LINGER = 0x80
- SO_LOCK_FILTER = 0x28
- SO_MARK = 0x22
- SO_MAX_PACING_RATE = 0x31
- SO_NOFCS = 0x27
- SO_NO_CHECK = 0xb
- SO_OOBINLINE = 0x100
- SO_PASSCRED = 0x2
- SO_PASSSEC = 0x1f
- SO_PEEK_OFF = 0x26
- SO_PEERCRED = 0x40
- SO_PEERNAME = 0x1c
- SO_PEERSEC = 0x1e
- SO_PRIORITY = 0xc
- SO_PROTOCOL = 0x1028
- SO_RCVBUF = 0x1002
- SO_RCVBUFFORCE = 0x100b
- SO_RCVLOWAT = 0x800
- SO_RCVTIMEO = 0x2000
- SO_REUSEADDR = 0x4
- SO_REUSEPORT = 0x200
- SO_RXQ_OVFL = 0x24
- SO_SECURITY_AUTHENTICATION = 0x5001
- SO_SECURITY_ENCRYPTION_NETWORK = 0x5004
- SO_SECURITY_ENCRYPTION_TRANSPORT = 0x5002
- SO_SELECT_ERR_QUEUE = 0x29
- SO_SNDBUF = 0x1001
- SO_SNDBUFFORCE = 0x100a
- SO_SNDLOWAT = 0x1000
- SO_SNDTIMEO = 0x4000
- SO_TIMESTAMP = 0x1d
- SO_TIMESTAMPING = 0x23
- SO_TIMESTAMPNS = 0x21
- SO_TYPE = 0x1008
- SO_VM_SOCKETS_BUFFER_MAX_SIZE = 0x2
- SO_VM_SOCKETS_BUFFER_MIN_SIZE = 0x1
- SO_VM_SOCKETS_BUFFER_SIZE = 0x0
- SO_VM_SOCKETS_CONNECT_TIMEOUT = 0x6
- SO_VM_SOCKETS_NONBLOCK_TXRX = 0x7
- SO_VM_SOCKETS_PEER_HOST_VM_ID = 0x3
- SO_VM_SOCKETS_TRUSTED = 0x5
- SO_WIFI_STATUS = 0x25
- SPLICE_F_GIFT = 0x8
- SPLICE_F_MORE = 0x4
- SPLICE_F_MOVE = 0x1
- SPLICE_F_NONBLOCK = 0x2
- S_BLKSIZE = 0x200
- S_IEXEC = 0x40
- S_IFBLK = 0x6000
- S_IFCHR = 0x2000
- S_IFDIR = 0x4000
- S_IFIFO = 0x1000
- S_IFLNK = 0xa000
- S_IFMT = 0xf000
- S_IFREG = 0x8000
- S_IFSOCK = 0xc000
- S_IREAD = 0x100
- S_IRGRP = 0x20
- S_IROTH = 0x4
- S_IRUSR = 0x100
- S_IRWXG = 0x38
- S_IRWXO = 0x7
- S_IRWXU = 0x1c0
- S_ISGID = 0x400
- S_ISUID = 0x800
- S_ISVTX = 0x200
- S_IWGRP = 0x10
- S_IWOTH = 0x2
- S_IWRITE = 0x80
- S_IWUSR = 0x80
- S_IXGRP = 0x8
- S_IXOTH = 0x1
- S_IXUSR = 0x40
- TAB0 = 0x0
- TAB1 = 0x800
- TAB2 = 0x1000
- TAB3 = 0x1800
- TABDLY = 0x1800
- TCFLSH = 0x20005407
- TCGETA = 0x40125401
- TCGETS = 0x40245408
- TCGETS2 = 0x402c540c
- TCIFLUSH = 0x0
- TCIOFF = 0x2
- TCIOFLUSH = 0x2
- TCION = 0x3
- TCOFLUSH = 0x1
- TCOOFF = 0x0
- TCOON = 0x1
- TCP_CC_INFO = 0x1a
- TCP_CONGESTION = 0xd
- TCP_COOKIE_IN_ALWAYS = 0x1
- TCP_COOKIE_MAX = 0x10
- TCP_COOKIE_MIN = 0x8
- TCP_COOKIE_OUT_NEVER = 0x2
- TCP_COOKIE_PAIR_SIZE = 0x20
- TCP_COOKIE_TRANSACTIONS = 0xf
- TCP_CORK = 0x3
- TCP_DEFER_ACCEPT = 0x9
- TCP_FASTOPEN = 0x17
- TCP_INFO = 0xb
- TCP_KEEPCNT = 0x6
- TCP_KEEPIDLE = 0x4
- TCP_KEEPINTVL = 0x5
- TCP_LINGER2 = 0x8
- TCP_MAXSEG = 0x2
- TCP_MAXWIN = 0xffff
- TCP_MAX_WINSHIFT = 0xe
- TCP_MD5SIG = 0xe
- TCP_MD5SIG_MAXKEYLEN = 0x50
- TCP_MSS = 0x200
- TCP_MSS_DEFAULT = 0x218
- TCP_MSS_DESIRED = 0x4c4
- TCP_NODELAY = 0x1
- TCP_NOTSENT_LOWAT = 0x19
- TCP_QUEUE_SEQ = 0x15
- TCP_QUICKACK = 0xc
- TCP_REPAIR = 0x13
- TCP_REPAIR_OPTIONS = 0x16
- TCP_REPAIR_QUEUE = 0x14
- TCP_SAVED_SYN = 0x1c
- TCP_SAVE_SYN = 0x1b
- TCP_SYNCNT = 0x7
- TCP_S_DATA_IN = 0x4
- TCP_S_DATA_OUT = 0x8
- TCP_THIN_DUPACK = 0x11
- TCP_THIN_LINEAR_TIMEOUTS = 0x10
- TCP_TIMESTAMP = 0x18
- TCP_USER_TIMEOUT = 0x12
- TCP_WINDOW_CLAMP = 0xa
- TCSAFLUSH = 0x2
- TCSBRK = 0x20005405
- TCSBRKP = 0x5425
- TCSETA = 0x80125402
- TCSETAF = 0x80125404
- TCSETAW = 0x80125403
- TCSETS = 0x80245409
- TCSETS2 = 0x802c540d
- TCSETSF = 0x8024540b
- TCSETSF2 = 0x802c540f
- TCSETSW = 0x8024540a
- TCSETSW2 = 0x802c540e
- TCXONC = 0x20005406
- TIOCCBRK = 0x2000747a
- TIOCCONS = 0x20007424
- TIOCEXCL = 0x2000740d
- TIOCGDEV = 0x40045432
- TIOCGETD = 0x40047400
- TIOCGEXCL = 0x40045440
- TIOCGICOUNT = 0x545d
- TIOCGLCKTRMIOS = 0x5456
- TIOCGPGRP = 0x40047483
- TIOCGPKT = 0x40045438
- TIOCGPTLCK = 0x40045439
- TIOCGPTN = 0x40047486
- TIOCGRS485 = 0x40205441
- TIOCGSERIAL = 0x541e
- TIOCGSID = 0x40047485
- TIOCGSOFTCAR = 0x40047464
- TIOCGWINSZ = 0x40087468
- TIOCINQ = 0x4004667f
- TIOCLINUX = 0x541c
- TIOCMBIC = 0x8004746b
- TIOCMBIS = 0x8004746c
- TIOCMGET = 0x4004746a
- TIOCMIWAIT = 0x545c
- TIOCMSET = 0x8004746d
- TIOCM_CAR = 0x40
- TIOCM_CD = 0x40
- TIOCM_CTS = 0x20
- TIOCM_DSR = 0x100
- TIOCM_DTR = 0x2
- TIOCM_LE = 0x1
- TIOCM_LOOP = 0x8000
- TIOCM_OUT1 = 0x2000
- TIOCM_OUT2 = 0x4000
- TIOCM_RI = 0x80
- TIOCM_RNG = 0x80
- TIOCM_RTS = 0x4
- TIOCM_SR = 0x10
- TIOCM_ST = 0x8
- TIOCNOTTY = 0x20007471
- TIOCNXCL = 0x2000740e
- TIOCOUTQ = 0x40047473
- TIOCPKT = 0x80047470
- TIOCPKT_DATA = 0x0
- TIOCPKT_DOSTOP = 0x20
- TIOCPKT_FLUSHREAD = 0x1
- TIOCPKT_FLUSHWRITE = 0x2
- TIOCPKT_IOCTL = 0x40
- TIOCPKT_NOSTOP = 0x10
- TIOCPKT_START = 0x8
- TIOCPKT_STOP = 0x4
- TIOCSBRK = 0x2000747b
- TIOCSCTTY = 0x20007484
- TIOCSERCONFIG = 0x5453
- TIOCSERGETLSR = 0x5459
- TIOCSERGETMULTI = 0x545a
- TIOCSERGSTRUCT = 0x5458
- TIOCSERGWILD = 0x5454
- TIOCSERSETMULTI = 0x545b
- TIOCSERSWILD = 0x5455
- TIOCSER_TEMT = 0x1
- TIOCSETD = 0x80047401
- TIOCSIG = 0x80047488
- TIOCSLCKTRMIOS = 0x5457
- TIOCSPGRP = 0x80047482
- TIOCSPTLCK = 0x80047487
- TIOCSRS485 = 0xc0205442
- TIOCSSERIAL = 0x541f
- TIOCSSOFTCAR = 0x80047465
- TIOCSTART = 0x2000746e
- TIOCSTI = 0x80017472
- TIOCSTOP = 0x2000746f
- TIOCSWINSZ = 0x80087467
- TIOCVHANGUP = 0x20005437
- TOSTOP = 0x100
- TUNATTACHFILTER = 0x801054d5
- TUNDETACHFILTER = 0x801054d6
- TUNGETFEATURES = 0x400454cf
- TUNGETFILTER = 0x401054db
- TUNGETIFF = 0x400454d2
- TUNGETSNDBUF = 0x400454d3
- TUNGETVNETBE = 0x400454df
- TUNGETVNETHDRSZ = 0x400454d7
- TUNGETVNETLE = 0x400454dd
- TUNSETDEBUG = 0x800454c9
- TUNSETGROUP = 0x800454ce
- TUNSETIFF = 0x800454ca
- TUNSETIFINDEX = 0x800454da
- TUNSETLINK = 0x800454cd
- TUNSETNOCSUM = 0x800454c8
- TUNSETOFFLOAD = 0x800454d0
- TUNSETOWNER = 0x800454cc
- TUNSETPERSIST = 0x800454cb
- TUNSETQUEUE = 0x800454d9
- TUNSETSNDBUF = 0x800454d4
- TUNSETTXFILTER = 0x800454d1
- TUNSETVNETBE = 0x800454de
- TUNSETVNETHDRSZ = 0x800454d8
- TUNSETVNETLE = 0x800454dc
- VDISCARD = 0xd
- VDSUSP = 0xb
- VEOF = 0x4
- VEOL = 0x5
- VEOL2 = 0x6
- VERASE = 0x2
- VINTR = 0x0
- VKILL = 0x3
- VLNEXT = 0xf
- VMADDR_CID_ANY = 0xffffffff
- VMADDR_CID_HOST = 0x2
- VMADDR_CID_HYPERVISOR = 0x0
- VMADDR_CID_RESERVED = 0x1
- VMADDR_PORT_ANY = 0xffffffff
- VMIN = 0x4
- VQUIT = 0x1
- VREPRINT = 0xc
- VSTART = 0x8
- VSTOP = 0x9
- VSUSP = 0xa
- VSWTC = 0x7
- VT0 = 0x0
- VT1 = 0x4000
- VTDLY = 0x4000
- VTIME = 0x5
- VWERASE = 0xe
- WALL = 0x40000000
- WCLONE = 0x80000000
- WCONTINUED = 0x8
- WEXITED = 0x4
- WNOHANG = 0x1
- WNOTHREAD = 0x20000000
- WNOWAIT = 0x1000000
- WORDSIZE = 0x40
- WRAP = 0x20000
- WSTOPPED = 0x2
- WUNTRACED = 0x2
- XCASE = 0x4
- XTABS = 0x1800
- __TIOCFLUSH = 0x80047410
+ AAFS_MAGIC = 0x5a3c69f0
+ ADFS_SUPER_MAGIC = 0xadf5
+ AFFS_SUPER_MAGIC = 0xadff
+ AFS_FS_MAGIC = 0x6b414653
+ AFS_SUPER_MAGIC = 0x5346414f
+ AF_ALG = 0x26
+ AF_APPLETALK = 0x5
+ AF_ASH = 0x12
+ AF_ATMPVC = 0x8
+ AF_ATMSVC = 0x14
+ AF_AX25 = 0x3
+ AF_BLUETOOTH = 0x1f
+ AF_BRIDGE = 0x7
+ AF_CAIF = 0x25
+ AF_CAN = 0x1d
+ AF_DECnet = 0xc
+ AF_ECONET = 0x13
+ AF_FILE = 0x1
+ AF_IB = 0x1b
+ AF_IEEE802154 = 0x24
+ AF_INET = 0x2
+ AF_INET6 = 0xa
+ AF_IPX = 0x4
+ AF_IRDA = 0x17
+ AF_ISDN = 0x22
+ AF_IUCV = 0x20
+ AF_KCM = 0x29
+ AF_KEY = 0xf
+ AF_LLC = 0x1a
+ AF_LOCAL = 0x1
+ AF_MAX = 0x2c
+ AF_MPLS = 0x1c
+ AF_NETBEUI = 0xd
+ AF_NETLINK = 0x10
+ AF_NETROM = 0x6
+ AF_NFC = 0x27
+ AF_PACKET = 0x11
+ AF_PHONET = 0x23
+ AF_PPPOX = 0x18
+ AF_QIPCRTR = 0x2a
+ AF_RDS = 0x15
+ AF_ROSE = 0xb
+ AF_ROUTE = 0x10
+ AF_RXRPC = 0x21
+ AF_SECURITY = 0xe
+ AF_SMC = 0x2b
+ AF_SNA = 0x16
+ AF_TIPC = 0x1e
+ AF_UNIX = 0x1
+ AF_UNSPEC = 0x0
+ AF_VSOCK = 0x28
+ AF_WANPIPE = 0x19
+ AF_X25 = 0x9
+ AF_XDP = 0x2c
+ ALG_OP_DECRYPT = 0x0
+ ALG_OP_ENCRYPT = 0x1
+ ALG_SET_AEAD_ASSOCLEN = 0x4
+ ALG_SET_AEAD_AUTHSIZE = 0x5
+ ALG_SET_IV = 0x2
+ ALG_SET_KEY = 0x1
+ ALG_SET_OP = 0x3
+ ANON_INODE_FS_MAGIC = 0x9041934
+ ARPHRD_6LOWPAN = 0x339
+ ARPHRD_ADAPT = 0x108
+ ARPHRD_APPLETLK = 0x8
+ ARPHRD_ARCNET = 0x7
+ ARPHRD_ASH = 0x30d
+ ARPHRD_ATM = 0x13
+ ARPHRD_AX25 = 0x3
+ ARPHRD_BIF = 0x307
+ ARPHRD_CAIF = 0x336
+ ARPHRD_CAN = 0x118
+ ARPHRD_CHAOS = 0x5
+ ARPHRD_CISCO = 0x201
+ ARPHRD_CSLIP = 0x101
+ ARPHRD_CSLIP6 = 0x103
+ ARPHRD_DDCMP = 0x205
+ ARPHRD_DLCI = 0xf
+ ARPHRD_ECONET = 0x30e
+ ARPHRD_EETHER = 0x2
+ ARPHRD_ETHER = 0x1
+ ARPHRD_EUI64 = 0x1b
+ ARPHRD_FCAL = 0x311
+ ARPHRD_FCFABRIC = 0x313
+ ARPHRD_FCPL = 0x312
+ ARPHRD_FCPP = 0x310
+ ARPHRD_FDDI = 0x306
+ ARPHRD_FRAD = 0x302
+ ARPHRD_HDLC = 0x201
+ ARPHRD_HIPPI = 0x30c
+ ARPHRD_HWX25 = 0x110
+ ARPHRD_IEEE1394 = 0x18
+ ARPHRD_IEEE802 = 0x6
+ ARPHRD_IEEE80211 = 0x321
+ ARPHRD_IEEE80211_PRISM = 0x322
+ ARPHRD_IEEE80211_RADIOTAP = 0x323
+ ARPHRD_IEEE802154 = 0x324
+ ARPHRD_IEEE802154_MONITOR = 0x325
+ ARPHRD_IEEE802_TR = 0x320
+ ARPHRD_INFINIBAND = 0x20
+ ARPHRD_IP6GRE = 0x337
+ ARPHRD_IPDDP = 0x309
+ ARPHRD_IPGRE = 0x30a
+ ARPHRD_IRDA = 0x30f
+ ARPHRD_LAPB = 0x204
+ ARPHRD_LOCALTLK = 0x305
+ ARPHRD_LOOPBACK = 0x304
+ ARPHRD_METRICOM = 0x17
+ ARPHRD_NETLINK = 0x338
+ ARPHRD_NETROM = 0x0
+ ARPHRD_NONE = 0xfffe
+ ARPHRD_PHONET = 0x334
+ ARPHRD_PHONET_PIPE = 0x335
+ ARPHRD_PIMREG = 0x30b
+ ARPHRD_PPP = 0x200
+ ARPHRD_PRONET = 0x4
+ ARPHRD_RAWHDLC = 0x206
+ ARPHRD_RAWIP = 0x207
+ ARPHRD_ROSE = 0x10e
+ ARPHRD_RSRVD = 0x104
+ ARPHRD_SIT = 0x308
+ ARPHRD_SKIP = 0x303
+ ARPHRD_SLIP = 0x100
+ ARPHRD_SLIP6 = 0x102
+ ARPHRD_TUNNEL = 0x300
+ ARPHRD_TUNNEL6 = 0x301
+ ARPHRD_VOID = 0xffff
+ ARPHRD_VSOCKMON = 0x33a
+ ARPHRD_X25 = 0x10f
+ ASI_LEON_DFLUSH = 0x11
+ ASI_LEON_IFLUSH = 0x10
+ ASI_LEON_MMUFLUSH = 0x18
+ AUTOFS_SUPER_MAGIC = 0x187
+ B0 = 0x0
+ B1000000 = 0x1008
+ B110 = 0x3
+ B115200 = 0x1002
+ B1152000 = 0x1009
+ B1200 = 0x9
+ B134 = 0x4
+ B150 = 0x5
+ B1500000 = 0x100a
+ B1800 = 0xa
+ B19200 = 0xe
+ B200 = 0x6
+ B2000000 = 0x100b
+ B230400 = 0x1003
+ B2400 = 0xb
+ B2500000 = 0x100c
+ B300 = 0x7
+ B3000000 = 0x100d
+ B3500000 = 0x100e
+ B38400 = 0xf
+ B4000000 = 0x100f
+ B460800 = 0x1004
+ B4800 = 0xc
+ B50 = 0x1
+ B500000 = 0x1005
+ B57600 = 0x1001
+ B576000 = 0x1006
+ B600 = 0x8
+ B75 = 0x2
+ B921600 = 0x1007
+ B9600 = 0xd
+ BALLOON_KVM_MAGIC = 0x13661366
+ BDEVFS_MAGIC = 0x62646576
+ BINFMTFS_MAGIC = 0x42494e4d
+ BLKBSZGET = 0x40081270
+ BLKBSZSET = 0x80081271
+ BLKFLSBUF = 0x20001261
+ BLKFRAGET = 0x20001265
+ BLKFRASET = 0x20001264
+ BLKGETSIZE = 0x20001260
+ BLKGETSIZE64 = 0x40081272
+ BLKPBSZGET = 0x2000127b
+ BLKRAGET = 0x20001263
+ BLKRASET = 0x20001262
+ BLKROGET = 0x2000125e
+ BLKROSET = 0x2000125d
+ BLKRRPART = 0x2000125f
+ BLKSECTGET = 0x20001267
+ BLKSECTSET = 0x20001266
+ BLKSSZGET = 0x20001268
+ BOTHER = 0x1000
+ BPF_A = 0x10
+ BPF_ABS = 0x20
+ BPF_ADD = 0x0
+ BPF_ALU = 0x4
+ BPF_AND = 0x50
+ BPF_B = 0x10
+ BPF_DIV = 0x30
+ BPF_FS_MAGIC = 0xcafe4a11
+ BPF_H = 0x8
+ BPF_IMM = 0x0
+ BPF_IND = 0x40
+ BPF_JA = 0x0
+ BPF_JEQ = 0x10
+ BPF_JGE = 0x30
+ BPF_JGT = 0x20
+ BPF_JMP = 0x5
+ BPF_JSET = 0x40
+ BPF_K = 0x0
+ BPF_LD = 0x0
+ BPF_LDX = 0x1
+ BPF_LEN = 0x80
+ BPF_LL_OFF = -0x200000
+ BPF_LSH = 0x60
+ BPF_MAJOR_VERSION = 0x1
+ BPF_MAXINSNS = 0x1000
+ BPF_MEM = 0x60
+ BPF_MEMWORDS = 0x10
+ BPF_MINOR_VERSION = 0x1
+ BPF_MISC = 0x7
+ BPF_MOD = 0x90
+ BPF_MSH = 0xa0
+ BPF_MUL = 0x20
+ BPF_NEG = 0x80
+ BPF_NET_OFF = -0x100000
+ BPF_OR = 0x40
+ BPF_RET = 0x6
+ BPF_RSH = 0x70
+ BPF_ST = 0x2
+ BPF_STX = 0x3
+ BPF_SUB = 0x10
+ BPF_TAX = 0x0
+ BPF_TXA = 0x80
+ BPF_W = 0x0
+ BPF_X = 0x8
+ BPF_XOR = 0xa0
+ BRKINT = 0x2
+ BS0 = 0x0
+ BS1 = 0x2000
+ BSDLY = 0x2000
+ BTRFS_SUPER_MAGIC = 0x9123683e
+ BTRFS_TEST_MAGIC = 0x73727279
+ CAN_BCM = 0x2
+ CAN_EFF_FLAG = 0x80000000
+ CAN_EFF_ID_BITS = 0x1d
+ CAN_EFF_MASK = 0x1fffffff
+ CAN_ERR_FLAG = 0x20000000
+ CAN_ERR_MASK = 0x1fffffff
+ CAN_INV_FILTER = 0x20000000
+ CAN_ISOTP = 0x6
+ CAN_MAX_DLC = 0x8
+ CAN_MAX_DLEN = 0x8
+ CAN_MCNET = 0x5
+ CAN_MTU = 0x10
+ CAN_NPROTO = 0x7
+ CAN_RAW = 0x1
+ CAN_RAW_FILTER_MAX = 0x200
+ CAN_RTR_FLAG = 0x40000000
+ CAN_SFF_ID_BITS = 0xb
+ CAN_SFF_MASK = 0x7ff
+ CAN_TP16 = 0x3
+ CAN_TP20 = 0x4
+ CBAUD = 0x100f
+ CBAUDEX = 0x1000
+ CFLUSH = 0xf
+ CGROUP2_SUPER_MAGIC = 0x63677270
+ CGROUP_SUPER_MAGIC = 0x27e0eb
+ CIBAUD = 0x100f0000
+ CLOCAL = 0x800
+ CLOCK_BOOTTIME = 0x7
+ CLOCK_BOOTTIME_ALARM = 0x9
+ CLOCK_DEFAULT = 0x0
+ CLOCK_EXT = 0x1
+ CLOCK_INT = 0x2
+ CLOCK_MONOTONIC = 0x1
+ CLOCK_MONOTONIC_COARSE = 0x6
+ CLOCK_MONOTONIC_RAW = 0x4
+ CLOCK_PROCESS_CPUTIME_ID = 0x2
+ CLOCK_REALTIME = 0x0
+ CLOCK_REALTIME_ALARM = 0x8
+ CLOCK_REALTIME_COARSE = 0x5
+ CLOCK_TAI = 0xb
+ CLOCK_THREAD_CPUTIME_ID = 0x3
+ CLOCK_TXFROMRX = 0x4
+ CLOCK_TXINT = 0x3
+ CLONE_CHILD_CLEARTID = 0x200000
+ CLONE_CHILD_SETTID = 0x1000000
+ CLONE_DETACHED = 0x400000
+ CLONE_FILES = 0x400
+ CLONE_FS = 0x200
+ CLONE_IO = 0x80000000
+ CLONE_NEWCGROUP = 0x2000000
+ CLONE_NEWIPC = 0x8000000
+ CLONE_NEWNET = 0x40000000
+ CLONE_NEWNS = 0x20000
+ CLONE_NEWPID = 0x20000000
+ CLONE_NEWUSER = 0x10000000
+ CLONE_NEWUTS = 0x4000000
+ CLONE_PARENT = 0x8000
+ CLONE_PARENT_SETTID = 0x100000
+ CLONE_PTRACE = 0x2000
+ CLONE_SETTLS = 0x80000
+ CLONE_SIGHAND = 0x800
+ CLONE_SYSVSEM = 0x40000
+ CLONE_THREAD = 0x10000
+ CLONE_UNTRACED = 0x800000
+ CLONE_VFORK = 0x4000
+ CLONE_VM = 0x100
+ CMSPAR = 0x40000000
+ CODA_SUPER_MAGIC = 0x73757245
+ CR0 = 0x0
+ CR1 = 0x200
+ CR2 = 0x400
+ CR3 = 0x600
+ CRAMFS_MAGIC = 0x28cd3d45
+ CRDLY = 0x600
+ CREAD = 0x80
+ CRTSCTS = 0x80000000
+ CS5 = 0x0
+ CS6 = 0x10
+ CS7 = 0x20
+ CS8 = 0x30
+ CSIGNAL = 0xff
+ CSIZE = 0x30
+ CSTART = 0x11
+ CSTATUS = 0x0
+ CSTOP = 0x13
+ CSTOPB = 0x40
+ CSUSP = 0x1a
+ DAXFS_MAGIC = 0x64646178
+ DEBUGFS_MAGIC = 0x64626720
+ DEVPTS_SUPER_MAGIC = 0x1cd1
+ DT_BLK = 0x6
+ DT_CHR = 0x2
+ DT_DIR = 0x4
+ DT_FIFO = 0x1
+ DT_LNK = 0xa
+ DT_REG = 0x8
+ DT_SOCK = 0xc
+ DT_UNKNOWN = 0x0
+ DT_WHT = 0xe
+ ECHO = 0x8
+ ECHOCTL = 0x200
+ ECHOE = 0x10
+ ECHOK = 0x20
+ ECHOKE = 0x800
+ ECHONL = 0x40
+ ECHOPRT = 0x400
+ ECRYPTFS_SUPER_MAGIC = 0xf15f
+ EFD_CLOEXEC = 0x400000
+ EFD_NONBLOCK = 0x4000
+ EFD_SEMAPHORE = 0x1
+ EFIVARFS_MAGIC = 0xde5e81e4
+ EFS_SUPER_MAGIC = 0x414a53
+ EMT_TAGOVF = 0x1
+ ENCODING_DEFAULT = 0x0
+ ENCODING_FM_MARK = 0x3
+ ENCODING_FM_SPACE = 0x4
+ ENCODING_MANCHESTER = 0x5
+ ENCODING_NRZ = 0x1
+ ENCODING_NRZI = 0x2
+ EPOLLERR = 0x8
+ EPOLLET = 0x80000000
+ EPOLLEXCLUSIVE = 0x10000000
+ EPOLLHUP = 0x10
+ EPOLLIN = 0x1
+ EPOLLMSG = 0x400
+ EPOLLONESHOT = 0x40000000
+ EPOLLOUT = 0x4
+ EPOLLPRI = 0x2
+ EPOLLRDBAND = 0x80
+ EPOLLRDHUP = 0x2000
+ EPOLLRDNORM = 0x40
+ EPOLLWAKEUP = 0x20000000
+ EPOLLWRBAND = 0x200
+ EPOLLWRNORM = 0x100
+ EPOLL_CLOEXEC = 0x400000
+ EPOLL_CTL_ADD = 0x1
+ EPOLL_CTL_DEL = 0x2
+ EPOLL_CTL_MOD = 0x3
+ ETH_P_1588 = 0x88f7
+ ETH_P_8021AD = 0x88a8
+ ETH_P_8021AH = 0x88e7
+ ETH_P_8021Q = 0x8100
+ ETH_P_80221 = 0x8917
+ ETH_P_802_2 = 0x4
+ ETH_P_802_3 = 0x1
+ ETH_P_802_3_MIN = 0x600
+ ETH_P_802_EX1 = 0x88b5
+ ETH_P_AARP = 0x80f3
+ ETH_P_AF_IUCV = 0xfbfb
+ ETH_P_ALL = 0x3
+ ETH_P_AOE = 0x88a2
+ ETH_P_ARCNET = 0x1a
+ ETH_P_ARP = 0x806
+ ETH_P_ATALK = 0x809b
+ ETH_P_ATMFATE = 0x8884
+ ETH_P_ATMMPOA = 0x884c
+ ETH_P_AX25 = 0x2
+ ETH_P_BATMAN = 0x4305
+ ETH_P_BPQ = 0x8ff
+ ETH_P_CAIF = 0xf7
+ ETH_P_CAN = 0xc
+ ETH_P_CANFD = 0xd
+ ETH_P_CONTROL = 0x16
+ ETH_P_CUST = 0x6006
+ ETH_P_DDCMP = 0x6
+ ETH_P_DEC = 0x6000
+ ETH_P_DIAG = 0x6005
+ ETH_P_DNA_DL = 0x6001
+ ETH_P_DNA_RC = 0x6002
+ ETH_P_DNA_RT = 0x6003
+ ETH_P_DSA = 0x1b
+ ETH_P_ECONET = 0x18
+ ETH_P_EDSA = 0xdada
+ ETH_P_ERSPAN = 0x88be
+ ETH_P_ERSPAN2 = 0x22eb
+ ETH_P_FCOE = 0x8906
+ ETH_P_FIP = 0x8914
+ ETH_P_HDLC = 0x19
+ ETH_P_HSR = 0x892f
+ ETH_P_IBOE = 0x8915
+ ETH_P_IEEE802154 = 0xf6
+ ETH_P_IEEEPUP = 0xa00
+ ETH_P_IEEEPUPAT = 0xa01
+ ETH_P_IFE = 0xed3e
+ ETH_P_IP = 0x800
+ ETH_P_IPV6 = 0x86dd
+ ETH_P_IPX = 0x8137
+ ETH_P_IRDA = 0x17
+ ETH_P_LAT = 0x6004
+ ETH_P_LINK_CTL = 0x886c
+ ETH_P_LOCALTALK = 0x9
+ ETH_P_LOOP = 0x60
+ ETH_P_LOOPBACK = 0x9000
+ ETH_P_MACSEC = 0x88e5
+ ETH_P_MAP = 0xf9
+ ETH_P_MOBITEX = 0x15
+ ETH_P_MPLS_MC = 0x8848
+ ETH_P_MPLS_UC = 0x8847
+ ETH_P_MVRP = 0x88f5
+ ETH_P_NCSI = 0x88f8
+ ETH_P_NSH = 0x894f
+ ETH_P_PAE = 0x888e
+ ETH_P_PAUSE = 0x8808
+ ETH_P_PHONET = 0xf5
+ ETH_P_PPPTALK = 0x10
+ ETH_P_PPP_DISC = 0x8863
+ ETH_P_PPP_MP = 0x8
+ ETH_P_PPP_SES = 0x8864
+ ETH_P_PREAUTH = 0x88c7
+ ETH_P_PRP = 0x88fb
+ ETH_P_PUP = 0x200
+ ETH_P_PUPAT = 0x201
+ ETH_P_QINQ1 = 0x9100
+ ETH_P_QINQ2 = 0x9200
+ ETH_P_QINQ3 = 0x9300
+ ETH_P_RARP = 0x8035
+ ETH_P_SCA = 0x6007
+ ETH_P_SLOW = 0x8809
+ ETH_P_SNAP = 0x5
+ ETH_P_TDLS = 0x890d
+ ETH_P_TEB = 0x6558
+ ETH_P_TIPC = 0x88ca
+ ETH_P_TRAILER = 0x1c
+ ETH_P_TR_802_2 = 0x11
+ ETH_P_TSN = 0x22f0
+ ETH_P_WAN_PPP = 0x7
+ ETH_P_WCCP = 0x883e
+ ETH_P_X25 = 0x805
+ ETH_P_XDSA = 0xf8
+ EXABYTE_ENABLE_NEST = 0xf0
+ EXT2_SUPER_MAGIC = 0xef53
+ EXT3_SUPER_MAGIC = 0xef53
+ EXT4_SUPER_MAGIC = 0xef53
+ EXTA = 0xe
+ EXTB = 0xf
+ EXTPROC = 0x10000
+ F2FS_SUPER_MAGIC = 0xf2f52010
+ FALLOC_FL_COLLAPSE_RANGE = 0x8
+ FALLOC_FL_INSERT_RANGE = 0x20
+ FALLOC_FL_KEEP_SIZE = 0x1
+ FALLOC_FL_NO_HIDE_STALE = 0x4
+ FALLOC_FL_PUNCH_HOLE = 0x2
+ FALLOC_FL_UNSHARE_RANGE = 0x40
+ FALLOC_FL_ZERO_RANGE = 0x10
+ FD_CLOEXEC = 0x1
+ FD_SETSIZE = 0x400
+ FF0 = 0x0
+ FF1 = 0x8000
+ FFDLY = 0x8000
+ FLUSHO = 0x1000
+ FS_ENCRYPTION_MODE_AES_128_CBC = 0x5
+ FS_ENCRYPTION_MODE_AES_128_CTS = 0x6
+ FS_ENCRYPTION_MODE_AES_256_CBC = 0x3
+ FS_ENCRYPTION_MODE_AES_256_CTS = 0x4
+ FS_ENCRYPTION_MODE_AES_256_GCM = 0x2
+ FS_ENCRYPTION_MODE_AES_256_XTS = 0x1
+ FS_ENCRYPTION_MODE_INVALID = 0x0
+ FS_ENCRYPTION_MODE_SPECK128_256_CTS = 0x8
+ FS_ENCRYPTION_MODE_SPECK128_256_XTS = 0x7
+ FS_IOC_GET_ENCRYPTION_POLICY = 0x800c6615
+ FS_IOC_GET_ENCRYPTION_PWSALT = 0x80106614
+ FS_IOC_SET_ENCRYPTION_POLICY = 0x400c6613
+ FS_KEY_DESCRIPTOR_SIZE = 0x8
+ FS_KEY_DESC_PREFIX = "fscrypt:"
+ FS_KEY_DESC_PREFIX_SIZE = 0x8
+ FS_MAX_KEY_SIZE = 0x40
+ FS_POLICY_FLAGS_PAD_16 = 0x2
+ FS_POLICY_FLAGS_PAD_32 = 0x3
+ FS_POLICY_FLAGS_PAD_4 = 0x0
+ FS_POLICY_FLAGS_PAD_8 = 0x1
+ FS_POLICY_FLAGS_PAD_MASK = 0x3
+ FS_POLICY_FLAGS_VALID = 0x3
+ FUTEXFS_SUPER_MAGIC = 0xbad1dea
+ F_ADD_SEALS = 0x409
+ F_DUPFD = 0x0
+ F_DUPFD_CLOEXEC = 0x406
+ F_EXLCK = 0x4
+ F_GETFD = 0x1
+ F_GETFL = 0x3
+ F_GETLEASE = 0x401
+ F_GETLK = 0x7
+ F_GETLK64 = 0x7
+ F_GETOWN = 0x5
+ F_GETOWN_EX = 0x10
+ F_GETPIPE_SZ = 0x408
+ F_GETSIG = 0xb
+ F_GET_FILE_RW_HINT = 0x40d
+ F_GET_RW_HINT = 0x40b
+ F_GET_SEALS = 0x40a
+ F_LOCK = 0x1
+ F_NOTIFY = 0x402
+ F_OFD_GETLK = 0x24
+ F_OFD_SETLK = 0x25
+ F_OFD_SETLKW = 0x26
+ F_OK = 0x0
+ F_RDLCK = 0x1
+ F_SEAL_GROW = 0x4
+ F_SEAL_SEAL = 0x1
+ F_SEAL_SHRINK = 0x2
+ F_SEAL_WRITE = 0x8
+ F_SETFD = 0x2
+ F_SETFL = 0x4
+ F_SETLEASE = 0x400
+ F_SETLK = 0x8
+ F_SETLK64 = 0x8
+ F_SETLKW = 0x9
+ F_SETLKW64 = 0x9
+ F_SETOWN = 0x6
+ F_SETOWN_EX = 0xf
+ F_SETPIPE_SZ = 0x407
+ F_SETSIG = 0xa
+ F_SET_FILE_RW_HINT = 0x40e
+ F_SET_RW_HINT = 0x40c
+ F_SHLCK = 0x8
+ F_TEST = 0x3
+ F_TLOCK = 0x2
+ F_ULOCK = 0x0
+ F_UNLCK = 0x3
+ F_WRLCK = 0x2
+ GENL_ADMIN_PERM = 0x1
+ GENL_CMD_CAP_DO = 0x2
+ GENL_CMD_CAP_DUMP = 0x4
+ GENL_CMD_CAP_HASPOL = 0x8
+ GENL_HDRLEN = 0x4
+ GENL_ID_CTRL = 0x10
+ GENL_ID_PMCRAID = 0x12
+ GENL_ID_VFS_DQUOT = 0x11
+ GENL_MAX_ID = 0x3ff
+ GENL_MIN_ID = 0x10
+ GENL_NAMSIZ = 0x10
+ GENL_START_ALLOC = 0x13
+ GENL_UNS_ADMIN_PERM = 0x10
+ GRND_NONBLOCK = 0x1
+ GRND_RANDOM = 0x2
+ HDIO_DRIVE_CMD = 0x31f
+ HDIO_DRIVE_CMD_AEB = 0x31e
+ HDIO_DRIVE_CMD_HDR_SIZE = 0x4
+ HDIO_DRIVE_HOB_HDR_SIZE = 0x8
+ HDIO_DRIVE_RESET = 0x31c
+ HDIO_DRIVE_TASK = 0x31e
+ HDIO_DRIVE_TASKFILE = 0x31d
+ HDIO_DRIVE_TASK_HDR_SIZE = 0x8
+ HDIO_GETGEO = 0x301
+ HDIO_GET_32BIT = 0x309
+ HDIO_GET_ACOUSTIC = 0x30f
+ HDIO_GET_ADDRESS = 0x310
+ HDIO_GET_BUSSTATE = 0x31a
+ HDIO_GET_DMA = 0x30b
+ HDIO_GET_IDENTITY = 0x30d
+ HDIO_GET_KEEPSETTINGS = 0x308
+ HDIO_GET_MULTCOUNT = 0x304
+ HDIO_GET_NICE = 0x30c
+ HDIO_GET_NOWERR = 0x30a
+ HDIO_GET_QDMA = 0x305
+ HDIO_GET_UNMASKINTR = 0x302
+ HDIO_GET_WCACHE = 0x30e
+ HDIO_OBSOLETE_IDENTITY = 0x307
+ HDIO_SCAN_HWIF = 0x328
+ HDIO_SET_32BIT = 0x324
+ HDIO_SET_ACOUSTIC = 0x32c
+ HDIO_SET_ADDRESS = 0x32f
+ HDIO_SET_BUSSTATE = 0x32d
+ HDIO_SET_DMA = 0x326
+ HDIO_SET_KEEPSETTINGS = 0x323
+ HDIO_SET_MULTCOUNT = 0x321
+ HDIO_SET_NICE = 0x329
+ HDIO_SET_NOWERR = 0x325
+ HDIO_SET_PIO_MODE = 0x327
+ HDIO_SET_QDMA = 0x32e
+ HDIO_SET_UNMASKINTR = 0x322
+ HDIO_SET_WCACHE = 0x32b
+ HDIO_SET_XFER = 0x306
+ HDIO_TRISTATE_HWIF = 0x31b
+ HDIO_UNREGISTER_HWIF = 0x32a
+ HOSTFS_SUPER_MAGIC = 0xc0ffee
+ HPFS_SUPER_MAGIC = 0xf995e849
+ HUGETLBFS_MAGIC = 0x958458f6
+ HUPCL = 0x400
+ IBSHIFT = 0x10
+ ICANON = 0x2
+ ICMPV6_FILTER = 0x1
+ ICRNL = 0x100
+ IEXTEN = 0x8000
+ IFA_F_DADFAILED = 0x8
+ IFA_F_DEPRECATED = 0x20
+ IFA_F_HOMEADDRESS = 0x10
+ IFA_F_MANAGETEMPADDR = 0x100
+ IFA_F_MCAUTOJOIN = 0x400
+ IFA_F_NODAD = 0x2
+ IFA_F_NOPREFIXROUTE = 0x200
+ IFA_F_OPTIMISTIC = 0x4
+ IFA_F_PERMANENT = 0x80
+ IFA_F_SECONDARY = 0x1
+ IFA_F_STABLE_PRIVACY = 0x800
+ IFA_F_TEMPORARY = 0x1
+ IFA_F_TENTATIVE = 0x40
+ IFA_MAX = 0x9
+ IFF_ALLMULTI = 0x200
+ IFF_ATTACH_QUEUE = 0x200
+ IFF_AUTOMEDIA = 0x4000
+ IFF_BROADCAST = 0x2
+ IFF_DEBUG = 0x4
+ IFF_DETACH_QUEUE = 0x400
+ IFF_DORMANT = 0x20000
+ IFF_DYNAMIC = 0x8000
+ IFF_ECHO = 0x40000
+ IFF_LOOPBACK = 0x8
+ IFF_LOWER_UP = 0x10000
+ IFF_MASTER = 0x400
+ IFF_MULTICAST = 0x1000
+ IFF_MULTI_QUEUE = 0x100
+ IFF_NAPI = 0x10
+ IFF_NAPI_FRAGS = 0x20
+ IFF_NOARP = 0x80
+ IFF_NOFILTER = 0x1000
+ IFF_NOTRAILERS = 0x20
+ IFF_NO_PI = 0x1000
+ IFF_ONE_QUEUE = 0x2000
+ IFF_PERSIST = 0x800
+ IFF_POINTOPOINT = 0x10
+ IFF_PORTSEL = 0x2000
+ IFF_PROMISC = 0x100
+ IFF_RUNNING = 0x40
+ IFF_SLAVE = 0x800
+ IFF_TAP = 0x2
+ IFF_TUN = 0x1
+ IFF_TUN_EXCL = 0x8000
+ IFF_UP = 0x1
+ IFF_VNET_HDR = 0x4000
+ IFF_VOLATILE = 0x70c5a
+ IFNAMSIZ = 0x10
+ IGNBRK = 0x1
+ IGNCR = 0x80
+ IGNPAR = 0x4
+ IMAXBEL = 0x2000
+ INLCR = 0x40
+ INPCK = 0x10
+ IN_ACCESS = 0x1
+ IN_ALL_EVENTS = 0xfff
+ IN_ATTRIB = 0x4
+ IN_CLASSA_HOST = 0xffffff
+ IN_CLASSA_MAX = 0x80
+ IN_CLASSA_NET = 0xff000000
+ IN_CLASSA_NSHIFT = 0x18
+ IN_CLASSB_HOST = 0xffff
+ IN_CLASSB_MAX = 0x10000
+ IN_CLASSB_NET = 0xffff0000
+ IN_CLASSB_NSHIFT = 0x10
+ IN_CLASSC_HOST = 0xff
+ IN_CLASSC_NET = 0xffffff00
+ IN_CLASSC_NSHIFT = 0x8
+ IN_CLOEXEC = 0x400000
+ IN_CLOSE = 0x18
+ IN_CLOSE_NOWRITE = 0x10
+ IN_CLOSE_WRITE = 0x8
+ IN_CREATE = 0x100
+ IN_DELETE = 0x200
+ IN_DELETE_SELF = 0x400
+ IN_DONT_FOLLOW = 0x2000000
+ IN_EXCL_UNLINK = 0x4000000
+ IN_IGNORED = 0x8000
+ IN_ISDIR = 0x40000000
+ IN_LOOPBACKNET = 0x7f
+ IN_MASK_ADD = 0x20000000
+ IN_MODIFY = 0x2
+ IN_MOVE = 0xc0
+ IN_MOVED_FROM = 0x40
+ IN_MOVED_TO = 0x80
+ IN_MOVE_SELF = 0x800
+ IN_NONBLOCK = 0x4000
+ IN_ONESHOT = 0x80000000
+ IN_ONLYDIR = 0x1000000
+ IN_OPEN = 0x20
+ IN_Q_OVERFLOW = 0x4000
+ IN_UNMOUNT = 0x2000
+ IOCTL_VM_SOCKETS_GET_LOCAL_CID = 0x200007b9
+ IPPROTO_AH = 0x33
+ IPPROTO_BEETPH = 0x5e
+ IPPROTO_COMP = 0x6c
+ IPPROTO_DCCP = 0x21
+ IPPROTO_DSTOPTS = 0x3c
+ IPPROTO_EGP = 0x8
+ IPPROTO_ENCAP = 0x62
+ IPPROTO_ESP = 0x32
+ IPPROTO_FRAGMENT = 0x2c
+ IPPROTO_GRE = 0x2f
+ IPPROTO_HOPOPTS = 0x0
+ IPPROTO_ICMP = 0x1
+ IPPROTO_ICMPV6 = 0x3a
+ IPPROTO_IDP = 0x16
+ IPPROTO_IGMP = 0x2
+ IPPROTO_IP = 0x0
+ IPPROTO_IPIP = 0x4
+ IPPROTO_IPV6 = 0x29
+ IPPROTO_MH = 0x87
+ IPPROTO_MPLS = 0x89
+ IPPROTO_MTP = 0x5c
+ IPPROTO_NONE = 0x3b
+ IPPROTO_PIM = 0x67
+ IPPROTO_PUP = 0xc
+ IPPROTO_RAW = 0xff
+ IPPROTO_ROUTING = 0x2b
+ IPPROTO_RSVP = 0x2e
+ IPPROTO_SCTP = 0x84
+ IPPROTO_TCP = 0x6
+ IPPROTO_TP = 0x1d
+ IPPROTO_UDP = 0x11
+ IPPROTO_UDPLITE = 0x88
+ IPV6_2292DSTOPTS = 0x4
+ IPV6_2292HOPLIMIT = 0x8
+ IPV6_2292HOPOPTS = 0x3
+ IPV6_2292PKTINFO = 0x2
+ IPV6_2292PKTOPTIONS = 0x6
+ IPV6_2292RTHDR = 0x5
+ IPV6_ADDRFORM = 0x1
+ IPV6_ADDR_PREFERENCES = 0x48
+ IPV6_ADD_MEMBERSHIP = 0x14
+ IPV6_AUTHHDR = 0xa
+ IPV6_AUTOFLOWLABEL = 0x46
+ IPV6_CHECKSUM = 0x7
+ IPV6_DONTFRAG = 0x3e
+ IPV6_DROP_MEMBERSHIP = 0x15
+ IPV6_DSTOPTS = 0x3b
+ IPV6_FREEBIND = 0x4e
+ IPV6_HDRINCL = 0x24
+ IPV6_HOPLIMIT = 0x34
+ IPV6_HOPOPTS = 0x36
+ IPV6_IPSEC_POLICY = 0x22
+ IPV6_JOIN_ANYCAST = 0x1b
+ IPV6_JOIN_GROUP = 0x14
+ IPV6_LEAVE_ANYCAST = 0x1c
+ IPV6_LEAVE_GROUP = 0x15
+ IPV6_MINHOPCOUNT = 0x49
+ IPV6_MTU = 0x18
+ IPV6_MTU_DISCOVER = 0x17
+ IPV6_MULTICAST_HOPS = 0x12
+ IPV6_MULTICAST_IF = 0x11
+ IPV6_MULTICAST_LOOP = 0x13
+ IPV6_NEXTHOP = 0x9
+ IPV6_ORIGDSTADDR = 0x4a
+ IPV6_PATHMTU = 0x3d
+ IPV6_PKTINFO = 0x32
+ IPV6_PMTUDISC_DO = 0x2
+ IPV6_PMTUDISC_DONT = 0x0
+ IPV6_PMTUDISC_INTERFACE = 0x4
+ IPV6_PMTUDISC_OMIT = 0x5
+ IPV6_PMTUDISC_PROBE = 0x3
+ IPV6_PMTUDISC_WANT = 0x1
+ IPV6_RECVDSTOPTS = 0x3a
+ IPV6_RECVERR = 0x19
+ IPV6_RECVFRAGSIZE = 0x4d
+ IPV6_RECVHOPLIMIT = 0x33
+ IPV6_RECVHOPOPTS = 0x35
+ IPV6_RECVORIGDSTADDR = 0x4a
+ IPV6_RECVPATHMTU = 0x3c
+ IPV6_RECVPKTINFO = 0x31
+ IPV6_RECVRTHDR = 0x38
+ IPV6_RECVTCLASS = 0x42
+ IPV6_ROUTER_ALERT = 0x16
+ IPV6_RTHDR = 0x39
+ IPV6_RTHDRDSTOPTS = 0x37
+ IPV6_RTHDR_LOOSE = 0x0
+ IPV6_RTHDR_STRICT = 0x1
+ IPV6_RTHDR_TYPE_0 = 0x0
+ IPV6_RXDSTOPTS = 0x3b
+ IPV6_RXHOPOPTS = 0x36
+ IPV6_TCLASS = 0x43
+ IPV6_TRANSPARENT = 0x4b
+ IPV6_UNICAST_HOPS = 0x10
+ IPV6_UNICAST_IF = 0x4c
+ IPV6_V6ONLY = 0x1a
+ IPV6_XFRM_POLICY = 0x23
+ IP_ADD_MEMBERSHIP = 0x23
+ IP_ADD_SOURCE_MEMBERSHIP = 0x27
+ IP_BIND_ADDRESS_NO_PORT = 0x18
+ IP_BLOCK_SOURCE = 0x26
+ IP_CHECKSUM = 0x17
+ IP_DEFAULT_MULTICAST_LOOP = 0x1
+ IP_DEFAULT_MULTICAST_TTL = 0x1
+ IP_DF = 0x4000
+ IP_DROP_MEMBERSHIP = 0x24
+ IP_DROP_SOURCE_MEMBERSHIP = 0x28
+ IP_FREEBIND = 0xf
+ IP_HDRINCL = 0x3
+ IP_IPSEC_POLICY = 0x10
+ IP_MAXPACKET = 0xffff
+ IP_MAX_MEMBERSHIPS = 0x14
+ IP_MF = 0x2000
+ IP_MINTTL = 0x15
+ IP_MSFILTER = 0x29
+ IP_MSS = 0x240
+ IP_MTU = 0xe
+ IP_MTU_DISCOVER = 0xa
+ IP_MULTICAST_ALL = 0x31
+ IP_MULTICAST_IF = 0x20
+ IP_MULTICAST_LOOP = 0x22
+ IP_MULTICAST_TTL = 0x21
+ IP_NODEFRAG = 0x16
+ IP_OFFMASK = 0x1fff
+ IP_OPTIONS = 0x4
+ IP_ORIGDSTADDR = 0x14
+ IP_PASSSEC = 0x12
+ IP_PKTINFO = 0x8
+ IP_PKTOPTIONS = 0x9
+ IP_PMTUDISC = 0xa
+ IP_PMTUDISC_DO = 0x2
+ IP_PMTUDISC_DONT = 0x0
+ IP_PMTUDISC_INTERFACE = 0x4
+ IP_PMTUDISC_OMIT = 0x5
+ IP_PMTUDISC_PROBE = 0x3
+ IP_PMTUDISC_WANT = 0x1
+ IP_RECVERR = 0xb
+ IP_RECVFRAGSIZE = 0x19
+ IP_RECVOPTS = 0x6
+ IP_RECVORIGDSTADDR = 0x14
+ IP_RECVRETOPTS = 0x7
+ IP_RECVTOS = 0xd
+ IP_RECVTTL = 0xc
+ IP_RETOPTS = 0x7
+ IP_RF = 0x8000
+ IP_ROUTER_ALERT = 0x5
+ IP_TOS = 0x1
+ IP_TRANSPARENT = 0x13
+ IP_TTL = 0x2
+ IP_UNBLOCK_SOURCE = 0x25
+ IP_UNICAST_IF = 0x32
+ IP_XFRM_POLICY = 0x11
+ ISIG = 0x1
+ ISOFS_SUPER_MAGIC = 0x9660
+ ISTRIP = 0x20
+ IUCLC = 0x200
+ IUTF8 = 0x4000
+ IXANY = 0x800
+ IXOFF = 0x1000
+ IXON = 0x400
+ JFFS2_SUPER_MAGIC = 0x72b6
+ KEXEC_ARCH_386 = 0x30000
+ KEXEC_ARCH_68K = 0x40000
+ KEXEC_ARCH_AARCH64 = 0xb70000
+ KEXEC_ARCH_ARM = 0x280000
+ KEXEC_ARCH_DEFAULT = 0x0
+ KEXEC_ARCH_IA_64 = 0x320000
+ KEXEC_ARCH_MASK = 0xffff0000
+ KEXEC_ARCH_MIPS = 0x80000
+ KEXEC_ARCH_MIPS_LE = 0xa0000
+ KEXEC_ARCH_PPC = 0x140000
+ KEXEC_ARCH_PPC64 = 0x150000
+ KEXEC_ARCH_S390 = 0x160000
+ KEXEC_ARCH_SH = 0x2a0000
+ KEXEC_ARCH_X86_64 = 0x3e0000
+ KEXEC_FILE_NO_INITRAMFS = 0x4
+ KEXEC_FILE_ON_CRASH = 0x2
+ KEXEC_FILE_UNLOAD = 0x1
+ KEXEC_ON_CRASH = 0x1
+ KEXEC_PRESERVE_CONTEXT = 0x2
+ KEXEC_SEGMENT_MAX = 0x10
+ KEYCTL_ASSUME_AUTHORITY = 0x10
+ KEYCTL_CHOWN = 0x4
+ KEYCTL_CLEAR = 0x7
+ KEYCTL_DESCRIBE = 0x6
+ KEYCTL_DH_COMPUTE = 0x17
+ KEYCTL_GET_KEYRING_ID = 0x0
+ KEYCTL_GET_PERSISTENT = 0x16
+ KEYCTL_GET_SECURITY = 0x11
+ KEYCTL_INSTANTIATE = 0xc
+ KEYCTL_INSTANTIATE_IOV = 0x14
+ KEYCTL_INVALIDATE = 0x15
+ KEYCTL_JOIN_SESSION_KEYRING = 0x1
+ KEYCTL_LINK = 0x8
+ KEYCTL_NEGATE = 0xd
+ KEYCTL_READ = 0xb
+ KEYCTL_REJECT = 0x13
+ KEYCTL_RESTRICT_KEYRING = 0x1d
+ KEYCTL_REVOKE = 0x3
+ KEYCTL_SEARCH = 0xa
+ KEYCTL_SESSION_TO_PARENT = 0x12
+ KEYCTL_SETPERM = 0x5
+ KEYCTL_SET_REQKEY_KEYRING = 0xe
+ KEYCTL_SET_TIMEOUT = 0xf
+ KEYCTL_UNLINK = 0x9
+ KEYCTL_UPDATE = 0x2
+ KEY_REQKEY_DEFL_DEFAULT = 0x0
+ KEY_REQKEY_DEFL_GROUP_KEYRING = 0x6
+ KEY_REQKEY_DEFL_NO_CHANGE = -0x1
+ KEY_REQKEY_DEFL_PROCESS_KEYRING = 0x2
+ KEY_REQKEY_DEFL_REQUESTOR_KEYRING = 0x7
+ KEY_REQKEY_DEFL_SESSION_KEYRING = 0x3
+ KEY_REQKEY_DEFL_THREAD_KEYRING = 0x1
+ KEY_REQKEY_DEFL_USER_KEYRING = 0x4
+ KEY_REQKEY_DEFL_USER_SESSION_KEYRING = 0x5
+ KEY_SPEC_GROUP_KEYRING = -0x6
+ KEY_SPEC_PROCESS_KEYRING = -0x2
+ KEY_SPEC_REQKEY_AUTH_KEY = -0x7
+ KEY_SPEC_REQUESTOR_KEYRING = -0x8
+ KEY_SPEC_SESSION_KEYRING = -0x3
+ KEY_SPEC_THREAD_KEYRING = -0x1
+ KEY_SPEC_USER_KEYRING = -0x4
+ KEY_SPEC_USER_SESSION_KEYRING = -0x5
+ LINUX_REBOOT_CMD_CAD_OFF = 0x0
+ LINUX_REBOOT_CMD_CAD_ON = 0x89abcdef
+ LINUX_REBOOT_CMD_HALT = 0xcdef0123
+ LINUX_REBOOT_CMD_KEXEC = 0x45584543
+ LINUX_REBOOT_CMD_POWER_OFF = 0x4321fedc
+ LINUX_REBOOT_CMD_RESTART = 0x1234567
+ LINUX_REBOOT_CMD_RESTART2 = 0xa1b2c3d4
+ LINUX_REBOOT_CMD_SW_SUSPEND = 0xd000fce2
+ LINUX_REBOOT_MAGIC1 = 0xfee1dead
+ LINUX_REBOOT_MAGIC2 = 0x28121969
+ LOCK_EX = 0x2
+ LOCK_NB = 0x4
+ LOCK_SH = 0x1
+ LOCK_UN = 0x8
+ MADV_DODUMP = 0x11
+ MADV_DOFORK = 0xb
+ MADV_DONTDUMP = 0x10
+ MADV_DONTFORK = 0xa
+ MADV_DONTNEED = 0x4
+ MADV_FREE = 0x8
+ MADV_HUGEPAGE = 0xe
+ MADV_HWPOISON = 0x64
+ MADV_KEEPONFORK = 0x13
+ MADV_MERGEABLE = 0xc
+ MADV_NOHUGEPAGE = 0xf
+ MADV_NORMAL = 0x0
+ MADV_RANDOM = 0x1
+ MADV_REMOVE = 0x9
+ MADV_SEQUENTIAL = 0x2
+ MADV_UNMERGEABLE = 0xd
+ MADV_WILLNEED = 0x3
+ MADV_WIPEONFORK = 0x12
+ MAP_ANON = 0x20
+ MAP_ANONYMOUS = 0x20
+ MAP_DENYWRITE = 0x800
+ MAP_EXECUTABLE = 0x1000
+ MAP_FILE = 0x0
+ MAP_FIXED = 0x10
+ MAP_FIXED_NOREPLACE = 0x100000
+ MAP_GROWSDOWN = 0x200
+ MAP_HUGETLB = 0x40000
+ MAP_HUGE_MASK = 0x3f
+ MAP_HUGE_SHIFT = 0x1a
+ MAP_LOCKED = 0x100
+ MAP_NONBLOCK = 0x10000
+ MAP_NORESERVE = 0x40
+ MAP_POPULATE = 0x8000
+ MAP_PRIVATE = 0x2
+ MAP_RENAME = 0x20
+ MAP_SHARED = 0x1
+ MAP_SHARED_VALIDATE = 0x3
+ MAP_STACK = 0x20000
+ MAP_TYPE = 0xf
+ MCL_CURRENT = 0x2000
+ MCL_FUTURE = 0x4000
+ MCL_ONFAULT = 0x8000
+ MFD_ALLOW_SEALING = 0x2
+ MFD_CLOEXEC = 0x1
+ MFD_HUGETLB = 0x4
+ MFD_HUGE_16GB = -0x78000000
+ MFD_HUGE_16MB = 0x60000000
+ MFD_HUGE_1GB = 0x78000000
+ MFD_HUGE_1MB = 0x50000000
+ MFD_HUGE_256MB = 0x70000000
+ MFD_HUGE_2GB = 0x7c000000
+ MFD_HUGE_2MB = 0x54000000
+ MFD_HUGE_32MB = 0x64000000
+ MFD_HUGE_512KB = 0x4c000000
+ MFD_HUGE_512MB = 0x74000000
+ MFD_HUGE_64KB = 0x40000000
+ MFD_HUGE_8MB = 0x5c000000
+ MFD_HUGE_MASK = 0x3f
+ MFD_HUGE_SHIFT = 0x1a
+ MINIX2_SUPER_MAGIC = 0x2468
+ MINIX2_SUPER_MAGIC2 = 0x2478
+ MINIX3_SUPER_MAGIC = 0x4d5a
+ MINIX_SUPER_MAGIC = 0x137f
+ MINIX_SUPER_MAGIC2 = 0x138f
+ MNT_DETACH = 0x2
+ MNT_EXPIRE = 0x4
+ MNT_FORCE = 0x1
+ MODULE_INIT_IGNORE_MODVERSIONS = 0x1
+ MODULE_INIT_IGNORE_VERMAGIC = 0x2
+ MSDOS_SUPER_MAGIC = 0x4d44
+ MSG_BATCH = 0x40000
+ MSG_CMSG_CLOEXEC = 0x40000000
+ MSG_CONFIRM = 0x800
+ MSG_CTRUNC = 0x8
+ MSG_DONTROUTE = 0x4
+ MSG_DONTWAIT = 0x40
+ MSG_EOR = 0x80
+ MSG_ERRQUEUE = 0x2000
+ MSG_FASTOPEN = 0x20000000
+ MSG_FIN = 0x200
+ MSG_MORE = 0x8000
+ MSG_NOSIGNAL = 0x4000
+ MSG_OOB = 0x1
+ MSG_PEEK = 0x2
+ MSG_PROXY = 0x10
+ MSG_RST = 0x1000
+ MSG_SYN = 0x400
+ MSG_TRUNC = 0x20
+ MSG_TRYHARD = 0x4
+ MSG_WAITALL = 0x100
+ MSG_WAITFORONE = 0x10000
+ MSG_ZEROCOPY = 0x4000000
+ MS_ACTIVE = 0x40000000
+ MS_ASYNC = 0x1
+ MS_BIND = 0x1000
+ MS_BORN = 0x20000000
+ MS_DIRSYNC = 0x80
+ MS_INVALIDATE = 0x2
+ MS_I_VERSION = 0x800000
+ MS_KERNMOUNT = 0x400000
+ MS_LAZYTIME = 0x2000000
+ MS_MANDLOCK = 0x40
+ MS_MGC_MSK = 0xffff0000
+ MS_MGC_VAL = 0xc0ed0000
+ MS_MOVE = 0x2000
+ MS_NOATIME = 0x400
+ MS_NODEV = 0x4
+ MS_NODIRATIME = 0x800
+ MS_NOEXEC = 0x8
+ MS_NOREMOTELOCK = 0x8000000
+ MS_NOSEC = 0x10000000
+ MS_NOSUID = 0x2
+ MS_NOUSER = -0x80000000
+ MS_POSIXACL = 0x10000
+ MS_PRIVATE = 0x40000
+ MS_RDONLY = 0x1
+ MS_REC = 0x4000
+ MS_RELATIME = 0x200000
+ MS_REMOUNT = 0x20
+ MS_RMT_MASK = 0x2800051
+ MS_SHARED = 0x100000
+ MS_SILENT = 0x8000
+ MS_SLAVE = 0x80000
+ MS_STRICTATIME = 0x1000000
+ MS_SUBMOUNT = 0x4000000
+ MS_SYNC = 0x4
+ MS_SYNCHRONOUS = 0x10
+ MS_UNBINDABLE = 0x20000
+ MS_VERBOSE = 0x8000
+ MTD_INODE_FS_MAGIC = 0x11307854
+ NAME_MAX = 0xff
+ NCP_SUPER_MAGIC = 0x564c
+ NETLINK_ADD_MEMBERSHIP = 0x1
+ NETLINK_AUDIT = 0x9
+ NETLINK_BROADCAST_ERROR = 0x4
+ NETLINK_CAP_ACK = 0xa
+ NETLINK_CONNECTOR = 0xb
+ NETLINK_CRYPTO = 0x15
+ NETLINK_DNRTMSG = 0xe
+ NETLINK_DROP_MEMBERSHIP = 0x2
+ NETLINK_ECRYPTFS = 0x13
+ NETLINK_EXT_ACK = 0xb
+ NETLINK_FIB_LOOKUP = 0xa
+ NETLINK_FIREWALL = 0x3
+ NETLINK_GENERIC = 0x10
+ NETLINK_INET_DIAG = 0x4
+ NETLINK_IP6_FW = 0xd
+ NETLINK_ISCSI = 0x8
+ NETLINK_KOBJECT_UEVENT = 0xf
+ NETLINK_LISTEN_ALL_NSID = 0x8
+ NETLINK_LIST_MEMBERSHIPS = 0x9
+ NETLINK_NETFILTER = 0xc
+ NETLINK_NFLOG = 0x5
+ NETLINK_NO_ENOBUFS = 0x5
+ NETLINK_PKTINFO = 0x3
+ NETLINK_RDMA = 0x14
+ NETLINK_ROUTE = 0x0
+ NETLINK_RX_RING = 0x6
+ NETLINK_SCSITRANSPORT = 0x12
+ NETLINK_SELINUX = 0x7
+ NETLINK_SMC = 0x16
+ NETLINK_SOCK_DIAG = 0x4
+ NETLINK_TX_RING = 0x7
+ NETLINK_UNUSED = 0x1
+ NETLINK_USERSOCK = 0x2
+ NETLINK_XFRM = 0x6
+ NETNSA_MAX = 0x3
+ NETNSA_NSID_NOT_ASSIGNED = -0x1
+ NFNETLINK_V0 = 0x0
+ NFNLGRP_ACCT_QUOTA = 0x8
+ NFNLGRP_CONNTRACK_DESTROY = 0x3
+ NFNLGRP_CONNTRACK_EXP_DESTROY = 0x6
+ NFNLGRP_CONNTRACK_EXP_NEW = 0x4
+ NFNLGRP_CONNTRACK_EXP_UPDATE = 0x5
+ NFNLGRP_CONNTRACK_NEW = 0x1
+ NFNLGRP_CONNTRACK_UPDATE = 0x2
+ NFNLGRP_MAX = 0x9
+ NFNLGRP_NFTABLES = 0x7
+ NFNLGRP_NFTRACE = 0x9
+ NFNLGRP_NONE = 0x0
+ NFNL_BATCH_MAX = 0x1
+ NFNL_MSG_BATCH_BEGIN = 0x10
+ NFNL_MSG_BATCH_END = 0x11
+ NFNL_NFA_NEST = 0x8000
+ NFNL_SUBSYS_ACCT = 0x7
+ NFNL_SUBSYS_COUNT = 0xc
+ NFNL_SUBSYS_CTHELPER = 0x9
+ NFNL_SUBSYS_CTNETLINK = 0x1
+ NFNL_SUBSYS_CTNETLINK_EXP = 0x2
+ NFNL_SUBSYS_CTNETLINK_TIMEOUT = 0x8
+ NFNL_SUBSYS_IPSET = 0x6
+ NFNL_SUBSYS_NFTABLES = 0xa
+ NFNL_SUBSYS_NFT_COMPAT = 0xb
+ NFNL_SUBSYS_NONE = 0x0
+ NFNL_SUBSYS_OSF = 0x5
+ NFNL_SUBSYS_QUEUE = 0x3
+ NFNL_SUBSYS_ULOG = 0x4
+ NFS_SUPER_MAGIC = 0x6969
+ NILFS_SUPER_MAGIC = 0x3434
+ NL0 = 0x0
+ NL1 = 0x100
+ NLA_ALIGNTO = 0x4
+ NLA_F_NESTED = 0x8000
+ NLA_F_NET_BYTEORDER = 0x4000
+ NLA_HDRLEN = 0x4
+ NLDLY = 0x100
+ NLMSG_ALIGNTO = 0x4
+ NLMSG_DONE = 0x3
+ NLMSG_ERROR = 0x2
+ NLMSG_HDRLEN = 0x10
+ NLMSG_MIN_TYPE = 0x10
+ NLMSG_NOOP = 0x1
+ NLMSG_OVERRUN = 0x4
+ NLM_F_ACK = 0x4
+ NLM_F_ACK_TLVS = 0x200
+ NLM_F_APPEND = 0x800
+ NLM_F_ATOMIC = 0x400
+ NLM_F_CAPPED = 0x100
+ NLM_F_CREATE = 0x400
+ NLM_F_DUMP = 0x300
+ NLM_F_DUMP_FILTERED = 0x20
+ NLM_F_DUMP_INTR = 0x10
+ NLM_F_ECHO = 0x8
+ NLM_F_EXCL = 0x200
+ NLM_F_MATCH = 0x200
+ NLM_F_MULTI = 0x2
+ NLM_F_NONREC = 0x100
+ NLM_F_REPLACE = 0x100
+ NLM_F_REQUEST = 0x1
+ NLM_F_ROOT = 0x100
+ NOFLSH = 0x80
+ NSFS_MAGIC = 0x6e736673
+ OCFS2_SUPER_MAGIC = 0x7461636f
+ OCRNL = 0x8
+ OFDEL = 0x80
+ OFILL = 0x40
+ OLCUC = 0x2
+ ONLCR = 0x4
+ ONLRET = 0x20
+ ONOCR = 0x10
+ OPENPROM_SUPER_MAGIC = 0x9fa1
+ OPOST = 0x1
+ OVERLAYFS_SUPER_MAGIC = 0x794c7630
+ O_ACCMODE = 0x3
+ O_APPEND = 0x8
+ O_ASYNC = 0x40
+ O_CLOEXEC = 0x400000
+ O_CREAT = 0x200
+ O_DIRECT = 0x100000
+ O_DIRECTORY = 0x10000
+ O_DSYNC = 0x2000
+ O_EXCL = 0x800
+ O_FSYNC = 0x802000
+ O_LARGEFILE = 0x0
+ O_NDELAY = 0x4004
+ O_NOATIME = 0x200000
+ O_NOCTTY = 0x8000
+ O_NOFOLLOW = 0x20000
+ O_NONBLOCK = 0x4000
+ O_PATH = 0x1000000
+ O_RDONLY = 0x0
+ O_RDWR = 0x2
+ O_RSYNC = 0x802000
+ O_SYNC = 0x802000
+ O_TMPFILE = 0x2010000
+ O_TRUNC = 0x400
+ O_WRONLY = 0x1
+ PACKET_ADD_MEMBERSHIP = 0x1
+ PACKET_AUXDATA = 0x8
+ PACKET_BROADCAST = 0x1
+ PACKET_COPY_THRESH = 0x7
+ PACKET_DROP_MEMBERSHIP = 0x2
+ PACKET_FANOUT = 0x12
+ PACKET_FANOUT_CBPF = 0x6
+ PACKET_FANOUT_CPU = 0x2
+ PACKET_FANOUT_DATA = 0x16
+ PACKET_FANOUT_EBPF = 0x7
+ PACKET_FANOUT_FLAG_DEFRAG = 0x8000
+ PACKET_FANOUT_FLAG_ROLLOVER = 0x1000
+ PACKET_FANOUT_FLAG_UNIQUEID = 0x2000
+ PACKET_FANOUT_HASH = 0x0
+ PACKET_FANOUT_LB = 0x1
+ PACKET_FANOUT_QM = 0x5
+ PACKET_FANOUT_RND = 0x4
+ PACKET_FANOUT_ROLLOVER = 0x3
+ PACKET_FASTROUTE = 0x6
+ PACKET_HDRLEN = 0xb
+ PACKET_HOST = 0x0
+ PACKET_KERNEL = 0x7
+ PACKET_LOOPBACK = 0x5
+ PACKET_LOSS = 0xe
+ PACKET_MR_ALLMULTI = 0x2
+ PACKET_MR_MULTICAST = 0x0
+ PACKET_MR_PROMISC = 0x1
+ PACKET_MR_UNICAST = 0x3
+ PACKET_MULTICAST = 0x2
+ PACKET_ORIGDEV = 0x9
+ PACKET_OTHERHOST = 0x3
+ PACKET_OUTGOING = 0x4
+ PACKET_QDISC_BYPASS = 0x14
+ PACKET_RECV_OUTPUT = 0x3
+ PACKET_RESERVE = 0xc
+ PACKET_ROLLOVER_STATS = 0x15
+ PACKET_RX_RING = 0x5
+ PACKET_STATISTICS = 0x6
+ PACKET_TIMESTAMP = 0x11
+ PACKET_TX_HAS_OFF = 0x13
+ PACKET_TX_RING = 0xd
+ PACKET_TX_TIMESTAMP = 0x10
+ PACKET_USER = 0x6
+ PACKET_VERSION = 0xa
+ PACKET_VNET_HDR = 0xf
+ PARENB = 0x100
+ PARITY_CRC16_PR0 = 0x2
+ PARITY_CRC16_PR0_CCITT = 0x4
+ PARITY_CRC16_PR1 = 0x3
+ PARITY_CRC16_PR1_CCITT = 0x5
+ PARITY_CRC32_PR0_CCITT = 0x6
+ PARITY_CRC32_PR1_CCITT = 0x7
+ PARITY_DEFAULT = 0x0
+ PARITY_NONE = 0x1
+ PARMRK = 0x8
+ PARODD = 0x200
+ PENDIN = 0x4000
+ PERF_EVENT_IOC_DISABLE = 0x20002401
+ PERF_EVENT_IOC_ENABLE = 0x20002400
+ PERF_EVENT_IOC_ID = 0x40082407
+ PERF_EVENT_IOC_MODIFY_ATTRIBUTES = 0x8008240b
+ PERF_EVENT_IOC_PAUSE_OUTPUT = 0x80042409
+ PERF_EVENT_IOC_PERIOD = 0x80082404
+ PERF_EVENT_IOC_QUERY_BPF = 0xc008240a
+ PERF_EVENT_IOC_REFRESH = 0x20002402
+ PERF_EVENT_IOC_RESET = 0x20002403
+ PERF_EVENT_IOC_SET_BPF = 0x80042408
+ PERF_EVENT_IOC_SET_FILTER = 0x80082406
+ PERF_EVENT_IOC_SET_OUTPUT = 0x20002405
+ PIPEFS_MAGIC = 0x50495045
+ PPPIOCATTACH = 0x8004743d
+ PPPIOCATTCHAN = 0x80047438
+ PPPIOCCONNECT = 0x8004743a
+ PPPIOCDETACH = 0x8004743c
+ PPPIOCDISCONN = 0x20007439
+ PPPIOCGASYNCMAP = 0x40047458
+ PPPIOCGCHAN = 0x40047437
+ PPPIOCGDEBUG = 0x40047441
+ PPPIOCGFLAGS = 0x4004745a
+ PPPIOCGIDLE = 0x4010743f
+ PPPIOCGL2TPSTATS = 0x40487436
+ PPPIOCGMRU = 0x40047453
+ PPPIOCGNPMODE = 0xc008744c
+ PPPIOCGRASYNCMAP = 0x40047455
+ PPPIOCGUNIT = 0x40047456
+ PPPIOCGXASYNCMAP = 0x40207450
+ PPPIOCNEWUNIT = 0xc004743e
+ PPPIOCSACTIVE = 0x80107446
+ PPPIOCSASYNCMAP = 0x80047457
+ PPPIOCSCOMPRESS = 0x8010744d
+ PPPIOCSDEBUG = 0x80047440
+ PPPIOCSFLAGS = 0x80047459
+ PPPIOCSMAXCID = 0x80047451
+ PPPIOCSMRRU = 0x8004743b
+ PPPIOCSMRU = 0x80047452
+ PPPIOCSNPMODE = 0x8008744b
+ PPPIOCSPASS = 0x80107447
+ PPPIOCSRASYNCMAP = 0x80047454
+ PPPIOCSXASYNCMAP = 0x8020744f
+ PPPIOCXFERUNIT = 0x2000744e
+ PRIO_PGRP = 0x1
+ PRIO_PROCESS = 0x0
+ PRIO_USER = 0x2
+ PROC_SUPER_MAGIC = 0x9fa0
+ PROT_EXEC = 0x4
+ PROT_GROWSDOWN = 0x1000000
+ PROT_GROWSUP = 0x2000000
+ PROT_NONE = 0x0
+ PROT_READ = 0x1
+ PROT_WRITE = 0x2
+ PR_CAPBSET_DROP = 0x18
+ PR_CAPBSET_READ = 0x17
+ PR_CAP_AMBIENT = 0x2f
+ PR_CAP_AMBIENT_CLEAR_ALL = 0x4
+ PR_CAP_AMBIENT_IS_SET = 0x1
+ PR_CAP_AMBIENT_LOWER = 0x3
+ PR_CAP_AMBIENT_RAISE = 0x2
+ PR_ENDIAN_BIG = 0x0
+ PR_ENDIAN_LITTLE = 0x1
+ PR_ENDIAN_PPC_LITTLE = 0x2
+ PR_FPEMU_NOPRINT = 0x1
+ PR_FPEMU_SIGFPE = 0x2
+ PR_FP_EXC_ASYNC = 0x2
+ PR_FP_EXC_DISABLED = 0x0
+ PR_FP_EXC_DIV = 0x10000
+ PR_FP_EXC_INV = 0x100000
+ PR_FP_EXC_NONRECOV = 0x1
+ PR_FP_EXC_OVF = 0x20000
+ PR_FP_EXC_PRECISE = 0x3
+ PR_FP_EXC_RES = 0x80000
+ PR_FP_EXC_SW_ENABLE = 0x80
+ PR_FP_EXC_UND = 0x40000
+ PR_FP_MODE_FR = 0x1
+ PR_FP_MODE_FRE = 0x2
+ PR_GET_CHILD_SUBREAPER = 0x25
+ PR_GET_DUMPABLE = 0x3
+ PR_GET_ENDIAN = 0x13
+ PR_GET_FPEMU = 0x9
+ PR_GET_FPEXC = 0xb
+ PR_GET_FP_MODE = 0x2e
+ PR_GET_KEEPCAPS = 0x7
+ PR_GET_NAME = 0x10
+ PR_GET_NO_NEW_PRIVS = 0x27
+ PR_GET_PDEATHSIG = 0x2
+ PR_GET_SECCOMP = 0x15
+ PR_GET_SECUREBITS = 0x1b
+ PR_GET_SPECULATION_CTRL = 0x34
+ PR_GET_THP_DISABLE = 0x2a
+ PR_GET_TID_ADDRESS = 0x28
+ PR_GET_TIMERSLACK = 0x1e
+ PR_GET_TIMING = 0xd
+ PR_GET_TSC = 0x19
+ PR_GET_UNALIGN = 0x5
+ PR_MCE_KILL = 0x21
+ PR_MCE_KILL_CLEAR = 0x0
+ PR_MCE_KILL_DEFAULT = 0x2
+ PR_MCE_KILL_EARLY = 0x1
+ PR_MCE_KILL_GET = 0x22
+ PR_MCE_KILL_LATE = 0x0
+ PR_MCE_KILL_SET = 0x1
+ PR_MPX_DISABLE_MANAGEMENT = 0x2c
+ PR_MPX_ENABLE_MANAGEMENT = 0x2b
+ PR_SET_CHILD_SUBREAPER = 0x24
+ PR_SET_DUMPABLE = 0x4
+ PR_SET_ENDIAN = 0x14
+ PR_SET_FPEMU = 0xa
+ PR_SET_FPEXC = 0xc
+ PR_SET_FP_MODE = 0x2d
+ PR_SET_KEEPCAPS = 0x8
+ PR_SET_MM = 0x23
+ PR_SET_MM_ARG_END = 0x9
+ PR_SET_MM_ARG_START = 0x8
+ PR_SET_MM_AUXV = 0xc
+ PR_SET_MM_BRK = 0x7
+ PR_SET_MM_END_CODE = 0x2
+ PR_SET_MM_END_DATA = 0x4
+ PR_SET_MM_ENV_END = 0xb
+ PR_SET_MM_ENV_START = 0xa
+ PR_SET_MM_EXE_FILE = 0xd
+ PR_SET_MM_MAP = 0xe
+ PR_SET_MM_MAP_SIZE = 0xf
+ PR_SET_MM_START_BRK = 0x6
+ PR_SET_MM_START_CODE = 0x1
+ PR_SET_MM_START_DATA = 0x3
+ PR_SET_MM_START_STACK = 0x5
+ PR_SET_NAME = 0xf
+ PR_SET_NO_NEW_PRIVS = 0x26
+ PR_SET_PDEATHSIG = 0x1
+ PR_SET_PTRACER = 0x59616d61
+ PR_SET_PTRACER_ANY = 0xffffffffffffffff
+ PR_SET_SECCOMP = 0x16
+ PR_SET_SECUREBITS = 0x1c
+ PR_SET_SPECULATION_CTRL = 0x35
+ PR_SET_THP_DISABLE = 0x29
+ PR_SET_TIMERSLACK = 0x1d
+ PR_SET_TIMING = 0xe
+ PR_SET_TSC = 0x1a
+ PR_SET_UNALIGN = 0x6
+ PR_SPEC_DISABLE = 0x4
+ PR_SPEC_ENABLE = 0x2
+ PR_SPEC_FORCE_DISABLE = 0x8
+ PR_SPEC_NOT_AFFECTED = 0x0
+ PR_SPEC_PRCTL = 0x1
+ PR_SPEC_STORE_BYPASS = 0x0
+ PR_SVE_GET_VL = 0x33
+ PR_SVE_SET_VL = 0x32
+ PR_SVE_SET_VL_ONEXEC = 0x40000
+ PR_SVE_VL_INHERIT = 0x20000
+ PR_SVE_VL_LEN_MASK = 0xffff
+ PR_TASK_PERF_EVENTS_DISABLE = 0x1f
+ PR_TASK_PERF_EVENTS_ENABLE = 0x20
+ PR_TIMING_STATISTICAL = 0x0
+ PR_TIMING_TIMESTAMP = 0x1
+ PR_TSC_ENABLE = 0x1
+ PR_TSC_SIGSEGV = 0x2
+ PR_UNALIGN_NOPRINT = 0x1
+ PR_UNALIGN_SIGBUS = 0x2
+ PSTOREFS_MAGIC = 0x6165676c
+ PTRACE_ATTACH = 0x10
+ PTRACE_CONT = 0x7
+ PTRACE_DETACH = 0x11
+ PTRACE_EVENT_CLONE = 0x3
+ PTRACE_EVENT_EXEC = 0x4
+ PTRACE_EVENT_EXIT = 0x6
+ PTRACE_EVENT_FORK = 0x1
+ PTRACE_EVENT_SECCOMP = 0x7
+ PTRACE_EVENT_STOP = 0x80
+ PTRACE_EVENT_VFORK = 0x2
+ PTRACE_EVENT_VFORK_DONE = 0x5
+ PTRACE_GETEVENTMSG = 0x4201
+ PTRACE_GETFPAREGS = 0x14
+ PTRACE_GETFPREGS = 0xe
+ PTRACE_GETFPREGS64 = 0x19
+ PTRACE_GETREGS = 0xc
+ PTRACE_GETREGS64 = 0x16
+ PTRACE_GETREGSET = 0x4204
+ PTRACE_GETSIGINFO = 0x4202
+ PTRACE_GETSIGMASK = 0x420a
+ PTRACE_INTERRUPT = 0x4207
+ PTRACE_KILL = 0x8
+ PTRACE_LISTEN = 0x4208
+ PTRACE_O_EXITKILL = 0x100000
+ PTRACE_O_MASK = 0x3000ff
+ PTRACE_O_SUSPEND_SECCOMP = 0x200000
+ PTRACE_O_TRACECLONE = 0x8
+ PTRACE_O_TRACEEXEC = 0x10
+ PTRACE_O_TRACEEXIT = 0x40
+ PTRACE_O_TRACEFORK = 0x2
+ PTRACE_O_TRACESECCOMP = 0x80
+ PTRACE_O_TRACESYSGOOD = 0x1
+ PTRACE_O_TRACEVFORK = 0x4
+ PTRACE_O_TRACEVFORKDONE = 0x20
+ PTRACE_PEEKDATA = 0x2
+ PTRACE_PEEKSIGINFO = 0x4209
+ PTRACE_PEEKSIGINFO_SHARED = 0x1
+ PTRACE_PEEKTEXT = 0x1
+ PTRACE_PEEKUSR = 0x3
+ PTRACE_POKEDATA = 0x5
+ PTRACE_POKETEXT = 0x4
+ PTRACE_POKEUSR = 0x6
+ PTRACE_READDATA = 0x10
+ PTRACE_READTEXT = 0x12
+ PTRACE_SECCOMP_GET_FILTER = 0x420c
+ PTRACE_SECCOMP_GET_METADATA = 0x420d
+ PTRACE_SEIZE = 0x4206
+ PTRACE_SETFPAREGS = 0x15
+ PTRACE_SETFPREGS = 0xf
+ PTRACE_SETFPREGS64 = 0x1a
+ PTRACE_SETOPTIONS = 0x4200
+ PTRACE_SETREGS = 0xd
+ PTRACE_SETREGS64 = 0x17
+ PTRACE_SETREGSET = 0x4205
+ PTRACE_SETSIGINFO = 0x4203
+ PTRACE_SETSIGMASK = 0x420b
+ PTRACE_SINGLESTEP = 0x9
+ PTRACE_SPARC_DETACH = 0xb
+ PTRACE_SYSCALL = 0x18
+ PTRACE_TRACEME = 0x0
+ PTRACE_WRITEDATA = 0x11
+ PTRACE_WRITETEXT = 0x13
+ PT_FP = 0x48
+ PT_G0 = 0x10
+ PT_G1 = 0x14
+ PT_G2 = 0x18
+ PT_G3 = 0x1c
+ PT_G4 = 0x20
+ PT_G5 = 0x24
+ PT_G6 = 0x28
+ PT_G7 = 0x2c
+ PT_I0 = 0x30
+ PT_I1 = 0x34
+ PT_I2 = 0x38
+ PT_I3 = 0x3c
+ PT_I4 = 0x40
+ PT_I5 = 0x44
+ PT_I6 = 0x48
+ PT_I7 = 0x4c
+ PT_NPC = 0x8
+ PT_PC = 0x4
+ PT_PSR = 0x0
+ PT_REGS_MAGIC = 0x57ac6c00
+ PT_TNPC = 0x90
+ PT_TPC = 0x88
+ PT_TSTATE = 0x80
+ PT_V9_FP = 0x70
+ PT_V9_G0 = 0x0
+ PT_V9_G1 = 0x8
+ PT_V9_G2 = 0x10
+ PT_V9_G3 = 0x18
+ PT_V9_G4 = 0x20
+ PT_V9_G5 = 0x28
+ PT_V9_G6 = 0x30
+ PT_V9_G7 = 0x38
+ PT_V9_I0 = 0x40
+ PT_V9_I1 = 0x48
+ PT_V9_I2 = 0x50
+ PT_V9_I3 = 0x58
+ PT_V9_I4 = 0x60
+ PT_V9_I5 = 0x68
+ PT_V9_I6 = 0x70
+ PT_V9_I7 = 0x78
+ PT_V9_MAGIC = 0x9c
+ PT_V9_TNPC = 0x90
+ PT_V9_TPC = 0x88
+ PT_V9_TSTATE = 0x80
+ PT_V9_Y = 0x98
+ PT_WIM = 0x10
+ PT_Y = 0xc
+ QNX4_SUPER_MAGIC = 0x2f
+ QNX6_SUPER_MAGIC = 0x68191122
+ RAMFS_MAGIC = 0x858458f6
+ RDTGROUP_SUPER_MAGIC = 0x7655821
+ REISERFS_SUPER_MAGIC = 0x52654973
+ RENAME_EXCHANGE = 0x2
+ RENAME_NOREPLACE = 0x1
+ RENAME_WHITEOUT = 0x4
+ RLIMIT_AS = 0x9
+ RLIMIT_CORE = 0x4
+ RLIMIT_CPU = 0x0
+ RLIMIT_DATA = 0x2
+ RLIMIT_FSIZE = 0x1
+ RLIMIT_LOCKS = 0xa
+ RLIMIT_MEMLOCK = 0x8
+ RLIMIT_MSGQUEUE = 0xc
+ RLIMIT_NICE = 0xd
+ RLIMIT_NOFILE = 0x6
+ RLIMIT_NPROC = 0x7
+ RLIMIT_RSS = 0x5
+ RLIMIT_RTPRIO = 0xe
+ RLIMIT_RTTIME = 0xf
+ RLIMIT_SIGPENDING = 0xb
+ RLIMIT_STACK = 0x3
+ RLIM_INFINITY = 0xffffffffffffffff
+ RTAX_ADVMSS = 0x8
+ RTAX_CC_ALGO = 0x10
+ RTAX_CWND = 0x7
+ RTAX_FASTOPEN_NO_COOKIE = 0x11
+ RTAX_FEATURES = 0xc
+ RTAX_FEATURE_ALLFRAG = 0x8
+ RTAX_FEATURE_ECN = 0x1
+ RTAX_FEATURE_MASK = 0xf
+ RTAX_FEATURE_SACK = 0x2
+ RTAX_FEATURE_TIMESTAMP = 0x4
+ RTAX_HOPLIMIT = 0xa
+ RTAX_INITCWND = 0xb
+ RTAX_INITRWND = 0xe
+ RTAX_LOCK = 0x1
+ RTAX_MAX = 0x11
+ RTAX_MTU = 0x2
+ RTAX_QUICKACK = 0xf
+ RTAX_REORDERING = 0x9
+ RTAX_RTO_MIN = 0xd
+ RTAX_RTT = 0x4
+ RTAX_RTTVAR = 0x5
+ RTAX_SSTHRESH = 0x6
+ RTAX_UNSPEC = 0x0
+ RTAX_WINDOW = 0x3
+ RTA_ALIGNTO = 0x4
+ RTA_MAX = 0x1d
+ RTCF_DIRECTSRC = 0x4000000
+ RTCF_DOREDIRECT = 0x1000000
+ RTCF_LOG = 0x2000000
+ RTCF_MASQ = 0x400000
+ RTCF_NAT = 0x800000
+ RTCF_VALVE = 0x200000
+ RTC_AF = 0x20
+ RTC_AIE_OFF = 0x20007002
+ RTC_AIE_ON = 0x20007001
+ RTC_ALM_READ = 0x40247008
+ RTC_ALM_SET = 0x80247007
+ RTC_EPOCH_READ = 0x4008700d
+ RTC_EPOCH_SET = 0x8008700e
+ RTC_IRQF = 0x80
+ RTC_IRQP_READ = 0x4008700b
+ RTC_IRQP_SET = 0x8008700c
+ RTC_MAX_FREQ = 0x2000
+ RTC_PF = 0x40
+ RTC_PIE_OFF = 0x20007006
+ RTC_PIE_ON = 0x20007005
+ RTC_PLL_GET = 0x40207011
+ RTC_PLL_SET = 0x80207012
+ RTC_RD_TIME = 0x40247009
+ RTC_SET_TIME = 0x8024700a
+ RTC_UF = 0x10
+ RTC_UIE_OFF = 0x20007004
+ RTC_UIE_ON = 0x20007003
+ RTC_VL_CLR = 0x20007014
+ RTC_VL_READ = 0x40047013
+ RTC_WIE_OFF = 0x20007010
+ RTC_WIE_ON = 0x2000700f
+ RTC_WKALM_RD = 0x40287010
+ RTC_WKALM_SET = 0x8028700f
+ RTF_ADDRCLASSMASK = 0xf8000000
+ RTF_ADDRCONF = 0x40000
+ RTF_ALLONLINK = 0x20000
+ RTF_BROADCAST = 0x10000000
+ RTF_CACHE = 0x1000000
+ RTF_DEFAULT = 0x10000
+ RTF_DYNAMIC = 0x10
+ RTF_FLOW = 0x2000000
+ RTF_GATEWAY = 0x2
+ RTF_HOST = 0x4
+ RTF_INTERFACE = 0x40000000
+ RTF_IRTT = 0x100
+ RTF_LINKRT = 0x100000
+ RTF_LOCAL = 0x80000000
+ RTF_MODIFIED = 0x20
+ RTF_MSS = 0x40
+ RTF_MTU = 0x40
+ RTF_MULTICAST = 0x20000000
+ RTF_NAT = 0x8000000
+ RTF_NOFORWARD = 0x1000
+ RTF_NONEXTHOP = 0x200000
+ RTF_NOPMTUDISC = 0x4000
+ RTF_POLICY = 0x4000000
+ RTF_REINSTATE = 0x8
+ RTF_REJECT = 0x200
+ RTF_STATIC = 0x400
+ RTF_THROW = 0x2000
+ RTF_UP = 0x1
+ RTF_WINDOW = 0x80
+ RTF_XRESOLVE = 0x800
+ RTM_BASE = 0x10
+ RTM_DELACTION = 0x31
+ RTM_DELADDR = 0x15
+ RTM_DELADDRLABEL = 0x49
+ RTM_DELCHAIN = 0x65
+ RTM_DELLINK = 0x11
+ RTM_DELMDB = 0x55
+ RTM_DELNEIGH = 0x1d
+ RTM_DELNETCONF = 0x51
+ RTM_DELNSID = 0x59
+ RTM_DELQDISC = 0x25
+ RTM_DELROUTE = 0x19
+ RTM_DELRULE = 0x21
+ RTM_DELTCLASS = 0x29
+ RTM_DELTFILTER = 0x2d
+ RTM_F_CLONED = 0x200
+ RTM_F_EQUALIZE = 0x400
+ RTM_F_FIB_MATCH = 0x2000
+ RTM_F_LOOKUP_TABLE = 0x1000
+ RTM_F_NOTIFY = 0x100
+ RTM_F_PREFIX = 0x800
+ RTM_GETACTION = 0x32
+ RTM_GETADDR = 0x16
+ RTM_GETADDRLABEL = 0x4a
+ RTM_GETANYCAST = 0x3e
+ RTM_GETCHAIN = 0x66
+ RTM_GETDCB = 0x4e
+ RTM_GETLINK = 0x12
+ RTM_GETMDB = 0x56
+ RTM_GETMULTICAST = 0x3a
+ RTM_GETNEIGH = 0x1e
+ RTM_GETNEIGHTBL = 0x42
+ RTM_GETNETCONF = 0x52
+ RTM_GETNSID = 0x5a
+ RTM_GETQDISC = 0x26
+ RTM_GETROUTE = 0x1a
+ RTM_GETRULE = 0x22
+ RTM_GETSTATS = 0x5e
+ RTM_GETTCLASS = 0x2a
+ RTM_GETTFILTER = 0x2e
+ RTM_MAX = 0x67
+ RTM_NEWACTION = 0x30
+ RTM_NEWADDR = 0x14
+ RTM_NEWADDRLABEL = 0x48
+ RTM_NEWCACHEREPORT = 0x60
+ RTM_NEWCHAIN = 0x64
+ RTM_NEWLINK = 0x10
+ RTM_NEWMDB = 0x54
+ RTM_NEWNDUSEROPT = 0x44
+ RTM_NEWNEIGH = 0x1c
+ RTM_NEWNEIGHTBL = 0x40
+ RTM_NEWNETCONF = 0x50
+ RTM_NEWNSID = 0x58
+ RTM_NEWPREFIX = 0x34
+ RTM_NEWQDISC = 0x24
+ RTM_NEWROUTE = 0x18
+ RTM_NEWRULE = 0x20
+ RTM_NEWSTATS = 0x5c
+ RTM_NEWTCLASS = 0x28
+ RTM_NEWTFILTER = 0x2c
+ RTM_NR_FAMILIES = 0x16
+ RTM_NR_MSGTYPES = 0x58
+ RTM_SETDCB = 0x4f
+ RTM_SETLINK = 0x13
+ RTM_SETNEIGHTBL = 0x43
+ RTNH_ALIGNTO = 0x4
+ RTNH_COMPARE_MASK = 0x19
+ RTNH_F_DEAD = 0x1
+ RTNH_F_LINKDOWN = 0x10
+ RTNH_F_OFFLOAD = 0x8
+ RTNH_F_ONLINK = 0x4
+ RTNH_F_PERVASIVE = 0x2
+ RTNH_F_UNRESOLVED = 0x20
+ RTN_MAX = 0xb
+ RTPROT_BABEL = 0x2a
+ RTPROT_BGP = 0xba
+ RTPROT_BIRD = 0xc
+ RTPROT_BOOT = 0x3
+ RTPROT_DHCP = 0x10
+ RTPROT_DNROUTED = 0xd
+ RTPROT_EIGRP = 0xc0
+ RTPROT_GATED = 0x8
+ RTPROT_ISIS = 0xbb
+ RTPROT_KERNEL = 0x2
+ RTPROT_MROUTED = 0x11
+ RTPROT_MRT = 0xa
+ RTPROT_NTK = 0xf
+ RTPROT_OSPF = 0xbc
+ RTPROT_RA = 0x9
+ RTPROT_REDIRECT = 0x1
+ RTPROT_RIP = 0xbd
+ RTPROT_STATIC = 0x4
+ RTPROT_UNSPEC = 0x0
+ RTPROT_XORP = 0xe
+ RTPROT_ZEBRA = 0xb
+ RT_CLASS_DEFAULT = 0xfd
+ RT_CLASS_LOCAL = 0xff
+ RT_CLASS_MAIN = 0xfe
+ RT_CLASS_MAX = 0xff
+ RT_CLASS_UNSPEC = 0x0
+ RUSAGE_CHILDREN = -0x1
+ RUSAGE_SELF = 0x0
+ RUSAGE_THREAD = 0x1
+ SCM_CREDENTIALS = 0x2
+ SCM_RIGHTS = 0x1
+ SCM_TIMESTAMP = 0x1d
+ SCM_TIMESTAMPING = 0x23
+ SCM_TIMESTAMPING_OPT_STATS = 0x38
+ SCM_TIMESTAMPING_PKTINFO = 0x3c
+ SCM_TIMESTAMPNS = 0x21
+ SCM_TXTIME = 0x3f
+ SCM_WIFI_STATUS = 0x25
+ SC_LOG_FLUSH = 0x100000
+ SECCOMP_MODE_DISABLED = 0x0
+ SECCOMP_MODE_FILTER = 0x2
+ SECCOMP_MODE_STRICT = 0x1
+ SECURITYFS_MAGIC = 0x73636673
+ SELINUX_MAGIC = 0xf97cff8c
+ SHUT_RD = 0x0
+ SHUT_RDWR = 0x2
+ SHUT_WR = 0x1
+ SIOCADDDLCI = 0x8980
+ SIOCADDMULTI = 0x8931
+ SIOCADDRT = 0x890b
+ SIOCATMARK = 0x8905
+ SIOCBONDCHANGEACTIVE = 0x8995
+ SIOCBONDENSLAVE = 0x8990
+ SIOCBONDINFOQUERY = 0x8994
+ SIOCBONDRELEASE = 0x8991
+ SIOCBONDSETHWADDR = 0x8992
+ SIOCBONDSLAVEINFOQUERY = 0x8993
+ SIOCBRADDBR = 0x89a0
+ SIOCBRADDIF = 0x89a2
+ SIOCBRDELBR = 0x89a1
+ SIOCBRDELIF = 0x89a3
+ SIOCDARP = 0x8953
+ SIOCDELDLCI = 0x8981
+ SIOCDELMULTI = 0x8932
+ SIOCDELRT = 0x890c
+ SIOCDEVPRIVATE = 0x89f0
+ SIOCDIFADDR = 0x8936
+ SIOCDRARP = 0x8960
+ SIOCETHTOOL = 0x8946
+ SIOCGARP = 0x8954
+ SIOCGHWTSTAMP = 0x89b1
+ SIOCGIFADDR = 0x8915
+ SIOCGIFBR = 0x8940
+ SIOCGIFBRDADDR = 0x8919
+ SIOCGIFCONF = 0x8912
+ SIOCGIFCOUNT = 0x8938
+ SIOCGIFDSTADDR = 0x8917
+ SIOCGIFENCAP = 0x8925
+ SIOCGIFFLAGS = 0x8913
+ SIOCGIFHWADDR = 0x8927
+ SIOCGIFINDEX = 0x8933
+ SIOCGIFMAP = 0x8970
+ SIOCGIFMEM = 0x891f
+ SIOCGIFMETRIC = 0x891d
+ SIOCGIFMTU = 0x8921
+ SIOCGIFNAME = 0x8910
+ SIOCGIFNETMASK = 0x891b
+ SIOCGIFPFLAGS = 0x8935
+ SIOCGIFSLAVE = 0x8929
+ SIOCGIFTXQLEN = 0x8942
+ SIOCGIFVLAN = 0x8982
+ SIOCGMIIPHY = 0x8947
+ SIOCGMIIREG = 0x8948
+ SIOCGPGRP = 0x8904
+ SIOCGPPPCSTATS = 0x89f2
+ SIOCGPPPSTATS = 0x89f0
+ SIOCGPPPVER = 0x89f1
+ SIOCGRARP = 0x8961
+ SIOCGSKNS = 0x894c
+ SIOCGSTAMP = 0x8906
+ SIOCGSTAMPNS = 0x8907
+ SIOCINQ = 0x4004667f
+ SIOCOUTQ = 0x40047473
+ SIOCOUTQNSD = 0x894b
+ SIOCPROTOPRIVATE = 0x89e0
+ SIOCRTMSG = 0x890d
+ SIOCSARP = 0x8955
+ SIOCSHWTSTAMP = 0x89b0
+ SIOCSIFADDR = 0x8916
+ SIOCSIFBR = 0x8941
+ SIOCSIFBRDADDR = 0x891a
+ SIOCSIFDSTADDR = 0x8918
+ SIOCSIFENCAP = 0x8926
+ SIOCSIFFLAGS = 0x8914
+ SIOCSIFHWADDR = 0x8924
+ SIOCSIFHWBROADCAST = 0x8937
+ SIOCSIFLINK = 0x8911
+ SIOCSIFMAP = 0x8971
+ SIOCSIFMEM = 0x8920
+ SIOCSIFMETRIC = 0x891e
+ SIOCSIFMTU = 0x8922
+ SIOCSIFNAME = 0x8923
+ SIOCSIFNETMASK = 0x891c
+ SIOCSIFPFLAGS = 0x8934
+ SIOCSIFSLAVE = 0x8930
+ SIOCSIFTXQLEN = 0x8943
+ SIOCSIFVLAN = 0x8983
+ SIOCSMIIREG = 0x8949
+ SIOCSPGRP = 0x8902
+ SIOCSRARP = 0x8962
+ SIOCWANDEV = 0x894a
+ SMACK_MAGIC = 0x43415d53
+ SMART_AUTOSAVE = 0xd2
+ SMART_AUTO_OFFLINE = 0xdb
+ SMART_DISABLE = 0xd9
+ SMART_ENABLE = 0xd8
+ SMART_HCYL_PASS = 0xc2
+ SMART_IMMEDIATE_OFFLINE = 0xd4
+ SMART_LCYL_PASS = 0x4f
+ SMART_READ_LOG_SECTOR = 0xd5
+ SMART_READ_THRESHOLDS = 0xd1
+ SMART_READ_VALUES = 0xd0
+ SMART_SAVE = 0xd3
+ SMART_STATUS = 0xda
+ SMART_WRITE_LOG_SECTOR = 0xd6
+ SMART_WRITE_THRESHOLDS = 0xd7
+ SMB_SUPER_MAGIC = 0x517b
+ SOCKFS_MAGIC = 0x534f434b
+ SOCK_CLOEXEC = 0x400000
+ SOCK_DCCP = 0x6
+ SOCK_DGRAM = 0x2
+ SOCK_IOC_TYPE = 0x89
+ SOCK_NONBLOCK = 0x4000
+ SOCK_PACKET = 0xa
+ SOCK_RAW = 0x3
+ SOCK_RDM = 0x4
+ SOCK_SEQPACKET = 0x5
+ SOCK_STREAM = 0x1
+ SOL_AAL = 0x109
+ SOL_ALG = 0x117
+ SOL_ATM = 0x108
+ SOL_CAIF = 0x116
+ SOL_CAN_BASE = 0x64
+ SOL_DCCP = 0x10d
+ SOL_DECNET = 0x105
+ SOL_ICMPV6 = 0x3a
+ SOL_IP = 0x0
+ SOL_IPV6 = 0x29
+ SOL_IRDA = 0x10a
+ SOL_IUCV = 0x115
+ SOL_KCM = 0x119
+ SOL_LLC = 0x10c
+ SOL_NETBEUI = 0x10b
+ SOL_NETLINK = 0x10e
+ SOL_NFC = 0x118
+ SOL_PACKET = 0x107
+ SOL_PNPIPE = 0x113
+ SOL_PPPOL2TP = 0x111
+ SOL_RAW = 0xff
+ SOL_RDS = 0x114
+ SOL_RXRPC = 0x110
+ SOL_SOCKET = 0xffff
+ SOL_TCP = 0x6
+ SOL_TIPC = 0x10f
+ SOL_TLS = 0x11a
+ SOL_X25 = 0x106
+ SOL_XDP = 0x11b
+ SOMAXCONN = 0x80
+ SO_ACCEPTCONN = 0x8000
+ SO_ATTACH_BPF = 0x34
+ SO_ATTACH_FILTER = 0x1a
+ SO_ATTACH_REUSEPORT_CBPF = 0x35
+ SO_ATTACH_REUSEPORT_EBPF = 0x36
+ SO_BINDTODEVICE = 0xd
+ SO_BPF_EXTENSIONS = 0x32
+ SO_BROADCAST = 0x20
+ SO_BSDCOMPAT = 0x400
+ SO_BUSY_POLL = 0x30
+ SO_CNX_ADVICE = 0x37
+ SO_COOKIE = 0x3b
+ SO_DEBUG = 0x1
+ SO_DETACH_BPF = 0x1b
+ SO_DETACH_FILTER = 0x1b
+ SO_DOMAIN = 0x1029
+ SO_DONTROUTE = 0x10
+ SO_ERROR = 0x1007
+ SO_GET_FILTER = 0x1a
+ SO_INCOMING_CPU = 0x33
+ SO_INCOMING_NAPI_ID = 0x3a
+ SO_KEEPALIVE = 0x8
+ SO_LINGER = 0x80
+ SO_LOCK_FILTER = 0x28
+ SO_MARK = 0x22
+ SO_MAX_PACING_RATE = 0x31
+ SO_MEMINFO = 0x39
+ SO_NOFCS = 0x27
+ SO_NO_CHECK = 0xb
+ SO_OOBINLINE = 0x100
+ SO_PASSCRED = 0x2
+ SO_PASSSEC = 0x1f
+ SO_PEEK_OFF = 0x26
+ SO_PEERCRED = 0x40
+ SO_PEERGROUPS = 0x3d
+ SO_PEERNAME = 0x1c
+ SO_PEERSEC = 0x1e
+ SO_PRIORITY = 0xc
+ SO_PROTOCOL = 0x1028
+ SO_RCVBUF = 0x1002
+ SO_RCVBUFFORCE = 0x100b
+ SO_RCVLOWAT = 0x800
+ SO_RCVTIMEO = 0x2000
+ SO_REUSEADDR = 0x4
+ SO_REUSEPORT = 0x200
+ SO_RXQ_OVFL = 0x24
+ SO_SECURITY_AUTHENTICATION = 0x5001
+ SO_SECURITY_ENCRYPTION_NETWORK = 0x5004
+ SO_SECURITY_ENCRYPTION_TRANSPORT = 0x5002
+ SO_SELECT_ERR_QUEUE = 0x29
+ SO_SNDBUF = 0x1001
+ SO_SNDBUFFORCE = 0x100a
+ SO_SNDLOWAT = 0x1000
+ SO_SNDTIMEO = 0x4000
+ SO_TIMESTAMP = 0x1d
+ SO_TIMESTAMPING = 0x23
+ SO_TIMESTAMPNS = 0x21
+ SO_TXTIME = 0x3f
+ SO_TYPE = 0x1008
+ SO_VM_SOCKETS_BUFFER_MAX_SIZE = 0x2
+ SO_VM_SOCKETS_BUFFER_MIN_SIZE = 0x1
+ SO_VM_SOCKETS_BUFFER_SIZE = 0x0
+ SO_VM_SOCKETS_CONNECT_TIMEOUT = 0x6
+ SO_VM_SOCKETS_NONBLOCK_TXRX = 0x7
+ SO_VM_SOCKETS_PEER_HOST_VM_ID = 0x3
+ SO_VM_SOCKETS_TRUSTED = 0x5
+ SO_WIFI_STATUS = 0x25
+ SO_ZEROCOPY = 0x3e
+ SPLICE_F_GIFT = 0x8
+ SPLICE_F_MORE = 0x4
+ SPLICE_F_MOVE = 0x1
+ SPLICE_F_NONBLOCK = 0x2
+ SQUASHFS_MAGIC = 0x73717368
+ STACK_END_MAGIC = 0x57ac6e9d
+ STATX_ALL = 0xfff
+ STATX_ATIME = 0x20
+ STATX_ATTR_APPEND = 0x20
+ STATX_ATTR_AUTOMOUNT = 0x1000
+ STATX_ATTR_COMPRESSED = 0x4
+ STATX_ATTR_ENCRYPTED = 0x800
+ STATX_ATTR_IMMUTABLE = 0x10
+ STATX_ATTR_NODUMP = 0x40
+ STATX_BASIC_STATS = 0x7ff
+ STATX_BLOCKS = 0x400
+ STATX_BTIME = 0x800
+ STATX_CTIME = 0x80
+ STATX_GID = 0x10
+ STATX_INO = 0x100
+ STATX_MODE = 0x2
+ STATX_MTIME = 0x40
+ STATX_NLINK = 0x4
+ STATX_SIZE = 0x200
+ STATX_TYPE = 0x1
+ STATX_UID = 0x8
+ STATX__RESERVED = 0x80000000
+ SYNC_FILE_RANGE_WAIT_AFTER = 0x4
+ SYNC_FILE_RANGE_WAIT_BEFORE = 0x1
+ SYNC_FILE_RANGE_WRITE = 0x2
+ SYSFS_MAGIC = 0x62656572
+ S_BLKSIZE = 0x200
+ S_IEXEC = 0x40
+ S_IFBLK = 0x6000
+ S_IFCHR = 0x2000
+ S_IFDIR = 0x4000
+ S_IFIFO = 0x1000
+ S_IFLNK = 0xa000
+ S_IFMT = 0xf000
+ S_IFREG = 0x8000
+ S_IFSOCK = 0xc000
+ S_IREAD = 0x100
+ S_IRGRP = 0x20
+ S_IROTH = 0x4
+ S_IRUSR = 0x100
+ S_IRWXG = 0x38
+ S_IRWXO = 0x7
+ S_IRWXU = 0x1c0
+ S_ISGID = 0x400
+ S_ISUID = 0x800
+ S_ISVTX = 0x200
+ S_IWGRP = 0x10
+ S_IWOTH = 0x2
+ S_IWRITE = 0x80
+ S_IWUSR = 0x80
+ S_IXGRP = 0x8
+ S_IXOTH = 0x1
+ S_IXUSR = 0x40
+ TAB0 = 0x0
+ TAB1 = 0x800
+ TAB2 = 0x1000
+ TAB3 = 0x1800
+ TABDLY = 0x1800
+ TASKSTATS_CMD_ATTR_MAX = 0x4
+ TASKSTATS_CMD_MAX = 0x2
+ TASKSTATS_GENL_NAME = "TASKSTATS"
+ TASKSTATS_GENL_VERSION = 0x1
+ TASKSTATS_TYPE_MAX = 0x6
+ TASKSTATS_VERSION = 0x8
+ TCFLSH = 0x20005407
+ TCGETA = 0x40125401
+ TCGETS = 0x40245408
+ TCGETS2 = 0x402c540c
+ TCIFLUSH = 0x0
+ TCIOFF = 0x2
+ TCIOFLUSH = 0x2
+ TCION = 0x3
+ TCOFLUSH = 0x1
+ TCOOFF = 0x0
+ TCOON = 0x1
+ TCP_CC_INFO = 0x1a
+ TCP_CONGESTION = 0xd
+ TCP_COOKIE_IN_ALWAYS = 0x1
+ TCP_COOKIE_MAX = 0x10
+ TCP_COOKIE_MIN = 0x8
+ TCP_COOKIE_OUT_NEVER = 0x2
+ TCP_COOKIE_PAIR_SIZE = 0x20
+ TCP_COOKIE_TRANSACTIONS = 0xf
+ TCP_CORK = 0x3
+ TCP_DEFER_ACCEPT = 0x9
+ TCP_FASTOPEN = 0x17
+ TCP_FASTOPEN_CONNECT = 0x1e
+ TCP_FASTOPEN_KEY = 0x21
+ TCP_FASTOPEN_NO_COOKIE = 0x22
+ TCP_INFO = 0xb
+ TCP_KEEPCNT = 0x6
+ TCP_KEEPIDLE = 0x4
+ TCP_KEEPINTVL = 0x5
+ TCP_LINGER2 = 0x8
+ TCP_MAXSEG = 0x2
+ TCP_MAXWIN = 0xffff
+ TCP_MAX_WINSHIFT = 0xe
+ TCP_MD5SIG = 0xe
+ TCP_MD5SIG_EXT = 0x20
+ TCP_MD5SIG_FLAG_PREFIX = 0x1
+ TCP_MD5SIG_MAXKEYLEN = 0x50
+ TCP_MSS = 0x200
+ TCP_MSS_DEFAULT = 0x218
+ TCP_MSS_DESIRED = 0x4c4
+ TCP_NODELAY = 0x1
+ TCP_NOTSENT_LOWAT = 0x19
+ TCP_QUEUE_SEQ = 0x15
+ TCP_QUICKACK = 0xc
+ TCP_REPAIR = 0x13
+ TCP_REPAIR_OPTIONS = 0x16
+ TCP_REPAIR_QUEUE = 0x14
+ TCP_REPAIR_WINDOW = 0x1d
+ TCP_SAVED_SYN = 0x1c
+ TCP_SAVE_SYN = 0x1b
+ TCP_SYNCNT = 0x7
+ TCP_S_DATA_IN = 0x4
+ TCP_S_DATA_OUT = 0x8
+ TCP_THIN_DUPACK = 0x11
+ TCP_THIN_LINEAR_TIMEOUTS = 0x10
+ TCP_TIMESTAMP = 0x18
+ TCP_ULP = 0x1f
+ TCP_USER_TIMEOUT = 0x12
+ TCP_WINDOW_CLAMP = 0xa
+ TCSAFLUSH = 0x2
+ TCSBRK = 0x20005405
+ TCSBRKP = 0x5425
+ TCSETA = 0x80125402
+ TCSETAF = 0x80125404
+ TCSETAW = 0x80125403
+ TCSETS = 0x80245409
+ TCSETS2 = 0x802c540d
+ TCSETSF = 0x8024540b
+ TCSETSF2 = 0x802c540f
+ TCSETSW = 0x8024540a
+ TCSETSW2 = 0x802c540e
+ TCXONC = 0x20005406
+ TIOCCBRK = 0x2000747a
+ TIOCCONS = 0x20007424
+ TIOCEXCL = 0x2000740d
+ TIOCGDEV = 0x40045432
+ TIOCGETD = 0x40047400
+ TIOCGEXCL = 0x40045440
+ TIOCGICOUNT = 0x545d
+ TIOCGLCKTRMIOS = 0x5456
+ TIOCGPGRP = 0x40047483
+ TIOCGPKT = 0x40045438
+ TIOCGPTLCK = 0x40045439
+ TIOCGPTN = 0x40047486
+ TIOCGPTPEER = 0x20007489
+ TIOCGRS485 = 0x40205441
+ TIOCGSERIAL = 0x541e
+ TIOCGSID = 0x40047485
+ TIOCGSOFTCAR = 0x40047464
+ TIOCGWINSZ = 0x40087468
+ TIOCINQ = 0x4004667f
+ TIOCLINUX = 0x541c
+ TIOCMBIC = 0x8004746b
+ TIOCMBIS = 0x8004746c
+ TIOCMGET = 0x4004746a
+ TIOCMIWAIT = 0x545c
+ TIOCMSET = 0x8004746d
+ TIOCM_CAR = 0x40
+ TIOCM_CD = 0x40
+ TIOCM_CTS = 0x20
+ TIOCM_DSR = 0x100
+ TIOCM_DTR = 0x2
+ TIOCM_LE = 0x1
+ TIOCM_RI = 0x80
+ TIOCM_RNG = 0x80
+ TIOCM_RTS = 0x4
+ TIOCM_SR = 0x10
+ TIOCM_ST = 0x8
+ TIOCNOTTY = 0x20007471
+ TIOCNXCL = 0x2000740e
+ TIOCOUTQ = 0x40047473
+ TIOCPKT = 0x80047470
+ TIOCPKT_DATA = 0x0
+ TIOCPKT_DOSTOP = 0x20
+ TIOCPKT_FLUSHREAD = 0x1
+ TIOCPKT_FLUSHWRITE = 0x2
+ TIOCPKT_IOCTL = 0x40
+ TIOCPKT_NOSTOP = 0x10
+ TIOCPKT_START = 0x8
+ TIOCPKT_STOP = 0x4
+ TIOCSBRK = 0x2000747b
+ TIOCSCTTY = 0x20007484
+ TIOCSERCONFIG = 0x5453
+ TIOCSERGETLSR = 0x5459
+ TIOCSERGETMULTI = 0x545a
+ TIOCSERGSTRUCT = 0x5458
+ TIOCSERGWILD = 0x5454
+ TIOCSERSETMULTI = 0x545b
+ TIOCSERSWILD = 0x5455
+ TIOCSETD = 0x80047401
+ TIOCSIG = 0x80047488
+ TIOCSLCKTRMIOS = 0x5457
+ TIOCSPGRP = 0x80047482
+ TIOCSPTLCK = 0x80047487
+ TIOCSRS485 = 0xc0205442
+ TIOCSSERIAL = 0x541f
+ TIOCSSOFTCAR = 0x80047465
+ TIOCSTART = 0x2000746e
+ TIOCSTI = 0x80017472
+ TIOCSTOP = 0x2000746f
+ TIOCSWINSZ = 0x80087467
+ TIOCVHANGUP = 0x20005437
+ TMPFS_MAGIC = 0x1021994
+ TOSTOP = 0x100
+ TPACKET_ALIGNMENT = 0x10
+ TPACKET_HDRLEN = 0x34
+ TP_STATUS_AVAILABLE = 0x0
+ TP_STATUS_BLK_TMO = 0x20
+ TP_STATUS_COPY = 0x2
+ TP_STATUS_CSUMNOTREADY = 0x8
+ TP_STATUS_CSUM_VALID = 0x80
+ TP_STATUS_KERNEL = 0x0
+ TP_STATUS_LOSING = 0x4
+ TP_STATUS_SENDING = 0x2
+ TP_STATUS_SEND_REQUEST = 0x1
+ TP_STATUS_TS_RAW_HARDWARE = -0x80000000
+ TP_STATUS_TS_SOFTWARE = 0x20000000
+ TP_STATUS_TS_SYS_HARDWARE = 0x40000000
+ TP_STATUS_USER = 0x1
+ TP_STATUS_VLAN_TPID_VALID = 0x40
+ TP_STATUS_VLAN_VALID = 0x10
+ TP_STATUS_WRONG_FORMAT = 0x4
+ TRACEFS_MAGIC = 0x74726163
+ TS_COMM_LEN = 0x20
+ TUNATTACHFILTER = 0x801054d5
+ TUNDETACHFILTER = 0x801054d6
+ TUNGETFEATURES = 0x400454cf
+ TUNGETFILTER = 0x401054db
+ TUNGETIFF = 0x400454d2
+ TUNGETSNDBUF = 0x400454d3
+ TUNGETVNETBE = 0x400454df
+ TUNGETVNETHDRSZ = 0x400454d7
+ TUNGETVNETLE = 0x400454dd
+ TUNSETDEBUG = 0x800454c9
+ TUNSETFILTEREBPF = 0x400454e1
+ TUNSETGROUP = 0x800454ce
+ TUNSETIFF = 0x800454ca
+ TUNSETIFINDEX = 0x800454da
+ TUNSETLINK = 0x800454cd
+ TUNSETNOCSUM = 0x800454c8
+ TUNSETOFFLOAD = 0x800454d0
+ TUNSETOWNER = 0x800454cc
+ TUNSETPERSIST = 0x800454cb
+ TUNSETQUEUE = 0x800454d9
+ TUNSETSNDBUF = 0x800454d4
+ TUNSETSTEERINGEBPF = 0x400454e0
+ TUNSETTXFILTER = 0x800454d1
+ TUNSETVNETBE = 0x800454de
+ TUNSETVNETHDRSZ = 0x800454d8
+ TUNSETVNETLE = 0x800454dc
+ UBI_IOCATT = 0x80186f40
+ UBI_IOCDET = 0x80046f41
+ UBI_IOCEBCH = 0x80044f02
+ UBI_IOCEBER = 0x80044f01
+ UBI_IOCEBISMAP = 0x40044f05
+ UBI_IOCEBMAP = 0x80084f03
+ UBI_IOCEBUNMAP = 0x80044f04
+ UBI_IOCMKVOL = 0x80986f00
+ UBI_IOCRMVOL = 0x80046f01
+ UBI_IOCRNVOL = 0x91106f03
+ UBI_IOCRSVOL = 0x800c6f02
+ UBI_IOCSETVOLPROP = 0x80104f06
+ UBI_IOCVOLCRBLK = 0x80804f07
+ UBI_IOCVOLRMBLK = 0x20004f08
+ UBI_IOCVOLUP = 0x80084f00
+ UDF_SUPER_MAGIC = 0x15013346
+ UMOUNT_NOFOLLOW = 0x8
+ USBDEVICE_SUPER_MAGIC = 0x9fa2
+ UTIME_NOW = 0x3fffffff
+ UTIME_OMIT = 0x3ffffffe
+ V9FS_MAGIC = 0x1021997
+ VDISCARD = 0xd
+ VEOF = 0x4
+ VEOL = 0xb
+ VEOL2 = 0x10
+ VERASE = 0x2
+ VINTR = 0x0
+ VKILL = 0x3
+ VLNEXT = 0xf
+ VMADDR_CID_ANY = 0xffffffff
+ VMADDR_CID_HOST = 0x2
+ VMADDR_CID_HYPERVISOR = 0x0
+ VMADDR_CID_RESERVED = 0x1
+ VMADDR_PORT_ANY = 0xffffffff
+ VMIN = 0x6
+ VM_SOCKETS_INVALID_VERSION = 0xffffffff
+ VQUIT = 0x1
+ VREPRINT = 0xc
+ VSTART = 0x8
+ VSTOP = 0x9
+ VSUSP = 0xa
+ VSWTC = 0x7
+ VT0 = 0x0
+ VT1 = 0x4000
+ VTDLY = 0x4000
+ VTIME = 0x5
+ VWERASE = 0xe
+ WALL = 0x40000000
+ WCLONE = 0x80000000
+ WCONTINUED = 0x8
+ WDIOC_GETBOOTSTATUS = 0x40045702
+ WDIOC_GETPRETIMEOUT = 0x40045709
+ WDIOC_GETSTATUS = 0x40045701
+ WDIOC_GETSUPPORT = 0x40285700
+ WDIOC_GETTEMP = 0x40045703
+ WDIOC_GETTIMELEFT = 0x4004570a
+ WDIOC_GETTIMEOUT = 0x40045707
+ WDIOC_KEEPALIVE = 0x40045705
+ WDIOC_SETOPTIONS = 0x40045704
+ WDIOC_SETPRETIMEOUT = 0xc0045708
+ WDIOC_SETTIMEOUT = 0xc0045706
+ WEXITED = 0x4
+ WIN_ACKMEDIACHANGE = 0xdb
+ WIN_CHECKPOWERMODE1 = 0xe5
+ WIN_CHECKPOWERMODE2 = 0x98
+ WIN_DEVICE_RESET = 0x8
+ WIN_DIAGNOSE = 0x90
+ WIN_DOORLOCK = 0xde
+ WIN_DOORUNLOCK = 0xdf
+ WIN_DOWNLOAD_MICROCODE = 0x92
+ WIN_FLUSH_CACHE = 0xe7
+ WIN_FLUSH_CACHE_EXT = 0xea
+ WIN_FORMAT = 0x50
+ WIN_GETMEDIASTATUS = 0xda
+ WIN_IDENTIFY = 0xec
+ WIN_IDENTIFY_DMA = 0xee
+ WIN_IDLEIMMEDIATE = 0xe1
+ WIN_INIT = 0x60
+ WIN_MEDIAEJECT = 0xed
+ WIN_MULTREAD = 0xc4
+ WIN_MULTREAD_EXT = 0x29
+ WIN_MULTWRITE = 0xc5
+ WIN_MULTWRITE_EXT = 0x39
+ WIN_NOP = 0x0
+ WIN_PACKETCMD = 0xa0
+ WIN_PIDENTIFY = 0xa1
+ WIN_POSTBOOT = 0xdc
+ WIN_PREBOOT = 0xdd
+ WIN_QUEUED_SERVICE = 0xa2
+ WIN_READ = 0x20
+ WIN_READDMA = 0xc8
+ WIN_READDMA_EXT = 0x25
+ WIN_READDMA_ONCE = 0xc9
+ WIN_READDMA_QUEUED = 0xc7
+ WIN_READDMA_QUEUED_EXT = 0x26
+ WIN_READ_BUFFER = 0xe4
+ WIN_READ_EXT = 0x24
+ WIN_READ_LONG = 0x22
+ WIN_READ_LONG_ONCE = 0x23
+ WIN_READ_NATIVE_MAX = 0xf8
+ WIN_READ_NATIVE_MAX_EXT = 0x27
+ WIN_READ_ONCE = 0x21
+ WIN_RECAL = 0x10
+ WIN_RESTORE = 0x10
+ WIN_SECURITY_DISABLE = 0xf6
+ WIN_SECURITY_ERASE_PREPARE = 0xf3
+ WIN_SECURITY_ERASE_UNIT = 0xf4
+ WIN_SECURITY_FREEZE_LOCK = 0xf5
+ WIN_SECURITY_SET_PASS = 0xf1
+ WIN_SECURITY_UNLOCK = 0xf2
+ WIN_SEEK = 0x70
+ WIN_SETFEATURES = 0xef
+ WIN_SETIDLE1 = 0xe3
+ WIN_SETIDLE2 = 0x97
+ WIN_SETMULT = 0xc6
+ WIN_SET_MAX = 0xf9
+ WIN_SET_MAX_EXT = 0x37
+ WIN_SLEEPNOW1 = 0xe6
+ WIN_SLEEPNOW2 = 0x99
+ WIN_SMART = 0xb0
+ WIN_SPECIFY = 0x91
+ WIN_SRST = 0x8
+ WIN_STANDBY = 0xe2
+ WIN_STANDBY2 = 0x96
+ WIN_STANDBYNOW1 = 0xe0
+ WIN_STANDBYNOW2 = 0x94
+ WIN_VERIFY = 0x40
+ WIN_VERIFY_EXT = 0x42
+ WIN_VERIFY_ONCE = 0x41
+ WIN_WRITE = 0x30
+ WIN_WRITEDMA = 0xca
+ WIN_WRITEDMA_EXT = 0x35
+ WIN_WRITEDMA_ONCE = 0xcb
+ WIN_WRITEDMA_QUEUED = 0xcc
+ WIN_WRITEDMA_QUEUED_EXT = 0x36
+ WIN_WRITE_BUFFER = 0xe8
+ WIN_WRITE_EXT = 0x34
+ WIN_WRITE_LONG = 0x32
+ WIN_WRITE_LONG_ONCE = 0x33
+ WIN_WRITE_ONCE = 0x31
+ WIN_WRITE_SAME = 0xe9
+ WIN_WRITE_VERIFY = 0x3c
+ WNOHANG = 0x1
+ WNOTHREAD = 0x20000000
+ WNOWAIT = 0x1000000
+ WORDSIZE = 0x40
+ WSTOPPED = 0x2
+ WUNTRACED = 0x2
+ XATTR_CREATE = 0x1
+ XATTR_REPLACE = 0x2
+ XCASE = 0x4
+ XDP_COPY = 0x2
+ XDP_FLAGS_DRV_MODE = 0x4
+ XDP_FLAGS_HW_MODE = 0x8
+ XDP_FLAGS_MASK = 0xf
+ XDP_FLAGS_MODES = 0xe
+ XDP_FLAGS_SKB_MODE = 0x2
+ XDP_FLAGS_UPDATE_IF_NOEXIST = 0x1
+ XDP_MMAP_OFFSETS = 0x1
+ XDP_PGOFF_RX_RING = 0x0
+ XDP_PGOFF_TX_RING = 0x80000000
+ XDP_RX_RING = 0x2
+ XDP_SHARED_UMEM = 0x1
+ XDP_STATISTICS = 0x7
+ XDP_TX_RING = 0x3
+ XDP_UMEM_COMPLETION_RING = 0x6
+ XDP_UMEM_FILL_RING = 0x5
+ XDP_UMEM_PGOFF_COMPLETION_RING = 0x180000000
+ XDP_UMEM_PGOFF_FILL_RING = 0x100000000
+ XDP_UMEM_REG = 0x4
+ XDP_ZEROCOPY = 0x4
+ XENFS_SUPER_MAGIC = 0xabba1974
+ XTABS = 0x1800
+ ZSMALLOC_MAGIC = 0x58295829
+ __TIOCFLUSH = 0x80047410
)
// Errors
diff --git a/vendor/golang.org/x/sys/unix/zsyscall_darwin_386.1_11.go b/vendor/golang.org/x/sys/unix/zsyscall_darwin_386.1_11.go
new file mode 100644
index 000000000..c4ec7ff87
--- /dev/null
+++ b/vendor/golang.org/x/sys/unix/zsyscall_darwin_386.1_11.go
@@ -0,0 +1,1810 @@
+// go run mksyscall.go -l32 -tags darwin,386,!go1.12 syscall_bsd.go syscall_darwin.go syscall_darwin_386.go
+// Code generated by the command above; see README.md. DO NOT EDIT.
+
+// +build darwin,386,!go1.12
+
+package unix
+
+import (
+ "syscall"
+ "unsafe"
+)
+
+var _ syscall.Errno
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func getgroups(ngid int, gid *_Gid_t) (n int, err error) {
+ r0, _, e1 := RawSyscall(SYS_GETGROUPS, uintptr(ngid), uintptr(unsafe.Pointer(gid)), 0)
+ n = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func setgroups(ngid int, gid *_Gid_t) (err error) {
+ _, _, e1 := RawSyscall(SYS_SETGROUPS, uintptr(ngid), uintptr(unsafe.Pointer(gid)), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func wait4(pid int, wstatus *_C_int, options int, rusage *Rusage) (wpid int, err error) {
+ r0, _, e1 := Syscall6(SYS_WAIT4, uintptr(pid), uintptr(unsafe.Pointer(wstatus)), uintptr(options), uintptr(unsafe.Pointer(rusage)), 0, 0)
+ wpid = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) {
+ r0, _, e1 := Syscall(SYS_ACCEPT, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
+ fd = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) {
+ _, _, e1 := Syscall(SYS_BIND, uintptr(s), uintptr(addr), uintptr(addrlen))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) {
+ _, _, e1 := Syscall(SYS_CONNECT, uintptr(s), uintptr(addr), uintptr(addrlen))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func socket(domain int, typ int, proto int) (fd int, err error) {
+ r0, _, e1 := RawSyscall(SYS_SOCKET, uintptr(domain), uintptr(typ), uintptr(proto))
+ fd = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) {
+ _, _, e1 := Syscall6(SYS_GETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(unsafe.Pointer(vallen)), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) {
+ _, _, e1 := Syscall6(SYS_SETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(vallen), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) {
+ _, _, e1 := RawSyscall(SYS_GETPEERNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) {
+ _, _, e1 := RawSyscall(SYS_GETSOCKNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Shutdown(s int, how int) (err error) {
+ _, _, e1 := Syscall(SYS_SHUTDOWN, uintptr(s), uintptr(how), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) {
+ _, _, e1 := RawSyscall6(SYS_SOCKETPAIR, uintptr(domain), uintptr(typ), uintptr(proto), uintptr(unsafe.Pointer(fd)), 0, 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) {
+ var _p0 unsafe.Pointer
+ if len(p) > 0 {
+ _p0 = unsafe.Pointer(&p[0])
+ } else {
+ _p0 = unsafe.Pointer(&_zero)
+ }
+ r0, _, e1 := Syscall6(SYS_RECVFROM, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(flags), uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(fromlen)))
+ n = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) {
+ var _p0 unsafe.Pointer
+ if len(buf) > 0 {
+ _p0 = unsafe.Pointer(&buf[0])
+ } else {
+ _p0 = unsafe.Pointer(&_zero)
+ }
+ _, _, e1 := Syscall6(SYS_SENDTO, uintptr(s), uintptr(_p0), uintptr(len(buf)), uintptr(flags), uintptr(to), uintptr(addrlen))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func recvmsg(s int, msg *Msghdr, flags int) (n int, err error) {
+ r0, _, e1 := Syscall(SYS_RECVMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags))
+ n = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func sendmsg(s int, msg *Msghdr, flags int) (n int, err error) {
+ r0, _, e1 := Syscall(SYS_SENDMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags))
+ n = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func kevent(kq int, change unsafe.Pointer, nchange int, event unsafe.Pointer, nevent int, timeout *Timespec) (n int, err error) {
+ r0, _, e1 := Syscall6(SYS_KEVENT, uintptr(kq), uintptr(change), uintptr(nchange), uintptr(event), uintptr(nevent), uintptr(unsafe.Pointer(timeout)))
+ n = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) {
+ var _p0 unsafe.Pointer
+ if len(mib) > 0 {
+ _p0 = unsafe.Pointer(&mib[0])
+ } else {
+ _p0 = unsafe.Pointer(&_zero)
+ }
+ _, _, e1 := Syscall6(SYS___SYSCTL, uintptr(_p0), uintptr(len(mib)), uintptr(unsafe.Pointer(old)), uintptr(unsafe.Pointer(oldlen)), uintptr(unsafe.Pointer(new)), uintptr(newlen))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func utimes(path string, timeval *[2]Timeval) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_UTIMES, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(timeval)), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func futimes(fd int, timeval *[2]Timeval) (err error) {
+ _, _, e1 := Syscall(SYS_FUTIMES, uintptr(fd), uintptr(unsafe.Pointer(timeval)), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func fcntl(fd int, cmd int, arg int) (val int, err error) {
+ r0, _, e1 := Syscall(SYS_FCNTL, uintptr(fd), uintptr(cmd), uintptr(arg))
+ val = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func poll(fds *PollFd, nfds int, timeout int) (n int, err error) {
+ r0, _, e1 := Syscall(SYS_POLL, uintptr(unsafe.Pointer(fds)), uintptr(nfds), uintptr(timeout))
+ n = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Madvise(b []byte, behav int) (err error) {
+ var _p0 unsafe.Pointer
+ if len(b) > 0 {
+ _p0 = unsafe.Pointer(&b[0])
+ } else {
+ _p0 = unsafe.Pointer(&_zero)
+ }
+ _, _, e1 := Syscall(SYS_MADVISE, uintptr(_p0), uintptr(len(b)), uintptr(behav))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Mlock(b []byte) (err error) {
+ var _p0 unsafe.Pointer
+ if len(b) > 0 {
+ _p0 = unsafe.Pointer(&b[0])
+ } else {
+ _p0 = unsafe.Pointer(&_zero)
+ }
+ _, _, e1 := Syscall(SYS_MLOCK, uintptr(_p0), uintptr(len(b)), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Mlockall(flags int) (err error) {
+ _, _, e1 := Syscall(SYS_MLOCKALL, uintptr(flags), 0, 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Mprotect(b []byte, prot int) (err error) {
+ var _p0 unsafe.Pointer
+ if len(b) > 0 {
+ _p0 = unsafe.Pointer(&b[0])
+ } else {
+ _p0 = unsafe.Pointer(&_zero)
+ }
+ _, _, e1 := Syscall(SYS_MPROTECT, uintptr(_p0), uintptr(len(b)), uintptr(prot))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Msync(b []byte, flags int) (err error) {
+ var _p0 unsafe.Pointer
+ if len(b) > 0 {
+ _p0 = unsafe.Pointer(&b[0])
+ } else {
+ _p0 = unsafe.Pointer(&_zero)
+ }
+ _, _, e1 := Syscall(SYS_MSYNC, uintptr(_p0), uintptr(len(b)), uintptr(flags))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Munlock(b []byte) (err error) {
+ var _p0 unsafe.Pointer
+ if len(b) > 0 {
+ _p0 = unsafe.Pointer(&b[0])
+ } else {
+ _p0 = unsafe.Pointer(&_zero)
+ }
+ _, _, e1 := Syscall(SYS_MUNLOCK, uintptr(_p0), uintptr(len(b)), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Munlockall() (err error) {
+ _, _, e1 := Syscall(SYS_MUNLOCKALL, 0, 0, 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func ptrace(request int, pid int, addr uintptr, data uintptr) (err error) {
+ _, _, e1 := Syscall6(SYS_PTRACE, uintptr(request), uintptr(pid), uintptr(addr), uintptr(data), 0, 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func getattrlist(path *byte, list unsafe.Pointer, buf unsafe.Pointer, size uintptr, options int) (err error) {
+ _, _, e1 := Syscall6(SYS_GETATTRLIST, uintptr(unsafe.Pointer(path)), uintptr(list), uintptr(buf), uintptr(size), uintptr(options), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func pipe() (r int, w int, err error) {
+ r0, r1, e1 := RawSyscall(SYS_PIPE, 0, 0, 0)
+ r = int(r0)
+ w = int(r1)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func getxattr(path string, attr string, dest *byte, size int, position uint32, options int) (sz int, err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ var _p1 *byte
+ _p1, err = BytePtrFromString(attr)
+ if err != nil {
+ return
+ }
+ r0, _, e1 := Syscall6(SYS_GETXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(unsafe.Pointer(dest)), uintptr(size), uintptr(position), uintptr(options))
+ sz = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func fgetxattr(fd int, attr string, dest *byte, size int, position uint32, options int) (sz int, err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(attr)
+ if err != nil {
+ return
+ }
+ r0, _, e1 := Syscall6(SYS_FGETXATTR, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(dest)), uintptr(size), uintptr(position), uintptr(options))
+ sz = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func setxattr(path string, attr string, data *byte, size int, position uint32, options int) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ var _p1 *byte
+ _p1, err = BytePtrFromString(attr)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall6(SYS_SETXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(unsafe.Pointer(data)), uintptr(size), uintptr(position), uintptr(options))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func fsetxattr(fd int, attr string, data *byte, size int, position uint32, options int) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(attr)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall6(SYS_FSETXATTR, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(data)), uintptr(size), uintptr(position), uintptr(options))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func removexattr(path string, attr string, options int) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ var _p1 *byte
+ _p1, err = BytePtrFromString(attr)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_REMOVEXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(options))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func fremovexattr(fd int, attr string, options int) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(attr)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_FREMOVEXATTR, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(options))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func listxattr(path string, dest *byte, size int, options int) (sz int, err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ r0, _, e1 := Syscall6(SYS_LISTXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(dest)), uintptr(size), uintptr(options), 0, 0)
+ sz = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func flistxattr(fd int, dest *byte, size int, options int) (sz int, err error) {
+ r0, _, e1 := Syscall6(SYS_FLISTXATTR, uintptr(fd), uintptr(unsafe.Pointer(dest)), uintptr(size), uintptr(options), 0, 0)
+ sz = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func setattrlist(path *byte, list unsafe.Pointer, buf unsafe.Pointer, size uintptr, options int) (err error) {
+ _, _, e1 := Syscall6(SYS_SETATTRLIST, uintptr(unsafe.Pointer(path)), uintptr(list), uintptr(buf), uintptr(size), uintptr(options), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func kill(pid int, signum int, posix int) (err error) {
+ _, _, e1 := Syscall(SYS_KILL, uintptr(pid), uintptr(signum), uintptr(posix))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func ioctl(fd int, req uint, arg uintptr) (err error) {
+ _, _, e1 := Syscall(SYS_IOCTL, uintptr(fd), uintptr(req), uintptr(arg))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func sendfile(infd int, outfd int, offset int64, len *int64, hdtr unsafe.Pointer, flags int) (err error) {
+ _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(offset), uintptr(offset>>32), uintptr(unsafe.Pointer(len)), uintptr(hdtr), uintptr(flags), 0, 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Access(path string, mode uint32) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_ACCESS, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Adjtime(delta *Timeval, olddelta *Timeval) (err error) {
+ _, _, e1 := Syscall(SYS_ADJTIME, uintptr(unsafe.Pointer(delta)), uintptr(unsafe.Pointer(olddelta)), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Chdir(path string) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_CHDIR, uintptr(unsafe.Pointer(_p0)), 0, 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Chflags(path string, flags int) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_CHFLAGS, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Chmod(path string, mode uint32) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_CHMOD, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Chown(path string, uid int, gid int) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_CHOWN, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Chroot(path string) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_CHROOT, uintptr(unsafe.Pointer(_p0)), 0, 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Close(fd int) (err error) {
+ _, _, e1 := Syscall(SYS_CLOSE, uintptr(fd), 0, 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Dup(fd int) (nfd int, err error) {
+ r0, _, e1 := Syscall(SYS_DUP, uintptr(fd), 0, 0)
+ nfd = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Dup2(from int, to int) (err error) {
+ _, _, e1 := Syscall(SYS_DUP2, uintptr(from), uintptr(to), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Exchangedata(path1 string, path2 string, options int) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path1)
+ if err != nil {
+ return
+ }
+ var _p1 *byte
+ _p1, err = BytePtrFromString(path2)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_EXCHANGEDATA, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(options))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Exit(code int) {
+ Syscall(SYS_EXIT, uintptr(code), 0, 0)
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Faccessat(dirfd int, path string, mode uint32, flags int) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall6(SYS_FACCESSAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Fchdir(fd int) (err error) {
+ _, _, e1 := Syscall(SYS_FCHDIR, uintptr(fd), 0, 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Fchflags(fd int, flags int) (err error) {
+ _, _, e1 := Syscall(SYS_FCHFLAGS, uintptr(fd), uintptr(flags), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Fchmod(fd int, mode uint32) (err error) {
+ _, _, e1 := Syscall(SYS_FCHMOD, uintptr(fd), uintptr(mode), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall6(SYS_FCHMODAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Fchown(fd int, uid int, gid int) (err error) {
+ _, _, e1 := Syscall(SYS_FCHOWN, uintptr(fd), uintptr(uid), uintptr(gid))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall6(SYS_FCHOWNAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid), uintptr(flags), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Flock(fd int, how int) (err error) {
+ _, _, e1 := Syscall(SYS_FLOCK, uintptr(fd), uintptr(how), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Fpathconf(fd int, name int) (val int, err error) {
+ r0, _, e1 := Syscall(SYS_FPATHCONF, uintptr(fd), uintptr(name), 0)
+ val = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Fsync(fd int) (err error) {
+ _, _, e1 := Syscall(SYS_FSYNC, uintptr(fd), 0, 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Ftruncate(fd int, length int64) (err error) {
+ _, _, e1 := Syscall(SYS_FTRUNCATE, uintptr(fd), uintptr(length), uintptr(length>>32))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Getdtablesize() (size int) {
+ r0, _, _ := Syscall(SYS_GETDTABLESIZE, 0, 0, 0)
+ size = int(r0)
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Getegid() (egid int) {
+ r0, _, _ := RawSyscall(SYS_GETEGID, 0, 0, 0)
+ egid = int(r0)
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Geteuid() (uid int) {
+ r0, _, _ := RawSyscall(SYS_GETEUID, 0, 0, 0)
+ uid = int(r0)
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Getgid() (gid int) {
+ r0, _, _ := RawSyscall(SYS_GETGID, 0, 0, 0)
+ gid = int(r0)
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Getpgid(pid int) (pgid int, err error) {
+ r0, _, e1 := RawSyscall(SYS_GETPGID, uintptr(pid), 0, 0)
+ pgid = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Getpgrp() (pgrp int) {
+ r0, _, _ := RawSyscall(SYS_GETPGRP, 0, 0, 0)
+ pgrp = int(r0)
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Getpid() (pid int) {
+ r0, _, _ := RawSyscall(SYS_GETPID, 0, 0, 0)
+ pid = int(r0)
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Getppid() (ppid int) {
+ r0, _, _ := RawSyscall(SYS_GETPPID, 0, 0, 0)
+ ppid = int(r0)
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Getpriority(which int, who int) (prio int, err error) {
+ r0, _, e1 := Syscall(SYS_GETPRIORITY, uintptr(which), uintptr(who), 0)
+ prio = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Getrlimit(which int, lim *Rlimit) (err error) {
+ _, _, e1 := RawSyscall(SYS_GETRLIMIT, uintptr(which), uintptr(unsafe.Pointer(lim)), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Getrusage(who int, rusage *Rusage) (err error) {
+ _, _, e1 := RawSyscall(SYS_GETRUSAGE, uintptr(who), uintptr(unsafe.Pointer(rusage)), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Getsid(pid int) (sid int, err error) {
+ r0, _, e1 := RawSyscall(SYS_GETSID, uintptr(pid), 0, 0)
+ sid = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Getuid() (uid int) {
+ r0, _, _ := RawSyscall(SYS_GETUID, 0, 0, 0)
+ uid = int(r0)
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Issetugid() (tainted bool) {
+ r0, _, _ := RawSyscall(SYS_ISSETUGID, 0, 0, 0)
+ tainted = bool(r0 != 0)
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Kqueue() (fd int, err error) {
+ r0, _, e1 := Syscall(SYS_KQUEUE, 0, 0, 0)
+ fd = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Lchown(path string, uid int, gid int) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_LCHOWN, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Link(path string, link string) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ var _p1 *byte
+ _p1, err = BytePtrFromString(link)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_LINK, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Linkat(pathfd int, path string, linkfd int, link string, flags int) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ var _p1 *byte
+ _p1, err = BytePtrFromString(link)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall6(SYS_LINKAT, uintptr(pathfd), uintptr(unsafe.Pointer(_p0)), uintptr(linkfd), uintptr(unsafe.Pointer(_p1)), uintptr(flags), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Listen(s int, backlog int) (err error) {
+ _, _, e1 := Syscall(SYS_LISTEN, uintptr(s), uintptr(backlog), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Mkdir(path string, mode uint32) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_MKDIR, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Mkdirat(dirfd int, path string, mode uint32) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_MKDIRAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Mkfifo(path string, mode uint32) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_MKFIFO, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Mknod(path string, mode uint32, dev int) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_MKNOD, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(dev))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Open(path string, mode int, perm uint32) (fd int, err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ r0, _, e1 := Syscall(SYS_OPEN, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(perm))
+ fd = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Openat(dirfd int, path string, mode int, perm uint32) (fd int, err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ r0, _, e1 := Syscall6(SYS_OPENAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(perm), 0, 0)
+ fd = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Pathconf(path string, name int) (val int, err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ r0, _, e1 := Syscall(SYS_PATHCONF, uintptr(unsafe.Pointer(_p0)), uintptr(name), 0)
+ val = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Pread(fd int, p []byte, offset int64) (n int, err error) {
+ var _p0 unsafe.Pointer
+ if len(p) > 0 {
+ _p0 = unsafe.Pointer(&p[0])
+ } else {
+ _p0 = unsafe.Pointer(&_zero)
+ }
+ r0, _, e1 := Syscall6(SYS_PREAD, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), uintptr(offset>>32), 0)
+ n = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Pwrite(fd int, p []byte, offset int64) (n int, err error) {
+ var _p0 unsafe.Pointer
+ if len(p) > 0 {
+ _p0 = unsafe.Pointer(&p[0])
+ } else {
+ _p0 = unsafe.Pointer(&_zero)
+ }
+ r0, _, e1 := Syscall6(SYS_PWRITE, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), uintptr(offset>>32), 0)
+ n = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func read(fd int, p []byte) (n int, err error) {
+ var _p0 unsafe.Pointer
+ if len(p) > 0 {
+ _p0 = unsafe.Pointer(&p[0])
+ } else {
+ _p0 = unsafe.Pointer(&_zero)
+ }
+ r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(_p0), uintptr(len(p)))
+ n = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Readlink(path string, buf []byte) (n int, err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ var _p1 unsafe.Pointer
+ if len(buf) > 0 {
+ _p1 = unsafe.Pointer(&buf[0])
+ } else {
+ _p1 = unsafe.Pointer(&_zero)
+ }
+ r0, _, e1 := Syscall(SYS_READLINK, uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(buf)))
+ n = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Readlinkat(dirfd int, path string, buf []byte) (n int, err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ var _p1 unsafe.Pointer
+ if len(buf) > 0 {
+ _p1 = unsafe.Pointer(&buf[0])
+ } else {
+ _p1 = unsafe.Pointer(&_zero)
+ }
+ r0, _, e1 := Syscall6(SYS_READLINKAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(buf)), 0, 0)
+ n = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Rename(from string, to string) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(from)
+ if err != nil {
+ return
+ }
+ var _p1 *byte
+ _p1, err = BytePtrFromString(to)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_RENAME, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Renameat(fromfd int, from string, tofd int, to string) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(from)
+ if err != nil {
+ return
+ }
+ var _p1 *byte
+ _p1, err = BytePtrFromString(to)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall6(SYS_RENAMEAT, uintptr(fromfd), uintptr(unsafe.Pointer(_p0)), uintptr(tofd), uintptr(unsafe.Pointer(_p1)), 0, 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Revoke(path string) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_REVOKE, uintptr(unsafe.Pointer(_p0)), 0, 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Rmdir(path string) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_RMDIR, uintptr(unsafe.Pointer(_p0)), 0, 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Seek(fd int, offset int64, whence int) (newoffset int64, err error) {
+ r0, r1, e1 := Syscall6(SYS_LSEEK, uintptr(fd), uintptr(offset), uintptr(offset>>32), uintptr(whence), 0, 0)
+ newoffset = int64(int64(r1)<<32 | int64(r0))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Select(n int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (err error) {
+ _, _, e1 := Syscall6(SYS_SELECT, uintptr(n), uintptr(unsafe.Pointer(r)), uintptr(unsafe.Pointer(w)), uintptr(unsafe.Pointer(e)), uintptr(unsafe.Pointer(timeout)), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Setegid(egid int) (err error) {
+ _, _, e1 := Syscall(SYS_SETEGID, uintptr(egid), 0, 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Seteuid(euid int) (err error) {
+ _, _, e1 := RawSyscall(SYS_SETEUID, uintptr(euid), 0, 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Setgid(gid int) (err error) {
+ _, _, e1 := RawSyscall(SYS_SETGID, uintptr(gid), 0, 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Setlogin(name string) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(name)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_SETLOGIN, uintptr(unsafe.Pointer(_p0)), 0, 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Setpgid(pid int, pgid int) (err error) {
+ _, _, e1 := RawSyscall(SYS_SETPGID, uintptr(pid), uintptr(pgid), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Setpriority(which int, who int, prio int) (err error) {
+ _, _, e1 := Syscall(SYS_SETPRIORITY, uintptr(which), uintptr(who), uintptr(prio))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Setprivexec(flag int) (err error) {
+ _, _, e1 := Syscall(SYS_SETPRIVEXEC, uintptr(flag), 0, 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Setregid(rgid int, egid int) (err error) {
+ _, _, e1 := RawSyscall(SYS_SETREGID, uintptr(rgid), uintptr(egid), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Setreuid(ruid int, euid int) (err error) {
+ _, _, e1 := RawSyscall(SYS_SETREUID, uintptr(ruid), uintptr(euid), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Setrlimit(which int, lim *Rlimit) (err error) {
+ _, _, e1 := RawSyscall(SYS_SETRLIMIT, uintptr(which), uintptr(unsafe.Pointer(lim)), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Setsid() (pid int, err error) {
+ r0, _, e1 := RawSyscall(SYS_SETSID, 0, 0, 0)
+ pid = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Settimeofday(tp *Timeval) (err error) {
+ _, _, e1 := RawSyscall(SYS_SETTIMEOFDAY, uintptr(unsafe.Pointer(tp)), 0, 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Setuid(uid int) (err error) {
+ _, _, e1 := RawSyscall(SYS_SETUID, uintptr(uid), 0, 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Symlink(path string, link string) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ var _p1 *byte
+ _p1, err = BytePtrFromString(link)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_SYMLINK, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Symlinkat(oldpath string, newdirfd int, newpath string) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(oldpath)
+ if err != nil {
+ return
+ }
+ var _p1 *byte
+ _p1, err = BytePtrFromString(newpath)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_SYMLINKAT, uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1)))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Sync() (err error) {
+ _, _, e1 := Syscall(SYS_SYNC, 0, 0, 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Truncate(path string, length int64) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_TRUNCATE, uintptr(unsafe.Pointer(_p0)), uintptr(length), uintptr(length>>32))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Umask(newmask int) (oldmask int) {
+ r0, _, _ := Syscall(SYS_UMASK, uintptr(newmask), 0, 0)
+ oldmask = int(r0)
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Undelete(path string) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_UNDELETE, uintptr(unsafe.Pointer(_p0)), 0, 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Unlink(path string) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_UNLINK, uintptr(unsafe.Pointer(_p0)), 0, 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Unlinkat(dirfd int, path string, flags int) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_UNLINKAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(flags))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Unmount(path string, flags int) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_UNMOUNT, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func write(fd int, p []byte) (n int, err error) {
+ var _p0 unsafe.Pointer
+ if len(p) > 0 {
+ _p0 = unsafe.Pointer(&p[0])
+ } else {
+ _p0 = unsafe.Pointer(&_zero)
+ }
+ r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(_p0), uintptr(len(p)))
+ n = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error) {
+ r0, _, e1 := Syscall9(SYS_MMAP, uintptr(addr), uintptr(length), uintptr(prot), uintptr(flag), uintptr(fd), uintptr(pos), uintptr(pos>>32), 0, 0)
+ ret = uintptr(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func munmap(addr uintptr, length uintptr) (err error) {
+ _, _, e1 := Syscall(SYS_MUNMAP, uintptr(addr), uintptr(length), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func readlen(fd int, buf *byte, nbuf int) (n int, err error) {
+ r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf))
+ n = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func writelen(fd int, buf *byte, nbuf int) (n int, err error) {
+ r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf))
+ n = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func gettimeofday(tp *Timeval) (sec int32, usec int32, err error) {
+ r0, r1, e1 := RawSyscall(SYS_GETTIMEOFDAY, uintptr(unsafe.Pointer(tp)), 0, 0)
+ sec = int32(r0)
+ usec = int32(r1)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Fstat(fd int, stat *Stat_t) (err error) {
+ _, _, e1 := Syscall(SYS_FSTAT64, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Fstatat(fd int, path string, stat *Stat_t, flags int) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall6(SYS_FSTATAT64, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), uintptr(flags), 0, 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Fstatfs(fd int, stat *Statfs_t) (err error) {
+ _, _, e1 := Syscall(SYS_FSTATFS64, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) {
+ var _p0 unsafe.Pointer
+ if len(buf) > 0 {
+ _p0 = unsafe.Pointer(&buf[0])
+ } else {
+ _p0 = unsafe.Pointer(&_zero)
+ }
+ r0, _, e1 := Syscall6(SYS_GETDIRENTRIES64, uintptr(fd), uintptr(_p0), uintptr(len(buf)), uintptr(unsafe.Pointer(basep)), 0, 0)
+ n = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func getfsstat(buf unsafe.Pointer, size uintptr, flags int) (n int, err error) {
+ r0, _, e1 := Syscall(SYS_GETFSSTAT64, uintptr(buf), uintptr(size), uintptr(flags))
+ n = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Lstat(path string, stat *Stat_t) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_LSTAT64, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Stat(path string, stat *Stat_t) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_STAT64, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Statfs(path string, stat *Statfs_t) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_STATFS64, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
diff --git a/vendor/golang.org/x/sys/unix/zsyscall_darwin_386.go b/vendor/golang.org/x/sys/unix/zsyscall_darwin_386.go
index 9ce06df6e..23346dc68 100644
--- a/vendor/golang.org/x/sys/unix/zsyscall_darwin_386.go
+++ b/vendor/golang.org/x/sys/unix/zsyscall_darwin_386.go
@@ -1,7 +1,7 @@
-// mksyscall.pl -l32 -tags darwin,386 syscall_bsd.go syscall_darwin.go syscall_darwin_386.go
+// go run mksyscall.go -l32 -tags darwin,386,go1.12 syscall_bsd.go syscall_darwin.go syscall_darwin_386.go
// Code generated by the command above; see README.md. DO NOT EDIT.
-// +build darwin,386
+// +build darwin,386,go1.12
package unix
@@ -15,7 +15,7 @@ var _ syscall.Errno
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func getgroups(ngid int, gid *_Gid_t) (n int, err error) {
- r0, _, e1 := RawSyscall(SYS_GETGROUPS, uintptr(ngid), uintptr(unsafe.Pointer(gid)), 0)
+ r0, _, e1 := syscall_rawSyscall(funcPC(libc_getgroups_trampoline), uintptr(ngid), uintptr(unsafe.Pointer(gid)), 0)
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -23,20 +23,30 @@ func getgroups(ngid int, gid *_Gid_t) (n int, err error) {
return
}
+func libc_getgroups_trampoline()
+
+//go:linkname libc_getgroups libc_getgroups
+//go:cgo_import_dynamic libc_getgroups getgroups "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func setgroups(ngid int, gid *_Gid_t) (err error) {
- _, _, e1 := RawSyscall(SYS_SETGROUPS, uintptr(ngid), uintptr(unsafe.Pointer(gid)), 0)
+ _, _, e1 := syscall_rawSyscall(funcPC(libc_setgroups_trampoline), uintptr(ngid), uintptr(unsafe.Pointer(gid)), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_setgroups_trampoline()
+
+//go:linkname libc_setgroups libc_setgroups
+//go:cgo_import_dynamic libc_setgroups setgroups "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func wait4(pid int, wstatus *_C_int, options int, rusage *Rusage) (wpid int, err error) {
- r0, _, e1 := Syscall6(SYS_WAIT4, uintptr(pid), uintptr(unsafe.Pointer(wstatus)), uintptr(options), uintptr(unsafe.Pointer(rusage)), 0, 0)
+ r0, _, e1 := syscall_syscall6(funcPC(libc_wait4_trampoline), uintptr(pid), uintptr(unsafe.Pointer(wstatus)), uintptr(options), uintptr(unsafe.Pointer(rusage)), 0, 0)
wpid = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -44,10 +54,15 @@ func wait4(pid int, wstatus *_C_int, options int, rusage *Rusage) (wpid int, err
return
}
+func libc_wait4_trampoline()
+
+//go:linkname libc_wait4 libc_wait4
+//go:cgo_import_dynamic libc_wait4 wait4 "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) {
- r0, _, e1 := Syscall(SYS_ACCEPT, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
+ r0, _, e1 := syscall_syscall(funcPC(libc_accept_trampoline), uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
fd = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -55,30 +70,45 @@ func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) {
return
}
+func libc_accept_trampoline()
+
+//go:linkname libc_accept libc_accept
+//go:cgo_import_dynamic libc_accept accept "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) {
- _, _, e1 := Syscall(SYS_BIND, uintptr(s), uintptr(addr), uintptr(addrlen))
+ _, _, e1 := syscall_syscall(funcPC(libc_bind_trampoline), uintptr(s), uintptr(addr), uintptr(addrlen))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_bind_trampoline()
+
+//go:linkname libc_bind libc_bind
+//go:cgo_import_dynamic libc_bind bind "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) {
- _, _, e1 := Syscall(SYS_CONNECT, uintptr(s), uintptr(addr), uintptr(addrlen))
+ _, _, e1 := syscall_syscall(funcPC(libc_connect_trampoline), uintptr(s), uintptr(addr), uintptr(addrlen))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_connect_trampoline()
+
+//go:linkname libc_connect libc_connect
+//go:cgo_import_dynamic libc_connect connect "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func socket(domain int, typ int, proto int) (fd int, err error) {
- r0, _, e1 := RawSyscall(SYS_SOCKET, uintptr(domain), uintptr(typ), uintptr(proto))
+ r0, _, e1 := syscall_rawSyscall(funcPC(libc_socket_trampoline), uintptr(domain), uintptr(typ), uintptr(proto))
fd = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -86,66 +116,101 @@ func socket(domain int, typ int, proto int) (fd int, err error) {
return
}
+func libc_socket_trampoline()
+
+//go:linkname libc_socket libc_socket
+//go:cgo_import_dynamic libc_socket socket "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) {
- _, _, e1 := Syscall6(SYS_GETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(unsafe.Pointer(vallen)), 0)
+ _, _, e1 := syscall_syscall6(funcPC(libc_getsockopt_trampoline), uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(unsafe.Pointer(vallen)), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_getsockopt_trampoline()
+
+//go:linkname libc_getsockopt libc_getsockopt
+//go:cgo_import_dynamic libc_getsockopt getsockopt "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) {
- _, _, e1 := Syscall6(SYS_SETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(vallen), 0)
+ _, _, e1 := syscall_syscall6(funcPC(libc_setsockopt_trampoline), uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(vallen), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_setsockopt_trampoline()
+
+//go:linkname libc_setsockopt libc_setsockopt
+//go:cgo_import_dynamic libc_setsockopt setsockopt "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) {
- _, _, e1 := RawSyscall(SYS_GETPEERNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
+ _, _, e1 := syscall_rawSyscall(funcPC(libc_getpeername_trampoline), uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_getpeername_trampoline()
+
+//go:linkname libc_getpeername libc_getpeername
+//go:cgo_import_dynamic libc_getpeername getpeername "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) {
- _, _, e1 := RawSyscall(SYS_GETSOCKNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
+ _, _, e1 := syscall_rawSyscall(funcPC(libc_getsockname_trampoline), uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_getsockname_trampoline()
+
+//go:linkname libc_getsockname libc_getsockname
+//go:cgo_import_dynamic libc_getsockname getsockname "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Shutdown(s int, how int) (err error) {
- _, _, e1 := Syscall(SYS_SHUTDOWN, uintptr(s), uintptr(how), 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_shutdown_trampoline), uintptr(s), uintptr(how), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_shutdown_trampoline()
+
+//go:linkname libc_shutdown libc_shutdown
+//go:cgo_import_dynamic libc_shutdown shutdown "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) {
- _, _, e1 := RawSyscall6(SYS_SOCKETPAIR, uintptr(domain), uintptr(typ), uintptr(proto), uintptr(unsafe.Pointer(fd)), 0, 0)
+ _, _, e1 := syscall_rawSyscall6(funcPC(libc_socketpair_trampoline), uintptr(domain), uintptr(typ), uintptr(proto), uintptr(unsafe.Pointer(fd)), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_socketpair_trampoline()
+
+//go:linkname libc_socketpair libc_socketpair
+//go:cgo_import_dynamic libc_socketpair socketpair "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) {
@@ -155,7 +220,7 @@ func recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Sockl
} else {
_p0 = unsafe.Pointer(&_zero)
}
- r0, _, e1 := Syscall6(SYS_RECVFROM, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(flags), uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(fromlen)))
+ r0, _, e1 := syscall_syscall6(funcPC(libc_recvfrom_trampoline), uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(flags), uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(fromlen)))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -163,6 +228,11 @@ func recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Sockl
return
}
+func libc_recvfrom_trampoline()
+
+//go:linkname libc_recvfrom libc_recvfrom
+//go:cgo_import_dynamic libc_recvfrom recvfrom "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) {
@@ -172,17 +242,22 @@ func sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (
} else {
_p0 = unsafe.Pointer(&_zero)
}
- _, _, e1 := Syscall6(SYS_SENDTO, uintptr(s), uintptr(_p0), uintptr(len(buf)), uintptr(flags), uintptr(to), uintptr(addrlen))
+ _, _, e1 := syscall_syscall6(funcPC(libc_sendto_trampoline), uintptr(s), uintptr(_p0), uintptr(len(buf)), uintptr(flags), uintptr(to), uintptr(addrlen))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_sendto_trampoline()
+
+//go:linkname libc_sendto libc_sendto
+//go:cgo_import_dynamic libc_sendto sendto "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func recvmsg(s int, msg *Msghdr, flags int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_RECVMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags))
+ r0, _, e1 := syscall_syscall(funcPC(libc_recvmsg_trampoline), uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -190,10 +265,15 @@ func recvmsg(s int, msg *Msghdr, flags int) (n int, err error) {
return
}
+func libc_recvmsg_trampoline()
+
+//go:linkname libc_recvmsg libc_recvmsg
+//go:cgo_import_dynamic libc_recvmsg recvmsg "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func sendmsg(s int, msg *Msghdr, flags int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_SENDMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags))
+ r0, _, e1 := syscall_syscall(funcPC(libc_sendmsg_trampoline), uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -201,10 +281,15 @@ func sendmsg(s int, msg *Msghdr, flags int) (n int, err error) {
return
}
+func libc_sendmsg_trampoline()
+
+//go:linkname libc_sendmsg libc_sendmsg
+//go:cgo_import_dynamic libc_sendmsg sendmsg "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func kevent(kq int, change unsafe.Pointer, nchange int, event unsafe.Pointer, nevent int, timeout *Timespec) (n int, err error) {
- r0, _, e1 := Syscall6(SYS_KEVENT, uintptr(kq), uintptr(change), uintptr(nchange), uintptr(event), uintptr(nevent), uintptr(unsafe.Pointer(timeout)))
+ r0, _, e1 := syscall_syscall6(funcPC(libc_kevent_trampoline), uintptr(kq), uintptr(change), uintptr(nchange), uintptr(event), uintptr(nevent), uintptr(unsafe.Pointer(timeout)))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -212,6 +297,11 @@ func kevent(kq int, change unsafe.Pointer, nchange int, event unsafe.Pointer, ne
return
}
+func libc_kevent_trampoline()
+
+//go:linkname libc_kevent libc_kevent
+//go:cgo_import_dynamic libc_kevent kevent "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) {
@@ -221,13 +311,18 @@ func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr)
} else {
_p0 = unsafe.Pointer(&_zero)
}
- _, _, e1 := Syscall6(SYS___SYSCTL, uintptr(_p0), uintptr(len(mib)), uintptr(unsafe.Pointer(old)), uintptr(unsafe.Pointer(oldlen)), uintptr(unsafe.Pointer(new)), uintptr(newlen))
+ _, _, e1 := syscall_syscall6(funcPC(libc___sysctl_trampoline), uintptr(_p0), uintptr(len(mib)), uintptr(unsafe.Pointer(old)), uintptr(unsafe.Pointer(oldlen)), uintptr(unsafe.Pointer(new)), uintptr(newlen))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc___sysctl_trampoline()
+
+//go:linkname libc___sysctl libc___sysctl
+//go:cgo_import_dynamic libc___sysctl __sysctl "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func utimes(path string, timeval *[2]Timeval) (err error) {
@@ -236,27 +331,37 @@ func utimes(path string, timeval *[2]Timeval) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall(SYS_UTIMES, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(timeval)), 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_utimes_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(timeval)), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_utimes_trampoline()
+
+//go:linkname libc_utimes libc_utimes
+//go:cgo_import_dynamic libc_utimes utimes "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func futimes(fd int, timeval *[2]Timeval) (err error) {
- _, _, e1 := Syscall(SYS_FUTIMES, uintptr(fd), uintptr(unsafe.Pointer(timeval)), 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_futimes_trampoline), uintptr(fd), uintptr(unsafe.Pointer(timeval)), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_futimes_trampoline()
+
+//go:linkname libc_futimes libc_futimes
+//go:cgo_import_dynamic libc_futimes futimes "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func fcntl(fd int, cmd int, arg int) (val int, err error) {
- r0, _, e1 := Syscall(SYS_FCNTL, uintptr(fd), uintptr(cmd), uintptr(arg))
+ r0, _, e1 := syscall_syscall(funcPC(libc_fcntl_trampoline), uintptr(fd), uintptr(cmd), uintptr(arg))
val = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -264,10 +369,15 @@ func fcntl(fd int, cmd int, arg int) (val int, err error) {
return
}
+func libc_fcntl_trampoline()
+
+//go:linkname libc_fcntl libc_fcntl
+//go:cgo_import_dynamic libc_fcntl fcntl "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func poll(fds *PollFd, nfds int, timeout int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_POLL, uintptr(unsafe.Pointer(fds)), uintptr(nfds), uintptr(timeout))
+ r0, _, e1 := syscall_syscall(funcPC(libc_poll_trampoline), uintptr(unsafe.Pointer(fds)), uintptr(nfds), uintptr(timeout))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -275,6 +385,11 @@ func poll(fds *PollFd, nfds int, timeout int) (n int, err error) {
return
}
+func libc_poll_trampoline()
+
+//go:linkname libc_poll libc_poll
+//go:cgo_import_dynamic libc_poll poll "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Madvise(b []byte, behav int) (err error) {
@@ -284,13 +399,18 @@ func Madvise(b []byte, behav int) (err error) {
} else {
_p0 = unsafe.Pointer(&_zero)
}
- _, _, e1 := Syscall(SYS_MADVISE, uintptr(_p0), uintptr(len(b)), uintptr(behav))
+ _, _, e1 := syscall_syscall(funcPC(libc_madvise_trampoline), uintptr(_p0), uintptr(len(b)), uintptr(behav))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_madvise_trampoline()
+
+//go:linkname libc_madvise libc_madvise
+//go:cgo_import_dynamic libc_madvise madvise "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Mlock(b []byte) (err error) {
@@ -300,23 +420,33 @@ func Mlock(b []byte) (err error) {
} else {
_p0 = unsafe.Pointer(&_zero)
}
- _, _, e1 := Syscall(SYS_MLOCK, uintptr(_p0), uintptr(len(b)), 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_mlock_trampoline), uintptr(_p0), uintptr(len(b)), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_mlock_trampoline()
+
+//go:linkname libc_mlock libc_mlock
+//go:cgo_import_dynamic libc_mlock mlock "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Mlockall(flags int) (err error) {
- _, _, e1 := Syscall(SYS_MLOCKALL, uintptr(flags), 0, 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_mlockall_trampoline), uintptr(flags), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_mlockall_trampoline()
+
+//go:linkname libc_mlockall libc_mlockall
+//go:cgo_import_dynamic libc_mlockall mlockall "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Mprotect(b []byte, prot int) (err error) {
@@ -326,13 +456,18 @@ func Mprotect(b []byte, prot int) (err error) {
} else {
_p0 = unsafe.Pointer(&_zero)
}
- _, _, e1 := Syscall(SYS_MPROTECT, uintptr(_p0), uintptr(len(b)), uintptr(prot))
+ _, _, e1 := syscall_syscall(funcPC(libc_mprotect_trampoline), uintptr(_p0), uintptr(len(b)), uintptr(prot))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_mprotect_trampoline()
+
+//go:linkname libc_mprotect libc_mprotect
+//go:cgo_import_dynamic libc_mprotect mprotect "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Msync(b []byte, flags int) (err error) {
@@ -342,13 +477,18 @@ func Msync(b []byte, flags int) (err error) {
} else {
_p0 = unsafe.Pointer(&_zero)
}
- _, _, e1 := Syscall(SYS_MSYNC, uintptr(_p0), uintptr(len(b)), uintptr(flags))
+ _, _, e1 := syscall_syscall(funcPC(libc_msync_trampoline), uintptr(_p0), uintptr(len(b)), uintptr(flags))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_msync_trampoline()
+
+//go:linkname libc_msync libc_msync
+//go:cgo_import_dynamic libc_msync msync "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Munlock(b []byte) (err error) {
@@ -358,37 +498,67 @@ func Munlock(b []byte) (err error) {
} else {
_p0 = unsafe.Pointer(&_zero)
}
- _, _, e1 := Syscall(SYS_MUNLOCK, uintptr(_p0), uintptr(len(b)), 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_munlock_trampoline), uintptr(_p0), uintptr(len(b)), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_munlock_trampoline()
+
+//go:linkname libc_munlock libc_munlock
+//go:cgo_import_dynamic libc_munlock munlock "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Munlockall() (err error) {
- _, _, e1 := Syscall(SYS_MUNLOCKALL, 0, 0, 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_munlockall_trampoline), 0, 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_munlockall_trampoline()
+
+//go:linkname libc_munlockall libc_munlockall
+//go:cgo_import_dynamic libc_munlockall munlockall "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func ptrace(request int, pid int, addr uintptr, data uintptr) (err error) {
- _, _, e1 := Syscall6(SYS_PTRACE, uintptr(request), uintptr(pid), uintptr(addr), uintptr(data), 0, 0)
+ _, _, e1 := syscall_syscall6(funcPC(libc_ptrace_trampoline), uintptr(request), uintptr(pid), uintptr(addr), uintptr(data), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_ptrace_trampoline()
+
+//go:linkname libc_ptrace libc_ptrace
+//go:cgo_import_dynamic libc_ptrace ptrace "/usr/lib/libSystem.B.dylib"
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func getattrlist(path *byte, list unsafe.Pointer, buf unsafe.Pointer, size uintptr, options int) (err error) {
+ _, _, e1 := syscall_syscall6(funcPC(libc_getattrlist_trampoline), uintptr(unsafe.Pointer(path)), uintptr(list), uintptr(buf), uintptr(size), uintptr(options), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func libc_getattrlist_trampoline()
+
+//go:linkname libc_getattrlist libc_getattrlist
+//go:cgo_import_dynamic libc_getattrlist getattrlist "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func pipe() (r int, w int, err error) {
- r0, r1, e1 := RawSyscall(SYS_PIPE, 0, 0, 0)
+ r0, r1, e1 := syscall_rawSyscall(funcPC(libc_pipe_trampoline), 0, 0, 0)
r = int(r0)
w = int(r1)
if e1 != 0 {
@@ -397,6 +567,11 @@ func pipe() (r int, w int, err error) {
return
}
+func libc_pipe_trampoline()
+
+//go:linkname libc_pipe libc_pipe
+//go:cgo_import_dynamic libc_pipe pipe "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func getxattr(path string, attr string, dest *byte, size int, position uint32, options int) (sz int, err error) {
@@ -410,7 +585,7 @@ func getxattr(path string, attr string, dest *byte, size int, position uint32, o
if err != nil {
return
}
- r0, _, e1 := Syscall6(SYS_GETXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(unsafe.Pointer(dest)), uintptr(size), uintptr(position), uintptr(options))
+ r0, _, e1 := syscall_syscall6(funcPC(libc_getxattr_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(unsafe.Pointer(dest)), uintptr(size), uintptr(position), uintptr(options))
sz = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -418,6 +593,11 @@ func getxattr(path string, attr string, dest *byte, size int, position uint32, o
return
}
+func libc_getxattr_trampoline()
+
+//go:linkname libc_getxattr libc_getxattr
+//go:cgo_import_dynamic libc_getxattr getxattr "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func fgetxattr(fd int, attr string, dest *byte, size int, position uint32, options int) (sz int, err error) {
@@ -426,7 +606,7 @@ func fgetxattr(fd int, attr string, dest *byte, size int, position uint32, optio
if err != nil {
return
}
- r0, _, e1 := Syscall6(SYS_FGETXATTR, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(dest)), uintptr(size), uintptr(position), uintptr(options))
+ r0, _, e1 := syscall_syscall6(funcPC(libc_fgetxattr_trampoline), uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(dest)), uintptr(size), uintptr(position), uintptr(options))
sz = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -434,6 +614,11 @@ func fgetxattr(fd int, attr string, dest *byte, size int, position uint32, optio
return
}
+func libc_fgetxattr_trampoline()
+
+//go:linkname libc_fgetxattr libc_fgetxattr
+//go:cgo_import_dynamic libc_fgetxattr fgetxattr "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func setxattr(path string, attr string, data *byte, size int, position uint32, options int) (err error) {
@@ -447,13 +632,18 @@ func setxattr(path string, attr string, data *byte, size int, position uint32, o
if err != nil {
return
}
- _, _, e1 := Syscall6(SYS_SETXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(unsafe.Pointer(data)), uintptr(size), uintptr(position), uintptr(options))
+ _, _, e1 := syscall_syscall6(funcPC(libc_setxattr_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(unsafe.Pointer(data)), uintptr(size), uintptr(position), uintptr(options))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_setxattr_trampoline()
+
+//go:linkname libc_setxattr libc_setxattr
+//go:cgo_import_dynamic libc_setxattr setxattr "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func fsetxattr(fd int, attr string, data *byte, size int, position uint32, options int) (err error) {
@@ -462,13 +652,18 @@ func fsetxattr(fd int, attr string, data *byte, size int, position uint32, optio
if err != nil {
return
}
- _, _, e1 := Syscall6(SYS_FSETXATTR, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(data)), uintptr(size), uintptr(position), uintptr(options))
+ _, _, e1 := syscall_syscall6(funcPC(libc_fsetxattr_trampoline), uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(data)), uintptr(size), uintptr(position), uintptr(options))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_fsetxattr_trampoline()
+
+//go:linkname libc_fsetxattr libc_fsetxattr
+//go:cgo_import_dynamic libc_fsetxattr fsetxattr "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func removexattr(path string, attr string, options int) (err error) {
@@ -482,13 +677,18 @@ func removexattr(path string, attr string, options int) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall(SYS_REMOVEXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(options))
+ _, _, e1 := syscall_syscall(funcPC(libc_removexattr_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(options))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_removexattr_trampoline()
+
+//go:linkname libc_removexattr libc_removexattr
+//go:cgo_import_dynamic libc_removexattr removexattr "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func fremovexattr(fd int, attr string, options int) (err error) {
@@ -497,13 +697,18 @@ func fremovexattr(fd int, attr string, options int) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall(SYS_FREMOVEXATTR, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(options))
+ _, _, e1 := syscall_syscall(funcPC(libc_fremovexattr_trampoline), uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(options))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_fremovexattr_trampoline()
+
+//go:linkname libc_fremovexattr libc_fremovexattr
+//go:cgo_import_dynamic libc_fremovexattr fremovexattr "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func listxattr(path string, dest *byte, size int, options int) (sz int, err error) {
@@ -512,7 +717,7 @@ func listxattr(path string, dest *byte, size int, options int) (sz int, err erro
if err != nil {
return
}
- r0, _, e1 := Syscall6(SYS_LISTXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(dest)), uintptr(size), uintptr(options), 0, 0)
+ r0, _, e1 := syscall_syscall6(funcPC(libc_listxattr_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(dest)), uintptr(size), uintptr(options), 0, 0)
sz = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -520,10 +725,15 @@ func listxattr(path string, dest *byte, size int, options int) (sz int, err erro
return
}
+func libc_listxattr_trampoline()
+
+//go:linkname libc_listxattr libc_listxattr
+//go:cgo_import_dynamic libc_listxattr listxattr "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func flistxattr(fd int, dest *byte, size int, options int) (sz int, err error) {
- r0, _, e1 := Syscall6(SYS_FLISTXATTR, uintptr(fd), uintptr(unsafe.Pointer(dest)), uintptr(size), uintptr(options), 0, 0)
+ r0, _, e1 := syscall_syscall6(funcPC(libc_flistxattr_trampoline), uintptr(fd), uintptr(unsafe.Pointer(dest)), uintptr(size), uintptr(options), 0, 0)
sz = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -531,26 +741,71 @@ func flistxattr(fd int, dest *byte, size int, options int) (sz int, err error) {
return
}
+func libc_flistxattr_trampoline()
+
+//go:linkname libc_flistxattr libc_flistxattr
+//go:cgo_import_dynamic libc_flistxattr flistxattr "/usr/lib/libSystem.B.dylib"
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func setattrlist(path *byte, list unsafe.Pointer, buf unsafe.Pointer, size uintptr, options int) (err error) {
+ _, _, e1 := syscall_syscall6(funcPC(libc_setattrlist_trampoline), uintptr(unsafe.Pointer(path)), uintptr(list), uintptr(buf), uintptr(size), uintptr(options), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func libc_setattrlist_trampoline()
+
+//go:linkname libc_setattrlist libc_setattrlist
+//go:cgo_import_dynamic libc_setattrlist setattrlist "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func kill(pid int, signum int, posix int) (err error) {
- _, _, e1 := Syscall(SYS_KILL, uintptr(pid), uintptr(signum), uintptr(posix))
+ _, _, e1 := syscall_syscall(funcPC(libc_kill_trampoline), uintptr(pid), uintptr(signum), uintptr(posix))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_kill_trampoline()
+
+//go:linkname libc_kill libc_kill
+//go:cgo_import_dynamic libc_kill kill "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func ioctl(fd int, req uint, arg uintptr) (err error) {
- _, _, e1 := Syscall(SYS_IOCTL, uintptr(fd), uintptr(req), uintptr(arg))
+ _, _, e1 := syscall_syscall(funcPC(libc_ioctl_trampoline), uintptr(fd), uintptr(req), uintptr(arg))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_ioctl_trampoline()
+
+//go:linkname libc_ioctl libc_ioctl
+//go:cgo_import_dynamic libc_ioctl ioctl "/usr/lib/libSystem.B.dylib"
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func sendfile(infd int, outfd int, offset int64, len *int64, hdtr unsafe.Pointer, flags int) (err error) {
+ _, _, e1 := syscall_syscall9(funcPC(libc_sendfile_trampoline), uintptr(infd), uintptr(outfd), uintptr(offset), uintptr(offset>>32), uintptr(unsafe.Pointer(len)), uintptr(hdtr), uintptr(flags), 0, 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func libc_sendfile_trampoline()
+
+//go:linkname libc_sendfile libc_sendfile
+//go:cgo_import_dynamic libc_sendfile sendfile "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Access(path string, mode uint32) (err error) {
@@ -559,23 +814,33 @@ func Access(path string, mode uint32) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall(SYS_ACCESS, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_access_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_access_trampoline()
+
+//go:linkname libc_access libc_access
+//go:cgo_import_dynamic libc_access access "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Adjtime(delta *Timeval, olddelta *Timeval) (err error) {
- _, _, e1 := Syscall(SYS_ADJTIME, uintptr(unsafe.Pointer(delta)), uintptr(unsafe.Pointer(olddelta)), 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_adjtime_trampoline), uintptr(unsafe.Pointer(delta)), uintptr(unsafe.Pointer(olddelta)), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_adjtime_trampoline()
+
+//go:linkname libc_adjtime libc_adjtime
+//go:cgo_import_dynamic libc_adjtime adjtime "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Chdir(path string) (err error) {
@@ -584,13 +849,18 @@ func Chdir(path string) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall(SYS_CHDIR, uintptr(unsafe.Pointer(_p0)), 0, 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_chdir_trampoline), uintptr(unsafe.Pointer(_p0)), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_chdir_trampoline()
+
+//go:linkname libc_chdir libc_chdir
+//go:cgo_import_dynamic libc_chdir chdir "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Chflags(path string, flags int) (err error) {
@@ -599,13 +869,18 @@ func Chflags(path string, flags int) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall(SYS_CHFLAGS, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_chflags_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_chflags_trampoline()
+
+//go:linkname libc_chflags libc_chflags
+//go:cgo_import_dynamic libc_chflags chflags "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Chmod(path string, mode uint32) (err error) {
@@ -614,13 +889,18 @@ func Chmod(path string, mode uint32) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall(SYS_CHMOD, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_chmod_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_chmod_trampoline()
+
+//go:linkname libc_chmod libc_chmod
+//go:cgo_import_dynamic libc_chmod chmod "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Chown(path string, uid int, gid int) (err error) {
@@ -629,13 +909,18 @@ func Chown(path string, uid int, gid int) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall(SYS_CHOWN, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid))
+ _, _, e1 := syscall_syscall(funcPC(libc_chown_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_chown_trampoline()
+
+//go:linkname libc_chown libc_chown
+//go:cgo_import_dynamic libc_chown chown "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Chroot(path string) (err error) {
@@ -644,27 +929,37 @@ func Chroot(path string) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall(SYS_CHROOT, uintptr(unsafe.Pointer(_p0)), 0, 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_chroot_trampoline), uintptr(unsafe.Pointer(_p0)), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_chroot_trampoline()
+
+//go:linkname libc_chroot libc_chroot
+//go:cgo_import_dynamic libc_chroot chroot "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Close(fd int) (err error) {
- _, _, e1 := Syscall(SYS_CLOSE, uintptr(fd), 0, 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_close_trampoline), uintptr(fd), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_close_trampoline()
+
+//go:linkname libc_close libc_close
+//go:cgo_import_dynamic libc_close close "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Dup(fd int) (nfd int, err error) {
- r0, _, e1 := Syscall(SYS_DUP, uintptr(fd), 0, 0)
+ r0, _, e1 := syscall_syscall(funcPC(libc_dup_trampoline), uintptr(fd), 0, 0)
nfd = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -672,16 +967,26 @@ func Dup(fd int) (nfd int, err error) {
return
}
+func libc_dup_trampoline()
+
+//go:linkname libc_dup libc_dup
+//go:cgo_import_dynamic libc_dup dup "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Dup2(from int, to int) (err error) {
- _, _, e1 := Syscall(SYS_DUP2, uintptr(from), uintptr(to), 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_dup2_trampoline), uintptr(from), uintptr(to), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_dup2_trampoline()
+
+//go:linkname libc_dup2 libc_dup2
+//go:cgo_import_dynamic libc_dup2 dup2 "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Exchangedata(path1 string, path2 string, options int) (err error) {
@@ -695,20 +1000,30 @@ func Exchangedata(path1 string, path2 string, options int) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall(SYS_EXCHANGEDATA, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(options))
+ _, _, e1 := syscall_syscall(funcPC(libc_exchangedata_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(options))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_exchangedata_trampoline()
+
+//go:linkname libc_exchangedata libc_exchangedata
+//go:cgo_import_dynamic libc_exchangedata exchangedata "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Exit(code int) {
- Syscall(SYS_EXIT, uintptr(code), 0, 0)
+ syscall_syscall(funcPC(libc_exit_trampoline), uintptr(code), 0, 0)
return
}
+func libc_exit_trampoline()
+
+//go:linkname libc_exit libc_exit
+//go:cgo_import_dynamic libc_exit exit "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Faccessat(dirfd int, path string, mode uint32, flags int) (err error) {
@@ -717,43 +1032,63 @@ func Faccessat(dirfd int, path string, mode uint32, flags int) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall6(SYS_FACCESSAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0)
+ _, _, e1 := syscall_syscall6(funcPC(libc_faccessat_trampoline), uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_faccessat_trampoline()
+
+//go:linkname libc_faccessat libc_faccessat
+//go:cgo_import_dynamic libc_faccessat faccessat "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Fchdir(fd int) (err error) {
- _, _, e1 := Syscall(SYS_FCHDIR, uintptr(fd), 0, 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_fchdir_trampoline), uintptr(fd), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_fchdir_trampoline()
+
+//go:linkname libc_fchdir libc_fchdir
+//go:cgo_import_dynamic libc_fchdir fchdir "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Fchflags(fd int, flags int) (err error) {
- _, _, e1 := Syscall(SYS_FCHFLAGS, uintptr(fd), uintptr(flags), 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_fchflags_trampoline), uintptr(fd), uintptr(flags), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_fchflags_trampoline()
+
+//go:linkname libc_fchflags libc_fchflags
+//go:cgo_import_dynamic libc_fchflags fchflags "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Fchmod(fd int, mode uint32) (err error) {
- _, _, e1 := Syscall(SYS_FCHMOD, uintptr(fd), uintptr(mode), 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_fchmod_trampoline), uintptr(fd), uintptr(mode), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_fchmod_trampoline()
+
+//go:linkname libc_fchmod libc_fchmod
+//go:cgo_import_dynamic libc_fchmod fchmod "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) {
@@ -762,23 +1097,33 @@ func Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall6(SYS_FCHMODAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0)
+ _, _, e1 := syscall_syscall6(funcPC(libc_fchmodat_trampoline), uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_fchmodat_trampoline()
+
+//go:linkname libc_fchmodat libc_fchmodat
+//go:cgo_import_dynamic libc_fchmodat fchmodat "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Fchown(fd int, uid int, gid int) (err error) {
- _, _, e1 := Syscall(SYS_FCHOWN, uintptr(fd), uintptr(uid), uintptr(gid))
+ _, _, e1 := syscall_syscall(funcPC(libc_fchown_trampoline), uintptr(fd), uintptr(uid), uintptr(gid))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_fchown_trampoline()
+
+//go:linkname libc_fchown libc_fchown
+//go:cgo_import_dynamic libc_fchown fchown "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error) {
@@ -787,142 +1132,135 @@ func Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall6(SYS_FCHOWNAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid), uintptr(flags), 0)
+ _, _, e1 := syscall_syscall6(funcPC(libc_fchownat_trampoline), uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid), uintptr(flags), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+func libc_fchownat_trampoline()
-func Flock(fd int, how int) (err error) {
- _, _, e1 := Syscall(SYS_FLOCK, uintptr(fd), uintptr(how), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
+//go:linkname libc_fchownat libc_fchownat
+//go:cgo_import_dynamic libc_fchownat fchownat "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-func Fpathconf(fd int, name int) (val int, err error) {
- r0, _, e1 := Syscall(SYS_FPATHCONF, uintptr(fd), uintptr(name), 0)
- val = int(r0)
+func Flock(fd int, how int) (err error) {
+ _, _, e1 := syscall_syscall(funcPC(libc_flock_trampoline), uintptr(fd), uintptr(how), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+func libc_flock_trampoline()
-func Fstat(fd int, stat *Stat_t) (err error) {
- _, _, e1 := Syscall(SYS_FSTAT64, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
+//go:linkname libc_flock libc_flock
+//go:cgo_import_dynamic libc_flock flock "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-func Fstatat(fd int, path string, stat *Stat_t, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall6(SYS_FSTATAT64, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), uintptr(flags), 0, 0)
+func Fpathconf(fd int, name int) (val int, err error) {
+ r0, _, e1 := syscall_syscall(funcPC(libc_fpathconf_trampoline), uintptr(fd), uintptr(name), 0)
+ val = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+func libc_fpathconf_trampoline()
-func Fstatfs(fd int, stat *Statfs_t) (err error) {
- _, _, e1 := Syscall(SYS_FSTATFS64, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
+//go:linkname libc_fpathconf libc_fpathconf
+//go:cgo_import_dynamic libc_fpathconf fpathconf "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Fsync(fd int) (err error) {
- _, _, e1 := Syscall(SYS_FSYNC, uintptr(fd), 0, 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_fsync_trampoline), uintptr(fd), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_fsync_trampoline()
+
+//go:linkname libc_fsync libc_fsync
+//go:cgo_import_dynamic libc_fsync fsync "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Ftruncate(fd int, length int64) (err error) {
- _, _, e1 := Syscall(SYS_FTRUNCATE, uintptr(fd), uintptr(length), uintptr(length>>32))
+ _, _, e1 := syscall_syscall(funcPC(libc_ftruncate_trampoline), uintptr(fd), uintptr(length), uintptr(length>>32))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+func libc_ftruncate_trampoline()
-func Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(buf) > 0 {
- _p0 = unsafe.Pointer(&buf[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall6(SYS_GETDIRENTRIES64, uintptr(fd), uintptr(_p0), uintptr(len(buf)), uintptr(unsafe.Pointer(basep)), 0, 0)
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
+//go:linkname libc_ftruncate libc_ftruncate
+//go:cgo_import_dynamic libc_ftruncate ftruncate "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Getdtablesize() (size int) {
- r0, _, _ := Syscall(SYS_GETDTABLESIZE, 0, 0, 0)
+ r0, _, _ := syscall_syscall(funcPC(libc_getdtablesize_trampoline), 0, 0, 0)
size = int(r0)
return
}
+func libc_getdtablesize_trampoline()
+
+//go:linkname libc_getdtablesize libc_getdtablesize
+//go:cgo_import_dynamic libc_getdtablesize getdtablesize "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Getegid() (egid int) {
- r0, _, _ := RawSyscall(SYS_GETEGID, 0, 0, 0)
+ r0, _, _ := syscall_rawSyscall(funcPC(libc_getegid_trampoline), 0, 0, 0)
egid = int(r0)
return
}
+func libc_getegid_trampoline()
+
+//go:linkname libc_getegid libc_getegid
+//go:cgo_import_dynamic libc_getegid getegid "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Geteuid() (uid int) {
- r0, _, _ := RawSyscall(SYS_GETEUID, 0, 0, 0)
+ r0, _, _ := syscall_rawSyscall(funcPC(libc_geteuid_trampoline), 0, 0, 0)
uid = int(r0)
return
}
+func libc_geteuid_trampoline()
+
+//go:linkname libc_geteuid libc_geteuid
+//go:cgo_import_dynamic libc_geteuid geteuid "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Getgid() (gid int) {
- r0, _, _ := RawSyscall(SYS_GETGID, 0, 0, 0)
+ r0, _, _ := syscall_rawSyscall(funcPC(libc_getgid_trampoline), 0, 0, 0)
gid = int(r0)
return
}
+func libc_getgid_trampoline()
+
+//go:linkname libc_getgid libc_getgid
+//go:cgo_import_dynamic libc_getgid getgid "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Getpgid(pid int) (pgid int, err error) {
- r0, _, e1 := RawSyscall(SYS_GETPGID, uintptr(pid), 0, 0)
+ r0, _, e1 := syscall_rawSyscall(funcPC(libc_getpgid_trampoline), uintptr(pid), 0, 0)
pgid = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -930,34 +1268,54 @@ func Getpgid(pid int) (pgid int, err error) {
return
}
+func libc_getpgid_trampoline()
+
+//go:linkname libc_getpgid libc_getpgid
+//go:cgo_import_dynamic libc_getpgid getpgid "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Getpgrp() (pgrp int) {
- r0, _, _ := RawSyscall(SYS_GETPGRP, 0, 0, 0)
+ r0, _, _ := syscall_rawSyscall(funcPC(libc_getpgrp_trampoline), 0, 0, 0)
pgrp = int(r0)
return
}
+func libc_getpgrp_trampoline()
+
+//go:linkname libc_getpgrp libc_getpgrp
+//go:cgo_import_dynamic libc_getpgrp getpgrp "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Getpid() (pid int) {
- r0, _, _ := RawSyscall(SYS_GETPID, 0, 0, 0)
+ r0, _, _ := syscall_rawSyscall(funcPC(libc_getpid_trampoline), 0, 0, 0)
pid = int(r0)
return
}
+func libc_getpid_trampoline()
+
+//go:linkname libc_getpid libc_getpid
+//go:cgo_import_dynamic libc_getpid getpid "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Getppid() (ppid int) {
- r0, _, _ := RawSyscall(SYS_GETPPID, 0, 0, 0)
+ r0, _, _ := syscall_rawSyscall(funcPC(libc_getppid_trampoline), 0, 0, 0)
ppid = int(r0)
return
}
+func libc_getppid_trampoline()
+
+//go:linkname libc_getppid libc_getppid
+//go:cgo_import_dynamic libc_getppid getppid "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Getpriority(which int, who int) (prio int, err error) {
- r0, _, e1 := Syscall(SYS_GETPRIORITY, uintptr(which), uintptr(who), 0)
+ r0, _, e1 := syscall_syscall(funcPC(libc_getpriority_trampoline), uintptr(which), uintptr(who), 0)
prio = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -965,30 +1323,45 @@ func Getpriority(which int, who int) (prio int, err error) {
return
}
+func libc_getpriority_trampoline()
+
+//go:linkname libc_getpriority libc_getpriority
+//go:cgo_import_dynamic libc_getpriority getpriority "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Getrlimit(which int, lim *Rlimit) (err error) {
- _, _, e1 := RawSyscall(SYS_GETRLIMIT, uintptr(which), uintptr(unsafe.Pointer(lim)), 0)
+ _, _, e1 := syscall_rawSyscall(funcPC(libc_getrlimit_trampoline), uintptr(which), uintptr(unsafe.Pointer(lim)), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_getrlimit_trampoline()
+
+//go:linkname libc_getrlimit libc_getrlimit
+//go:cgo_import_dynamic libc_getrlimit getrlimit "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Getrusage(who int, rusage *Rusage) (err error) {
- _, _, e1 := RawSyscall(SYS_GETRUSAGE, uintptr(who), uintptr(unsafe.Pointer(rusage)), 0)
+ _, _, e1 := syscall_rawSyscall(funcPC(libc_getrusage_trampoline), uintptr(who), uintptr(unsafe.Pointer(rusage)), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_getrusage_trampoline()
+
+//go:linkname libc_getrusage libc_getrusage
+//go:cgo_import_dynamic libc_getrusage getrusage "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Getsid(pid int) (sid int, err error) {
- r0, _, e1 := RawSyscall(SYS_GETSID, uintptr(pid), 0, 0)
+ r0, _, e1 := syscall_rawSyscall(funcPC(libc_getsid_trampoline), uintptr(pid), 0, 0)
sid = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -996,26 +1369,41 @@ func Getsid(pid int) (sid int, err error) {
return
}
+func libc_getsid_trampoline()
+
+//go:linkname libc_getsid libc_getsid
+//go:cgo_import_dynamic libc_getsid getsid "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Getuid() (uid int) {
- r0, _, _ := RawSyscall(SYS_GETUID, 0, 0, 0)
+ r0, _, _ := syscall_rawSyscall(funcPC(libc_getuid_trampoline), 0, 0, 0)
uid = int(r0)
return
}
+func libc_getuid_trampoline()
+
+//go:linkname libc_getuid libc_getuid
+//go:cgo_import_dynamic libc_getuid getuid "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Issetugid() (tainted bool) {
- r0, _, _ := RawSyscall(SYS_ISSETUGID, 0, 0, 0)
+ r0, _, _ := syscall_rawSyscall(funcPC(libc_issetugid_trampoline), 0, 0, 0)
tainted = bool(r0 != 0)
return
}
+func libc_issetugid_trampoline()
+
+//go:linkname libc_issetugid libc_issetugid
+//go:cgo_import_dynamic libc_issetugid issetugid "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Kqueue() (fd int, err error) {
- r0, _, e1 := Syscall(SYS_KQUEUE, 0, 0, 0)
+ r0, _, e1 := syscall_syscall(funcPC(libc_kqueue_trampoline), 0, 0, 0)
fd = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -1023,6 +1411,11 @@ func Kqueue() (fd int, err error) {
return
}
+func libc_kqueue_trampoline()
+
+//go:linkname libc_kqueue libc_kqueue
+//go:cgo_import_dynamic libc_kqueue kqueue "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Lchown(path string, uid int, gid int) (err error) {
@@ -1031,13 +1424,18 @@ func Lchown(path string, uid int, gid int) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall(SYS_LCHOWN, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid))
+ _, _, e1 := syscall_syscall(funcPC(libc_lchown_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_lchown_trampoline()
+
+//go:linkname libc_lchown libc_lchown
+//go:cgo_import_dynamic libc_lchown lchown "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Link(path string, link string) (err error) {
@@ -1051,13 +1449,18 @@ func Link(path string, link string) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall(SYS_LINK, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_link_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_link_trampoline()
+
+//go:linkname libc_link libc_link
+//go:cgo_import_dynamic libc_link link "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Linkat(pathfd int, path string, linkfd int, link string, flags int) (err error) {
@@ -1071,37 +1474,32 @@ func Linkat(pathfd int, path string, linkfd int, link string, flags int) (err er
if err != nil {
return
}
- _, _, e1 := Syscall6(SYS_LINKAT, uintptr(pathfd), uintptr(unsafe.Pointer(_p0)), uintptr(linkfd), uintptr(unsafe.Pointer(_p1)), uintptr(flags), 0)
+ _, _, e1 := syscall_syscall6(funcPC(libc_linkat_trampoline), uintptr(pathfd), uintptr(unsafe.Pointer(_p0)), uintptr(linkfd), uintptr(unsafe.Pointer(_p1)), uintptr(flags), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_linkat_trampoline()
+
+//go:linkname libc_linkat libc_linkat
+//go:cgo_import_dynamic libc_linkat linkat "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Listen(s int, backlog int) (err error) {
- _, _, e1 := Syscall(SYS_LISTEN, uintptr(s), uintptr(backlog), 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_listen_trampoline), uintptr(s), uintptr(backlog), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+func libc_listen_trampoline()
-func Lstat(path string, stat *Stat_t) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_LSTAT64, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
+//go:linkname libc_listen libc_listen
+//go:cgo_import_dynamic libc_listen listen "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
@@ -1111,13 +1509,18 @@ func Mkdir(path string, mode uint32) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall(SYS_MKDIR, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_mkdir_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_mkdir_trampoline()
+
+//go:linkname libc_mkdir libc_mkdir
+//go:cgo_import_dynamic libc_mkdir mkdir "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Mkdirat(dirfd int, path string, mode uint32) (err error) {
@@ -1126,13 +1529,18 @@ func Mkdirat(dirfd int, path string, mode uint32) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall(SYS_MKDIRAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode))
+ _, _, e1 := syscall_syscall(funcPC(libc_mkdirat_trampoline), uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_mkdirat_trampoline()
+
+//go:linkname libc_mkdirat libc_mkdirat
+//go:cgo_import_dynamic libc_mkdirat mkdirat "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Mkfifo(path string, mode uint32) (err error) {
@@ -1141,13 +1549,18 @@ func Mkfifo(path string, mode uint32) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall(SYS_MKFIFO, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_mkfifo_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_mkfifo_trampoline()
+
+//go:linkname libc_mkfifo libc_mkfifo
+//go:cgo_import_dynamic libc_mkfifo mkfifo "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Mknod(path string, mode uint32, dev int) (err error) {
@@ -1156,13 +1569,18 @@ func Mknod(path string, mode uint32, dev int) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall(SYS_MKNOD, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(dev))
+ _, _, e1 := syscall_syscall(funcPC(libc_mknod_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(dev))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_mknod_trampoline()
+
+//go:linkname libc_mknod libc_mknod
+//go:cgo_import_dynamic libc_mknod mknod "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Open(path string, mode int, perm uint32) (fd int, err error) {
@@ -1171,7 +1589,7 @@ func Open(path string, mode int, perm uint32) (fd int, err error) {
if err != nil {
return
}
- r0, _, e1 := Syscall(SYS_OPEN, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(perm))
+ r0, _, e1 := syscall_syscall(funcPC(libc_open_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(perm))
fd = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -1179,6 +1597,11 @@ func Open(path string, mode int, perm uint32) (fd int, err error) {
return
}
+func libc_open_trampoline()
+
+//go:linkname libc_open libc_open
+//go:cgo_import_dynamic libc_open open "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Openat(dirfd int, path string, mode int, perm uint32) (fd int, err error) {
@@ -1187,7 +1610,7 @@ func Openat(dirfd int, path string, mode int, perm uint32) (fd int, err error) {
if err != nil {
return
}
- r0, _, e1 := Syscall6(SYS_OPENAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(perm), 0, 0)
+ r0, _, e1 := syscall_syscall6(funcPC(libc_openat_trampoline), uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(perm), 0, 0)
fd = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -1195,6 +1618,11 @@ func Openat(dirfd int, path string, mode int, perm uint32) (fd int, err error) {
return
}
+func libc_openat_trampoline()
+
+//go:linkname libc_openat libc_openat
+//go:cgo_import_dynamic libc_openat openat "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Pathconf(path string, name int) (val int, err error) {
@@ -1203,7 +1631,7 @@ func Pathconf(path string, name int) (val int, err error) {
if err != nil {
return
}
- r0, _, e1 := Syscall(SYS_PATHCONF, uintptr(unsafe.Pointer(_p0)), uintptr(name), 0)
+ r0, _, e1 := syscall_syscall(funcPC(libc_pathconf_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(name), 0)
val = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -1211,6 +1639,11 @@ func Pathconf(path string, name int) (val int, err error) {
return
}
+func libc_pathconf_trampoline()
+
+//go:linkname libc_pathconf libc_pathconf
+//go:cgo_import_dynamic libc_pathconf pathconf "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Pread(fd int, p []byte, offset int64) (n int, err error) {
@@ -1220,7 +1653,7 @@ func Pread(fd int, p []byte, offset int64) (n int, err error) {
} else {
_p0 = unsafe.Pointer(&_zero)
}
- r0, _, e1 := Syscall6(SYS_PREAD, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), uintptr(offset>>32), 0)
+ r0, _, e1 := syscall_syscall6(funcPC(libc_pread_trampoline), uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), uintptr(offset>>32), 0)
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -1228,6 +1661,11 @@ func Pread(fd int, p []byte, offset int64) (n int, err error) {
return
}
+func libc_pread_trampoline()
+
+//go:linkname libc_pread libc_pread
+//go:cgo_import_dynamic libc_pread pread "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Pwrite(fd int, p []byte, offset int64) (n int, err error) {
@@ -1237,7 +1675,7 @@ func Pwrite(fd int, p []byte, offset int64) (n int, err error) {
} else {
_p0 = unsafe.Pointer(&_zero)
}
- r0, _, e1 := Syscall6(SYS_PWRITE, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), uintptr(offset>>32), 0)
+ r0, _, e1 := syscall_syscall6(funcPC(libc_pwrite_trampoline), uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), uintptr(offset>>32), 0)
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -1245,6 +1683,11 @@ func Pwrite(fd int, p []byte, offset int64) (n int, err error) {
return
}
+func libc_pwrite_trampoline()
+
+//go:linkname libc_pwrite libc_pwrite
+//go:cgo_import_dynamic libc_pwrite pwrite "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func read(fd int, p []byte) (n int, err error) {
@@ -1254,7 +1697,7 @@ func read(fd int, p []byte) (n int, err error) {
} else {
_p0 = unsafe.Pointer(&_zero)
}
- r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(_p0), uintptr(len(p)))
+ r0, _, e1 := syscall_syscall(funcPC(libc_read_trampoline), uintptr(fd), uintptr(_p0), uintptr(len(p)))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -1262,6 +1705,11 @@ func read(fd int, p []byte) (n int, err error) {
return
}
+func libc_read_trampoline()
+
+//go:linkname libc_read libc_read
+//go:cgo_import_dynamic libc_read read "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Readlink(path string, buf []byte) (n int, err error) {
@@ -1276,7 +1724,7 @@ func Readlink(path string, buf []byte) (n int, err error) {
} else {
_p1 = unsafe.Pointer(&_zero)
}
- r0, _, e1 := Syscall(SYS_READLINK, uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(buf)))
+ r0, _, e1 := syscall_syscall(funcPC(libc_readlink_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(buf)))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -1284,6 +1732,11 @@ func Readlink(path string, buf []byte) (n int, err error) {
return
}
+func libc_readlink_trampoline()
+
+//go:linkname libc_readlink libc_readlink
+//go:cgo_import_dynamic libc_readlink readlink "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Readlinkat(dirfd int, path string, buf []byte) (n int, err error) {
@@ -1298,7 +1751,7 @@ func Readlinkat(dirfd int, path string, buf []byte) (n int, err error) {
} else {
_p1 = unsafe.Pointer(&_zero)
}
- r0, _, e1 := Syscall6(SYS_READLINKAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(buf)), 0, 0)
+ r0, _, e1 := syscall_syscall6(funcPC(libc_readlinkat_trampoline), uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(buf)), 0, 0)
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -1306,6 +1759,11 @@ func Readlinkat(dirfd int, path string, buf []byte) (n int, err error) {
return
}
+func libc_readlinkat_trampoline()
+
+//go:linkname libc_readlinkat libc_readlinkat
+//go:cgo_import_dynamic libc_readlinkat readlinkat "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Rename(from string, to string) (err error) {
@@ -1319,13 +1777,18 @@ func Rename(from string, to string) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall(SYS_RENAME, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_rename_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_rename_trampoline()
+
+//go:linkname libc_rename libc_rename
+//go:cgo_import_dynamic libc_rename rename "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Renameat(fromfd int, from string, tofd int, to string) (err error) {
@@ -1339,13 +1802,18 @@ func Renameat(fromfd int, from string, tofd int, to string) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall6(SYS_RENAMEAT, uintptr(fromfd), uintptr(unsafe.Pointer(_p0)), uintptr(tofd), uintptr(unsafe.Pointer(_p1)), 0, 0)
+ _, _, e1 := syscall_syscall6(funcPC(libc_renameat_trampoline), uintptr(fromfd), uintptr(unsafe.Pointer(_p0)), uintptr(tofd), uintptr(unsafe.Pointer(_p1)), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_renameat_trampoline()
+
+//go:linkname libc_renameat libc_renameat
+//go:cgo_import_dynamic libc_renameat renameat "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Revoke(path string) (err error) {
@@ -1354,13 +1822,18 @@ func Revoke(path string) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall(SYS_REVOKE, uintptr(unsafe.Pointer(_p0)), 0, 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_revoke_trampoline), uintptr(unsafe.Pointer(_p0)), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_revoke_trampoline()
+
+//go:linkname libc_revoke libc_revoke
+//go:cgo_import_dynamic libc_revoke revoke "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Rmdir(path string) (err error) {
@@ -1369,17 +1842,22 @@ func Rmdir(path string) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall(SYS_RMDIR, uintptr(unsafe.Pointer(_p0)), 0, 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_rmdir_trampoline), uintptr(unsafe.Pointer(_p0)), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_rmdir_trampoline()
+
+//go:linkname libc_rmdir libc_rmdir
+//go:cgo_import_dynamic libc_rmdir rmdir "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Seek(fd int, offset int64, whence int) (newoffset int64, err error) {
- r0, r1, e1 := Syscall6(SYS_LSEEK, uintptr(fd), uintptr(offset), uintptr(offset>>32), uintptr(whence), 0, 0)
+ r0, r1, e1 := syscall_syscall6(funcPC(libc_lseek_trampoline), uintptr(fd), uintptr(offset), uintptr(offset>>32), uintptr(whence), 0, 0)
newoffset = int64(int64(r1)<<32 | int64(r0))
if e1 != 0 {
err = errnoErr(e1)
@@ -1387,46 +1865,71 @@ func Seek(fd int, offset int64, whence int) (newoffset int64, err error) {
return
}
+func libc_lseek_trampoline()
+
+//go:linkname libc_lseek libc_lseek
+//go:cgo_import_dynamic libc_lseek lseek "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Select(n int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (err error) {
- _, _, e1 := Syscall6(SYS_SELECT, uintptr(n), uintptr(unsafe.Pointer(r)), uintptr(unsafe.Pointer(w)), uintptr(unsafe.Pointer(e)), uintptr(unsafe.Pointer(timeout)), 0)
+ _, _, e1 := syscall_syscall6(funcPC(libc_select_trampoline), uintptr(n), uintptr(unsafe.Pointer(r)), uintptr(unsafe.Pointer(w)), uintptr(unsafe.Pointer(e)), uintptr(unsafe.Pointer(timeout)), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_select_trampoline()
+
+//go:linkname libc_select libc_select
+//go:cgo_import_dynamic libc_select select "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Setegid(egid int) (err error) {
- _, _, e1 := Syscall(SYS_SETEGID, uintptr(egid), 0, 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_setegid_trampoline), uintptr(egid), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_setegid_trampoline()
+
+//go:linkname libc_setegid libc_setegid
+//go:cgo_import_dynamic libc_setegid setegid "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Seteuid(euid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETEUID, uintptr(euid), 0, 0)
+ _, _, e1 := syscall_rawSyscall(funcPC(libc_seteuid_trampoline), uintptr(euid), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_seteuid_trampoline()
+
+//go:linkname libc_seteuid libc_seteuid
+//go:cgo_import_dynamic libc_seteuid seteuid "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Setgid(gid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETGID, uintptr(gid), 0, 0)
+ _, _, e1 := syscall_rawSyscall(funcPC(libc_setgid_trampoline), uintptr(gid), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_setgid_trampoline()
+
+//go:linkname libc_setgid libc_setgid
+//go:cgo_import_dynamic libc_setgid setgid "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Setlogin(name string) (err error) {
@@ -1435,77 +1938,112 @@ func Setlogin(name string) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall(SYS_SETLOGIN, uintptr(unsafe.Pointer(_p0)), 0, 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_setlogin_trampoline), uintptr(unsafe.Pointer(_p0)), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_setlogin_trampoline()
+
+//go:linkname libc_setlogin libc_setlogin
+//go:cgo_import_dynamic libc_setlogin setlogin "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Setpgid(pid int, pgid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETPGID, uintptr(pid), uintptr(pgid), 0)
+ _, _, e1 := syscall_rawSyscall(funcPC(libc_setpgid_trampoline), uintptr(pid), uintptr(pgid), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_setpgid_trampoline()
+
+//go:linkname libc_setpgid libc_setpgid
+//go:cgo_import_dynamic libc_setpgid setpgid "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Setpriority(which int, who int, prio int) (err error) {
- _, _, e1 := Syscall(SYS_SETPRIORITY, uintptr(which), uintptr(who), uintptr(prio))
+ _, _, e1 := syscall_syscall(funcPC(libc_setpriority_trampoline), uintptr(which), uintptr(who), uintptr(prio))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_setpriority_trampoline()
+
+//go:linkname libc_setpriority libc_setpriority
+//go:cgo_import_dynamic libc_setpriority setpriority "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Setprivexec(flag int) (err error) {
- _, _, e1 := Syscall(SYS_SETPRIVEXEC, uintptr(flag), 0, 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_setprivexec_trampoline), uintptr(flag), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_setprivexec_trampoline()
+
+//go:linkname libc_setprivexec libc_setprivexec
+//go:cgo_import_dynamic libc_setprivexec setprivexec "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Setregid(rgid int, egid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETREGID, uintptr(rgid), uintptr(egid), 0)
+ _, _, e1 := syscall_rawSyscall(funcPC(libc_setregid_trampoline), uintptr(rgid), uintptr(egid), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_setregid_trampoline()
+
+//go:linkname libc_setregid libc_setregid
+//go:cgo_import_dynamic libc_setregid setregid "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Setreuid(ruid int, euid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETREUID, uintptr(ruid), uintptr(euid), 0)
+ _, _, e1 := syscall_rawSyscall(funcPC(libc_setreuid_trampoline), uintptr(ruid), uintptr(euid), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_setreuid_trampoline()
+
+//go:linkname libc_setreuid libc_setreuid
+//go:cgo_import_dynamic libc_setreuid setreuid "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Setrlimit(which int, lim *Rlimit) (err error) {
- _, _, e1 := RawSyscall(SYS_SETRLIMIT, uintptr(which), uintptr(unsafe.Pointer(lim)), 0)
+ _, _, e1 := syscall_rawSyscall(funcPC(libc_setrlimit_trampoline), uintptr(which), uintptr(unsafe.Pointer(lim)), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_setrlimit_trampoline()
+
+//go:linkname libc_setrlimit libc_setrlimit
+//go:cgo_import_dynamic libc_setrlimit setrlimit "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Setsid() (pid int, err error) {
- r0, _, e1 := RawSyscall(SYS_SETSID, 0, 0, 0)
+ r0, _, e1 := syscall_rawSyscall(funcPC(libc_setsid_trampoline), 0, 0, 0)
pid = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -1513,55 +2051,40 @@ func Setsid() (pid int, err error) {
return
}
+func libc_setsid_trampoline()
+
+//go:linkname libc_setsid libc_setsid
+//go:cgo_import_dynamic libc_setsid setsid "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Settimeofday(tp *Timeval) (err error) {
- _, _, e1 := RawSyscall(SYS_SETTIMEOFDAY, uintptr(unsafe.Pointer(tp)), 0, 0)
+ _, _, e1 := syscall_rawSyscall(funcPC(libc_settimeofday_trampoline), uintptr(unsafe.Pointer(tp)), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+func libc_settimeofday_trampoline()
-func Setuid(uid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETUID, uintptr(uid), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
+//go:linkname libc_settimeofday libc_settimeofday
+//go:cgo_import_dynamic libc_settimeofday settimeofday "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-func Stat(path string, stat *Stat_t) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_STAT64, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
+func Setuid(uid int) (err error) {
+ _, _, e1 := syscall_rawSyscall(funcPC(libc_setuid_trampoline), uintptr(uid), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+func libc_setuid_trampoline()
-func Statfs(path string, stat *Statfs_t) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_STATFS64, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
+//go:linkname libc_setuid libc_setuid
+//go:cgo_import_dynamic libc_setuid setuid "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
@@ -1576,13 +2099,18 @@ func Symlink(path string, link string) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall(SYS_SYMLINK, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_symlink_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_symlink_trampoline()
+
+//go:linkname libc_symlink libc_symlink
+//go:cgo_import_dynamic libc_symlink symlink "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Symlinkat(oldpath string, newdirfd int, newpath string) (err error) {
@@ -1596,23 +2124,33 @@ func Symlinkat(oldpath string, newdirfd int, newpath string) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall(SYS_SYMLINKAT, uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1)))
+ _, _, e1 := syscall_syscall(funcPC(libc_symlinkat_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1)))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_symlinkat_trampoline()
+
+//go:linkname libc_symlinkat libc_symlinkat
+//go:cgo_import_dynamic libc_symlinkat symlinkat "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Sync() (err error) {
- _, _, e1 := Syscall(SYS_SYNC, 0, 0, 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_sync_trampoline), 0, 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_sync_trampoline()
+
+//go:linkname libc_sync libc_sync
+//go:cgo_import_dynamic libc_sync sync "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Truncate(path string, length int64) (err error) {
@@ -1621,21 +2159,31 @@ func Truncate(path string, length int64) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall(SYS_TRUNCATE, uintptr(unsafe.Pointer(_p0)), uintptr(length), uintptr(length>>32))
+ _, _, e1 := syscall_syscall(funcPC(libc_truncate_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(length), uintptr(length>>32))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_truncate_trampoline()
+
+//go:linkname libc_truncate libc_truncate
+//go:cgo_import_dynamic libc_truncate truncate "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Umask(newmask int) (oldmask int) {
- r0, _, _ := Syscall(SYS_UMASK, uintptr(newmask), 0, 0)
+ r0, _, _ := syscall_syscall(funcPC(libc_umask_trampoline), uintptr(newmask), 0, 0)
oldmask = int(r0)
return
}
+func libc_umask_trampoline()
+
+//go:linkname libc_umask libc_umask
+//go:cgo_import_dynamic libc_umask umask "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Undelete(path string) (err error) {
@@ -1644,13 +2192,18 @@ func Undelete(path string) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall(SYS_UNDELETE, uintptr(unsafe.Pointer(_p0)), 0, 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_undelete_trampoline), uintptr(unsafe.Pointer(_p0)), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_undelete_trampoline()
+
+//go:linkname libc_undelete libc_undelete
+//go:cgo_import_dynamic libc_undelete undelete "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Unlink(path string) (err error) {
@@ -1659,13 +2212,18 @@ func Unlink(path string) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall(SYS_UNLINK, uintptr(unsafe.Pointer(_p0)), 0, 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_unlink_trampoline), uintptr(unsafe.Pointer(_p0)), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_unlink_trampoline()
+
+//go:linkname libc_unlink libc_unlink
+//go:cgo_import_dynamic libc_unlink unlink "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Unlinkat(dirfd int, path string, flags int) (err error) {
@@ -1674,13 +2232,18 @@ func Unlinkat(dirfd int, path string, flags int) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall(SYS_UNLINKAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(flags))
+ _, _, e1 := syscall_syscall(funcPC(libc_unlinkat_trampoline), uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(flags))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_unlinkat_trampoline()
+
+//go:linkname libc_unlinkat libc_unlinkat
+//go:cgo_import_dynamic libc_unlinkat unlinkat "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Unmount(path string, flags int) (err error) {
@@ -1689,13 +2252,18 @@ func Unmount(path string, flags int) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall(SYS_UNMOUNT, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_unmount_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_unmount_trampoline()
+
+//go:linkname libc_unmount libc_unmount
+//go:cgo_import_dynamic libc_unmount unmount "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func write(fd int, p []byte) (n int, err error) {
@@ -1705,7 +2273,7 @@ func write(fd int, p []byte) (n int, err error) {
} else {
_p0 = unsafe.Pointer(&_zero)
}
- r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(_p0), uintptr(len(p)))
+ r0, _, e1 := syscall_syscall(funcPC(libc_write_trampoline), uintptr(fd), uintptr(_p0), uintptr(len(p)))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -1713,10 +2281,15 @@ func write(fd int, p []byte) (n int, err error) {
return
}
+func libc_write_trampoline()
+
+//go:linkname libc_write libc_write
+//go:cgo_import_dynamic libc_write write "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error) {
- r0, _, e1 := Syscall9(SYS_MMAP, uintptr(addr), uintptr(length), uintptr(prot), uintptr(flag), uintptr(fd), uintptr(pos), uintptr(pos>>32), 0, 0)
+ r0, _, e1 := syscall_syscall9(funcPC(libc_mmap_trampoline), uintptr(addr), uintptr(length), uintptr(prot), uintptr(flag), uintptr(fd), uintptr(pos), uintptr(pos>>32), 0, 0)
ret = uintptr(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -1724,20 +2297,30 @@ func mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (
return
}
+func libc_mmap_trampoline()
+
+//go:linkname libc_mmap libc_mmap
+//go:cgo_import_dynamic libc_mmap mmap "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func munmap(addr uintptr, length uintptr) (err error) {
- _, _, e1 := Syscall(SYS_MUNMAP, uintptr(addr), uintptr(length), 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_munmap_trampoline), uintptr(addr), uintptr(length), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_munmap_trampoline()
+
+//go:linkname libc_munmap libc_munmap
+//go:cgo_import_dynamic libc_munmap munmap "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func readlen(fd int, buf *byte, nbuf int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf))
+ r0, _, e1 := syscall_syscall(funcPC(libc_read_trampoline), uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -1748,7 +2331,7 @@ func readlen(fd int, buf *byte, nbuf int) (n int, err error) {
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func writelen(fd int, buf *byte, nbuf int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf))
+ r0, _, e1 := syscall_syscall(funcPC(libc_write_trampoline), uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -1759,7 +2342,7 @@ func writelen(fd int, buf *byte, nbuf int) (n int, err error) {
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func gettimeofday(tp *Timeval) (sec int32, usec int32, err error) {
- r0, r1, e1 := RawSyscall(SYS_GETTIMEOFDAY, uintptr(unsafe.Pointer(tp)), 0, 0)
+ r0, r1, e1 := syscall_rawSyscall(funcPC(libc_gettimeofday_trampoline), uintptr(unsafe.Pointer(tp)), 0, 0)
sec = int32(r0)
usec = int32(r1)
if e1 != 0 {
@@ -1767,3 +2350,156 @@ func gettimeofday(tp *Timeval) (sec int32, usec int32, err error) {
}
return
}
+
+func libc_gettimeofday_trampoline()
+
+//go:linkname libc_gettimeofday libc_gettimeofday
+//go:cgo_import_dynamic libc_gettimeofday gettimeofday "/usr/lib/libSystem.B.dylib"
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Fstat(fd int, stat *Stat_t) (err error) {
+ _, _, e1 := syscall_syscall(funcPC(libc_fstat64_trampoline), uintptr(fd), uintptr(unsafe.Pointer(stat)), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func libc_fstat64_trampoline()
+
+//go:linkname libc_fstat64 libc_fstat64
+//go:cgo_import_dynamic libc_fstat64 fstat64 "/usr/lib/libSystem.B.dylib"
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Fstatat(fd int, path string, stat *Stat_t, flags int) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := syscall_syscall6(funcPC(libc_fstatat64_trampoline), uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), uintptr(flags), 0, 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func libc_fstatat64_trampoline()
+
+//go:linkname libc_fstatat64 libc_fstatat64
+//go:cgo_import_dynamic libc_fstatat64 fstatat64 "/usr/lib/libSystem.B.dylib"
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Fstatfs(fd int, stat *Statfs_t) (err error) {
+ _, _, e1 := syscall_syscall(funcPC(libc_fstatfs64_trampoline), uintptr(fd), uintptr(unsafe.Pointer(stat)), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func libc_fstatfs64_trampoline()
+
+//go:linkname libc_fstatfs64 libc_fstatfs64
+//go:cgo_import_dynamic libc_fstatfs64 fstatfs64 "/usr/lib/libSystem.B.dylib"
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) {
+ var _p0 unsafe.Pointer
+ if len(buf) > 0 {
+ _p0 = unsafe.Pointer(&buf[0])
+ } else {
+ _p0 = unsafe.Pointer(&_zero)
+ }
+ r0, _, e1 := syscall_syscall6(funcPC(libc___getdirentries64_trampoline), uintptr(fd), uintptr(_p0), uintptr(len(buf)), uintptr(unsafe.Pointer(basep)), 0, 0)
+ n = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func libc___getdirentries64_trampoline()
+
+//go:linkname libc___getdirentries64 libc___getdirentries64
+//go:cgo_import_dynamic libc___getdirentries64 __getdirentries64 "/usr/lib/libSystem.B.dylib"
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func getfsstat(buf unsafe.Pointer, size uintptr, flags int) (n int, err error) {
+ r0, _, e1 := syscall_syscall(funcPC(libc_getfsstat64_trampoline), uintptr(buf), uintptr(size), uintptr(flags))
+ n = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func libc_getfsstat64_trampoline()
+
+//go:linkname libc_getfsstat64 libc_getfsstat64
+//go:cgo_import_dynamic libc_getfsstat64 getfsstat64 "/usr/lib/libSystem.B.dylib"
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Lstat(path string, stat *Stat_t) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := syscall_syscall(funcPC(libc_lstat64_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func libc_lstat64_trampoline()
+
+//go:linkname libc_lstat64 libc_lstat64
+//go:cgo_import_dynamic libc_lstat64 lstat64 "/usr/lib/libSystem.B.dylib"
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Stat(path string, stat *Stat_t) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := syscall_syscall(funcPC(libc_stat64_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func libc_stat64_trampoline()
+
+//go:linkname libc_stat64 libc_stat64
+//go:cgo_import_dynamic libc_stat64 stat64 "/usr/lib/libSystem.B.dylib"
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Statfs(path string, stat *Statfs_t) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := syscall_syscall(funcPC(libc_statfs64_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func libc_statfs64_trampoline()
+
+//go:linkname libc_statfs64 libc_statfs64
+//go:cgo_import_dynamic libc_statfs64 statfs64 "/usr/lib/libSystem.B.dylib"
diff --git a/vendor/golang.org/x/sys/unix/zsyscall_darwin_386.s b/vendor/golang.org/x/sys/unix/zsyscall_darwin_386.s
new file mode 100644
index 000000000..37b85b4f6
--- /dev/null
+++ b/vendor/golang.org/x/sys/unix/zsyscall_darwin_386.s
@@ -0,0 +1,284 @@
+// go run mkasm_darwin.go 386
+// Code generated by the command above; DO NOT EDIT.
+
+// +build go1.12
+
+#include "textflag.h"
+TEXT ·libc_getgroups_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_getgroups(SB)
+TEXT ·libc_setgroups_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_setgroups(SB)
+TEXT ·libc_wait4_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_wait4(SB)
+TEXT ·libc_accept_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_accept(SB)
+TEXT ·libc_bind_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_bind(SB)
+TEXT ·libc_connect_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_connect(SB)
+TEXT ·libc_socket_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_socket(SB)
+TEXT ·libc_getsockopt_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_getsockopt(SB)
+TEXT ·libc_setsockopt_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_setsockopt(SB)
+TEXT ·libc_getpeername_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_getpeername(SB)
+TEXT ·libc_getsockname_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_getsockname(SB)
+TEXT ·libc_shutdown_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_shutdown(SB)
+TEXT ·libc_socketpair_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_socketpair(SB)
+TEXT ·libc_recvfrom_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_recvfrom(SB)
+TEXT ·libc_sendto_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_sendto(SB)
+TEXT ·libc_recvmsg_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_recvmsg(SB)
+TEXT ·libc_sendmsg_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_sendmsg(SB)
+TEXT ·libc_kevent_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_kevent(SB)
+TEXT ·libc___sysctl_trampoline(SB),NOSPLIT,$0-0
+ JMP libc___sysctl(SB)
+TEXT ·libc_utimes_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_utimes(SB)
+TEXT ·libc_futimes_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_futimes(SB)
+TEXT ·libc_fcntl_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_fcntl(SB)
+TEXT ·libc_poll_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_poll(SB)
+TEXT ·libc_madvise_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_madvise(SB)
+TEXT ·libc_mlock_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_mlock(SB)
+TEXT ·libc_mlockall_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_mlockall(SB)
+TEXT ·libc_mprotect_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_mprotect(SB)
+TEXT ·libc_msync_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_msync(SB)
+TEXT ·libc_munlock_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_munlock(SB)
+TEXT ·libc_munlockall_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_munlockall(SB)
+TEXT ·libc_ptrace_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_ptrace(SB)
+TEXT ·libc_getattrlist_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_getattrlist(SB)
+TEXT ·libc_pipe_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_pipe(SB)
+TEXT ·libc_getxattr_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_getxattr(SB)
+TEXT ·libc_fgetxattr_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_fgetxattr(SB)
+TEXT ·libc_setxattr_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_setxattr(SB)
+TEXT ·libc_fsetxattr_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_fsetxattr(SB)
+TEXT ·libc_removexattr_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_removexattr(SB)
+TEXT ·libc_fremovexattr_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_fremovexattr(SB)
+TEXT ·libc_listxattr_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_listxattr(SB)
+TEXT ·libc_flistxattr_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_flistxattr(SB)
+TEXT ·libc_setattrlist_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_setattrlist(SB)
+TEXT ·libc_kill_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_kill(SB)
+TEXT ·libc_ioctl_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_ioctl(SB)
+TEXT ·libc_sendfile_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_sendfile(SB)
+TEXT ·libc_access_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_access(SB)
+TEXT ·libc_adjtime_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_adjtime(SB)
+TEXT ·libc_chdir_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_chdir(SB)
+TEXT ·libc_chflags_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_chflags(SB)
+TEXT ·libc_chmod_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_chmod(SB)
+TEXT ·libc_chown_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_chown(SB)
+TEXT ·libc_chroot_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_chroot(SB)
+TEXT ·libc_close_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_close(SB)
+TEXT ·libc_dup_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_dup(SB)
+TEXT ·libc_dup2_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_dup2(SB)
+TEXT ·libc_exchangedata_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_exchangedata(SB)
+TEXT ·libc_exit_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_exit(SB)
+TEXT ·libc_faccessat_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_faccessat(SB)
+TEXT ·libc_fchdir_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_fchdir(SB)
+TEXT ·libc_fchflags_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_fchflags(SB)
+TEXT ·libc_fchmod_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_fchmod(SB)
+TEXT ·libc_fchmodat_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_fchmodat(SB)
+TEXT ·libc_fchown_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_fchown(SB)
+TEXT ·libc_fchownat_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_fchownat(SB)
+TEXT ·libc_flock_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_flock(SB)
+TEXT ·libc_fpathconf_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_fpathconf(SB)
+TEXT ·libc_fsync_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_fsync(SB)
+TEXT ·libc_ftruncate_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_ftruncate(SB)
+TEXT ·libc_getdtablesize_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_getdtablesize(SB)
+TEXT ·libc_getegid_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_getegid(SB)
+TEXT ·libc_geteuid_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_geteuid(SB)
+TEXT ·libc_getgid_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_getgid(SB)
+TEXT ·libc_getpgid_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_getpgid(SB)
+TEXT ·libc_getpgrp_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_getpgrp(SB)
+TEXT ·libc_getpid_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_getpid(SB)
+TEXT ·libc_getppid_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_getppid(SB)
+TEXT ·libc_getpriority_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_getpriority(SB)
+TEXT ·libc_getrlimit_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_getrlimit(SB)
+TEXT ·libc_getrusage_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_getrusage(SB)
+TEXT ·libc_getsid_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_getsid(SB)
+TEXT ·libc_getuid_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_getuid(SB)
+TEXT ·libc_issetugid_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_issetugid(SB)
+TEXT ·libc_kqueue_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_kqueue(SB)
+TEXT ·libc_lchown_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_lchown(SB)
+TEXT ·libc_link_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_link(SB)
+TEXT ·libc_linkat_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_linkat(SB)
+TEXT ·libc_listen_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_listen(SB)
+TEXT ·libc_mkdir_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_mkdir(SB)
+TEXT ·libc_mkdirat_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_mkdirat(SB)
+TEXT ·libc_mkfifo_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_mkfifo(SB)
+TEXT ·libc_mknod_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_mknod(SB)
+TEXT ·libc_open_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_open(SB)
+TEXT ·libc_openat_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_openat(SB)
+TEXT ·libc_pathconf_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_pathconf(SB)
+TEXT ·libc_pread_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_pread(SB)
+TEXT ·libc_pwrite_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_pwrite(SB)
+TEXT ·libc_read_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_read(SB)
+TEXT ·libc_readlink_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_readlink(SB)
+TEXT ·libc_readlinkat_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_readlinkat(SB)
+TEXT ·libc_rename_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_rename(SB)
+TEXT ·libc_renameat_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_renameat(SB)
+TEXT ·libc_revoke_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_revoke(SB)
+TEXT ·libc_rmdir_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_rmdir(SB)
+TEXT ·libc_lseek_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_lseek(SB)
+TEXT ·libc_select_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_select(SB)
+TEXT ·libc_setegid_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_setegid(SB)
+TEXT ·libc_seteuid_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_seteuid(SB)
+TEXT ·libc_setgid_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_setgid(SB)
+TEXT ·libc_setlogin_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_setlogin(SB)
+TEXT ·libc_setpgid_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_setpgid(SB)
+TEXT ·libc_setpriority_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_setpriority(SB)
+TEXT ·libc_setprivexec_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_setprivexec(SB)
+TEXT ·libc_setregid_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_setregid(SB)
+TEXT ·libc_setreuid_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_setreuid(SB)
+TEXT ·libc_setrlimit_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_setrlimit(SB)
+TEXT ·libc_setsid_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_setsid(SB)
+TEXT ·libc_settimeofday_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_settimeofday(SB)
+TEXT ·libc_setuid_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_setuid(SB)
+TEXT ·libc_symlink_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_symlink(SB)
+TEXT ·libc_symlinkat_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_symlinkat(SB)
+TEXT ·libc_sync_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_sync(SB)
+TEXT ·libc_truncate_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_truncate(SB)
+TEXT ·libc_umask_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_umask(SB)
+TEXT ·libc_undelete_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_undelete(SB)
+TEXT ·libc_unlink_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_unlink(SB)
+TEXT ·libc_unlinkat_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_unlinkat(SB)
+TEXT ·libc_unmount_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_unmount(SB)
+TEXT ·libc_write_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_write(SB)
+TEXT ·libc_mmap_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_mmap(SB)
+TEXT ·libc_munmap_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_munmap(SB)
+TEXT ·libc_gettimeofday_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_gettimeofday(SB)
+TEXT ·libc_fstat64_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_fstat64(SB)
+TEXT ·libc_fstatat64_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_fstatat64(SB)
+TEXT ·libc_fstatfs64_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_fstatfs64(SB)
+TEXT ·libc___getdirentries64_trampoline(SB),NOSPLIT,$0-0
+ JMP libc___getdirentries64(SB)
+TEXT ·libc_getfsstat64_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_getfsstat64(SB)
+TEXT ·libc_lstat64_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_lstat64(SB)
+TEXT ·libc_stat64_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_stat64(SB)
+TEXT ·libc_statfs64_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_statfs64(SB)
diff --git a/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.1_11.go b/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.1_11.go
new file mode 100644
index 000000000..2581e8960
--- /dev/null
+++ b/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.1_11.go
@@ -0,0 +1,1810 @@
+// go run mksyscall.go -tags darwin,amd64,!go1.12 syscall_bsd.go syscall_darwin.go syscall_darwin_amd64.go
+// Code generated by the command above; see README.md. DO NOT EDIT.
+
+// +build darwin,amd64,!go1.12
+
+package unix
+
+import (
+ "syscall"
+ "unsafe"
+)
+
+var _ syscall.Errno
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func getgroups(ngid int, gid *_Gid_t) (n int, err error) {
+ r0, _, e1 := RawSyscall(SYS_GETGROUPS, uintptr(ngid), uintptr(unsafe.Pointer(gid)), 0)
+ n = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func setgroups(ngid int, gid *_Gid_t) (err error) {
+ _, _, e1 := RawSyscall(SYS_SETGROUPS, uintptr(ngid), uintptr(unsafe.Pointer(gid)), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func wait4(pid int, wstatus *_C_int, options int, rusage *Rusage) (wpid int, err error) {
+ r0, _, e1 := Syscall6(SYS_WAIT4, uintptr(pid), uintptr(unsafe.Pointer(wstatus)), uintptr(options), uintptr(unsafe.Pointer(rusage)), 0, 0)
+ wpid = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) {
+ r0, _, e1 := Syscall(SYS_ACCEPT, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
+ fd = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) {
+ _, _, e1 := Syscall(SYS_BIND, uintptr(s), uintptr(addr), uintptr(addrlen))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) {
+ _, _, e1 := Syscall(SYS_CONNECT, uintptr(s), uintptr(addr), uintptr(addrlen))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func socket(domain int, typ int, proto int) (fd int, err error) {
+ r0, _, e1 := RawSyscall(SYS_SOCKET, uintptr(domain), uintptr(typ), uintptr(proto))
+ fd = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) {
+ _, _, e1 := Syscall6(SYS_GETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(unsafe.Pointer(vallen)), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) {
+ _, _, e1 := Syscall6(SYS_SETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(vallen), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) {
+ _, _, e1 := RawSyscall(SYS_GETPEERNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) {
+ _, _, e1 := RawSyscall(SYS_GETSOCKNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Shutdown(s int, how int) (err error) {
+ _, _, e1 := Syscall(SYS_SHUTDOWN, uintptr(s), uintptr(how), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) {
+ _, _, e1 := RawSyscall6(SYS_SOCKETPAIR, uintptr(domain), uintptr(typ), uintptr(proto), uintptr(unsafe.Pointer(fd)), 0, 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) {
+ var _p0 unsafe.Pointer
+ if len(p) > 0 {
+ _p0 = unsafe.Pointer(&p[0])
+ } else {
+ _p0 = unsafe.Pointer(&_zero)
+ }
+ r0, _, e1 := Syscall6(SYS_RECVFROM, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(flags), uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(fromlen)))
+ n = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) {
+ var _p0 unsafe.Pointer
+ if len(buf) > 0 {
+ _p0 = unsafe.Pointer(&buf[0])
+ } else {
+ _p0 = unsafe.Pointer(&_zero)
+ }
+ _, _, e1 := Syscall6(SYS_SENDTO, uintptr(s), uintptr(_p0), uintptr(len(buf)), uintptr(flags), uintptr(to), uintptr(addrlen))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func recvmsg(s int, msg *Msghdr, flags int) (n int, err error) {
+ r0, _, e1 := Syscall(SYS_RECVMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags))
+ n = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func sendmsg(s int, msg *Msghdr, flags int) (n int, err error) {
+ r0, _, e1 := Syscall(SYS_SENDMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags))
+ n = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func kevent(kq int, change unsafe.Pointer, nchange int, event unsafe.Pointer, nevent int, timeout *Timespec) (n int, err error) {
+ r0, _, e1 := Syscall6(SYS_KEVENT, uintptr(kq), uintptr(change), uintptr(nchange), uintptr(event), uintptr(nevent), uintptr(unsafe.Pointer(timeout)))
+ n = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) {
+ var _p0 unsafe.Pointer
+ if len(mib) > 0 {
+ _p0 = unsafe.Pointer(&mib[0])
+ } else {
+ _p0 = unsafe.Pointer(&_zero)
+ }
+ _, _, e1 := Syscall6(SYS___SYSCTL, uintptr(_p0), uintptr(len(mib)), uintptr(unsafe.Pointer(old)), uintptr(unsafe.Pointer(oldlen)), uintptr(unsafe.Pointer(new)), uintptr(newlen))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func utimes(path string, timeval *[2]Timeval) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_UTIMES, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(timeval)), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func futimes(fd int, timeval *[2]Timeval) (err error) {
+ _, _, e1 := Syscall(SYS_FUTIMES, uintptr(fd), uintptr(unsafe.Pointer(timeval)), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func fcntl(fd int, cmd int, arg int) (val int, err error) {
+ r0, _, e1 := Syscall(SYS_FCNTL, uintptr(fd), uintptr(cmd), uintptr(arg))
+ val = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func poll(fds *PollFd, nfds int, timeout int) (n int, err error) {
+ r0, _, e1 := Syscall(SYS_POLL, uintptr(unsafe.Pointer(fds)), uintptr(nfds), uintptr(timeout))
+ n = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Madvise(b []byte, behav int) (err error) {
+ var _p0 unsafe.Pointer
+ if len(b) > 0 {
+ _p0 = unsafe.Pointer(&b[0])
+ } else {
+ _p0 = unsafe.Pointer(&_zero)
+ }
+ _, _, e1 := Syscall(SYS_MADVISE, uintptr(_p0), uintptr(len(b)), uintptr(behav))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Mlock(b []byte) (err error) {
+ var _p0 unsafe.Pointer
+ if len(b) > 0 {
+ _p0 = unsafe.Pointer(&b[0])
+ } else {
+ _p0 = unsafe.Pointer(&_zero)
+ }
+ _, _, e1 := Syscall(SYS_MLOCK, uintptr(_p0), uintptr(len(b)), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Mlockall(flags int) (err error) {
+ _, _, e1 := Syscall(SYS_MLOCKALL, uintptr(flags), 0, 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Mprotect(b []byte, prot int) (err error) {
+ var _p0 unsafe.Pointer
+ if len(b) > 0 {
+ _p0 = unsafe.Pointer(&b[0])
+ } else {
+ _p0 = unsafe.Pointer(&_zero)
+ }
+ _, _, e1 := Syscall(SYS_MPROTECT, uintptr(_p0), uintptr(len(b)), uintptr(prot))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Msync(b []byte, flags int) (err error) {
+ var _p0 unsafe.Pointer
+ if len(b) > 0 {
+ _p0 = unsafe.Pointer(&b[0])
+ } else {
+ _p0 = unsafe.Pointer(&_zero)
+ }
+ _, _, e1 := Syscall(SYS_MSYNC, uintptr(_p0), uintptr(len(b)), uintptr(flags))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Munlock(b []byte) (err error) {
+ var _p0 unsafe.Pointer
+ if len(b) > 0 {
+ _p0 = unsafe.Pointer(&b[0])
+ } else {
+ _p0 = unsafe.Pointer(&_zero)
+ }
+ _, _, e1 := Syscall(SYS_MUNLOCK, uintptr(_p0), uintptr(len(b)), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Munlockall() (err error) {
+ _, _, e1 := Syscall(SYS_MUNLOCKALL, 0, 0, 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func ptrace(request int, pid int, addr uintptr, data uintptr) (err error) {
+ _, _, e1 := Syscall6(SYS_PTRACE, uintptr(request), uintptr(pid), uintptr(addr), uintptr(data), 0, 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func getattrlist(path *byte, list unsafe.Pointer, buf unsafe.Pointer, size uintptr, options int) (err error) {
+ _, _, e1 := Syscall6(SYS_GETATTRLIST, uintptr(unsafe.Pointer(path)), uintptr(list), uintptr(buf), uintptr(size), uintptr(options), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func pipe() (r int, w int, err error) {
+ r0, r1, e1 := RawSyscall(SYS_PIPE, 0, 0, 0)
+ r = int(r0)
+ w = int(r1)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func getxattr(path string, attr string, dest *byte, size int, position uint32, options int) (sz int, err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ var _p1 *byte
+ _p1, err = BytePtrFromString(attr)
+ if err != nil {
+ return
+ }
+ r0, _, e1 := Syscall6(SYS_GETXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(unsafe.Pointer(dest)), uintptr(size), uintptr(position), uintptr(options))
+ sz = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func fgetxattr(fd int, attr string, dest *byte, size int, position uint32, options int) (sz int, err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(attr)
+ if err != nil {
+ return
+ }
+ r0, _, e1 := Syscall6(SYS_FGETXATTR, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(dest)), uintptr(size), uintptr(position), uintptr(options))
+ sz = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func setxattr(path string, attr string, data *byte, size int, position uint32, options int) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ var _p1 *byte
+ _p1, err = BytePtrFromString(attr)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall6(SYS_SETXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(unsafe.Pointer(data)), uintptr(size), uintptr(position), uintptr(options))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func fsetxattr(fd int, attr string, data *byte, size int, position uint32, options int) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(attr)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall6(SYS_FSETXATTR, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(data)), uintptr(size), uintptr(position), uintptr(options))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func removexattr(path string, attr string, options int) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ var _p1 *byte
+ _p1, err = BytePtrFromString(attr)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_REMOVEXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(options))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func fremovexattr(fd int, attr string, options int) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(attr)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_FREMOVEXATTR, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(options))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func listxattr(path string, dest *byte, size int, options int) (sz int, err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ r0, _, e1 := Syscall6(SYS_LISTXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(dest)), uintptr(size), uintptr(options), 0, 0)
+ sz = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func flistxattr(fd int, dest *byte, size int, options int) (sz int, err error) {
+ r0, _, e1 := Syscall6(SYS_FLISTXATTR, uintptr(fd), uintptr(unsafe.Pointer(dest)), uintptr(size), uintptr(options), 0, 0)
+ sz = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func setattrlist(path *byte, list unsafe.Pointer, buf unsafe.Pointer, size uintptr, options int) (err error) {
+ _, _, e1 := Syscall6(SYS_SETATTRLIST, uintptr(unsafe.Pointer(path)), uintptr(list), uintptr(buf), uintptr(size), uintptr(options), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func kill(pid int, signum int, posix int) (err error) {
+ _, _, e1 := Syscall(SYS_KILL, uintptr(pid), uintptr(signum), uintptr(posix))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func ioctl(fd int, req uint, arg uintptr) (err error) {
+ _, _, e1 := Syscall(SYS_IOCTL, uintptr(fd), uintptr(req), uintptr(arg))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func sendfile(infd int, outfd int, offset int64, len *int64, hdtr unsafe.Pointer, flags int) (err error) {
+ _, _, e1 := Syscall6(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(offset), uintptr(unsafe.Pointer(len)), uintptr(hdtr), uintptr(flags))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Access(path string, mode uint32) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_ACCESS, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Adjtime(delta *Timeval, olddelta *Timeval) (err error) {
+ _, _, e1 := Syscall(SYS_ADJTIME, uintptr(unsafe.Pointer(delta)), uintptr(unsafe.Pointer(olddelta)), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Chdir(path string) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_CHDIR, uintptr(unsafe.Pointer(_p0)), 0, 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Chflags(path string, flags int) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_CHFLAGS, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Chmod(path string, mode uint32) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_CHMOD, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Chown(path string, uid int, gid int) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_CHOWN, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Chroot(path string) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_CHROOT, uintptr(unsafe.Pointer(_p0)), 0, 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Close(fd int) (err error) {
+ _, _, e1 := Syscall(SYS_CLOSE, uintptr(fd), 0, 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Dup(fd int) (nfd int, err error) {
+ r0, _, e1 := Syscall(SYS_DUP, uintptr(fd), 0, 0)
+ nfd = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Dup2(from int, to int) (err error) {
+ _, _, e1 := Syscall(SYS_DUP2, uintptr(from), uintptr(to), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Exchangedata(path1 string, path2 string, options int) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path1)
+ if err != nil {
+ return
+ }
+ var _p1 *byte
+ _p1, err = BytePtrFromString(path2)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_EXCHANGEDATA, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(options))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Exit(code int) {
+ Syscall(SYS_EXIT, uintptr(code), 0, 0)
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Faccessat(dirfd int, path string, mode uint32, flags int) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall6(SYS_FACCESSAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Fchdir(fd int) (err error) {
+ _, _, e1 := Syscall(SYS_FCHDIR, uintptr(fd), 0, 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Fchflags(fd int, flags int) (err error) {
+ _, _, e1 := Syscall(SYS_FCHFLAGS, uintptr(fd), uintptr(flags), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Fchmod(fd int, mode uint32) (err error) {
+ _, _, e1 := Syscall(SYS_FCHMOD, uintptr(fd), uintptr(mode), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall6(SYS_FCHMODAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Fchown(fd int, uid int, gid int) (err error) {
+ _, _, e1 := Syscall(SYS_FCHOWN, uintptr(fd), uintptr(uid), uintptr(gid))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall6(SYS_FCHOWNAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid), uintptr(flags), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Flock(fd int, how int) (err error) {
+ _, _, e1 := Syscall(SYS_FLOCK, uintptr(fd), uintptr(how), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Fpathconf(fd int, name int) (val int, err error) {
+ r0, _, e1 := Syscall(SYS_FPATHCONF, uintptr(fd), uintptr(name), 0)
+ val = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Fsync(fd int) (err error) {
+ _, _, e1 := Syscall(SYS_FSYNC, uintptr(fd), 0, 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Ftruncate(fd int, length int64) (err error) {
+ _, _, e1 := Syscall(SYS_FTRUNCATE, uintptr(fd), uintptr(length), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Getdtablesize() (size int) {
+ r0, _, _ := Syscall(SYS_GETDTABLESIZE, 0, 0, 0)
+ size = int(r0)
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Getegid() (egid int) {
+ r0, _, _ := RawSyscall(SYS_GETEGID, 0, 0, 0)
+ egid = int(r0)
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Geteuid() (uid int) {
+ r0, _, _ := RawSyscall(SYS_GETEUID, 0, 0, 0)
+ uid = int(r0)
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Getgid() (gid int) {
+ r0, _, _ := RawSyscall(SYS_GETGID, 0, 0, 0)
+ gid = int(r0)
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Getpgid(pid int) (pgid int, err error) {
+ r0, _, e1 := RawSyscall(SYS_GETPGID, uintptr(pid), 0, 0)
+ pgid = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Getpgrp() (pgrp int) {
+ r0, _, _ := RawSyscall(SYS_GETPGRP, 0, 0, 0)
+ pgrp = int(r0)
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Getpid() (pid int) {
+ r0, _, _ := RawSyscall(SYS_GETPID, 0, 0, 0)
+ pid = int(r0)
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Getppid() (ppid int) {
+ r0, _, _ := RawSyscall(SYS_GETPPID, 0, 0, 0)
+ ppid = int(r0)
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Getpriority(which int, who int) (prio int, err error) {
+ r0, _, e1 := Syscall(SYS_GETPRIORITY, uintptr(which), uintptr(who), 0)
+ prio = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Getrlimit(which int, lim *Rlimit) (err error) {
+ _, _, e1 := RawSyscall(SYS_GETRLIMIT, uintptr(which), uintptr(unsafe.Pointer(lim)), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Getrusage(who int, rusage *Rusage) (err error) {
+ _, _, e1 := RawSyscall(SYS_GETRUSAGE, uintptr(who), uintptr(unsafe.Pointer(rusage)), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Getsid(pid int) (sid int, err error) {
+ r0, _, e1 := RawSyscall(SYS_GETSID, uintptr(pid), 0, 0)
+ sid = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Getuid() (uid int) {
+ r0, _, _ := RawSyscall(SYS_GETUID, 0, 0, 0)
+ uid = int(r0)
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Issetugid() (tainted bool) {
+ r0, _, _ := RawSyscall(SYS_ISSETUGID, 0, 0, 0)
+ tainted = bool(r0 != 0)
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Kqueue() (fd int, err error) {
+ r0, _, e1 := Syscall(SYS_KQUEUE, 0, 0, 0)
+ fd = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Lchown(path string, uid int, gid int) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_LCHOWN, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Link(path string, link string) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ var _p1 *byte
+ _p1, err = BytePtrFromString(link)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_LINK, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Linkat(pathfd int, path string, linkfd int, link string, flags int) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ var _p1 *byte
+ _p1, err = BytePtrFromString(link)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall6(SYS_LINKAT, uintptr(pathfd), uintptr(unsafe.Pointer(_p0)), uintptr(linkfd), uintptr(unsafe.Pointer(_p1)), uintptr(flags), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Listen(s int, backlog int) (err error) {
+ _, _, e1 := Syscall(SYS_LISTEN, uintptr(s), uintptr(backlog), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Mkdir(path string, mode uint32) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_MKDIR, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Mkdirat(dirfd int, path string, mode uint32) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_MKDIRAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Mkfifo(path string, mode uint32) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_MKFIFO, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Mknod(path string, mode uint32, dev int) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_MKNOD, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(dev))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Open(path string, mode int, perm uint32) (fd int, err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ r0, _, e1 := Syscall(SYS_OPEN, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(perm))
+ fd = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Openat(dirfd int, path string, mode int, perm uint32) (fd int, err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ r0, _, e1 := Syscall6(SYS_OPENAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(perm), 0, 0)
+ fd = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Pathconf(path string, name int) (val int, err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ r0, _, e1 := Syscall(SYS_PATHCONF, uintptr(unsafe.Pointer(_p0)), uintptr(name), 0)
+ val = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Pread(fd int, p []byte, offset int64) (n int, err error) {
+ var _p0 unsafe.Pointer
+ if len(p) > 0 {
+ _p0 = unsafe.Pointer(&p[0])
+ } else {
+ _p0 = unsafe.Pointer(&_zero)
+ }
+ r0, _, e1 := Syscall6(SYS_PREAD, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), 0, 0)
+ n = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Pwrite(fd int, p []byte, offset int64) (n int, err error) {
+ var _p0 unsafe.Pointer
+ if len(p) > 0 {
+ _p0 = unsafe.Pointer(&p[0])
+ } else {
+ _p0 = unsafe.Pointer(&_zero)
+ }
+ r0, _, e1 := Syscall6(SYS_PWRITE, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), 0, 0)
+ n = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func read(fd int, p []byte) (n int, err error) {
+ var _p0 unsafe.Pointer
+ if len(p) > 0 {
+ _p0 = unsafe.Pointer(&p[0])
+ } else {
+ _p0 = unsafe.Pointer(&_zero)
+ }
+ r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(_p0), uintptr(len(p)))
+ n = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Readlink(path string, buf []byte) (n int, err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ var _p1 unsafe.Pointer
+ if len(buf) > 0 {
+ _p1 = unsafe.Pointer(&buf[0])
+ } else {
+ _p1 = unsafe.Pointer(&_zero)
+ }
+ r0, _, e1 := Syscall(SYS_READLINK, uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(buf)))
+ n = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Readlinkat(dirfd int, path string, buf []byte) (n int, err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ var _p1 unsafe.Pointer
+ if len(buf) > 0 {
+ _p1 = unsafe.Pointer(&buf[0])
+ } else {
+ _p1 = unsafe.Pointer(&_zero)
+ }
+ r0, _, e1 := Syscall6(SYS_READLINKAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(buf)), 0, 0)
+ n = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Rename(from string, to string) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(from)
+ if err != nil {
+ return
+ }
+ var _p1 *byte
+ _p1, err = BytePtrFromString(to)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_RENAME, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Renameat(fromfd int, from string, tofd int, to string) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(from)
+ if err != nil {
+ return
+ }
+ var _p1 *byte
+ _p1, err = BytePtrFromString(to)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall6(SYS_RENAMEAT, uintptr(fromfd), uintptr(unsafe.Pointer(_p0)), uintptr(tofd), uintptr(unsafe.Pointer(_p1)), 0, 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Revoke(path string) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_REVOKE, uintptr(unsafe.Pointer(_p0)), 0, 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Rmdir(path string) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_RMDIR, uintptr(unsafe.Pointer(_p0)), 0, 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Seek(fd int, offset int64, whence int) (newoffset int64, err error) {
+ r0, _, e1 := Syscall(SYS_LSEEK, uintptr(fd), uintptr(offset), uintptr(whence))
+ newoffset = int64(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Select(n int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (err error) {
+ _, _, e1 := Syscall6(SYS_SELECT, uintptr(n), uintptr(unsafe.Pointer(r)), uintptr(unsafe.Pointer(w)), uintptr(unsafe.Pointer(e)), uintptr(unsafe.Pointer(timeout)), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Setegid(egid int) (err error) {
+ _, _, e1 := Syscall(SYS_SETEGID, uintptr(egid), 0, 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Seteuid(euid int) (err error) {
+ _, _, e1 := RawSyscall(SYS_SETEUID, uintptr(euid), 0, 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Setgid(gid int) (err error) {
+ _, _, e1 := RawSyscall(SYS_SETGID, uintptr(gid), 0, 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Setlogin(name string) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(name)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_SETLOGIN, uintptr(unsafe.Pointer(_p0)), 0, 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Setpgid(pid int, pgid int) (err error) {
+ _, _, e1 := RawSyscall(SYS_SETPGID, uintptr(pid), uintptr(pgid), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Setpriority(which int, who int, prio int) (err error) {
+ _, _, e1 := Syscall(SYS_SETPRIORITY, uintptr(which), uintptr(who), uintptr(prio))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Setprivexec(flag int) (err error) {
+ _, _, e1 := Syscall(SYS_SETPRIVEXEC, uintptr(flag), 0, 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Setregid(rgid int, egid int) (err error) {
+ _, _, e1 := RawSyscall(SYS_SETREGID, uintptr(rgid), uintptr(egid), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Setreuid(ruid int, euid int) (err error) {
+ _, _, e1 := RawSyscall(SYS_SETREUID, uintptr(ruid), uintptr(euid), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Setrlimit(which int, lim *Rlimit) (err error) {
+ _, _, e1 := RawSyscall(SYS_SETRLIMIT, uintptr(which), uintptr(unsafe.Pointer(lim)), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Setsid() (pid int, err error) {
+ r0, _, e1 := RawSyscall(SYS_SETSID, 0, 0, 0)
+ pid = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Settimeofday(tp *Timeval) (err error) {
+ _, _, e1 := RawSyscall(SYS_SETTIMEOFDAY, uintptr(unsafe.Pointer(tp)), 0, 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Setuid(uid int) (err error) {
+ _, _, e1 := RawSyscall(SYS_SETUID, uintptr(uid), 0, 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Symlink(path string, link string) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ var _p1 *byte
+ _p1, err = BytePtrFromString(link)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_SYMLINK, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Symlinkat(oldpath string, newdirfd int, newpath string) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(oldpath)
+ if err != nil {
+ return
+ }
+ var _p1 *byte
+ _p1, err = BytePtrFromString(newpath)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_SYMLINKAT, uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1)))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Sync() (err error) {
+ _, _, e1 := Syscall(SYS_SYNC, 0, 0, 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Truncate(path string, length int64) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_TRUNCATE, uintptr(unsafe.Pointer(_p0)), uintptr(length), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Umask(newmask int) (oldmask int) {
+ r0, _, _ := Syscall(SYS_UMASK, uintptr(newmask), 0, 0)
+ oldmask = int(r0)
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Undelete(path string) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_UNDELETE, uintptr(unsafe.Pointer(_p0)), 0, 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Unlink(path string) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_UNLINK, uintptr(unsafe.Pointer(_p0)), 0, 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Unlinkat(dirfd int, path string, flags int) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_UNLINKAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(flags))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Unmount(path string, flags int) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_UNMOUNT, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func write(fd int, p []byte) (n int, err error) {
+ var _p0 unsafe.Pointer
+ if len(p) > 0 {
+ _p0 = unsafe.Pointer(&p[0])
+ } else {
+ _p0 = unsafe.Pointer(&_zero)
+ }
+ r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(_p0), uintptr(len(p)))
+ n = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error) {
+ r0, _, e1 := Syscall6(SYS_MMAP, uintptr(addr), uintptr(length), uintptr(prot), uintptr(flag), uintptr(fd), uintptr(pos))
+ ret = uintptr(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func munmap(addr uintptr, length uintptr) (err error) {
+ _, _, e1 := Syscall(SYS_MUNMAP, uintptr(addr), uintptr(length), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func readlen(fd int, buf *byte, nbuf int) (n int, err error) {
+ r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf))
+ n = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func writelen(fd int, buf *byte, nbuf int) (n int, err error) {
+ r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf))
+ n = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func gettimeofday(tp *Timeval) (sec int64, usec int32, err error) {
+ r0, r1, e1 := RawSyscall(SYS_GETTIMEOFDAY, uintptr(unsafe.Pointer(tp)), 0, 0)
+ sec = int64(r0)
+ usec = int32(r1)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Fstat(fd int, stat *Stat_t) (err error) {
+ _, _, e1 := Syscall(SYS_FSTAT64, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Fstatat(fd int, path string, stat *Stat_t, flags int) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall6(SYS_FSTATAT64, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), uintptr(flags), 0, 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Fstatfs(fd int, stat *Statfs_t) (err error) {
+ _, _, e1 := Syscall(SYS_FSTATFS64, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) {
+ var _p0 unsafe.Pointer
+ if len(buf) > 0 {
+ _p0 = unsafe.Pointer(&buf[0])
+ } else {
+ _p0 = unsafe.Pointer(&_zero)
+ }
+ r0, _, e1 := Syscall6(SYS_GETDIRENTRIES64, uintptr(fd), uintptr(_p0), uintptr(len(buf)), uintptr(unsafe.Pointer(basep)), 0, 0)
+ n = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func getfsstat(buf unsafe.Pointer, size uintptr, flags int) (n int, err error) {
+ r0, _, e1 := Syscall(SYS_GETFSSTAT64, uintptr(buf), uintptr(size), uintptr(flags))
+ n = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Lstat(path string, stat *Stat_t) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_LSTAT64, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Stat(path string, stat *Stat_t) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_STAT64, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Statfs(path string, stat *Statfs_t) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_STATFS64, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
diff --git a/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go b/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go
index de9927049..b50178d67 100644
--- a/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go
+++ b/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go
@@ -1,7 +1,7 @@
-// mksyscall.pl -tags darwin,amd64 syscall_bsd.go syscall_darwin.go syscall_darwin_amd64.go
+// go run mksyscall.go -tags darwin,amd64,go1.12 syscall_bsd.go syscall_darwin.go syscall_darwin_amd64.go
// Code generated by the command above; see README.md. DO NOT EDIT.
-// +build darwin,amd64
+// +build darwin,amd64,go1.12
package unix
@@ -15,7 +15,7 @@ var _ syscall.Errno
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func getgroups(ngid int, gid *_Gid_t) (n int, err error) {
- r0, _, e1 := RawSyscall(SYS_GETGROUPS, uintptr(ngid), uintptr(unsafe.Pointer(gid)), 0)
+ r0, _, e1 := syscall_rawSyscall(funcPC(libc_getgroups_trampoline), uintptr(ngid), uintptr(unsafe.Pointer(gid)), 0)
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -23,20 +23,30 @@ func getgroups(ngid int, gid *_Gid_t) (n int, err error) {
return
}
+func libc_getgroups_trampoline()
+
+//go:linkname libc_getgroups libc_getgroups
+//go:cgo_import_dynamic libc_getgroups getgroups "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func setgroups(ngid int, gid *_Gid_t) (err error) {
- _, _, e1 := RawSyscall(SYS_SETGROUPS, uintptr(ngid), uintptr(unsafe.Pointer(gid)), 0)
+ _, _, e1 := syscall_rawSyscall(funcPC(libc_setgroups_trampoline), uintptr(ngid), uintptr(unsafe.Pointer(gid)), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_setgroups_trampoline()
+
+//go:linkname libc_setgroups libc_setgroups
+//go:cgo_import_dynamic libc_setgroups setgroups "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func wait4(pid int, wstatus *_C_int, options int, rusage *Rusage) (wpid int, err error) {
- r0, _, e1 := Syscall6(SYS_WAIT4, uintptr(pid), uintptr(unsafe.Pointer(wstatus)), uintptr(options), uintptr(unsafe.Pointer(rusage)), 0, 0)
+ r0, _, e1 := syscall_syscall6(funcPC(libc_wait4_trampoline), uintptr(pid), uintptr(unsafe.Pointer(wstatus)), uintptr(options), uintptr(unsafe.Pointer(rusage)), 0, 0)
wpid = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -44,10 +54,15 @@ func wait4(pid int, wstatus *_C_int, options int, rusage *Rusage) (wpid int, err
return
}
+func libc_wait4_trampoline()
+
+//go:linkname libc_wait4 libc_wait4
+//go:cgo_import_dynamic libc_wait4 wait4 "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) {
- r0, _, e1 := Syscall(SYS_ACCEPT, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
+ r0, _, e1 := syscall_syscall(funcPC(libc_accept_trampoline), uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
fd = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -55,30 +70,45 @@ func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) {
return
}
+func libc_accept_trampoline()
+
+//go:linkname libc_accept libc_accept
+//go:cgo_import_dynamic libc_accept accept "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) {
- _, _, e1 := Syscall(SYS_BIND, uintptr(s), uintptr(addr), uintptr(addrlen))
+ _, _, e1 := syscall_syscall(funcPC(libc_bind_trampoline), uintptr(s), uintptr(addr), uintptr(addrlen))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_bind_trampoline()
+
+//go:linkname libc_bind libc_bind
+//go:cgo_import_dynamic libc_bind bind "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) {
- _, _, e1 := Syscall(SYS_CONNECT, uintptr(s), uintptr(addr), uintptr(addrlen))
+ _, _, e1 := syscall_syscall(funcPC(libc_connect_trampoline), uintptr(s), uintptr(addr), uintptr(addrlen))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_connect_trampoline()
+
+//go:linkname libc_connect libc_connect
+//go:cgo_import_dynamic libc_connect connect "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func socket(domain int, typ int, proto int) (fd int, err error) {
- r0, _, e1 := RawSyscall(SYS_SOCKET, uintptr(domain), uintptr(typ), uintptr(proto))
+ r0, _, e1 := syscall_rawSyscall(funcPC(libc_socket_trampoline), uintptr(domain), uintptr(typ), uintptr(proto))
fd = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -86,66 +116,101 @@ func socket(domain int, typ int, proto int) (fd int, err error) {
return
}
+func libc_socket_trampoline()
+
+//go:linkname libc_socket libc_socket
+//go:cgo_import_dynamic libc_socket socket "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) {
- _, _, e1 := Syscall6(SYS_GETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(unsafe.Pointer(vallen)), 0)
+ _, _, e1 := syscall_syscall6(funcPC(libc_getsockopt_trampoline), uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(unsafe.Pointer(vallen)), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_getsockopt_trampoline()
+
+//go:linkname libc_getsockopt libc_getsockopt
+//go:cgo_import_dynamic libc_getsockopt getsockopt "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) {
- _, _, e1 := Syscall6(SYS_SETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(vallen), 0)
+ _, _, e1 := syscall_syscall6(funcPC(libc_setsockopt_trampoline), uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(vallen), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_setsockopt_trampoline()
+
+//go:linkname libc_setsockopt libc_setsockopt
+//go:cgo_import_dynamic libc_setsockopt setsockopt "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) {
- _, _, e1 := RawSyscall(SYS_GETPEERNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
+ _, _, e1 := syscall_rawSyscall(funcPC(libc_getpeername_trampoline), uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_getpeername_trampoline()
+
+//go:linkname libc_getpeername libc_getpeername
+//go:cgo_import_dynamic libc_getpeername getpeername "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) {
- _, _, e1 := RawSyscall(SYS_GETSOCKNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
+ _, _, e1 := syscall_rawSyscall(funcPC(libc_getsockname_trampoline), uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_getsockname_trampoline()
+
+//go:linkname libc_getsockname libc_getsockname
+//go:cgo_import_dynamic libc_getsockname getsockname "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Shutdown(s int, how int) (err error) {
- _, _, e1 := Syscall(SYS_SHUTDOWN, uintptr(s), uintptr(how), 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_shutdown_trampoline), uintptr(s), uintptr(how), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_shutdown_trampoline()
+
+//go:linkname libc_shutdown libc_shutdown
+//go:cgo_import_dynamic libc_shutdown shutdown "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) {
- _, _, e1 := RawSyscall6(SYS_SOCKETPAIR, uintptr(domain), uintptr(typ), uintptr(proto), uintptr(unsafe.Pointer(fd)), 0, 0)
+ _, _, e1 := syscall_rawSyscall6(funcPC(libc_socketpair_trampoline), uintptr(domain), uintptr(typ), uintptr(proto), uintptr(unsafe.Pointer(fd)), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_socketpair_trampoline()
+
+//go:linkname libc_socketpair libc_socketpair
+//go:cgo_import_dynamic libc_socketpair socketpair "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) {
@@ -155,7 +220,7 @@ func recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Sockl
} else {
_p0 = unsafe.Pointer(&_zero)
}
- r0, _, e1 := Syscall6(SYS_RECVFROM, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(flags), uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(fromlen)))
+ r0, _, e1 := syscall_syscall6(funcPC(libc_recvfrom_trampoline), uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(flags), uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(fromlen)))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -163,6 +228,11 @@ func recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Sockl
return
}
+func libc_recvfrom_trampoline()
+
+//go:linkname libc_recvfrom libc_recvfrom
+//go:cgo_import_dynamic libc_recvfrom recvfrom "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) {
@@ -172,17 +242,22 @@ func sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (
} else {
_p0 = unsafe.Pointer(&_zero)
}
- _, _, e1 := Syscall6(SYS_SENDTO, uintptr(s), uintptr(_p0), uintptr(len(buf)), uintptr(flags), uintptr(to), uintptr(addrlen))
+ _, _, e1 := syscall_syscall6(funcPC(libc_sendto_trampoline), uintptr(s), uintptr(_p0), uintptr(len(buf)), uintptr(flags), uintptr(to), uintptr(addrlen))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_sendto_trampoline()
+
+//go:linkname libc_sendto libc_sendto
+//go:cgo_import_dynamic libc_sendto sendto "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func recvmsg(s int, msg *Msghdr, flags int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_RECVMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags))
+ r0, _, e1 := syscall_syscall(funcPC(libc_recvmsg_trampoline), uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -190,10 +265,15 @@ func recvmsg(s int, msg *Msghdr, flags int) (n int, err error) {
return
}
+func libc_recvmsg_trampoline()
+
+//go:linkname libc_recvmsg libc_recvmsg
+//go:cgo_import_dynamic libc_recvmsg recvmsg "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func sendmsg(s int, msg *Msghdr, flags int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_SENDMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags))
+ r0, _, e1 := syscall_syscall(funcPC(libc_sendmsg_trampoline), uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -201,10 +281,15 @@ func sendmsg(s int, msg *Msghdr, flags int) (n int, err error) {
return
}
+func libc_sendmsg_trampoline()
+
+//go:linkname libc_sendmsg libc_sendmsg
+//go:cgo_import_dynamic libc_sendmsg sendmsg "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func kevent(kq int, change unsafe.Pointer, nchange int, event unsafe.Pointer, nevent int, timeout *Timespec) (n int, err error) {
- r0, _, e1 := Syscall6(SYS_KEVENT, uintptr(kq), uintptr(change), uintptr(nchange), uintptr(event), uintptr(nevent), uintptr(unsafe.Pointer(timeout)))
+ r0, _, e1 := syscall_syscall6(funcPC(libc_kevent_trampoline), uintptr(kq), uintptr(change), uintptr(nchange), uintptr(event), uintptr(nevent), uintptr(unsafe.Pointer(timeout)))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -212,6 +297,11 @@ func kevent(kq int, change unsafe.Pointer, nchange int, event unsafe.Pointer, ne
return
}
+func libc_kevent_trampoline()
+
+//go:linkname libc_kevent libc_kevent
+//go:cgo_import_dynamic libc_kevent kevent "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) {
@@ -221,13 +311,18 @@ func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr)
} else {
_p0 = unsafe.Pointer(&_zero)
}
- _, _, e1 := Syscall6(SYS___SYSCTL, uintptr(_p0), uintptr(len(mib)), uintptr(unsafe.Pointer(old)), uintptr(unsafe.Pointer(oldlen)), uintptr(unsafe.Pointer(new)), uintptr(newlen))
+ _, _, e1 := syscall_syscall6(funcPC(libc___sysctl_trampoline), uintptr(_p0), uintptr(len(mib)), uintptr(unsafe.Pointer(old)), uintptr(unsafe.Pointer(oldlen)), uintptr(unsafe.Pointer(new)), uintptr(newlen))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc___sysctl_trampoline()
+
+//go:linkname libc___sysctl libc___sysctl
+//go:cgo_import_dynamic libc___sysctl __sysctl "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func utimes(path string, timeval *[2]Timeval) (err error) {
@@ -236,27 +331,37 @@ func utimes(path string, timeval *[2]Timeval) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall(SYS_UTIMES, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(timeval)), 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_utimes_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(timeval)), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_utimes_trampoline()
+
+//go:linkname libc_utimes libc_utimes
+//go:cgo_import_dynamic libc_utimes utimes "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func futimes(fd int, timeval *[2]Timeval) (err error) {
- _, _, e1 := Syscall(SYS_FUTIMES, uintptr(fd), uintptr(unsafe.Pointer(timeval)), 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_futimes_trampoline), uintptr(fd), uintptr(unsafe.Pointer(timeval)), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_futimes_trampoline()
+
+//go:linkname libc_futimes libc_futimes
+//go:cgo_import_dynamic libc_futimes futimes "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func fcntl(fd int, cmd int, arg int) (val int, err error) {
- r0, _, e1 := Syscall(SYS_FCNTL, uintptr(fd), uintptr(cmd), uintptr(arg))
+ r0, _, e1 := syscall_syscall(funcPC(libc_fcntl_trampoline), uintptr(fd), uintptr(cmd), uintptr(arg))
val = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -264,10 +369,15 @@ func fcntl(fd int, cmd int, arg int) (val int, err error) {
return
}
+func libc_fcntl_trampoline()
+
+//go:linkname libc_fcntl libc_fcntl
+//go:cgo_import_dynamic libc_fcntl fcntl "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func poll(fds *PollFd, nfds int, timeout int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_POLL, uintptr(unsafe.Pointer(fds)), uintptr(nfds), uintptr(timeout))
+ r0, _, e1 := syscall_syscall(funcPC(libc_poll_trampoline), uintptr(unsafe.Pointer(fds)), uintptr(nfds), uintptr(timeout))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -275,6 +385,11 @@ func poll(fds *PollFd, nfds int, timeout int) (n int, err error) {
return
}
+func libc_poll_trampoline()
+
+//go:linkname libc_poll libc_poll
+//go:cgo_import_dynamic libc_poll poll "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Madvise(b []byte, behav int) (err error) {
@@ -284,13 +399,18 @@ func Madvise(b []byte, behav int) (err error) {
} else {
_p0 = unsafe.Pointer(&_zero)
}
- _, _, e1 := Syscall(SYS_MADVISE, uintptr(_p0), uintptr(len(b)), uintptr(behav))
+ _, _, e1 := syscall_syscall(funcPC(libc_madvise_trampoline), uintptr(_p0), uintptr(len(b)), uintptr(behav))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_madvise_trampoline()
+
+//go:linkname libc_madvise libc_madvise
+//go:cgo_import_dynamic libc_madvise madvise "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Mlock(b []byte) (err error) {
@@ -300,23 +420,33 @@ func Mlock(b []byte) (err error) {
} else {
_p0 = unsafe.Pointer(&_zero)
}
- _, _, e1 := Syscall(SYS_MLOCK, uintptr(_p0), uintptr(len(b)), 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_mlock_trampoline), uintptr(_p0), uintptr(len(b)), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_mlock_trampoline()
+
+//go:linkname libc_mlock libc_mlock
+//go:cgo_import_dynamic libc_mlock mlock "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Mlockall(flags int) (err error) {
- _, _, e1 := Syscall(SYS_MLOCKALL, uintptr(flags), 0, 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_mlockall_trampoline), uintptr(flags), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_mlockall_trampoline()
+
+//go:linkname libc_mlockall libc_mlockall
+//go:cgo_import_dynamic libc_mlockall mlockall "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Mprotect(b []byte, prot int) (err error) {
@@ -326,13 +456,18 @@ func Mprotect(b []byte, prot int) (err error) {
} else {
_p0 = unsafe.Pointer(&_zero)
}
- _, _, e1 := Syscall(SYS_MPROTECT, uintptr(_p0), uintptr(len(b)), uintptr(prot))
+ _, _, e1 := syscall_syscall(funcPC(libc_mprotect_trampoline), uintptr(_p0), uintptr(len(b)), uintptr(prot))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_mprotect_trampoline()
+
+//go:linkname libc_mprotect libc_mprotect
+//go:cgo_import_dynamic libc_mprotect mprotect "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Msync(b []byte, flags int) (err error) {
@@ -342,13 +477,18 @@ func Msync(b []byte, flags int) (err error) {
} else {
_p0 = unsafe.Pointer(&_zero)
}
- _, _, e1 := Syscall(SYS_MSYNC, uintptr(_p0), uintptr(len(b)), uintptr(flags))
+ _, _, e1 := syscall_syscall(funcPC(libc_msync_trampoline), uintptr(_p0), uintptr(len(b)), uintptr(flags))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_msync_trampoline()
+
+//go:linkname libc_msync libc_msync
+//go:cgo_import_dynamic libc_msync msync "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Munlock(b []byte) (err error) {
@@ -358,37 +498,67 @@ func Munlock(b []byte) (err error) {
} else {
_p0 = unsafe.Pointer(&_zero)
}
- _, _, e1 := Syscall(SYS_MUNLOCK, uintptr(_p0), uintptr(len(b)), 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_munlock_trampoline), uintptr(_p0), uintptr(len(b)), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_munlock_trampoline()
+
+//go:linkname libc_munlock libc_munlock
+//go:cgo_import_dynamic libc_munlock munlock "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Munlockall() (err error) {
- _, _, e1 := Syscall(SYS_MUNLOCKALL, 0, 0, 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_munlockall_trampoline), 0, 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_munlockall_trampoline()
+
+//go:linkname libc_munlockall libc_munlockall
+//go:cgo_import_dynamic libc_munlockall munlockall "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func ptrace(request int, pid int, addr uintptr, data uintptr) (err error) {
- _, _, e1 := Syscall6(SYS_PTRACE, uintptr(request), uintptr(pid), uintptr(addr), uintptr(data), 0, 0)
+ _, _, e1 := syscall_syscall6(funcPC(libc_ptrace_trampoline), uintptr(request), uintptr(pid), uintptr(addr), uintptr(data), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_ptrace_trampoline()
+
+//go:linkname libc_ptrace libc_ptrace
+//go:cgo_import_dynamic libc_ptrace ptrace "/usr/lib/libSystem.B.dylib"
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func getattrlist(path *byte, list unsafe.Pointer, buf unsafe.Pointer, size uintptr, options int) (err error) {
+ _, _, e1 := syscall_syscall6(funcPC(libc_getattrlist_trampoline), uintptr(unsafe.Pointer(path)), uintptr(list), uintptr(buf), uintptr(size), uintptr(options), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func libc_getattrlist_trampoline()
+
+//go:linkname libc_getattrlist libc_getattrlist
+//go:cgo_import_dynamic libc_getattrlist getattrlist "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func pipe() (r int, w int, err error) {
- r0, r1, e1 := RawSyscall(SYS_PIPE, 0, 0, 0)
+ r0, r1, e1 := syscall_rawSyscall(funcPC(libc_pipe_trampoline), 0, 0, 0)
r = int(r0)
w = int(r1)
if e1 != 0 {
@@ -397,6 +567,11 @@ func pipe() (r int, w int, err error) {
return
}
+func libc_pipe_trampoline()
+
+//go:linkname libc_pipe libc_pipe
+//go:cgo_import_dynamic libc_pipe pipe "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func getxattr(path string, attr string, dest *byte, size int, position uint32, options int) (sz int, err error) {
@@ -410,7 +585,7 @@ func getxattr(path string, attr string, dest *byte, size int, position uint32, o
if err != nil {
return
}
- r0, _, e1 := Syscall6(SYS_GETXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(unsafe.Pointer(dest)), uintptr(size), uintptr(position), uintptr(options))
+ r0, _, e1 := syscall_syscall6(funcPC(libc_getxattr_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(unsafe.Pointer(dest)), uintptr(size), uintptr(position), uintptr(options))
sz = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -418,6 +593,11 @@ func getxattr(path string, attr string, dest *byte, size int, position uint32, o
return
}
+func libc_getxattr_trampoline()
+
+//go:linkname libc_getxattr libc_getxattr
+//go:cgo_import_dynamic libc_getxattr getxattr "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func fgetxattr(fd int, attr string, dest *byte, size int, position uint32, options int) (sz int, err error) {
@@ -426,7 +606,7 @@ func fgetxattr(fd int, attr string, dest *byte, size int, position uint32, optio
if err != nil {
return
}
- r0, _, e1 := Syscall6(SYS_FGETXATTR, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(dest)), uintptr(size), uintptr(position), uintptr(options))
+ r0, _, e1 := syscall_syscall6(funcPC(libc_fgetxattr_trampoline), uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(dest)), uintptr(size), uintptr(position), uintptr(options))
sz = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -434,6 +614,11 @@ func fgetxattr(fd int, attr string, dest *byte, size int, position uint32, optio
return
}
+func libc_fgetxattr_trampoline()
+
+//go:linkname libc_fgetxattr libc_fgetxattr
+//go:cgo_import_dynamic libc_fgetxattr fgetxattr "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func setxattr(path string, attr string, data *byte, size int, position uint32, options int) (err error) {
@@ -447,13 +632,18 @@ func setxattr(path string, attr string, data *byte, size int, position uint32, o
if err != nil {
return
}
- _, _, e1 := Syscall6(SYS_SETXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(unsafe.Pointer(data)), uintptr(size), uintptr(position), uintptr(options))
+ _, _, e1 := syscall_syscall6(funcPC(libc_setxattr_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(unsafe.Pointer(data)), uintptr(size), uintptr(position), uintptr(options))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_setxattr_trampoline()
+
+//go:linkname libc_setxattr libc_setxattr
+//go:cgo_import_dynamic libc_setxattr setxattr "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func fsetxattr(fd int, attr string, data *byte, size int, position uint32, options int) (err error) {
@@ -462,13 +652,18 @@ func fsetxattr(fd int, attr string, data *byte, size int, position uint32, optio
if err != nil {
return
}
- _, _, e1 := Syscall6(SYS_FSETXATTR, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(data)), uintptr(size), uintptr(position), uintptr(options))
+ _, _, e1 := syscall_syscall6(funcPC(libc_fsetxattr_trampoline), uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(data)), uintptr(size), uintptr(position), uintptr(options))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_fsetxattr_trampoline()
+
+//go:linkname libc_fsetxattr libc_fsetxattr
+//go:cgo_import_dynamic libc_fsetxattr fsetxattr "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func removexattr(path string, attr string, options int) (err error) {
@@ -482,13 +677,18 @@ func removexattr(path string, attr string, options int) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall(SYS_REMOVEXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(options))
+ _, _, e1 := syscall_syscall(funcPC(libc_removexattr_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(options))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_removexattr_trampoline()
+
+//go:linkname libc_removexattr libc_removexattr
+//go:cgo_import_dynamic libc_removexattr removexattr "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func fremovexattr(fd int, attr string, options int) (err error) {
@@ -497,13 +697,18 @@ func fremovexattr(fd int, attr string, options int) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall(SYS_FREMOVEXATTR, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(options))
+ _, _, e1 := syscall_syscall(funcPC(libc_fremovexattr_trampoline), uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(options))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_fremovexattr_trampoline()
+
+//go:linkname libc_fremovexattr libc_fremovexattr
+//go:cgo_import_dynamic libc_fremovexattr fremovexattr "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func listxattr(path string, dest *byte, size int, options int) (sz int, err error) {
@@ -512,7 +717,7 @@ func listxattr(path string, dest *byte, size int, options int) (sz int, err erro
if err != nil {
return
}
- r0, _, e1 := Syscall6(SYS_LISTXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(dest)), uintptr(size), uintptr(options), 0, 0)
+ r0, _, e1 := syscall_syscall6(funcPC(libc_listxattr_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(dest)), uintptr(size), uintptr(options), 0, 0)
sz = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -520,10 +725,15 @@ func listxattr(path string, dest *byte, size int, options int) (sz int, err erro
return
}
+func libc_listxattr_trampoline()
+
+//go:linkname libc_listxattr libc_listxattr
+//go:cgo_import_dynamic libc_listxattr listxattr "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func flistxattr(fd int, dest *byte, size int, options int) (sz int, err error) {
- r0, _, e1 := Syscall6(SYS_FLISTXATTR, uintptr(fd), uintptr(unsafe.Pointer(dest)), uintptr(size), uintptr(options), 0, 0)
+ r0, _, e1 := syscall_syscall6(funcPC(libc_flistxattr_trampoline), uintptr(fd), uintptr(unsafe.Pointer(dest)), uintptr(size), uintptr(options), 0, 0)
sz = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -531,26 +741,71 @@ func flistxattr(fd int, dest *byte, size int, options int) (sz int, err error) {
return
}
+func libc_flistxattr_trampoline()
+
+//go:linkname libc_flistxattr libc_flistxattr
+//go:cgo_import_dynamic libc_flistxattr flistxattr "/usr/lib/libSystem.B.dylib"
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func setattrlist(path *byte, list unsafe.Pointer, buf unsafe.Pointer, size uintptr, options int) (err error) {
+ _, _, e1 := syscall_syscall6(funcPC(libc_setattrlist_trampoline), uintptr(unsafe.Pointer(path)), uintptr(list), uintptr(buf), uintptr(size), uintptr(options), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func libc_setattrlist_trampoline()
+
+//go:linkname libc_setattrlist libc_setattrlist
+//go:cgo_import_dynamic libc_setattrlist setattrlist "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func kill(pid int, signum int, posix int) (err error) {
- _, _, e1 := Syscall(SYS_KILL, uintptr(pid), uintptr(signum), uintptr(posix))
+ _, _, e1 := syscall_syscall(funcPC(libc_kill_trampoline), uintptr(pid), uintptr(signum), uintptr(posix))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_kill_trampoline()
+
+//go:linkname libc_kill libc_kill
+//go:cgo_import_dynamic libc_kill kill "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func ioctl(fd int, req uint, arg uintptr) (err error) {
- _, _, e1 := Syscall(SYS_IOCTL, uintptr(fd), uintptr(req), uintptr(arg))
+ _, _, e1 := syscall_syscall(funcPC(libc_ioctl_trampoline), uintptr(fd), uintptr(req), uintptr(arg))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_ioctl_trampoline()
+
+//go:linkname libc_ioctl libc_ioctl
+//go:cgo_import_dynamic libc_ioctl ioctl "/usr/lib/libSystem.B.dylib"
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func sendfile(infd int, outfd int, offset int64, len *int64, hdtr unsafe.Pointer, flags int) (err error) {
+ _, _, e1 := syscall_syscall6(funcPC(libc_sendfile_trampoline), uintptr(infd), uintptr(outfd), uintptr(offset), uintptr(unsafe.Pointer(len)), uintptr(hdtr), uintptr(flags))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func libc_sendfile_trampoline()
+
+//go:linkname libc_sendfile libc_sendfile
+//go:cgo_import_dynamic libc_sendfile sendfile "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Access(path string, mode uint32) (err error) {
@@ -559,23 +814,33 @@ func Access(path string, mode uint32) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall(SYS_ACCESS, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_access_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_access_trampoline()
+
+//go:linkname libc_access libc_access
+//go:cgo_import_dynamic libc_access access "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Adjtime(delta *Timeval, olddelta *Timeval) (err error) {
- _, _, e1 := Syscall(SYS_ADJTIME, uintptr(unsafe.Pointer(delta)), uintptr(unsafe.Pointer(olddelta)), 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_adjtime_trampoline), uintptr(unsafe.Pointer(delta)), uintptr(unsafe.Pointer(olddelta)), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_adjtime_trampoline()
+
+//go:linkname libc_adjtime libc_adjtime
+//go:cgo_import_dynamic libc_adjtime adjtime "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Chdir(path string) (err error) {
@@ -584,13 +849,18 @@ func Chdir(path string) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall(SYS_CHDIR, uintptr(unsafe.Pointer(_p0)), 0, 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_chdir_trampoline), uintptr(unsafe.Pointer(_p0)), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_chdir_trampoline()
+
+//go:linkname libc_chdir libc_chdir
+//go:cgo_import_dynamic libc_chdir chdir "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Chflags(path string, flags int) (err error) {
@@ -599,13 +869,18 @@ func Chflags(path string, flags int) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall(SYS_CHFLAGS, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_chflags_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_chflags_trampoline()
+
+//go:linkname libc_chflags libc_chflags
+//go:cgo_import_dynamic libc_chflags chflags "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Chmod(path string, mode uint32) (err error) {
@@ -614,13 +889,18 @@ func Chmod(path string, mode uint32) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall(SYS_CHMOD, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_chmod_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_chmod_trampoline()
+
+//go:linkname libc_chmod libc_chmod
+//go:cgo_import_dynamic libc_chmod chmod "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Chown(path string, uid int, gid int) (err error) {
@@ -629,13 +909,18 @@ func Chown(path string, uid int, gid int) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall(SYS_CHOWN, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid))
+ _, _, e1 := syscall_syscall(funcPC(libc_chown_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_chown_trampoline()
+
+//go:linkname libc_chown libc_chown
+//go:cgo_import_dynamic libc_chown chown "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Chroot(path string) (err error) {
@@ -644,27 +929,37 @@ func Chroot(path string) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall(SYS_CHROOT, uintptr(unsafe.Pointer(_p0)), 0, 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_chroot_trampoline), uintptr(unsafe.Pointer(_p0)), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_chroot_trampoline()
+
+//go:linkname libc_chroot libc_chroot
+//go:cgo_import_dynamic libc_chroot chroot "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Close(fd int) (err error) {
- _, _, e1 := Syscall(SYS_CLOSE, uintptr(fd), 0, 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_close_trampoline), uintptr(fd), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_close_trampoline()
+
+//go:linkname libc_close libc_close
+//go:cgo_import_dynamic libc_close close "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Dup(fd int) (nfd int, err error) {
- r0, _, e1 := Syscall(SYS_DUP, uintptr(fd), 0, 0)
+ r0, _, e1 := syscall_syscall(funcPC(libc_dup_trampoline), uintptr(fd), 0, 0)
nfd = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -672,16 +967,26 @@ func Dup(fd int) (nfd int, err error) {
return
}
+func libc_dup_trampoline()
+
+//go:linkname libc_dup libc_dup
+//go:cgo_import_dynamic libc_dup dup "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Dup2(from int, to int) (err error) {
- _, _, e1 := Syscall(SYS_DUP2, uintptr(from), uintptr(to), 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_dup2_trampoline), uintptr(from), uintptr(to), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_dup2_trampoline()
+
+//go:linkname libc_dup2 libc_dup2
+//go:cgo_import_dynamic libc_dup2 dup2 "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Exchangedata(path1 string, path2 string, options int) (err error) {
@@ -695,20 +1000,30 @@ func Exchangedata(path1 string, path2 string, options int) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall(SYS_EXCHANGEDATA, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(options))
+ _, _, e1 := syscall_syscall(funcPC(libc_exchangedata_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(options))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_exchangedata_trampoline()
+
+//go:linkname libc_exchangedata libc_exchangedata
+//go:cgo_import_dynamic libc_exchangedata exchangedata "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Exit(code int) {
- Syscall(SYS_EXIT, uintptr(code), 0, 0)
+ syscall_syscall(funcPC(libc_exit_trampoline), uintptr(code), 0, 0)
return
}
+func libc_exit_trampoline()
+
+//go:linkname libc_exit libc_exit
+//go:cgo_import_dynamic libc_exit exit "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Faccessat(dirfd int, path string, mode uint32, flags int) (err error) {
@@ -717,43 +1032,63 @@ func Faccessat(dirfd int, path string, mode uint32, flags int) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall6(SYS_FACCESSAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0)
+ _, _, e1 := syscall_syscall6(funcPC(libc_faccessat_trampoline), uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_faccessat_trampoline()
+
+//go:linkname libc_faccessat libc_faccessat
+//go:cgo_import_dynamic libc_faccessat faccessat "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Fchdir(fd int) (err error) {
- _, _, e1 := Syscall(SYS_FCHDIR, uintptr(fd), 0, 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_fchdir_trampoline), uintptr(fd), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_fchdir_trampoline()
+
+//go:linkname libc_fchdir libc_fchdir
+//go:cgo_import_dynamic libc_fchdir fchdir "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Fchflags(fd int, flags int) (err error) {
- _, _, e1 := Syscall(SYS_FCHFLAGS, uintptr(fd), uintptr(flags), 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_fchflags_trampoline), uintptr(fd), uintptr(flags), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_fchflags_trampoline()
+
+//go:linkname libc_fchflags libc_fchflags
+//go:cgo_import_dynamic libc_fchflags fchflags "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Fchmod(fd int, mode uint32) (err error) {
- _, _, e1 := Syscall(SYS_FCHMOD, uintptr(fd), uintptr(mode), 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_fchmod_trampoline), uintptr(fd), uintptr(mode), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_fchmod_trampoline()
+
+//go:linkname libc_fchmod libc_fchmod
+//go:cgo_import_dynamic libc_fchmod fchmod "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) {
@@ -762,23 +1097,33 @@ func Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall6(SYS_FCHMODAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0)
+ _, _, e1 := syscall_syscall6(funcPC(libc_fchmodat_trampoline), uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_fchmodat_trampoline()
+
+//go:linkname libc_fchmodat libc_fchmodat
+//go:cgo_import_dynamic libc_fchmodat fchmodat "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Fchown(fd int, uid int, gid int) (err error) {
- _, _, e1 := Syscall(SYS_FCHOWN, uintptr(fd), uintptr(uid), uintptr(gid))
+ _, _, e1 := syscall_syscall(funcPC(libc_fchown_trampoline), uintptr(fd), uintptr(uid), uintptr(gid))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_fchown_trampoline()
+
+//go:linkname libc_fchown libc_fchown
+//go:cgo_import_dynamic libc_fchown fchown "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error) {
@@ -787,142 +1132,135 @@ func Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall6(SYS_FCHOWNAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid), uintptr(flags), 0)
+ _, _, e1 := syscall_syscall6(funcPC(libc_fchownat_trampoline), uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid), uintptr(flags), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+func libc_fchownat_trampoline()
-func Flock(fd int, how int) (err error) {
- _, _, e1 := Syscall(SYS_FLOCK, uintptr(fd), uintptr(how), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
+//go:linkname libc_fchownat libc_fchownat
+//go:cgo_import_dynamic libc_fchownat fchownat "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-func Fpathconf(fd int, name int) (val int, err error) {
- r0, _, e1 := Syscall(SYS_FPATHCONF, uintptr(fd), uintptr(name), 0)
- val = int(r0)
+func Flock(fd int, how int) (err error) {
+ _, _, e1 := syscall_syscall(funcPC(libc_flock_trampoline), uintptr(fd), uintptr(how), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+func libc_flock_trampoline()
-func Fstat(fd int, stat *Stat_t) (err error) {
- _, _, e1 := Syscall(SYS_FSTAT64, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
+//go:linkname libc_flock libc_flock
+//go:cgo_import_dynamic libc_flock flock "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-func Fstatat(fd int, path string, stat *Stat_t, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall6(SYS_FSTATAT64, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), uintptr(flags), 0, 0)
+func Fpathconf(fd int, name int) (val int, err error) {
+ r0, _, e1 := syscall_syscall(funcPC(libc_fpathconf_trampoline), uintptr(fd), uintptr(name), 0)
+ val = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+func libc_fpathconf_trampoline()
-func Fstatfs(fd int, stat *Statfs_t) (err error) {
- _, _, e1 := Syscall(SYS_FSTATFS64, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
+//go:linkname libc_fpathconf libc_fpathconf
+//go:cgo_import_dynamic libc_fpathconf fpathconf "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Fsync(fd int) (err error) {
- _, _, e1 := Syscall(SYS_FSYNC, uintptr(fd), 0, 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_fsync_trampoline), uintptr(fd), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_fsync_trampoline()
+
+//go:linkname libc_fsync libc_fsync
+//go:cgo_import_dynamic libc_fsync fsync "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Ftruncate(fd int, length int64) (err error) {
- _, _, e1 := Syscall(SYS_FTRUNCATE, uintptr(fd), uintptr(length), 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_ftruncate_trampoline), uintptr(fd), uintptr(length), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+func libc_ftruncate_trampoline()
-func Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(buf) > 0 {
- _p0 = unsafe.Pointer(&buf[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall6(SYS_GETDIRENTRIES64, uintptr(fd), uintptr(_p0), uintptr(len(buf)), uintptr(unsafe.Pointer(basep)), 0, 0)
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
+//go:linkname libc_ftruncate libc_ftruncate
+//go:cgo_import_dynamic libc_ftruncate ftruncate "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Getdtablesize() (size int) {
- r0, _, _ := Syscall(SYS_GETDTABLESIZE, 0, 0, 0)
+ r0, _, _ := syscall_syscall(funcPC(libc_getdtablesize_trampoline), 0, 0, 0)
size = int(r0)
return
}
+func libc_getdtablesize_trampoline()
+
+//go:linkname libc_getdtablesize libc_getdtablesize
+//go:cgo_import_dynamic libc_getdtablesize getdtablesize "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Getegid() (egid int) {
- r0, _, _ := RawSyscall(SYS_GETEGID, 0, 0, 0)
+ r0, _, _ := syscall_rawSyscall(funcPC(libc_getegid_trampoline), 0, 0, 0)
egid = int(r0)
return
}
+func libc_getegid_trampoline()
+
+//go:linkname libc_getegid libc_getegid
+//go:cgo_import_dynamic libc_getegid getegid "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Geteuid() (uid int) {
- r0, _, _ := RawSyscall(SYS_GETEUID, 0, 0, 0)
+ r0, _, _ := syscall_rawSyscall(funcPC(libc_geteuid_trampoline), 0, 0, 0)
uid = int(r0)
return
}
+func libc_geteuid_trampoline()
+
+//go:linkname libc_geteuid libc_geteuid
+//go:cgo_import_dynamic libc_geteuid geteuid "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Getgid() (gid int) {
- r0, _, _ := RawSyscall(SYS_GETGID, 0, 0, 0)
+ r0, _, _ := syscall_rawSyscall(funcPC(libc_getgid_trampoline), 0, 0, 0)
gid = int(r0)
return
}
+func libc_getgid_trampoline()
+
+//go:linkname libc_getgid libc_getgid
+//go:cgo_import_dynamic libc_getgid getgid "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Getpgid(pid int) (pgid int, err error) {
- r0, _, e1 := RawSyscall(SYS_GETPGID, uintptr(pid), 0, 0)
+ r0, _, e1 := syscall_rawSyscall(funcPC(libc_getpgid_trampoline), uintptr(pid), 0, 0)
pgid = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -930,34 +1268,54 @@ func Getpgid(pid int) (pgid int, err error) {
return
}
+func libc_getpgid_trampoline()
+
+//go:linkname libc_getpgid libc_getpgid
+//go:cgo_import_dynamic libc_getpgid getpgid "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Getpgrp() (pgrp int) {
- r0, _, _ := RawSyscall(SYS_GETPGRP, 0, 0, 0)
+ r0, _, _ := syscall_rawSyscall(funcPC(libc_getpgrp_trampoline), 0, 0, 0)
pgrp = int(r0)
return
}
+func libc_getpgrp_trampoline()
+
+//go:linkname libc_getpgrp libc_getpgrp
+//go:cgo_import_dynamic libc_getpgrp getpgrp "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Getpid() (pid int) {
- r0, _, _ := RawSyscall(SYS_GETPID, 0, 0, 0)
+ r0, _, _ := syscall_rawSyscall(funcPC(libc_getpid_trampoline), 0, 0, 0)
pid = int(r0)
return
}
+func libc_getpid_trampoline()
+
+//go:linkname libc_getpid libc_getpid
+//go:cgo_import_dynamic libc_getpid getpid "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Getppid() (ppid int) {
- r0, _, _ := RawSyscall(SYS_GETPPID, 0, 0, 0)
+ r0, _, _ := syscall_rawSyscall(funcPC(libc_getppid_trampoline), 0, 0, 0)
ppid = int(r0)
return
}
+func libc_getppid_trampoline()
+
+//go:linkname libc_getppid libc_getppid
+//go:cgo_import_dynamic libc_getppid getppid "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Getpriority(which int, who int) (prio int, err error) {
- r0, _, e1 := Syscall(SYS_GETPRIORITY, uintptr(which), uintptr(who), 0)
+ r0, _, e1 := syscall_syscall(funcPC(libc_getpriority_trampoline), uintptr(which), uintptr(who), 0)
prio = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -965,30 +1323,45 @@ func Getpriority(which int, who int) (prio int, err error) {
return
}
+func libc_getpriority_trampoline()
+
+//go:linkname libc_getpriority libc_getpriority
+//go:cgo_import_dynamic libc_getpriority getpriority "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Getrlimit(which int, lim *Rlimit) (err error) {
- _, _, e1 := RawSyscall(SYS_GETRLIMIT, uintptr(which), uintptr(unsafe.Pointer(lim)), 0)
+ _, _, e1 := syscall_rawSyscall(funcPC(libc_getrlimit_trampoline), uintptr(which), uintptr(unsafe.Pointer(lim)), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_getrlimit_trampoline()
+
+//go:linkname libc_getrlimit libc_getrlimit
+//go:cgo_import_dynamic libc_getrlimit getrlimit "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Getrusage(who int, rusage *Rusage) (err error) {
- _, _, e1 := RawSyscall(SYS_GETRUSAGE, uintptr(who), uintptr(unsafe.Pointer(rusage)), 0)
+ _, _, e1 := syscall_rawSyscall(funcPC(libc_getrusage_trampoline), uintptr(who), uintptr(unsafe.Pointer(rusage)), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_getrusage_trampoline()
+
+//go:linkname libc_getrusage libc_getrusage
+//go:cgo_import_dynamic libc_getrusage getrusage "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Getsid(pid int) (sid int, err error) {
- r0, _, e1 := RawSyscall(SYS_GETSID, uintptr(pid), 0, 0)
+ r0, _, e1 := syscall_rawSyscall(funcPC(libc_getsid_trampoline), uintptr(pid), 0, 0)
sid = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -996,26 +1369,41 @@ func Getsid(pid int) (sid int, err error) {
return
}
+func libc_getsid_trampoline()
+
+//go:linkname libc_getsid libc_getsid
+//go:cgo_import_dynamic libc_getsid getsid "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Getuid() (uid int) {
- r0, _, _ := RawSyscall(SYS_GETUID, 0, 0, 0)
+ r0, _, _ := syscall_rawSyscall(funcPC(libc_getuid_trampoline), 0, 0, 0)
uid = int(r0)
return
}
+func libc_getuid_trampoline()
+
+//go:linkname libc_getuid libc_getuid
+//go:cgo_import_dynamic libc_getuid getuid "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Issetugid() (tainted bool) {
- r0, _, _ := RawSyscall(SYS_ISSETUGID, 0, 0, 0)
+ r0, _, _ := syscall_rawSyscall(funcPC(libc_issetugid_trampoline), 0, 0, 0)
tainted = bool(r0 != 0)
return
}
+func libc_issetugid_trampoline()
+
+//go:linkname libc_issetugid libc_issetugid
+//go:cgo_import_dynamic libc_issetugid issetugid "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Kqueue() (fd int, err error) {
- r0, _, e1 := Syscall(SYS_KQUEUE, 0, 0, 0)
+ r0, _, e1 := syscall_syscall(funcPC(libc_kqueue_trampoline), 0, 0, 0)
fd = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -1023,6 +1411,11 @@ func Kqueue() (fd int, err error) {
return
}
+func libc_kqueue_trampoline()
+
+//go:linkname libc_kqueue libc_kqueue
+//go:cgo_import_dynamic libc_kqueue kqueue "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Lchown(path string, uid int, gid int) (err error) {
@@ -1031,13 +1424,18 @@ func Lchown(path string, uid int, gid int) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall(SYS_LCHOWN, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid))
+ _, _, e1 := syscall_syscall(funcPC(libc_lchown_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_lchown_trampoline()
+
+//go:linkname libc_lchown libc_lchown
+//go:cgo_import_dynamic libc_lchown lchown "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Link(path string, link string) (err error) {
@@ -1051,13 +1449,18 @@ func Link(path string, link string) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall(SYS_LINK, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_link_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_link_trampoline()
+
+//go:linkname libc_link libc_link
+//go:cgo_import_dynamic libc_link link "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Linkat(pathfd int, path string, linkfd int, link string, flags int) (err error) {
@@ -1071,37 +1474,32 @@ func Linkat(pathfd int, path string, linkfd int, link string, flags int) (err er
if err != nil {
return
}
- _, _, e1 := Syscall6(SYS_LINKAT, uintptr(pathfd), uintptr(unsafe.Pointer(_p0)), uintptr(linkfd), uintptr(unsafe.Pointer(_p1)), uintptr(flags), 0)
+ _, _, e1 := syscall_syscall6(funcPC(libc_linkat_trampoline), uintptr(pathfd), uintptr(unsafe.Pointer(_p0)), uintptr(linkfd), uintptr(unsafe.Pointer(_p1)), uintptr(flags), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_linkat_trampoline()
+
+//go:linkname libc_linkat libc_linkat
+//go:cgo_import_dynamic libc_linkat linkat "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Listen(s int, backlog int) (err error) {
- _, _, e1 := Syscall(SYS_LISTEN, uintptr(s), uintptr(backlog), 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_listen_trampoline), uintptr(s), uintptr(backlog), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+func libc_listen_trampoline()
-func Lstat(path string, stat *Stat_t) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_LSTAT64, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
+//go:linkname libc_listen libc_listen
+//go:cgo_import_dynamic libc_listen listen "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
@@ -1111,13 +1509,18 @@ func Mkdir(path string, mode uint32) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall(SYS_MKDIR, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_mkdir_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_mkdir_trampoline()
+
+//go:linkname libc_mkdir libc_mkdir
+//go:cgo_import_dynamic libc_mkdir mkdir "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Mkdirat(dirfd int, path string, mode uint32) (err error) {
@@ -1126,13 +1529,18 @@ func Mkdirat(dirfd int, path string, mode uint32) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall(SYS_MKDIRAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode))
+ _, _, e1 := syscall_syscall(funcPC(libc_mkdirat_trampoline), uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_mkdirat_trampoline()
+
+//go:linkname libc_mkdirat libc_mkdirat
+//go:cgo_import_dynamic libc_mkdirat mkdirat "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Mkfifo(path string, mode uint32) (err error) {
@@ -1141,13 +1549,18 @@ func Mkfifo(path string, mode uint32) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall(SYS_MKFIFO, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_mkfifo_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_mkfifo_trampoline()
+
+//go:linkname libc_mkfifo libc_mkfifo
+//go:cgo_import_dynamic libc_mkfifo mkfifo "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Mknod(path string, mode uint32, dev int) (err error) {
@@ -1156,13 +1569,18 @@ func Mknod(path string, mode uint32, dev int) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall(SYS_MKNOD, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(dev))
+ _, _, e1 := syscall_syscall(funcPC(libc_mknod_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(dev))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_mknod_trampoline()
+
+//go:linkname libc_mknod libc_mknod
+//go:cgo_import_dynamic libc_mknod mknod "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Open(path string, mode int, perm uint32) (fd int, err error) {
@@ -1171,7 +1589,7 @@ func Open(path string, mode int, perm uint32) (fd int, err error) {
if err != nil {
return
}
- r0, _, e1 := Syscall(SYS_OPEN, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(perm))
+ r0, _, e1 := syscall_syscall(funcPC(libc_open_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(perm))
fd = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -1179,6 +1597,11 @@ func Open(path string, mode int, perm uint32) (fd int, err error) {
return
}
+func libc_open_trampoline()
+
+//go:linkname libc_open libc_open
+//go:cgo_import_dynamic libc_open open "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Openat(dirfd int, path string, mode int, perm uint32) (fd int, err error) {
@@ -1187,7 +1610,7 @@ func Openat(dirfd int, path string, mode int, perm uint32) (fd int, err error) {
if err != nil {
return
}
- r0, _, e1 := Syscall6(SYS_OPENAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(perm), 0, 0)
+ r0, _, e1 := syscall_syscall6(funcPC(libc_openat_trampoline), uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(perm), 0, 0)
fd = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -1195,6 +1618,11 @@ func Openat(dirfd int, path string, mode int, perm uint32) (fd int, err error) {
return
}
+func libc_openat_trampoline()
+
+//go:linkname libc_openat libc_openat
+//go:cgo_import_dynamic libc_openat openat "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Pathconf(path string, name int) (val int, err error) {
@@ -1203,7 +1631,7 @@ func Pathconf(path string, name int) (val int, err error) {
if err != nil {
return
}
- r0, _, e1 := Syscall(SYS_PATHCONF, uintptr(unsafe.Pointer(_p0)), uintptr(name), 0)
+ r0, _, e1 := syscall_syscall(funcPC(libc_pathconf_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(name), 0)
val = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -1211,6 +1639,11 @@ func Pathconf(path string, name int) (val int, err error) {
return
}
+func libc_pathconf_trampoline()
+
+//go:linkname libc_pathconf libc_pathconf
+//go:cgo_import_dynamic libc_pathconf pathconf "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Pread(fd int, p []byte, offset int64) (n int, err error) {
@@ -1220,7 +1653,7 @@ func Pread(fd int, p []byte, offset int64) (n int, err error) {
} else {
_p0 = unsafe.Pointer(&_zero)
}
- r0, _, e1 := Syscall6(SYS_PREAD, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), 0, 0)
+ r0, _, e1 := syscall_syscall6(funcPC(libc_pread_trampoline), uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), 0, 0)
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -1228,6 +1661,11 @@ func Pread(fd int, p []byte, offset int64) (n int, err error) {
return
}
+func libc_pread_trampoline()
+
+//go:linkname libc_pread libc_pread
+//go:cgo_import_dynamic libc_pread pread "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Pwrite(fd int, p []byte, offset int64) (n int, err error) {
@@ -1237,7 +1675,7 @@ func Pwrite(fd int, p []byte, offset int64) (n int, err error) {
} else {
_p0 = unsafe.Pointer(&_zero)
}
- r0, _, e1 := Syscall6(SYS_PWRITE, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), 0, 0)
+ r0, _, e1 := syscall_syscall6(funcPC(libc_pwrite_trampoline), uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), 0, 0)
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -1245,6 +1683,11 @@ func Pwrite(fd int, p []byte, offset int64) (n int, err error) {
return
}
+func libc_pwrite_trampoline()
+
+//go:linkname libc_pwrite libc_pwrite
+//go:cgo_import_dynamic libc_pwrite pwrite "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func read(fd int, p []byte) (n int, err error) {
@@ -1254,7 +1697,7 @@ func read(fd int, p []byte) (n int, err error) {
} else {
_p0 = unsafe.Pointer(&_zero)
}
- r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(_p0), uintptr(len(p)))
+ r0, _, e1 := syscall_syscall(funcPC(libc_read_trampoline), uintptr(fd), uintptr(_p0), uintptr(len(p)))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -1262,6 +1705,11 @@ func read(fd int, p []byte) (n int, err error) {
return
}
+func libc_read_trampoline()
+
+//go:linkname libc_read libc_read
+//go:cgo_import_dynamic libc_read read "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Readlink(path string, buf []byte) (n int, err error) {
@@ -1276,7 +1724,7 @@ func Readlink(path string, buf []byte) (n int, err error) {
} else {
_p1 = unsafe.Pointer(&_zero)
}
- r0, _, e1 := Syscall(SYS_READLINK, uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(buf)))
+ r0, _, e1 := syscall_syscall(funcPC(libc_readlink_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(buf)))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -1284,6 +1732,11 @@ func Readlink(path string, buf []byte) (n int, err error) {
return
}
+func libc_readlink_trampoline()
+
+//go:linkname libc_readlink libc_readlink
+//go:cgo_import_dynamic libc_readlink readlink "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Readlinkat(dirfd int, path string, buf []byte) (n int, err error) {
@@ -1298,7 +1751,7 @@ func Readlinkat(dirfd int, path string, buf []byte) (n int, err error) {
} else {
_p1 = unsafe.Pointer(&_zero)
}
- r0, _, e1 := Syscall6(SYS_READLINKAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(buf)), 0, 0)
+ r0, _, e1 := syscall_syscall6(funcPC(libc_readlinkat_trampoline), uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(buf)), 0, 0)
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -1306,6 +1759,11 @@ func Readlinkat(dirfd int, path string, buf []byte) (n int, err error) {
return
}
+func libc_readlinkat_trampoline()
+
+//go:linkname libc_readlinkat libc_readlinkat
+//go:cgo_import_dynamic libc_readlinkat readlinkat "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Rename(from string, to string) (err error) {
@@ -1319,13 +1777,18 @@ func Rename(from string, to string) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall(SYS_RENAME, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_rename_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_rename_trampoline()
+
+//go:linkname libc_rename libc_rename
+//go:cgo_import_dynamic libc_rename rename "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Renameat(fromfd int, from string, tofd int, to string) (err error) {
@@ -1339,13 +1802,18 @@ func Renameat(fromfd int, from string, tofd int, to string) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall6(SYS_RENAMEAT, uintptr(fromfd), uintptr(unsafe.Pointer(_p0)), uintptr(tofd), uintptr(unsafe.Pointer(_p1)), 0, 0)
+ _, _, e1 := syscall_syscall6(funcPC(libc_renameat_trampoline), uintptr(fromfd), uintptr(unsafe.Pointer(_p0)), uintptr(tofd), uintptr(unsafe.Pointer(_p1)), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_renameat_trampoline()
+
+//go:linkname libc_renameat libc_renameat
+//go:cgo_import_dynamic libc_renameat renameat "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Revoke(path string) (err error) {
@@ -1354,13 +1822,18 @@ func Revoke(path string) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall(SYS_REVOKE, uintptr(unsafe.Pointer(_p0)), 0, 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_revoke_trampoline), uintptr(unsafe.Pointer(_p0)), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_revoke_trampoline()
+
+//go:linkname libc_revoke libc_revoke
+//go:cgo_import_dynamic libc_revoke revoke "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Rmdir(path string) (err error) {
@@ -1369,17 +1842,22 @@ func Rmdir(path string) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall(SYS_RMDIR, uintptr(unsafe.Pointer(_p0)), 0, 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_rmdir_trampoline), uintptr(unsafe.Pointer(_p0)), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_rmdir_trampoline()
+
+//go:linkname libc_rmdir libc_rmdir
+//go:cgo_import_dynamic libc_rmdir rmdir "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Seek(fd int, offset int64, whence int) (newoffset int64, err error) {
- r0, _, e1 := Syscall(SYS_LSEEK, uintptr(fd), uintptr(offset), uintptr(whence))
+ r0, _, e1 := syscall_syscall(funcPC(libc_lseek_trampoline), uintptr(fd), uintptr(offset), uintptr(whence))
newoffset = int64(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -1387,46 +1865,71 @@ func Seek(fd int, offset int64, whence int) (newoffset int64, err error) {
return
}
+func libc_lseek_trampoline()
+
+//go:linkname libc_lseek libc_lseek
+//go:cgo_import_dynamic libc_lseek lseek "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Select(n int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (err error) {
- _, _, e1 := Syscall6(SYS_SELECT, uintptr(n), uintptr(unsafe.Pointer(r)), uintptr(unsafe.Pointer(w)), uintptr(unsafe.Pointer(e)), uintptr(unsafe.Pointer(timeout)), 0)
+ _, _, e1 := syscall_syscall6(funcPC(libc_select_trampoline), uintptr(n), uintptr(unsafe.Pointer(r)), uintptr(unsafe.Pointer(w)), uintptr(unsafe.Pointer(e)), uintptr(unsafe.Pointer(timeout)), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_select_trampoline()
+
+//go:linkname libc_select libc_select
+//go:cgo_import_dynamic libc_select select "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Setegid(egid int) (err error) {
- _, _, e1 := Syscall(SYS_SETEGID, uintptr(egid), 0, 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_setegid_trampoline), uintptr(egid), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_setegid_trampoline()
+
+//go:linkname libc_setegid libc_setegid
+//go:cgo_import_dynamic libc_setegid setegid "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Seteuid(euid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETEUID, uintptr(euid), 0, 0)
+ _, _, e1 := syscall_rawSyscall(funcPC(libc_seteuid_trampoline), uintptr(euid), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_seteuid_trampoline()
+
+//go:linkname libc_seteuid libc_seteuid
+//go:cgo_import_dynamic libc_seteuid seteuid "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Setgid(gid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETGID, uintptr(gid), 0, 0)
+ _, _, e1 := syscall_rawSyscall(funcPC(libc_setgid_trampoline), uintptr(gid), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_setgid_trampoline()
+
+//go:linkname libc_setgid libc_setgid
+//go:cgo_import_dynamic libc_setgid setgid "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Setlogin(name string) (err error) {
@@ -1435,77 +1938,112 @@ func Setlogin(name string) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall(SYS_SETLOGIN, uintptr(unsafe.Pointer(_p0)), 0, 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_setlogin_trampoline), uintptr(unsafe.Pointer(_p0)), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_setlogin_trampoline()
+
+//go:linkname libc_setlogin libc_setlogin
+//go:cgo_import_dynamic libc_setlogin setlogin "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Setpgid(pid int, pgid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETPGID, uintptr(pid), uintptr(pgid), 0)
+ _, _, e1 := syscall_rawSyscall(funcPC(libc_setpgid_trampoline), uintptr(pid), uintptr(pgid), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_setpgid_trampoline()
+
+//go:linkname libc_setpgid libc_setpgid
+//go:cgo_import_dynamic libc_setpgid setpgid "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Setpriority(which int, who int, prio int) (err error) {
- _, _, e1 := Syscall(SYS_SETPRIORITY, uintptr(which), uintptr(who), uintptr(prio))
+ _, _, e1 := syscall_syscall(funcPC(libc_setpriority_trampoline), uintptr(which), uintptr(who), uintptr(prio))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_setpriority_trampoline()
+
+//go:linkname libc_setpriority libc_setpriority
+//go:cgo_import_dynamic libc_setpriority setpriority "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Setprivexec(flag int) (err error) {
- _, _, e1 := Syscall(SYS_SETPRIVEXEC, uintptr(flag), 0, 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_setprivexec_trampoline), uintptr(flag), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_setprivexec_trampoline()
+
+//go:linkname libc_setprivexec libc_setprivexec
+//go:cgo_import_dynamic libc_setprivexec setprivexec "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Setregid(rgid int, egid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETREGID, uintptr(rgid), uintptr(egid), 0)
+ _, _, e1 := syscall_rawSyscall(funcPC(libc_setregid_trampoline), uintptr(rgid), uintptr(egid), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_setregid_trampoline()
+
+//go:linkname libc_setregid libc_setregid
+//go:cgo_import_dynamic libc_setregid setregid "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Setreuid(ruid int, euid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETREUID, uintptr(ruid), uintptr(euid), 0)
+ _, _, e1 := syscall_rawSyscall(funcPC(libc_setreuid_trampoline), uintptr(ruid), uintptr(euid), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_setreuid_trampoline()
+
+//go:linkname libc_setreuid libc_setreuid
+//go:cgo_import_dynamic libc_setreuid setreuid "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Setrlimit(which int, lim *Rlimit) (err error) {
- _, _, e1 := RawSyscall(SYS_SETRLIMIT, uintptr(which), uintptr(unsafe.Pointer(lim)), 0)
+ _, _, e1 := syscall_rawSyscall(funcPC(libc_setrlimit_trampoline), uintptr(which), uintptr(unsafe.Pointer(lim)), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_setrlimit_trampoline()
+
+//go:linkname libc_setrlimit libc_setrlimit
+//go:cgo_import_dynamic libc_setrlimit setrlimit "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Setsid() (pid int, err error) {
- r0, _, e1 := RawSyscall(SYS_SETSID, 0, 0, 0)
+ r0, _, e1 := syscall_rawSyscall(funcPC(libc_setsid_trampoline), 0, 0, 0)
pid = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -1513,55 +2051,40 @@ func Setsid() (pid int, err error) {
return
}
+func libc_setsid_trampoline()
+
+//go:linkname libc_setsid libc_setsid
+//go:cgo_import_dynamic libc_setsid setsid "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Settimeofday(tp *Timeval) (err error) {
- _, _, e1 := RawSyscall(SYS_SETTIMEOFDAY, uintptr(unsafe.Pointer(tp)), 0, 0)
+ _, _, e1 := syscall_rawSyscall(funcPC(libc_settimeofday_trampoline), uintptr(unsafe.Pointer(tp)), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+func libc_settimeofday_trampoline()
-func Setuid(uid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETUID, uintptr(uid), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
+//go:linkname libc_settimeofday libc_settimeofday
+//go:cgo_import_dynamic libc_settimeofday settimeofday "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-func Stat(path string, stat *Stat_t) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_STAT64, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
+func Setuid(uid int) (err error) {
+ _, _, e1 := syscall_rawSyscall(funcPC(libc_setuid_trampoline), uintptr(uid), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+func libc_setuid_trampoline()
-func Statfs(path string, stat *Statfs_t) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_STATFS64, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
+//go:linkname libc_setuid libc_setuid
+//go:cgo_import_dynamic libc_setuid setuid "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
@@ -1576,13 +2099,18 @@ func Symlink(path string, link string) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall(SYS_SYMLINK, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_symlink_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_symlink_trampoline()
+
+//go:linkname libc_symlink libc_symlink
+//go:cgo_import_dynamic libc_symlink symlink "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Symlinkat(oldpath string, newdirfd int, newpath string) (err error) {
@@ -1596,23 +2124,33 @@ func Symlinkat(oldpath string, newdirfd int, newpath string) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall(SYS_SYMLINKAT, uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1)))
+ _, _, e1 := syscall_syscall(funcPC(libc_symlinkat_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1)))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_symlinkat_trampoline()
+
+//go:linkname libc_symlinkat libc_symlinkat
+//go:cgo_import_dynamic libc_symlinkat symlinkat "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Sync() (err error) {
- _, _, e1 := Syscall(SYS_SYNC, 0, 0, 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_sync_trampoline), 0, 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_sync_trampoline()
+
+//go:linkname libc_sync libc_sync
+//go:cgo_import_dynamic libc_sync sync "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Truncate(path string, length int64) (err error) {
@@ -1621,21 +2159,31 @@ func Truncate(path string, length int64) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall(SYS_TRUNCATE, uintptr(unsafe.Pointer(_p0)), uintptr(length), 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_truncate_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(length), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_truncate_trampoline()
+
+//go:linkname libc_truncate libc_truncate
+//go:cgo_import_dynamic libc_truncate truncate "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Umask(newmask int) (oldmask int) {
- r0, _, _ := Syscall(SYS_UMASK, uintptr(newmask), 0, 0)
+ r0, _, _ := syscall_syscall(funcPC(libc_umask_trampoline), uintptr(newmask), 0, 0)
oldmask = int(r0)
return
}
+func libc_umask_trampoline()
+
+//go:linkname libc_umask libc_umask
+//go:cgo_import_dynamic libc_umask umask "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Undelete(path string) (err error) {
@@ -1644,13 +2192,18 @@ func Undelete(path string) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall(SYS_UNDELETE, uintptr(unsafe.Pointer(_p0)), 0, 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_undelete_trampoline), uintptr(unsafe.Pointer(_p0)), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_undelete_trampoline()
+
+//go:linkname libc_undelete libc_undelete
+//go:cgo_import_dynamic libc_undelete undelete "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Unlink(path string) (err error) {
@@ -1659,13 +2212,18 @@ func Unlink(path string) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall(SYS_UNLINK, uintptr(unsafe.Pointer(_p0)), 0, 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_unlink_trampoline), uintptr(unsafe.Pointer(_p0)), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_unlink_trampoline()
+
+//go:linkname libc_unlink libc_unlink
+//go:cgo_import_dynamic libc_unlink unlink "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Unlinkat(dirfd int, path string, flags int) (err error) {
@@ -1674,13 +2232,18 @@ func Unlinkat(dirfd int, path string, flags int) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall(SYS_UNLINKAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(flags))
+ _, _, e1 := syscall_syscall(funcPC(libc_unlinkat_trampoline), uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(flags))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_unlinkat_trampoline()
+
+//go:linkname libc_unlinkat libc_unlinkat
+//go:cgo_import_dynamic libc_unlinkat unlinkat "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Unmount(path string, flags int) (err error) {
@@ -1689,13 +2252,18 @@ func Unmount(path string, flags int) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall(SYS_UNMOUNT, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_unmount_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_unmount_trampoline()
+
+//go:linkname libc_unmount libc_unmount
+//go:cgo_import_dynamic libc_unmount unmount "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func write(fd int, p []byte) (n int, err error) {
@@ -1705,7 +2273,7 @@ func write(fd int, p []byte) (n int, err error) {
} else {
_p0 = unsafe.Pointer(&_zero)
}
- r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(_p0), uintptr(len(p)))
+ r0, _, e1 := syscall_syscall(funcPC(libc_write_trampoline), uintptr(fd), uintptr(_p0), uintptr(len(p)))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -1713,10 +2281,15 @@ func write(fd int, p []byte) (n int, err error) {
return
}
+func libc_write_trampoline()
+
+//go:linkname libc_write libc_write
+//go:cgo_import_dynamic libc_write write "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error) {
- r0, _, e1 := Syscall6(SYS_MMAP, uintptr(addr), uintptr(length), uintptr(prot), uintptr(flag), uintptr(fd), uintptr(pos))
+ r0, _, e1 := syscall_syscall6(funcPC(libc_mmap_trampoline), uintptr(addr), uintptr(length), uintptr(prot), uintptr(flag), uintptr(fd), uintptr(pos))
ret = uintptr(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -1724,20 +2297,30 @@ func mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (
return
}
+func libc_mmap_trampoline()
+
+//go:linkname libc_mmap libc_mmap
+//go:cgo_import_dynamic libc_mmap mmap "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func munmap(addr uintptr, length uintptr) (err error) {
- _, _, e1 := Syscall(SYS_MUNMAP, uintptr(addr), uintptr(length), 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_munmap_trampoline), uintptr(addr), uintptr(length), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_munmap_trampoline()
+
+//go:linkname libc_munmap libc_munmap
+//go:cgo_import_dynamic libc_munmap munmap "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func readlen(fd int, buf *byte, nbuf int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf))
+ r0, _, e1 := syscall_syscall(funcPC(libc_read_trampoline), uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -1748,7 +2331,7 @@ func readlen(fd int, buf *byte, nbuf int) (n int, err error) {
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func writelen(fd int, buf *byte, nbuf int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf))
+ r0, _, e1 := syscall_syscall(funcPC(libc_write_trampoline), uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -1759,7 +2342,7 @@ func writelen(fd int, buf *byte, nbuf int) (n int, err error) {
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func gettimeofday(tp *Timeval) (sec int64, usec int32, err error) {
- r0, r1, e1 := RawSyscall(SYS_GETTIMEOFDAY, uintptr(unsafe.Pointer(tp)), 0, 0)
+ r0, r1, e1 := syscall_rawSyscall(funcPC(libc_gettimeofday_trampoline), uintptr(unsafe.Pointer(tp)), 0, 0)
sec = int64(r0)
usec = int32(r1)
if e1 != 0 {
@@ -1767,3 +2350,156 @@ func gettimeofday(tp *Timeval) (sec int64, usec int32, err error) {
}
return
}
+
+func libc_gettimeofday_trampoline()
+
+//go:linkname libc_gettimeofday libc_gettimeofday
+//go:cgo_import_dynamic libc_gettimeofday gettimeofday "/usr/lib/libSystem.B.dylib"
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Fstat(fd int, stat *Stat_t) (err error) {
+ _, _, e1 := syscall_syscall(funcPC(libc_fstat64_trampoline), uintptr(fd), uintptr(unsafe.Pointer(stat)), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func libc_fstat64_trampoline()
+
+//go:linkname libc_fstat64 libc_fstat64
+//go:cgo_import_dynamic libc_fstat64 fstat64 "/usr/lib/libSystem.B.dylib"
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Fstatat(fd int, path string, stat *Stat_t, flags int) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := syscall_syscall6(funcPC(libc_fstatat64_trampoline), uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), uintptr(flags), 0, 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func libc_fstatat64_trampoline()
+
+//go:linkname libc_fstatat64 libc_fstatat64
+//go:cgo_import_dynamic libc_fstatat64 fstatat64 "/usr/lib/libSystem.B.dylib"
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Fstatfs(fd int, stat *Statfs_t) (err error) {
+ _, _, e1 := syscall_syscall(funcPC(libc_fstatfs64_trampoline), uintptr(fd), uintptr(unsafe.Pointer(stat)), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func libc_fstatfs64_trampoline()
+
+//go:linkname libc_fstatfs64 libc_fstatfs64
+//go:cgo_import_dynamic libc_fstatfs64 fstatfs64 "/usr/lib/libSystem.B.dylib"
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) {
+ var _p0 unsafe.Pointer
+ if len(buf) > 0 {
+ _p0 = unsafe.Pointer(&buf[0])
+ } else {
+ _p0 = unsafe.Pointer(&_zero)
+ }
+ r0, _, e1 := syscall_syscall6(funcPC(libc___getdirentries64_trampoline), uintptr(fd), uintptr(_p0), uintptr(len(buf)), uintptr(unsafe.Pointer(basep)), 0, 0)
+ n = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func libc___getdirentries64_trampoline()
+
+//go:linkname libc___getdirentries64 libc___getdirentries64
+//go:cgo_import_dynamic libc___getdirentries64 __getdirentries64 "/usr/lib/libSystem.B.dylib"
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func getfsstat(buf unsafe.Pointer, size uintptr, flags int) (n int, err error) {
+ r0, _, e1 := syscall_syscall(funcPC(libc_getfsstat64_trampoline), uintptr(buf), uintptr(size), uintptr(flags))
+ n = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func libc_getfsstat64_trampoline()
+
+//go:linkname libc_getfsstat64 libc_getfsstat64
+//go:cgo_import_dynamic libc_getfsstat64 getfsstat64 "/usr/lib/libSystem.B.dylib"
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Lstat(path string, stat *Stat_t) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := syscall_syscall(funcPC(libc_lstat64_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func libc_lstat64_trampoline()
+
+//go:linkname libc_lstat64 libc_lstat64
+//go:cgo_import_dynamic libc_lstat64 lstat64 "/usr/lib/libSystem.B.dylib"
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Stat(path string, stat *Stat_t) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := syscall_syscall(funcPC(libc_stat64_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func libc_stat64_trampoline()
+
+//go:linkname libc_stat64 libc_stat64
+//go:cgo_import_dynamic libc_stat64 stat64 "/usr/lib/libSystem.B.dylib"
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Statfs(path string, stat *Statfs_t) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := syscall_syscall(funcPC(libc_statfs64_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func libc_statfs64_trampoline()
+
+//go:linkname libc_statfs64 libc_statfs64
+//go:cgo_import_dynamic libc_statfs64 statfs64 "/usr/lib/libSystem.B.dylib"
diff --git a/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.s b/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.s
new file mode 100644
index 000000000..da9b900a8
--- /dev/null
+++ b/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.s
@@ -0,0 +1,284 @@
+// go run mkasm_darwin.go amd64
+// Code generated by the command above; DO NOT EDIT.
+
+// +build go1.12
+
+#include "textflag.h"
+TEXT ·libc_getgroups_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_getgroups(SB)
+TEXT ·libc_setgroups_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_setgroups(SB)
+TEXT ·libc_wait4_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_wait4(SB)
+TEXT ·libc_accept_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_accept(SB)
+TEXT ·libc_bind_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_bind(SB)
+TEXT ·libc_connect_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_connect(SB)
+TEXT ·libc_socket_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_socket(SB)
+TEXT ·libc_getsockopt_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_getsockopt(SB)
+TEXT ·libc_setsockopt_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_setsockopt(SB)
+TEXT ·libc_getpeername_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_getpeername(SB)
+TEXT ·libc_getsockname_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_getsockname(SB)
+TEXT ·libc_shutdown_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_shutdown(SB)
+TEXT ·libc_socketpair_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_socketpair(SB)
+TEXT ·libc_recvfrom_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_recvfrom(SB)
+TEXT ·libc_sendto_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_sendto(SB)
+TEXT ·libc_recvmsg_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_recvmsg(SB)
+TEXT ·libc_sendmsg_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_sendmsg(SB)
+TEXT ·libc_kevent_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_kevent(SB)
+TEXT ·libc___sysctl_trampoline(SB),NOSPLIT,$0-0
+ JMP libc___sysctl(SB)
+TEXT ·libc_utimes_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_utimes(SB)
+TEXT ·libc_futimes_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_futimes(SB)
+TEXT ·libc_fcntl_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_fcntl(SB)
+TEXT ·libc_poll_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_poll(SB)
+TEXT ·libc_madvise_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_madvise(SB)
+TEXT ·libc_mlock_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_mlock(SB)
+TEXT ·libc_mlockall_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_mlockall(SB)
+TEXT ·libc_mprotect_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_mprotect(SB)
+TEXT ·libc_msync_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_msync(SB)
+TEXT ·libc_munlock_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_munlock(SB)
+TEXT ·libc_munlockall_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_munlockall(SB)
+TEXT ·libc_ptrace_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_ptrace(SB)
+TEXT ·libc_getattrlist_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_getattrlist(SB)
+TEXT ·libc_pipe_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_pipe(SB)
+TEXT ·libc_getxattr_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_getxattr(SB)
+TEXT ·libc_fgetxattr_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_fgetxattr(SB)
+TEXT ·libc_setxattr_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_setxattr(SB)
+TEXT ·libc_fsetxattr_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_fsetxattr(SB)
+TEXT ·libc_removexattr_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_removexattr(SB)
+TEXT ·libc_fremovexattr_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_fremovexattr(SB)
+TEXT ·libc_listxattr_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_listxattr(SB)
+TEXT ·libc_flistxattr_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_flistxattr(SB)
+TEXT ·libc_setattrlist_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_setattrlist(SB)
+TEXT ·libc_kill_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_kill(SB)
+TEXT ·libc_ioctl_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_ioctl(SB)
+TEXT ·libc_sendfile_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_sendfile(SB)
+TEXT ·libc_access_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_access(SB)
+TEXT ·libc_adjtime_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_adjtime(SB)
+TEXT ·libc_chdir_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_chdir(SB)
+TEXT ·libc_chflags_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_chflags(SB)
+TEXT ·libc_chmod_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_chmod(SB)
+TEXT ·libc_chown_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_chown(SB)
+TEXT ·libc_chroot_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_chroot(SB)
+TEXT ·libc_close_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_close(SB)
+TEXT ·libc_dup_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_dup(SB)
+TEXT ·libc_dup2_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_dup2(SB)
+TEXT ·libc_exchangedata_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_exchangedata(SB)
+TEXT ·libc_exit_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_exit(SB)
+TEXT ·libc_faccessat_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_faccessat(SB)
+TEXT ·libc_fchdir_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_fchdir(SB)
+TEXT ·libc_fchflags_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_fchflags(SB)
+TEXT ·libc_fchmod_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_fchmod(SB)
+TEXT ·libc_fchmodat_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_fchmodat(SB)
+TEXT ·libc_fchown_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_fchown(SB)
+TEXT ·libc_fchownat_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_fchownat(SB)
+TEXT ·libc_flock_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_flock(SB)
+TEXT ·libc_fpathconf_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_fpathconf(SB)
+TEXT ·libc_fsync_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_fsync(SB)
+TEXT ·libc_ftruncate_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_ftruncate(SB)
+TEXT ·libc_getdtablesize_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_getdtablesize(SB)
+TEXT ·libc_getegid_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_getegid(SB)
+TEXT ·libc_geteuid_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_geteuid(SB)
+TEXT ·libc_getgid_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_getgid(SB)
+TEXT ·libc_getpgid_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_getpgid(SB)
+TEXT ·libc_getpgrp_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_getpgrp(SB)
+TEXT ·libc_getpid_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_getpid(SB)
+TEXT ·libc_getppid_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_getppid(SB)
+TEXT ·libc_getpriority_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_getpriority(SB)
+TEXT ·libc_getrlimit_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_getrlimit(SB)
+TEXT ·libc_getrusage_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_getrusage(SB)
+TEXT ·libc_getsid_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_getsid(SB)
+TEXT ·libc_getuid_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_getuid(SB)
+TEXT ·libc_issetugid_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_issetugid(SB)
+TEXT ·libc_kqueue_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_kqueue(SB)
+TEXT ·libc_lchown_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_lchown(SB)
+TEXT ·libc_link_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_link(SB)
+TEXT ·libc_linkat_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_linkat(SB)
+TEXT ·libc_listen_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_listen(SB)
+TEXT ·libc_mkdir_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_mkdir(SB)
+TEXT ·libc_mkdirat_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_mkdirat(SB)
+TEXT ·libc_mkfifo_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_mkfifo(SB)
+TEXT ·libc_mknod_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_mknod(SB)
+TEXT ·libc_open_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_open(SB)
+TEXT ·libc_openat_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_openat(SB)
+TEXT ·libc_pathconf_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_pathconf(SB)
+TEXT ·libc_pread_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_pread(SB)
+TEXT ·libc_pwrite_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_pwrite(SB)
+TEXT ·libc_read_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_read(SB)
+TEXT ·libc_readlink_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_readlink(SB)
+TEXT ·libc_readlinkat_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_readlinkat(SB)
+TEXT ·libc_rename_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_rename(SB)
+TEXT ·libc_renameat_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_renameat(SB)
+TEXT ·libc_revoke_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_revoke(SB)
+TEXT ·libc_rmdir_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_rmdir(SB)
+TEXT ·libc_lseek_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_lseek(SB)
+TEXT ·libc_select_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_select(SB)
+TEXT ·libc_setegid_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_setegid(SB)
+TEXT ·libc_seteuid_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_seteuid(SB)
+TEXT ·libc_setgid_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_setgid(SB)
+TEXT ·libc_setlogin_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_setlogin(SB)
+TEXT ·libc_setpgid_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_setpgid(SB)
+TEXT ·libc_setpriority_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_setpriority(SB)
+TEXT ·libc_setprivexec_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_setprivexec(SB)
+TEXT ·libc_setregid_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_setregid(SB)
+TEXT ·libc_setreuid_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_setreuid(SB)
+TEXT ·libc_setrlimit_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_setrlimit(SB)
+TEXT ·libc_setsid_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_setsid(SB)
+TEXT ·libc_settimeofday_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_settimeofday(SB)
+TEXT ·libc_setuid_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_setuid(SB)
+TEXT ·libc_symlink_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_symlink(SB)
+TEXT ·libc_symlinkat_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_symlinkat(SB)
+TEXT ·libc_sync_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_sync(SB)
+TEXT ·libc_truncate_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_truncate(SB)
+TEXT ·libc_umask_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_umask(SB)
+TEXT ·libc_undelete_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_undelete(SB)
+TEXT ·libc_unlink_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_unlink(SB)
+TEXT ·libc_unlinkat_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_unlinkat(SB)
+TEXT ·libc_unmount_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_unmount(SB)
+TEXT ·libc_write_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_write(SB)
+TEXT ·libc_mmap_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_mmap(SB)
+TEXT ·libc_munmap_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_munmap(SB)
+TEXT ·libc_gettimeofday_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_gettimeofday(SB)
+TEXT ·libc_fstat64_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_fstat64(SB)
+TEXT ·libc_fstatat64_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_fstatat64(SB)
+TEXT ·libc_fstatfs64_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_fstatfs64(SB)
+TEXT ·libc___getdirentries64_trampoline(SB),NOSPLIT,$0-0
+ JMP libc___getdirentries64(SB)
+TEXT ·libc_getfsstat64_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_getfsstat64(SB)
+TEXT ·libc_lstat64_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_lstat64(SB)
+TEXT ·libc_stat64_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_stat64(SB)
+TEXT ·libc_statfs64_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_statfs64(SB)
diff --git a/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm.1_11.go b/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm.1_11.go
new file mode 100644
index 000000000..f8caecef0
--- /dev/null
+++ b/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm.1_11.go
@@ -0,0 +1,1793 @@
+// go run mksyscall.go -l32 -tags darwin,arm,!go1.12 syscall_bsd.go syscall_darwin.go syscall_darwin_arm.go
+// Code generated by the command above; see README.md. DO NOT EDIT.
+
+// +build darwin,arm,!go1.12
+
+package unix
+
+import (
+ "syscall"
+ "unsafe"
+)
+
+var _ syscall.Errno
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func getgroups(ngid int, gid *_Gid_t) (n int, err error) {
+ r0, _, e1 := RawSyscall(SYS_GETGROUPS, uintptr(ngid), uintptr(unsafe.Pointer(gid)), 0)
+ n = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func setgroups(ngid int, gid *_Gid_t) (err error) {
+ _, _, e1 := RawSyscall(SYS_SETGROUPS, uintptr(ngid), uintptr(unsafe.Pointer(gid)), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func wait4(pid int, wstatus *_C_int, options int, rusage *Rusage) (wpid int, err error) {
+ r0, _, e1 := Syscall6(SYS_WAIT4, uintptr(pid), uintptr(unsafe.Pointer(wstatus)), uintptr(options), uintptr(unsafe.Pointer(rusage)), 0, 0)
+ wpid = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) {
+ r0, _, e1 := Syscall(SYS_ACCEPT, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
+ fd = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) {
+ _, _, e1 := Syscall(SYS_BIND, uintptr(s), uintptr(addr), uintptr(addrlen))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) {
+ _, _, e1 := Syscall(SYS_CONNECT, uintptr(s), uintptr(addr), uintptr(addrlen))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func socket(domain int, typ int, proto int) (fd int, err error) {
+ r0, _, e1 := RawSyscall(SYS_SOCKET, uintptr(domain), uintptr(typ), uintptr(proto))
+ fd = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) {
+ _, _, e1 := Syscall6(SYS_GETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(unsafe.Pointer(vallen)), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) {
+ _, _, e1 := Syscall6(SYS_SETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(vallen), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) {
+ _, _, e1 := RawSyscall(SYS_GETPEERNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) {
+ _, _, e1 := RawSyscall(SYS_GETSOCKNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Shutdown(s int, how int) (err error) {
+ _, _, e1 := Syscall(SYS_SHUTDOWN, uintptr(s), uintptr(how), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) {
+ _, _, e1 := RawSyscall6(SYS_SOCKETPAIR, uintptr(domain), uintptr(typ), uintptr(proto), uintptr(unsafe.Pointer(fd)), 0, 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) {
+ var _p0 unsafe.Pointer
+ if len(p) > 0 {
+ _p0 = unsafe.Pointer(&p[0])
+ } else {
+ _p0 = unsafe.Pointer(&_zero)
+ }
+ r0, _, e1 := Syscall6(SYS_RECVFROM, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(flags), uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(fromlen)))
+ n = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) {
+ var _p0 unsafe.Pointer
+ if len(buf) > 0 {
+ _p0 = unsafe.Pointer(&buf[0])
+ } else {
+ _p0 = unsafe.Pointer(&_zero)
+ }
+ _, _, e1 := Syscall6(SYS_SENDTO, uintptr(s), uintptr(_p0), uintptr(len(buf)), uintptr(flags), uintptr(to), uintptr(addrlen))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func recvmsg(s int, msg *Msghdr, flags int) (n int, err error) {
+ r0, _, e1 := Syscall(SYS_RECVMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags))
+ n = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func sendmsg(s int, msg *Msghdr, flags int) (n int, err error) {
+ r0, _, e1 := Syscall(SYS_SENDMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags))
+ n = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func kevent(kq int, change unsafe.Pointer, nchange int, event unsafe.Pointer, nevent int, timeout *Timespec) (n int, err error) {
+ r0, _, e1 := Syscall6(SYS_KEVENT, uintptr(kq), uintptr(change), uintptr(nchange), uintptr(event), uintptr(nevent), uintptr(unsafe.Pointer(timeout)))
+ n = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) {
+ var _p0 unsafe.Pointer
+ if len(mib) > 0 {
+ _p0 = unsafe.Pointer(&mib[0])
+ } else {
+ _p0 = unsafe.Pointer(&_zero)
+ }
+ _, _, e1 := Syscall6(SYS___SYSCTL, uintptr(_p0), uintptr(len(mib)), uintptr(unsafe.Pointer(old)), uintptr(unsafe.Pointer(oldlen)), uintptr(unsafe.Pointer(new)), uintptr(newlen))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func utimes(path string, timeval *[2]Timeval) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_UTIMES, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(timeval)), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func futimes(fd int, timeval *[2]Timeval) (err error) {
+ _, _, e1 := Syscall(SYS_FUTIMES, uintptr(fd), uintptr(unsafe.Pointer(timeval)), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func fcntl(fd int, cmd int, arg int) (val int, err error) {
+ r0, _, e1 := Syscall(SYS_FCNTL, uintptr(fd), uintptr(cmd), uintptr(arg))
+ val = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func poll(fds *PollFd, nfds int, timeout int) (n int, err error) {
+ r0, _, e1 := Syscall(SYS_POLL, uintptr(unsafe.Pointer(fds)), uintptr(nfds), uintptr(timeout))
+ n = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Madvise(b []byte, behav int) (err error) {
+ var _p0 unsafe.Pointer
+ if len(b) > 0 {
+ _p0 = unsafe.Pointer(&b[0])
+ } else {
+ _p0 = unsafe.Pointer(&_zero)
+ }
+ _, _, e1 := Syscall(SYS_MADVISE, uintptr(_p0), uintptr(len(b)), uintptr(behav))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Mlock(b []byte) (err error) {
+ var _p0 unsafe.Pointer
+ if len(b) > 0 {
+ _p0 = unsafe.Pointer(&b[0])
+ } else {
+ _p0 = unsafe.Pointer(&_zero)
+ }
+ _, _, e1 := Syscall(SYS_MLOCK, uintptr(_p0), uintptr(len(b)), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Mlockall(flags int) (err error) {
+ _, _, e1 := Syscall(SYS_MLOCKALL, uintptr(flags), 0, 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Mprotect(b []byte, prot int) (err error) {
+ var _p0 unsafe.Pointer
+ if len(b) > 0 {
+ _p0 = unsafe.Pointer(&b[0])
+ } else {
+ _p0 = unsafe.Pointer(&_zero)
+ }
+ _, _, e1 := Syscall(SYS_MPROTECT, uintptr(_p0), uintptr(len(b)), uintptr(prot))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Msync(b []byte, flags int) (err error) {
+ var _p0 unsafe.Pointer
+ if len(b) > 0 {
+ _p0 = unsafe.Pointer(&b[0])
+ } else {
+ _p0 = unsafe.Pointer(&_zero)
+ }
+ _, _, e1 := Syscall(SYS_MSYNC, uintptr(_p0), uintptr(len(b)), uintptr(flags))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Munlock(b []byte) (err error) {
+ var _p0 unsafe.Pointer
+ if len(b) > 0 {
+ _p0 = unsafe.Pointer(&b[0])
+ } else {
+ _p0 = unsafe.Pointer(&_zero)
+ }
+ _, _, e1 := Syscall(SYS_MUNLOCK, uintptr(_p0), uintptr(len(b)), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Munlockall() (err error) {
+ _, _, e1 := Syscall(SYS_MUNLOCKALL, 0, 0, 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func ptrace(request int, pid int, addr uintptr, data uintptr) (err error) {
+ _, _, e1 := Syscall6(SYS_PTRACE, uintptr(request), uintptr(pid), uintptr(addr), uintptr(data), 0, 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func getattrlist(path *byte, list unsafe.Pointer, buf unsafe.Pointer, size uintptr, options int) (err error) {
+ _, _, e1 := Syscall6(SYS_GETATTRLIST, uintptr(unsafe.Pointer(path)), uintptr(list), uintptr(buf), uintptr(size), uintptr(options), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func pipe() (r int, w int, err error) {
+ r0, r1, e1 := RawSyscall(SYS_PIPE, 0, 0, 0)
+ r = int(r0)
+ w = int(r1)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func getxattr(path string, attr string, dest *byte, size int, position uint32, options int) (sz int, err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ var _p1 *byte
+ _p1, err = BytePtrFromString(attr)
+ if err != nil {
+ return
+ }
+ r0, _, e1 := Syscall6(SYS_GETXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(unsafe.Pointer(dest)), uintptr(size), uintptr(position), uintptr(options))
+ sz = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func fgetxattr(fd int, attr string, dest *byte, size int, position uint32, options int) (sz int, err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(attr)
+ if err != nil {
+ return
+ }
+ r0, _, e1 := Syscall6(SYS_FGETXATTR, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(dest)), uintptr(size), uintptr(position), uintptr(options))
+ sz = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func setxattr(path string, attr string, data *byte, size int, position uint32, options int) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ var _p1 *byte
+ _p1, err = BytePtrFromString(attr)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall6(SYS_SETXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(unsafe.Pointer(data)), uintptr(size), uintptr(position), uintptr(options))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func fsetxattr(fd int, attr string, data *byte, size int, position uint32, options int) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(attr)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall6(SYS_FSETXATTR, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(data)), uintptr(size), uintptr(position), uintptr(options))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func removexattr(path string, attr string, options int) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ var _p1 *byte
+ _p1, err = BytePtrFromString(attr)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_REMOVEXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(options))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func fremovexattr(fd int, attr string, options int) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(attr)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_FREMOVEXATTR, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(options))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func listxattr(path string, dest *byte, size int, options int) (sz int, err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ r0, _, e1 := Syscall6(SYS_LISTXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(dest)), uintptr(size), uintptr(options), 0, 0)
+ sz = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func flistxattr(fd int, dest *byte, size int, options int) (sz int, err error) {
+ r0, _, e1 := Syscall6(SYS_FLISTXATTR, uintptr(fd), uintptr(unsafe.Pointer(dest)), uintptr(size), uintptr(options), 0, 0)
+ sz = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func setattrlist(path *byte, list unsafe.Pointer, buf unsafe.Pointer, size uintptr, options int) (err error) {
+ _, _, e1 := Syscall6(SYS_SETATTRLIST, uintptr(unsafe.Pointer(path)), uintptr(list), uintptr(buf), uintptr(size), uintptr(options), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func kill(pid int, signum int, posix int) (err error) {
+ _, _, e1 := Syscall(SYS_KILL, uintptr(pid), uintptr(signum), uintptr(posix))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func ioctl(fd int, req uint, arg uintptr) (err error) {
+ _, _, e1 := Syscall(SYS_IOCTL, uintptr(fd), uintptr(req), uintptr(arg))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func sendfile(infd int, outfd int, offset int64, len *int64, hdtr unsafe.Pointer, flags int) (err error) {
+ _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(offset), uintptr(offset>>32), uintptr(unsafe.Pointer(len)), uintptr(hdtr), uintptr(flags), 0, 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Access(path string, mode uint32) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_ACCESS, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Adjtime(delta *Timeval, olddelta *Timeval) (err error) {
+ _, _, e1 := Syscall(SYS_ADJTIME, uintptr(unsafe.Pointer(delta)), uintptr(unsafe.Pointer(olddelta)), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Chdir(path string) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_CHDIR, uintptr(unsafe.Pointer(_p0)), 0, 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Chflags(path string, flags int) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_CHFLAGS, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Chmod(path string, mode uint32) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_CHMOD, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Chown(path string, uid int, gid int) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_CHOWN, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Chroot(path string) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_CHROOT, uintptr(unsafe.Pointer(_p0)), 0, 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Close(fd int) (err error) {
+ _, _, e1 := Syscall(SYS_CLOSE, uintptr(fd), 0, 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Dup(fd int) (nfd int, err error) {
+ r0, _, e1 := Syscall(SYS_DUP, uintptr(fd), 0, 0)
+ nfd = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Dup2(from int, to int) (err error) {
+ _, _, e1 := Syscall(SYS_DUP2, uintptr(from), uintptr(to), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Exchangedata(path1 string, path2 string, options int) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path1)
+ if err != nil {
+ return
+ }
+ var _p1 *byte
+ _p1, err = BytePtrFromString(path2)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_EXCHANGEDATA, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(options))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Exit(code int) {
+ Syscall(SYS_EXIT, uintptr(code), 0, 0)
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Faccessat(dirfd int, path string, mode uint32, flags int) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall6(SYS_FACCESSAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Fchdir(fd int) (err error) {
+ _, _, e1 := Syscall(SYS_FCHDIR, uintptr(fd), 0, 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Fchflags(fd int, flags int) (err error) {
+ _, _, e1 := Syscall(SYS_FCHFLAGS, uintptr(fd), uintptr(flags), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Fchmod(fd int, mode uint32) (err error) {
+ _, _, e1 := Syscall(SYS_FCHMOD, uintptr(fd), uintptr(mode), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall6(SYS_FCHMODAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Fchown(fd int, uid int, gid int) (err error) {
+ _, _, e1 := Syscall(SYS_FCHOWN, uintptr(fd), uintptr(uid), uintptr(gid))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall6(SYS_FCHOWNAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid), uintptr(flags), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Flock(fd int, how int) (err error) {
+ _, _, e1 := Syscall(SYS_FLOCK, uintptr(fd), uintptr(how), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Fpathconf(fd int, name int) (val int, err error) {
+ r0, _, e1 := Syscall(SYS_FPATHCONF, uintptr(fd), uintptr(name), 0)
+ val = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Fsync(fd int) (err error) {
+ _, _, e1 := Syscall(SYS_FSYNC, uintptr(fd), 0, 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Ftruncate(fd int, length int64) (err error) {
+ _, _, e1 := Syscall(SYS_FTRUNCATE, uintptr(fd), uintptr(length), uintptr(length>>32))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Getdtablesize() (size int) {
+ r0, _, _ := Syscall(SYS_GETDTABLESIZE, 0, 0, 0)
+ size = int(r0)
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Getegid() (egid int) {
+ r0, _, _ := RawSyscall(SYS_GETEGID, 0, 0, 0)
+ egid = int(r0)
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Geteuid() (uid int) {
+ r0, _, _ := RawSyscall(SYS_GETEUID, 0, 0, 0)
+ uid = int(r0)
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Getgid() (gid int) {
+ r0, _, _ := RawSyscall(SYS_GETGID, 0, 0, 0)
+ gid = int(r0)
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Getpgid(pid int) (pgid int, err error) {
+ r0, _, e1 := RawSyscall(SYS_GETPGID, uintptr(pid), 0, 0)
+ pgid = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Getpgrp() (pgrp int) {
+ r0, _, _ := RawSyscall(SYS_GETPGRP, 0, 0, 0)
+ pgrp = int(r0)
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Getpid() (pid int) {
+ r0, _, _ := RawSyscall(SYS_GETPID, 0, 0, 0)
+ pid = int(r0)
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Getppid() (ppid int) {
+ r0, _, _ := RawSyscall(SYS_GETPPID, 0, 0, 0)
+ ppid = int(r0)
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Getpriority(which int, who int) (prio int, err error) {
+ r0, _, e1 := Syscall(SYS_GETPRIORITY, uintptr(which), uintptr(who), 0)
+ prio = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Getrlimit(which int, lim *Rlimit) (err error) {
+ _, _, e1 := RawSyscall(SYS_GETRLIMIT, uintptr(which), uintptr(unsafe.Pointer(lim)), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Getrusage(who int, rusage *Rusage) (err error) {
+ _, _, e1 := RawSyscall(SYS_GETRUSAGE, uintptr(who), uintptr(unsafe.Pointer(rusage)), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Getsid(pid int) (sid int, err error) {
+ r0, _, e1 := RawSyscall(SYS_GETSID, uintptr(pid), 0, 0)
+ sid = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Getuid() (uid int) {
+ r0, _, _ := RawSyscall(SYS_GETUID, 0, 0, 0)
+ uid = int(r0)
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Issetugid() (tainted bool) {
+ r0, _, _ := RawSyscall(SYS_ISSETUGID, 0, 0, 0)
+ tainted = bool(r0 != 0)
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Kqueue() (fd int, err error) {
+ r0, _, e1 := Syscall(SYS_KQUEUE, 0, 0, 0)
+ fd = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Lchown(path string, uid int, gid int) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_LCHOWN, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Link(path string, link string) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ var _p1 *byte
+ _p1, err = BytePtrFromString(link)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_LINK, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Linkat(pathfd int, path string, linkfd int, link string, flags int) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ var _p1 *byte
+ _p1, err = BytePtrFromString(link)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall6(SYS_LINKAT, uintptr(pathfd), uintptr(unsafe.Pointer(_p0)), uintptr(linkfd), uintptr(unsafe.Pointer(_p1)), uintptr(flags), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Listen(s int, backlog int) (err error) {
+ _, _, e1 := Syscall(SYS_LISTEN, uintptr(s), uintptr(backlog), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Mkdir(path string, mode uint32) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_MKDIR, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Mkdirat(dirfd int, path string, mode uint32) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_MKDIRAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Mkfifo(path string, mode uint32) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_MKFIFO, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Mknod(path string, mode uint32, dev int) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_MKNOD, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(dev))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Open(path string, mode int, perm uint32) (fd int, err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ r0, _, e1 := Syscall(SYS_OPEN, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(perm))
+ fd = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Openat(dirfd int, path string, mode int, perm uint32) (fd int, err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ r0, _, e1 := Syscall6(SYS_OPENAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(perm), 0, 0)
+ fd = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Pathconf(path string, name int) (val int, err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ r0, _, e1 := Syscall(SYS_PATHCONF, uintptr(unsafe.Pointer(_p0)), uintptr(name), 0)
+ val = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Pread(fd int, p []byte, offset int64) (n int, err error) {
+ var _p0 unsafe.Pointer
+ if len(p) > 0 {
+ _p0 = unsafe.Pointer(&p[0])
+ } else {
+ _p0 = unsafe.Pointer(&_zero)
+ }
+ r0, _, e1 := Syscall6(SYS_PREAD, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), uintptr(offset>>32), 0)
+ n = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Pwrite(fd int, p []byte, offset int64) (n int, err error) {
+ var _p0 unsafe.Pointer
+ if len(p) > 0 {
+ _p0 = unsafe.Pointer(&p[0])
+ } else {
+ _p0 = unsafe.Pointer(&_zero)
+ }
+ r0, _, e1 := Syscall6(SYS_PWRITE, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), uintptr(offset>>32), 0)
+ n = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func read(fd int, p []byte) (n int, err error) {
+ var _p0 unsafe.Pointer
+ if len(p) > 0 {
+ _p0 = unsafe.Pointer(&p[0])
+ } else {
+ _p0 = unsafe.Pointer(&_zero)
+ }
+ r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(_p0), uintptr(len(p)))
+ n = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Readlink(path string, buf []byte) (n int, err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ var _p1 unsafe.Pointer
+ if len(buf) > 0 {
+ _p1 = unsafe.Pointer(&buf[0])
+ } else {
+ _p1 = unsafe.Pointer(&_zero)
+ }
+ r0, _, e1 := Syscall(SYS_READLINK, uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(buf)))
+ n = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Readlinkat(dirfd int, path string, buf []byte) (n int, err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ var _p1 unsafe.Pointer
+ if len(buf) > 0 {
+ _p1 = unsafe.Pointer(&buf[0])
+ } else {
+ _p1 = unsafe.Pointer(&_zero)
+ }
+ r0, _, e1 := Syscall6(SYS_READLINKAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(buf)), 0, 0)
+ n = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Rename(from string, to string) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(from)
+ if err != nil {
+ return
+ }
+ var _p1 *byte
+ _p1, err = BytePtrFromString(to)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_RENAME, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Renameat(fromfd int, from string, tofd int, to string) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(from)
+ if err != nil {
+ return
+ }
+ var _p1 *byte
+ _p1, err = BytePtrFromString(to)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall6(SYS_RENAMEAT, uintptr(fromfd), uintptr(unsafe.Pointer(_p0)), uintptr(tofd), uintptr(unsafe.Pointer(_p1)), 0, 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Revoke(path string) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_REVOKE, uintptr(unsafe.Pointer(_p0)), 0, 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Rmdir(path string) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_RMDIR, uintptr(unsafe.Pointer(_p0)), 0, 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Seek(fd int, offset int64, whence int) (newoffset int64, err error) {
+ r0, r1, e1 := Syscall6(SYS_LSEEK, uintptr(fd), uintptr(offset), uintptr(offset>>32), uintptr(whence), 0, 0)
+ newoffset = int64(int64(r1)<<32 | int64(r0))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Select(n int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (err error) {
+ _, _, e1 := Syscall6(SYS_SELECT, uintptr(n), uintptr(unsafe.Pointer(r)), uintptr(unsafe.Pointer(w)), uintptr(unsafe.Pointer(e)), uintptr(unsafe.Pointer(timeout)), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Setegid(egid int) (err error) {
+ _, _, e1 := Syscall(SYS_SETEGID, uintptr(egid), 0, 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Seteuid(euid int) (err error) {
+ _, _, e1 := RawSyscall(SYS_SETEUID, uintptr(euid), 0, 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Setgid(gid int) (err error) {
+ _, _, e1 := RawSyscall(SYS_SETGID, uintptr(gid), 0, 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Setlogin(name string) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(name)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_SETLOGIN, uintptr(unsafe.Pointer(_p0)), 0, 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Setpgid(pid int, pgid int) (err error) {
+ _, _, e1 := RawSyscall(SYS_SETPGID, uintptr(pid), uintptr(pgid), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Setpriority(which int, who int, prio int) (err error) {
+ _, _, e1 := Syscall(SYS_SETPRIORITY, uintptr(which), uintptr(who), uintptr(prio))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Setprivexec(flag int) (err error) {
+ _, _, e1 := Syscall(SYS_SETPRIVEXEC, uintptr(flag), 0, 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Setregid(rgid int, egid int) (err error) {
+ _, _, e1 := RawSyscall(SYS_SETREGID, uintptr(rgid), uintptr(egid), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Setreuid(ruid int, euid int) (err error) {
+ _, _, e1 := RawSyscall(SYS_SETREUID, uintptr(ruid), uintptr(euid), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Setrlimit(which int, lim *Rlimit) (err error) {
+ _, _, e1 := RawSyscall(SYS_SETRLIMIT, uintptr(which), uintptr(unsafe.Pointer(lim)), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Setsid() (pid int, err error) {
+ r0, _, e1 := RawSyscall(SYS_SETSID, 0, 0, 0)
+ pid = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Settimeofday(tp *Timeval) (err error) {
+ _, _, e1 := RawSyscall(SYS_SETTIMEOFDAY, uintptr(unsafe.Pointer(tp)), 0, 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Setuid(uid int) (err error) {
+ _, _, e1 := RawSyscall(SYS_SETUID, uintptr(uid), 0, 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Symlink(path string, link string) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ var _p1 *byte
+ _p1, err = BytePtrFromString(link)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_SYMLINK, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Symlinkat(oldpath string, newdirfd int, newpath string) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(oldpath)
+ if err != nil {
+ return
+ }
+ var _p1 *byte
+ _p1, err = BytePtrFromString(newpath)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_SYMLINKAT, uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1)))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Sync() (err error) {
+ _, _, e1 := Syscall(SYS_SYNC, 0, 0, 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Truncate(path string, length int64) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_TRUNCATE, uintptr(unsafe.Pointer(_p0)), uintptr(length), uintptr(length>>32))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Umask(newmask int) (oldmask int) {
+ r0, _, _ := Syscall(SYS_UMASK, uintptr(newmask), 0, 0)
+ oldmask = int(r0)
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Undelete(path string) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_UNDELETE, uintptr(unsafe.Pointer(_p0)), 0, 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Unlink(path string) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_UNLINK, uintptr(unsafe.Pointer(_p0)), 0, 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Unlinkat(dirfd int, path string, flags int) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_UNLINKAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(flags))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Unmount(path string, flags int) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_UNMOUNT, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func write(fd int, p []byte) (n int, err error) {
+ var _p0 unsafe.Pointer
+ if len(p) > 0 {
+ _p0 = unsafe.Pointer(&p[0])
+ } else {
+ _p0 = unsafe.Pointer(&_zero)
+ }
+ r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(_p0), uintptr(len(p)))
+ n = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error) {
+ r0, _, e1 := Syscall9(SYS_MMAP, uintptr(addr), uintptr(length), uintptr(prot), uintptr(flag), uintptr(fd), uintptr(pos), uintptr(pos>>32), 0, 0)
+ ret = uintptr(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func munmap(addr uintptr, length uintptr) (err error) {
+ _, _, e1 := Syscall(SYS_MUNMAP, uintptr(addr), uintptr(length), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func readlen(fd int, buf *byte, nbuf int) (n int, err error) {
+ r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf))
+ n = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func writelen(fd int, buf *byte, nbuf int) (n int, err error) {
+ r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf))
+ n = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func gettimeofday(tp *Timeval) (sec int32, usec int32, err error) {
+ r0, r1, e1 := RawSyscall(SYS_GETTIMEOFDAY, uintptr(unsafe.Pointer(tp)), 0, 0)
+ sec = int32(r0)
+ usec = int32(r1)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Fstat(fd int, stat *Stat_t) (err error) {
+ _, _, e1 := Syscall(SYS_FSTAT, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Fstatat(fd int, path string, stat *Stat_t, flags int) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall6(SYS_FSTATAT, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), uintptr(flags), 0, 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Fstatfs(fd int, stat *Statfs_t) (err error) {
+ _, _, e1 := Syscall(SYS_FSTATFS, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func getfsstat(buf unsafe.Pointer, size uintptr, flags int) (n int, err error) {
+ r0, _, e1 := Syscall(SYS_GETFSSTAT, uintptr(buf), uintptr(size), uintptr(flags))
+ n = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Lstat(path string, stat *Stat_t) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_LSTAT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Stat(path string, stat *Stat_t) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_STAT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Statfs(path string, stat *Statfs_t) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_STATFS, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
diff --git a/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm.go b/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm.go
index 81c4f0935..01cffbf46 100644
--- a/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm.go
+++ b/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm.go
@@ -1,7 +1,7 @@
-// mksyscall.pl -l32 -tags darwin,arm syscall_bsd.go syscall_darwin.go syscall_darwin_arm.go
+// go run mksyscall.go -l32 -tags darwin,arm,go1.12 syscall_bsd.go syscall_darwin.go syscall_darwin_arm.go
// Code generated by the command above; see README.md. DO NOT EDIT.
-// +build darwin,arm
+// +build darwin,arm,go1.12
package unix
@@ -15,7 +15,7 @@ var _ syscall.Errno
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func getgroups(ngid int, gid *_Gid_t) (n int, err error) {
- r0, _, e1 := RawSyscall(SYS_GETGROUPS, uintptr(ngid), uintptr(unsafe.Pointer(gid)), 0)
+ r0, _, e1 := syscall_rawSyscall(funcPC(libc_getgroups_trampoline), uintptr(ngid), uintptr(unsafe.Pointer(gid)), 0)
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -23,20 +23,30 @@ func getgroups(ngid int, gid *_Gid_t) (n int, err error) {
return
}
+func libc_getgroups_trampoline()
+
+//go:linkname libc_getgroups libc_getgroups
+//go:cgo_import_dynamic libc_getgroups getgroups "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func setgroups(ngid int, gid *_Gid_t) (err error) {
- _, _, e1 := RawSyscall(SYS_SETGROUPS, uintptr(ngid), uintptr(unsafe.Pointer(gid)), 0)
+ _, _, e1 := syscall_rawSyscall(funcPC(libc_setgroups_trampoline), uintptr(ngid), uintptr(unsafe.Pointer(gid)), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_setgroups_trampoline()
+
+//go:linkname libc_setgroups libc_setgroups
+//go:cgo_import_dynamic libc_setgroups setgroups "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func wait4(pid int, wstatus *_C_int, options int, rusage *Rusage) (wpid int, err error) {
- r0, _, e1 := Syscall6(SYS_WAIT4, uintptr(pid), uintptr(unsafe.Pointer(wstatus)), uintptr(options), uintptr(unsafe.Pointer(rusage)), 0, 0)
+ r0, _, e1 := syscall_syscall6(funcPC(libc_wait4_trampoline), uintptr(pid), uintptr(unsafe.Pointer(wstatus)), uintptr(options), uintptr(unsafe.Pointer(rusage)), 0, 0)
wpid = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -44,10 +54,15 @@ func wait4(pid int, wstatus *_C_int, options int, rusage *Rusage) (wpid int, err
return
}
+func libc_wait4_trampoline()
+
+//go:linkname libc_wait4 libc_wait4
+//go:cgo_import_dynamic libc_wait4 wait4 "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) {
- r0, _, e1 := Syscall(SYS_ACCEPT, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
+ r0, _, e1 := syscall_syscall(funcPC(libc_accept_trampoline), uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
fd = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -55,30 +70,45 @@ func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) {
return
}
+func libc_accept_trampoline()
+
+//go:linkname libc_accept libc_accept
+//go:cgo_import_dynamic libc_accept accept "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) {
- _, _, e1 := Syscall(SYS_BIND, uintptr(s), uintptr(addr), uintptr(addrlen))
+ _, _, e1 := syscall_syscall(funcPC(libc_bind_trampoline), uintptr(s), uintptr(addr), uintptr(addrlen))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_bind_trampoline()
+
+//go:linkname libc_bind libc_bind
+//go:cgo_import_dynamic libc_bind bind "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) {
- _, _, e1 := Syscall(SYS_CONNECT, uintptr(s), uintptr(addr), uintptr(addrlen))
+ _, _, e1 := syscall_syscall(funcPC(libc_connect_trampoline), uintptr(s), uintptr(addr), uintptr(addrlen))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_connect_trampoline()
+
+//go:linkname libc_connect libc_connect
+//go:cgo_import_dynamic libc_connect connect "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func socket(domain int, typ int, proto int) (fd int, err error) {
- r0, _, e1 := RawSyscall(SYS_SOCKET, uintptr(domain), uintptr(typ), uintptr(proto))
+ r0, _, e1 := syscall_rawSyscall(funcPC(libc_socket_trampoline), uintptr(domain), uintptr(typ), uintptr(proto))
fd = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -86,66 +116,101 @@ func socket(domain int, typ int, proto int) (fd int, err error) {
return
}
+func libc_socket_trampoline()
+
+//go:linkname libc_socket libc_socket
+//go:cgo_import_dynamic libc_socket socket "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) {
- _, _, e1 := Syscall6(SYS_GETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(unsafe.Pointer(vallen)), 0)
+ _, _, e1 := syscall_syscall6(funcPC(libc_getsockopt_trampoline), uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(unsafe.Pointer(vallen)), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_getsockopt_trampoline()
+
+//go:linkname libc_getsockopt libc_getsockopt
+//go:cgo_import_dynamic libc_getsockopt getsockopt "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) {
- _, _, e1 := Syscall6(SYS_SETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(vallen), 0)
+ _, _, e1 := syscall_syscall6(funcPC(libc_setsockopt_trampoline), uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(vallen), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_setsockopt_trampoline()
+
+//go:linkname libc_setsockopt libc_setsockopt
+//go:cgo_import_dynamic libc_setsockopt setsockopt "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) {
- _, _, e1 := RawSyscall(SYS_GETPEERNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
+ _, _, e1 := syscall_rawSyscall(funcPC(libc_getpeername_trampoline), uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_getpeername_trampoline()
+
+//go:linkname libc_getpeername libc_getpeername
+//go:cgo_import_dynamic libc_getpeername getpeername "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) {
- _, _, e1 := RawSyscall(SYS_GETSOCKNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
+ _, _, e1 := syscall_rawSyscall(funcPC(libc_getsockname_trampoline), uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_getsockname_trampoline()
+
+//go:linkname libc_getsockname libc_getsockname
+//go:cgo_import_dynamic libc_getsockname getsockname "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Shutdown(s int, how int) (err error) {
- _, _, e1 := Syscall(SYS_SHUTDOWN, uintptr(s), uintptr(how), 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_shutdown_trampoline), uintptr(s), uintptr(how), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_shutdown_trampoline()
+
+//go:linkname libc_shutdown libc_shutdown
+//go:cgo_import_dynamic libc_shutdown shutdown "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) {
- _, _, e1 := RawSyscall6(SYS_SOCKETPAIR, uintptr(domain), uintptr(typ), uintptr(proto), uintptr(unsafe.Pointer(fd)), 0, 0)
+ _, _, e1 := syscall_rawSyscall6(funcPC(libc_socketpair_trampoline), uintptr(domain), uintptr(typ), uintptr(proto), uintptr(unsafe.Pointer(fd)), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_socketpair_trampoline()
+
+//go:linkname libc_socketpair libc_socketpair
+//go:cgo_import_dynamic libc_socketpair socketpair "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) {
@@ -155,7 +220,7 @@ func recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Sockl
} else {
_p0 = unsafe.Pointer(&_zero)
}
- r0, _, e1 := Syscall6(SYS_RECVFROM, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(flags), uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(fromlen)))
+ r0, _, e1 := syscall_syscall6(funcPC(libc_recvfrom_trampoline), uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(flags), uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(fromlen)))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -163,6 +228,11 @@ func recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Sockl
return
}
+func libc_recvfrom_trampoline()
+
+//go:linkname libc_recvfrom libc_recvfrom
+//go:cgo_import_dynamic libc_recvfrom recvfrom "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) {
@@ -172,17 +242,22 @@ func sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (
} else {
_p0 = unsafe.Pointer(&_zero)
}
- _, _, e1 := Syscall6(SYS_SENDTO, uintptr(s), uintptr(_p0), uintptr(len(buf)), uintptr(flags), uintptr(to), uintptr(addrlen))
+ _, _, e1 := syscall_syscall6(funcPC(libc_sendto_trampoline), uintptr(s), uintptr(_p0), uintptr(len(buf)), uintptr(flags), uintptr(to), uintptr(addrlen))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_sendto_trampoline()
+
+//go:linkname libc_sendto libc_sendto
+//go:cgo_import_dynamic libc_sendto sendto "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func recvmsg(s int, msg *Msghdr, flags int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_RECVMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags))
+ r0, _, e1 := syscall_syscall(funcPC(libc_recvmsg_trampoline), uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -190,10 +265,15 @@ func recvmsg(s int, msg *Msghdr, flags int) (n int, err error) {
return
}
+func libc_recvmsg_trampoline()
+
+//go:linkname libc_recvmsg libc_recvmsg
+//go:cgo_import_dynamic libc_recvmsg recvmsg "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func sendmsg(s int, msg *Msghdr, flags int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_SENDMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags))
+ r0, _, e1 := syscall_syscall(funcPC(libc_sendmsg_trampoline), uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -201,10 +281,15 @@ func sendmsg(s int, msg *Msghdr, flags int) (n int, err error) {
return
}
+func libc_sendmsg_trampoline()
+
+//go:linkname libc_sendmsg libc_sendmsg
+//go:cgo_import_dynamic libc_sendmsg sendmsg "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func kevent(kq int, change unsafe.Pointer, nchange int, event unsafe.Pointer, nevent int, timeout *Timespec) (n int, err error) {
- r0, _, e1 := Syscall6(SYS_KEVENT, uintptr(kq), uintptr(change), uintptr(nchange), uintptr(event), uintptr(nevent), uintptr(unsafe.Pointer(timeout)))
+ r0, _, e1 := syscall_syscall6(funcPC(libc_kevent_trampoline), uintptr(kq), uintptr(change), uintptr(nchange), uintptr(event), uintptr(nevent), uintptr(unsafe.Pointer(timeout)))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -212,6 +297,11 @@ func kevent(kq int, change unsafe.Pointer, nchange int, event unsafe.Pointer, ne
return
}
+func libc_kevent_trampoline()
+
+//go:linkname libc_kevent libc_kevent
+//go:cgo_import_dynamic libc_kevent kevent "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) {
@@ -221,13 +311,18 @@ func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr)
} else {
_p0 = unsafe.Pointer(&_zero)
}
- _, _, e1 := Syscall6(SYS___SYSCTL, uintptr(_p0), uintptr(len(mib)), uintptr(unsafe.Pointer(old)), uintptr(unsafe.Pointer(oldlen)), uintptr(unsafe.Pointer(new)), uintptr(newlen))
+ _, _, e1 := syscall_syscall6(funcPC(libc___sysctl_trampoline), uintptr(_p0), uintptr(len(mib)), uintptr(unsafe.Pointer(old)), uintptr(unsafe.Pointer(oldlen)), uintptr(unsafe.Pointer(new)), uintptr(newlen))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc___sysctl_trampoline()
+
+//go:linkname libc___sysctl libc___sysctl
+//go:cgo_import_dynamic libc___sysctl __sysctl "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func utimes(path string, timeval *[2]Timeval) (err error) {
@@ -236,27 +331,37 @@ func utimes(path string, timeval *[2]Timeval) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall(SYS_UTIMES, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(timeval)), 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_utimes_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(timeval)), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_utimes_trampoline()
+
+//go:linkname libc_utimes libc_utimes
+//go:cgo_import_dynamic libc_utimes utimes "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func futimes(fd int, timeval *[2]Timeval) (err error) {
- _, _, e1 := Syscall(SYS_FUTIMES, uintptr(fd), uintptr(unsafe.Pointer(timeval)), 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_futimes_trampoline), uintptr(fd), uintptr(unsafe.Pointer(timeval)), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_futimes_trampoline()
+
+//go:linkname libc_futimes libc_futimes
+//go:cgo_import_dynamic libc_futimes futimes "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func fcntl(fd int, cmd int, arg int) (val int, err error) {
- r0, _, e1 := Syscall(SYS_FCNTL, uintptr(fd), uintptr(cmd), uintptr(arg))
+ r0, _, e1 := syscall_syscall(funcPC(libc_fcntl_trampoline), uintptr(fd), uintptr(cmd), uintptr(arg))
val = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -264,10 +369,15 @@ func fcntl(fd int, cmd int, arg int) (val int, err error) {
return
}
+func libc_fcntl_trampoline()
+
+//go:linkname libc_fcntl libc_fcntl
+//go:cgo_import_dynamic libc_fcntl fcntl "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func poll(fds *PollFd, nfds int, timeout int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_POLL, uintptr(unsafe.Pointer(fds)), uintptr(nfds), uintptr(timeout))
+ r0, _, e1 := syscall_syscall(funcPC(libc_poll_trampoline), uintptr(unsafe.Pointer(fds)), uintptr(nfds), uintptr(timeout))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -275,6 +385,11 @@ func poll(fds *PollFd, nfds int, timeout int) (n int, err error) {
return
}
+func libc_poll_trampoline()
+
+//go:linkname libc_poll libc_poll
+//go:cgo_import_dynamic libc_poll poll "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Madvise(b []byte, behav int) (err error) {
@@ -284,13 +399,18 @@ func Madvise(b []byte, behav int) (err error) {
} else {
_p0 = unsafe.Pointer(&_zero)
}
- _, _, e1 := Syscall(SYS_MADVISE, uintptr(_p0), uintptr(len(b)), uintptr(behav))
+ _, _, e1 := syscall_syscall(funcPC(libc_madvise_trampoline), uintptr(_p0), uintptr(len(b)), uintptr(behav))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_madvise_trampoline()
+
+//go:linkname libc_madvise libc_madvise
+//go:cgo_import_dynamic libc_madvise madvise "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Mlock(b []byte) (err error) {
@@ -300,23 +420,33 @@ func Mlock(b []byte) (err error) {
} else {
_p0 = unsafe.Pointer(&_zero)
}
- _, _, e1 := Syscall(SYS_MLOCK, uintptr(_p0), uintptr(len(b)), 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_mlock_trampoline), uintptr(_p0), uintptr(len(b)), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_mlock_trampoline()
+
+//go:linkname libc_mlock libc_mlock
+//go:cgo_import_dynamic libc_mlock mlock "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Mlockall(flags int) (err error) {
- _, _, e1 := Syscall(SYS_MLOCKALL, uintptr(flags), 0, 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_mlockall_trampoline), uintptr(flags), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_mlockall_trampoline()
+
+//go:linkname libc_mlockall libc_mlockall
+//go:cgo_import_dynamic libc_mlockall mlockall "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Mprotect(b []byte, prot int) (err error) {
@@ -326,13 +456,18 @@ func Mprotect(b []byte, prot int) (err error) {
} else {
_p0 = unsafe.Pointer(&_zero)
}
- _, _, e1 := Syscall(SYS_MPROTECT, uintptr(_p0), uintptr(len(b)), uintptr(prot))
+ _, _, e1 := syscall_syscall(funcPC(libc_mprotect_trampoline), uintptr(_p0), uintptr(len(b)), uintptr(prot))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_mprotect_trampoline()
+
+//go:linkname libc_mprotect libc_mprotect
+//go:cgo_import_dynamic libc_mprotect mprotect "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Msync(b []byte, flags int) (err error) {
@@ -342,13 +477,18 @@ func Msync(b []byte, flags int) (err error) {
} else {
_p0 = unsafe.Pointer(&_zero)
}
- _, _, e1 := Syscall(SYS_MSYNC, uintptr(_p0), uintptr(len(b)), uintptr(flags))
+ _, _, e1 := syscall_syscall(funcPC(libc_msync_trampoline), uintptr(_p0), uintptr(len(b)), uintptr(flags))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_msync_trampoline()
+
+//go:linkname libc_msync libc_msync
+//go:cgo_import_dynamic libc_msync msync "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Munlock(b []byte) (err error) {
@@ -358,37 +498,67 @@ func Munlock(b []byte) (err error) {
} else {
_p0 = unsafe.Pointer(&_zero)
}
- _, _, e1 := Syscall(SYS_MUNLOCK, uintptr(_p0), uintptr(len(b)), 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_munlock_trampoline), uintptr(_p0), uintptr(len(b)), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_munlock_trampoline()
+
+//go:linkname libc_munlock libc_munlock
+//go:cgo_import_dynamic libc_munlock munlock "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Munlockall() (err error) {
- _, _, e1 := Syscall(SYS_MUNLOCKALL, 0, 0, 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_munlockall_trampoline), 0, 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_munlockall_trampoline()
+
+//go:linkname libc_munlockall libc_munlockall
+//go:cgo_import_dynamic libc_munlockall munlockall "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func ptrace(request int, pid int, addr uintptr, data uintptr) (err error) {
- _, _, e1 := Syscall6(SYS_PTRACE, uintptr(request), uintptr(pid), uintptr(addr), uintptr(data), 0, 0)
+ _, _, e1 := syscall_syscall6(funcPC(libc_ptrace_trampoline), uintptr(request), uintptr(pid), uintptr(addr), uintptr(data), 0, 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func libc_ptrace_trampoline()
+
+//go:linkname libc_ptrace libc_ptrace
+//go:cgo_import_dynamic libc_ptrace ptrace "/usr/lib/libSystem.B.dylib"
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func getattrlist(path *byte, list unsafe.Pointer, buf unsafe.Pointer, size uintptr, options int) (err error) {
+ _, _, e1 := syscall_syscall6(funcPC(libc_getattrlist_trampoline), uintptr(unsafe.Pointer(path)), uintptr(list), uintptr(buf), uintptr(size), uintptr(options), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_getattrlist_trampoline()
+
+//go:linkname libc_getattrlist libc_getattrlist
+//go:cgo_import_dynamic libc_getattrlist getattrlist "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func pipe() (r int, w int, err error) {
- r0, r1, e1 := RawSyscall(SYS_PIPE, 0, 0, 0)
+ r0, r1, e1 := syscall_rawSyscall(funcPC(libc_pipe_trampoline), 0, 0, 0)
r = int(r0)
w = int(r1)
if e1 != 0 {
@@ -397,6 +567,11 @@ func pipe() (r int, w int, err error) {
return
}
+func libc_pipe_trampoline()
+
+//go:linkname libc_pipe libc_pipe
+//go:cgo_import_dynamic libc_pipe pipe "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func getxattr(path string, attr string, dest *byte, size int, position uint32, options int) (sz int, err error) {
@@ -410,7 +585,7 @@ func getxattr(path string, attr string, dest *byte, size int, position uint32, o
if err != nil {
return
}
- r0, _, e1 := Syscall6(SYS_GETXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(unsafe.Pointer(dest)), uintptr(size), uintptr(position), uintptr(options))
+ r0, _, e1 := syscall_syscall6(funcPC(libc_getxattr_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(unsafe.Pointer(dest)), uintptr(size), uintptr(position), uintptr(options))
sz = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -418,6 +593,11 @@ func getxattr(path string, attr string, dest *byte, size int, position uint32, o
return
}
+func libc_getxattr_trampoline()
+
+//go:linkname libc_getxattr libc_getxattr
+//go:cgo_import_dynamic libc_getxattr getxattr "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func fgetxattr(fd int, attr string, dest *byte, size int, position uint32, options int) (sz int, err error) {
@@ -426,7 +606,7 @@ func fgetxattr(fd int, attr string, dest *byte, size int, position uint32, optio
if err != nil {
return
}
- r0, _, e1 := Syscall6(SYS_FGETXATTR, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(dest)), uintptr(size), uintptr(position), uintptr(options))
+ r0, _, e1 := syscall_syscall6(funcPC(libc_fgetxattr_trampoline), uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(dest)), uintptr(size), uintptr(position), uintptr(options))
sz = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -434,6 +614,11 @@ func fgetxattr(fd int, attr string, dest *byte, size int, position uint32, optio
return
}
+func libc_fgetxattr_trampoline()
+
+//go:linkname libc_fgetxattr libc_fgetxattr
+//go:cgo_import_dynamic libc_fgetxattr fgetxattr "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func setxattr(path string, attr string, data *byte, size int, position uint32, options int) (err error) {
@@ -447,13 +632,18 @@ func setxattr(path string, attr string, data *byte, size int, position uint32, o
if err != nil {
return
}
- _, _, e1 := Syscall6(SYS_SETXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(unsafe.Pointer(data)), uintptr(size), uintptr(position), uintptr(options))
+ _, _, e1 := syscall_syscall6(funcPC(libc_setxattr_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(unsafe.Pointer(data)), uintptr(size), uintptr(position), uintptr(options))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_setxattr_trampoline()
+
+//go:linkname libc_setxattr libc_setxattr
+//go:cgo_import_dynamic libc_setxattr setxattr "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func fsetxattr(fd int, attr string, data *byte, size int, position uint32, options int) (err error) {
@@ -462,13 +652,18 @@ func fsetxattr(fd int, attr string, data *byte, size int, position uint32, optio
if err != nil {
return
}
- _, _, e1 := Syscall6(SYS_FSETXATTR, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(data)), uintptr(size), uintptr(position), uintptr(options))
+ _, _, e1 := syscall_syscall6(funcPC(libc_fsetxattr_trampoline), uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(data)), uintptr(size), uintptr(position), uintptr(options))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_fsetxattr_trampoline()
+
+//go:linkname libc_fsetxattr libc_fsetxattr
+//go:cgo_import_dynamic libc_fsetxattr fsetxattr "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func removexattr(path string, attr string, options int) (err error) {
@@ -482,13 +677,18 @@ func removexattr(path string, attr string, options int) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall(SYS_REMOVEXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(options))
+ _, _, e1 := syscall_syscall(funcPC(libc_removexattr_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(options))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_removexattr_trampoline()
+
+//go:linkname libc_removexattr libc_removexattr
+//go:cgo_import_dynamic libc_removexattr removexattr "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func fremovexattr(fd int, attr string, options int) (err error) {
@@ -497,13 +697,18 @@ func fremovexattr(fd int, attr string, options int) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall(SYS_FREMOVEXATTR, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(options))
+ _, _, e1 := syscall_syscall(funcPC(libc_fremovexattr_trampoline), uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(options))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_fremovexattr_trampoline()
+
+//go:linkname libc_fremovexattr libc_fremovexattr
+//go:cgo_import_dynamic libc_fremovexattr fremovexattr "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func listxattr(path string, dest *byte, size int, options int) (sz int, err error) {
@@ -512,7 +717,7 @@ func listxattr(path string, dest *byte, size int, options int) (sz int, err erro
if err != nil {
return
}
- r0, _, e1 := Syscall6(SYS_LISTXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(dest)), uintptr(size), uintptr(options), 0, 0)
+ r0, _, e1 := syscall_syscall6(funcPC(libc_listxattr_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(dest)), uintptr(size), uintptr(options), 0, 0)
sz = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -520,10 +725,15 @@ func listxattr(path string, dest *byte, size int, options int) (sz int, err erro
return
}
+func libc_listxattr_trampoline()
+
+//go:linkname libc_listxattr libc_listxattr
+//go:cgo_import_dynamic libc_listxattr listxattr "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func flistxattr(fd int, dest *byte, size int, options int) (sz int, err error) {
- r0, _, e1 := Syscall6(SYS_FLISTXATTR, uintptr(fd), uintptr(unsafe.Pointer(dest)), uintptr(size), uintptr(options), 0, 0)
+ r0, _, e1 := syscall_syscall6(funcPC(libc_flistxattr_trampoline), uintptr(fd), uintptr(unsafe.Pointer(dest)), uintptr(size), uintptr(options), 0, 0)
sz = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -531,26 +741,71 @@ func flistxattr(fd int, dest *byte, size int, options int) (sz int, err error) {
return
}
+func libc_flistxattr_trampoline()
+
+//go:linkname libc_flistxattr libc_flistxattr
+//go:cgo_import_dynamic libc_flistxattr flistxattr "/usr/lib/libSystem.B.dylib"
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func setattrlist(path *byte, list unsafe.Pointer, buf unsafe.Pointer, size uintptr, options int) (err error) {
+ _, _, e1 := syscall_syscall6(funcPC(libc_setattrlist_trampoline), uintptr(unsafe.Pointer(path)), uintptr(list), uintptr(buf), uintptr(size), uintptr(options), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func libc_setattrlist_trampoline()
+
+//go:linkname libc_setattrlist libc_setattrlist
+//go:cgo_import_dynamic libc_setattrlist setattrlist "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func kill(pid int, signum int, posix int) (err error) {
- _, _, e1 := Syscall(SYS_KILL, uintptr(pid), uintptr(signum), uintptr(posix))
+ _, _, e1 := syscall_syscall(funcPC(libc_kill_trampoline), uintptr(pid), uintptr(signum), uintptr(posix))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_kill_trampoline()
+
+//go:linkname libc_kill libc_kill
+//go:cgo_import_dynamic libc_kill kill "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func ioctl(fd int, req uint, arg uintptr) (err error) {
- _, _, e1 := Syscall(SYS_IOCTL, uintptr(fd), uintptr(req), uintptr(arg))
+ _, _, e1 := syscall_syscall(funcPC(libc_ioctl_trampoline), uintptr(fd), uintptr(req), uintptr(arg))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func libc_ioctl_trampoline()
+
+//go:linkname libc_ioctl libc_ioctl
+//go:cgo_import_dynamic libc_ioctl ioctl "/usr/lib/libSystem.B.dylib"
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func sendfile(infd int, outfd int, offset int64, len *int64, hdtr unsafe.Pointer, flags int) (err error) {
+ _, _, e1 := syscall_syscall9(funcPC(libc_sendfile_trampoline), uintptr(infd), uintptr(outfd), uintptr(offset), uintptr(offset>>32), uintptr(unsafe.Pointer(len)), uintptr(hdtr), uintptr(flags), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_sendfile_trampoline()
+
+//go:linkname libc_sendfile libc_sendfile
+//go:cgo_import_dynamic libc_sendfile sendfile "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Access(path string, mode uint32) (err error) {
@@ -559,23 +814,33 @@ func Access(path string, mode uint32) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall(SYS_ACCESS, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_access_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_access_trampoline()
+
+//go:linkname libc_access libc_access
+//go:cgo_import_dynamic libc_access access "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Adjtime(delta *Timeval, olddelta *Timeval) (err error) {
- _, _, e1 := Syscall(SYS_ADJTIME, uintptr(unsafe.Pointer(delta)), uintptr(unsafe.Pointer(olddelta)), 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_adjtime_trampoline), uintptr(unsafe.Pointer(delta)), uintptr(unsafe.Pointer(olddelta)), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_adjtime_trampoline()
+
+//go:linkname libc_adjtime libc_adjtime
+//go:cgo_import_dynamic libc_adjtime adjtime "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Chdir(path string) (err error) {
@@ -584,13 +849,18 @@ func Chdir(path string) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall(SYS_CHDIR, uintptr(unsafe.Pointer(_p0)), 0, 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_chdir_trampoline), uintptr(unsafe.Pointer(_p0)), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_chdir_trampoline()
+
+//go:linkname libc_chdir libc_chdir
+//go:cgo_import_dynamic libc_chdir chdir "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Chflags(path string, flags int) (err error) {
@@ -599,13 +869,18 @@ func Chflags(path string, flags int) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall(SYS_CHFLAGS, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_chflags_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_chflags_trampoline()
+
+//go:linkname libc_chflags libc_chflags
+//go:cgo_import_dynamic libc_chflags chflags "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Chmod(path string, mode uint32) (err error) {
@@ -614,13 +889,18 @@ func Chmod(path string, mode uint32) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall(SYS_CHMOD, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_chmod_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_chmod_trampoline()
+
+//go:linkname libc_chmod libc_chmod
+//go:cgo_import_dynamic libc_chmod chmod "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Chown(path string, uid int, gid int) (err error) {
@@ -629,13 +909,18 @@ func Chown(path string, uid int, gid int) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall(SYS_CHOWN, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid))
+ _, _, e1 := syscall_syscall(funcPC(libc_chown_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_chown_trampoline()
+
+//go:linkname libc_chown libc_chown
+//go:cgo_import_dynamic libc_chown chown "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Chroot(path string) (err error) {
@@ -644,27 +929,37 @@ func Chroot(path string) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall(SYS_CHROOT, uintptr(unsafe.Pointer(_p0)), 0, 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_chroot_trampoline), uintptr(unsafe.Pointer(_p0)), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_chroot_trampoline()
+
+//go:linkname libc_chroot libc_chroot
+//go:cgo_import_dynamic libc_chroot chroot "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Close(fd int) (err error) {
- _, _, e1 := Syscall(SYS_CLOSE, uintptr(fd), 0, 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_close_trampoline), uintptr(fd), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_close_trampoline()
+
+//go:linkname libc_close libc_close
+//go:cgo_import_dynamic libc_close close "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Dup(fd int) (nfd int, err error) {
- r0, _, e1 := Syscall(SYS_DUP, uintptr(fd), 0, 0)
+ r0, _, e1 := syscall_syscall(funcPC(libc_dup_trampoline), uintptr(fd), 0, 0)
nfd = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -672,16 +967,26 @@ func Dup(fd int) (nfd int, err error) {
return
}
+func libc_dup_trampoline()
+
+//go:linkname libc_dup libc_dup
+//go:cgo_import_dynamic libc_dup dup "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Dup2(from int, to int) (err error) {
- _, _, e1 := Syscall(SYS_DUP2, uintptr(from), uintptr(to), 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_dup2_trampoline), uintptr(from), uintptr(to), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_dup2_trampoline()
+
+//go:linkname libc_dup2 libc_dup2
+//go:cgo_import_dynamic libc_dup2 dup2 "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Exchangedata(path1 string, path2 string, options int) (err error) {
@@ -695,20 +1000,30 @@ func Exchangedata(path1 string, path2 string, options int) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall(SYS_EXCHANGEDATA, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(options))
+ _, _, e1 := syscall_syscall(funcPC(libc_exchangedata_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(options))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_exchangedata_trampoline()
+
+//go:linkname libc_exchangedata libc_exchangedata
+//go:cgo_import_dynamic libc_exchangedata exchangedata "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Exit(code int) {
- Syscall(SYS_EXIT, uintptr(code), 0, 0)
+ syscall_syscall(funcPC(libc_exit_trampoline), uintptr(code), 0, 0)
return
}
+func libc_exit_trampoline()
+
+//go:linkname libc_exit libc_exit
+//go:cgo_import_dynamic libc_exit exit "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Faccessat(dirfd int, path string, mode uint32, flags int) (err error) {
@@ -717,43 +1032,63 @@ func Faccessat(dirfd int, path string, mode uint32, flags int) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall6(SYS_FACCESSAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0)
+ _, _, e1 := syscall_syscall6(funcPC(libc_faccessat_trampoline), uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_faccessat_trampoline()
+
+//go:linkname libc_faccessat libc_faccessat
+//go:cgo_import_dynamic libc_faccessat faccessat "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Fchdir(fd int) (err error) {
- _, _, e1 := Syscall(SYS_FCHDIR, uintptr(fd), 0, 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_fchdir_trampoline), uintptr(fd), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_fchdir_trampoline()
+
+//go:linkname libc_fchdir libc_fchdir
+//go:cgo_import_dynamic libc_fchdir fchdir "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Fchflags(fd int, flags int) (err error) {
- _, _, e1 := Syscall(SYS_FCHFLAGS, uintptr(fd), uintptr(flags), 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_fchflags_trampoline), uintptr(fd), uintptr(flags), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_fchflags_trampoline()
+
+//go:linkname libc_fchflags libc_fchflags
+//go:cgo_import_dynamic libc_fchflags fchflags "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Fchmod(fd int, mode uint32) (err error) {
- _, _, e1 := Syscall(SYS_FCHMOD, uintptr(fd), uintptr(mode), 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_fchmod_trampoline), uintptr(fd), uintptr(mode), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_fchmod_trampoline()
+
+//go:linkname libc_fchmod libc_fchmod
+//go:cgo_import_dynamic libc_fchmod fchmod "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) {
@@ -762,23 +1097,33 @@ func Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall6(SYS_FCHMODAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0)
+ _, _, e1 := syscall_syscall6(funcPC(libc_fchmodat_trampoline), uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_fchmodat_trampoline()
+
+//go:linkname libc_fchmodat libc_fchmodat
+//go:cgo_import_dynamic libc_fchmodat fchmodat "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Fchown(fd int, uid int, gid int) (err error) {
- _, _, e1 := Syscall(SYS_FCHOWN, uintptr(fd), uintptr(uid), uintptr(gid))
+ _, _, e1 := syscall_syscall(funcPC(libc_fchown_trampoline), uintptr(fd), uintptr(uid), uintptr(gid))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_fchown_trampoline()
+
+//go:linkname libc_fchown libc_fchown
+//go:cgo_import_dynamic libc_fchown fchown "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error) {
@@ -787,142 +1132,135 @@ func Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall6(SYS_FCHOWNAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid), uintptr(flags), 0)
+ _, _, e1 := syscall_syscall6(funcPC(libc_fchownat_trampoline), uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid), uintptr(flags), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+func libc_fchownat_trampoline()
-func Flock(fd int, how int) (err error) {
- _, _, e1 := Syscall(SYS_FLOCK, uintptr(fd), uintptr(how), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
+//go:linkname libc_fchownat libc_fchownat
+//go:cgo_import_dynamic libc_fchownat fchownat "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-func Fpathconf(fd int, name int) (val int, err error) {
- r0, _, e1 := Syscall(SYS_FPATHCONF, uintptr(fd), uintptr(name), 0)
- val = int(r0)
+func Flock(fd int, how int) (err error) {
+ _, _, e1 := syscall_syscall(funcPC(libc_flock_trampoline), uintptr(fd), uintptr(how), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+func libc_flock_trampoline()
-func Fstat(fd int, stat *Stat_t) (err error) {
- _, _, e1 := Syscall(SYS_FSTAT64, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
+//go:linkname libc_flock libc_flock
+//go:cgo_import_dynamic libc_flock flock "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-func Fstatat(fd int, path string, stat *Stat_t, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall6(SYS_FSTATAT64, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), uintptr(flags), 0, 0)
+func Fpathconf(fd int, name int) (val int, err error) {
+ r0, _, e1 := syscall_syscall(funcPC(libc_fpathconf_trampoline), uintptr(fd), uintptr(name), 0)
+ val = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+func libc_fpathconf_trampoline()
-func Fstatfs(fd int, stat *Statfs_t) (err error) {
- _, _, e1 := Syscall(SYS_FSTATFS64, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
+//go:linkname libc_fpathconf libc_fpathconf
+//go:cgo_import_dynamic libc_fpathconf fpathconf "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Fsync(fd int) (err error) {
- _, _, e1 := Syscall(SYS_FSYNC, uintptr(fd), 0, 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_fsync_trampoline), uintptr(fd), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_fsync_trampoline()
+
+//go:linkname libc_fsync libc_fsync
+//go:cgo_import_dynamic libc_fsync fsync "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Ftruncate(fd int, length int64) (err error) {
- _, _, e1 := Syscall(SYS_FTRUNCATE, uintptr(fd), uintptr(length), uintptr(length>>32))
+ _, _, e1 := syscall_syscall(funcPC(libc_ftruncate_trampoline), uintptr(fd), uintptr(length), uintptr(length>>32))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+func libc_ftruncate_trampoline()
-func Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(buf) > 0 {
- _p0 = unsafe.Pointer(&buf[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall6(SYS_GETDIRENTRIES64, uintptr(fd), uintptr(_p0), uintptr(len(buf)), uintptr(unsafe.Pointer(basep)), 0, 0)
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
+//go:linkname libc_ftruncate libc_ftruncate
+//go:cgo_import_dynamic libc_ftruncate ftruncate "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Getdtablesize() (size int) {
- r0, _, _ := Syscall(SYS_GETDTABLESIZE, 0, 0, 0)
+ r0, _, _ := syscall_syscall(funcPC(libc_getdtablesize_trampoline), 0, 0, 0)
size = int(r0)
return
}
+func libc_getdtablesize_trampoline()
+
+//go:linkname libc_getdtablesize libc_getdtablesize
+//go:cgo_import_dynamic libc_getdtablesize getdtablesize "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Getegid() (egid int) {
- r0, _, _ := RawSyscall(SYS_GETEGID, 0, 0, 0)
+ r0, _, _ := syscall_rawSyscall(funcPC(libc_getegid_trampoline), 0, 0, 0)
egid = int(r0)
return
}
+func libc_getegid_trampoline()
+
+//go:linkname libc_getegid libc_getegid
+//go:cgo_import_dynamic libc_getegid getegid "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Geteuid() (uid int) {
- r0, _, _ := RawSyscall(SYS_GETEUID, 0, 0, 0)
+ r0, _, _ := syscall_rawSyscall(funcPC(libc_geteuid_trampoline), 0, 0, 0)
uid = int(r0)
return
}
+func libc_geteuid_trampoline()
+
+//go:linkname libc_geteuid libc_geteuid
+//go:cgo_import_dynamic libc_geteuid geteuid "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Getgid() (gid int) {
- r0, _, _ := RawSyscall(SYS_GETGID, 0, 0, 0)
+ r0, _, _ := syscall_rawSyscall(funcPC(libc_getgid_trampoline), 0, 0, 0)
gid = int(r0)
return
}
+func libc_getgid_trampoline()
+
+//go:linkname libc_getgid libc_getgid
+//go:cgo_import_dynamic libc_getgid getgid "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Getpgid(pid int) (pgid int, err error) {
- r0, _, e1 := RawSyscall(SYS_GETPGID, uintptr(pid), 0, 0)
+ r0, _, e1 := syscall_rawSyscall(funcPC(libc_getpgid_trampoline), uintptr(pid), 0, 0)
pgid = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -930,34 +1268,54 @@ func Getpgid(pid int) (pgid int, err error) {
return
}
+func libc_getpgid_trampoline()
+
+//go:linkname libc_getpgid libc_getpgid
+//go:cgo_import_dynamic libc_getpgid getpgid "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Getpgrp() (pgrp int) {
- r0, _, _ := RawSyscall(SYS_GETPGRP, 0, 0, 0)
+ r0, _, _ := syscall_rawSyscall(funcPC(libc_getpgrp_trampoline), 0, 0, 0)
pgrp = int(r0)
return
}
+func libc_getpgrp_trampoline()
+
+//go:linkname libc_getpgrp libc_getpgrp
+//go:cgo_import_dynamic libc_getpgrp getpgrp "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Getpid() (pid int) {
- r0, _, _ := RawSyscall(SYS_GETPID, 0, 0, 0)
+ r0, _, _ := syscall_rawSyscall(funcPC(libc_getpid_trampoline), 0, 0, 0)
pid = int(r0)
return
}
+func libc_getpid_trampoline()
+
+//go:linkname libc_getpid libc_getpid
+//go:cgo_import_dynamic libc_getpid getpid "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Getppid() (ppid int) {
- r0, _, _ := RawSyscall(SYS_GETPPID, 0, 0, 0)
+ r0, _, _ := syscall_rawSyscall(funcPC(libc_getppid_trampoline), 0, 0, 0)
ppid = int(r0)
return
}
+func libc_getppid_trampoline()
+
+//go:linkname libc_getppid libc_getppid
+//go:cgo_import_dynamic libc_getppid getppid "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Getpriority(which int, who int) (prio int, err error) {
- r0, _, e1 := Syscall(SYS_GETPRIORITY, uintptr(which), uintptr(who), 0)
+ r0, _, e1 := syscall_syscall(funcPC(libc_getpriority_trampoline), uintptr(which), uintptr(who), 0)
prio = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -965,30 +1323,45 @@ func Getpriority(which int, who int) (prio int, err error) {
return
}
+func libc_getpriority_trampoline()
+
+//go:linkname libc_getpriority libc_getpriority
+//go:cgo_import_dynamic libc_getpriority getpriority "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Getrlimit(which int, lim *Rlimit) (err error) {
- _, _, e1 := RawSyscall(SYS_GETRLIMIT, uintptr(which), uintptr(unsafe.Pointer(lim)), 0)
+ _, _, e1 := syscall_rawSyscall(funcPC(libc_getrlimit_trampoline), uintptr(which), uintptr(unsafe.Pointer(lim)), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_getrlimit_trampoline()
+
+//go:linkname libc_getrlimit libc_getrlimit
+//go:cgo_import_dynamic libc_getrlimit getrlimit "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Getrusage(who int, rusage *Rusage) (err error) {
- _, _, e1 := RawSyscall(SYS_GETRUSAGE, uintptr(who), uintptr(unsafe.Pointer(rusage)), 0)
+ _, _, e1 := syscall_rawSyscall(funcPC(libc_getrusage_trampoline), uintptr(who), uintptr(unsafe.Pointer(rusage)), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_getrusage_trampoline()
+
+//go:linkname libc_getrusage libc_getrusage
+//go:cgo_import_dynamic libc_getrusage getrusage "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Getsid(pid int) (sid int, err error) {
- r0, _, e1 := RawSyscall(SYS_GETSID, uintptr(pid), 0, 0)
+ r0, _, e1 := syscall_rawSyscall(funcPC(libc_getsid_trampoline), uintptr(pid), 0, 0)
sid = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -996,26 +1369,41 @@ func Getsid(pid int) (sid int, err error) {
return
}
+func libc_getsid_trampoline()
+
+//go:linkname libc_getsid libc_getsid
+//go:cgo_import_dynamic libc_getsid getsid "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Getuid() (uid int) {
- r0, _, _ := RawSyscall(SYS_GETUID, 0, 0, 0)
+ r0, _, _ := syscall_rawSyscall(funcPC(libc_getuid_trampoline), 0, 0, 0)
uid = int(r0)
return
}
+func libc_getuid_trampoline()
+
+//go:linkname libc_getuid libc_getuid
+//go:cgo_import_dynamic libc_getuid getuid "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Issetugid() (tainted bool) {
- r0, _, _ := RawSyscall(SYS_ISSETUGID, 0, 0, 0)
+ r0, _, _ := syscall_rawSyscall(funcPC(libc_issetugid_trampoline), 0, 0, 0)
tainted = bool(r0 != 0)
return
}
+func libc_issetugid_trampoline()
+
+//go:linkname libc_issetugid libc_issetugid
+//go:cgo_import_dynamic libc_issetugid issetugid "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Kqueue() (fd int, err error) {
- r0, _, e1 := Syscall(SYS_KQUEUE, 0, 0, 0)
+ r0, _, e1 := syscall_syscall(funcPC(libc_kqueue_trampoline), 0, 0, 0)
fd = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -1023,6 +1411,11 @@ func Kqueue() (fd int, err error) {
return
}
+func libc_kqueue_trampoline()
+
+//go:linkname libc_kqueue libc_kqueue
+//go:cgo_import_dynamic libc_kqueue kqueue "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Lchown(path string, uid int, gid int) (err error) {
@@ -1031,13 +1424,18 @@ func Lchown(path string, uid int, gid int) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall(SYS_LCHOWN, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid))
+ _, _, e1 := syscall_syscall(funcPC(libc_lchown_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_lchown_trampoline()
+
+//go:linkname libc_lchown libc_lchown
+//go:cgo_import_dynamic libc_lchown lchown "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Link(path string, link string) (err error) {
@@ -1051,13 +1449,18 @@ func Link(path string, link string) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall(SYS_LINK, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_link_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_link_trampoline()
+
+//go:linkname libc_link libc_link
+//go:cgo_import_dynamic libc_link link "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Linkat(pathfd int, path string, linkfd int, link string, flags int) (err error) {
@@ -1071,37 +1474,32 @@ func Linkat(pathfd int, path string, linkfd int, link string, flags int) (err er
if err != nil {
return
}
- _, _, e1 := Syscall6(SYS_LINKAT, uintptr(pathfd), uintptr(unsafe.Pointer(_p0)), uintptr(linkfd), uintptr(unsafe.Pointer(_p1)), uintptr(flags), 0)
+ _, _, e1 := syscall_syscall6(funcPC(libc_linkat_trampoline), uintptr(pathfd), uintptr(unsafe.Pointer(_p0)), uintptr(linkfd), uintptr(unsafe.Pointer(_p1)), uintptr(flags), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_linkat_trampoline()
+
+//go:linkname libc_linkat libc_linkat
+//go:cgo_import_dynamic libc_linkat linkat "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Listen(s int, backlog int) (err error) {
- _, _, e1 := Syscall(SYS_LISTEN, uintptr(s), uintptr(backlog), 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_listen_trampoline), uintptr(s), uintptr(backlog), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+func libc_listen_trampoline()
-func Lstat(path string, stat *Stat_t) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_LSTAT64, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
+//go:linkname libc_listen libc_listen
+//go:cgo_import_dynamic libc_listen listen "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
@@ -1111,13 +1509,18 @@ func Mkdir(path string, mode uint32) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall(SYS_MKDIR, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_mkdir_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_mkdir_trampoline()
+
+//go:linkname libc_mkdir libc_mkdir
+//go:cgo_import_dynamic libc_mkdir mkdir "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Mkdirat(dirfd int, path string, mode uint32) (err error) {
@@ -1126,13 +1529,18 @@ func Mkdirat(dirfd int, path string, mode uint32) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall(SYS_MKDIRAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode))
+ _, _, e1 := syscall_syscall(funcPC(libc_mkdirat_trampoline), uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_mkdirat_trampoline()
+
+//go:linkname libc_mkdirat libc_mkdirat
+//go:cgo_import_dynamic libc_mkdirat mkdirat "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Mkfifo(path string, mode uint32) (err error) {
@@ -1141,13 +1549,18 @@ func Mkfifo(path string, mode uint32) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall(SYS_MKFIFO, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_mkfifo_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_mkfifo_trampoline()
+
+//go:linkname libc_mkfifo libc_mkfifo
+//go:cgo_import_dynamic libc_mkfifo mkfifo "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Mknod(path string, mode uint32, dev int) (err error) {
@@ -1156,13 +1569,18 @@ func Mknod(path string, mode uint32, dev int) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall(SYS_MKNOD, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(dev))
+ _, _, e1 := syscall_syscall(funcPC(libc_mknod_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(dev))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_mknod_trampoline()
+
+//go:linkname libc_mknod libc_mknod
+//go:cgo_import_dynamic libc_mknod mknod "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Open(path string, mode int, perm uint32) (fd int, err error) {
@@ -1171,7 +1589,7 @@ func Open(path string, mode int, perm uint32) (fd int, err error) {
if err != nil {
return
}
- r0, _, e1 := Syscall(SYS_OPEN, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(perm))
+ r0, _, e1 := syscall_syscall(funcPC(libc_open_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(perm))
fd = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -1179,6 +1597,11 @@ func Open(path string, mode int, perm uint32) (fd int, err error) {
return
}
+func libc_open_trampoline()
+
+//go:linkname libc_open libc_open
+//go:cgo_import_dynamic libc_open open "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Openat(dirfd int, path string, mode int, perm uint32) (fd int, err error) {
@@ -1187,7 +1610,7 @@ func Openat(dirfd int, path string, mode int, perm uint32) (fd int, err error) {
if err != nil {
return
}
- r0, _, e1 := Syscall6(SYS_OPENAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(perm), 0, 0)
+ r0, _, e1 := syscall_syscall6(funcPC(libc_openat_trampoline), uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(perm), 0, 0)
fd = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -1195,6 +1618,11 @@ func Openat(dirfd int, path string, mode int, perm uint32) (fd int, err error) {
return
}
+func libc_openat_trampoline()
+
+//go:linkname libc_openat libc_openat
+//go:cgo_import_dynamic libc_openat openat "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Pathconf(path string, name int) (val int, err error) {
@@ -1203,7 +1631,7 @@ func Pathconf(path string, name int) (val int, err error) {
if err != nil {
return
}
- r0, _, e1 := Syscall(SYS_PATHCONF, uintptr(unsafe.Pointer(_p0)), uintptr(name), 0)
+ r0, _, e1 := syscall_syscall(funcPC(libc_pathconf_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(name), 0)
val = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -1211,6 +1639,11 @@ func Pathconf(path string, name int) (val int, err error) {
return
}
+func libc_pathconf_trampoline()
+
+//go:linkname libc_pathconf libc_pathconf
+//go:cgo_import_dynamic libc_pathconf pathconf "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Pread(fd int, p []byte, offset int64) (n int, err error) {
@@ -1220,7 +1653,7 @@ func Pread(fd int, p []byte, offset int64) (n int, err error) {
} else {
_p0 = unsafe.Pointer(&_zero)
}
- r0, _, e1 := Syscall6(SYS_PREAD, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), uintptr(offset>>32), 0)
+ r0, _, e1 := syscall_syscall6(funcPC(libc_pread_trampoline), uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), uintptr(offset>>32), 0)
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -1228,6 +1661,11 @@ func Pread(fd int, p []byte, offset int64) (n int, err error) {
return
}
+func libc_pread_trampoline()
+
+//go:linkname libc_pread libc_pread
+//go:cgo_import_dynamic libc_pread pread "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Pwrite(fd int, p []byte, offset int64) (n int, err error) {
@@ -1237,7 +1675,7 @@ func Pwrite(fd int, p []byte, offset int64) (n int, err error) {
} else {
_p0 = unsafe.Pointer(&_zero)
}
- r0, _, e1 := Syscall6(SYS_PWRITE, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), uintptr(offset>>32), 0)
+ r0, _, e1 := syscall_syscall6(funcPC(libc_pwrite_trampoline), uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), uintptr(offset>>32), 0)
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -1245,6 +1683,11 @@ func Pwrite(fd int, p []byte, offset int64) (n int, err error) {
return
}
+func libc_pwrite_trampoline()
+
+//go:linkname libc_pwrite libc_pwrite
+//go:cgo_import_dynamic libc_pwrite pwrite "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func read(fd int, p []byte) (n int, err error) {
@@ -1254,7 +1697,7 @@ func read(fd int, p []byte) (n int, err error) {
} else {
_p0 = unsafe.Pointer(&_zero)
}
- r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(_p0), uintptr(len(p)))
+ r0, _, e1 := syscall_syscall(funcPC(libc_read_trampoline), uintptr(fd), uintptr(_p0), uintptr(len(p)))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -1262,6 +1705,11 @@ func read(fd int, p []byte) (n int, err error) {
return
}
+func libc_read_trampoline()
+
+//go:linkname libc_read libc_read
+//go:cgo_import_dynamic libc_read read "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Readlink(path string, buf []byte) (n int, err error) {
@@ -1276,7 +1724,7 @@ func Readlink(path string, buf []byte) (n int, err error) {
} else {
_p1 = unsafe.Pointer(&_zero)
}
- r0, _, e1 := Syscall(SYS_READLINK, uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(buf)))
+ r0, _, e1 := syscall_syscall(funcPC(libc_readlink_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(buf)))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -1284,6 +1732,11 @@ func Readlink(path string, buf []byte) (n int, err error) {
return
}
+func libc_readlink_trampoline()
+
+//go:linkname libc_readlink libc_readlink
+//go:cgo_import_dynamic libc_readlink readlink "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Readlinkat(dirfd int, path string, buf []byte) (n int, err error) {
@@ -1298,7 +1751,7 @@ func Readlinkat(dirfd int, path string, buf []byte) (n int, err error) {
} else {
_p1 = unsafe.Pointer(&_zero)
}
- r0, _, e1 := Syscall6(SYS_READLINKAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(buf)), 0, 0)
+ r0, _, e1 := syscall_syscall6(funcPC(libc_readlinkat_trampoline), uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(buf)), 0, 0)
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -1306,6 +1759,11 @@ func Readlinkat(dirfd int, path string, buf []byte) (n int, err error) {
return
}
+func libc_readlinkat_trampoline()
+
+//go:linkname libc_readlinkat libc_readlinkat
+//go:cgo_import_dynamic libc_readlinkat readlinkat "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Rename(from string, to string) (err error) {
@@ -1319,13 +1777,18 @@ func Rename(from string, to string) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall(SYS_RENAME, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_rename_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_rename_trampoline()
+
+//go:linkname libc_rename libc_rename
+//go:cgo_import_dynamic libc_rename rename "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Renameat(fromfd int, from string, tofd int, to string) (err error) {
@@ -1339,13 +1802,18 @@ func Renameat(fromfd int, from string, tofd int, to string) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall6(SYS_RENAMEAT, uintptr(fromfd), uintptr(unsafe.Pointer(_p0)), uintptr(tofd), uintptr(unsafe.Pointer(_p1)), 0, 0)
+ _, _, e1 := syscall_syscall6(funcPC(libc_renameat_trampoline), uintptr(fromfd), uintptr(unsafe.Pointer(_p0)), uintptr(tofd), uintptr(unsafe.Pointer(_p1)), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_renameat_trampoline()
+
+//go:linkname libc_renameat libc_renameat
+//go:cgo_import_dynamic libc_renameat renameat "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Revoke(path string) (err error) {
@@ -1354,13 +1822,18 @@ func Revoke(path string) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall(SYS_REVOKE, uintptr(unsafe.Pointer(_p0)), 0, 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_revoke_trampoline), uintptr(unsafe.Pointer(_p0)), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_revoke_trampoline()
+
+//go:linkname libc_revoke libc_revoke
+//go:cgo_import_dynamic libc_revoke revoke "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Rmdir(path string) (err error) {
@@ -1369,17 +1842,22 @@ func Rmdir(path string) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall(SYS_RMDIR, uintptr(unsafe.Pointer(_p0)), 0, 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_rmdir_trampoline), uintptr(unsafe.Pointer(_p0)), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_rmdir_trampoline()
+
+//go:linkname libc_rmdir libc_rmdir
+//go:cgo_import_dynamic libc_rmdir rmdir "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Seek(fd int, offset int64, whence int) (newoffset int64, err error) {
- r0, r1, e1 := Syscall6(SYS_LSEEK, uintptr(fd), uintptr(offset), uintptr(offset>>32), uintptr(whence), 0, 0)
+ r0, r1, e1 := syscall_syscall6(funcPC(libc_lseek_trampoline), uintptr(fd), uintptr(offset), uintptr(offset>>32), uintptr(whence), 0, 0)
newoffset = int64(int64(r1)<<32 | int64(r0))
if e1 != 0 {
err = errnoErr(e1)
@@ -1387,46 +1865,71 @@ func Seek(fd int, offset int64, whence int) (newoffset int64, err error) {
return
}
+func libc_lseek_trampoline()
+
+//go:linkname libc_lseek libc_lseek
+//go:cgo_import_dynamic libc_lseek lseek "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Select(n int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (err error) {
- _, _, e1 := Syscall6(SYS_SELECT, uintptr(n), uintptr(unsafe.Pointer(r)), uintptr(unsafe.Pointer(w)), uintptr(unsafe.Pointer(e)), uintptr(unsafe.Pointer(timeout)), 0)
+ _, _, e1 := syscall_syscall6(funcPC(libc_select_trampoline), uintptr(n), uintptr(unsafe.Pointer(r)), uintptr(unsafe.Pointer(w)), uintptr(unsafe.Pointer(e)), uintptr(unsafe.Pointer(timeout)), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_select_trampoline()
+
+//go:linkname libc_select libc_select
+//go:cgo_import_dynamic libc_select select "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Setegid(egid int) (err error) {
- _, _, e1 := Syscall(SYS_SETEGID, uintptr(egid), 0, 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_setegid_trampoline), uintptr(egid), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_setegid_trampoline()
+
+//go:linkname libc_setegid libc_setegid
+//go:cgo_import_dynamic libc_setegid setegid "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Seteuid(euid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETEUID, uintptr(euid), 0, 0)
+ _, _, e1 := syscall_rawSyscall(funcPC(libc_seteuid_trampoline), uintptr(euid), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_seteuid_trampoline()
+
+//go:linkname libc_seteuid libc_seteuid
+//go:cgo_import_dynamic libc_seteuid seteuid "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Setgid(gid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETGID, uintptr(gid), 0, 0)
+ _, _, e1 := syscall_rawSyscall(funcPC(libc_setgid_trampoline), uintptr(gid), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_setgid_trampoline()
+
+//go:linkname libc_setgid libc_setgid
+//go:cgo_import_dynamic libc_setgid setgid "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Setlogin(name string) (err error) {
@@ -1435,77 +1938,112 @@ func Setlogin(name string) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall(SYS_SETLOGIN, uintptr(unsafe.Pointer(_p0)), 0, 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_setlogin_trampoline), uintptr(unsafe.Pointer(_p0)), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_setlogin_trampoline()
+
+//go:linkname libc_setlogin libc_setlogin
+//go:cgo_import_dynamic libc_setlogin setlogin "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Setpgid(pid int, pgid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETPGID, uintptr(pid), uintptr(pgid), 0)
+ _, _, e1 := syscall_rawSyscall(funcPC(libc_setpgid_trampoline), uintptr(pid), uintptr(pgid), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_setpgid_trampoline()
+
+//go:linkname libc_setpgid libc_setpgid
+//go:cgo_import_dynamic libc_setpgid setpgid "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Setpriority(which int, who int, prio int) (err error) {
- _, _, e1 := Syscall(SYS_SETPRIORITY, uintptr(which), uintptr(who), uintptr(prio))
+ _, _, e1 := syscall_syscall(funcPC(libc_setpriority_trampoline), uintptr(which), uintptr(who), uintptr(prio))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_setpriority_trampoline()
+
+//go:linkname libc_setpriority libc_setpriority
+//go:cgo_import_dynamic libc_setpriority setpriority "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Setprivexec(flag int) (err error) {
- _, _, e1 := Syscall(SYS_SETPRIVEXEC, uintptr(flag), 0, 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_setprivexec_trampoline), uintptr(flag), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_setprivexec_trampoline()
+
+//go:linkname libc_setprivexec libc_setprivexec
+//go:cgo_import_dynamic libc_setprivexec setprivexec "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Setregid(rgid int, egid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETREGID, uintptr(rgid), uintptr(egid), 0)
+ _, _, e1 := syscall_rawSyscall(funcPC(libc_setregid_trampoline), uintptr(rgid), uintptr(egid), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_setregid_trampoline()
+
+//go:linkname libc_setregid libc_setregid
+//go:cgo_import_dynamic libc_setregid setregid "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Setreuid(ruid int, euid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETREUID, uintptr(ruid), uintptr(euid), 0)
+ _, _, e1 := syscall_rawSyscall(funcPC(libc_setreuid_trampoline), uintptr(ruid), uintptr(euid), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_setreuid_trampoline()
+
+//go:linkname libc_setreuid libc_setreuid
+//go:cgo_import_dynamic libc_setreuid setreuid "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Setrlimit(which int, lim *Rlimit) (err error) {
- _, _, e1 := RawSyscall(SYS_SETRLIMIT, uintptr(which), uintptr(unsafe.Pointer(lim)), 0)
+ _, _, e1 := syscall_rawSyscall(funcPC(libc_setrlimit_trampoline), uintptr(which), uintptr(unsafe.Pointer(lim)), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_setrlimit_trampoline()
+
+//go:linkname libc_setrlimit libc_setrlimit
+//go:cgo_import_dynamic libc_setrlimit setrlimit "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Setsid() (pid int, err error) {
- r0, _, e1 := RawSyscall(SYS_SETSID, 0, 0, 0)
+ r0, _, e1 := syscall_rawSyscall(funcPC(libc_setsid_trampoline), 0, 0, 0)
pid = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -1513,55 +2051,40 @@ func Setsid() (pid int, err error) {
return
}
+func libc_setsid_trampoline()
+
+//go:linkname libc_setsid libc_setsid
+//go:cgo_import_dynamic libc_setsid setsid "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Settimeofday(tp *Timeval) (err error) {
- _, _, e1 := RawSyscall(SYS_SETTIMEOFDAY, uintptr(unsafe.Pointer(tp)), 0, 0)
+ _, _, e1 := syscall_rawSyscall(funcPC(libc_settimeofday_trampoline), uintptr(unsafe.Pointer(tp)), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+func libc_settimeofday_trampoline()
-func Setuid(uid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETUID, uintptr(uid), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
+//go:linkname libc_settimeofday libc_settimeofday
+//go:cgo_import_dynamic libc_settimeofday settimeofday "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-func Stat(path string, stat *Stat_t) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_STAT64, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
+func Setuid(uid int) (err error) {
+ _, _, e1 := syscall_rawSyscall(funcPC(libc_setuid_trampoline), uintptr(uid), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+func libc_setuid_trampoline()
-func Statfs(path string, stat *Statfs_t) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_STATFS64, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
+//go:linkname libc_setuid libc_setuid
+//go:cgo_import_dynamic libc_setuid setuid "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
@@ -1576,13 +2099,18 @@ func Symlink(path string, link string) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall(SYS_SYMLINK, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_symlink_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_symlink_trampoline()
+
+//go:linkname libc_symlink libc_symlink
+//go:cgo_import_dynamic libc_symlink symlink "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Symlinkat(oldpath string, newdirfd int, newpath string) (err error) {
@@ -1596,23 +2124,33 @@ func Symlinkat(oldpath string, newdirfd int, newpath string) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall(SYS_SYMLINKAT, uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1)))
+ _, _, e1 := syscall_syscall(funcPC(libc_symlinkat_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1)))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_symlinkat_trampoline()
+
+//go:linkname libc_symlinkat libc_symlinkat
+//go:cgo_import_dynamic libc_symlinkat symlinkat "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Sync() (err error) {
- _, _, e1 := Syscall(SYS_SYNC, 0, 0, 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_sync_trampoline), 0, 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_sync_trampoline()
+
+//go:linkname libc_sync libc_sync
+//go:cgo_import_dynamic libc_sync sync "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Truncate(path string, length int64) (err error) {
@@ -1621,21 +2159,31 @@ func Truncate(path string, length int64) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall(SYS_TRUNCATE, uintptr(unsafe.Pointer(_p0)), uintptr(length), uintptr(length>>32))
+ _, _, e1 := syscall_syscall(funcPC(libc_truncate_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(length), uintptr(length>>32))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_truncate_trampoline()
+
+//go:linkname libc_truncate libc_truncate
+//go:cgo_import_dynamic libc_truncate truncate "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Umask(newmask int) (oldmask int) {
- r0, _, _ := Syscall(SYS_UMASK, uintptr(newmask), 0, 0)
+ r0, _, _ := syscall_syscall(funcPC(libc_umask_trampoline), uintptr(newmask), 0, 0)
oldmask = int(r0)
return
}
+func libc_umask_trampoline()
+
+//go:linkname libc_umask libc_umask
+//go:cgo_import_dynamic libc_umask umask "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Undelete(path string) (err error) {
@@ -1644,13 +2192,18 @@ func Undelete(path string) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall(SYS_UNDELETE, uintptr(unsafe.Pointer(_p0)), 0, 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_undelete_trampoline), uintptr(unsafe.Pointer(_p0)), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_undelete_trampoline()
+
+//go:linkname libc_undelete libc_undelete
+//go:cgo_import_dynamic libc_undelete undelete "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Unlink(path string) (err error) {
@@ -1659,13 +2212,18 @@ func Unlink(path string) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall(SYS_UNLINK, uintptr(unsafe.Pointer(_p0)), 0, 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_unlink_trampoline), uintptr(unsafe.Pointer(_p0)), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_unlink_trampoline()
+
+//go:linkname libc_unlink libc_unlink
+//go:cgo_import_dynamic libc_unlink unlink "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Unlinkat(dirfd int, path string, flags int) (err error) {
@@ -1674,13 +2232,18 @@ func Unlinkat(dirfd int, path string, flags int) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall(SYS_UNLINKAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(flags))
+ _, _, e1 := syscall_syscall(funcPC(libc_unlinkat_trampoline), uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(flags))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_unlinkat_trampoline()
+
+//go:linkname libc_unlinkat libc_unlinkat
+//go:cgo_import_dynamic libc_unlinkat unlinkat "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Unmount(path string, flags int) (err error) {
@@ -1689,13 +2252,18 @@ func Unmount(path string, flags int) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall(SYS_UNMOUNT, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_unmount_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_unmount_trampoline()
+
+//go:linkname libc_unmount libc_unmount
+//go:cgo_import_dynamic libc_unmount unmount "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func write(fd int, p []byte) (n int, err error) {
@@ -1705,7 +2273,7 @@ func write(fd int, p []byte) (n int, err error) {
} else {
_p0 = unsafe.Pointer(&_zero)
}
- r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(_p0), uintptr(len(p)))
+ r0, _, e1 := syscall_syscall(funcPC(libc_write_trampoline), uintptr(fd), uintptr(_p0), uintptr(len(p)))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -1713,10 +2281,15 @@ func write(fd int, p []byte) (n int, err error) {
return
}
+func libc_write_trampoline()
+
+//go:linkname libc_write libc_write
+//go:cgo_import_dynamic libc_write write "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error) {
- r0, _, e1 := Syscall9(SYS_MMAP, uintptr(addr), uintptr(length), uintptr(prot), uintptr(flag), uintptr(fd), uintptr(pos), uintptr(pos>>32), 0, 0)
+ r0, _, e1 := syscall_syscall9(funcPC(libc_mmap_trampoline), uintptr(addr), uintptr(length), uintptr(prot), uintptr(flag), uintptr(fd), uintptr(pos), uintptr(pos>>32), 0, 0)
ret = uintptr(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -1724,20 +2297,30 @@ func mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (
return
}
+func libc_mmap_trampoline()
+
+//go:linkname libc_mmap libc_mmap
+//go:cgo_import_dynamic libc_mmap mmap "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func munmap(addr uintptr, length uintptr) (err error) {
- _, _, e1 := Syscall(SYS_MUNMAP, uintptr(addr), uintptr(length), 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_munmap_trampoline), uintptr(addr), uintptr(length), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_munmap_trampoline()
+
+//go:linkname libc_munmap libc_munmap
+//go:cgo_import_dynamic libc_munmap munmap "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func readlen(fd int, buf *byte, nbuf int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf))
+ r0, _, e1 := syscall_syscall(funcPC(libc_read_trampoline), uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -1748,7 +2331,7 @@ func readlen(fd int, buf *byte, nbuf int) (n int, err error) {
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func writelen(fd int, buf *byte, nbuf int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf))
+ r0, _, e1 := syscall_syscall(funcPC(libc_write_trampoline), uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -1759,7 +2342,7 @@ func writelen(fd int, buf *byte, nbuf int) (n int, err error) {
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func gettimeofday(tp *Timeval) (sec int32, usec int32, err error) {
- r0, r1, e1 := RawSyscall(SYS_GETTIMEOFDAY, uintptr(unsafe.Pointer(tp)), 0, 0)
+ r0, r1, e1 := syscall_rawSyscall(funcPC(libc_gettimeofday_trampoline), uintptr(unsafe.Pointer(tp)), 0, 0)
sec = int32(r0)
usec = int32(r1)
if e1 != 0 {
@@ -1767,3 +2350,134 @@ func gettimeofday(tp *Timeval) (sec int32, usec int32, err error) {
}
return
}
+
+func libc_gettimeofday_trampoline()
+
+//go:linkname libc_gettimeofday libc_gettimeofday
+//go:cgo_import_dynamic libc_gettimeofday gettimeofday "/usr/lib/libSystem.B.dylib"
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Fstat(fd int, stat *Stat_t) (err error) {
+ _, _, e1 := syscall_syscall(funcPC(libc_fstat_trampoline), uintptr(fd), uintptr(unsafe.Pointer(stat)), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func libc_fstat_trampoline()
+
+//go:linkname libc_fstat libc_fstat
+//go:cgo_import_dynamic libc_fstat fstat "/usr/lib/libSystem.B.dylib"
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Fstatat(fd int, path string, stat *Stat_t, flags int) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := syscall_syscall6(funcPC(libc_fstatat_trampoline), uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), uintptr(flags), 0, 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func libc_fstatat_trampoline()
+
+//go:linkname libc_fstatat libc_fstatat
+//go:cgo_import_dynamic libc_fstatat fstatat "/usr/lib/libSystem.B.dylib"
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Fstatfs(fd int, stat *Statfs_t) (err error) {
+ _, _, e1 := syscall_syscall(funcPC(libc_fstatfs_trampoline), uintptr(fd), uintptr(unsafe.Pointer(stat)), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func libc_fstatfs_trampoline()
+
+//go:linkname libc_fstatfs libc_fstatfs
+//go:cgo_import_dynamic libc_fstatfs fstatfs "/usr/lib/libSystem.B.dylib"
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func getfsstat(buf unsafe.Pointer, size uintptr, flags int) (n int, err error) {
+ r0, _, e1 := syscall_syscall(funcPC(libc_getfsstat_trampoline), uintptr(buf), uintptr(size), uintptr(flags))
+ n = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func libc_getfsstat_trampoline()
+
+//go:linkname libc_getfsstat libc_getfsstat
+//go:cgo_import_dynamic libc_getfsstat getfsstat "/usr/lib/libSystem.B.dylib"
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Lstat(path string, stat *Stat_t) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := syscall_syscall(funcPC(libc_lstat_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func libc_lstat_trampoline()
+
+//go:linkname libc_lstat libc_lstat
+//go:cgo_import_dynamic libc_lstat lstat "/usr/lib/libSystem.B.dylib"
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Stat(path string, stat *Stat_t) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := syscall_syscall(funcPC(libc_stat_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func libc_stat_trampoline()
+
+//go:linkname libc_stat libc_stat
+//go:cgo_import_dynamic libc_stat stat "/usr/lib/libSystem.B.dylib"
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Statfs(path string, stat *Statfs_t) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := syscall_syscall(funcPC(libc_statfs_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func libc_statfs_trampoline()
+
+//go:linkname libc_statfs libc_statfs
+//go:cgo_import_dynamic libc_statfs statfs "/usr/lib/libSystem.B.dylib"
diff --git a/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm.s b/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm.s
new file mode 100644
index 000000000..994056f35
--- /dev/null
+++ b/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm.s
@@ -0,0 +1,282 @@
+// go run mkasm_darwin.go arm
+// Code generated by the command above; DO NOT EDIT.
+
+// +build go1.12
+
+#include "textflag.h"
+TEXT ·libc_getgroups_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_getgroups(SB)
+TEXT ·libc_setgroups_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_setgroups(SB)
+TEXT ·libc_wait4_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_wait4(SB)
+TEXT ·libc_accept_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_accept(SB)
+TEXT ·libc_bind_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_bind(SB)
+TEXT ·libc_connect_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_connect(SB)
+TEXT ·libc_socket_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_socket(SB)
+TEXT ·libc_getsockopt_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_getsockopt(SB)
+TEXT ·libc_setsockopt_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_setsockopt(SB)
+TEXT ·libc_getpeername_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_getpeername(SB)
+TEXT ·libc_getsockname_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_getsockname(SB)
+TEXT ·libc_shutdown_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_shutdown(SB)
+TEXT ·libc_socketpair_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_socketpair(SB)
+TEXT ·libc_recvfrom_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_recvfrom(SB)
+TEXT ·libc_sendto_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_sendto(SB)
+TEXT ·libc_recvmsg_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_recvmsg(SB)
+TEXT ·libc_sendmsg_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_sendmsg(SB)
+TEXT ·libc_kevent_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_kevent(SB)
+TEXT ·libc___sysctl_trampoline(SB),NOSPLIT,$0-0
+ JMP libc___sysctl(SB)
+TEXT ·libc_utimes_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_utimes(SB)
+TEXT ·libc_futimes_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_futimes(SB)
+TEXT ·libc_fcntl_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_fcntl(SB)
+TEXT ·libc_poll_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_poll(SB)
+TEXT ·libc_madvise_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_madvise(SB)
+TEXT ·libc_mlock_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_mlock(SB)
+TEXT ·libc_mlockall_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_mlockall(SB)
+TEXT ·libc_mprotect_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_mprotect(SB)
+TEXT ·libc_msync_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_msync(SB)
+TEXT ·libc_munlock_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_munlock(SB)
+TEXT ·libc_munlockall_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_munlockall(SB)
+TEXT ·libc_ptrace_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_ptrace(SB)
+TEXT ·libc_getattrlist_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_getattrlist(SB)
+TEXT ·libc_pipe_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_pipe(SB)
+TEXT ·libc_getxattr_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_getxattr(SB)
+TEXT ·libc_fgetxattr_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_fgetxattr(SB)
+TEXT ·libc_setxattr_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_setxattr(SB)
+TEXT ·libc_fsetxattr_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_fsetxattr(SB)
+TEXT ·libc_removexattr_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_removexattr(SB)
+TEXT ·libc_fremovexattr_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_fremovexattr(SB)
+TEXT ·libc_listxattr_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_listxattr(SB)
+TEXT ·libc_flistxattr_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_flistxattr(SB)
+TEXT ·libc_setattrlist_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_setattrlist(SB)
+TEXT ·libc_kill_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_kill(SB)
+TEXT ·libc_ioctl_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_ioctl(SB)
+TEXT ·libc_sendfile_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_sendfile(SB)
+TEXT ·libc_access_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_access(SB)
+TEXT ·libc_adjtime_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_adjtime(SB)
+TEXT ·libc_chdir_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_chdir(SB)
+TEXT ·libc_chflags_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_chflags(SB)
+TEXT ·libc_chmod_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_chmod(SB)
+TEXT ·libc_chown_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_chown(SB)
+TEXT ·libc_chroot_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_chroot(SB)
+TEXT ·libc_close_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_close(SB)
+TEXT ·libc_dup_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_dup(SB)
+TEXT ·libc_dup2_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_dup2(SB)
+TEXT ·libc_exchangedata_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_exchangedata(SB)
+TEXT ·libc_exit_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_exit(SB)
+TEXT ·libc_faccessat_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_faccessat(SB)
+TEXT ·libc_fchdir_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_fchdir(SB)
+TEXT ·libc_fchflags_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_fchflags(SB)
+TEXT ·libc_fchmod_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_fchmod(SB)
+TEXT ·libc_fchmodat_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_fchmodat(SB)
+TEXT ·libc_fchown_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_fchown(SB)
+TEXT ·libc_fchownat_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_fchownat(SB)
+TEXT ·libc_flock_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_flock(SB)
+TEXT ·libc_fpathconf_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_fpathconf(SB)
+TEXT ·libc_fsync_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_fsync(SB)
+TEXT ·libc_ftruncate_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_ftruncate(SB)
+TEXT ·libc_getdtablesize_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_getdtablesize(SB)
+TEXT ·libc_getegid_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_getegid(SB)
+TEXT ·libc_geteuid_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_geteuid(SB)
+TEXT ·libc_getgid_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_getgid(SB)
+TEXT ·libc_getpgid_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_getpgid(SB)
+TEXT ·libc_getpgrp_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_getpgrp(SB)
+TEXT ·libc_getpid_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_getpid(SB)
+TEXT ·libc_getppid_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_getppid(SB)
+TEXT ·libc_getpriority_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_getpriority(SB)
+TEXT ·libc_getrlimit_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_getrlimit(SB)
+TEXT ·libc_getrusage_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_getrusage(SB)
+TEXT ·libc_getsid_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_getsid(SB)
+TEXT ·libc_getuid_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_getuid(SB)
+TEXT ·libc_issetugid_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_issetugid(SB)
+TEXT ·libc_kqueue_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_kqueue(SB)
+TEXT ·libc_lchown_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_lchown(SB)
+TEXT ·libc_link_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_link(SB)
+TEXT ·libc_linkat_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_linkat(SB)
+TEXT ·libc_listen_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_listen(SB)
+TEXT ·libc_mkdir_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_mkdir(SB)
+TEXT ·libc_mkdirat_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_mkdirat(SB)
+TEXT ·libc_mkfifo_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_mkfifo(SB)
+TEXT ·libc_mknod_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_mknod(SB)
+TEXT ·libc_open_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_open(SB)
+TEXT ·libc_openat_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_openat(SB)
+TEXT ·libc_pathconf_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_pathconf(SB)
+TEXT ·libc_pread_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_pread(SB)
+TEXT ·libc_pwrite_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_pwrite(SB)
+TEXT ·libc_read_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_read(SB)
+TEXT ·libc_readlink_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_readlink(SB)
+TEXT ·libc_readlinkat_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_readlinkat(SB)
+TEXT ·libc_rename_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_rename(SB)
+TEXT ·libc_renameat_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_renameat(SB)
+TEXT ·libc_revoke_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_revoke(SB)
+TEXT ·libc_rmdir_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_rmdir(SB)
+TEXT ·libc_lseek_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_lseek(SB)
+TEXT ·libc_select_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_select(SB)
+TEXT ·libc_setegid_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_setegid(SB)
+TEXT ·libc_seteuid_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_seteuid(SB)
+TEXT ·libc_setgid_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_setgid(SB)
+TEXT ·libc_setlogin_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_setlogin(SB)
+TEXT ·libc_setpgid_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_setpgid(SB)
+TEXT ·libc_setpriority_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_setpriority(SB)
+TEXT ·libc_setprivexec_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_setprivexec(SB)
+TEXT ·libc_setregid_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_setregid(SB)
+TEXT ·libc_setreuid_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_setreuid(SB)
+TEXT ·libc_setrlimit_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_setrlimit(SB)
+TEXT ·libc_setsid_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_setsid(SB)
+TEXT ·libc_settimeofday_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_settimeofday(SB)
+TEXT ·libc_setuid_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_setuid(SB)
+TEXT ·libc_symlink_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_symlink(SB)
+TEXT ·libc_symlinkat_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_symlinkat(SB)
+TEXT ·libc_sync_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_sync(SB)
+TEXT ·libc_truncate_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_truncate(SB)
+TEXT ·libc_umask_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_umask(SB)
+TEXT ·libc_undelete_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_undelete(SB)
+TEXT ·libc_unlink_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_unlink(SB)
+TEXT ·libc_unlinkat_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_unlinkat(SB)
+TEXT ·libc_unmount_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_unmount(SB)
+TEXT ·libc_write_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_write(SB)
+TEXT ·libc_mmap_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_mmap(SB)
+TEXT ·libc_munmap_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_munmap(SB)
+TEXT ·libc_gettimeofday_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_gettimeofday(SB)
+TEXT ·libc_fstat_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_fstat(SB)
+TEXT ·libc_fstatat_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_fstatat(SB)
+TEXT ·libc_fstatfs_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_fstatfs(SB)
+TEXT ·libc_getfsstat_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_getfsstat(SB)
+TEXT ·libc_lstat_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_lstat(SB)
+TEXT ·libc_stat_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_stat(SB)
+TEXT ·libc_statfs_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_statfs(SB)
diff --git a/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.1_11.go b/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.1_11.go
new file mode 100644
index 000000000..3fd0f3c85
--- /dev/null
+++ b/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.1_11.go
@@ -0,0 +1,1793 @@
+// go run mksyscall.go -tags darwin,arm64,!go1.12 syscall_bsd.go syscall_darwin.go syscall_darwin_arm64.go
+// Code generated by the command above; see README.md. DO NOT EDIT.
+
+// +build darwin,arm64,!go1.12
+
+package unix
+
+import (
+ "syscall"
+ "unsafe"
+)
+
+var _ syscall.Errno
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func getgroups(ngid int, gid *_Gid_t) (n int, err error) {
+ r0, _, e1 := RawSyscall(SYS_GETGROUPS, uintptr(ngid), uintptr(unsafe.Pointer(gid)), 0)
+ n = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func setgroups(ngid int, gid *_Gid_t) (err error) {
+ _, _, e1 := RawSyscall(SYS_SETGROUPS, uintptr(ngid), uintptr(unsafe.Pointer(gid)), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func wait4(pid int, wstatus *_C_int, options int, rusage *Rusage) (wpid int, err error) {
+ r0, _, e1 := Syscall6(SYS_WAIT4, uintptr(pid), uintptr(unsafe.Pointer(wstatus)), uintptr(options), uintptr(unsafe.Pointer(rusage)), 0, 0)
+ wpid = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) {
+ r0, _, e1 := Syscall(SYS_ACCEPT, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
+ fd = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) {
+ _, _, e1 := Syscall(SYS_BIND, uintptr(s), uintptr(addr), uintptr(addrlen))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) {
+ _, _, e1 := Syscall(SYS_CONNECT, uintptr(s), uintptr(addr), uintptr(addrlen))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func socket(domain int, typ int, proto int) (fd int, err error) {
+ r0, _, e1 := RawSyscall(SYS_SOCKET, uintptr(domain), uintptr(typ), uintptr(proto))
+ fd = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) {
+ _, _, e1 := Syscall6(SYS_GETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(unsafe.Pointer(vallen)), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) {
+ _, _, e1 := Syscall6(SYS_SETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(vallen), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) {
+ _, _, e1 := RawSyscall(SYS_GETPEERNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) {
+ _, _, e1 := RawSyscall(SYS_GETSOCKNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Shutdown(s int, how int) (err error) {
+ _, _, e1 := Syscall(SYS_SHUTDOWN, uintptr(s), uintptr(how), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) {
+ _, _, e1 := RawSyscall6(SYS_SOCKETPAIR, uintptr(domain), uintptr(typ), uintptr(proto), uintptr(unsafe.Pointer(fd)), 0, 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) {
+ var _p0 unsafe.Pointer
+ if len(p) > 0 {
+ _p0 = unsafe.Pointer(&p[0])
+ } else {
+ _p0 = unsafe.Pointer(&_zero)
+ }
+ r0, _, e1 := Syscall6(SYS_RECVFROM, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(flags), uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(fromlen)))
+ n = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) {
+ var _p0 unsafe.Pointer
+ if len(buf) > 0 {
+ _p0 = unsafe.Pointer(&buf[0])
+ } else {
+ _p0 = unsafe.Pointer(&_zero)
+ }
+ _, _, e1 := Syscall6(SYS_SENDTO, uintptr(s), uintptr(_p0), uintptr(len(buf)), uintptr(flags), uintptr(to), uintptr(addrlen))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func recvmsg(s int, msg *Msghdr, flags int) (n int, err error) {
+ r0, _, e1 := Syscall(SYS_RECVMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags))
+ n = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func sendmsg(s int, msg *Msghdr, flags int) (n int, err error) {
+ r0, _, e1 := Syscall(SYS_SENDMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags))
+ n = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func kevent(kq int, change unsafe.Pointer, nchange int, event unsafe.Pointer, nevent int, timeout *Timespec) (n int, err error) {
+ r0, _, e1 := Syscall6(SYS_KEVENT, uintptr(kq), uintptr(change), uintptr(nchange), uintptr(event), uintptr(nevent), uintptr(unsafe.Pointer(timeout)))
+ n = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) {
+ var _p0 unsafe.Pointer
+ if len(mib) > 0 {
+ _p0 = unsafe.Pointer(&mib[0])
+ } else {
+ _p0 = unsafe.Pointer(&_zero)
+ }
+ _, _, e1 := Syscall6(SYS___SYSCTL, uintptr(_p0), uintptr(len(mib)), uintptr(unsafe.Pointer(old)), uintptr(unsafe.Pointer(oldlen)), uintptr(unsafe.Pointer(new)), uintptr(newlen))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func utimes(path string, timeval *[2]Timeval) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_UTIMES, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(timeval)), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func futimes(fd int, timeval *[2]Timeval) (err error) {
+ _, _, e1 := Syscall(SYS_FUTIMES, uintptr(fd), uintptr(unsafe.Pointer(timeval)), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func fcntl(fd int, cmd int, arg int) (val int, err error) {
+ r0, _, e1 := Syscall(SYS_FCNTL, uintptr(fd), uintptr(cmd), uintptr(arg))
+ val = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func poll(fds *PollFd, nfds int, timeout int) (n int, err error) {
+ r0, _, e1 := Syscall(SYS_POLL, uintptr(unsafe.Pointer(fds)), uintptr(nfds), uintptr(timeout))
+ n = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Madvise(b []byte, behav int) (err error) {
+ var _p0 unsafe.Pointer
+ if len(b) > 0 {
+ _p0 = unsafe.Pointer(&b[0])
+ } else {
+ _p0 = unsafe.Pointer(&_zero)
+ }
+ _, _, e1 := Syscall(SYS_MADVISE, uintptr(_p0), uintptr(len(b)), uintptr(behav))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Mlock(b []byte) (err error) {
+ var _p0 unsafe.Pointer
+ if len(b) > 0 {
+ _p0 = unsafe.Pointer(&b[0])
+ } else {
+ _p0 = unsafe.Pointer(&_zero)
+ }
+ _, _, e1 := Syscall(SYS_MLOCK, uintptr(_p0), uintptr(len(b)), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Mlockall(flags int) (err error) {
+ _, _, e1 := Syscall(SYS_MLOCKALL, uintptr(flags), 0, 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Mprotect(b []byte, prot int) (err error) {
+ var _p0 unsafe.Pointer
+ if len(b) > 0 {
+ _p0 = unsafe.Pointer(&b[0])
+ } else {
+ _p0 = unsafe.Pointer(&_zero)
+ }
+ _, _, e1 := Syscall(SYS_MPROTECT, uintptr(_p0), uintptr(len(b)), uintptr(prot))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Msync(b []byte, flags int) (err error) {
+ var _p0 unsafe.Pointer
+ if len(b) > 0 {
+ _p0 = unsafe.Pointer(&b[0])
+ } else {
+ _p0 = unsafe.Pointer(&_zero)
+ }
+ _, _, e1 := Syscall(SYS_MSYNC, uintptr(_p0), uintptr(len(b)), uintptr(flags))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Munlock(b []byte) (err error) {
+ var _p0 unsafe.Pointer
+ if len(b) > 0 {
+ _p0 = unsafe.Pointer(&b[0])
+ } else {
+ _p0 = unsafe.Pointer(&_zero)
+ }
+ _, _, e1 := Syscall(SYS_MUNLOCK, uintptr(_p0), uintptr(len(b)), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Munlockall() (err error) {
+ _, _, e1 := Syscall(SYS_MUNLOCKALL, 0, 0, 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func ptrace(request int, pid int, addr uintptr, data uintptr) (err error) {
+ _, _, e1 := Syscall6(SYS_PTRACE, uintptr(request), uintptr(pid), uintptr(addr), uintptr(data), 0, 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func getattrlist(path *byte, list unsafe.Pointer, buf unsafe.Pointer, size uintptr, options int) (err error) {
+ _, _, e1 := Syscall6(SYS_GETATTRLIST, uintptr(unsafe.Pointer(path)), uintptr(list), uintptr(buf), uintptr(size), uintptr(options), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func pipe() (r int, w int, err error) {
+ r0, r1, e1 := RawSyscall(SYS_PIPE, 0, 0, 0)
+ r = int(r0)
+ w = int(r1)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func getxattr(path string, attr string, dest *byte, size int, position uint32, options int) (sz int, err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ var _p1 *byte
+ _p1, err = BytePtrFromString(attr)
+ if err != nil {
+ return
+ }
+ r0, _, e1 := Syscall6(SYS_GETXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(unsafe.Pointer(dest)), uintptr(size), uintptr(position), uintptr(options))
+ sz = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func fgetxattr(fd int, attr string, dest *byte, size int, position uint32, options int) (sz int, err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(attr)
+ if err != nil {
+ return
+ }
+ r0, _, e1 := Syscall6(SYS_FGETXATTR, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(dest)), uintptr(size), uintptr(position), uintptr(options))
+ sz = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func setxattr(path string, attr string, data *byte, size int, position uint32, options int) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ var _p1 *byte
+ _p1, err = BytePtrFromString(attr)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall6(SYS_SETXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(unsafe.Pointer(data)), uintptr(size), uintptr(position), uintptr(options))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func fsetxattr(fd int, attr string, data *byte, size int, position uint32, options int) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(attr)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall6(SYS_FSETXATTR, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(data)), uintptr(size), uintptr(position), uintptr(options))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func removexattr(path string, attr string, options int) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ var _p1 *byte
+ _p1, err = BytePtrFromString(attr)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_REMOVEXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(options))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func fremovexattr(fd int, attr string, options int) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(attr)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_FREMOVEXATTR, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(options))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func listxattr(path string, dest *byte, size int, options int) (sz int, err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ r0, _, e1 := Syscall6(SYS_LISTXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(dest)), uintptr(size), uintptr(options), 0, 0)
+ sz = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func flistxattr(fd int, dest *byte, size int, options int) (sz int, err error) {
+ r0, _, e1 := Syscall6(SYS_FLISTXATTR, uintptr(fd), uintptr(unsafe.Pointer(dest)), uintptr(size), uintptr(options), 0, 0)
+ sz = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func setattrlist(path *byte, list unsafe.Pointer, buf unsafe.Pointer, size uintptr, options int) (err error) {
+ _, _, e1 := Syscall6(SYS_SETATTRLIST, uintptr(unsafe.Pointer(path)), uintptr(list), uintptr(buf), uintptr(size), uintptr(options), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func kill(pid int, signum int, posix int) (err error) {
+ _, _, e1 := Syscall(SYS_KILL, uintptr(pid), uintptr(signum), uintptr(posix))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func ioctl(fd int, req uint, arg uintptr) (err error) {
+ _, _, e1 := Syscall(SYS_IOCTL, uintptr(fd), uintptr(req), uintptr(arg))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func sendfile(infd int, outfd int, offset int64, len *int64, hdtr unsafe.Pointer, flags int) (err error) {
+ _, _, e1 := Syscall6(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(offset), uintptr(unsafe.Pointer(len)), uintptr(hdtr), uintptr(flags))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Access(path string, mode uint32) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_ACCESS, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Adjtime(delta *Timeval, olddelta *Timeval) (err error) {
+ _, _, e1 := Syscall(SYS_ADJTIME, uintptr(unsafe.Pointer(delta)), uintptr(unsafe.Pointer(olddelta)), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Chdir(path string) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_CHDIR, uintptr(unsafe.Pointer(_p0)), 0, 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Chflags(path string, flags int) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_CHFLAGS, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Chmod(path string, mode uint32) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_CHMOD, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Chown(path string, uid int, gid int) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_CHOWN, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Chroot(path string) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_CHROOT, uintptr(unsafe.Pointer(_p0)), 0, 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Close(fd int) (err error) {
+ _, _, e1 := Syscall(SYS_CLOSE, uintptr(fd), 0, 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Dup(fd int) (nfd int, err error) {
+ r0, _, e1 := Syscall(SYS_DUP, uintptr(fd), 0, 0)
+ nfd = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Dup2(from int, to int) (err error) {
+ _, _, e1 := Syscall(SYS_DUP2, uintptr(from), uintptr(to), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Exchangedata(path1 string, path2 string, options int) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path1)
+ if err != nil {
+ return
+ }
+ var _p1 *byte
+ _p1, err = BytePtrFromString(path2)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_EXCHANGEDATA, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(options))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Exit(code int) {
+ Syscall(SYS_EXIT, uintptr(code), 0, 0)
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Faccessat(dirfd int, path string, mode uint32, flags int) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall6(SYS_FACCESSAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Fchdir(fd int) (err error) {
+ _, _, e1 := Syscall(SYS_FCHDIR, uintptr(fd), 0, 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Fchflags(fd int, flags int) (err error) {
+ _, _, e1 := Syscall(SYS_FCHFLAGS, uintptr(fd), uintptr(flags), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Fchmod(fd int, mode uint32) (err error) {
+ _, _, e1 := Syscall(SYS_FCHMOD, uintptr(fd), uintptr(mode), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall6(SYS_FCHMODAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Fchown(fd int, uid int, gid int) (err error) {
+ _, _, e1 := Syscall(SYS_FCHOWN, uintptr(fd), uintptr(uid), uintptr(gid))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall6(SYS_FCHOWNAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid), uintptr(flags), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Flock(fd int, how int) (err error) {
+ _, _, e1 := Syscall(SYS_FLOCK, uintptr(fd), uintptr(how), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Fpathconf(fd int, name int) (val int, err error) {
+ r0, _, e1 := Syscall(SYS_FPATHCONF, uintptr(fd), uintptr(name), 0)
+ val = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Fsync(fd int) (err error) {
+ _, _, e1 := Syscall(SYS_FSYNC, uintptr(fd), 0, 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Ftruncate(fd int, length int64) (err error) {
+ _, _, e1 := Syscall(SYS_FTRUNCATE, uintptr(fd), uintptr(length), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Getdtablesize() (size int) {
+ r0, _, _ := Syscall(SYS_GETDTABLESIZE, 0, 0, 0)
+ size = int(r0)
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Getegid() (egid int) {
+ r0, _, _ := RawSyscall(SYS_GETEGID, 0, 0, 0)
+ egid = int(r0)
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Geteuid() (uid int) {
+ r0, _, _ := RawSyscall(SYS_GETEUID, 0, 0, 0)
+ uid = int(r0)
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Getgid() (gid int) {
+ r0, _, _ := RawSyscall(SYS_GETGID, 0, 0, 0)
+ gid = int(r0)
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Getpgid(pid int) (pgid int, err error) {
+ r0, _, e1 := RawSyscall(SYS_GETPGID, uintptr(pid), 0, 0)
+ pgid = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Getpgrp() (pgrp int) {
+ r0, _, _ := RawSyscall(SYS_GETPGRP, 0, 0, 0)
+ pgrp = int(r0)
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Getpid() (pid int) {
+ r0, _, _ := RawSyscall(SYS_GETPID, 0, 0, 0)
+ pid = int(r0)
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Getppid() (ppid int) {
+ r0, _, _ := RawSyscall(SYS_GETPPID, 0, 0, 0)
+ ppid = int(r0)
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Getpriority(which int, who int) (prio int, err error) {
+ r0, _, e1 := Syscall(SYS_GETPRIORITY, uintptr(which), uintptr(who), 0)
+ prio = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Getrlimit(which int, lim *Rlimit) (err error) {
+ _, _, e1 := RawSyscall(SYS_GETRLIMIT, uintptr(which), uintptr(unsafe.Pointer(lim)), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Getrusage(who int, rusage *Rusage) (err error) {
+ _, _, e1 := RawSyscall(SYS_GETRUSAGE, uintptr(who), uintptr(unsafe.Pointer(rusage)), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Getsid(pid int) (sid int, err error) {
+ r0, _, e1 := RawSyscall(SYS_GETSID, uintptr(pid), 0, 0)
+ sid = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Getuid() (uid int) {
+ r0, _, _ := RawSyscall(SYS_GETUID, 0, 0, 0)
+ uid = int(r0)
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Issetugid() (tainted bool) {
+ r0, _, _ := RawSyscall(SYS_ISSETUGID, 0, 0, 0)
+ tainted = bool(r0 != 0)
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Kqueue() (fd int, err error) {
+ r0, _, e1 := Syscall(SYS_KQUEUE, 0, 0, 0)
+ fd = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Lchown(path string, uid int, gid int) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_LCHOWN, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Link(path string, link string) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ var _p1 *byte
+ _p1, err = BytePtrFromString(link)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_LINK, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Linkat(pathfd int, path string, linkfd int, link string, flags int) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ var _p1 *byte
+ _p1, err = BytePtrFromString(link)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall6(SYS_LINKAT, uintptr(pathfd), uintptr(unsafe.Pointer(_p0)), uintptr(linkfd), uintptr(unsafe.Pointer(_p1)), uintptr(flags), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Listen(s int, backlog int) (err error) {
+ _, _, e1 := Syscall(SYS_LISTEN, uintptr(s), uintptr(backlog), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Mkdir(path string, mode uint32) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_MKDIR, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Mkdirat(dirfd int, path string, mode uint32) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_MKDIRAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Mkfifo(path string, mode uint32) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_MKFIFO, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Mknod(path string, mode uint32, dev int) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_MKNOD, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(dev))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Open(path string, mode int, perm uint32) (fd int, err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ r0, _, e1 := Syscall(SYS_OPEN, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(perm))
+ fd = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Openat(dirfd int, path string, mode int, perm uint32) (fd int, err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ r0, _, e1 := Syscall6(SYS_OPENAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(perm), 0, 0)
+ fd = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Pathconf(path string, name int) (val int, err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ r0, _, e1 := Syscall(SYS_PATHCONF, uintptr(unsafe.Pointer(_p0)), uintptr(name), 0)
+ val = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Pread(fd int, p []byte, offset int64) (n int, err error) {
+ var _p0 unsafe.Pointer
+ if len(p) > 0 {
+ _p0 = unsafe.Pointer(&p[0])
+ } else {
+ _p0 = unsafe.Pointer(&_zero)
+ }
+ r0, _, e1 := Syscall6(SYS_PREAD, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), 0, 0)
+ n = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Pwrite(fd int, p []byte, offset int64) (n int, err error) {
+ var _p0 unsafe.Pointer
+ if len(p) > 0 {
+ _p0 = unsafe.Pointer(&p[0])
+ } else {
+ _p0 = unsafe.Pointer(&_zero)
+ }
+ r0, _, e1 := Syscall6(SYS_PWRITE, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), 0, 0)
+ n = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func read(fd int, p []byte) (n int, err error) {
+ var _p0 unsafe.Pointer
+ if len(p) > 0 {
+ _p0 = unsafe.Pointer(&p[0])
+ } else {
+ _p0 = unsafe.Pointer(&_zero)
+ }
+ r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(_p0), uintptr(len(p)))
+ n = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Readlink(path string, buf []byte) (n int, err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ var _p1 unsafe.Pointer
+ if len(buf) > 0 {
+ _p1 = unsafe.Pointer(&buf[0])
+ } else {
+ _p1 = unsafe.Pointer(&_zero)
+ }
+ r0, _, e1 := Syscall(SYS_READLINK, uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(buf)))
+ n = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Readlinkat(dirfd int, path string, buf []byte) (n int, err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ var _p1 unsafe.Pointer
+ if len(buf) > 0 {
+ _p1 = unsafe.Pointer(&buf[0])
+ } else {
+ _p1 = unsafe.Pointer(&_zero)
+ }
+ r0, _, e1 := Syscall6(SYS_READLINKAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(buf)), 0, 0)
+ n = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Rename(from string, to string) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(from)
+ if err != nil {
+ return
+ }
+ var _p1 *byte
+ _p1, err = BytePtrFromString(to)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_RENAME, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Renameat(fromfd int, from string, tofd int, to string) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(from)
+ if err != nil {
+ return
+ }
+ var _p1 *byte
+ _p1, err = BytePtrFromString(to)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall6(SYS_RENAMEAT, uintptr(fromfd), uintptr(unsafe.Pointer(_p0)), uintptr(tofd), uintptr(unsafe.Pointer(_p1)), 0, 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Revoke(path string) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_REVOKE, uintptr(unsafe.Pointer(_p0)), 0, 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Rmdir(path string) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_RMDIR, uintptr(unsafe.Pointer(_p0)), 0, 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Seek(fd int, offset int64, whence int) (newoffset int64, err error) {
+ r0, _, e1 := Syscall(SYS_LSEEK, uintptr(fd), uintptr(offset), uintptr(whence))
+ newoffset = int64(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Select(n int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (err error) {
+ _, _, e1 := Syscall6(SYS_SELECT, uintptr(n), uintptr(unsafe.Pointer(r)), uintptr(unsafe.Pointer(w)), uintptr(unsafe.Pointer(e)), uintptr(unsafe.Pointer(timeout)), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Setegid(egid int) (err error) {
+ _, _, e1 := Syscall(SYS_SETEGID, uintptr(egid), 0, 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Seteuid(euid int) (err error) {
+ _, _, e1 := RawSyscall(SYS_SETEUID, uintptr(euid), 0, 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Setgid(gid int) (err error) {
+ _, _, e1 := RawSyscall(SYS_SETGID, uintptr(gid), 0, 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Setlogin(name string) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(name)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_SETLOGIN, uintptr(unsafe.Pointer(_p0)), 0, 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Setpgid(pid int, pgid int) (err error) {
+ _, _, e1 := RawSyscall(SYS_SETPGID, uintptr(pid), uintptr(pgid), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Setpriority(which int, who int, prio int) (err error) {
+ _, _, e1 := Syscall(SYS_SETPRIORITY, uintptr(which), uintptr(who), uintptr(prio))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Setprivexec(flag int) (err error) {
+ _, _, e1 := Syscall(SYS_SETPRIVEXEC, uintptr(flag), 0, 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Setregid(rgid int, egid int) (err error) {
+ _, _, e1 := RawSyscall(SYS_SETREGID, uintptr(rgid), uintptr(egid), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Setreuid(ruid int, euid int) (err error) {
+ _, _, e1 := RawSyscall(SYS_SETREUID, uintptr(ruid), uintptr(euid), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Setrlimit(which int, lim *Rlimit) (err error) {
+ _, _, e1 := RawSyscall(SYS_SETRLIMIT, uintptr(which), uintptr(unsafe.Pointer(lim)), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Setsid() (pid int, err error) {
+ r0, _, e1 := RawSyscall(SYS_SETSID, 0, 0, 0)
+ pid = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Settimeofday(tp *Timeval) (err error) {
+ _, _, e1 := RawSyscall(SYS_SETTIMEOFDAY, uintptr(unsafe.Pointer(tp)), 0, 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Setuid(uid int) (err error) {
+ _, _, e1 := RawSyscall(SYS_SETUID, uintptr(uid), 0, 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Symlink(path string, link string) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ var _p1 *byte
+ _p1, err = BytePtrFromString(link)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_SYMLINK, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Symlinkat(oldpath string, newdirfd int, newpath string) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(oldpath)
+ if err != nil {
+ return
+ }
+ var _p1 *byte
+ _p1, err = BytePtrFromString(newpath)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_SYMLINKAT, uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1)))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Sync() (err error) {
+ _, _, e1 := Syscall(SYS_SYNC, 0, 0, 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Truncate(path string, length int64) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_TRUNCATE, uintptr(unsafe.Pointer(_p0)), uintptr(length), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Umask(newmask int) (oldmask int) {
+ r0, _, _ := Syscall(SYS_UMASK, uintptr(newmask), 0, 0)
+ oldmask = int(r0)
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Undelete(path string) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_UNDELETE, uintptr(unsafe.Pointer(_p0)), 0, 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Unlink(path string) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_UNLINK, uintptr(unsafe.Pointer(_p0)), 0, 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Unlinkat(dirfd int, path string, flags int) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_UNLINKAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(flags))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Unmount(path string, flags int) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_UNMOUNT, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func write(fd int, p []byte) (n int, err error) {
+ var _p0 unsafe.Pointer
+ if len(p) > 0 {
+ _p0 = unsafe.Pointer(&p[0])
+ } else {
+ _p0 = unsafe.Pointer(&_zero)
+ }
+ r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(_p0), uintptr(len(p)))
+ n = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error) {
+ r0, _, e1 := Syscall6(SYS_MMAP, uintptr(addr), uintptr(length), uintptr(prot), uintptr(flag), uintptr(fd), uintptr(pos))
+ ret = uintptr(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func munmap(addr uintptr, length uintptr) (err error) {
+ _, _, e1 := Syscall(SYS_MUNMAP, uintptr(addr), uintptr(length), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func readlen(fd int, buf *byte, nbuf int) (n int, err error) {
+ r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf))
+ n = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func writelen(fd int, buf *byte, nbuf int) (n int, err error) {
+ r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf))
+ n = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func gettimeofday(tp *Timeval) (sec int64, usec int32, err error) {
+ r0, r1, e1 := RawSyscall(SYS_GETTIMEOFDAY, uintptr(unsafe.Pointer(tp)), 0, 0)
+ sec = int64(r0)
+ usec = int32(r1)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Fstat(fd int, stat *Stat_t) (err error) {
+ _, _, e1 := Syscall(SYS_FSTAT, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Fstatat(fd int, path string, stat *Stat_t, flags int) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall6(SYS_FSTATAT, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), uintptr(flags), 0, 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Fstatfs(fd int, stat *Statfs_t) (err error) {
+ _, _, e1 := Syscall(SYS_FSTATFS, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func getfsstat(buf unsafe.Pointer, size uintptr, flags int) (n int, err error) {
+ r0, _, e1 := Syscall(SYS_GETFSSTAT, uintptr(buf), uintptr(size), uintptr(flags))
+ n = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Lstat(path string, stat *Stat_t) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_LSTAT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Stat(path string, stat *Stat_t) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_STAT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Statfs(path string, stat *Statfs_t) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_STATFS, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
diff --git a/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go b/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go
index 338c32d40..8f2691dee 100644
--- a/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go
+++ b/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go
@@ -1,7 +1,7 @@
-// mksyscall.pl -tags darwin,arm64 syscall_bsd.go syscall_darwin.go syscall_darwin_arm64.go
+// go run mksyscall.go -tags darwin,arm64,go1.12 syscall_bsd.go syscall_darwin.go syscall_darwin_arm64.go
// Code generated by the command above; see README.md. DO NOT EDIT.
-// +build darwin,arm64
+// +build darwin,arm64,go1.12
package unix
@@ -15,7 +15,7 @@ var _ syscall.Errno
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func getgroups(ngid int, gid *_Gid_t) (n int, err error) {
- r0, _, e1 := RawSyscall(SYS_GETGROUPS, uintptr(ngid), uintptr(unsafe.Pointer(gid)), 0)
+ r0, _, e1 := syscall_rawSyscall(funcPC(libc_getgroups_trampoline), uintptr(ngid), uintptr(unsafe.Pointer(gid)), 0)
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -23,20 +23,30 @@ func getgroups(ngid int, gid *_Gid_t) (n int, err error) {
return
}
+func libc_getgroups_trampoline()
+
+//go:linkname libc_getgroups libc_getgroups
+//go:cgo_import_dynamic libc_getgroups getgroups "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func setgroups(ngid int, gid *_Gid_t) (err error) {
- _, _, e1 := RawSyscall(SYS_SETGROUPS, uintptr(ngid), uintptr(unsafe.Pointer(gid)), 0)
+ _, _, e1 := syscall_rawSyscall(funcPC(libc_setgroups_trampoline), uintptr(ngid), uintptr(unsafe.Pointer(gid)), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_setgroups_trampoline()
+
+//go:linkname libc_setgroups libc_setgroups
+//go:cgo_import_dynamic libc_setgroups setgroups "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func wait4(pid int, wstatus *_C_int, options int, rusage *Rusage) (wpid int, err error) {
- r0, _, e1 := Syscall6(SYS_WAIT4, uintptr(pid), uintptr(unsafe.Pointer(wstatus)), uintptr(options), uintptr(unsafe.Pointer(rusage)), 0, 0)
+ r0, _, e1 := syscall_syscall6(funcPC(libc_wait4_trampoline), uintptr(pid), uintptr(unsafe.Pointer(wstatus)), uintptr(options), uintptr(unsafe.Pointer(rusage)), 0, 0)
wpid = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -44,10 +54,15 @@ func wait4(pid int, wstatus *_C_int, options int, rusage *Rusage) (wpid int, err
return
}
+func libc_wait4_trampoline()
+
+//go:linkname libc_wait4 libc_wait4
+//go:cgo_import_dynamic libc_wait4 wait4 "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) {
- r0, _, e1 := Syscall(SYS_ACCEPT, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
+ r0, _, e1 := syscall_syscall(funcPC(libc_accept_trampoline), uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
fd = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -55,30 +70,45 @@ func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) {
return
}
+func libc_accept_trampoline()
+
+//go:linkname libc_accept libc_accept
+//go:cgo_import_dynamic libc_accept accept "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) {
- _, _, e1 := Syscall(SYS_BIND, uintptr(s), uintptr(addr), uintptr(addrlen))
+ _, _, e1 := syscall_syscall(funcPC(libc_bind_trampoline), uintptr(s), uintptr(addr), uintptr(addrlen))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_bind_trampoline()
+
+//go:linkname libc_bind libc_bind
+//go:cgo_import_dynamic libc_bind bind "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) {
- _, _, e1 := Syscall(SYS_CONNECT, uintptr(s), uintptr(addr), uintptr(addrlen))
+ _, _, e1 := syscall_syscall(funcPC(libc_connect_trampoline), uintptr(s), uintptr(addr), uintptr(addrlen))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_connect_trampoline()
+
+//go:linkname libc_connect libc_connect
+//go:cgo_import_dynamic libc_connect connect "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func socket(domain int, typ int, proto int) (fd int, err error) {
- r0, _, e1 := RawSyscall(SYS_SOCKET, uintptr(domain), uintptr(typ), uintptr(proto))
+ r0, _, e1 := syscall_rawSyscall(funcPC(libc_socket_trampoline), uintptr(domain), uintptr(typ), uintptr(proto))
fd = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -86,66 +116,101 @@ func socket(domain int, typ int, proto int) (fd int, err error) {
return
}
+func libc_socket_trampoline()
+
+//go:linkname libc_socket libc_socket
+//go:cgo_import_dynamic libc_socket socket "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) {
- _, _, e1 := Syscall6(SYS_GETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(unsafe.Pointer(vallen)), 0)
+ _, _, e1 := syscall_syscall6(funcPC(libc_getsockopt_trampoline), uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(unsafe.Pointer(vallen)), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_getsockopt_trampoline()
+
+//go:linkname libc_getsockopt libc_getsockopt
+//go:cgo_import_dynamic libc_getsockopt getsockopt "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) {
- _, _, e1 := Syscall6(SYS_SETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(vallen), 0)
+ _, _, e1 := syscall_syscall6(funcPC(libc_setsockopt_trampoline), uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(vallen), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_setsockopt_trampoline()
+
+//go:linkname libc_setsockopt libc_setsockopt
+//go:cgo_import_dynamic libc_setsockopt setsockopt "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) {
- _, _, e1 := RawSyscall(SYS_GETPEERNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
+ _, _, e1 := syscall_rawSyscall(funcPC(libc_getpeername_trampoline), uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_getpeername_trampoline()
+
+//go:linkname libc_getpeername libc_getpeername
+//go:cgo_import_dynamic libc_getpeername getpeername "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) {
- _, _, e1 := RawSyscall(SYS_GETSOCKNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
+ _, _, e1 := syscall_rawSyscall(funcPC(libc_getsockname_trampoline), uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_getsockname_trampoline()
+
+//go:linkname libc_getsockname libc_getsockname
+//go:cgo_import_dynamic libc_getsockname getsockname "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Shutdown(s int, how int) (err error) {
- _, _, e1 := Syscall(SYS_SHUTDOWN, uintptr(s), uintptr(how), 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_shutdown_trampoline), uintptr(s), uintptr(how), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_shutdown_trampoline()
+
+//go:linkname libc_shutdown libc_shutdown
+//go:cgo_import_dynamic libc_shutdown shutdown "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) {
- _, _, e1 := RawSyscall6(SYS_SOCKETPAIR, uintptr(domain), uintptr(typ), uintptr(proto), uintptr(unsafe.Pointer(fd)), 0, 0)
+ _, _, e1 := syscall_rawSyscall6(funcPC(libc_socketpair_trampoline), uintptr(domain), uintptr(typ), uintptr(proto), uintptr(unsafe.Pointer(fd)), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_socketpair_trampoline()
+
+//go:linkname libc_socketpair libc_socketpair
+//go:cgo_import_dynamic libc_socketpair socketpair "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) {
@@ -155,7 +220,7 @@ func recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Sockl
} else {
_p0 = unsafe.Pointer(&_zero)
}
- r0, _, e1 := Syscall6(SYS_RECVFROM, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(flags), uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(fromlen)))
+ r0, _, e1 := syscall_syscall6(funcPC(libc_recvfrom_trampoline), uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(flags), uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(fromlen)))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -163,6 +228,11 @@ func recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Sockl
return
}
+func libc_recvfrom_trampoline()
+
+//go:linkname libc_recvfrom libc_recvfrom
+//go:cgo_import_dynamic libc_recvfrom recvfrom "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) {
@@ -172,17 +242,22 @@ func sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (
} else {
_p0 = unsafe.Pointer(&_zero)
}
- _, _, e1 := Syscall6(SYS_SENDTO, uintptr(s), uintptr(_p0), uintptr(len(buf)), uintptr(flags), uintptr(to), uintptr(addrlen))
+ _, _, e1 := syscall_syscall6(funcPC(libc_sendto_trampoline), uintptr(s), uintptr(_p0), uintptr(len(buf)), uintptr(flags), uintptr(to), uintptr(addrlen))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_sendto_trampoline()
+
+//go:linkname libc_sendto libc_sendto
+//go:cgo_import_dynamic libc_sendto sendto "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func recvmsg(s int, msg *Msghdr, flags int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_RECVMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags))
+ r0, _, e1 := syscall_syscall(funcPC(libc_recvmsg_trampoline), uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -190,10 +265,15 @@ func recvmsg(s int, msg *Msghdr, flags int) (n int, err error) {
return
}
+func libc_recvmsg_trampoline()
+
+//go:linkname libc_recvmsg libc_recvmsg
+//go:cgo_import_dynamic libc_recvmsg recvmsg "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func sendmsg(s int, msg *Msghdr, flags int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_SENDMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags))
+ r0, _, e1 := syscall_syscall(funcPC(libc_sendmsg_trampoline), uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -201,10 +281,15 @@ func sendmsg(s int, msg *Msghdr, flags int) (n int, err error) {
return
}
+func libc_sendmsg_trampoline()
+
+//go:linkname libc_sendmsg libc_sendmsg
+//go:cgo_import_dynamic libc_sendmsg sendmsg "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func kevent(kq int, change unsafe.Pointer, nchange int, event unsafe.Pointer, nevent int, timeout *Timespec) (n int, err error) {
- r0, _, e1 := Syscall6(SYS_KEVENT, uintptr(kq), uintptr(change), uintptr(nchange), uintptr(event), uintptr(nevent), uintptr(unsafe.Pointer(timeout)))
+ r0, _, e1 := syscall_syscall6(funcPC(libc_kevent_trampoline), uintptr(kq), uintptr(change), uintptr(nchange), uintptr(event), uintptr(nevent), uintptr(unsafe.Pointer(timeout)))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -212,6 +297,11 @@ func kevent(kq int, change unsafe.Pointer, nchange int, event unsafe.Pointer, ne
return
}
+func libc_kevent_trampoline()
+
+//go:linkname libc_kevent libc_kevent
+//go:cgo_import_dynamic libc_kevent kevent "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) {
@@ -221,13 +311,18 @@ func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr)
} else {
_p0 = unsafe.Pointer(&_zero)
}
- _, _, e1 := Syscall6(SYS___SYSCTL, uintptr(_p0), uintptr(len(mib)), uintptr(unsafe.Pointer(old)), uintptr(unsafe.Pointer(oldlen)), uintptr(unsafe.Pointer(new)), uintptr(newlen))
+ _, _, e1 := syscall_syscall6(funcPC(libc___sysctl_trampoline), uintptr(_p0), uintptr(len(mib)), uintptr(unsafe.Pointer(old)), uintptr(unsafe.Pointer(oldlen)), uintptr(unsafe.Pointer(new)), uintptr(newlen))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc___sysctl_trampoline()
+
+//go:linkname libc___sysctl libc___sysctl
+//go:cgo_import_dynamic libc___sysctl __sysctl "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func utimes(path string, timeval *[2]Timeval) (err error) {
@@ -236,27 +331,37 @@ func utimes(path string, timeval *[2]Timeval) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall(SYS_UTIMES, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(timeval)), 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_utimes_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(timeval)), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_utimes_trampoline()
+
+//go:linkname libc_utimes libc_utimes
+//go:cgo_import_dynamic libc_utimes utimes "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func futimes(fd int, timeval *[2]Timeval) (err error) {
- _, _, e1 := Syscall(SYS_FUTIMES, uintptr(fd), uintptr(unsafe.Pointer(timeval)), 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_futimes_trampoline), uintptr(fd), uintptr(unsafe.Pointer(timeval)), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_futimes_trampoline()
+
+//go:linkname libc_futimes libc_futimes
+//go:cgo_import_dynamic libc_futimes futimes "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func fcntl(fd int, cmd int, arg int) (val int, err error) {
- r0, _, e1 := Syscall(SYS_FCNTL, uintptr(fd), uintptr(cmd), uintptr(arg))
+ r0, _, e1 := syscall_syscall(funcPC(libc_fcntl_trampoline), uintptr(fd), uintptr(cmd), uintptr(arg))
val = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -264,10 +369,15 @@ func fcntl(fd int, cmd int, arg int) (val int, err error) {
return
}
+func libc_fcntl_trampoline()
+
+//go:linkname libc_fcntl libc_fcntl
+//go:cgo_import_dynamic libc_fcntl fcntl "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func poll(fds *PollFd, nfds int, timeout int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_POLL, uintptr(unsafe.Pointer(fds)), uintptr(nfds), uintptr(timeout))
+ r0, _, e1 := syscall_syscall(funcPC(libc_poll_trampoline), uintptr(unsafe.Pointer(fds)), uintptr(nfds), uintptr(timeout))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -275,6 +385,11 @@ func poll(fds *PollFd, nfds int, timeout int) (n int, err error) {
return
}
+func libc_poll_trampoline()
+
+//go:linkname libc_poll libc_poll
+//go:cgo_import_dynamic libc_poll poll "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Madvise(b []byte, behav int) (err error) {
@@ -284,13 +399,18 @@ func Madvise(b []byte, behav int) (err error) {
} else {
_p0 = unsafe.Pointer(&_zero)
}
- _, _, e1 := Syscall(SYS_MADVISE, uintptr(_p0), uintptr(len(b)), uintptr(behav))
+ _, _, e1 := syscall_syscall(funcPC(libc_madvise_trampoline), uintptr(_p0), uintptr(len(b)), uintptr(behav))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_madvise_trampoline()
+
+//go:linkname libc_madvise libc_madvise
+//go:cgo_import_dynamic libc_madvise madvise "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Mlock(b []byte) (err error) {
@@ -300,23 +420,33 @@ func Mlock(b []byte) (err error) {
} else {
_p0 = unsafe.Pointer(&_zero)
}
- _, _, e1 := Syscall(SYS_MLOCK, uintptr(_p0), uintptr(len(b)), 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_mlock_trampoline), uintptr(_p0), uintptr(len(b)), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_mlock_trampoline()
+
+//go:linkname libc_mlock libc_mlock
+//go:cgo_import_dynamic libc_mlock mlock "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Mlockall(flags int) (err error) {
- _, _, e1 := Syscall(SYS_MLOCKALL, uintptr(flags), 0, 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_mlockall_trampoline), uintptr(flags), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_mlockall_trampoline()
+
+//go:linkname libc_mlockall libc_mlockall
+//go:cgo_import_dynamic libc_mlockall mlockall "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Mprotect(b []byte, prot int) (err error) {
@@ -326,13 +456,18 @@ func Mprotect(b []byte, prot int) (err error) {
} else {
_p0 = unsafe.Pointer(&_zero)
}
- _, _, e1 := Syscall(SYS_MPROTECT, uintptr(_p0), uintptr(len(b)), uintptr(prot))
+ _, _, e1 := syscall_syscall(funcPC(libc_mprotect_trampoline), uintptr(_p0), uintptr(len(b)), uintptr(prot))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_mprotect_trampoline()
+
+//go:linkname libc_mprotect libc_mprotect
+//go:cgo_import_dynamic libc_mprotect mprotect "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Msync(b []byte, flags int) (err error) {
@@ -342,13 +477,18 @@ func Msync(b []byte, flags int) (err error) {
} else {
_p0 = unsafe.Pointer(&_zero)
}
- _, _, e1 := Syscall(SYS_MSYNC, uintptr(_p0), uintptr(len(b)), uintptr(flags))
+ _, _, e1 := syscall_syscall(funcPC(libc_msync_trampoline), uintptr(_p0), uintptr(len(b)), uintptr(flags))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_msync_trampoline()
+
+//go:linkname libc_msync libc_msync
+//go:cgo_import_dynamic libc_msync msync "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Munlock(b []byte) (err error) {
@@ -358,37 +498,67 @@ func Munlock(b []byte) (err error) {
} else {
_p0 = unsafe.Pointer(&_zero)
}
- _, _, e1 := Syscall(SYS_MUNLOCK, uintptr(_p0), uintptr(len(b)), 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_munlock_trampoline), uintptr(_p0), uintptr(len(b)), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_munlock_trampoline()
+
+//go:linkname libc_munlock libc_munlock
+//go:cgo_import_dynamic libc_munlock munlock "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Munlockall() (err error) {
- _, _, e1 := Syscall(SYS_MUNLOCKALL, 0, 0, 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_munlockall_trampoline), 0, 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_munlockall_trampoline()
+
+//go:linkname libc_munlockall libc_munlockall
+//go:cgo_import_dynamic libc_munlockall munlockall "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func ptrace(request int, pid int, addr uintptr, data uintptr) (err error) {
- _, _, e1 := Syscall6(SYS_PTRACE, uintptr(request), uintptr(pid), uintptr(addr), uintptr(data), 0, 0)
+ _, _, e1 := syscall_syscall6(funcPC(libc_ptrace_trampoline), uintptr(request), uintptr(pid), uintptr(addr), uintptr(data), 0, 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func libc_ptrace_trampoline()
+
+//go:linkname libc_ptrace libc_ptrace
+//go:cgo_import_dynamic libc_ptrace ptrace "/usr/lib/libSystem.B.dylib"
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func getattrlist(path *byte, list unsafe.Pointer, buf unsafe.Pointer, size uintptr, options int) (err error) {
+ _, _, e1 := syscall_syscall6(funcPC(libc_getattrlist_trampoline), uintptr(unsafe.Pointer(path)), uintptr(list), uintptr(buf), uintptr(size), uintptr(options), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_getattrlist_trampoline()
+
+//go:linkname libc_getattrlist libc_getattrlist
+//go:cgo_import_dynamic libc_getattrlist getattrlist "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func pipe() (r int, w int, err error) {
- r0, r1, e1 := RawSyscall(SYS_PIPE, 0, 0, 0)
+ r0, r1, e1 := syscall_rawSyscall(funcPC(libc_pipe_trampoline), 0, 0, 0)
r = int(r0)
w = int(r1)
if e1 != 0 {
@@ -397,6 +567,11 @@ func pipe() (r int, w int, err error) {
return
}
+func libc_pipe_trampoline()
+
+//go:linkname libc_pipe libc_pipe
+//go:cgo_import_dynamic libc_pipe pipe "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func getxattr(path string, attr string, dest *byte, size int, position uint32, options int) (sz int, err error) {
@@ -410,7 +585,7 @@ func getxattr(path string, attr string, dest *byte, size int, position uint32, o
if err != nil {
return
}
- r0, _, e1 := Syscall6(SYS_GETXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(unsafe.Pointer(dest)), uintptr(size), uintptr(position), uintptr(options))
+ r0, _, e1 := syscall_syscall6(funcPC(libc_getxattr_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(unsafe.Pointer(dest)), uintptr(size), uintptr(position), uintptr(options))
sz = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -418,6 +593,11 @@ func getxattr(path string, attr string, dest *byte, size int, position uint32, o
return
}
+func libc_getxattr_trampoline()
+
+//go:linkname libc_getxattr libc_getxattr
+//go:cgo_import_dynamic libc_getxattr getxattr "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func fgetxattr(fd int, attr string, dest *byte, size int, position uint32, options int) (sz int, err error) {
@@ -426,7 +606,7 @@ func fgetxattr(fd int, attr string, dest *byte, size int, position uint32, optio
if err != nil {
return
}
- r0, _, e1 := Syscall6(SYS_FGETXATTR, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(dest)), uintptr(size), uintptr(position), uintptr(options))
+ r0, _, e1 := syscall_syscall6(funcPC(libc_fgetxattr_trampoline), uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(dest)), uintptr(size), uintptr(position), uintptr(options))
sz = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -434,6 +614,11 @@ func fgetxattr(fd int, attr string, dest *byte, size int, position uint32, optio
return
}
+func libc_fgetxattr_trampoline()
+
+//go:linkname libc_fgetxattr libc_fgetxattr
+//go:cgo_import_dynamic libc_fgetxattr fgetxattr "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func setxattr(path string, attr string, data *byte, size int, position uint32, options int) (err error) {
@@ -447,13 +632,18 @@ func setxattr(path string, attr string, data *byte, size int, position uint32, o
if err != nil {
return
}
- _, _, e1 := Syscall6(SYS_SETXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(unsafe.Pointer(data)), uintptr(size), uintptr(position), uintptr(options))
+ _, _, e1 := syscall_syscall6(funcPC(libc_setxattr_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(unsafe.Pointer(data)), uintptr(size), uintptr(position), uintptr(options))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_setxattr_trampoline()
+
+//go:linkname libc_setxattr libc_setxattr
+//go:cgo_import_dynamic libc_setxattr setxattr "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func fsetxattr(fd int, attr string, data *byte, size int, position uint32, options int) (err error) {
@@ -462,13 +652,18 @@ func fsetxattr(fd int, attr string, data *byte, size int, position uint32, optio
if err != nil {
return
}
- _, _, e1 := Syscall6(SYS_FSETXATTR, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(data)), uintptr(size), uintptr(position), uintptr(options))
+ _, _, e1 := syscall_syscall6(funcPC(libc_fsetxattr_trampoline), uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(data)), uintptr(size), uintptr(position), uintptr(options))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_fsetxattr_trampoline()
+
+//go:linkname libc_fsetxattr libc_fsetxattr
+//go:cgo_import_dynamic libc_fsetxattr fsetxattr "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func removexattr(path string, attr string, options int) (err error) {
@@ -482,13 +677,18 @@ func removexattr(path string, attr string, options int) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall(SYS_REMOVEXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(options))
+ _, _, e1 := syscall_syscall(funcPC(libc_removexattr_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(options))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_removexattr_trampoline()
+
+//go:linkname libc_removexattr libc_removexattr
+//go:cgo_import_dynamic libc_removexattr removexattr "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func fremovexattr(fd int, attr string, options int) (err error) {
@@ -497,13 +697,18 @@ func fremovexattr(fd int, attr string, options int) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall(SYS_FREMOVEXATTR, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(options))
+ _, _, e1 := syscall_syscall(funcPC(libc_fremovexattr_trampoline), uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(options))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_fremovexattr_trampoline()
+
+//go:linkname libc_fremovexattr libc_fremovexattr
+//go:cgo_import_dynamic libc_fremovexattr fremovexattr "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func listxattr(path string, dest *byte, size int, options int) (sz int, err error) {
@@ -512,7 +717,7 @@ func listxattr(path string, dest *byte, size int, options int) (sz int, err erro
if err != nil {
return
}
- r0, _, e1 := Syscall6(SYS_LISTXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(dest)), uintptr(size), uintptr(options), 0, 0)
+ r0, _, e1 := syscall_syscall6(funcPC(libc_listxattr_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(dest)), uintptr(size), uintptr(options), 0, 0)
sz = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -520,10 +725,15 @@ func listxattr(path string, dest *byte, size int, options int) (sz int, err erro
return
}
+func libc_listxattr_trampoline()
+
+//go:linkname libc_listxattr libc_listxattr
+//go:cgo_import_dynamic libc_listxattr listxattr "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func flistxattr(fd int, dest *byte, size int, options int) (sz int, err error) {
- r0, _, e1 := Syscall6(SYS_FLISTXATTR, uintptr(fd), uintptr(unsafe.Pointer(dest)), uintptr(size), uintptr(options), 0, 0)
+ r0, _, e1 := syscall_syscall6(funcPC(libc_flistxattr_trampoline), uintptr(fd), uintptr(unsafe.Pointer(dest)), uintptr(size), uintptr(options), 0, 0)
sz = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -531,26 +741,71 @@ func flistxattr(fd int, dest *byte, size int, options int) (sz int, err error) {
return
}
+func libc_flistxattr_trampoline()
+
+//go:linkname libc_flistxattr libc_flistxattr
+//go:cgo_import_dynamic libc_flistxattr flistxattr "/usr/lib/libSystem.B.dylib"
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func setattrlist(path *byte, list unsafe.Pointer, buf unsafe.Pointer, size uintptr, options int) (err error) {
+ _, _, e1 := syscall_syscall6(funcPC(libc_setattrlist_trampoline), uintptr(unsafe.Pointer(path)), uintptr(list), uintptr(buf), uintptr(size), uintptr(options), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func libc_setattrlist_trampoline()
+
+//go:linkname libc_setattrlist libc_setattrlist
+//go:cgo_import_dynamic libc_setattrlist setattrlist "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func kill(pid int, signum int, posix int) (err error) {
- _, _, e1 := Syscall(SYS_KILL, uintptr(pid), uintptr(signum), uintptr(posix))
+ _, _, e1 := syscall_syscall(funcPC(libc_kill_trampoline), uintptr(pid), uintptr(signum), uintptr(posix))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_kill_trampoline()
+
+//go:linkname libc_kill libc_kill
+//go:cgo_import_dynamic libc_kill kill "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func ioctl(fd int, req uint, arg uintptr) (err error) {
- _, _, e1 := Syscall(SYS_IOCTL, uintptr(fd), uintptr(req), uintptr(arg))
+ _, _, e1 := syscall_syscall(funcPC(libc_ioctl_trampoline), uintptr(fd), uintptr(req), uintptr(arg))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func libc_ioctl_trampoline()
+
+//go:linkname libc_ioctl libc_ioctl
+//go:cgo_import_dynamic libc_ioctl ioctl "/usr/lib/libSystem.B.dylib"
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func sendfile(infd int, outfd int, offset int64, len *int64, hdtr unsafe.Pointer, flags int) (err error) {
+ _, _, e1 := syscall_syscall6(funcPC(libc_sendfile_trampoline), uintptr(infd), uintptr(outfd), uintptr(offset), uintptr(unsafe.Pointer(len)), uintptr(hdtr), uintptr(flags))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_sendfile_trampoline()
+
+//go:linkname libc_sendfile libc_sendfile
+//go:cgo_import_dynamic libc_sendfile sendfile "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Access(path string, mode uint32) (err error) {
@@ -559,23 +814,33 @@ func Access(path string, mode uint32) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall(SYS_ACCESS, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_access_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_access_trampoline()
+
+//go:linkname libc_access libc_access
+//go:cgo_import_dynamic libc_access access "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Adjtime(delta *Timeval, olddelta *Timeval) (err error) {
- _, _, e1 := Syscall(SYS_ADJTIME, uintptr(unsafe.Pointer(delta)), uintptr(unsafe.Pointer(olddelta)), 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_adjtime_trampoline), uintptr(unsafe.Pointer(delta)), uintptr(unsafe.Pointer(olddelta)), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_adjtime_trampoline()
+
+//go:linkname libc_adjtime libc_adjtime
+//go:cgo_import_dynamic libc_adjtime adjtime "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Chdir(path string) (err error) {
@@ -584,13 +849,18 @@ func Chdir(path string) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall(SYS_CHDIR, uintptr(unsafe.Pointer(_p0)), 0, 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_chdir_trampoline), uintptr(unsafe.Pointer(_p0)), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_chdir_trampoline()
+
+//go:linkname libc_chdir libc_chdir
+//go:cgo_import_dynamic libc_chdir chdir "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Chflags(path string, flags int) (err error) {
@@ -599,13 +869,18 @@ func Chflags(path string, flags int) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall(SYS_CHFLAGS, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_chflags_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_chflags_trampoline()
+
+//go:linkname libc_chflags libc_chflags
+//go:cgo_import_dynamic libc_chflags chflags "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Chmod(path string, mode uint32) (err error) {
@@ -614,13 +889,18 @@ func Chmod(path string, mode uint32) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall(SYS_CHMOD, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_chmod_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_chmod_trampoline()
+
+//go:linkname libc_chmod libc_chmod
+//go:cgo_import_dynamic libc_chmod chmod "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Chown(path string, uid int, gid int) (err error) {
@@ -629,13 +909,18 @@ func Chown(path string, uid int, gid int) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall(SYS_CHOWN, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid))
+ _, _, e1 := syscall_syscall(funcPC(libc_chown_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_chown_trampoline()
+
+//go:linkname libc_chown libc_chown
+//go:cgo_import_dynamic libc_chown chown "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Chroot(path string) (err error) {
@@ -644,27 +929,37 @@ func Chroot(path string) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall(SYS_CHROOT, uintptr(unsafe.Pointer(_p0)), 0, 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_chroot_trampoline), uintptr(unsafe.Pointer(_p0)), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_chroot_trampoline()
+
+//go:linkname libc_chroot libc_chroot
+//go:cgo_import_dynamic libc_chroot chroot "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Close(fd int) (err error) {
- _, _, e1 := Syscall(SYS_CLOSE, uintptr(fd), 0, 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_close_trampoline), uintptr(fd), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_close_trampoline()
+
+//go:linkname libc_close libc_close
+//go:cgo_import_dynamic libc_close close "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Dup(fd int) (nfd int, err error) {
- r0, _, e1 := Syscall(SYS_DUP, uintptr(fd), 0, 0)
+ r0, _, e1 := syscall_syscall(funcPC(libc_dup_trampoline), uintptr(fd), 0, 0)
nfd = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -672,16 +967,26 @@ func Dup(fd int) (nfd int, err error) {
return
}
+func libc_dup_trampoline()
+
+//go:linkname libc_dup libc_dup
+//go:cgo_import_dynamic libc_dup dup "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Dup2(from int, to int) (err error) {
- _, _, e1 := Syscall(SYS_DUP2, uintptr(from), uintptr(to), 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_dup2_trampoline), uintptr(from), uintptr(to), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_dup2_trampoline()
+
+//go:linkname libc_dup2 libc_dup2
+//go:cgo_import_dynamic libc_dup2 dup2 "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Exchangedata(path1 string, path2 string, options int) (err error) {
@@ -695,20 +1000,30 @@ func Exchangedata(path1 string, path2 string, options int) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall(SYS_EXCHANGEDATA, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(options))
+ _, _, e1 := syscall_syscall(funcPC(libc_exchangedata_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(options))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_exchangedata_trampoline()
+
+//go:linkname libc_exchangedata libc_exchangedata
+//go:cgo_import_dynamic libc_exchangedata exchangedata "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Exit(code int) {
- Syscall(SYS_EXIT, uintptr(code), 0, 0)
+ syscall_syscall(funcPC(libc_exit_trampoline), uintptr(code), 0, 0)
return
}
+func libc_exit_trampoline()
+
+//go:linkname libc_exit libc_exit
+//go:cgo_import_dynamic libc_exit exit "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Faccessat(dirfd int, path string, mode uint32, flags int) (err error) {
@@ -717,43 +1032,63 @@ func Faccessat(dirfd int, path string, mode uint32, flags int) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall6(SYS_FACCESSAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0)
+ _, _, e1 := syscall_syscall6(funcPC(libc_faccessat_trampoline), uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_faccessat_trampoline()
+
+//go:linkname libc_faccessat libc_faccessat
+//go:cgo_import_dynamic libc_faccessat faccessat "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Fchdir(fd int) (err error) {
- _, _, e1 := Syscall(SYS_FCHDIR, uintptr(fd), 0, 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_fchdir_trampoline), uintptr(fd), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_fchdir_trampoline()
+
+//go:linkname libc_fchdir libc_fchdir
+//go:cgo_import_dynamic libc_fchdir fchdir "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Fchflags(fd int, flags int) (err error) {
- _, _, e1 := Syscall(SYS_FCHFLAGS, uintptr(fd), uintptr(flags), 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_fchflags_trampoline), uintptr(fd), uintptr(flags), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_fchflags_trampoline()
+
+//go:linkname libc_fchflags libc_fchflags
+//go:cgo_import_dynamic libc_fchflags fchflags "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Fchmod(fd int, mode uint32) (err error) {
- _, _, e1 := Syscall(SYS_FCHMOD, uintptr(fd), uintptr(mode), 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_fchmod_trampoline), uintptr(fd), uintptr(mode), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_fchmod_trampoline()
+
+//go:linkname libc_fchmod libc_fchmod
+//go:cgo_import_dynamic libc_fchmod fchmod "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) {
@@ -762,23 +1097,33 @@ func Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall6(SYS_FCHMODAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0)
+ _, _, e1 := syscall_syscall6(funcPC(libc_fchmodat_trampoline), uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_fchmodat_trampoline()
+
+//go:linkname libc_fchmodat libc_fchmodat
+//go:cgo_import_dynamic libc_fchmodat fchmodat "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Fchown(fd int, uid int, gid int) (err error) {
- _, _, e1 := Syscall(SYS_FCHOWN, uintptr(fd), uintptr(uid), uintptr(gid))
+ _, _, e1 := syscall_syscall(funcPC(libc_fchown_trampoline), uintptr(fd), uintptr(uid), uintptr(gid))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_fchown_trampoline()
+
+//go:linkname libc_fchown libc_fchown
+//go:cgo_import_dynamic libc_fchown fchown "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error) {
@@ -787,142 +1132,135 @@ func Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall6(SYS_FCHOWNAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid), uintptr(flags), 0)
+ _, _, e1 := syscall_syscall6(funcPC(libc_fchownat_trampoline), uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid), uintptr(flags), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+func libc_fchownat_trampoline()
-func Flock(fd int, how int) (err error) {
- _, _, e1 := Syscall(SYS_FLOCK, uintptr(fd), uintptr(how), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
+//go:linkname libc_fchownat libc_fchownat
+//go:cgo_import_dynamic libc_fchownat fchownat "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-func Fpathconf(fd int, name int) (val int, err error) {
- r0, _, e1 := Syscall(SYS_FPATHCONF, uintptr(fd), uintptr(name), 0)
- val = int(r0)
+func Flock(fd int, how int) (err error) {
+ _, _, e1 := syscall_syscall(funcPC(libc_flock_trampoline), uintptr(fd), uintptr(how), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+func libc_flock_trampoline()
-func Fstat(fd int, stat *Stat_t) (err error) {
- _, _, e1 := Syscall(SYS_FSTAT64, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
+//go:linkname libc_flock libc_flock
+//go:cgo_import_dynamic libc_flock flock "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-func Fstatat(fd int, path string, stat *Stat_t, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall6(SYS_FSTATAT64, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), uintptr(flags), 0, 0)
+func Fpathconf(fd int, name int) (val int, err error) {
+ r0, _, e1 := syscall_syscall(funcPC(libc_fpathconf_trampoline), uintptr(fd), uintptr(name), 0)
+ val = int(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+func libc_fpathconf_trampoline()
-func Fstatfs(fd int, stat *Statfs_t) (err error) {
- _, _, e1 := Syscall(SYS_FSTATFS64, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
+//go:linkname libc_fpathconf libc_fpathconf
+//go:cgo_import_dynamic libc_fpathconf fpathconf "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Fsync(fd int) (err error) {
- _, _, e1 := Syscall(SYS_FSYNC, uintptr(fd), 0, 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_fsync_trampoline), uintptr(fd), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_fsync_trampoline()
+
+//go:linkname libc_fsync libc_fsync
+//go:cgo_import_dynamic libc_fsync fsync "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Ftruncate(fd int, length int64) (err error) {
- _, _, e1 := Syscall(SYS_FTRUNCATE, uintptr(fd), uintptr(length), 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_ftruncate_trampoline), uintptr(fd), uintptr(length), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+func libc_ftruncate_trampoline()
-func Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) {
- var _p0 unsafe.Pointer
- if len(buf) > 0 {
- _p0 = unsafe.Pointer(&buf[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- r0, _, e1 := Syscall6(SYS_GETDIRENTRIES64, uintptr(fd), uintptr(_p0), uintptr(len(buf)), uintptr(unsafe.Pointer(basep)), 0, 0)
- n = int(r0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
+//go:linkname libc_ftruncate libc_ftruncate
+//go:cgo_import_dynamic libc_ftruncate ftruncate "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Getdtablesize() (size int) {
- r0, _, _ := Syscall(SYS_GETDTABLESIZE, 0, 0, 0)
+ r0, _, _ := syscall_syscall(funcPC(libc_getdtablesize_trampoline), 0, 0, 0)
size = int(r0)
return
}
+func libc_getdtablesize_trampoline()
+
+//go:linkname libc_getdtablesize libc_getdtablesize
+//go:cgo_import_dynamic libc_getdtablesize getdtablesize "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Getegid() (egid int) {
- r0, _, _ := RawSyscall(SYS_GETEGID, 0, 0, 0)
+ r0, _, _ := syscall_rawSyscall(funcPC(libc_getegid_trampoline), 0, 0, 0)
egid = int(r0)
return
}
+func libc_getegid_trampoline()
+
+//go:linkname libc_getegid libc_getegid
+//go:cgo_import_dynamic libc_getegid getegid "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Geteuid() (uid int) {
- r0, _, _ := RawSyscall(SYS_GETEUID, 0, 0, 0)
+ r0, _, _ := syscall_rawSyscall(funcPC(libc_geteuid_trampoline), 0, 0, 0)
uid = int(r0)
return
}
+func libc_geteuid_trampoline()
+
+//go:linkname libc_geteuid libc_geteuid
+//go:cgo_import_dynamic libc_geteuid geteuid "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Getgid() (gid int) {
- r0, _, _ := RawSyscall(SYS_GETGID, 0, 0, 0)
+ r0, _, _ := syscall_rawSyscall(funcPC(libc_getgid_trampoline), 0, 0, 0)
gid = int(r0)
return
}
+func libc_getgid_trampoline()
+
+//go:linkname libc_getgid libc_getgid
+//go:cgo_import_dynamic libc_getgid getgid "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Getpgid(pid int) (pgid int, err error) {
- r0, _, e1 := RawSyscall(SYS_GETPGID, uintptr(pid), 0, 0)
+ r0, _, e1 := syscall_rawSyscall(funcPC(libc_getpgid_trampoline), uintptr(pid), 0, 0)
pgid = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -930,34 +1268,54 @@ func Getpgid(pid int) (pgid int, err error) {
return
}
+func libc_getpgid_trampoline()
+
+//go:linkname libc_getpgid libc_getpgid
+//go:cgo_import_dynamic libc_getpgid getpgid "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Getpgrp() (pgrp int) {
- r0, _, _ := RawSyscall(SYS_GETPGRP, 0, 0, 0)
+ r0, _, _ := syscall_rawSyscall(funcPC(libc_getpgrp_trampoline), 0, 0, 0)
pgrp = int(r0)
return
}
+func libc_getpgrp_trampoline()
+
+//go:linkname libc_getpgrp libc_getpgrp
+//go:cgo_import_dynamic libc_getpgrp getpgrp "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Getpid() (pid int) {
- r0, _, _ := RawSyscall(SYS_GETPID, 0, 0, 0)
+ r0, _, _ := syscall_rawSyscall(funcPC(libc_getpid_trampoline), 0, 0, 0)
pid = int(r0)
return
}
+func libc_getpid_trampoline()
+
+//go:linkname libc_getpid libc_getpid
+//go:cgo_import_dynamic libc_getpid getpid "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Getppid() (ppid int) {
- r0, _, _ := RawSyscall(SYS_GETPPID, 0, 0, 0)
+ r0, _, _ := syscall_rawSyscall(funcPC(libc_getppid_trampoline), 0, 0, 0)
ppid = int(r0)
return
}
+func libc_getppid_trampoline()
+
+//go:linkname libc_getppid libc_getppid
+//go:cgo_import_dynamic libc_getppid getppid "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Getpriority(which int, who int) (prio int, err error) {
- r0, _, e1 := Syscall(SYS_GETPRIORITY, uintptr(which), uintptr(who), 0)
+ r0, _, e1 := syscall_syscall(funcPC(libc_getpriority_trampoline), uintptr(which), uintptr(who), 0)
prio = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -965,30 +1323,45 @@ func Getpriority(which int, who int) (prio int, err error) {
return
}
+func libc_getpriority_trampoline()
+
+//go:linkname libc_getpriority libc_getpriority
+//go:cgo_import_dynamic libc_getpriority getpriority "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Getrlimit(which int, lim *Rlimit) (err error) {
- _, _, e1 := RawSyscall(SYS_GETRLIMIT, uintptr(which), uintptr(unsafe.Pointer(lim)), 0)
+ _, _, e1 := syscall_rawSyscall(funcPC(libc_getrlimit_trampoline), uintptr(which), uintptr(unsafe.Pointer(lim)), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_getrlimit_trampoline()
+
+//go:linkname libc_getrlimit libc_getrlimit
+//go:cgo_import_dynamic libc_getrlimit getrlimit "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Getrusage(who int, rusage *Rusage) (err error) {
- _, _, e1 := RawSyscall(SYS_GETRUSAGE, uintptr(who), uintptr(unsafe.Pointer(rusage)), 0)
+ _, _, e1 := syscall_rawSyscall(funcPC(libc_getrusage_trampoline), uintptr(who), uintptr(unsafe.Pointer(rusage)), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_getrusage_trampoline()
+
+//go:linkname libc_getrusage libc_getrusage
+//go:cgo_import_dynamic libc_getrusage getrusage "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Getsid(pid int) (sid int, err error) {
- r0, _, e1 := RawSyscall(SYS_GETSID, uintptr(pid), 0, 0)
+ r0, _, e1 := syscall_rawSyscall(funcPC(libc_getsid_trampoline), uintptr(pid), 0, 0)
sid = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -996,26 +1369,41 @@ func Getsid(pid int) (sid int, err error) {
return
}
+func libc_getsid_trampoline()
+
+//go:linkname libc_getsid libc_getsid
+//go:cgo_import_dynamic libc_getsid getsid "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Getuid() (uid int) {
- r0, _, _ := RawSyscall(SYS_GETUID, 0, 0, 0)
+ r0, _, _ := syscall_rawSyscall(funcPC(libc_getuid_trampoline), 0, 0, 0)
uid = int(r0)
return
}
+func libc_getuid_trampoline()
+
+//go:linkname libc_getuid libc_getuid
+//go:cgo_import_dynamic libc_getuid getuid "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Issetugid() (tainted bool) {
- r0, _, _ := RawSyscall(SYS_ISSETUGID, 0, 0, 0)
+ r0, _, _ := syscall_rawSyscall(funcPC(libc_issetugid_trampoline), 0, 0, 0)
tainted = bool(r0 != 0)
return
}
+func libc_issetugid_trampoline()
+
+//go:linkname libc_issetugid libc_issetugid
+//go:cgo_import_dynamic libc_issetugid issetugid "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Kqueue() (fd int, err error) {
- r0, _, e1 := Syscall(SYS_KQUEUE, 0, 0, 0)
+ r0, _, e1 := syscall_syscall(funcPC(libc_kqueue_trampoline), 0, 0, 0)
fd = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -1023,6 +1411,11 @@ func Kqueue() (fd int, err error) {
return
}
+func libc_kqueue_trampoline()
+
+//go:linkname libc_kqueue libc_kqueue
+//go:cgo_import_dynamic libc_kqueue kqueue "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Lchown(path string, uid int, gid int) (err error) {
@@ -1031,13 +1424,18 @@ func Lchown(path string, uid int, gid int) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall(SYS_LCHOWN, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid))
+ _, _, e1 := syscall_syscall(funcPC(libc_lchown_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_lchown_trampoline()
+
+//go:linkname libc_lchown libc_lchown
+//go:cgo_import_dynamic libc_lchown lchown "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Link(path string, link string) (err error) {
@@ -1051,13 +1449,18 @@ func Link(path string, link string) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall(SYS_LINK, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_link_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_link_trampoline()
+
+//go:linkname libc_link libc_link
+//go:cgo_import_dynamic libc_link link "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Linkat(pathfd int, path string, linkfd int, link string, flags int) (err error) {
@@ -1071,37 +1474,32 @@ func Linkat(pathfd int, path string, linkfd int, link string, flags int) (err er
if err != nil {
return
}
- _, _, e1 := Syscall6(SYS_LINKAT, uintptr(pathfd), uintptr(unsafe.Pointer(_p0)), uintptr(linkfd), uintptr(unsafe.Pointer(_p1)), uintptr(flags), 0)
+ _, _, e1 := syscall_syscall6(funcPC(libc_linkat_trampoline), uintptr(pathfd), uintptr(unsafe.Pointer(_p0)), uintptr(linkfd), uintptr(unsafe.Pointer(_p1)), uintptr(flags), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_linkat_trampoline()
+
+//go:linkname libc_linkat libc_linkat
+//go:cgo_import_dynamic libc_linkat linkat "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Listen(s int, backlog int) (err error) {
- _, _, e1 := Syscall(SYS_LISTEN, uintptr(s), uintptr(backlog), 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_listen_trampoline), uintptr(s), uintptr(backlog), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+func libc_listen_trampoline()
-func Lstat(path string, stat *Stat_t) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_LSTAT64, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
+//go:linkname libc_listen libc_listen
+//go:cgo_import_dynamic libc_listen listen "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
@@ -1111,13 +1509,18 @@ func Mkdir(path string, mode uint32) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall(SYS_MKDIR, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_mkdir_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_mkdir_trampoline()
+
+//go:linkname libc_mkdir libc_mkdir
+//go:cgo_import_dynamic libc_mkdir mkdir "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Mkdirat(dirfd int, path string, mode uint32) (err error) {
@@ -1126,13 +1529,18 @@ func Mkdirat(dirfd int, path string, mode uint32) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall(SYS_MKDIRAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode))
+ _, _, e1 := syscall_syscall(funcPC(libc_mkdirat_trampoline), uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_mkdirat_trampoline()
+
+//go:linkname libc_mkdirat libc_mkdirat
+//go:cgo_import_dynamic libc_mkdirat mkdirat "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Mkfifo(path string, mode uint32) (err error) {
@@ -1141,13 +1549,18 @@ func Mkfifo(path string, mode uint32) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall(SYS_MKFIFO, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_mkfifo_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_mkfifo_trampoline()
+
+//go:linkname libc_mkfifo libc_mkfifo
+//go:cgo_import_dynamic libc_mkfifo mkfifo "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Mknod(path string, mode uint32, dev int) (err error) {
@@ -1156,13 +1569,18 @@ func Mknod(path string, mode uint32, dev int) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall(SYS_MKNOD, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(dev))
+ _, _, e1 := syscall_syscall(funcPC(libc_mknod_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(dev))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_mknod_trampoline()
+
+//go:linkname libc_mknod libc_mknod
+//go:cgo_import_dynamic libc_mknod mknod "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Open(path string, mode int, perm uint32) (fd int, err error) {
@@ -1171,7 +1589,7 @@ func Open(path string, mode int, perm uint32) (fd int, err error) {
if err != nil {
return
}
- r0, _, e1 := Syscall(SYS_OPEN, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(perm))
+ r0, _, e1 := syscall_syscall(funcPC(libc_open_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(perm))
fd = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -1179,6 +1597,11 @@ func Open(path string, mode int, perm uint32) (fd int, err error) {
return
}
+func libc_open_trampoline()
+
+//go:linkname libc_open libc_open
+//go:cgo_import_dynamic libc_open open "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Openat(dirfd int, path string, mode int, perm uint32) (fd int, err error) {
@@ -1187,7 +1610,7 @@ func Openat(dirfd int, path string, mode int, perm uint32) (fd int, err error) {
if err != nil {
return
}
- r0, _, e1 := Syscall6(SYS_OPENAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(perm), 0, 0)
+ r0, _, e1 := syscall_syscall6(funcPC(libc_openat_trampoline), uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(perm), 0, 0)
fd = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -1195,6 +1618,11 @@ func Openat(dirfd int, path string, mode int, perm uint32) (fd int, err error) {
return
}
+func libc_openat_trampoline()
+
+//go:linkname libc_openat libc_openat
+//go:cgo_import_dynamic libc_openat openat "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Pathconf(path string, name int) (val int, err error) {
@@ -1203,7 +1631,7 @@ func Pathconf(path string, name int) (val int, err error) {
if err != nil {
return
}
- r0, _, e1 := Syscall(SYS_PATHCONF, uintptr(unsafe.Pointer(_p0)), uintptr(name), 0)
+ r0, _, e1 := syscall_syscall(funcPC(libc_pathconf_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(name), 0)
val = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -1211,6 +1639,11 @@ func Pathconf(path string, name int) (val int, err error) {
return
}
+func libc_pathconf_trampoline()
+
+//go:linkname libc_pathconf libc_pathconf
+//go:cgo_import_dynamic libc_pathconf pathconf "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Pread(fd int, p []byte, offset int64) (n int, err error) {
@@ -1220,7 +1653,7 @@ func Pread(fd int, p []byte, offset int64) (n int, err error) {
} else {
_p0 = unsafe.Pointer(&_zero)
}
- r0, _, e1 := Syscall6(SYS_PREAD, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), 0, 0)
+ r0, _, e1 := syscall_syscall6(funcPC(libc_pread_trampoline), uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), 0, 0)
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -1228,6 +1661,11 @@ func Pread(fd int, p []byte, offset int64) (n int, err error) {
return
}
+func libc_pread_trampoline()
+
+//go:linkname libc_pread libc_pread
+//go:cgo_import_dynamic libc_pread pread "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Pwrite(fd int, p []byte, offset int64) (n int, err error) {
@@ -1237,7 +1675,7 @@ func Pwrite(fd int, p []byte, offset int64) (n int, err error) {
} else {
_p0 = unsafe.Pointer(&_zero)
}
- r0, _, e1 := Syscall6(SYS_PWRITE, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), 0, 0)
+ r0, _, e1 := syscall_syscall6(funcPC(libc_pwrite_trampoline), uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), 0, 0)
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -1245,6 +1683,11 @@ func Pwrite(fd int, p []byte, offset int64) (n int, err error) {
return
}
+func libc_pwrite_trampoline()
+
+//go:linkname libc_pwrite libc_pwrite
+//go:cgo_import_dynamic libc_pwrite pwrite "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func read(fd int, p []byte) (n int, err error) {
@@ -1254,7 +1697,7 @@ func read(fd int, p []byte) (n int, err error) {
} else {
_p0 = unsafe.Pointer(&_zero)
}
- r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(_p0), uintptr(len(p)))
+ r0, _, e1 := syscall_syscall(funcPC(libc_read_trampoline), uintptr(fd), uintptr(_p0), uintptr(len(p)))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -1262,6 +1705,11 @@ func read(fd int, p []byte) (n int, err error) {
return
}
+func libc_read_trampoline()
+
+//go:linkname libc_read libc_read
+//go:cgo_import_dynamic libc_read read "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Readlink(path string, buf []byte) (n int, err error) {
@@ -1276,7 +1724,7 @@ func Readlink(path string, buf []byte) (n int, err error) {
} else {
_p1 = unsafe.Pointer(&_zero)
}
- r0, _, e1 := Syscall(SYS_READLINK, uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(buf)))
+ r0, _, e1 := syscall_syscall(funcPC(libc_readlink_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(buf)))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -1284,6 +1732,11 @@ func Readlink(path string, buf []byte) (n int, err error) {
return
}
+func libc_readlink_trampoline()
+
+//go:linkname libc_readlink libc_readlink
+//go:cgo_import_dynamic libc_readlink readlink "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Readlinkat(dirfd int, path string, buf []byte) (n int, err error) {
@@ -1298,7 +1751,7 @@ func Readlinkat(dirfd int, path string, buf []byte) (n int, err error) {
} else {
_p1 = unsafe.Pointer(&_zero)
}
- r0, _, e1 := Syscall6(SYS_READLINKAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(buf)), 0, 0)
+ r0, _, e1 := syscall_syscall6(funcPC(libc_readlinkat_trampoline), uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(buf)), 0, 0)
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -1306,6 +1759,11 @@ func Readlinkat(dirfd int, path string, buf []byte) (n int, err error) {
return
}
+func libc_readlinkat_trampoline()
+
+//go:linkname libc_readlinkat libc_readlinkat
+//go:cgo_import_dynamic libc_readlinkat readlinkat "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Rename(from string, to string) (err error) {
@@ -1319,13 +1777,18 @@ func Rename(from string, to string) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall(SYS_RENAME, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_rename_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_rename_trampoline()
+
+//go:linkname libc_rename libc_rename
+//go:cgo_import_dynamic libc_rename rename "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Renameat(fromfd int, from string, tofd int, to string) (err error) {
@@ -1339,13 +1802,18 @@ func Renameat(fromfd int, from string, tofd int, to string) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall6(SYS_RENAMEAT, uintptr(fromfd), uintptr(unsafe.Pointer(_p0)), uintptr(tofd), uintptr(unsafe.Pointer(_p1)), 0, 0)
+ _, _, e1 := syscall_syscall6(funcPC(libc_renameat_trampoline), uintptr(fromfd), uintptr(unsafe.Pointer(_p0)), uintptr(tofd), uintptr(unsafe.Pointer(_p1)), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_renameat_trampoline()
+
+//go:linkname libc_renameat libc_renameat
+//go:cgo_import_dynamic libc_renameat renameat "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Revoke(path string) (err error) {
@@ -1354,13 +1822,18 @@ func Revoke(path string) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall(SYS_REVOKE, uintptr(unsafe.Pointer(_p0)), 0, 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_revoke_trampoline), uintptr(unsafe.Pointer(_p0)), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_revoke_trampoline()
+
+//go:linkname libc_revoke libc_revoke
+//go:cgo_import_dynamic libc_revoke revoke "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Rmdir(path string) (err error) {
@@ -1369,17 +1842,22 @@ func Rmdir(path string) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall(SYS_RMDIR, uintptr(unsafe.Pointer(_p0)), 0, 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_rmdir_trampoline), uintptr(unsafe.Pointer(_p0)), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_rmdir_trampoline()
+
+//go:linkname libc_rmdir libc_rmdir
+//go:cgo_import_dynamic libc_rmdir rmdir "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Seek(fd int, offset int64, whence int) (newoffset int64, err error) {
- r0, _, e1 := Syscall(SYS_LSEEK, uintptr(fd), uintptr(offset), uintptr(whence))
+ r0, _, e1 := syscall_syscall(funcPC(libc_lseek_trampoline), uintptr(fd), uintptr(offset), uintptr(whence))
newoffset = int64(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -1387,46 +1865,71 @@ func Seek(fd int, offset int64, whence int) (newoffset int64, err error) {
return
}
+func libc_lseek_trampoline()
+
+//go:linkname libc_lseek libc_lseek
+//go:cgo_import_dynamic libc_lseek lseek "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Select(n int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (err error) {
- _, _, e1 := Syscall6(SYS_SELECT, uintptr(n), uintptr(unsafe.Pointer(r)), uintptr(unsafe.Pointer(w)), uintptr(unsafe.Pointer(e)), uintptr(unsafe.Pointer(timeout)), 0)
+ _, _, e1 := syscall_syscall6(funcPC(libc_select_trampoline), uintptr(n), uintptr(unsafe.Pointer(r)), uintptr(unsafe.Pointer(w)), uintptr(unsafe.Pointer(e)), uintptr(unsafe.Pointer(timeout)), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_select_trampoline()
+
+//go:linkname libc_select libc_select
+//go:cgo_import_dynamic libc_select select "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Setegid(egid int) (err error) {
- _, _, e1 := Syscall(SYS_SETEGID, uintptr(egid), 0, 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_setegid_trampoline), uintptr(egid), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_setegid_trampoline()
+
+//go:linkname libc_setegid libc_setegid
+//go:cgo_import_dynamic libc_setegid setegid "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Seteuid(euid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETEUID, uintptr(euid), 0, 0)
+ _, _, e1 := syscall_rawSyscall(funcPC(libc_seteuid_trampoline), uintptr(euid), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_seteuid_trampoline()
+
+//go:linkname libc_seteuid libc_seteuid
+//go:cgo_import_dynamic libc_seteuid seteuid "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Setgid(gid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETGID, uintptr(gid), 0, 0)
+ _, _, e1 := syscall_rawSyscall(funcPC(libc_setgid_trampoline), uintptr(gid), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_setgid_trampoline()
+
+//go:linkname libc_setgid libc_setgid
+//go:cgo_import_dynamic libc_setgid setgid "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Setlogin(name string) (err error) {
@@ -1435,77 +1938,112 @@ func Setlogin(name string) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall(SYS_SETLOGIN, uintptr(unsafe.Pointer(_p0)), 0, 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_setlogin_trampoline), uintptr(unsafe.Pointer(_p0)), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_setlogin_trampoline()
+
+//go:linkname libc_setlogin libc_setlogin
+//go:cgo_import_dynamic libc_setlogin setlogin "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Setpgid(pid int, pgid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETPGID, uintptr(pid), uintptr(pgid), 0)
+ _, _, e1 := syscall_rawSyscall(funcPC(libc_setpgid_trampoline), uintptr(pid), uintptr(pgid), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_setpgid_trampoline()
+
+//go:linkname libc_setpgid libc_setpgid
+//go:cgo_import_dynamic libc_setpgid setpgid "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Setpriority(which int, who int, prio int) (err error) {
- _, _, e1 := Syscall(SYS_SETPRIORITY, uintptr(which), uintptr(who), uintptr(prio))
+ _, _, e1 := syscall_syscall(funcPC(libc_setpriority_trampoline), uintptr(which), uintptr(who), uintptr(prio))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_setpriority_trampoline()
+
+//go:linkname libc_setpriority libc_setpriority
+//go:cgo_import_dynamic libc_setpriority setpriority "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Setprivexec(flag int) (err error) {
- _, _, e1 := Syscall(SYS_SETPRIVEXEC, uintptr(flag), 0, 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_setprivexec_trampoline), uintptr(flag), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_setprivexec_trampoline()
+
+//go:linkname libc_setprivexec libc_setprivexec
+//go:cgo_import_dynamic libc_setprivexec setprivexec "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Setregid(rgid int, egid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETREGID, uintptr(rgid), uintptr(egid), 0)
+ _, _, e1 := syscall_rawSyscall(funcPC(libc_setregid_trampoline), uintptr(rgid), uintptr(egid), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_setregid_trampoline()
+
+//go:linkname libc_setregid libc_setregid
+//go:cgo_import_dynamic libc_setregid setregid "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Setreuid(ruid int, euid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETREUID, uintptr(ruid), uintptr(euid), 0)
+ _, _, e1 := syscall_rawSyscall(funcPC(libc_setreuid_trampoline), uintptr(ruid), uintptr(euid), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_setreuid_trampoline()
+
+//go:linkname libc_setreuid libc_setreuid
+//go:cgo_import_dynamic libc_setreuid setreuid "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Setrlimit(which int, lim *Rlimit) (err error) {
- _, _, e1 := RawSyscall(SYS_SETRLIMIT, uintptr(which), uintptr(unsafe.Pointer(lim)), 0)
+ _, _, e1 := syscall_rawSyscall(funcPC(libc_setrlimit_trampoline), uintptr(which), uintptr(unsafe.Pointer(lim)), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_setrlimit_trampoline()
+
+//go:linkname libc_setrlimit libc_setrlimit
+//go:cgo_import_dynamic libc_setrlimit setrlimit "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Setsid() (pid int, err error) {
- r0, _, e1 := RawSyscall(SYS_SETSID, 0, 0, 0)
+ r0, _, e1 := syscall_rawSyscall(funcPC(libc_setsid_trampoline), 0, 0, 0)
pid = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -1513,55 +2051,40 @@ func Setsid() (pid int, err error) {
return
}
+func libc_setsid_trampoline()
+
+//go:linkname libc_setsid libc_setsid
+//go:cgo_import_dynamic libc_setsid setsid "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Settimeofday(tp *Timeval) (err error) {
- _, _, e1 := RawSyscall(SYS_SETTIMEOFDAY, uintptr(unsafe.Pointer(tp)), 0, 0)
+ _, _, e1 := syscall_rawSyscall(funcPC(libc_settimeofday_trampoline), uintptr(unsafe.Pointer(tp)), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+func libc_settimeofday_trampoline()
-func Setuid(uid int) (err error) {
- _, _, e1 := RawSyscall(SYS_SETUID, uintptr(uid), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
+//go:linkname libc_settimeofday libc_settimeofday
+//go:cgo_import_dynamic libc_settimeofday settimeofday "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-func Stat(path string, stat *Stat_t) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_STAT64, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
+func Setuid(uid int) (err error) {
+ _, _, e1 := syscall_rawSyscall(funcPC(libc_setuid_trampoline), uintptr(uid), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+func libc_setuid_trampoline()
-func Statfs(path string, stat *Statfs_t) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_STATFS64, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
+//go:linkname libc_setuid libc_setuid
+//go:cgo_import_dynamic libc_setuid setuid "/usr/lib/libSystem.B.dylib"
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
@@ -1576,13 +2099,18 @@ func Symlink(path string, link string) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall(SYS_SYMLINK, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_symlink_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_symlink_trampoline()
+
+//go:linkname libc_symlink libc_symlink
+//go:cgo_import_dynamic libc_symlink symlink "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Symlinkat(oldpath string, newdirfd int, newpath string) (err error) {
@@ -1596,23 +2124,33 @@ func Symlinkat(oldpath string, newdirfd int, newpath string) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall(SYS_SYMLINKAT, uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1)))
+ _, _, e1 := syscall_syscall(funcPC(libc_symlinkat_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1)))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_symlinkat_trampoline()
+
+//go:linkname libc_symlinkat libc_symlinkat
+//go:cgo_import_dynamic libc_symlinkat symlinkat "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Sync() (err error) {
- _, _, e1 := Syscall(SYS_SYNC, 0, 0, 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_sync_trampoline), 0, 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_sync_trampoline()
+
+//go:linkname libc_sync libc_sync
+//go:cgo_import_dynamic libc_sync sync "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Truncate(path string, length int64) (err error) {
@@ -1621,21 +2159,31 @@ func Truncate(path string, length int64) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall(SYS_TRUNCATE, uintptr(unsafe.Pointer(_p0)), uintptr(length), 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_truncate_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(length), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_truncate_trampoline()
+
+//go:linkname libc_truncate libc_truncate
+//go:cgo_import_dynamic libc_truncate truncate "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Umask(newmask int) (oldmask int) {
- r0, _, _ := Syscall(SYS_UMASK, uintptr(newmask), 0, 0)
+ r0, _, _ := syscall_syscall(funcPC(libc_umask_trampoline), uintptr(newmask), 0, 0)
oldmask = int(r0)
return
}
+func libc_umask_trampoline()
+
+//go:linkname libc_umask libc_umask
+//go:cgo_import_dynamic libc_umask umask "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Undelete(path string) (err error) {
@@ -1644,13 +2192,18 @@ func Undelete(path string) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall(SYS_UNDELETE, uintptr(unsafe.Pointer(_p0)), 0, 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_undelete_trampoline), uintptr(unsafe.Pointer(_p0)), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_undelete_trampoline()
+
+//go:linkname libc_undelete libc_undelete
+//go:cgo_import_dynamic libc_undelete undelete "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Unlink(path string) (err error) {
@@ -1659,13 +2212,18 @@ func Unlink(path string) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall(SYS_UNLINK, uintptr(unsafe.Pointer(_p0)), 0, 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_unlink_trampoline), uintptr(unsafe.Pointer(_p0)), 0, 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_unlink_trampoline()
+
+//go:linkname libc_unlink libc_unlink
+//go:cgo_import_dynamic libc_unlink unlink "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Unlinkat(dirfd int, path string, flags int) (err error) {
@@ -1674,13 +2232,18 @@ func Unlinkat(dirfd int, path string, flags int) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall(SYS_UNLINKAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(flags))
+ _, _, e1 := syscall_syscall(funcPC(libc_unlinkat_trampoline), uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(flags))
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_unlinkat_trampoline()
+
+//go:linkname libc_unlinkat libc_unlinkat
+//go:cgo_import_dynamic libc_unlinkat unlinkat "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Unmount(path string, flags int) (err error) {
@@ -1689,13 +2252,18 @@ func Unmount(path string, flags int) (err error) {
if err != nil {
return
}
- _, _, e1 := Syscall(SYS_UNMOUNT, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_unmount_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_unmount_trampoline()
+
+//go:linkname libc_unmount libc_unmount
+//go:cgo_import_dynamic libc_unmount unmount "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func write(fd int, p []byte) (n int, err error) {
@@ -1705,7 +2273,7 @@ func write(fd int, p []byte) (n int, err error) {
} else {
_p0 = unsafe.Pointer(&_zero)
}
- r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(_p0), uintptr(len(p)))
+ r0, _, e1 := syscall_syscall(funcPC(libc_write_trampoline), uintptr(fd), uintptr(_p0), uintptr(len(p)))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -1713,10 +2281,15 @@ func write(fd int, p []byte) (n int, err error) {
return
}
+func libc_write_trampoline()
+
+//go:linkname libc_write libc_write
+//go:cgo_import_dynamic libc_write write "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error) {
- r0, _, e1 := Syscall6(SYS_MMAP, uintptr(addr), uintptr(length), uintptr(prot), uintptr(flag), uintptr(fd), uintptr(pos))
+ r0, _, e1 := syscall_syscall6(funcPC(libc_mmap_trampoline), uintptr(addr), uintptr(length), uintptr(prot), uintptr(flag), uintptr(fd), uintptr(pos))
ret = uintptr(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -1724,20 +2297,30 @@ func mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (
return
}
+func libc_mmap_trampoline()
+
+//go:linkname libc_mmap libc_mmap
+//go:cgo_import_dynamic libc_mmap mmap "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func munmap(addr uintptr, length uintptr) (err error) {
- _, _, e1 := Syscall(SYS_MUNMAP, uintptr(addr), uintptr(length), 0)
+ _, _, e1 := syscall_syscall(funcPC(libc_munmap_trampoline), uintptr(addr), uintptr(length), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
+func libc_munmap_trampoline()
+
+//go:linkname libc_munmap libc_munmap
+//go:cgo_import_dynamic libc_munmap munmap "/usr/lib/libSystem.B.dylib"
+
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func readlen(fd int, buf *byte, nbuf int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf))
+ r0, _, e1 := syscall_syscall(funcPC(libc_read_trampoline), uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -1748,7 +2331,7 @@ func readlen(fd int, buf *byte, nbuf int) (n int, err error) {
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func writelen(fd int, buf *byte, nbuf int) (n int, err error) {
- r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf))
+ r0, _, e1 := syscall_syscall(funcPC(libc_write_trampoline), uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)
@@ -1759,7 +2342,7 @@ func writelen(fd int, buf *byte, nbuf int) (n int, err error) {
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func gettimeofday(tp *Timeval) (sec int64, usec int32, err error) {
- r0, r1, e1 := RawSyscall(SYS_GETTIMEOFDAY, uintptr(unsafe.Pointer(tp)), 0, 0)
+ r0, r1, e1 := syscall_rawSyscall(funcPC(libc_gettimeofday_trampoline), uintptr(unsafe.Pointer(tp)), 0, 0)
sec = int64(r0)
usec = int32(r1)
if e1 != 0 {
@@ -1767,3 +2350,134 @@ func gettimeofday(tp *Timeval) (sec int64, usec int32, err error) {
}
return
}
+
+func libc_gettimeofday_trampoline()
+
+//go:linkname libc_gettimeofday libc_gettimeofday
+//go:cgo_import_dynamic libc_gettimeofday gettimeofday "/usr/lib/libSystem.B.dylib"
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Fstat(fd int, stat *Stat_t) (err error) {
+ _, _, e1 := syscall_syscall(funcPC(libc_fstat_trampoline), uintptr(fd), uintptr(unsafe.Pointer(stat)), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func libc_fstat_trampoline()
+
+//go:linkname libc_fstat libc_fstat
+//go:cgo_import_dynamic libc_fstat fstat "/usr/lib/libSystem.B.dylib"
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Fstatat(fd int, path string, stat *Stat_t, flags int) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := syscall_syscall6(funcPC(libc_fstatat_trampoline), uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), uintptr(flags), 0, 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func libc_fstatat_trampoline()
+
+//go:linkname libc_fstatat libc_fstatat
+//go:cgo_import_dynamic libc_fstatat fstatat "/usr/lib/libSystem.B.dylib"
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Fstatfs(fd int, stat *Statfs_t) (err error) {
+ _, _, e1 := syscall_syscall(funcPC(libc_fstatfs_trampoline), uintptr(fd), uintptr(unsafe.Pointer(stat)), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func libc_fstatfs_trampoline()
+
+//go:linkname libc_fstatfs libc_fstatfs
+//go:cgo_import_dynamic libc_fstatfs fstatfs "/usr/lib/libSystem.B.dylib"
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func getfsstat(buf unsafe.Pointer, size uintptr, flags int) (n int, err error) {
+ r0, _, e1 := syscall_syscall(funcPC(libc_getfsstat_trampoline), uintptr(buf), uintptr(size), uintptr(flags))
+ n = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func libc_getfsstat_trampoline()
+
+//go:linkname libc_getfsstat libc_getfsstat
+//go:cgo_import_dynamic libc_getfsstat getfsstat "/usr/lib/libSystem.B.dylib"
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Lstat(path string, stat *Stat_t) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := syscall_syscall(funcPC(libc_lstat_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func libc_lstat_trampoline()
+
+//go:linkname libc_lstat libc_lstat
+//go:cgo_import_dynamic libc_lstat lstat "/usr/lib/libSystem.B.dylib"
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Stat(path string, stat *Stat_t) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := syscall_syscall(funcPC(libc_stat_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func libc_stat_trampoline()
+
+//go:linkname libc_stat libc_stat
+//go:cgo_import_dynamic libc_stat stat "/usr/lib/libSystem.B.dylib"
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Statfs(path string, stat *Statfs_t) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := syscall_syscall(funcPC(libc_statfs_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func libc_statfs_trampoline()
+
+//go:linkname libc_statfs libc_statfs
+//go:cgo_import_dynamic libc_statfs statfs "/usr/lib/libSystem.B.dylib"
diff --git a/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.s b/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.s
new file mode 100644
index 000000000..61dc0d4c1
--- /dev/null
+++ b/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.s
@@ -0,0 +1,282 @@
+// go run mkasm_darwin.go arm64
+// Code generated by the command above; DO NOT EDIT.
+
+// +build go1.12
+
+#include "textflag.h"
+TEXT ·libc_getgroups_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_getgroups(SB)
+TEXT ·libc_setgroups_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_setgroups(SB)
+TEXT ·libc_wait4_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_wait4(SB)
+TEXT ·libc_accept_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_accept(SB)
+TEXT ·libc_bind_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_bind(SB)
+TEXT ·libc_connect_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_connect(SB)
+TEXT ·libc_socket_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_socket(SB)
+TEXT ·libc_getsockopt_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_getsockopt(SB)
+TEXT ·libc_setsockopt_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_setsockopt(SB)
+TEXT ·libc_getpeername_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_getpeername(SB)
+TEXT ·libc_getsockname_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_getsockname(SB)
+TEXT ·libc_shutdown_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_shutdown(SB)
+TEXT ·libc_socketpair_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_socketpair(SB)
+TEXT ·libc_recvfrom_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_recvfrom(SB)
+TEXT ·libc_sendto_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_sendto(SB)
+TEXT ·libc_recvmsg_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_recvmsg(SB)
+TEXT ·libc_sendmsg_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_sendmsg(SB)
+TEXT ·libc_kevent_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_kevent(SB)
+TEXT ·libc___sysctl_trampoline(SB),NOSPLIT,$0-0
+ JMP libc___sysctl(SB)
+TEXT ·libc_utimes_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_utimes(SB)
+TEXT ·libc_futimes_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_futimes(SB)
+TEXT ·libc_fcntl_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_fcntl(SB)
+TEXT ·libc_poll_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_poll(SB)
+TEXT ·libc_madvise_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_madvise(SB)
+TEXT ·libc_mlock_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_mlock(SB)
+TEXT ·libc_mlockall_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_mlockall(SB)
+TEXT ·libc_mprotect_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_mprotect(SB)
+TEXT ·libc_msync_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_msync(SB)
+TEXT ·libc_munlock_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_munlock(SB)
+TEXT ·libc_munlockall_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_munlockall(SB)
+TEXT ·libc_ptrace_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_ptrace(SB)
+TEXT ·libc_getattrlist_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_getattrlist(SB)
+TEXT ·libc_pipe_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_pipe(SB)
+TEXT ·libc_getxattr_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_getxattr(SB)
+TEXT ·libc_fgetxattr_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_fgetxattr(SB)
+TEXT ·libc_setxattr_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_setxattr(SB)
+TEXT ·libc_fsetxattr_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_fsetxattr(SB)
+TEXT ·libc_removexattr_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_removexattr(SB)
+TEXT ·libc_fremovexattr_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_fremovexattr(SB)
+TEXT ·libc_listxattr_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_listxattr(SB)
+TEXT ·libc_flistxattr_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_flistxattr(SB)
+TEXT ·libc_setattrlist_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_setattrlist(SB)
+TEXT ·libc_kill_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_kill(SB)
+TEXT ·libc_ioctl_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_ioctl(SB)
+TEXT ·libc_sendfile_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_sendfile(SB)
+TEXT ·libc_access_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_access(SB)
+TEXT ·libc_adjtime_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_adjtime(SB)
+TEXT ·libc_chdir_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_chdir(SB)
+TEXT ·libc_chflags_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_chflags(SB)
+TEXT ·libc_chmod_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_chmod(SB)
+TEXT ·libc_chown_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_chown(SB)
+TEXT ·libc_chroot_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_chroot(SB)
+TEXT ·libc_close_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_close(SB)
+TEXT ·libc_dup_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_dup(SB)
+TEXT ·libc_dup2_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_dup2(SB)
+TEXT ·libc_exchangedata_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_exchangedata(SB)
+TEXT ·libc_exit_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_exit(SB)
+TEXT ·libc_faccessat_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_faccessat(SB)
+TEXT ·libc_fchdir_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_fchdir(SB)
+TEXT ·libc_fchflags_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_fchflags(SB)
+TEXT ·libc_fchmod_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_fchmod(SB)
+TEXT ·libc_fchmodat_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_fchmodat(SB)
+TEXT ·libc_fchown_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_fchown(SB)
+TEXT ·libc_fchownat_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_fchownat(SB)
+TEXT ·libc_flock_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_flock(SB)
+TEXT ·libc_fpathconf_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_fpathconf(SB)
+TEXT ·libc_fsync_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_fsync(SB)
+TEXT ·libc_ftruncate_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_ftruncate(SB)
+TEXT ·libc_getdtablesize_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_getdtablesize(SB)
+TEXT ·libc_getegid_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_getegid(SB)
+TEXT ·libc_geteuid_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_geteuid(SB)
+TEXT ·libc_getgid_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_getgid(SB)
+TEXT ·libc_getpgid_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_getpgid(SB)
+TEXT ·libc_getpgrp_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_getpgrp(SB)
+TEXT ·libc_getpid_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_getpid(SB)
+TEXT ·libc_getppid_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_getppid(SB)
+TEXT ·libc_getpriority_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_getpriority(SB)
+TEXT ·libc_getrlimit_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_getrlimit(SB)
+TEXT ·libc_getrusage_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_getrusage(SB)
+TEXT ·libc_getsid_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_getsid(SB)
+TEXT ·libc_getuid_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_getuid(SB)
+TEXT ·libc_issetugid_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_issetugid(SB)
+TEXT ·libc_kqueue_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_kqueue(SB)
+TEXT ·libc_lchown_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_lchown(SB)
+TEXT ·libc_link_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_link(SB)
+TEXT ·libc_linkat_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_linkat(SB)
+TEXT ·libc_listen_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_listen(SB)
+TEXT ·libc_mkdir_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_mkdir(SB)
+TEXT ·libc_mkdirat_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_mkdirat(SB)
+TEXT ·libc_mkfifo_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_mkfifo(SB)
+TEXT ·libc_mknod_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_mknod(SB)
+TEXT ·libc_open_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_open(SB)
+TEXT ·libc_openat_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_openat(SB)
+TEXT ·libc_pathconf_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_pathconf(SB)
+TEXT ·libc_pread_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_pread(SB)
+TEXT ·libc_pwrite_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_pwrite(SB)
+TEXT ·libc_read_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_read(SB)
+TEXT ·libc_readlink_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_readlink(SB)
+TEXT ·libc_readlinkat_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_readlinkat(SB)
+TEXT ·libc_rename_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_rename(SB)
+TEXT ·libc_renameat_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_renameat(SB)
+TEXT ·libc_revoke_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_revoke(SB)
+TEXT ·libc_rmdir_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_rmdir(SB)
+TEXT ·libc_lseek_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_lseek(SB)
+TEXT ·libc_select_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_select(SB)
+TEXT ·libc_setegid_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_setegid(SB)
+TEXT ·libc_seteuid_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_seteuid(SB)
+TEXT ·libc_setgid_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_setgid(SB)
+TEXT ·libc_setlogin_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_setlogin(SB)
+TEXT ·libc_setpgid_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_setpgid(SB)
+TEXT ·libc_setpriority_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_setpriority(SB)
+TEXT ·libc_setprivexec_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_setprivexec(SB)
+TEXT ·libc_setregid_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_setregid(SB)
+TEXT ·libc_setreuid_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_setreuid(SB)
+TEXT ·libc_setrlimit_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_setrlimit(SB)
+TEXT ·libc_setsid_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_setsid(SB)
+TEXT ·libc_settimeofday_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_settimeofday(SB)
+TEXT ·libc_setuid_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_setuid(SB)
+TEXT ·libc_symlink_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_symlink(SB)
+TEXT ·libc_symlinkat_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_symlinkat(SB)
+TEXT ·libc_sync_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_sync(SB)
+TEXT ·libc_truncate_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_truncate(SB)
+TEXT ·libc_umask_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_umask(SB)
+TEXT ·libc_undelete_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_undelete(SB)
+TEXT ·libc_unlink_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_unlink(SB)
+TEXT ·libc_unlinkat_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_unlinkat(SB)
+TEXT ·libc_unmount_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_unmount(SB)
+TEXT ·libc_write_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_write(SB)
+TEXT ·libc_mmap_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_mmap(SB)
+TEXT ·libc_munmap_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_munmap(SB)
+TEXT ·libc_gettimeofday_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_gettimeofday(SB)
+TEXT ·libc_fstat_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_fstat(SB)
+TEXT ·libc_fstatat_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_fstatat(SB)
+TEXT ·libc_fstatfs_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_fstatfs(SB)
+TEXT ·libc_getfsstat_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_getfsstat(SB)
+TEXT ·libc_lstat_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_lstat(SB)
+TEXT ·libc_stat_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_stat(SB)
+TEXT ·libc_statfs_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_statfs(SB)
diff --git a/vendor/golang.org/x/sys/unix/zsyscall_dragonfly_amd64.go b/vendor/golang.org/x/sys/unix/zsyscall_dragonfly_amd64.go
index 96a671344..da9986dd2 100644
--- a/vendor/golang.org/x/sys/unix/zsyscall_dragonfly_amd64.go
+++ b/vendor/golang.org/x/sys/unix/zsyscall_dragonfly_amd64.go
@@ -1,4 +1,4 @@
-// mksyscall.pl -dragonfly -tags dragonfly,amd64 syscall_bsd.go syscall_dragonfly.go syscall_dragonfly_amd64.go
+// go run mksyscall.go -dragonfly -tags dragonfly,amd64 syscall_bsd.go syscall_dragonfly.go syscall_dragonfly_amd64.go
// Code generated by the command above; see README.md. DO NOT EDIT.
// +build dragonfly,amd64
diff --git a/vendor/golang.org/x/sys/unix/zsyscall_freebsd_386.go b/vendor/golang.org/x/sys/unix/zsyscall_freebsd_386.go
index 9bbbf9662..80903e47b 100644
--- a/vendor/golang.org/x/sys/unix/zsyscall_freebsd_386.go
+++ b/vendor/golang.org/x/sys/unix/zsyscall_freebsd_386.go
@@ -1,4 +1,4 @@
-// mksyscall.pl -l32 -tags freebsd,386 syscall_bsd.go syscall_freebsd.go syscall_freebsd_386.go
+// go run mksyscall.go -l32 -tags freebsd,386 syscall_bsd.go syscall_freebsd.go syscall_freebsd_386.go
// Code generated by the command above; see README.md. DO NOT EDIT.
// +build freebsd,386
diff --git a/vendor/golang.org/x/sys/unix/zsyscall_freebsd_amd64.go b/vendor/golang.org/x/sys/unix/zsyscall_freebsd_amd64.go
index ee7090ff4..cd250ff0e 100644
--- a/vendor/golang.org/x/sys/unix/zsyscall_freebsd_amd64.go
+++ b/vendor/golang.org/x/sys/unix/zsyscall_freebsd_amd64.go
@@ -1,4 +1,4 @@
-// mksyscall.pl -tags freebsd,amd64 syscall_bsd.go syscall_freebsd.go syscall_freebsd_amd64.go
+// go run mksyscall.go -tags freebsd,amd64 syscall_bsd.go syscall_freebsd.go syscall_freebsd_amd64.go
// Code generated by the command above; see README.md. DO NOT EDIT.
// +build freebsd,amd64
diff --git a/vendor/golang.org/x/sys/unix/zsyscall_freebsd_arm.go b/vendor/golang.org/x/sys/unix/zsyscall_freebsd_arm.go
index 9aeff5131..290a9c2cb 100644
--- a/vendor/golang.org/x/sys/unix/zsyscall_freebsd_arm.go
+++ b/vendor/golang.org/x/sys/unix/zsyscall_freebsd_arm.go
@@ -1,4 +1,4 @@
-// mksyscall.pl -l32 -arm -tags freebsd,arm syscall_bsd.go syscall_freebsd.go syscall_freebsd_arm.go
+// go run mksyscall.go -l32 -arm -tags freebsd,arm syscall_bsd.go syscall_freebsd.go syscall_freebsd_arm.go
// Code generated by the command above; see README.md. DO NOT EDIT.
// +build freebsd,arm
diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_386.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_386.go
index cd94680d1..5356a5175 100644
--- a/vendor/golang.org/x/sys/unix/zsyscall_linux_386.go
+++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_386.go
@@ -1,4 +1,4 @@
-// mksyscall.pl -l32 -tags linux,386 syscall_linux.go syscall_linux_386.go
+// go run mksyscall.go -l32 -tags linux,386 syscall_linux.go syscall_linux_386.go
// Code generated by the command above; see README.md. DO NOT EDIT.
// +build linux,386
diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_amd64.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_amd64.go
index 96e9df7da..0f6d265d8 100644
--- a/vendor/golang.org/x/sys/unix/zsyscall_linux_amd64.go
+++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_amd64.go
@@ -1,4 +1,4 @@
-// mksyscall.pl -tags linux,amd64 syscall_linux.go syscall_linux_amd64.go
+// go run mksyscall.go -tags linux,amd64 syscall_linux.go syscall_linux_amd64.go
// Code generated by the command above; see README.md. DO NOT EDIT.
// +build linux,amd64
@@ -1806,7 +1806,7 @@ func Getuid() (uid int) {
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-func InotifyInit() (fd int, err error) {
+func inotifyInit() (fd int, err error) {
r0, _, e1 := RawSyscall(SYS_INOTIFY_INIT, 0, 0, 0)
fd = int(r0)
if e1 != 0 {
@@ -1862,21 +1862,6 @@ func Listen(s int, n int) (err error) {
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-func Lstat(path string, stat *Stat_t) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall(SYS_LSTAT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
func Pause() (err error) {
_, _, e1 := Syscall(SYS_PAUSE, 0, 0, 0)
if e1 != 0 {
diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_arm.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_arm.go
index e8d82d14c..012261ad5 100644
--- a/vendor/golang.org/x/sys/unix/zsyscall_linux_arm.go
+++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_arm.go
@@ -1,4 +1,4 @@
-// mksyscall.pl -l32 -arm -tags linux,arm syscall_linux.go syscall_linux_arm.go
+// go run mksyscall.go -l32 -arm -tags linux,arm syscall_linux.go syscall_linux_arm.go
// Code generated by the command above; see README.md. DO NOT EDIT.
// +build linux,arm
@@ -2282,3 +2282,13 @@ func poll(fds *PollFd, nfds int, timeout int) (n int, err error) {
}
return
}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func armSyncFileRange(fd int, flags int, off int64, n int64) (err error) {
+ _, _, e1 := Syscall6(SYS_ARM_SYNC_FILE_RANGE, uintptr(fd), uintptr(flags), uintptr(off), uintptr(off>>32), uintptr(n), uintptr(n>>32))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_arm64.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_arm64.go
index 41f2d0cf0..b890cb03c 100644
--- a/vendor/golang.org/x/sys/unix/zsyscall_linux_arm64.go
+++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_arm64.go
@@ -1,4 +1,4 @@
-// mksyscall.pl -tags linux,arm64 syscall_linux.go syscall_linux_arm64.go
+// go run mksyscall.go -tags linux,arm64 syscall_linux.go syscall_linux_arm64.go
// Code generated by the command above; see README.md. DO NOT EDIT.
// +build linux,arm64
diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_mips.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_mips.go
index 7e65fe0b7..cc17b43d3 100644
--- a/vendor/golang.org/x/sys/unix/zsyscall_linux_mips.go
+++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_mips.go
@@ -1,4 +1,4 @@
-// mksyscall.pl -b32 -arm -tags linux,mips syscall_linux.go syscall_linux_mipsx.go
+// go run mksyscall.go -b32 -arm -tags linux,mips syscall_linux.go syscall_linux_mipsx.go
// Code generated by the command above; see README.md. DO NOT EDIT.
// +build linux,mips
diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64.go
index fd06fb890..caf1408ec 100644
--- a/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64.go
+++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64.go
@@ -1,4 +1,4 @@
-// mksyscall.pl -tags linux,mips64 syscall_linux.go syscall_linux_mips64x.go
+// go run mksyscall.go -tags linux,mips64 syscall_linux.go syscall_linux_mips64x.go
// Code generated by the command above; see README.md. DO NOT EDIT.
// +build linux,mips64
diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64le.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64le.go
index 9e8ec28c9..266be8b4a 100644
--- a/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64le.go
+++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64le.go
@@ -1,4 +1,4 @@
-// mksyscall.pl -tags linux,mips64le syscall_linux.go syscall_linux_mips64x.go
+// go run mksyscall.go -tags linux,mips64le syscall_linux.go syscall_linux_mips64x.go
// Code generated by the command above; see README.md. DO NOT EDIT.
// +build linux,mips64le
diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_mipsle.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_mipsle.go
index b4d2ccbb0..b16b3e102 100644
--- a/vendor/golang.org/x/sys/unix/zsyscall_linux_mipsle.go
+++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_mipsle.go
@@ -1,4 +1,4 @@
-// mksyscall.pl -l32 -arm -tags linux,mipsle syscall_linux.go syscall_linux_mipsx.go
+// go run mksyscall.go -l32 -arm -tags linux,mipsle syscall_linux.go syscall_linux_mipsx.go
// Code generated by the command above; see README.md. DO NOT EDIT.
// +build linux,mipsle
diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64.go
index bca3d2536..27b6a6bf0 100644
--- a/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64.go
+++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64.go
@@ -1,4 +1,4 @@
-// mksyscall.pl -tags linux,ppc64 syscall_linux.go syscall_linux_ppc64x.go
+// go run mksyscall.go -tags linux,ppc64 syscall_linux.go syscall_linux_ppc64x.go
// Code generated by the command above; see README.md. DO NOT EDIT.
// +build linux,ppc64
diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64le.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64le.go
index e34089c66..f7ecc9afd 100644
--- a/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64le.go
+++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64le.go
@@ -1,4 +1,4 @@
-// mksyscall.pl -tags linux,ppc64le syscall_linux.go syscall_linux_ppc64x.go
+// go run mksyscall.go -tags linux,ppc64le syscall_linux.go syscall_linux_ppc64x.go
// Code generated by the command above; see README.md. DO NOT EDIT.
// +build linux,ppc64le
diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_riscv64.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_riscv64.go
index 312b2afaf..e3cd4e53f 100644
--- a/vendor/golang.org/x/sys/unix/zsyscall_linux_riscv64.go
+++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_riscv64.go
@@ -1,4 +1,4 @@
-// mksyscall.pl -tags linux,riscv64 syscall_linux.go syscall_linux_riscv64.go
+// go run mksyscall.go -tags linux,riscv64 syscall_linux.go syscall_linux_riscv64.go
// Code generated by the command above; see README.md. DO NOT EDIT.
// +build linux,riscv64
diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_s390x.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_s390x.go
index 04ec8befe..3001d3798 100644
--- a/vendor/golang.org/x/sys/unix/zsyscall_linux_s390x.go
+++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_s390x.go
@@ -1,4 +1,4 @@
-// mksyscall.pl -tags linux,s390x syscall_linux.go syscall_linux_s390x.go
+// go run mksyscall.go -tags linux,s390x syscall_linux.go syscall_linux_s390x.go
// Code generated by the command above; see README.md. DO NOT EDIT.
// +build linux,s390x
diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_sparc64.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_sparc64.go
index b26aee957..aafe3660f 100644
--- a/vendor/golang.org/x/sys/unix/zsyscall_linux_sparc64.go
+++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_sparc64.go
@@ -1,4 +1,4 @@
-// mksyscall.pl -tags linux,sparc64 syscall_linux.go syscall_linux_sparc64.go
+// go run mksyscall.go -tags linux,sparc64 syscall_linux.go syscall_linux_sparc64.go
// Code generated by the command above; see README.md. DO NOT EDIT.
// +build linux,sparc64
@@ -417,6 +417,16 @@ func Chroot(path string) (err error) {
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+func ClockGetres(clockid int32, res *Timespec) (err error) {
+ _, _, e1 := Syscall(SYS_CLOCK_GETRES, uintptr(clockid), uintptr(unsafe.Pointer(res)), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
func ClockGettime(clockid int32, time *Timespec) (err error) {
_, _, e1 := Syscall(SYS_CLOCK_GETTIME, uintptr(clockid), uintptr(unsafe.Pointer(time)), 0)
if e1 != 0 {
@@ -448,6 +458,21 @@ func CopyFileRange(rfd int, roff *int64, wfd int, woff *int64, len int, flags in
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+func DeleteModule(name string, flags int) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(name)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_DELETE_MODULE, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
func Dup(oldfd int) (fd int, err error) {
r0, _, e1 := Syscall(SYS_DUP, uintptr(oldfd), 0, 0)
fd = int(r0)
@@ -508,21 +533,6 @@ func Exit(code int) {
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-func Faccessat(dirfd int, path string, mode uint32, flags int) (err error) {
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := Syscall6(SYS_FACCESSAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
func Fallocate(fd int, mode uint32, off int64, len int64) (err error) {
_, _, e1 := Syscall6(SYS_FALLOCATE, uintptr(fd), uintptr(mode), uintptr(off), uintptr(len), 0, 0)
if e1 != 0 {
@@ -589,6 +599,60 @@ func Fdatasync(fd int) (err error) {
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+func Fgetxattr(fd int, attr string, dest []byte) (sz int, err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(attr)
+ if err != nil {
+ return
+ }
+ var _p1 unsafe.Pointer
+ if len(dest) > 0 {
+ _p1 = unsafe.Pointer(&dest[0])
+ } else {
+ _p1 = unsafe.Pointer(&_zero)
+ }
+ r0, _, e1 := Syscall6(SYS_FGETXATTR, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(dest)), 0, 0)
+ sz = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func FinitModule(fd int, params string, flags int) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(params)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_FINIT_MODULE, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(flags))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Flistxattr(fd int, dest []byte) (sz int, err error) {
+ var _p0 unsafe.Pointer
+ if len(dest) > 0 {
+ _p0 = unsafe.Pointer(&dest[0])
+ } else {
+ _p0 = unsafe.Pointer(&_zero)
+ }
+ r0, _, e1 := Syscall(SYS_FLISTXATTR, uintptr(fd), uintptr(_p0), uintptr(len(dest)))
+ sz = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
func Flock(fd int, how int) (err error) {
_, _, e1 := Syscall(SYS_FLOCK, uintptr(fd), uintptr(how), 0)
if e1 != 0 {
@@ -599,6 +663,42 @@ func Flock(fd int, how int) (err error) {
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+func Fremovexattr(fd int, attr string) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(attr)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_FREMOVEXATTR, uintptr(fd), uintptr(unsafe.Pointer(_p0)), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func Fsetxattr(fd int, attr string, dest []byte, flags int) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(attr)
+ if err != nil {
+ return
+ }
+ var _p1 unsafe.Pointer
+ if len(dest) > 0 {
+ _p1 = unsafe.Pointer(&dest[0])
+ } else {
+ _p1 = unsafe.Pointer(&_zero)
+ }
+ _, _, e1 := Syscall6(SYS_FSETXATTR, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(dest)), uintptr(flags), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
func Fsync(fd int) (err error) {
_, _, e1 := Syscall(SYS_FSYNC, uintptr(fd), 0, 0)
if e1 != 0 {
@@ -737,6 +837,27 @@ func Getxattr(path string, attr string, dest []byte) (sz int, err error) {
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+func InitModule(moduleImage []byte, params string) (err error) {
+ var _p0 unsafe.Pointer
+ if len(moduleImage) > 0 {
+ _p0 = unsafe.Pointer(&moduleImage[0])
+ } else {
+ _p0 = unsafe.Pointer(&_zero)
+ }
+ var _p1 *byte
+ _p1, err = BytePtrFromString(params)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_INIT_MODULE, uintptr(_p0), uintptr(len(moduleImage)), uintptr(unsafe.Pointer(_p1)))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
func InotifyAddWatch(fd int, pathname string, mask uint32) (watchdesc int, err error) {
var _p0 *byte
_p0, err = BytePtrFromString(pathname)
@@ -919,6 +1040,22 @@ func Lsetxattr(path string, attr string, data []byte, flags int) (err error) {
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+func MemfdCreate(name string, flags int) (fd int, err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(name)
+ if err != nil {
+ return
+ }
+ r0, _, e1 := Syscall(SYS_MEMFD_CREATE, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0)
+ fd = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
func Mkdirat(dirfd int, path string, mode uint32) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(path)
@@ -1078,6 +1215,26 @@ func Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err e
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+func Renameat2(olddirfd int, oldpath string, newdirfd int, newpath string, flags uint) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(oldpath)
+ if err != nil {
+ return
+ }
+ var _p1 *byte
+ _p1, err = BytePtrFromString(newpath)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall6(SYS_RENAMEAT2, uintptr(olddirfd), uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1)), uintptr(flags), 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
func RequestKey(keyType string, description string, callback string, destRingid int) (id int, err error) {
var _p0 *byte
_p0, err = BytePtrFromString(keyType)
@@ -1489,6 +1646,21 @@ func Munlockall() (err error) {
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+func faccessat(dirfd int, path string, mode uint32) (err error) {
+ var _p0 *byte
+ _p0, err = BytePtrFromString(path)
+ if err != nil {
+ return
+ }
+ _, _, e1 := Syscall(SYS_FACCESSAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
func EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) {
var _p0 unsafe.Pointer
if len(events) > 0 {
diff --git a/vendor/golang.org/x/sys/unix/zsyscall_netbsd_386.go b/vendor/golang.org/x/sys/unix/zsyscall_netbsd_386.go
index 9ed7c71fb..642db7670 100644
--- a/vendor/golang.org/x/sys/unix/zsyscall_netbsd_386.go
+++ b/vendor/golang.org/x/sys/unix/zsyscall_netbsd_386.go
@@ -1,4 +1,4 @@
-// mksyscall.pl -l32 -netbsd -tags netbsd,386 syscall_bsd.go syscall_netbsd.go syscall_netbsd_386.go
+// go run mksyscall.go -l32 -netbsd -tags netbsd,386 syscall_bsd.go syscall_netbsd.go syscall_netbsd_386.go
// Code generated by the command above; see README.md. DO NOT EDIT.
// +build netbsd,386
diff --git a/vendor/golang.org/x/sys/unix/zsyscall_netbsd_amd64.go b/vendor/golang.org/x/sys/unix/zsyscall_netbsd_amd64.go
index 613b7fd99..59585fee3 100644
--- a/vendor/golang.org/x/sys/unix/zsyscall_netbsd_amd64.go
+++ b/vendor/golang.org/x/sys/unix/zsyscall_netbsd_amd64.go
@@ -1,4 +1,4 @@
-// mksyscall.pl -netbsd -tags netbsd,amd64 syscall_bsd.go syscall_netbsd.go syscall_netbsd_amd64.go
+// go run mksyscall.go -netbsd -tags netbsd,amd64 syscall_bsd.go syscall_netbsd.go syscall_netbsd_amd64.go
// Code generated by the command above; see README.md. DO NOT EDIT.
// +build netbsd,amd64
diff --git a/vendor/golang.org/x/sys/unix/zsyscall_netbsd_arm.go b/vendor/golang.org/x/sys/unix/zsyscall_netbsd_arm.go
index 084750878..6ec31434b 100644
--- a/vendor/golang.org/x/sys/unix/zsyscall_netbsd_arm.go
+++ b/vendor/golang.org/x/sys/unix/zsyscall_netbsd_arm.go
@@ -1,4 +1,4 @@
-// mksyscall.pl -l32 -netbsd -arm -tags netbsd,arm syscall_bsd.go syscall_netbsd.go syscall_netbsd_arm.go
+// go run mksyscall.go -l32 -netbsd -arm -tags netbsd,arm syscall_bsd.go syscall_netbsd.go syscall_netbsd_arm.go
// Code generated by the command above; see README.md. DO NOT EDIT.
// +build netbsd,arm
diff --git a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.go b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.go
index 414cd13c8..6a489fac0 100644
--- a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.go
+++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.go
@@ -1,4 +1,4 @@
-// mksyscall.pl -l32 -openbsd -tags openbsd,386 syscall_bsd.go syscall_openbsd.go syscall_openbsd_386.go
+// go run mksyscall.go -l32 -openbsd -tags openbsd,386 syscall_bsd.go syscall_openbsd.go syscall_openbsd_386.go
// Code generated by the command above; see README.md. DO NOT EDIT.
// +build openbsd,386
diff --git a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.go b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.go
index 846f5fa64..30cba4347 100644
--- a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.go
+++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.go
@@ -1,4 +1,4 @@
-// mksyscall.pl -openbsd -tags openbsd,amd64 syscall_bsd.go syscall_openbsd.go syscall_openbsd_amd64.go
+// go run mksyscall.go -openbsd -tags openbsd,amd64 syscall_bsd.go syscall_openbsd.go syscall_openbsd_amd64.go
// Code generated by the command above; see README.md. DO NOT EDIT.
// +build openbsd,amd64
diff --git a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.go b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.go
index 59911659d..fa1beda33 100644
--- a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.go
+++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.go
@@ -1,4 +1,4 @@
-// mksyscall.pl -l32 -openbsd -arm -tags openbsd,arm syscall_bsd.go syscall_openbsd.go syscall_openbsd_arm.go
+// go run mksyscall.go -l32 -openbsd -arm -tags openbsd,arm syscall_bsd.go syscall_openbsd.go syscall_openbsd_arm.go
// Code generated by the command above; see README.md. DO NOT EDIT.
// +build openbsd,arm
diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_386.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_386.go
index 8f33ece7c..8d17873de 100644
--- a/vendor/golang.org/x/sys/unix/zsysnum_linux_386.go
+++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_386.go
@@ -1,4 +1,4 @@
-// linux/mksysnum.pl -Wall -Werror -static -I/tmp/include -m32 /tmp/include/asm/unistd.h
+// go run linux/mksysnum.go -Wall -Werror -static -I/tmp/include -m32 /tmp/include/asm/unistd.h
// Code generated by the command above; see README.md. DO NOT EDIT.
// +build 386,linux
diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_amd64.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_amd64.go
index 70c1a2c12..b3d8ad79d 100644
--- a/vendor/golang.org/x/sys/unix/zsysnum_linux_amd64.go
+++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_amd64.go
@@ -1,4 +1,4 @@
-// linux/mksysnum.pl -Wall -Werror -static -I/tmp/include -m64 /tmp/include/asm/unistd.h
+// go run linux/mksysnum.go -Wall -Werror -static -I/tmp/include -m64 /tmp/include/asm/unistd.h
// Code generated by the command above; see README.md. DO NOT EDIT.
// +build amd64,linux
diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_arm.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_arm.go
index 6e281d6b3..e092822fb 100644
--- a/vendor/golang.org/x/sys/unix/zsysnum_linux_arm.go
+++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_arm.go
@@ -1,4 +1,4 @@
-// linux/mksysnum.pl -Wall -Werror -static -I/tmp/include /tmp/include/asm/unistd.h
+// go run linux/mksysnum.go -Wall -Werror -static -I/tmp/include /tmp/include/asm/unistd.h
// Code generated by the command above; see README.md. DO NOT EDIT.
// +build arm,linux
diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_arm64.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_arm64.go
index f9157e192..320696789 100644
--- a/vendor/golang.org/x/sys/unix/zsysnum_linux_arm64.go
+++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_arm64.go
@@ -1,4 +1,4 @@
-// linux/mksysnum.pl -Wall -Werror -static -I/tmp/include -fsigned-char /tmp/include/asm/unistd.h
+// go run linux/mksysnum.go -Wall -Werror -static -I/tmp/include -fsigned-char /tmp/include/asm/unistd.h
// Code generated by the command above; see README.md. DO NOT EDIT.
// +build arm64,linux
diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_mips.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_mips.go
index 16714491a..6893a5bd0 100644
--- a/vendor/golang.org/x/sys/unix/zsysnum_linux_mips.go
+++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_mips.go
@@ -1,4 +1,4 @@
-// linux/mksysnum.pl -Wall -Werror -static -I/tmp/include /tmp/include/asm/unistd.h
+// go run linux/mksysnum.go -Wall -Werror -static -I/tmp/include /tmp/include/asm/unistd.h
// Code generated by the command above; see README.md. DO NOT EDIT.
// +build mips,linux
diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64.go
index 1270a1c90..40164cacd 100644
--- a/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64.go
+++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64.go
@@ -1,4 +1,4 @@
-// linux/mksysnum.pl -Wall -Werror -static -I/tmp/include /tmp/include/asm/unistd.h
+// go run linux/mksysnum.go -Wall -Werror -static -I/tmp/include /tmp/include/asm/unistd.h
// Code generated by the command above; see README.md. DO NOT EDIT.
// +build mips64,linux
diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64le.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64le.go
index 93980be13..8a909738b 100644
--- a/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64le.go
+++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64le.go
@@ -1,4 +1,4 @@
-// linux/mksysnum.pl -Wall -Werror -static -I/tmp/include /tmp/include/asm/unistd.h
+// go run linux/mksysnum.go -Wall -Werror -static -I/tmp/include /tmp/include/asm/unistd.h
// Code generated by the command above; see README.md. DO NOT EDIT.
// +build mips64le,linux
diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_mipsle.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_mipsle.go
index 0fc772619..8d7818422 100644
--- a/vendor/golang.org/x/sys/unix/zsysnum_linux_mipsle.go
+++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_mipsle.go
@@ -1,4 +1,4 @@
-// linux/mksysnum.pl -Wall -Werror -static -I/tmp/include /tmp/include/asm/unistd.h
+// go run linux/mksysnum.go -Wall -Werror -static -I/tmp/include /tmp/include/asm/unistd.h
// Code generated by the command above; see README.md. DO NOT EDIT.
// +build mipsle,linux
diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64.go
index a5c5f3def..ec5bde3d5 100644
--- a/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64.go
+++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64.go
@@ -1,4 +1,4 @@
-// linux/mksysnum.pl -Wall -Werror -static -I/tmp/include /tmp/include/asm/unistd.h
+// go run linux/mksysnum.go -Wall -Werror -static -I/tmp/include /tmp/include/asm/unistd.h
// Code generated by the command above; see README.md. DO NOT EDIT.
// +build ppc64,linux
diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64le.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64le.go
index 5470eadbf..bdbabdbcd 100644
--- a/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64le.go
+++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64le.go
@@ -1,4 +1,4 @@
-// linux/mksysnum.pl -Wall -Werror -static -I/tmp/include /tmp/include/asm/unistd.h
+// go run linux/mksysnum.go -Wall -Werror -static -I/tmp/include /tmp/include/asm/unistd.h
// Code generated by the command above; see README.md. DO NOT EDIT.
// +build ppc64le,linux
diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_riscv64.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_riscv64.go
index a5d991915..473c74613 100644
--- a/vendor/golang.org/x/sys/unix/zsysnum_linux_riscv64.go
+++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_riscv64.go
@@ -1,4 +1,4 @@
-// linux/mksysnum.pl -Wall -Werror -static -I/tmp/include /tmp/include/asm/unistd.h
+// go run linux/mksysnum.go -Wall -Werror -static -I/tmp/include /tmp/include/asm/unistd.h
// Code generated by the command above; see README.md. DO NOT EDIT.
// +build riscv64,linux
diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_s390x.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_s390x.go
index de0245a92..6eb7c257f 100644
--- a/vendor/golang.org/x/sys/unix/zsysnum_linux_s390x.go
+++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_s390x.go
@@ -1,4 +1,4 @@
-// linux/mksysnum.pl -Wall -Werror -static -I/tmp/include -fsigned-char /tmp/include/asm/unistd.h
+// go run linux/mksysnum.go -Wall -Werror -static -I/tmp/include -fsigned-char /tmp/include/asm/unistd.h
// Code generated by the command above; see README.md. DO NOT EDIT.
// +build s390x,linux
diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_sparc64.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_sparc64.go
index 2d0993672..93480fcb1 100644
--- a/vendor/golang.org/x/sys/unix/zsysnum_linux_sparc64.go
+++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_sparc64.go
@@ -1,5 +1,5 @@
-// mksysnum_linux.pl -Ilinux/usr/include -m64 -D__arch64__ linux/usr/include/asm/unistd.h
-// Code generated by the command above; DO NOT EDIT.
+// go run linux/mksysnum.go -Wall -Werror -static -I/tmp/include /tmp/include/asm/unistd.h
+// Code generated by the command above; see README.md. DO NOT EDIT.
// +build sparc64,linux
@@ -345,4 +345,6 @@ const (
SYS_COPY_FILE_RANGE = 357
SYS_PREADV2 = 358
SYS_PWRITEV2 = 359
+ SYS_STATX = 360
+ SYS_IO_PGETEVENTS = 361
)
diff --git a/vendor/golang.org/x/sys/unix/ztypes_freebsd_386.go b/vendor/golang.org/x/sys/unix/ztypes_freebsd_386.go
index 28ef5242f..c146c1ad3 100644
--- a/vendor/golang.org/x/sys/unix/ztypes_freebsd_386.go
+++ b/vendor/golang.org/x/sys/unix/ztypes_freebsd_386.go
@@ -339,7 +339,7 @@ type Kevent_t struct {
}
type FdSet struct {
- _ [32]uint32
+ Bits [32]uint32
}
const (
diff --git a/vendor/golang.org/x/sys/unix/ztypes_freebsd_amd64.go b/vendor/golang.org/x/sys/unix/ztypes_freebsd_amd64.go
index e2d984a48..ac33a8dd4 100644
--- a/vendor/golang.org/x/sys/unix/ztypes_freebsd_amd64.go
+++ b/vendor/golang.org/x/sys/unix/ztypes_freebsd_amd64.go
@@ -337,7 +337,7 @@ type Kevent_t struct {
}
type FdSet struct {
- _ [16]uint64
+ Bits [16]uint64
}
const (
diff --git a/vendor/golang.org/x/sys/unix/ztypes_freebsd_arm.go b/vendor/golang.org/x/sys/unix/ztypes_freebsd_arm.go
index 9b415aba4..e27511a64 100644
--- a/vendor/golang.org/x/sys/unix/ztypes_freebsd_arm.go
+++ b/vendor/golang.org/x/sys/unix/ztypes_freebsd_arm.go
@@ -337,7 +337,7 @@ type Kevent_t struct {
}
type FdSet struct {
- _ [32]uint32
+ Bits [32]uint32
}
const (
diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_386.go b/vendor/golang.org/x/sys/unix/ztypes_linux_386.go
index 5f8f03492..8ee54ec32 100644
--- a/vendor/golang.org/x/sys/unix/ztypes_linux_386.go
+++ b/vendor/golang.org/x/sys/unix/ztypes_linux_386.go
@@ -98,7 +98,6 @@ type _Gid_t uint32
type Stat_t struct {
Dev uint64
_ uint16
- _ [2]byte
_ uint32
Mode uint32
Nlink uint32
@@ -106,7 +105,6 @@ type Stat_t struct {
Gid uint32
Rdev uint64
_ uint16
- _ [2]byte
Size int64
Blksize int32
Blocks int64
@@ -257,7 +255,6 @@ type RawSockaddrRFCOMM struct {
type RawSockaddrCAN struct {
Family uint16
- _ [2]byte
Ifindex int32
Addr [8]byte
}
@@ -286,6 +283,8 @@ type RawSockaddrXDP struct {
Shared_umem_fd uint32
}
+type RawSockaddrPPPoX [0x1e]byte
+
type RawSockaddr struct {
Family uint16
Data [14]int8
@@ -380,7 +379,6 @@ type TCPInfo struct {
Probes uint8
Backoff uint8
Options uint8
- _ [2]byte
Rto uint32
Ato uint32
Snd_mss uint32
@@ -421,6 +419,7 @@ const (
SizeofSockaddrALG = 0x58
SizeofSockaddrVM = 0x10
SizeofSockaddrXDP = 0x10
+ SizeofSockaddrPPPoX = 0x1e
SizeofLinger = 0x8
SizeofIovec = 0x8
SizeofIPMreq = 0x8
@@ -649,7 +648,6 @@ type SockFilter struct {
type SockFprog struct {
Len uint16
- _ [2]byte
Filter *SockFilter
}
@@ -785,11 +783,10 @@ type Winsize struct {
type Taskstats struct {
Version uint16
- _ [2]byte
Ac_exitcode uint32
Ac_flag uint8
Ac_nice uint8
- _ [6]byte
+ _ [4]byte
Cpu_count uint64
Cpu_delay_total uint64
Blkio_count uint64
@@ -1863,7 +1860,6 @@ type RTCTime struct {
type RTCWkAlrm struct {
Enabled uint8
Pending uint8
- _ [2]byte
Time RTCTime
}
diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_amd64.go b/vendor/golang.org/x/sys/unix/ztypes_linux_amd64.go
index aa52a439d..dcfe39124 100644
--- a/vendor/golang.org/x/sys/unix/ztypes_linux_amd64.go
+++ b/vendor/golang.org/x/sys/unix/ztypes_linux_amd64.go
@@ -33,13 +33,11 @@ type Timeval struct {
type Timex struct {
Modes uint32
- _ [4]byte
Offset int64
Freq int64
Maxerror int64
Esterror int64
Status int32
- _ [4]byte
Constant int64
Precision int64
Tolerance int64
@@ -48,7 +46,6 @@ type Timex struct {
Ppsfreq int64
Jitter int64
Shift int32
- _ [4]byte
Stabil int64
Jitcnt int64
Calcnt int64
@@ -162,7 +159,6 @@ type Fsid struct {
type Flock_t struct {
Type int16
Whence int16
- _ [4]byte
Start int64
Len int64
Pid int32
@@ -259,7 +255,6 @@ type RawSockaddrRFCOMM struct {
type RawSockaddrCAN struct {
Family uint16
- _ [2]byte
Ifindex int32
Addr [8]byte
}
@@ -288,6 +283,8 @@ type RawSockaddrXDP struct {
Shared_umem_fd uint32
}
+type RawSockaddrPPPoX [0x1e]byte
+
type RawSockaddr struct {
Family uint16
Data [14]int8
@@ -336,7 +333,6 @@ type PacketMreq struct {
type Msghdr struct {
Name *byte
Namelen uint32
- _ [4]byte
Iov *Iovec
Iovlen uint64
Control *byte
@@ -384,7 +380,6 @@ type TCPInfo struct {
Probes uint8
Backoff uint8
Options uint8
- _ [2]byte
Rto uint32
Ato uint32
Snd_mss uint32
@@ -425,6 +420,7 @@ const (
SizeofSockaddrALG = 0x58
SizeofSockaddrVM = 0x10
SizeofSockaddrXDP = 0x10
+ SizeofSockaddrPPPoX = 0x1e
SizeofLinger = 0x8
SizeofIovec = 0x10
SizeofIPMreq = 0x8
@@ -653,7 +649,6 @@ type SockFilter struct {
type SockFprog struct {
Len uint16
- _ [6]byte
Filter *SockFilter
}
@@ -711,7 +706,6 @@ type Sysinfo_t struct {
Freeswap uint64
Procs uint16
Pad uint16
- _ [4]byte
Totalhigh uint64
Freehigh uint64
Unit uint32
@@ -730,7 +724,6 @@ type Utsname struct {
type Ustat_t struct {
Tfree int32
- _ [4]byte
Tinode uint64
Fname [6]int8
Fpack [6]int8
@@ -803,11 +796,9 @@ type Winsize struct {
type Taskstats struct {
Version uint16
- _ [2]byte
Ac_exitcode uint32
Ac_flag uint8
Ac_nice uint8
- _ [6]byte
Cpu_count uint64
Cpu_delay_total uint64
Blkio_count uint64
@@ -825,7 +816,6 @@ type Taskstats struct {
Ac_pid uint32
Ac_ppid uint32
Ac_btime uint32
- _ [4]byte
Ac_etime uint64
Ac_utime uint64
Ac_stime uint64
@@ -1197,7 +1187,6 @@ type HDGeometry struct {
Heads uint8
Sectors uint8
Cylinders uint16
- _ [4]byte
Start uint64
}
@@ -1883,7 +1872,6 @@ type RTCTime struct {
type RTCWkAlrm struct {
Enabled uint8
Pending uint8
- _ [2]byte
Time RTCTime
}
@@ -1901,7 +1889,6 @@ type BlkpgIoctlArg struct {
Op int32
Flags int32
Datalen int32
- _ [4]byte
Data *byte
}
diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_arm.go b/vendor/golang.org/x/sys/unix/ztypes_linux_arm.go
index 23c8438be..692f2966d 100644
--- a/vendor/golang.org/x/sys/unix/ztypes_linux_arm.go
+++ b/vendor/golang.org/x/sys/unix/ztypes_linux_arm.go
@@ -98,7 +98,6 @@ type _Gid_t uint32
type Stat_t struct {
Dev uint64
_ uint16
- _ [2]byte
_ uint32
Mode uint32
Nlink uint32
@@ -106,7 +105,7 @@ type Stat_t struct {
Gid uint32
Rdev uint64
_ uint16
- _ [6]byte
+ _ [4]byte
Size int64
Blksize int32
_ [4]byte
@@ -260,7 +259,6 @@ type RawSockaddrRFCOMM struct {
type RawSockaddrCAN struct {
Family uint16
- _ [2]byte
Ifindex int32
Addr [8]byte
}
@@ -289,6 +287,8 @@ type RawSockaddrXDP struct {
Shared_umem_fd uint32
}
+type RawSockaddrPPPoX [0x1e]byte
+
type RawSockaddr struct {
Family uint16
Data [14]uint8
@@ -383,7 +383,6 @@ type TCPInfo struct {
Probes uint8
Backoff uint8
Options uint8
- _ [2]byte
Rto uint32
Ato uint32
Snd_mss uint32
@@ -424,6 +423,7 @@ const (
SizeofSockaddrALG = 0x58
SizeofSockaddrVM = 0x10
SizeofSockaddrXDP = 0x10
+ SizeofSockaddrPPPoX = 0x1e
SizeofLinger = 0x8
SizeofIovec = 0x8
SizeofIPMreq = 0x8
@@ -652,7 +652,6 @@ type SockFilter struct {
type SockFprog struct {
Len uint16
- _ [2]byte
Filter *SockFilter
}
@@ -773,11 +772,10 @@ type Winsize struct {
type Taskstats struct {
Version uint16
- _ [2]byte
Ac_exitcode uint32
Ac_flag uint8
Ac_nice uint8
- _ [6]byte
+ _ [4]byte
Cpu_count uint64
Cpu_delay_total uint64
Blkio_count uint64
@@ -1852,7 +1850,6 @@ type RTCTime struct {
type RTCWkAlrm struct {
Enabled uint8
Pending uint8
- _ [2]byte
Time RTCTime
}
diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_arm64.go b/vendor/golang.org/x/sys/unix/ztypes_linux_arm64.go
index d7a993e25..54ff596c5 100644
--- a/vendor/golang.org/x/sys/unix/ztypes_linux_arm64.go
+++ b/vendor/golang.org/x/sys/unix/ztypes_linux_arm64.go
@@ -33,13 +33,11 @@ type Timeval struct {
type Timex struct {
Modes uint32
- _ [4]byte
Offset int64
Freq int64
Maxerror int64
Esterror int64
Status int32
- _ [4]byte
Constant int64
Precision int64
Tolerance int64
@@ -48,7 +46,6 @@ type Timex struct {
Ppsfreq int64
Jitter int64
Shift int32
- _ [4]byte
Stabil int64
Jitcnt int64
Calcnt int64
@@ -163,7 +160,6 @@ type Fsid struct {
type Flock_t struct {
Type int16
Whence int16
- _ [4]byte
Start int64
Len int64
Pid int32
@@ -260,7 +256,6 @@ type RawSockaddrRFCOMM struct {
type RawSockaddrCAN struct {
Family uint16
- _ [2]byte
Ifindex int32
Addr [8]byte
}
@@ -289,6 +284,8 @@ type RawSockaddrXDP struct {
Shared_umem_fd uint32
}
+type RawSockaddrPPPoX [0x1e]byte
+
type RawSockaddr struct {
Family uint16
Data [14]int8
@@ -337,7 +334,6 @@ type PacketMreq struct {
type Msghdr struct {
Name *byte
Namelen uint32
- _ [4]byte
Iov *Iovec
Iovlen uint64
Control *byte
@@ -385,7 +381,6 @@ type TCPInfo struct {
Probes uint8
Backoff uint8
Options uint8
- _ [2]byte
Rto uint32
Ato uint32
Snd_mss uint32
@@ -426,6 +421,7 @@ const (
SizeofSockaddrALG = 0x58
SizeofSockaddrVM = 0x10
SizeofSockaddrXDP = 0x10
+ SizeofSockaddrPPPoX = 0x1e
SizeofLinger = 0x8
SizeofIovec = 0x10
SizeofIPMreq = 0x8
@@ -654,7 +650,6 @@ type SockFilter struct {
type SockFprog struct {
Len uint16
- _ [6]byte
Filter *SockFilter
}
@@ -689,7 +684,6 @@ type Sysinfo_t struct {
Freeswap uint64
Procs uint16
Pad uint16
- _ [4]byte
Totalhigh uint64
Freehigh uint64
Unit uint32
@@ -708,7 +702,6 @@ type Utsname struct {
type Ustat_t struct {
Tfree int32
- _ [4]byte
Tinode uint64
Fname [6]int8
Fpack [6]int8
@@ -782,11 +775,9 @@ type Winsize struct {
type Taskstats struct {
Version uint16
- _ [2]byte
Ac_exitcode uint32
Ac_flag uint8
Ac_nice uint8
- _ [6]byte
Cpu_count uint64
Cpu_delay_total uint64
Blkio_count uint64
@@ -804,7 +795,6 @@ type Taskstats struct {
Ac_pid uint32
Ac_ppid uint32
Ac_btime uint32
- _ [4]byte
Ac_etime uint64
Ac_utime uint64
Ac_stime uint64
@@ -1176,7 +1166,6 @@ type HDGeometry struct {
Heads uint8
Sectors uint8
Cylinders uint16
- _ [4]byte
Start uint64
}
@@ -1862,7 +1851,6 @@ type RTCTime struct {
type RTCWkAlrm struct {
Enabled uint8
Pending uint8
- _ [2]byte
Time RTCTime
}
@@ -1880,7 +1868,6 @@ type BlkpgIoctlArg struct {
Op int32
Flags int32
Datalen int32
- _ [4]byte
Data *byte
}
diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_mips.go b/vendor/golang.org/x/sys/unix/ztypes_linux_mips.go
index b8c3d0a4d..5dbe0c318 100644
--- a/vendor/golang.org/x/sys/unix/ztypes_linux_mips.go
+++ b/vendor/golang.org/x/sys/unix/ztypes_linux_mips.go
@@ -258,7 +258,6 @@ type RawSockaddrRFCOMM struct {
type RawSockaddrCAN struct {
Family uint16
- _ [2]byte
Ifindex int32
Addr [8]byte
}
@@ -287,6 +286,8 @@ type RawSockaddrXDP struct {
Shared_umem_fd uint32
}
+type RawSockaddrPPPoX [0x1e]byte
+
type RawSockaddr struct {
Family uint16
Data [14]int8
@@ -381,7 +382,6 @@ type TCPInfo struct {
Probes uint8
Backoff uint8
Options uint8
- _ [2]byte
Rto uint32
Ato uint32
Snd_mss uint32
@@ -422,6 +422,7 @@ const (
SizeofSockaddrALG = 0x58
SizeofSockaddrVM = 0x10
SizeofSockaddrXDP = 0x10
+ SizeofSockaddrPPPoX = 0x1e
SizeofLinger = 0x8
SizeofIovec = 0x8
SizeofIPMreq = 0x8
@@ -650,7 +651,6 @@ type SockFilter struct {
type SockFprog struct {
Len uint16
- _ [2]byte
Filter *SockFilter
}
@@ -777,11 +777,10 @@ type Winsize struct {
type Taskstats struct {
Version uint16
- _ [2]byte
Ac_exitcode uint32
Ac_flag uint8
Ac_nice uint8
- _ [6]byte
+ _ [4]byte
Cpu_count uint64
Cpu_delay_total uint64
Blkio_count uint64
@@ -1857,7 +1856,6 @@ type RTCTime struct {
type RTCWkAlrm struct {
Enabled uint8
Pending uint8
- _ [2]byte
Time RTCTime
}
diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_mips64.go b/vendor/golang.org/x/sys/unix/ztypes_linux_mips64.go
index a6f76149a..26766ee37 100644
--- a/vendor/golang.org/x/sys/unix/ztypes_linux_mips64.go
+++ b/vendor/golang.org/x/sys/unix/ztypes_linux_mips64.go
@@ -33,13 +33,11 @@ type Timeval struct {
type Timex struct {
Modes uint32
- _ [4]byte
Offset int64
Freq int64
Maxerror int64
Esterror int64
Status int32
- _ [4]byte
Constant int64
Precision int64
Tolerance int64
@@ -48,7 +46,6 @@ type Timex struct {
Ppsfreq int64
Jitter int64
Shift int32
- _ [4]byte
Stabil int64
Jitcnt int64
Calcnt int64
@@ -163,7 +160,6 @@ type Fsid struct {
type Flock_t struct {
Type int16
Whence int16
- _ [4]byte
Start int64
Len int64
Pid int32
@@ -260,7 +256,6 @@ type RawSockaddrRFCOMM struct {
type RawSockaddrCAN struct {
Family uint16
- _ [2]byte
Ifindex int32
Addr [8]byte
}
@@ -289,6 +284,8 @@ type RawSockaddrXDP struct {
Shared_umem_fd uint32
}
+type RawSockaddrPPPoX [0x1e]byte
+
type RawSockaddr struct {
Family uint16
Data [14]int8
@@ -337,7 +334,6 @@ type PacketMreq struct {
type Msghdr struct {
Name *byte
Namelen uint32
- _ [4]byte
Iov *Iovec
Iovlen uint64
Control *byte
@@ -385,7 +381,6 @@ type TCPInfo struct {
Probes uint8
Backoff uint8
Options uint8
- _ [2]byte
Rto uint32
Ato uint32
Snd_mss uint32
@@ -426,6 +421,7 @@ const (
SizeofSockaddrALG = 0x58
SizeofSockaddrVM = 0x10
SizeofSockaddrXDP = 0x10
+ SizeofSockaddrPPPoX = 0x1e
SizeofLinger = 0x8
SizeofIovec = 0x10
SizeofIPMreq = 0x8
@@ -654,7 +650,6 @@ type SockFilter struct {
type SockFprog struct {
Len uint16
- _ [6]byte
Filter *SockFilter
}
@@ -692,7 +687,6 @@ type Sysinfo_t struct {
Freeswap uint64
Procs uint16
Pad uint16
- _ [4]byte
Totalhigh uint64
Freehigh uint64
Unit uint32
@@ -711,7 +705,6 @@ type Utsname struct {
type Ustat_t struct {
Tfree int32
- _ [4]byte
Tinode uint64
Fname [6]int8
Fpack [6]int8
@@ -784,11 +777,9 @@ type Winsize struct {
type Taskstats struct {
Version uint16
- _ [2]byte
Ac_exitcode uint32
Ac_flag uint8
Ac_nice uint8
- _ [6]byte
Cpu_count uint64
Cpu_delay_total uint64
Blkio_count uint64
@@ -806,7 +797,6 @@ type Taskstats struct {
Ac_pid uint32
Ac_ppid uint32
Ac_btime uint32
- _ [4]byte
Ac_etime uint64
Ac_utime uint64
Ac_stime uint64
@@ -1178,7 +1168,6 @@ type HDGeometry struct {
Heads uint8
Sectors uint8
Cylinders uint16
- _ [4]byte
Start uint64
}
@@ -1864,7 +1853,6 @@ type RTCTime struct {
type RTCWkAlrm struct {
Enabled uint8
Pending uint8
- _ [2]byte
Time RTCTime
}
@@ -1882,7 +1870,6 @@ type BlkpgIoctlArg struct {
Op int32
Flags int32
Datalen int32
- _ [4]byte
Data *byte
}
diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_mips64le.go b/vendor/golang.org/x/sys/unix/ztypes_linux_mips64le.go
index 3dd194176..2d23ed17a 100644
--- a/vendor/golang.org/x/sys/unix/ztypes_linux_mips64le.go
+++ b/vendor/golang.org/x/sys/unix/ztypes_linux_mips64le.go
@@ -33,13 +33,11 @@ type Timeval struct {
type Timex struct {
Modes uint32
- _ [4]byte
Offset int64
Freq int64
Maxerror int64
Esterror int64
Status int32
- _ [4]byte
Constant int64
Precision int64
Tolerance int64
@@ -48,7 +46,6 @@ type Timex struct {
Ppsfreq int64
Jitter int64
Shift int32
- _ [4]byte
Stabil int64
Jitcnt int64
Calcnt int64
@@ -163,7 +160,6 @@ type Fsid struct {
type Flock_t struct {
Type int16
Whence int16
- _ [4]byte
Start int64
Len int64
Pid int32
@@ -260,7 +256,6 @@ type RawSockaddrRFCOMM struct {
type RawSockaddrCAN struct {
Family uint16
- _ [2]byte
Ifindex int32
Addr [8]byte
}
@@ -289,6 +284,8 @@ type RawSockaddrXDP struct {
Shared_umem_fd uint32
}
+type RawSockaddrPPPoX [0x1e]byte
+
type RawSockaddr struct {
Family uint16
Data [14]int8
@@ -337,7 +334,6 @@ type PacketMreq struct {
type Msghdr struct {
Name *byte
Namelen uint32
- _ [4]byte
Iov *Iovec
Iovlen uint64
Control *byte
@@ -385,7 +381,6 @@ type TCPInfo struct {
Probes uint8
Backoff uint8
Options uint8
- _ [2]byte
Rto uint32
Ato uint32
Snd_mss uint32
@@ -426,6 +421,7 @@ const (
SizeofSockaddrALG = 0x58
SizeofSockaddrVM = 0x10
SizeofSockaddrXDP = 0x10
+ SizeofSockaddrPPPoX = 0x1e
SizeofLinger = 0x8
SizeofIovec = 0x10
SizeofIPMreq = 0x8
@@ -654,7 +650,6 @@ type SockFilter struct {
type SockFprog struct {
Len uint16
- _ [6]byte
Filter *SockFilter
}
@@ -692,7 +687,6 @@ type Sysinfo_t struct {
Freeswap uint64
Procs uint16
Pad uint16
- _ [4]byte
Totalhigh uint64
Freehigh uint64
Unit uint32
@@ -711,7 +705,6 @@ type Utsname struct {
type Ustat_t struct {
Tfree int32
- _ [4]byte
Tinode uint64
Fname [6]int8
Fpack [6]int8
@@ -784,11 +777,9 @@ type Winsize struct {
type Taskstats struct {
Version uint16
- _ [2]byte
Ac_exitcode uint32
Ac_flag uint8
Ac_nice uint8
- _ [6]byte
Cpu_count uint64
Cpu_delay_total uint64
Blkio_count uint64
@@ -806,7 +797,6 @@ type Taskstats struct {
Ac_pid uint32
Ac_ppid uint32
Ac_btime uint32
- _ [4]byte
Ac_etime uint64
Ac_utime uint64
Ac_stime uint64
@@ -1178,7 +1168,6 @@ type HDGeometry struct {
Heads uint8
Sectors uint8
Cylinders uint16
- _ [4]byte
Start uint64
}
@@ -1864,7 +1853,6 @@ type RTCTime struct {
type RTCWkAlrm struct {
Enabled uint8
Pending uint8
- _ [2]byte
Time RTCTime
}
@@ -1882,7 +1870,6 @@ type BlkpgIoctlArg struct {
Op int32
Flags int32
Datalen int32
- _ [4]byte
Data *byte
}
diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_mipsle.go b/vendor/golang.org/x/sys/unix/ztypes_linux_mipsle.go
index 210de76cc..dac6168eb 100644
--- a/vendor/golang.org/x/sys/unix/ztypes_linux_mipsle.go
+++ b/vendor/golang.org/x/sys/unix/ztypes_linux_mipsle.go
@@ -258,7 +258,6 @@ type RawSockaddrRFCOMM struct {
type RawSockaddrCAN struct {
Family uint16
- _ [2]byte
Ifindex int32
Addr [8]byte
}
@@ -287,6 +286,8 @@ type RawSockaddrXDP struct {
Shared_umem_fd uint32
}
+type RawSockaddrPPPoX [0x1e]byte
+
type RawSockaddr struct {
Family uint16
Data [14]int8
@@ -381,7 +382,6 @@ type TCPInfo struct {
Probes uint8
Backoff uint8
Options uint8
- _ [2]byte
Rto uint32
Ato uint32
Snd_mss uint32
@@ -422,6 +422,7 @@ const (
SizeofSockaddrALG = 0x58
SizeofSockaddrVM = 0x10
SizeofSockaddrXDP = 0x10
+ SizeofSockaddrPPPoX = 0x1e
SizeofLinger = 0x8
SizeofIovec = 0x8
SizeofIPMreq = 0x8
@@ -650,7 +651,6 @@ type SockFilter struct {
type SockFprog struct {
Len uint16
- _ [2]byte
Filter *SockFilter
}
@@ -777,11 +777,10 @@ type Winsize struct {
type Taskstats struct {
Version uint16
- _ [2]byte
Ac_exitcode uint32
Ac_flag uint8
Ac_nice uint8
- _ [6]byte
+ _ [4]byte
Cpu_count uint64
Cpu_delay_total uint64
Blkio_count uint64
@@ -1857,7 +1856,6 @@ type RTCTime struct {
type RTCWkAlrm struct {
Enabled uint8
Pending uint8
- _ [2]byte
Time RTCTime
}
diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64.go b/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64.go
index b46d54e37..d79111c36 100644
--- a/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64.go
+++ b/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64.go
@@ -33,13 +33,11 @@ type Timeval struct {
type Timex struct {
Modes uint32
- _ [4]byte
Offset int64
Freq int64
Maxerror int64
Esterror int64
Status int32
- _ [4]byte
Constant int64
Precision int64
Tolerance int64
@@ -48,7 +46,6 @@ type Timex struct {
Ppsfreq int64
Jitter int64
Shift int32
- _ [4]byte
Stabil int64
Jitcnt int64
Calcnt int64
@@ -164,7 +161,6 @@ type Fsid struct {
type Flock_t struct {
Type int16
Whence int16
- _ [4]byte
Start int64
Len int64
Pid int32
@@ -261,7 +257,6 @@ type RawSockaddrRFCOMM struct {
type RawSockaddrCAN struct {
Family uint16
- _ [2]byte
Ifindex int32
Addr [8]byte
}
@@ -290,6 +285,8 @@ type RawSockaddrXDP struct {
Shared_umem_fd uint32
}
+type RawSockaddrPPPoX [0x1e]byte
+
type RawSockaddr struct {
Family uint16
Data [14]uint8
@@ -338,7 +335,6 @@ type PacketMreq struct {
type Msghdr struct {
Name *byte
Namelen uint32
- _ [4]byte
Iov *Iovec
Iovlen uint64
Control *byte
@@ -386,7 +382,6 @@ type TCPInfo struct {
Probes uint8
Backoff uint8
Options uint8
- _ [2]byte
Rto uint32
Ato uint32
Snd_mss uint32
@@ -427,6 +422,7 @@ const (
SizeofSockaddrALG = 0x58
SizeofSockaddrVM = 0x10
SizeofSockaddrXDP = 0x10
+ SizeofSockaddrPPPoX = 0x1e
SizeofLinger = 0x8
SizeofIovec = 0x10
SizeofIPMreq = 0x8
@@ -655,7 +651,6 @@ type SockFilter struct {
type SockFprog struct {
Len uint16
- _ [6]byte
Filter *SockFilter
}
@@ -699,7 +694,6 @@ type Sysinfo_t struct {
Freeswap uint64
Procs uint16
Pad uint16
- _ [4]byte
Totalhigh uint64
Freehigh uint64
Unit uint32
@@ -718,7 +712,6 @@ type Utsname struct {
type Ustat_t struct {
Tfree int32
- _ [4]byte
Tinode uint64
Fname [6]uint8
Fpack [6]uint8
@@ -792,11 +785,9 @@ type Winsize struct {
type Taskstats struct {
Version uint16
- _ [2]byte
Ac_exitcode uint32
Ac_flag uint8
Ac_nice uint8
- _ [6]byte
Cpu_count uint64
Cpu_delay_total uint64
Blkio_count uint64
@@ -814,7 +805,6 @@ type Taskstats struct {
Ac_pid uint32
Ac_ppid uint32
Ac_btime uint32
- _ [4]byte
Ac_etime uint64
Ac_utime uint64
Ac_stime uint64
@@ -1186,7 +1176,6 @@ type HDGeometry struct {
Heads uint8
Sectors uint8
Cylinders uint16
- _ [4]byte
Start uint64
}
@@ -1872,7 +1861,6 @@ type RTCTime struct {
type RTCWkAlrm struct {
Enabled uint8
Pending uint8
- _ [2]byte
Time RTCTime
}
@@ -1890,7 +1878,6 @@ type BlkpgIoctlArg struct {
Op int32
Flags int32
Datalen int32
- _ [4]byte
Data *byte
}
diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64le.go b/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64le.go
index 6ee799cef..f58b691b4 100644
--- a/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64le.go
+++ b/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64le.go
@@ -33,13 +33,11 @@ type Timeval struct {
type Timex struct {
Modes uint32
- _ [4]byte
Offset int64
Freq int64
Maxerror int64
Esterror int64
Status int32
- _ [4]byte
Constant int64
Precision int64
Tolerance int64
@@ -48,7 +46,6 @@ type Timex struct {
Ppsfreq int64
Jitter int64
Shift int32
- _ [4]byte
Stabil int64
Jitcnt int64
Calcnt int64
@@ -164,7 +161,6 @@ type Fsid struct {
type Flock_t struct {
Type int16
Whence int16
- _ [4]byte
Start int64
Len int64
Pid int32
@@ -261,7 +257,6 @@ type RawSockaddrRFCOMM struct {
type RawSockaddrCAN struct {
Family uint16
- _ [2]byte
Ifindex int32
Addr [8]byte
}
@@ -290,6 +285,8 @@ type RawSockaddrXDP struct {
Shared_umem_fd uint32
}
+type RawSockaddrPPPoX [0x1e]byte
+
type RawSockaddr struct {
Family uint16
Data [14]uint8
@@ -338,7 +335,6 @@ type PacketMreq struct {
type Msghdr struct {
Name *byte
Namelen uint32
- _ [4]byte
Iov *Iovec
Iovlen uint64
Control *byte
@@ -386,7 +382,6 @@ type TCPInfo struct {
Probes uint8
Backoff uint8
Options uint8
- _ [2]byte
Rto uint32
Ato uint32
Snd_mss uint32
@@ -427,6 +422,7 @@ const (
SizeofSockaddrALG = 0x58
SizeofSockaddrVM = 0x10
SizeofSockaddrXDP = 0x10
+ SizeofSockaddrPPPoX = 0x1e
SizeofLinger = 0x8
SizeofIovec = 0x10
SizeofIPMreq = 0x8
@@ -655,7 +651,6 @@ type SockFilter struct {
type SockFprog struct {
Len uint16
- _ [6]byte
Filter *SockFilter
}
@@ -699,7 +694,6 @@ type Sysinfo_t struct {
Freeswap uint64
Procs uint16
Pad uint16
- _ [4]byte
Totalhigh uint64
Freehigh uint64
Unit uint32
@@ -718,7 +712,6 @@ type Utsname struct {
type Ustat_t struct {
Tfree int32
- _ [4]byte
Tinode uint64
Fname [6]uint8
Fpack [6]uint8
@@ -792,11 +785,9 @@ type Winsize struct {
type Taskstats struct {
Version uint16
- _ [2]byte
Ac_exitcode uint32
Ac_flag uint8
Ac_nice uint8
- _ [6]byte
Cpu_count uint64
Cpu_delay_total uint64
Blkio_count uint64
@@ -814,7 +805,6 @@ type Taskstats struct {
Ac_pid uint32
Ac_ppid uint32
Ac_btime uint32
- _ [4]byte
Ac_etime uint64
Ac_utime uint64
Ac_stime uint64
@@ -1186,7 +1176,6 @@ type HDGeometry struct {
Heads uint8
Sectors uint8
Cylinders uint16
- _ [4]byte
Start uint64
}
@@ -1872,7 +1861,6 @@ type RTCTime struct {
type RTCWkAlrm struct {
Enabled uint8
Pending uint8
- _ [2]byte
Time RTCTime
}
@@ -1890,7 +1878,6 @@ type BlkpgIoctlArg struct {
Op int32
Flags int32
Datalen int32
- _ [4]byte
Data *byte
}
diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_riscv64.go b/vendor/golang.org/x/sys/unix/ztypes_linux_riscv64.go
index 60ae71e62..2a493b552 100644
--- a/vendor/golang.org/x/sys/unix/ztypes_linux_riscv64.go
+++ b/vendor/golang.org/x/sys/unix/ztypes_linux_riscv64.go
@@ -33,13 +33,11 @@ type Timeval struct {
type Timex struct {
Modes uint32
- _ [4]byte
Offset int64
Freq int64
Maxerror int64
Esterror int64
Status int32
- _ [4]byte
Constant int64
Precision int64
Tolerance int64
@@ -48,7 +46,6 @@ type Timex struct {
Ppsfreq int64
Jitter int64
Shift int32
- _ [4]byte
Stabil int64
Jitcnt int64
Calcnt int64
@@ -163,7 +160,6 @@ type Fsid struct {
type Flock_t struct {
Type int16
Whence int16
- _ [4]byte
Start int64
Len int64
Pid int32
@@ -260,7 +256,6 @@ type RawSockaddrRFCOMM struct {
type RawSockaddrCAN struct {
Family uint16
- _ [2]byte
Ifindex int32
Addr [8]byte
}
@@ -289,6 +284,8 @@ type RawSockaddrXDP struct {
Shared_umem_fd uint32
}
+type RawSockaddrPPPoX [0x1e]byte
+
type RawSockaddr struct {
Family uint16
Data [14]uint8
@@ -337,7 +334,6 @@ type PacketMreq struct {
type Msghdr struct {
Name *byte
Namelen uint32
- _ [4]byte
Iov *Iovec
Iovlen uint64
Control *byte
@@ -385,7 +381,6 @@ type TCPInfo struct {
Probes uint8
Backoff uint8
Options uint8
- _ [2]byte
Rto uint32
Ato uint32
Snd_mss uint32
@@ -426,6 +421,7 @@ const (
SizeofSockaddrALG = 0x58
SizeofSockaddrVM = 0x10
SizeofSockaddrXDP = 0x10
+ SizeofSockaddrPPPoX = 0x1e
SizeofLinger = 0x8
SizeofIovec = 0x10
SizeofIPMreq = 0x8
@@ -654,7 +650,6 @@ type SockFilter struct {
type SockFprog struct {
Len uint16
- _ [6]byte
Filter *SockFilter
}
@@ -717,7 +712,6 @@ type Sysinfo_t struct {
Freeswap uint64
Procs uint16
Pad uint16
- _ [4]byte
Totalhigh uint64
Freehigh uint64
Unit uint32
@@ -736,7 +730,6 @@ type Utsname struct {
type Ustat_t struct {
Tfree int32
- _ [4]byte
Tinode uint64
Fname [6]uint8
Fpack [6]uint8
@@ -809,11 +802,9 @@ type Winsize struct {
type Taskstats struct {
Version uint16
- _ [2]byte
Ac_exitcode uint32
Ac_flag uint8
Ac_nice uint8
- _ [6]byte
Cpu_count uint64
Cpu_delay_total uint64
Blkio_count uint64
@@ -831,7 +822,6 @@ type Taskstats struct {
Ac_pid uint32
Ac_ppid uint32
Ac_btime uint32
- _ [4]byte
Ac_etime uint64
Ac_utime uint64
Ac_stime uint64
@@ -1203,7 +1193,6 @@ type HDGeometry struct {
Heads uint8
Sectors uint8
Cylinders uint16
- _ [4]byte
Start uint64
}
@@ -1889,7 +1878,6 @@ type RTCTime struct {
type RTCWkAlrm struct {
Enabled uint8
Pending uint8
- _ [2]byte
Time RTCTime
}
@@ -1907,7 +1895,6 @@ type BlkpgIoctlArg struct {
Op int32
Flags int32
Datalen int32
- _ [4]byte
Data *byte
}
diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_s390x.go b/vendor/golang.org/x/sys/unix/ztypes_linux_s390x.go
index dea88f7bb..4ff4097c2 100644
--- a/vendor/golang.org/x/sys/unix/ztypes_linux_s390x.go
+++ b/vendor/golang.org/x/sys/unix/ztypes_linux_s390x.go
@@ -33,13 +33,11 @@ type Timeval struct {
type Timex struct {
Modes uint32
- _ [4]byte
Offset int64
Freq int64
Maxerror int64
Esterror int64
Status int32
- _ [4]byte
Constant int64
Precision int64
Tolerance int64
@@ -48,7 +46,6 @@ type Timex struct {
Ppsfreq int64
Jitter int64
Shift int32
- _ [4]byte
Stabil int64
Jitcnt int64
Calcnt int64
@@ -162,7 +159,6 @@ type Fsid struct {
type Flock_t struct {
Type int16
Whence int16
- _ [4]byte
Start int64
Len int64
Pid int32
@@ -259,7 +255,6 @@ type RawSockaddrRFCOMM struct {
type RawSockaddrCAN struct {
Family uint16
- _ [2]byte
Ifindex int32
Addr [8]byte
}
@@ -288,6 +283,8 @@ type RawSockaddrXDP struct {
Shared_umem_fd uint32
}
+type RawSockaddrPPPoX [0x1e]byte
+
type RawSockaddr struct {
Family uint16
Data [14]int8
@@ -336,7 +333,6 @@ type PacketMreq struct {
type Msghdr struct {
Name *byte
Namelen uint32
- _ [4]byte
Iov *Iovec
Iovlen uint64
Control *byte
@@ -384,7 +380,6 @@ type TCPInfo struct {
Probes uint8
Backoff uint8
Options uint8
- _ [2]byte
Rto uint32
Ato uint32
Snd_mss uint32
@@ -425,6 +420,7 @@ const (
SizeofSockaddrALG = 0x58
SizeofSockaddrVM = 0x10
SizeofSockaddrXDP = 0x10
+ SizeofSockaddrPPPoX = 0x1e
SizeofLinger = 0x8
SizeofIovec = 0x10
SizeofIPMreq = 0x8
@@ -653,7 +649,6 @@ type SockFilter struct {
type SockFprog struct {
Len uint16
- _ [6]byte
Filter *SockFilter
}
@@ -683,18 +678,15 @@ type PtracePsw struct {
type PtraceFpregs struct {
Fpc uint32
- _ [4]byte
Fprs [16]float64
}
type PtracePer struct {
_ [0]uint64
- _ [24]byte
- _ [8]byte
+ _ [32]byte
Starting_addr uint64
Ending_addr uint64
Perc_atmid uint16
- _ [6]byte
Address uint64
Access_id uint8
_ [7]byte
@@ -715,7 +707,6 @@ type Sysinfo_t struct {
Freeswap uint64
Procs uint16
Pad uint16
- _ [4]byte
Totalhigh uint64
Freehigh uint64
Unit uint32
@@ -734,7 +725,6 @@ type Utsname struct {
type Ustat_t struct {
Tfree int32
- _ [4]byte
Tinode uint64
Fname [6]int8
Fpack [6]int8
@@ -808,11 +798,9 @@ type Winsize struct {
type Taskstats struct {
Version uint16
- _ [2]byte
Ac_exitcode uint32
Ac_flag uint8
Ac_nice uint8
- _ [6]byte
Cpu_count uint64
Cpu_delay_total uint64
Blkio_count uint64
@@ -830,7 +818,6 @@ type Taskstats struct {
Ac_pid uint32
Ac_ppid uint32
Ac_btime uint32
- _ [4]byte
Ac_etime uint64
Ac_utime uint64
Ac_stime uint64
@@ -1202,7 +1189,6 @@ type HDGeometry struct {
Heads uint8
Sectors uint8
Cylinders uint16
- _ [4]byte
Start uint64
}
@@ -1889,7 +1875,6 @@ type RTCTime struct {
type RTCWkAlrm struct {
Enabled uint8
Pending uint8
- _ [2]byte
Time RTCTime
}
@@ -1907,7 +1892,6 @@ type BlkpgIoctlArg struct {
Op int32
Flags int32
Datalen int32
- _ [4]byte
Data *byte
}
diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_sparc64.go b/vendor/golang.org/x/sys/unix/ztypes_linux_sparc64.go
index 1fc7f7dea..ec980c1ab 100644
--- a/vendor/golang.org/x/sys/unix/ztypes_linux_sparc64.go
+++ b/vendor/golang.org/x/sys/unix/ztypes_linux_sparc64.go
@@ -1,6 +1,7 @@
+// cgo -godefs -- -Wall -Werror -static -I/tmp/include linux/types.go | go run mkpost.go
+// Code generated by the command above; see README.md. DO NOT EDIT.
+
// +build sparc64,linux
-// Created by cgo -godefs - DO NOT EDIT
-// cgo -godefs types_linux.go | go run mkpost.go
package unix
@@ -26,20 +27,18 @@ type Timespec struct {
}
type Timeval struct {
- Sec int64
- Usec int32
- Pad_cgo_0 [4]byte
+ Sec int64
+ Usec int32
+ _ [4]byte
}
type Timex struct {
Modes uint32
- Pad_cgo_0 [4]byte
Offset int64
Freq int64
Maxerror int64
Esterror int64
Status int32
- Pad_cgo_1 [4]byte
Constant int64
Precision int64
Tolerance int64
@@ -48,14 +47,13 @@ type Timex struct {
Ppsfreq int64
Jitter int64
Shift int32
- Pad_cgo_2 [4]byte
Stabil int64
Jitcnt int64
Calcnt int64
Errcnt int64
Stbcnt int64
Tai int32
- Pad_cgo_3 [44]byte
+ _ [44]byte
}
type Time_t int64
@@ -99,64 +97,96 @@ type Rlimit struct {
type _Gid_t uint32
type Stat_t struct {
- Dev uint64
- X__pad1 uint16
- Pad_cgo_0 [6]byte
- Ino uint64
- Mode uint32
- Nlink uint32
- Uid uint32
- Gid uint32
- Rdev uint64
- X__pad2 uint16
- Pad_cgo_1 [6]byte
- Size int64
- Blksize int64
- Blocks int64
- Atim Timespec
- Mtim Timespec
- Ctim Timespec
- X__glibc_reserved4 uint64
- X__glibc_reserved5 uint64
+ Dev uint64
+ _ uint16
+ Ino uint64
+ Mode uint32
+ Nlink uint32
+ Uid uint32
+ Gid uint32
+ Rdev uint64
+ _ uint16
+ Size int64
+ Blksize int64
+ Blocks int64
+ Atim Timespec
+ Mtim Timespec
+ Ctim Timespec
+ _ uint64
+ _ uint64
}
-type Statfs_t struct {
- Type int64
- Bsize int64
- Blocks uint64
- Bfree uint64
- Bavail uint64
- Files uint64
- Ffree uint64
- Fsid Fsid
- Namelen int64
- Frsize int64
- Flags int64
- Spare [4]int64
+type StatxTimestamp struct {
+ Sec int64
+ Nsec uint32
+ _ int32
+}
+
+type Statx_t struct {
+ Mask uint32
+ Blksize uint32
+ Attributes uint64
+ Nlink uint32
+ Uid uint32
+ Gid uint32
+ Mode uint16
+ _ [1]uint16
+ Ino uint64
+ Size uint64
+ Blocks uint64
+ Attributes_mask uint64
+ Atime StatxTimestamp
+ Btime StatxTimestamp
+ Ctime StatxTimestamp
+ Mtime StatxTimestamp
+ Rdev_major uint32
+ Rdev_minor uint32
+ Dev_major uint32
+ Dev_minor uint32
+ _ [14]uint64
}
type Dirent struct {
- Ino uint64
- Off int64
- Reclen uint16
- Type uint8
- Name [256]int8
- Pad_cgo_0 [5]byte
+ Ino uint64
+ Off int64
+ Reclen uint16
+ Type uint8
+ Name [256]int8
+ _ [5]byte
}
type Fsid struct {
- X__val [2]int32
+ Val [2]int32
}
type Flock_t struct {
- Type int16
- Whence int16
- Pad_cgo_0 [4]byte
- Start int64
- Len int64
- Pid int32
- X__glibc_reserved int16
- Pad_cgo_1 [2]byte
+ Type int16
+ Whence int16
+ Start int64
+ Len int64
+ Pid int32
+ _ int16
+ _ [2]byte
+}
+
+type FscryptPolicy struct {
+ Version uint8
+ Contents_encryption_mode uint8
+ Filenames_encryption_mode uint8
+ Flags uint8
+ Master_key_descriptor [8]uint8
+}
+
+type FscryptKey struct {
+ Mode uint32
+ Raw [64]uint8
+ Size uint32
+}
+
+type KeyctlDHParams struct {
+ Private int32
+ Prime int32
+ Base int32
}
const (
@@ -211,11 +241,26 @@ type RawSockaddrHCI struct {
Channel uint16
}
+type RawSockaddrL2 struct {
+ Family uint16
+ Psm uint16
+ Bdaddr [6]uint8
+ Cid uint16
+ Bdaddr_type uint8
+ _ [1]byte
+}
+
+type RawSockaddrRFCOMM struct {
+ Family uint16
+ Bdaddr [6]uint8
+ Channel uint8
+ _ [1]byte
+}
+
type RawSockaddrCAN struct {
- Family uint16
- Pad_cgo_0 [2]byte
- Ifindex int32
- Addr [8]byte
+ Family uint16
+ Ifindex int32
+ Addr [8]byte
}
type RawSockaddrALG struct {
@@ -234,6 +279,16 @@ type RawSockaddrVM struct {
Zero [4]uint8
}
+type RawSockaddrXDP struct {
+ Family uint16
+ Flags uint16
+ Ifindex uint32
+ Queue_id uint32
+ Shared_umem_fd uint32
+}
+
+type RawSockaddrPPPoX [0x1e]byte
+
type RawSockaddr struct {
Family uint16
Data [14]int8
@@ -272,16 +327,22 @@ type IPv6Mreq struct {
Interface uint32
}
+type PacketMreq struct {
+ Ifindex int32
+ Type uint16
+ Alen uint16
+ Address [8]uint8
+}
+
type Msghdr struct {
Name *byte
Namelen uint32
- Pad_cgo_0 [4]byte
Iov *Iovec
Iovlen uint64
Control *byte
Controllen uint64
Flags int32
- Pad_cgo_1 [4]byte
+ _ [4]byte
}
type Cmsghdr struct {
@@ -323,7 +384,6 @@ type TCPInfo struct {
Probes uint8
Backoff uint8
Options uint8
- Pad_cgo_0 [2]byte
Rto uint32
Ato uint32
Snd_mss uint32
@@ -358,13 +418,19 @@ const (
SizeofSockaddrLinklayer = 0x14
SizeofSockaddrNetlink = 0xc
SizeofSockaddrHCI = 0x6
+ SizeofSockaddrL2 = 0xe
+ SizeofSockaddrRFCOMM = 0xa
SizeofSockaddrCAN = 0x10
SizeofSockaddrALG = 0x58
SizeofSockaddrVM = 0x10
+ SizeofSockaddrXDP = 0x10
+ SizeofSockaddrPPPoX = 0x1e
SizeofLinger = 0x8
+ SizeofIovec = 0x10
SizeofIPMreq = 0x8
SizeofIPMreqn = 0xc
SizeofIPv6Mreq = 0x14
+ SizeofPacketMreq = 0x10
SizeofMsghdr = 0x38
SizeofCmsghdr = 0x10
SizeofInet4Pktinfo = 0xc
@@ -388,6 +454,7 @@ const (
IFLA_ADDRESS = 0x1
IFLA_BROADCAST = 0x2
IFLA_IFNAME = 0x3
+ IFLA_INFO_KIND = 0x1
IFLA_MTU = 0x4
IFLA_LINK = 0x5
IFLA_QDISC = 0x6
@@ -431,7 +498,7 @@ const (
IFLA_EVENT = 0x2c
IFLA_NEW_NETNSID = 0x2d
IFLA_IF_NETNSID = 0x2e
- IFLA_MAX = 0x2e
+ IFLA_MAX = 0x33
RT_SCOPE_UNIVERSE = 0x0
RT_SCOPE_SITE = 0xc8
RT_SCOPE_LINK = 0xfd
@@ -456,6 +523,20 @@ const (
RTA_FLOW = 0xb
RTA_CACHEINFO = 0xc
RTA_TABLE = 0xf
+ RTA_MARK = 0x10
+ RTA_MFC_STATS = 0x11
+ RTA_VIA = 0x12
+ RTA_NEWDST = 0x13
+ RTA_PREF = 0x14
+ RTA_ENCAP_TYPE = 0x15
+ RTA_ENCAP = 0x16
+ RTA_EXPIRES = 0x17
+ RTA_PAD = 0x18
+ RTA_UID = 0x19
+ RTA_TTL_PROPAGATE = 0x1a
+ RTA_IP_PROTO = 0x1b
+ RTA_SPORT = 0x1c
+ RTA_DPORT = 0x1d
RTN_UNSPEC = 0x0
RTN_UNICAST = 0x1
RTN_LOCAL = 0x2
@@ -523,12 +604,12 @@ type RtAttr struct {
}
type IfInfomsg struct {
- Family uint8
- X__ifi_pad uint8
- Type uint16
- Index int32
- Flags uint32
- Change uint32
+ Family uint8
+ _ uint8
+ Type uint16
+ Index int32
+ Flags uint32
+ Change uint32
}
type IfAddrmsg struct {
@@ -571,9 +652,8 @@ type SockFilter struct {
}
type SockFprog struct {
- Len uint16
- Pad_cgo_0 [6]byte
- Filter *SockFilter
+ Len uint16
+ Filter *SockFilter
}
type InotifyEvent struct {
@@ -594,15 +674,6 @@ type PtraceRegs struct {
Magic uint32
}
-type ptracePsw struct {
-}
-
-type ptraceFpregs struct {
-}
-
-type ptracePer struct {
-}
-
type FdSet struct {
Bits [16]int64
}
@@ -618,12 +689,11 @@ type Sysinfo_t struct {
Freeswap uint64
Procs uint16
Pad uint16
- Pad_cgo_0 [4]byte
Totalhigh uint64
Freehigh uint64
Unit uint32
- X_f [0]int8
- Pad_cgo_1 [4]byte
+ _ [0]int8
+ _ [4]byte
}
type Utsname struct {
@@ -636,26 +706,34 @@ type Utsname struct {
}
type Ustat_t struct {
- Tfree int32
- Pad_cgo_0 [4]byte
- Tinode uint64
- Fname [6]int8
- Fpack [6]int8
- Pad_cgo_1 [4]byte
+ Tfree int32
+ Tinode uint64
+ Fname [6]int8
+ Fpack [6]int8
+ _ [4]byte
}
type EpollEvent struct {
- Events uint32
- X_padFd int32
- Fd int32
- Pad int32
+ Events uint32
+ _ int32
+ Fd int32
+ Pad int32
}
const (
- AT_FDCWD = -0x64
- AT_REMOVEDIR = 0x200
+ AT_EMPTY_PATH = 0x1000
+ AT_FDCWD = -0x64
+ AT_NO_AUTOMOUNT = 0x800
+ AT_REMOVEDIR = 0x200
+
+ AT_STATX_SYNC_AS_STAT = 0x0
+ AT_STATX_FORCE_SYNC = 0x2000
+ AT_STATX_DONT_SYNC = 0x4000
+
AT_SYMLINK_FOLLOW = 0x400
AT_SYMLINK_NOFOLLOW = 0x100
+
+ AT_EACCESS = 0x200
)
type PollFd struct {
@@ -675,9 +753,13 @@ const (
)
type Sigset_t struct {
- X__val [16]uint64
+ Val [16]uint64
}
+const RNDGETENTCNT = 0x40045200
+
+const PERF_IOC_FLAG_GROUP = 0x1
+
type Termios struct {
Iflag uint32
Oflag uint32
@@ -688,3 +770,1212 @@ type Termios struct {
Ispeed uint32
Ospeed uint32
}
+
+type Winsize struct {
+ Row uint16
+ Col uint16
+ Xpixel uint16
+ Ypixel uint16
+}
+
+type Taskstats struct {
+ Version uint16
+ Ac_exitcode uint32
+ Ac_flag uint8
+ Ac_nice uint8
+ Cpu_count uint64
+ Cpu_delay_total uint64
+ Blkio_count uint64
+ Blkio_delay_total uint64
+ Swapin_count uint64
+ Swapin_delay_total uint64
+ Cpu_run_real_total uint64
+ Cpu_run_virtual_total uint64
+ Ac_comm [32]int8
+ Ac_sched uint8
+ Ac_pad [3]uint8
+ _ [4]byte
+ Ac_uid uint32
+ Ac_gid uint32
+ Ac_pid uint32
+ Ac_ppid uint32
+ Ac_btime uint32
+ Ac_etime uint64
+ Ac_utime uint64
+ Ac_stime uint64
+ Ac_minflt uint64
+ Ac_majflt uint64
+ Coremem uint64
+ Virtmem uint64
+ Hiwater_rss uint64
+ Hiwater_vm uint64
+ Read_char uint64
+ Write_char uint64
+ Read_syscalls uint64
+ Write_syscalls uint64
+ Read_bytes uint64
+ Write_bytes uint64
+ Cancelled_write_bytes uint64
+ Nvcsw uint64
+ Nivcsw uint64
+ Ac_utimescaled uint64
+ Ac_stimescaled uint64
+ Cpu_scaled_run_real_total uint64
+ Freepages_count uint64
+ Freepages_delay_total uint64
+}
+
+const (
+ TASKSTATS_CMD_UNSPEC = 0x0
+ TASKSTATS_CMD_GET = 0x1
+ TASKSTATS_CMD_NEW = 0x2
+ TASKSTATS_TYPE_UNSPEC = 0x0
+ TASKSTATS_TYPE_PID = 0x1
+ TASKSTATS_TYPE_TGID = 0x2
+ TASKSTATS_TYPE_STATS = 0x3
+ TASKSTATS_TYPE_AGGR_PID = 0x4
+ TASKSTATS_TYPE_AGGR_TGID = 0x5
+ TASKSTATS_TYPE_NULL = 0x6
+ TASKSTATS_CMD_ATTR_UNSPEC = 0x0
+ TASKSTATS_CMD_ATTR_PID = 0x1
+ TASKSTATS_CMD_ATTR_TGID = 0x2
+ TASKSTATS_CMD_ATTR_REGISTER_CPUMASK = 0x3
+ TASKSTATS_CMD_ATTR_DEREGISTER_CPUMASK = 0x4
+)
+
+type CGroupStats struct {
+ Sleeping uint64
+ Running uint64
+ Stopped uint64
+ Uninterruptible uint64
+ Io_wait uint64
+}
+
+const (
+ CGROUPSTATS_CMD_UNSPEC = 0x3
+ CGROUPSTATS_CMD_GET = 0x4
+ CGROUPSTATS_CMD_NEW = 0x5
+ CGROUPSTATS_TYPE_UNSPEC = 0x0
+ CGROUPSTATS_TYPE_CGROUP_STATS = 0x1
+ CGROUPSTATS_CMD_ATTR_UNSPEC = 0x0
+ CGROUPSTATS_CMD_ATTR_FD = 0x1
+)
+
+type Genlmsghdr struct {
+ Cmd uint8
+ Version uint8
+ Reserved uint16
+}
+
+const (
+ CTRL_CMD_UNSPEC = 0x0
+ CTRL_CMD_NEWFAMILY = 0x1
+ CTRL_CMD_DELFAMILY = 0x2
+ CTRL_CMD_GETFAMILY = 0x3
+ CTRL_CMD_NEWOPS = 0x4
+ CTRL_CMD_DELOPS = 0x5
+ CTRL_CMD_GETOPS = 0x6
+ CTRL_CMD_NEWMCAST_GRP = 0x7
+ CTRL_CMD_DELMCAST_GRP = 0x8
+ CTRL_CMD_GETMCAST_GRP = 0x9
+ CTRL_ATTR_UNSPEC = 0x0
+ CTRL_ATTR_FAMILY_ID = 0x1
+ CTRL_ATTR_FAMILY_NAME = 0x2
+ CTRL_ATTR_VERSION = 0x3
+ CTRL_ATTR_HDRSIZE = 0x4
+ CTRL_ATTR_MAXATTR = 0x5
+ CTRL_ATTR_OPS = 0x6
+ CTRL_ATTR_MCAST_GROUPS = 0x7
+ CTRL_ATTR_OP_UNSPEC = 0x0
+ CTRL_ATTR_OP_ID = 0x1
+ CTRL_ATTR_OP_FLAGS = 0x2
+ CTRL_ATTR_MCAST_GRP_UNSPEC = 0x0
+ CTRL_ATTR_MCAST_GRP_NAME = 0x1
+ CTRL_ATTR_MCAST_GRP_ID = 0x2
+)
+
+type cpuMask uint64
+
+const (
+ _CPU_SETSIZE = 0x400
+ _NCPUBITS = 0x40
+)
+
+const (
+ BDADDR_BREDR = 0x0
+ BDADDR_LE_PUBLIC = 0x1
+ BDADDR_LE_RANDOM = 0x2
+)
+
+type PerfEventAttr struct {
+ Type uint32
+ Size uint32
+ Config uint64
+ Sample uint64
+ Sample_type uint64
+ Read_format uint64
+ Bits uint64
+ Wakeup uint32
+ Bp_type uint32
+ Ext1 uint64
+ Ext2 uint64
+ Branch_sample_type uint64
+ Sample_regs_user uint64
+ Sample_stack_user uint32
+ Clockid int32
+ Sample_regs_intr uint64
+ Aux_watermark uint32
+ _ uint32
+}
+
+type PerfEventMmapPage struct {
+ Version uint32
+ Compat_version uint32
+ Lock uint32
+ Index uint32
+ Offset int64
+ Time_enabled uint64
+ Time_running uint64
+ Capabilities uint64
+ Pmc_width uint16
+ Time_shift uint16
+ Time_mult uint32
+ Time_offset uint64
+ Time_zero uint64
+ Size uint32
+ _ [948]uint8
+ Data_head uint64
+ Data_tail uint64
+ Data_offset uint64
+ Data_size uint64
+ Aux_head uint64
+ Aux_tail uint64
+ Aux_offset uint64
+ Aux_size uint64
+}
+
+const (
+ PerfBitDisabled uint64 = CBitFieldMaskBit0
+ PerfBitInherit = CBitFieldMaskBit1
+ PerfBitPinned = CBitFieldMaskBit2
+ PerfBitExclusive = CBitFieldMaskBit3
+ PerfBitExcludeUser = CBitFieldMaskBit4
+ PerfBitExcludeKernel = CBitFieldMaskBit5
+ PerfBitExcludeHv = CBitFieldMaskBit6
+ PerfBitExcludeIdle = CBitFieldMaskBit7
+ PerfBitMmap = CBitFieldMaskBit8
+ PerfBitComm = CBitFieldMaskBit9
+ PerfBitFreq = CBitFieldMaskBit10
+ PerfBitInheritStat = CBitFieldMaskBit11
+ PerfBitEnableOnExec = CBitFieldMaskBit12
+ PerfBitTask = CBitFieldMaskBit13
+ PerfBitWatermark = CBitFieldMaskBit14
+ PerfBitPreciseIPBit1 = CBitFieldMaskBit15
+ PerfBitPreciseIPBit2 = CBitFieldMaskBit16
+ PerfBitMmapData = CBitFieldMaskBit17
+ PerfBitSampleIDAll = CBitFieldMaskBit18
+ PerfBitExcludeHost = CBitFieldMaskBit19
+ PerfBitExcludeGuest = CBitFieldMaskBit20
+ PerfBitExcludeCallchainKernel = CBitFieldMaskBit21
+ PerfBitExcludeCallchainUser = CBitFieldMaskBit22
+ PerfBitMmap2 = CBitFieldMaskBit23
+ PerfBitCommExec = CBitFieldMaskBit24
+ PerfBitUseClockID = CBitFieldMaskBit25
+ PerfBitContextSwitch = CBitFieldMaskBit26
+)
+
+const (
+ PERF_TYPE_HARDWARE = 0x0
+ PERF_TYPE_SOFTWARE = 0x1
+ PERF_TYPE_TRACEPOINT = 0x2
+ PERF_TYPE_HW_CACHE = 0x3
+ PERF_TYPE_RAW = 0x4
+ PERF_TYPE_BREAKPOINT = 0x5
+
+ PERF_COUNT_HW_CPU_CYCLES = 0x0
+ PERF_COUNT_HW_INSTRUCTIONS = 0x1
+ PERF_COUNT_HW_CACHE_REFERENCES = 0x2
+ PERF_COUNT_HW_CACHE_MISSES = 0x3
+ PERF_COUNT_HW_BRANCH_INSTRUCTIONS = 0x4
+ PERF_COUNT_HW_BRANCH_MISSES = 0x5
+ PERF_COUNT_HW_BUS_CYCLES = 0x6
+ PERF_COUNT_HW_STALLED_CYCLES_FRONTEND = 0x7
+ PERF_COUNT_HW_STALLED_CYCLES_BACKEND = 0x8
+ PERF_COUNT_HW_REF_CPU_CYCLES = 0x9
+
+ PERF_COUNT_HW_CACHE_L1D = 0x0
+ PERF_COUNT_HW_CACHE_L1I = 0x1
+ PERF_COUNT_HW_CACHE_LL = 0x2
+ PERF_COUNT_HW_CACHE_DTLB = 0x3
+ PERF_COUNT_HW_CACHE_ITLB = 0x4
+ PERF_COUNT_HW_CACHE_BPU = 0x5
+ PERF_COUNT_HW_CACHE_NODE = 0x6
+
+ PERF_COUNT_HW_CACHE_OP_READ = 0x0
+ PERF_COUNT_HW_CACHE_OP_WRITE = 0x1
+ PERF_COUNT_HW_CACHE_OP_PREFETCH = 0x2
+
+ PERF_COUNT_HW_CACHE_RESULT_ACCESS = 0x0
+ PERF_COUNT_HW_CACHE_RESULT_MISS = 0x1
+
+ PERF_COUNT_SW_CPU_CLOCK = 0x0
+ PERF_COUNT_SW_TASK_CLOCK = 0x1
+ PERF_COUNT_SW_PAGE_FAULTS = 0x2
+ PERF_COUNT_SW_CONTEXT_SWITCHES = 0x3
+ PERF_COUNT_SW_CPU_MIGRATIONS = 0x4
+ PERF_COUNT_SW_PAGE_FAULTS_MIN = 0x5
+ PERF_COUNT_SW_PAGE_FAULTS_MAJ = 0x6
+ PERF_COUNT_SW_ALIGNMENT_FAULTS = 0x7
+ PERF_COUNT_SW_EMULATION_FAULTS = 0x8
+ PERF_COUNT_SW_DUMMY = 0x9
+
+ PERF_SAMPLE_IP = 0x1
+ PERF_SAMPLE_TID = 0x2
+ PERF_SAMPLE_TIME = 0x4
+ PERF_SAMPLE_ADDR = 0x8
+ PERF_SAMPLE_READ = 0x10
+ PERF_SAMPLE_CALLCHAIN = 0x20
+ PERF_SAMPLE_ID = 0x40
+ PERF_SAMPLE_CPU = 0x80
+ PERF_SAMPLE_PERIOD = 0x100
+ PERF_SAMPLE_STREAM_ID = 0x200
+ PERF_SAMPLE_RAW = 0x400
+ PERF_SAMPLE_BRANCH_STACK = 0x800
+
+ PERF_SAMPLE_BRANCH_USER = 0x1
+ PERF_SAMPLE_BRANCH_KERNEL = 0x2
+ PERF_SAMPLE_BRANCH_HV = 0x4
+ PERF_SAMPLE_BRANCH_ANY = 0x8
+ PERF_SAMPLE_BRANCH_ANY_CALL = 0x10
+ PERF_SAMPLE_BRANCH_ANY_RETURN = 0x20
+ PERF_SAMPLE_BRANCH_IND_CALL = 0x40
+
+ PERF_FORMAT_TOTAL_TIME_ENABLED = 0x1
+ PERF_FORMAT_TOTAL_TIME_RUNNING = 0x2
+ PERF_FORMAT_ID = 0x4
+ PERF_FORMAT_GROUP = 0x8
+
+ PERF_RECORD_MMAP = 0x1
+ PERF_RECORD_LOST = 0x2
+ PERF_RECORD_COMM = 0x3
+ PERF_RECORD_EXIT = 0x4
+ PERF_RECORD_THROTTLE = 0x5
+ PERF_RECORD_UNTHROTTLE = 0x6
+ PERF_RECORD_FORK = 0x7
+ PERF_RECORD_READ = 0x8
+ PERF_RECORD_SAMPLE = 0x9
+
+ PERF_CONTEXT_HV = -0x20
+ PERF_CONTEXT_KERNEL = -0x80
+ PERF_CONTEXT_USER = -0x200
+
+ PERF_CONTEXT_GUEST = -0x800
+ PERF_CONTEXT_GUEST_KERNEL = -0x880
+ PERF_CONTEXT_GUEST_USER = -0xa00
+
+ PERF_FLAG_FD_NO_GROUP = 0x1
+ PERF_FLAG_FD_OUTPUT = 0x2
+ PERF_FLAG_PID_CGROUP = 0x4
+)
+
+const (
+ CBitFieldMaskBit0 = 0x8000000000000000
+ CBitFieldMaskBit1 = 0x4000000000000000
+ CBitFieldMaskBit2 = 0x2000000000000000
+ CBitFieldMaskBit3 = 0x1000000000000000
+ CBitFieldMaskBit4 = 0x800000000000000
+ CBitFieldMaskBit5 = 0x400000000000000
+ CBitFieldMaskBit6 = 0x200000000000000
+ CBitFieldMaskBit7 = 0x100000000000000
+ CBitFieldMaskBit8 = 0x80000000000000
+ CBitFieldMaskBit9 = 0x40000000000000
+ CBitFieldMaskBit10 = 0x20000000000000
+ CBitFieldMaskBit11 = 0x10000000000000
+ CBitFieldMaskBit12 = 0x8000000000000
+ CBitFieldMaskBit13 = 0x4000000000000
+ CBitFieldMaskBit14 = 0x2000000000000
+ CBitFieldMaskBit15 = 0x1000000000000
+ CBitFieldMaskBit16 = 0x800000000000
+ CBitFieldMaskBit17 = 0x400000000000
+ CBitFieldMaskBit18 = 0x200000000000
+ CBitFieldMaskBit19 = 0x100000000000
+ CBitFieldMaskBit20 = 0x80000000000
+ CBitFieldMaskBit21 = 0x40000000000
+ CBitFieldMaskBit22 = 0x20000000000
+ CBitFieldMaskBit23 = 0x10000000000
+ CBitFieldMaskBit24 = 0x8000000000
+ CBitFieldMaskBit25 = 0x4000000000
+ CBitFieldMaskBit26 = 0x2000000000
+ CBitFieldMaskBit27 = 0x1000000000
+ CBitFieldMaskBit28 = 0x800000000
+ CBitFieldMaskBit29 = 0x400000000
+ CBitFieldMaskBit30 = 0x200000000
+ CBitFieldMaskBit31 = 0x100000000
+ CBitFieldMaskBit32 = 0x80000000
+ CBitFieldMaskBit33 = 0x40000000
+ CBitFieldMaskBit34 = 0x20000000
+ CBitFieldMaskBit35 = 0x10000000
+ CBitFieldMaskBit36 = 0x8000000
+ CBitFieldMaskBit37 = 0x4000000
+ CBitFieldMaskBit38 = 0x2000000
+ CBitFieldMaskBit39 = 0x1000000
+ CBitFieldMaskBit40 = 0x800000
+ CBitFieldMaskBit41 = 0x400000
+ CBitFieldMaskBit42 = 0x200000
+ CBitFieldMaskBit43 = 0x100000
+ CBitFieldMaskBit44 = 0x80000
+ CBitFieldMaskBit45 = 0x40000
+ CBitFieldMaskBit46 = 0x20000
+ CBitFieldMaskBit47 = 0x10000
+ CBitFieldMaskBit48 = 0x8000
+ CBitFieldMaskBit49 = 0x4000
+ CBitFieldMaskBit50 = 0x2000
+ CBitFieldMaskBit51 = 0x1000
+ CBitFieldMaskBit52 = 0x800
+ CBitFieldMaskBit53 = 0x400
+ CBitFieldMaskBit54 = 0x200
+ CBitFieldMaskBit55 = 0x100
+ CBitFieldMaskBit56 = 0x80
+ CBitFieldMaskBit57 = 0x40
+ CBitFieldMaskBit58 = 0x20
+ CBitFieldMaskBit59 = 0x10
+ CBitFieldMaskBit60 = 0x8
+ CBitFieldMaskBit61 = 0x4
+ CBitFieldMaskBit62 = 0x2
+ CBitFieldMaskBit63 = 0x1
+)
+
+type SockaddrStorage struct {
+ Family uint16
+ _ [118]int8
+ _ uint64
+}
+
+type TCPMD5Sig struct {
+ Addr SockaddrStorage
+ Flags uint8
+ Prefixlen uint8
+ Keylen uint16
+ _ uint32
+ Key [80]uint8
+}
+
+type HDDriveCmdHdr struct {
+ Command uint8
+ Number uint8
+ Feature uint8
+ Count uint8
+}
+
+type HDGeometry struct {
+ Heads uint8
+ Sectors uint8
+ Cylinders uint16
+ Start uint64
+}
+
+type HDDriveID struct {
+ Config uint16
+ Cyls uint16
+ Reserved2 uint16
+ Heads uint16
+ Track_bytes uint16
+ Sector_bytes uint16
+ Sectors uint16
+ Vendor0 uint16
+ Vendor1 uint16
+ Vendor2 uint16
+ Serial_no [20]uint8
+ Buf_type uint16
+ Buf_size uint16
+ Ecc_bytes uint16
+ Fw_rev [8]uint8
+ Model [40]uint8
+ Max_multsect uint8
+ Vendor3 uint8
+ Dword_io uint16
+ Vendor4 uint8
+ Capability uint8
+ Reserved50 uint16
+ Vendor5 uint8
+ TPIO uint8
+ Vendor6 uint8
+ TDMA uint8
+ Field_valid uint16
+ Cur_cyls uint16
+ Cur_heads uint16
+ Cur_sectors uint16
+ Cur_capacity0 uint16
+ Cur_capacity1 uint16
+ Multsect uint8
+ Multsect_valid uint8
+ Lba_capacity uint32
+ Dma_1word uint16
+ Dma_mword uint16
+ Eide_pio_modes uint16
+ Eide_dma_min uint16
+ Eide_dma_time uint16
+ Eide_pio uint16
+ Eide_pio_iordy uint16
+ Words69_70 [2]uint16
+ Words71_74 [4]uint16
+ Queue_depth uint16
+ Words76_79 [4]uint16
+ Major_rev_num uint16
+ Minor_rev_num uint16
+ Command_set_1 uint16
+ Command_set_2 uint16
+ Cfsse uint16
+ Cfs_enable_1 uint16
+ Cfs_enable_2 uint16
+ Csf_default uint16
+ Dma_ultra uint16
+ Trseuc uint16
+ TrsEuc uint16
+ CurAPMvalues uint16
+ Mprc uint16
+ Hw_config uint16
+ Acoustic uint16
+ Msrqs uint16
+ Sxfert uint16
+ Sal uint16
+ Spg uint32
+ Lba_capacity_2 uint64
+ Words104_125 [22]uint16
+ Last_lun uint16
+ Word127 uint16
+ Dlf uint16
+ Csfo uint16
+ Words130_155 [26]uint16
+ Word156 uint16
+ Words157_159 [3]uint16
+ Cfa_power uint16
+ Words161_175 [15]uint16
+ Words176_205 [30]uint16
+ Words206_254 [49]uint16
+ Integrity_word uint16
+}
+
+type Statfs_t struct {
+ Type int64
+ Bsize int64
+ Blocks uint64
+ Bfree uint64
+ Bavail uint64
+ Files uint64
+ Ffree uint64
+ Fsid Fsid
+ Namelen int64
+ Frsize int64
+ Flags int64
+ Spare [4]int64
+}
+
+const (
+ ST_MANDLOCK = 0x40
+ ST_NOATIME = 0x400
+ ST_NODEV = 0x4
+ ST_NODIRATIME = 0x800
+ ST_NOEXEC = 0x8
+ ST_NOSUID = 0x2
+ ST_RDONLY = 0x1
+ ST_RELATIME = 0x1000
+ ST_SYNCHRONOUS = 0x10
+)
+
+type TpacketHdr struct {
+ Status uint64
+ Len uint32
+ Snaplen uint32
+ Mac uint16
+ Net uint16
+ Sec uint32
+ Usec uint32
+ _ [4]byte
+}
+
+type Tpacket2Hdr struct {
+ Status uint32
+ Len uint32
+ Snaplen uint32
+ Mac uint16
+ Net uint16
+ Sec uint32
+ Nsec uint32
+ Vlan_tci uint16
+ Vlan_tpid uint16
+ _ [4]uint8
+}
+
+type Tpacket3Hdr struct {
+ Next_offset uint32
+ Sec uint32
+ Nsec uint32
+ Snaplen uint32
+ Len uint32
+ Status uint32
+ Mac uint16
+ Net uint16
+ Hv1 TpacketHdrVariant1
+ _ [8]uint8
+}
+
+type TpacketHdrVariant1 struct {
+ Rxhash uint32
+ Vlan_tci uint32
+ Vlan_tpid uint16
+ _ uint16
+}
+
+type TpacketBlockDesc struct {
+ Version uint32
+ To_priv uint32
+ Hdr [40]byte
+}
+
+type TpacketReq struct {
+ Block_size uint32
+ Block_nr uint32
+ Frame_size uint32
+ Frame_nr uint32
+}
+
+type TpacketReq3 struct {
+ Block_size uint32
+ Block_nr uint32
+ Frame_size uint32
+ Frame_nr uint32
+ Retire_blk_tov uint32
+ Sizeof_priv uint32
+ Feature_req_word uint32
+}
+
+type TpacketStats struct {
+ Packets uint32
+ Drops uint32
+}
+
+type TpacketStatsV3 struct {
+ Packets uint32
+ Drops uint32
+ Freeze_q_cnt uint32
+}
+
+type TpacketAuxdata struct {
+ Status uint32
+ Len uint32
+ Snaplen uint32
+ Mac uint16
+ Net uint16
+ Vlan_tci uint16
+ Vlan_tpid uint16
+}
+
+const (
+ TPACKET_V1 = 0x0
+ TPACKET_V2 = 0x1
+ TPACKET_V3 = 0x2
+)
+
+const (
+ SizeofTpacketHdr = 0x20
+ SizeofTpacket2Hdr = 0x20
+ SizeofTpacket3Hdr = 0x30
+)
+
+const (
+ NF_INET_PRE_ROUTING = 0x0
+ NF_INET_LOCAL_IN = 0x1
+ NF_INET_FORWARD = 0x2
+ NF_INET_LOCAL_OUT = 0x3
+ NF_INET_POST_ROUTING = 0x4
+ NF_INET_NUMHOOKS = 0x5
+)
+
+const (
+ NF_NETDEV_INGRESS = 0x0
+ NF_NETDEV_NUMHOOKS = 0x1
+)
+
+const (
+ NFPROTO_UNSPEC = 0x0
+ NFPROTO_INET = 0x1
+ NFPROTO_IPV4 = 0x2
+ NFPROTO_ARP = 0x3
+ NFPROTO_NETDEV = 0x5
+ NFPROTO_BRIDGE = 0x7
+ NFPROTO_IPV6 = 0xa
+ NFPROTO_DECNET = 0xc
+ NFPROTO_NUMPROTO = 0xd
+)
+
+type Nfgenmsg struct {
+ Nfgen_family uint8
+ Version uint8
+ Res_id uint16
+}
+
+const (
+ NFNL_BATCH_UNSPEC = 0x0
+ NFNL_BATCH_GENID = 0x1
+)
+
+const (
+ NFT_REG_VERDICT = 0x0
+ NFT_REG_1 = 0x1
+ NFT_REG_2 = 0x2
+ NFT_REG_3 = 0x3
+ NFT_REG_4 = 0x4
+ NFT_REG32_00 = 0x8
+ NFT_REG32_01 = 0x9
+ NFT_REG32_02 = 0xa
+ NFT_REG32_03 = 0xb
+ NFT_REG32_04 = 0xc
+ NFT_REG32_05 = 0xd
+ NFT_REG32_06 = 0xe
+ NFT_REG32_07 = 0xf
+ NFT_REG32_08 = 0x10
+ NFT_REG32_09 = 0x11
+ NFT_REG32_10 = 0x12
+ NFT_REG32_11 = 0x13
+ NFT_REG32_12 = 0x14
+ NFT_REG32_13 = 0x15
+ NFT_REG32_14 = 0x16
+ NFT_REG32_15 = 0x17
+ NFT_CONTINUE = -0x1
+ NFT_BREAK = -0x2
+ NFT_JUMP = -0x3
+ NFT_GOTO = -0x4
+ NFT_RETURN = -0x5
+ NFT_MSG_NEWTABLE = 0x0
+ NFT_MSG_GETTABLE = 0x1
+ NFT_MSG_DELTABLE = 0x2
+ NFT_MSG_NEWCHAIN = 0x3
+ NFT_MSG_GETCHAIN = 0x4
+ NFT_MSG_DELCHAIN = 0x5
+ NFT_MSG_NEWRULE = 0x6
+ NFT_MSG_GETRULE = 0x7
+ NFT_MSG_DELRULE = 0x8
+ NFT_MSG_NEWSET = 0x9
+ NFT_MSG_GETSET = 0xa
+ NFT_MSG_DELSET = 0xb
+ NFT_MSG_NEWSETELEM = 0xc
+ NFT_MSG_GETSETELEM = 0xd
+ NFT_MSG_DELSETELEM = 0xe
+ NFT_MSG_NEWGEN = 0xf
+ NFT_MSG_GETGEN = 0x10
+ NFT_MSG_TRACE = 0x11
+ NFT_MSG_NEWOBJ = 0x12
+ NFT_MSG_GETOBJ = 0x13
+ NFT_MSG_DELOBJ = 0x14
+ NFT_MSG_GETOBJ_RESET = 0x15
+ NFT_MSG_MAX = 0x19
+ NFTA_LIST_UNPEC = 0x0
+ NFTA_LIST_ELEM = 0x1
+ NFTA_HOOK_UNSPEC = 0x0
+ NFTA_HOOK_HOOKNUM = 0x1
+ NFTA_HOOK_PRIORITY = 0x2
+ NFTA_HOOK_DEV = 0x3
+ NFT_TABLE_F_DORMANT = 0x1
+ NFTA_TABLE_UNSPEC = 0x0
+ NFTA_TABLE_NAME = 0x1
+ NFTA_TABLE_FLAGS = 0x2
+ NFTA_TABLE_USE = 0x3
+ NFTA_CHAIN_UNSPEC = 0x0
+ NFTA_CHAIN_TABLE = 0x1
+ NFTA_CHAIN_HANDLE = 0x2
+ NFTA_CHAIN_NAME = 0x3
+ NFTA_CHAIN_HOOK = 0x4
+ NFTA_CHAIN_POLICY = 0x5
+ NFTA_CHAIN_USE = 0x6
+ NFTA_CHAIN_TYPE = 0x7
+ NFTA_CHAIN_COUNTERS = 0x8
+ NFTA_CHAIN_PAD = 0x9
+ NFTA_RULE_UNSPEC = 0x0
+ NFTA_RULE_TABLE = 0x1
+ NFTA_RULE_CHAIN = 0x2
+ NFTA_RULE_HANDLE = 0x3
+ NFTA_RULE_EXPRESSIONS = 0x4
+ NFTA_RULE_COMPAT = 0x5
+ NFTA_RULE_POSITION = 0x6
+ NFTA_RULE_USERDATA = 0x7
+ NFTA_RULE_PAD = 0x8
+ NFTA_RULE_ID = 0x9
+ NFT_RULE_COMPAT_F_INV = 0x2
+ NFT_RULE_COMPAT_F_MASK = 0x2
+ NFTA_RULE_COMPAT_UNSPEC = 0x0
+ NFTA_RULE_COMPAT_PROTO = 0x1
+ NFTA_RULE_COMPAT_FLAGS = 0x2
+ NFT_SET_ANONYMOUS = 0x1
+ NFT_SET_CONSTANT = 0x2
+ NFT_SET_INTERVAL = 0x4
+ NFT_SET_MAP = 0x8
+ NFT_SET_TIMEOUT = 0x10
+ NFT_SET_EVAL = 0x20
+ NFT_SET_OBJECT = 0x40
+ NFT_SET_POL_PERFORMANCE = 0x0
+ NFT_SET_POL_MEMORY = 0x1
+ NFTA_SET_DESC_UNSPEC = 0x0
+ NFTA_SET_DESC_SIZE = 0x1
+ NFTA_SET_UNSPEC = 0x0
+ NFTA_SET_TABLE = 0x1
+ NFTA_SET_NAME = 0x2
+ NFTA_SET_FLAGS = 0x3
+ NFTA_SET_KEY_TYPE = 0x4
+ NFTA_SET_KEY_LEN = 0x5
+ NFTA_SET_DATA_TYPE = 0x6
+ NFTA_SET_DATA_LEN = 0x7
+ NFTA_SET_POLICY = 0x8
+ NFTA_SET_DESC = 0x9
+ NFTA_SET_ID = 0xa
+ NFTA_SET_TIMEOUT = 0xb
+ NFTA_SET_GC_INTERVAL = 0xc
+ NFTA_SET_USERDATA = 0xd
+ NFTA_SET_PAD = 0xe
+ NFTA_SET_OBJ_TYPE = 0xf
+ NFT_SET_ELEM_INTERVAL_END = 0x1
+ NFTA_SET_ELEM_UNSPEC = 0x0
+ NFTA_SET_ELEM_KEY = 0x1
+ NFTA_SET_ELEM_DATA = 0x2
+ NFTA_SET_ELEM_FLAGS = 0x3
+ NFTA_SET_ELEM_TIMEOUT = 0x4
+ NFTA_SET_ELEM_EXPIRATION = 0x5
+ NFTA_SET_ELEM_USERDATA = 0x6
+ NFTA_SET_ELEM_EXPR = 0x7
+ NFTA_SET_ELEM_PAD = 0x8
+ NFTA_SET_ELEM_OBJREF = 0x9
+ NFTA_SET_ELEM_LIST_UNSPEC = 0x0
+ NFTA_SET_ELEM_LIST_TABLE = 0x1
+ NFTA_SET_ELEM_LIST_SET = 0x2
+ NFTA_SET_ELEM_LIST_ELEMENTS = 0x3
+ NFTA_SET_ELEM_LIST_SET_ID = 0x4
+ NFT_DATA_VALUE = 0x0
+ NFT_DATA_VERDICT = 0xffffff00
+ NFTA_DATA_UNSPEC = 0x0
+ NFTA_DATA_VALUE = 0x1
+ NFTA_DATA_VERDICT = 0x2
+ NFTA_VERDICT_UNSPEC = 0x0
+ NFTA_VERDICT_CODE = 0x1
+ NFTA_VERDICT_CHAIN = 0x2
+ NFTA_EXPR_UNSPEC = 0x0
+ NFTA_EXPR_NAME = 0x1
+ NFTA_EXPR_DATA = 0x2
+ NFTA_IMMEDIATE_UNSPEC = 0x0
+ NFTA_IMMEDIATE_DREG = 0x1
+ NFTA_IMMEDIATE_DATA = 0x2
+ NFTA_BITWISE_UNSPEC = 0x0
+ NFTA_BITWISE_SREG = 0x1
+ NFTA_BITWISE_DREG = 0x2
+ NFTA_BITWISE_LEN = 0x3
+ NFTA_BITWISE_MASK = 0x4
+ NFTA_BITWISE_XOR = 0x5
+ NFT_BYTEORDER_NTOH = 0x0
+ NFT_BYTEORDER_HTON = 0x1
+ NFTA_BYTEORDER_UNSPEC = 0x0
+ NFTA_BYTEORDER_SREG = 0x1
+ NFTA_BYTEORDER_DREG = 0x2
+ NFTA_BYTEORDER_OP = 0x3
+ NFTA_BYTEORDER_LEN = 0x4
+ NFTA_BYTEORDER_SIZE = 0x5
+ NFT_CMP_EQ = 0x0
+ NFT_CMP_NEQ = 0x1
+ NFT_CMP_LT = 0x2
+ NFT_CMP_LTE = 0x3
+ NFT_CMP_GT = 0x4
+ NFT_CMP_GTE = 0x5
+ NFTA_CMP_UNSPEC = 0x0
+ NFTA_CMP_SREG = 0x1
+ NFTA_CMP_OP = 0x2
+ NFTA_CMP_DATA = 0x3
+ NFT_RANGE_EQ = 0x0
+ NFT_RANGE_NEQ = 0x1
+ NFTA_RANGE_UNSPEC = 0x0
+ NFTA_RANGE_SREG = 0x1
+ NFTA_RANGE_OP = 0x2
+ NFTA_RANGE_FROM_DATA = 0x3
+ NFTA_RANGE_TO_DATA = 0x4
+ NFT_LOOKUP_F_INV = 0x1
+ NFTA_LOOKUP_UNSPEC = 0x0
+ NFTA_LOOKUP_SET = 0x1
+ NFTA_LOOKUP_SREG = 0x2
+ NFTA_LOOKUP_DREG = 0x3
+ NFTA_LOOKUP_SET_ID = 0x4
+ NFTA_LOOKUP_FLAGS = 0x5
+ NFT_DYNSET_OP_ADD = 0x0
+ NFT_DYNSET_OP_UPDATE = 0x1
+ NFT_DYNSET_F_INV = 0x1
+ NFTA_DYNSET_UNSPEC = 0x0
+ NFTA_DYNSET_SET_NAME = 0x1
+ NFTA_DYNSET_SET_ID = 0x2
+ NFTA_DYNSET_OP = 0x3
+ NFTA_DYNSET_SREG_KEY = 0x4
+ NFTA_DYNSET_SREG_DATA = 0x5
+ NFTA_DYNSET_TIMEOUT = 0x6
+ NFTA_DYNSET_EXPR = 0x7
+ NFTA_DYNSET_PAD = 0x8
+ NFTA_DYNSET_FLAGS = 0x9
+ NFT_PAYLOAD_LL_HEADER = 0x0
+ NFT_PAYLOAD_NETWORK_HEADER = 0x1
+ NFT_PAYLOAD_TRANSPORT_HEADER = 0x2
+ NFT_PAYLOAD_CSUM_NONE = 0x0
+ NFT_PAYLOAD_CSUM_INET = 0x1
+ NFT_PAYLOAD_L4CSUM_PSEUDOHDR = 0x1
+ NFTA_PAYLOAD_UNSPEC = 0x0
+ NFTA_PAYLOAD_DREG = 0x1
+ NFTA_PAYLOAD_BASE = 0x2
+ NFTA_PAYLOAD_OFFSET = 0x3
+ NFTA_PAYLOAD_LEN = 0x4
+ NFTA_PAYLOAD_SREG = 0x5
+ NFTA_PAYLOAD_CSUM_TYPE = 0x6
+ NFTA_PAYLOAD_CSUM_OFFSET = 0x7
+ NFTA_PAYLOAD_CSUM_FLAGS = 0x8
+ NFT_EXTHDR_F_PRESENT = 0x1
+ NFT_EXTHDR_OP_IPV6 = 0x0
+ NFT_EXTHDR_OP_TCPOPT = 0x1
+ NFTA_EXTHDR_UNSPEC = 0x0
+ NFTA_EXTHDR_DREG = 0x1
+ NFTA_EXTHDR_TYPE = 0x2
+ NFTA_EXTHDR_OFFSET = 0x3
+ NFTA_EXTHDR_LEN = 0x4
+ NFTA_EXTHDR_FLAGS = 0x5
+ NFTA_EXTHDR_OP = 0x6
+ NFTA_EXTHDR_SREG = 0x7
+ NFT_META_LEN = 0x0
+ NFT_META_PROTOCOL = 0x1
+ NFT_META_PRIORITY = 0x2
+ NFT_META_MARK = 0x3
+ NFT_META_IIF = 0x4
+ NFT_META_OIF = 0x5
+ NFT_META_IIFNAME = 0x6
+ NFT_META_OIFNAME = 0x7
+ NFT_META_IIFTYPE = 0x8
+ NFT_META_OIFTYPE = 0x9
+ NFT_META_SKUID = 0xa
+ NFT_META_SKGID = 0xb
+ NFT_META_NFTRACE = 0xc
+ NFT_META_RTCLASSID = 0xd
+ NFT_META_SECMARK = 0xe
+ NFT_META_NFPROTO = 0xf
+ NFT_META_L4PROTO = 0x10
+ NFT_META_BRI_IIFNAME = 0x11
+ NFT_META_BRI_OIFNAME = 0x12
+ NFT_META_PKTTYPE = 0x13
+ NFT_META_CPU = 0x14
+ NFT_META_IIFGROUP = 0x15
+ NFT_META_OIFGROUP = 0x16
+ NFT_META_CGROUP = 0x17
+ NFT_META_PRANDOM = 0x18
+ NFT_RT_CLASSID = 0x0
+ NFT_RT_NEXTHOP4 = 0x1
+ NFT_RT_NEXTHOP6 = 0x2
+ NFT_RT_TCPMSS = 0x3
+ NFT_HASH_JENKINS = 0x0
+ NFT_HASH_SYM = 0x1
+ NFTA_HASH_UNSPEC = 0x0
+ NFTA_HASH_SREG = 0x1
+ NFTA_HASH_DREG = 0x2
+ NFTA_HASH_LEN = 0x3
+ NFTA_HASH_MODULUS = 0x4
+ NFTA_HASH_SEED = 0x5
+ NFTA_HASH_OFFSET = 0x6
+ NFTA_HASH_TYPE = 0x7
+ NFTA_META_UNSPEC = 0x0
+ NFTA_META_DREG = 0x1
+ NFTA_META_KEY = 0x2
+ NFTA_META_SREG = 0x3
+ NFTA_RT_UNSPEC = 0x0
+ NFTA_RT_DREG = 0x1
+ NFTA_RT_KEY = 0x2
+ NFT_CT_STATE = 0x0
+ NFT_CT_DIRECTION = 0x1
+ NFT_CT_STATUS = 0x2
+ NFT_CT_MARK = 0x3
+ NFT_CT_SECMARK = 0x4
+ NFT_CT_EXPIRATION = 0x5
+ NFT_CT_HELPER = 0x6
+ NFT_CT_L3PROTOCOL = 0x7
+ NFT_CT_SRC = 0x8
+ NFT_CT_DST = 0x9
+ NFT_CT_PROTOCOL = 0xa
+ NFT_CT_PROTO_SRC = 0xb
+ NFT_CT_PROTO_DST = 0xc
+ NFT_CT_LABELS = 0xd
+ NFT_CT_PKTS = 0xe
+ NFT_CT_BYTES = 0xf
+ NFT_CT_AVGPKT = 0x10
+ NFT_CT_ZONE = 0x11
+ NFT_CT_EVENTMASK = 0x12
+ NFTA_CT_UNSPEC = 0x0
+ NFTA_CT_DREG = 0x1
+ NFTA_CT_KEY = 0x2
+ NFTA_CT_DIRECTION = 0x3
+ NFTA_CT_SREG = 0x4
+ NFT_LIMIT_PKTS = 0x0
+ NFT_LIMIT_PKT_BYTES = 0x1
+ NFT_LIMIT_F_INV = 0x1
+ NFTA_LIMIT_UNSPEC = 0x0
+ NFTA_LIMIT_RATE = 0x1
+ NFTA_LIMIT_UNIT = 0x2
+ NFTA_LIMIT_BURST = 0x3
+ NFTA_LIMIT_TYPE = 0x4
+ NFTA_LIMIT_FLAGS = 0x5
+ NFTA_LIMIT_PAD = 0x6
+ NFTA_COUNTER_UNSPEC = 0x0
+ NFTA_COUNTER_BYTES = 0x1
+ NFTA_COUNTER_PACKETS = 0x2
+ NFTA_COUNTER_PAD = 0x3
+ NFTA_LOG_UNSPEC = 0x0
+ NFTA_LOG_GROUP = 0x1
+ NFTA_LOG_PREFIX = 0x2
+ NFTA_LOG_SNAPLEN = 0x3
+ NFTA_LOG_QTHRESHOLD = 0x4
+ NFTA_LOG_LEVEL = 0x5
+ NFTA_LOG_FLAGS = 0x6
+ NFTA_QUEUE_UNSPEC = 0x0
+ NFTA_QUEUE_NUM = 0x1
+ NFTA_QUEUE_TOTAL = 0x2
+ NFTA_QUEUE_FLAGS = 0x3
+ NFTA_QUEUE_SREG_QNUM = 0x4
+ NFT_QUOTA_F_INV = 0x1
+ NFT_QUOTA_F_DEPLETED = 0x2
+ NFTA_QUOTA_UNSPEC = 0x0
+ NFTA_QUOTA_BYTES = 0x1
+ NFTA_QUOTA_FLAGS = 0x2
+ NFTA_QUOTA_PAD = 0x3
+ NFTA_QUOTA_CONSUMED = 0x4
+ NFT_REJECT_ICMP_UNREACH = 0x0
+ NFT_REJECT_TCP_RST = 0x1
+ NFT_REJECT_ICMPX_UNREACH = 0x2
+ NFT_REJECT_ICMPX_NO_ROUTE = 0x0
+ NFT_REJECT_ICMPX_PORT_UNREACH = 0x1
+ NFT_REJECT_ICMPX_HOST_UNREACH = 0x2
+ NFT_REJECT_ICMPX_ADMIN_PROHIBITED = 0x3
+ NFTA_REJECT_UNSPEC = 0x0
+ NFTA_REJECT_TYPE = 0x1
+ NFTA_REJECT_ICMP_CODE = 0x2
+ NFT_NAT_SNAT = 0x0
+ NFT_NAT_DNAT = 0x1
+ NFTA_NAT_UNSPEC = 0x0
+ NFTA_NAT_TYPE = 0x1
+ NFTA_NAT_FAMILY = 0x2
+ NFTA_NAT_REG_ADDR_MIN = 0x3
+ NFTA_NAT_REG_ADDR_MAX = 0x4
+ NFTA_NAT_REG_PROTO_MIN = 0x5
+ NFTA_NAT_REG_PROTO_MAX = 0x6
+ NFTA_NAT_FLAGS = 0x7
+ NFTA_MASQ_UNSPEC = 0x0
+ NFTA_MASQ_FLAGS = 0x1
+ NFTA_MASQ_REG_PROTO_MIN = 0x2
+ NFTA_MASQ_REG_PROTO_MAX = 0x3
+ NFTA_REDIR_UNSPEC = 0x0
+ NFTA_REDIR_REG_PROTO_MIN = 0x1
+ NFTA_REDIR_REG_PROTO_MAX = 0x2
+ NFTA_REDIR_FLAGS = 0x3
+ NFTA_DUP_UNSPEC = 0x0
+ NFTA_DUP_SREG_ADDR = 0x1
+ NFTA_DUP_SREG_DEV = 0x2
+ NFTA_FWD_UNSPEC = 0x0
+ NFTA_FWD_SREG_DEV = 0x1
+ NFTA_OBJREF_UNSPEC = 0x0
+ NFTA_OBJREF_IMM_TYPE = 0x1
+ NFTA_OBJREF_IMM_NAME = 0x2
+ NFTA_OBJREF_SET_SREG = 0x3
+ NFTA_OBJREF_SET_NAME = 0x4
+ NFTA_OBJREF_SET_ID = 0x5
+ NFTA_GEN_UNSPEC = 0x0
+ NFTA_GEN_ID = 0x1
+ NFTA_GEN_PROC_PID = 0x2
+ NFTA_GEN_PROC_NAME = 0x3
+ NFTA_FIB_UNSPEC = 0x0
+ NFTA_FIB_DREG = 0x1
+ NFTA_FIB_RESULT = 0x2
+ NFTA_FIB_FLAGS = 0x3
+ NFT_FIB_RESULT_UNSPEC = 0x0
+ NFT_FIB_RESULT_OIF = 0x1
+ NFT_FIB_RESULT_OIFNAME = 0x2
+ NFT_FIB_RESULT_ADDRTYPE = 0x3
+ NFTA_FIB_F_SADDR = 0x1
+ NFTA_FIB_F_DADDR = 0x2
+ NFTA_FIB_F_MARK = 0x4
+ NFTA_FIB_F_IIF = 0x8
+ NFTA_FIB_F_OIF = 0x10
+ NFTA_FIB_F_PRESENT = 0x20
+ NFTA_CT_HELPER_UNSPEC = 0x0
+ NFTA_CT_HELPER_NAME = 0x1
+ NFTA_CT_HELPER_L3PROTO = 0x2
+ NFTA_CT_HELPER_L4PROTO = 0x3
+ NFTA_OBJ_UNSPEC = 0x0
+ NFTA_OBJ_TABLE = 0x1
+ NFTA_OBJ_NAME = 0x2
+ NFTA_OBJ_TYPE = 0x3
+ NFTA_OBJ_DATA = 0x4
+ NFTA_OBJ_USE = 0x5
+ NFTA_TRACE_UNSPEC = 0x0
+ NFTA_TRACE_TABLE = 0x1
+ NFTA_TRACE_CHAIN = 0x2
+ NFTA_TRACE_RULE_HANDLE = 0x3
+ NFTA_TRACE_TYPE = 0x4
+ NFTA_TRACE_VERDICT = 0x5
+ NFTA_TRACE_ID = 0x6
+ NFTA_TRACE_LL_HEADER = 0x7
+ NFTA_TRACE_NETWORK_HEADER = 0x8
+ NFTA_TRACE_TRANSPORT_HEADER = 0x9
+ NFTA_TRACE_IIF = 0xa
+ NFTA_TRACE_IIFTYPE = 0xb
+ NFTA_TRACE_OIF = 0xc
+ NFTA_TRACE_OIFTYPE = 0xd
+ NFTA_TRACE_MARK = 0xe
+ NFTA_TRACE_NFPROTO = 0xf
+ NFTA_TRACE_POLICY = 0x10
+ NFTA_TRACE_PAD = 0x11
+ NFT_TRACETYPE_UNSPEC = 0x0
+ NFT_TRACETYPE_POLICY = 0x1
+ NFT_TRACETYPE_RETURN = 0x2
+ NFT_TRACETYPE_RULE = 0x3
+ NFTA_NG_UNSPEC = 0x0
+ NFTA_NG_DREG = 0x1
+ NFTA_NG_MODULUS = 0x2
+ NFTA_NG_TYPE = 0x3
+ NFTA_NG_OFFSET = 0x4
+ NFT_NG_INCREMENTAL = 0x0
+ NFT_NG_RANDOM = 0x1
+)
+
+type RTCTime struct {
+ Sec int32
+ Min int32
+ Hour int32
+ Mday int32
+ Mon int32
+ Year int32
+ Wday int32
+ Yday int32
+ Isdst int32
+}
+
+type RTCWkAlrm struct {
+ Enabled uint8
+ Pending uint8
+ Time RTCTime
+}
+
+type RTCPLLInfo struct {
+ Ctrl int32
+ Value int32
+ Max int32
+ Min int32
+ Posmult int32
+ Negmult int32
+ Clock int64
+}
+
+type BlkpgIoctlArg struct {
+ Op int32
+ Flags int32
+ Datalen int32
+ Data *byte
+}
+
+type BlkpgPartition struct {
+ Start int64
+ Length int64
+ Pno int32
+ Devname [64]uint8
+ Volname [64]uint8
+ _ [4]byte
+}
+
+const (
+ BLKPG = 0x20001269
+ BLKPG_ADD_PARTITION = 0x1
+ BLKPG_DEL_PARTITION = 0x2
+ BLKPG_RESIZE_PARTITION = 0x3
+)
+
+const (
+ NETNSA_NONE = 0x0
+ NETNSA_NSID = 0x1
+ NETNSA_PID = 0x2
+ NETNSA_FD = 0x3
+)
+
+type XDPRingOffset struct {
+ Producer uint64
+ Consumer uint64
+ Desc uint64
+}
+
+type XDPMmapOffsets struct {
+ Rx XDPRingOffset
+ Tx XDPRingOffset
+ Fr XDPRingOffset
+ Cr XDPRingOffset
+}
+
+type XDPUmemReg struct {
+ Addr uint64
+ Len uint64
+ Size uint32
+ Headroom uint32
+}
+
+type XDPStatistics struct {
+ Rx_dropped uint64
+ Rx_invalid_descs uint64
+ Tx_invalid_descs uint64
+}
+
+type XDPDesc struct {
+ Addr uint64
+ Len uint32
+ Options uint32
+}
+
+const (
+ NCSI_CMD_UNSPEC = 0x0
+ NCSI_CMD_PKG_INFO = 0x1
+ NCSI_CMD_SET_INTERFACE = 0x2
+ NCSI_CMD_CLEAR_INTERFACE = 0x3
+ NCSI_ATTR_UNSPEC = 0x0
+ NCSI_ATTR_IFINDEX = 0x1
+ NCSI_ATTR_PACKAGE_LIST = 0x2
+ NCSI_ATTR_PACKAGE_ID = 0x3
+ NCSI_ATTR_CHANNEL_ID = 0x4
+ NCSI_PKG_ATTR_UNSPEC = 0x0
+ NCSI_PKG_ATTR = 0x1
+ NCSI_PKG_ATTR_ID = 0x2
+ NCSI_PKG_ATTR_FORCED = 0x3
+ NCSI_PKG_ATTR_CHANNEL_LIST = 0x4
+ NCSI_CHANNEL_ATTR_UNSPEC = 0x0
+ NCSI_CHANNEL_ATTR = 0x1
+ NCSI_CHANNEL_ATTR_ID = 0x2
+ NCSI_CHANNEL_ATTR_VERSION_MAJOR = 0x3
+ NCSI_CHANNEL_ATTR_VERSION_MINOR = 0x4
+ NCSI_CHANNEL_ATTR_VERSION_STR = 0x5
+ NCSI_CHANNEL_ATTR_LINK_STATE = 0x6
+ NCSI_CHANNEL_ATTR_ACTIVE = 0x7
+ NCSI_CHANNEL_ATTR_FORCED = 0x8
+ NCSI_CHANNEL_ATTR_VLAN_LIST = 0x9
+ NCSI_CHANNEL_ATTR_VLAN_ID = 0xa
+)
+
+const (
+ SOF_TIMESTAMPING_TX_HARDWARE = 0x1
+ SOF_TIMESTAMPING_TX_SOFTWARE = 0x2
+ SOF_TIMESTAMPING_RX_HARDWARE = 0x4
+ SOF_TIMESTAMPING_RX_SOFTWARE = 0x8
+ SOF_TIMESTAMPING_SOFTWARE = 0x10
+ SOF_TIMESTAMPING_SYS_HARDWARE = 0x20
+ SOF_TIMESTAMPING_RAW_HARDWARE = 0x40
+ SOF_TIMESTAMPING_OPT_ID = 0x80
+ SOF_TIMESTAMPING_TX_SCHED = 0x100
+ SOF_TIMESTAMPING_TX_ACK = 0x200
+ SOF_TIMESTAMPING_OPT_CMSG = 0x400
+ SOF_TIMESTAMPING_OPT_TSONLY = 0x800
+ SOF_TIMESTAMPING_OPT_STATS = 0x1000
+ SOF_TIMESTAMPING_OPT_PKTINFO = 0x2000
+ SOF_TIMESTAMPING_OPT_TX_SWHW = 0x4000
+
+ SOF_TIMESTAMPING_LAST = 0x4000
+ SOF_TIMESTAMPING_MASK = 0x7fff
+)
diff --git a/vendor/golang.org/x/sys/unix/ztypes_netbsd_386.go b/vendor/golang.org/x/sys/unix/ztypes_netbsd_386.go
index 1fdc5fd21..2dae0c17a 100644
--- a/vendor/golang.org/x/sys/unix/ztypes_netbsd_386.go
+++ b/vendor/golang.org/x/sys/unix/ztypes_netbsd_386.go
@@ -402,6 +402,13 @@ type Winsize struct {
Ypixel uint16
}
+type Ptmget struct {
+ Cfd int32
+ Sfd int32
+ Cn [1024]byte
+ Sn [1024]byte
+}
+
const (
AT_FDCWD = -0x64
AT_SYMLINK_NOFOLLOW = 0x200
diff --git a/vendor/golang.org/x/sys/unix/ztypes_netbsd_amd64.go b/vendor/golang.org/x/sys/unix/ztypes_netbsd_amd64.go
index 711f78067..1f0e76c0c 100644
--- a/vendor/golang.org/x/sys/unix/ztypes_netbsd_amd64.go
+++ b/vendor/golang.org/x/sys/unix/ztypes_netbsd_amd64.go
@@ -409,6 +409,13 @@ type Winsize struct {
Ypixel uint16
}
+type Ptmget struct {
+ Cfd int32
+ Sfd int32
+ Cn [1024]byte
+ Sn [1024]byte
+}
+
const (
AT_FDCWD = -0x64
AT_SYMLINK_NOFOLLOW = 0x200
diff --git a/vendor/golang.org/x/sys/unix/ztypes_netbsd_arm.go b/vendor/golang.org/x/sys/unix/ztypes_netbsd_arm.go
index fa1a16bae..53f2159c7 100644
--- a/vendor/golang.org/x/sys/unix/ztypes_netbsd_arm.go
+++ b/vendor/golang.org/x/sys/unix/ztypes_netbsd_arm.go
@@ -407,6 +407,13 @@ type Winsize struct {
Ypixel uint16
}
+type Ptmget struct {
+ Cfd int32
+ Sfd int32
+ Cn [1024]byte
+ Sn [1024]byte
+}
+
const (
AT_FDCWD = -0x64
AT_SYMLINK_NOFOLLOW = 0x200
diff --git a/vendor/golang.org/x/sys/unix/ztypes_openbsd_arm.go b/vendor/golang.org/x/sys/unix/ztypes_openbsd_arm.go
index 87a637e3f..510efc3ea 100644
--- a/vendor/golang.org/x/sys/unix/ztypes_openbsd_arm.go
+++ b/vendor/golang.org/x/sys/unix/ztypes_openbsd_arm.go
@@ -1,4 +1,4 @@
-// cgo -godefs types_openbsd.go | go run mkpost.go
+// cgo -godefs -- -fsigned-char types_openbsd.go | go run mkpost.go
// Code generated by the command above; see README.md. DO NOT EDIT.
// +build arm,openbsd
@@ -23,11 +23,13 @@ type (
type Timespec struct {
Sec int64
Nsec int32
+ _ [4]byte
}
type Timeval struct {
Sec int64
Usec int32
+ _ [4]byte
}
type Rusage struct {
@@ -57,28 +59,30 @@ type Rlimit struct {
type _Gid_t uint32
type Stat_t struct {
- Mode uint32
- Dev int32
- Ino uint64
- Nlink uint32
- Uid uint32
- Gid uint32
- Rdev int32
- Atim Timespec
- Mtim Timespec
- Ctim Timespec
- Size int64
- Blocks int64
- Blksize int32
- Flags uint32
- Gen uint32
- X__st_birthtim Timespec
+ Mode uint32
+ Dev int32
+ Ino uint64
+ Nlink uint32
+ Uid uint32
+ Gid uint32
+ Rdev int32
+ Atim Timespec
+ Mtim Timespec
+ Ctim Timespec
+ Size int64
+ Blocks int64
+ Blksize int32
+ Flags uint32
+ Gen uint32
+ _ [4]byte
+ _ Timespec
}
type Statfs_t struct {
F_flags uint32
F_bsize uint32
F_iosize uint32
+ _ [4]byte
F_blocks uint64
F_bfree uint64
F_bavail int64
@@ -93,11 +97,11 @@ type Statfs_t struct {
F_namemax uint32
F_owner uint32
F_ctime uint64
- F_fstypename [16]uint8
- F_mntonname [90]uint8
- F_mntfromname [90]uint8
- F_mntfromspec [90]uint8
- Pad_cgo_0 [2]byte
+ F_fstypename [16]int8
+ F_mntonname [90]int8
+ F_mntfromname [90]int8
+ F_mntfromspec [90]int8
+ _ [2]byte
Mount_info [160]byte
}
@@ -110,13 +114,13 @@ type Flock_t struct {
}
type Dirent struct {
- Fileno uint64
- Off int64
- Reclen uint16
- Type uint8
- Namlen uint8
- X__d_padding [4]uint8
- Name [256]uint8
+ Fileno uint64
+ Off int64
+ Reclen uint16
+ Type uint8
+ Namlen uint8
+ _ [4]uint8
+ Name [256]int8
}
type Fsid struct {
@@ -251,8 +255,10 @@ type Kevent_t struct {
Filter int16
Flags uint16
Fflags uint32
+ _ [4]byte
Data int64
Udata *byte
+ _ [4]byte
}
type FdSet struct {
@@ -260,8 +266,8 @@ type FdSet struct {
}
const (
- SizeofIfMsghdr = 0x98
- SizeofIfData = 0x80
+ SizeofIfMsghdr = 0xa8
+ SizeofIfData = 0x90
SizeofIfaMsghdr = 0x18
SizeofIfAnnounceMsghdr = 0x1a
SizeofRtMsghdr = 0x60
@@ -290,7 +296,7 @@ type IfData struct {
Link_state uint8
Mtu uint32
Metric uint32
- Pad uint32
+ Rdomain uint32
Baudrate uint64
Ipackets uint64
Ierrors uint64
@@ -302,8 +308,10 @@ type IfData struct {
Imcasts uint64
Omcasts uint64
Iqdrops uint64
+ Oqdrops uint64
Noproto uint64
Capabilities uint32
+ _ [4]byte
Lastchange Timeval
}
@@ -328,7 +336,7 @@ type IfAnnounceMsghdr struct {
Hdrlen uint16
Index uint16
What uint16
- Name [16]uint8
+ Name [16]int8
}
type RtMsghdr struct {
@@ -398,11 +406,11 @@ type BpfInsn struct {
}
type BpfHdr struct {
- Tstamp BpfTimeval
- Caplen uint32
- Datalen uint32
- Hdrlen uint16
- Pad_cgo_0 [2]byte
+ Tstamp BpfTimeval
+ Caplen uint32
+ Datalen uint32
+ Hdrlen uint16
+ _ [2]byte
}
type BpfTimeval struct {
@@ -476,7 +484,7 @@ type Uvmexp struct {
Zeropages int32
Reserve_pagedaemon int32
Reserve_kernel int32
- Anonpages int32
+ Unused01 int32
Vnodepages int32
Vtextpages int32
Freemin int32
@@ -495,8 +503,8 @@ type Uvmexp struct {
Swpgonly int32
Nswget int32
Nanon int32
- Nanonneeded int32
- Nfreeanon int32
+ Unused05 int32
+ Unused06 int32
Faults int32
Traps int32
Intrs int32
@@ -504,8 +512,8 @@ type Uvmexp struct {
Softs int32
Syscalls int32
Pageins int32
- Obsolete_swapins int32
- Obsolete_swapouts int32
+ Unused07 int32
+ Unused08 int32
Pgswapin int32
Pgswapout int32
Forks int32
@@ -513,7 +521,7 @@ type Uvmexp struct {
Forks_sharevm int32
Pga_zerohit int32
Pga_zeromiss int32
- Zeroaborts int32
+ Unused09 int32
Fltnoram int32
Fltnoanon int32
Fltnoamap int32
@@ -545,9 +553,9 @@ type Uvmexp struct {
Pdpageouts int32
Pdpending int32
Pddeact int32
- Pdreanon int32
- Pdrevnode int32
- Pdrevtext int32
+ Unused11 int32
+ Unused12 int32
+ Unused13 int32
Fpswtch int32
Kmapent int32
}
diff --git a/vendor/gopkg.in/yaml.v2/encode.go b/vendor/gopkg.in/yaml.v2/encode.go
index a14435e82..0ee738e11 100644
--- a/vendor/gopkg.in/yaml.v2/encode.go
+++ b/vendor/gopkg.in/yaml.v2/encode.go
@@ -13,6 +13,19 @@ import (
"unicode/utf8"
)
+// jsonNumber is the interface of the encoding/json.Number datatype.
+// Repeating the interface here avoids a dependency on encoding/json, and also
+// supports other libraries like jsoniter, which use a similar datatype with
+// the same interface. Detecting this interface is useful when dealing with
+// structures containing json.Number, which is a string under the hood. The
+// encoder should prefer the use of Int64(), Float64() and string(), in that
+// order, when encoding this type.
+type jsonNumber interface {
+ Float64() (float64, error)
+ Int64() (int64, error)
+ String() string
+}
+
type encoder struct {
emitter yaml_emitter_t
event yaml_event_t
@@ -89,6 +102,21 @@ func (e *encoder) marshal(tag string, in reflect.Value) {
}
iface := in.Interface()
switch m := iface.(type) {
+ case jsonNumber:
+ integer, err := m.Int64()
+ if err == nil {
+ // In this case the json.Number is a valid int64
+ in = reflect.ValueOf(integer)
+ break
+ }
+ float, err := m.Float64()
+ if err == nil {
+ // In this case the json.Number is a valid float64
+ in = reflect.ValueOf(float)
+ break
+ }
+ // fallback case - no number could be obtained
+ in = reflect.ValueOf(m.String())
case time.Time, *time.Time:
// Although time.Time implements TextMarshaler,
// we don't want to treat it as a string for YAML
From acaf07c18969a90fa15e1ab8297a2a4d35322808 Mon Sep 17 00:00:00 2001
From: leventeliu
Date: Tue, 25 Dec 2018 22:43:54 +0800
Subject: [PATCH 160/278] Hack to allow a reference at genesis block while deep
copying sqlchain profile
---
blockproducer/metaindex.go | 7 ++++++-
blockproducer/metastate.go | 29 ++++++++++++++++++-----------
2 files changed, 24 insertions(+), 12 deletions(-)
diff --git a/blockproducer/metaindex.go b/blockproducer/metaindex.go
index cbef46e66..a3f1fea0f 100644
--- a/blockproducer/metaindex.go
+++ b/blockproducer/metaindex.go
@@ -60,7 +60,12 @@ func (i *metaIndex) deepCopy() (cpy *metaIndex) {
cpy.accounts[k] = deepcopy.Copy(v).(*types.Account)
}
for k, v := range i.databases {
- cpy.databases[k] = deepcopy.Copy(v).(*types.SQLChainProfile)
+ // HACK(leventeliu): public key / signature cannot be deep-copied correctly due to their
+ // hidden fields. Hack this since genesis block should be implied to be immutable.
+ // Also more similar hacks can be found in metastate.go.
+ var dst = deepcopy.Copy(v).(*types.SQLChainProfile)
+ dst.Genesis = v.Genesis
+ cpy.databases[k] = dst
}
for k, v := range i.provider {
cpy.provider[k] = deepcopy.Copy(v).(*types.ProviderProfile)
diff --git a/blockproducer/metastate.go b/blockproducer/metastate.go
index f7cec62ab..72331764f 100644
--- a/blockproducer/metastate.go
+++ b/blockproducer/metastate.go
@@ -154,10 +154,12 @@ func (s *metaState) loadSQLChainObject(k proto.DatabaseID) (o *types.SQLChainPro
return
}
o = deepcopy.Copy(old).(*types.SQLChainProfile)
+ o.Genesis = old.Genesis
return
}
if old, loaded = s.readonly.databases[k]; loaded {
o = deepcopy.Copy(old).(*types.SQLChainProfile)
+ o.Genesis = old.Genesis
return
}
return
@@ -394,6 +396,7 @@ func (s *metaState) addSQLChainUser(
return ErrDatabaseNotFound
}
dst = deepcopy.Copy(src).(*types.SQLChainProfile)
+ dst.Genesis = src.Genesis
s.dirty.databases[k] = dst
}
for _, v := range dst.Users {
@@ -418,6 +421,7 @@ func (s *metaState) deleteSQLChainUser(k proto.DatabaseID, addr proto.AccountAdd
return ErrDatabaseNotFound
}
dst = deepcopy.Copy(src).(*types.SQLChainProfile)
+ dst.Genesis = src.Genesis
s.dirty.databases[k] = dst
}
for i, v := range dst.Users {
@@ -443,6 +447,7 @@ func (s *metaState) alterSQLChainUser(
return ErrDatabaseNotFound
}
dst = deepcopy.Copy(src).(*types.SQLChainProfile)
+ dst.Genesis = src.Genesis
s.dirty.databases[k] = dst
}
for _, v := range dst.Users {
@@ -758,19 +763,19 @@ func (s *metaState) updateKeys(tx *types.IssueKeys) (err error) {
}
func (s *metaState) updateBilling(tx *types.UpdateBilling) (err error) {
- sqlchainObj, loaded := s.loadSQLChainObject(tx.Receiver.DatabaseID())
+ newProfile, loaded := s.loadSQLChainObject(tx.Receiver.DatabaseID())
if !loaded {
err = errors.Wrap(ErrDatabaseNotFound, "update billing failed")
return
}
log.Debugf("update billing addr: %s, tx: %v", tx.GetAccountAddress(), tx)
- if sqlchainObj.GasPrice == 0 {
+ if newProfile.GasPrice == 0 {
return
}
// pending income to income
- for _, miner := range sqlchainObj.Miners {
+ for _, miner := range newProfile.Miners {
miner.ReceivedIncome += miner.PendingIncome
}
@@ -788,18 +793,18 @@ func (s *metaState) updateBilling(tx *types.UpdateBilling) (err error) {
userMap[userCost.User][minerIncome.Miner] += minerIncome.Income
}
}
- for _, user := range sqlchainObj.Users {
- if user.AdvancePayment >= costMap[user.Address]*sqlchainObj.GasPrice {
- user.AdvancePayment -= costMap[user.Address] * sqlchainObj.GasPrice
- for _, miner := range sqlchainObj.Miners {
- miner.PendingIncome += userMap[user.Address][miner.Address] * sqlchainObj.GasPrice
+ for _, user := range newProfile.Users {
+ if user.AdvancePayment >= costMap[user.Address]*newProfile.GasPrice {
+ user.AdvancePayment -= costMap[user.Address] * newProfile.GasPrice
+ for _, miner := range newProfile.Miners {
+ miner.PendingIncome += userMap[user.Address][miner.Address] * newProfile.GasPrice
}
} else {
- rate := 1 - float64(user.AdvancePayment)/float64(costMap[user.Address]*sqlchainObj.GasPrice)
+ rate := 1 - float64(user.AdvancePayment)/float64(costMap[user.Address]*newProfile.GasPrice)
user.AdvancePayment = 0
user.Status = types.Arrears
- for _, miner := range sqlchainObj.Miners {
- income := userMap[user.Address][miner.Address] * sqlchainObj.GasPrice
+ for _, miner := range newProfile.Miners {
+ income := userMap[user.Address][miner.Address] * newProfile.GasPrice
minerIncome := uint64(float64(income) * rate)
miner.PendingIncome += minerIncome
for i := range miner.UserArrears {
@@ -808,6 +813,7 @@ func (s *metaState) updateBilling(tx *types.UpdateBilling) (err error) {
}
}
}
+ s.dirty.databases[tx.Receiver.DatabaseID()] = newProfile
return
}
@@ -816,6 +822,7 @@ func (s *metaState) loadROSQLChains(addr proto.AccountAddress) (dbs []*types.SQL
for _, miner := range db.Miners {
if miner.Address == addr {
var dst = deepcopy.Copy(db).(*types.SQLChainProfile)
+ dst.Genesis = db.Genesis
dbs = append(dbs, dst)
}
}
From dbfd463b3514cb3d70d75631d84efea64b6381df Mon Sep 17 00:00:00 2001
From: leventeliu
Date: Tue, 25 Dec 2018 22:51:16 +0800
Subject: [PATCH 161/278] Revert "Hack to allow a reference at genesis block
while deep copying sqlchain profile"
This reverts commit acaf07c18969a90fa15e1ab8297a2a4d35322808.
---
blockproducer/metaindex.go | 7 +------
blockproducer/metastate.go | 29 +++++++++++------------------
2 files changed, 12 insertions(+), 24 deletions(-)
diff --git a/blockproducer/metaindex.go b/blockproducer/metaindex.go
index a3f1fea0f..cbef46e66 100644
--- a/blockproducer/metaindex.go
+++ b/blockproducer/metaindex.go
@@ -60,12 +60,7 @@ func (i *metaIndex) deepCopy() (cpy *metaIndex) {
cpy.accounts[k] = deepcopy.Copy(v).(*types.Account)
}
for k, v := range i.databases {
- // HACK(leventeliu): public key / signature cannot be deep-copied correctly due to their
- // hidden fields. Hack this since genesis block should be implied to be immutable.
- // Also more similar hacks can be found in metastate.go.
- var dst = deepcopy.Copy(v).(*types.SQLChainProfile)
- dst.Genesis = v.Genesis
- cpy.databases[k] = dst
+ cpy.databases[k] = deepcopy.Copy(v).(*types.SQLChainProfile)
}
for k, v := range i.provider {
cpy.provider[k] = deepcopy.Copy(v).(*types.ProviderProfile)
diff --git a/blockproducer/metastate.go b/blockproducer/metastate.go
index 72331764f..f7cec62ab 100644
--- a/blockproducer/metastate.go
+++ b/blockproducer/metastate.go
@@ -154,12 +154,10 @@ func (s *metaState) loadSQLChainObject(k proto.DatabaseID) (o *types.SQLChainPro
return
}
o = deepcopy.Copy(old).(*types.SQLChainProfile)
- o.Genesis = old.Genesis
return
}
if old, loaded = s.readonly.databases[k]; loaded {
o = deepcopy.Copy(old).(*types.SQLChainProfile)
- o.Genesis = old.Genesis
return
}
return
@@ -396,7 +394,6 @@ func (s *metaState) addSQLChainUser(
return ErrDatabaseNotFound
}
dst = deepcopy.Copy(src).(*types.SQLChainProfile)
- dst.Genesis = src.Genesis
s.dirty.databases[k] = dst
}
for _, v := range dst.Users {
@@ -421,7 +418,6 @@ func (s *metaState) deleteSQLChainUser(k proto.DatabaseID, addr proto.AccountAdd
return ErrDatabaseNotFound
}
dst = deepcopy.Copy(src).(*types.SQLChainProfile)
- dst.Genesis = src.Genesis
s.dirty.databases[k] = dst
}
for i, v := range dst.Users {
@@ -447,7 +443,6 @@ func (s *metaState) alterSQLChainUser(
return ErrDatabaseNotFound
}
dst = deepcopy.Copy(src).(*types.SQLChainProfile)
- dst.Genesis = src.Genesis
s.dirty.databases[k] = dst
}
for _, v := range dst.Users {
@@ -763,19 +758,19 @@ func (s *metaState) updateKeys(tx *types.IssueKeys) (err error) {
}
func (s *metaState) updateBilling(tx *types.UpdateBilling) (err error) {
- newProfile, loaded := s.loadSQLChainObject(tx.Receiver.DatabaseID())
+ sqlchainObj, loaded := s.loadSQLChainObject(tx.Receiver.DatabaseID())
if !loaded {
err = errors.Wrap(ErrDatabaseNotFound, "update billing failed")
return
}
log.Debugf("update billing addr: %s, tx: %v", tx.GetAccountAddress(), tx)
- if newProfile.GasPrice == 0 {
+ if sqlchainObj.GasPrice == 0 {
return
}
// pending income to income
- for _, miner := range newProfile.Miners {
+ for _, miner := range sqlchainObj.Miners {
miner.ReceivedIncome += miner.PendingIncome
}
@@ -793,18 +788,18 @@ func (s *metaState) updateBilling(tx *types.UpdateBilling) (err error) {
userMap[userCost.User][minerIncome.Miner] += minerIncome.Income
}
}
- for _, user := range newProfile.Users {
- if user.AdvancePayment >= costMap[user.Address]*newProfile.GasPrice {
- user.AdvancePayment -= costMap[user.Address] * newProfile.GasPrice
- for _, miner := range newProfile.Miners {
- miner.PendingIncome += userMap[user.Address][miner.Address] * newProfile.GasPrice
+ for _, user := range sqlchainObj.Users {
+ if user.AdvancePayment >= costMap[user.Address]*sqlchainObj.GasPrice {
+ user.AdvancePayment -= costMap[user.Address] * sqlchainObj.GasPrice
+ for _, miner := range sqlchainObj.Miners {
+ miner.PendingIncome += userMap[user.Address][miner.Address] * sqlchainObj.GasPrice
}
} else {
- rate := 1 - float64(user.AdvancePayment)/float64(costMap[user.Address]*newProfile.GasPrice)
+ rate := 1 - float64(user.AdvancePayment)/float64(costMap[user.Address]*sqlchainObj.GasPrice)
user.AdvancePayment = 0
user.Status = types.Arrears
- for _, miner := range newProfile.Miners {
- income := userMap[user.Address][miner.Address] * newProfile.GasPrice
+ for _, miner := range sqlchainObj.Miners {
+ income := userMap[user.Address][miner.Address] * sqlchainObj.GasPrice
minerIncome := uint64(float64(income) * rate)
miner.PendingIncome += minerIncome
for i := range miner.UserArrears {
@@ -813,7 +808,6 @@ func (s *metaState) updateBilling(tx *types.UpdateBilling) (err error) {
}
}
}
- s.dirty.databases[tx.Receiver.DatabaseID()] = newProfile
return
}
@@ -822,7 +816,6 @@ func (s *metaState) loadROSQLChains(addr proto.AccountAddress) (dbs []*types.SQL
for _, miner := range db.Miners {
if miner.Address == addr {
var dst = deepcopy.Copy(db).(*types.SQLChainProfile)
- dst.Genesis = db.Genesis
dbs = append(dbs, dst)
}
}
From 80e52e3bd885e0eeb0fa74c7d40c3bfe8c175f8a Mon Sep 17 00:00:00 2001
From: leventeliu
Date: Tue, 25 Dec 2018 23:03:23 +0800
Subject: [PATCH 162/278] Use encoded genesis block in sqlchain profile
---
blockproducer/metastate.go | 29 ++++++++++++++++++++---------
types/account.go | 2 +-
types/account_gen.go | 22 ++++------------------
worker/dbms.go | 6 +++++-
4 files changed, 30 insertions(+), 29 deletions(-)
diff --git a/blockproducer/metastate.go b/blockproducer/metastate.go
index f7cec62ab..2a1684e36 100644
--- a/blockproducer/metastate.go
+++ b/blockproducer/metastate.go
@@ -17,6 +17,7 @@
package blockproducer
import (
+ "bytes"
"time"
pi "github.com/CovenantSQL/CovenantSQL/blockproducer/interfaces"
@@ -27,6 +28,7 @@ import (
"github.com/CovenantSQL/CovenantSQL/crypto/kms"
"github.com/CovenantSQL/CovenantSQL/proto"
"github.com/CovenantSQL/CovenantSQL/types"
+ "github.com/CovenantSQL/CovenantSQL/utils"
"github.com/CovenantSQL/CovenantSQL/utils/log"
"github.com/mohae/deepcopy"
"github.com/pkg/errors"
@@ -632,17 +634,26 @@ func (s *metaState) matchProvidersWithUser(tx *types.CreateDatabase) (err error)
return err
}
+ // Encode genesis block
+ var enc *bytes.Buffer
+ if enc, err = utils.EncodeMsgPack(gb); err != nil {
+ log.WithFields(log.Fields{
+ "dbID": dbID,
+ }).WithError(err).Error("failed to encode genesis block")
+ return
+ }
+
// create sqlchain
sp := &types.SQLChainProfile{
- ID: *dbID,
- Address: dbAddr,
- Period: sqlchainPeriod,
- GasPrice: sqlchainGasPrice,
- TokenType: types.Particle,
- Owner: sender,
- Users: users,
- Genesis: gb,
- Miners: miners[:],
+ ID: *dbID,
+ Address: dbAddr,
+ Period: sqlchainPeriod,
+ GasPrice: sqlchainGasPrice,
+ TokenType: types.Particle,
+ Owner: sender,
+ Users: users,
+ EncodedGenesis: enc.Bytes(),
+ Miners: miners[:],
}
if _, loaded := s.loadSQLChainObject(*dbID); loaded {
diff --git a/types/account.go b/types/account.go
index 51a1e488f..3bc209ce6 100644
--- a/types/account.go
+++ b/types/account.go
@@ -133,7 +133,7 @@ type SQLChainProfile struct {
Users []*SQLChainUser
- Genesis *Block
+ EncodedGenesis []byte
Meta ResourceMeta // dumped from db creation tx
}
diff --git a/types/account_gen.go b/types/account_gen.go
index d3665ac94..7b5c4dbb8 100644
--- a/types/account_gen.go
+++ b/types/account_gen.go
@@ -156,16 +156,6 @@ func (z *SQLChainProfile) MarshalHash() (o []byte, err error) {
o = hsp.Require(b, z.Msgsize())
// map header, size 11
o = append(o, 0x8b, 0x8b)
- if z.Genesis == nil {
- o = hsp.AppendNil(o)
- } else {
- if oTemp, err := z.Genesis.MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
- }
- }
- o = append(o, 0x8b)
if oTemp, err := z.Meta.MarshalHash(); err != nil {
return nil, err
} else {
@@ -204,6 +194,8 @@ func (z *SQLChainProfile) MarshalHash() (o []byte, err error) {
}
}
o = append(o, 0x8b)
+ o = hsp.AppendBytes(o, z.EncodedGenesis)
+ o = append(o, 0x8b)
if oTemp, err := z.Owner.MarshalHash(); err != nil {
return nil, err
} else {
@@ -232,13 +224,7 @@ func (z *SQLChainProfile) MarshalHash() (o []byte, err error) {
// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (z *SQLChainProfile) Msgsize() (s int) {
- s = 1 + 8
- if z.Genesis == nil {
- s += hsp.NilSize
- } else {
- s += z.Genesis.Msgsize()
- }
- s += 5 + z.Meta.Msgsize() + 10 + z.TokenType.Msgsize() + 7 + hsp.ArrayHeaderSize
+ s = 1 + 5 + z.Meta.Msgsize() + 10 + z.TokenType.Msgsize() + 7 + hsp.ArrayHeaderSize
for za0001 := range z.Miners {
if z.Miners[za0001] == nil {
s += hsp.NilSize
@@ -254,7 +240,7 @@ func (z *SQLChainProfile) Msgsize() (s int) {
s += z.Users[za0002].Msgsize()
}
}
- s += 6 + z.Owner.Msgsize() + 8 + z.Address.Msgsize() + 3 + z.ID.Msgsize() + 18 + hsp.Uint32Size + 7 + hsp.Uint64Size + 9 + hsp.Uint64Size
+ s += 15 + hsp.BytesPrefixSize + len(z.EncodedGenesis) + 6 + z.Owner.Msgsize() + 8 + z.Address.Msgsize() + 3 + z.ID.Msgsize() + 18 + hsp.Uint32Size + 7 + hsp.Uint64Size + 9 + hsp.Uint64Size
return
}
diff --git a/worker/dbms.go b/worker/dbms.go
index fc7bf74ad..338d0ad57 100644
--- a/worker/dbms.go
+++ b/worker/dbms.go
@@ -289,6 +289,7 @@ func (dbms *DBMS) buildSQLChainServiceInstance(
var (
nodeids = make([]proto.NodeID, len(profile.Miners))
peers *proto.Peers
+ genesis = &types.Block{}
)
for i, v := range profile.Miners {
nodeids[i] = v.NodeID
@@ -308,11 +309,14 @@ func (dbms *DBMS) buildSQLChainServiceInstance(
if err = peers.Sign(dbms.privKey); err != nil {
return
}
+ if err = utils.DecodeMsgPack(profile.EncodedGenesis, genesis); err != nil {
+ return
+ }
instance = &types.ServiceInstance{
DatabaseID: profile.ID,
Peers: peers,
ResourceMeta: profile.Meta,
- GenesisBlock: profile.Genesis,
+ GenesisBlock: genesis,
}
return
}
From 39d1283965c16126103769cc9d1e60deb28d9fe2 Mon Sep 17 00:00:00 2001
From: leventeliu
Date: Tue, 25 Dec 2018 23:15:35 +0800
Subject: [PATCH 163/278] Fix bug: profile changed but not rewrote back
---
blockproducer/metastate.go | 23 ++++++++++++-----------
1 file changed, 12 insertions(+), 11 deletions(-)
diff --git a/blockproducer/metastate.go b/blockproducer/metastate.go
index 2a1684e36..39ff03089 100644
--- a/blockproducer/metastate.go
+++ b/blockproducer/metastate.go
@@ -769,19 +769,19 @@ func (s *metaState) updateKeys(tx *types.IssueKeys) (err error) {
}
func (s *metaState) updateBilling(tx *types.UpdateBilling) (err error) {
- sqlchainObj, loaded := s.loadSQLChainObject(tx.Receiver.DatabaseID())
+ newProfile, loaded := s.loadSQLChainObject(tx.Receiver.DatabaseID())
if !loaded {
err = errors.Wrap(ErrDatabaseNotFound, "update billing failed")
return
}
log.Debugf("update billing addr: %s, tx: %v", tx.GetAccountAddress(), tx)
- if sqlchainObj.GasPrice == 0 {
+ if newProfile.GasPrice == 0 {
return
}
// pending income to income
- for _, miner := range sqlchainObj.Miners {
+ for _, miner := range newProfile.Miners {
miner.ReceivedIncome += miner.PendingIncome
}
@@ -799,18 +799,18 @@ func (s *metaState) updateBilling(tx *types.UpdateBilling) (err error) {
userMap[userCost.User][minerIncome.Miner] += minerIncome.Income
}
}
- for _, user := range sqlchainObj.Users {
- if user.AdvancePayment >= costMap[user.Address]*sqlchainObj.GasPrice {
- user.AdvancePayment -= costMap[user.Address] * sqlchainObj.GasPrice
- for _, miner := range sqlchainObj.Miners {
- miner.PendingIncome += userMap[user.Address][miner.Address] * sqlchainObj.GasPrice
+ for _, user := range newProfile.Users {
+ if user.AdvancePayment >= costMap[user.Address]*newProfile.GasPrice {
+ user.AdvancePayment -= costMap[user.Address] * newProfile.GasPrice
+ for _, miner := range newProfile.Miners {
+ miner.PendingIncome += userMap[user.Address][miner.Address] * newProfile.GasPrice
}
} else {
- rate := 1 - float64(user.AdvancePayment)/float64(costMap[user.Address]*sqlchainObj.GasPrice)
+ rate := 1 - float64(user.AdvancePayment)/float64(costMap[user.Address]*newProfile.GasPrice)
user.AdvancePayment = 0
user.Status = types.Arrears
- for _, miner := range sqlchainObj.Miners {
- income := userMap[user.Address][miner.Address] * sqlchainObj.GasPrice
+ for _, miner := range newProfile.Miners {
+ income := userMap[user.Address][miner.Address] * newProfile.GasPrice
minerIncome := uint64(float64(income) * rate)
miner.PendingIncome += minerIncome
for i := range miner.UserArrears {
@@ -819,6 +819,7 @@ func (s *metaState) updateBilling(tx *types.UpdateBilling) (err error) {
}
}
}
+ s.dirty.databases[tx.Receiver.DatabaseID()] = newProfile
return
}
From 75079b568adf034ecbc4f2c204d74650e4150c5f Mon Sep 17 00:00:00 2001
From: zeqing-guo
Date: Tue, 25 Dec 2018 23:55:12 +0800
Subject: [PATCH 164/278] Add SQLChain Transfer and some test cases
---
blockproducer/errors.go | 2 +
blockproducer/metastate.go | 181 ++++++++++++++++++++++++++++----
blockproducer/metastate_test.go | 165 ++++++++++++++++++++++++++++-
crypto/etls/conn.go | 3 +-
rpc/client.go | 5 +-
types/init_service_type_gen.go | 21 +++-
types/request_type_gen.go | 23 +---
types/transfer.go | 1 +
types/transfer_gen.go | 18 ++--
9 files changed, 361 insertions(+), 58 deletions(-)
diff --git a/blockproducer/errors.go b/blockproducer/errors.go
index dd05596ca..be6398c31 100644
--- a/blockproducer/errors.go
+++ b/blockproducer/errors.go
@@ -96,4 +96,6 @@ var (
ErrLocalNodeNotFound = errors.New("local node id not found in peer list")
// ErrNoAvailableBranch indicates that there is no available branch from the state storage.
ErrNoAvailableBranch = errors.New("no available branch from state storage")
+ // ErrWrongTokenType indicates that token type in transfer is wrong.
+ ErrWrongTokenType = errors.New("wrong token type")
)
diff --git a/blockproducer/metastate.go b/blockproducer/metastate.go
index f5ddc221a..ee0b60754 100644
--- a/blockproducer/metastate.go
+++ b/blockproducer/metastate.go
@@ -33,8 +33,7 @@ import (
)
var (
- sqlchainPeriod uint64 = 60 * 24 * 30
- sqlchainGasPrice uint64 = 10
+ sqlchainPeriod uint64 = 60 * 24 * 30
)
// TODO(leventeliu): lock optimization.
@@ -296,6 +295,86 @@ func (s *metaState) decreaseAccountStableBalance(k proto.AccountAddress, amount
return s.decreaseAccountToken(k, amount, types.Particle)
}
+func (s *metaState) transferAccountToken(transfer *types.Transfer) (err error) {
+ if transfer.Signee == nil {
+ err = ErrInvalidSender
+ log.WithError(err).Warning("invalid signee in applyTransaction")
+ }
+ realSender, err := crypto.PubKeyHash(transfer.Signee)
+ if err != nil {
+ err = errors.Wrap(err, "applyTx failed")
+ return err
+ }
+ if realSender != transfer.Sender {
+ err = errors.Wrapf(ErrInvalidSender,
+ "applyTx failed: real sender %s, sender %s", realSender.String(), transfer.Sender.String())
+ log.WithError(err).Warning("public key not match sender in applyTransaction")
+ }
+
+ var (
+ sender = transfer.Sender
+ receiver = transfer.Receiver
+ amount = transfer.Amount
+ tokenType = transfer.TokenType
+ )
+
+ if sender == receiver || amount == 0 {
+ return
+ }
+
+ // Create empty receiver account if not found
+ s.loadOrStoreAccountObject(receiver, &accountObject{Account: types.Account{Address: receiver}})
+
+ var (
+ so, ro *accountObject
+ sd, rd, ok bool
+ )
+
+ // Load sender and receiver objects
+ if so, sd = s.dirty.accounts[sender]; !sd {
+ if so, ok = s.readonly.accounts[sender]; !ok {
+ err = ErrAccountNotFound
+ return
+ }
+ }
+ if ro, rd = s.dirty.accounts[receiver]; !rd {
+ if ro, ok = s.readonly.accounts[receiver]; !ok {
+ err = ErrAccountNotFound
+ return
+ }
+ }
+
+ // Try transfer
+ var (
+ sb = so.TokenBalance[tokenType]
+ rb = ro.TokenBalance[tokenType]
+ )
+ if err = safeSub(&sb, &amount); err != nil {
+ return
+ }
+ if err = safeAdd(&rb, &amount); err != nil {
+ return
+ }
+
+ // Proceed transfer
+ if !sd {
+ var cpy = &accountObject{}
+ deepcopier.Copy(&so.Account).To(&cpy.Account)
+ so = cpy
+ s.dirty.accounts[sender] = cpy
+ }
+ if !rd {
+ var cpy = &accountObject{}
+ deepcopier.Copy(&ro.Account).To(&cpy.Account)
+ ro = cpy
+ s.dirty.accounts[receiver] = cpy
+ }
+ so.TokenBalance[tokenType] = sb
+ ro.TokenBalance[tokenType] = rb
+ return
+
+}
+
func (s *metaState) transferAccountStableBalance(
sender, receiver proto.AccountAddress, amount uint64) (err error,
) {
@@ -561,8 +640,7 @@ func (s *metaState) matchProvidersWithUser(tx *types.CreateDatabase) (err error)
}
var (
- minAdvancePayment = uint64(tx.GasPrice) * uint64(conf.GConf.QPS) *
- uint64(conf.GConf.UpdatePeriod) * uint64(len(tx.ResourceMeta.TargetMiners))
+ minAdvancePayment = minDeposit(tx.GasPrice, uint64(len(tx.ResourceMeta.TargetMiners)))
)
if tx.AdvancePayment < minAdvancePayment {
err = ErrInsufficientAdvancePayment
@@ -649,7 +727,7 @@ func (s *metaState) matchProvidersWithUser(tx *types.CreateDatabase) (err error)
ID: *dbID,
Address: dbAddr,
Period: sqlchainPeriod,
- GasPrice: sqlchainGasPrice,
+ GasPrice: tx.GasPrice,
TokenType: types.Particle,
Owner: sender,
Users: users,
@@ -783,15 +861,23 @@ func (s *metaState) updateBilling(tx *types.UpdateBilling) (err error) {
return
}
- // pending income to income
+ var (
+ costMap = make(map[proto.AccountAddress]uint64)
+ userMap = make(map[proto.AccountAddress]map[proto.AccountAddress]uint64)
+ minerAddr = tx.GetAccountAddress()
+ isMiner = false
+ )
for _, miner := range sqlchainObj.Miners {
+ isMiner = isMiner || (miner.Address == minerAddr)
miner.ReceivedIncome += miner.PendingIncome
+ miner.PendingIncome = 0
+ }
+ if !isMiner {
+ err = ErrInvalidSender
+ log.WithError(err).Warning("sender does not include in sqlchain (updateBilling)")
+ return
}
- var (
- costMap = make(map[proto.AccountAddress]uint64)
- userMap = make(map[proto.AccountAddress]map[proto.AccountAddress]uint64)
- )
for _, userCost := range tx.Users {
log.Debugf("update billing user cost: %s, cost: %d", userCost.User.String(), userCost.Cost)
costMap[userCost.User] = userCost.Cost
@@ -838,21 +924,69 @@ func (s *metaState) loadROSQLChains(addr proto.AccountAddress) (dbs []*types.SQL
return
}
+func (s *metaState) transferSQLChainTokenBalance(transfer *types.Transfer) (err error) {
+ if transfer.Signee == nil {
+ err = ErrInvalidSender
+ log.WithError(err).Warning("invalid signee in applyTransaction")
+ }
+
+ realSender, err := crypto.PubKeyHash(transfer.Signee)
+ if err != nil {
+ err = errors.Wrap(err, "applyTx failed")
+ return err
+ }
+
+ if realSender != transfer.Sender {
+ err = errors.Wrapf(ErrInvalidSender,
+ "applyTx failed: real sender %s, sender %s", realSender.String(), transfer.Sender.String())
+ log.WithError(err).Warning("public key not match sender in applyTransaction")
+ }
+
+ var (
+ sqlchain *sqlchainObject
+ ok bool
+ )
+ sqlchain, ok = s.loadSQLChainObject(transfer.Sender.DatabaseID())
+ if !ok {
+ return ErrDatabaseNotFound
+ }
+
+ for _, user := range sqlchain.Users {
+ if user.Address == transfer.Sender {
+ if sqlchain.TokenType != transfer.TokenType {
+ return ErrWrongTokenType
+ }
+ minDep := minDeposit(sqlchain.GasPrice, uint64(len(sqlchain.Miners)))
+ if user.Deposit < minDep {
+ diff := minDep - user.Deposit
+ if diff >= transfer.Amount {
+ user.Deposit += transfer.Amount
+ } else {
+ user.Deposit = minDep
+ diff2 := transfer.Amount - diff
+ user.Deposit += diff2
+ }
+ } else {
+ err = safeAdd(&user.AdvancePayment, &transfer.Amount)
+ if err != nil {
+ return err
+ }
+ }
+ s.loadOrStoreSQLChainObject(transfer.Sender.DatabaseID(), sqlchain)
+ return
+ }
+ }
+ return
+}
+
func (s *metaState) applyTransaction(tx pi.Transaction) (err error) {
switch t := tx.(type) {
case *types.Transfer:
- realSender, err := crypto.PubKeyHash(t.Signee)
- if err != nil {
- err = errors.Wrap(err, "applyTx failed")
- return err
- }
- if realSender != t.Sender {
- err = errors.Wrapf(ErrInvalidSender,
- "applyTx failed: real sender %s, sender %s", realSender.String(), t.Sender.String())
- // TODO(lambda): update test cases and return err
- log.Debug(err)
+ err = s.transferSQLChainTokenBalance(t)
+ if err == ErrDatabaseNotFound {
+ err = s.transferAccountToken(t)
}
- err = s.transferAccountStableBalance(t.Sender, t.Receiver, t.Amount)
+ return
case *types.Billing:
err = s.applyBilling(t)
case *types.BaseAccount:
@@ -947,3 +1081,8 @@ func (s *metaState) makeCopy() *metaState {
readonly: s.readonly.deepCopy(),
}
}
+
+func minDeposit(gasPrice uint64, minerNumber uint64) uint64 {
+ return gasPrice * uint64(conf.GConf.QPS) *
+ uint64(conf.GConf.UpdatePeriod) * minerNumber
+}
diff --git a/blockproducer/metastate_test.go b/blockproducer/metastate_test.go
index 4f3f6c662..dc0f5f41e 100644
--- a/blockproducer/metastate_test.go
+++ b/blockproducer/metastate_test.go
@@ -360,18 +360,66 @@ func TestMetaState(t *testing.T) {
Convey(
"The metaState should copy object when stable balance transferred",
func() {
- err = ms.transferAccountStableBalance(addr1, addr3, incSta+1)
+ tran1 := &types.Transfer{
+ TransferHeader: types.TransferHeader{
+ Sender: addr1,
+ Receiver: addr2,
+ Amount: incSta + 1,
+ TokenType: types.Particle,
+ Nonce: 1,
+ },
+ }
+ err = tran1.Sign(privKey1)
+ So(err, ShouldBeNil)
+ err = ms.transferAccountToken(tran1)
So(err, ShouldEqual, ErrInsufficientBalance)
- err = ms.transferAccountStableBalance(addr1, addr3, 1)
+ tran2 := &types.Transfer{
+ TransferHeader: types.TransferHeader{
+ Sender: addr1,
+ Receiver: addr3,
+ Amount: 1,
+ TokenType: types.Particle,
+ Nonce: 1,
+ },
+ }
+ err = tran2.Sign(privKey1)
+ So(err, ShouldBeNil)
+ err = ms.transferAccountToken(tran2)
So(err, ShouldBeNil)
+ ms.commit()
+
err = ms.increaseAccountStableBalance(addr2, math.MaxUint64)
So(err, ShouldBeNil)
ms.commit()
- err = ms.transferAccountStableBalance(addr2, addr1, math.MaxUint64)
+
+ tran3 := &types.Transfer{
+ TransferHeader: types.TransferHeader{
+ Sender: addr2,
+ Receiver: addr1,
+ Amount: math.MaxUint64,
+ TokenType: types.Particle,
+ Nonce: 1,
+ },
+ }
+ err = tran3.Sign(privKey2)
+ So(err, ShouldBeNil)
+ err = ms.transferAccountToken(tran3)
So(err, ShouldEqual, ErrBalanceOverflow)
- err = ms.transferAccountStableBalance(addr2, addr3, 1)
+ tran4 := &types.Transfer{
+ TransferHeader: types.TransferHeader{
+ Sender: addr2,
+ Receiver: addr3,
+ Amount: 1,
+ TokenType: types.Particle,
+ Nonce: 1,
+ },
+ }
+ err = tran4.Sign(privKey2)
So(err, ShouldBeNil)
+ err = ms.transferAccountToken(tran4)
+ So(err, ShouldBeNil)
+ ms.commit()
},
)
Convey(
@@ -850,7 +898,7 @@ func TestMetaState(t *testing.T) {
continue
}
}
- Convey("Update key", func() {
+ Convey("update key", func() {
invalidIk1 := &types.IssueKeys{}
err = invalidIk1.Sign(privKey1)
So(err, ShouldBeNil)
@@ -913,6 +961,113 @@ func TestMetaState(t *testing.T) {
}
}
})
+ Convey("update billing", func() {
+ ub1 := &types.UpdateBilling{
+ UpdateBillingHeader: types.UpdateBillingHeader{
+ Receiver: addr1,
+ Nonce: up.Nonce,
+ },
+ }
+ err = ub1.Sign(privKey1)
+ So(err, ShouldBeNil)
+ err = ms.apply(ub1)
+ So(errors.Cause(err), ShouldEqual, ErrDatabaseNotFound)
+ users := [3]*types.UserCost{
+ &types.UserCost{
+ User: addr1,
+ Cost: 100,
+ Miners: []*types.MinerIncome{
+ &types.MinerIncome{
+ Miner: addr2,
+ Income: 100,
+ },
+ },
+ },
+ &types.UserCost{
+ User: addr3,
+ Cost: 10,
+ Miners: []*types.MinerIncome{
+ &types.MinerIncome{
+ Miner: addr2,
+ Income: 10,
+ },
+ },
+ },
+ &types.UserCost{
+ User: addr4,
+ Cost: 15,
+ Miners: []*types.MinerIncome{
+ &types.MinerIncome{
+ Miner: addr2,
+ Income: 15,
+ },
+ },
+ },
+ }
+ ub2 := &types.UpdateBilling{
+ UpdateBillingHeader: types.UpdateBillingHeader{
+ Receiver: dbAccount,
+ Users: users[:],
+ Nonce: 2,
+ },
+ }
+ err = ub2.Sign(privKey2)
+ So(err, ShouldBeNil)
+ err = ms.apply(ub2)
+ ms.commit()
+ sqlchain, loaded := ms.loadSQLChainObject(*dbID)
+ So(loaded, ShouldBeTrue)
+ So(len(sqlchain.Miners), ShouldEqual, 1)
+ So(sqlchain.Miners[0].PendingIncome, ShouldEqual, 125)
+ users = [3]*types.UserCost{
+ &types.UserCost{
+ User: addr1,
+ Cost: 100,
+ Miners: []*types.MinerIncome{
+ &types.MinerIncome{
+ Miner: addr2,
+ Income: 100,
+ },
+ },
+ },
+ &types.UserCost{
+ User: addr2,
+ Cost: 10,
+ Miners: []*types.MinerIncome{
+ &types.MinerIncome{
+ Miner: addr3,
+ Income: 10,
+ },
+ },
+ },
+ &types.UserCost{
+ User: addr4,
+ Cost: 15,
+ Miners: []*types.MinerIncome{
+ &types.MinerIncome{
+ Miner: addr2,
+ Income: 15,
+ },
+ },
+ },
+ }
+ ub3 := &types.UpdateBilling{
+ UpdateBillingHeader: types.UpdateBillingHeader{
+ Receiver: dbAccount,
+ Users: users[:],
+ Nonce: 3,
+ },
+ }
+ err = ub3.Sign(privKey2)
+ So(err, ShouldBeNil)
+ err = ms.apply(ub3)
+ So(err, ShouldBeNil)
+ sqlchain, loaded = ms.loadSQLChainObject(*dbID)
+ So(loaded, ShouldBeTrue)
+ So(len(sqlchain.Miners), ShouldEqual, 1)
+ So(sqlchain.Miners[0].PendingIncome, ShouldEqual, 115)
+ So(sqlchain.Miners[0].ReceivedIncome, ShouldEqual, 125)
+ })
})
})
})
diff --git a/crypto/etls/conn.go b/crypto/etls/conn.go
index 150d85a3e..2c9db2ecb 100644
--- a/crypto/etls/conn.go
+++ b/crypto/etls/conn.go
@@ -24,10 +24,9 @@ import (
"net"
"time"
- "github.com/pkg/errors"
-
"github.com/CovenantSQL/CovenantSQL/proto"
"github.com/CovenantSQL/CovenantSQL/utils/log"
+ "github.com/pkg/errors"
)
var (
diff --git a/rpc/client.go b/rpc/client.go
index 4afb91055..b3bc19165 100644
--- a/rpc/client.go
+++ b/rpc/client.go
@@ -21,9 +21,6 @@ import (
"net"
"net/rpc"
- "github.com/pkg/errors"
- mux "github.com/xtaci/smux"
-
"github.com/CovenantSQL/CovenantSQL/crypto/etls"
"github.com/CovenantSQL/CovenantSQL/crypto/hash"
"github.com/CovenantSQL/CovenantSQL/crypto/kms"
@@ -31,6 +28,8 @@ import (
"github.com/CovenantSQL/CovenantSQL/proto"
"github.com/CovenantSQL/CovenantSQL/utils"
"github.com/CovenantSQL/CovenantSQL/utils/log"
+ "github.com/pkg/errors"
+ mux "github.com/xtaci/smux"
)
const (
diff --git a/types/init_service_type_gen.go b/types/init_service_type_gen.go
index 27008aa2e..7ff4eb63a 100644
--- a/types/init_service_type_gen.go
+++ b/types/init_service_type_gen.go
@@ -31,8 +31,19 @@ func (z *InitServiceResponse) MarshalHash() (o []byte, err error) {
var b []byte
o = hsp.Require(b, z.Msgsize())
// map header, size 1
- o = append(o, 0x81, 0x81)
- if oTemp, err := z.Header.MarshalHash(); err != nil {
+ // map header, size 2
+ // map header, size 1
+ o = append(o, 0x81, 0x81, 0x82, 0x82, 0x81, 0x81)
+ o = hsp.AppendArrayHeader(o, uint32(len(z.Header.InitServiceResponseHeader.Instances)))
+ for za0001 := range z.Header.InitServiceResponseHeader.Instances {
+ if oTemp, err := z.Header.InitServiceResponseHeader.Instances[za0001].MarshalHash(); err != nil {
+ return nil, err
+ } else {
+ o = hsp.AppendBytes(o, oTemp)
+ }
+ }
+ o = append(o, 0x82)
+ if oTemp, err := z.Header.DefaultHashSignVerifierImpl.MarshalHash(); err != nil {
return nil, err
} else {
o = hsp.AppendBytes(o, oTemp)
@@ -42,7 +53,11 @@ func (z *InitServiceResponse) MarshalHash() (o []byte, err error) {
// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (z *InitServiceResponse) Msgsize() (s int) {
- s = 1 + 7 + z.Header.Msgsize()
+ s = 1 + 7 + 1 + 26 + 1 + 10 + hsp.ArrayHeaderSize
+ for za0001 := range z.Header.InitServiceResponseHeader.Instances {
+ s += z.Header.InitServiceResponseHeader.Instances[za0001].Msgsize()
+ }
+ s += 28 + z.Header.DefaultHashSignVerifierImpl.Msgsize()
return
}
diff --git a/types/request_type_gen.go b/types/request_type_gen.go
index 7033d7aa6..709e66bb9 100644
--- a/types/request_type_gen.go
+++ b/types/request_type_gen.go
@@ -106,20 +106,10 @@ func (z *Request) MarshalHash() (o []byte, err error) {
o = append(o, 0x83, 0x83, 0x81, 0x81)
o = hsp.AppendArrayHeader(o, uint32(len(z.Payload.Queries)))
for za0001 := range z.Payload.Queries {
- // map header, size 2
- o = append(o, 0x82, 0x82)
- o = hsp.AppendString(o, z.Payload.Queries[za0001].Pattern)
- o = append(o, 0x82)
- o = hsp.AppendArrayHeader(o, uint32(len(z.Payload.Queries[za0001].Args)))
- for za0002 := range z.Payload.Queries[za0001].Args {
- // map header, size 2
- o = append(o, 0x82, 0x82)
- o = hsp.AppendString(o, z.Payload.Queries[za0001].Args[za0002].Name)
- o = append(o, 0x82)
- o, err = hsp.AppendIntf(o, z.Payload.Queries[za0001].Args[za0002].Value)
- if err != nil {
- return
- }
+ if oTemp, err := z.Payload.Queries[za0001].MarshalHash(); err != nil {
+ return nil, err
+ } else {
+ o = hsp.AppendBytes(o, oTemp)
}
}
// map header, size 2
@@ -148,10 +138,7 @@ func (z *Request) MarshalHash() (o []byte, err error) {
func (z *Request) Msgsize() (s int) {
s = 1 + 8 + 1 + 8 + hsp.ArrayHeaderSize
for za0001 := range z.Payload.Queries {
- s += 1 + 8 + hsp.StringPrefixSize + len(z.Payload.Queries[za0001].Pattern) + 5 + hsp.ArrayHeaderSize
- for za0002 := range z.Payload.Queries[za0001].Args {
- s += 1 + 5 + hsp.StringPrefixSize + len(z.Payload.Queries[za0001].Args[za0002].Name) + 6 + hsp.GuessSize(z.Payload.Queries[za0001].Args[za0002].Value)
- }
+ s += z.Payload.Queries[za0001].Msgsize()
}
s += 7 + 1 + 14 + z.Header.RequestHeader.Msgsize() + 28 + z.Header.DefaultHashSignVerifierImpl.Msgsize() + 9 + z.Envelope.Msgsize()
return
diff --git a/types/transfer.go b/types/transfer.go
index 38d6f7134..e047f6051 100644
--- a/types/transfer.go
+++ b/types/transfer.go
@@ -30,6 +30,7 @@ type TransferHeader struct {
Sender, Receiver proto.AccountAddress
Nonce pi.AccountNonce
Amount uint64
+ TokenType TokenType
}
// Transfer defines the transfer transaction.
diff --git a/types/transfer_gen.go b/types/transfer_gen.go
index c2f7f8736..8c918b251 100644
--- a/types/transfer_gen.go
+++ b/types/transfer_gen.go
@@ -42,32 +42,38 @@ func (z *Transfer) Msgsize() (s int) {
func (z *TransferHeader) MarshalHash() (o []byte, err error) {
var b []byte
o = hsp.Require(b, z.Msgsize())
- // map header, size 4
- o = append(o, 0x84, 0x84)
+ // map header, size 5
+ o = append(o, 0x85, 0x85)
+ if oTemp, err := z.TokenType.MarshalHash(); err != nil {
+ return nil, err
+ } else {
+ o = hsp.AppendBytes(o, oTemp)
+ }
+ o = append(o, 0x85)
if oTemp, err := z.Nonce.MarshalHash(); err != nil {
return nil, err
} else {
o = hsp.AppendBytes(o, oTemp)
}
- o = append(o, 0x84)
+ o = append(o, 0x85)
if oTemp, err := z.Sender.MarshalHash(); err != nil {
return nil, err
} else {
o = hsp.AppendBytes(o, oTemp)
}
- o = append(o, 0x84)
+ o = append(o, 0x85)
if oTemp, err := z.Receiver.MarshalHash(); err != nil {
return nil, err
} else {
o = hsp.AppendBytes(o, oTemp)
}
- o = append(o, 0x84)
+ o = append(o, 0x85)
o = hsp.AppendUint64(o, z.Amount)
return
}
// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (z *TransferHeader) Msgsize() (s int) {
- s = 1 + 6 + z.Nonce.Msgsize() + 7 + z.Sender.Msgsize() + 9 + z.Receiver.Msgsize() + 7 + hsp.Uint64Size
+ s = 1 + 10 + z.TokenType.Msgsize() + 6 + z.Nonce.Msgsize() + 7 + z.Sender.Msgsize() + 9 + z.Receiver.Msgsize() + 7 + hsp.Uint64Size
return
}
From af490e80c8990ead2689d1536a1d1c5e0a065dc3 Mon Sep 17 00:00:00 2001
From: Qi Xiao
Date: Tue, 4 Dec 2018 22:38:21 +0800
Subject: [PATCH 165/278] Add slow query log with a fixed 5 seconds slow query
config
---
worker/db.go | 61 +++++++++++++++++++++++++++++++++++++++++++--
worker/db_config.go | 1 +
worker/dbms.go | 5 ++++
3 files changed, 65 insertions(+), 2 deletions(-)
diff --git a/worker/db.go b/worker/db.go
index 50293b7de..fec609167 100644
--- a/worker/db.go
+++ b/worker/db.go
@@ -20,9 +20,8 @@ import (
"context"
"os"
"path/filepath"
-
- //"runtime/trace"
"sync"
+ "sync/atomic"
"time"
"github.com/CovenantSQL/CovenantSQL/crypto/kms"
@@ -33,6 +32,7 @@ import (
"github.com/CovenantSQL/CovenantSQL/sqlchain"
"github.com/CovenantSQL/CovenantSQL/storage"
"github.com/CovenantSQL/CovenantSQL/types"
+ "github.com/CovenantSQL/CovenantSQL/utils/log"
"github.com/pkg/errors"
)
@@ -54,6 +54,9 @@ const (
// CommitThreshold defines the commit complete threshold.
CommitThreshold = 1.0
+
+ // SlowQuerySampleSize defines the maximum slow query log size (default: 1KB).
+ SlowQuerySampleSize = 1 << 10
)
// Database defines a single database instance in worker runtime.
@@ -200,6 +203,25 @@ func (db *Database) Query(request *types.Request) (response *types.Response, err
// return
//}
+ var (
+ isSlowQuery uint32
+ tmStart = time.Now()
+ )
+
+ // log the query if the underlying storage layer take too long to response
+ slowQueryTimer := time.AfterFunc(db.cfg.SlowQueryTime, func() {
+ // mark as slow query
+ atomic.StoreUint32(&isSlowQuery, 1)
+ db.logSlow(request, false, tmStart)
+ })
+ defer slowQueryTimer.Stop()
+ defer func() {
+ if atomic.LoadUint32(&isSlowQuery) == 1 {
+ // slow query
+ db.logSlow(request, true, tmStart)
+ }
+ }()
+
switch request.Header.QueryType {
case types.ReadQuery:
return db.chain.Query(request)
@@ -216,6 +238,41 @@ func (db *Database) Query(request *types.Request) (response *types.Response, err
}
}
+func (db *Database) logSlow(request *types.Request, isFinished bool, tmStart time.Time) {
+ if request == nil {
+ return
+ }
+
+ // sample the queries
+ querySample := ""
+
+ for _, q := range request.Payload.Queries {
+ if len(querySample) < SlowQuerySampleSize {
+ querySample += "; "
+ querySample += q.Pattern
+ } else {
+ break
+ }
+ }
+
+ if len(querySample) >= SlowQuerySampleSize {
+ querySample = querySample[:SlowQuerySampleSize-3]
+ querySample += "..."
+ }
+
+ log.WithFields(log.Fields{
+ "finished": isFinished,
+ "db": request.Header.DatabaseID,
+ "req_time": request.Header.Timestamp.String(),
+ "req_node": request.Header.NodeID,
+ "count": request.Header.BatchCount,
+ "type": request.Header.QueryType.String(),
+ "sample": querySample,
+ "start": tmStart.String(),
+ "elapsed": time.Now().Sub(tmStart).String(),
+ }).Error("slow query detected")
+}
+
// Ack defines client response ack interface.
func (db *Database) Ack(ack *types.Ack) (err error) {
// Just need to verify signature in db.saveAck
diff --git a/worker/db_config.go b/worker/db_config.go
index 828bfb1de..ba0330de5 100644
--- a/worker/db_config.go
+++ b/worker/db_config.go
@@ -34,4 +34,5 @@ type DBConfig struct {
SpaceLimit uint64
UseEventualConsistency bool
ConsistencyLevel float64
+ SlowQueryTime time.Duration
}
diff --git a/worker/dbms.go b/worker/dbms.go
index c2df28a04..3717443d5 100644
--- a/worker/dbms.go
+++ b/worker/dbms.go
@@ -22,6 +22,7 @@ import (
"os"
"path/filepath"
"sync"
+ "time"
"github.com/CovenantSQL/CovenantSQL/crypto"
"github.com/CovenantSQL/CovenantSQL/proto"
@@ -40,6 +41,9 @@ const (
// DBMetaFileName defines dbms meta file name.
DBMetaFileName = "db.meta"
+
+ // DefaultSlowQueryTime defines the default slow query log time
+ DefaultSlowQueryTime = time.Second * 5
)
// DBMS defines a database management instance.
@@ -218,6 +222,7 @@ func (dbms *DBMS) Create(instance *types.ServiceInstance, cleanup bool) (err err
SpaceLimit: instance.ResourceMeta.Space,
UseEventualConsistency: instance.ResourceMeta.UseEventualConsistency,
ConsistencyLevel: instance.ResourceMeta.ConsistencyLevel,
+ SlowQueryTime: DefaultSlowQueryTime,
}
if db, err = NewDatabase(dbCfg, instance.Peers, instance.GenesisBlock); err != nil {
From 5b174f74a8364abc7f71bdca1eaa51a8aeb91924 Mon Sep 17 00:00:00 2001
From: Qi Xiao
Date: Tue, 4 Dec 2018 22:45:59 +0800
Subject: [PATCH 166/278] Update sqlparser dependency
---
Gopkg.lock | 4 +-
.../CovenantSQL/sqlparser/analyzer.go | 4 +-
.../github.com/CovenantSQL/sqlparser/ast.go | 187 +-
.../github.com/CovenantSQL/sqlparser/sql.go | 2793 ++++++++---------
vendor/github.com/CovenantSQL/sqlparser/sql.y | 44 +-
.../github.com/CovenantSQL/sqlparser/token.go | 34 +-
6 files changed, 1518 insertions(+), 1548 deletions(-)
diff --git a/Gopkg.lock b/Gopkg.lock
index f938ce406..bd69af2cc 100644
--- a/Gopkg.lock
+++ b/Gopkg.lock
@@ -32,7 +32,7 @@
[[projects]]
branch = "master"
- digest = "1:9552f97d556ffa281b8d5c23280aad519e9792a02222cded90467882ff675063"
+ digest = "1:72eed3fbb752e4ff388da196ff30a50a0e15524b3a2b12c6ab6430b89eb67f1e"
name = "github.com/CovenantSQL/sqlparser"
packages = [
".",
@@ -42,7 +42,7 @@
"dependency/sqltypes",
]
pruneopts = "UT"
- revision = "21a792a5b3b3ecddc9a836fb3da0468f0bd0434f"
+ revision = "78095ffffebc9ad7ece9e07a0acfa5afdd3a0505"
[[projects]]
branch = "master"
diff --git a/vendor/github.com/CovenantSQL/sqlparser/analyzer.go b/vendor/github.com/CovenantSQL/sqlparser/analyzer.go
index eff1c8f89..3a8471556 100644
--- a/vendor/github.com/CovenantSQL/sqlparser/analyzer.go
+++ b/vendor/github.com/CovenantSQL/sqlparser/analyzer.go
@@ -173,7 +173,7 @@ func IsValue(node Expr) bool {
switch v := node.(type) {
case *SQLVal:
switch v.Type {
- case StrVal, HexVal, IntVal, ValArg:
+ case StrVal, HexVal, IntVal, ValArg, PosArg:
return true
}
}
@@ -212,7 +212,7 @@ func NewPlanValue(node Expr) (sqltypes.PlanValue, error) {
switch node := node.(type) {
case *SQLVal:
switch node.Type {
- case ValArg:
+ case ValArg, PosArg:
return sqltypes.PlanValue{Key: string(node.Val[1:])}, nil
case IntVal:
n, err := sqltypes.NewIntegral(string(node.Val))
diff --git a/vendor/github.com/CovenantSQL/sqlparser/ast.go b/vendor/github.com/CovenantSQL/sqlparser/ast.go
index c850c5006..014d914af 100644
--- a/vendor/github.com/CovenantSQL/sqlparser/ast.go
+++ b/vendor/github.com/CovenantSQL/sqlparser/ast.go
@@ -94,6 +94,36 @@ func ParseNext(tokenizer *Tokenizer) (Statement, error) {
return tokenizer.ParseTree, nil
}
+// ParseMultiple returns multiple parsed original query and parsed statement.
+func ParseMultiple(tokenizer *Tokenizer) (queries []string, statements []Statement, err error) {
+ var lastPos int
+
+ for {
+ if tokenizer.lastChar == ';' {
+ tokenizer.next()
+ tokenizer.skipBlank()
+ lastPos = tokenizer.Position - 1
+ }
+ if tokenizer.lastChar == eofChar {
+ break
+ }
+
+ tokenizer.reset()
+ tokenizer.multi = true
+ if yyParse(tokenizer) != 0 && tokenizer.partialDDL == nil {
+ err = tokenizer.LastError
+ return
+ }
+ if tokenizer.partialDDL != nil {
+ statements = append(statements, tokenizer.partialDDL)
+ } else {
+ statements = append(statements, tokenizer.ParseTree)
+ }
+ queries = append(queries, string(tokenizer.buf[lastPos:tokenizer.Position-1]))
+ }
+ return
+}
+
// SplitStatement returns the first sql statement up to either a ; or EOF
// and the remainder from the given buffer
func SplitStatement(blob string) (string, string, error) {
@@ -207,16 +237,17 @@ type Statement interface {
SQLNode
}
-func (*Union) iStatement() {}
-func (*Select) iStatement() {}
-func (*Stream) iStatement() {}
-func (*Insert) iStatement() {}
-func (*Update) iStatement() {}
-func (*Delete) iStatement() {}
-func (*Set) iStatement() {}
-func (*DBDDL) iStatement() {}
-func (*DDL) iStatement() {}
-func (*Show) iStatement() {}
+func (*Union) iStatement() {}
+func (*Select) iStatement() {}
+func (*Stream) iStatement() {}
+func (*Insert) iStatement() {}
+func (*Update) iStatement() {}
+func (*Delete) iStatement() {}
+func (*Set) iStatement() {}
+func (*DBDDL) iStatement() {}
+func (*DDL) iStatement() {}
+func (*Show) iStatement() {}
+func (*Explain) iStatement() {}
// ParenSelect can actually not be a top level statement,
// but we have to allow it because it's a requirement
@@ -1273,6 +1304,19 @@ func (node *Show) walkSubtree(visit Visit) error {
return nil
}
+// Explain represents a explain statement.
+type Explain struct {
+}
+
+// Format formats the node.
+func (node *Explain) Format(buf *TrackedBuffer) {
+ buf.WriteString("explain")
+}
+
+func (node *Explain) walkSubtree(visit Visit) error {
+ return nil
+}
+
// Comments represents a list of comments.
type Comments [][]byte
@@ -1753,35 +1797,33 @@ type Expr interface {
SQLNode
}
-func (*AndExpr) iExpr() {}
-func (*OrExpr) iExpr() {}
-func (*NotExpr) iExpr() {}
-func (*ParenExpr) iExpr() {}
-func (*ComparisonExpr) iExpr() {}
-func (*RangeCond) iExpr() {}
-func (*IsExpr) iExpr() {}
-func (*ExistsExpr) iExpr() {}
-func (*SQLVal) iExpr() {}
-func (*NullVal) iExpr() {}
-func (BoolVal) iExpr() {}
-func (*ColName) iExpr() {}
-func (ValTuple) iExpr() {}
-func (*Subquery) iExpr() {}
-func (ListArg) iExpr() {}
-func (*BinaryExpr) iExpr() {}
-func (*UnaryExpr) iExpr() {}
-func (*IntervalExpr) iExpr() {}
-func (*CollateExpr) iExpr() {}
-func (*FuncExpr) iExpr() {}
-func (*CaseExpr) iExpr() {}
-func (*ValuesFuncExpr) iExpr() {}
-func (*ConvertExpr) iExpr() {}
-func (*SubstrExpr) iExpr() {}
-func (*ConvertUsingExpr) iExpr() {}
-func (*MatchExpr) iExpr() {}
-func (*GroupConcatExpr) iExpr() {}
-func (*Default) iExpr() {}
-func (*TimeExpr) iExpr() {}
+func (*AndExpr) iExpr() {}
+func (*OrExpr) iExpr() {}
+func (*NotExpr) iExpr() {}
+func (*ParenExpr) iExpr() {}
+func (*ComparisonExpr) iExpr() {}
+func (*RangeCond) iExpr() {}
+func (*IsExpr) iExpr() {}
+func (*ExistsExpr) iExpr() {}
+func (*SQLVal) iExpr() {}
+func (*NullVal) iExpr() {}
+func (BoolVal) iExpr() {}
+func (*ColName) iExpr() {}
+func (ValTuple) iExpr() {}
+func (*Subquery) iExpr() {}
+func (ListArg) iExpr() {}
+func (*BinaryExpr) iExpr() {}
+func (*UnaryExpr) iExpr() {}
+func (*IntervalExpr) iExpr() {}
+func (*CollateExpr) iExpr() {}
+func (*FuncExpr) iExpr() {}
+func (*CaseExpr) iExpr() {}
+func (*ValuesFuncExpr) iExpr() {}
+func (*ConvertExpr) iExpr() {}
+func (*MatchExpr) iExpr() {}
+func (*GroupConcatExpr) iExpr() {}
+func (*Default) iExpr() {}
+func (*TimeExpr) iExpr() {}
// ReplaceExpr finds the from expression from root
// and replaces it with to. If from matches root,
@@ -2108,6 +2150,7 @@ const (
HexVal
ValArg
BitVal
+ PosArg
)
// SQLVal represents a single value.
@@ -2151,6 +2194,11 @@ func NewValArg(in []byte) *SQLVal {
return &SQLVal{Type: ValArg, Val: in}
}
+// NewPosArg build a new PosArg.
+func NewPosArg(in []byte) *SQLVal {
+ return &SQLVal{Type: PosArg, Val: in}
+}
+
// Format formats the node.
func (node *SQLVal) Format(buf *TrackedBuffer) {
switch node.Type {
@@ -2164,6 +2212,8 @@ func (node *SQLVal) Format(buf *TrackedBuffer) {
buf.Myprintf("B'%s'", []byte(node.Val))
case ValArg:
buf.WriteArg(string(node.Val))
+ case PosArg:
+ buf.WriteArg("?")
default:
panic("unexpected")
}
@@ -2625,40 +2675,6 @@ func (node *ValuesFuncExpr) replace(from, to Expr) bool {
return false
}
-// SubstrExpr represents a call to SubstrExpr(column, value_expression) or SubstrExpr(column, value_expression,value_expression)
-// also supported syntax SubstrExpr(column from value_expression for value_expression)
-type SubstrExpr struct {
- Name *ColName
- From Expr
- To Expr
-}
-
-// Format formats the node.
-func (node *SubstrExpr) Format(buf *TrackedBuffer) {
-
- if node.To == nil {
- buf.Myprintf("substr(%v, %v)", node.Name, node.From)
- } else {
- buf.Myprintf("substr(%v, %v, %v)", node.Name, node.From, node.To)
- }
-}
-
-func (node *SubstrExpr) replace(from, to Expr) bool {
- return replaceExprs(from, to, &node.From, &node.To)
-}
-
-func (node *SubstrExpr) walkSubtree(visit Visit) error {
- if node == nil {
- return nil
- }
- return Walk(
- visit,
- node.Name,
- node.From,
- node.To,
- )
-}
-
// ConvertExpr represents a call to CONVERT(expr, type)
// or it's equivalent CAST(expr AS type). Both are rewritten to the former.
type ConvertExpr struct {
@@ -2686,31 +2702,6 @@ func (node *ConvertExpr) replace(from, to Expr) bool {
return replaceExprs(from, to, &node.Expr)
}
-// ConvertUsingExpr represents a call to CONVERT(expr USING charset).
-type ConvertUsingExpr struct {
- Expr Expr
- Type string
-}
-
-// Format formats the node.
-func (node *ConvertUsingExpr) Format(buf *TrackedBuffer) {
- buf.Myprintf("convert(%v using %s)", node.Expr, node.Type)
-}
-
-func (node *ConvertUsingExpr) walkSubtree(visit Visit) error {
- if node == nil {
- return nil
- }
- return Walk(
- visit,
- node.Expr,
- )
-}
-
-func (node *ConvertUsingExpr) replace(from, to Expr) bool {
- return replaceExprs(from, to, &node.Expr)
-}
-
// ConvertType represents the type in call to CONVERT(expr, type)
type ConvertType struct {
Type string
diff --git a/vendor/github.com/CovenantSQL/sqlparser/sql.go b/vendor/github.com/CovenantSQL/sqlparser/sql.go
index 54f4cdef6..de19d4c40 100644
--- a/vendor/github.com/CovenantSQL/sqlparser/sql.go
+++ b/vendor/github.com/CovenantSQL/sqlparser/sql.go
@@ -130,97 +130,98 @@ const INTEGRAL = 57384
const FLOAT = 57385
const HEXNUM = 57386
const VALUE_ARG = 57387
-const LIST_ARG = 57388
-const COMMENT = 57389
-const NULL = 57390
-const TRUE = 57391
-const FALSE = 57392
-const FULL = 57393
-const COLUMNS = 57394
-const OR = 57395
-const AND = 57396
-const NOT = 57397
-const BETWEEN = 57398
-const CASE = 57399
-const WHEN = 57400
-const THEN = 57401
-const ELSE = 57402
-const END = 57403
-const LE = 57404
-const GE = 57405
-const NE = 57406
-const IS = 57407
-const LIKE = 57408
-const REGEXP = 57409
-const IN = 57410
-const NULL_SAFE_NOTEQUAL = 57411
-const SHIFT_LEFT = 57412
-const SHIFT_RIGHT = 57413
-const DIV = 57414
-const MOD = 57415
-const UNARY = 57416
-const INTERVAL = 57417
-const CREATE = 57418
-const ALTER = 57419
-const DROP = 57420
-const RENAME = 57421
-const ADD = 57422
-const TABLE = 57423
-const INDEX = 57424
-const TO = 57425
-const IGNORE = 57426
-const IF = 57427
-const UNIQUE = 57428
-const PRIMARY = 57429
-const COLUMN = 57430
-const CONSTRAINT = 57431
-const FOREIGN = 57432
-const SHOW = 57433
-const DESCRIBE = 57434
-const DATE = 57435
-const ESCAPE = 57436
-const TINYINT = 57437
-const SMALLINT = 57438
-const MEDIUMINT = 57439
-const INT = 57440
-const INTEGER = 57441
-const BIGINT = 57442
-const INTNUM = 57443
-const REAL = 57444
-const DOUBLE = 57445
-const FLOAT_TYPE = 57446
-const DECIMAL = 57447
-const NUMERIC = 57448
-const TIME = 57449
-const TIMESTAMP = 57450
-const DATETIME = 57451
-const YEAR = 57452
-const CHAR = 57453
-const VARCHAR = 57454
-const BOOL = 57455
-const NCHAR = 57456
-const TEXT = 57457
-const TINYTEXT = 57458
-const MEDIUMTEXT = 57459
-const LONGTEXT = 57460
-const BLOB = 57461
-const TINYBLOB = 57462
-const MEDIUMBLOB = 57463
-const LONGBLOB = 57464
-const AUTO_INCREMENT = 57465
-const SIGNED = 57466
-const UNSIGNED = 57467
-const ZEROFILL = 57468
-const TABLES = 57469
-const CURRENT_TIMESTAMP = 57470
-const CURRENT_DATE = 57471
-const CURRENT_TIME = 57472
-const REPLACE = 57473
-const CAST = 57474
-const SUBSTR = 57475
-const GROUP_CONCAT = 57476
-const SEPARATOR = 57477
-const UNUSED = 57478
+const POS_ARG = 57388
+const LIST_ARG = 57389
+const COMMENT = 57390
+const NULL = 57391
+const TRUE = 57392
+const FALSE = 57393
+const FULL = 57394
+const COLUMNS = 57395
+const OR = 57396
+const AND = 57397
+const NOT = 57398
+const BETWEEN = 57399
+const CASE = 57400
+const WHEN = 57401
+const THEN = 57402
+const ELSE = 57403
+const END = 57404
+const LE = 57405
+const GE = 57406
+const NE = 57407
+const IS = 57408
+const LIKE = 57409
+const REGEXP = 57410
+const IN = 57411
+const NULL_SAFE_NOTEQUAL = 57412
+const SHIFT_LEFT = 57413
+const SHIFT_RIGHT = 57414
+const DIV = 57415
+const MOD = 57416
+const UNARY = 57417
+const INTERVAL = 57418
+const CREATE = 57419
+const ALTER = 57420
+const DROP = 57421
+const RENAME = 57422
+const ADD = 57423
+const TABLE = 57424
+const INDEX = 57425
+const TO = 57426
+const IGNORE = 57427
+const IF = 57428
+const UNIQUE = 57429
+const PRIMARY = 57430
+const COLUMN = 57431
+const CONSTRAINT = 57432
+const FOREIGN = 57433
+const SHOW = 57434
+const DESCRIBE = 57435
+const DATE = 57436
+const ESCAPE = 57437
+const EXPLAIN = 57438
+const TINYINT = 57439
+const SMALLINT = 57440
+const MEDIUMINT = 57441
+const INT = 57442
+const INTEGER = 57443
+const BIGINT = 57444
+const INTNUM = 57445
+const REAL = 57446
+const DOUBLE = 57447
+const FLOAT_TYPE = 57448
+const DECIMAL = 57449
+const NUMERIC = 57450
+const TIME = 57451
+const TIMESTAMP = 57452
+const DATETIME = 57453
+const YEAR = 57454
+const CHAR = 57455
+const VARCHAR = 57456
+const BOOL = 57457
+const NCHAR = 57458
+const TEXT = 57459
+const TINYTEXT = 57460
+const MEDIUMTEXT = 57461
+const LONGTEXT = 57462
+const BLOB = 57463
+const TINYBLOB = 57464
+const MEDIUMBLOB = 57465
+const LONGBLOB = 57466
+const AUTO_INCREMENT = 57467
+const SIGNED = 57468
+const UNSIGNED = 57469
+const ZEROFILL = 57470
+const TABLES = 57471
+const CURRENT_TIMESTAMP = 57472
+const CURRENT_DATE = 57473
+const CURRENT_TIME = 57474
+const REPLACE = 57475
+const CAST = 57476
+const GROUP_CONCAT = 57477
+const SEPARATOR = 57478
+const UNUSED = 57479
var yyToknames = [...]string{
"$end",
@@ -271,6 +272,7 @@ var yyToknames = [...]string{
"FLOAT",
"HEXNUM",
"VALUE_ARG",
+ "POS_ARG",
"LIST_ARG",
"COMMENT",
"NULL",
@@ -334,6 +336,7 @@ var yyToknames = [...]string{
"DESCRIBE",
"DATE",
"ESCAPE",
+ "EXPLAIN",
"TINYINT",
"SMALLINT",
"MEDIUMINT",
@@ -372,7 +375,6 @@ var yyToknames = [...]string{
"CURRENT_TIME",
"REPLACE",
"CAST",
- "SUBSTR",
"GROUP_CONCAT",
"SEPARATOR",
"UNUSED",
@@ -392,610 +394,608 @@ var yyExca = [...]int{
-1, 3,
5, 17,
-2, 4,
- -1, 114,
- 1, 156,
- 5, 156,
- 11, 156,
- 12, 156,
- 13, 156,
- 14, 156,
- 16, 156,
- 27, 156,
- 30, 156,
- 31, 156,
- 33, 156,
- 35, 156,
- 36, 156,
- 37, 156,
- 38, 156,
- 40, 156,
- 41, 156,
- 154, 156,
- -2, 169,
- -1, 183,
- 92, 356,
- -2, 352,
+ -1, 116,
+ 1, 157,
+ 5, 157,
+ 11, 157,
+ 12, 157,
+ 13, 157,
+ 14, 157,
+ 16, 157,
+ 27, 157,
+ 30, 157,
+ 31, 157,
+ 33, 157,
+ 35, 157,
+ 36, 157,
+ 37, 157,
+ 38, 157,
+ 40, 157,
+ 41, 157,
+ 155, 157,
+ -2, 170,
-1, 184,
- 92, 357,
- -2, 353,
- -1, 402,
+ 93, 353,
+ -2, 349,
+ -1, 185,
+ 93, 354,
+ -2, 350,
+ -1, 400,
5, 17,
- -2, 325,
- -1, 519,
- 92, 359,
- -2, 355,
- -1, 551,
+ -2, 322,
+ -1, 516,
+ 93, 356,
+ -2, 352,
+ -1, 547,
5, 18,
- -2, 228,
- -1, 609,
+ -2, 226,
+ -1, 603,
5, 18,
- -2, 326,
- -1, 672,
+ -2, 323,
+ -1, 665,
5, 17,
- -2, 328,
- -1, 732,
+ -2, 325,
+ -1, 722,
5, 18,
- -2, 329,
+ -2, 326,
}
const yyPrivate = 57344
-const yyLast = 4079
+const yyLast = 4076
var yyAct = [...]int{
- 184, 381, 623, 136, 534, 429, 459, 514, 337, 535,
- 142, 99, 31, 587, 428, 434, 207, 3, 406, 46,
- 168, 526, 518, 94, 94, 489, 474, 147, 170, 440,
- 405, 206, 119, 464, 546, 430, 335, 455, 94, 44,
- 425, 210, 97, 186, 197, 134, 30, 111, 715, 138,
- 132, 516, 566, 116, 110, 447, 627, 628, 629, 630,
- 705, 122, 703, 466, 631, 684, 465, 123, 465, 109,
- 126, 107, 638, 442, 84, 85, 91, 95, 121, 258,
- 253, 252, 719, 128, 94, 83, 641, 353, 90, 94,
- 560, 352, 351, 361, 362, 354, 355, 356, 357, 358,
- 359, 360, 353, 612, 594, 125, 667, 94, 544, 139,
- 187, 478, 380, 133, 341, 188, 94, 94, 94, 171,
- 25, 189, 543, 94, 527, 588, 94, 86, 94, 94,
- 340, 339, 88, 87, 94, 251, 339, 124, 527, 131,
- 601, 444, 130, 685, 683, 25, 341, 441, 445, 262,
- 344, 341, 448, 104, 496, 442, 260, 115, 632, 98,
- 192, 374, 375, 376, 377, 378, 564, 494, 495, 493,
- 193, 214, 120, 580, 581, 582, 250, 687, 686, 254,
- 382, 256, 257, 249, 388, 569, 334, 24, 26, 15,
- 16, 127, 94, 398, 568, 596, 94, 94, 94, 94,
- 397, 340, 339, 28, 22, 94, 567, 402, 669, 94,
- 421, 422, 94, 492, 731, 408, 46, 341, 720, 721,
- 28, 625, 407, 137, 25, 423, 726, 395, 396, 441,
- 120, 340, 339, 439, 438, 208, 433, 356, 357, 358,
- 359, 360, 353, 561, 411, 404, 413, 341, 419, 435,
- 410, 512, 412, 424, 462, 461, 680, 679, 725, 94,
- 94, 340, 339, 371, 373, 354, 355, 356, 357, 358,
- 359, 360, 353, 633, 18, 19, 20, 341, 471, 137,
- 343, 636, 635, 457, 458, 611, 137, 467, 379, 21,
- 23, 383, 384, 385, 386, 520, 389, 482, 484, 485,
- 390, 391, 392, 342, 483, 520, 137, 195, 137, 607,
- 403, 195, 468, 469, 32, 115, 115, 115, 115, 340,
- 339, 216, 215, 472, 24, 426, 634, 542, 208, 27,
- 597, 471, 554, 393, 194, 341, 199, 202, 46, 200,
- 471, 201, 203, 547, 548, 400, 401, 195, 479, 480,
- 24, 486, 487, 471, 542, 28, 488, 28, 476, 497,
- 498, 499, 500, 501, 502, 503, 504, 505, 506, 507,
- 508, 509, 510, 511, 449, 490, 450, 451, 460, 46,
- 618, 24, 557, 28, 664, 521, 456, 452, 453, 454,
- 547, 548, 382, 522, 40, 570, 519, 418, 202, 513,
- 423, 433, 187, 671, 46, 12, 408, 416, 550, 415,
- 408, 417, 414, 523, 28, 563, 517, 528, 724, 723,
- 538, 408, 558, 463, 540, 255, 205, 551, 407, 46,
- 536, 533, 524, 135, 555, 553, 105, 532, 552, 103,
- 100, 694, 529, 530, 531, 101, 541, 549, 32, 433,
- 651, 693, 660, 661, 662, 659, 426, 663, 640, 259,
- 129, 117, 653, 34, 656, 658, 652, 94, 650, 559,
- 36, 654, 29, 94, 199, 202, 46, 200, 1, 201,
- 203, 655, 657, 89, 622, 437, 427, 118, 408, 39,
- 149, 436, 682, 25, 519, 573, 476, 571, 626, 433,
- 443, 579, 577, 383, 576, 584, 585, 586, 575, 565,
- 446, 574, 562, 219, 517, 220, 590, 218, 591, 583,
- 572, 537, 490, 25, 222, 221, 217, 649, 114, 595,
- 688, 204, 603, 604, 605, 606, 602, 209, 473, 41,
- 370, 608, 609, 610, 106, 677, 382, 600, 539, 394,
- 185, 692, 615, 639, 613, 46, 617, 46, 46, 599,
- 519, 614, 621, 408, 619, 433, 387, 592, 525, 620,
- 407, 94, 148, 481, 158, 433, 598, 433, 624, 155,
- 616, 351, 361, 362, 354, 355, 356, 357, 358, 359,
- 360, 353, 115, 157, 156, 46, 646, 145, 642, 644,
- 645, 647, 399, 345, 146, 140, 114, 113, 665, 190,
- 668, 666, 46, 46, 198, 433, 196, 670, 545, 46,
- 112, 46, 470, 714, 637, 676, 555, 672, 14, 33,
- 648, 108, 674, 675, 11, 372, 536, 593, 46, 678,
- 35, 433, 46, 10, 17, 9, 8, 169, 7, 6,
- 5, 697, 4, 698, 696, 102, 37, 38, 433, 408,
- 701, 13, 433, 2, 0, 96, 691, 713, 137, 712,
- 92, 92, 0, 690, 0, 0, 717, 648, 716, 0,
- 0, 46, 0, 722, 0, 92, 114, 114, 114, 114,
- 718, 0, 0, 0, 0, 0, 728, 0, 0, 114,
- 536, 624, 727, 382, 352, 351, 361, 362, 354, 355,
- 356, 357, 358, 359, 360, 353, 0, 0, 730, 0,
- 46, 46, 732, 0, 729, 0, 0, 537, 0, 0,
- 673, 92, 0, 735, 0, 0, 92, 0, 0, 0,
- 733, 734, 352, 351, 361, 362, 354, 355, 356, 357,
- 358, 359, 360, 353, 92, 0, 0, 689, 0, 0,
- 0, 0, 0, 92, 212, 92, 0, 0, 0, 0,
- 92, 0, 0, 92, 0, 92, 92, 681, 0, 0,
- 0, 261, 338, 137, 0, 0, 0, 0, 0, 0,
- 0, 537, 0, 25, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 699, 0, 700, 0, 702, 0, 704,
- 0, 706, 707, 708, 709, 710, 711, 0, 0, 352,
- 351, 361, 362, 354, 355, 356, 357, 358, 359, 360,
- 353, 0, 0, 0, 0, 0, 0, 491, 0, 92,
- 643, 0, 409, 92, 92, 92, 92, 0, 0, 0,
- 0, 0, 420, 0, 0, 0, 92, 0, 0, 212,
- 352, 351, 361, 362, 354, 355, 356, 357, 358, 359,
- 360, 353, 361, 362, 354, 355, 356, 357, 358, 359,
- 360, 353, 0, 67, 0, 515, 0, 144, 0, 0,
- 0, 0, 143, 0, 176, 59, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 28, 92, 92, 183, 160,
- 159, 161, 162, 163, 164, 589, 0, 165, 166, 167,
- 0, 0, 0, 0, 141, 153, 0, 175, 0, 0,
- 0, 0, 0, 0, 0, 352, 351, 361, 362, 354,
- 355, 356, 357, 358, 359, 360, 353, 150, 151, 336,
- 0, 0, 0, 181, 0, 152, 0, 154, 0, 0,
- 0, 0, 0, 114, 0, 0, 0, 0, 180, 0,
- 68, 0, 0, 56, 0, 0, 51, 0, 76, 71,
- 63, 57, 58, 47, 491, 69, 54, 55, 53, 66,
- 73, 74, 52, 81, 50, 80, 49, 65, 72, 77,
- 64, 61, 48, 75, 62, 60, 0, 70, 78, 82,
- 0, 177, 178, 179, 182, 172, 173, 174, 0, 79,
- 0, 0, 0, 0, 0, 0, 0, 338, 261, 0,
- 0, 0, 0, 409, 67, 0, 0, 409, 338, 338,
- 338, 0, 0, 0, 0, 0, 59, 0, 409, 0,
- 0, 233, 0, 238, 239, 240, 241, 242, 243, 45,
- 244, 245, 246, 247, 248, 234, 235, 236, 237, 223,
- 224, 0, 0, 225, 226, 227, 228, 229, 230, 231,
- 232, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 352, 351, 361, 362, 354, 355,
- 356, 357, 358, 359, 360, 353, 0, 0, 0, 0,
- 0, 0, 0, 0, 92, 409, 0, 0, 0, 338,
- 92, 68, 0, 0, 56, 0, 261, 51, 0, 76,
- 71, 63, 57, 58, 47, 0, 69, 54, 55, 53,
- 66, 73, 74, 52, 81, 50, 80, 49, 65, 72,
- 77, 64, 61, 48, 75, 62, 60, 0, 70, 78,
- 82, 0, 0, 338, 0, 0, 0, 0, 0, 0,
- 79, 0, 338, 0, 0, 0, 0, 0, 0, 0,
+ 185, 617, 530, 338, 380, 427, 172, 531, 511, 457,
+ 32, 170, 522, 487, 515, 583, 148, 208, 3, 47,
+ 404, 472, 207, 95, 95, 426, 101, 432, 438, 336,
+ 45, 423, 187, 136, 121, 542, 462, 428, 403, 95,
+ 453, 113, 211, 31, 99, 138, 706, 140, 173, 26,
+ 134, 198, 562, 513, 622, 623, 624, 445, 118, 621,
+ 124, 111, 625, 698, 696, 677, 112, 464, 463, 91,
+ 125, 128, 463, 109, 440, 26, 632, 85, 86, 123,
+ 259, 92, 96, 106, 130, 95, 84, 117, 254, 253,
+ 95, 122, 710, 353, 352, 362, 363, 355, 356, 357,
+ 358, 359, 360, 361, 354, 635, 141, 188, 87, 95,
+ 606, 589, 440, 89, 88, 189, 540, 476, 95, 95,
+ 95, 379, 135, 354, 190, 95, 446, 584, 95, 556,
+ 95, 95, 342, 127, 539, 660, 95, 340, 523, 523,
+ 133, 595, 252, 126, 678, 676, 494, 345, 132, 439,
+ 261, 100, 342, 437, 436, 26, 560, 626, 591, 492,
+ 493, 491, 344, 263, 194, 29, 209, 193, 355, 356,
+ 357, 358, 359, 360, 361, 354, 490, 381, 215, 680,
+ 386, 679, 565, 251, 250, 343, 255, 439, 257, 258,
+ 335, 564, 563, 95, 372, 341, 340, 95, 95, 95,
+ 95, 442, 341, 340, 721, 619, 95, 406, 443, 400,
+ 95, 342, 405, 95, 711, 712, 395, 47, 342, 378,
+ 129, 122, 382, 383, 384, 557, 387, 421, 431, 460,
+ 388, 389, 390, 341, 340, 139, 396, 673, 672, 409,
+ 401, 411, 658, 469, 139, 117, 117, 117, 117, 342,
+ 717, 402, 433, 419, 420, 422, 417, 716, 209, 459,
+ 95, 95, 150, 408, 627, 410, 517, 25, 27, 15,
+ 16, 353, 352, 362, 363, 355, 356, 357, 358, 359,
+ 360, 361, 354, 601, 22, 393, 394, 455, 456, 630,
+ 629, 465, 357, 358, 359, 360, 361, 354, 605, 139,
+ 29, 116, 25, 480, 482, 483, 576, 577, 578, 645,
+ 481, 196, 654, 655, 656, 653, 470, 657, 466, 467,
+ 341, 340, 647, 628, 650, 652, 646, 33, 644, 517,
+ 139, 648, 424, 341, 340, 29, 342, 196, 139, 47,
+ 662, 649, 651, 538, 477, 478, 469, 484, 485, 342,
+ 474, 448, 449, 469, 488, 18, 19, 20, 217, 216,
+ 195, 538, 450, 451, 452, 469, 550, 391, 25, 29,
+ 21, 23, 25, 196, 24, 447, 200, 203, 47, 201,
+ 116, 202, 204, 543, 544, 566, 381, 519, 458, 510,
+ 664, 431, 612, 398, 399, 188, 553, 543, 544, 406,
+ 421, 29, 47, 454, 524, 29, 532, 516, 371, 41,
+ 406, 28, 414, 536, 12, 405, 415, 514, 520, 534,
+ 546, 26, 416, 203, 528, 413, 518, 47, 549, 412,
+ 559, 382, 551, 715, 548, 537, 714, 529, 431, 144,
+ 554, 461, 525, 526, 527, 256, 545, 36, 533, 105,
+ 26, 200, 203, 206, 201, 137, 202, 204, 107, 116,
+ 116, 116, 116, 38, 39, 95, 555, 547, 102, 687,
+ 103, 95, 116, 98, 47, 33, 686, 406, 634, 424,
+ 260, 131, 569, 119, 35, 474, 37, 97, 431, 30,
+ 1, 575, 90, 572, 616, 573, 435, 567, 488, 571,
+ 570, 425, 120, 40, 516, 579, 434, 675, 620, 441,
+ 561, 444, 558, 220, 514, 221, 219, 223, 222, 117,
+ 218, 590, 643, 568, 681, 205, 210, 596, 471, 42,
+ 108, 670, 535, 392, 594, 186, 685, 381, 633, 593,
+ 385, 521, 149, 609, 479, 159, 156, 611, 607, 158,
+ 406, 47, 431, 47, 47, 405, 157, 586, 615, 608,
+ 146, 397, 431, 588, 431, 618, 587, 95, 516, 346,
+ 597, 598, 599, 600, 592, 613, 614, 147, 610, 602,
+ 603, 604, 142, 115, 191, 199, 197, 541, 114, 468,
+ 47, 373, 374, 375, 376, 377, 636, 641, 705, 661,
+ 14, 431, 34, 659, 110, 11, 47, 47, 532, 663,
+ 489, 10, 17, 47, 9, 47, 171, 667, 668, 8,
+ 551, 7, 665, 6, 671, 631, 431, 642, 5, 4,
+ 104, 13, 47, 640, 669, 2, 47, 0, 0, 93,
+ 93, 0, 0, 431, 406, 0, 0, 431, 0, 684,
+ 533, 0, 0, 666, 0, 93, 0, 694, 0, 0,
+ 0, 0, 0, 0, 0, 0, 707, 708, 0, 683,
+ 0, 532, 0, 642, 47, 713, 0, 0, 0, 0,
+ 682, 0, 0, 0, 709, 618, 0, 690, 0, 691,
+ 718, 381, 719, 0, 0, 0, 0, 0, 0, 0,
+ 0, 93, 0, 0, 0, 0, 93, 0, 0, 0,
+ 0, 47, 47, 533, 0, 26, 0, 0, 0, 0,
+ 0, 0, 723, 724, 0, 93, 0, 0, 0, 0,
+ 0, 0, 0, 116, 93, 213, 93, 637, 0, 0,
+ 0, 93, 0, 0, 93, 674, 93, 93, 0, 0,
+ 0, 720, 262, 339, 489, 722, 0, 353, 352, 362,
+ 363, 355, 356, 357, 358, 359, 360, 361, 354, 0,
+ 0, 692, 0, 693, 0, 695, 0, 697, 0, 699,
+ 700, 701, 702, 703, 704, 0, 486, 0, 0, 495,
+ 496, 497, 498, 499, 500, 501, 502, 503, 504, 505,
+ 506, 507, 508, 509, 0, 0, 0, 0, 0, 93,
+ 585, 0, 407, 93, 93, 93, 93, 0, 0, 0,
+ 0, 0, 418, 0, 0, 0, 93, 0, 0, 213,
+ 353, 352, 362, 363, 355, 356, 357, 358, 359, 360,
+ 361, 354, 352, 362, 363, 355, 356, 357, 358, 359,
+ 360, 361, 354, 68, 0, 512, 0, 145, 0, 0,
+ 0, 0, 0, 0, 177, 60, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 29, 93, 93, 184, 161,
+ 160, 162, 163, 164, 165, 166, 0, 0, 167, 168,
+ 169, 0, 0, 0, 0, 143, 154, 0, 176, 362,
+ 363, 355, 356, 357, 358, 359, 360, 361, 354, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 151, 152,
+ 337, 0, 0, 0, 182, 0, 153, 0, 155, 0,
+ 0, 0, 580, 581, 582, 0, 0, 0, 0, 181,
+ 0, 69, 0, 0, 57, 0, 0, 52, 0, 0,
+ 77, 72, 64, 58, 59, 48, 0, 70, 55, 56,
+ 54, 67, 74, 75, 53, 82, 51, 81, 50, 66,
+ 73, 78, 65, 62, 49, 76, 63, 61, 0, 71,
+ 79, 83, 0, 178, 179, 180, 183, 174, 175, 0,
+ 80, 0, 0, 0, 0, 339, 262, 68, 0, 0,
+ 0, 0, 0, 0, 407, 339, 339, 339, 0, 60,
+ 0, 0, 0, 0, 0, 407, 0, 0, 0, 0,
+ 0, 0, 46, 234, 638, 639, 239, 240, 241, 242,
+ 243, 244, 0, 245, 246, 247, 248, 249, 235, 236,
+ 237, 238, 224, 225, 0, 0, 226, 227, 228, 229,
+ 230, 231, 232, 233, 0, 0, 0, 0, 353, 352,
+ 362, 363, 355, 356, 357, 358, 359, 360, 361, 354,
+ 0, 0, 0, 0, 0, 0, 0, 689, 0, 0,
+ 0, 93, 407, 0, 0, 69, 339, 93, 57, 0,
+ 0, 52, 0, 262, 77, 72, 64, 58, 59, 48,
+ 0, 70, 55, 56, 54, 67, 74, 75, 53, 82,
+ 51, 81, 50, 66, 73, 78, 65, 62, 49, 76,
+ 63, 61, 0, 71, 79, 83, 0, 0, 0, 339,
+ 0, 0, 0, 0, 80, 0, 0, 339, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 409, 0, 261, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 327, 318, 297, 329, 278,
- 289, 333, 290, 291, 312, 269, 305, 67, 92, 281,
- 265, 287, 266, 279, 299, 302, 277, 320, 331, 59,
- 301, 303, 317, 296, 313, 272, 307, 310, 330, 0,
- 0, 338, 45, 0, 431, 432, 0, 0, 0, 0,
- 0, 309, 326, 288, 0, 0, 311, 264, 308, 0,
- 268, 270, 332, 324, 284, 285, 556, 0, 0, 0,
- 0, 0, 300, 304, 314, 294, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 282, 409, 306, 0, 0,
- 0, 298, 0, 271, 0, 283, 315, 263, 322, 295,
- 325, 293, 292, 328, 68, 0, 0, 56, 321, 280,
- 51, 286, 76, 71, 63, 57, 58, 47, 0, 69,
- 54, 55, 53, 66, 73, 74, 52, 81, 50, 80,
- 49, 65, 72, 77, 64, 61, 48, 75, 62, 60,
- 267, 70, 78, 82, 323, 275, 273, 274, 316, 0,
- 276, 0, 319, 79, 327, 318, 297, 329, 278, 289,
- 333, 290, 291, 312, 269, 305, 67, 0, 281, 265,
- 287, 266, 279, 299, 302, 277, 320, 331, 59, 301,
- 303, 317, 296, 313, 272, 307, 310, 330, 0, 0,
- 0, 45, 0, 431, 432, 0, 0, 0, 0, 0,
- 309, 326, 288, 0, 0, 311, 264, 308, 0, 268,
- 270, 332, 324, 284, 285, 0, 0, 0, 0, 0,
- 0, 300, 304, 314, 294, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 282, 0, 306, 0, 0, 0,
- 298, 0, 271, 0, 283, 315, 263, 322, 295, 325,
- 293, 292, 328, 68, 0, 0, 56, 321, 280, 51,
- 286, 76, 71, 63, 57, 58, 47, 0, 69, 54,
- 55, 53, 66, 73, 74, 52, 81, 50, 80, 49,
- 65, 72, 77, 64, 61, 48, 75, 62, 60, 267,
- 70, 78, 82, 323, 275, 273, 274, 316, 0, 276,
- 0, 319, 79, 327, 318, 297, 329, 278, 289, 333,
- 290, 291, 312, 269, 305, 67, 0, 281, 265, 287,
- 266, 279, 299, 302, 277, 320, 331, 59, 301, 303,
- 317, 296, 313, 272, 307, 310, 330, 0, 0, 0,
- 45, 0, 0, 0, 0, 0, 0, 0, 0, 309,
- 326, 288, 0, 0, 311, 264, 308, 0, 268, 270,
- 332, 324, 284, 285, 0, 0, 0, 0, 0, 0,
- 300, 304, 314, 294, 0, 0, 0, 0, 0, 0,
- 0, 695, 0, 282, 0, 306, 0, 0, 0, 298,
- 0, 271, 0, 283, 315, 263, 322, 295, 325, 293,
- 292, 328, 68, 0, 0, 56, 321, 280, 51, 286,
- 76, 71, 63, 57, 58, 47, 0, 69, 54, 55,
- 53, 66, 73, 74, 52, 81, 50, 80, 49, 65,
- 72, 77, 64, 61, 48, 75, 62, 60, 267, 70,
- 78, 82, 323, 275, 273, 274, 316, 0, 276, 0,
- 319, 79, 327, 318, 297, 329, 278, 289, 333, 290,
- 291, 312, 269, 305, 67, 0, 281, 265, 287, 266,
- 279, 299, 302, 277, 320, 331, 59, 301, 303, 317,
- 296, 313, 272, 307, 310, 330, 28, 0, 0, 45,
- 0, 0, 0, 0, 0, 0, 0, 0, 309, 326,
- 288, 0, 0, 311, 264, 308, 0, 268, 270, 332,
- 324, 284, 285, 0, 0, 0, 0, 0, 0, 300,
- 304, 314, 294, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 282, 0, 306, 0, 0, 0, 298, 0,
- 271, 0, 283, 315, 263, 322, 295, 325, 293, 292,
- 328, 68, 0, 0, 56, 321, 280, 51, 286, 76,
- 71, 63, 57, 58, 47, 0, 69, 54, 55, 53,
- 66, 73, 74, 52, 81, 50, 80, 49, 65, 72,
- 77, 64, 61, 48, 75, 62, 60, 267, 70, 78,
- 82, 323, 275, 273, 274, 316, 0, 276, 0, 319,
- 79, 327, 318, 297, 329, 278, 289, 333, 290, 291,
- 312, 269, 305, 67, 0, 281, 265, 287, 266, 279,
- 299, 302, 277, 320, 331, 59, 301, 303, 317, 296,
- 313, 272, 307, 310, 330, 0, 0, 0, 183, 0,
+ 0, 0, 0, 0, 0, 407, 0, 262, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 327, 318, 297, 329, 278, 289, 333, 290, 291, 312,
+ 270, 305, 68, 93, 281, 266, 287, 267, 279, 299,
+ 302, 277, 320, 331, 60, 301, 303, 317, 296, 313,
+ 273, 307, 310, 330, 0, 339, 0, 46, 0, 429,
+ 430, 0, 0, 0, 0, 0, 0, 309, 326, 288,
+ 0, 0, 311, 265, 308, 0, 269, 271, 332, 324,
+ 284, 285, 552, 0, 0, 0, 0, 0, 300, 304,
+ 314, 294, 0, 0, 0, 0, 0, 0, 0, 407,
+ 0, 282, 0, 306, 0, 0, 0, 298, 0, 272,
+ 0, 283, 315, 264, 322, 295, 325, 293, 292, 328,
+ 69, 0, 0, 57, 321, 280, 52, 286, 334, 77,
+ 72, 64, 58, 59, 48, 0, 70, 55, 56, 54,
+ 67, 74, 75, 53, 82, 51, 81, 50, 66, 73,
+ 78, 65, 62, 49, 76, 63, 61, 268, 71, 79,
+ 83, 323, 276, 274, 275, 316, 0, 0, 319, 80,
+ 327, 318, 297, 329, 278, 289, 333, 290, 291, 312,
+ 270, 305, 68, 0, 281, 266, 287, 267, 279, 299,
+ 302, 277, 320, 331, 60, 301, 303, 317, 296, 313,
+ 273, 307, 310, 330, 0, 0, 0, 46, 0, 429,
+ 430, 0, 0, 0, 0, 0, 0, 309, 326, 288,
+ 0, 0, 311, 265, 308, 0, 269, 271, 332, 324,
+ 284, 285, 0, 0, 0, 0, 0, 0, 300, 304,
+ 314, 294, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 282, 0, 306, 0, 0, 0, 298, 0, 272,
+ 0, 283, 315, 264, 322, 295, 325, 293, 292, 328,
+ 69, 0, 0, 57, 321, 280, 52, 286, 334, 77,
+ 72, 64, 58, 59, 48, 0, 70, 55, 56, 54,
+ 67, 74, 75, 53, 82, 51, 81, 50, 66, 73,
+ 78, 65, 62, 49, 76, 63, 61, 268, 71, 79,
+ 83, 323, 276, 274, 275, 316, 0, 0, 319, 80,
+ 327, 318, 297, 329, 278, 289, 333, 290, 291, 312,
+ 270, 305, 68, 0, 281, 266, 287, 267, 279, 299,
+ 302, 277, 320, 331, 60, 301, 303, 317, 296, 313,
+ 273, 307, 310, 330, 0, 0, 0, 46, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 309, 326, 288,
+ 0, 0, 311, 265, 308, 0, 269, 271, 332, 324,
+ 284, 285, 0, 0, 0, 0, 0, 0, 300, 304,
+ 314, 294, 0, 0, 0, 0, 0, 0, 0, 688,
+ 0, 282, 0, 306, 0, 0, 0, 298, 0, 272,
+ 0, 283, 315, 264, 322, 295, 325, 293, 292, 328,
+ 69, 0, 0, 57, 321, 280, 52, 286, 334, 77,
+ 72, 64, 58, 59, 48, 0, 70, 55, 56, 54,
+ 67, 74, 75, 53, 82, 51, 81, 50, 66, 73,
+ 78, 65, 62, 49, 76, 63, 61, 268, 71, 79,
+ 83, 323, 276, 274, 275, 316, 0, 0, 319, 80,
+ 327, 318, 297, 329, 278, 289, 333, 290, 291, 312,
+ 270, 305, 68, 0, 281, 266, 287, 267, 279, 299,
+ 302, 277, 320, 331, 60, 301, 303, 317, 296, 313,
+ 273, 307, 310, 330, 29, 0, 0, 46, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 309, 326, 288,
+ 0, 0, 311, 265, 308, 0, 269, 271, 332, 324,
+ 284, 285, 0, 0, 0, 0, 0, 0, 300, 304,
+ 314, 294, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 282, 0, 306, 0, 0, 0, 298, 0, 272,
+ 0, 283, 315, 264, 322, 295, 325, 293, 292, 328,
+ 69, 0, 0, 57, 321, 280, 52, 286, 334, 77,
+ 72, 64, 58, 59, 48, 0, 70, 55, 56, 54,
+ 67, 74, 75, 53, 82, 51, 81, 50, 66, 73,
+ 78, 65, 62, 49, 76, 63, 61, 268, 71, 79,
+ 83, 323, 276, 274, 275, 316, 0, 0, 319, 80,
+ 327, 318, 297, 329, 278, 289, 333, 290, 291, 312,
+ 270, 305, 68, 0, 281, 266, 287, 267, 279, 299,
+ 302, 277, 320, 331, 60, 301, 303, 317, 296, 313,
+ 273, 307, 310, 330, 0, 0, 0, 184, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 309, 326, 288,
+ 0, 0, 311, 265, 308, 0, 269, 271, 332, 324,
+ 284, 285, 0, 0, 0, 0, 0, 0, 300, 304,
+ 314, 294, 0, 0, 0, 0, 0, 0, 0, 574,
+ 0, 282, 0, 306, 0, 0, 0, 298, 0, 272,
+ 0, 283, 315, 264, 322, 295, 325, 293, 292, 328,
+ 69, 0, 0, 57, 321, 280, 52, 286, 334, 77,
+ 72, 64, 58, 59, 48, 0, 70, 55, 56, 54,
+ 67, 74, 75, 53, 82, 51, 81, 50, 66, 73,
+ 78, 65, 62, 49, 76, 63, 61, 268, 71, 79,
+ 83, 323, 276, 274, 275, 316, 0, 0, 319, 80,
+ 327, 318, 297, 329, 278, 289, 333, 290, 291, 312,
+ 270, 305, 68, 0, 281, 266, 287, 267, 279, 299,
+ 302, 277, 320, 331, 60, 301, 303, 317, 296, 313,
+ 273, 307, 310, 330, 0, 0, 0, 46, 0, 0,
0, 0, 0, 0, 0, 0, 0, 309, 326, 288,
- 0, 0, 311, 264, 308, 0, 268, 270, 332, 324,
+ 0, 0, 311, 265, 308, 0, 269, 271, 332, 324,
284, 285, 0, 0, 0, 0, 0, 0, 300, 304,
- 314, 294, 0, 0, 0, 0, 0, 0, 0, 578,
- 0, 282, 0, 306, 0, 0, 0, 298, 0, 271,
- 0, 283, 315, 263, 322, 295, 325, 293, 292, 328,
- 68, 0, 0, 56, 321, 280, 51, 286, 76, 71,
- 63, 57, 58, 47, 0, 69, 54, 55, 53, 66,
- 73, 74, 52, 81, 50, 80, 49, 65, 72, 77,
- 64, 61, 48, 75, 62, 60, 267, 70, 78, 82,
- 323, 275, 273, 274, 316, 0, 276, 0, 319, 79,
+ 314, 294, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 282, 0, 306, 0, 0, 0, 298, 0, 272,
+ 0, 283, 315, 264, 322, 295, 325, 293, 292, 328,
+ 69, 0, 0, 57, 321, 280, 52, 286, 334, 77,
+ 72, 64, 58, 59, 48, 0, 70, 55, 56, 54,
+ 67, 74, 75, 53, 82, 51, 81, 50, 66, 73,
+ 78, 65, 62, 49, 76, 63, 61, 268, 71, 79,
+ 83, 323, 276, 274, 275, 316, 0, 0, 319, 80,
327, 318, 297, 329, 278, 289, 333, 290, 291, 312,
- 269, 305, 67, 0, 281, 265, 287, 266, 279, 299,
- 302, 277, 320, 331, 59, 301, 303, 317, 296, 313,
- 272, 307, 310, 330, 0, 0, 0, 45, 0, 0,
- 0, 0, 0, 0, 0, 0, 309, 326, 288, 0,
- 0, 311, 264, 308, 0, 268, 270, 332, 324, 284,
- 285, 0, 0, 0, 0, 0, 0, 300, 304, 314,
- 294, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 282, 0, 306, 0, 0, 0, 298, 0, 271, 0,
- 283, 315, 263, 322, 295, 325, 293, 292, 328, 68,
- 0, 0, 56, 321, 280, 51, 286, 76, 71, 63,
- 57, 58, 47, 0, 69, 54, 55, 53, 66, 73,
- 74, 52, 81, 50, 80, 49, 65, 72, 77, 64,
- 61, 48, 75, 62, 60, 267, 70, 78, 82, 323,
- 275, 273, 274, 316, 0, 276, 0, 319, 79, 327,
- 318, 297, 329, 278, 289, 333, 290, 291, 312, 269,
- 305, 67, 0, 281, 265, 287, 266, 279, 299, 302,
- 277, 320, 331, 59, 301, 303, 317, 296, 313, 272,
- 307, 310, 330, 0, 0, 0, 183, 0, 0, 0,
- 0, 0, 0, 0, 0, 309, 326, 288, 0, 0,
- 311, 264, 308, 0, 268, 270, 332, 324, 284, 285,
- 0, 0, 0, 0, 0, 0, 300, 304, 314, 294,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 282,
- 0, 306, 0, 0, 0, 298, 0, 271, 0, 283,
- 315, 263, 322, 295, 325, 293, 292, 328, 68, 0,
- 0, 56, 321, 280, 51, 286, 76, 71, 63, 57,
- 58, 47, 0, 69, 54, 55, 53, 66, 73, 74,
- 52, 81, 50, 80, 49, 65, 72, 77, 64, 61,
- 48, 75, 62, 60, 267, 70, 78, 82, 323, 275,
- 273, 274, 316, 0, 276, 0, 319, 79, 327, 318,
- 297, 329, 278, 289, 333, 290, 291, 312, 269, 305,
- 67, 0, 281, 265, 287, 266, 279, 299, 302, 277,
- 320, 331, 59, 301, 303, 317, 296, 313, 272, 307,
- 310, 330, 0, 0, 0, 93, 0, 0, 0, 0,
- 0, 0, 0, 0, 309, 326, 288, 0, 0, 311,
- 264, 308, 0, 268, 270, 332, 324, 284, 285, 0,
- 0, 0, 0, 0, 0, 300, 304, 314, 294, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 282, 0,
- 306, 0, 0, 0, 298, 0, 271, 0, 283, 315,
- 263, 322, 295, 325, 293, 292, 328, 68, 0, 0,
- 56, 321, 280, 51, 286, 76, 71, 63, 57, 58,
- 47, 0, 69, 54, 55, 53, 66, 73, 74, 52,
- 81, 50, 80, 49, 65, 72, 77, 64, 61, 48,
- 75, 62, 60, 267, 70, 78, 82, 323, 275, 273,
- 274, 316, 0, 276, 67, 319, 79, 0, 144, 0,
- 0, 0, 0, 143, 0, 176, 59, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 28, 0, 0, 183,
- 160, 159, 161, 162, 163, 164, 0, 0, 165, 166,
- 167, 0, 0, 0, 0, 141, 153, 0, 175, 0,
+ 270, 305, 68, 0, 281, 266, 287, 267, 279, 299,
+ 302, 277, 320, 331, 60, 301, 303, 317, 296, 313,
+ 273, 307, 310, 330, 0, 0, 0, 184, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 309, 326, 288,
+ 0, 0, 311, 265, 308, 0, 269, 271, 332, 324,
+ 284, 285, 0, 0, 0, 0, 0, 0, 300, 304,
+ 314, 294, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 282, 0, 306, 0, 0, 0, 298, 0, 272,
+ 0, 283, 315, 264, 322, 295, 325, 293, 292, 328,
+ 69, 0, 0, 57, 321, 280, 52, 286, 334, 77,
+ 72, 64, 58, 59, 48, 0, 70, 55, 56, 54,
+ 67, 74, 75, 53, 82, 51, 81, 50, 66, 73,
+ 78, 65, 62, 49, 76, 63, 61, 268, 71, 79,
+ 83, 323, 276, 274, 275, 316, 0, 0, 319, 80,
+ 327, 318, 297, 329, 278, 289, 333, 290, 291, 312,
+ 270, 305, 68, 0, 281, 266, 287, 267, 279, 299,
+ 302, 277, 320, 331, 60, 301, 303, 317, 296, 313,
+ 273, 307, 310, 330, 0, 0, 0, 94, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 309, 326, 288,
+ 0, 0, 311, 265, 308, 0, 269, 271, 332, 324,
+ 284, 285, 0, 0, 0, 0, 0, 0, 300, 304,
+ 314, 294, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 282, 0, 306, 0, 0, 0, 298, 0, 272,
+ 0, 283, 315, 264, 322, 295, 325, 293, 292, 328,
+ 69, 0, 0, 57, 321, 280, 52, 286, 334, 77,
+ 72, 64, 58, 59, 48, 0, 70, 55, 56, 54,
+ 67, 74, 75, 53, 82, 51, 81, 50, 66, 73,
+ 78, 65, 62, 49, 76, 63, 61, 268, 71, 79,
+ 83, 323, 276, 274, 275, 316, 68, 0, 319, 80,
+ 145, 0, 0, 0, 0, 0, 0, 177, 60, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 29, 0,
+ 0, 184, 161, 160, 162, 163, 164, 165, 166, 0,
+ 0, 167, 168, 169, 0, 0, 0, 0, 143, 154,
+ 0, 176, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 151, 152, 337, 0, 0, 0, 182, 0, 153,
+ 0, 155, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 181, 0, 69, 0, 0, 57, 0, 0,
+ 52, 0, 0, 77, 72, 64, 58, 59, 48, 0,
+ 70, 55, 56, 54, 67, 74, 75, 53, 82, 51,
+ 81, 50, 66, 73, 78, 65, 62, 49, 76, 63,
+ 61, 0, 71, 79, 83, 0, 178, 179, 180, 183,
+ 174, 175, 68, 80, 0, 0, 145, 0, 0, 0,
+ 0, 0, 0, 177, 60, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 29, 0, 139, 184, 161, 160,
+ 162, 163, 164, 165, 166, 0, 0, 167, 168, 169,
+ 0, 0, 0, 0, 143, 154, 0, 176, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 150, 151,
- 336, 0, 0, 0, 181, 0, 152, 0, 154, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 180,
- 0, 68, 0, 0, 56, 0, 0, 51, 0, 76,
- 71, 63, 57, 58, 47, 0, 69, 54, 55, 53,
- 66, 73, 74, 52, 81, 50, 80, 49, 65, 72,
- 77, 64, 61, 48, 75, 62, 60, 0, 70, 78,
- 82, 0, 177, 178, 179, 182, 172, 173, 174, 67,
- 79, 0, 0, 144, 0, 0, 0, 0, 143, 0,
- 176, 59, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 28, 0, 137, 183, 160, 159, 161, 162, 163,
- 164, 0, 0, 165, 166, 167, 0, 0, 0, 0,
- 141, 153, 0, 175, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 151, 152, 0,
+ 0, 0, 0, 182, 0, 153, 0, 155, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 181, 0,
+ 69, 0, 0, 57, 0, 0, 52, 0, 0, 77,
+ 72, 64, 58, 59, 48, 0, 70, 55, 56, 54,
+ 67, 74, 75, 53, 82, 51, 81, 50, 66, 73,
+ 78, 65, 62, 49, 76, 63, 61, 25, 71, 79,
+ 83, 0, 178, 179, 180, 183, 174, 175, 68, 80,
+ 0, 0, 145, 0, 0, 0, 0, 0, 0, 177,
+ 60, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 29, 0, 0, 184, 161, 160, 162, 163, 164, 165,
+ 166, 0, 0, 167, 168, 169, 0, 0, 0, 0,
+ 143, 154, 0, 176, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 150, 151, 0, 0, 0, 0, 181,
- 0, 152, 0, 154, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 180, 0, 68, 0, 0, 56,
- 0, 0, 51, 0, 76, 71, 63, 57, 58, 47,
- 0, 69, 54, 55, 53, 66, 73, 74, 52, 81,
- 50, 80, 49, 65, 72, 77, 64, 61, 48, 75,
- 62, 60, 0, 70, 78, 82, 24, 177, 178, 179,
- 182, 172, 173, 174, 0, 79, 0, 67, 0, 0,
- 0, 144, 0, 0, 0, 0, 143, 0, 176, 59,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 28,
- 0, 0, 183, 160, 159, 161, 162, 163, 164, 0,
- 0, 165, 166, 167, 0, 0, 0, 0, 141, 153,
- 0, 175, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 151, 152, 0, 0, 0, 0, 182,
+ 0, 153, 0, 155, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 181, 0, 69, 0, 0, 57,
+ 0, 0, 52, 0, 0, 77, 72, 64, 58, 59,
+ 48, 0, 70, 55, 56, 54, 67, 74, 75, 53,
+ 82, 51, 81, 50, 66, 73, 78, 65, 62, 49,
+ 76, 63, 61, 0, 71, 79, 83, 0, 178, 179,
+ 180, 183, 174, 175, 68, 80, 0, 0, 145, 0,
+ 0, 0, 0, 0, 0, 177, 60, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 29, 0, 0, 184,
+ 161, 160, 162, 163, 164, 165, 166, 0, 0, 167,
+ 168, 169, 0, 0, 0, 0, 143, 154, 0, 176,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 150, 151, 0, 0, 0, 0, 181, 0, 152,
- 0, 154, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 180, 0, 68, 0, 0, 56, 0, 0,
- 51, 0, 76, 71, 63, 57, 58, 47, 0, 69,
- 54, 55, 53, 66, 73, 74, 52, 81, 50, 80,
- 49, 65, 72, 77, 64, 61, 48, 75, 62, 60,
- 0, 70, 78, 82, 0, 177, 178, 179, 182, 172,
- 173, 174, 67, 79, 0, 0, 144, 0, 0, 0,
- 0, 143, 0, 176, 59, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 28, 0, 0, 183, 160, 159,
- 161, 162, 163, 164, 0, 0, 165, 166, 167, 0,
- 0, 0, 0, 141, 153, 0, 175, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 151,
+ 152, 0, 0, 0, 0, 182, 0, 153, 0, 155,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 150, 151, 0, 0,
- 0, 0, 181, 0, 152, 0, 154, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 180, 0, 68,
- 0, 0, 56, 0, 0, 51, 0, 76, 71, 63,
- 57, 58, 47, 0, 69, 54, 55, 53, 66, 73,
- 74, 52, 81, 50, 80, 49, 65, 72, 77, 64,
- 61, 48, 75, 62, 60, 0, 70, 78, 82, 67,
- 177, 178, 179, 182, 172, 173, 174, 0, 79, 0,
- 176, 59, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 28, 0, 0, 183, 160, 159, 161, 162, 163,
- 164, 0, 0, 165, 166, 167, 0, 0, 0, 0,
- 0, 153, 0, 175, 0, 0, 0, 0, 0, 0,
+ 181, 0, 69, 0, 0, 57, 0, 0, 52, 0,
+ 0, 77, 72, 64, 58, 59, 48, 0, 70, 55,
+ 56, 54, 67, 74, 75, 53, 82, 51, 81, 50,
+ 66, 73, 78, 65, 62, 49, 76, 63, 61, 0,
+ 71, 79, 83, 68, 178, 179, 180, 183, 174, 175,
+ 0, 80, 0, 0, 177, 60, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 29, 0, 0, 184, 161,
+ 160, 162, 163, 164, 165, 166, 0, 0, 167, 168,
+ 169, 0, 0, 0, 0, 0, 154, 0, 176, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 150, 151, 0, 0, 0, 0, 181,
- 0, 152, 0, 154, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 180, 0, 68, 0, 0, 56,
- 0, 0, 51, 0, 76, 71, 63, 57, 58, 47,
- 0, 69, 54, 55, 53, 66, 73, 74, 52, 81,
- 50, 80, 49, 65, 72, 77, 64, 61, 48, 75,
- 62, 60, 0, 70, 78, 82, 0, 177, 178, 179,
- 182, 172, 173, 174, 67, 79, 0, 475, 0, 0,
- 0, 0, 0, 0, 0, 0, 59, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 45,
- 0, 477, 0, 0, 0, 24, 0, 0, 0, 0,
- 0, 0, 0, 340, 339, 0, 67, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 59, 341,
- 0, 0, 0, 0, 0, 0, 0, 0, 28, 0,
- 0, 45, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 151, 152,
+ 0, 0, 0, 0, 182, 0, 153, 0, 155, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 181,
+ 0, 69, 0, 0, 57, 0, 0, 52, 0, 0,
+ 77, 72, 64, 58, 59, 48, 0, 70, 55, 56,
+ 54, 67, 74, 75, 53, 82, 51, 81, 50, 66,
+ 73, 78, 65, 62, 49, 76, 63, 61, 0, 71,
+ 79, 83, 0, 178, 179, 180, 183, 174, 175, 68,
+ 80, 0, 473, 0, 0, 0, 0, 0, 0, 0,
+ 0, 60, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 46, 0, 475, 0, 0, 0,
+ 25, 0, 0, 0, 0, 0, 0, 0, 0, 341,
+ 340, 68, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 60, 0, 342, 0, 0, 0, 0,
+ 0, 0, 0, 29, 0, 0, 46, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 68, 0, 0, 56, 0, 0, 51, 0, 76,
- 71, 63, 57, 58, 47, 0, 69, 54, 55, 53,
- 66, 73, 74, 52, 81, 50, 80, 49, 65, 72,
- 77, 64, 61, 48, 75, 62, 60, 0, 70, 78,
- 82, 0, 0, 68, 0, 0, 56, 0, 0, 51,
- 79, 76, 71, 63, 57, 58, 47, 0, 69, 54,
- 55, 53, 66, 73, 74, 52, 81, 50, 80, 49,
- 65, 72, 77, 64, 61, 48, 75, 62, 60, 24,
- 70, 78, 82, 0, 0, 0, 0, 0, 0, 0,
- 67, 0, 79, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 59, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 28, 0, 0, 93, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 69, 0, 0,
+ 57, 0, 0, 52, 0, 0, 77, 72, 64, 58,
+ 59, 48, 0, 70, 55, 56, 54, 67, 74, 75,
+ 53, 82, 51, 81, 50, 66, 73, 78, 65, 62,
+ 49, 76, 63, 61, 0, 71, 79, 83, 0, 69,
+ 0, 0, 57, 0, 0, 52, 80, 0, 77, 72,
+ 64, 58, 59, 48, 0, 70, 55, 56, 54, 67,
+ 74, 75, 53, 82, 51, 81, 50, 66, 73, 78,
+ 65, 62, 49, 76, 63, 61, 25, 71, 79, 83,
+ 0, 0, 0, 0, 0, 0, 0, 68, 80, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 60,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 29,
+ 0, 0, 94, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 68, 0,
+ 0, 212, 0, 0, 0, 0, 0, 0, 0, 0,
+ 60, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 94, 0, 214, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 67, 0, 0, 211, 0, 0, 0, 0,
- 0, 0, 0, 0, 59, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 93, 0, 213,
+ 0, 0, 0, 0, 0, 69, 0, 0, 57, 0,
+ 0, 52, 0, 0, 77, 72, 64, 58, 59, 48,
+ 0, 70, 55, 56, 54, 67, 74, 75, 53, 82,
+ 51, 81, 50, 66, 73, 78, 65, 62, 49, 76,
+ 63, 61, 0, 71, 79, 83, 69, 0, 0, 57,
+ 0, 0, 52, 0, 80, 77, 72, 64, 58, 59,
+ 48, 0, 70, 55, 56, 54, 67, 74, 75, 53,
+ 82, 51, 81, 50, 66, 73, 78, 65, 62, 49,
+ 76, 63, 61, 0, 71, 79, 83, 68, 0, 0,
+ 0, 0, 0, 0, 0, 80, 0, 0, 0, 60,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 68, 0, 0,
- 56, 0, 0, 51, 0, 76, 71, 63, 57, 58,
- 47, 0, 69, 54, 55, 53, 66, 73, 74, 52,
- 81, 50, 80, 49, 65, 72, 77, 64, 61, 48,
- 75, 62, 60, 0, 70, 78, 82, 0, 0, 68,
- 0, 0, 56, 0, 0, 51, 79, 76, 71, 63,
- 57, 58, 47, 0, 69, 54, 55, 53, 66, 73,
- 74, 52, 81, 50, 80, 49, 65, 72, 77, 64,
- 61, 48, 75, 62, 60, 67, 70, 78, 82, 0,
- 0, 0, 0, 0, 0, 0, 0, 59, 79, 0,
+ 0, 0, 46, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 68, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 45, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 67, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 59,
+ 60, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 46, 0, 475, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 43,
+ 0, 0, 0, 0, 44, 69, 0, 0, 57, 0,
+ 0, 52, 0, 0, 77, 72, 64, 58, 59, 48,
+ 0, 70, 55, 56, 54, 67, 74, 75, 53, 82,
+ 51, 81, 50, 66, 73, 78, 65, 62, 49, 76,
+ 63, 61, 0, 71, 79, 83, 69, 0, 0, 57,
+ 0, 0, 52, 0, 80, 77, 72, 64, 58, 59,
+ 48, 0, 70, 55, 56, 54, 67, 74, 75, 53,
+ 82, 51, 81, 50, 66, 73, 78, 65, 62, 49,
+ 76, 63, 61, 0, 71, 79, 83, 68, 0, 0,
+ 0, 0, 0, 0, 0, 80, 0, 0, 0, 60,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 29,
+ 0, 0, 94, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 68, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 45, 0, 477, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 42, 0, 0, 0,
- 0, 43, 68, 0, 0, 56, 0, 0, 51, 0,
- 76, 71, 63, 57, 58, 47, 0, 69, 54, 55,
- 53, 66, 73, 74, 52, 81, 50, 80, 49, 65,
- 72, 77, 64, 61, 48, 75, 62, 60, 0, 70,
- 78, 82, 0, 0, 68, 0, 0, 56, 0, 0,
- 51, 79, 76, 71, 63, 57, 58, 47, 0, 69,
- 54, 55, 53, 66, 73, 74, 52, 81, 50, 80,
- 49, 65, 72, 77, 64, 61, 48, 75, 62, 60,
- 67, 70, 78, 82, 0, 0, 0, 0, 0, 0,
- 0, 0, 59, 79, 0, 0, 0, 0, 0, 0,
- 0, 0, 28, 0, 0, 93, 0, 0, 0, 0,
+ 60, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 94, 0, 214, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 67, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 59, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 93, 0, 213,
+ 0, 0, 0, 0, 0, 69, 0, 0, 57, 0,
+ 0, 52, 0, 0, 77, 72, 64, 58, 59, 48,
+ 0, 70, 55, 56, 54, 67, 74, 75, 53, 82,
+ 51, 81, 50, 66, 73, 78, 65, 62, 49, 76,
+ 63, 61, 0, 71, 79, 83, 69, 0, 0, 57,
+ 0, 0, 52, 0, 80, 77, 72, 64, 58, 59,
+ 48, 0, 70, 55, 56, 54, 67, 74, 75, 53,
+ 82, 51, 81, 50, 66, 73, 78, 65, 62, 49,
+ 76, 63, 61, 0, 71, 79, 83, 68, 0, 0,
+ 0, 0, 0, 0, 192, 80, 0, 0, 0, 60,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 68, 0, 0,
- 56, 0, 0, 51, 0, 76, 71, 63, 57, 58,
- 47, 0, 69, 54, 55, 53, 66, 73, 74, 52,
- 81, 50, 80, 49, 65, 72, 77, 64, 61, 48,
- 75, 62, 60, 0, 70, 78, 82, 0, 0, 68,
- 0, 0, 56, 0, 0, 51, 79, 76, 71, 63,
- 57, 58, 47, 0, 69, 54, 55, 53, 66, 73,
- 74, 52, 81, 50, 80, 49, 65, 72, 77, 64,
- 61, 48, 75, 62, 60, 67, 70, 78, 82, 0,
- 0, 0, 191, 0, 0, 0, 0, 59, 79, 0,
+ 0, 0, 94, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 68, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 348,
+ 60, 351, 0, 0, 0, 0, 0, 364, 365, 366,
+ 367, 368, 369, 46, 349, 350, 347, 370, 353, 352,
+ 362, 363, 355, 356, 357, 358, 359, 360, 361, 354,
+ 0, 0, 0, 0, 0, 69, 0, 0, 57, 0,
+ 0, 52, 0, 0, 77, 72, 64, 58, 59, 48,
+ 0, 70, 55, 56, 54, 67, 74, 75, 53, 82,
+ 51, 81, 50, 66, 73, 78, 65, 62, 49, 76,
+ 63, 61, 0, 71, 79, 83, 69, 0, 0, 57,
+ 0, 0, 52, 0, 80, 77, 72, 64, 58, 59,
+ 48, 0, 70, 55, 56, 54, 67, 74, 75, 53,
+ 82, 51, 81, 50, 66, 73, 78, 65, 62, 49,
+ 76, 63, 61, 0, 71, 79, 83, 68, 0, 0,
+ 0, 0, 0, 0, 0, 80, 0, 0, 0, 60,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 93, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 67, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 347, 59,
- 350, 0, 0, 0, 0, 0, 363, 364, 365, 366,
- 367, 368, 45, 348, 349, 346, 369, 352, 351, 361,
- 362, 354, 355, 356, 357, 358, 359, 360, 353, 0,
- 0, 0, 68, 0, 0, 56, 0, 0, 51, 0,
- 76, 71, 63, 57, 58, 47, 0, 69, 54, 55,
- 53, 66, 73, 74, 52, 81, 50, 80, 49, 65,
- 72, 77, 64, 61, 48, 75, 62, 60, 0, 70,
- 78, 82, 0, 0, 68, 0, 0, 56, 0, 0,
- 51, 79, 76, 71, 63, 57, 58, 47, 0, 69,
- 54, 55, 53, 66, 73, 74, 52, 81, 50, 80,
- 49, 65, 72, 77, 64, 61, 48, 75, 62, 60,
- 67, 70, 78, 82, 0, 0, 0, 0, 0, 0,
- 0, 0, 59, 79, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 183, 0, 0, 0, 0,
+ 0, 0, 184, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 68, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 67, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 59, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 93, 0, 0,
+ 60, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 94, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 68, 0, 0,
- 56, 0, 0, 51, 0, 76, 71, 63, 57, 58,
- 47, 0, 69, 54, 55, 53, 66, 73, 74, 52,
- 81, 50, 80, 49, 65, 72, 77, 64, 61, 48,
- 75, 62, 60, 0, 70, 78, 82, 0, 0, 68,
- 0, 0, 56, 0, 0, 51, 79, 76, 71, 63,
- 57, 58, 47, 0, 69, 54, 55, 53, 66, 73,
- 74, 52, 81, 50, 80, 49, 65, 72, 77, 64,
- 61, 48, 75, 62, 60, 0, 70, 78, 82, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 79,
+ 0, 0, 0, 0, 0, 69, 0, 0, 57, 0,
+ 0, 52, 0, 0, 77, 72, 64, 58, 59, 48,
+ 0, 70, 55, 56, 54, 67, 74, 75, 53, 82,
+ 51, 81, 50, 66, 73, 78, 65, 62, 49, 76,
+ 63, 61, 0, 71, 79, 83, 69, 0, 0, 57,
+ 0, 0, 52, 0, 80, 77, 72, 64, 58, 59,
+ 48, 0, 70, 55, 56, 54, 67, 74, 75, 53,
+ 82, 51, 81, 50, 66, 73, 78, 65, 62, 49,
+ 76, 63, 61, 0, 71, 79, 83, 0, 0, 0,
+ 0, 0, 0, 0, 0, 80,
}
var yyPact = [...]int{
- 181, -1000, -108, -1000, -1000, -1000, -1000, -1000, -1000, -1000,
- -1000, -1000, 434, 458, -1000, -1000, -1000, 355, 3388, -13,
- -24, 34, 3925, 3925, -1000, 344, 103, -1000, -1000, -1000,
- -1000, 424, 430, 344, 418, -30, -1000, 3553, 451, -1000,
- 188, -21, -35, -1000, -1000, -1000, -1000, -1000, -1000, -1000,
+ 261, -1000, -112, -1000, -1000, -1000, -1000, -1000, -1000, -1000,
+ -1000, -1000, 461, 479, -1000, -1000, -1000, 370, 3370, -13,
+ -22, 14, 3921, 3921, -1000, -1000, 296, 94, -1000, -1000,
+ -1000, -1000, 452, 455, 296, 440, -29, -1000, 3540, 473,
+ -1000, 179, -21, -33, -1000, -1000, -1000, -1000, -1000, -1000,
-1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000,
-1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000,
-1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000,
- -1000, -1000, -1000, 3925, -32, -32, -15, 450, 3925, -5,
- -1000, -1000, 21, -1000, -1000, -1000, 414, 182, -99, -1000,
- 2785, 2785, 434, -1000, 344, -1000, 3718, -1000, 120, 307,
- 444, -1000, -1000, -1000, 406, 3223, 3265, 3925, 281, -1000,
- 941, -35, 3925, 77, -16, 3925, 404, 3925, 3925, -19,
- -1000, -1000, 449, 2243, 2377, -1000, -1000, -1000, -1000, 263,
- -1000, 2785, 3730, 316, 316, -1000, -1000, -1000, -1000, -1000,
- 2912, 2912, 2912, 2912, 2912, -1000, -1000, -1000, -1000, -1000,
- -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, 316, 20,
- -1000, 2650, 316, 316, 316, 2785, 316, -1000, -1000, -1000,
- 316, 316, 316, -1000, -1000, 293, -1000, 205, 424, 182,
- 318, 3925, -1000, -1000, 3883, 3553, 3553, 3553, 3553, -1000,
- 382, 379, 377, 367, 3925, -1000, 267, 182, 3223, -1000,
- -1000, 3595, -1000, -1000, 445, 1349, 130, 90, -87, -1000,
- -1000, 335, -1000, 335, 335, -1000, -1000, -1000, -1000, -1000,
- -1000, -1000, -1000, -1000, 335, 335, 335, -1000, -1000, -1000,
- -1000, -1000, -1000, -1000, 347, 347, 347, 339, 339, 212,
- -1000, 402, -39, -37, -1000, -1000, -1000, -1000, 3925, 3925,
+ -1000, -1000, -1000, -1000, 3921, -32, -32, -15, 471, 3921,
+ -6, -1000, -1000, 29, -1000, -1000, -1000, -1000, 436, 194,
+ -103, -1000, 2757, 2757, 461, -1000, 296, -1000, 3710, -1000,
+ 113, 333, 421, -1000, -1000, -1000, 433, 3200, 3241, 3921,
+ 318, -1000, 912, -33, 3921, 83, -9, 3921, 424, 3921,
+ 3921, -19, -1000, -1000, 470, 2215, 2349, -1000, -1000, -1000,
+ -1000, 145, -1000, 2757, 3720, 330, -1000, -1000, -1000, -1000,
+ -1000, 2886, 2886, 2886, 2886, 2886, -1000, -1000, -1000, -1000,
-1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000,
+ 330, 28, -1000, 2621, 330, 330, 2757, 330, -1000, -1000,
+ -1000, 330, 330, 330, -1000, -1000, 327, -1000, 263, 452,
+ 194, 366, 3921, -1000, -1000, 3880, 3540, 3540, 3540, 3540,
+ -1000, 399, 395, 382, 392, 3921, -1000, 297, 194, 3200,
+ -1000, -1000, 3581, -1000, -1000, 468, 1315, 49, 149, -87,
+ -1000, -1000, 336, -1000, 336, 336, -1000, -1000, -1000, -1000,
+ -1000, -1000, -1000, -1000, -1000, 336, 336, 336, -1000, -1000,
+ -1000, -1000, -1000, -1000, -1000, 364, 364, 364, 349, 349,
+ 187, -1000, 420, -38, -34, -1000, -1000, -1000, -1000, 3921,
+ 3921, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000,
-1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000,
-1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000,
-1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000,
-1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000,
-1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000,
-1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000,
- -1000, -1000, -1000, -1000, 313, -1000, -1000, 3047, 19, 2785,
- 2785, 246, 2785, 2785, 42, 2912, 164, 94, 2912, 2912,
- 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912,
- 2912, 2912, 2912, -1000, -1000, -1000, -1000, -1000, -1000, -1000,
- -1000, 209, -1000, 344, -1000, -1000, -1000, -1000, 1017, 866,
- 2094, 265, 74, 2650, 2785, 3883, 414, 62, 74, 3883,
- 2377, 2377, 2377, 2785, -1000, -1000, -1000, -1000, -1000, -1000,
- 3883, 316, -1000, 3089, -1000, 314, -1000, 56, -1000, 16,
- 444, 353, 306, -1000, -1000, -1000, -1000, 378, -1000, -1000,
- -1000, -1000, -1000, 182, -1000, 434, 2785, 292, 1200, -1000,
- -1000, -1000, -1000, -1000, -1000, -1000, -1000, 343, 397, 48,
- 201, -1000, -1000, 389, -1000, 115, -91, -1000, -1000, 161,
- -1000, -1000, -1000, -1000, -1000, -1000, 149, -1000, -1000, -1000,
- 140, -1000, 358, -1000, 188, -1000, 3925, 3883, -1000, -1000,
- 445, 2377, 3553, -1000, -1000, 3430, -1000, -1000, 1796, 42,
- 79, -1000, -1000, 122, -1000, -1000, 74, 74, 665, -1000,
- -1000, -1000, -1000, 164, 2912, 2912, 2912, 14, 665, 858,
- 793, 503, -1000, 154, 154, -1, -1, -1, -1, -1,
- 184, 184, 182, -1000, 182, 2377, 291, 316, 12, -1000,
- 2785, -1000, 175, 290, 2377, 76, -1000, 2785, 182, 238,
- 238, 238, -1000, 287, 269, -1000, -1000, 2512, 182, 245,
- 11, 434, 3883, 2785, 2094, -1000, -1000, 2785, 341, -1000,
- -1000, -1000, 424, 74, 1349, -1000, 1349, 3760, -1000, 179,
- -1000, -1000, -84, 13, -1000, -1000, -1000, 232, 286, 241,
- 3925, -1000, -1000, -28, 446, -1000, 271, -1000, -1000, -6,
- -1000, -1000, -1000, -1000, 14, 665, 783, -1000, 2912, 2912,
- -1000, -1000, 238, 2377, 1945, 74, 340, 2912, 300, 41,
- -1000, 2785, 145, -1000, -1000, -1000, -1000, 316, -1000, -1000,
- 375, 3760, 3760, 424, -1000, 74, -1000, 74, 3760, -1000,
- 1200, -1000, 216, -1000, 335, -1000, 40, -1000, -1000, -1000,
- -1000, -1000, -1000, -1000, 133, -1000, 132, 1647, 3883, 438,
- 426, 1498, -1000, 2912, 665, 665, -1000, 182, -1000, 182,
- 335, -1000, 335, 339, 335, -54, 335, -56, 335, 335,
- 335, 335, 335, 335, -1000, 627, -104, -1000, 74, 2785,
- -1000, 316, -1000, 344, -10, -1000, -1000, 178, -1000, -1000,
- 3760, -1000, -1000, 394, -1000, 393, 217, 185, -1000, -1000,
- -1000, -1000, -1000, 2785, 2785, -1000, 665, -1000, -1000, -1000,
+ -1000, -1000, -1000, -1000, -1000, 306, -1000, -1000, 3022, 24,
+ 2757, 2757, 251, 2757, 2757, 59, 2886, 126, 85, 2886,
+ 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886,
+ 2886, 2886, 2886, 2886, -1000, -1000, -1000, -1000, -1000, -1000,
+ -1000, -1000, 296, -1000, -1000, -1000, -1000, 980, 836, 2065,
+ 289, 176, 2621, 2757, 436, 75, 176, 3880, 2349, 2349,
+ 2349, 2757, -1000, -1000, -1000, -1000, -1000, -1000, 3880, 330,
+ -1000, 3064, -1000, 321, -1000, 67, -1000, 23, 421, 360,
+ 346, -1000, -1000, -1000, -1000, 390, -1000, -1000, -1000, -1000,
+ -1000, 194, -1000, 461, 2757, 326, 1165, -1000, -1000, -1000,
+ -1000, -1000, -1000, -1000, -1000, 357, 415, 87, 183, -1000,
+ -1000, 404, -1000, 104, -93, -1000, -1000, 147, -1000, -1000,
+ -1000, -1000, -1000, -1000, 146, -1000, -1000, -1000, 137, -1000,
+ 348, -1000, 179, -1000, 3921, 3880, -1000, -1000, 468, 2349,
+ 3540, -1000, -1000, 3411, -1000, -1000, 1765, 59, 79, -1000,
+ -1000, 254, -1000, -1000, 176, 176, 193, -1000, -1000, -1000,
+ -1000, 126, 2886, 2886, 2886, 15, 193, 752, 819, 763,
+ -1000, 208, 208, 34, 34, 34, 34, 34, 86, 86,
+ -1000, 194, 2349, 325, 330, 18, -1000, 2757, -1000, 138,
+ 2349, 76, -1000, 2757, 194, 203, 203, 203, -1000, 303,
+ 243, -1000, -1000, 2485, 194, 258, 17, 461, 3880, 2757,
+ 2065, -1000, -1000, 2757, 353, -1000, -1000, -1000, 452, 176,
+ 1315, -1000, 1315, 3751, -1000, 163, -1000, -1000, -83, 10,
+ -1000, -1000, -1000, 223, 283, 249, 3921, -1000, -1000, -25,
+ 466, -1000, 271, -1000, -1000, 12, -1000, -1000, -1000, -1000,
+ 15, 193, 679, -1000, 2886, 2886, -1000, 203, 2349, 1915,
+ 176, 198, 313, 69, -1000, 2757, 276, -1000, -1000, -1000,
+ -1000, 330, -1000, -1000, 362, 3751, 3751, 452, -1000, 176,
+ -1000, 176, 3751, -1000, 1165, -1000, 197, -1000, 336, -1000,
+ 40, -1000, -1000, -1000, -1000, -1000, -1000, -1000, 136, -1000,
+ 134, 1615, 3880, 463, 454, 1465, -1000, 2886, 193, 193,
+ -1000, 194, -1000, 194, 336, -1000, 336, 349, 336, -54,
+ 336, -55, 336, 336, 336, 336, 336, 336, -1000, -107,
+ -1000, 176, 2757, -1000, 330, -1000, 296, -1, -1000, -1000,
+ 174, -1000, -1000, 3751, -1000, -1000, 411, -1000, 408, 216,
+ 209, -1000, -1000, -1000, -1000, -1000, 2757, 2757, -1000, 193,
-1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000,
- -1000, -1000, -1000, 2912, 182, 170, 74, 269, 182, 3760,
- 3760, -1000, -1000, -1000, -1000, -1000, -1000, 74, 255, 742,
- -1000, -1000, -1000, -1000, -1000, -1000,
+ -1000, -1000, -1000, -1000, -1000, 194, 160, 176, 243, 194,
+ 3751, 3751, -1000, -1000, -1000, -1000, -1000, -1000, 176, 226,
+ -1000, -1000, -1000, -1000, -1000,
}
var yyPgo = [...]int{
- 0, 663, 16, 405, 661, 655, 652, 650, 649, 648,
- 646, 645, 644, 643, 634, 640, 631, 629, 628, 45,
- 623, 13, 51, 7, 36, 8, 622, 31, 54, 47,
- 620, 34, 618, 616, 44, 614, 53, 609, 607, 40,
- 605, 604, 603, 602, 597, 10, 594, 593, 579, 574,
- 573, 25, 1, 4, 28, 9, 572, 490, 27, 568,
- 21, 566, 559, 553, 551, 12, 550, 43, 549, 11,
- 548, 545, 30, 18, 544, 540, 105, 61, 539, 15,
- 0, 20, 35, 26, 538, 647, 22, 41, 537, 531,
- 530, 527, 526, 525, 524, 517, 515, 513, 152, 512,
- 510, 509, 37, 6, 500, 498, 492, 32, 491, 29,
- 489, 487, 486, 14, 5, 485, 2, 484, 33, 483,
- 478, 472, 119, 3, 470,
+ 0, 635, 17, 414, 631, 630, 629, 628, 623, 621,
+ 619, 614, 612, 611, 605, 447, 604, 602, 600, 33,
+ 598, 15, 53, 8, 29, 3, 589, 22, 66, 41,
+ 588, 35, 587, 586, 51, 585, 58, 584, 583, 31,
+ 582, 577, 569, 561, 560, 439, 556, 549, 546, 545,
+ 544, 13, 4, 2, 6, 7, 542, 262, 16, 541,
+ 12, 540, 539, 538, 536, 10, 535, 32, 533, 26,
+ 532, 531, 38, 20, 530, 133, 60, 529, 27, 0,
+ 11, 37, 21, 528, 616, 14, 42, 526, 525, 524,
+ 522, 520, 518, 517, 516, 515, 513, 126, 512, 511,
+ 510, 40, 9, 509, 508, 507, 34, 506, 28, 503,
+ 502, 501, 25, 5, 496, 1, 494, 36, 492, 490,
+ 489, 48, 45, 487, 486,
}
var yyR1 = [...]int{
- 0, 120, 121, 121, 1, 1, 1, 1, 1, 1,
+ 0, 119, 120, 120, 1, 1, 1, 1, 1, 1,
1, 1, 1, 2, 2, 3, 3, 4, 4, 5,
5, 6, 6, 18, 18, 18, 7, 8, 9, 9,
- 12, 110, 111, 111, 111, 107, 92, 92, 92, 95,
- 95, 93, 93, 93, 93, 93, 93, 94, 94, 94,
- 94, 94, 96, 96, 96, 96, 96, 97, 97, 97,
- 97, 97, 97, 97, 97, 97, 97, 98, 98, 102,
- 102, 103, 103, 103, 100, 100, 101, 101, 104, 104,
- 104, 99, 99, 99, 99, 99, 99, 105, 105, 106,
- 106, 106, 106, 106, 108, 115, 115, 115, 115, 109,
- 109, 117, 117, 116, 112, 112, 112, 113, 113, 113,
- 114, 114, 114, 10, 10, 10, 118, 118, 11, 11,
- 13, 13, 13, 13, 13, 119, 119, 14, 14, 124,
- 15, 16, 16, 17, 17, 19, 19, 23, 23, 22,
- 22, 24, 24, 24, 24, 84, 84, 84, 83, 83,
- 26, 27, 27, 28, 28, 29, 29, 29, 29, 38,
- 71, 71, 30, 30, 30, 31, 31, 32, 32, 89,
- 89, 88, 88, 88, 87, 87, 33, 33, 33, 34,
- 34, 35, 35, 37, 37, 36, 36, 39, 39, 25,
- 25, 25, 25, 25, 25, 25, 75, 75, 41, 41,
- 40, 40, 40, 40, 40, 40, 40, 40, 40, 40,
- 50, 50, 50, 50, 50, 50, 42, 42, 42, 42,
- 42, 42, 42, 21, 21, 51, 51, 51, 57, 52,
- 52, 45, 45, 45, 45, 45, 45, 45, 45, 45,
+ 12, 109, 110, 110, 110, 106, 91, 91, 91, 94,
+ 94, 92, 92, 92, 92, 92, 92, 93, 93, 93,
+ 93, 93, 95, 95, 95, 95, 95, 96, 96, 96,
+ 96, 96, 96, 96, 96, 96, 96, 97, 97, 101,
+ 101, 102, 102, 102, 99, 99, 100, 100, 103, 103,
+ 103, 98, 98, 98, 98, 98, 98, 104, 104, 105,
+ 105, 105, 105, 105, 107, 114, 114, 114, 114, 108,
+ 108, 116, 116, 115, 111, 111, 111, 112, 112, 112,
+ 113, 113, 113, 10, 10, 10, 117, 117, 11, 11,
+ 13, 13, 13, 13, 13, 118, 118, 14, 14, 14,
+ 124, 15, 16, 16, 17, 17, 19, 19, 23, 23,
+ 22, 22, 24, 24, 24, 24, 83, 83, 83, 82,
+ 82, 26, 27, 27, 28, 28, 29, 29, 29, 29,
+ 38, 71, 71, 30, 30, 30, 31, 31, 32, 32,
+ 88, 88, 87, 87, 87, 86, 86, 33, 33, 33,
+ 34, 34, 35, 35, 37, 37, 36, 36, 39, 39,
+ 25, 25, 25, 25, 25, 25, 41, 41, 40, 40,
+ 40, 40, 40, 40, 40, 40, 40, 40, 50, 50,
+ 50, 50, 50, 50, 42, 42, 42, 42, 42, 42,
+ 42, 21, 21, 51, 51, 51, 57, 52, 52, 45,
45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
- 45, 45, 45, 45, 45, 45, 45, 48, 48, 48,
- 46, 46, 46, 46, 46, 46, 47, 47, 47, 49,
- 49, 49, 91, 91, 91, 91, 91, 91, 91, 91,
- 91, 91, 91, 91, 91, 91, 91, 91, 91, 61,
- 61, 20, 20, 59, 59, 60, 62, 62, 58, 58,
- 58, 44, 44, 44, 44, 44, 44, 44, 63, 63,
- 64, 64, 65, 65, 66, 66, 67, 68, 68, 68,
- 69, 69, 69, 69, 43, 43, 43, 43, 43, 43,
- 70, 70, 70, 70, 53, 53, 55, 55, 54, 56,
- 72, 72, 73, 76, 76, 77, 77, 74, 74, 78,
- 78, 78, 81, 81, 82, 82, 85, 85, 86, 86,
- 79, 79, 79, 79, 79, 79, 79, 79, 79, 79,
- 79, 79, 79, 79, 79, 79, 79, 79, 79, 79,
- 79, 79, 79, 79, 79, 79, 79, 79, 79, 79,
- 79, 79, 79, 79, 79, 79, 79, 79, 79, 79,
+ 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
+ 45, 45, 45, 45, 45, 48, 48, 48, 46, 46,
+ 46, 46, 47, 47, 47, 49, 49, 49, 90, 90,
+ 90, 90, 90, 90, 90, 90, 90, 90, 90, 90,
+ 90, 90, 90, 90, 90, 61, 61, 20, 20, 59,
+ 59, 60, 62, 62, 58, 58, 58, 44, 44, 44,
+ 44, 44, 44, 44, 44, 63, 63, 64, 64, 65,
+ 65, 66, 66, 67, 68, 68, 68, 69, 69, 69,
+ 69, 43, 43, 43, 43, 43, 43, 70, 70, 70,
+ 70, 53, 53, 55, 55, 54, 56, 72, 72, 73,
+ 75, 75, 76, 76, 74, 74, 77, 77, 77, 80,
+ 80, 81, 81, 84, 84, 85, 85, 78, 78, 78,
+ 78, 78, 78, 78, 78, 78, 78, 78, 78, 78,
+ 78, 78, 78, 78, 78, 78, 78, 78, 78, 78,
+ 78, 78, 78, 78, 78, 78, 78, 78, 78, 78,
+ 78, 78, 78, 78, 78, 78, 78, 78, 78, 78,
+ 78, 78, 78, 78, 78, 78, 78, 78, 78, 78,
+ 78, 78, 78, 78, 78, 78, 78, 78, 78, 78,
+ 78, 78, 78, 78, 78, 78, 78, 78, 79, 79,
79, 79, 79, 79, 79, 79, 79, 79, 79, 79,
79, 79, 79, 79, 79, 79, 79, 79, 79, 79,
79, 79, 79, 79, 79, 79, 79, 79, 79, 79,
- 79, 80, 80, 80, 80, 80, 80, 80, 80, 80,
- 80, 80, 80, 80, 80, 80, 80, 80, 80, 80,
- 80, 80, 80, 80, 80, 80, 80, 80, 80, 80,
- 80, 80, 80, 80, 80, 80, 80, 122, 123, 90,
- 90, 90,
+ 79, 79, 79, 79, 121, 122, 123, 89, 89, 89,
}
var yyR2 = [...]int{
@@ -1011,29 +1011,29 @@ var yyR2 = [...]int{
2, 1, 2, 1, 4, 2, 3, 2, 2, 1,
1, 1, 3, 2, 0, 1, 3, 1, 2, 3,
1, 1, 1, 6, 6, 8, 0, 1, 4, 4,
- 4, 5, 3, 3, 5, 0, 1, 2, 2, 0,
- 2, 0, 2, 1, 2, 0, 1, 0, 1, 1,
- 3, 1, 2, 3, 5, 0, 1, 2, 1, 1,
- 2, 1, 3, 1, 1, 1, 1, 3, 3, 2,
- 1, 3, 4, 4, 3, 2, 4, 0, 1, 0,
- 1, 0, 1, 2, 1, 1, 1, 2, 2, 2,
- 3, 2, 2, 2, 1, 1, 3, 0, 2, 1,
- 3, 3, 2, 3, 1, 2, 0, 3, 1, 1,
- 3, 3, 4, 4, 5, 3, 4, 5, 6, 2,
- 1, 2, 1, 2, 1, 2, 1, 1, 1, 1,
- 1, 1, 1, 0, 2, 1, 1, 1, 3, 1,
- 3, 1, 1, 1, 1, 1, 3, 3, 3, 3,
- 3, 3, 3, 3, 3, 3, 3, 3, 2, 2,
- 2, 2, 3, 1, 1, 1, 1, 4, 5, 6,
- 6, 6, 8, 7, 5, 4, 1, 1, 1, 4,
- 4, 4, 2, 1, 2, 2, 2, 1, 2, 2,
- 1, 2, 2, 2, 2, 2, 2, 2, 1, 0,
- 1, 0, 2, 1, 2, 4, 0, 2, 1, 3,
- 5, 1, 1, 1, 1, 1, 1, 1, 0, 3,
- 0, 2, 0, 3, 1, 3, 2, 0, 1, 1,
- 0, 2, 4, 4, 2, 1, 3, 5, 4, 6,
- 1, 3, 3, 5, 1, 3, 1, 2, 3, 1,
- 1, 3, 3, 0, 2, 0, 3, 0, 1, 0,
+ 4, 5, 3, 3, 5, 0, 1, 2, 2, 2,
+ 0, 2, 0, 2, 1, 2, 0, 1, 0, 1,
+ 1, 3, 1, 2, 3, 5, 0, 1, 2, 1,
+ 1, 2, 1, 3, 1, 1, 1, 1, 3, 3,
+ 2, 1, 3, 4, 4, 3, 2, 4, 0, 1,
+ 0, 1, 0, 1, 2, 1, 1, 1, 2, 2,
+ 2, 3, 2, 2, 2, 1, 1, 3, 0, 2,
+ 1, 3, 3, 2, 3, 1, 1, 1, 3, 3,
+ 4, 4, 5, 3, 4, 5, 6, 2, 1, 2,
+ 1, 2, 1, 2, 1, 1, 1, 1, 1, 1,
+ 1, 0, 2, 1, 1, 1, 3, 1, 3, 1,
+ 1, 1, 1, 1, 3, 3, 3, 3, 3, 3,
+ 3, 3, 3, 3, 3, 3, 2, 2, 2, 2,
+ 3, 1, 1, 1, 1, 4, 5, 6, 6, 7,
+ 5, 4, 1, 1, 1, 4, 4, 4, 2, 1,
+ 2, 2, 2, 1, 2, 2, 1, 2, 2, 2,
+ 2, 2, 2, 2, 1, 0, 1, 0, 2, 1,
+ 2, 4, 0, 2, 1, 3, 5, 1, 1, 1,
+ 1, 1, 1, 1, 1, 0, 3, 0, 2, 0,
+ 3, 1, 3, 2, 0, 1, 1, 0, 2, 4,
+ 4, 2, 1, 3, 5, 4, 6, 1, 3, 3,
+ 5, 1, 3, 1, 2, 3, 1, 1, 3, 3,
+ 0, 2, 0, 3, 0, 1, 0, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
@@ -1045,178 +1045,175 @@ var yyR2 = [...]int{
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 0,
- 1, 1,
+ 1, 1, 1, 1, 1, 1, 0, 0, 1, 1,
}
var yyChk = [...]int{
- -1000, -120, -1, -2, -6, -7, -8, -9, -10, -11,
- -13, -14, -3, -4, -18, 8, 9, -12, 93, 94,
- 95, 108, 23, 109, 6, -122, 7, 148, 39, -121,
- 154, -65, 14, -17, 5, -15, -124, -15, -15, -110,
- 39, -78, 98, 103, -81, 42, -80, 117, 136, 130,
- 128, 110, 126, 122, 120, 121, 107, 115, 116, 29,
- 139, 135, 138, 114, 134, 131, 123, 17, 104, 119,
- 141, 113, 132, 124, 125, 137, 112, 133, 142, 153,
- 129, 127, 143, 98, 98, 99, 93, 99, 98, -119,
- 54, -36, -85, 42, -80, -36, -15, -2, 56, -69,
- 16, 15, -5, -3, -122, 18, -74, 101, -16, -27,
- -28, -29, -30, -38, -57, -122, -36, 10, -111, -107,
- 42, 99, -77, 102, -36, -76, 102, -76, 98, 10,
- -36, 144, 55, 92, -19, 19, -123, 41, 148, -25,
- -40, 58, -45, 26, 21, -44, -41, -58, -56, -57,
- 81, 82, 89, 59, 91, -48, -46, -47, -49, 44,
- 43, 45, 46, 47, 48, 51, 52, 53, -81, -85,
- -54, -122, 149, 150, 151, 61, 28, 145, 146, 147,
- 102, 87, 148, 42, -80, -66, -67, -25, -65, -2,
- -37, 24, -36, 50, 27, 40, -33, -34, -35, 30,
- 33, 35, 31, 36, -89, 20, -27, -2, -122, -88,
- -87, 20, -85, 44, -36, 41, 40, -92, -95, -97,
- -96, -93, -94, 128, 129, 132, 133, 134, 135, 136,
- 137, 138, 139, 110, 124, 125, 126, 127, 112, 113,
- 114, 115, 116, 117, 119, 120, 121, 122, 123, -77,
- -36, 58, 97, 96, -36, 21, -36, -36, 98, 10,
- -86, -85, -79, 97, 57, 20, 22, 140, 60, 15,
- 61, 93, 35, 146, 147, 145, 150, 26, 9, 23,
- 109, 19, 85, 95, 64, 65, 111, 21, 53, 10,
- 12, 13, 102, 101, 75, 99, 33, 7, 91, 24,
- 72, 30, 25, 31, 73, 16, 87, 36, 58, 51,
- 37, 56, 14, 34, 74, 96, 148, 32, 6, 152,
- 27, 108, 98, 144, 63, 100, 52, 5, 103, 8,
- 38, 28, 62, 11, -22, -24, 83, -25, -85, 57,
- 56, 72, 40, 17, -25, -42, 75, 58, 73, 74,
- 60, 78, 77, 88, 81, 82, 83, 84, 85, 86,
- 87, 79, 80, 66, 67, 68, 69, 70, 71, 76,
- -75, -122, -57, -122, -45, -45, -45, -45, -45, -122,
- 92, -52, -25, -122, -122, -122, -122, -61, -25, -122,
- -122, -122, -122, 40, -68, 22, 23, -69, -123, -43,
- 27, 28, -2, -122, -36, -72, -73, -58, -81, -85,
- -28, -29, -28, -29, 30, 30, 30, 34, 30, -34,
- -85, -123, -123, -2, -87, -39, 11, -112, -113, -114,
- -82, 44, 45, -81, -79, -107, -108, -115, 104, 103,
- -109, 99, 25, -104, 51, 58, -100, 142, -98, 39,
- -98, -98, -98, -98, -98, -102, 39, -102, -102, -103,
- 39, -103, 42, 21, -118, 105, 100, -118, -36, -36,
- -26, 40, 10, -84, -83, 20, -81, 44, 92, -25,
- -25, -50, 51, 58, 52, 53, -25, -25, -45, -51,
- -54, -57, 49, 75, 73, 74, 60, -45, -45, -45,
+ -1000, -119, -1, -2, -6, -7, -8, -9, -10, -11,
+ -13, -14, -3, -4, -18, 8, 9, -12, 94, 95,
+ 96, 109, 23, 110, 113, 6, -121, 7, 150, 39,
+ -120, 155, -65, 14, -17, 5, -15, -124, -15, -15,
+ -109, 39, -77, 99, 104, -80, 42, -79, 119, 138,
+ 132, 130, 111, 128, 124, 122, 123, 108, 117, 118,
+ 29, 141, 137, 140, 116, 136, 133, 125, 17, 105,
+ 121, 143, 115, 134, 126, 127, 139, 114, 135, 144,
+ 154, 131, 129, 145, 99, 99, 100, 94, 100, 99,
+ -118, 55, -36, -84, 42, -79, -36, -123, -15, -2,
+ 57, -69, 16, 15, -5, -3, -121, 18, -74, 102,
+ -16, -27, -28, -29, -30, -38, -57, -121, -36, 10,
+ -110, -106, 42, 100, -76, 103, -36, -75, 103, -75,
+ 99, 10, -36, 146, 56, 93, -19, 19, -122, 41,
+ 150, -25, -40, 59, -45, 21, -44, -41, -58, -56,
+ -57, 82, 83, 90, 60, 92, -48, -46, -47, -49,
+ 44, 43, 45, 46, 47, 48, 49, 52, 53, 54,
+ -80, -84, -54, -121, 151, 152, 62, 28, 147, 148,
+ 149, 103, 88, 150, 42, -79, -66, -67, -25, -65,
+ -2, -37, 24, -36, 51, 27, 40, -33, -34, -35,
+ 30, 33, 35, 31, 36, -88, 20, -27, -2, -121,
+ -87, -86, 20, -84, 44, -36, 41, 40, -91, -94,
+ -96, -95, -92, -93, 130, 131, 134, 135, 136, 137,
+ 138, 139, 140, 141, 111, 126, 127, 128, 129, 114,
+ 115, 116, 117, 118, 119, 121, 122, 123, 124, 125,
+ -76, -36, 59, 98, 97, -36, 21, -36, -36, 99,
+ 10, -85, -84, -78, 98, 58, 20, 22, 142, 61,
+ 15, 62, 94, 35, 148, 149, 147, 26, 9, 23,
+ 110, 19, 86, 96, 65, 66, 112, 21, 54, 10,
+ 12, 13, 103, 102, 76, 100, 33, 7, 92, 24,
+ 73, 30, 25, 31, 74, 16, 88, 36, 59, 52,
+ 37, 57, 14, 34, 75, 97, 150, 32, 6, 153,
+ 27, 109, 99, 146, 64, 101, 53, 5, 104, 8,
+ 38, 28, 63, 11, 113, -22, -24, 84, -25, -84,
+ 58, 57, 73, 40, 17, -25, -42, 76, 59, 74,
+ 75, 61, 79, 78, 89, 82, 83, 84, 85, 86,
+ 87, 88, 80, 81, 67, 68, 69, 70, 71, 72,
+ 77, -57, -121, -45, -45, -45, -45, -45, -121, 93,
+ -52, -25, -121, -121, -121, -61, -25, -121, -121, -121,
+ -121, 40, -68, 22, 23, -69, -122, -43, 27, 28,
+ -2, -121, -36, -72, -73, -58, -80, -84, -28, -29,
+ -28, -29, 30, 30, 30, 34, 30, -34, -84, -122,
+ -122, -2, -86, -39, 11, -111, -112, -113, -81, 44,
+ 45, -80, -78, -106, -107, -114, 105, 104, -108, 100,
+ 25, -103, 52, 59, -99, 144, -97, 39, -97, -97,
+ -97, -97, -97, -101, 39, -101, -101, -102, 39, -102,
+ 42, 21, -117, 106, 101, -117, -36, -36, -26, 40,
+ 10, -83, -82, 20, -80, 44, 93, -25, -25, -50,
+ 52, 59, 53, 54, -25, -25, -45, -51, -54, -57,
+ 50, 76, 74, 75, 61, -45, -45, -45, -45, -45,
-45, -45, -45, -45, -45, -45, -45, -45, -45, -45,
- -45, -45, 42, -81, -23, 19, -22, -82, -86, -79,
- 40, -123, -25, -58, -19, -59, -60, 62, -58, -22,
- -22, -22, -67, -72, -53, -55, -54, -122, -2, -70,
- -81, -39, 40, 66, 92, -32, -31, 37, 38, -31,
- 30, -123, -65, -25, 40, -114, 66, 39, 25, -109,
- 42, 42, -99, 26, 51, -101, 143, 45, 45, 45,
- 37, -107, -36, -58, -39, -24, -27, -83, 83, -86,
- 51, 52, 53, -51, -45, -45, -45, -21, 111, 57,
- -123, -123, -22, -122, 92, -25, 20, 40, -22, -62,
- -60, 64, -25, -123, -123, -123, -123, 40, -123, -123,
- -123, 40, 92, -65, -73, -25, -82, -25, 39, -69,
- -113, -114, -117, -116, -81, 42, -105, 140, 44, 45,
- 46, 51, 145, 41, 40, 41, 40, -36, 100, -63,
- 12, 92, -21, 57, -45, -45, -123, -23, -82, -91,
- 128, 110, 126, 122, 131, 141, 124, 142, 125, 115,
- 112, 113, 114, 117, 44, -45, -65, 65, -25, 63,
- -55, 28, -2, -122, -81, -81, -69, -71, -81, 41,
- 40, -98, -106, 104, 25, 103, 45, 45, -90, -122,
- -82, -58, -64, 13, 15, 83, -45, -123, -123, -98,
- -98, -103, -98, 116, -98, 116, -98, -98, -98, -98,
- -98, -98, -123, 40, -20, 152, -25, -53, -2, 92,
- 40, 41, -116, 25, 25, 41, 41, -25, -52, -45,
- -123, 44, -123, -81, -81, -123,
+ -80, -23, 19, -22, -81, -85, -78, 40, -122, -25,
+ -19, -59, -60, 63, -58, -22, -22, -22, -67, -72,
+ -53, -55, -54, -121, -2, -70, -80, -39, 40, 67,
+ 93, -32, -31, 37, 38, -31, 30, -122, -65, -25,
+ 40, -113, 67, 39, 25, -108, 42, 42, -98, 26,
+ 52, -100, 145, 45, 45, 45, 37, -106, -36, -58,
+ -39, -24, -27, -82, 84, -85, 52, 53, 54, -51,
+ -45, -45, -45, -21, 112, 58, -122, -22, -121, 93,
+ -25, 20, -22, -62, -60, 65, -25, -122, -122, -122,
+ -122, 40, -122, -122, -122, 40, 93, -65, -73, -25,
+ -81, -25, 39, -69, -112, -113, -116, -115, -80, 42,
+ -104, 142, 44, 45, 46, 52, 147, 41, 40, 41,
+ 40, -36, 101, -63, 12, 93, -21, 58, -45, -45,
+ -122, -23, -81, -90, 130, 111, 128, 124, 133, 143,
+ 126, 144, 127, 117, 114, 115, 116, 119, 44, -65,
+ 66, -25, 64, -55, 28, -2, -121, -80, -80, -69,
+ -71, -80, 41, 40, -97, -105, 105, 25, 104, 45,
+ 45, -89, -121, -81, -58, -64, 13, 15, 84, -45,
+ -122, -122, -97, -97, -102, -97, 118, -97, 118, -97,
+ -97, -97, -97, -97, -97, -20, 153, -25, -53, -2,
+ 93, 40, 41, -115, 25, 25, 41, 41, -25, -52,
+ -122, 44, -122, -80, -80,
}
var yyDef = [...]int{
0, -2, 2, -2, 5, 6, 7, 8, 9, 10,
- 11, 12, 312, 0, 129, 129, 129, 0, 349, 0,
- 0, 125, 0, 0, 129, 0, 23, 24, 467, 1,
- 3, 320, 0, 0, 133, 347, 131, 0, 0, 28,
- 0, 0, 345, 350, 351, 352, 353, 431, 432, 433,
- 434, 435, 436, 437, 438, 439, 440, 441, 442, 443,
- 444, 445, 446, 447, 448, 449, 450, 451, 452, 453,
- 454, 455, 456, 457, 458, 459, 460, 461, 462, 463,
- 464, 465, 466, 0, 343, 343, 0, 0, 0, 0,
- 126, 127, 185, 356, 357, 128, 135, 17, 0, 13,
- 0, 0, 312, 19, 0, 134, 0, 348, 130, 0,
- 151, 153, 154, 155, -2, 0, 171, 0, 0, 32,
- 0, 345, 0, 0, 0, 0, 0, 0, 0, 0,
- 122, 123, 0, 0, 0, 136, 18, 468, 25, 321,
- 189, 0, 194, 196, 0, 231, 232, 233, 234, 235,
- 0, 0, 0, 0, 0, 253, 254, 255, 256, 301,
- 302, 303, 304, 305, 306, 307, 198, 199, 298, 0,
- 339, 0, 0, 0, 0, 289, 0, 266, 267, 268,
- 0, 0, 0, -2, -2, 313, 314, 317, 320, 17,
- 0, 0, 184, 132, 0, 0, 0, 0, 0, 176,
- 0, 0, 0, 0, 0, 170, 0, 17, 0, 159,
- 172, 0, 174, 175, 187, 104, 0, 78, 74, 37,
- 38, 67, 40, 67, 67, 59, 60, 61, 62, 63,
- 64, 65, 66, 52, 67, 67, 67, 56, 41, 42,
- 43, 44, 45, 46, 69, 69, 69, 71, 71, 0,
- 30, 0, 116, 116, 118, 344, 119, 120, 0, 0,
- 186, 358, 359, 360, 361, 362, 363, 364, 365, 366,
- 367, 368, 369, 370, 371, 372, 373, 374, 375, 376,
- 377, 378, 379, 380, 381, 382, 383, 384, 385, 386,
- 387, 388, 389, 390, 391, 392, 393, 394, 395, 396,
- 397, 398, 399, 400, 401, 402, 403, 404, 405, 406,
- 407, 408, 409, 410, 411, 412, 413, 414, 415, 416,
- 417, 418, 419, 420, 421, 422, 423, 424, 425, 426,
- 427, 428, 429, 430, 16, 139, 141, 145, 0, 0,
- 0, 0, 0, 0, 192, 0, 0, 0, 0, 0,
+ 11, 12, 309, 0, 130, 130, 130, 0, 346, 0,
+ 0, 125, 0, 0, 466, 130, 0, 23, 24, 464,
+ 1, 3, 317, 0, 0, 134, 344, 132, 0, 0,
+ 28, 0, 0, 342, 347, 348, 349, 350, 428, 429,
+ 430, 431, 432, 433, 434, 435, 436, 437, 438, 439,
+ 440, 441, 442, 443, 444, 445, 446, 447, 448, 449,
+ 450, 451, 452, 453, 454, 455, 456, 457, 458, 459,
+ 460, 461, 462, 463, 0, 340, 340, 0, 0, 0,
+ 0, 126, 127, 186, 353, 354, 128, 129, 136, 17,
+ 0, 13, 0, 0, 309, 19, 0, 135, 0, 345,
+ 131, 0, 152, 154, 155, 156, -2, 0, 172, 0,
+ 0, 32, 0, 342, 0, 0, 0, 0, 0, 0,
+ 0, 0, 122, 123, 0, 0, 0, 137, 18, 465,
+ 25, 318, 190, 0, 195, 0, 229, 230, 231, 232,
+ 233, 0, 0, 0, 0, 0, 251, 252, 253, 254,
+ 297, 298, 299, 300, 301, 302, 303, 304, 196, 197,
+ 294, 0, 336, 0, 0, 0, 285, 0, 262, 263,
+ 264, 0, 0, 0, -2, -2, 310, 311, 314, 317,
+ 17, 0, 0, 185, 133, 0, 0, 0, 0, 0,
+ 177, 0, 0, 0, 0, 0, 171, 0, 17, 0,
+ 160, 173, 0, 175, 176, 188, 104, 0, 78, 74,
+ 37, 38, 67, 40, 67, 67, 59, 60, 61, 62,
+ 63, 64, 65, 66, 52, 67, 67, 67, 56, 41,
+ 42, 43, 44, 45, 46, 69, 69, 69, 71, 71,
+ 0, 30, 0, 116, 116, 118, 341, 119, 120, 0,
+ 0, 187, 355, 356, 357, 358, 359, 360, 361, 362,
+ 363, 364, 365, 366, 367, 368, 369, 370, 371, 372,
+ 373, 374, 375, 376, 377, 378, 379, 380, 381, 382,
+ 383, 384, 385, 386, 387, 388, 389, 390, 391, 392,
+ 393, 394, 395, 396, 397, 398, 399, 400, 401, 402,
+ 403, 404, 405, 406, 407, 408, 409, 410, 411, 412,
+ 413, 414, 415, 416, 417, 418, 419, 420, 421, 422,
+ 423, 424, 425, 426, 427, 16, 140, 142, 146, 0,
+ 0, 0, 0, 0, 0, 193, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 216, 217, 218, 219, 220, 221, 222,
- 195, 0, 209, 0, 248, 249, 250, 251, 0, 137,
- 0, 0, 229, 0, 0, 0, 135, 0, 290, 0,
- 0, 0, 0, 0, 316, 318, 319, 14, 20, 21,
- 0, 0, -2, 0, 183, 187, 340, 0, 298, 0,
- 152, 167, 0, 164, 177, 178, 179, 0, 181, 182,
- 157, 158, 228, 17, 173, 312, 0, 31, 105, 107,
- 110, 111, 112, 354, 355, 33, 34, 0, 0, 0,
- 0, 99, 100, 81, 79, 0, 76, 75, 39, 0,
- 57, 58, 53, 54, 55, 47, 0, 48, 49, 50,
- 0, 51, 0, 346, 0, 117, 0, 0, 121, 124,
- 187, 0, 0, 142, 146, 0, 148, 149, 0, 190,
- 191, 193, 210, 0, 212, 214, 322, 323, 200, 201,
- 225, 226, 227, 0, 0, 0, 0, 223, 205, 0,
+ 0, 0, 0, 0, 214, 215, 216, 217, 218, 219,
+ 220, 207, 0, 246, 247, 248, 249, 0, 138, 0,
+ 0, 227, 0, 0, 136, 0, 286, 0, 0, 0,
+ 0, 0, 313, 315, 316, 14, 20, 21, 0, 0,
+ -2, 0, 184, 188, 337, 0, 294, 0, 153, 168,
+ 0, 165, 178, 179, 180, 0, 182, 183, 158, 159,
+ 226, 17, 174, 309, 0, 31, 105, 107, 110, 111,
+ 112, 351, 352, 33, 34, 0, 0, 0, 0, 99,
+ 100, 81, 79, 0, 76, 75, 39, 0, 57, 58,
+ 53, 54, 55, 47, 0, 48, 49, 50, 0, 51,
+ 0, 343, 0, 117, 0, 0, 121, 124, 188, 0,
+ 0, 143, 147, 0, 149, 150, 0, 191, 192, 194,
+ 208, 0, 210, 212, 319, 320, 198, 199, 223, 224,
+ 225, 0, 0, 0, 0, 221, 203, 0, 234, 235,
236, 237, 238, 239, 240, 241, 242, 243, 244, 245,
- 246, 247, 0, 252, 0, 0, 138, 299, 0, -2,
- 0, 338, 0, 0, 0, 296, 293, 0, 0, 0,
- 0, 0, 315, 22, 324, 334, 336, 0, 17, 0,
- 330, 312, 0, 0, 0, 162, 168, 0, 0, 163,
- 180, -2, 320, 188, 0, 108, 0, 0, 95, 0,
- 97, 98, 87, 0, 80, 36, 77, 0, 0, 0,
- 0, 113, 114, 0, 308, 140, 150, 147, 143, 0,
- 211, 213, 215, 202, 223, 206, 0, 203, 0, 0,
- 197, 257, 0, 137, 0, 230, 0, 0, 312, 0,
- 294, 0, 0, 265, 269, 270, 271, 0, 337, -2,
- 0, 0, 0, 320, 341, 342, 299, 165, 0, 27,
- 106, 109, 0, 101, 67, 96, 89, 88, 82, 83,
- 84, 85, 86, 68, 0, 72, 0, 469, 0, 310,
- 0, 0, 204, 0, 224, 207, 258, 0, 300, 0,
- 67, 273, 67, 71, 67, 277, 67, 280, 67, 67,
- 67, 67, 67, 67, 288, 0, 291, 264, 297, 0,
- 335, 0, -2, 0, 332, 331, 26, 0, 160, 94,
- 0, 103, 35, 0, 91, 93, 0, 0, 29, 470,
- 471, 115, 15, 0, 0, 144, 208, 259, 260, 272,
- 274, 275, 276, 278, 279, 281, 282, 283, 284, 285,
- 286, 287, 261, 0, 0, 0, 295, 327, 17, 0,
- 0, 166, 102, 90, 92, 70, 73, 311, 309, 0,
- 263, 292, -2, 333, 161, 262,
+ 250, 0, 0, 139, 295, 0, -2, 0, 335, 0,
+ 0, 292, 289, 0, 0, 0, 0, 0, 312, 22,
+ 321, 331, 333, 0, 17, 0, 327, 309, 0, 0,
+ 0, 163, 169, 0, 0, 164, 181, -2, 317, 189,
+ 0, 108, 0, 0, 95, 0, 97, 98, 87, 0,
+ 80, 36, 77, 0, 0, 0, 0, 113, 114, 0,
+ 305, 141, 151, 148, 144, 0, 209, 211, 213, 200,
+ 221, 204, 0, 201, 0, 0, 255, 0, 138, 0,
+ 228, 0, 309, 0, 290, 0, 0, 261, 265, 266,
+ 267, 0, 334, -2, 0, 0, 0, 317, 338, 339,
+ 295, 166, 0, 27, 106, 109, 0, 101, 67, 96,
+ 89, 88, 82, 83, 84, 85, 86, 68, 0, 72,
+ 0, 467, 0, 307, 0, 0, 202, 0, 222, 205,
+ 256, 0, 296, 0, 67, 269, 67, 71, 67, 273,
+ 67, 276, 67, 67, 67, 67, 67, 67, 284, 287,
+ 260, 293, 0, 332, 0, -2, 0, 329, 328, 26,
+ 0, 161, 94, 0, 103, 35, 0, 91, 93, 0,
+ 0, 29, 468, 469, 115, 15, 0, 0, 145, 206,
+ 257, 258, 268, 270, 271, 272, 274, 275, 277, 278,
+ 279, 280, 281, 282, 283, 0, 0, 291, 324, 17,
+ 0, 0, 167, 102, 90, 92, 70, 73, 308, 306,
+ 259, 288, -2, 330, 162,
}
var yyTok1 = [...]int{
1, 3, 3, 3, 3, 3, 3, 3, 3, 3,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
- 3, 3, 3, 59, 3, 3, 3, 86, 78, 3,
- 39, 41, 83, 81, 40, 82, 92, 84, 3, 3,
- 3, 3, 3, 3, 3, 3, 3, 3, 3, 154,
- 67, 66, 68, 3, 3, 3, 3, 3, 3, 3,
+ 3, 3, 3, 60, 3, 3, 3, 87, 79, 3,
+ 39, 41, 84, 82, 40, 83, 93, 85, 3, 3,
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 155,
+ 68, 67, 69, 3, 3, 3, 3, 3, 3, 3,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
- 3, 3, 3, 3, 88, 3, 3, 3, 3, 3,
+ 3, 3, 3, 3, 89, 3, 3, 3, 3, 3,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
- 3, 3, 3, 3, 77, 3, 89,
+ 3, 3, 3, 3, 78, 3, 90,
}
var yyTok2 = [...]int{
@@ -1225,15 +1222,15 @@ var yyTok2 = [...]int{
22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
32, 33, 34, 35, 36, 37, 38, 42, 43, 44,
45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
- 55, 56, 57, 58, 60, 61, 62, 63, 64, 65,
- 69, 70, 71, 72, 73, 74, 75, 76, 79, 80,
- 85, 87, 90, 91, 93, 94, 95, 96, 97, 98,
+ 55, 56, 57, 58, 59, 61, 62, 63, 64, 65,
+ 66, 70, 71, 72, 73, 74, 75, 76, 77, 80,
+ 81, 86, 88, 91, 92, 94, 95, 96, 97, 98,
99, 100, 101, 102, 103, 104, 105, 106, 107, 108,
109, 110, 111, 112, 113, 114, 115, 116, 117, 118,
119, 120, 121, 122, 123, 124, 125, 126, 127, 128,
129, 130, 131, 132, 133, 134, 135, 136, 137, 138,
139, 140, 141, 142, 143, 144, 145, 146, 147, 148,
- 149, 150, 151, 152, 153,
+ 149, 150, 151, 152, 153, 154,
}
var yyTok3 = [...]int{
0,
@@ -1578,29 +1575,29 @@ yydefault:
case 1:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:244
+ //line sql.y:243
{
setParseTree(yylex, yyDollar[1].statement)
}
case 2:
yyDollar = yyS[yypt-0 : yypt+1]
- //line sql.y:249
+ //line sql.y:248
{
}
case 3:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:250
+ //line sql.y:249
{
}
case 4:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:254
+ //line sql.y:253
{
yyVAL.statement = yyDollar[1].selStmt
}
case 13:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:268
+ //line sql.y:267
{
sel := yyDollar[1].selStmt.(*Select)
sel.OrderBy = yyDollar[2].orderBy
@@ -1609,49 +1606,49 @@ yydefault:
}
case 14:
yyDollar = yyS[yypt-5 : yypt+1]
- //line sql.y:275
+ //line sql.y:274
{
yyVAL.selStmt = &Union{Type: yyDollar[2].str, Left: yyDollar[1].selStmt, Right: yyDollar[3].selStmt, OrderBy: yyDollar[4].orderBy, Limit: yyDollar[5].limit}
}
case 15:
yyDollar = yyS[yypt-8 : yypt+1]
- //line sql.y:282
+ //line sql.y:281
{
yyVAL.selStmt = &Select{Comments: Comments(yyDollar[2].bytes2), Distinct: yyDollar[3].str, SelectExprs: yyDollar[4].selectExprs, From: yyDollar[5].tableExprs, Where: NewWhere(WhereStr, yyDollar[6].expr), GroupBy: GroupBy(yyDollar[7].exprs), Having: NewWhere(HavingStr, yyDollar[8].expr)}
}
case 16:
yyDollar = yyS[yypt-4 : yypt+1]
- //line sql.y:286
+ //line sql.y:285
{
yyVAL.selStmt = &Select{Comments: Comments(yyDollar[2].bytes2), Distinct: yyDollar[3].str, SelectExprs: yyDollar[4].selectExprs}
}
case 17:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:292
+ //line sql.y:291
{
yyVAL.selStmt = yyDollar[1].selStmt
}
case 18:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:296
+ //line sql.y:295
{
yyVAL.selStmt = &ParenSelect{Select: yyDollar[2].selStmt}
}
case 19:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:302
+ //line sql.y:301
{
yyVAL.selStmt = yyDollar[1].selStmt
}
case 20:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:306
+ //line sql.y:305
{
yyVAL.selStmt = &ParenSelect{Select: yyDollar[2].selStmt}
}
case 21:
yyDollar = yyS[yypt-5 : yypt+1]
- //line sql.y:313
+ //line sql.y:312
{
// insert_data returns a *Insert pre-filled with Columns & Values
ins := yyDollar[5].ins
@@ -1663,7 +1660,7 @@ yydefault:
}
case 22:
yyDollar = yyS[yypt-6 : yypt+1]
- //line sql.y:323
+ //line sql.y:322
{
cols := make(Columns, 0, len(yyDollar[6].updateExprs))
vals := make(ValTuple, 0, len(yyDollar[6].updateExprs))
@@ -1675,84 +1672,84 @@ yydefault:
}
case 23:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:335
+ //line sql.y:334
{
yyVAL.str = InsertStr
}
case 24:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:339
+ //line sql.y:338
{
yyVAL.str = ReplaceStr
}
case 25:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:343
+ //line sql.y:342
{
yyVAL.str = ReplaceStr
}
case 26:
yyDollar = yyS[yypt-8 : yypt+1]
- //line sql.y:349
+ //line sql.y:348
{
yyVAL.statement = &Update{Comments: Comments(yyDollar[2].bytes2), TableExprs: yyDollar[3].tableExprs, Exprs: yyDollar[5].updateExprs, Where: NewWhere(WhereStr, yyDollar[6].expr), OrderBy: yyDollar[7].orderBy, Limit: yyDollar[8].limit}
}
case 27:
yyDollar = yyS[yypt-7 : yypt+1]
- //line sql.y:355
+ //line sql.y:354
{
yyVAL.statement = &Delete{Comments: Comments(yyDollar[2].bytes2), TableExprs: TableExprs{&AliasedTableExpr{Expr: yyDollar[4].tableName}}, Where: NewWhere(WhereStr, yyDollar[5].expr), OrderBy: yyDollar[6].orderBy, Limit: yyDollar[7].limit}
}
case 28:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:361
+ //line sql.y:360
{
yyDollar[1].ddl.TableSpec = yyDollar[2].TableSpec
yyVAL.statement = yyDollar[1].ddl
}
case 29:
yyDollar = yyS[yypt-8 : yypt+1]
- //line sql.y:366
+ //line sql.y:365
{
// Change this to an alter statement
yyVAL.statement = &DDL{Action: CreateIndexStr, Table: yyDollar[7].tableName, NewName: yyDollar[7].tableName}
}
case 30:
yyDollar = yyS[yypt-4 : yypt+1]
- //line sql.y:373
+ //line sql.y:372
{
yyVAL.ddl = &DDL{Action: CreateStr, NewName: yyDollar[4].tableName}
setDDL(yylex, yyVAL.ddl)
}
case 31:
yyDollar = yyS[yypt-4 : yypt+1]
- //line sql.y:380
+ //line sql.y:379
{
yyVAL.TableSpec = yyDollar[2].TableSpec
yyVAL.TableSpec.Options = yyDollar[4].str
}
case 32:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:387
+ //line sql.y:386
{
yyVAL.TableSpec = &TableSpec{}
yyVAL.TableSpec.AddColumn(yyDollar[1].columnDefinition)
}
case 33:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:392
+ //line sql.y:391
{
yyVAL.TableSpec.AddColumn(yyDollar[3].columnDefinition)
}
case 34:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:396
+ //line sql.y:395
{
yyVAL.TableSpec.AddIndex(yyDollar[3].indexDefinition)
}
case 35:
yyDollar = yyS[yypt-6 : yypt+1]
- //line sql.y:402
+ //line sql.y:401
{
yyDollar[2].columnType.NotNull = yyDollar[3].boolVal
yyDollar[2].columnType.Default = yyDollar[4].optVal
@@ -1762,7 +1759,7 @@ yydefault:
}
case 36:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:411
+ //line sql.y:410
{
yyVAL.columnType = yyDollar[1].columnType
yyVAL.columnType.Unsigned = yyDollar[2].boolVal
@@ -1770,56 +1767,56 @@ yydefault:
}
case 39:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:421
+ //line sql.y:420
{
yyVAL.columnType = yyDollar[1].columnType
yyVAL.columnType.Length = yyDollar[2].optVal
}
case 40:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:426
+ //line sql.y:425
{
yyVAL.columnType = yyDollar[1].columnType
}
case 41:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:432
+ //line sql.y:431
{
yyVAL.columnType = ColumnType{Type: string(yyDollar[1].bytes)}
}
case 42:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:436
+ //line sql.y:435
{
yyVAL.columnType = ColumnType{Type: string(yyDollar[1].bytes)}
}
case 43:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:440
+ //line sql.y:439
{
yyVAL.columnType = ColumnType{Type: string(yyDollar[1].bytes)}
}
case 44:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:444
+ //line sql.y:443
{
yyVAL.columnType = ColumnType{Type: string(yyDollar[1].bytes)}
}
case 45:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:448
+ //line sql.y:447
{
yyVAL.columnType = ColumnType{Type: string(yyDollar[1].bytes)}
}
case 46:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:452
+ //line sql.y:451
{
yyVAL.columnType = ColumnType{Type: string(yyDollar[1].bytes)}
}
case 47:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:458
+ //line sql.y:457
{
yyVAL.columnType = ColumnType{Type: string(yyDollar[1].bytes)}
yyVAL.columnType.Length = yyDollar[2].LengthScaleOption.Length
@@ -1827,7 +1824,7 @@ yydefault:
}
case 48:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:464
+ //line sql.y:463
{
yyVAL.columnType = ColumnType{Type: string(yyDollar[1].bytes)}
yyVAL.columnType.Length = yyDollar[2].LengthScaleOption.Length
@@ -1835,7 +1832,7 @@ yydefault:
}
case 49:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:470
+ //line sql.y:469
{
yyVAL.columnType = ColumnType{Type: string(yyDollar[1].bytes)}
yyVAL.columnType.Length = yyDollar[2].LengthScaleOption.Length
@@ -1843,7 +1840,7 @@ yydefault:
}
case 50:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:476
+ //line sql.y:475
{
yyVAL.columnType = ColumnType{Type: string(yyDollar[1].bytes)}
yyVAL.columnType.Length = yyDollar[2].LengthScaleOption.Length
@@ -1851,7 +1848,7 @@ yydefault:
}
case 51:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:482
+ //line sql.y:481
{
yyVAL.columnType = ColumnType{Type: string(yyDollar[1].bytes)}
yyVAL.columnType.Length = yyDollar[2].LengthScaleOption.Length
@@ -1859,115 +1856,115 @@ yydefault:
}
case 52:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:490
+ //line sql.y:489
{
yyVAL.columnType = ColumnType{Type: string(yyDollar[1].bytes)}
}
case 53:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:494
+ //line sql.y:493
{
yyVAL.columnType = ColumnType{Type: string(yyDollar[1].bytes), Length: yyDollar[2].optVal}
}
case 54:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:498
+ //line sql.y:497
{
yyVAL.columnType = ColumnType{Type: string(yyDollar[1].bytes), Length: yyDollar[2].optVal}
}
case 55:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:502
+ //line sql.y:501
{
yyVAL.columnType = ColumnType{Type: string(yyDollar[1].bytes), Length: yyDollar[2].optVal}
}
case 56:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:506
+ //line sql.y:505
{
yyVAL.columnType = ColumnType{Type: string(yyDollar[1].bytes)}
}
case 57:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:512
+ //line sql.y:511
{
yyVAL.columnType = ColumnType{Type: string(yyDollar[1].bytes), Length: yyDollar[2].optVal}
}
case 58:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:516
+ //line sql.y:515
{
yyVAL.columnType = ColumnType{Type: string(yyDollar[1].bytes), Length: yyDollar[2].optVal}
}
case 59:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:520
+ //line sql.y:519
{
yyVAL.columnType = ColumnType{Type: string(yyDollar[1].bytes)}
}
case 60:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:524
+ //line sql.y:523
{
yyVAL.columnType = ColumnType{Type: string(yyDollar[1].bytes)}
}
case 61:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:528
+ //line sql.y:527
{
yyVAL.columnType = ColumnType{Type: string(yyDollar[1].bytes)}
}
case 62:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:532
+ //line sql.y:531
{
yyVAL.columnType = ColumnType{Type: string(yyDollar[1].bytes)}
}
case 63:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:536
+ //line sql.y:535
{
yyVAL.columnType = ColumnType{Type: string(yyDollar[1].bytes)}
}
case 64:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:540
+ //line sql.y:539
{
yyVAL.columnType = ColumnType{Type: string(yyDollar[1].bytes)}
}
case 65:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:544
+ //line sql.y:543
{
yyVAL.columnType = ColumnType{Type: string(yyDollar[1].bytes)}
}
case 66:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:548
+ //line sql.y:547
{
yyVAL.columnType = ColumnType{Type: string(yyDollar[1].bytes)}
}
case 67:
yyDollar = yyS[yypt-0 : yypt+1]
- //line sql.y:553
+ //line sql.y:552
{
yyVAL.optVal = nil
}
case 68:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:557
+ //line sql.y:556
{
yyVAL.optVal = NewIntVal(yyDollar[2].bytes)
}
case 69:
yyDollar = yyS[yypt-0 : yypt+1]
- //line sql.y:562
+ //line sql.y:561
{
yyVAL.LengthScaleOption = LengthScaleOption{}
}
case 70:
yyDollar = yyS[yypt-5 : yypt+1]
- //line sql.y:566
+ //line sql.y:565
{
yyVAL.LengthScaleOption = LengthScaleOption{
Length: NewIntVal(yyDollar[2].bytes),
@@ -1976,13 +1973,13 @@ yydefault:
}
case 71:
yyDollar = yyS[yypt-0 : yypt+1]
- //line sql.y:574
+ //line sql.y:573
{
yyVAL.LengthScaleOption = LengthScaleOption{}
}
case 72:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:578
+ //line sql.y:577
{
yyVAL.LengthScaleOption = LengthScaleOption{
Length: NewIntVal(yyDollar[2].bytes),
@@ -1990,7 +1987,7 @@ yydefault:
}
case 73:
yyDollar = yyS[yypt-5 : yypt+1]
- //line sql.y:584
+ //line sql.y:583
{
yyVAL.LengthScaleOption = LengthScaleOption{
Length: NewIntVal(yyDollar[2].bytes),
@@ -1999,266 +1996,266 @@ yydefault:
}
case 74:
yyDollar = yyS[yypt-0 : yypt+1]
- //line sql.y:592
+ //line sql.y:591
{
yyVAL.boolVal = BoolVal(false)
}
case 75:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:596
+ //line sql.y:595
{
yyVAL.boolVal = BoolVal(true)
}
case 76:
yyDollar = yyS[yypt-0 : yypt+1]
- //line sql.y:601
+ //line sql.y:600
{
yyVAL.boolVal = BoolVal(false)
}
case 77:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:605
+ //line sql.y:604
{
yyVAL.boolVal = BoolVal(true)
}
case 78:
yyDollar = yyS[yypt-0 : yypt+1]
- //line sql.y:611
+ //line sql.y:610
{
yyVAL.boolVal = BoolVal(false)
}
case 79:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:615
+ //line sql.y:614
{
yyVAL.boolVal = BoolVal(false)
}
case 80:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:619
+ //line sql.y:618
{
yyVAL.boolVal = BoolVal(true)
}
case 81:
yyDollar = yyS[yypt-0 : yypt+1]
- //line sql.y:624
+ //line sql.y:623
{
yyVAL.optVal = nil
}
case 82:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:628
+ //line sql.y:627
{
yyVAL.optVal = NewStrVal(yyDollar[2].bytes)
}
case 83:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:632
+ //line sql.y:631
{
yyVAL.optVal = NewIntVal(yyDollar[2].bytes)
}
case 84:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:636
+ //line sql.y:635
{
yyVAL.optVal = NewFloatVal(yyDollar[2].bytes)
}
case 85:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:640
+ //line sql.y:639
{
yyVAL.optVal = NewValArg(yyDollar[2].bytes)
}
case 86:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:644
+ //line sql.y:643
{
yyVAL.optVal = NewValArg(yyDollar[2].bytes)
}
case 87:
yyDollar = yyS[yypt-0 : yypt+1]
- //line sql.y:649
+ //line sql.y:648
{
yyVAL.boolVal = BoolVal(false)
}
case 88:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:653
+ //line sql.y:652
{
yyVAL.boolVal = BoolVal(true)
}
case 89:
yyDollar = yyS[yypt-0 : yypt+1]
- //line sql.y:658
+ //line sql.y:657
{
yyVAL.colKeyOpt = colKeyNone
}
case 90:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:662
+ //line sql.y:661
{
yyVAL.colKeyOpt = colKeyPrimary
}
case 91:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:666
+ //line sql.y:665
{
yyVAL.colKeyOpt = colKey
}
case 92:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:670
+ //line sql.y:669
{
yyVAL.colKeyOpt = colKeyUniqueKey
}
case 93:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:674
+ //line sql.y:673
{
yyVAL.colKeyOpt = colKeyUnique
}
case 94:
yyDollar = yyS[yypt-4 : yypt+1]
- //line sql.y:680
+ //line sql.y:679
{
yyVAL.indexDefinition = &IndexDefinition{Info: yyDollar[1].indexInfo, Columns: yyDollar[3].indexColumns}
}
case 95:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:686
+ //line sql.y:685
{
yyVAL.indexInfo = &IndexInfo{Type: string(yyDollar[1].bytes) + " " + string(yyDollar[2].bytes), Name: NewColIdent("PRIMARY"), Primary: true, Unique: true}
}
case 96:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:690
+ //line sql.y:689
{
yyVAL.indexInfo = &IndexInfo{Type: string(yyDollar[1].bytes) + " " + string(yyDollar[2].str), Name: NewColIdent(string(yyDollar[3].bytes)), Unique: true}
}
case 97:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:694
+ //line sql.y:693
{
yyVAL.indexInfo = &IndexInfo{Type: string(yyDollar[1].bytes), Name: NewColIdent(string(yyDollar[2].bytes)), Unique: true}
}
case 98:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:698
+ //line sql.y:697
{
yyVAL.indexInfo = &IndexInfo{Type: string(yyDollar[1].str), Name: NewColIdent(string(yyDollar[2].bytes)), Unique: false}
}
case 99:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:704
+ //line sql.y:703
{
yyVAL.str = string(yyDollar[1].bytes)
}
case 100:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:708
+ //line sql.y:707
{
yyVAL.str = string(yyDollar[1].bytes)
}
case 101:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:714
+ //line sql.y:713
{
yyVAL.indexColumns = []*IndexColumn{yyDollar[1].indexColumn}
}
case 102:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:718
+ //line sql.y:717
{
yyVAL.indexColumns = append(yyVAL.indexColumns, yyDollar[3].indexColumn)
}
case 103:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:724
+ //line sql.y:723
{
yyVAL.indexColumn = &IndexColumn{Column: yyDollar[1].colIdent, Length: yyDollar[2].optVal}
}
case 104:
yyDollar = yyS[yypt-0 : yypt+1]
- //line sql.y:729
+ //line sql.y:728
{
yyVAL.str = ""
}
case 105:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:733
+ //line sql.y:732
{
yyVAL.str = " " + string(yyDollar[1].str)
}
case 106:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:737
+ //line sql.y:736
{
yyVAL.str = string(yyDollar[1].str) + ", " + string(yyDollar[3].str)
}
case 107:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:745
+ //line sql.y:744
{
yyVAL.str = yyDollar[1].str
}
case 108:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:749
+ //line sql.y:748
{
yyVAL.str = yyDollar[1].str + " " + yyDollar[2].str
}
case 109:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:753
+ //line sql.y:752
{
yyVAL.str = yyDollar[1].str + "=" + yyDollar[3].str
}
case 110:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:759
+ //line sql.y:758
{
yyVAL.str = yyDollar[1].colIdent.String()
}
case 111:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:763
+ //line sql.y:762
{
yyVAL.str = "'" + string(yyDollar[1].bytes) + "'"
}
case 112:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:767
+ //line sql.y:766
{
yyVAL.str = string(yyDollar[1].bytes)
}
case 113:
yyDollar = yyS[yypt-6 : yypt+1]
- //line sql.y:773
+ //line sql.y:772
{
yyVAL.statement = &DDL{Action: AlterStr, Table: yyDollar[3].tableName, NewName: yyDollar[3].tableName}
}
case 114:
yyDollar = yyS[yypt-6 : yypt+1]
- //line sql.y:777
+ //line sql.y:776
{
// Change this to a rename statement
yyVAL.statement = &DDL{Action: RenameStr, Table: yyDollar[3].tableName, NewName: yyDollar[6].tableName}
}
case 115:
yyDollar = yyS[yypt-8 : yypt+1]
- //line sql.y:782
+ //line sql.y:781
{
// Rename an index can just be an alter
yyVAL.statement = &DDL{Action: AlterStr, Table: yyDollar[3].tableName, NewName: yyDollar[3].tableName}
}
case 116:
yyDollar = yyS[yypt-0 : yypt+1]
- //line sql.y:788
+ //line sql.y:787
{
}
case 118:
yyDollar = yyS[yypt-4 : yypt+1]
- //line sql.y:792
+ //line sql.y:791
{
var exists bool
if yyDollar[3].byt != 0 {
@@ -2268,7 +2265,7 @@ yydefault:
}
case 119:
yyDollar = yyS[yypt-4 : yypt+1]
- //line sql.y:800
+ //line sql.y:799
{
var exists bool
if yyDollar[3].byt != 0 {
@@ -2278,752 +2275,740 @@ yydefault:
}
case 120:
yyDollar = yyS[yypt-4 : yypt+1]
- //line sql.y:810
+ //line sql.y:809
{
yyVAL.statement = &Show{Type: string(yyDollar[3].bytes), ShowCreate: true, OnTable: yyDollar[4].tableName}
}
case 121:
yyDollar = yyS[yypt-5 : yypt+1]
- //line sql.y:814
+ //line sql.y:813
{
yyVAL.statement = &Show{Type: string(yyDollar[2].bytes), OnTable: yyDollar[5].tableName}
}
case 122:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:818
+ //line sql.y:817
{
yyVAL.statement = &Show{Type: string(yyDollar[2].bytes), OnTable: yyDollar[3].tableName}
}
case 123:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:822
+ //line sql.y:821
{
yyVAL.statement = &Show{Type: string(yyDollar[3].bytes)}
}
case 124:
yyDollar = yyS[yypt-5 : yypt+1]
- //line sql.y:826
+ //line sql.y:825
{
yyVAL.statement = &Show{Type: "table", OnTable: yyDollar[5].tableName}
}
case 125:
yyDollar = yyS[yypt-0 : yypt+1]
- //line sql.y:831
+ //line sql.y:830
{
yyVAL.bytes = nil
}
case 126:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:835
+ //line sql.y:834
{
yyVAL.bytes = nil
}
case 127:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:841
+ //line sql.y:840
{
yyVAL.statement = &Show{Type: "table", OnTable: yyDollar[2].tableName}
}
case 128:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:845
+ //line sql.y:844
{
yyVAL.statement = &Show{Type: "table", OnTable: yyDollar[2].tableName}
}
case 129:
+ yyDollar = yyS[yypt-2 : yypt+1]
+ //line sql.y:848
+ {
+ yyVAL.statement = &Explain{}
+ }
+ case 130:
yyDollar = yyS[yypt-0 : yypt+1]
- //line sql.y:850
+ //line sql.y:853
{
setAllowComments(yylex, true)
}
- case 130:
+ case 131:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:854
+ //line sql.y:857
{
yyVAL.bytes2 = yyDollar[2].bytes2
setAllowComments(yylex, false)
}
- case 131:
+ case 132:
yyDollar = yyS[yypt-0 : yypt+1]
- //line sql.y:860
+ //line sql.y:863
{
yyVAL.bytes2 = nil
}
- case 132:
+ case 133:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:864
+ //line sql.y:867
{
yyVAL.bytes2 = append(yyDollar[1].bytes2, yyDollar[2].bytes)
}
- case 133:
+ case 134:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:870
+ //line sql.y:873
{
yyVAL.str = UnionStr
}
- case 134:
+ case 135:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:874
+ //line sql.y:877
{
yyVAL.str = UnionAllStr
}
- case 135:
+ case 136:
yyDollar = yyS[yypt-0 : yypt+1]
- //line sql.y:879
+ //line sql.y:882
{
yyVAL.str = ""
}
- case 136:
+ case 137:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:883
+ //line sql.y:886
{
yyVAL.str = DistinctStr
}
- case 137:
+ case 138:
yyDollar = yyS[yypt-0 : yypt+1]
- //line sql.y:888
+ //line sql.y:891
{
yyVAL.selectExprs = nil
}
- case 138:
+ case 139:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:892
+ //line sql.y:895
{
yyVAL.selectExprs = yyDollar[1].selectExprs
}
- case 139:
+ case 140:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:898
+ //line sql.y:901
{
yyVAL.selectExprs = SelectExprs{yyDollar[1].selectExpr}
}
- case 140:
+ case 141:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:902
+ //line sql.y:905
{
yyVAL.selectExprs = append(yyVAL.selectExprs, yyDollar[3].selectExpr)
}
- case 141:
+ case 142:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:908
+ //line sql.y:911
{
yyVAL.selectExpr = &StarExpr{}
}
- case 142:
+ case 143:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:912
+ //line sql.y:915
{
yyVAL.selectExpr = &AliasedExpr{Expr: yyDollar[1].expr, As: yyDollar[2].colIdent}
}
- case 143:
+ case 144:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:916
+ //line sql.y:919
{
yyVAL.selectExpr = &StarExpr{TableName: TableName{Name: yyDollar[1].tableIdent}}
}
- case 144:
+ case 145:
yyDollar = yyS[yypt-5 : yypt+1]
- //line sql.y:920
+ //line sql.y:923
{
yyVAL.selectExpr = &StarExpr{TableName: TableName{Qualifier: yyDollar[1].tableIdent, Name: yyDollar[3].tableIdent}}
}
- case 145:
+ case 146:
yyDollar = yyS[yypt-0 : yypt+1]
- //line sql.y:925
+ //line sql.y:928
{
yyVAL.colIdent = ColIdent{}
}
- case 146:
+ case 147:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:929
+ //line sql.y:932
{
yyVAL.colIdent = yyDollar[1].colIdent
}
- case 147:
+ case 148:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:933
+ //line sql.y:936
{
yyVAL.colIdent = yyDollar[2].colIdent
}
- case 149:
+ case 150:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:940
+ //line sql.y:943
{
yyVAL.colIdent = NewColIdent(string(yyDollar[1].bytes))
}
- case 150:
+ case 151:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:946
+ //line sql.y:949
{
yyVAL.tableExprs = yyDollar[2].tableExprs
}
- case 151:
+ case 152:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:952
+ //line sql.y:955
{
yyVAL.tableExprs = TableExprs{yyDollar[1].tableExpr}
}
- case 152:
+ case 153:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:956
+ //line sql.y:959
{
yyVAL.tableExprs = append(yyVAL.tableExprs, yyDollar[3].tableExpr)
}
- case 155:
+ case 156:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:966
+ //line sql.y:969
{
yyVAL.tableExpr = yyDollar[1].aliasedTableName
}
- case 156:
+ case 157:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:970
+ //line sql.y:973
{
yyVAL.tableExpr = &AliasedTableExpr{Expr: yyDollar[1].subquery}
}
- case 157:
+ case 158:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:974
+ //line sql.y:977
{
yyVAL.tableExpr = &AliasedTableExpr{Expr: yyDollar[1].subquery, As: yyDollar[3].tableIdent}
}
- case 158:
+ case 159:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:978
+ //line sql.y:981
{
yyVAL.tableExpr = &ParenTableExpr{Exprs: yyDollar[2].tableExprs}
}
- case 159:
+ case 160:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:984
+ //line sql.y:987
{
yyVAL.aliasedTableName = &AliasedTableExpr{Expr: yyDollar[1].tableName, As: yyDollar[2].tableIdent}
}
- case 160:
+ case 161:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:990
+ //line sql.y:993
{
yyVAL.columns = Columns{yyDollar[1].colIdent}
}
- case 161:
+ case 162:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:994
+ //line sql.y:997
{
yyVAL.columns = append(yyVAL.columns, yyDollar[3].colIdent)
}
- case 162:
+ case 163:
yyDollar = yyS[yypt-4 : yypt+1]
- //line sql.y:1000
+ //line sql.y:1003
{
yyVAL.tableExpr = &JoinTableExpr{LeftExpr: yyDollar[1].tableExpr, Join: yyDollar[2].str, RightExpr: yyDollar[3].tableExpr, Condition: yyDollar[4].joinCondition}
}
- case 163:
+ case 164:
yyDollar = yyS[yypt-4 : yypt+1]
- //line sql.y:1004
+ //line sql.y:1007
{
yyVAL.tableExpr = &JoinTableExpr{LeftExpr: yyDollar[1].tableExpr, Join: yyDollar[2].str, RightExpr: yyDollar[3].tableExpr, Condition: yyDollar[4].joinCondition}
}
- case 164:
+ case 165:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:1008
+ //line sql.y:1011
{
yyVAL.tableExpr = &JoinTableExpr{LeftExpr: yyDollar[1].tableExpr, Join: yyDollar[2].str, RightExpr: yyDollar[3].tableExpr}
}
- case 165:
+ case 166:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:1014
+ //line sql.y:1017
{
yyVAL.joinCondition = JoinCondition{On: yyDollar[2].expr}
}
- case 166:
+ case 167:
yyDollar = yyS[yypt-4 : yypt+1]
- //line sql.y:1016
+ //line sql.y:1019
{
yyVAL.joinCondition = JoinCondition{Using: yyDollar[3].columns}
}
- case 167:
+ case 168:
yyDollar = yyS[yypt-0 : yypt+1]
- //line sql.y:1020
+ //line sql.y:1023
{
yyVAL.joinCondition = JoinCondition{}
}
- case 168:
+ case 169:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1022
+ //line sql.y:1025
{
yyVAL.joinCondition = yyDollar[1].joinCondition
}
- case 169:
+ case 170:
yyDollar = yyS[yypt-0 : yypt+1]
- //line sql.y:1025
+ //line sql.y:1028
{
yyVAL.empty = struct{}{}
}
- case 170:
+ case 171:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1027
+ //line sql.y:1030
{
yyVAL.empty = struct{}{}
}
- case 171:
+ case 172:
yyDollar = yyS[yypt-0 : yypt+1]
- //line sql.y:1030
+ //line sql.y:1033
{
yyVAL.tableIdent = NewTableIdent("")
}
- case 172:
+ case 173:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1034
+ //line sql.y:1037
{
yyVAL.tableIdent = yyDollar[1].tableIdent
}
- case 173:
+ case 174:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:1038
+ //line sql.y:1041
{
yyVAL.tableIdent = yyDollar[2].tableIdent
}
- case 175:
+ case 176:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1045
+ //line sql.y:1048
{
yyVAL.tableIdent = NewTableIdent(string(yyDollar[1].bytes))
}
- case 176:
+ case 177:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1051
+ //line sql.y:1054
{
yyVAL.str = JoinStr
}
- case 177:
+ case 178:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:1055
+ //line sql.y:1058
{
yyVAL.str = InnerJoinStr
}
- case 178:
+ case 179:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:1059
+ //line sql.y:1062
{
yyVAL.str = CrossJoinStr
}
- case 179:
+ case 180:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:1065
+ //line sql.y:1068
{
yyVAL.str = LeftJoinStr
}
- case 180:
+ case 181:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:1069
+ //line sql.y:1072
{
yyVAL.str = LeftJoinStr
}
- case 181:
+ case 182:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:1075
+ //line sql.y:1078
{
yyVAL.str = NaturalJoinStr
}
- case 182:
+ case 183:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:1079
+ //line sql.y:1082
{
yyVAL.str = NaturalLeftJoinStr
}
- case 183:
+ case 184:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:1085
+ //line sql.y:1088
{
yyVAL.tableName = yyDollar[2].tableName
}
- case 184:
+ case 185:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1089
+ //line sql.y:1092
{
yyVAL.tableName = yyDollar[1].tableName
}
- case 185:
+ case 186:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1095
+ //line sql.y:1098
{
yyVAL.tableName = TableName{Name: yyDollar[1].tableIdent}
}
- case 186:
+ case 187:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:1099
+ //line sql.y:1102
{
yyVAL.tableName = TableName{Qualifier: yyDollar[1].tableIdent, Name: yyDollar[3].tableIdent}
}
- case 187:
+ case 188:
yyDollar = yyS[yypt-0 : yypt+1]
- //line sql.y:1104
+ //line sql.y:1107
{
yyVAL.expr = nil
}
- case 188:
+ case 189:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:1108
+ //line sql.y:1111
{
yyVAL.expr = yyDollar[2].expr
}
- case 189:
+ case 190:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1114
+ //line sql.y:1117
{
yyVAL.expr = yyDollar[1].expr
}
- case 190:
+ case 191:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:1118
+ //line sql.y:1121
{
yyVAL.expr = &AndExpr{Left: yyDollar[1].expr, Right: yyDollar[3].expr}
}
- case 191:
+ case 192:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:1122
+ //line sql.y:1125
{
yyVAL.expr = &OrExpr{Left: yyDollar[1].expr, Right: yyDollar[3].expr}
}
- case 192:
+ case 193:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:1126
+ //line sql.y:1129
{
yyVAL.expr = &NotExpr{Expr: yyDollar[2].expr}
}
- case 193:
+ case 194:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:1130
+ //line sql.y:1133
{
yyVAL.expr = &IsExpr{Operator: yyDollar[3].str, Expr: yyDollar[1].expr}
}
- case 194:
+ case 195:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1134
+ //line sql.y:1137
{
yyVAL.expr = yyDollar[1].expr
}
- case 195:
- yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:1138
- {
- yyVAL.expr = &Default{ColName: yyDollar[2].str}
- }
case 196:
- yyDollar = yyS[yypt-0 : yypt+1]
- //line sql.y:1144
- {
- yyVAL.str = ""
- }
- case 197:
- yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:1148
- {
- yyVAL.str = string(yyDollar[2].bytes)
- }
- case 198:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1154
+ //line sql.y:1143
{
yyVAL.boolVal = BoolVal(true)
}
- case 199:
+ case 197:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1158
+ //line sql.y:1147
{
yyVAL.boolVal = BoolVal(false)
}
- case 200:
+ case 198:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:1164
+ //line sql.y:1153
{
yyVAL.expr = &ComparisonExpr{Left: yyDollar[1].expr, Operator: yyDollar[2].str, Right: yyDollar[3].expr}
}
- case 201:
+ case 199:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:1168
+ //line sql.y:1157
{
yyVAL.expr = &ComparisonExpr{Left: yyDollar[1].expr, Operator: InStr, Right: yyDollar[3].colTuple}
}
- case 202:
+ case 200:
yyDollar = yyS[yypt-4 : yypt+1]
- //line sql.y:1172
+ //line sql.y:1161
{
yyVAL.expr = &ComparisonExpr{Left: yyDollar[1].expr, Operator: NotInStr, Right: yyDollar[4].colTuple}
}
- case 203:
+ case 201:
yyDollar = yyS[yypt-4 : yypt+1]
- //line sql.y:1176
+ //line sql.y:1165
{
yyVAL.expr = &ComparisonExpr{Left: yyDollar[1].expr, Operator: LikeStr, Right: yyDollar[3].expr, Escape: yyDollar[4].expr}
}
- case 204:
+ case 202:
yyDollar = yyS[yypt-5 : yypt+1]
- //line sql.y:1180
+ //line sql.y:1169
{
yyVAL.expr = &ComparisonExpr{Left: yyDollar[1].expr, Operator: NotLikeStr, Right: yyDollar[4].expr, Escape: yyDollar[5].expr}
}
- case 205:
+ case 203:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:1184
+ //line sql.y:1173
{
yyVAL.expr = &ComparisonExpr{Left: yyDollar[1].expr, Operator: RegexpStr, Right: yyDollar[3].expr}
}
- case 206:
+ case 204:
yyDollar = yyS[yypt-4 : yypt+1]
- //line sql.y:1188
+ //line sql.y:1177
{
yyVAL.expr = &ComparisonExpr{Left: yyDollar[1].expr, Operator: NotRegexpStr, Right: yyDollar[4].expr}
}
- case 207:
+ case 205:
yyDollar = yyS[yypt-5 : yypt+1]
- //line sql.y:1192
+ //line sql.y:1181
{
yyVAL.expr = &RangeCond{Left: yyDollar[1].expr, Operator: BetweenStr, From: yyDollar[3].expr, To: yyDollar[5].expr}
}
- case 208:
+ case 206:
yyDollar = yyS[yypt-6 : yypt+1]
- //line sql.y:1196
+ //line sql.y:1185
{
yyVAL.expr = &RangeCond{Left: yyDollar[1].expr, Operator: NotBetweenStr, From: yyDollar[4].expr, To: yyDollar[6].expr}
}
- case 209:
+ case 207:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:1200
+ //line sql.y:1189
{
yyVAL.expr = &ExistsExpr{Subquery: yyDollar[2].subquery}
}
- case 210:
+ case 208:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1206
+ //line sql.y:1195
{
yyVAL.str = IsNullStr
}
- case 211:
+ case 209:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:1210
+ //line sql.y:1199
{
yyVAL.str = IsNotNullStr
}
- case 212:
+ case 210:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1214
+ //line sql.y:1203
{
yyVAL.str = IsTrueStr
}
- case 213:
+ case 211:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:1218
+ //line sql.y:1207
{
yyVAL.str = IsNotTrueStr
}
- case 214:
+ case 212:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1222
+ //line sql.y:1211
{
yyVAL.str = IsFalseStr
}
- case 215:
+ case 213:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:1226
+ //line sql.y:1215
{
yyVAL.str = IsNotFalseStr
}
- case 216:
+ case 214:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1232
+ //line sql.y:1221
{
yyVAL.str = EqualStr
}
- case 217:
+ case 215:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1236
+ //line sql.y:1225
{
yyVAL.str = LessThanStr
}
- case 218:
+ case 216:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1240
+ //line sql.y:1229
{
yyVAL.str = GreaterThanStr
}
- case 219:
+ case 217:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1244
+ //line sql.y:1233
{
yyVAL.str = LessEqualStr
}
- case 220:
+ case 218:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1248
+ //line sql.y:1237
{
yyVAL.str = GreaterEqualStr
}
- case 221:
+ case 219:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1252
+ //line sql.y:1241
{
yyVAL.str = NotEqualStr
}
- case 222:
+ case 220:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1256
+ //line sql.y:1245
{
yyVAL.str = NullSafeNotEqualStr
}
- case 223:
+ case 221:
yyDollar = yyS[yypt-0 : yypt+1]
- //line sql.y:1261
+ //line sql.y:1250
{
yyVAL.expr = nil
}
- case 224:
+ case 222:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:1265
+ //line sql.y:1254
{
yyVAL.expr = yyDollar[2].expr
}
- case 225:
+ case 223:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1271
+ //line sql.y:1260
{
yyVAL.colTuple = yyDollar[1].valTuple
}
- case 226:
+ case 224:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1275
+ //line sql.y:1264
{
yyVAL.colTuple = yyDollar[1].subquery
}
- case 227:
+ case 225:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1279
+ //line sql.y:1268
{
yyVAL.colTuple = ListArg(yyDollar[1].bytes)
}
- case 228:
+ case 226:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:1285
+ //line sql.y:1274
{
yyVAL.subquery = &Subquery{yyDollar[2].selStmt}
}
- case 229:
+ case 227:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1291
+ //line sql.y:1280
{
yyVAL.exprs = Exprs{yyDollar[1].expr}
}
- case 230:
+ case 228:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:1295
+ //line sql.y:1284
{
yyVAL.exprs = append(yyDollar[1].exprs, yyDollar[3].expr)
}
- case 231:
+ case 229:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1301
+ //line sql.y:1290
{
yyVAL.expr = yyDollar[1].expr
}
- case 232:
+ case 230:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1305
+ //line sql.y:1294
{
yyVAL.expr = yyDollar[1].boolVal
}
- case 233:
+ case 231:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1309
+ //line sql.y:1298
{
yyVAL.expr = yyDollar[1].colName
}
- case 234:
+ case 232:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1313
+ //line sql.y:1302
{
yyVAL.expr = yyDollar[1].expr
}
- case 235:
+ case 233:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1317
+ //line sql.y:1306
{
yyVAL.expr = yyDollar[1].subquery
}
- case 236:
+ case 234:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:1321
+ //line sql.y:1310
{
yyVAL.expr = &BinaryExpr{Left: yyDollar[1].expr, Operator: BitAndStr, Right: yyDollar[3].expr}
}
- case 237:
+ case 235:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:1325
+ //line sql.y:1314
{
yyVAL.expr = &BinaryExpr{Left: yyDollar[1].expr, Operator: BitOrStr, Right: yyDollar[3].expr}
}
- case 238:
+ case 236:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:1329
+ //line sql.y:1318
{
yyVAL.expr = &BinaryExpr{Left: yyDollar[1].expr, Operator: BitXorStr, Right: yyDollar[3].expr}
}
- case 239:
+ case 237:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:1333
+ //line sql.y:1322
{
yyVAL.expr = &BinaryExpr{Left: yyDollar[1].expr, Operator: PlusStr, Right: yyDollar[3].expr}
}
- case 240:
+ case 238:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:1337
+ //line sql.y:1326
{
yyVAL.expr = &BinaryExpr{Left: yyDollar[1].expr, Operator: MinusStr, Right: yyDollar[3].expr}
}
- case 241:
+ case 239:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:1341
+ //line sql.y:1330
{
yyVAL.expr = &BinaryExpr{Left: yyDollar[1].expr, Operator: MultStr, Right: yyDollar[3].expr}
}
- case 242:
+ case 240:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:1345
+ //line sql.y:1334
{
yyVAL.expr = &BinaryExpr{Left: yyDollar[1].expr, Operator: DivStr, Right: yyDollar[3].expr}
}
- case 243:
+ case 241:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:1349
+ //line sql.y:1338
{
yyVAL.expr = &BinaryExpr{Left: yyDollar[1].expr, Operator: IntDivStr, Right: yyDollar[3].expr}
}
- case 244:
+ case 242:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:1353
+ //line sql.y:1342
{
yyVAL.expr = &BinaryExpr{Left: yyDollar[1].expr, Operator: ModStr, Right: yyDollar[3].expr}
}
- case 245:
+ case 243:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:1357
+ //line sql.y:1346
{
yyVAL.expr = &BinaryExpr{Left: yyDollar[1].expr, Operator: ModStr, Right: yyDollar[3].expr}
}
- case 246:
+ case 244:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:1361
+ //line sql.y:1350
{
yyVAL.expr = &BinaryExpr{Left: yyDollar[1].expr, Operator: ShiftLeftStr, Right: yyDollar[3].expr}
}
- case 247:
+ case 245:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:1365
+ //line sql.y:1354
{
yyVAL.expr = &BinaryExpr{Left: yyDollar[1].expr, Operator: ShiftRightStr, Right: yyDollar[3].expr}
}
- case 248:
+ case 246:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:1369
+ //line sql.y:1358
{
if num, ok := yyDollar[2].expr.(*SQLVal); ok && num.Type == IntVal {
yyVAL.expr = num
@@ -3031,9 +3016,9 @@ yydefault:
yyVAL.expr = &UnaryExpr{Operator: UPlusStr, Expr: yyDollar[2].expr}
}
}
- case 249:
+ case 247:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:1377
+ //line sql.y:1366
{
if num, ok := yyDollar[2].expr.(*SQLVal); ok && num.Type == IntVal {
// Handle double negative
@@ -3047,21 +3032,21 @@ yydefault:
yyVAL.expr = &UnaryExpr{Operator: UMinusStr, Expr: yyDollar[2].expr}
}
}
- case 250:
+ case 248:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:1391
+ //line sql.y:1380
{
yyVAL.expr = &UnaryExpr{Operator: TildaStr, Expr: yyDollar[2].expr}
}
- case 251:
+ case 249:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:1395
+ //line sql.y:1384
{
yyVAL.expr = &UnaryExpr{Operator: BangStr, Expr: yyDollar[2].expr}
}
- case 252:
+ case 250:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:1399
+ //line sql.y:1388
{
// This rule prevents the usage of INTERVAL
// as a function. If support is needed for that,
@@ -3069,505 +3054,499 @@ yydefault:
// will be non-trivial because of grammar conflicts.
yyVAL.expr = &IntervalExpr{Expr: yyDollar[2].expr, Unit: yyDollar[3].colIdent.String()}
}
- case 257:
+ case 255:
yyDollar = yyS[yypt-4 : yypt+1]
- //line sql.y:1417
+ //line sql.y:1406
{
yyVAL.expr = &FuncExpr{Name: yyDollar[1].colIdent, Exprs: yyDollar[3].selectExprs}
}
- case 258:
+ case 256:
yyDollar = yyS[yypt-5 : yypt+1]
- //line sql.y:1421
+ //line sql.y:1410
{
yyVAL.expr = &FuncExpr{Name: yyDollar[1].colIdent, Distinct: true, Exprs: yyDollar[4].selectExprs}
}
- case 259:
+ case 257:
yyDollar = yyS[yypt-6 : yypt+1]
- //line sql.y:1425
+ //line sql.y:1414
{
yyVAL.expr = &FuncExpr{Qualifier: yyDollar[1].tableIdent, Name: yyDollar[3].colIdent, Exprs: yyDollar[5].selectExprs}
}
- case 260:
+ case 258:
yyDollar = yyS[yypt-6 : yypt+1]
- //line sql.y:1435
+ //line sql.y:1424
{
yyVAL.expr = &ConvertExpr{Expr: yyDollar[3].expr, Type: yyDollar[5].convertType}
}
- case 261:
- yyDollar = yyS[yypt-6 : yypt+1]
- //line sql.y:1439
- {
- yyVAL.expr = &SubstrExpr{Name: yyDollar[3].colName, From: yyDollar[5].expr, To: nil}
- }
- case 262:
- yyDollar = yyS[yypt-8 : yypt+1]
- //line sql.y:1443
- {
- yyVAL.expr = &SubstrExpr{Name: yyDollar[3].colName, From: yyDollar[5].expr, To: yyDollar[7].expr}
- }
- case 263:
+ case 259:
yyDollar = yyS[yypt-7 : yypt+1]
- //line sql.y:1447
+ //line sql.y:1428
{
yyVAL.expr = &GroupConcatExpr{Distinct: yyDollar[3].str, Exprs: yyDollar[4].selectExprs, OrderBy: yyDollar[5].orderBy, Separator: yyDollar[6].str}
}
- case 264:
+ case 260:
yyDollar = yyS[yypt-5 : yypt+1]
- //line sql.y:1451
+ //line sql.y:1432
{
yyVAL.expr = &CaseExpr{Expr: yyDollar[2].expr, Whens: yyDollar[3].whens, Else: yyDollar[4].expr}
}
- case 265:
+ case 261:
yyDollar = yyS[yypt-4 : yypt+1]
- //line sql.y:1455
+ //line sql.y:1436
{
yyVAL.expr = &ValuesFuncExpr{Name: yyDollar[3].colName}
}
- case 266:
+ case 262:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1465
+ //line sql.y:1446
{
yyVAL.expr = &TimeExpr{Expr: NewColIdent("current_timestamp")}
}
- case 267:
+ case 263:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1470
+ //line sql.y:1451
{
yyVAL.expr = &TimeExpr{Expr: NewColIdent("current_date")}
}
- case 268:
+ case 264:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1475
+ //line sql.y:1456
{
yyVAL.expr = &TimeExpr{Expr: NewColIdent("current_time")}
}
- case 269:
+ case 265:
yyDollar = yyS[yypt-4 : yypt+1]
- //line sql.y:1485
+ //line sql.y:1466
{
yyVAL.expr = &FuncExpr{Name: NewColIdent("if"), Exprs: yyDollar[3].selectExprs}
}
- case 270:
+ case 266:
yyDollar = yyS[yypt-4 : yypt+1]
- //line sql.y:1489
+ //line sql.y:1470
{
yyVAL.expr = &FuncExpr{Name: NewColIdent("mod"), Exprs: yyDollar[3].selectExprs}
}
- case 271:
+ case 267:
yyDollar = yyS[yypt-4 : yypt+1]
- //line sql.y:1493
+ //line sql.y:1474
{
yyVAL.expr = &FuncExpr{Name: NewColIdent("replace"), Exprs: yyDollar[3].selectExprs}
}
- case 272:
+ case 268:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:1499
+ //line sql.y:1480
{
yyVAL.convertType = &ConvertType{Type: string(yyDollar[1].bytes), Length: yyDollar[2].optVal}
}
- case 273:
+ case 269:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1503
+ //line sql.y:1484
{
yyVAL.convertType = &ConvertType{Type: string(yyDollar[1].bytes)}
}
- case 274:
+ case 270:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:1507
+ //line sql.y:1488
{
yyVAL.convertType = &ConvertType{Type: string(yyDollar[1].bytes), Length: yyDollar[2].optVal}
}
- case 275:
+ case 271:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:1511
+ //line sql.y:1492
{
yyVAL.convertType = &ConvertType{Type: string(yyDollar[1].bytes)}
yyVAL.convertType.Length = yyDollar[2].LengthScaleOption.Length
yyVAL.convertType.Scale = yyDollar[2].LengthScaleOption.Scale
}
- case 276:
+ case 272:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:1517
+ //line sql.y:1498
{
yyVAL.convertType = &ConvertType{Type: string(yyDollar[1].bytes), Length: yyDollar[2].optVal}
}
- case 277:
+ case 273:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1521
+ //line sql.y:1502
{
yyVAL.convertType = &ConvertType{Type: string(yyDollar[1].bytes)}
}
- case 278:
+ case 274:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:1525
+ //line sql.y:1506
{
yyVAL.convertType = &ConvertType{Type: string(yyDollar[1].bytes)}
}
- case 279:
+ case 275:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:1529
+ //line sql.y:1510
{
yyVAL.convertType = &ConvertType{Type: string(yyDollar[1].bytes), Length: yyDollar[2].optVal}
}
- case 280:
+ case 276:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1533
+ //line sql.y:1514
{
yyVAL.convertType = &ConvertType{Type: string(yyDollar[1].bytes)}
}
- case 281:
+ case 277:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:1537
+ //line sql.y:1518
{
yyVAL.convertType = &ConvertType{Type: string(yyDollar[1].bytes)}
}
- case 282:
+ case 278:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:1541
+ //line sql.y:1522
{
yyVAL.convertType = &ConvertType{Type: string(yyDollar[1].bytes), Length: yyDollar[2].optVal}
}
- case 283:
+ case 279:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:1545
+ //line sql.y:1526
{
yyVAL.convertType = &ConvertType{Type: string(yyDollar[1].bytes), Length: yyDollar[2].optVal}
}
- case 284:
+ case 280:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:1549
+ //line sql.y:1530
{
yyVAL.convertType = &ConvertType{Type: string(yyDollar[1].bytes), Length: yyDollar[2].optVal}
}
- case 285:
+ case 281:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:1553
+ //line sql.y:1534
{
yyVAL.convertType = &ConvertType{Type: string(yyDollar[1].bytes), Length: yyDollar[2].optVal}
}
- case 286:
+ case 282:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:1557
+ //line sql.y:1538
{
yyVAL.convertType = &ConvertType{Type: string(yyDollar[1].bytes), Length: yyDollar[2].optVal}
}
- case 287:
+ case 283:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:1561
+ //line sql.y:1542
{
yyVAL.convertType = &ConvertType{Type: string(yyDollar[1].bytes), Length: yyDollar[2].optVal}
}
- case 288:
+ case 284:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1565
+ //line sql.y:1546
{
yyVAL.convertType = &ConvertType{Type: string(yyDollar[1].bytes)}
}
- case 289:
+ case 285:
yyDollar = yyS[yypt-0 : yypt+1]
- //line sql.y:1570
+ //line sql.y:1551
{
yyVAL.expr = nil
}
- case 290:
+ case 286:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1574
+ //line sql.y:1555
{
yyVAL.expr = yyDollar[1].expr
}
- case 291:
+ case 287:
yyDollar = yyS[yypt-0 : yypt+1]
- //line sql.y:1579
+ //line sql.y:1560
{
yyVAL.str = string("")
}
- case 292:
+ case 288:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:1583
+ //line sql.y:1564
{
yyVAL.str = " separator '" + string(yyDollar[2].bytes) + "'"
}
- case 293:
+ case 289:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1589
+ //line sql.y:1570
{
yyVAL.whens = []*When{yyDollar[1].when}
}
- case 294:
+ case 290:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:1593
+ //line sql.y:1574
{
yyVAL.whens = append(yyDollar[1].whens, yyDollar[2].when)
}
- case 295:
+ case 291:
yyDollar = yyS[yypt-4 : yypt+1]
- //line sql.y:1599
+ //line sql.y:1580
{
yyVAL.when = &When{Cond: yyDollar[2].expr, Val: yyDollar[4].expr}
}
- case 296:
+ case 292:
yyDollar = yyS[yypt-0 : yypt+1]
- //line sql.y:1604
+ //line sql.y:1585
{
yyVAL.expr = nil
}
- case 297:
+ case 293:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:1608
+ //line sql.y:1589
{
yyVAL.expr = yyDollar[2].expr
}
- case 298:
+ case 294:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1614
+ //line sql.y:1595
{
yyVAL.colName = &ColName{Name: yyDollar[1].colIdent}
}
- case 299:
+ case 295:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:1618
+ //line sql.y:1599
{
yyVAL.colName = &ColName{Qualifier: TableName{Name: yyDollar[1].tableIdent}, Name: yyDollar[3].colIdent}
}
- case 300:
+ case 296:
yyDollar = yyS[yypt-5 : yypt+1]
- //line sql.y:1622
+ //line sql.y:1603
{
yyVAL.colName = &ColName{Qualifier: TableName{Qualifier: yyDollar[1].tableIdent, Name: yyDollar[3].tableIdent}, Name: yyDollar[5].colIdent}
}
- case 301:
+ case 297:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1628
+ //line sql.y:1609
{
yyVAL.expr = NewStrVal(yyDollar[1].bytes)
}
- case 302:
+ case 298:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1632
+ //line sql.y:1613
{
yyVAL.expr = NewHexVal(yyDollar[1].bytes)
}
- case 303:
+ case 299:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1636
+ //line sql.y:1617
{
yyVAL.expr = NewIntVal(yyDollar[1].bytes)
}
- case 304:
+ case 300:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1640
+ //line sql.y:1621
{
yyVAL.expr = NewFloatVal(yyDollar[1].bytes)
}
- case 305:
+ case 301:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1644
+ //line sql.y:1625
{
yyVAL.expr = NewHexNum(yyDollar[1].bytes)
}
- case 306:
+ case 302:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1648
+ //line sql.y:1629
{
yyVAL.expr = NewValArg(yyDollar[1].bytes)
}
- case 307:
+ case 303:
+ yyDollar = yyS[yypt-1 : yypt+1]
+ //line sql.y:1633
+ {
+ yyVAL.expr = NewPosArg(yyDollar[1].bytes)
+ }
+ case 304:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1652
+ //line sql.y:1637
{
yyVAL.expr = &NullVal{}
}
- case 308:
+ case 305:
yyDollar = yyS[yypt-0 : yypt+1]
- //line sql.y:1657
+ //line sql.y:1642
{
yyVAL.exprs = nil
}
- case 309:
+ case 306:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:1661
+ //line sql.y:1646
{
yyVAL.exprs = yyDollar[3].exprs
}
- case 310:
+ case 307:
yyDollar = yyS[yypt-0 : yypt+1]
- //line sql.y:1666
+ //line sql.y:1651
{
yyVAL.expr = nil
}
- case 311:
+ case 308:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:1670
+ //line sql.y:1655
{
yyVAL.expr = yyDollar[2].expr
}
- case 312:
+ case 309:
yyDollar = yyS[yypt-0 : yypt+1]
- //line sql.y:1675
+ //line sql.y:1660
{
yyVAL.orderBy = nil
}
- case 313:
+ case 310:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:1679
+ //line sql.y:1664
{
yyVAL.orderBy = yyDollar[3].orderBy
}
- case 314:
+ case 311:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1685
+ //line sql.y:1670
{
yyVAL.orderBy = OrderBy{yyDollar[1].order}
}
- case 315:
+ case 312:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:1689
+ //line sql.y:1674
{
yyVAL.orderBy = append(yyDollar[1].orderBy, yyDollar[3].order)
}
- case 316:
+ case 313:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:1695
+ //line sql.y:1680
{
yyVAL.order = &Order{Expr: yyDollar[1].expr, Direction: yyDollar[2].str}
}
- case 317:
+ case 314:
yyDollar = yyS[yypt-0 : yypt+1]
- //line sql.y:1700
+ //line sql.y:1685
{
yyVAL.str = AscScr
}
- case 318:
+ case 315:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1704
+ //line sql.y:1689
{
yyVAL.str = AscScr
}
- case 319:
+ case 316:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1708
+ //line sql.y:1693
{
yyVAL.str = DescScr
}
- case 320:
+ case 317:
yyDollar = yyS[yypt-0 : yypt+1]
- //line sql.y:1713
+ //line sql.y:1698
{
yyVAL.limit = nil
}
- case 321:
+ case 318:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:1717
+ //line sql.y:1702
{
yyVAL.limit = &Limit{Rowcount: yyDollar[2].expr}
}
- case 322:
+ case 319:
yyDollar = yyS[yypt-4 : yypt+1]
- //line sql.y:1721
+ //line sql.y:1706
{
yyVAL.limit = &Limit{Offset: yyDollar[2].expr, Rowcount: yyDollar[4].expr}
}
- case 323:
+ case 320:
yyDollar = yyS[yypt-4 : yypt+1]
- //line sql.y:1725
+ //line sql.y:1710
{
yyVAL.limit = &Limit{Offset: yyDollar[4].expr, Rowcount: yyDollar[2].expr}
}
- case 324:
+ case 321:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:1738
+ //line sql.y:1723
{
yyVAL.ins = &Insert{Rows: yyDollar[2].values}
}
- case 325:
+ case 322:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1742
+ //line sql.y:1727
{
yyVAL.ins = &Insert{Rows: yyDollar[1].selStmt}
}
- case 326:
+ case 323:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:1746
+ //line sql.y:1731
{
// Drop the redundant parenthesis.
yyVAL.ins = &Insert{Rows: yyDollar[2].selStmt}
}
- case 327:
+ case 324:
yyDollar = yyS[yypt-5 : yypt+1]
- //line sql.y:1751
+ //line sql.y:1736
{
yyVAL.ins = &Insert{Columns: yyDollar[2].columns, Rows: yyDollar[5].values}
}
- case 328:
+ case 325:
yyDollar = yyS[yypt-4 : yypt+1]
- //line sql.y:1755
+ //line sql.y:1740
{
yyVAL.ins = &Insert{Columns: yyDollar[2].columns, Rows: yyDollar[4].selStmt}
}
- case 329:
+ case 326:
yyDollar = yyS[yypt-6 : yypt+1]
- //line sql.y:1759
+ //line sql.y:1744
{
// Drop the redundant parenthesis.
yyVAL.ins = &Insert{Columns: yyDollar[2].columns, Rows: yyDollar[5].selStmt}
}
- case 330:
+ case 327:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1766
+ //line sql.y:1751
{
yyVAL.columns = Columns{yyDollar[1].colIdent}
}
- case 331:
+ case 328:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:1770
+ //line sql.y:1755
{
yyVAL.columns = Columns{yyDollar[3].colIdent}
}
- case 332:
+ case 329:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:1774
+ //line sql.y:1759
{
yyVAL.columns = append(yyVAL.columns, yyDollar[3].colIdent)
}
- case 333:
+ case 330:
yyDollar = yyS[yypt-5 : yypt+1]
- //line sql.y:1778
+ //line sql.y:1763
{
yyVAL.columns = append(yyVAL.columns, yyDollar[5].colIdent)
}
- case 334:
+ case 331:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1784
+ //line sql.y:1769
{
yyVAL.values = Values{yyDollar[1].valTuple}
}
- case 335:
+ case 332:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:1788
+ //line sql.y:1773
{
yyVAL.values = append(yyDollar[1].values, yyDollar[3].valTuple)
}
- case 336:
+ case 333:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1794
+ //line sql.y:1779
{
yyVAL.valTuple = yyDollar[1].valTuple
}
- case 337:
+ case 334:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:1798
+ //line sql.y:1783
{
yyVAL.valTuple = ValTuple{}
}
- case 338:
+ case 335:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:1804
+ //line sql.y:1789
{
yyVAL.valTuple = ValTuple(yyDollar[2].exprs)
}
- case 339:
+ case 336:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1810
+ //line sql.y:1795
{
if len(yyDollar[1].valTuple) == 1 {
yyVAL.expr = &ParenExpr{yyDollar[1].valTuple[0]}
@@ -3575,144 +3554,150 @@ yydefault:
yyVAL.expr = yyDollar[1].valTuple
}
}
- case 340:
+ case 337:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1820
+ //line sql.y:1805
{
yyVAL.updateExprs = UpdateExprs{yyDollar[1].updateExpr}
}
- case 341:
+ case 338:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:1824
+ //line sql.y:1809
{
yyVAL.updateExprs = append(yyDollar[1].updateExprs, yyDollar[3].updateExpr)
}
- case 342:
+ case 339:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:1830
+ //line sql.y:1815
{
yyVAL.updateExpr = &UpdateExpr{Name: yyDollar[1].colName, Expr: yyDollar[3].expr}
}
- case 343:
+ case 340:
yyDollar = yyS[yypt-0 : yypt+1]
- //line sql.y:1835
+ //line sql.y:1820
{
yyVAL.byt = 0
}
- case 344:
+ case 341:
yyDollar = yyS[yypt-2 : yypt+1]
- //line sql.y:1837
+ //line sql.y:1822
{
yyVAL.byt = 1
}
- case 345:
+ case 342:
yyDollar = yyS[yypt-0 : yypt+1]
- //line sql.y:1840
+ //line sql.y:1825
{
yyVAL.empty = struct{}{}
}
- case 346:
+ case 343:
yyDollar = yyS[yypt-3 : yypt+1]
- //line sql.y:1842
+ //line sql.y:1827
{
yyVAL.empty = struct{}{}
}
- case 347:
+ case 344:
yyDollar = yyS[yypt-0 : yypt+1]
- //line sql.y:1845
+ //line sql.y:1830
{
yyVAL.str = ""
}
- case 348:
+ case 345:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1847
+ //line sql.y:1832
{
yyVAL.str = IgnoreStr
}
- case 349:
+ case 346:
yyDollar = yyS[yypt-0 : yypt+1]
- //line sql.y:1850
+ //line sql.y:1835
{
yyVAL.empty = struct{}{}
}
- case 350:
+ case 347:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1852
+ //line sql.y:1837
{
yyVAL.empty = struct{}{}
}
- case 351:
+ case 348:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1854
+ //line sql.y:1839
{
yyVAL.empty = struct{}{}
}
- case 352:
+ case 349:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1858
+ //line sql.y:1843
{
yyVAL.colIdent = NewColIdent(string(yyDollar[1].bytes))
}
- case 353:
+ case 350:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1862
+ //line sql.y:1847
{
yyVAL.colIdent = NewColIdent(string(yyDollar[1].bytes))
}
- case 355:
+ case 352:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1869
+ //line sql.y:1854
{
yyVAL.colIdent = NewColIdent(string(yyDollar[1].bytes))
}
- case 356:
+ case 353:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1875
+ //line sql.y:1860
{
yyVAL.tableIdent = NewTableIdent(string(yyDollar[1].bytes))
}
- case 357:
+ case 354:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1879
+ //line sql.y:1864
{
yyVAL.tableIdent = NewTableIdent(string(yyDollar[1].bytes))
}
- case 359:
+ case 356:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:1886
+ //line sql.y:1871
{
yyVAL.tableIdent = NewTableIdent(string(yyDollar[1].bytes))
}
- case 467:
+ case 464:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:2019
+ //line sql.y:2004
{
if incNesting(yylex) {
yylex.Error("max nesting level reached")
return 1
}
}
- case 468:
+ case 465:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:2028
+ //line sql.y:2013
{
decNesting(yylex)
}
- case 469:
+ case 466:
+ yyDollar = yyS[yypt-0 : yypt+1]
+ //line sql.y:2018
+ {
+ forceEOF(yylex)
+ }
+ case 467:
yyDollar = yyS[yypt-0 : yypt+1]
- //line sql.y:2033
+ //line sql.y:2023
{
forceEOF(yylex)
}
- case 470:
+ case 468:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:2037
+ //line sql.y:2027
{
forceEOF(yylex)
}
- case 471:
+ case 469:
yyDollar = yyS[yypt-1 : yypt+1]
- //line sql.y:2041
+ //line sql.y:2031
{
forceEOF(yylex)
}
diff --git a/vendor/github.com/CovenantSQL/sqlparser/sql.y b/vendor/github.com/CovenantSQL/sqlparser/sql.y
index 6e70d8a16..37d4b0fe8 100644
--- a/vendor/github.com/CovenantSQL/sqlparser/sql.y
+++ b/vendor/github.com/CovenantSQL/sqlparser/sql.y
@@ -110,7 +110,7 @@ func forceEOF(yylex interface{}) {
%left JOIN LEFT RIGHT INNER OUTER CROSS NATURAL
%left ON USING
%token '(' ',' ')'
-%token ID HEX STRING INTEGRAL FLOAT HEXNUM VALUE_ARG LIST_ARG COMMENT
+%token ID HEX STRING INTEGRAL FLOAT HEXNUM VALUE_ARG POS_ARG LIST_ARG COMMENT
%token NULL TRUE FALSE
%token FULL COLUMNS
@@ -136,7 +136,7 @@ func forceEOF(yylex interface{}) {
// DDL Tokens
%token CREATE ALTER DROP RENAME ADD
%token TABLE INDEX TO IGNORE IF UNIQUE PRIMARY COLUMN CONSTRAINT FOREIGN
-%token SHOW DESCRIBE DATE ESCAPE
+%token SHOW DESCRIBE DATE ESCAPE EXPLAIN
// Type Tokens
%token TINYINT SMALLINT MEDIUMINT INT INTEGER BIGINT INTNUM
@@ -156,7 +156,6 @@ func forceEOF(yylex interface{}) {
%token CURRENT_TIMESTAMP CURRENT_DATE CURRENT_TIME
%token REPLACE
%token CAST
-%token SUBSTR
%token GROUP_CONCAT SEPARATOR
// MySQL reserved words that are unused by this grammar will map to this token.
@@ -208,7 +207,7 @@ func forceEOF(yylex interface{}) {
%type ins_column_list column_list
%type update_list
%type update_expression
-%type ignore_opt default_opt
+%type ignore_opt
%type exists_opt
%type not_exists_opt constraint_opt
%type reserved_keyword non_reserved_keyword
@@ -845,6 +844,10 @@ other_statement:
{
$$ = &Show{Type: "table", OnTable: $2}
}
+| EXPLAIN force_eof
+ {
+ $$ = &Explain{}
+ }
comment_opt:
{
@@ -1134,20 +1137,6 @@ expression:
{
$$ = $1
}
-| DEFAULT default_opt
- {
- $$ = &Default{ColName: $2}
- }
-
-default_opt:
- /* empty */
- {
- $$ = ""
- }
-| openb ID closeb
- {
- $$ = string($2)
- }
boolean_value:
TRUE
@@ -1435,14 +1424,6 @@ function_call_keyword:
{
$$ = &ConvertExpr{Expr: $3, Type: $5}
}
-| SUBSTR openb column_name ',' value_expression closeb
- {
- $$ = &SubstrExpr{Name: $3, From: $5, To: nil}
- }
-| SUBSTR openb column_name ',' value_expression ',' value_expression closeb
- {
- $$ = &SubstrExpr{Name: $3, From: $5, To: $7}
- }
| GROUP_CONCAT openb distinct_opt select_expression_list order_by_opt separator_opt closeb
{
$$ = &GroupConcatExpr{Distinct: $3, Exprs: $4, OrderBy: $5, Separator: $6}
@@ -1648,6 +1629,10 @@ value:
{
$$ = NewValArg($1)
}
+| POS_ARG
+ {
+ $$ = NewPosArg($1)
+ }
| NULL
{
$$ = &NullVal{}
@@ -1910,7 +1895,6 @@ reserved_keyword:
| CURRENT_DATE
| CURRENT_TIME
| CURRENT_TIMESTAMP
-| SUBSTR
| DEFAULT
| DELETE
| DESC
@@ -1968,6 +1952,7 @@ reserved_keyword:
| VALUES
| WHEN
| WHERE
+| EXPLAIN
/*
These are non-reserved Vitess, because they don't cause conflicts in the grammar.
@@ -2029,6 +2014,11 @@ closeb:
decNesting(yylex)
}
+force_eof:
+ {
+ forceEOF(yylex)
+ }
+
ddl_force_eof:
{
forceEOF(yylex)
diff --git a/vendor/github.com/CovenantSQL/sqlparser/token.go b/vendor/github.com/CovenantSQL/sqlparser/token.go
index 74ed904e6..36b556569 100644
--- a/vendor/github.com/CovenantSQL/sqlparser/token.go
+++ b/vendor/github.com/CovenantSQL/sqlparser/token.go
@@ -34,20 +34,21 @@ const (
// Tokenizer is the struct used to generate SQL
// tokens for the parser.
type Tokenizer struct {
- InStream io.Reader
- AllowComments bool
- AllowBackSlashEscape bool
- ForceEOF bool
- lastChar uint16
- Position int
- lastToken []byte
- LastError error
- posVarIndex int
- ParseTree Statement
- partialDDL *DDL
- nesting int
- multi bool
- specialComment *Tokenizer
+ InStream io.Reader
+ AllowComments bool
+ AllowBackSlashEscape bool
+ SeparatePositionalArgs bool
+ ForceEOF bool
+ lastChar uint16
+ Position int
+ lastToken []byte
+ LastError error
+ posVarIndex int
+ ParseTree Statement
+ partialDDL *DDL
+ nesting int
+ multi bool
+ specialComment *Tokenizer
buf []byte
bufPos int
@@ -112,7 +113,6 @@ var keywords = map[string]int{
"condition": UNUSED,
"constraint": CONSTRAINT,
"continue": UNUSED,
- "substr": SUBSTR,
"create": CREATE,
"cross": CROSS,
"current_date": CURRENT_DATE,
@@ -304,6 +304,7 @@ var keywords = map[string]int{
"year": YEAR,
"year_month": UNUSED,
"zerofill": ZEROFILL,
+ "explain": EXPLAIN,
}
// keywordStrings contains the reverse mapping of token to keyword strings
@@ -426,6 +427,9 @@ func (tkn *Tokenizer) Scan() (int, []byte) {
tkn.posVarIndex++
buf := new(bytes2.Buffer)
fmt.Fprintf(buf, ":v%d", tkn.posVarIndex)
+ if tkn.SeparatePositionalArgs {
+ return POS_ARG, buf.Bytes()
+ }
return VALUE_ARG, buf.Bytes()
case '.':
if isDigit(tkn.lastChar) {
From f7078ddcc8b38cf81df0db9606ddc19e7bfb9a7c Mon Sep 17 00:00:00 2001
From: Qi Xiao
Date: Mon, 3 Dec 2018 12:00:17 +0800
Subject: [PATCH 167/278] Update xenomint query filter to use ParseMulti
instead of custom parsing
---
xenomint/state.go | 49 +++++++++++++++++++----------------------------
1 file changed, 20 insertions(+), 29 deletions(-)
diff --git a/xenomint/state.go b/xenomint/state.go
index ee4906527..a3083947b 100644
--- a/xenomint/state.go
+++ b/xenomint/state.go
@@ -19,7 +19,6 @@ package xenomint
import (
"context"
"database/sql"
- "io"
"strings"
"sync"
"sync/atomic"
@@ -113,42 +112,34 @@ func (s *State) Close(commit bool) (err error) {
func convertQueryAndBuildArgs(pattern string, args []types.NamedArg) (containsDDL bool, p string, ifs []interface{}, err error) {
var (
tokenizer = sqlparser.NewStringTokenizer(pattern)
- stmt sqlparser.Statement
- lastPos int
- query string
queryParts []string
+ statements []sqlparser.Statement
+ i int
+ origQuery string
+ query string
)
- for {
- stmt, err = sqlparser.ParseNext(tokenizer)
-
- if err != nil && err != io.EOF {
- return
- }
-
- if err == io.EOF {
- err = nil
- break
- }
-
- query = pattern[lastPos : tokenizer.Position-1]
- lastPos = tokenizer.Position + 1
+ if queryParts, statements, err = sqlparser.ParseMultiple(tokenizer); err != nil {
+ err = errors.Wrap(err, "parse sql failed")
+ return
+ }
- // translate show statement
- if showStmt, ok := stmt.(*sqlparser.Show); ok {
- origQuery := query
+ for i = range queryParts {
+ switch stmt := statements[i].(type) {
+ case *sqlparser.Show:
+ origQuery = queryParts[i]
- switch showStmt.Type {
+ switch stmt.Type {
case "table":
- if showStmt.ShowCreate {
+ if stmt.ShowCreate {
query = "SELECT sql FROM sqlite_master WHERE type = \"table\" AND tbl_name = \"" +
- showStmt.OnTable.Name.String() + "\""
+ stmt.OnTable.Name.String() + "\""
} else {
- query = "PRAGMA table_info(" + showStmt.OnTable.Name.String() + ")"
+ query = "PRAGMA table_info(" + stmt.OnTable.Name.String() + ")"
}
case "index":
query = "SELECT name FROM sqlite_master WHERE type = \"index\" AND tbl_name = \"" +
- showStmt.OnTable.Name.String() + "\""
+ stmt.OnTable.Name.String() + "\""
case "tables":
query = "SELECT name FROM sqlite_master WHERE type = \"table\""
}
@@ -157,11 +148,11 @@ func convertQueryAndBuildArgs(pattern string, args []types.NamedArg) (containsDD
"from": origQuery,
"to": query,
}).Debug("query translated")
- } else if _, ok := stmt.(*sqlparser.DDL); ok {
+
+ queryParts[i] = query
+ case *sqlparser.DDL:
containsDDL = true
}
-
- queryParts = append(queryParts, query)
}
p = strings.Join(queryParts, "; ")
From 68dadf05a7491bba5fc5f43ebb499f1b09fb9326 Mon Sep 17 00:00:00 2001
From: Qi Xiao
Date: Tue, 4 Dec 2018 23:50:41 +0800
Subject: [PATCH 168/278] Ban all stateful query parts in sql statement
---
xenomint/errors.go | 2 +
xenomint/state.go | 43 +++++++++++++++++
xenomint/state_test.go | 106 +++++++++++++++++++++++++++++++++++++++++
3 files changed, 151 insertions(+)
diff --git a/xenomint/errors.go b/xenomint/errors.go
index 725b140cb..1929577e6 100644
--- a/xenomint/errors.go
+++ b/xenomint/errors.go
@@ -35,4 +35,6 @@ var (
ErrLocalBehindRemote = errors.New("local state is behind the remote")
// ErrMuxServiceNotFound indicates that the multiplexing service endpoint is not found.
ErrMuxServiceNotFound = errors.New("mux service not found")
+ // ErrStatefulQueryParts indicates query contains stateful query parts.
+ ErrStatefulQueryParts = errors.New("query contains stateful query parts")
)
diff --git a/xenomint/state.go b/xenomint/state.go
index a3083947b..f92718040 100644
--- a/xenomint/state.go
+++ b/xenomint/state.go
@@ -17,6 +17,7 @@
package xenomint
import (
+ "bytes"
"context"
"database/sql"
"strings"
@@ -125,6 +126,8 @@ func convertQueryAndBuildArgs(pattern string, args []types.NamedArg) (containsDD
}
for i = range queryParts {
+ walkNodes := []sqlparser.SQLNode{statements[i]}
+
switch stmt := statements[i].(type) {
case *sqlparser.Show:
origQuery = queryParts[i]
@@ -152,6 +155,46 @@ func convertQueryAndBuildArgs(pattern string, args []types.NamedArg) (containsDD
queryParts[i] = query
case *sqlparser.DDL:
containsDDL = true
+ if stmt.TableSpec != nil {
+ // walk table default values for invalid stateful expressions
+ for _, c := range stmt.TableSpec.Columns {
+ if c == nil || c.Type.Default == nil {
+ continue
+ }
+
+ walkNodes = append(walkNodes, c.Type.Default)
+ }
+ }
+ }
+
+ // scan query and test if there is any stateful query logic like time expression or random function
+ err = sqlparser.Walk(func(node sqlparser.SQLNode) (kontinue bool, err error) {
+ switch n := node.(type) {
+ case *sqlparser.SQLVal:
+ if n.Type == sqlparser.ValArg && bytes.EqualFold([]byte("CURRENT_TIMESTAMP"), n.Val) {
+ // current_timestamp literal in default expression
+ err = errors.Wrap(ErrStatefulQueryParts, "DEFAULT CURRENT_TIMESTAMP not supported")
+ return
+ }
+ case *sqlparser.TimeExpr:
+ tb := sqlparser.NewTrackedBuffer(nil)
+ err = errors.Wrapf(ErrStatefulQueryParts, "time expression %s not supported",
+ tb.WriteNode(n).String())
+ return
+ case *sqlparser.FuncExpr:
+ if n.Name.EqualString("random") {
+ // random function detected
+ tb := sqlparser.NewTrackedBuffer(nil)
+ err = errors.Wrapf(ErrStatefulQueryParts, "stateful function call %s not supported",
+ tb.WriteNode(n).String())
+ return
+ }
+ }
+ return true, nil
+ }, walkNodes...)
+ if err != nil {
+ err = errors.Wrapf(err, "parse sql failed")
+ return
}
}
diff --git a/xenomint/state_test.go b/xenomint/state_test.go
index bcd84a732..467ff89df 100644
--- a/xenomint/state_test.go
+++ b/xenomint/state_test.go
@@ -519,3 +519,109 @@ INSERT INTO t1 (k, v) VALUES (?, ?)`, concat(values[2:4])...),
})
})
}
+
+func TestConvertQueryAndBuildArgs(t *testing.T) {
+ Convey("Test query rewrite and sanitizer", t, func() {
+ var (
+ containsDDL bool
+ sanitizedQuery string
+ sanitizedArgs []interface{}
+ err error
+ )
+
+ // show tables query
+ containsDDL, sanitizedQuery, sanitizedArgs, err = convertQueryAndBuildArgs(
+ "SHOW TABLES", []types.NamedArg{})
+ So(containsDDL, ShouldBeFalse)
+ So(sanitizedQuery, ShouldContainSubstring, "sqlite_master")
+ So(sanitizedArgs, ShouldHaveLength, 0)
+ So(err, ShouldBeNil)
+
+ // show index query
+ containsDDL, sanitizedQuery, sanitizedArgs, err = convertQueryAndBuildArgs(
+ "SHOW INDEX FROM TABLE a", []types.NamedArg{})
+ So(containsDDL, ShouldBeFalse)
+ So(sanitizedQuery, ShouldContainSubstring, "sqlite_master")
+ So(sanitizedArgs, ShouldHaveLength, 0)
+ So(err, ShouldBeNil)
+
+ // show create table query
+ containsDDL, sanitizedQuery, sanitizedArgs, err = convertQueryAndBuildArgs(
+ "SHOW CREATE TABLE a", []types.NamedArg{})
+ So(containsDDL, ShouldBeFalse)
+ So(sanitizedQuery, ShouldContainSubstring, "sqlite_master")
+ So(sanitizedArgs, ShouldHaveLength, 0)
+ So(err, ShouldBeNil)
+
+ // desc table query
+ containsDDL, sanitizedQuery, sanitizedArgs, err = convertQueryAndBuildArgs(
+ "DESC a", []types.NamedArg{})
+ So(containsDDL, ShouldBeFalse)
+ So(sanitizedQuery, ShouldContainSubstring, "table_info")
+ So(sanitizedArgs, ShouldHaveLength, 0)
+ So(err, ShouldBeNil)
+
+ // contains ddl query
+ ddlQuery := "CREATE TABLE test (test int)"
+ containsDDL, sanitizedQuery, sanitizedArgs, err = convertQueryAndBuildArgs(
+ ddlQuery, []types.NamedArg{})
+ So(containsDDL, ShouldBeTrue)
+ So(sanitizedQuery, ShouldEqual, ddlQuery)
+ So(sanitizedArgs, ShouldHaveLength, 0)
+ So(err, ShouldBeNil)
+
+ // test invalid query
+ containsDDL, sanitizedQuery, sanitizedArgs, err = convertQueryAndBuildArgs(
+ "CREATE 1", []types.NamedArg{})
+ So(err, ShouldNotBeNil)
+
+ // contains stateful query parts, create table with default current_timestamp
+ ddlQuery = "CREATE TABLE test (test datetime default current_timestamp)"
+ containsDDL, sanitizedQuery, sanitizedArgs, err = convertQueryAndBuildArgs(
+ ddlQuery, []types.NamedArg{})
+ So(err, ShouldNotBeNil)
+ So(errors.Cause(err), ShouldEqual, ErrStatefulQueryParts)
+
+ // contains stateful query parts, using time expression
+ containsDDL, sanitizedQuery, sanitizedArgs, err = convertQueryAndBuildArgs(
+ "SELECT current_timestamp", []types.NamedArg{})
+ So(err, ShouldNotBeNil)
+ So(errors.Cause(err), ShouldEqual, ErrStatefulQueryParts)
+
+ containsDDL, sanitizedQuery, sanitizedArgs, err = convertQueryAndBuildArgs(
+ "SELECT current_date", []types.NamedArg{})
+ So(err, ShouldNotBeNil)
+ So(errors.Cause(err), ShouldEqual, ErrStatefulQueryParts)
+
+ containsDDL, sanitizedQuery, sanitizedArgs, err = convertQueryAndBuildArgs(
+ "SELECT current_time", []types.NamedArg{})
+ So(err, ShouldNotBeNil)
+ So(errors.Cause(err), ShouldEqual, ErrStatefulQueryParts)
+
+ // contains stateful query parts, using random function
+ containsDDL, sanitizedQuery, sanitizedArgs, err = convertQueryAndBuildArgs(
+ "SELECT random()", []types.NamedArg{})
+ So(err, ShouldNotBeNil)
+ So(errors.Cause(err), ShouldEqual, ErrStatefulQueryParts)
+
+ // counterpart to prove successful parsing of normal query
+ containsDDL, sanitizedQuery, sanitizedArgs, err = convertQueryAndBuildArgs(
+ "SELECT 1; SELECT func(); SELECT * FROM a", []types.NamedArg{})
+ So(err, ShouldBeNil)
+
+ // counterpart with args
+ containsDDL, sanitizedQuery, sanitizedArgs, err = convertQueryAndBuildArgs(
+ "SELECT ?", []types.NamedArg{{Value: "1"}})
+ So(err, ShouldBeNil)
+ So(sanitizedArgs, ShouldHaveLength, 1)
+
+ // counterpart with valid default value of column definition
+ ddlQuery = "CREATE TABLE test (test int default 1)"
+ containsDDL, sanitizedQuery, sanitizedArgs, err = convertQueryAndBuildArgs(
+ ddlQuery, []types.NamedArg{})
+ So(containsDDL, ShouldBeTrue)
+ So(err, ShouldBeNil)
+ So(sanitizedQuery, ShouldEqual, ddlQuery)
+ So(sanitizedArgs, ShouldHaveLength, 0)
+ })
+}
From 9d3b1ad3d143f97d3523ac877ddaf17876a3d65c Mon Sep 17 00:00:00 2001
From: Qi Xiao
Date: Wed, 12 Dec 2018 09:48:39 +0800
Subject: [PATCH 169/278] Add more function sanitization
---
xenomint/query_sanitizer.go | 199 ++++++++++++++++++++++++++++++++++++
xenomint/state.go | 103 -------------------
2 files changed, 199 insertions(+), 103 deletions(-)
create mode 100644 xenomint/query_sanitizer.go
diff --git a/xenomint/query_sanitizer.go b/xenomint/query_sanitizer.go
new file mode 100644
index 000000000..eb6af09d1
--- /dev/null
+++ b/xenomint/query_sanitizer.go
@@ -0,0 +1,199 @@
+/*
+ * Copyright 2018 The CovenantSQL Authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package xenomint
+
+import (
+ "bytes"
+ "database/sql"
+ "strings"
+
+ "github.com/CovenantSQL/CovenantSQL/types"
+ "github.com/CovenantSQL/CovenantSQL/utils/log"
+ "github.com/CovenantSQL/sqlparser"
+ "github.com/pkg/errors"
+)
+
+var (
+ sanitizeFunctionMap = map[string]map[string]bool{
+ "load_extension": nil,
+ "unlikely": nil,
+ "likelihood": nil,
+ "likely": nil,
+ "affinity": nil,
+ "typeof": nil,
+ "random": nil,
+ "randomblob": nil,
+ "unknown": nil,
+ "date": {
+ "now": true,
+ "localtime": true,
+ },
+ "time": {
+ "now": true,
+ "localtime": true,
+ },
+ "datetime": {
+ "now": true,
+ "localtime": true,
+ },
+ "julianday": {
+ "now": true,
+ "localtime": true,
+ },
+ "strftime": {
+ "now": true,
+ "localtime": true,
+ },
+
+ // all sqlite functions is already ignored, including
+ //"sqlite_offset": nil,
+ //"sqlite_version": nil,
+ //"sqlite_source_id": nil,
+ //"sqlite_log": nil,
+ //"sqlite_compileoption_used": nil,
+ //"sqlite_rename_table": nil,
+ //"sqlite_rename_trigger": nil,
+ //"sqlite_rename_parent": nil,
+ //"sqlite_record": nil,
+ }
+)
+
+func convertQueryAndBuildArgs(pattern string, args []types.NamedArg) (containsDDL bool, p string, ifs []interface{}, err error) {
+ var (
+ tokenizer = sqlparser.NewStringTokenizer(pattern)
+ queryParts []string
+ statements []sqlparser.Statement
+ i int
+ origQuery string
+ query string
+ )
+
+ if queryParts, statements, err = sqlparser.ParseMultiple(tokenizer); err != nil {
+ err = errors.Wrap(err, "parse sql failed")
+ return
+ }
+
+ for i = range queryParts {
+ walkNodes := []sqlparser.SQLNode{statements[i]}
+
+ switch stmt := statements[i].(type) {
+ case *sqlparser.Show:
+ origQuery = queryParts[i]
+
+ switch stmt.Type {
+ case "table":
+ if stmt.ShowCreate {
+ query = "SELECT sql FROM sqlite_master WHERE type = \"table\" AND tbl_name = \"" +
+ stmt.OnTable.Name.String() + "\""
+ } else {
+ query = "PRAGMA table_info(" + stmt.OnTable.Name.String() + ")"
+ }
+ case "index":
+ query = "SELECT name FROM sqlite_master WHERE type = \"index\" AND tbl_name = \"" +
+ stmt.OnTable.Name.String() + "\""
+ case "tables":
+ query = "SELECT name FROM sqlite_master WHERE type = \"table\""
+ }
+
+ log.WithFields(log.Fields{
+ "from": origQuery,
+ "to": query,
+ }).Debug("query translated")
+
+ queryParts[i] = query
+ case *sqlparser.DDL:
+ containsDDL = true
+ if stmt.TableSpec != nil {
+ // walk table default values for invalid stateful expressions
+ for _, c := range stmt.TableSpec.Columns {
+ if c == nil || c.Type.Default == nil {
+ continue
+ }
+
+ walkNodes = append(walkNodes, c.Type.Default)
+ }
+ }
+ }
+
+ // scan query and test if there is any stateful query logic like time expression or random function
+ err = sqlparser.Walk(func(node sqlparser.SQLNode) (kontinue bool, err error) {
+ switch n := node.(type) {
+ case *sqlparser.SQLVal:
+ if n.Type == sqlparser.ValArg && bytes.EqualFold([]byte("CURRENT_TIMESTAMP"), n.Val) {
+ // current_timestamp literal in default expression
+ err = errors.Wrap(ErrStatefulQueryParts, "DEFAULT CURRENT_TIMESTAMP not supported")
+ return
+ }
+ case *sqlparser.TimeExpr:
+ tb := sqlparser.NewTrackedBuffer(nil)
+ err = errors.Wrapf(ErrStatefulQueryParts, "time expression %s not supported",
+ tb.WriteNode(n).String())
+ return
+ case *sqlparser.FuncExpr:
+ if strings.HasPrefix(n.Name.Lowered(), "sqlite") {
+ tb := sqlparser.NewTrackedBuffer(nil)
+ err = errors.Wrapf(ErrStatefulQueryParts, "function call %s not supported",
+ tb.WriteNode(n).String())
+ return
+ }
+ if sanitizeArgs, ok := sanitizeFunctionMap[n.Name.Lowered()]; ok {
+ // need to sanitize this function
+ tb := sqlparser.NewTrackedBuffer(nil)
+ sanitizeErr := errors.Wrapf(ErrStatefulQueryParts, "stateful function call %s not supported",
+ tb.WriteNode(n).String())
+
+ if sanitizeArgs == nil {
+ err = sanitizeErr
+ return
+ }
+
+ err = sqlparser.Walk(func(node sqlparser.SQLNode) (kontinue bool, walkErr error) {
+ if v, ok := node.(*sqlparser.SQLVal); ok {
+ if v.Type == sqlparser.StrVal {
+ argStr := strings.ToLower(string(v.Val))
+
+ if sanitizeArgs[argStr] {
+ walkErr = sanitizeErr
+ }
+ return
+ }
+ }
+ return true, nil
+ })
+
+ return
+ }
+ }
+ return true, nil
+ }, walkNodes...)
+ if err != nil {
+ err = errors.Wrapf(err, "parse sql failed")
+ return
+ }
+ }
+
+ p = strings.Join(queryParts, "; ")
+
+ ifs = make([]interface{}, len(args))
+ for i, v := range args {
+ ifs[i] = sql.NamedArg{
+ Name: v.Name,
+ Value: v.Value,
+ }
+ }
+ return
+}
diff --git a/xenomint/state.go b/xenomint/state.go
index f92718040..fe41483ac 100644
--- a/xenomint/state.go
+++ b/xenomint/state.go
@@ -17,10 +17,8 @@
package xenomint
import (
- "bytes"
"context"
"database/sql"
- "strings"
"sync"
"sync/atomic"
"time"
@@ -29,7 +27,6 @@ import (
"github.com/CovenantSQL/CovenantSQL/types"
"github.com/CovenantSQL/CovenantSQL/utils/log"
xi "github.com/CovenantSQL/CovenantSQL/xenomint/interfaces"
- "github.com/CovenantSQL/sqlparser"
"github.com/pkg/errors"
)
@@ -110,106 +107,6 @@ func (s *State) Close(commit bool) (err error) {
return
}
-func convertQueryAndBuildArgs(pattern string, args []types.NamedArg) (containsDDL bool, p string, ifs []interface{}, err error) {
- var (
- tokenizer = sqlparser.NewStringTokenizer(pattern)
- queryParts []string
- statements []sqlparser.Statement
- i int
- origQuery string
- query string
- )
-
- if queryParts, statements, err = sqlparser.ParseMultiple(tokenizer); err != nil {
- err = errors.Wrap(err, "parse sql failed")
- return
- }
-
- for i = range queryParts {
- walkNodes := []sqlparser.SQLNode{statements[i]}
-
- switch stmt := statements[i].(type) {
- case *sqlparser.Show:
- origQuery = queryParts[i]
-
- switch stmt.Type {
- case "table":
- if stmt.ShowCreate {
- query = "SELECT sql FROM sqlite_master WHERE type = \"table\" AND tbl_name = \"" +
- stmt.OnTable.Name.String() + "\""
- } else {
- query = "PRAGMA table_info(" + stmt.OnTable.Name.String() + ")"
- }
- case "index":
- query = "SELECT name FROM sqlite_master WHERE type = \"index\" AND tbl_name = \"" +
- stmt.OnTable.Name.String() + "\""
- case "tables":
- query = "SELECT name FROM sqlite_master WHERE type = \"table\""
- }
-
- log.WithFields(log.Fields{
- "from": origQuery,
- "to": query,
- }).Debug("query translated")
-
- queryParts[i] = query
- case *sqlparser.DDL:
- containsDDL = true
- if stmt.TableSpec != nil {
- // walk table default values for invalid stateful expressions
- for _, c := range stmt.TableSpec.Columns {
- if c == nil || c.Type.Default == nil {
- continue
- }
-
- walkNodes = append(walkNodes, c.Type.Default)
- }
- }
- }
-
- // scan query and test if there is any stateful query logic like time expression or random function
- err = sqlparser.Walk(func(node sqlparser.SQLNode) (kontinue bool, err error) {
- switch n := node.(type) {
- case *sqlparser.SQLVal:
- if n.Type == sqlparser.ValArg && bytes.EqualFold([]byte("CURRENT_TIMESTAMP"), n.Val) {
- // current_timestamp literal in default expression
- err = errors.Wrap(ErrStatefulQueryParts, "DEFAULT CURRENT_TIMESTAMP not supported")
- return
- }
- case *sqlparser.TimeExpr:
- tb := sqlparser.NewTrackedBuffer(nil)
- err = errors.Wrapf(ErrStatefulQueryParts, "time expression %s not supported",
- tb.WriteNode(n).String())
- return
- case *sqlparser.FuncExpr:
- if n.Name.EqualString("random") {
- // random function detected
- tb := sqlparser.NewTrackedBuffer(nil)
- err = errors.Wrapf(ErrStatefulQueryParts, "stateful function call %s not supported",
- tb.WriteNode(n).String())
- return
- }
- }
- return true, nil
- }, walkNodes...)
- if err != nil {
- err = errors.Wrapf(err, "parse sql failed")
- return
- }
- }
-
- p = strings.Join(queryParts, "; ")
-
- ifs = make([]interface{}, len(args))
- for i, v := range args {
- ifs[i] = sql.NamedArg{
- Name: v.Name,
- Value: v.Value,
- }
- }
- return
-}
-
func buildTypeNamesFromSQLColumnTypes(types []*sql.ColumnType) (names []string) {
names = make([]string, len(types))
for i, v := range types {
From b3b77a5f368b73b6ab3ea150f637133c0844bbca Mon Sep 17 00:00:00 2001
From: Qi Xiao
Date: Wed, 12 Dec 2018 16:43:26 +0800
Subject: [PATCH 170/278] Upgrade hash-upgrade command for xenomint version
sqlchain
---
cmd/hotfix/hash-upgrade/main.go | 70 +++++++++++++++++++++++++--------
1 file changed, 53 insertions(+), 17 deletions(-)
diff --git a/cmd/hotfix/hash-upgrade/main.go b/cmd/hotfix/hash-upgrade/main.go
index 7e4e89a93..044a8de7b 100644
--- a/cmd/hotfix/hash-upgrade/main.go
+++ b/cmd/hotfix/hash-upgrade/main.go
@@ -33,6 +33,7 @@ import (
"github.com/CovenantSQL/CovenantSQL/proto"
ct "github.com/CovenantSQL/CovenantSQL/sqlchain/otypes"
"github.com/CovenantSQL/CovenantSQL/storage"
+ "github.com/CovenantSQL/CovenantSQL/types"
"github.com/CovenantSQL/CovenantSQL/utils"
"github.com/CovenantSQL/CovenantSQL/utils/log"
wt "github.com/CovenantSQL/CovenantSQL/worker/otypes"
@@ -98,22 +99,25 @@ type OldPeers struct {
Signature *asymmetric.Signature
}
-// PlainOldServiceInstance defines the plain old service instance type before marshaller updates.
-type PlainOldServiceInstance struct {
+// ServiceInstanceV0 defines the version 0 service instance type before marshaller updates.
+type ServiceInstanceV0 struct {
DatabaseID proto.DatabaseID
Peers *OldPeers
ResourceMeta wt.ResourceMeta
GenesisBlock *OldBlock
}
-// OldServiceInstance defines the old service instance type before marshaller updates.
-type OldServiceInstance struct {
+// ServiceInstanceV1 defines the version 1 service instance type before marshaller updates.
+type ServiceInstanceV1 struct {
DatabaseID proto.DatabaseID
Peers *OldPeers
ResourceMeta wt.ResourceMeta
GenesisBlock *ct.Block
}
+// ServiceInstanceV2 defines the version 2 service instance type before marshaller updates.
+type ServiceInstanceV2 wt.ServiceInstance
+
func convertPeers(oldPeers *OldPeers) (newPeers *proto.Peers) {
if oldPeers == nil {
return
@@ -129,6 +133,25 @@ func convertPeers(oldPeers *OldPeers) (newPeers *proto.Peers) {
return
}
+func convertResourceMeta(oldMeta wt.ResourceMeta) (newMeta types.ResourceMeta) {
+ newMeta.Node = oldMeta.Node
+ newMeta.Space = oldMeta.Space
+ newMeta.Memory = oldMeta.Memory
+ newMeta.LoadAvgPerCPU = oldMeta.LoadAvgPerCPU
+ newMeta.EncryptionKey = oldMeta.EncryptionKey
+ return
+}
+
+func convertBlockHeader(oldHeader ct.Header) (newHeader types.Header) {
+ newHeader.Version = oldHeader.Version
+ newHeader.Producer = oldHeader.Producer
+ newHeader.GenesisHash = oldHeader.GenesisHash
+ newHeader.ParentHash = oldHeader.ParentHash
+ newHeader.MerkleRoot = oldHeader.MerkleRoot
+ newHeader.Timestamp = oldHeader.Timestamp
+ return
+}
+
func main() {
flag.Parse()
@@ -174,15 +197,15 @@ func main() {
var testDecode interface{}
// copy instance to new type
- var newInstance wt.ServiceInstance
+ var newInstance types.ServiceInstance
if err := utils.DecodeMsgPackPlain(rawInstance, &testDecode); err != nil {
log.WithError(err).Fatal("test decode failed")
} else {
// detect if the genesis block is in old version
if strings.Contains(fmt.Sprintf("%#v", testDecode), "\"GenesisBlock\":[]uint8") {
- log.Info("detected plain old version (without msgpack tag and use custom serializer)")
- var instance PlainOldServiceInstance
+ log.Info("detected version 0 (without msgpack tag and use custom serializer)")
+ var instance ServiceInstanceV0
if err := utils.DecodeMsgPackPlain(rawInstance, &instance); err != nil {
log.WithError(err).Fatal("decode msgpack failed")
@@ -191,14 +214,12 @@ func main() {
newInstance.DatabaseID = instance.DatabaseID
newInstance.Peers = convertPeers(instance.Peers)
- newInstance.ResourceMeta = instance.ResourceMeta
- newInstance.GenesisBlock = &ct.Block{
- SignedHeader: instance.GenesisBlock.SignedHeader,
- Queries: instance.GenesisBlock.Queries,
- }
+ newInstance.ResourceMeta = convertResourceMeta(instance.ResourceMeta)
+ newInstance.GenesisBlock = &types.Block{}
+ newInstance.GenesisBlock.SignedHeader.Header = convertBlockHeader(instance.GenesisBlock.SignedHeader.Header)
} else if strings.Contains(fmt.Sprintf("%#v", testDecode), "\"PubKey\"") {
- log.Info("detected old version (old kayak implementation [called as kaar])")
- var instance OldServiceInstance
+ log.Info("detected version 1 (old kayak implementation [called as kaar])")
+ var instance ServiceInstanceV1
if err := utils.DecodeMsgPack(rawInstance, &instance); err != nil {
log.WithError(err).Fatal("decode msgpack failed")
@@ -207,10 +228,25 @@ func main() {
newInstance.DatabaseID = instance.DatabaseID
newInstance.Peers = convertPeers(instance.Peers)
- newInstance.ResourceMeta = instance.ResourceMeta
- newInstance.GenesisBlock = instance.GenesisBlock
+ newInstance.ResourceMeta = convertResourceMeta(instance.ResourceMeta)
+ newInstance.GenesisBlock = &types.Block{}
+ newInstance.GenesisBlock.SignedHeader.Header = convertBlockHeader(instance.GenesisBlock.SignedHeader.Header)
+ } else if !strings.Contains(fmt.Sprintf("%#v", testDecode), "\"HSV\"") {
+ log.Info("detected version 2 (old block format without HSV)")
+ var instance ServiceInstanceV2
+
+ if err := utils.DecodeMsgPack(rawInstance, &instance); err != nil {
+ log.WithError(err).Fatal("decode msgpack failed")
+ return
+ }
+
+ newInstance.DatabaseID = instance.DatabaseID
+ newInstance.Peers = instance.Peers
+ newInstance.ResourceMeta = convertResourceMeta(instance.ResourceMeta)
+ newInstance.GenesisBlock = &types.Block{}
+ newInstance.GenesisBlock.SignedHeader.Header = convertBlockHeader(instance.GenesisBlock.SignedHeader.Header)
} else {
- log.Info("detected new version, need re-signature")
+ log.Info("detected latest version, need re-signature")
if err := utils.DecodeMsgPack(rawInstance, &newInstance); err != nil {
log.WithError(err).Fatal("decode msgpack failed")
From a7267bc771f95f5e04bf36da79797a1d384fc02d Mon Sep 17 00:00:00 2001
From: Qi Xiao
Date: Wed, 12 Dec 2018 16:44:54 +0800
Subject: [PATCH 171/278] Reduce leveldb page size
---
sqlchain/chain.go | 1 -
1 file changed, 1 deletion(-)
diff --git a/sqlchain/chain.go b/sqlchain/chain.go
index 9be8553d0..b60d00372 100644
--- a/sqlchain/chain.go
+++ b/sqlchain/chain.go
@@ -62,7 +62,6 @@ var (
)
func init() {
- leveldbConf.BlockSize = 4 * 1024 * 1024
leveldbConf.Compression = opt.SnappyCompression
}
From 6ab887aaa40edf642e381ffdcb3d3734b5c8ff89 Mon Sep 17 00:00:00 2001
From: Qi Xiao
Date: Tue, 25 Dec 2018 17:33:51 +0800
Subject: [PATCH 172/278] Prevent sqlite internal table from showing to users
---
xenomint/query_sanitizer.go | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/xenomint/query_sanitizer.go b/xenomint/query_sanitizer.go
index eb6af09d1..9af881125 100644
--- a/xenomint/query_sanitizer.go
+++ b/xenomint/query_sanitizer.go
@@ -98,15 +98,15 @@ func convertQueryAndBuildArgs(pattern string, args []types.NamedArg) (containsDD
case "table":
if stmt.ShowCreate {
query = "SELECT sql FROM sqlite_master WHERE type = \"table\" AND tbl_name = \"" +
- stmt.OnTable.Name.String() + "\""
+ stmt.OnTable.Name.String() + "\" AND tbl_name NOT LIKE \"sqlite%\""
} else {
query = "PRAGMA table_info(" + stmt.OnTable.Name.String() + ")"
}
case "index":
query = "SELECT name FROM sqlite_master WHERE type = \"index\" AND tbl_name = \"" +
- stmt.OnTable.Name.String() + "\""
+ stmt.OnTable.Name.String() + "\" AND name NOT LIKE \"sqlite%\""
case "tables":
- query = "SELECT name FROM sqlite_master WHERE type = \"table\""
+ query = "SELECT name FROM sqlite_master WHERE type = \"table\" AND name NOT LIKE \"sqlite%\""
}
log.WithFields(log.Fields{
From 5a262ee3163e2f60304253c9e75c86a8667da035 Mon Sep 17 00:00:00 2001
From: Qi Xiao
Date: Tue, 25 Dec 2018 19:06:14 +0800
Subject: [PATCH 173/278] Support query with bind parameters
---
cmd/cql-adapter/api/query.go | 58 +++++++------
cmd/cql-adapter/api/utils.go | 110 ++++++++++++++++++++++---
cmd/cql-adapter/storage/covenantsql.go | 8 +-
cmd/cql-adapter/storage/sqlite3.go | 8 +-
cmd/cql-adapter/storage/storage.go | 4 +-
5 files changed, 142 insertions(+), 46 deletions(-)
diff --git a/cmd/cql-adapter/api/query.go b/cmd/cql-adapter/api/query.go
index abf0d9fc1..da1e43544 100644
--- a/cmd/cql-adapter/api/query.go
+++ b/cmd/cql-adapter/api/query.go
@@ -37,25 +37,31 @@ type queryAPI struct{}
// Query defines read query for database.
func (a *queryAPI) Query(rw http.ResponseWriter, r *http.Request) {
- query := buildQuery(rw, r)
- if query == "" {
- return
- }
+ var (
+ qm *queryMap
+ err error
+ )
- dbID := getDatabaseID(rw, r)
- if dbID == "" {
+ if qm, err = parseForm(r); err != nil {
+ sendResponse(http.StatusBadRequest, false, err, nil, rw)
return
}
- log.WithField("db", dbID).WithField("query", query).Info("got query")
+ log.WithFields(log.Fields{
+ "db": qm.Database,
+ "query": qm.Query,
+ }).Info("got query")
assoc := r.FormValue("assoc")
- var columns []string
- var types []string
- var rows [][]interface{}
- var err error
- if columns, types, rows, err = config.GetConfig().StorageInstance.Query(dbID, query); err != nil {
+ var (
+ columns []string
+ types []string
+ rows [][]interface{}
+ )
+
+ if columns, types, rows, err = config.GetConfig().StorageInstance.Query(
+ qm.Database, qm.Query, qm.Args...); err != nil {
sendResponse(http.StatusInternalServerError, false, err, nil, rw)
return
}
@@ -126,22 +132,28 @@ func (a *queryAPI) Write(rw http.ResponseWriter, r *http.Request) {
return
}
- query := buildQuery(rw, r)
- if query == "" {
- return
- }
+ var (
+ qm *queryMap
+ err error
+ )
- dbID := getDatabaseID(rw, r)
- if dbID == "" {
+ if qm, err = parseForm(r); err != nil {
+ sendResponse(http.StatusBadRequest, false, err, nil, rw)
return
}
- log.WithField("db", dbID).WithField("query", query).Info("got exec")
+ log.WithFields(log.Fields{
+ "db": qm.Database,
+ "query": qm.Query,
+ }).Info("got exec")
+
+ var (
+ affectedRows int64
+ lastInsertID int64
+ )
- var err error
- var affectedRows int64
- var lastInsertID int64
- if affectedRows, lastInsertID, err = config.GetConfig().StorageInstance.Exec(dbID, query); err != nil {
+ if affectedRows, lastInsertID, err = config.GetConfig().StorageInstance.Exec(
+ qm.Database, qm.Query, qm.Args...); err != nil {
sendResponse(http.StatusInternalServerError, false, err, nil, rw)
return
}
diff --git a/cmd/cql-adapter/api/utils.go b/cmd/cql-adapter/api/utils.go
index 6a464aff0..f1278eaf1 100644
--- a/cmd/cql-adapter/api/utils.go
+++ b/cmd/cql-adapter/api/utils.go
@@ -17,48 +17,132 @@
package api
import (
+ "database/sql"
"encoding/json"
"fmt"
+ "mime"
"net/http"
"regexp"
+
+ "github.com/pkg/errors"
)
var (
dbIDRegex = regexp.MustCompile("^[a-zA-Z0-9_\\.]+$")
)
+type queryMap struct {
+ Database string `json:"database"`
+ Query string `json:"query"`
+ RawArgs interface{} `json:"args"`
+ Assoc bool `json:"assoc,omitempty"`
+ Args []interface{}
+}
+
func getDatabaseID(rw http.ResponseWriter, r *http.Request) string {
// try form
if database := r.FormValue("database"); database != "" {
- return validateDatabaseID(database, rw)
+ if err := isValidDatabaseID(database); err != nil {
+ sendResponse(http.StatusBadRequest, false, err, nil, rw)
+ return ""
+ }
}
// try header
if database := r.Header.Get("X-Database-ID"); database != "" {
- return validateDatabaseID(database, rw)
+ if err := isValidDatabaseID(database); err != nil {
+ sendResponse(http.StatusBadRequest, false, err, nil, rw)
+ return ""
+ }
}
- sendResponse(http.StatusBadRequest, false, "Missing database id", nil, rw)
+ sendResponse(http.StatusBadRequest, false, "missing database id", nil, rw)
return ""
}
-func validateDatabaseID(dbID string, rw http.ResponseWriter) string {
+func isValidDatabaseID(dbID string) error {
if !dbIDRegex.MatchString(dbID) {
- sendResponse(http.StatusBadRequest, false, "Invalid database id", nil, rw)
- return ""
+ return errors.New("invalid database id")
}
- return dbID
+ return nil
}
-func buildQuery(rw http.ResponseWriter, r *http.Request) string {
- // TODO(xq262144), support partial query and big query using application/octet-stream content-type
- if query := r.FormValue("query"); query != "" {
- return query
+func parseForm(r *http.Request) (qm *queryMap, err error) {
+ ct := r.Header.Get("Content-Type")
+ if ct != "" {
+ ct, _, _ = mime.ParseMediaType(ct)
}
+ if ct == "application/json" {
+ // json form
+ if r.Body == nil {
+ err = errors.New("missing request payload")
+ return
+ }
+ if err = json.NewDecoder(r.Body).Decode(&qm); err != nil {
+ // decode failed
+ err = errors.New("decode request json payload failed")
+ return
+ }
- sendResponse(http.StatusBadRequest, false, "Missing query parameter", nil, rw)
- return ""
+ // resolve args
+ if qm.RawArgs != nil {
+ switch v := qm.RawArgs.(type) {
+ case map[string]interface{}:
+ if len(v) > 0 {
+ qm.Args = make([]interface{}, 0, len(v))
+ for pk, pv := range v {
+ qm.Args = append(qm.Args, sql.Named(pk, pv))
+ }
+ }
+ case []interface{}:
+ qm.Args = v
+ default:
+ // scalar types
+ qm.Args = []interface{}{qm.RawArgs}
+ }
+ }
+ } else {
+ // normal form
+ // parse database id
+ qm = &queryMap{}
+
+ if qm.Database = r.FormValue("database"); qm.Database != "" {
+ if err = isValidDatabaseID(qm.Database); err != nil {
+ return
+ }
+ }
+ // parse query
+ qm.Query = r.FormValue("query")
+ // parse args
+ args := r.Form["args"]
+
+ if len(args) > 0 {
+ qm.Args = make([]interface{}, len(args))
+
+ for i, v := range args {
+ qm.Args[i] = v
+ }
+ }
+ }
+
+ // in case no database id
+ if qm.Database == "" {
+ if qm.Database = r.Header.Get("X-Database-ID"); qm.Database != "" {
+ if err = isValidDatabaseID(qm.Database); err != nil {
+ return
+ }
+ }
+ }
+ if qm.Database == "" {
+ err = errors.New("missing database id")
+ return
+ }
+ if qm.Query == "" {
+ err = errors.New("missing query parameter")
+ }
+
+ return
}
func sendResponse(code int, success bool, msg interface{}, data interface{}, rw http.ResponseWriter) {
diff --git a/cmd/cql-adapter/storage/covenantsql.go b/cmd/cql-adapter/storage/covenantsql.go
index 9750c891c..104a992d3 100644
--- a/cmd/cql-adapter/storage/covenantsql.go
+++ b/cmd/cql-adapter/storage/covenantsql.go
@@ -56,7 +56,7 @@ func (s *CovenantSQLStorage) Drop(dbID string) (err error) {
}
// Query implements the Storage abstraction interface.
-func (s *CovenantSQLStorage) Query(dbID string, query string) (columns []string, types []string, result [][]interface{}, err error) {
+func (s *CovenantSQLStorage) Query(dbID string, query string, args ...interface{}) (columns []string, types []string, result [][]interface{}, err error) {
var conn *sql.DB
if conn, err = s.getConn(dbID); err != nil {
return
@@ -64,7 +64,7 @@ func (s *CovenantSQLStorage) Query(dbID string, query string) (columns []string,
defer conn.Close()
var rows *sql.Rows
- if rows, err = conn.Query(query); err != nil {
+ if rows, err = conn.Query(query, args...); err != nil {
return
}
defer rows.Close()
@@ -92,7 +92,7 @@ func (s *CovenantSQLStorage) Query(dbID string, query string) (columns []string,
}
// Exec implements the Storage abstraction interface.
-func (s *CovenantSQLStorage) Exec(dbID string, query string) (affectedRows int64, lastInsertID int64, err error) {
+func (s *CovenantSQLStorage) Exec(dbID string, query string, args ...interface{}) (affectedRows int64, lastInsertID int64, err error) {
var conn *sql.DB
if conn, err = s.getConn(dbID); err != nil {
return
@@ -100,7 +100,7 @@ func (s *CovenantSQLStorage) Exec(dbID string, query string) (affectedRows int64
defer conn.Close()
var result sql.Result
- result, err = conn.Exec(query)
+ result, err = conn.Exec(query, args...)
if err == nil {
affectedRows, _ = result.RowsAffected()
diff --git a/cmd/cql-adapter/storage/sqlite3.go b/cmd/cql-adapter/storage/sqlite3.go
index d9be539d8..9eeaab39f 100644
--- a/cmd/cql-adapter/storage/sqlite3.go
+++ b/cmd/cql-adapter/storage/sqlite3.go
@@ -74,7 +74,7 @@ func (s *SQLite3Storage) Drop(dbID string) (err error) {
}
// Query implements the Storage abstraction interface.
-func (s *SQLite3Storage) Query(dbID string, query string) (columns []string, types []string, result [][]interface{}, err error) {
+func (s *SQLite3Storage) Query(dbID string, query string, args ...interface{}) (columns []string, types []string, result [][]interface{}, err error) {
var conn *sql.DB
if conn, err = s.getConn(dbID, true); err != nil {
return
@@ -88,7 +88,7 @@ func (s *SQLite3Storage) Query(dbID string, query string) (columns []string, typ
defer tx.Rollback()
var rows *sql.Rows
- if rows, err = tx.Query(query); err != nil {
+ if rows, err = tx.Query(query, args...); err != nil {
return
}
defer rows.Close()
@@ -116,7 +116,7 @@ func (s *SQLite3Storage) Query(dbID string, query string) (columns []string, typ
}
// Exec implements the Storage abstraction interface.
-func (s *SQLite3Storage) Exec(dbID string, query string) (affectedRows int64, lastInsertID int64, err error) {
+func (s *SQLite3Storage) Exec(dbID string, query string, args ...interface{}) (affectedRows int64, lastInsertID int64, err error) {
var conn *sql.DB
if conn, err = s.getConn(dbID, false); err != nil {
return
@@ -124,7 +124,7 @@ func (s *SQLite3Storage) Exec(dbID string, query string) (affectedRows int64, la
defer conn.Close()
var result sql.Result
- result, err = conn.Exec(query)
+ result, err = conn.Exec(query, args...)
affectedRows, _ = result.RowsAffected()
lastInsertID, _ = result.LastInsertId()
diff --git a/cmd/cql-adapter/storage/storage.go b/cmd/cql-adapter/storage/storage.go
index c35dbfbfa..91c4a8e7f 100644
--- a/cmd/cql-adapter/storage/storage.go
+++ b/cmd/cql-adapter/storage/storage.go
@@ -28,9 +28,9 @@ type Storage interface {
// Drop operation.
Drop(dbID string) (err error)
// Query for result.
- Query(dbID string, query string) (columns []string, types []string, rows [][]interface{}, err error)
+ Query(dbID string, query string, args ...interface{}) (columns []string, types []string, rows [][]interface{}, err error)
// Exec for update.
- Exec(dbID string, query string) (affectedRows int64, lastInsertID int64, err error)
+ Exec(dbID string, query string, args ...interface{}) (affectedRows int64, lastInsertID int64, err error)
}
// golang does trick convert, use rowScanner to return the original result type in sqlite3 driver
From 61f5d5fbb4c2a56e2b8c9b94dc8f9b32fd917aee Mon Sep 17 00:00:00 2001
From: Qi Xiao
Date: Wed, 26 Dec 2018 08:06:44 +0800
Subject: [PATCH 174/278] Support http and unprivileged mode of adapter
---
cmd/cql-adapter/api/admin.go | 6 +++
cmd/cql-adapter/api/query.go | 6 +++
cmd/cql-adapter/config/config.go | 88 ++++++++++++++++----------------
cmd/cql-adapter/server.go | 7 +--
4 files changed, 60 insertions(+), 47 deletions(-)
diff --git a/cmd/cql-adapter/api/admin.go b/cmd/cql-adapter/api/admin.go
index 6ee4c2fe6..55eb4ef79 100644
--- a/cmd/cql-adapter/api/admin.go
+++ b/cmd/cql-adapter/api/admin.go
@@ -38,6 +38,12 @@ func init() {
func adminPrivilegeChecker(next http.Handler) http.Handler {
return http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) {
+ if config.GetConfig().TLSConfig == nil || !config.GetConfig().VerifyCertificate {
+ // http mode or no certificate verification required
+ next.ServeHTTP(rw, r)
+ return
+ }
+
if r.TLS != nil && len(r.TLS.PeerCertificates) > 0 {
cert := r.TLS.PeerCertificates[0]
diff --git a/cmd/cql-adapter/api/query.go b/cmd/cql-adapter/api/query.go
index da1e43544..1142e4bf2 100644
--- a/cmd/cql-adapter/api/query.go
+++ b/cmd/cql-adapter/api/query.go
@@ -106,6 +106,12 @@ func (a *queryAPI) Query(rw http.ResponseWriter, r *http.Request) {
func (a *queryAPI) Write(rw http.ResponseWriter, r *http.Request) {
// check privilege
hasPrivilege := false
+
+ if config.GetConfig().TLSConfig == nil || !config.GetConfig().VerifyCertificate {
+ // http mode or no certificate verification required
+ hasPrivilege = true
+ }
+
if r.TLS != nil && len(r.TLS.PeerCertificates) > 0 {
cert := r.TLS.PeerCertificates[0]
diff --git a/cmd/cql-adapter/config/config.go b/cmd/cql-adapter/config/config.go
index f5a39ba62..a6c82771a 100644
--- a/cmd/cql-adapter/config/config.go
+++ b/cmd/cql-adapter/config/config.go
@@ -102,65 +102,65 @@ func LoadConfig(configPath string, password string) (config *Config, err error)
}
if config.CertificatePath == "" || config.PrivateKeyPath == "" {
- err = ErrRequireServerCertificate
- log.WithError(err).Error("invalid adapter config")
- return
- }
+ // http mode
+ log.Warningf("running in http mode")
+ } else {
+ // tls mode
+ // init tls config
+ config.TLSConfig = &tls.Config{}
+ certPath := filepath.Join(workingRoot, config.CertificatePath)
+ privateKeyPath := filepath.Join(workingRoot, config.PrivateKeyPath)
- // init tls config
- config.TLSConfig = &tls.Config{}
- certPath := filepath.Join(workingRoot, config.CertificatePath)
- privateKeyPath := filepath.Join(workingRoot, config.PrivateKeyPath)
+ if config.ServerCertificate, err = tls.LoadX509KeyPair(certPath, privateKeyPath); err != nil {
+ return
+ }
- if config.ServerCertificate, err = tls.LoadX509KeyPair(certPath, privateKeyPath); err != nil {
- return
- }
+ config.TLSConfig.Certificates = []tls.Certificate{config.ServerCertificate}
- config.TLSConfig.Certificates = []tls.Certificate{config.ServerCertificate}
+ if config.VerifyCertificate && config.ClientCAPath != "" {
+ clientCAPath := filepath.Join(workingRoot, config.ClientCAPath)
- if config.VerifyCertificate && config.ClientCAPath != "" {
- clientCAPath := filepath.Join(workingRoot, config.ClientCAPath)
+ // load client CA
+ caCertPool := x509.NewCertPool()
+ var caCert []byte
+ if caCert, err = ioutil.ReadFile(clientCAPath); err != nil {
+ return
+ }
+ caCertPool.AppendCertsFromPEM(caCert)
- // load client CA
- caCertPool := x509.NewCertPool()
- var caCert []byte
- if caCert, err = ioutil.ReadFile(clientCAPath); err != nil {
- return
- }
- caCertPool.AppendCertsFromPEM(caCert)
+ config.ClientCertPool = caCertPool
+ config.TLSConfig.ClientCAs = caCertPool
+ config.TLSConfig.ClientAuth = tls.RequireAndVerifyClientCert
- config.ClientCertPool = caCertPool
- config.TLSConfig.ClientCAs = caCertPool
- config.TLSConfig.ClientAuth = tls.RequireAndVerifyClientCert
+ // load admin certs
+ config.AdminCertificates = make([]*x509.Certificate, 0)
+ for _, certFile := range config.AdminCertFiles {
+ certFile = filepath.Join(workingRoot, certFile)
- // load admin certs
- config.AdminCertificates = make([]*x509.Certificate, 0)
- for _, certFile := range config.AdminCertFiles {
- certFile = filepath.Join(workingRoot, certFile)
+ var cert *x509.Certificate
+ if cert, err = loadCert(certFile); err != nil {
+ return
+ }
- var cert *x509.Certificate
- if cert, err = loadCert(certFile); err != nil {
- return
+ config.AdminCertificates = append(config.AdminCertificates, cert)
}
- config.AdminCertificates = append(config.AdminCertificates, cert)
- }
+ // load write certs
+ config.WriteCertificates = make([]*x509.Certificate, 0)
+ for _, certFile := range config.WriteCertFiles {
+ certFile = filepath.Join(workingRoot, certFile)
- // load write certs
- config.WriteCertificates = make([]*x509.Certificate, 0)
- for _, certFile := range config.WriteCertFiles {
- certFile = filepath.Join(workingRoot, certFile)
+ var cert *x509.Certificate
+ if cert, err = loadCert(certFile); err != nil {
+ return
+ }
- var cert *x509.Certificate
- if cert, err = loadCert(certFile); err != nil {
- return
+ config.WriteCertificates = append(config.WriteCertificates, cert)
}
- config.WriteCertificates = append(config.WriteCertificates, cert)
+ } else {
+ config.TLSConfig.ClientAuth = tls.NoClientCert
}
-
- } else {
- config.TLSConfig.ClientAuth = tls.NoClientCert
}
// load storage
diff --git a/cmd/cql-adapter/server.go b/cmd/cql-adapter/server.go
index e8cc0c204..3c880b69f 100644
--- a/cmd/cql-adapter/server.go
+++ b/cmd/cql-adapter/server.go
@@ -66,11 +66,12 @@ func (adapter *HTTPAdapter) Serve() (err error) {
return
}
- // start tls
- tlsListener := tls.NewListener(listener, cfg.TLSConfig)
+ if cfg.TLSConfig != nil {
+ listener = tls.NewListener(listener, cfg.TLSConfig)
+ }
// serve the connection
- go adapter.server.Serve(tlsListener)
+ go adapter.server.Serve(listener)
return
}
From fd02c3e1d19a1ec6141c34d6f4712969010850a8 Mon Sep 17 00:00:00 2001
From: Qi Xiao
Date: Wed, 26 Dec 2018 08:26:05 +0800
Subject: [PATCH 175/278] Query sanitization for DDL table name
---
xenomint/errors.go | 2 ++
xenomint/query_sanitizer.go | 12 ++++++++++++
xenomint/state_test.go | 35 +++++++++++++++++++++++++++++++++++
3 files changed, 49 insertions(+)
diff --git a/xenomint/errors.go b/xenomint/errors.go
index 1929577e6..9a8ec2dea 100644
--- a/xenomint/errors.go
+++ b/xenomint/errors.go
@@ -37,4 +37,6 @@ var (
ErrMuxServiceNotFound = errors.New("mux service not found")
// ErrStatefulQueryParts indicates query contains stateful query parts.
ErrStatefulQueryParts = errors.New("query contains stateful query parts")
+ // ErrInvalidTableName indicates query contains invalid table name in ddl statement.
+ ErrInvalidTableName = errors.New("invalid table name in ddl")
)
diff --git a/xenomint/query_sanitizer.go b/xenomint/query_sanitizer.go
index 9af881125..ff7580ccc 100644
--- a/xenomint/query_sanitizer.go
+++ b/xenomint/query_sanitizer.go
@@ -127,6 +127,18 @@ func convertQueryAndBuildArgs(pattern string, args []types.NamedArg) (containsDD
walkNodes = append(walkNodes, c.Type.Default)
}
}
+ // for new table
+ if strings.HasPrefix(strings.ToLower(stmt.NewName.Name.String()), "sqlite") {
+ // invalid table name
+ err = errors.Wrapf(ErrInvalidTableName, "%s", stmt.NewName.Name.String())
+ return
+ }
+ // for alter table/alter index
+ if strings.HasPrefix(strings.ToLower(stmt.Table.Name.String()), "sqlite") {
+ // invalid table name
+ err = errors.Wrapf(ErrInvalidTableName, "%s", stmt.NewName.Name.String())
+ return
+ }
}
// scan query and test if there is any stateful query logic like time expression or random function
diff --git a/xenomint/state_test.go b/xenomint/state_test.go
index 467ff89df..c6dec59bd 100644
--- a/xenomint/state_test.go
+++ b/xenomint/state_test.go
@@ -623,5 +623,40 @@ func TestConvertQueryAndBuildArgs(t *testing.T) {
So(err, ShouldBeNil)
So(sanitizedQuery, ShouldEqual, ddlQuery)
So(sanitizedArgs, ShouldHaveLength, 0)
+
+ // invalid table name to create
+ ddlQuery = "CREATE TABLE sqlite_test (test int)"
+ _, _, _, err = convertQueryAndBuildArgs(
+ ddlQuery, nil)
+ So(err, ShouldNotBeNil)
+ So(errors.Cause(err), ShouldEqual, ErrInvalidTableName)
+
+ // invalid table name to drop
+ ddlQuery = "DROP TABLE sqlite_test"
+ _, _, _, err = convertQueryAndBuildArgs(
+ ddlQuery, nil)
+ So(err, ShouldNotBeNil)
+ So(errors.Cause(err), ShouldEqual, ErrInvalidTableName)
+
+ // invalid table name to alter
+ ddlQuery = "ALTER TABLE sqlite_test RENAME TO normal"
+ _, _, _, err = convertQueryAndBuildArgs(
+ ddlQuery, nil)
+ So(err, ShouldNotBeNil)
+ So(errors.Cause(err), ShouldEqual, ErrInvalidTableName)
+
+ ddlQuery = "ALTER TABLE test RENAME TO sqlite_test"
+ _, _, _, err = convertQueryAndBuildArgs(
+ ddlQuery, nil)
+ So(err, ShouldNotBeNil)
+ So(errors.Cause(err), ShouldEqual, ErrInvalidTableName)
+
+ // valid counterpart of alter statement
+ ddlQuery = "ALTER TABLE test RENAME to test2"
+ containsDDL, sanitizedQuery, sanitizedArgs, err = convertQueryAndBuildArgs(
+ ddlQuery, nil)
+ So(err, ShouldBeNil)
+ So(containsDDL, ShouldBeTrue)
+ So(sanitizedQuery, ShouldEqual, ddlQuery)
})
}
From 966e490f9ea39a7f533c5840807af23f10ad6d7c Mon Sep 17 00:00:00 2001
From: leventeliu
Date: Wed, 26 Dec 2018 11:45:55 +0800
Subject: [PATCH 176/278] Rename fork method to newBranch
---
blockproducer/branch.go | 12 ++++++------
blockproducer/chain.go | 4 ++--
2 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/blockproducer/branch.go b/blockproducer/branch.go
index 40095755b..c774da871 100644
--- a/blockproducer/branch.go
+++ b/blockproducer/branch.go
@@ -36,22 +36,22 @@ type branch struct {
unpacked map[hash.Hash]pi.Transaction
}
-func fork(
- from, to *blockNode, initState *metaState, initPool map[hash.Hash]pi.Transaction,
+func newBranch(
+ baseNode, headNode *blockNode, baseState *metaState, basePool map[hash.Hash]pi.Transaction,
) (
br *branch, err error,
) {
var (
- list = to.fetchNodeList(from.count)
+ list = headNode.fetchNodeList(baseNode.count)
inst = &branch{
- head: to,
- preview: initState.makeCopy(),
+ head: headNode,
+ preview: baseState.makeCopy(),
packed: make(map[hash.Hash]pi.Transaction),
unpacked: make(map[hash.Hash]pi.Transaction),
}
)
// Copy pool
- for k, v := range initPool {
+ for k, v := range basePool {
inst.unpacked[k] = v
}
// Apply new blocks to view and pool
diff --git a/blockproducer/chain.go b/blockproducer/chain.go
index ac737d573..adeb1433d 100644
--- a/blockproducer/chain.go
+++ b/blockproducer/chain.go
@@ -177,7 +177,7 @@ func NewChainWithContext(ctx context.Context, cfg *Config) (c *Chain, err error)
"head_count": v.count,
}).Debug("checking head")
if v.hasAncestor(irre) {
- if br, ierr = fork(irre, v, immutable, txPool); ierr != nil {
+ if br, ierr = newBranch(irre, v, immutable, txPool); ierr != nil {
err = errors.Wrapf(ierr, "failed to rebuild branch with head %s", v.hash.Short(4))
return
}
@@ -854,7 +854,7 @@ func (c *Chain) applyBlock(bl *types.BPBlock) (err error) {
bl.SignedHeader.ParentHash, c.lastIrre.count,
); ok {
head = newBlockNode(height, bl, parent)
- if br, ierr = fork(c.lastIrre, head, c.immutable, c.txPool); ierr != nil {
+ if br, ierr = newBranch(c.lastIrre, head, c.immutable, c.txPool); ierr != nil {
err = errors.Wrapf(ierr, "failed to fork from %s", parent.hash.Short(4))
return
}
From c1d7f9c6c6e7c7d063c1efed9f77c64277501859 Mon Sep 17 00:00:00 2001
From: leventeliu
Date: Wed, 26 Dec 2018 12:43:28 +0800
Subject: [PATCH 177/278] Do not copy metaState when producing/applying block
in a branch
---
blockproducer/branch.go | 24 +++++++++++++++++-------
blockproducer/chain.go | 6 +++++-
blockproducer/chain_test.go | 8 ++++++--
3 files changed, 28 insertions(+), 10 deletions(-)
diff --git a/blockproducer/branch.go b/blockproducer/branch.go
index c774da871..8c511ccef 100644
--- a/blockproducer/branch.go
+++ b/blockproducer/branch.go
@@ -80,7 +80,16 @@ func newBranch(
return
}
-func (b *branch) makeCopy() *branch {
+// makeArena creates an arena branch from the receiver (origin) branch for tx/block applying test.
+// It copies head node and transaction pools, but references the read-only preview index
+// of the origin branch.
+//
+// This branch is typically used to attempt a block producing or applying base on the origin
+// branch.
+// Since it's sharing read-only index with the origin branch, result changes of the transactions
+// in the new block should be written to its dirty index first, and committed to the read-only
+// index later when the origin branch is being replaced by this new branch.
+func (b *branch) makeArena() *branch {
var (
p = make(map[hash.Hash]pi.Transaction)
u = make(map[hash.Hash]pi.Transaction)
@@ -92,8 +101,11 @@ func (b *branch) makeCopy() *branch {
u[k] = v
}
return &branch{
- head: b.head,
- preview: b.preview.makeCopy(),
+ head: b.head,
+ preview: &metaState{
+ dirty: newMetaIndex(),
+ readonly: b.preview.readonly,
+ },
packed: p,
unpacked: u,
}
@@ -113,7 +125,7 @@ func (b *branch) applyBlock(n *blockNode) (br *branch, err error) {
err = ErrParentNotMatch
return
}
- var cpy = b.makeCopy()
+ var cpy = b.makeArena()
for _, v := range n.block.Transactions {
var k = v.Hash()
// Check in tx pool
@@ -132,7 +144,6 @@ func (b *branch) applyBlock(n *blockNode) (br *branch, err error) {
return
}
}
- cpy.preview.commit()
cpy.head = n
br = cpy
return
@@ -161,7 +172,7 @@ func (b *branch) produceBlock(
br *branch, bl *types.BPBlock, err error,
) {
var (
- cpy = b.makeCopy()
+ cpy = b.makeArena()
txs = cpy.sortUnpackedTxs()
out = make([]pi.Transaction, 0, len(txs))
ierr error
@@ -175,7 +186,6 @@ func (b *branch) produceBlock(
cpy.packed[k] = v
out = append(out, v)
}
- cpy.preview.commit()
// Create new block and update head
var block = &types.BPBlock{
SignedHeader: types.BPSignedHeader{
diff --git a/blockproducer/chain.go b/blockproducer/chain.go
index adeb1433d..7e4fd81ee 100644
--- a/blockproducer/chain.go
+++ b/blockproducer/chain.go
@@ -752,6 +752,7 @@ func (c *Chain) replaceAndSwitchToBranch(
for i, b := range c.branches {
if i == originBrIdx {
// Replace origin branch with new branch
+ newBranch.preview.commit()
brs = append(brs, newBranch)
idx = len(brs) - 1
} else if b.head.hasAncestor(lastIrre) {
@@ -836,7 +837,10 @@ func (c *Chain) applyBlock(bl *types.BPBlock) (err error) {
if br.head.count <= c.headBranch.head.count {
return store(c.st,
[]storageProcedure{addBlock(height, bl)},
- func() { c.branches[i] = br },
+ func() {
+ br.preview.commit()
+ c.branches[i] = br
+ },
)
}
// Switch branch or grow current branch
diff --git a/blockproducer/chain_test.go b/blockproducer/chain_test.go
index e8f89f275..dd72d4d48 100644
--- a/blockproducer/chain_test.go
+++ b/blockproducer/chain_test.go
@@ -181,7 +181,7 @@ func TestChain(t *testing.T) {
So(err, ShouldBeNil)
// Fork from #0
- f0 = chain.headBranch.makeCopy()
+ f0 = chain.headBranch.makeArena()
err = chain.storeTx(t1)
So(err, ShouldBeNil)
@@ -200,7 +200,7 @@ func TestChain(t *testing.T) {
So(err, ShouldBeNil)
// Fork from #1
- f1 = chain.headBranch.makeCopy()
+ f1 = chain.headBranch.makeArena()
err = chain.storeTx(t2)
So(err, ShouldBeNil)
@@ -217,6 +217,7 @@ func TestChain(t *testing.T) {
f1, bl, err = f1.produceBlock(3, begin.Add(3*chain.period), addr2, priv2)
So(err, ShouldBeNil)
So(bl, ShouldNotBeNil)
+ f1.preview.commit()
err = chain.pushBlock(bl)
So(err, ShouldBeNil)
@@ -229,6 +230,7 @@ func TestChain(t *testing.T) {
i, begin.Add(time.Duration(i)*chain.period), addr2, priv2)
So(err, ShouldBeNil)
So(bl, ShouldNotBeNil)
+ f1.preview.commit()
err = chain.pushBlock(bl)
So(err, ShouldBeNil)
}
@@ -258,11 +260,13 @@ func TestChain(t *testing.T) {
f1, bl, err = f1.produceBlock(7, begin.Add(8*chain.period), addr2, priv2)
So(err, ShouldBeNil)
So(bl, ShouldNotBeNil)
+ f1.preview.commit()
err = chain.pushBlock(bl)
So(err, ShouldBeNil)
f1, bl, err = f1.produceBlock(8, begin.Add(9*chain.period), addr2, priv2)
So(err, ShouldBeNil)
So(bl, ShouldNotBeNil)
+ f1.preview.commit()
err = chain.pushBlock(bl)
So(err, ShouldBeNil)
From 9932429b8683f6427dee383a48c250b2481ce324 Mon Sep 17 00:00:00 2001
From: auxten
Date: Wed, 26 Dec 2018 14:15:37 +0800
Subject: [PATCH 178/278] Add more test cases for ETLS
---
crypto/etls/conn.go | 10 --
crypto/etls/conn_test.go | 198 ++++++++++++++++++++++++++++++++-------
2 files changed, 165 insertions(+), 43 deletions(-)
diff --git a/crypto/etls/conn.go b/crypto/etls/conn.go
index 150d85a3e..4b25bbb5d 100644
--- a/crypto/etls/conn.go
+++ b/crypto/etls/conn.go
@@ -64,11 +64,6 @@ func Dial(network, address string, cipher *Cipher) (c *CryptoConn, err error) {
return
}
-// RawRead is the raw net.Conn.Read
-func (c *CryptoConn) RawRead(b []byte) (n int, err error) {
- return c.Conn.Read(b)
-}
-
// Read iv and Encrypted data
func (c *CryptoConn) Read(b []byte) (n int, err error) {
if c.decStream == nil {
@@ -104,11 +99,6 @@ func (c *CryptoConn) Read(b []byte) (n int, err error) {
return
}
-// RawWrite is the raw net.Conn.Write
-func (c *CryptoConn) RawWrite(b []byte) (n int, err error) {
- return c.Conn.Read(b)
-}
-
// Write iv and Encrypted data
func (c *CryptoConn) Write(b []byte) (n int, err error) {
var iv []byte
diff --git a/crypto/etls/conn_test.go b/crypto/etls/conn_test.go
index 4778c12b8..ffa9b1010 100644
--- a/crypto/etls/conn_test.go
+++ b/crypto/etls/conn_test.go
@@ -20,12 +20,25 @@ import (
"net"
"net/rpc"
"strings"
+ "sync"
"testing"
+ "github.com/CovenantSQL/CovenantSQL/crypto/hash"
"github.com/CovenantSQL/CovenantSQL/utils/log"
. "github.com/smartystreets/goconvey/convey"
)
+const service = "127.0.0.1:28000"
+const serviceComplex = "127.0.0.1:28001"
+const contentLength = 9999
+const pass = "123"
+
+var simpleCipherHandler CipherHandler = func(conn net.Conn) (cryptoConn *CryptoConn, err error) {
+ cipher := NewCipher([]byte(pass))
+ cryptoConn = NewConn(conn, cipher, nil)
+ return
+}
+
type Foo bool
type Result struct {
@@ -34,19 +47,34 @@ type Result struct {
func (f *Foo) Bar(args *string, res *Result) error {
res.Data = len(*args)
- log.Printf("Received %q, its length is %d", *args, res.Data)
- //return fmt.Error("whoops, error happened")
+ log.Debugf("Received %q, its length is %d", *args, res.Data)
return nil
}
-const service = "127.0.0.1:28000"
-const contentLength = 9999
-const pass = "123"
+type FooComplex bool
-var simpleCipherHandler CipherHandler = func(conn net.Conn) (cryptoConn *CryptoConn, err error) {
- cipher := NewCipher([]byte(pass))
- cryptoConn = NewConn(conn, cipher, nil)
- return
+type QueryComplex struct {
+ DataS struct {
+ Strs []string
+ }
+}
+
+type ResultComplex struct {
+ Count int
+ Hash struct {
+ Str string
+ }
+}
+
+func qHash(q *QueryComplex) string {
+ return string(hash.THashB([]byte(strings.Join(q.DataS.Strs, ""))))
+}
+
+func (f *FooComplex) Bar(args *QueryComplex, res *ResultComplex) error {
+ res.Count = len(args.DataS.Strs)
+ res.Hash.Str = qHash(args)
+ log.Debugf("Received %v", *args)
+ return nil
}
func server() *CryptoListener {
@@ -59,15 +87,15 @@ func server() *CryptoListener {
if err != nil {
log.Errorf("server: listen: %s", err)
}
- log.Print("server: listening")
+ log.Debug("server: listening")
go func() {
for {
conn, err := listener.Accept()
if err != nil {
- log.Printf("server: accept: %s", err)
+ log.Debugf("server: accept: %s", err)
break
}
- log.Printf("server: accepted from %s", conn.RemoteAddr())
+ log.Debugf("server: accepted from %s", conn.RemoteAddr())
go handleClient(conn)
}
}()
@@ -89,26 +117,72 @@ func client(pass string) (ret int, err error) {
//conn.SetReadDeadline(time.Time{})
//conn.SetWriteDeadline(time.Time{})
- log.Println("client: connected to: ", conn.RemoteAddr())
- log.Println("client: LocalAddr: ", conn.LocalAddr())
+ log.Debugln("client: connected to: ", conn.RemoteAddr())
+ log.Debugln("client: LocalAddr: ", conn.LocalAddr())
rpcClient := rpc.NewClient(conn)
res := new(Result)
args := strings.Repeat("a", contentLength)
if err := rpcClient.Call("Foo.Bar", args, &res); err != nil {
- log.Error("failed to call RPC", err)
+ log.Errorf("failed to call RPC %v", err)
return 0, err
}
- log.Printf("Returned result is %d", res.Data)
+ log.Debugf("Returned result is %d", res.Data)
return res.Data, err
}
+func serverComplex() *CryptoListener {
+ if err := rpc.Register(new(FooComplex)); err != nil {
+ log.Error("failed to register RPC method")
+ }
+
+ listener, err := NewCryptoListener("tcp", serviceComplex, simpleCipherHandler)
+ if err != nil {
+ log.Errorf("server: listen: %s", err)
+ }
+ log.Debug("server: listening")
+ go func() {
+ for {
+ conn, err := listener.Accept()
+ if err != nil {
+ log.Debugf("server: accept: %s", err)
+ break
+ }
+ log.Debugf("server: accepted from %s", conn.RemoteAddr())
+ go handleClient(conn)
+ }
+ }()
+ return listener
+}
+
+func clientComplex(pass string, args *QueryComplex) (ret *ResultComplex, err error) {
+ cipher := NewCipher([]byte(pass))
+
+ conn, err := Dial("tcp", serviceComplex, cipher)
+ if err != nil {
+ log.Errorf("client: dial: %s", err)
+ return nil, err
+ }
+ defer conn.Close()
+
+ log.Debugln("client: connected to: ", conn.RemoteAddr())
+ log.Debugln("client: LocalAddr: ", conn.LocalAddr())
+ rpcClient := rpc.NewClient(conn)
+ res := new(ResultComplex)
+
+ if err := rpcClient.Call("FooComplex.Bar", args, &res); err != nil {
+ log.Errorf("failed to call RPC %v", err)
+ return nil, err
+ }
+ return res, err
+}
+
func handleClient(conn net.Conn) {
defer conn.Close()
rpc.ServeConn(conn)
- log.Println("server: conn: closed")
+ log.Debugln("server: conn: closed")
}
-func TestConn(t *testing.T) {
+func TestSimpleRPC(t *testing.T) {
l := server()
Convey("get addr", t, func() {
addr := l.Addr().String()
@@ -119,38 +193,96 @@ func TestConn(t *testing.T) {
So(ret, ShouldEqual, contentLength)
So(err, ShouldBeNil)
})
+ Convey("server client OK 100", t, func() {
+ for i := 0; i < 100; i++ {
+ ret, err := client(pass)
+ So(ret, ShouldEqual, contentLength)
+ So(err, ShouldBeNil)
+ }
+ })
Convey("pass not match", t, func() {
ret, err := client("1234")
So(ret, ShouldEqual, 0)
So(err, ShouldNotBeNil)
})
+ Convey("pass not match 100", t, func() {
+ for i := 0; i < 100; i++ {
+ ret, err := client("12345")
+ So(ret, ShouldEqual, 0)
+ So(err, ShouldNotBeNil)
+ }
+ })
+ Convey("server close", t, func() {
+ err := l.Close()
+ So(err, ShouldBeNil)
+ })
+}
+
+func TestComplexRPC(t *testing.T) {
+ l := serverComplex()
+ Convey("get addr", t, func() {
+ addr := l.Addr().String()
+ So(addr, ShouldEqual, serviceComplex)
+ })
+ Convey("server client OK", t, func() {
+ argsComplex := &QueryComplex{
+ DataS: struct{ Strs []string }{Strs: []string{"aaa", "bbbbbbb"}},
+ }
+ ret, err := clientComplex(pass, argsComplex)
+ So(ret.Count, ShouldEqual, len(argsComplex.DataS.Strs))
+ So(ret.Hash.Str, ShouldResemble, qHash(argsComplex))
+ So(err, ShouldBeNil)
+ })
+ Convey("server client pass error", t, func() {
+ argsComplex := &QueryComplex{
+ DataS: struct{ Strs []string }{Strs: []string{"aaa", "bbbbbbb"}},
+ }
+ ret, err := clientComplex(pass+"1", argsComplex)
+ So(ret, ShouldBeNil)
+ So(err, ShouldNotBeNil)
+ })
+
+ Convey("server client pass error", t, func() {
+ argsComplex := &QueryComplex{
+ DataS: struct{ Strs []string }{Strs: []string{"aaa", "bbbbbbb"}},
+ }
+ ret, err := clientComplex(strings.Repeat(pass, 100), argsComplex)
+ So(ret, ShouldBeNil)
+ So(err, ShouldNotBeNil)
+ })
+
Convey("server close", t, func() {
err := l.Close()
So(err, ShouldBeNil)
})
}
-func TestCryptoConn_RawRead(t *testing.T) {
+func TestCryptoConn_RW(t *testing.T) {
+ cipher := NewCipher([]byte(pass))
var nilCipherHandler CipherHandler = func(conn net.Conn) (cryptoConn *CryptoConn, err error) {
- cryptoConn = NewConn(conn, nil, nil)
+ cryptoConn = NewConn(conn, cipher, nil)
return
}
- Convey("server client OK", t, func() {
+ Convey("server client OK", t, func(c C) {
+ msg := "xxxxxxxxxxxxxxxx"
l, _ := NewCryptoListener("tcp", "127.0.0.1:0", nilCipherHandler)
+ wg := sync.WaitGroup{}
+ wg.Add(1)
go func() {
- rBuf := make([]byte, 1)
- c, err := l.Accept()
- cc, _ := c.(*CryptoConn)
- _, err = cc.RawRead(rBuf)
- log.Errorf("RawRead: %s", err)
- So(rBuf[0], ShouldEqual, 'x')
- So(err, ShouldBeNil)
- }()
- conn, _ := Dial("tcp", l.Addr().String(), nil)
- go func() {
- n, err := conn.RawWrite([]byte("xxxxxxxxxxxxxxxx"))
- log.Errorf("RawWrite: %d %s", n, err)
+ rBuf := make([]byte, len(msg))
+ conn, err := l.Accept()
+ cc, _ := conn.(*CryptoConn)
+ n, err := cc.Read(rBuf)
+ c.So(n, ShouldEqual, len(msg))
+ c.So(string(rBuf), ShouldResemble, msg)
+ c.So(err, ShouldBeNil)
+ wg.Done()
}()
+ conn, _ := Dial("tcp", l.Addr().String(), cipher)
+ n, err := conn.Write([]byte(msg))
+ So(n, ShouldEqual, len(msg))
+ So(err, ShouldBeNil)
+ wg.Wait()
})
}
From 1d33e3f2e8e045b729712c5790dcf8e78295b2d4 Mon Sep 17 00:00:00 2001
From: Qi Xiao
Date: Wed, 26 Dec 2018 14:44:13 +0800
Subject: [PATCH 179/278] Use Wrap as Wrapf
---
xenomint/query_sanitizer.go | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/xenomint/query_sanitizer.go b/xenomint/query_sanitizer.go
index ff7580ccc..fe358e693 100644
--- a/xenomint/query_sanitizer.go
+++ b/xenomint/query_sanitizer.go
@@ -193,7 +193,7 @@ func convertQueryAndBuildArgs(pattern string, args []types.NamedArg) (containsDD
return true, nil
}, walkNodes...)
if err != nil {
- err = errors.Wrapf(err, "parse sql failed")
+ err = errors.Wrap(err, "parse sql failed")
return
}
}
From 90f1ce1029d181931e97756d9a6c1d0ddfe9f39e Mon Sep 17 00:00:00 2001
From: Qi Xiao
Date: Wed, 26 Dec 2018 14:51:55 +0800
Subject: [PATCH 180/278] Use backtick instead of double quote for long sql
statement
---
xenomint/query_sanitizer.go | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/xenomint/query_sanitizer.go b/xenomint/query_sanitizer.go
index fe358e693..760f5092c 100644
--- a/xenomint/query_sanitizer.go
+++ b/xenomint/query_sanitizer.go
@@ -19,6 +19,7 @@ package xenomint
import (
"bytes"
"database/sql"
+ "fmt"
"strings"
"github.com/CovenantSQL/CovenantSQL/types"
@@ -97,16 +98,21 @@ func convertQueryAndBuildArgs(pattern string, args []types.NamedArg) (containsDD
switch stmt.Type {
case "table":
if stmt.ShowCreate {
- query = "SELECT sql FROM sqlite_master WHERE type = \"table\" AND tbl_name = \"" +
- stmt.OnTable.Name.String() + "\" AND tbl_name NOT LIKE \"sqlite%\""
+ query = fmt.Sprintf(`SELECT sql
+FROM sqlite_master
+WHERE type = "table" AND tbl_name = "%s"
+ AND tbl_name NOT LIKE "sqlite%%"`,
+ stmt.OnTable.Name.String())
} else {
- query = "PRAGMA table_info(" + stmt.OnTable.Name.String() + ")"
+ query = fmt.Sprintf(`PRAGMA table_info(%s)`, stmt.OnTable.Name.String())
}
case "index":
- query = "SELECT name FROM sqlite_master WHERE type = \"index\" AND tbl_name = \"" +
- stmt.OnTable.Name.String() + "\" AND name NOT LIKE \"sqlite%\""
+ query = fmt.Sprintf(`SELECT name
+FROM sqlite_master
+WHERE type = "index" AND tbl_name = "%s"
+ AND name NOT LIKE "sqlite%%"`, stmt.OnTable.Name.String())
case "tables":
- query = "SELECT name FROM sqlite_master WHERE type = \"table\" AND name NOT LIKE \"sqlite%\""
+ query = `SELECT name FROM sqlite_master WHERE type = "table" AND name NOT LIKE "sqlite%"`
}
log.WithFields(log.Fields{
From dff121082fece339df8fe204061bde7393759768 Mon Sep 17 00:00:00 2001
From: auxten
Date: Wed, 26 Dec 2018 15:21:26 +0800
Subject: [PATCH 181/278] Make all members in ResourceMeta in HSP
---
types/init_service_type.go | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/types/init_service_type.go b/types/init_service_type.go
index 6cefba184..9f3292ae3 100644
--- a/types/init_service_type.go
+++ b/types/init_service_type.go
@@ -36,9 +36,9 @@ type ResourceMeta struct {
Space uint64 // reserved storage space in bytes
Memory uint64 // reserved memory in bytes
LoadAvgPerCPU uint64 // max loadAvg15 per CPU
- EncryptionKey string `hspack:"-"` // encryption key for database instance
- UseEventualConsistency bool `hspack:"-"` // use eventual consistency replication if enabled
- ConsistencyLevel float64 `hspack:"-"` // customized strong consistency level
+ EncryptionKey string // encryption key for database instance
+ UseEventualConsistency bool // use eventual consistency replication if enabled
+ ConsistencyLevel float64 // customized strong consistency level
}
// ServiceInstance defines single instance to be initialized.
From ec9ccffe559e2af83c67bca06222686520ce85a6 Mon Sep 17 00:00:00 2001
From: zeqing-guo
Date: Wed, 26 Dec 2018 15:27:37 +0800
Subject: [PATCH 182/278] Move chainbusservice.go to worker package
---
client/driver.go | 10 ++++++++++
client/errors.go | 2 ++
cmd/cql-adapter/storage/sqlite3.go | 1 -
cmd/cql-faucet/persistence.go | 1 -
cmd/cql-minerd/main.go | 1 -
crypto/hash/hashfuncs.go | 1 -
storage/storage.go | 1 -
{sqlchain => worker}/chainbusservice.go | 2 +-
worker/db.go | 1 -
worker/dbms.go | 4 ++--
xenomint/xxx_test.go | 1 -
11 files changed, 15 insertions(+), 10 deletions(-)
rename {sqlchain => worker}/chainbusservice.go (99%)
diff --git a/client/driver.go b/client/driver.go
index 51317e666..d60981a01 100644
--- a/client/driver.go
+++ b/client/driver.go
@@ -353,6 +353,11 @@ func getPeers(dbID proto.DatabaseID, privKey *asymmetric.PrivateKey) (peers *pro
}
nodeIDs := make([]proto.NodeID, len(profileResp.Profile.Miners))
+ if len(profileResp.Profile.Miners) <= 0 {
+ err = ErrInvalidProfile
+ log.WithError(err).Warning("unexpected error in getPeers")
+ return
+ }
for i, mi := range profileResp.Profile.Miners {
nodeIDs[i] = mi.NodeID
}
@@ -362,6 +367,11 @@ func getPeers(dbID proto.DatabaseID, privKey *asymmetric.PrivateKey) (peers *pro
Servers: nodeIDs[:],
},
}
+ err = peers.Sign(privKey)
+ if err != nil {
+ log.WithError(err).Warning("sign peers failed in getPeers")
+ return
+ }
// set peers in the updater cache
peerList.Store(dbID, peers)
diff --git a/client/errors.go b/client/errors.go
index ca89de944..d9b5ca49a 100644
--- a/client/errors.go
+++ b/client/errors.go
@@ -28,4 +28,6 @@ var (
ErrAlreadyInitialized = errors.New("driver already initialized")
// ErrInvalidRequestSeq defines invalid sequence no of request.
ErrInvalidRequestSeq = errors.New("invalid request sequence applied")
+ // ErrInvalidProfile indicates the SQLChain profile is invalid.
+ ErrInvalidProfile = errors.New("invalid sqlchain profile")
)
diff --git a/cmd/cql-adapter/storage/sqlite3.go b/cmd/cql-adapter/storage/sqlite3.go
index d9be539d8..aac13f94d 100644
--- a/cmd/cql-adapter/storage/sqlite3.go
+++ b/cmd/cql-adapter/storage/sqlite3.go
@@ -24,7 +24,6 @@ import (
"math/rand"
"os"
"path/filepath"
-
// Import sqlite3 manually.
_ "github.com/CovenantSQL/go-sqlite3-encrypt"
)
diff --git a/cmd/cql-faucet/persistence.go b/cmd/cql-faucet/persistence.go
index 140a6c6d6..dfdc3d458 100644
--- a/cmd/cql-faucet/persistence.go
+++ b/cmd/cql-faucet/persistence.go
@@ -26,7 +26,6 @@ import (
"github.com/CovenantSQL/CovenantSQL/conf"
"github.com/CovenantSQL/CovenantSQL/utils/log"
uuid "github.com/satori/go.uuid"
-
// Load sqlite3 database driver.
_ "github.com/CovenantSQL/go-sqlite3-encrypt"
)
diff --git a/cmd/cql-minerd/main.go b/cmd/cql-minerd/main.go
index 8bdb88863..db032512b 100644
--- a/cmd/cql-minerd/main.go
+++ b/cmd/cql-minerd/main.go
@@ -26,7 +26,6 @@ import (
"os"
"os/signal"
"runtime"
-
//"runtime/trace"
"syscall"
"time"
diff --git a/crypto/hash/hashfuncs.go b/crypto/hash/hashfuncs.go
index af14cf46d..d3cd98561 100644
--- a/crypto/hash/hashfuncs.go
+++ b/crypto/hash/hashfuncs.go
@@ -19,7 +19,6 @@ package hash
import (
"encoding/binary"
"hash/fnv"
-
// "crypto/sha256" benchmark is at least 10% faster on
// i7-4870HQ CPU @ 2.50GHz than "github.com/minio/sha256-simd"
"crypto/sha256"
diff --git a/storage/storage.go b/storage/storage.go
index e059819af..7e36bad0e 100644
--- a/storage/storage.go
+++ b/storage/storage.go
@@ -26,7 +26,6 @@ import (
"github.com/CovenantSQL/CovenantSQL/twopc"
"github.com/CovenantSQL/CovenantSQL/utils/log"
-
// Register CovenantSQL/go-sqlite3-encrypt engine.
_ "github.com/CovenantSQL/go-sqlite3-encrypt"
)
diff --git a/sqlchain/chainbusservice.go b/worker/chainbusservice.go
similarity index 99%
rename from sqlchain/chainbusservice.go
rename to worker/chainbusservice.go
index 848a711d8..6c648329f 100644
--- a/sqlchain/chainbusservice.go
+++ b/worker/chainbusservice.go
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package sqlchain
+package worker
import (
"context"
diff --git a/worker/db.go b/worker/db.go
index c91b43b57..70d1e7281 100644
--- a/worker/db.go
+++ b/worker/db.go
@@ -20,7 +20,6 @@ import (
"context"
"os"
"path/filepath"
-
//"runtime/trace"
"sync"
"time"
diff --git a/worker/dbms.go b/worker/dbms.go
index 338d0ad57..461c18ca5 100644
--- a/worker/dbms.go
+++ b/worker/dbms.go
@@ -60,7 +60,7 @@ type DBMS struct {
kayakMux *DBKayakMuxService
chainMux *sqlchain.MuxService
rpc *DBMSRPCService
- busService *sqlchain.BusService
+ busService *BusService
address proto.AccountAddress
privKey *asymmetric.PrivateKey
}
@@ -100,7 +100,7 @@ func NewDBMS(cfg *DBMSConfig) (dbms *DBMS, err error) {
// init chain bus service
ctx := context.Background()
- bs := sqlchain.NewBusService(ctx, addr, CheckInterval)
+ bs := NewBusService(ctx, addr, CheckInterval)
dbms.busService = bs
// private key cache
diff --git a/xenomint/xxx_test.go b/xenomint/xxx_test.go
index 6e19f1b08..13a973878 100644
--- a/xenomint/xxx_test.go
+++ b/xenomint/xxx_test.go
@@ -22,7 +22,6 @@ import (
"os"
"path"
"sync/atomic"
-
//"runtime/trace"
"sync"
"syscall"
From 02aafbb5004f25a97da32f44782ef399410c8d94 Mon Sep 17 00:00:00 2001
From: auxten
Date: Wed, 26 Dec 2018 15:50:58 +0800
Subject: [PATCH 183/278] Remove unnecessary build in test case
---
rpc/leak_test.go | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/rpc/leak_test.go b/rpc/leak_test.go
index 5b4a4544d..7bca030c1 100644
--- a/rpc/leak_test.go
+++ b/rpc/leak_test.go
@@ -33,10 +33,7 @@ import (
func TestSessionPool_SessionBroken(t *testing.T) {
log.SetLevel(log.DebugLevel)
var err error
- err = utils.Build()
- if err != nil {
- t.Errorf("build failed: %v", err)
- }
+
conf.GConf, err = conf.LoadConfig(FJ(testWorkingDir, "./leak/client.yaml"))
if err != nil {
t.Errorf("load config from %s failed: %s", FJ(testWorkingDir, "./leak/client.yaml"), err)
From 54905e4e740e7906bcc7c134e04c861c9b2ed782 Mon Sep 17 00:00:00 2001
From: auxten
Date: Wed, 26 Dec 2018 15:51:31 +0800
Subject: [PATCH 184/278] Remove all otypes
---
blockproducer/otypes/billing_request.go | 155 --
blockproducer/otypes/billing_request_gen.go | 132 --
.../otypes/billing_request_gen_test.go | 84 --
blockproducer/otypes/billing_request_test.go | 339 -----
blockproducer/otypes/errors.go | 28 -
blockproducer/otypes/xxx_test.go | 102 --
cmd/hotfix/hash-upgrade/main.go | 267 ----
cmd/hotfix/hash-upgrade/serial.go | 1336 -----------------
cmd/hotfix/observer-upgrade/main.go | 222 ---
sqlchain/otypes/billing_req.go | 34 -
sqlchain/otypes/block.go | 186 ---
sqlchain/otypes/block_gen.go | 179 ---
sqlchain/otypes/block_gen_test.go | 158 --
sqlchain/otypes/block_test.go | 287 ----
sqlchain/otypes/doc.go | 18 -
sqlchain/otypes/errors.go | 36 -
sqlchain/otypes/observer.go | 24 -
sqlchain/otypes/xxx_test.go | 142 --
worker/otypes/ack_type.go | 115 --
worker/otypes/ack_type_gen.go | 143 --
worker/otypes/ack_type_gen_test.go | 158 --
worker/otypes/doc.go | 20 -
worker/otypes/errors.go | 30 -
worker/otypes/get_request.go | 32 -
worker/otypes/init_service_type.go | 104 --
worker/otypes/init_service_type_gen.go | 219 ---
worker/otypes/init_service_type_gen_test.go | 232 ---
worker/otypes/no_ack_report_type.go | 165 --
worker/otypes/no_ack_report_type_gen.go | 263 ----
worker/otypes/no_ack_report_type_gen_test.go | 232 ---
worker/otypes/request_type.go | 162 --
worker/otypes/request_type_gen.go | 277 ----
worker/otypes/request_type_gen_test.go | 269 ----
worker/otypes/response_type.go | 128 --
worker/otypes/response_type_gen.go | 209 ---
worker/otypes/response_type_gen_test.go | 195 ---
worker/otypes/types_test.go | 729 ---------
worker/otypes/update_service_type.go | 98 --
worker/otypes/update_service_type_gen.go | 145 --
worker/otypes/update_service_type_gen_test.go | 158 --
worker/otypes/util.go | 46 -
41 files changed, 7858 deletions(-)
delete mode 100644 blockproducer/otypes/billing_request.go
delete mode 100644 blockproducer/otypes/billing_request_gen.go
delete mode 100644 blockproducer/otypes/billing_request_gen_test.go
delete mode 100644 blockproducer/otypes/billing_request_test.go
delete mode 100644 blockproducer/otypes/errors.go
delete mode 100644 blockproducer/otypes/xxx_test.go
delete mode 100644 cmd/hotfix/hash-upgrade/main.go
delete mode 100644 cmd/hotfix/hash-upgrade/serial.go
delete mode 100644 cmd/hotfix/observer-upgrade/main.go
delete mode 100644 sqlchain/otypes/billing_req.go
delete mode 100644 sqlchain/otypes/block.go
delete mode 100644 sqlchain/otypes/block_gen.go
delete mode 100644 sqlchain/otypes/block_gen_test.go
delete mode 100644 sqlchain/otypes/block_test.go
delete mode 100644 sqlchain/otypes/doc.go
delete mode 100644 sqlchain/otypes/errors.go
delete mode 100644 sqlchain/otypes/observer.go
delete mode 100644 sqlchain/otypes/xxx_test.go
delete mode 100644 worker/otypes/ack_type.go
delete mode 100644 worker/otypes/ack_type_gen.go
delete mode 100644 worker/otypes/ack_type_gen_test.go
delete mode 100644 worker/otypes/doc.go
delete mode 100644 worker/otypes/errors.go
delete mode 100644 worker/otypes/get_request.go
delete mode 100644 worker/otypes/init_service_type.go
delete mode 100644 worker/otypes/init_service_type_gen.go
delete mode 100644 worker/otypes/init_service_type_gen_test.go
delete mode 100644 worker/otypes/no_ack_report_type.go
delete mode 100644 worker/otypes/no_ack_report_type_gen.go
delete mode 100644 worker/otypes/no_ack_report_type_gen_test.go
delete mode 100644 worker/otypes/request_type.go
delete mode 100644 worker/otypes/request_type_gen.go
delete mode 100644 worker/otypes/request_type_gen_test.go
delete mode 100644 worker/otypes/response_type.go
delete mode 100644 worker/otypes/response_type_gen.go
delete mode 100644 worker/otypes/response_type_gen_test.go
delete mode 100644 worker/otypes/types_test.go
delete mode 100644 worker/otypes/update_service_type.go
delete mode 100644 worker/otypes/update_service_type_gen.go
delete mode 100644 worker/otypes/update_service_type_gen_test.go
delete mode 100644 worker/otypes/util.go
diff --git a/blockproducer/otypes/billing_request.go b/blockproducer/otypes/billing_request.go
deleted file mode 100644
index 14d96c1b9..000000000
--- a/blockproducer/otypes/billing_request.go
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
- * Copyright 2018 The CovenantSQL Authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package types
-
-import (
- "reflect"
-
- "github.com/CovenantSQL/CovenantSQL/crypto/asymmetric"
- "github.com/CovenantSQL/CovenantSQL/crypto/hash"
- "github.com/CovenantSQL/CovenantSQL/proto"
-)
-
-//go:generate hsp
-
-// BillingRequestHeader includes contents that need to be signed. Billing blocks should be within
-// height range [low, high] (inclusive).
-type BillingRequestHeader struct {
- DatabaseID proto.DatabaseID
- // sqlchain block hash and its height
- LowBlock hash.Hash
- LowHeight int32
- HighBlock hash.Hash
- HighHeight int32
- GasAmounts []*proto.AddrAndGas
-}
-
-// BillingRequest defines periodically Billing sync.
-type BillingRequest struct {
- Header BillingRequestHeader
- RequestHash hash.Hash
- Signees []*asymmetric.PublicKey
- Signatures []*asymmetric.Signature
-}
-
-// PackRequestHeader computes the hash of header.
-func (br *BillingRequest) PackRequestHeader() (h *hash.Hash, err error) {
- var enc []byte
- if enc, err = br.Header.MarshalHash(); err != nil {
- return
- }
-
- br.RequestHash = hash.THashH(enc)
- h = &br.RequestHash
- return
-}
-
-// SignRequestHeader first computes the hash of BillingRequestHeader, then signs the request.
-func (br *BillingRequest) SignRequestHeader(signer *asymmetric.PrivateKey, calcHash bool) (
- signee *asymmetric.PublicKey, signature *asymmetric.Signature, err error) {
- if calcHash {
- if _, err = br.PackRequestHeader(); err != nil {
- return
- }
- }
-
- if signature, err = signer.Sign(br.RequestHash[:]); err == nil {
- // append to current signatures
- signee = signer.PubKey()
- br.Signees = append(br.Signees, signee)
- br.Signatures = append(br.Signatures, signature)
- }
-
- return
-}
-
-// AddSignature add existing signature to BillingRequest, requires the structure to be packed first.
-func (br *BillingRequest) AddSignature(
- signee *asymmetric.PublicKey, signature *asymmetric.Signature, calcHash bool) (err error) {
- if calcHash {
- if _, err = br.PackRequestHeader(); err != nil {
- return
- }
- }
-
- if !signature.Verify(br.RequestHash[:], signee) {
- err = ErrSignVerification
- return
- }
-
- // append
- br.Signees = append(br.Signees, signee)
- br.Signatures = append(br.Signatures, signature)
-
- return
-}
-
-// VerifySignatures verify existing signatures.
-func (br *BillingRequest) VerifySignatures() (err error) {
- if len(br.Signees) != len(br.Signatures) {
- return ErrSignVerification
- }
-
- var enc []byte
- if enc, err = br.Header.MarshalHash(); err != nil {
- return
- }
-
- h := hash.THashH(enc)
- if !br.RequestHash.IsEqual(&h) {
- return ErrSignVerification
- }
-
- if len(br.Signees) == 0 {
- return
- }
-
- for idx, signee := range br.Signees {
- if !br.Signatures[idx].Verify(br.RequestHash[:], signee) {
- return ErrSignVerification
- }
- }
-
- return
-}
-
-// Compare returns if two billing records are identical.
-func (br *BillingRequest) Compare(r *BillingRequest) (err error) {
- if !br.Header.LowBlock.IsEqual(&r.Header.LowBlock) ||
- !br.Header.HighBlock.IsEqual(&br.Header.HighBlock) {
- err = ErrBillingNotMatch
- return
- }
-
- reqMap := make(map[proto.AccountAddress]*proto.AddrAndGas)
- locMap := make(map[proto.AccountAddress]*proto.AddrAndGas)
-
- for _, v := range br.Header.GasAmounts {
- reqMap[v.AccountAddress] = v
- }
-
- for _, v := range r.Header.GasAmounts {
- locMap[v.AccountAddress] = v
- }
-
- if !reflect.DeepEqual(reqMap, locMap) {
- err = ErrBillingNotMatch
- return
- }
-
- return
-}
diff --git a/blockproducer/otypes/billing_request_gen.go b/blockproducer/otypes/billing_request_gen.go
deleted file mode 100644
index 48da8b034..000000000
--- a/blockproducer/otypes/billing_request_gen.go
+++ /dev/null
@@ -1,132 +0,0 @@
-package types
-
-// Code generated by github.com/CovenantSQL/HashStablePack DO NOT EDIT.
-
-import (
- hsp "github.com/CovenantSQL/HashStablePack/marshalhash"
-)
-
-// MarshalHash marshals for hash
-func (z *BillingRequest) MarshalHash() (o []byte, err error) {
- var b []byte
- o = hsp.Require(b, z.Msgsize())
- // map header, size 4
- o = append(o, 0x84, 0x84)
- if oTemp, err := z.Header.MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
- }
- o = append(o, 0x84)
- o = hsp.AppendArrayHeader(o, uint32(len(z.Signees)))
- for za0001 := range z.Signees {
- if z.Signees[za0001] == nil {
- o = hsp.AppendNil(o)
- } else {
- if oTemp, err := z.Signees[za0001].MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
- }
- }
- }
- o = append(o, 0x84)
- o = hsp.AppendArrayHeader(o, uint32(len(z.Signatures)))
- for za0002 := range z.Signatures {
- if z.Signatures[za0002] == nil {
- o = hsp.AppendNil(o)
- } else {
- if oTemp, err := z.Signatures[za0002].MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
- }
- }
- }
- o = append(o, 0x84)
- if oTemp, err := z.RequestHash.MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
- }
- return
-}
-
-// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
-func (z *BillingRequest) Msgsize() (s int) {
- s = 1 + 7 + z.Header.Msgsize() + 8 + hsp.ArrayHeaderSize
- for za0001 := range z.Signees {
- if z.Signees[za0001] == nil {
- s += hsp.NilSize
- } else {
- s += z.Signees[za0001].Msgsize()
- }
- }
- s += 11 + hsp.ArrayHeaderSize
- for za0002 := range z.Signatures {
- if z.Signatures[za0002] == nil {
- s += hsp.NilSize
- } else {
- s += z.Signatures[za0002].Msgsize()
- }
- }
- s += 12 + z.RequestHash.Msgsize()
- return
-}
-
-// MarshalHash marshals for hash
-func (z *BillingRequestHeader) MarshalHash() (o []byte, err error) {
- var b []byte
- o = hsp.Require(b, z.Msgsize())
- // map header, size 6
- o = append(o, 0x86, 0x86)
- o = hsp.AppendArrayHeader(o, uint32(len(z.GasAmounts)))
- for za0001 := range z.GasAmounts {
- if z.GasAmounts[za0001] == nil {
- o = hsp.AppendNil(o)
- } else {
- if oTemp, err := z.GasAmounts[za0001].MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
- }
- }
- }
- o = append(o, 0x86)
- if oTemp, err := z.LowBlock.MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
- }
- o = append(o, 0x86)
- if oTemp, err := z.HighBlock.MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
- }
- o = append(o, 0x86)
- o = hsp.AppendInt32(o, z.LowHeight)
- o = append(o, 0x86)
- o = hsp.AppendInt32(o, z.HighHeight)
- o = append(o, 0x86)
- if oTemp, err := z.DatabaseID.MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
- }
- return
-}
-
-// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
-func (z *BillingRequestHeader) Msgsize() (s int) {
- s = 1 + 11 + hsp.ArrayHeaderSize
- for za0001 := range z.GasAmounts {
- if z.GasAmounts[za0001] == nil {
- s += hsp.NilSize
- } else {
- s += z.GasAmounts[za0001].Msgsize()
- }
- }
- s += 9 + z.LowBlock.Msgsize() + 10 + z.HighBlock.Msgsize() + 10 + hsp.Int32Size + 11 + hsp.Int32Size + 11 + z.DatabaseID.Msgsize()
- return
-}
diff --git a/blockproducer/otypes/billing_request_gen_test.go b/blockproducer/otypes/billing_request_gen_test.go
deleted file mode 100644
index d46613c46..000000000
--- a/blockproducer/otypes/billing_request_gen_test.go
+++ /dev/null
@@ -1,84 +0,0 @@
-package types
-
-// Code generated by github.com/CovenantSQL/HashStablePack DO NOT EDIT.
-
-import (
- "bytes"
- "crypto/rand"
- "encoding/binary"
- "testing"
-)
-
-func TestMarshalHashBillingRequest(t *testing.T) {
- v := BillingRequest{}
- binary.Read(rand.Reader, binary.BigEndian, &v)
- bts1, err := v.MarshalHash()
- if err != nil {
- t.Fatal(err)
- }
- bts2, err := v.MarshalHash()
- if err != nil {
- t.Fatal(err)
- }
- if !bytes.Equal(bts1, bts2) {
- t.Fatal("hash not stable")
- }
-}
-
-func BenchmarkMarshalHashBillingRequest(b *testing.B) {
- v := BillingRequest{}
- b.ReportAllocs()
- b.ResetTimer()
- for i := 0; i < b.N; i++ {
- v.MarshalHash()
- }
-}
-
-func BenchmarkAppendMsgBillingRequest(b *testing.B) {
- v := BillingRequest{}
- bts := make([]byte, 0, v.Msgsize())
- bts, _ = v.MarshalHash()
- b.SetBytes(int64(len(bts)))
- b.ReportAllocs()
- b.ResetTimer()
- for i := 0; i < b.N; i++ {
- bts, _ = v.MarshalHash()
- }
-}
-
-func TestMarshalHashBillingRequestHeader(t *testing.T) {
- v := BillingRequestHeader{}
- binary.Read(rand.Reader, binary.BigEndian, &v)
- bts1, err := v.MarshalHash()
- if err != nil {
- t.Fatal(err)
- }
- bts2, err := v.MarshalHash()
- if err != nil {
- t.Fatal(err)
- }
- if !bytes.Equal(bts1, bts2) {
- t.Fatal("hash not stable")
- }
-}
-
-func BenchmarkMarshalHashBillingRequestHeader(b *testing.B) {
- v := BillingRequestHeader{}
- b.ReportAllocs()
- b.ResetTimer()
- for i := 0; i < b.N; i++ {
- v.MarshalHash()
- }
-}
-
-func BenchmarkAppendMsgBillingRequestHeader(b *testing.B) {
- v := BillingRequestHeader{}
- bts := make([]byte, 0, v.Msgsize())
- bts, _ = v.MarshalHash()
- b.SetBytes(int64(len(bts)))
- b.ReportAllocs()
- b.ResetTimer()
- for i := 0; i < b.N; i++ {
- bts, _ = v.MarshalHash()
- }
-}
diff --git a/blockproducer/otypes/billing_request_test.go b/blockproducer/otypes/billing_request_test.go
deleted file mode 100644
index c6d7ee998..000000000
--- a/blockproducer/otypes/billing_request_test.go
+++ /dev/null
@@ -1,339 +0,0 @@
-/*
- * Copyright 2018 The CovenantSQL Authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package types
-
-import (
- "reflect"
- "testing"
-
- "github.com/CovenantSQL/CovenantSQL/crypto/asymmetric"
- "github.com/CovenantSQL/CovenantSQL/crypto/hash"
- "github.com/CovenantSQL/CovenantSQL/proto"
- "github.com/CovenantSQL/CovenantSQL/utils"
- "github.com/CovenantSQL/CovenantSQL/utils/log"
-)
-
-var (
- peerNum = 32
-)
-
-func TestBillingRequestHeader_MarshalUnmarshalBinary(t *testing.T) {
- reqHeader := generateRandomBillingRequestHeader()
- b, err := utils.EncodeMsgPack(reqHeader)
- if err != nil {
- t.Fatalf("unexpect error when marshal request header: %v", err)
- }
-
- newReqHeader := &BillingRequestHeader{}
- err = utils.DecodeMsgPack(b.Bytes(), newReqHeader)
- if err != nil {
- t.Fatalf("unexpect error when unmashll request header: %v", err)
- }
-
- if !reflect.DeepEqual(reqHeader, newReqHeader) {
- t.Fatalf("values not match:\n\tv0=%+v\n\tv1=%+v", reqHeader, newReqHeader)
- }
-}
-
-func TestBillingRequest_MarshalUnmarshalBinary(t *testing.T) {
- req, err := generateRandomBillingRequest()
- if err != nil {
- t.Fatalf("unexpected error: %v", err)
- }
-
- enc, err := utils.EncodeMsgPack(req)
- if err != nil {
- t.Fatalf("unexpected error: %v", err)
- }
-
- dec := &BillingRequest{}
- err = utils.DecodeMsgPack(enc.Bytes(), dec)
- if err != nil {
- t.Fatalf("unexpected error: %v", err)
- }
-
- if !reflect.DeepEqual(req, dec) {
- log.Debug(req)
- log.Debug(dec)
- t.Fatal("values not match")
- }
-}
-
-func TestBillingRequest_PackRequestHeader(t *testing.T) {
- req, err := generateRandomBillingRequest()
- if err != nil {
- t.Fatalf("unexpected error: %v", err)
- }
-
- enc, err := req.Header.MarshalHash()
- if err != nil {
- t.Fatalf("unexpected error: %v", err)
- }
-
- h := hash.THashH(enc)
- if !h.IsEqual(&req.RequestHash) {
- t.Fatalf("hash not matched: \n\tv1=%v\n\tv2=%v", req.RequestHash, h)
- }
-}
-
-func TestBillingRequest_SignRequestHeader(t *testing.T) {
- req, err := generateRandomBillingRequest()
- if err != nil {
- t.Fatalf("unexpected error: %v", err)
- }
-
- enc, err := req.Header.MarshalHash()
- if err != nil {
- t.Fatalf("unexpected error: %v", err)
- }
-
- h := hash.THashH(enc)
- if !h.IsEqual(&req.RequestHash) {
- t.Fatalf("hash not matched: \n\tv1=%v\n\tv2=%v", req.RequestHash, h)
- }
-
- for i, sign := range req.Signatures {
- if !sign.Verify(req.RequestHash[:], req.Signees[i]) {
-
- t.Fatalf("signature cannot match the hash and public key: %v", req)
- }
- }
-
- priv, pub, err := asymmetric.GenSecp256k1KeyPair()
- _, sign, err := req.SignRequestHeader(priv, false)
- if err != nil || !sign.Verify(req.RequestHash[:], pub) {
- t.Fatalf("signature cannot match the hash and public key: %v", req)
- }
-}
-
-func TestBillingRequest_SignRequestHeader2(t *testing.T) {
- header := generateRandomBillingRequestHeader()
- req := &BillingRequest{
- Header: *header,
- }
-
- priv, _, err := asymmetric.GenSecp256k1KeyPair()
- signee, sign, err := req.SignRequestHeader(priv, true)
- if err != nil || !sign.Verify(req.RequestHash[:], signee) {
- t.Fatalf("signature cannot match the hash and public key: %v", req)
- }
-}
-
-func TestBillingRequest_AddSignature(t *testing.T) {
- header := generateRandomBillingRequestHeader()
- req := &BillingRequest{
- Header: *header,
- }
-
- priv, _, err := asymmetric.GenSecp256k1KeyPair()
- signee, sign, err := req.SignRequestHeader(priv, true)
- if err != nil || !sign.Verify(req.RequestHash[:], signee) {
- t.Fatalf("signature cannot match the hash and public key, req: %v, err: %v", req, err)
- }
-
- // clear previous signees and signatures
- req.Signees = req.Signees[:0]
- req.Signatures = req.Signatures[:0]
-
- if err := req.AddSignature(signee, sign, false); err != nil {
- t.Fatalf("add signature failed, req: %v, err: %v", req, err)
- }
-}
-
-func TestBillingRequest_AddSignature2(t *testing.T) {
- header := generateRandomBillingRequestHeader()
- req := &BillingRequest{
- Header: *header,
- }
-
- priv, _, err := asymmetric.GenSecp256k1KeyPair()
- signee, sign, err := req.SignRequestHeader(priv, true)
- if err != nil || !sign.Verify(req.RequestHash[:], signee) {
- t.Fatalf("signature cannot match the hash and public key, req: %v, err: %v", req, err)
- }
-
- // clear previous signees and signatures
- req.RequestHash = hash.Hash{}
- req.Signees = req.Signees[:0]
- req.Signatures = req.Signatures[:0]
-
- if err := req.AddSignature(signee, sign, true); err != nil {
- t.Fatalf("add signature failed, req: %v, err: %v", req, err)
- }
-}
-
-func TestBillingRequest_AddSignature3(t *testing.T) {
- header := generateRandomBillingRequestHeader()
- req := &BillingRequest{
- Header: *header,
- }
-
- priv, _, err := asymmetric.GenSecp256k1KeyPair()
- signee, sign, err := req.SignRequestHeader(priv, true)
- if err != nil || !sign.Verify(req.RequestHash[:], signee) {
- t.Fatalf("signature cannot match the hash and public key, req: %v, err: %v", req, err)
- }
-
- // clear previous signees and signatures
- req.RequestHash = hash.Hash{}
- req.Signees = req.Signees[:0]
- req.Signatures = req.Signatures[:0]
-
- _, signee, _ = asymmetric.GenSecp256k1KeyPair()
- if err := req.AddSignature(signee, sign, true); err != ErrSignVerification {
- t.Fatalf("add signature should failed, req: %v, err: %v", req, err)
- }
-}
-
-func TestBillingRequest_VerifySignatures(t *testing.T) {
- header := generateRandomBillingRequestHeader()
- req := &BillingRequest{
- Header: *header,
- }
-
- addSignature := func(calcHash bool) {
- priv, _, err := asymmetric.GenSecp256k1KeyPair()
- _, _, err = req.SignRequestHeader(priv, calcHash)
- if err != nil {
- t.Fatalf("sign request failed, req: %v, err: %v", req, err)
- }
- }
-
- // add 3 signatures
- addSignature(true)
- addSignature(false)
- addSignature(false)
-
- if err := req.VerifySignatures(); err != nil {
- t.Fatalf("verify signature failed, req: %v, err: %v", req, err)
- }
-}
-
-func TestBillingRequest_VerifySignatures2(t *testing.T) {
- header := generateRandomBillingRequestHeader()
- req := &BillingRequest{
- Header: *header,
- }
-
- addSignature := func(calcHash bool) {
- priv, _, err := asymmetric.GenSecp256k1KeyPair()
- _, _, err = req.SignRequestHeader(priv, calcHash)
- if err != nil {
- t.Fatalf("sign request failed, req: %v, err: %v", req, err)
- }
- }
-
- // add 3 signatures
- addSignature(true)
- addSignature(false)
- addSignature(false)
-
- // length invalidation
- req.Signees = req.Signees[:0]
-
- if err := req.VerifySignatures(); err != ErrSignVerification {
- t.Fatalf("verify should be failed, req: %v, err: %v", req, err)
- }
-}
-
-func TestBillingRequest_VerifySignatures3(t *testing.T) {
- header := generateRandomBillingRequestHeader()
- req := &BillingRequest{
- Header: *header,
- }
-
- addSignature := func(calcHash bool) {
- priv, _, err := asymmetric.GenSecp256k1KeyPair()
- _, _, err = req.SignRequestHeader(priv, calcHash)
- if err != nil {
- t.Fatalf("sign request failed, req: %v, err: %v", req, err)
- }
- }
-
- // add 3 signatures
- addSignature(true)
- addSignature(false)
- addSignature(false)
-
- // length invalidation
- req.RequestHash = hash.Hash{}
-
- if err := req.VerifySignatures(); err != ErrSignVerification {
- t.Fatalf("verify should be failed, req: %v, err: %v", req, err)
- }
-}
-
-func TestBillingRequest_VerifySignatures4(t *testing.T) {
- header := generateRandomBillingRequestHeader()
- req := &BillingRequest{
- Header: *header,
- }
-
- addSignature := func(calcHash bool) {
- priv, _, err := asymmetric.GenSecp256k1KeyPair()
- _, _, err = req.SignRequestHeader(priv, calcHash)
- if err != nil {
- t.Fatalf("sign request failed, req: %v, err: %v", req, err)
- }
- }
-
- // add 3 signatures
- addSignature(true)
- addSignature(false)
- addSignature(false)
-
- // length invalidation
- _, req.Signees[0], _ = asymmetric.GenSecp256k1KeyPair()
-
- if err := req.VerifySignatures(); err == nil || err != ErrSignVerification {
- t.Fatalf("verify should be failed, req: %v, err: %v", req, err)
- }
-}
-
-func TestBillingRequest_Compare(t *testing.T) {
- req, _ := generateRandomBillingRequest()
-
- if err := req.Compare(req); err != nil {
- t.Fatalf("compare failed, req: %v, err: %v", req, err)
- }
-
- var req2 BillingRequest
- req2 = *req
-
- req2.Header.LowBlock = hash.Hash{}
-
- if err := req.Compare(&req2); err != ErrBillingNotMatch {
- t.Fatalf("compare should be failed, req: %v, req2: %v, err: %v", req, req2, err)
- }
-}
-
-func TestBillingRequest_Compare2(t *testing.T) {
- req, _ := generateRandomBillingRequest()
- var req2 BillingRequest
- req2 = *req
-
- var gasAmount proto.AddrAndGas
- gasAmount = *req.Header.GasAmounts[0]
- gasAmount.GasAmount += 10
- req2.Header.GasAmounts = nil
- req2.Header.GasAmounts = append(req2.Header.GasAmounts, &gasAmount)
- req2.Header.GasAmounts = append(req2.Header.GasAmounts, req.Header.GasAmounts[1:]...)
-
- if err := req.Compare(&req2); err != ErrBillingNotMatch {
- t.Fatalf("compare should be failed, req: %v, req2: %v, err: %v", req, req2, err)
- }
-}
diff --git a/blockproducer/otypes/errors.go b/blockproducer/otypes/errors.go
deleted file mode 100644
index 7de275fe4..000000000
--- a/blockproducer/otypes/errors.go
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright 2018 The CovenantSQL Authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package types
-
-import (
- "errors"
-)
-
-var (
- // ErrSignVerification indicates a failed signature verification.
- ErrSignVerification = errors.New("signature verification failed")
- // ErrBillingNotMatch indicates that the billing request doesn't match the local result.
- ErrBillingNotMatch = errors.New("billing request doesn't match")
-)
diff --git a/blockproducer/otypes/xxx_test.go b/blockproducer/otypes/xxx_test.go
deleted file mode 100644
index 76651456e..000000000
--- a/blockproducer/otypes/xxx_test.go
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Copyright 2018 The CovenantSQL Authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package types
-
-import (
- "math/rand"
-
- "github.com/CovenantSQL/CovenantSQL/crypto/asymmetric"
- "github.com/CovenantSQL/CovenantSQL/crypto/hash"
- "github.com/CovenantSQL/CovenantSQL/proto"
-)
-
-var (
- uuidLen = 32
-)
-
-const (
- letterBytes = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
-)
-
-func generateRandomHash() hash.Hash {
- h := hash.Hash{}
- rand.Read(h[:])
- return h
-}
-
-func generateRandomDatabaseID() *proto.DatabaseID {
- id := proto.DatabaseID(randStringBytes(uuidLen))
- return &id
-}
-
-func randStringBytes(n int) string {
- b := make([]byte, n)
- for i := range b {
- b[i] = letterBytes[rand.Intn(len(letterBytes))]
- }
- return string(b)
-}
-
-func generateRandomBillingRequestHeader() *BillingRequestHeader {
- return &BillingRequestHeader{
- DatabaseID: *generateRandomDatabaseID(),
- LowBlock: generateRandomHash(),
- LowHeight: rand.Int31(),
- HighBlock: generateRandomHash(),
- HighHeight: rand.Int31(),
- GasAmounts: generateRandomGasAmount(peerNum),
- }
-}
-
-func generateRandomBillingRequest() (req *BillingRequest, err error) {
- reqHeader := generateRandomBillingRequestHeader()
- req = &BillingRequest{
- Header: *reqHeader,
- }
- if _, err = req.PackRequestHeader(); err != nil {
- return nil, err
- }
-
- for i := 0; i < peerNum; i++ {
- // Generate key pair
- var priv *asymmetric.PrivateKey
-
- if priv, _, err = asymmetric.GenSecp256k1KeyPair(); err != nil {
- return
- }
-
- if _, _, err = req.SignRequestHeader(priv, false); err != nil {
- return
- }
- }
-
- return
-}
-
-func generateRandomGasAmount(n int) []*proto.AddrAndGas {
- gasAmount := make([]*proto.AddrAndGas, n)
-
- for i := range gasAmount {
- gasAmount[i] = &proto.AddrAndGas{
- AccountAddress: proto.AccountAddress(generateRandomHash()),
- RawNodeID: proto.RawNodeID{Hash: generateRandomHash()},
- GasAmount: rand.Uint64(),
- }
- }
-
- return gasAmount
-}
diff --git a/cmd/hotfix/hash-upgrade/main.go b/cmd/hotfix/hash-upgrade/main.go
deleted file mode 100644
index 7e4e89a93..000000000
--- a/cmd/hotfix/hash-upgrade/main.go
+++ /dev/null
@@ -1,267 +0,0 @@
-/*
- * Copyright 2018 The CovenantSQL Authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package main
-
-import (
- "bytes"
- "context"
- "database/sql"
- "encoding/binary"
- "encoding/json"
- "flag"
- "fmt"
- "os/exec"
- "strings"
- "time"
-
- "github.com/CovenantSQL/CovenantSQL/crypto/asymmetric"
- "github.com/CovenantSQL/CovenantSQL/crypto/kms"
- "github.com/CovenantSQL/CovenantSQL/proto"
- ct "github.com/CovenantSQL/CovenantSQL/sqlchain/otypes"
- "github.com/CovenantSQL/CovenantSQL/storage"
- "github.com/CovenantSQL/CovenantSQL/utils"
- "github.com/CovenantSQL/CovenantSQL/utils/log"
- wt "github.com/CovenantSQL/CovenantSQL/worker/otypes"
-)
-
-var (
- dhtFile string
- privateKey string
-)
-
-func init() {
- flag.StringVar(&dhtFile, "dhtFile", "dht.db", "dht database file to fix")
- flag.StringVar(&privateKey, "private", "private.key", "private key to use for signing")
-}
-
-// OldBlock type mocks current sqlchain block type for custom serialization.
-type OldBlock ct.Block
-
-// MarshalBinary implements custom binary marshaller for OldBlock.
-func (b *OldBlock) MarshalBinary() ([]byte, error) {
- return nil, nil
-}
-
-// UnmarshalBinary implements custom binary unmarshaller for OldBlock.
-func (b *OldBlock) UnmarshalBinary(data []byte) (err error) {
- reader := bytes.NewReader(data)
- var headerBuf []byte
-
- if err = ReadElements(reader, binary.BigEndian, &headerBuf); err != nil {
- return
- }
-
- if err = ReadElements(bytes.NewReader(headerBuf), binary.BigEndian,
- &b.SignedHeader.Version,
- &b.SignedHeader.Producer,
- &b.SignedHeader.GenesisHash,
- &b.SignedHeader.ParentHash,
- &b.SignedHeader.MerkleRoot,
- &b.SignedHeader.Timestamp,
- &b.SignedHeader.BlockHash,
- &b.SignedHeader.Signee,
- &b.SignedHeader.Signature); err != nil {
- return
- }
-
- err = ReadElements(reader, binary.BigEndian, &b.Queries)
- return
-}
-
-// OldServer ports back the original kayak server structure.
-type OldServer struct {
- Role proto.ServerRole
- ID proto.NodeID
- PubKey *asymmetric.PublicKey
-}
-
-// OldPeers ports back the original kayak peers structure.
-type OldPeers struct {
- Term uint64
- Leader *OldServer
- Servers []*OldServer
- PubKey *asymmetric.PublicKey
- Signature *asymmetric.Signature
-}
-
-// PlainOldServiceInstance defines the plain old service instance type before marshaller updates.
-type PlainOldServiceInstance struct {
- DatabaseID proto.DatabaseID
- Peers *OldPeers
- ResourceMeta wt.ResourceMeta
- GenesisBlock *OldBlock
-}
-
-// OldServiceInstance defines the old service instance type before marshaller updates.
-type OldServiceInstance struct {
- DatabaseID proto.DatabaseID
- Peers *OldPeers
- ResourceMeta wt.ResourceMeta
- GenesisBlock *ct.Block
-}
-
-func convertPeers(oldPeers *OldPeers) (newPeers *proto.Peers) {
- if oldPeers == nil {
- return
- }
-
- newPeers = new(proto.Peers)
- for _, s := range oldPeers.Servers {
- newPeers.Servers = append(newPeers.Servers, s.ID)
- }
- newPeers.Leader = oldPeers.Leader.ID
- newPeers.Term = oldPeers.Term
-
- return
-}
-
-func main() {
- flag.Parse()
-
- log.Info("start hotfix")
-
- // load private key
- privateKey, err := kms.LoadPrivateKey(privateKey, []byte(""))
- if err != nil {
- log.WithError(err).Fatal("load private key failed")
- return
- }
-
- // backup dht file
- if err := exec.Command("cp", "-av", dhtFile, dhtFile+".bak").Run(); err != nil {
- log.WithError(err).Fatal("backup database failed")
- return
- }
-
- st, err := storage.New(dhtFile)
- if err != nil {
- log.WithError(err).Fatal("open database failed")
- return
- }
- defer st.Close()
-
- _, _, rows, err := st.Query(context.Background(),
- []storage.Query{{Pattern: "SELECT `id`, `meta` FROM `databases`"}})
-
- if err != nil {
- log.WithError(err).Fatal("select database failed")
- return
- }
-
- for _, row := range rows {
- if len(row) <= 0 {
- continue
- }
-
- id := string(row[0].([]byte))
- rawInstance := row[1].([]byte)
-
- // test decode
- var testDecode interface{}
-
- // copy instance to new type
- var newInstance wt.ServiceInstance
-
- if err := utils.DecodeMsgPackPlain(rawInstance, &testDecode); err != nil {
- log.WithError(err).Fatal("test decode failed")
- } else {
- // detect if the genesis block is in old version
- if strings.Contains(fmt.Sprintf("%#v", testDecode), "\"GenesisBlock\":[]uint8") {
- log.Info("detected plain old version (without msgpack tag and use custom serializer)")
- var instance PlainOldServiceInstance
-
- if err := utils.DecodeMsgPackPlain(rawInstance, &instance); err != nil {
- log.WithError(err).Fatal("decode msgpack failed")
- return
- }
-
- newInstance.DatabaseID = instance.DatabaseID
- newInstance.Peers = convertPeers(instance.Peers)
- newInstance.ResourceMeta = instance.ResourceMeta
- newInstance.GenesisBlock = &ct.Block{
- SignedHeader: instance.GenesisBlock.SignedHeader,
- Queries: instance.GenesisBlock.Queries,
- }
- } else if strings.Contains(fmt.Sprintf("%#v", testDecode), "\"PubKey\"") {
- log.Info("detected old version (old kayak implementation [called as kaar])")
- var instance OldServiceInstance
-
- if err := utils.DecodeMsgPack(rawInstance, &instance); err != nil {
- log.WithError(err).Fatal("decode msgpack failed")
- return
- }
-
- newInstance.DatabaseID = instance.DatabaseID
- newInstance.Peers = convertPeers(instance.Peers)
- newInstance.ResourceMeta = instance.ResourceMeta
- newInstance.GenesisBlock = instance.GenesisBlock
- } else {
- log.Info("detected new version, need re-signature")
-
- if err := utils.DecodeMsgPack(rawInstance, &newInstance); err != nil {
- log.WithError(err).Fatal("decode msgpack failed")
- return
- }
- }
-
- // set genesis block to now
- newInstance.GenesisBlock.SignedHeader.Timestamp = time.Now().UTC()
-
- // sign peers again
- if err := newInstance.Peers.Sign(privateKey); err != nil {
- log.WithError(err).Fatal("sign peers failed")
- return
- }
-
- if err := newInstance.GenesisBlock.PackAndSignBlock(privateKey); err != nil {
- log.WithError(err).Fatal("sign genesis block failed")
- return
- }
- }
-
- d, _ := json.Marshal(newInstance)
- log.Infof("database is: %#v -> %s", id, string(d))
-
- // encode and put back to database
- rawInstanceBuffer, err := utils.EncodeMsgPack(newInstance)
- if err != nil {
- log.WithError(err).Fatal("encode msgpack failed")
- return
- }
-
- rawInstance = rawInstanceBuffer.Bytes()
-
- if _, err := st.Exec(context.Background(), []storage.Query{
- {
- Pattern: "UPDATE `databases` SET `meta` = ? WHERE `id` = ?",
- Args: []sql.NamedArg{
- {
- Value: rawInstance,
- },
- {
- Value: id,
- },
- },
- },
- }); err != nil {
- log.WithError(err).Fatal("update meta failed")
- return
- }
- }
-
- log.Info("hotfix complete")
-}
diff --git a/cmd/hotfix/hash-upgrade/serial.go b/cmd/hotfix/hash-upgrade/serial.go
deleted file mode 100644
index 9fe483ecd..000000000
--- a/cmd/hotfix/hash-upgrade/serial.go
+++ /dev/null
@@ -1,1336 +0,0 @@
-/*
- * Copyright 2018 The CovenantSQL Authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package main
-
-import (
- "encoding"
- "encoding/binary"
- "errors"
- "io"
- "math"
- "reflect"
- "time"
-
- "github.com/CovenantSQL/CovenantSQL/crypto/asymmetric"
- "github.com/CovenantSQL/CovenantSQL/crypto/hash"
- "github.com/CovenantSQL/CovenantSQL/proto"
- "github.com/CovenantSQL/CovenantSQL/utils/log"
-)
-
-var (
- // ErrInvalidType defines invalid type.
- ErrInvalidType = errors.New("invalid type")
-)
-
-const (
- pooledBufferLength = hash.HashSize
- maxPooledBufferNumber = 1024
- maxSliceLength = 4 << 10
- maxBufferLength = 1 << 20
-)
-
-// simpleSerializer is just a simple serializer with its own []byte pool, which is done by a
-// buffered []byte channel.
-type simpleSerializer chan []byte
-
-var (
- serializer simpleSerializer = make(chan []byte, maxPooledBufferNumber)
-
- // ErrBufferLengthExceedLimit indicates that a string length exceeds limit during
- // deserialization.
- ErrBufferLengthExceedLimit = errors.New("buffer length exceeds limit")
-
- // ErrSliceLengthExceedLimit indicates that a slice length exceeds limit during
- // deserialization.
- ErrSliceLengthExceedLimit = errors.New("slice length exceeds limit")
-
- // ErrInsufficientBuffer indicates that the given buffer space is insufficient during
- // deserialization.
- ErrInsufficientBuffer = errors.New("insufficient buffer space")
-
- // ErrUnexpectedBufferLength indicates that the given buffer doesn't have length as specified.
- ErrUnexpectedBufferLength = errors.New("unexpected buffer length")
-)
-
-func (s simpleSerializer) borrowBuffer(len int) []byte {
- if len > pooledBufferLength {
- return make([]byte, len)
- }
-
- select {
- case buffer := <-s:
- return buffer[:len]
- default:
- }
-
- return make([]byte, len, pooledBufferLength)
-}
-
-func (s simpleSerializer) returnBuffer(buffer []byte) {
- // This guarantees all the buffers in free list are of the same size pooledBufferLength.
- if cap(buffer) != pooledBufferLength {
- return
- }
-
- select {
- case s <- buffer:
- default:
- }
-}
-
-func (s simpleSerializer) readUint8(r io.Reader) (ret uint8, err error) {
- buffer := s.borrowBuffer(1)
- defer s.returnBuffer(buffer)
-
- if _, err = io.ReadFull(r, buffer); err == nil {
- ret = buffer[0]
- }
-
- return
-}
-
-func (s simpleSerializer) readUint16(r io.Reader, order binary.ByteOrder) (ret uint16, err error) {
- buffer := s.borrowBuffer(2)
- defer s.returnBuffer(buffer)
-
- if _, err = io.ReadFull(r, buffer); err == nil {
- ret = order.Uint16(buffer)
- }
-
- return
-}
-
-func (s simpleSerializer) readUint32(r io.Reader, order binary.ByteOrder) (ret uint32, err error) {
- buffer := s.borrowBuffer(4)
- defer s.returnBuffer(buffer)
-
- if _, err = io.ReadFull(r, buffer); err == nil {
- ret = order.Uint32(buffer)
- }
-
- return
-}
-
-func (s simpleSerializer) readUint64(r io.Reader, order binary.ByteOrder) (ret uint64, err error) {
- buffer := s.borrowBuffer(8)
- defer s.returnBuffer(buffer)
-
- if _, err = io.ReadFull(r, buffer); err == nil {
- ret = order.Uint64(buffer)
- }
-
- return
-}
-
-func (s simpleSerializer) readFloat64(r io.Reader, order binary.ByteOrder) (ret float64, err error) {
- buffer := s.borrowBuffer(8)
- defer s.returnBuffer(buffer)
-
- if _, err = io.ReadFull(r, buffer); err == nil {
- val := order.Uint64(buffer)
- ret = math.Float64frombits(val)
- }
-
- return
-}
-
-func (s simpleSerializer) readPublicKey(r io.Reader, order binary.ByteOrder) (val *asymmetric.PublicKey, err error) {
- var buffer []byte
-
- if err = serializer.readBytes(r, order, &buffer); err == nil && len(buffer) > 0 {
- val, err = asymmetric.ParsePubKey(buffer)
- } else {
- val = nil
- }
- return
-}
-
-func (s simpleSerializer) readPublicKeys(r io.Reader, order binary.ByteOrder, val *[]*asymmetric.PublicKey) (err error) {
- lenBuffer := s.borrowBuffer(4)
- defer s.returnBuffer(lenBuffer)
-
- if _, err = io.ReadFull(r, lenBuffer); err != nil {
- return
- }
-
- retLen := order.Uint32(lenBuffer)
-
- if retLen > maxBufferLength {
- err = ErrBufferLengthExceedLimit
- return
- } else if retLen == 0 {
- // Always return nil slice for a zero-length
- *val = nil
- return
- }
-
- if *val == nil || cap(*val) < int(retLen) {
- *val = make([]*asymmetric.PublicKey, retLen)
- } else {
- *val = (*val)[:retLen]
- }
-
- for i := range *val {
- (*val)[i], err = s.readPublicKey(r, order)
- if err != nil {
- return
- }
- }
-
- return
-}
-
-func (s simpleSerializer) readSignature(r io.Reader, order binary.ByteOrder) (val *asymmetric.Signature, err error) {
- var buffer []byte
-
- if err = serializer.readBytes(r, order, &buffer); err == nil && len(buffer) > 0 {
- val, err = asymmetric.ParseSignature(buffer)
- } else {
- val = nil
- }
- return
-}
-
-func (s simpleSerializer) readSignatures(r io.Reader, order binary.ByteOrder, val *[]*asymmetric.Signature) (err error) {
- lenBuffer := s.borrowBuffer(4)
- defer s.returnBuffer(lenBuffer)
-
- if _, err = io.ReadFull(r, lenBuffer); err != nil {
- return
- }
-
- retLen := order.Uint32(lenBuffer)
-
- if retLen > maxBufferLength {
- err = ErrBufferLengthExceedLimit
- return
- } else if retLen == 0 {
- // Always return nil slice for a zero-length
- *val = nil
- return
- }
-
- if *val == nil || cap(*val) < int(retLen) {
- *val = make([]*asymmetric.Signature, retLen)
- } else {
- *val = (*val)[:retLen]
- }
-
- for i := range *val {
- (*val)[i], err = s.readSignature(r, order)
- }
-
- return
-}
-
-// readAddrAndGas reads AddrAndGas from reader with the following format:
-//
-// 0 32 64 72
-// +--------------+--------------+----------+
-// | hash | hash | uint64 |
-// +--------------+--------------+----------+
-//
-func (s simpleSerializer) readAddrAndGas(r io.Reader, order binary.ByteOrder, ret *proto.AddrAndGas) (err error) {
- addr := hash.Hash{}
- err = s.readFixedSizeBytes(r, hash.HashSize, addr[:])
- if err != nil {
- return err
- }
-
- nodeID := hash.Hash{}
- err = s.readFixedSizeBytes(r, hash.HashSize, nodeID[:])
- if err != nil {
- return err
- }
-
- gasAmount, err := s.readUint64(r, order)
- if err != nil {
- return err
- }
-
- ret.GasAmount = gasAmount
- ret.RawNodeID = proto.RawNodeID{Hash: nodeID}
- ret.AccountAddress = proto.AccountAddress(addr)
-
- return nil
-}
-
-// readString reads string from reader with the following format:
-//
-// 0 4 4+len
-// +-----+---------------------------------+
-// | len | string |
-// +-----+---------------------------------+
-//
-func (s simpleSerializer) readString(r io.Reader, order binary.ByteOrder, ret *string) (
- err error) {
- lenBuffer := s.borrowBuffer(4)
- defer s.returnBuffer(lenBuffer)
-
- if _, err = io.ReadFull(r, lenBuffer); err != nil {
- return
- }
-
- retLen := order.Uint32(lenBuffer)
-
- if retLen > maxBufferLength {
- err = ErrBufferLengthExceedLimit
- return
- }
-
- strBuffer := s.borrowBuffer(int(retLen))
- defer s.returnBuffer(strBuffer)
-
- if _, err = io.ReadFull(r, strBuffer); err == nil {
- *ret = string(strBuffer[:])
- }
-
- return
-}
-
-// readBytes reads bytes from reader with the following format:
-//
-// 0 4 4+len
-// +-----+---------------------------------+
-// | len | bytes |
-// +-----+---------------------------------+
-//
-func (s simpleSerializer) readBytes(r io.Reader, order binary.ByteOrder, ret *[]byte) (err error) {
- lenBuffer := s.borrowBuffer(4)
- defer s.returnBuffer(lenBuffer)
-
- if _, err = io.ReadFull(r, lenBuffer); err != nil {
- return
- }
-
- retLen := order.Uint32(lenBuffer)
-
- if retLen > maxBufferLength {
- err = ErrBufferLengthExceedLimit
- return
- } else if retLen == 0 {
- // Always return nil slice for a zero-length
- *ret = nil
- return
- }
-
- retBuffer := s.borrowBuffer(int(retLen))
- defer s.returnBuffer(retBuffer)
-
- if _, err = io.ReadFull(r, retBuffer); err == nil {
- if *ret == nil || cap(*ret) < int(retLen) {
- *ret = make([]byte, retLen)
- } else {
- *ret = (*ret)[:retLen]
- }
-
- copy(*ret, retBuffer)
- }
-
- return
-}
-
-// readUint32s reads bytes from reader with the following format:
-//
-// 0 4 4+len
-// +-----+---------------------------------+
-// | len | uint32s |
-// +-----+---------------------------------+
-//
-func (s simpleSerializer) readUint32s(r io.Reader, order binary.ByteOrder, ret *[]uint32) (err error) {
- lenBuffer := s.borrowBuffer(4)
- defer s.returnBuffer(lenBuffer)
-
- if _, err = io.ReadFull(r, lenBuffer); err != nil {
- return
- }
-
- retLen := order.Uint32(lenBuffer)
-
- if retLen > maxBufferLength {
- err = ErrBufferLengthExceedLimit
- return
- } else if retLen == 0 {
- // Always return nil slice for a zero-length
- *ret = nil
- return
- }
-
- retBuffer := s.borrowBuffer(int(retLen) * 4)
- defer s.returnBuffer(retBuffer)
-
- if _, err = io.ReadFull(r, retBuffer); err == nil {
- if *ret == nil || cap(*ret) < int(retLen) {
- *ret = make([]uint32, retLen)
- } else {
- *ret = (*ret)[:retLen]
- }
-
- for i := range *ret {
- (*ret)[i] = order.Uint32(retBuffer[i*4 : i*4+4])
- }
- }
-
- return
-}
-
-// readUint64s reads bytes from reader with the following format:
-//
-// 0 4 4+len
-// +-----+---------------------------------+
-// | len | uint64s |
-// +-----+---------------------------------+
-//
-func (s simpleSerializer) readUint64s(r io.Reader, order binary.ByteOrder, ret *[]uint64) (err error) {
- lenBuffer := s.borrowBuffer(4)
- defer s.returnBuffer(lenBuffer)
-
- if _, err = io.ReadFull(r, lenBuffer); err != nil {
- return
- }
-
- retLen := order.Uint32(lenBuffer)
-
- if retLen > maxBufferLength {
- err = ErrBufferLengthExceedLimit
- return
- } else if retLen == 0 {
- // Always return nil slice for a zero-length
- *ret = nil
- return
- }
-
- retBuffer := s.borrowBuffer(int(retLen) * 8)
- defer s.returnBuffer(retBuffer)
-
- if _, err = io.ReadFull(r, retBuffer); err == nil {
- if *ret == nil || cap(*ret) < int(retLen) {
- *ret = make([]uint64, retLen)
- } else {
- *ret = (*ret)[:retLen]
- }
-
- for i := range *ret {
- (*ret)[i] = order.Uint64(retBuffer[i*8 : i*8+8])
- }
- }
-
- return
-}
-
-// readFixedSizeBytes reads fixed-size bytes from reader. It's used to read fixed-size array such
-// as Hash, which is a [32]byte array.
-func (s simpleSerializer) readFixedSizeBytes(r io.Reader, lenToRead int, ret []byte) (err error) {
- if len(ret) != lenToRead {
- return ErrInsufficientBuffer
- }
-
- _, err = io.ReadFull(r, ret)
- return
-}
-
-// readStrings reads strings from reader with the following format:
-//
-// 0 4 8 8+len_0
-// +----------+-------+----------+---------+-------+----------+
-// | sliceLen | len_0 | string_0 | ... | len_n | string_n |
-// +----------+-------+----------+---------+-------+----------+
-//
-func (s simpleSerializer) readStrings(r io.Reader, order binary.ByteOrder, ret *[]string) (
- err error) {
- var retLen uint32
-
- if retLen, err = s.readUint32(r, order); err != nil {
- return
- }
-
- if retLen > maxSliceLength {
- err = ErrSliceLengthExceedLimit
- return
- } else if retLen == 0 {
- // Always return nil slice for a zero-length
- *ret = nil
- return
- }
-
- if *ret == nil || cap(*ret) < int(retLen) {
- *ret = make([]string, retLen)
- } else {
- *ret = (*ret)[:retLen]
- }
-
- for i := range *ret {
- if err = s.readString(r, order, &((*ret)[i])); err != nil {
- break
- }
- }
-
- return
-}
-
-// readDatabaseIDs reads databaseIDs from reader with the following format:
-//
-// 0 4 8 8+len_0
-// +----------+-------+--------------+---------+-------+--------------+
-// | sliceLen | len_0 | databaseID_0 | ... | len_n | databaseID_n |
-// +----------+-------+--------------+---------+-------+--------------+
-//
-func (s simpleSerializer) readDatabaseIDs(r io.Reader, order binary.ByteOrder, ret *[]proto.DatabaseID) (
- err error) {
- var retLen uint32
-
- if retLen, err = s.readUint32(r, order); err != nil {
- return
- }
-
- if retLen > maxSliceLength {
- err = ErrSliceLengthExceedLimit
- return
- } else if retLen == 0 {
- // Always return nil slice for a zero-length
- *ret = nil
- return
- }
-
- if *ret == nil || cap(*ret) < int(retLen) {
- *ret = make([]proto.DatabaseID, retLen)
- } else {
- *ret = (*ret)[:retLen]
- }
-
- for i := range *ret {
- if err = s.readString(r, order, (*string)(&((*ret)[i]))); err != nil {
- break
- }
- }
-
- return
-}
-
-// readAddrAndGases reads hashes from reader with the following format:
-//
-// 0 4
-// +----------+----------------+---------------+-------+----------------+
-// | sliceLen | AddrAndGas_0 | AddrAndGas_1 | ... | AddrAndGas_2 |
-// +----------+----------------+---------------+-------+----------------+
-//
-func (s simpleSerializer) readAddrAndGases(r io.Reader, order binary.ByteOrder, ret *[]*proto.AddrAndGas) error {
- retLen, err := s.readUint32(r, order)
- if err != nil {
- return err
- }
-
- if retLen > maxSliceLength {
- return ErrSliceLengthExceedLimit
- } else if retLen == 0 {
- *ret = nil
- return nil
- }
-
- if *ret == nil || cap(*ret) < int(retLen) {
- *ret = make([]*proto.AddrAndGas, retLen)
- } else {
- *ret = (*ret)[:retLen]
- }
-
- for i := range *ret {
- (*ret)[i] = new(proto.AddrAndGas)
-
- err = s.readAddrAndGas(r, order, (*ret)[i])
- if err != nil {
- return err
- }
- }
-
- return nil
-}
-
-// readHashes reads hashes from reader with the following format:
-//
-// 0 4 4+hashsize 4+2*hashsize ... 4+(n+1)*hashsize
-// +----------+------------+------------+------------+------------+
-// | sliceLen | hash_0 | hash_1 | ... | hash_n |
-// +----------+------------+------------+------------+------------+
-//
-func (s simpleSerializer) readHashes(r io.Reader, order binary.ByteOrder, ret *[]*hash.Hash) (
- err error) {
- var retLen uint32
-
- if retLen, err = s.readUint32(r, order); err != nil {
- return
- }
-
- if retLen > maxSliceLength {
- err = ErrSliceLengthExceedLimit
- return
- } else if retLen == 0 {
- // Always return nil slice for a zero-length
- *ret = nil
- return
- }
-
- if *ret == nil || cap(*ret) < int(retLen) {
- *ret = make([]*hash.Hash, retLen)
- } else {
- *ret = (*ret)[:retLen]
- }
-
- for i := range *ret {
- (*ret)[i] = new(hash.Hash)
-
- if err = s.readFixedSizeBytes(r, hash.HashSize, ((*ret)[i])[:]); err != nil {
- break
- }
- }
-
- return
-}
-
-// readAccountAddresses reads hashes from reader with the following format:
-//
-// 0 4 4+hashsize 4+2*hashsize ... 4+(n+1)*hashsize
-// +----------+------------+------------+------------+------------+
-// | sliceLen | hash_0 | hash_1 | ... | hash_n |
-// +----------+------------+------------+------------+------------+
-//
-func (s simpleSerializer) readAccountAddresses(r io.Reader, order binary.ByteOrder, ret *[]*proto.AccountAddress) (
- err error) {
- var retLen uint32
-
- if retLen, err = s.readUint32(r, order); err != nil {
- return
- }
-
- if retLen > maxSliceLength {
- err = ErrSliceLengthExceedLimit
- return
- } else if retLen == 0 {
- // Always return nil slice for a zero-length
- *ret = nil
- return
- }
-
- if *ret == nil || cap(*ret) < int(retLen) {
- *ret = make([]*proto.AccountAddress, retLen)
- } else {
- *ret = (*ret)[:retLen]
- }
-
- for i := range *ret {
- (*ret)[i] = new(proto.AccountAddress)
-
- if err = s.readFixedSizeBytes(r, hash.HashSize, ((*ret)[i])[:]); err != nil {
- break
- }
- }
-
- return
-}
-
-func (s simpleSerializer) writeUint8(w io.Writer, val uint8) (err error) {
- buffer := s.borrowBuffer(1)
- defer s.returnBuffer(buffer)
-
- buffer[0] = val
- _, err = w.Write(buffer)
- return
-}
-
-func (s simpleSerializer) writeUint16(w io.Writer, order binary.ByteOrder, val uint16) (
- err error) {
- buffer := s.borrowBuffer(2)
- defer s.returnBuffer(buffer)
-
- order.PutUint16(buffer, val)
- _, err = w.Write(buffer)
- return
-}
-
-func (s simpleSerializer) writeUint32(w io.Writer, order binary.ByteOrder, val uint32) (
- err error) {
- buffer := s.borrowBuffer(4)
- defer s.returnBuffer(buffer)
-
- order.PutUint32(buffer, val)
- _, err = w.Write(buffer)
- return
-}
-
-func (s simpleSerializer) writeUint64(w io.Writer, order binary.ByteOrder, val uint64) (
- err error) {
- buffer := s.borrowBuffer(8)
- defer s.returnBuffer(buffer)
-
- order.PutUint64(buffer, val)
- _, err = w.Write(buffer)
- return
-}
-
-func (s simpleSerializer) writeFloat64(w io.Writer, order binary.ByteOrder, val float64) (
- err error) {
- buffer := s.borrowBuffer(8)
- defer s.returnBuffer(buffer)
-
- valToUint64 := math.Float64bits(val)
- order.PutUint64(buffer, valToUint64)
- _, err = w.Write(buffer)
- return
-}
-
-func (s simpleSerializer) writeSignature(w io.Writer, order binary.ByteOrder, val *asymmetric.Signature) (err error) {
- if val == nil {
- err = s.writeBytes(w, order, nil)
- } else {
- err = s.writeBytes(w, order, val.Serialize())
- }
- return
-}
-
-func (s simpleSerializer) writePublicKey(w io.Writer, order binary.ByteOrder, val *asymmetric.PublicKey) (err error) {
- if val == nil {
- err = s.writeBytes(w, order, nil)
- } else {
- err = s.writeBytes(w, order, val.Serialize())
- }
- return
-}
-
-// writeString writes string to writer with the following format:
-//
-// 0 4 4+len
-// +-----+---------------------------------+
-// | len | string |
-// +-----+---------------------------------+
-//
-func (s simpleSerializer) writeString(w io.Writer, order binary.ByteOrder, val *string) (
- err error) {
- buffer := s.borrowBuffer(4 + len(*val))
- defer s.returnBuffer(buffer)
-
- valLen := uint32(len(*val))
- order.PutUint32(buffer, valLen)
- copy(buffer[4:], []byte(*val))
- _, err = w.Write(buffer)
- return
-}
-
-// writeAddrAndGas writes AddrAndGas to writer with the following format:
-//
-// 0 32 64 72
-// +--------------+--------------+----------+
-// | hash | hash | uint64 |
-// +--------------+--------------+----------+
-//
-func (s simpleSerializer) writeAddrAndGas(w io.Writer, order binary.ByteOrder, val *proto.AddrAndGas) (err error) {
- err = s.writeFixedSizeBytes(w, hash.HashSize, val.AccountAddress[:])
- if err != nil {
- return
- }
- err = s.writeFixedSizeBytes(w, hash.HashSize, val.RawNodeID.Hash[:])
- if err != nil {
- return
- }
- err = s.writeUint64(w, binary.BigEndian, val.GasAmount)
- if err != nil {
- return
- }
-
- return
-}
-
-// writeBytes writes bytes to writer with the following format:
-//
-// 0 4 4+len
-// +-----+---------------------------------+
-// | len | bytes |
-// +-----+---------------------------------+
-//
-func (s simpleSerializer) writeBytes(w io.Writer, order binary.ByteOrder, val []byte) (err error) {
- buffer := s.borrowBuffer(4 + len(val))
- defer s.returnBuffer(buffer)
-
- valLen := uint32(len(val))
- order.PutUint32(buffer, valLen)
- copy(buffer[4:], []byte(val))
- _, err = w.Write(buffer)
- return
-}
-
-// writeUint32s writes bytes to writer with the following format:
-//
-// 0 4 4+len
-// +-----+---------------------------------+
-// | len | uint32s |
-// +-----+---------------------------------+
-//
-func (s simpleSerializer) writeUint32s(w io.Writer, order binary.ByteOrder, val []uint32) (err error) {
- buffer := s.borrowBuffer(4 + len(val)*4)
- defer s.returnBuffer(buffer)
-
- valLen := uint32(len(val))
- order.PutUint32(buffer, valLen)
- for i := range val {
- order.PutUint32(buffer[4+i*4:], val[i])
- }
- _, err = w.Write(buffer)
- return
-}
-
-// writeUint64 writes bytes to writer with the following format:
-//
-// 0 4 4+len
-// +-----+---------------------------------+
-// | len | uint64s |
-// +-----+---------------------------------+
-//
-func (s simpleSerializer) writeUint64s(w io.Writer, order binary.ByteOrder, val []uint64) (err error) {
- buffer := s.borrowBuffer(4 + len(val)*8)
- defer s.returnBuffer(buffer)
-
- valLen := uint32(len(val))
- order.PutUint32(buffer, valLen)
- for i := range val {
- order.PutUint64(buffer[4+i*8:], val[i])
- }
- _, err = w.Write(buffer)
- return
-}
-
-// writeFixedSizeBytes writes fixed-size bytes to wirter. It's used to write fixed-size array such
-// as Hash, which is a [32]byte array.
-func (s simpleSerializer) writeFixedSizeBytes(w io.Writer, lenToPut int, val []byte) (err error) {
- if len(val) != lenToPut {
- return ErrUnexpectedBufferLength
- }
-
- _, err = w.Write(val)
- return
-}
-
-// writeStrings writes strings to writer with the following format:
-//
-// 0 4 8 8+len_0
-// +----------+-------+----------+---------+-------+----------+
-// | sliceLen | len_0 | string_0 | ... | len_n | string_n |
-// +----------+-------+----------+---------+-------+----------+
-//
-func (s simpleSerializer) writeStrings(w io.Writer, order binary.ByteOrder, val []string) (
- err error) {
- if err = s.writeUint32(w, order, uint32(len(val))); err != nil {
- return
- }
-
- for i := range val {
- if err = s.writeString(w, order, &val[i]); err != nil {
- break
- }
- }
-
- return
-}
-
-// writeDatabaseIDs writes databaseIDs to writer with the following format:
-//
-// 0 4 8 8+len_0
-// +----------+-------+--------------+---------+-------+--------------+
-// | sliceLen | len_0 | databaseID_0 | ... | len_n | databaseID_n |
-// +----------+-------+--------------+---------+-------+--------------+
-//
-func (s simpleSerializer) writeDatabaseIDs(w io.Writer,
- order binary.ByteOrder,
- val []proto.DatabaseID) (err error) {
- if err = s.writeUint32(w, order, uint32(len(val))); err != nil {
- return
- }
-
- for i := range val {
- if err = s.writeString(w, order, (*string)(&val[i])); err != nil {
- break
- }
- }
-
- return
-}
-
-// writeSignatures writes signatures to writer with the following format:
-//
-// 0 4 4+signaturesize 4+2*signaturesize ... 4+(n+1)*signaturesize
-// +----------+-----------------+-----------------+------------+-----------------+
-// | sliceLen | signature_0 | signature_1 | ... | signature_n |
-// +----------+-----------------+-----------------+------------+-----------------+
-//
-func (s simpleSerializer) writeSignatures(w io.Writer, order binary.ByteOrder, val []*asymmetric.Signature) (
- err error) {
- if err = s.writeUint32(w, order, uint32(len(val))); err != nil {
- return
- }
-
- for _, v := range val {
- if err = s.writeSignature(w, order, v); err != nil {
- break
- }
- }
-
- return
-}
-
-// writePublicKeys writes public key to writer with the following format:
-//
-// 0 4 4+pubkeysize 4+2*pubkeysize ... 4+(n+1)*pubkeysize
-// +----------+-----------------+-----------------+------------+-----------------+
-// | sliceLen | publickey_0 | publickey_1 | ... | publickey_n |
-// +----------+-----------------+-----------------+------------+-----------------+
-//
-func (s simpleSerializer) writePublicKeys(w io.Writer, order binary.ByteOrder, val []*asymmetric.PublicKey) (
- err error) {
- if err = s.writeUint32(w, order, uint32(len(val))); err != nil {
- return
- }
-
- for _, v := range val {
- if err = s.writePublicKey(w, order, v); err != nil {
- break
- }
- }
-
- return
-}
-
-// writeHashes writes hashes to writer with the following format:
-//
-// 0 4 4+hashsize 4+2*hashsize ... 4+(n+1)*hashsize
-// +----------+------------+------------+------------+------------+
-// | sliceLen | hash_0 | hash_1 | ... | hash_n |
-// +----------+------------+------------+------------+------------+
-//
-func (s simpleSerializer) writeHashes(w io.Writer, order binary.ByteOrder, val []*hash.Hash) (
- err error) {
- if err = s.writeUint32(w, order, uint32(len(val))); err != nil {
- return
- }
-
- for _, v := range val {
- if err = s.writeFixedSizeBytes(w, hash.HashSize, v[:]); err != nil {
- break
- }
- }
-
- return
-}
-
-// writeAccountAddresses writes hashes to writer with the following format:
-//
-// 0 4 4+hashsize 4+2*hashsize ... 4+(n+1)*hashsize
-// +----------+------------+------------+------------+------------+
-// | sliceLen | hash_0 | hash_1 | ... | hash_n |
-// +----------+------------+------------+------------+------------+
-//
-func (s simpleSerializer) writeAccountAddresses(w io.Writer, order binary.ByteOrder, val []*proto.AccountAddress) (err error) {
- if err = s.writeUint32(w, order, uint32(len(val))); err != nil {
- return
- }
-
- for _, v := range val {
- if err = s.writeFixedSizeBytes(w, hash.HashSize, v[:]); err != nil {
- break
- }
- }
-
- return
-}
-
-// writeAddrAndGases writes hashes to writer with the following format:
-//
-// 0 4
-// +----------+----------------+---------------+-------+----------------+
-// | sliceLen | AddrAndGas_0 | AddrAndGas_1 | ... | AddrAndGas_2 |
-// +----------+----------------+---------------+-------+----------------+
-//
-func (s simpleSerializer) writeAddrAndGases(w io.Writer, order binary.ByteOrder, val []*proto.AddrAndGas) error {
- if err := s.writeUint32(w, order, uint32(len(val))); err != nil {
- return err
- }
-
- for _, v := range val {
- if err := s.writeAddrAndGas(w, order, v); err != nil {
- return err
- }
- }
-
- return nil
-}
-
-func readElement(r io.Reader, order binary.ByteOrder, element interface{}) (err error) {
- switch e := element.(type) {
- case *bool:
- var ret uint8
-
- if ret, err = serializer.readUint8(r); err == nil {
- *e = (ret != 0x00)
- }
-
- case *int8:
- var ret uint8
-
- if ret, err = serializer.readUint8(r); err == nil {
- *e = int8(ret)
- }
-
- case *uint8:
- *e, err = serializer.readUint8(r)
-
- case *int16:
- var ret uint16
-
- if ret, err = serializer.readUint16(r, order); err == nil {
- *e = int16(ret)
- }
-
- case *uint16:
- *e, err = serializer.readUint16(r, order)
-
- case *int32:
- var ret uint32
-
- if ret, err = serializer.readUint32(r, order); err == nil {
- *e = int32(ret)
- }
-
- case *uint32:
- *e, err = serializer.readUint32(r, order)
-
- case *int64:
- var ret uint64
-
- if ret, err = serializer.readUint64(r, order); err == nil {
- *e = int64(ret)
- }
-
- case *uint64:
- *e, err = serializer.readUint64(r, order)
-
- case *float64:
- *e, err = serializer.readFloat64(r, order)
-
- case *time.Time:
- var ret uint64
-
- if ret, err = serializer.readUint64(r, order); err == nil {
- *e = time.Unix(0, int64(ret)).UTC()
- }
-
- case *string:
- err = serializer.readString(r, order, e)
-
- case *[]byte:
- err = serializer.readBytes(r, order, e)
-
- case *[]uint32:
- err = serializer.readUint32s(r, order, e)
-
- case *[]uint64:
- err = serializer.readUint64s(r, order, e)
-
- case *proto.NodeID:
- err = serializer.readString(r, order, (*string)(e))
-
- case *proto.DatabaseID:
- err = serializer.readString(r, order, (*string)(e))
-
- case *hash.Hash:
- err = serializer.readFixedSizeBytes(r, hash.HashSize, (*e)[:])
-
- case *proto.AccountAddress:
- err = serializer.readFixedSizeBytes(r, hash.HashSize, (*e)[:])
-
- case *proto.AddrAndGas:
- err = serializer.readAddrAndGas(r, order, e)
-
- case **asymmetric.PublicKey:
- *e, err = serializer.readPublicKey(r, order)
-
- case **asymmetric.Signature:
- *e, err = serializer.readSignature(r, order)
-
- case *[]*asymmetric.PublicKey:
- serializer.readPublicKeys(r, order, e)
-
- case *[]*asymmetric.Signature:
- serializer.readSignatures(r, order, e)
-
- case *[]string:
- err = serializer.readStrings(r, order, e)
-
- case *[]*hash.Hash:
- err = serializer.readHashes(r, order, e)
-
- case *[]*proto.AccountAddress:
- err = serializer.readAccountAddresses(r, order, e)
-
- case *[]proto.DatabaseID:
- err = serializer.readDatabaseIDs(r, order, e)
-
- case *[]*proto.AddrAndGas:
- err = serializer.readAddrAndGases(r, order, e)
-
- default:
- // Fallback to BinaryUnmarshaler interface
- if i, ok := e.(encoding.BinaryUnmarshaler); ok {
- var buffer []byte
-
- if err = serializer.readBytes(r, order, &buffer); err != nil {
- return
- }
-
- return i.UnmarshalBinary(buffer)
- }
-
- log.Debugf("element type is: %#v", reflect.TypeOf(e).String())
- return ErrInvalidType
- }
-
- return
-}
-
-// ReadElements reads the element list in order from the given reader.
-func ReadElements(r io.Reader, order binary.ByteOrder, elements ...interface{}) (err error) {
- for _, element := range elements {
- if err = readElement(r, order, element); err != nil {
- break
- }
- }
-
- return
-}
-
-func writeElement(w io.Writer, order binary.ByteOrder, element interface{}) (err error) {
- switch e := element.(type) {
- case bool:
- err = serializer.writeUint8(w, func() uint8 {
- if e {
- return uint8(0x01)
- }
-
- return uint8(0x00)
- }())
-
- case *bool:
- err = serializer.writeUint8(w, func() uint8 {
- if *e {
- return uint8(0x01)
- }
-
- return uint8(0x00)
- }())
-
- case int8:
- err = serializer.writeUint8(w, uint8(e))
-
- case *int8:
- err = serializer.writeUint8(w, uint8(*e))
-
- case uint8:
- err = serializer.writeUint8(w, e)
-
- case *uint8:
- err = serializer.writeUint8(w, *e)
-
- case int16:
- err = serializer.writeUint16(w, order, uint16(e))
-
- case *int16:
- err = serializer.writeUint16(w, order, uint16(*e))
-
- case uint16:
- err = serializer.writeUint16(w, order, e)
-
- case *uint16:
- err = serializer.writeUint16(w, order, *e)
-
- case int32:
- err = serializer.writeUint32(w, order, uint32(e))
-
- case *int32:
- err = serializer.writeUint32(w, order, uint32(*e))
-
- case uint32:
- err = serializer.writeUint32(w, order, e)
-
- case *uint32:
- err = serializer.writeUint32(w, order, *e)
-
- case int64:
- err = serializer.writeUint64(w, order, uint64(e))
-
- case *int64:
- err = serializer.writeUint64(w, order, uint64(*e))
-
- case uint64:
- err = serializer.writeUint64(w, order, e)
-
- case *uint64:
- err = serializer.writeUint64(w, order, *e)
-
- case float64:
- err = serializer.writeFloat64(w, order, e)
-
- case *float64:
- err = serializer.writeFloat64(w, order, *e)
-
- case string:
- err = serializer.writeString(w, order, &e)
-
- case *string:
- err = serializer.writeString(w, order, e)
-
- case []byte:
- err = serializer.writeBytes(w, order, e)
-
- case *[]byte:
- err = serializer.writeBytes(w, order, *e)
-
- case []uint32:
- err = serializer.writeUint32s(w, order, e)
-
- case *[]uint32:
- err = serializer.writeUint32s(w, order, *e)
-
- case []uint64:
- err = serializer.writeUint64s(w, order, e)
-
- case *[]uint64:
- err = serializer.writeUint64s(w, order, *e)
-
- case time.Time:
- err = serializer.writeUint64(w, order, (uint64)(e.UnixNano()))
-
- case *time.Time:
- err = serializer.writeUint64(w, order, (uint64)(e.UnixNano()))
-
- case proto.NodeID:
- err = serializer.writeString(w, order, (*string)(&e))
-
- case *proto.NodeID:
- err = serializer.writeString(w, order, (*string)(e))
-
- case proto.DatabaseID:
- err = serializer.writeString(w, order, (*string)(&e))
-
- case *proto.DatabaseID:
- err = serializer.writeString(w, order, (*string)(e))
-
- case hash.Hash:
- err = serializer.writeFixedSizeBytes(w, hash.HashSize, e[:])
-
- case *hash.Hash:
- err = serializer.writeFixedSizeBytes(w, hash.HashSize, (*e)[:])
-
- case proto.AccountAddress:
- err = serializer.writeFixedSizeBytes(w, hash.HashSize, e[:])
-
- case *proto.AccountAddress:
- err = serializer.writeFixedSizeBytes(w, hash.HashSize, (*e)[:])
-
- case *proto.AddrAndGas:
- serializer.writeAddrAndGas(w, order, e)
-
- case proto.AddrAndGas:
- serializer.writeAddrAndGas(w, order, &e)
-
- case *asymmetric.PublicKey:
- serializer.writePublicKey(w, order, e)
-
- case **asymmetric.PublicKey:
- serializer.writePublicKey(w, order, *e)
-
- case *asymmetric.Signature:
- serializer.writeSignature(w, order, e)
-
- case **asymmetric.Signature:
- serializer.writeSignature(w, order, *e)
-
- case []*asymmetric.Signature:
- err = serializer.writeSignatures(w, order, e)
-
- case *[]*asymmetric.Signature:
- err = serializer.writeSignatures(w, order, *e)
-
- case []*asymmetric.PublicKey:
- err = serializer.writePublicKeys(w, order, e)
-
- case *[]*asymmetric.PublicKey:
- err = serializer.writePublicKeys(w, order, *e)
-
- case []string:
- err = serializer.writeStrings(w, order, e)
-
- case *([]string):
- err = serializer.writeStrings(w, order, *e)
-
- case []*hash.Hash:
- err = serializer.writeHashes(w, order, e)
-
- case *[]*hash.Hash:
- err = serializer.writeHashes(w, order, *e)
-
- case []*proto.AccountAddress:
- err = serializer.writeAccountAddresses(w, order, e)
-
- case *[]*proto.AccountAddress:
- err = serializer.writeAccountAddresses(w, order, *e)
-
- case []proto.DatabaseID:
- err = serializer.writeDatabaseIDs(w, order, e)
-
- case *[]proto.DatabaseID:
- err = serializer.writeDatabaseIDs(w, order, *e)
-
- case []*proto.AddrAndGas:
- err = serializer.writeAddrAndGases(w, order, e)
-
- case *[]*proto.AddrAndGas:
- err = serializer.writeAddrAndGases(w, order, *e)
-
- default:
- // Fallback to BinaryMarshaler interface
- if i, ok := e.(encoding.BinaryMarshaler); ok {
- var data []byte
-
- if data, err = i.MarshalBinary(); err == nil {
- err = serializer.writeBytes(w, order, data)
- }
-
- return
- }
-
- log.Debugf("element type is: %#v", reflect.TypeOf(e).String())
- return ErrInvalidType
- }
-
- return
-}
-
-// WriteElements writes the element list in order to the given writer.
-func WriteElements(w io.Writer, order binary.ByteOrder, elements ...interface{}) (err error) {
- for _, element := range elements {
- if err = writeElement(w, order, element); err != nil {
- break
- }
- }
-
- return
-}
diff --git a/cmd/hotfix/observer-upgrade/main.go b/cmd/hotfix/observer-upgrade/main.go
deleted file mode 100644
index fae13f31b..000000000
--- a/cmd/hotfix/observer-upgrade/main.go
+++ /dev/null
@@ -1,222 +0,0 @@
-/*
- * Copyright 2018 The CovenantSQL Authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package main
-
-import (
- "encoding/binary"
- "errors"
- "flag"
- "os"
-
- "github.com/CovenantSQL/CovenantSQL/crypto/hash"
- ct "github.com/CovenantSQL/CovenantSQL/sqlchain/otypes"
- "github.com/CovenantSQL/CovenantSQL/utils"
- "github.com/CovenantSQL/CovenantSQL/utils/log"
- bolt "github.com/coreos/bbolt"
-)
-
-type blockNode struct {
- count int32
- height int32
- block *ct.Block
- parent *blockNode
-}
-
-type blockIndex map[hash.Hash]*blockNode
-
-var (
- rootHash = &hash.Hash{}
- // Bucket keys
- blockBucket = []byte("block")
- blockCount2HeightBucket = []byte("block-count-to-height")
- // Errors
- errBlockBucketNotFound = errors.New("block bucket not found")
- // Flags
- path string
-)
-
-func init() {
- flag.StringVar(&path, "file", "observer.db", "Data file of observer to be upgraded")
- flag.Parse()
- log.SetLevel(log.DebugLevel)
-}
-
-func int32ToBytes(h int32) (data []byte) {
- data = make([]byte, 4)
- binary.BigEndian.PutUint32(data, uint32(h))
- return
-}
-
-func bytesToInt32(data []byte) int32 {
- return int32(binary.BigEndian.Uint32(data))
-}
-
-func process() (err error) {
- var (
- db *bolt.DB
- bis = make(map[string]blockIndex)
- )
- if db, err = bolt.Open(path, 0600, nil); err != nil {
- return
- }
- if err = db.View(func(tx *bolt.Tx) (err error) {
- var (
- bk, dbbk *bolt.Bucket
- cur *bolt.Cursor
- )
-
- if bk = tx.Bucket(blockBucket); bk == nil {
- err = errBlockBucketNotFound
- return
- }
-
- cur = bk.Cursor()
- for k, v := cur.First(); k != nil; k, v = cur.Next() {
- // Ensure that the cursor is pointing to a bucket
- if v != nil {
- log.WithFields(log.Fields{
- "k": string(k),
- }).Warn("KV pair detected in block bucket")
- continue
- }
-
- // Get bucket from key
- if dbbk = cur.Bucket().Bucket(k); dbbk == nil {
- log.WithFields(log.Fields{
- "k": string(k),
- }).Warn("failed to get bucket")
- continue
- }
-
- // Start processing a new database bucket
- log.WithFields(log.Fields{
- "database": string(k),
- }).Info("start processing a new database bucket")
- var (
- fb bool
- bi = make(blockIndex)
- )
- if err = dbbk.ForEach(func(k, v []byte) (err error) {
- if k == nil || v == nil {
- log.Warn("unexpected nil value of key or value")
- return
- }
- var (
- height = bytesToInt32(k)
- ok bool
- block *ct.Block
- parent, this *blockNode
- )
- if err = utils.DecodeMsgPack(v, &block); err != nil {
- log.WithFields(log.Fields{
- "height": height,
- "block": block,
- }).WithError(err).Warn("failed to decode block data")
- // Do not return error and keep `ForEach` running
- err = nil
- return
- }
- if block.ParentHash().IsEqual(rootHash) || !fb {
- fb = true
- // Clean block index -- seems that this db is restarted at some point
- bi = make(blockIndex)
- // Add first block
- this = &blockNode{
- height: height,
- block: block,
- }
- } else {
- // Add block according to parent
- if parent, ok = bi[block.SignedHeader.ParentHash]; !ok {
- log.WithFields(log.Fields{
- "height": height,
- "block": block,
- }).Warn("failed to lookup parent node")
- this = &blockNode{
- // Temporary set to height for unrecoverable chain
- count: height,
- height: height,
- block: block,
- }
- } else {
- this = &blockNode{
- count: parent.count + 1,
- height: height,
- block: block,
- parent: parent,
- }
- }
- }
- log.WithFields(log.Fields{
- "count": this.count,
- "height": this.height,
- "parent": this.block.SignedHeader.ParentHash.String(),
- "block": this.block.SignedHeader.BlockHash.String(),
- }).Info("add new block to index")
- bi[block.SignedHeader.BlockHash] = this
- return
- }); err != nil {
- return
- }
- bis[string(k)] = bi
- }
- return
- }); err != nil {
- return
- }
-
- // Rewrite count -> height index
- if err = db.Update(func(tx *bolt.Tx) (err error) {
- var bk, dbbk *bolt.Bucket
- if bk, err = tx.CreateBucketIfNotExists(blockCount2HeightBucket); err != nil {
- return
- }
- for dbid, bi := range bis {
- // Start processing a new database bucket
- log.WithFields(log.Fields{
- "database": dbid,
- }).Info("start adding count2height index for a new database bucket")
- if dbbk, err = bk.CreateBucketIfNotExists([]byte(dbid)); err != nil {
- return
- }
- for _, v := range bi {
- if err = dbbk.Put(int32ToBytes(v.count), int32ToBytes(v.height)); err != nil {
- return
- }
- log.WithFields(log.Fields{
- "diff": v.height - v.count,
- "count": v.count,
- "height": v.height,
- "parent": v.block.SignedHeader.ParentHash.String(),
- "block": v.block.SignedHeader.BlockHash.String(),
- }).Info("add new block count2height index")
- }
- }
- return
- }); err != nil {
- return
- }
-
- return
-}
-
-func main() {
- if err := process(); err != nil {
- log.WithError(err).Error("failed to process data file")
- os.Exit(1)
- }
-}
diff --git a/sqlchain/otypes/billing_req.go b/sqlchain/otypes/billing_req.go
deleted file mode 100644
index 2b5c360d2..000000000
--- a/sqlchain/otypes/billing_req.go
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright 2018 The CovenantSQL Authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package otypes
-
-import (
- pt "github.com/CovenantSQL/CovenantSQL/blockproducer/otypes"
- "github.com/CovenantSQL/CovenantSQL/proto"
-)
-
-// AdviseBillingReq defines a request of the AdviseBillingRequest RPC method.
-type AdviseBillingReq struct {
- proto.Envelope
- Req *pt.BillingRequest
-}
-
-// AdviseBillingResp defines a request of the AdviseBillingRequest RPC method.
-type AdviseBillingResp struct {
- proto.Envelope
- Resp *pt.BillingRequest
-}
diff --git a/sqlchain/otypes/block.go b/sqlchain/otypes/block.go
deleted file mode 100644
index 9cf4b8ff0..000000000
--- a/sqlchain/otypes/block.go
+++ /dev/null
@@ -1,186 +0,0 @@
-/*
- * Copyright 2018 The CovenantSQL Authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package otypes
-
-import (
- "reflect"
- "time"
-
- "github.com/CovenantSQL/CovenantSQL/crypto/asymmetric"
- "github.com/CovenantSQL/CovenantSQL/crypto/hash"
- "github.com/CovenantSQL/CovenantSQL/crypto/kms"
- "github.com/CovenantSQL/CovenantSQL/merkle"
- "github.com/CovenantSQL/CovenantSQL/proto"
- "github.com/CovenantSQL/CovenantSQL/utils/log"
-)
-
-//go:generate hsp
-
-// Header is a block header.
-type Header struct {
- Version int32
- Producer proto.NodeID
- GenesisHash hash.Hash
- ParentHash hash.Hash
- MerkleRoot hash.Hash
- Timestamp time.Time
-}
-
-// SignedHeader is block header along with its producer signature.
-type SignedHeader struct {
- Header
- BlockHash hash.Hash
- Signee *asymmetric.PublicKey
- Signature *asymmetric.Signature
-}
-
-// Verify verifies the signature of the signed header.
-func (s *SignedHeader) Verify() error {
- if !s.Signature.Verify(s.BlockHash[:], s.Signee) {
- return ErrSignVerification
- }
-
- return nil
-}
-
-// VerifyAsGenesis verifies the signed header as a genesis block header.
-func (s *SignedHeader) VerifyAsGenesis() (err error) {
- log.WithFields(log.Fields{
- "producer": s.Producer,
- "root": s.GenesisHash.String(),
- "parent": s.ParentHash.String(),
- "merkle": s.MerkleRoot.String(),
- "block": s.BlockHash.String(),
- }).Debug("verify genesis header")
-
- // Assume that we can fetch public key from kms after initialization.
- pk, err := kms.GetPublicKey(s.Producer)
-
- if err != nil {
- return
- }
-
- if !reflect.DeepEqual(pk, s.Signee) {
- return ErrNodePublicKeyNotMatch
- }
-
- return s.Verify()
-}
-
-// Block is a node of blockchain.
-type Block struct {
- SignedHeader SignedHeader
- Queries []*hash.Hash
-}
-
-// PackAndSignBlock generates the signature for the Block from the given PrivateKey.
-func (b *Block) PackAndSignBlock(signer *asymmetric.PrivateKey) (err error) {
- // Calculate merkle root
- b.SignedHeader.MerkleRoot = *merkle.NewMerkle(b.Queries).GetRoot()
- buffer, err := b.SignedHeader.Header.MarshalHash()
- if err != nil {
- return
- }
-
- b.SignedHeader.Signee = signer.PubKey()
- b.SignedHeader.BlockHash = hash.THashH(buffer)
- b.SignedHeader.Signature, err = signer.Sign(b.SignedHeader.BlockHash[:])
-
- return
-}
-
-// PushAckedQuery pushes a acknowledged and verified query into the block.
-func (b *Block) PushAckedQuery(h *hash.Hash) {
- if b.Queries == nil {
- // TODO(leventeliu): set appropriate capacity.
- b.Queries = make([]*hash.Hash, 0, 100)
- }
-
- b.Queries = append(b.Queries, h)
-}
-
-// Verify verifies the merkle root and header signature of the block.
-func (b *Block) Verify() (err error) {
- // Verify merkle root
- if MerkleRoot := *merkle.NewMerkle(b.Queries).GetRoot(); !MerkleRoot.IsEqual(
- &b.SignedHeader.MerkleRoot,
- ) {
- return ErrMerkleRootVerification
- }
-
- // Verify block hash
- buffer, err := b.SignedHeader.Header.MarshalHash()
- if err != nil {
- return
- }
-
- if h := hash.THashH(buffer); !h.IsEqual(&b.SignedHeader.BlockHash) {
- return ErrHashVerification
- }
-
- // Verify signature
- return b.SignedHeader.Verify()
-}
-
-// VerifyAsGenesis verifies the block as a genesis block.
-func (b *Block) VerifyAsGenesis() (err error) {
- // Assume that we can fetch public key from kms after initialization.
- pk, err := kms.GetPublicKey(b.Producer())
-
- if err != nil {
- return
- }
-
- if !reflect.DeepEqual(pk, b.SignedHeader.Signee) {
- return ErrNodePublicKeyNotMatch
- }
-
- return b.Verify()
-}
-
-// Timestamp returns the timestamp field of the block header.
-func (b *Block) Timestamp() time.Time {
- return b.SignedHeader.Timestamp
-}
-
-// Producer returns the producer field of the block header.
-func (b *Block) Producer() proto.NodeID {
- return b.SignedHeader.Producer
-}
-
-// ParentHash returns the parent hash field of the block header.
-func (b *Block) ParentHash() *hash.Hash {
- return &b.SignedHeader.ParentHash
-}
-
-// BlockHash returns the parent hash field of the block header.
-func (b *Block) BlockHash() *hash.Hash {
- return &b.SignedHeader.BlockHash
-}
-
-// GenesisHash returns the parent hash field of the block header.
-func (b *Block) GenesisHash() *hash.Hash {
- return &b.SignedHeader.GenesisHash
-}
-
-// Signee returns the signee field of the block signed header.
-func (b *Block) Signee() *asymmetric.PublicKey {
- return b.SignedHeader.Signee
-}
-
-// Blocks is Block (reference) array.
-type Blocks []*Block
diff --git a/sqlchain/otypes/block_gen.go b/sqlchain/otypes/block_gen.go
deleted file mode 100644
index ebd75b2fe..000000000
--- a/sqlchain/otypes/block_gen.go
+++ /dev/null
@@ -1,179 +0,0 @@
-package otypes
-
-// Code generated by github.com/CovenantSQL/HashStablePack DO NOT EDIT.
-
-import (
- hsp "github.com/CovenantSQL/HashStablePack/marshalhash"
-)
-
-// MarshalHash marshals for hash
-func (z *Block) MarshalHash() (o []byte, err error) {
- var b []byte
- o = hsp.Require(b, z.Msgsize())
- // map header, size 2
- o = append(o, 0x82, 0x82)
- if oTemp, err := z.SignedHeader.MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
- }
- o = append(o, 0x82)
- o = hsp.AppendArrayHeader(o, uint32(len(z.Queries)))
- for za0001 := range z.Queries {
- if z.Queries[za0001] == nil {
- o = hsp.AppendNil(o)
- } else {
- if oTemp, err := z.Queries[za0001].MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
- }
- }
- }
- return
-}
-
-// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
-func (z *Block) Msgsize() (s int) {
- s = 1 + 13 + z.SignedHeader.Msgsize() + 8 + hsp.ArrayHeaderSize
- for za0001 := range z.Queries {
- if z.Queries[za0001] == nil {
- s += hsp.NilSize
- } else {
- s += z.Queries[za0001].Msgsize()
- }
- }
- return
-}
-
-// MarshalHash marshals for hash
-func (z Blocks) MarshalHash() (o []byte, err error) {
- var b []byte
- o = hsp.Require(b, z.Msgsize())
- o = hsp.AppendArrayHeader(o, uint32(len(z)))
- for za0001 := range z {
- if z[za0001] == nil {
- o = hsp.AppendNil(o)
- } else {
- if oTemp, err := z[za0001].MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
- }
- }
- }
- return
-}
-
-// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
-func (z Blocks) Msgsize() (s int) {
- s = hsp.ArrayHeaderSize
- for za0001 := range z {
- if z[za0001] == nil {
- s += hsp.NilSize
- } else {
- s += z[za0001].Msgsize()
- }
- }
- return
-}
-
-// MarshalHash marshals for hash
-func (z *Header) MarshalHash() (o []byte, err error) {
- var b []byte
- o = hsp.Require(b, z.Msgsize())
- // map header, size 6
- o = append(o, 0x86, 0x86)
- if oTemp, err := z.GenesisHash.MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
- }
- o = append(o, 0x86)
- if oTemp, err := z.ParentHash.MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
- }
- o = append(o, 0x86)
- if oTemp, err := z.MerkleRoot.MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
- }
- o = append(o, 0x86)
- o = hsp.AppendInt32(o, z.Version)
- o = append(o, 0x86)
- if oTemp, err := z.Producer.MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
- }
- o = append(o, 0x86)
- o = hsp.AppendTime(o, z.Timestamp)
- return
-}
-
-// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
-func (z *Header) Msgsize() (s int) {
- s = 1 + 12 + z.GenesisHash.Msgsize() + 11 + z.ParentHash.Msgsize() + 11 + z.MerkleRoot.Msgsize() + 8 + hsp.Int32Size + 9 + z.Producer.Msgsize() + 10 + hsp.TimeSize
- return
-}
-
-// MarshalHash marshals for hash
-func (z *SignedHeader) MarshalHash() (o []byte, err error) {
- var b []byte
- o = hsp.Require(b, z.Msgsize())
- // map header, size 4
- o = append(o, 0x84, 0x84)
- if z.Signee == nil {
- o = hsp.AppendNil(o)
- } else {
- if oTemp, err := z.Signee.MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
- }
- }
- o = append(o, 0x84)
- if z.Signature == nil {
- o = hsp.AppendNil(o)
- } else {
- if oTemp, err := z.Signature.MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
- }
- }
- o = append(o, 0x84)
- if oTemp, err := z.Header.MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
- }
- o = append(o, 0x84)
- if oTemp, err := z.BlockHash.MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
- }
- return
-}
-
-// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
-func (z *SignedHeader) Msgsize() (s int) {
- s = 1 + 7
- if z.Signee == nil {
- s += hsp.NilSize
- } else {
- s += z.Signee.Msgsize()
- }
- s += 10
- if z.Signature == nil {
- s += hsp.NilSize
- } else {
- s += z.Signature.Msgsize()
- }
- s += 7 + z.Header.Msgsize() + 10 + z.BlockHash.Msgsize()
- return
-}
diff --git a/sqlchain/otypes/block_gen_test.go b/sqlchain/otypes/block_gen_test.go
deleted file mode 100644
index 7743f3729..000000000
--- a/sqlchain/otypes/block_gen_test.go
+++ /dev/null
@@ -1,158 +0,0 @@
-package otypes
-
-// Code generated by github.com/CovenantSQL/HashStablePack DO NOT EDIT.
-
-import (
- "bytes"
- "crypto/rand"
- "encoding/binary"
- "testing"
-)
-
-func TestMarshalHashBlock(t *testing.T) {
- v := Block{}
- binary.Read(rand.Reader, binary.BigEndian, &v)
- bts1, err := v.MarshalHash()
- if err != nil {
- t.Fatal(err)
- }
- bts2, err := v.MarshalHash()
- if err != nil {
- t.Fatal(err)
- }
- if !bytes.Equal(bts1, bts2) {
- t.Fatal("hash not stable")
- }
-}
-
-func BenchmarkMarshalHashBlock(b *testing.B) {
- v := Block{}
- b.ReportAllocs()
- b.ResetTimer()
- for i := 0; i < b.N; i++ {
- v.MarshalHash()
- }
-}
-
-func BenchmarkAppendMsgBlock(b *testing.B) {
- v := Block{}
- bts := make([]byte, 0, v.Msgsize())
- bts, _ = v.MarshalHash()
- b.SetBytes(int64(len(bts)))
- b.ReportAllocs()
- b.ResetTimer()
- for i := 0; i < b.N; i++ {
- bts, _ = v.MarshalHash()
- }
-}
-
-func TestMarshalHashBlocks(t *testing.T) {
- v := Blocks{}
- binary.Read(rand.Reader, binary.BigEndian, &v)
- bts1, err := v.MarshalHash()
- if err != nil {
- t.Fatal(err)
- }
- bts2, err := v.MarshalHash()
- if err != nil {
- t.Fatal(err)
- }
- if !bytes.Equal(bts1, bts2) {
- t.Fatal("hash not stable")
- }
-}
-
-func BenchmarkMarshalHashBlocks(b *testing.B) {
- v := Blocks{}
- b.ReportAllocs()
- b.ResetTimer()
- for i := 0; i < b.N; i++ {
- v.MarshalHash()
- }
-}
-
-func BenchmarkAppendMsgBlocks(b *testing.B) {
- v := Blocks{}
- bts := make([]byte, 0, v.Msgsize())
- bts, _ = v.MarshalHash()
- b.SetBytes(int64(len(bts)))
- b.ReportAllocs()
- b.ResetTimer()
- for i := 0; i < b.N; i++ {
- bts, _ = v.MarshalHash()
- }
-}
-
-func TestMarshalHashHeader(t *testing.T) {
- v := Header{}
- binary.Read(rand.Reader, binary.BigEndian, &v)
- bts1, err := v.MarshalHash()
- if err != nil {
- t.Fatal(err)
- }
- bts2, err := v.MarshalHash()
- if err != nil {
- t.Fatal(err)
- }
- if !bytes.Equal(bts1, bts2) {
- t.Fatal("hash not stable")
- }
-}
-
-func BenchmarkMarshalHashHeader(b *testing.B) {
- v := Header{}
- b.ReportAllocs()
- b.ResetTimer()
- for i := 0; i < b.N; i++ {
- v.MarshalHash()
- }
-}
-
-func BenchmarkAppendMsgHeader(b *testing.B) {
- v := Header{}
- bts := make([]byte, 0, v.Msgsize())
- bts, _ = v.MarshalHash()
- b.SetBytes(int64(len(bts)))
- b.ReportAllocs()
- b.ResetTimer()
- for i := 0; i < b.N; i++ {
- bts, _ = v.MarshalHash()
- }
-}
-
-func TestMarshalHashSignedHeader(t *testing.T) {
- v := SignedHeader{}
- binary.Read(rand.Reader, binary.BigEndian, &v)
- bts1, err := v.MarshalHash()
- if err != nil {
- t.Fatal(err)
- }
- bts2, err := v.MarshalHash()
- if err != nil {
- t.Fatal(err)
- }
- if !bytes.Equal(bts1, bts2) {
- t.Fatal("hash not stable")
- }
-}
-
-func BenchmarkMarshalHashSignedHeader(b *testing.B) {
- v := SignedHeader{}
- b.ReportAllocs()
- b.ResetTimer()
- for i := 0; i < b.N; i++ {
- v.MarshalHash()
- }
-}
-
-func BenchmarkAppendMsgSignedHeader(b *testing.B) {
- v := SignedHeader{}
- bts := make([]byte, 0, v.Msgsize())
- bts, _ = v.MarshalHash()
- b.SetBytes(int64(len(bts)))
- b.ReportAllocs()
- b.ResetTimer()
- for i := 0; i < b.N; i++ {
- bts, _ = v.MarshalHash()
- }
-}
diff --git a/sqlchain/otypes/block_test.go b/sqlchain/otypes/block_test.go
deleted file mode 100644
index 84715bfd9..000000000
--- a/sqlchain/otypes/block_test.go
+++ /dev/null
@@ -1,287 +0,0 @@
-/*
- * Copyright 2018 The CovenantSQL Authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package otypes
-
-import (
- "bytes"
- "math/big"
- "reflect"
- "testing"
-
- "github.com/CovenantSQL/CovenantSQL/crypto/asymmetric"
- "github.com/CovenantSQL/CovenantSQL/crypto/hash"
- "github.com/CovenantSQL/CovenantSQL/utils"
-)
-
-func TestSignAndVerify(t *testing.T) {
- block, err := createRandomBlock(genesisHash, true)
-
- if err != nil {
- t.Fatalf("error occurred: %v", err)
- }
-
- if err = block.Verify(); err != nil {
- t.Fatalf("error occurred: %v", err)
- }
-
- block.SignedHeader.BlockHash[0]++
-
- if err = block.Verify(); err != ErrHashVerification {
- t.Fatalf("unexpected error: %v", err)
- }
-
- h := &hash.Hash{}
- block.PushAckedQuery(h)
-
- if err = block.Verify(); err != ErrMerkleRootVerification {
- t.Fatalf("unexpected error: %v", err)
- }
-}
-
-func TestHeaderMarshalUnmarshaler(t *testing.T) {
- block, err := createRandomBlock(genesisHash, false)
-
- if err != nil {
- t.Fatalf("error occurred: %v", err)
- }
-
- origin := &block.SignedHeader.Header
- enc, err := utils.EncodeMsgPack(origin)
-
- if err != nil {
- t.Fatalf("error occurred: %v", err)
- }
-
- dec := &Header{}
- if err = utils.DecodeMsgPack(enc.Bytes(), dec); err != nil {
- t.Fatalf("error occurred: %v", err)
- }
-
- bts1, err := origin.MarshalHash()
- if err != nil {
- t.Fatalf("error occurred: %v", err)
- }
-
- bts2, err := dec.MarshalHash()
- if err != nil {
- t.Fatalf("error occurred: %v", err)
- }
-
- if !bytes.Equal(bts1, bts2) {
- t.Fatal("hash not stable")
- }
-
- if !reflect.DeepEqual(origin, dec) {
- t.Fatalf("values don't match:\n\tv1 = %+v\n\tv2 = %+v", origin, dec)
- }
-}
-
-func TestSignedHeaderMarshaleUnmarshaler(t *testing.T) {
- block, err := createRandomBlock(genesisHash, true)
-
- if err != nil {
- t.Fatalf("error occurred: %v", err)
- }
-
- origin := &block.SignedHeader
- enc, err := utils.EncodeMsgPack(origin)
-
- if err != nil {
- t.Fatalf("error occurred: %v", err)
- }
-
- dec := &SignedHeader{}
-
- if err = utils.DecodeMsgPack(enc.Bytes(), dec); err != nil {
- t.Fatalf("error occurred: %v", err)
- }
-
- bts1, err := origin.MarshalHash()
- if err != nil {
- t.Fatalf("error occurred: %v", err)
- }
-
- bts2, err := dec.MarshalHash()
- if err != nil {
- t.Fatalf("error occurred: %v", err)
- }
-
- if !bytes.Equal(bts1, bts2) {
- t.Fatal("hash not stable")
- }
-
- if !reflect.DeepEqual(origin.Header, dec.Header) {
- t.Fatalf("values don't match:\n\tv1 = %+v\n\tv2 = %+v", origin.Header, dec.Header)
- }
-
- if err = origin.Verify(); err != nil {
- t.Fatalf("error occurred: %v", err)
- }
-
- if err = dec.Verify(); err != nil {
- t.Fatalf("error occurred: %v", err)
- }
-}
-
-func TestBlockMarshalUnmarshaler(t *testing.T) {
- origin, err := createRandomBlock(genesisHash, false)
- if err != nil {
- t.Fatalf("error occurred: %v", err)
- }
- origin2, err := createRandomBlock(genesisHash, false)
- if err != nil {
- t.Fatalf("error occurred: %v", err)
- }
-
- blocks := make(Blocks, 0, 2)
- blocks = append(blocks, origin)
- blocks = append(blocks, origin2)
- blocks = append(blocks, nil)
-
- blocks2 := make(Blocks, 0, 2)
- blocks2 = append(blocks2, origin)
- blocks2 = append(blocks2, origin2)
- blocks2 = append(blocks2, nil)
-
- bts1, err := blocks.MarshalHash()
- if err != nil {
- t.Fatalf("error occurred: %v", err)
- }
-
- bts2, err := blocks2.MarshalHash()
- if err != nil {
- t.Fatalf("error occurred: %v", err)
- }
-
- if !bytes.Equal(bts1, bts2) {
- t.Fatal("hash not stable")
- }
-
- enc, err := utils.EncodeMsgPack(origin)
-
- if err != nil {
- t.Fatalf("error occurred: %v", err)
- }
-
- dec := &Block{}
-
- if err = utils.DecodeMsgPack(enc.Bytes(), dec); err != nil {
- t.Fatalf("error occurred: %v", err)
- }
-
- bts1, err = origin.MarshalHash()
- if err != nil {
- t.Fatalf("error occurred: %v", err)
- }
-
- bts2, err = dec.MarshalHash()
- if err != nil {
- t.Fatalf("error occurred: %v", err)
- }
-
- if !bytes.Equal(bts1, bts2) {
- t.Fatal("hash not stable")
- }
-
- if !reflect.DeepEqual(origin, dec) {
- t.Fatalf("values don't match:\n\tv1 = %+v\n\tv2 = %+v", origin, dec)
- }
-}
-
-func TestGenesis(t *testing.T) {
- genesis, err := createRandomBlock(genesisHash, true)
-
- if err != nil {
- t.Fatalf("error occurred: %v", err)
- }
-
- if err = genesis.VerifyAsGenesis(); err != nil {
- t.Fatalf("error occurred: %v", err)
- }
-
- if err = genesis.SignedHeader.VerifyAsGenesis(); err != nil {
- t.Fatalf("error occurred: %v", err)
- }
-
- // Test non-genesis block
- genesis, err = createRandomBlock(genesisHash, false)
-
- if err != nil {
- t.Fatalf("error occurred: %v", err)
- }
-
- if err = genesis.VerifyAsGenesis(); err != nil {
- t.Logf("Error occurred as expected: %v", err)
- } else {
- t.Fatal("unexpected result: returned nil while expecting an error")
- }
-
- if err = genesis.SignedHeader.VerifyAsGenesis(); err != nil {
- t.Logf("Error occurred as expected: %v", err)
- } else {
- t.Fatal("unexpected result: returned nil while expecting an error")
- }
-
- // Test altered public key block
- genesis, err = createRandomBlock(genesisHash, true)
-
- if err != nil {
- t.Fatalf("error occurred: %v", err)
- }
-
- _, pub, err := asymmetric.GenSecp256k1KeyPair()
-
- if err != nil {
- t.Fatalf("error occurred: %v", err)
- }
-
- genesis.SignedHeader.Signee = pub
-
- if err = genesis.VerifyAsGenesis(); err != nil {
- t.Logf("Error occurred as expected: %v", err)
- } else {
- t.Fatal("unexpected result: returned nil while expecting an error")
- }
-
- if err = genesis.SignedHeader.VerifyAsGenesis(); err != nil {
- t.Logf("Error occurred as expected: %v", err)
- } else {
- t.Fatal("unexpected result: returned nil while expecting an error")
- }
-
- // Test altered signature
- genesis, err = createRandomBlock(genesisHash, true)
-
- if err != nil {
- t.Fatalf("error occurred: %v", err)
- }
-
- genesis.SignedHeader.Signature.R.Add(genesis.SignedHeader.Signature.R, big.NewInt(int64(1)))
- genesis.SignedHeader.Signature.S.Add(genesis.SignedHeader.Signature.S, big.NewInt(int64(1)))
-
- if err = genesis.VerifyAsGenesis(); err != nil {
- t.Logf("Error occurred as expected: %v", err)
- } else {
- t.Fatalf("unexpected error: %v", err)
- }
-
- if err = genesis.SignedHeader.VerifyAsGenesis(); err != nil {
- t.Logf("Error occurred as expected: %v", err)
- } else {
- t.Fatal("unexpected result: returned nil while expecting an error")
- }
-}
diff --git a/sqlchain/otypes/doc.go b/sqlchain/otypes/doc.go
deleted file mode 100644
index 00ef1d7d4..000000000
--- a/sqlchain/otypes/doc.go
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- * Copyright 2018 The CovenantSQL Authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-// Package otypes defines commonly used types for sql-chain.
-package otypes
diff --git a/sqlchain/otypes/errors.go b/sqlchain/otypes/errors.go
deleted file mode 100644
index 9a065843d..000000000
--- a/sqlchain/otypes/errors.go
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright 2018 The CovenantSQL Authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package otypes
-
-import (
- "errors"
-)
-
-var (
- // ErrHashVerification indicates a failed hash verification.
- ErrHashVerification = errors.New("hash verification failed")
-
- // ErrSignVerification indicates a failed signature verification.
- ErrSignVerification = errors.New("signature verification failed")
-
- // ErrMerkleRootVerification indicates a failed merkle root verificatin.
- ErrMerkleRootVerification = errors.New("merkle root verification failed")
-
- // ErrNodePublicKeyNotMatch indicates that the public key given with a node does not match the
- // one in the key store.
- ErrNodePublicKeyNotMatch = errors.New("node publick key doesn't match")
-)
diff --git a/sqlchain/otypes/observer.go b/sqlchain/otypes/observer.go
deleted file mode 100644
index 3eb20dce2..000000000
--- a/sqlchain/otypes/observer.go
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Copyright 2018 The CovenantSQL Authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package otypes
-
-const (
- // ReplicateFromBeginning is the replication offset observes from genesis block.
- ReplicateFromBeginning = int32(0)
- // ReplicateFromNewest is the replication offset observes from block head of current node.
- ReplicateFromNewest = int32(-1)
-)
diff --git a/sqlchain/otypes/xxx_test.go b/sqlchain/otypes/xxx_test.go
deleted file mode 100644
index 428be91c5..000000000
--- a/sqlchain/otypes/xxx_test.go
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- * Copyright 2018 The CovenantSQL Authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package otypes
-
-import (
- "io/ioutil"
- "math/rand"
- "os"
- "testing"
- "time"
-
- "github.com/CovenantSQL/CovenantSQL/crypto/asymmetric"
- "github.com/CovenantSQL/CovenantSQL/crypto/hash"
- "github.com/CovenantSQL/CovenantSQL/crypto/kms"
- "github.com/CovenantSQL/CovenantSQL/pow/cpuminer"
- "github.com/CovenantSQL/CovenantSQL/proto"
- "github.com/CovenantSQL/CovenantSQL/utils/log"
-)
-
-var (
- genesisHash = hash.Hash{}
-)
-
-func setup() {
- rand.Seed(time.Now().UnixNano())
- rand.Read(genesisHash[:])
- f, err := ioutil.TempFile("", "keystore")
-
- if err != nil {
- panic(err)
- }
-
- f.Close()
-
- if err = kms.InitPublicKeyStore(f.Name(), nil); err != nil {
- panic(err)
- }
-
- kms.Unittest = true
-
- if priv, pub, err := asymmetric.GenSecp256k1KeyPair(); err == nil {
- kms.SetLocalKeyPair(priv, pub)
- } else {
- panic(err)
- }
-
- log.SetOutput(os.Stdout)
- log.SetLevel(log.DebugLevel)
-}
-
-func createRandomString(offset, length int, s *string) {
- buff := make([]byte, rand.Intn(length)+offset)
- rand.Read(buff)
- *s = string(buff)
-}
-
-func createRandomStrings(offset, length, soffset, slength int) (s []string) {
- s = make([]string, rand.Intn(length)+offset)
-
- for i := range s {
- createRandomString(soffset, slength, &s[i])
- }
-
- return
-}
-
-func createRandomBlock(parent hash.Hash, isGenesis bool) (b *Block, err error) {
- // Generate key pair
- priv, pub, err := asymmetric.GenSecp256k1KeyPair()
-
- if err != nil {
- return
- }
-
- h := hash.Hash{}
- rand.Read(h[:])
-
- b = &Block{
- SignedHeader: SignedHeader{
- Header: Header{
- Version: 0x01000000,
- Producer: proto.NodeID(h.String()),
- GenesisHash: genesisHash,
- ParentHash: parent,
- Timestamp: time.Now().UTC(),
- },
- },
- }
-
- for i, n := 0, rand.Intn(10)+10; i < n; i++ {
- h := &hash.Hash{}
- rand.Read(h[:])
- b.PushAckedQuery(h)
- }
-
- if isGenesis {
- // Compute nonce with public key
- nonceCh := make(chan cpuminer.NonceInfo)
- quitCh := make(chan struct{})
- miner := cpuminer.NewCPUMiner(quitCh)
- go miner.ComputeBlockNonce(cpuminer.MiningBlock{
- Data: pub.Serialize(),
- NonceChan: nonceCh,
- Stop: nil,
- }, cpuminer.Uint256{A: 0, B: 0, C: 0, D: 0}, 4)
- nonce := <-nonceCh
- close(quitCh)
- close(nonceCh)
- // Add public key to KMS
- id := cpuminer.HashBlock(pub.Serialize(), nonce.Nonce)
- b.SignedHeader.Header.Producer = proto.NodeID(id.String())
-
- if err = kms.SetPublicKey(proto.NodeID(id.String()), nonce.Nonce, pub); err != nil {
- return nil, err
- }
-
- // Set genesis hash as zero value
- b.SignedHeader.GenesisHash = hash.Hash{}
- }
-
- err = b.PackAndSignBlock(priv)
- return
-}
-
-func TestMain(m *testing.M) {
- setup()
- os.Exit(m.Run())
-}
diff --git a/worker/otypes/ack_type.go b/worker/otypes/ack_type.go
deleted file mode 100644
index 795c99e1a..000000000
--- a/worker/otypes/ack_type.go
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * Copyright 2018 The CovenantSQL Authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package otypes
-
-import (
- "time"
-
- "github.com/CovenantSQL/CovenantSQL/crypto/asymmetric"
- "github.com/CovenantSQL/CovenantSQL/crypto/hash"
- "github.com/CovenantSQL/CovenantSQL/proto"
-)
-
-//go:generate hsp
-
-// AckHeader defines client ack entity.
-type AckHeader struct {
- Response SignedResponseHeader `json:"r"`
- NodeID proto.NodeID `json:"i"` // ack node id
- Timestamp time.Time `json:"t"` // time in UTC zone
-}
-
-// SignedAckHeader defines client signed ack entity.
-type SignedAckHeader struct {
- AckHeader
- Hash hash.Hash `json:"hh"`
- Signee *asymmetric.PublicKey `json:"e"`
- Signature *asymmetric.Signature `json:"s"`
-}
-
-// Ack defines a whole client ack request entity.
-type Ack struct {
- proto.Envelope
- Header SignedAckHeader `json:"h"`
-}
-
-// AckResponse defines client ack response entity.
-type AckResponse struct{}
-
-// Verify checks hash and signature in ack header.
-func (sh *SignedAckHeader) Verify() (err error) {
- // verify response
- if err = sh.Response.Verify(); err != nil {
- return
- }
- if err = verifyHash(&sh.AckHeader, &sh.Hash); err != nil {
- return
- }
- // verify sign
- if sh.Signee == nil || sh.Signature == nil || !sh.Signature.Verify(sh.Hash[:], sh.Signee) {
- return ErrSignVerification
- }
- return
-}
-
-// Sign the request.
-func (sh *SignedAckHeader) Sign(signer *asymmetric.PrivateKey, verifyReqHeader bool) (err error) {
- // Only used by ack worker, and ack.Header is verified before build ack
- if verifyReqHeader {
- // check original header signature
- if err = sh.Response.Verify(); err != nil {
- return
- }
- }
-
- // build hash
- if err = buildHash(&sh.AckHeader, &sh.Hash); err != nil {
- return
- }
-
- // sign
- sh.Signature, err = signer.Sign(sh.Hash[:])
- sh.Signee = signer.PubKey()
-
- return
-}
-
-// Verify checks hash and signature in ack.
-func (a *Ack) Verify() error {
- return a.Header.Verify()
-}
-
-// Sign the request.
-func (a *Ack) Sign(signer *asymmetric.PrivateKey, verifyReqHeader bool) (err error) {
- // sign
- return a.Header.Sign(signer, verifyReqHeader)
-}
-
-// ResponseHash returns the deep shadowed Response Hash field.
-func (sh *SignedAckHeader) ResponseHash() hash.Hash {
- return sh.AckHeader.Response.Hash
-}
-
-// SignedRequestHeader returns the deep shadowed Request reference.
-func (sh *SignedAckHeader) SignedRequestHeader() *SignedRequestHeader {
- return &sh.AckHeader.Response.Request
-}
-
-// SignedResponseHeader returns the Response reference.
-func (sh *SignedAckHeader) SignedResponseHeader() *SignedResponseHeader {
- return &sh.Response
-}
diff --git a/worker/otypes/ack_type_gen.go b/worker/otypes/ack_type_gen.go
deleted file mode 100644
index 9c4a845c0..000000000
--- a/worker/otypes/ack_type_gen.go
+++ /dev/null
@@ -1,143 +0,0 @@
-package otypes
-
-// Code generated by github.com/CovenantSQL/HashStablePack DO NOT EDIT.
-
-import (
- hsp "github.com/CovenantSQL/HashStablePack/marshalhash"
-)
-
-// MarshalHash marshals for hash
-func (z *Ack) MarshalHash() (o []byte, err error) {
- var b []byte
- o = hsp.Require(b, z.Msgsize())
- // map header, size 2
- o = append(o, 0x82, 0x82)
- if oTemp, err := z.Header.MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
- }
- o = append(o, 0x82)
- if oTemp, err := z.Envelope.MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
- }
- return
-}
-
-// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
-func (z *Ack) Msgsize() (s int) {
- s = 1 + 7 + z.Header.Msgsize() + 9 + z.Envelope.Msgsize()
- return
-}
-
-// MarshalHash marshals for hash
-func (z *AckHeader) MarshalHash() (o []byte, err error) {
- var b []byte
- o = hsp.Require(b, z.Msgsize())
- // map header, size 3
- o = append(o, 0x83, 0x83)
- if oTemp, err := z.Response.MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
- }
- o = append(o, 0x83)
- if oTemp, err := z.NodeID.MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
- }
- o = append(o, 0x83)
- o = hsp.AppendTime(o, z.Timestamp)
- return
-}
-
-// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
-func (z *AckHeader) Msgsize() (s int) {
- s = 1 + 9 + z.Response.Msgsize() + 7 + z.NodeID.Msgsize() + 10 + hsp.TimeSize
- return
-}
-
-// MarshalHash marshals for hash
-func (z AckResponse) MarshalHash() (o []byte, err error) {
- var b []byte
- o = hsp.Require(b, z.Msgsize())
- // map header, size 0
- o = append(o, 0x80)
- return
-}
-
-// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
-func (z AckResponse) Msgsize() (s int) {
- s = 1
- return
-}
-
-// MarshalHash marshals for hash
-func (z *SignedAckHeader) MarshalHash() (o []byte, err error) {
- var b []byte
- o = hsp.Require(b, z.Msgsize())
- // map header, size 4
- o = append(o, 0x84, 0x84)
- if z.Signee == nil {
- o = hsp.AppendNil(o)
- } else {
- if oTemp, err := z.Signee.MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
- }
- }
- o = append(o, 0x84)
- if z.Signature == nil {
- o = hsp.AppendNil(o)
- } else {
- if oTemp, err := z.Signature.MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
- }
- }
- // map header, size 3
- o = append(o, 0x84, 0x83, 0x83)
- if oTemp, err := z.AckHeader.Response.MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
- }
- o = append(o, 0x83)
- if oTemp, err := z.AckHeader.NodeID.MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
- }
- o = append(o, 0x83)
- o = hsp.AppendTime(o, z.AckHeader.Timestamp)
- o = append(o, 0x84)
- if oTemp, err := z.Hash.MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
- }
- return
-}
-
-// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
-func (z *SignedAckHeader) Msgsize() (s int) {
- s = 1 + 7
- if z.Signee == nil {
- s += hsp.NilSize
- } else {
- s += z.Signee.Msgsize()
- }
- s += 10
- if z.Signature == nil {
- s += hsp.NilSize
- } else {
- s += z.Signature.Msgsize()
- }
- s += 10 + 1 + 9 + z.AckHeader.Response.Msgsize() + 7 + z.AckHeader.NodeID.Msgsize() + 10 + hsp.TimeSize + 5 + z.Hash.Msgsize()
- return
-}
diff --git a/worker/otypes/ack_type_gen_test.go b/worker/otypes/ack_type_gen_test.go
deleted file mode 100644
index 3fc0faf87..000000000
--- a/worker/otypes/ack_type_gen_test.go
+++ /dev/null
@@ -1,158 +0,0 @@
-package otypes
-
-// Code generated by github.com/CovenantSQL/HashStablePack DO NOT EDIT.
-
-import (
- "bytes"
- "crypto/rand"
- "encoding/binary"
- "testing"
-)
-
-func TestMarshalHashAck(t *testing.T) {
- v := Ack{}
- binary.Read(rand.Reader, binary.BigEndian, &v)
- bts1, err := v.MarshalHash()
- if err != nil {
- t.Fatal(err)
- }
- bts2, err := v.MarshalHash()
- if err != nil {
- t.Fatal(err)
- }
- if !bytes.Equal(bts1, bts2) {
- t.Fatal("hash not stable")
- }
-}
-
-func BenchmarkMarshalHashAck(b *testing.B) {
- v := Ack{}
- b.ReportAllocs()
- b.ResetTimer()
- for i := 0; i < b.N; i++ {
- v.MarshalHash()
- }
-}
-
-func BenchmarkAppendMsgAck(b *testing.B) {
- v := Ack{}
- bts := make([]byte, 0, v.Msgsize())
- bts, _ = v.MarshalHash()
- b.SetBytes(int64(len(bts)))
- b.ReportAllocs()
- b.ResetTimer()
- for i := 0; i < b.N; i++ {
- bts, _ = v.MarshalHash()
- }
-}
-
-func TestMarshalHashAckHeader(t *testing.T) {
- v := AckHeader{}
- binary.Read(rand.Reader, binary.BigEndian, &v)
- bts1, err := v.MarshalHash()
- if err != nil {
- t.Fatal(err)
- }
- bts2, err := v.MarshalHash()
- if err != nil {
- t.Fatal(err)
- }
- if !bytes.Equal(bts1, bts2) {
- t.Fatal("hash not stable")
- }
-}
-
-func BenchmarkMarshalHashAckHeader(b *testing.B) {
- v := AckHeader{}
- b.ReportAllocs()
- b.ResetTimer()
- for i := 0; i < b.N; i++ {
- v.MarshalHash()
- }
-}
-
-func BenchmarkAppendMsgAckHeader(b *testing.B) {
- v := AckHeader{}
- bts := make([]byte, 0, v.Msgsize())
- bts, _ = v.MarshalHash()
- b.SetBytes(int64(len(bts)))
- b.ReportAllocs()
- b.ResetTimer()
- for i := 0; i < b.N; i++ {
- bts, _ = v.MarshalHash()
- }
-}
-
-func TestMarshalHashAckResponse(t *testing.T) {
- v := AckResponse{}
- binary.Read(rand.Reader, binary.BigEndian, &v)
- bts1, err := v.MarshalHash()
- if err != nil {
- t.Fatal(err)
- }
- bts2, err := v.MarshalHash()
- if err != nil {
- t.Fatal(err)
- }
- if !bytes.Equal(bts1, bts2) {
- t.Fatal("hash not stable")
- }
-}
-
-func BenchmarkMarshalHashAckResponse(b *testing.B) {
- v := AckResponse{}
- b.ReportAllocs()
- b.ResetTimer()
- for i := 0; i < b.N; i++ {
- v.MarshalHash()
- }
-}
-
-func BenchmarkAppendMsgAckResponse(b *testing.B) {
- v := AckResponse{}
- bts := make([]byte, 0, v.Msgsize())
- bts, _ = v.MarshalHash()
- b.SetBytes(int64(len(bts)))
- b.ReportAllocs()
- b.ResetTimer()
- for i := 0; i < b.N; i++ {
- bts, _ = v.MarshalHash()
- }
-}
-
-func TestMarshalHashSignedAckHeader(t *testing.T) {
- v := SignedAckHeader{}
- binary.Read(rand.Reader, binary.BigEndian, &v)
- bts1, err := v.MarshalHash()
- if err != nil {
- t.Fatal(err)
- }
- bts2, err := v.MarshalHash()
- if err != nil {
- t.Fatal(err)
- }
- if !bytes.Equal(bts1, bts2) {
- t.Fatal("hash not stable")
- }
-}
-
-func BenchmarkMarshalHashSignedAckHeader(b *testing.B) {
- v := SignedAckHeader{}
- b.ReportAllocs()
- b.ResetTimer()
- for i := 0; i < b.N; i++ {
- v.MarshalHash()
- }
-}
-
-func BenchmarkAppendMsgSignedAckHeader(b *testing.B) {
- v := SignedAckHeader{}
- bts := make([]byte, 0, v.Msgsize())
- bts, _ = v.MarshalHash()
- b.SetBytes(int64(len(bts)))
- b.ReportAllocs()
- b.ResetTimer()
- for i := 0; i < b.N; i++ {
- bts, _ = v.MarshalHash()
- }
-}
diff --git a/worker/otypes/doc.go b/worker/otypes/doc.go
deleted file mode 100644
index 089862dc6..000000000
--- a/worker/otypes/doc.go
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2018 The CovenantSQL Authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/*
-Package otypes defines miner node export types.
-*/
-package otypes
diff --git a/worker/otypes/errors.go b/worker/otypes/errors.go
deleted file mode 100644
index 5c44a3c9d..000000000
--- a/worker/otypes/errors.go
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright 2018 The CovenantSQL Authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package otypes
-
-import "errors"
-
-var (
- // ErrHashVerification indicates a failed hash verification.
- ErrHashVerification = errors.New("hash verification failed")
-
- // ErrSignVerification indicates a failed signature verification.
- ErrSignVerification = errors.New("signature verification failed")
-
- // ErrSignRequest indicates a failed signature compute operation.
- ErrSignRequest = errors.New("signature compute failed")
-)
diff --git a/worker/otypes/get_request.go b/worker/otypes/get_request.go
deleted file mode 100644
index cd1bd4567..000000000
--- a/worker/otypes/get_request.go
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright 2018 The CovenantSQL Authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package otypes
-
-import "github.com/CovenantSQL/CovenantSQL/proto"
-
-// GetRequestReq defines GetRequest RPC request entity.
-type GetRequestReq struct {
- proto.Envelope
- DatabaseID proto.DatabaseID
- LogOffset uint64
-}
-
-// GetRequestResp defines GetRequest RPC response entity.
-type GetRequestResp struct {
- proto.Envelope
- Request *Request
-}
diff --git a/worker/otypes/init_service_type.go b/worker/otypes/init_service_type.go
deleted file mode 100644
index 54d2af65a..000000000
--- a/worker/otypes/init_service_type.go
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Copyright 2018 The CovenantSQL Authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package otypes
-
-import (
- "github.com/CovenantSQL/CovenantSQL/crypto/asymmetric"
- "github.com/CovenantSQL/CovenantSQL/crypto/hash"
- "github.com/CovenantSQL/CovenantSQL/proto"
- ct "github.com/CovenantSQL/CovenantSQL/sqlchain/otypes"
-)
-
-//go:generate hsp
-
-// InitService defines worker service init request.
-type InitService struct {
- proto.Envelope
-}
-
-// ResourceMeta defines single database resource meta.
-type ResourceMeta struct {
- Node uint16 // reserved node count
- Space uint64 // reserved storage space in bytes
- Memory uint64 // reserved memory in bytes
- LoadAvgPerCPU uint64 // max loadAvg15 per CPU
- EncryptionKey string `hspack:"-"` // encryption key for database instance
-}
-
-// ServiceInstance defines single instance to be initialized.
-type ServiceInstance struct {
- DatabaseID proto.DatabaseID
- Peers *proto.Peers
- ResourceMeta ResourceMeta
- GenesisBlock *ct.Block
-}
-
-// InitServiceResponseHeader defines worker service init response header.
-type InitServiceResponseHeader struct {
- Instances []ServiceInstance
-}
-
-// SignedInitServiceResponseHeader defines signed worker service init response header.
-type SignedInitServiceResponseHeader struct {
- InitServiceResponseHeader
- Hash hash.Hash
- Signee *asymmetric.PublicKey
- Signature *asymmetric.Signature
-}
-
-// InitServiceResponse defines worker service init response.
-type InitServiceResponse struct {
- Header SignedInitServiceResponseHeader
-}
-
-// Verify checks hash and signature in init service response header.
-func (sh *SignedInitServiceResponseHeader) Verify() (err error) {
- // verify hash
- if err = verifyHash(&sh.InitServiceResponseHeader, &sh.Hash); err != nil {
- return
- }
- // verify sign
- if sh.Signee == nil || sh.Signature == nil || !sh.Signature.Verify(sh.Hash[:], sh.Signee) {
- return ErrSignVerification
- }
- return
-}
-
-// Sign the request.
-func (sh *SignedInitServiceResponseHeader) Sign(signer *asymmetric.PrivateKey) (err error) {
- // build hash
- if err = buildHash(&sh.InitServiceResponseHeader, &sh.Hash); err != nil {
- return
- }
-
- // sign
- sh.Signature, err = signer.Sign(sh.Hash[:])
- sh.Signee = signer.PubKey()
-
- return
-}
-
-// Verify checks hash and signature in init service response header.
-func (rs *InitServiceResponse) Verify() error {
- return rs.Header.Verify()
-}
-
-// Sign the request.
-func (rs *InitServiceResponse) Sign(signer *asymmetric.PrivateKey) (err error) {
- // sign
- return rs.Header.Sign(signer)
-}
diff --git a/worker/otypes/init_service_type_gen.go b/worker/otypes/init_service_type_gen.go
deleted file mode 100644
index a538613bb..000000000
--- a/worker/otypes/init_service_type_gen.go
+++ /dev/null
@@ -1,219 +0,0 @@
-package otypes
-
-// Code generated by github.com/CovenantSQL/HashStablePack DO NOT EDIT.
-
-import (
- hsp "github.com/CovenantSQL/HashStablePack/marshalhash"
-)
-
-// MarshalHash marshals for hash
-func (z *InitService) MarshalHash() (o []byte, err error) {
- var b []byte
- o = hsp.Require(b, z.Msgsize())
- // map header, size 1
- o = append(o, 0x81, 0x81)
- if oTemp, err := z.Envelope.MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
- }
- return
-}
-
-// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
-func (z *InitService) Msgsize() (s int) {
- s = 1 + 9 + z.Envelope.Msgsize()
- return
-}
-
-// MarshalHash marshals for hash
-func (z *InitServiceResponse) MarshalHash() (o []byte, err error) {
- var b []byte
- o = hsp.Require(b, z.Msgsize())
- // map header, size 1
- o = append(o, 0x81, 0x81)
- if oTemp, err := z.Header.MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
- }
- return
-}
-
-// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
-func (z *InitServiceResponse) Msgsize() (s int) {
- s = 1 + 7 + z.Header.Msgsize()
- return
-}
-
-// MarshalHash marshals for hash
-func (z *InitServiceResponseHeader) MarshalHash() (o []byte, err error) {
- var b []byte
- o = hsp.Require(b, z.Msgsize())
- // map header, size 1
- o = append(o, 0x81, 0x81)
- o = hsp.AppendArrayHeader(o, uint32(len(z.Instances)))
- for za0001 := range z.Instances {
- if oTemp, err := z.Instances[za0001].MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
- }
- }
- return
-}
-
-// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
-func (z *InitServiceResponseHeader) Msgsize() (s int) {
- s = 1 + 10 + hsp.ArrayHeaderSize
- for za0001 := range z.Instances {
- s += z.Instances[za0001].Msgsize()
- }
- return
-}
-
-// MarshalHash marshals for hash
-func (z *ResourceMeta) MarshalHash() (o []byte, err error) {
- var b []byte
- o = hsp.Require(b, z.Msgsize())
- // map header, size 4
- o = append(o, 0x84, 0x84)
- o = hsp.AppendUint16(o, z.Node)
- o = append(o, 0x84)
- o = hsp.AppendUint64(o, z.Space)
- o = append(o, 0x84)
- o = hsp.AppendUint64(o, z.Memory)
- o = append(o, 0x84)
- o = hsp.AppendUint64(o, z.LoadAvgPerCPU)
- return
-}
-
-// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
-func (z *ResourceMeta) Msgsize() (s int) {
- s = 1 + 5 + hsp.Uint16Size + 6 + hsp.Uint64Size + 7 + hsp.Uint64Size + 14 + hsp.Uint64Size
- return
-}
-
-// MarshalHash marshals for hash
-func (z *ServiceInstance) MarshalHash() (o []byte, err error) {
- var b []byte
- o = hsp.Require(b, z.Msgsize())
- // map header, size 4
- o = append(o, 0x84, 0x84)
- if z.GenesisBlock == nil {
- o = hsp.AppendNil(o)
- } else {
- if oTemp, err := z.GenesisBlock.MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
- }
- }
- o = append(o, 0x84)
- if z.Peers == nil {
- o = hsp.AppendNil(o)
- } else {
- if oTemp, err := z.Peers.MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
- }
- }
- o = append(o, 0x84)
- if oTemp, err := z.ResourceMeta.MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
- }
- o = append(o, 0x84)
- if oTemp, err := z.DatabaseID.MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
- }
- return
-}
-
-// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
-func (z *ServiceInstance) Msgsize() (s int) {
- s = 1 + 13
- if z.GenesisBlock == nil {
- s += hsp.NilSize
- } else {
- s += z.GenesisBlock.Msgsize()
- }
- s += 6
- if z.Peers == nil {
- s += hsp.NilSize
- } else {
- s += z.Peers.Msgsize()
- }
- s += 13 + z.ResourceMeta.Msgsize() + 11 + z.DatabaseID.Msgsize()
- return
-}
-
-// MarshalHash marshals for hash
-func (z *SignedInitServiceResponseHeader) MarshalHash() (o []byte, err error) {
- var b []byte
- o = hsp.Require(b, z.Msgsize())
- // map header, size 4
- o = append(o, 0x84, 0x84)
- if z.Signee == nil {
- o = hsp.AppendNil(o)
- } else {
- if oTemp, err := z.Signee.MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
- }
- }
- o = append(o, 0x84)
- if z.Signature == nil {
- o = hsp.AppendNil(o)
- } else {
- if oTemp, err := z.Signature.MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
- }
- }
- // map header, size 1
- o = append(o, 0x84, 0x81, 0x81)
- o = hsp.AppendArrayHeader(o, uint32(len(z.InitServiceResponseHeader.Instances)))
- for za0001 := range z.InitServiceResponseHeader.Instances {
- if oTemp, err := z.InitServiceResponseHeader.Instances[za0001].MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
- }
- }
- o = append(o, 0x84)
- if oTemp, err := z.Hash.MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
- }
- return
-}
-
-// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
-func (z *SignedInitServiceResponseHeader) Msgsize() (s int) {
- s = 1 + 7
- if z.Signee == nil {
- s += hsp.NilSize
- } else {
- s += z.Signee.Msgsize()
- }
- s += 10
- if z.Signature == nil {
- s += hsp.NilSize
- } else {
- s += z.Signature.Msgsize()
- }
- s += 26 + 1 + 10 + hsp.ArrayHeaderSize
- for za0001 := range z.InitServiceResponseHeader.Instances {
- s += z.InitServiceResponseHeader.Instances[za0001].Msgsize()
- }
- s += 5 + z.Hash.Msgsize()
- return
-}
diff --git a/worker/otypes/init_service_type_gen_test.go b/worker/otypes/init_service_type_gen_test.go
deleted file mode 100644
index ee88b0eb6..000000000
--- a/worker/otypes/init_service_type_gen_test.go
+++ /dev/null
@@ -1,232 +0,0 @@
-package otypes
-
-// Code generated by github.com/CovenantSQL/HashStablePack DO NOT EDIT.
-
-import (
- "bytes"
- "crypto/rand"
- "encoding/binary"
- "testing"
-)
-
-func TestMarshalHashInitService(t *testing.T) {
- v := InitService{}
- binary.Read(rand.Reader, binary.BigEndian, &v)
- bts1, err := v.MarshalHash()
- if err != nil {
- t.Fatal(err)
- }
- bts2, err := v.MarshalHash()
- if err != nil {
- t.Fatal(err)
- }
- if !bytes.Equal(bts1, bts2) {
- t.Fatal("hash not stable")
- }
-}
-
-func BenchmarkMarshalHashInitService(b *testing.B) {
- v := InitService{}
- b.ReportAllocs()
- b.ResetTimer()
- for i := 0; i < b.N; i++ {
- v.MarshalHash()
- }
-}
-
-func BenchmarkAppendMsgInitService(b *testing.B) {
- v := InitService{}
- bts := make([]byte, 0, v.Msgsize())
- bts, _ = v.MarshalHash()
- b.SetBytes(int64(len(bts)))
- b.ReportAllocs()
- b.ResetTimer()
- for i := 0; i < b.N; i++ {
- bts, _ = v.MarshalHash()
- }
-}
-
-func TestMarshalHashInitServiceResponse(t *testing.T) {
- v := InitServiceResponse{}
- binary.Read(rand.Reader, binary.BigEndian, &v)
- bts1, err := v.MarshalHash()
- if err != nil {
- t.Fatal(err)
- }
- bts2, err := v.MarshalHash()
- if err != nil {
- t.Fatal(err)
- }
- if !bytes.Equal(bts1, bts2) {
- t.Fatal("hash not stable")
- }
-}
-
-func BenchmarkMarshalHashInitServiceResponse(b *testing.B) {
- v := InitServiceResponse{}
- b.ReportAllocs()
- b.ResetTimer()
- for i := 0; i < b.N; i++ {
- v.MarshalHash()
- }
-}
-
-func BenchmarkAppendMsgInitServiceResponse(b *testing.B) {
- v := InitServiceResponse{}
- bts := make([]byte, 0, v.Msgsize())
- bts, _ = v.MarshalHash()
- b.SetBytes(int64(len(bts)))
- b.ReportAllocs()
- b.ResetTimer()
- for i := 0; i < b.N; i++ {
- bts, _ = v.MarshalHash()
- }
-}
-
-func TestMarshalHashInitServiceResponseHeader(t *testing.T) {
- v := InitServiceResponseHeader{}
- binary.Read(rand.Reader, binary.BigEndian, &v)
- bts1, err := v.MarshalHash()
- if err != nil {
- t.Fatal(err)
- }
- bts2, err := v.MarshalHash()
- if err != nil {
- t.Fatal(err)
- }
- if !bytes.Equal(bts1, bts2) {
- t.Fatal("hash not stable")
- }
-}
-
-func BenchmarkMarshalHashInitServiceResponseHeader(b *testing.B) {
- v := InitServiceResponseHeader{}
- b.ReportAllocs()
- b.ResetTimer()
- for i := 0; i < b.N; i++ {
- v.MarshalHash()
- }
-}
-
-func BenchmarkAppendMsgInitServiceResponseHeader(b *testing.B) {
- v := InitServiceResponseHeader{}
- bts := make([]byte, 0, v.Msgsize())
- bts, _ = v.MarshalHash()
- b.SetBytes(int64(len(bts)))
- b.ReportAllocs()
- b.ResetTimer()
- for i := 0; i < b.N; i++ {
- bts, _ = v.MarshalHash()
- }
-}
-
-func TestMarshalHashResourceMeta(t *testing.T) {
- v := ResourceMeta{}
- binary.Read(rand.Reader, binary.BigEndian, &v)
- bts1, err := v.MarshalHash()
- if err != nil {
- t.Fatal(err)
- }
- bts2, err := v.MarshalHash()
- if err != nil {
- t.Fatal(err)
- }
- if !bytes.Equal(bts1, bts2) {
- t.Fatal("hash not stable")
- }
-}
-
-func BenchmarkMarshalHashResourceMeta(b *testing.B) {
- v := ResourceMeta{}
- b.ReportAllocs()
- b.ResetTimer()
- for i := 0; i < b.N; i++ {
- v.MarshalHash()
- }
-}
-
-func BenchmarkAppendMsgResourceMeta(b *testing.B) {
- v := ResourceMeta{}
- bts := make([]byte, 0, v.Msgsize())
- bts, _ = v.MarshalHash()
- b.SetBytes(int64(len(bts)))
- b.ReportAllocs()
- b.ResetTimer()
- for i := 0; i < b.N; i++ {
- bts, _ = v.MarshalHash()
- }
-}
-
-func TestMarshalHashServiceInstance(t *testing.T) {
- v := ServiceInstance{}
- binary.Read(rand.Reader, binary.BigEndian, &v)
- bts1, err := v.MarshalHash()
- if err != nil {
- t.Fatal(err)
- }
- bts2, err := v.MarshalHash()
- if err != nil {
- t.Fatal(err)
- }
- if !bytes.Equal(bts1, bts2) {
- t.Fatal("hash not stable")
- }
-}
-
-func BenchmarkMarshalHashServiceInstance(b *testing.B) {
- v := ServiceInstance{}
- b.ReportAllocs()
- b.ResetTimer()
- for i := 0; i < b.N; i++ {
- v.MarshalHash()
- }
-}
-
-func BenchmarkAppendMsgServiceInstance(b *testing.B) {
- v := ServiceInstance{}
- bts := make([]byte, 0, v.Msgsize())
- bts, _ = v.MarshalHash()
- b.SetBytes(int64(len(bts)))
- b.ReportAllocs()
- b.ResetTimer()
- for i := 0; i < b.N; i++ {
- bts, _ = v.MarshalHash()
- }
-}
-
-func TestMarshalHashSignedInitServiceResponseHeader(t *testing.T) {
- v := SignedInitServiceResponseHeader{}
- binary.Read(rand.Reader, binary.BigEndian, &v)
- bts1, err := v.MarshalHash()
- if err != nil {
- t.Fatal(err)
- }
- bts2, err := v.MarshalHash()
- if err != nil {
- t.Fatal(err)
- }
- if !bytes.Equal(bts1, bts2) {
- t.Fatal("hash not stable")
- }
-}
-
-func BenchmarkMarshalHashSignedInitServiceResponseHeader(b *testing.B) {
- v := SignedInitServiceResponseHeader{}
- b.ReportAllocs()
- b.ResetTimer()
- for i := 0; i < b.N; i++ {
- v.MarshalHash()
- }
-}
-
-func BenchmarkAppendMsgSignedInitServiceResponseHeader(b *testing.B) {
- v := SignedInitServiceResponseHeader{}
- bts := make([]byte, 0, v.Msgsize())
- bts, _ = v.MarshalHash()
- b.SetBytes(int64(len(bts)))
- b.ReportAllocs()
- b.ResetTimer()
- for i := 0; i < b.N; i++ {
- bts, _ = v.MarshalHash()
- }
-}
diff --git a/worker/otypes/no_ack_report_type.go b/worker/otypes/no_ack_report_type.go
deleted file mode 100644
index 24b0fbfc4..000000000
--- a/worker/otypes/no_ack_report_type.go
+++ /dev/null
@@ -1,165 +0,0 @@
-/*
- * Copyright 2018 The CovenantSQL Authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package otypes
-
-import (
- "time"
-
- "github.com/CovenantSQL/CovenantSQL/crypto/asymmetric"
- "github.com/CovenantSQL/CovenantSQL/crypto/hash"
- "github.com/CovenantSQL/CovenantSQL/proto"
-)
-
-//go:generate hsp
-
-// NoAckReportHeader defines worker issued client no ack report.
-type NoAckReportHeader struct {
- NodeID proto.NodeID // reporter node id
- Timestamp time.Time // time in UTC zone
- Response SignedResponseHeader
-}
-
-// SignedNoAckReportHeader defines worker worker issued/signed client no ack report.
-type SignedNoAckReportHeader struct {
- NoAckReportHeader
- Hash hash.Hash
- Signee *asymmetric.PublicKey
- Signature *asymmetric.Signature
-}
-
-// NoAckReport defines whole worker no client ack report.
-type NoAckReport struct {
- proto.Envelope
- Header SignedNoAckReportHeader
-}
-
-// AggrNoAckReportHeader defines worker leader aggregated client no ack report.
-type AggrNoAckReportHeader struct {
- NodeID proto.NodeID // aggregated report node id
- Timestamp time.Time // time in UTC zone
- Reports []SignedNoAckReportHeader // no-ack reports
- Peers *proto.Peers // serving peers during report
-}
-
-// SignedAggrNoAckReportHeader defines worker leader aggregated/signed client no ack report.
-type SignedAggrNoAckReportHeader struct {
- AggrNoAckReportHeader
- Hash hash.Hash
- Signee *asymmetric.PublicKey
- Signature *asymmetric.Signature
-}
-
-// AggrNoAckReport defines whole worker leader no client ack report.
-type AggrNoAckReport struct {
- proto.Envelope
- Header SignedAggrNoAckReportHeader
-}
-
-// Verify checks hash and signature in signed no ack report header.
-func (sh *SignedNoAckReportHeader) Verify() (err error) {
- // verify original response
- if err = sh.Response.Verify(); err != nil {
- return
- }
- // verify hash
- if err = verifyHash(&sh.NoAckReportHeader, &sh.Hash); err != nil {
- return
- }
- // validate signature
- if sh.Signee == nil || sh.Signature == nil || !sh.Signature.Verify(sh.Hash[:], sh.Signee) {
- return ErrSignVerification
- }
- return
-}
-
-// Sign the request.
-func (sh *SignedNoAckReportHeader) Sign(signer *asymmetric.PrivateKey) (err error) {
- // verify original response
- if err = sh.Response.Verify(); err != nil {
- return
- }
-
- // build hash
- if err = buildHash(&sh.NoAckReportHeader, &sh.Hash); err != nil {
- return
- }
-
- // sign
- sh.Signature, err = signer.Sign(sh.Hash[:])
- sh.Signee = signer.PubKey()
-
- return
-}
-
-// Verify checks hash and signature in whole no ack report.
-func (r *NoAckReport) Verify() error {
- return r.Header.Verify()
-}
-
-// Sign the request.
-func (r *NoAckReport) Sign(signer *asymmetric.PrivateKey) error {
- return r.Header.Sign(signer)
-}
-
-// Verify checks hash and signature in aggregated no ack report.
-func (sh *SignedAggrNoAckReportHeader) Verify() (err error) {
- // verify original reports
- for _, r := range sh.Reports {
- if err = r.Verify(); err != nil {
- return
- }
- }
- // verify hash
- if err = verifyHash(&sh.AggrNoAckReportHeader, &sh.Hash); err != nil {
- return
- }
- // verify signature
- if sh.Signee == nil || sh.Signature == nil || !sh.Signature.Verify(sh.Hash[:], sh.Signee) {
- return ErrSignVerification
- }
- return
-}
-
-// Sign the request.
-func (sh *SignedAggrNoAckReportHeader) Sign(signer *asymmetric.PrivateKey) (err error) {
- for _, r := range sh.Reports {
- if err = r.Verify(); err != nil {
- return
- }
- }
-
- // verify hash
- if err = buildHash(&sh.AggrNoAckReportHeader, &sh.Hash); err != nil {
- return
- }
-
- // verify signature
- sh.Signature, err = signer.Sign(sh.Hash[:])
- sh.Signee = signer.PubKey()
-
- return
-}
-
-// Verify the whole aggregation no ack report.
-func (r *AggrNoAckReport) Verify() (err error) {
- return r.Header.Verify()
-}
-
-// Sign the request.
-func (r *AggrNoAckReport) Sign(signer *asymmetric.PrivateKey) error {
- return r.Header.Sign(signer)
-}
diff --git a/worker/otypes/no_ack_report_type_gen.go b/worker/otypes/no_ack_report_type_gen.go
deleted file mode 100644
index d2a3408b7..000000000
--- a/worker/otypes/no_ack_report_type_gen.go
+++ /dev/null
@@ -1,263 +0,0 @@
-package otypes
-
-// Code generated by github.com/CovenantSQL/HashStablePack DO NOT EDIT.
-
-import (
- hsp "github.com/CovenantSQL/HashStablePack/marshalhash"
-)
-
-// MarshalHash marshals for hash
-func (z *AggrNoAckReport) MarshalHash() (o []byte, err error) {
- var b []byte
- o = hsp.Require(b, z.Msgsize())
- // map header, size 2
- o = append(o, 0x82, 0x82)
- if oTemp, err := z.Header.MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
- }
- o = append(o, 0x82)
- if oTemp, err := z.Envelope.MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
- }
- return
-}
-
-// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
-func (z *AggrNoAckReport) Msgsize() (s int) {
- s = 1 + 7 + z.Header.Msgsize() + 9 + z.Envelope.Msgsize()
- return
-}
-
-// MarshalHash marshals for hash
-func (z *AggrNoAckReportHeader) MarshalHash() (o []byte, err error) {
- var b []byte
- o = hsp.Require(b, z.Msgsize())
- // map header, size 4
- o = append(o, 0x84, 0x84)
- if z.Peers == nil {
- o = hsp.AppendNil(o)
- } else {
- if oTemp, err := z.Peers.MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
- }
- }
- o = append(o, 0x84)
- o = hsp.AppendArrayHeader(o, uint32(len(z.Reports)))
- for za0001 := range z.Reports {
- if oTemp, err := z.Reports[za0001].MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
- }
- }
- o = append(o, 0x84)
- if oTemp, err := z.NodeID.MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
- }
- o = append(o, 0x84)
- o = hsp.AppendTime(o, z.Timestamp)
- return
-}
-
-// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
-func (z *AggrNoAckReportHeader) Msgsize() (s int) {
- s = 1 + 6
- if z.Peers == nil {
- s += hsp.NilSize
- } else {
- s += z.Peers.Msgsize()
- }
- s += 8 + hsp.ArrayHeaderSize
- for za0001 := range z.Reports {
- s += z.Reports[za0001].Msgsize()
- }
- s += 7 + z.NodeID.Msgsize() + 10 + hsp.TimeSize
- return
-}
-
-// MarshalHash marshals for hash
-func (z *NoAckReport) MarshalHash() (o []byte, err error) {
- var b []byte
- o = hsp.Require(b, z.Msgsize())
- // map header, size 2
- o = append(o, 0x82, 0x82)
- if oTemp, err := z.Header.MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
- }
- o = append(o, 0x82)
- if oTemp, err := z.Envelope.MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
- }
- return
-}
-
-// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
-func (z *NoAckReport) Msgsize() (s int) {
- s = 1 + 7 + z.Header.Msgsize() + 9 + z.Envelope.Msgsize()
- return
-}
-
-// MarshalHash marshals for hash
-func (z *NoAckReportHeader) MarshalHash() (o []byte, err error) {
- var b []byte
- o = hsp.Require(b, z.Msgsize())
- // map header, size 3
- o = append(o, 0x83, 0x83)
- if oTemp, err := z.Response.MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
- }
- o = append(o, 0x83)
- if oTemp, err := z.NodeID.MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
- }
- o = append(o, 0x83)
- o = hsp.AppendTime(o, z.Timestamp)
- return
-}
-
-// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
-func (z *NoAckReportHeader) Msgsize() (s int) {
- s = 1 + 9 + z.Response.Msgsize() + 7 + z.NodeID.Msgsize() + 10 + hsp.TimeSize
- return
-}
-
-// MarshalHash marshals for hash
-func (z *SignedAggrNoAckReportHeader) MarshalHash() (o []byte, err error) {
- var b []byte
- o = hsp.Require(b, z.Msgsize())
- // map header, size 4
- o = append(o, 0x84, 0x84)
- if z.Signee == nil {
- o = hsp.AppendNil(o)
- } else {
- if oTemp, err := z.Signee.MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
- }
- }
- o = append(o, 0x84)
- if z.Signature == nil {
- o = hsp.AppendNil(o)
- } else {
- if oTemp, err := z.Signature.MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
- }
- }
- o = append(o, 0x84)
- if oTemp, err := z.AggrNoAckReportHeader.MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
- }
- o = append(o, 0x84)
- if oTemp, err := z.Hash.MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
- }
- return
-}
-
-// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
-func (z *SignedAggrNoAckReportHeader) Msgsize() (s int) {
- s = 1 + 7
- if z.Signee == nil {
- s += hsp.NilSize
- } else {
- s += z.Signee.Msgsize()
- }
- s += 10
- if z.Signature == nil {
- s += hsp.NilSize
- } else {
- s += z.Signature.Msgsize()
- }
- s += 22 + z.AggrNoAckReportHeader.Msgsize() + 5 + z.Hash.Msgsize()
- return
-}
-
-// MarshalHash marshals for hash
-func (z *SignedNoAckReportHeader) MarshalHash() (o []byte, err error) {
- var b []byte
- o = hsp.Require(b, z.Msgsize())
- // map header, size 4
- o = append(o, 0x84, 0x84)
- if z.Signee == nil {
- o = hsp.AppendNil(o)
- } else {
- if oTemp, err := z.Signee.MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
- }
- }
- o = append(o, 0x84)
- if z.Signature == nil {
- o = hsp.AppendNil(o)
- } else {
- if oTemp, err := z.Signature.MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
- }
- }
- // map header, size 3
- o = append(o, 0x84, 0x83, 0x83)
- if oTemp, err := z.NoAckReportHeader.NodeID.MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
- }
- o = append(o, 0x83)
- o = hsp.AppendTime(o, z.NoAckReportHeader.Timestamp)
- o = append(o, 0x83)
- if oTemp, err := z.NoAckReportHeader.Response.MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
- }
- o = append(o, 0x84)
- if oTemp, err := z.Hash.MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
- }
- return
-}
-
-// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
-func (z *SignedNoAckReportHeader) Msgsize() (s int) {
- s = 1 + 7
- if z.Signee == nil {
- s += hsp.NilSize
- } else {
- s += z.Signee.Msgsize()
- }
- s += 10
- if z.Signature == nil {
- s += hsp.NilSize
- } else {
- s += z.Signature.Msgsize()
- }
- s += 18 + 1 + 7 + z.NoAckReportHeader.NodeID.Msgsize() + 10 + hsp.TimeSize + 9 + z.NoAckReportHeader.Response.Msgsize() + 5 + z.Hash.Msgsize()
- return
-}
diff --git a/worker/otypes/no_ack_report_type_gen_test.go b/worker/otypes/no_ack_report_type_gen_test.go
deleted file mode 100644
index bf3e1bb8b..000000000
--- a/worker/otypes/no_ack_report_type_gen_test.go
+++ /dev/null
@@ -1,232 +0,0 @@
-package otypes
-
-// Code generated by github.com/CovenantSQL/HashStablePack DO NOT EDIT.
-
-import (
- "bytes"
- "crypto/rand"
- "encoding/binary"
- "testing"
-)
-
-func TestMarshalHashAggrNoAckReport(t *testing.T) {
- v := AggrNoAckReport{}
- binary.Read(rand.Reader, binary.BigEndian, &v)
- bts1, err := v.MarshalHash()
- if err != nil {
- t.Fatal(err)
- }
- bts2, err := v.MarshalHash()
- if err != nil {
- t.Fatal(err)
- }
- if !bytes.Equal(bts1, bts2) {
- t.Fatal("hash not stable")
- }
-}
-
-func BenchmarkMarshalHashAggrNoAckReport(b *testing.B) {
- v := AggrNoAckReport{}
- b.ReportAllocs()
- b.ResetTimer()
- for i := 0; i < b.N; i++ {
- v.MarshalHash()
- }
-}
-
-func BenchmarkAppendMsgAggrNoAckReport(b *testing.B) {
- v := AggrNoAckReport{}
- bts := make([]byte, 0, v.Msgsize())
- bts, _ = v.MarshalHash()
- b.SetBytes(int64(len(bts)))
- b.ReportAllocs()
- b.ResetTimer()
- for i := 0; i < b.N; i++ {
- bts, _ = v.MarshalHash()
- }
-}
-
-func TestMarshalHashAggrNoAckReportHeader(t *testing.T) {
- v := AggrNoAckReportHeader{}
- binary.Read(rand.Reader, binary.BigEndian, &v)
- bts1, err := v.MarshalHash()
- if err != nil {
- t.Fatal(err)
- }
- bts2, err := v.MarshalHash()
- if err != nil {
- t.Fatal(err)
- }
- if !bytes.Equal(bts1, bts2) {
- t.Fatal("hash not stable")
- }
-}
-
-func BenchmarkMarshalHashAggrNoAckReportHeader(b *testing.B) {
- v := AggrNoAckReportHeader{}
- b.ReportAllocs()
- b.ResetTimer()
- for i := 0; i < b.N; i++ {
- v.MarshalHash()
- }
-}
-
-func BenchmarkAppendMsgAggrNoAckReportHeader(b *testing.B) {
- v := AggrNoAckReportHeader{}
- bts := make([]byte, 0, v.Msgsize())
- bts, _ = v.MarshalHash()
- b.SetBytes(int64(len(bts)))
- b.ReportAllocs()
- b.ResetTimer()
- for i := 0; i < b.N; i++ {
- bts, _ = v.MarshalHash()
- }
-}
-
-func TestMarshalHashNoAckReport(t *testing.T) {
- v := NoAckReport{}
- binary.Read(rand.Reader, binary.BigEndian, &v)
- bts1, err := v.MarshalHash()
- if err != nil {
- t.Fatal(err)
- }
- bts2, err := v.MarshalHash()
- if err != nil {
- t.Fatal(err)
- }
- if !bytes.Equal(bts1, bts2) {
- t.Fatal("hash not stable")
- }
-}
-
-func BenchmarkMarshalHashNoAckReport(b *testing.B) {
- v := NoAckReport{}
- b.ReportAllocs()
- b.ResetTimer()
- for i := 0; i < b.N; i++ {
- v.MarshalHash()
- }
-}
-
-func BenchmarkAppendMsgNoAckReport(b *testing.B) {
- v := NoAckReport{}
- bts := make([]byte, 0, v.Msgsize())
- bts, _ = v.MarshalHash()
- b.SetBytes(int64(len(bts)))
- b.ReportAllocs()
- b.ResetTimer()
- for i := 0; i < b.N; i++ {
- bts, _ = v.MarshalHash()
- }
-}
-
-func TestMarshalHashNoAckReportHeader(t *testing.T) {
- v := NoAckReportHeader{}
- binary.Read(rand.Reader, binary.BigEndian, &v)
- bts1, err := v.MarshalHash()
- if err != nil {
- t.Fatal(err)
- }
- bts2, err := v.MarshalHash()
- if err != nil {
- t.Fatal(err)
- }
- if !bytes.Equal(bts1, bts2) {
- t.Fatal("hash not stable")
- }
-}
-
-func BenchmarkMarshalHashNoAckReportHeader(b *testing.B) {
- v := NoAckReportHeader{}
- b.ReportAllocs()
- b.ResetTimer()
- for i := 0; i < b.N; i++ {
- v.MarshalHash()
- }
-}
-
-func BenchmarkAppendMsgNoAckReportHeader(b *testing.B) {
- v := NoAckReportHeader{}
- bts := make([]byte, 0, v.Msgsize())
- bts, _ = v.MarshalHash()
- b.SetBytes(int64(len(bts)))
- b.ReportAllocs()
- b.ResetTimer()
- for i := 0; i < b.N; i++ {
- bts, _ = v.MarshalHash()
- }
-}
-
-func TestMarshalHashSignedAggrNoAckReportHeader(t *testing.T) {
- v := SignedAggrNoAckReportHeader{}
- binary.Read(rand.Reader, binary.BigEndian, &v)
- bts1, err := v.MarshalHash()
- if err != nil {
- t.Fatal(err)
- }
- bts2, err := v.MarshalHash()
- if err != nil {
- t.Fatal(err)
- }
- if !bytes.Equal(bts1, bts2) {
- t.Fatal("hash not stable")
- }
-}
-
-func BenchmarkMarshalHashSignedAggrNoAckReportHeader(b *testing.B) {
- v := SignedAggrNoAckReportHeader{}
- b.ReportAllocs()
- b.ResetTimer()
- for i := 0; i < b.N; i++ {
- v.MarshalHash()
- }
-}
-
-func BenchmarkAppendMsgSignedAggrNoAckReportHeader(b *testing.B) {
- v := SignedAggrNoAckReportHeader{}
- bts := make([]byte, 0, v.Msgsize())
- bts, _ = v.MarshalHash()
- b.SetBytes(int64(len(bts)))
- b.ReportAllocs()
- b.ResetTimer()
- for i := 0; i < b.N; i++ {
- bts, _ = v.MarshalHash()
- }
-}
-
-func TestMarshalHashSignedNoAckReportHeader(t *testing.T) {
- v := SignedNoAckReportHeader{}
- binary.Read(rand.Reader, binary.BigEndian, &v)
- bts1, err := v.MarshalHash()
- if err != nil {
- t.Fatal(err)
- }
- bts2, err := v.MarshalHash()
- if err != nil {
- t.Fatal(err)
- }
- if !bytes.Equal(bts1, bts2) {
- t.Fatal("hash not stable")
- }
-}
-
-func BenchmarkMarshalHashSignedNoAckReportHeader(b *testing.B) {
- v := SignedNoAckReportHeader{}
- b.ReportAllocs()
- b.ResetTimer()
- for i := 0; i < b.N; i++ {
- v.MarshalHash()
- }
-}
-
-func BenchmarkAppendMsgSignedNoAckReportHeader(b *testing.B) {
- v := SignedNoAckReportHeader{}
- bts := make([]byte, 0, v.Msgsize())
- bts, _ = v.MarshalHash()
- b.SetBytes(int64(len(bts)))
- b.ReportAllocs()
- b.ResetTimer()
- for i := 0; i < b.N; i++ {
- bts, _ = v.MarshalHash()
- }
-}
diff --git a/worker/otypes/request_type.go b/worker/otypes/request_type.go
deleted file mode 100644
index 768c3165a..000000000
--- a/worker/otypes/request_type.go
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
- * Copyright 2018 The CovenantSQL Authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package otypes
-
-import (
- "time"
-
- "github.com/CovenantSQL/CovenantSQL/crypto/asymmetric"
- "github.com/CovenantSQL/CovenantSQL/crypto/hash"
- "github.com/CovenantSQL/CovenantSQL/proto"
-)
-
-//go:generate hsp
-
-// QueryType enumerates available query type, currently read/write.
-type QueryType int32
-
-const (
- // ReadQuery defines a read query type.
- ReadQuery QueryType = iota
- // WriteQuery defines a write query type.
- WriteQuery
-)
-
-// NamedArg defines the named argument structure for database.
-type NamedArg struct {
- Name string
- Value interface{}
-}
-
-// Query defines single query.
-type Query struct {
- Pattern string
- Args []NamedArg
-}
-
-// RequestPayload defines a queries payload.
-type RequestPayload struct {
- Queries []Query `json:"qs"`
-}
-
-// RequestHeader defines a query request header.
-type RequestHeader struct {
- QueryType QueryType `json:"qt"`
- NodeID proto.NodeID `json:"id"` // request node id
- DatabaseID proto.DatabaseID `json:"dbid"` // request database id
- ConnectionID uint64 `json:"cid"`
- SeqNo uint64 `json:"seq"`
- Timestamp time.Time `json:"t"` // time in UTC zone
- BatchCount uint64 `json:"bc"` // query count in this request
- QueriesHash hash.Hash `json:"qh"` // hash of query payload
-}
-
-// QueryKey defines an unique query key of a request.
-type QueryKey struct {
- NodeID proto.NodeID `json:"id"`
- ConnectionID uint64 `json:"cid"`
- SeqNo uint64 `json:"seq"`
-}
-
-// SignedRequestHeader defines a signed query request header.
-type SignedRequestHeader struct {
- RequestHeader
- Hash hash.Hash `json:"hh"`
- Signee *asymmetric.PublicKey `json:"e"`
- Signature *asymmetric.Signature `json:"s"`
-}
-
-// Request defines a complete query request.
-type Request struct {
- proto.Envelope
- Header SignedRequestHeader `json:"h"`
- Payload RequestPayload `json:"p"`
-}
-
-func (t QueryType) String() string {
- switch t {
- case ReadQuery:
- return "read"
- case WriteQuery:
- return "write"
- default:
- return "unknown"
- }
-}
-
-// Verify checks hash and signature in request header.
-func (sh *SignedRequestHeader) Verify() (err error) {
- // verify hash
- if err = verifyHash(&sh.RequestHeader, &sh.Hash); err != nil {
- return
- }
- // verify sign
- if sh.Signee == nil || sh.Signature == nil || !sh.Signature.Verify(sh.Hash[:], sh.Signee) {
- return ErrSignVerification
- }
- return nil
-}
-
-// Sign the request.
-func (sh *SignedRequestHeader) Sign(signer *asymmetric.PrivateKey) (err error) {
- // compute hash
- if err = buildHash(&sh.RequestHeader, &sh.Hash); err != nil {
- return
- }
-
- if signer == nil {
- return ErrSignRequest
- }
-
- // sign
- sh.Signature, err = signer.Sign(sh.Hash[:])
- sh.Signee = signer.PubKey()
-
- return
-}
-
-// Verify checks hash and signature in whole request.
-func (r *Request) Verify() (err error) {
- // verify payload hash in signed header
- if err = verifyHash(&r.Payload, &r.Header.QueriesHash); err != nil {
- return
- }
- // verify header sign
- return r.Header.Verify()
-}
-
-// Sign the request.
-func (r *Request) Sign(signer *asymmetric.PrivateKey) (err error) {
- // set query count
- r.Header.BatchCount = uint64(len(r.Payload.Queries))
-
- // compute payload hash
- if err = buildHash(&r.Payload, &r.Header.QueriesHash); err != nil {
- return
- }
-
- return r.Header.Sign(signer)
-}
-
-// GetQueryKey returns a unique query key of this request.
-func (sh *SignedRequestHeader) GetQueryKey() QueryKey {
- return QueryKey{
- NodeID: sh.NodeID,
- ConnectionID: sh.ConnectionID,
- SeqNo: sh.SeqNo,
- }
-}
diff --git a/worker/otypes/request_type_gen.go b/worker/otypes/request_type_gen.go
deleted file mode 100644
index 0dd0e6375..000000000
--- a/worker/otypes/request_type_gen.go
+++ /dev/null
@@ -1,277 +0,0 @@
-package otypes
-
-// Code generated by github.com/CovenantSQL/HashStablePack DO NOT EDIT.
-
-import (
- hsp "github.com/CovenantSQL/HashStablePack/marshalhash"
-)
-
-// MarshalHash marshals for hash
-func (z NamedArg) MarshalHash() (o []byte, err error) {
- var b []byte
- o = hsp.Require(b, z.Msgsize())
- // map header, size 2
- o = append(o, 0x82, 0x82)
- o, err = hsp.AppendIntf(o, z.Value)
- if err != nil {
- return
- }
- o = append(o, 0x82)
- o = hsp.AppendString(o, z.Name)
- return
-}
-
-// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
-func (z NamedArg) Msgsize() (s int) {
- s = 1 + 6 + hsp.GuessSize(z.Value) + 5 + hsp.StringPrefixSize + len(z.Name)
- return
-}
-
-// MarshalHash marshals for hash
-func (z *Query) MarshalHash() (o []byte, err error) {
- var b []byte
- o = hsp.Require(b, z.Msgsize())
- // map header, size 2
- o = append(o, 0x82, 0x82)
- o = hsp.AppendArrayHeader(o, uint32(len(z.Args)))
- for za0001 := range z.Args {
- // map header, size 2
- o = append(o, 0x82, 0x82)
- o = hsp.AppendString(o, z.Args[za0001].Name)
- o = append(o, 0x82)
- o, err = hsp.AppendIntf(o, z.Args[za0001].Value)
- if err != nil {
- return
- }
- }
- o = append(o, 0x82)
- o = hsp.AppendString(o, z.Pattern)
- return
-}
-
-// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
-func (z *Query) Msgsize() (s int) {
- s = 1 + 5 + hsp.ArrayHeaderSize
- for za0001 := range z.Args {
- s += 1 + 5 + hsp.StringPrefixSize + len(z.Args[za0001].Name) + 6 + hsp.GuessSize(z.Args[za0001].Value)
- }
- s += 8 + hsp.StringPrefixSize + len(z.Pattern)
- return
-}
-
-// MarshalHash marshals for hash
-func (z *QueryKey) MarshalHash() (o []byte, err error) {
- var b []byte
- o = hsp.Require(b, z.Msgsize())
- // map header, size 3
- o = append(o, 0x83, 0x83)
- if oTemp, err := z.NodeID.MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
- }
- o = append(o, 0x83)
- o = hsp.AppendUint64(o, z.ConnectionID)
- o = append(o, 0x83)
- o = hsp.AppendUint64(o, z.SeqNo)
- return
-}
-
-// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
-func (z *QueryKey) Msgsize() (s int) {
- s = 1 + 7 + z.NodeID.Msgsize() + 13 + hsp.Uint64Size + 6 + hsp.Uint64Size
- return
-}
-
-// MarshalHash marshals for hash
-func (z QueryType) MarshalHash() (o []byte, err error) {
- var b []byte
- o = hsp.Require(b, z.Msgsize())
- o = hsp.AppendInt32(o, int32(z))
- return
-}
-
-// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
-func (z QueryType) Msgsize() (s int) {
- s = hsp.Int32Size
- return
-}
-
-// MarshalHash marshals for hash
-func (z *Request) MarshalHash() (o []byte, err error) {
- var b []byte
- o = hsp.Require(b, z.Msgsize())
- // map header, size 3
- // map header, size 1
- o = append(o, 0x83, 0x83, 0x81, 0x81)
- o = hsp.AppendArrayHeader(o, uint32(len(z.Payload.Queries)))
- for za0001 := range z.Payload.Queries {
- // map header, size 2
- o = append(o, 0x82, 0x82)
- o = hsp.AppendString(o, z.Payload.Queries[za0001].Pattern)
- o = append(o, 0x82)
- o = hsp.AppendArrayHeader(o, uint32(len(z.Payload.Queries[za0001].Args)))
- for za0002 := range z.Payload.Queries[za0001].Args {
- // map header, size 2
- o = append(o, 0x82, 0x82)
- o = hsp.AppendString(o, z.Payload.Queries[za0001].Args[za0002].Name)
- o = append(o, 0x82)
- o, err = hsp.AppendIntf(o, z.Payload.Queries[za0001].Args[za0002].Value)
- if err != nil {
- return
- }
- }
- }
- o = append(o, 0x83)
- if oTemp, err := z.Header.MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
- }
- o = append(o, 0x83)
- if oTemp, err := z.Envelope.MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
- }
- return
-}
-
-// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
-func (z *Request) Msgsize() (s int) {
- s = 1 + 8 + 1 + 8 + hsp.ArrayHeaderSize
- for za0001 := range z.Payload.Queries {
- s += 1 + 8 + hsp.StringPrefixSize + len(z.Payload.Queries[za0001].Pattern) + 5 + hsp.ArrayHeaderSize
- for za0002 := range z.Payload.Queries[za0001].Args {
- s += 1 + 5 + hsp.StringPrefixSize + len(z.Payload.Queries[za0001].Args[za0002].Name) + 6 + hsp.GuessSize(z.Payload.Queries[za0001].Args[za0002].Value)
- }
- }
- s += 7 + z.Header.Msgsize() + 9 + z.Envelope.Msgsize()
- return
-}
-
-// MarshalHash marshals for hash
-func (z *RequestHeader) MarshalHash() (o []byte, err error) {
- var b []byte
- o = hsp.Require(b, z.Msgsize())
- // map header, size 8
- o = append(o, 0x88, 0x88)
- o = hsp.AppendInt32(o, int32(z.QueryType))
- o = append(o, 0x88)
- if oTemp, err := z.QueriesHash.MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
- }
- o = append(o, 0x88)
- if oTemp, err := z.DatabaseID.MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
- }
- o = append(o, 0x88)
- if oTemp, err := z.NodeID.MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
- }
- o = append(o, 0x88)
- o = hsp.AppendTime(o, z.Timestamp)
- o = append(o, 0x88)
- o = hsp.AppendUint64(o, z.ConnectionID)
- o = append(o, 0x88)
- o = hsp.AppendUint64(o, z.SeqNo)
- o = append(o, 0x88)
- o = hsp.AppendUint64(o, z.BatchCount)
- return
-}
-
-// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
-func (z *RequestHeader) Msgsize() (s int) {
- s = 1 + 10 + hsp.Int32Size + 12 + z.QueriesHash.Msgsize() + 11 + z.DatabaseID.Msgsize() + 7 + z.NodeID.Msgsize() + 10 + hsp.TimeSize + 13 + hsp.Uint64Size + 6 + hsp.Uint64Size + 11 + hsp.Uint64Size
- return
-}
-
-// MarshalHash marshals for hash
-func (z *RequestPayload) MarshalHash() (o []byte, err error) {
- var b []byte
- o = hsp.Require(b, z.Msgsize())
- // map header, size 1
- o = append(o, 0x81, 0x81)
- o = hsp.AppendArrayHeader(o, uint32(len(z.Queries)))
- for za0001 := range z.Queries {
- if oTemp, err := z.Queries[za0001].MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
- }
- }
- return
-}
-
-// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
-func (z *RequestPayload) Msgsize() (s int) {
- s = 1 + 8 + hsp.ArrayHeaderSize
- for za0001 := range z.Queries {
- s += z.Queries[za0001].Msgsize()
- }
- return
-}
-
-// MarshalHash marshals for hash
-func (z *SignedRequestHeader) MarshalHash() (o []byte, err error) {
- var b []byte
- o = hsp.Require(b, z.Msgsize())
- // map header, size 4
- o = append(o, 0x84, 0x84)
- if z.Signee == nil {
- o = hsp.AppendNil(o)
- } else {
- if oTemp, err := z.Signee.MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
- }
- }
- o = append(o, 0x84)
- if z.Signature == nil {
- o = hsp.AppendNil(o)
- } else {
- if oTemp, err := z.Signature.MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
- }
- }
- o = append(o, 0x84)
- if oTemp, err := z.RequestHeader.MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
- }
- o = append(o, 0x84)
- if oTemp, err := z.Hash.MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
- }
- return
-}
-
-// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
-func (z *SignedRequestHeader) Msgsize() (s int) {
- s = 1 + 7
- if z.Signee == nil {
- s += hsp.NilSize
- } else {
- s += z.Signee.Msgsize()
- }
- s += 10
- if z.Signature == nil {
- s += hsp.NilSize
- } else {
- s += z.Signature.Msgsize()
- }
- s += 14 + z.RequestHeader.Msgsize() + 5 + z.Hash.Msgsize()
- return
-}
diff --git a/worker/otypes/request_type_gen_test.go b/worker/otypes/request_type_gen_test.go
deleted file mode 100644
index c1371bf13..000000000
--- a/worker/otypes/request_type_gen_test.go
+++ /dev/null
@@ -1,269 +0,0 @@
-package otypes
-
-// Code generated by github.com/CovenantSQL/HashStablePack DO NOT EDIT.
-
-import (
- "bytes"
- "crypto/rand"
- "encoding/binary"
- "testing"
-)
-
-func TestMarshalHashNamedArg(t *testing.T) {
- v := NamedArg{}
- binary.Read(rand.Reader, binary.BigEndian, &v)
- bts1, err := v.MarshalHash()
- if err != nil {
- t.Fatal(err)
- }
- bts2, err := v.MarshalHash()
- if err != nil {
- t.Fatal(err)
- }
- if !bytes.Equal(bts1, bts2) {
- t.Fatal("hash not stable")
- }
-}
-
-func BenchmarkMarshalHashNamedArg(b *testing.B) {
- v := NamedArg{}
- b.ReportAllocs()
- b.ResetTimer()
- for i := 0; i < b.N; i++ {
- v.MarshalHash()
- }
-}
-
-func BenchmarkAppendMsgNamedArg(b *testing.B) {
- v := NamedArg{}
- bts := make([]byte, 0, v.Msgsize())
- bts, _ = v.MarshalHash()
- b.SetBytes(int64(len(bts)))
- b.ReportAllocs()
- b.ResetTimer()
- for i := 0; i < b.N; i++ {
- bts, _ = v.MarshalHash()
- }
-}
-
-func TestMarshalHashQuery(t *testing.T) {
- v := Query{}
- binary.Read(rand.Reader, binary.BigEndian, &v)
- bts1, err := v.MarshalHash()
- if err != nil {
- t.Fatal(err)
- }
- bts2, err := v.MarshalHash()
- if err != nil {
- t.Fatal(err)
- }
- if !bytes.Equal(bts1, bts2) {
- t.Fatal("hash not stable")
- }
-}
-
-func BenchmarkMarshalHashQuery(b *testing.B) {
- v := Query{}
- b.ReportAllocs()
- b.ResetTimer()
- for i := 0; i < b.N; i++ {
- v.MarshalHash()
- }
-}
-
-func BenchmarkAppendMsgQuery(b *testing.B) {
- v := Query{}
- bts := make([]byte, 0, v.Msgsize())
- bts, _ = v.MarshalHash()
- b.SetBytes(int64(len(bts)))
- b.ReportAllocs()
- b.ResetTimer()
- for i := 0; i < b.N; i++ {
- bts, _ = v.MarshalHash()
- }
-}
-
-func TestMarshalHashQueryKey(t *testing.T) {
- v := QueryKey{}
- binary.Read(rand.Reader, binary.BigEndian, &v)
- bts1, err := v.MarshalHash()
- if err != nil {
- t.Fatal(err)
- }
- bts2, err := v.MarshalHash()
- if err != nil {
- t.Fatal(err)
- }
- if !bytes.Equal(bts1, bts2) {
- t.Fatal("hash not stable")
- }
-}
-
-func BenchmarkMarshalHashQueryKey(b *testing.B) {
- v := QueryKey{}
- b.ReportAllocs()
- b.ResetTimer()
- for i := 0; i < b.N; i++ {
- v.MarshalHash()
- }
-}
-
-func BenchmarkAppendMsgQueryKey(b *testing.B) {
- v := QueryKey{}
- bts := make([]byte, 0, v.Msgsize())
- bts, _ = v.MarshalHash()
- b.SetBytes(int64(len(bts)))
- b.ReportAllocs()
- b.ResetTimer()
- for i := 0; i < b.N; i++ {
- bts, _ = v.MarshalHash()
- }
-}
-
-func TestMarshalHashRequest(t *testing.T) {
- v := Request{}
- binary.Read(rand.Reader, binary.BigEndian, &v)
- bts1, err := v.MarshalHash()
- if err != nil {
- t.Fatal(err)
- }
- bts2, err := v.MarshalHash()
- if err != nil {
- t.Fatal(err)
- }
- if !bytes.Equal(bts1, bts2) {
- t.Fatal("hash not stable")
- }
-}
-
-func BenchmarkMarshalHashRequest(b *testing.B) {
- v := Request{}
- b.ReportAllocs()
- b.ResetTimer()
- for i := 0; i < b.N; i++ {
- v.MarshalHash()
- }
-}
-
-func BenchmarkAppendMsgRequest(b *testing.B) {
- v := Request{}
- bts := make([]byte, 0, v.Msgsize())
- bts, _ = v.MarshalHash()
- b.SetBytes(int64(len(bts)))
- b.ReportAllocs()
- b.ResetTimer()
- for i := 0; i < b.N; i++ {
- bts, _ = v.MarshalHash()
- }
-}
-
-func TestMarshalHashRequestHeader(t *testing.T) {
- v := RequestHeader{}
- binary.Read(rand.Reader, binary.BigEndian, &v)
- bts1, err := v.MarshalHash()
- if err != nil {
- t.Fatal(err)
- }
- bts2, err := v.MarshalHash()
- if err != nil {
- t.Fatal(err)
- }
- if !bytes.Equal(bts1, bts2) {
- t.Fatal("hash not stable")
- }
-}
-
-func BenchmarkMarshalHashRequestHeader(b *testing.B) {
- v := RequestHeader{}
- b.ReportAllocs()
- b.ResetTimer()
- for i := 0; i < b.N; i++ {
- v.MarshalHash()
- }
-}
-
-func BenchmarkAppendMsgRequestHeader(b *testing.B) {
- v := RequestHeader{}
- bts := make([]byte, 0, v.Msgsize())
- bts, _ = v.MarshalHash()
- b.SetBytes(int64(len(bts)))
- b.ReportAllocs()
- b.ResetTimer()
- for i := 0; i < b.N; i++ {
- bts, _ = v.MarshalHash()
- }
-}
-
-func TestMarshalHashRequestPayload(t *testing.T) {
- v := RequestPayload{}
- binary.Read(rand.Reader, binary.BigEndian, &v)
- bts1, err := v.MarshalHash()
- if err != nil {
- t.Fatal(err)
- }
- bts2, err := v.MarshalHash()
- if err != nil {
- t.Fatal(err)
- }
- if !bytes.Equal(bts1, bts2) {
- t.Fatal("hash not stable")
- }
-}
-
-func BenchmarkMarshalHashRequestPayload(b *testing.B) {
- v := RequestPayload{}
- b.ReportAllocs()
- b.ResetTimer()
- for i := 0; i < b.N; i++ {
- v.MarshalHash()
- }
-}
-
-func BenchmarkAppendMsgRequestPayload(b *testing.B) {
- v := RequestPayload{}
- bts := make([]byte, 0, v.Msgsize())
- bts, _ = v.MarshalHash()
- b.SetBytes(int64(len(bts)))
- b.ReportAllocs()
- b.ResetTimer()
- for i := 0; i < b.N; i++ {
- bts, _ = v.MarshalHash()
- }
-}
-
-func TestMarshalHashSignedRequestHeader(t *testing.T) {
- v := SignedRequestHeader{}
- binary.Read(rand.Reader, binary.BigEndian, &v)
- bts1, err := v.MarshalHash()
- if err != nil {
- t.Fatal(err)
- }
- bts2, err := v.MarshalHash()
- if err != nil {
- t.Fatal(err)
- }
- if !bytes.Equal(bts1, bts2) {
- t.Fatal("hash not stable")
- }
-}
-
-func BenchmarkMarshalHashSignedRequestHeader(b *testing.B) {
- v := SignedRequestHeader{}
- b.ReportAllocs()
- b.ResetTimer()
- for i := 0; i < b.N; i++ {
- v.MarshalHash()
- }
-}
-
-func BenchmarkAppendMsgSignedRequestHeader(b *testing.B) {
- v := SignedRequestHeader{}
- bts := make([]byte, 0, v.Msgsize())
- bts, _ = v.MarshalHash()
- b.SetBytes(int64(len(bts)))
- b.ReportAllocs()
- b.ResetTimer()
- for i := 0; i < b.N; i++ {
- bts, _ = v.MarshalHash()
- }
-}
diff --git a/worker/otypes/response_type.go b/worker/otypes/response_type.go
deleted file mode 100644
index 931eaa06d..000000000
--- a/worker/otypes/response_type.go
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * Copyright 2018 The CovenantSQL Authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package otypes
-
-import (
- "time"
-
- "github.com/CovenantSQL/CovenantSQL/crypto/asymmetric"
- "github.com/CovenantSQL/CovenantSQL/crypto/hash"
- "github.com/CovenantSQL/CovenantSQL/proto"
- "github.com/pkg/errors"
-)
-
-//go:generate hsp
-
-// ResponseRow defines single row of query response.
-type ResponseRow struct {
- Values []interface{}
-}
-
-// ResponsePayload defines column names and rows of query response.
-type ResponsePayload struct {
- Columns []string `json:"c"`
- DeclTypes []string `json:"t"`
- Rows []ResponseRow `json:"r"`
-}
-
-// ResponseHeader defines a query response header.
-type ResponseHeader struct {
- Request SignedRequestHeader `json:"r"`
- NodeID proto.NodeID `json:"id"` // response node id
- Timestamp time.Time `json:"t"` // time in UTC zone
- RowCount uint64 `json:"c"` // response row count of payload
- LogOffset uint64 `json:"o"` // request log offset
- LastInsertID int64 `json:"l"` // insert insert id
- AffectedRows int64 `json:"a"` // affected rows
- DataHash hash.Hash `json:"dh"` // hash of query response
-}
-
-// SignedResponseHeader defines a signed query response header.
-type SignedResponseHeader struct {
- ResponseHeader
- Hash hash.Hash `json:"h"`
- Signee *asymmetric.PublicKey `json:"e"`
- Signature *asymmetric.Signature `json:"s"`
-}
-
-// Response defines a complete query response.
-type Response struct {
- Header SignedResponseHeader `json:"h"`
- Payload ResponsePayload `json:"p"`
-}
-
-// Verify checks hash and signature in response header.
-func (sh *SignedResponseHeader) Verify() (err error) {
- // verify original request header
- if err = sh.Request.Verify(); err != nil {
- return
- }
- // verify hash
- if err = verifyHash(&sh.ResponseHeader, &sh.Hash); err != nil {
- return
- }
- // verify signature
- if sh.Signee == nil || sh.Signature == nil || !sh.Signature.Verify(sh.Hash[:], sh.Signee) {
- return ErrSignVerification
- }
-
- return nil
-}
-
-// Sign the request.
-func (sh *SignedResponseHeader) Sign(signer *asymmetric.PrivateKey) (err error) {
- // make sure original header is signed
- if err = sh.Request.Verify(); err != nil {
- err = errors.Wrapf(err, "SignedResponseHeader %v", sh)
- return
- }
-
- // build our hash
- if err = buildHash(&sh.ResponseHeader, &sh.Hash); err != nil {
- return
- }
-
- // sign
- sh.Signature, err = signer.Sign(sh.Hash[:])
- sh.Signee = signer.PubKey()
-
- return
-}
-
-// Verify checks hash and signature in whole response.
-func (sh *Response) Verify() (err error) {
- // verify data hash in header
- if err = verifyHash(&sh.Payload, &sh.Header.DataHash); err != nil {
- return
- }
-
- return sh.Header.Verify()
-}
-
-// Sign the request.
-func (sh *Response) Sign(signer *asymmetric.PrivateKey) (err error) {
- // set rows count
- sh.Header.RowCount = uint64(len(sh.Payload.Rows))
-
- // build hash in header
- if err = buildHash(&sh.Payload, &sh.Header.DataHash); err != nil {
- return
- }
-
- // sign the request
- return sh.Header.Sign(signer)
-}
diff --git a/worker/otypes/response_type_gen.go b/worker/otypes/response_type_gen.go
deleted file mode 100644
index b3d6e68ce..000000000
--- a/worker/otypes/response_type_gen.go
+++ /dev/null
@@ -1,209 +0,0 @@
-package otypes
-
-// Code generated by github.com/CovenantSQL/HashStablePack DO NOT EDIT.
-
-import (
- hsp "github.com/CovenantSQL/HashStablePack/marshalhash"
-)
-
-// MarshalHash marshals for hash
-func (z *Response) MarshalHash() (o []byte, err error) {
- var b []byte
- o = hsp.Require(b, z.Msgsize())
- // map header, size 2
- o = append(o, 0x82, 0x82)
- if oTemp, err := z.Payload.MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
- }
- o = append(o, 0x82)
- if oTemp, err := z.Header.MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
- }
- return
-}
-
-// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
-func (z *Response) Msgsize() (s int) {
- s = 1 + 8 + z.Payload.Msgsize() + 7 + z.Header.Msgsize()
- return
-}
-
-// MarshalHash marshals for hash
-func (z *ResponseHeader) MarshalHash() (o []byte, err error) {
- var b []byte
- o = hsp.Require(b, z.Msgsize())
- // map header, size 8
- o = append(o, 0x88, 0x88)
- if oTemp, err := z.Request.MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
- }
- o = append(o, 0x88)
- if oTemp, err := z.DataHash.MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
- }
- o = append(o, 0x88)
- o = hsp.AppendInt64(o, z.LastInsertID)
- o = append(o, 0x88)
- o = hsp.AppendInt64(o, z.AffectedRows)
- o = append(o, 0x88)
- if oTemp, err := z.NodeID.MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
- }
- o = append(o, 0x88)
- o = hsp.AppendTime(o, z.Timestamp)
- o = append(o, 0x88)
- o = hsp.AppendUint64(o, z.RowCount)
- o = append(o, 0x88)
- o = hsp.AppendUint64(o, z.LogOffset)
- return
-}
-
-// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
-func (z *ResponseHeader) Msgsize() (s int) {
- s = 1 + 8 + z.Request.Msgsize() + 9 + z.DataHash.Msgsize() + 13 + hsp.Int64Size + 13 + hsp.Int64Size + 7 + z.NodeID.Msgsize() + 10 + hsp.TimeSize + 9 + hsp.Uint64Size + 10 + hsp.Uint64Size
- return
-}
-
-// MarshalHash marshals for hash
-func (z *ResponsePayload) MarshalHash() (o []byte, err error) {
- var b []byte
- o = hsp.Require(b, z.Msgsize())
- // map header, size 3
- o = append(o, 0x83, 0x83)
- o = hsp.AppendArrayHeader(o, uint32(len(z.Rows)))
- for za0003 := range z.Rows {
- // map header, size 1
- o = append(o, 0x81, 0x81)
- o = hsp.AppendArrayHeader(o, uint32(len(z.Rows[za0003].Values)))
- for za0004 := range z.Rows[za0003].Values {
- o, err = hsp.AppendIntf(o, z.Rows[za0003].Values[za0004])
- if err != nil {
- return
- }
- }
- }
- o = append(o, 0x83)
- o = hsp.AppendArrayHeader(o, uint32(len(z.Columns)))
- for za0001 := range z.Columns {
- o = hsp.AppendString(o, z.Columns[za0001])
- }
- o = append(o, 0x83)
- o = hsp.AppendArrayHeader(o, uint32(len(z.DeclTypes)))
- for za0002 := range z.DeclTypes {
- o = hsp.AppendString(o, z.DeclTypes[za0002])
- }
- return
-}
-
-// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
-func (z *ResponsePayload) Msgsize() (s int) {
- s = 1 + 5 + hsp.ArrayHeaderSize
- for za0003 := range z.Rows {
- s += 1 + 7 + hsp.ArrayHeaderSize
- for za0004 := range z.Rows[za0003].Values {
- s += hsp.GuessSize(z.Rows[za0003].Values[za0004])
- }
- }
- s += 8 + hsp.ArrayHeaderSize
- for za0001 := range z.Columns {
- s += hsp.StringPrefixSize + len(z.Columns[za0001])
- }
- s += 10 + hsp.ArrayHeaderSize
- for za0002 := range z.DeclTypes {
- s += hsp.StringPrefixSize + len(z.DeclTypes[za0002])
- }
- return
-}
-
-// MarshalHash marshals for hash
-func (z *ResponseRow) MarshalHash() (o []byte, err error) {
- var b []byte
- o = hsp.Require(b, z.Msgsize())
- // map header, size 1
- o = append(o, 0x81, 0x81)
- o = hsp.AppendArrayHeader(o, uint32(len(z.Values)))
- for za0001 := range z.Values {
- o, err = hsp.AppendIntf(o, z.Values[za0001])
- if err != nil {
- return
- }
- }
- return
-}
-
-// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
-func (z *ResponseRow) Msgsize() (s int) {
- s = 1 + 7 + hsp.ArrayHeaderSize
- for za0001 := range z.Values {
- s += hsp.GuessSize(z.Values[za0001])
- }
- return
-}
-
-// MarshalHash marshals for hash
-func (z *SignedResponseHeader) MarshalHash() (o []byte, err error) {
- var b []byte
- o = hsp.Require(b, z.Msgsize())
- // map header, size 4
- o = append(o, 0x84, 0x84)
- if z.Signee == nil {
- o = hsp.AppendNil(o)
- } else {
- if oTemp, err := z.Signee.MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
- }
- }
- o = append(o, 0x84)
- if z.Signature == nil {
- o = hsp.AppendNil(o)
- } else {
- if oTemp, err := z.Signature.MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
- }
- }
- o = append(o, 0x84)
- if oTemp, err := z.ResponseHeader.MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
- }
- o = append(o, 0x84)
- if oTemp, err := z.Hash.MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
- }
- return
-}
-
-// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
-func (z *SignedResponseHeader) Msgsize() (s int) {
- s = 1 + 7
- if z.Signee == nil {
- s += hsp.NilSize
- } else {
- s += z.Signee.Msgsize()
- }
- s += 10
- if z.Signature == nil {
- s += hsp.NilSize
- } else {
- s += z.Signature.Msgsize()
- }
- s += 15 + z.ResponseHeader.Msgsize() + 5 + z.Hash.Msgsize()
- return
-}
diff --git a/worker/otypes/response_type_gen_test.go b/worker/otypes/response_type_gen_test.go
deleted file mode 100644
index 3b263b1ed..000000000
--- a/worker/otypes/response_type_gen_test.go
+++ /dev/null
@@ -1,195 +0,0 @@
-package otypes
-
-// Code generated by github.com/CovenantSQL/HashStablePack DO NOT EDIT.
-
-import (
- "bytes"
- "crypto/rand"
- "encoding/binary"
- "testing"
-)
-
-func TestMarshalHashResponse(t *testing.T) {
- v := Response{}
- binary.Read(rand.Reader, binary.BigEndian, &v)
- bts1, err := v.MarshalHash()
- if err != nil {
- t.Fatal(err)
- }
- bts2, err := v.MarshalHash()
- if err != nil {
- t.Fatal(err)
- }
- if !bytes.Equal(bts1, bts2) {
- t.Fatal("hash not stable")
- }
-}
-
-func BenchmarkMarshalHashResponse(b *testing.B) {
- v := Response{}
- b.ReportAllocs()
- b.ResetTimer()
- for i := 0; i < b.N; i++ {
- v.MarshalHash()
- }
-}
-
-func BenchmarkAppendMsgResponse(b *testing.B) {
- v := Response{}
- bts := make([]byte, 0, v.Msgsize())
- bts, _ = v.MarshalHash()
- b.SetBytes(int64(len(bts)))
- b.ReportAllocs()
- b.ResetTimer()
- for i := 0; i < b.N; i++ {
- bts, _ = v.MarshalHash()
- }
-}
-
-func TestMarshalHashResponseHeader(t *testing.T) {
- v := ResponseHeader{}
- binary.Read(rand.Reader, binary.BigEndian, &v)
- bts1, err := v.MarshalHash()
- if err != nil {
- t.Fatal(err)
- }
- bts2, err := v.MarshalHash()
- if err != nil {
- t.Fatal(err)
- }
- if !bytes.Equal(bts1, bts2) {
- t.Fatal("hash not stable")
- }
-}
-
-func BenchmarkMarshalHashResponseHeader(b *testing.B) {
- v := ResponseHeader{}
- b.ReportAllocs()
- b.ResetTimer()
- for i := 0; i < b.N; i++ {
- v.MarshalHash()
- }
-}
-
-func BenchmarkAppendMsgResponseHeader(b *testing.B) {
- v := ResponseHeader{}
- bts := make([]byte, 0, v.Msgsize())
- bts, _ = v.MarshalHash()
- b.SetBytes(int64(len(bts)))
- b.ReportAllocs()
- b.ResetTimer()
- for i := 0; i < b.N; i++ {
- bts, _ = v.MarshalHash()
- }
-}
-
-func TestMarshalHashResponsePayload(t *testing.T) {
- v := ResponsePayload{}
- binary.Read(rand.Reader, binary.BigEndian, &v)
- bts1, err := v.MarshalHash()
- if err != nil {
- t.Fatal(err)
- }
- bts2, err := v.MarshalHash()
- if err != nil {
- t.Fatal(err)
- }
- if !bytes.Equal(bts1, bts2) {
- t.Fatal("hash not stable")
- }
-}
-
-func BenchmarkMarshalHashResponsePayload(b *testing.B) {
- v := ResponsePayload{}
- b.ReportAllocs()
- b.ResetTimer()
- for i := 0; i < b.N; i++ {
- v.MarshalHash()
- }
-}
-
-func BenchmarkAppendMsgResponsePayload(b *testing.B) {
- v := ResponsePayload{}
- bts := make([]byte, 0, v.Msgsize())
- bts, _ = v.MarshalHash()
- b.SetBytes(int64(len(bts)))
- b.ReportAllocs()
- b.ResetTimer()
- for i := 0; i < b.N; i++ {
- bts, _ = v.MarshalHash()
- }
-}
-
-func TestMarshalHashResponseRow(t *testing.T) {
- v := ResponseRow{}
- binary.Read(rand.Reader, binary.BigEndian, &v)
- bts1, err := v.MarshalHash()
- if err != nil {
- t.Fatal(err)
- }
- bts2, err := v.MarshalHash()
- if err != nil {
- t.Fatal(err)
- }
- if !bytes.Equal(bts1, bts2) {
- t.Fatal("hash not stable")
- }
-}
-
-func BenchmarkMarshalHashResponseRow(b *testing.B) {
- v := ResponseRow{}
- b.ReportAllocs()
- b.ResetTimer()
- for i := 0; i < b.N; i++ {
- v.MarshalHash()
- }
-}
-
-func BenchmarkAppendMsgResponseRow(b *testing.B) {
- v := ResponseRow{}
- bts := make([]byte, 0, v.Msgsize())
- bts, _ = v.MarshalHash()
- b.SetBytes(int64(len(bts)))
- b.ReportAllocs()
- b.ResetTimer()
- for i := 0; i < b.N; i++ {
- bts, _ = v.MarshalHash()
- }
-}
-
-func TestMarshalHashSignedResponseHeader(t *testing.T) {
- v := SignedResponseHeader{}
- binary.Read(rand.Reader, binary.BigEndian, &v)
- bts1, err := v.MarshalHash()
- if err != nil {
- t.Fatal(err)
- }
- bts2, err := v.MarshalHash()
- if err != nil {
- t.Fatal(err)
- }
- if !bytes.Equal(bts1, bts2) {
- t.Fatal("hash not stable")
- }
-}
-
-func BenchmarkMarshalHashSignedResponseHeader(b *testing.B) {
- v := SignedResponseHeader{}
- b.ReportAllocs()
- b.ResetTimer()
- for i := 0; i < b.N; i++ {
- v.MarshalHash()
- }
-}
-
-func BenchmarkAppendMsgSignedResponseHeader(b *testing.B) {
- v := SignedResponseHeader{}
- bts := make([]byte, 0, v.Msgsize())
- bts, _ = v.MarshalHash()
- b.SetBytes(int64(len(bts)))
- b.ReportAllocs()
- b.ResetTimer()
- for i := 0; i < b.N; i++ {
- bts, _ = v.MarshalHash()
- }
-}
diff --git a/worker/otypes/types_test.go b/worker/otypes/types_test.go
deleted file mode 100644
index aa498a453..000000000
--- a/worker/otypes/types_test.go
+++ /dev/null
@@ -1,729 +0,0 @@
-/*
- * Copyright 2018 The CovenantSQL Authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package otypes
-
-import (
- "testing"
- "time"
-
- "github.com/CovenantSQL/CovenantSQL/crypto/asymmetric"
- "github.com/CovenantSQL/CovenantSQL/proto"
- "github.com/CovenantSQL/CovenantSQL/utils"
- "github.com/pkg/errors"
- . "github.com/smartystreets/goconvey/convey"
-)
-
-func getCommKeys() (*asymmetric.PrivateKey, *asymmetric.PublicKey) {
- testPriv := []byte{
- 0xea, 0xf0, 0x2c, 0xa3, 0x48, 0xc5, 0x24, 0xe6,
- 0x39, 0x26, 0x55, 0xba, 0x4d, 0x29, 0x60, 0x3c,
- 0xd1, 0xa7, 0x34, 0x7d, 0x9d, 0x65, 0xcf, 0xe9,
- 0x3c, 0xe1, 0xeb, 0xff, 0xdc, 0xa2, 0x26, 0x94,
- }
- return asymmetric.PrivKeyFromBytes(testPriv)
-}
-
-func TestSignedRequestHeader_Sign(t *testing.T) {
- privKey, _ := getCommKeys()
-
- Convey("sign", t, func() {
- req := &SignedRequestHeader{
- RequestHeader: RequestHeader{
- QueryType: WriteQuery,
- NodeID: proto.NodeID("node"),
- DatabaseID: proto.DatabaseID("db1"),
- ConnectionID: uint64(1),
- SeqNo: uint64(2),
- Timestamp: time.Now().UTC(),
- },
- }
-
- var err error
-
- err = req.Sign(privKey)
- So(err, ShouldBeNil)
-
- Convey("verify", func() {
- err = req.Verify()
- So(err, ShouldBeNil)
-
- // modify structure
- req.Timestamp = req.Timestamp.Add(time.Second)
-
- err = req.Verify()
- So(err, ShouldNotBeNil)
-
- s, err := req.MarshalHash()
- So(err, ShouldBeNil)
- So(s, ShouldNotBeEmpty)
- })
- })
-}
-
-func TestRequest_Sign(t *testing.T) {
- privKey, _ := getCommKeys()
-
- Convey("sign", t, func() {
- req := &Request{
- Header: SignedRequestHeader{
- RequestHeader: RequestHeader{
- QueryType: WriteQuery,
- NodeID: proto.NodeID("node"),
- DatabaseID: proto.DatabaseID("db1"),
- ConnectionID: uint64(1),
- SeqNo: uint64(2),
- Timestamp: time.Now().UTC(),
- },
- },
- Payload: RequestPayload{
- Queries: []Query{
- {
- Pattern: "INSERT INTO test VALUES(?)",
- Args: []NamedArg{
- {
- Value: 1,
- },
- },
- },
- {
- Pattern: "INSERT INTO test VALUES(?)",
- Args: []NamedArg{
- {
- Value: "happy",
- },
- },
- },
- },
- },
- }
-
- var err error
-
- // sign
- err = req.Sign(privKey)
- So(err, ShouldBeNil)
- So(req.Header.BatchCount, ShouldEqual, uint64(len(req.Payload.Queries)))
-
- // test queries hash
- err = verifyHash(&req.Payload, &req.Header.QueriesHash)
- So(err, ShouldBeNil)
-
- Convey("verify", func() {
- err = req.Verify()
- So(err, ShouldBeNil)
-
- Convey("header change", func() {
- // modify structure
- req.Header.Timestamp = req.Header.Timestamp.Add(time.Second)
-
- err = req.Verify()
- So(err, ShouldNotBeNil)
- })
-
- Convey("header change without signing", func() {
- req.Header.Timestamp = req.Header.Timestamp.Add(time.Second)
-
- buildHash(&req.Header.RequestHeader, &req.Header.Hash)
- err = req.Verify()
- So(err, ShouldNotBeNil)
- })
-
- Convey("header change with invalid queries hash", func() {
- req.Payload.Queries = append(req.Payload.Queries,
- Query{
- Pattern: "select 1",
- },
- )
-
- err = req.Verify()
- So(err, ShouldNotBeNil)
- })
- })
- })
-}
-
-func TestResponse_Sign(t *testing.T) {
- privKey, _ := getCommKeys()
-
- Convey("sign", t, func() {
- res := &Response{
- Header: SignedResponseHeader{
- ResponseHeader: ResponseHeader{
- Request: SignedRequestHeader{
- RequestHeader: RequestHeader{
- QueryType: WriteQuery,
- NodeID: proto.NodeID("0000000000000000000000000000000000000000000000000000000000001111"),
- DatabaseID: proto.DatabaseID("db1"),
- ConnectionID: uint64(1),
- SeqNo: uint64(2),
- Timestamp: time.Now().UTC(),
- },
- },
- NodeID: proto.NodeID("0000000000000000000000000000000000000000000000000000000000002222"),
- Timestamp: time.Now().UTC(),
- RowCount: uint64(1),
- },
- },
- Payload: ResponsePayload{
- Columns: []string{
- "test_integer",
- "test_boolean",
- "test_time",
- "test_nil",
- "test_float",
- "test_binary_string",
- "test_string",
- "test_empty_time",
- },
- DeclTypes: []string{
- "INTEGER",
- "BOOLEAN",
- "DATETIME",
- "INTEGER",
- "FLOAT",
- "BLOB",
- "TEXT",
- "DATETIME",
- },
- Rows: []ResponseRow{
- {
- Values: []interface{}{
- int(1),
- true,
- time.Now().UTC(),
- nil,
- float64(1.0001),
- "11111\0001111111",
- "11111111111111",
- time.Time{},
- },
- },
- },
- },
- }
-
- var err error
-
- // sign directly, embedded original request is not filled
- err = res.Sign(privKey)
- So(err, ShouldNotBeNil)
- So(errors.Cause(err), ShouldBeIn, []error{
- ErrSignVerification,
- ErrHashVerification,
- })
-
- // sign original request first
- err = res.Header.Request.Sign(privKey)
- So(err, ShouldBeNil)
-
- // sign again
- err = res.Sign(privKey)
- So(err, ShouldBeNil)
-
- // test hash
- err = verifyHash(&res.Payload, &res.Header.DataHash)
- So(err, ShouldBeNil)
-
- // verify
- Convey("verify", func() {
- err = res.Verify()
- So(err, ShouldBeNil)
-
- Convey("encode/decode verify", func() {
- buf, err := utils.EncodeMsgPack(res)
- So(err, ShouldBeNil)
- var r *Response
- err = utils.DecodeMsgPack(buf.Bytes(), &r)
- So(err, ShouldBeNil)
- err = r.Verify()
- So(err, ShouldBeNil)
- })
- Convey("request change", func() {
- res.Header.Request.BatchCount = 200
-
- err = res.Verify()
- So(err, ShouldNotBeNil)
- })
- Convey("payload change", func() {
- res.Payload.DeclTypes[0] = "INT"
-
- err = res.Verify()
- So(err, ShouldNotBeNil)
- })
- Convey("header change", func() {
- res.Header.Timestamp = res.Header.Timestamp.Add(time.Second)
-
- err = res.Verify()
- So(err, ShouldNotBeNil)
- })
- Convey("header change without signing", func() {
- res.Header.Timestamp = res.Header.Timestamp.Add(time.Second)
- buildHash(&res.Header.ResponseHeader, &res.Header.Hash)
-
- err = res.Verify()
- So(err, ShouldNotBeNil)
- })
- })
- })
-}
-
-func TestAck_Sign(t *testing.T) {
- privKey, _ := getCommKeys()
-
- Convey("sign", t, func() {
- ack := &Ack{
- Header: SignedAckHeader{
- AckHeader: AckHeader{
- Response: SignedResponseHeader{
- ResponseHeader: ResponseHeader{
- Request: SignedRequestHeader{
- RequestHeader: RequestHeader{
- QueryType: WriteQuery,
- NodeID: proto.NodeID("0000000000000000000000000000000000000000000000000000000000001111"),
- DatabaseID: proto.DatabaseID("db1"),
- ConnectionID: uint64(1),
- SeqNo: uint64(2),
- Timestamp: time.Now().UTC(),
- },
- },
- NodeID: proto.NodeID("0000000000000000000000000000000000000000000000000000000000002222"),
- Timestamp: time.Now().UTC(),
- RowCount: uint64(1),
- },
- },
- NodeID: proto.NodeID("0000000000000000000000000000000000000000000000000000000000001111"),
- Timestamp: time.Now().UTC(),
- },
- },
- }
-
- var err error
-
- Convey("get query key", func() {
- key := ack.Header.SignedRequestHeader().GetQueryKey()
- So(key.NodeID, ShouldEqual, ack.Header.SignedRequestHeader().NodeID)
- So(key.ConnectionID, ShouldEqual, ack.Header.SignedRequestHeader().ConnectionID)
- So(key.SeqNo, ShouldEqual, ack.Header.SignedRequestHeader().SeqNo)
- })
-
- // sign directly, embedded original response is not filled
- err = ack.Sign(privKey, false)
- So(err, ShouldBeNil)
- err = ack.Sign(privKey, true)
- So(err, ShouldNotBeNil)
- So(err, ShouldBeIn, []error{
- ErrSignVerification,
- ErrHashVerification,
- })
-
- // sign nested structure, step by step
- // this is not required during runtime
- // during runtime, nested structures is signed and provided by peers
- err = ack.Header.Response.Request.Sign(privKey)
- So(err, ShouldBeNil)
- err = ack.Header.Response.Sign(privKey)
- So(err, ShouldBeNil)
- err = ack.Sign(privKey, true)
- So(err, ShouldBeNil)
-
- Convey("verify", func() {
- err = ack.Verify()
- So(err, ShouldBeNil)
-
- Convey("request change", func() {
- ack.Header.Response.Request.QueryType = ReadQuery
-
- err = ack.Verify()
- So(err, ShouldNotBeNil)
- })
- Convey("response change", func() {
- ack.Header.Response.RowCount = 100
-
- err = ack.Verify()
- So(err, ShouldNotBeNil)
- })
- Convey("header change", func() {
- ack.Header.Timestamp = ack.Header.Timestamp.Add(time.Second)
-
- err = ack.Verify()
- So(err, ShouldNotBeNil)
- })
- Convey("header change without signing", func() {
- ack.Header.Timestamp = ack.Header.Timestamp.Add(time.Second)
-
- buildHash(&ack.Header.AckHeader, &ack.Header.Hash)
-
- err = ack.Verify()
- So(err, ShouldNotBeNil)
- })
- })
- })
-}
-
-func TestNoAckReport_Sign(t *testing.T) {
- privKey, _ := getCommKeys()
-
- Convey("sign", t, func() {
- noAck := &NoAckReport{
- Header: SignedNoAckReportHeader{
- NoAckReportHeader: NoAckReportHeader{
- NodeID: proto.NodeID("0000000000000000000000000000000000000000000000000000000000002222"),
- Timestamp: time.Now().UTC(),
- Response: SignedResponseHeader{
- ResponseHeader: ResponseHeader{
- Request: SignedRequestHeader{
- RequestHeader: RequestHeader{
- QueryType: WriteQuery,
- NodeID: proto.NodeID("0000000000000000000000000000000000000000000000000000000000001111"),
- DatabaseID: proto.DatabaseID("db1"),
- ConnectionID: uint64(1),
- SeqNo: uint64(2),
- Timestamp: time.Now().UTC(),
- },
- },
- NodeID: proto.NodeID("0000000000000000000000000000000000000000000000000000000000002222"),
- Timestamp: time.Now().UTC(),
- RowCount: uint64(1),
- },
- },
- },
- },
- }
-
- var err error
-
- // sign directly, embedded original response/request is not filled
- err = noAck.Sign(privKey)
- So(err, ShouldNotBeNil)
- So(err, ShouldBeIn, []error{
- ErrSignVerification,
- ErrHashVerification,
- })
-
- // sign nested structure
- err = noAck.Header.Response.Request.Sign(privKey)
- So(err, ShouldBeNil)
- err = noAck.Header.Response.Sign(privKey)
- So(err, ShouldBeNil)
- err = noAck.Sign(privKey)
- So(err, ShouldBeNil)
-
- Convey("verify", func() {
- err = noAck.Verify()
- So(err, ShouldBeNil)
-
- Convey("request change", func() {
- noAck.Header.Response.Request.QueryType = ReadQuery
-
- err = noAck.Verify()
- So(err, ShouldNotBeNil)
- })
-
- Convey("response change", func() {
- noAck.Header.Response.RowCount = 100
-
- err = noAck.Verify()
- So(err, ShouldNotBeNil)
- })
-
- Convey("header change", func() {
- noAck.Header.Timestamp = noAck.Header.Timestamp.Add(time.Second)
-
- err = noAck.Verify()
- So(err, ShouldNotBeNil)
- })
-
- Convey("header change without signing", func() {
- noAck.Header.Timestamp = noAck.Header.Timestamp.Add(time.Second)
-
- buildHash(&noAck.Header.NoAckReportHeader, &noAck.Header.Hash)
-
- err = noAck.Verify()
- So(err, ShouldNotBeNil)
- })
- })
- })
-}
-
-func TestAggrNoAckReport_Sign(t *testing.T) {
- privKey, _ := getCommKeys()
-
- Convey("sign", t, func() {
- aggrNoAck := &AggrNoAckReport{
- Header: SignedAggrNoAckReportHeader{
- AggrNoAckReportHeader: AggrNoAckReportHeader{
- NodeID: proto.NodeID("0000000000000000000000000000000000000000000000000000000000003333"),
- Timestamp: time.Now().UTC(),
- Reports: []SignedNoAckReportHeader{
- {
- NoAckReportHeader: NoAckReportHeader{
- NodeID: proto.NodeID("0000000000000000000000000000000000000000000000000000000000002222"),
- Timestamp: time.Now().UTC(),
- Response: SignedResponseHeader{
- ResponseHeader: ResponseHeader{
- Request: SignedRequestHeader{
- RequestHeader: RequestHeader{
- QueryType: WriteQuery,
- NodeID: proto.NodeID("0000000000000000000000000000000000000000000000000000000000001111"),
- DatabaseID: proto.DatabaseID("db1"),
- ConnectionID: uint64(1),
- SeqNo: uint64(2),
- Timestamp: time.Now().UTC(),
- },
- },
- NodeID: proto.NodeID("0000000000000000000000000000000000000000000000000000000000002222"),
- Timestamp: time.Now().UTC(),
- RowCount: uint64(1),
- },
- },
- },
- },
- {
- NoAckReportHeader: NoAckReportHeader{
- NodeID: proto.NodeID("0000000000000000000000000000000000000000000000000000000000003333"),
- Timestamp: time.Now().UTC(),
- Response: SignedResponseHeader{
- ResponseHeader: ResponseHeader{
- Request: SignedRequestHeader{
- RequestHeader: RequestHeader{
- QueryType: WriteQuery,
- NodeID: proto.NodeID("0000000000000000000000000000000000000000000000000000000000001111"),
- DatabaseID: proto.DatabaseID("db1"),
- ConnectionID: uint64(1),
- SeqNo: uint64(2),
- Timestamp: time.Now().UTC(),
- },
- },
- NodeID: proto.NodeID("0000000000000000000000000000000000000000000000000000000000003333"),
- Timestamp: time.Now().UTC(),
- RowCount: uint64(1),
- },
- },
- },
- },
- },
- Peers: &proto.Peers{
- PeersHeader: proto.PeersHeader{
- Term: uint64(1),
- Leader: proto.NodeID("0000000000000000000000000000000000000000000000000000000000003333"),
- Servers: []proto.NodeID{
- proto.NodeID("0000000000000000000000000000000000000000000000000000000000003333"),
- proto.NodeID("0000000000000000000000000000000000000000000000000000000000002222"),
- },
- },
- },
- },
- },
- }
-
- var err error
-
- // sign directly, embedded original response/request is not filled
- err = aggrNoAck.Sign(privKey)
- So(err, ShouldNotBeNil)
- So(err, ShouldBeIn, []error{
- ErrSignVerification,
- ErrHashVerification,
- })
-
- // sign nested structure
- err = aggrNoAck.Header.Reports[0].Response.Request.Sign(privKey)
- So(err, ShouldBeNil)
- err = aggrNoAck.Header.Reports[1].Response.Request.Sign(privKey)
- So(err, ShouldBeNil)
- err = aggrNoAck.Header.Reports[0].Response.Sign(privKey)
- So(err, ShouldBeNil)
- err = aggrNoAck.Header.Reports[1].Response.Sign(privKey)
- So(err, ShouldBeNil)
- err = aggrNoAck.Header.Reports[0].Sign(privKey)
- So(err, ShouldBeNil)
- err = aggrNoAck.Header.Reports[1].Sign(privKey)
- So(err, ShouldBeNil)
- err = aggrNoAck.Sign(privKey)
- So(err, ShouldBeNil)
-
- Convey("verify", func() {
- err = aggrNoAck.Verify()
- So(err, ShouldBeNil)
-
- Convey("request change", func() {
- aggrNoAck.Header.Reports[0].Response.Request.QueryType = ReadQuery
-
- err = aggrNoAck.Verify()
- So(err, ShouldNotBeNil)
- })
-
- Convey("response change", func() {
- aggrNoAck.Header.Reports[0].Response.RowCount = 1000
-
- err = aggrNoAck.Verify()
- So(err, ShouldNotBeNil)
- })
-
- Convey("report change", func() {
- aggrNoAck.Header.Reports[0].Timestamp = aggrNoAck.Header.Reports[0].Timestamp.Add(time.Second)
-
- err = aggrNoAck.Verify()
- So(err, ShouldNotBeNil)
- })
-
- Convey("header change", func() {
- aggrNoAck.Header.Timestamp = aggrNoAck.Header.Timestamp.Add(time.Second)
-
- err = aggrNoAck.Verify()
- So(err, ShouldNotBeNil)
- })
-
- Convey("header change without signing", func() {
- aggrNoAck.Header.Timestamp = aggrNoAck.Header.Timestamp.Add(time.Second)
-
- buildHash(&aggrNoAck.Header.AggrNoAckReportHeader, &aggrNoAck.Header.Hash)
-
- err = aggrNoAck.Verify()
- So(err, ShouldNotBeNil)
- })
- })
- })
-}
-
-func TestInitServiceResponse_Sign(t *testing.T) {
- privKey, _ := getCommKeys()
-
- Convey("sign", t, func() {
- var err error
-
- initServiceResponse := &InitServiceResponse{
- Header: SignedInitServiceResponseHeader{
- InitServiceResponseHeader: InitServiceResponseHeader{
- Instances: []ServiceInstance{
- {
- DatabaseID: proto.DatabaseID("db1"),
- Peers: &proto.Peers{
- PeersHeader: proto.PeersHeader{
- Term: uint64(1),
- Leader: proto.NodeID("0000000000000000000000000000000000000000000000000000000000003333"),
- Servers: []proto.NodeID{
- proto.NodeID("0000000000000000000000000000000000000000000000000000000000003333"),
- proto.NodeID("0000000000000000000000000000000000000000000000000000000000002222"),
- },
- },
- },
- // TODO(xq262144), should integrated with genesis block serialization test
- GenesisBlock: nil,
- },
- },
- },
- },
- }
-
- // sign
- err = initServiceResponse.Sign(privKey)
-
- Convey("verify", func() {
- err = initServiceResponse.Verify()
- So(err, ShouldBeNil)
-
- Convey("header change", func() {
- initServiceResponse.Header.Instances[0].DatabaseID = proto.DatabaseID("db2")
-
- err = initServiceResponse.Verify()
- So(err, ShouldNotBeNil)
- })
-
- Convey("header change without signing", func() {
- initServiceResponse.Header.Instances[0].DatabaseID = proto.DatabaseID("db2")
-
- buildHash(&initServiceResponse.Header.InitServiceResponseHeader, &initServiceResponse.Header.Hash)
-
- s, err := initServiceResponse.Header.InitServiceResponseHeader.MarshalHash()
- So(err, ShouldBeNil)
- So(s, ShouldNotBeEmpty)
-
- err = initServiceResponse.Verify()
- So(err, ShouldNotBeNil)
- })
- })
- })
-}
-
-func TestUpdateService_Sign(t *testing.T) {
- privKey, _ := getCommKeys()
-
- Convey("sign", t, func() {
- var err error
-
- updateServiceReq := &UpdateService{
- Header: SignedUpdateServiceHeader{
- UpdateServiceHeader: UpdateServiceHeader{
- Op: CreateDB,
- Instance: ServiceInstance{
- DatabaseID: proto.DatabaseID("db1"),
- Peers: &proto.Peers{
- PeersHeader: proto.PeersHeader{
- Term: uint64(1),
- Leader: proto.NodeID("0000000000000000000000000000000000000000000000000000000000003333"),
- Servers: []proto.NodeID{
- proto.NodeID("0000000000000000000000000000000000000000000000000000000000003333"),
- proto.NodeID("0000000000000000000000000000000000000000000000000000000000002222"),
- },
- },
- },
- // TODO(xq262144), should integrated with genesis block serialization test
- GenesisBlock: nil,
- },
- },
- },
- }
-
- // sign
- err = updateServiceReq.Sign(privKey)
-
- Convey("verify", func() {
- err = updateServiceReq.Verify()
- So(err, ShouldBeNil)
-
- Convey("header change", func() {
- updateServiceReq.Header.Instance.DatabaseID = proto.DatabaseID("db2")
-
- err = updateServiceReq.Verify()
- So(err, ShouldNotBeNil)
- })
-
- Convey("header change without signing", func() {
- updateServiceReq.Header.Instance.DatabaseID = proto.DatabaseID("db2")
- buildHash(&updateServiceReq.Header.UpdateServiceHeader, &updateServiceReq.Header.Hash)
-
- err = updateServiceReq.Verify()
- So(err, ShouldNotBeNil)
- })
- })
- })
-}
-
-func TestOther_MarshalHash(t *testing.T) {
- Convey("marshal hash", t, func() {
- tm := UpdateType(1)
- s, err := tm.MarshalHash()
- So(err, ShouldBeNil)
- So(s, ShouldNotBeEmpty)
-
- tm2 := QueryType(1)
- s, err = tm2.MarshalHash()
- So(err, ShouldBeNil)
- So(s, ShouldNotBeEmpty)
- })
-}
diff --git a/worker/otypes/update_service_type.go b/worker/otypes/update_service_type.go
deleted file mode 100644
index 24c83c49b..000000000
--- a/worker/otypes/update_service_type.go
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Copyright 2018 The CovenantSQL Authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package otypes
-
-import (
- "github.com/CovenantSQL/CovenantSQL/crypto/asymmetric"
- "github.com/CovenantSQL/CovenantSQL/crypto/hash"
- "github.com/CovenantSQL/CovenantSQL/proto"
-)
-
-//go:generate hsp
-
-// UpdateType defines service update type.
-type UpdateType int32
-
-const (
- // CreateDB indicates create database operation.
- CreateDB UpdateType = iota
- // UpdateDB indicates database peers update operation.
- UpdateDB
- // DropDB indicates drop database operation.
- DropDB
-)
-
-// UpdateServiceHeader defines service update header.
-type UpdateServiceHeader struct {
- Op UpdateType
- Instance ServiceInstance
-}
-
-// SignedUpdateServiceHeader defines signed service update header.
-type SignedUpdateServiceHeader struct {
- UpdateServiceHeader
- Hash hash.Hash
- Signee *asymmetric.PublicKey
- Signature *asymmetric.Signature
-}
-
-// UpdateService defines service update type.
-type UpdateService struct {
- proto.Envelope
- Header SignedUpdateServiceHeader
-}
-
-// UpdateServiceResponse defines empty response entity.
-type UpdateServiceResponse struct{}
-
-// Verify checks hash and signature in update service header.
-func (sh *SignedUpdateServiceHeader) Verify() (err error) {
- // verify hash
- if err = verifyHash(&sh.UpdateServiceHeader, &sh.Hash); err != nil {
- return
- }
- // verify sign
- if sh.Signee == nil || sh.Signature == nil || !sh.Signature.Verify(sh.Hash[:], sh.Signee) {
- return ErrSignVerification
- }
- return
-}
-
-// Sign the request.
-func (sh *SignedUpdateServiceHeader) Sign(signer *asymmetric.PrivateKey) (err error) {
- // build hash
- if err = buildHash(&sh.UpdateServiceHeader, &sh.Hash); err != nil {
- return
- }
-
- // sign
- sh.Signature, err = signer.Sign(sh.Hash[:])
- sh.Signee = signer.PubKey()
-
- return
-}
-
-// Verify checks hash and signature in update service.
-func (s *UpdateService) Verify() error {
- return s.Header.Verify()
-}
-
-// Sign the request.
-func (s *UpdateService) Sign(signer *asymmetric.PrivateKey) (err error) {
- // sign
- return s.Header.Sign(signer)
-}
diff --git a/worker/otypes/update_service_type_gen.go b/worker/otypes/update_service_type_gen.go
deleted file mode 100644
index e48777622..000000000
--- a/worker/otypes/update_service_type_gen.go
+++ /dev/null
@@ -1,145 +0,0 @@
-package otypes
-
-// Code generated by github.com/CovenantSQL/HashStablePack DO NOT EDIT.
-
-import (
- hsp "github.com/CovenantSQL/HashStablePack/marshalhash"
-)
-
-// MarshalHash marshals for hash
-func (z *SignedUpdateServiceHeader) MarshalHash() (o []byte, err error) {
- var b []byte
- o = hsp.Require(b, z.Msgsize())
- // map header, size 4
- o = append(o, 0x84, 0x84)
- if z.Signee == nil {
- o = hsp.AppendNil(o)
- } else {
- if oTemp, err := z.Signee.MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
- }
- }
- o = append(o, 0x84)
- if z.Signature == nil {
- o = hsp.AppendNil(o)
- } else {
- if oTemp, err := z.Signature.MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
- }
- }
- // map header, size 2
- o = append(o, 0x84, 0x82, 0x82)
- o = hsp.AppendInt32(o, int32(z.UpdateServiceHeader.Op))
- o = append(o, 0x82)
- if oTemp, err := z.UpdateServiceHeader.Instance.MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
- }
- o = append(o, 0x84)
- if oTemp, err := z.Hash.MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
- }
- return
-}
-
-// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
-func (z *SignedUpdateServiceHeader) Msgsize() (s int) {
- s = 1 + 7
- if z.Signee == nil {
- s += hsp.NilSize
- } else {
- s += z.Signee.Msgsize()
- }
- s += 10
- if z.Signature == nil {
- s += hsp.NilSize
- } else {
- s += z.Signature.Msgsize()
- }
- s += 20 + 1 + 3 + hsp.Int32Size + 9 + z.UpdateServiceHeader.Instance.Msgsize() + 5 + z.Hash.Msgsize()
- return
-}
-
-// MarshalHash marshals for hash
-func (z *UpdateService) MarshalHash() (o []byte, err error) {
- var b []byte
- o = hsp.Require(b, z.Msgsize())
- // map header, size 2
- o = append(o, 0x82, 0x82)
- if oTemp, err := z.Header.MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
- }
- o = append(o, 0x82)
- if oTemp, err := z.Envelope.MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
- }
- return
-}
-
-// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
-func (z *UpdateService) Msgsize() (s int) {
- s = 1 + 7 + z.Header.Msgsize() + 9 + z.Envelope.Msgsize()
- return
-}
-
-// MarshalHash marshals for hash
-func (z *UpdateServiceHeader) MarshalHash() (o []byte, err error) {
- var b []byte
- o = hsp.Require(b, z.Msgsize())
- // map header, size 2
- o = append(o, 0x82, 0x82)
- if oTemp, err := z.Instance.MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
- }
- o = append(o, 0x82)
- o = hsp.AppendInt32(o, int32(z.Op))
- return
-}
-
-// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
-func (z *UpdateServiceHeader) Msgsize() (s int) {
- s = 1 + 9 + z.Instance.Msgsize() + 3 + hsp.Int32Size
- return
-}
-
-// MarshalHash marshals for hash
-func (z UpdateServiceResponse) MarshalHash() (o []byte, err error) {
- var b []byte
- o = hsp.Require(b, z.Msgsize())
- // map header, size 0
- o = append(o, 0x80)
- return
-}
-
-// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
-func (z UpdateServiceResponse) Msgsize() (s int) {
- s = 1
- return
-}
-
-// MarshalHash marshals for hash
-func (z UpdateType) MarshalHash() (o []byte, err error) {
- var b []byte
- o = hsp.Require(b, z.Msgsize())
- o = hsp.AppendInt32(o, int32(z))
- return
-}
-
-// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
-func (z UpdateType) Msgsize() (s int) {
- s = hsp.Int32Size
- return
-}
diff --git a/worker/otypes/update_service_type_gen_test.go b/worker/otypes/update_service_type_gen_test.go
deleted file mode 100644
index d78a63158..000000000
--- a/worker/otypes/update_service_type_gen_test.go
+++ /dev/null
@@ -1,158 +0,0 @@
-package otypes
-
-// Code generated by github.com/CovenantSQL/HashStablePack DO NOT EDIT.
-
-import (
- "bytes"
- "crypto/rand"
- "encoding/binary"
- "testing"
-)
-
-func TestMarshalHashSignedUpdateServiceHeader(t *testing.T) {
- v := SignedUpdateServiceHeader{}
- binary.Read(rand.Reader, binary.BigEndian, &v)
- bts1, err := v.MarshalHash()
- if err != nil {
- t.Fatal(err)
- }
- bts2, err := v.MarshalHash()
- if err != nil {
- t.Fatal(err)
- }
- if !bytes.Equal(bts1, bts2) {
- t.Fatal("hash not stable")
- }
-}
-
-func BenchmarkMarshalHashSignedUpdateServiceHeader(b *testing.B) {
- v := SignedUpdateServiceHeader{}
- b.ReportAllocs()
- b.ResetTimer()
- for i := 0; i < b.N; i++ {
- v.MarshalHash()
- }
-}
-
-func BenchmarkAppendMsgSignedUpdateServiceHeader(b *testing.B) {
- v := SignedUpdateServiceHeader{}
- bts := make([]byte, 0, v.Msgsize())
- bts, _ = v.MarshalHash()
- b.SetBytes(int64(len(bts)))
- b.ReportAllocs()
- b.ResetTimer()
- for i := 0; i < b.N; i++ {
- bts, _ = v.MarshalHash()
- }
-}
-
-func TestMarshalHashUpdateService(t *testing.T) {
- v := UpdateService{}
- binary.Read(rand.Reader, binary.BigEndian, &v)
- bts1, err := v.MarshalHash()
- if err != nil {
- t.Fatal(err)
- }
- bts2, err := v.MarshalHash()
- if err != nil {
- t.Fatal(err)
- }
- if !bytes.Equal(bts1, bts2) {
- t.Fatal("hash not stable")
- }
-}
-
-func BenchmarkMarshalHashUpdateService(b *testing.B) {
- v := UpdateService{}
- b.ReportAllocs()
- b.ResetTimer()
- for i := 0; i < b.N; i++ {
- v.MarshalHash()
- }
-}
-
-func BenchmarkAppendMsgUpdateService(b *testing.B) {
- v := UpdateService{}
- bts := make([]byte, 0, v.Msgsize())
- bts, _ = v.MarshalHash()
- b.SetBytes(int64(len(bts)))
- b.ReportAllocs()
- b.ResetTimer()
- for i := 0; i < b.N; i++ {
- bts, _ = v.MarshalHash()
- }
-}
-
-func TestMarshalHashUpdateServiceHeader(t *testing.T) {
- v := UpdateServiceHeader{}
- binary.Read(rand.Reader, binary.BigEndian, &v)
- bts1, err := v.MarshalHash()
- if err != nil {
- t.Fatal(err)
- }
- bts2, err := v.MarshalHash()
- if err != nil {
- t.Fatal(err)
- }
- if !bytes.Equal(bts1, bts2) {
- t.Fatal("hash not stable")
- }
-}
-
-func BenchmarkMarshalHashUpdateServiceHeader(b *testing.B) {
- v := UpdateServiceHeader{}
- b.ReportAllocs()
- b.ResetTimer()
- for i := 0; i < b.N; i++ {
- v.MarshalHash()
- }
-}
-
-func BenchmarkAppendMsgUpdateServiceHeader(b *testing.B) {
- v := UpdateServiceHeader{}
- bts := make([]byte, 0, v.Msgsize())
- bts, _ = v.MarshalHash()
- b.SetBytes(int64(len(bts)))
- b.ReportAllocs()
- b.ResetTimer()
- for i := 0; i < b.N; i++ {
- bts, _ = v.MarshalHash()
- }
-}
-
-func TestMarshalHashUpdateServiceResponse(t *testing.T) {
- v := UpdateServiceResponse{}
- binary.Read(rand.Reader, binary.BigEndian, &v)
- bts1, err := v.MarshalHash()
- if err != nil {
- t.Fatal(err)
- }
- bts2, err := v.MarshalHash()
- if err != nil {
- t.Fatal(err)
- }
- if !bytes.Equal(bts1, bts2) {
- t.Fatal("hash not stable")
- }
-}
-
-func BenchmarkMarshalHashUpdateServiceResponse(b *testing.B) {
- v := UpdateServiceResponse{}
- b.ReportAllocs()
- b.ResetTimer()
- for i := 0; i < b.N; i++ {
- v.MarshalHash()
- }
-}
-
-func BenchmarkAppendMsgUpdateServiceResponse(b *testing.B) {
- v := UpdateServiceResponse{}
- bts := make([]byte, 0, v.Msgsize())
- bts, _ = v.MarshalHash()
- b.SetBytes(int64(len(bts)))
- b.ReportAllocs()
- b.ResetTimer()
- for i := 0; i < b.N; i++ {
- bts, _ = v.MarshalHash()
- }
-}
diff --git a/worker/otypes/util.go b/worker/otypes/util.go
deleted file mode 100644
index 0108aec1e..000000000
--- a/worker/otypes/util.go
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright 2018 The CovenantSQL Authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package otypes
-
-import (
- "github.com/CovenantSQL/CovenantSQL/crypto/hash"
-)
-
-type canMarshalHash interface {
- MarshalHash() ([]byte, error)
-}
-
-func verifyHash(data canMarshalHash, h *hash.Hash) (err error) {
- var newHash hash.Hash
- if err = buildHash(data, &newHash); err != nil {
- return
- }
- if !newHash.IsEqual(h) {
- return ErrHashVerification
- }
- return
-}
-
-func buildHash(data canMarshalHash, h *hash.Hash) (err error) {
- var hashBytes []byte
- if hashBytes, err = data.MarshalHash(); err != nil {
- return
- }
- newHash := hash.THashH(hashBytes)
- copy(h[:], newHash[:])
- return
-}
From 5e6289f9c1762aae542c8e078f04b1c8384e8bd0 Mon Sep 17 00:00:00 2001
From: Qi Xiao
Date: Wed, 26 Dec 2018 16:08:32 +0800
Subject: [PATCH 185/278] Support AddTx method in cql-utils
---
.../interfaces/transaction_wrapper.go | 32 ++++++++++++++
.../interfaces/transaction_wrapper_test.go | 44 +++++++++++++++++++
cmd/cql-utils/rpc.go | 8 ++++
3 files changed, 84 insertions(+)
diff --git a/blockproducer/interfaces/transaction_wrapper.go b/blockproducer/interfaces/transaction_wrapper.go
index 2c46b6cf7..612251356 100644
--- a/blockproducer/interfaces/transaction_wrapper.go
+++ b/blockproducer/interfaces/transaction_wrapper.go
@@ -17,6 +17,7 @@
package interfaces
import (
+ "encoding/json"
"reflect"
"sync"
@@ -104,6 +105,37 @@ func (w *TransactionWrapper) CodecDecodeSelf(d *codec.Decoder) {
}
}
+// MarshalJSON implements json.Marshaler interface.
+func (w TransactionWrapper) MarshalJSON() ([]byte, error) {
+ return json.Marshal(w.Transaction)
+}
+
+// UnmarshalJSON implements json.Unmarshaler interface.
+func (w *TransactionWrapper) UnmarshalJSON(data []byte) (err error) {
+ // detect type from current bytes
+ var typeDetector TransactionTypeMixin
+ typeDetector.SetTransactionType(TransactionTypeNumber)
+
+ if err = json.Unmarshal(data, &typeDetector); err != nil {
+ err = errors.Wrap(err, "try decode transaction failed")
+ return
+ }
+
+ txType := typeDetector.GetTransactionType()
+
+ if txType == TransactionTypeNumber {
+ err = errors.Wrapf(ErrInvalidTransactionType, "invalid tx type: %d", txType)
+ return
+ }
+
+ if w.Transaction, err = NewTransaction(txType); err != nil {
+ err = errors.Wrapf(err, "instantiate transaction type %s failed", txType.String())
+ return
+ }
+
+ return json.Unmarshal(data, &w.Transaction)
+}
+
func (w *TransactionWrapper) decodeFromWrapper(d *codec.Decoder) {
helperDecoder, decodeDriver := codec.GenHelperDecoder(d)
containerLen := decodeDriver.ReadArrayStart()
diff --git a/blockproducer/interfaces/transaction_wrapper_test.go b/blockproducer/interfaces/transaction_wrapper_test.go
index a8d97608c..1d3e75bc5 100644
--- a/blockproducer/interfaces/transaction_wrapper_test.go
+++ b/blockproducer/interfaces/transaction_wrapper_test.go
@@ -17,6 +17,8 @@
package interfaces_test
import (
+ "encoding/json"
+ "fmt"
"testing"
pi "github.com/CovenantSQL/CovenantSQL/blockproducer/interfaces"
@@ -183,6 +185,48 @@ func TestTransactionWrapper(t *testing.T) {
var v15 pi.Transaction
err = utils.DecodeMsgPack(buf.Bytes(), &v15)
So(err, ShouldNotBeNil)
+
+ // test json marshal and unmarshal
+ v16 := &TestTransactionEncode{TestField: 10}
+ v16.SetTransactionType(pi.TransactionTypeBilling)
+ var v17 pi.Transaction = v16
+ var jsonData []byte
+ jsonData, err = json.Marshal(v17)
+ So(string(jsonData), ShouldContainSubstring, "TestField")
+ So(err, ShouldBeNil)
+
+ var v18 pi.Transaction = &pi.TransactionWrapper{}
+ err = json.Unmarshal(jsonData, &v18)
+ So(err, ShouldBeNil)
+ So(v18.(*pi.TransactionWrapper).Unwrap(), ShouldNotBeNil)
+ So(v18.GetTransactionType(), ShouldEqual, pi.TransactionTypeBilling)
+ So(v18.(*pi.TransactionWrapper).Unwrap().(*TestTransactionEncode).TestField, ShouldEqual, 10)
+
+ jsonData, err = json.Marshal(v18)
+ So(string(jsonData), ShouldContainSubstring, "TestField")
+
+ v18.(*pi.TransactionWrapper).Transaction = nil
+ jsonData = []byte(`{"TxType": 0, "TestField": 11}`)
+ err = json.Unmarshal(jsonData, &v18)
+ So(err, ShouldBeNil)
+ So(v18.GetTransactionType(), ShouldEqual, pi.TransactionTypeBilling)
+ So(v18.(*pi.TransactionWrapper).Unwrap().(*TestTransactionEncode).TestField, ShouldEqual, 11)
+
+ // unmarshal fail cases
+ v18.(*pi.TransactionWrapper).Transaction = nil
+ jsonData = []byte(`{"TxType": {}, "TestField": 11}`)
+ err = json.Unmarshal(jsonData, &v18)
+ So(err, ShouldNotBeNil)
+
+ v18.(*pi.TransactionWrapper).Transaction = nil
+ jsonData = []byte(fmt.Sprintf(`{"TxType": %d, "TestField": 11}`, pi.TransactionTypeNumber))
+ err = json.Unmarshal(jsonData, &v18)
+ So(err, ShouldNotBeNil)
+
+ v18.(*pi.TransactionWrapper).Transaction = nil
+ jsonData = []byte(fmt.Sprintf(`{"TxType": %d, "TestField": 11}`, pi.TransactionTypeTransfer))
+ err = json.Unmarshal(jsonData, &v18)
+ So(err, ShouldNotBeNil)
})
}
diff --git a/cmd/cql-utils/rpc.go b/cmd/cql-utils/rpc.go
index 43674d6bb..c6082936a 100644
--- a/cmd/cql-utils/rpc.go
+++ b/cmd/cql-utils/rpc.go
@@ -25,6 +25,7 @@ import (
"strings"
bp "github.com/CovenantSQL/CovenantSQL/blockproducer"
+ pi "github.com/CovenantSQL/CovenantSQL/blockproducer/interfaces"
"github.com/CovenantSQL/CovenantSQL/client"
"github.com/CovenantSQL/CovenantSQL/crypto/asymmetric"
"github.com/CovenantSQL/CovenantSQL/crypto/kms"
@@ -80,6 +81,13 @@ func runRPC() {
req, resp := resolveRPCEntities()
+ if rpcName == route.MCCAddTx.String() {
+ // special type of query
+ if addTxReqType, ok := req.(*bp.AddTxReq); ok {
+ addTxReqType.Tx = &pi.TransactionWrapper{}
+ }
+ }
+
// fill the req with request body
if err := json.Unmarshal([]byte(rpcReq), req); err != nil {
fmt.Printf("decode request body failed: %v\n", err)
From f42777282b860d4633e38558c62d65e2578a7885 Mon Sep 17 00:00:00 2001
From: Qi Xiao
Date: Wed, 26 Dec 2018 16:11:54 +0800
Subject: [PATCH 186/278] Fix previous commit with correct types and imports
---
cmd/cql-utils/rpc.go | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/cmd/cql-utils/rpc.go b/cmd/cql-utils/rpc.go
index c6082936a..9c4f55448 100644
--- a/cmd/cql-utils/rpc.go
+++ b/cmd/cql-utils/rpc.go
@@ -33,6 +33,7 @@ import (
"github.com/CovenantSQL/CovenantSQL/route"
"github.com/CovenantSQL/CovenantSQL/rpc"
"github.com/CovenantSQL/CovenantSQL/sqlchain"
+ "github.com/CovenantSQL/CovenantSQL/types"
"github.com/CovenantSQL/CovenantSQL/utils/log"
"github.com/CovenantSQL/CovenantSQL/worker"
yaml "gopkg.in/yaml.v2"
@@ -83,7 +84,7 @@ func runRPC() {
if rpcName == route.MCCAddTx.String() {
// special type of query
- if addTxReqType, ok := req.(*bp.AddTxReq); ok {
+ if addTxReqType, ok := req.(*types.AddTxReq); ok {
addTxReqType.Tx = &pi.TransactionWrapper{}
}
}
From 541e9b718e886da739067e301afe6533dd3a7bfa Mon Sep 17 00:00:00 2001
From: auxten
Date: Wed, 26 Dec 2018 16:52:18 +0800
Subject: [PATCH 187/278] Check pubkey is nil in PubKeyHash
---
crypto/address.go | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/crypto/address.go b/crypto/address.go
index 061ccb0a3..5f09b72e1 100644
--- a/crypto/address.go
+++ b/crypto/address.go
@@ -21,6 +21,7 @@ import (
"github.com/CovenantSQL/CovenantSQL/crypto/hash"
"github.com/CovenantSQL/CovenantSQL/proto"
"github.com/btcsuite/btcutil/base58"
+ "github.com/pkg/errors"
)
const (
@@ -44,6 +45,10 @@ func PubKey2Addr(pubKey *asymmetric.PublicKey, version byte) (addr string, err e
// PubKeyHash generates the account hash address for specified public key.
func PubKeyHash(pubKey *asymmetric.PublicKey) (addr proto.AccountAddress, err error) {
+ if pubKey == nil {
+ err = errors.New("nil public key")
+ return
+ }
var enc []byte
if enc, err = pubKey.MarshalHash(); err != nil {
From 5370eda14fb581e9b9c2a08d52792642b682a576 Mon Sep 17 00:00:00 2001
From: auxten
Date: Wed, 26 Dec 2018 16:52:51 +0800
Subject: [PATCH 188/278] Wrap too long line
---
blockproducer/chain.go | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/blockproducer/chain.go b/blockproducer/chain.go
index 312c023e6..a8dddbfb1 100644
--- a/blockproducer/chain.go
+++ b/blockproducer/chain.go
@@ -445,7 +445,8 @@ func (c *Chain) addTx(tx pi.Transaction) {
func (c *Chain) processTx(tx pi.Transaction) {
if err := tx.Verify(); err != nil {
- log.WithError(err).Errorf("failed to verify transaction with hash: %s, address: %s, tx type: %s", tx.Hash(), tx.GetAccountAddress(), tx.GetTransactionType().String())
+ log.WithError(err).Errorf("failed to verify transaction with hash: %s, address: %s, tx type: %s",
+ tx.Hash(), tx.GetAccountAddress(), tx.GetTransactionType().String())
return
}
if ok := func() (ok bool) {
From 21fba7212f385c3187cd568d7329ab0b2fa47481 Mon Sep 17 00:00:00 2001
From: Qi Xiao
Date: Wed, 26 Dec 2018 16:45:10 +0800
Subject: [PATCH 189/278] Print request and response in cql-utils rpc tool
---
Gopkg.lock | 9 +
Gopkg.toml | 4 +
cmd/cql-utils/rpc.go | 12 +-
vendor/github.com/davecgh/go-spew/LICENSE | 15 +
.../github.com/davecgh/go-spew/spew/bypass.go | 145 +++++
.../davecgh/go-spew/spew/bypasssafe.go | 38 ++
.../github.com/davecgh/go-spew/spew/common.go | 341 ++++++++++++
vendor/github.com/davecgh/go-spew/spew/doc.go | 211 ++++++++
.../github.com/davecgh/go-spew/spew/dump.go | 509 ++++++++++++++++++
.../github.com/davecgh/go-spew/spew/format.go | 419 ++++++++++++++
.../github.com/davecgh/go-spew/spew/spew.go | 148 +++++
11 files changed, 1844 insertions(+), 7 deletions(-)
create mode 100644 vendor/github.com/davecgh/go-spew/LICENSE
create mode 100644 vendor/github.com/davecgh/go-spew/spew/bypass.go
create mode 100644 vendor/github.com/davecgh/go-spew/spew/bypasssafe.go
create mode 100644 vendor/github.com/davecgh/go-spew/spew/common.go
create mode 100644 vendor/github.com/davecgh/go-spew/spew/doc.go
create mode 100644 vendor/github.com/davecgh/go-spew/spew/dump.go
create mode 100644 vendor/github.com/davecgh/go-spew/spew/format.go
create mode 100644 vendor/github.com/davecgh/go-spew/spew/spew.go
diff --git a/Gopkg.lock b/Gopkg.lock
index 63a9e8e89..59c769ad4 100644
--- a/Gopkg.lock
+++ b/Gopkg.lock
@@ -148,6 +148,14 @@
pruneopts = "UT"
revision = "cbb64ac3d964b81592e64f957ad53df015803288"
+[[projects]]
+ digest = "1:ffe9824d294da03b391f44e1ae8281281b4afc1bdaa9588c9097785e3af10cec"
+ name = "github.com/davecgh/go-spew"
+ packages = ["spew"]
+ pruneopts = "UT"
+ revision = "8991bc29aa16c548c550c7ff78260e27b9ab7c73"
+ version = "v1.1.1"
+
[[projects]]
digest = "1:72dc2b6056e7097f829260e4a2ff08d32fec6017df1982a66e110ab4128486f8"
name = "github.com/dlclark/regexp2"
@@ -638,6 +646,7 @@
"github.com/btcsuite/btcutil/base58",
"github.com/coreos/bbolt",
"github.com/cyberdelia/go-metrics-graphite",
+ "github.com/davecgh/go-spew/spew",
"github.com/dyatlov/go-opengraph/opengraph",
"github.com/fortytw2/leaktest",
"github.com/gorilla/handlers",
diff --git a/Gopkg.toml b/Gopkg.toml
index 0b2e9a1b8..9df96a495 100644
--- a/Gopkg.toml
+++ b/Gopkg.toml
@@ -77,3 +77,7 @@
[[constraint]]
branch = "master"
name = "github.com/btcsuite/btcutil"
+
+[[constraint]]
+ name = "github.com/davecgh/go-spew"
+ version = "1.1.1"
diff --git a/cmd/cql-utils/rpc.go b/cmd/cql-utils/rpc.go
index 9c4f55448..b6afe277c 100644
--- a/cmd/cql-utils/rpc.go
+++ b/cmd/cql-utils/rpc.go
@@ -36,7 +36,7 @@ import (
"github.com/CovenantSQL/CovenantSQL/types"
"github.com/CovenantSQL/CovenantSQL/utils/log"
"github.com/CovenantSQL/CovenantSQL/worker"
- yaml "gopkg.in/yaml.v2"
+ "github.com/davecgh/go-spew/spew"
)
var (
@@ -103,6 +103,8 @@ func runRPC() {
return
}
+ fmt.Println("sending request")
+ spew.Dump(req)
if err := rpc.NewCaller().CallNode(proto.NodeID(rpcEndpoint), rpcName, req, resp); err != nil {
// send request failed
fmt.Printf("call rpc failed: %v\n", err)
@@ -111,12 +113,8 @@ func runRPC() {
}
// print the response
- if resBytes, err := yaml.Marshal(resp); err != nil {
- fmt.Printf("marshal response failed: %v\n", err)
- os.Exit(1)
- } else {
- fmt.Println(string(resBytes))
- }
+ fmt.Println("got response")
+ spew.Dump(resp)
}
func checkAndSign(req interface{}) (err error) {
diff --git a/vendor/github.com/davecgh/go-spew/LICENSE b/vendor/github.com/davecgh/go-spew/LICENSE
new file mode 100644
index 000000000..bc52e96f2
--- /dev/null
+++ b/vendor/github.com/davecgh/go-spew/LICENSE
@@ -0,0 +1,15 @@
+ISC License
+
+Copyright (c) 2012-2016 Dave Collins
+
+Permission to use, copy, modify, and/or distribute this software for any
+purpose with or without fee is hereby granted, provided that the above
+copyright notice and this permission notice appear in all copies.
+
+THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
diff --git a/vendor/github.com/davecgh/go-spew/spew/bypass.go b/vendor/github.com/davecgh/go-spew/spew/bypass.go
new file mode 100644
index 000000000..792994785
--- /dev/null
+++ b/vendor/github.com/davecgh/go-spew/spew/bypass.go
@@ -0,0 +1,145 @@
+// Copyright (c) 2015-2016 Dave Collins
+//
+// Permission to use, copy, modify, and distribute this software for any
+// purpose with or without fee is hereby granted, provided that the above
+// copyright notice and this permission notice appear in all copies.
+//
+// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+// NOTE: Due to the following build constraints, this file will only be compiled
+// when the code is not running on Google App Engine, compiled by GopherJS, and
+// "-tags safe" is not added to the go build command line. The "disableunsafe"
+// tag is deprecated and thus should not be used.
+// Go versions prior to 1.4 are disabled because they use a different layout
+// for interfaces which make the implementation of unsafeReflectValue more complex.
+// +build !js,!appengine,!safe,!disableunsafe,go1.4
+
+package spew
+
+import (
+ "reflect"
+ "unsafe"
+)
+
+const (
+ // UnsafeDisabled is a build-time constant which specifies whether or
+ // not access to the unsafe package is available.
+ UnsafeDisabled = false
+
+ // ptrSize is the size of a pointer on the current arch.
+ ptrSize = unsafe.Sizeof((*byte)(nil))
+)
+
+type flag uintptr
+
+var (
+ // flagRO indicates whether the value field of a reflect.Value
+ // is read-only.
+ flagRO flag
+
+ // flagAddr indicates whether the address of the reflect.Value's
+ // value may be taken.
+ flagAddr flag
+)
+
+// flagKindMask holds the bits that make up the kind
+// part of the flags field. In all the supported versions,
+// it is in the lower 5 bits.
+const flagKindMask = flag(0x1f)
+
+// Different versions of Go have used different
+// bit layouts for the flags type. This table
+// records the known combinations.
+var okFlags = []struct {
+ ro, addr flag
+}{{
+ // From Go 1.4 to 1.5
+ ro: 1 << 5,
+ addr: 1 << 7,
+}, {
+ // Up to Go tip.
+ ro: 1<<5 | 1<<6,
+ addr: 1 << 8,
+}}
+
+var flagValOffset = func() uintptr {
+ field, ok := reflect.TypeOf(reflect.Value{}).FieldByName("flag")
+ if !ok {
+ panic("reflect.Value has no flag field")
+ }
+ return field.Offset
+}()
+
+// flagField returns a pointer to the flag field of a reflect.Value.
+func flagField(v *reflect.Value) *flag {
+ return (*flag)(unsafe.Pointer(uintptr(unsafe.Pointer(v)) + flagValOffset))
+}
+
+// unsafeReflectValue converts the passed reflect.Value into a one that bypasses
+// the typical safety restrictions preventing access to unaddressable and
+// unexported data. It works by digging the raw pointer to the underlying
+// value out of the protected value and generating a new unprotected (unsafe)
+// reflect.Value to it.
+//
+// This allows us to check for implementations of the Stringer and error
+// interfaces to be used for pretty printing ordinarily unaddressable and
+// inaccessible values such as unexported struct fields.
+func unsafeReflectValue(v reflect.Value) reflect.Value {
+ if !v.IsValid() || (v.CanInterface() && v.CanAddr()) {
+ return v
+ }
+ flagFieldPtr := flagField(&v)
+ *flagFieldPtr &^= flagRO
+ *flagFieldPtr |= flagAddr
+ return v
+}
+
+// Sanity checks against future reflect package changes
+// to the type or semantics of the Value.flag field.
+func init() {
+ field, ok := reflect.TypeOf(reflect.Value{}).FieldByName("flag")
+ if !ok {
+ panic("reflect.Value has no flag field")
+ }
+ if field.Type.Kind() != reflect.TypeOf(flag(0)).Kind() {
+ panic("reflect.Value flag field has changed kind")
+ }
+ type t0 int
+ var t struct {
+ A t0
+ // t0 will have flagEmbedRO set.
+ t0
+ // a will have flagStickyRO set
+ a t0
+ }
+ vA := reflect.ValueOf(t).FieldByName("A")
+ va := reflect.ValueOf(t).FieldByName("a")
+ vt0 := reflect.ValueOf(t).FieldByName("t0")
+
+ // Infer flagRO from the difference between the flags
+ // for the (otherwise identical) fields in t.
+ flagPublic := *flagField(&vA)
+ flagWithRO := *flagField(&va) | *flagField(&vt0)
+ flagRO = flagPublic ^ flagWithRO
+
+ // Infer flagAddr from the difference between a value
+ // taken from a pointer and not.
+ vPtrA := reflect.ValueOf(&t).Elem().FieldByName("A")
+ flagNoPtr := *flagField(&vA)
+ flagPtr := *flagField(&vPtrA)
+ flagAddr = flagNoPtr ^ flagPtr
+
+ // Check that the inferred flags tally with one of the known versions.
+ for _, f := range okFlags {
+ if flagRO == f.ro && flagAddr == f.addr {
+ return
+ }
+ }
+ panic("reflect.Value read-only flag has changed semantics")
+}
diff --git a/vendor/github.com/davecgh/go-spew/spew/bypasssafe.go b/vendor/github.com/davecgh/go-spew/spew/bypasssafe.go
new file mode 100644
index 000000000..205c28d68
--- /dev/null
+++ b/vendor/github.com/davecgh/go-spew/spew/bypasssafe.go
@@ -0,0 +1,38 @@
+// Copyright (c) 2015-2016 Dave Collins
+//
+// Permission to use, copy, modify, and distribute this software for any
+// purpose with or without fee is hereby granted, provided that the above
+// copyright notice and this permission notice appear in all copies.
+//
+// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+// NOTE: Due to the following build constraints, this file will only be compiled
+// when the code is running on Google App Engine, compiled by GopherJS, or
+// "-tags safe" is added to the go build command line. The "disableunsafe"
+// tag is deprecated and thus should not be used.
+// +build js appengine safe disableunsafe !go1.4
+
+package spew
+
+import "reflect"
+
+const (
+ // UnsafeDisabled is a build-time constant which specifies whether or
+ // not access to the unsafe package is available.
+ UnsafeDisabled = true
+)
+
+// unsafeReflectValue typically converts the passed reflect.Value into a one
+// that bypasses the typical safety restrictions preventing access to
+// unaddressable and unexported data. However, doing this relies on access to
+// the unsafe package. This is a stub version which simply returns the passed
+// reflect.Value when the unsafe package is not available.
+func unsafeReflectValue(v reflect.Value) reflect.Value {
+ return v
+}
diff --git a/vendor/github.com/davecgh/go-spew/spew/common.go b/vendor/github.com/davecgh/go-spew/spew/common.go
new file mode 100644
index 000000000..1be8ce945
--- /dev/null
+++ b/vendor/github.com/davecgh/go-spew/spew/common.go
@@ -0,0 +1,341 @@
+/*
+ * Copyright (c) 2013-2016 Dave Collins
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+package spew
+
+import (
+ "bytes"
+ "fmt"
+ "io"
+ "reflect"
+ "sort"
+ "strconv"
+)
+
+// Some constants in the form of bytes to avoid string overhead. This mirrors
+// the technique used in the fmt package.
+var (
+ panicBytes = []byte("(PANIC=")
+ plusBytes = []byte("+")
+ iBytes = []byte("i")
+ trueBytes = []byte("true")
+ falseBytes = []byte("false")
+ interfaceBytes = []byte("(interface {})")
+ commaNewlineBytes = []byte(",\n")
+ newlineBytes = []byte("\n")
+ openBraceBytes = []byte("{")
+ openBraceNewlineBytes = []byte("{\n")
+ closeBraceBytes = []byte("}")
+ asteriskBytes = []byte("*")
+ colonBytes = []byte(":")
+ colonSpaceBytes = []byte(": ")
+ openParenBytes = []byte("(")
+ closeParenBytes = []byte(")")
+ spaceBytes = []byte(" ")
+ pointerChainBytes = []byte("->")
+ nilAngleBytes = []byte("")
+ maxNewlineBytes = []byte("\n")
+ maxShortBytes = []byte("")
+ circularBytes = []byte("")
+ circularShortBytes = []byte("")
+ invalidAngleBytes = []byte("")
+ openBracketBytes = []byte("[")
+ closeBracketBytes = []byte("]")
+ percentBytes = []byte("%")
+ precisionBytes = []byte(".")
+ openAngleBytes = []byte("<")
+ closeAngleBytes = []byte(">")
+ openMapBytes = []byte("map[")
+ closeMapBytes = []byte("]")
+ lenEqualsBytes = []byte("len=")
+ capEqualsBytes = []byte("cap=")
+)
+
+// hexDigits is used to map a decimal value to a hex digit.
+var hexDigits = "0123456789abcdef"
+
+// catchPanic handles any panics that might occur during the handleMethods
+// calls.
+func catchPanic(w io.Writer, v reflect.Value) {
+ if err := recover(); err != nil {
+ w.Write(panicBytes)
+ fmt.Fprintf(w, "%v", err)
+ w.Write(closeParenBytes)
+ }
+}
+
+// handleMethods attempts to call the Error and String methods on the underlying
+// type the passed reflect.Value represents and outputes the result to Writer w.
+//
+// It handles panics in any called methods by catching and displaying the error
+// as the formatted value.
+func handleMethods(cs *ConfigState, w io.Writer, v reflect.Value) (handled bool) {
+ // We need an interface to check if the type implements the error or
+ // Stringer interface. However, the reflect package won't give us an
+ // interface on certain things like unexported struct fields in order
+ // to enforce visibility rules. We use unsafe, when it's available,
+ // to bypass these restrictions since this package does not mutate the
+ // values.
+ if !v.CanInterface() {
+ if UnsafeDisabled {
+ return false
+ }
+
+ v = unsafeReflectValue(v)
+ }
+
+ // Choose whether or not to do error and Stringer interface lookups against
+ // the base type or a pointer to the base type depending on settings.
+ // Technically calling one of these methods with a pointer receiver can
+ // mutate the value, however, types which choose to satisify an error or
+ // Stringer interface with a pointer receiver should not be mutating their
+ // state inside these interface methods.
+ if !cs.DisablePointerMethods && !UnsafeDisabled && !v.CanAddr() {
+ v = unsafeReflectValue(v)
+ }
+ if v.CanAddr() {
+ v = v.Addr()
+ }
+
+ // Is it an error or Stringer?
+ switch iface := v.Interface().(type) {
+ case error:
+ defer catchPanic(w, v)
+ if cs.ContinueOnMethod {
+ w.Write(openParenBytes)
+ w.Write([]byte(iface.Error()))
+ w.Write(closeParenBytes)
+ w.Write(spaceBytes)
+ return false
+ }
+
+ w.Write([]byte(iface.Error()))
+ return true
+
+ case fmt.Stringer:
+ defer catchPanic(w, v)
+ if cs.ContinueOnMethod {
+ w.Write(openParenBytes)
+ w.Write([]byte(iface.String()))
+ w.Write(closeParenBytes)
+ w.Write(spaceBytes)
+ return false
+ }
+ w.Write([]byte(iface.String()))
+ return true
+ }
+ return false
+}
+
+// printBool outputs a boolean value as true or false to Writer w.
+func printBool(w io.Writer, val bool) {
+ if val {
+ w.Write(trueBytes)
+ } else {
+ w.Write(falseBytes)
+ }
+}
+
+// printInt outputs a signed integer value to Writer w.
+func printInt(w io.Writer, val int64, base int) {
+ w.Write([]byte(strconv.FormatInt(val, base)))
+}
+
+// printUint outputs an unsigned integer value to Writer w.
+func printUint(w io.Writer, val uint64, base int) {
+ w.Write([]byte(strconv.FormatUint(val, base)))
+}
+
+// printFloat outputs a floating point value using the specified precision,
+// which is expected to be 32 or 64bit, to Writer w.
+func printFloat(w io.Writer, val float64, precision int) {
+ w.Write([]byte(strconv.FormatFloat(val, 'g', -1, precision)))
+}
+
+// printComplex outputs a complex value using the specified float precision
+// for the real and imaginary parts to Writer w.
+func printComplex(w io.Writer, c complex128, floatPrecision int) {
+ r := real(c)
+ w.Write(openParenBytes)
+ w.Write([]byte(strconv.FormatFloat(r, 'g', -1, floatPrecision)))
+ i := imag(c)
+ if i >= 0 {
+ w.Write(plusBytes)
+ }
+ w.Write([]byte(strconv.FormatFloat(i, 'g', -1, floatPrecision)))
+ w.Write(iBytes)
+ w.Write(closeParenBytes)
+}
+
+// printHexPtr outputs a uintptr formatted as hexadecimal with a leading '0x'
+// prefix to Writer w.
+func printHexPtr(w io.Writer, p uintptr) {
+ // Null pointer.
+ num := uint64(p)
+ if num == 0 {
+ w.Write(nilAngleBytes)
+ return
+ }
+
+ // Max uint64 is 16 bytes in hex + 2 bytes for '0x' prefix
+ buf := make([]byte, 18)
+
+ // It's simpler to construct the hex string right to left.
+ base := uint64(16)
+ i := len(buf) - 1
+ for num >= base {
+ buf[i] = hexDigits[num%base]
+ num /= base
+ i--
+ }
+ buf[i] = hexDigits[num]
+
+ // Add '0x' prefix.
+ i--
+ buf[i] = 'x'
+ i--
+ buf[i] = '0'
+
+ // Strip unused leading bytes.
+ buf = buf[i:]
+ w.Write(buf)
+}
+
+// valuesSorter implements sort.Interface to allow a slice of reflect.Value
+// elements to be sorted.
+type valuesSorter struct {
+ values []reflect.Value
+ strings []string // either nil or same len and values
+ cs *ConfigState
+}
+
+// newValuesSorter initializes a valuesSorter instance, which holds a set of
+// surrogate keys on which the data should be sorted. It uses flags in
+// ConfigState to decide if and how to populate those surrogate keys.
+func newValuesSorter(values []reflect.Value, cs *ConfigState) sort.Interface {
+ vs := &valuesSorter{values: values, cs: cs}
+ if canSortSimply(vs.values[0].Kind()) {
+ return vs
+ }
+ if !cs.DisableMethods {
+ vs.strings = make([]string, len(values))
+ for i := range vs.values {
+ b := bytes.Buffer{}
+ if !handleMethods(cs, &b, vs.values[i]) {
+ vs.strings = nil
+ break
+ }
+ vs.strings[i] = b.String()
+ }
+ }
+ if vs.strings == nil && cs.SpewKeys {
+ vs.strings = make([]string, len(values))
+ for i := range vs.values {
+ vs.strings[i] = Sprintf("%#v", vs.values[i].Interface())
+ }
+ }
+ return vs
+}
+
+// canSortSimply tests whether a reflect.Kind is a primitive that can be sorted
+// directly, or whether it should be considered for sorting by surrogate keys
+// (if the ConfigState allows it).
+func canSortSimply(kind reflect.Kind) bool {
+ // This switch parallels valueSortLess, except for the default case.
+ switch kind {
+ case reflect.Bool:
+ return true
+ case reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Int:
+ return true
+ case reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uint:
+ return true
+ case reflect.Float32, reflect.Float64:
+ return true
+ case reflect.String:
+ return true
+ case reflect.Uintptr:
+ return true
+ case reflect.Array:
+ return true
+ }
+ return false
+}
+
+// Len returns the number of values in the slice. It is part of the
+// sort.Interface implementation.
+func (s *valuesSorter) Len() int {
+ return len(s.values)
+}
+
+// Swap swaps the values at the passed indices. It is part of the
+// sort.Interface implementation.
+func (s *valuesSorter) Swap(i, j int) {
+ s.values[i], s.values[j] = s.values[j], s.values[i]
+ if s.strings != nil {
+ s.strings[i], s.strings[j] = s.strings[j], s.strings[i]
+ }
+}
+
+// valueSortLess returns whether the first value should sort before the second
+// value. It is used by valueSorter.Less as part of the sort.Interface
+// implementation.
+func valueSortLess(a, b reflect.Value) bool {
+ switch a.Kind() {
+ case reflect.Bool:
+ return !a.Bool() && b.Bool()
+ case reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Int:
+ return a.Int() < b.Int()
+ case reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uint:
+ return a.Uint() < b.Uint()
+ case reflect.Float32, reflect.Float64:
+ return a.Float() < b.Float()
+ case reflect.String:
+ return a.String() < b.String()
+ case reflect.Uintptr:
+ return a.Uint() < b.Uint()
+ case reflect.Array:
+ // Compare the contents of both arrays.
+ l := a.Len()
+ for i := 0; i < l; i++ {
+ av := a.Index(i)
+ bv := b.Index(i)
+ if av.Interface() == bv.Interface() {
+ continue
+ }
+ return valueSortLess(av, bv)
+ }
+ }
+ return a.String() < b.String()
+}
+
+// Less returns whether the value at index i should sort before the
+// value at index j. It is part of the sort.Interface implementation.
+func (s *valuesSorter) Less(i, j int) bool {
+ if s.strings == nil {
+ return valueSortLess(s.values[i], s.values[j])
+ }
+ return s.strings[i] < s.strings[j]
+}
+
+// sortValues is a sort function that handles both native types and any type that
+// can be converted to error or Stringer. Other inputs are sorted according to
+// their Value.String() value to ensure display stability.
+func sortValues(values []reflect.Value, cs *ConfigState) {
+ if len(values) == 0 {
+ return
+ }
+ sort.Sort(newValuesSorter(values, cs))
+}
diff --git a/vendor/github.com/davecgh/go-spew/spew/doc.go b/vendor/github.com/davecgh/go-spew/spew/doc.go
new file mode 100644
index 000000000..aacaac6f1
--- /dev/null
+++ b/vendor/github.com/davecgh/go-spew/spew/doc.go
@@ -0,0 +1,211 @@
+/*
+ * Copyright (c) 2013-2016 Dave Collins
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/*
+Package spew implements a deep pretty printer for Go data structures to aid in
+debugging.
+
+A quick overview of the additional features spew provides over the built-in
+printing facilities for Go data types are as follows:
+
+ * Pointers are dereferenced and followed
+ * Circular data structures are detected and handled properly
+ * Custom Stringer/error interfaces are optionally invoked, including
+ on unexported types
+ * Custom types which only implement the Stringer/error interfaces via
+ a pointer receiver are optionally invoked when passing non-pointer
+ variables
+ * Byte arrays and slices are dumped like the hexdump -C command which
+ includes offsets, byte values in hex, and ASCII output (only when using
+ Dump style)
+
+There are two different approaches spew allows for dumping Go data structures:
+
+ * Dump style which prints with newlines, customizable indentation,
+ and additional debug information such as types and all pointer addresses
+ used to indirect to the final value
+ * A custom Formatter interface that integrates cleanly with the standard fmt
+ package and replaces %v, %+v, %#v, and %#+v to provide inline printing
+ similar to the default %v while providing the additional functionality
+ outlined above and passing unsupported format verbs such as %x and %q
+ along to fmt
+
+Quick Start
+
+This section demonstrates how to quickly get started with spew. See the
+sections below for further details on formatting and configuration options.
+
+To dump a variable with full newlines, indentation, type, and pointer
+information use Dump, Fdump, or Sdump:
+ spew.Dump(myVar1, myVar2, ...)
+ spew.Fdump(someWriter, myVar1, myVar2, ...)
+ str := spew.Sdump(myVar1, myVar2, ...)
+
+Alternatively, if you would prefer to use format strings with a compacted inline
+printing style, use the convenience wrappers Printf, Fprintf, etc with
+%v (most compact), %+v (adds pointer addresses), %#v (adds types), or
+%#+v (adds types and pointer addresses):
+ spew.Printf("myVar1: %v -- myVar2: %+v", myVar1, myVar2)
+ spew.Printf("myVar3: %#v -- myVar4: %#+v", myVar3, myVar4)
+ spew.Fprintf(someWriter, "myVar1: %v -- myVar2: %+v", myVar1, myVar2)
+ spew.Fprintf(someWriter, "myVar3: %#v -- myVar4: %#+v", myVar3, myVar4)
+
+Configuration Options
+
+Configuration of spew is handled by fields in the ConfigState type. For
+convenience, all of the top-level functions use a global state available
+via the spew.Config global.
+
+It is also possible to create a ConfigState instance that provides methods
+equivalent to the top-level functions. This allows concurrent configuration
+options. See the ConfigState documentation for more details.
+
+The following configuration options are available:
+ * Indent
+ String to use for each indentation level for Dump functions.
+ It is a single space by default. A popular alternative is "\t".
+
+ * MaxDepth
+ Maximum number of levels to descend into nested data structures.
+ There is no limit by default.
+
+ * DisableMethods
+ Disables invocation of error and Stringer interface methods.
+ Method invocation is enabled by default.
+
+ * DisablePointerMethods
+ Disables invocation of error and Stringer interface methods on types
+ which only accept pointer receivers from non-pointer variables.
+ Pointer method invocation is enabled by default.
+
+ * DisablePointerAddresses
+ DisablePointerAddresses specifies whether to disable the printing of
+ pointer addresses. This is useful when diffing data structures in tests.
+
+ * DisableCapacities
+ DisableCapacities specifies whether to disable the printing of
+ capacities for arrays, slices, maps and channels. This is useful when
+ diffing data structures in tests.
+
+ * ContinueOnMethod
+ Enables recursion into types after invoking error and Stringer interface
+ methods. Recursion after method invocation is disabled by default.
+
+ * SortKeys
+ Specifies map keys should be sorted before being printed. Use
+ this to have a more deterministic, diffable output. Note that
+ only native types (bool, int, uint, floats, uintptr and string)
+ and types which implement error or Stringer interfaces are
+ supported with other types sorted according to the
+ reflect.Value.String() output which guarantees display
+ stability. Natural map order is used by default.
+
+ * SpewKeys
+ Specifies that, as a last resort attempt, map keys should be
+ spewed to strings and sorted by those strings. This is only
+ considered if SortKeys is true.
+
+Dump Usage
+
+Simply call spew.Dump with a list of variables you want to dump:
+
+ spew.Dump(myVar1, myVar2, ...)
+
+You may also call spew.Fdump if you would prefer to output to an arbitrary
+io.Writer. For example, to dump to standard error:
+
+ spew.Fdump(os.Stderr, myVar1, myVar2, ...)
+
+A third option is to call spew.Sdump to get the formatted output as a string:
+
+ str := spew.Sdump(myVar1, myVar2, ...)
+
+Sample Dump Output
+
+See the Dump example for details on the setup of the types and variables being
+shown here.
+
+ (main.Foo) {
+ unexportedField: (*main.Bar)(0xf84002e210)({
+ flag: (main.Flag) flagTwo,
+ data: (uintptr)
+ }),
+ ExportedField: (map[interface {}]interface {}) (len=1) {
+ (string) (len=3) "one": (bool) true
+ }
+ }
+
+Byte (and uint8) arrays and slices are displayed uniquely like the hexdump -C
+command as shown.
+ ([]uint8) (len=32 cap=32) {
+ 00000000 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 |............... |
+ 00000010 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 30 |!"#$%&'()*+,-./0|
+ 00000020 31 32 |12|
+ }
+
+Custom Formatter
+
+Spew provides a custom formatter that implements the fmt.Formatter interface
+so that it integrates cleanly with standard fmt package printing functions. The
+formatter is useful for inline printing of smaller data types similar to the
+standard %v format specifier.
+
+The custom formatter only responds to the %v (most compact), %+v (adds pointer
+addresses), %#v (adds types), or %#+v (adds types and pointer addresses) verb
+combinations. Any other verbs such as %x and %q will be sent to the the
+standard fmt package for formatting. In addition, the custom formatter ignores
+the width and precision arguments (however they will still work on the format
+specifiers not handled by the custom formatter).
+
+Custom Formatter Usage
+
+The simplest way to make use of the spew custom formatter is to call one of the
+convenience functions such as spew.Printf, spew.Println, or spew.Printf. The
+functions have syntax you are most likely already familiar with:
+
+ spew.Printf("myVar1: %v -- myVar2: %+v", myVar1, myVar2)
+ spew.Printf("myVar3: %#v -- myVar4: %#+v", myVar3, myVar4)
+ spew.Println(myVar, myVar2)
+ spew.Fprintf(os.Stderr, "myVar1: %v -- myVar2: %+v", myVar1, myVar2)
+ spew.Fprintf(os.Stderr, "myVar3: %#v -- myVar4: %#+v", myVar3, myVar4)
+
+See the Index for the full list convenience functions.
+
+Sample Formatter Output
+
+Double pointer to a uint8:
+ %v: <**>5
+ %+v: <**>(0xf8400420d0->0xf8400420c8)5
+ %#v: (**uint8)5
+ %#+v: (**uint8)(0xf8400420d0->0xf8400420c8)5
+
+Pointer to circular struct with a uint8 field and a pointer to itself:
+ %v: <*>{1 <*>}
+ %+v: <*>(0xf84003e260){ui8:1 c:<*>(0xf84003e260)}
+ %#v: (*main.circular){ui8:(uint8)1 c:(*main.circular)}
+ %#+v: (*main.circular)(0xf84003e260){ui8:(uint8)1 c:(*main.circular)(0xf84003e260)}
+
+See the Printf example for details on the setup of variables being shown
+here.
+
+Errors
+
+Since it is possible for custom Stringer/error interfaces to panic, spew
+detects them and handles them internally by printing the panic information
+inline with the output. Since spew is intended to provide deep pretty printing
+capabilities on structures, it intentionally does not return any errors.
+*/
+package spew
diff --git a/vendor/github.com/davecgh/go-spew/spew/dump.go b/vendor/github.com/davecgh/go-spew/spew/dump.go
new file mode 100644
index 000000000..f78d89fc1
--- /dev/null
+++ b/vendor/github.com/davecgh/go-spew/spew/dump.go
@@ -0,0 +1,509 @@
+/*
+ * Copyright (c) 2013-2016 Dave Collins
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+package spew
+
+import (
+ "bytes"
+ "encoding/hex"
+ "fmt"
+ "io"
+ "os"
+ "reflect"
+ "regexp"
+ "strconv"
+ "strings"
+)
+
+var (
+ // uint8Type is a reflect.Type representing a uint8. It is used to
+ // convert cgo types to uint8 slices for hexdumping.
+ uint8Type = reflect.TypeOf(uint8(0))
+
+ // cCharRE is a regular expression that matches a cgo char.
+ // It is used to detect character arrays to hexdump them.
+ cCharRE = regexp.MustCompile(`^.*\._Ctype_char$`)
+
+ // cUnsignedCharRE is a regular expression that matches a cgo unsigned
+ // char. It is used to detect unsigned character arrays to hexdump
+ // them.
+ cUnsignedCharRE = regexp.MustCompile(`^.*\._Ctype_unsignedchar$`)
+
+ // cUint8tCharRE is a regular expression that matches a cgo uint8_t.
+ // It is used to detect uint8_t arrays to hexdump them.
+ cUint8tCharRE = regexp.MustCompile(`^.*\._Ctype_uint8_t$`)
+)
+
+// dumpState contains information about the state of a dump operation.
+type dumpState struct {
+ w io.Writer
+ depth int
+ pointers map[uintptr]int
+ ignoreNextType bool
+ ignoreNextIndent bool
+ cs *ConfigState
+}
+
+// indent performs indentation according to the depth level and cs.Indent
+// option.
+func (d *dumpState) indent() {
+ if d.ignoreNextIndent {
+ d.ignoreNextIndent = false
+ return
+ }
+ d.w.Write(bytes.Repeat([]byte(d.cs.Indent), d.depth))
+}
+
+// unpackValue returns values inside of non-nil interfaces when possible.
+// This is useful for data types like structs, arrays, slices, and maps which
+// can contain varying types packed inside an interface.
+func (d *dumpState) unpackValue(v reflect.Value) reflect.Value {
+ if v.Kind() == reflect.Interface && !v.IsNil() {
+ v = v.Elem()
+ }
+ return v
+}
+
+// dumpPtr handles formatting of pointers by indirecting them as necessary.
+func (d *dumpState) dumpPtr(v reflect.Value) {
+ // Remove pointers at or below the current depth from map used to detect
+ // circular refs.
+ for k, depth := range d.pointers {
+ if depth >= d.depth {
+ delete(d.pointers, k)
+ }
+ }
+
+ // Keep list of all dereferenced pointers to show later.
+ pointerChain := make([]uintptr, 0)
+
+ // Figure out how many levels of indirection there are by dereferencing
+ // pointers and unpacking interfaces down the chain while detecting circular
+ // references.
+ nilFound := false
+ cycleFound := false
+ indirects := 0
+ ve := v
+ for ve.Kind() == reflect.Ptr {
+ if ve.IsNil() {
+ nilFound = true
+ break
+ }
+ indirects++
+ addr := ve.Pointer()
+ pointerChain = append(pointerChain, addr)
+ if pd, ok := d.pointers[addr]; ok && pd < d.depth {
+ cycleFound = true
+ indirects--
+ break
+ }
+ d.pointers[addr] = d.depth
+
+ ve = ve.Elem()
+ if ve.Kind() == reflect.Interface {
+ if ve.IsNil() {
+ nilFound = true
+ break
+ }
+ ve = ve.Elem()
+ }
+ }
+
+ // Display type information.
+ d.w.Write(openParenBytes)
+ d.w.Write(bytes.Repeat(asteriskBytes, indirects))
+ d.w.Write([]byte(ve.Type().String()))
+ d.w.Write(closeParenBytes)
+
+ // Display pointer information.
+ if !d.cs.DisablePointerAddresses && len(pointerChain) > 0 {
+ d.w.Write(openParenBytes)
+ for i, addr := range pointerChain {
+ if i > 0 {
+ d.w.Write(pointerChainBytes)
+ }
+ printHexPtr(d.w, addr)
+ }
+ d.w.Write(closeParenBytes)
+ }
+
+ // Display dereferenced value.
+ d.w.Write(openParenBytes)
+ switch {
+ case nilFound:
+ d.w.Write(nilAngleBytes)
+
+ case cycleFound:
+ d.w.Write(circularBytes)
+
+ default:
+ d.ignoreNextType = true
+ d.dump(ve)
+ }
+ d.w.Write(closeParenBytes)
+}
+
+// dumpSlice handles formatting of arrays and slices. Byte (uint8 under
+// reflection) arrays and slices are dumped in hexdump -C fashion.
+func (d *dumpState) dumpSlice(v reflect.Value) {
+ // Determine whether this type should be hex dumped or not. Also,
+ // for types which should be hexdumped, try to use the underlying data
+ // first, then fall back to trying to convert them to a uint8 slice.
+ var buf []uint8
+ doConvert := false
+ doHexDump := false
+ numEntries := v.Len()
+ if numEntries > 0 {
+ vt := v.Index(0).Type()
+ vts := vt.String()
+ switch {
+ // C types that need to be converted.
+ case cCharRE.MatchString(vts):
+ fallthrough
+ case cUnsignedCharRE.MatchString(vts):
+ fallthrough
+ case cUint8tCharRE.MatchString(vts):
+ doConvert = true
+
+ // Try to use existing uint8 slices and fall back to converting
+ // and copying if that fails.
+ case vt.Kind() == reflect.Uint8:
+ // We need an addressable interface to convert the type
+ // to a byte slice. However, the reflect package won't
+ // give us an interface on certain things like
+ // unexported struct fields in order to enforce
+ // visibility rules. We use unsafe, when available, to
+ // bypass these restrictions since this package does not
+ // mutate the values.
+ vs := v
+ if !vs.CanInterface() || !vs.CanAddr() {
+ vs = unsafeReflectValue(vs)
+ }
+ if !UnsafeDisabled {
+ vs = vs.Slice(0, numEntries)
+
+ // Use the existing uint8 slice if it can be
+ // type asserted.
+ iface := vs.Interface()
+ if slice, ok := iface.([]uint8); ok {
+ buf = slice
+ doHexDump = true
+ break
+ }
+ }
+
+ // The underlying data needs to be converted if it can't
+ // be type asserted to a uint8 slice.
+ doConvert = true
+ }
+
+ // Copy and convert the underlying type if needed.
+ if doConvert && vt.ConvertibleTo(uint8Type) {
+ // Convert and copy each element into a uint8 byte
+ // slice.
+ buf = make([]uint8, numEntries)
+ for i := 0; i < numEntries; i++ {
+ vv := v.Index(i)
+ buf[i] = uint8(vv.Convert(uint8Type).Uint())
+ }
+ doHexDump = true
+ }
+ }
+
+ // Hexdump the entire slice as needed.
+ if doHexDump {
+ indent := strings.Repeat(d.cs.Indent, d.depth)
+ str := indent + hex.Dump(buf)
+ str = strings.Replace(str, "\n", "\n"+indent, -1)
+ str = strings.TrimRight(str, d.cs.Indent)
+ d.w.Write([]byte(str))
+ return
+ }
+
+ // Recursively call dump for each item.
+ for i := 0; i < numEntries; i++ {
+ d.dump(d.unpackValue(v.Index(i)))
+ if i < (numEntries - 1) {
+ d.w.Write(commaNewlineBytes)
+ } else {
+ d.w.Write(newlineBytes)
+ }
+ }
+}
+
+// dump is the main workhorse for dumping a value. It uses the passed reflect
+// value to figure out what kind of object we are dealing with and formats it
+// appropriately. It is a recursive function, however circular data structures
+// are detected and handled properly.
+func (d *dumpState) dump(v reflect.Value) {
+ // Handle invalid reflect values immediately.
+ kind := v.Kind()
+ if kind == reflect.Invalid {
+ d.w.Write(invalidAngleBytes)
+ return
+ }
+
+ // Handle pointers specially.
+ if kind == reflect.Ptr {
+ d.indent()
+ d.dumpPtr(v)
+ return
+ }
+
+ // Print type information unless already handled elsewhere.
+ if !d.ignoreNextType {
+ d.indent()
+ d.w.Write(openParenBytes)
+ d.w.Write([]byte(v.Type().String()))
+ d.w.Write(closeParenBytes)
+ d.w.Write(spaceBytes)
+ }
+ d.ignoreNextType = false
+
+ // Display length and capacity if the built-in len and cap functions
+ // work with the value's kind and the len/cap itself is non-zero.
+ valueLen, valueCap := 0, 0
+ switch v.Kind() {
+ case reflect.Array, reflect.Slice, reflect.Chan:
+ valueLen, valueCap = v.Len(), v.Cap()
+ case reflect.Map, reflect.String:
+ valueLen = v.Len()
+ }
+ if valueLen != 0 || !d.cs.DisableCapacities && valueCap != 0 {
+ d.w.Write(openParenBytes)
+ if valueLen != 0 {
+ d.w.Write(lenEqualsBytes)
+ printInt(d.w, int64(valueLen), 10)
+ }
+ if !d.cs.DisableCapacities && valueCap != 0 {
+ if valueLen != 0 {
+ d.w.Write(spaceBytes)
+ }
+ d.w.Write(capEqualsBytes)
+ printInt(d.w, int64(valueCap), 10)
+ }
+ d.w.Write(closeParenBytes)
+ d.w.Write(spaceBytes)
+ }
+
+ // Call Stringer/error interfaces if they exist and the handle methods flag
+ // is enabled
+ if !d.cs.DisableMethods {
+ if (kind != reflect.Invalid) && (kind != reflect.Interface) {
+ if handled := handleMethods(d.cs, d.w, v); handled {
+ return
+ }
+ }
+ }
+
+ switch kind {
+ case reflect.Invalid:
+ // Do nothing. We should never get here since invalid has already
+ // been handled above.
+
+ case reflect.Bool:
+ printBool(d.w, v.Bool())
+
+ case reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Int:
+ printInt(d.w, v.Int(), 10)
+
+ case reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uint:
+ printUint(d.w, v.Uint(), 10)
+
+ case reflect.Float32:
+ printFloat(d.w, v.Float(), 32)
+
+ case reflect.Float64:
+ printFloat(d.w, v.Float(), 64)
+
+ case reflect.Complex64:
+ printComplex(d.w, v.Complex(), 32)
+
+ case reflect.Complex128:
+ printComplex(d.w, v.Complex(), 64)
+
+ case reflect.Slice:
+ if v.IsNil() {
+ d.w.Write(nilAngleBytes)
+ break
+ }
+ fallthrough
+
+ case reflect.Array:
+ d.w.Write(openBraceNewlineBytes)
+ d.depth++
+ if (d.cs.MaxDepth != 0) && (d.depth > d.cs.MaxDepth) {
+ d.indent()
+ d.w.Write(maxNewlineBytes)
+ } else {
+ d.dumpSlice(v)
+ }
+ d.depth--
+ d.indent()
+ d.w.Write(closeBraceBytes)
+
+ case reflect.String:
+ d.w.Write([]byte(strconv.Quote(v.String())))
+
+ case reflect.Interface:
+ // The only time we should get here is for nil interfaces due to
+ // unpackValue calls.
+ if v.IsNil() {
+ d.w.Write(nilAngleBytes)
+ }
+
+ case reflect.Ptr:
+ // Do nothing. We should never get here since pointers have already
+ // been handled above.
+
+ case reflect.Map:
+ // nil maps should be indicated as different than empty maps
+ if v.IsNil() {
+ d.w.Write(nilAngleBytes)
+ break
+ }
+
+ d.w.Write(openBraceNewlineBytes)
+ d.depth++
+ if (d.cs.MaxDepth != 0) && (d.depth > d.cs.MaxDepth) {
+ d.indent()
+ d.w.Write(maxNewlineBytes)
+ } else {
+ numEntries := v.Len()
+ keys := v.MapKeys()
+ if d.cs.SortKeys {
+ sortValues(keys, d.cs)
+ }
+ for i, key := range keys {
+ d.dump(d.unpackValue(key))
+ d.w.Write(colonSpaceBytes)
+ d.ignoreNextIndent = true
+ d.dump(d.unpackValue(v.MapIndex(key)))
+ if i < (numEntries - 1) {
+ d.w.Write(commaNewlineBytes)
+ } else {
+ d.w.Write(newlineBytes)
+ }
+ }
+ }
+ d.depth--
+ d.indent()
+ d.w.Write(closeBraceBytes)
+
+ case reflect.Struct:
+ d.w.Write(openBraceNewlineBytes)
+ d.depth++
+ if (d.cs.MaxDepth != 0) && (d.depth > d.cs.MaxDepth) {
+ d.indent()
+ d.w.Write(maxNewlineBytes)
+ } else {
+ vt := v.Type()
+ numFields := v.NumField()
+ for i := 0; i < numFields; i++ {
+ d.indent()
+ vtf := vt.Field(i)
+ d.w.Write([]byte(vtf.Name))
+ d.w.Write(colonSpaceBytes)
+ d.ignoreNextIndent = true
+ d.dump(d.unpackValue(v.Field(i)))
+ if i < (numFields - 1) {
+ d.w.Write(commaNewlineBytes)
+ } else {
+ d.w.Write(newlineBytes)
+ }
+ }
+ }
+ d.depth--
+ d.indent()
+ d.w.Write(closeBraceBytes)
+
+ case reflect.Uintptr:
+ printHexPtr(d.w, uintptr(v.Uint()))
+
+ case reflect.UnsafePointer, reflect.Chan, reflect.Func:
+ printHexPtr(d.w, v.Pointer())
+
+ // There were not any other types at the time this code was written, but
+ // fall back to letting the default fmt package handle it in case any new
+ // types are added.
+ default:
+ if v.CanInterface() {
+ fmt.Fprintf(d.w, "%v", v.Interface())
+ } else {
+ fmt.Fprintf(d.w, "%v", v.String())
+ }
+ }
+}
+
+// fdump is a helper function to consolidate the logic from the various public
+// methods which take varying writers and config states.
+func fdump(cs *ConfigState, w io.Writer, a ...interface{}) {
+ for _, arg := range a {
+ if arg == nil {
+ w.Write(interfaceBytes)
+ w.Write(spaceBytes)
+ w.Write(nilAngleBytes)
+ w.Write(newlineBytes)
+ continue
+ }
+
+ d := dumpState{w: w, cs: cs}
+ d.pointers = make(map[uintptr]int)
+ d.dump(reflect.ValueOf(arg))
+ d.w.Write(newlineBytes)
+ }
+}
+
+// Fdump formats and displays the passed arguments to io.Writer w. It formats
+// exactly the same as Dump.
+func Fdump(w io.Writer, a ...interface{}) {
+ fdump(&Config, w, a...)
+}
+
+// Sdump returns a string with the passed arguments formatted exactly the same
+// as Dump.
+func Sdump(a ...interface{}) string {
+ var buf bytes.Buffer
+ fdump(&Config, &buf, a...)
+ return buf.String()
+}
+
+/*
+Dump displays the passed parameters to standard out with newlines, customizable
+indentation, and additional debug information such as complete types and all
+pointer addresses used to indirect to the final value. It provides the
+following features over the built-in printing facilities provided by the fmt
+package:
+
+ * Pointers are dereferenced and followed
+ * Circular data structures are detected and handled properly
+ * Custom Stringer/error interfaces are optionally invoked, including
+ on unexported types
+ * Custom types which only implement the Stringer/error interfaces via
+ a pointer receiver are optionally invoked when passing non-pointer
+ variables
+ * Byte arrays and slices are dumped like the hexdump -C command which
+ includes offsets, byte values in hex, and ASCII output
+
+The configuration options are controlled by an exported package global,
+spew.Config. See ConfigState for options documentation.
+
+See Fdump if you would prefer dumping to an arbitrary io.Writer or Sdump to
+get the formatted result as a string.
+*/
+func Dump(a ...interface{}) {
+ fdump(&Config, os.Stdout, a...)
+}
diff --git a/vendor/github.com/davecgh/go-spew/spew/format.go b/vendor/github.com/davecgh/go-spew/spew/format.go
new file mode 100644
index 000000000..b04edb7d7
--- /dev/null
+++ b/vendor/github.com/davecgh/go-spew/spew/format.go
@@ -0,0 +1,419 @@
+/*
+ * Copyright (c) 2013-2016 Dave Collins
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+package spew
+
+import (
+ "bytes"
+ "fmt"
+ "reflect"
+ "strconv"
+ "strings"
+)
+
+// supportedFlags is a list of all the character flags supported by fmt package.
+const supportedFlags = "0-+# "
+
+// formatState implements the fmt.Formatter interface and contains information
+// about the state of a formatting operation. The NewFormatter function can
+// be used to get a new Formatter which can be used directly as arguments
+// in standard fmt package printing calls.
+type formatState struct {
+ value interface{}
+ fs fmt.State
+ depth int
+ pointers map[uintptr]int
+ ignoreNextType bool
+ cs *ConfigState
+}
+
+// buildDefaultFormat recreates the original format string without precision
+// and width information to pass in to fmt.Sprintf in the case of an
+// unrecognized type. Unless new types are added to the language, this
+// function won't ever be called.
+func (f *formatState) buildDefaultFormat() (format string) {
+ buf := bytes.NewBuffer(percentBytes)
+
+ for _, flag := range supportedFlags {
+ if f.fs.Flag(int(flag)) {
+ buf.WriteRune(flag)
+ }
+ }
+
+ buf.WriteRune('v')
+
+ format = buf.String()
+ return format
+}
+
+// constructOrigFormat recreates the original format string including precision
+// and width information to pass along to the standard fmt package. This allows
+// automatic deferral of all format strings this package doesn't support.
+func (f *formatState) constructOrigFormat(verb rune) (format string) {
+ buf := bytes.NewBuffer(percentBytes)
+
+ for _, flag := range supportedFlags {
+ if f.fs.Flag(int(flag)) {
+ buf.WriteRune(flag)
+ }
+ }
+
+ if width, ok := f.fs.Width(); ok {
+ buf.WriteString(strconv.Itoa(width))
+ }
+
+ if precision, ok := f.fs.Precision(); ok {
+ buf.Write(precisionBytes)
+ buf.WriteString(strconv.Itoa(precision))
+ }
+
+ buf.WriteRune(verb)
+
+ format = buf.String()
+ return format
+}
+
+// unpackValue returns values inside of non-nil interfaces when possible and
+// ensures that types for values which have been unpacked from an interface
+// are displayed when the show types flag is also set.
+// This is useful for data types like structs, arrays, slices, and maps which
+// can contain varying types packed inside an interface.
+func (f *formatState) unpackValue(v reflect.Value) reflect.Value {
+ if v.Kind() == reflect.Interface {
+ f.ignoreNextType = false
+ if !v.IsNil() {
+ v = v.Elem()
+ }
+ }
+ return v
+}
+
+// formatPtr handles formatting of pointers by indirecting them as necessary.
+func (f *formatState) formatPtr(v reflect.Value) {
+ // Display nil if top level pointer is nil.
+ showTypes := f.fs.Flag('#')
+ if v.IsNil() && (!showTypes || f.ignoreNextType) {
+ f.fs.Write(nilAngleBytes)
+ return
+ }
+
+ // Remove pointers at or below the current depth from map used to detect
+ // circular refs.
+ for k, depth := range f.pointers {
+ if depth >= f.depth {
+ delete(f.pointers, k)
+ }
+ }
+
+ // Keep list of all dereferenced pointers to possibly show later.
+ pointerChain := make([]uintptr, 0)
+
+ // Figure out how many levels of indirection there are by derferencing
+ // pointers and unpacking interfaces down the chain while detecting circular
+ // references.
+ nilFound := false
+ cycleFound := false
+ indirects := 0
+ ve := v
+ for ve.Kind() == reflect.Ptr {
+ if ve.IsNil() {
+ nilFound = true
+ break
+ }
+ indirects++
+ addr := ve.Pointer()
+ pointerChain = append(pointerChain, addr)
+ if pd, ok := f.pointers[addr]; ok && pd < f.depth {
+ cycleFound = true
+ indirects--
+ break
+ }
+ f.pointers[addr] = f.depth
+
+ ve = ve.Elem()
+ if ve.Kind() == reflect.Interface {
+ if ve.IsNil() {
+ nilFound = true
+ break
+ }
+ ve = ve.Elem()
+ }
+ }
+
+ // Display type or indirection level depending on flags.
+ if showTypes && !f.ignoreNextType {
+ f.fs.Write(openParenBytes)
+ f.fs.Write(bytes.Repeat(asteriskBytes, indirects))
+ f.fs.Write([]byte(ve.Type().String()))
+ f.fs.Write(closeParenBytes)
+ } else {
+ if nilFound || cycleFound {
+ indirects += strings.Count(ve.Type().String(), "*")
+ }
+ f.fs.Write(openAngleBytes)
+ f.fs.Write([]byte(strings.Repeat("*", indirects)))
+ f.fs.Write(closeAngleBytes)
+ }
+
+ // Display pointer information depending on flags.
+ if f.fs.Flag('+') && (len(pointerChain) > 0) {
+ f.fs.Write(openParenBytes)
+ for i, addr := range pointerChain {
+ if i > 0 {
+ f.fs.Write(pointerChainBytes)
+ }
+ printHexPtr(f.fs, addr)
+ }
+ f.fs.Write(closeParenBytes)
+ }
+
+ // Display dereferenced value.
+ switch {
+ case nilFound:
+ f.fs.Write(nilAngleBytes)
+
+ case cycleFound:
+ f.fs.Write(circularShortBytes)
+
+ default:
+ f.ignoreNextType = true
+ f.format(ve)
+ }
+}
+
+// format is the main workhorse for providing the Formatter interface. It
+// uses the passed reflect value to figure out what kind of object we are
+// dealing with and formats it appropriately. It is a recursive function,
+// however circular data structures are detected and handled properly.
+func (f *formatState) format(v reflect.Value) {
+ // Handle invalid reflect values immediately.
+ kind := v.Kind()
+ if kind == reflect.Invalid {
+ f.fs.Write(invalidAngleBytes)
+ return
+ }
+
+ // Handle pointers specially.
+ if kind == reflect.Ptr {
+ f.formatPtr(v)
+ return
+ }
+
+ // Print type information unless already handled elsewhere.
+ if !f.ignoreNextType && f.fs.Flag('#') {
+ f.fs.Write(openParenBytes)
+ f.fs.Write([]byte(v.Type().String()))
+ f.fs.Write(closeParenBytes)
+ }
+ f.ignoreNextType = false
+
+ // Call Stringer/error interfaces if they exist and the handle methods
+ // flag is enabled.
+ if !f.cs.DisableMethods {
+ if (kind != reflect.Invalid) && (kind != reflect.Interface) {
+ if handled := handleMethods(f.cs, f.fs, v); handled {
+ return
+ }
+ }
+ }
+
+ switch kind {
+ case reflect.Invalid:
+ // Do nothing. We should never get here since invalid has already
+ // been handled above.
+
+ case reflect.Bool:
+ printBool(f.fs, v.Bool())
+
+ case reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Int:
+ printInt(f.fs, v.Int(), 10)
+
+ case reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uint:
+ printUint(f.fs, v.Uint(), 10)
+
+ case reflect.Float32:
+ printFloat(f.fs, v.Float(), 32)
+
+ case reflect.Float64:
+ printFloat(f.fs, v.Float(), 64)
+
+ case reflect.Complex64:
+ printComplex(f.fs, v.Complex(), 32)
+
+ case reflect.Complex128:
+ printComplex(f.fs, v.Complex(), 64)
+
+ case reflect.Slice:
+ if v.IsNil() {
+ f.fs.Write(nilAngleBytes)
+ break
+ }
+ fallthrough
+
+ case reflect.Array:
+ f.fs.Write(openBracketBytes)
+ f.depth++
+ if (f.cs.MaxDepth != 0) && (f.depth > f.cs.MaxDepth) {
+ f.fs.Write(maxShortBytes)
+ } else {
+ numEntries := v.Len()
+ for i := 0; i < numEntries; i++ {
+ if i > 0 {
+ f.fs.Write(spaceBytes)
+ }
+ f.ignoreNextType = true
+ f.format(f.unpackValue(v.Index(i)))
+ }
+ }
+ f.depth--
+ f.fs.Write(closeBracketBytes)
+
+ case reflect.String:
+ f.fs.Write([]byte(v.String()))
+
+ case reflect.Interface:
+ // The only time we should get here is for nil interfaces due to
+ // unpackValue calls.
+ if v.IsNil() {
+ f.fs.Write(nilAngleBytes)
+ }
+
+ case reflect.Ptr:
+ // Do nothing. We should never get here since pointers have already
+ // been handled above.
+
+ case reflect.Map:
+ // nil maps should be indicated as different than empty maps
+ if v.IsNil() {
+ f.fs.Write(nilAngleBytes)
+ break
+ }
+
+ f.fs.Write(openMapBytes)
+ f.depth++
+ if (f.cs.MaxDepth != 0) && (f.depth > f.cs.MaxDepth) {
+ f.fs.Write(maxShortBytes)
+ } else {
+ keys := v.MapKeys()
+ if f.cs.SortKeys {
+ sortValues(keys, f.cs)
+ }
+ for i, key := range keys {
+ if i > 0 {
+ f.fs.Write(spaceBytes)
+ }
+ f.ignoreNextType = true
+ f.format(f.unpackValue(key))
+ f.fs.Write(colonBytes)
+ f.ignoreNextType = true
+ f.format(f.unpackValue(v.MapIndex(key)))
+ }
+ }
+ f.depth--
+ f.fs.Write(closeMapBytes)
+
+ case reflect.Struct:
+ numFields := v.NumField()
+ f.fs.Write(openBraceBytes)
+ f.depth++
+ if (f.cs.MaxDepth != 0) && (f.depth > f.cs.MaxDepth) {
+ f.fs.Write(maxShortBytes)
+ } else {
+ vt := v.Type()
+ for i := 0; i < numFields; i++ {
+ if i > 0 {
+ f.fs.Write(spaceBytes)
+ }
+ vtf := vt.Field(i)
+ if f.fs.Flag('+') || f.fs.Flag('#') {
+ f.fs.Write([]byte(vtf.Name))
+ f.fs.Write(colonBytes)
+ }
+ f.format(f.unpackValue(v.Field(i)))
+ }
+ }
+ f.depth--
+ f.fs.Write(closeBraceBytes)
+
+ case reflect.Uintptr:
+ printHexPtr(f.fs, uintptr(v.Uint()))
+
+ case reflect.UnsafePointer, reflect.Chan, reflect.Func:
+ printHexPtr(f.fs, v.Pointer())
+
+ // There were not any other types at the time this code was written, but
+ // fall back to letting the default fmt package handle it if any get added.
+ default:
+ format := f.buildDefaultFormat()
+ if v.CanInterface() {
+ fmt.Fprintf(f.fs, format, v.Interface())
+ } else {
+ fmt.Fprintf(f.fs, format, v.String())
+ }
+ }
+}
+
+// Format satisfies the fmt.Formatter interface. See NewFormatter for usage
+// details.
+func (f *formatState) Format(fs fmt.State, verb rune) {
+ f.fs = fs
+
+ // Use standard formatting for verbs that are not v.
+ if verb != 'v' {
+ format := f.constructOrigFormat(verb)
+ fmt.Fprintf(fs, format, f.value)
+ return
+ }
+
+ if f.value == nil {
+ if fs.Flag('#') {
+ fs.Write(interfaceBytes)
+ }
+ fs.Write(nilAngleBytes)
+ return
+ }
+
+ f.format(reflect.ValueOf(f.value))
+}
+
+// newFormatter is a helper function to consolidate the logic from the various
+// public methods which take varying config states.
+func newFormatter(cs *ConfigState, v interface{}) fmt.Formatter {
+ fs := &formatState{value: v, cs: cs}
+ fs.pointers = make(map[uintptr]int)
+ return fs
+}
+
+/*
+NewFormatter returns a custom formatter that satisfies the fmt.Formatter
+interface. As a result, it integrates cleanly with standard fmt package
+printing functions. The formatter is useful for inline printing of smaller data
+types similar to the standard %v format specifier.
+
+The custom formatter only responds to the %v (most compact), %+v (adds pointer
+addresses), %#v (adds types), or %#+v (adds types and pointer addresses) verb
+combinations. Any other verbs such as %x and %q will be sent to the the
+standard fmt package for formatting. In addition, the custom formatter ignores
+the width and precision arguments (however they will still work on the format
+specifiers not handled by the custom formatter).
+
+Typically this function shouldn't be called directly. It is much easier to make
+use of the custom formatter by calling one of the convenience functions such as
+Printf, Println, or Fprintf.
+*/
+func NewFormatter(v interface{}) fmt.Formatter {
+ return newFormatter(&Config, v)
+}
diff --git a/vendor/github.com/davecgh/go-spew/spew/spew.go b/vendor/github.com/davecgh/go-spew/spew/spew.go
new file mode 100644
index 000000000..32c0e3388
--- /dev/null
+++ b/vendor/github.com/davecgh/go-spew/spew/spew.go
@@ -0,0 +1,148 @@
+/*
+ * Copyright (c) 2013-2016 Dave Collins
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+package spew
+
+import (
+ "fmt"
+ "io"
+)
+
+// Errorf is a wrapper for fmt.Errorf that treats each argument as if it were
+// passed with a default Formatter interface returned by NewFormatter. It
+// returns the formatted string as a value that satisfies error. See
+// NewFormatter for formatting details.
+//
+// This function is shorthand for the following syntax:
+//
+// fmt.Errorf(format, spew.NewFormatter(a), spew.NewFormatter(b))
+func Errorf(format string, a ...interface{}) (err error) {
+ return fmt.Errorf(format, convertArgs(a)...)
+}
+
+// Fprint is a wrapper for fmt.Fprint that treats each argument as if it were
+// passed with a default Formatter interface returned by NewFormatter. It
+// returns the number of bytes written and any write error encountered. See
+// NewFormatter for formatting details.
+//
+// This function is shorthand for the following syntax:
+//
+// fmt.Fprint(w, spew.NewFormatter(a), spew.NewFormatter(b))
+func Fprint(w io.Writer, a ...interface{}) (n int, err error) {
+ return fmt.Fprint(w, convertArgs(a)...)
+}
+
+// Fprintf is a wrapper for fmt.Fprintf that treats each argument as if it were
+// passed with a default Formatter interface returned by NewFormatter. It
+// returns the number of bytes written and any write error encountered. See
+// NewFormatter for formatting details.
+//
+// This function is shorthand for the following syntax:
+//
+// fmt.Fprintf(w, format, spew.NewFormatter(a), spew.NewFormatter(b))
+func Fprintf(w io.Writer, format string, a ...interface{}) (n int, err error) {
+ return fmt.Fprintf(w, format, convertArgs(a)...)
+}
+
+// Fprintln is a wrapper for fmt.Fprintln that treats each argument as if it
+// passed with a default Formatter interface returned by NewFormatter. See
+// NewFormatter for formatting details.
+//
+// This function is shorthand for the following syntax:
+//
+// fmt.Fprintln(w, spew.NewFormatter(a), spew.NewFormatter(b))
+func Fprintln(w io.Writer, a ...interface{}) (n int, err error) {
+ return fmt.Fprintln(w, convertArgs(a)...)
+}
+
+// Print is a wrapper for fmt.Print that treats each argument as if it were
+// passed with a default Formatter interface returned by NewFormatter. It
+// returns the number of bytes written and any write error encountered. See
+// NewFormatter for formatting details.
+//
+// This function is shorthand for the following syntax:
+//
+// fmt.Print(spew.NewFormatter(a), spew.NewFormatter(b))
+func Print(a ...interface{}) (n int, err error) {
+ return fmt.Print(convertArgs(a)...)
+}
+
+// Printf is a wrapper for fmt.Printf that treats each argument as if it were
+// passed with a default Formatter interface returned by NewFormatter. It
+// returns the number of bytes written and any write error encountered. See
+// NewFormatter for formatting details.
+//
+// This function is shorthand for the following syntax:
+//
+// fmt.Printf(format, spew.NewFormatter(a), spew.NewFormatter(b))
+func Printf(format string, a ...interface{}) (n int, err error) {
+ return fmt.Printf(format, convertArgs(a)...)
+}
+
+// Println is a wrapper for fmt.Println that treats each argument as if it were
+// passed with a default Formatter interface returned by NewFormatter. It
+// returns the number of bytes written and any write error encountered. See
+// NewFormatter for formatting details.
+//
+// This function is shorthand for the following syntax:
+//
+// fmt.Println(spew.NewFormatter(a), spew.NewFormatter(b))
+func Println(a ...interface{}) (n int, err error) {
+ return fmt.Println(convertArgs(a)...)
+}
+
+// Sprint is a wrapper for fmt.Sprint that treats each argument as if it were
+// passed with a default Formatter interface returned by NewFormatter. It
+// returns the resulting string. See NewFormatter for formatting details.
+//
+// This function is shorthand for the following syntax:
+//
+// fmt.Sprint(spew.NewFormatter(a), spew.NewFormatter(b))
+func Sprint(a ...interface{}) string {
+ return fmt.Sprint(convertArgs(a)...)
+}
+
+// Sprintf is a wrapper for fmt.Sprintf that treats each argument as if it were
+// passed with a default Formatter interface returned by NewFormatter. It
+// returns the resulting string. See NewFormatter for formatting details.
+//
+// This function is shorthand for the following syntax:
+//
+// fmt.Sprintf(format, spew.NewFormatter(a), spew.NewFormatter(b))
+func Sprintf(format string, a ...interface{}) string {
+ return fmt.Sprintf(format, convertArgs(a)...)
+}
+
+// Sprintln is a wrapper for fmt.Sprintln that treats each argument as if it
+// were passed with a default Formatter interface returned by NewFormatter. It
+// returns the resulting string. See NewFormatter for formatting details.
+//
+// This function is shorthand for the following syntax:
+//
+// fmt.Sprintln(spew.NewFormatter(a), spew.NewFormatter(b))
+func Sprintln(a ...interface{}) string {
+ return fmt.Sprintln(convertArgs(a)...)
+}
+
+// convertArgs accepts a slice of arguments and returns a slice of the same
+// length with each argument converted to a default spew Formatter interface.
+func convertArgs(args []interface{}) (formatters []interface{}) {
+ formatters = make([]interface{}, len(args))
+ for index, arg := range args {
+ formatters[index] = NewFormatter(arg)
+ }
+ return formatters
+}
From 2230da52e3cddd2fbe4d7d752c9e258fe1f92667 Mon Sep 17 00:00:00 2001
From: Qi Xiao
Date: Wed, 26 Dec 2018 17:12:33 +0800
Subject: [PATCH 190/278] Support nonce inject in AddTx method
---
cmd/cql-utils/rpc.go | 99 ++++++++++++++++++++++++++++++++++----------
1 file changed, 76 insertions(+), 23 deletions(-)
diff --git a/cmd/cql-utils/rpc.go b/cmd/cql-utils/rpc.go
index b6afe277c..79730528b 100644
--- a/cmd/cql-utils/rpc.go
+++ b/cmd/cql-utils/rpc.go
@@ -19,14 +19,13 @@ package main
import (
"encoding/json"
"flag"
- "fmt"
- "os"
"reflect"
"strings"
bp "github.com/CovenantSQL/CovenantSQL/blockproducer"
pi "github.com/CovenantSQL/CovenantSQL/blockproducer/interfaces"
"github.com/CovenantSQL/CovenantSQL/client"
+ "github.com/CovenantSQL/CovenantSQL/crypto"
"github.com/CovenantSQL/CovenantSQL/crypto/asymmetric"
"github.com/CovenantSQL/CovenantSQL/crypto/kms"
"github.com/CovenantSQL/CovenantSQL/proto"
@@ -65,18 +64,17 @@ func init() {
func runRPC() {
if configFile == "" {
// error
- log.Error("config file path is required for rpc tool")
- os.Exit(1)
+ log.Fatal("config file path is required for rpc tool")
+ return
}
if rpcEndpoint == "" || rpcName == "" || rpcReq == "" {
// error
- log.Error("rpc payload is required for rpc tool")
- os.Exit(1)
+ log.Fatal("rpc payload is required for rpc tool")
+ return
}
if err := client.Init(configFile, []byte("")); err != nil {
- fmt.Printf("init rpc client failed: %v\n", err)
- os.Exit(1)
+ log.Fatalf("init rpc client failed: %v\n", err)
return
}
@@ -91,29 +89,51 @@ func runRPC() {
// fill the req with request body
if err := json.Unmarshal([]byte(rpcReq), req); err != nil {
- fmt.Printf("decode request body failed: %v\n", err)
- os.Exit(1)
+ log.Fatalf("decode request body failed: %v\n", err)
return
}
+ // fill nonce if this is a AddTx request
+ if rpcName == route.MCCAddTx.String() {
+ if addTxReqType, ok := req.(*types.AddTxReq); ok {
+ var tx = addTxReqType.Tx
+ for {
+ if txWrapper, ok := tx.(*pi.TransactionWrapper); ok {
+ tx = txWrapper.Unwrap()
+ } else {
+ break
+ }
+ }
+
+ // unwrapped tx, find account nonce field and set
+ if err := fillTxNonce(tx); err != nil {
+ log.Fatalf("fill block producer transaction nonce failed: %v\n", err)
+ return
+ }
+
+ if err := checkAndSign(tx); err != nil {
+ log.Fatalf("sign transaction failed: %v\n", err)
+ return
+ }
+ }
+ }
+
// requires signature?
if err := checkAndSign(req); err != nil {
- fmt.Printf("sign request failed: %v\n", err)
- os.Exit(1)
+ log.Fatalf("sign request failed: %v\n", err)
return
}
- fmt.Println("sending request")
+ log.Info("sending request")
spew.Dump(req)
if err := rpc.NewCaller().CallNode(proto.NodeID(rpcEndpoint), rpcName, req, resp); err != nil {
// send request failed
- fmt.Printf("call rpc failed: %v\n", err)
- os.Exit(1)
+ log.Infof("call rpc failed: %v\n", err)
return
}
// print the response
- fmt.Println("got response")
+ log.Info("got response")
spew.Dump(resp)
}
@@ -123,6 +143,8 @@ func checkAndSign(req interface{}) (err error) {
}
if canSignObj, ok := req.(canSign); ok {
+ log.Info("signing request")
+
var privKey *asymmetric.PrivateKey
if privKey, err = kms.GetLocalPrivateKey(); err != nil {
return
@@ -135,13 +157,47 @@ func checkAndSign(req interface{}) (err error) {
return
}
+func fillTxNonce(tx pi.Transaction) (err error) {
+ rv := reflect.ValueOf(tx)
+ for i := 0; i != rv.NumField(); i++ {
+ if _, ok := rv.Field(i).Interface().(pi.AccountNonce); ok {
+ // nonce type
+ // generate nonce for account
+ var (
+ pubKey *asymmetric.PublicKey
+ accountAddr proto.AccountAddress
+ )
+ if pubKey, err = kms.GetLocalPublicKey(); err != nil {
+ return
+ }
+ if accountAddr, err = crypto.PubKeyHash(pubKey); err != nil {
+ return
+ }
+ nonceReq := &types.NextAccountNonceReq{
+ Addr: accountAddr,
+ }
+ nonceResp := &types.NextAccountNonceResp{}
+ if err = rpc.NewCaller().CallNode(proto.NodeID(rpcEndpoint),
+ route.MCCNextAccountNonce.String(), nonceReq, nonceResp); err != nil {
+ return
+ }
+
+ rv.Field(i).SetUint(uint64(nonceResp.Nonce))
+ log.Infof("filled tx type %s nonce field %s with nonce %d",
+ tx.GetTransactionType().String(), rv.Type().Field(i).Name, nonceResp.Nonce)
+ break
+ }
+ }
+
+ return
+}
+
func resolveRPCEntities() (req interface{}, resp interface{}) {
rpcParts := strings.SplitN(rpcName, ".", 2)
if len(rpcParts) != 2 {
// error rpc name
- fmt.Printf("%v is not a valid rpc name\n", rpcName)
- os.Exit(1)
+ log.Fatalf("%v is not a valid rpc name\n", rpcName)
return
}
@@ -158,8 +214,7 @@ func resolveRPCEntities() (req interface{}, resp interface{}) {
if method.Name == rpcParts[1] {
// name matched
if mtype.PkgPath() != "" || mtype.NumIn() != 3 || mtype.NumOut() != 1 {
- fmt.Printf("%v is not a valid rpc endpoint method\n", rpcName)
- os.Exit(1)
+ log.Infof("%v is not a valid rpc endpoint method\n", rpcName)
return
}
@@ -180,8 +235,6 @@ func resolveRPCEntities() (req interface{}, resp interface{}) {
}
// not found
- fmt.Printf("rpc method %v not found\n", rpcName)
- os.Exit(1)
-
+ log.Infof("rpc method %v not found\n", rpcName)
return
}
From 45374df0f2442a35e26b382d272c9fc241be56f8 Mon Sep 17 00:00:00 2001
From: Qi Xiao
Date: Wed, 26 Dec 2018 17:19:13 +0800
Subject: [PATCH 191/278] Add missing deps file
---
.../github.com/davecgh/go-spew/spew/config.go | 306 ++++++++++++++++++
1 file changed, 306 insertions(+)
create mode 100644 vendor/github.com/davecgh/go-spew/spew/config.go
diff --git a/vendor/github.com/davecgh/go-spew/spew/config.go b/vendor/github.com/davecgh/go-spew/spew/config.go
new file mode 100644
index 000000000..2e3d22f31
--- /dev/null
+++ b/vendor/github.com/davecgh/go-spew/spew/config.go
@@ -0,0 +1,306 @@
+/*
+ * Copyright (c) 2013-2016 Dave Collins
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+package spew
+
+import (
+ "bytes"
+ "fmt"
+ "io"
+ "os"
+)
+
+// ConfigState houses the configuration options used by spew to format and
+// display values. There is a global instance, Config, that is used to control
+// all top-level Formatter and Dump functionality. Each ConfigState instance
+// provides methods equivalent to the top-level functions.
+//
+// The zero value for ConfigState provides no indentation. You would typically
+// want to set it to a space or a tab.
+//
+// Alternatively, you can use NewDefaultConfig to get a ConfigState instance
+// with default settings. See the documentation of NewDefaultConfig for default
+// values.
+type ConfigState struct {
+ // Indent specifies the string to use for each indentation level. The
+ // global config instance that all top-level functions use set this to a
+ // single space by default. If you would like more indentation, you might
+ // set this to a tab with "\t" or perhaps two spaces with " ".
+ Indent string
+
+ // MaxDepth controls the maximum number of levels to descend into nested
+ // data structures. The default, 0, means there is no limit.
+ //
+ // NOTE: Circular data structures are properly detected, so it is not
+ // necessary to set this value unless you specifically want to limit deeply
+ // nested data structures.
+ MaxDepth int
+
+ // DisableMethods specifies whether or not error and Stringer interfaces are
+ // invoked for types that implement them.
+ DisableMethods bool
+
+ // DisablePointerMethods specifies whether or not to check for and invoke
+ // error and Stringer interfaces on types which only accept a pointer
+ // receiver when the current type is not a pointer.
+ //
+ // NOTE: This might be an unsafe action since calling one of these methods
+ // with a pointer receiver could technically mutate the value, however,
+ // in practice, types which choose to satisify an error or Stringer
+ // interface with a pointer receiver should not be mutating their state
+ // inside these interface methods. As a result, this option relies on
+ // access to the unsafe package, so it will not have any effect when
+ // running in environments without access to the unsafe package such as
+ // Google App Engine or with the "safe" build tag specified.
+ DisablePointerMethods bool
+
+ // DisablePointerAddresses specifies whether to disable the printing of
+ // pointer addresses. This is useful when diffing data structures in tests.
+ DisablePointerAddresses bool
+
+ // DisableCapacities specifies whether to disable the printing of capacities
+ // for arrays, slices, maps and channels. This is useful when diffing
+ // data structures in tests.
+ DisableCapacities bool
+
+ // ContinueOnMethod specifies whether or not recursion should continue once
+ // a custom error or Stringer interface is invoked. The default, false,
+ // means it will print the results of invoking the custom error or Stringer
+ // interface and return immediately instead of continuing to recurse into
+ // the internals of the data type.
+ //
+ // NOTE: This flag does not have any effect if method invocation is disabled
+ // via the DisableMethods or DisablePointerMethods options.
+ ContinueOnMethod bool
+
+ // SortKeys specifies map keys should be sorted before being printed. Use
+ // this to have a more deterministic, diffable output. Note that only
+ // native types (bool, int, uint, floats, uintptr and string) and types
+ // that support the error or Stringer interfaces (if methods are
+ // enabled) are supported, with other types sorted according to the
+ // reflect.Value.String() output which guarantees display stability.
+ SortKeys bool
+
+ // SpewKeys specifies that, as a last resort attempt, map keys should
+ // be spewed to strings and sorted by those strings. This is only
+ // considered if SortKeys is true.
+ SpewKeys bool
+}
+
+// Config is the active configuration of the top-level functions.
+// The configuration can be changed by modifying the contents of spew.Config.
+var Config = ConfigState{Indent: " "}
+
+// Errorf is a wrapper for fmt.Errorf that treats each argument as if it were
+// passed with a Formatter interface returned by c.NewFormatter. It returns
+// the formatted string as a value that satisfies error. See NewFormatter
+// for formatting details.
+//
+// This function is shorthand for the following syntax:
+//
+// fmt.Errorf(format, c.NewFormatter(a), c.NewFormatter(b))
+func (c *ConfigState) Errorf(format string, a ...interface{}) (err error) {
+ return fmt.Errorf(format, c.convertArgs(a)...)
+}
+
+// Fprint is a wrapper for fmt.Fprint that treats each argument as if it were
+// passed with a Formatter interface returned by c.NewFormatter. It returns
+// the number of bytes written and any write error encountered. See
+// NewFormatter for formatting details.
+//
+// This function is shorthand for the following syntax:
+//
+// fmt.Fprint(w, c.NewFormatter(a), c.NewFormatter(b))
+func (c *ConfigState) Fprint(w io.Writer, a ...interface{}) (n int, err error) {
+ return fmt.Fprint(w, c.convertArgs(a)...)
+}
+
+// Fprintf is a wrapper for fmt.Fprintf that treats each argument as if it were
+// passed with a Formatter interface returned by c.NewFormatter. It returns
+// the number of bytes written and any write error encountered. See
+// NewFormatter for formatting details.
+//
+// This function is shorthand for the following syntax:
+//
+// fmt.Fprintf(w, format, c.NewFormatter(a), c.NewFormatter(b))
+func (c *ConfigState) Fprintf(w io.Writer, format string, a ...interface{}) (n int, err error) {
+ return fmt.Fprintf(w, format, c.convertArgs(a)...)
+}
+
+// Fprintln is a wrapper for fmt.Fprintln that treats each argument as if it
+// passed with a Formatter interface returned by c.NewFormatter. See
+// NewFormatter for formatting details.
+//
+// This function is shorthand for the following syntax:
+//
+// fmt.Fprintln(w, c.NewFormatter(a), c.NewFormatter(b))
+func (c *ConfigState) Fprintln(w io.Writer, a ...interface{}) (n int, err error) {
+ return fmt.Fprintln(w, c.convertArgs(a)...)
+}
+
+// Print is a wrapper for fmt.Print that treats each argument as if it were
+// passed with a Formatter interface returned by c.NewFormatter. It returns
+// the number of bytes written and any write error encountered. See
+// NewFormatter for formatting details.
+//
+// This function is shorthand for the following syntax:
+//
+// fmt.Print(c.NewFormatter(a), c.NewFormatter(b))
+func (c *ConfigState) Print(a ...interface{}) (n int, err error) {
+ return fmt.Print(c.convertArgs(a)...)
+}
+
+// Printf is a wrapper for fmt.Printf that treats each argument as if it were
+// passed with a Formatter interface returned by c.NewFormatter. It returns
+// the number of bytes written and any write error encountered. See
+// NewFormatter for formatting details.
+//
+// This function is shorthand for the following syntax:
+//
+// fmt.Printf(format, c.NewFormatter(a), c.NewFormatter(b))
+func (c *ConfigState) Printf(format string, a ...interface{}) (n int, err error) {
+ return fmt.Printf(format, c.convertArgs(a)...)
+}
+
+// Println is a wrapper for fmt.Println that treats each argument as if it were
+// passed with a Formatter interface returned by c.NewFormatter. It returns
+// the number of bytes written and any write error encountered. See
+// NewFormatter for formatting details.
+//
+// This function is shorthand for the following syntax:
+//
+// fmt.Println(c.NewFormatter(a), c.NewFormatter(b))
+func (c *ConfigState) Println(a ...interface{}) (n int, err error) {
+ return fmt.Println(c.convertArgs(a)...)
+}
+
+// Sprint is a wrapper for fmt.Sprint that treats each argument as if it were
+// passed with a Formatter interface returned by c.NewFormatter. It returns
+// the resulting string. See NewFormatter for formatting details.
+//
+// This function is shorthand for the following syntax:
+//
+// fmt.Sprint(c.NewFormatter(a), c.NewFormatter(b))
+func (c *ConfigState) Sprint(a ...interface{}) string {
+ return fmt.Sprint(c.convertArgs(a)...)
+}
+
+// Sprintf is a wrapper for fmt.Sprintf that treats each argument as if it were
+// passed with a Formatter interface returned by c.NewFormatter. It returns
+// the resulting string. See NewFormatter for formatting details.
+//
+// This function is shorthand for the following syntax:
+//
+// fmt.Sprintf(format, c.NewFormatter(a), c.NewFormatter(b))
+func (c *ConfigState) Sprintf(format string, a ...interface{}) string {
+ return fmt.Sprintf(format, c.convertArgs(a)...)
+}
+
+// Sprintln is a wrapper for fmt.Sprintln that treats each argument as if it
+// were passed with a Formatter interface returned by c.NewFormatter. It
+// returns the resulting string. See NewFormatter for formatting details.
+//
+// This function is shorthand for the following syntax:
+//
+// fmt.Sprintln(c.NewFormatter(a), c.NewFormatter(b))
+func (c *ConfigState) Sprintln(a ...interface{}) string {
+ return fmt.Sprintln(c.convertArgs(a)...)
+}
+
+/*
+NewFormatter returns a custom formatter that satisfies the fmt.Formatter
+interface. As a result, it integrates cleanly with standard fmt package
+printing functions. The formatter is useful for inline printing of smaller data
+types similar to the standard %v format specifier.
+
+The custom formatter only responds to the %v (most compact), %+v (adds pointer
+addresses), %#v (adds types), and %#+v (adds types and pointer addresses) verb
+combinations. Any other verbs such as %x and %q will be sent to the the
+standard fmt package for formatting. In addition, the custom formatter ignores
+the width and precision arguments (however they will still work on the format
+specifiers not handled by the custom formatter).
+
+Typically this function shouldn't be called directly. It is much easier to make
+use of the custom formatter by calling one of the convenience functions such as
+c.Printf, c.Println, or c.Printf.
+*/
+func (c *ConfigState) NewFormatter(v interface{}) fmt.Formatter {
+ return newFormatter(c, v)
+}
+
+// Fdump formats and displays the passed arguments to io.Writer w. It formats
+// exactly the same as Dump.
+func (c *ConfigState) Fdump(w io.Writer, a ...interface{}) {
+ fdump(c, w, a...)
+}
+
+/*
+Dump displays the passed parameters to standard out with newlines, customizable
+indentation, and additional debug information such as complete types and all
+pointer addresses used to indirect to the final value. It provides the
+following features over the built-in printing facilities provided by the fmt
+package:
+
+ * Pointers are dereferenced and followed
+ * Circular data structures are detected and handled properly
+ * Custom Stringer/error interfaces are optionally invoked, including
+ on unexported types
+ * Custom types which only implement the Stringer/error interfaces via
+ a pointer receiver are optionally invoked when passing non-pointer
+ variables
+ * Byte arrays and slices are dumped like the hexdump -C command which
+ includes offsets, byte values in hex, and ASCII output
+
+The configuration options are controlled by modifying the public members
+of c. See ConfigState for options documentation.
+
+See Fdump if you would prefer dumping to an arbitrary io.Writer or Sdump to
+get the formatted result as a string.
+*/
+func (c *ConfigState) Dump(a ...interface{}) {
+ fdump(c, os.Stdout, a...)
+}
+
+// Sdump returns a string with the passed arguments formatted exactly the same
+// as Dump.
+func (c *ConfigState) Sdump(a ...interface{}) string {
+ var buf bytes.Buffer
+ fdump(c, &buf, a...)
+ return buf.String()
+}
+
+// convertArgs accepts a slice of arguments and returns a slice of the same
+// length with each argument converted to a spew Formatter interface using
+// the ConfigState associated with s.
+func (c *ConfigState) convertArgs(args []interface{}) (formatters []interface{}) {
+ formatters = make([]interface{}, len(args))
+ for index, arg := range args {
+ formatters[index] = newFormatter(c, arg)
+ }
+ return formatters
+}
+
+// NewDefaultConfig returns a ConfigState with the following default settings.
+//
+// Indent: " "
+// MaxDepth: 0
+// DisableMethods: false
+// DisablePointerMethods: false
+// ContinueOnMethod: false
+// SortKeys: false
+func NewDefaultConfig() *ConfigState {
+ return &ConfigState{Indent: " "}
+}
From 4ce61bb54f32e0925d29960eb4e8cda090b805c9 Mon Sep 17 00:00:00 2001
From: Qi Xiao
Date: Wed, 26 Dec 2018 17:58:47 +0800
Subject: [PATCH 192/278] Fix fillTxNonce function for nested structure
---
cmd/cql-utils/rpc.go | 107 +++++++++++++++++++++++++++++++++----------
1 file changed, 84 insertions(+), 23 deletions(-)
diff --git a/cmd/cql-utils/rpc.go b/cmd/cql-utils/rpc.go
index 79730528b..5a311fd7e 100644
--- a/cmd/cql-utils/rpc.go
+++ b/cmd/cql-utils/rpc.go
@@ -19,6 +19,7 @@ package main
import (
"encoding/json"
"flag"
+ "fmt"
"reflect"
"strings"
@@ -125,7 +126,9 @@ func runRPC() {
}
log.Info("sending request")
- spew.Dump(req)
+ spewCfg := spew.NewDefaultConfig()
+ spewCfg.MaxDepth = 4
+ spewCfg.Dump(req)
if err := rpc.NewCaller().CallNode(proto.NodeID(rpcEndpoint), rpcName, req, resp); err != nil {
// send request failed
log.Infof("call rpc failed: %v\n", err)
@@ -134,7 +137,7 @@ func runRPC() {
// print the response
log.Info("got response")
- spew.Dump(resp)
+ spewCfg.Dump(resp)
}
func checkAndSign(req interface{}) (err error) {
@@ -157,41 +160,99 @@ func checkAndSign(req interface{}) (err error) {
return
}
-func fillTxNonce(tx pi.Transaction) (err error) {
- rv := reflect.ValueOf(tx)
- for i := 0; i != rv.NumField(); i++ {
- if _, ok := rv.Field(i).Interface().(pi.AccountNonce); ok {
- // nonce type
- // generate nonce for account
- var (
- pubKey *asymmetric.PublicKey
- accountAddr proto.AccountAddress
- )
- if pubKey, err = kms.GetLocalPublicKey(); err != nil {
+func nestedWalkFillTxNonce(rv reflect.Value, fieldPath string, signCallback func(fieldPath string, rv reflect.Value) (err error)) (signed bool, err error) {
+ rv = reflect.Indirect(rv)
+
+ switch rv.Kind() {
+ case reflect.Bool, reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Float32,
+ reflect.Float64, reflect.Complex64, reflect.Complex128, reflect.Chan, reflect.Interface, reflect.Ptr,
+ reflect.String, reflect.UnsafePointer, reflect.Func:
+ return
+ case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
+ if _, ok := rv.Interface().(pi.AccountNonce); ok {
+ if err = signCallback(fieldPath, rv); err != nil {
return
}
- if accountAddr, err = crypto.PubKeyHash(pubKey); err != nil {
+ return true, nil
+ }
+ case reflect.Array, reflect.Slice:
+ for i := 0; i != rv.Len(); i++ {
+ fieldName := fieldPath
+ if fieldPath != "" {
+ fieldName += "."
+ }
+ fieldName += fmt.Sprintf("[%d]", i)
+ if signed, err = nestedWalkFillTxNonce(rv.Index(i), fieldName, signCallback); err != nil || signed {
return
}
- nonceReq := &types.NextAccountNonceReq{
- Addr: accountAddr,
+ }
+ case reflect.Map:
+ for _, k := range rv.MapKeys() {
+ fieldName := fieldPath
+ if fieldPath != "" {
+ fieldName += "."
}
- nonceResp := &types.NextAccountNonceResp{}
- if err = rpc.NewCaller().CallNode(proto.NodeID(rpcEndpoint),
- route.MCCNextAccountNonce.String(), nonceReq, nonceResp); err != nil {
+ fieldName += fmt.Sprintf("[%v]", k)
+ if signed, err = nestedWalkFillTxNonce(rv.MapIndex(k), fieldName, signCallback); err != nil || signed {
return
}
+ }
+ case reflect.Struct:
+ for i := 0; i != rv.NumField(); i++ {
+ // walk inside
+ fieldName := fieldPath
+ if fieldPath != "" {
+ fieldName += "."
+ }
+ fieldName += rv.Type().Field(i).Name
- rv.Field(i).SetUint(uint64(nonceResp.Nonce))
- log.Infof("filled tx type %s nonce field %s with nonce %d",
- tx.GetTransactionType().String(), rv.Type().Field(i).Name, nonceResp.Nonce)
- break
+ if _, ok := rv.Field(i).Interface().(pi.AccountNonce); ok {
+ if err = signCallback(fieldName, rv.Field(i)); err != nil {
+ return
+ }
+ return true, nil
+ } else {
+ if signed, err = nestedWalkFillTxNonce(rv.Field(i), fieldName, signCallback); err != nil || signed {
+ return
+ }
+ }
}
}
return
}
+func fillTxNonce(tx pi.Transaction) (err error) {
+ _, err = nestedWalkFillTxNonce(reflect.ValueOf(tx), "", func(fieldPath string, rv reflect.Value) (err error) {
+ var (
+ pubKey *asymmetric.PublicKey
+ accountAddr proto.AccountAddress
+ )
+ if pubKey, err = kms.GetLocalPublicKey(); err != nil {
+ return
+ }
+ if accountAddr, err = crypto.PubKeyHash(pubKey); err != nil {
+ return
+ }
+ nonceReq := &types.NextAccountNonceReq{
+ Addr: accountAddr,
+ }
+ nonceResp := &types.NextAccountNonceResp{}
+ if err = rpc.NewCaller().CallNode(proto.NodeID(rpcEndpoint),
+ route.MCCNextAccountNonce.String(), nonceReq, nonceResp); err != nil {
+ return
+ }
+
+ rv.SetUint(uint64(nonceResp.Nonce))
+ log.Infof("filled tx type %s nonce field %s with nonce %d",
+ tx.GetTransactionType().String(), fieldPath, nonceResp.Nonce)
+
+ return
+ })
+
+ return
+}
+
func resolveRPCEntities() (req interface{}, resp interface{}) {
rpcParts := strings.SplitN(rpcName, ".", 2)
From 2053d1b862625ef98e40e0d8e5cac1e9f475618d Mon Sep 17 00:00:00 2001
From: laodouya
Date: Wed, 26 Dec 2018 18:04:44 +0800
Subject: [PATCH 193/278] Update client README.md. Add create dsn and drop dsn
in simple example.
---
client/README.md | 115 +++++++++++++-------------------------
client/_example/simple.go | 10 +++-
2 files changed, 47 insertions(+), 78 deletions(-)
diff --git a/client/README.md b/client/README.md
index 602cd4543..394022647 100644
--- a/client/README.md
+++ b/client/README.md
@@ -11,28 +11,33 @@ $ go get github.com/CovenantSQL/CovenantSQL/cmd/cql-utils
and import `client` package if you want to use it in your code.
+
+## Initialize a CovenantSQL Client
+
+You need to provide a config and a master key for initialization. The master key is used to encrypt/decrypt local key pair. Here is how to generate a default config with master key
+
### Generating Default Config File
+Run `cql-utils` like below. Enter a master key (like a password) for generating local key pair. After that, it may take a few seconds with a private key file and config.yaml file generated in `conf` folder.
+
```bash
-$ cql-utils -tool confgen -root bp
+$ cql-utils -tool confgen -root conf
Generating key pair...
Enter master key(press Enter for default: ""):
⏎
-Private key file: bp/private.key
-Public key's hex: 02296ea73240dcd69d2b3f1fb754c8debdf68c62147488abb10165428667ec8cbd
+Private key file: conf/private.key
+Public key's hex: 025abec9b0072615170f4acf4a2fa1162a13864bb66bc3f140b29f6bf50ceafc75
Generated key pair.
Generating nonce...
-nonce: {{731613648 0 0 0} 11 001ea9c8381c4e8bb875372df9e02cd74326cbec33ef6f5d4c6829fcbf5012e9}
-node id: 001ea9c8381c4e8bb875372df9e02cd74326cbec33ef6f5d4c6829fcbf5012e9
+INFO[0005] cpu: 1
+INFO[0005] position: 0, shift: 0x0, i: 0
+nonce: {{1450338416 0 0 0} 26 0000002dd8bdb50ba0270642e4c4bc593c1630ef7784653f311b3c3d6374e514}
+node id: 0000002dd8bdb50ba0270642e4c4bc593c1630ef7784653f311b3c3d6374e514
Generated nonce.
Generating config file...
Generated nonce.
```
-## Initialize a CovenantSQL Client
-
-You need to provide a config and a master key for initialization. The master key is used to encrypt/decrypt local key pair. If you generate a config file with `cql-utils`, you can find the config file in the directory that `cql-utils` create.
-
After you prepare your master key and config file, CovenantSQL client can be initialized by:
```go
@@ -47,90 +52,46 @@ To create a new SQL Chain, the number of node should be provided:
```go
var dsn string
-dsn, err := client.ResourceMeta{Node: uint16(nodeCnt)}
-// process err
-var cfg *client.Config
-cfg, err = client.ParseDSN(dsn)
+dsn, err = client.Create(client.ResourceMeta{Node: uint16(nodeCount)})
// process err
```
+And you will get a dsn string. It represents a database instance, use it for queries.
-Database ID can be found in `cfg`:
+### Query and Exec
+
+When you get the dsn, you can query or execute some sql on SQL Chain as follows:
```go
-databaseID := cfg.DatabaseID
-```
-In all:
+ db, err := sql.Open("covenantsql", dsn)
+ // process err
-```go
-func Create(nodeCnt uint16) (dbID string, err error) {
- var dsn string
- if dsn, err = client.Create(client.ResourceMeta{Node: uint16(nodeCnt)}); err != nil {
- return
- }
-
- var cfg *client.Config
- if cfg, err = client.ParseDSN(dsn); err != nil {
- return
- }
-
- dbID = cfg.DatabaseID
- return
-}
-```
+ _, err = db.Exec("CREATE TABLE testSimple ( column int );")
+ // process err
-### Query and Exec
+ _, err = db.Exec("INSERT INTO testSimple VALUES(?);", 42)
+ // process err
-When you get the database ID, you can query or execute some sql on SQL Chain as follows:
+ row := db.QueryRow("SELECT column FROM testSimple LIMIT 1;")
+
+ var result int
+ err = row.Scan(&result)
+ // process err
+ fmt.Printf("SELECT column FROM testSimple LIMIT 1; result %d\n", result)
+
+ err = db.Close()
+ // process err
-```go
-func Query(dbID string, query string) (result , err error) {
- var conn *sql.DB
- if conn, err = s.getConn(dbID); err != nil {
- return
- }
- defer conn.Close()
-
- var rows *sql.Rows
- if rows, err = conn.Query(query); err != nil {
- return
- }
- defer rows.Close()
-
- // read the rows of rows
-}
-
-func Exec(dbID string, query string) (err error) {
- var conn *sql.DB
- if conn, err = s.getConn(dbID); err != nil {
- return
- }
- defer conn.Close()
-
- _, err = conn.Exec(query)
-
- return
-}
-
-func getConn(dbID string) (db *sql.DB, err error) {
- cfg := client.NewConfig()
- cfg.DatabaseID = dbID
-
- return sql.Open("covenantsql", cfg.FormatDSN())
-}
```
+It just like other standard go sql database.
### Drop the Database
-Drop your database on SQL Chain is very easy with your database ID:
+Drop your database on SQL Chain is very easy with your dsn string:
```go
-func Drop(dbID string) (err error) {
- cfg := client.NewConfig()
- cfg.DatabaseID = dbID
- err = client.Drop(cfg.FormatDSN())
- return
-}
+ err = client.Drop(dsn)
+ // process err
```
### Full Example
diff --git a/client/_example/simple.go b/client/_example/simple.go
index cc8c88464..94ea0ec33 100644
--- a/client/_example/simple.go
+++ b/client/_example/simple.go
@@ -39,10 +39,19 @@ func main() {
log.Fatal(err)
}
+ if dsn == "" {
+ dsn, err = client.Create(client.ResourceMeta{Node: uint16(2)})
+ if err != nil {
+ log.Fatal(err)
+ }
+ defer client.Drop(dsn)
+ }
+
db, err := sql.Open("covenantsql", dsn)
if err != nil {
log.Fatal(err)
}
+ defer db.Close()
_, err = db.Exec("DROP TABLE IF EXISTS testSimple;")
if err != nil {
@@ -73,5 +82,4 @@ func main() {
}
fmt.Printf("SELECT nonIndexedColumn FROM testSimple LIMIT 1; result %d\n", result)
- err = db.Close()
}
From 2d09353f4b93d0bad3b7b0d7732675f6745dea23 Mon Sep 17 00:00:00 2001
From: Qi Xiao
Date: Wed, 26 Dec 2018 18:06:56 +0800
Subject: [PATCH 194/278] Update rpc tool max depth to 6
---
cmd/cql-utils/rpc.go | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/cmd/cql-utils/rpc.go b/cmd/cql-utils/rpc.go
index 5a311fd7e..b0a8793b1 100644
--- a/cmd/cql-utils/rpc.go
+++ b/cmd/cql-utils/rpc.go
@@ -127,7 +127,7 @@ func runRPC() {
log.Info("sending request")
spewCfg := spew.NewDefaultConfig()
- spewCfg.MaxDepth = 4
+ spewCfg.MaxDepth = 6
spewCfg.Dump(req)
if err := rpc.NewCaller().CallNode(proto.NodeID(rpcEndpoint), rpcName, req, resp); err != nil {
// send request failed
From 7c71595281c4e46a623a29e7eb97439a5322014e Mon Sep 17 00:00:00 2001
From: leventeliu
Date: Wed, 26 Dec 2018 18:24:49 +0800
Subject: [PATCH 195/278] Add QuerySQLChainProfile mock method
---
client/helper_test.go | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/client/helper_test.go b/client/helper_test.go
index 824f1c055..b803c8e22 100644
--- a/client/helper_test.go
+++ b/client/helper_test.go
@@ -146,6 +146,22 @@ func (s *stubBPDBService) QueryAccountCovenantBalance(req *types.QueryAccountCov
return
}
+func (s *stubBPDBService) QuerySQLChainProfile(req *types.QuerySQLChainProfileReq,
+ resp *types.QuerySQLChainProfileResp) (err error) {
+ var nodeID proto.NodeID
+ if nodeID, err = kms.GetLocalNodeID(); err != nil {
+ return
+ }
+ resp.Profile = types.SQLChainProfile{
+ Miners: []*types.MinerInfo{
+ &types.MinerInfo{
+ NodeID: nodeID,
+ },
+ },
+ }
+ return
+}
+
func startTestService() (stopTestService func(), tempDir string, err error) {
var server *rpc.Server
var cleanup func()
From c16574a8dda40ebb29e6a4b397dbb218f939ecd3 Mon Sep 17 00:00:00 2001
From: Qi Xiao
Date: Wed, 26 Dec 2018 18:36:52 +0800
Subject: [PATCH 196/278] Support CreateDatabase in client and command line
tools
---
client/driver.go | 60 ++++++++++++++++++++------
cmd/cql-adapter/storage/covenantsql.go | 5 ++-
cmd/cql-utils/rpc.go | 6 +--
cmd/cql/main.go | 3 +-
4 files changed, 56 insertions(+), 18 deletions(-)
diff --git a/client/driver.go b/client/driver.go
index 51317e666..30c5a02a3 100644
--- a/client/driver.go
+++ b/client/driver.go
@@ -43,6 +43,10 @@ const (
DBScheme = "covenantsql"
// DBSchemeAlias defines the alias dsn scheme.
DBSchemeAlias = "cql"
+ // DefaultGasPrice defines the default gas price for new created database.
+ DefaultGasPrice = 1
+ // DefaultAdvancePayment defines the default advance payment for new created database.
+ DefaultAdvancePayment = 20000000
)
var (
@@ -84,7 +88,11 @@ func (d *covenantSQLDriver) Open(dsn string) (conn driver.Conn, err error) {
}
// ResourceMeta defines new database resources requirement descriptions.
-type ResourceMeta types.ResourceMeta
+type ResourceMeta struct {
+ types.ResourceMeta
+ GasPrice uint64
+ AdvancePayment uint64
+}
// Init defines init process for client.
func Init(configFile string, masterKey []byte) (err error) {
@@ -122,30 +130,58 @@ func Create(meta ResourceMeta) (dsn string, err error) {
return
}
- req := new(types.CreateDatabaseRequest)
- req.Header.ResourceMeta = types.ResourceMeta(meta)
- var privateKey *asymmetric.PrivateKey
+ var (
+ nonceReq = new(types.NextAccountNonceReq)
+ nonceResp = new(types.NextAccountNonceResp)
+ req = new(types.AddTxReq)
+ resp = new(types.AddTxResp)
+ privateKey *asymmetric.PrivateKey
+ clientAddr proto.AccountAddress
+ )
if privateKey, err = kms.GetLocalPrivateKey(); err != nil {
err = errors.Wrap(err, "get local private key failed")
return
}
- if err = req.Sign(privateKey); err != nil {
- err = errors.Wrap(err, "sign request failed")
+ if clientAddr, err = crypto.PubKeyHash(privateKey.PubKey()); err != nil {
+ err = errors.Wrap(err, "get local account address failed")
return
}
- res := new(types.CreateDatabaseResponse)
+ // allocate nonce
+ nonceReq.Addr = clientAddr
- if err = requestBP(route.BPDBCreateDatabase, req, res); err != nil {
- err = errors.Wrap(err, "call BPDB.CreateDatabase failed")
+ if err = requestBP(route.MCCNextAccountNonce, nonceReq, nonceResp); err != nil {
+ err = errors.Wrap(err, "allocate create database transaction nonce failed")
return
}
- if err = res.Verify(); err != nil {
- err = errors.Wrap(err, "response verify failed")
+
+ if meta.GasPrice == 0 {
+ meta.GasPrice = DefaultGasPrice
+ }
+ if meta.AdvancePayment == 0 {
+ meta.AdvancePayment = DefaultAdvancePayment
+ }
+
+ req.Tx = types.NewCreateDatabase(&types.CreateDatabaseHeader{
+ Owner: clientAddr,
+ ResourceMeta: meta.ResourceMeta,
+ GasPrice: meta.GasPrice,
+ AdvancePayment: meta.AdvancePayment,
+ TokenType: types.Particle,
+ Nonce: nonceResp.Nonce,
+ })
+
+ if err = req.Tx.Sign(privateKey); err != nil {
+ err = errors.Wrap(err, "sign request failed")
+ return
+ }
+
+ if err = requestBP(route.MCCAddTx, req, resp); err != nil {
+ err = errors.Wrap(err, "call create database transaction failed")
return
}
cfg := NewConfig()
- cfg.DatabaseID = string(res.Header.InstanceMeta.DatabaseID)
+ cfg.DatabaseID = string(*proto.FromAccountAndNonce(clientAddr, uint32(nonceResp.Nonce)))
dsn = cfg.FormatDSN()
return
diff --git a/cmd/cql-adapter/storage/covenantsql.go b/cmd/cql-adapter/storage/covenantsql.go
index 9750c891c..ced9155f8 100644
--- a/cmd/cql-adapter/storage/covenantsql.go
+++ b/cmd/cql-adapter/storage/covenantsql.go
@@ -33,8 +33,11 @@ func NewCovenantSQLStorage() (s *CovenantSQLStorage) {
// Create implements the Storage abstraction interface.
func (s *CovenantSQLStorage) Create(nodeCnt int) (dbID string, err error) {
+ var meta = client.ResourceMeta{}
+ meta.Node = uint16(nodeCnt)
+
var dsn string
- if dsn, err = client.Create(client.ResourceMeta{Node: uint16(nodeCnt)}); err != nil {
+ if dsn, err = client.Create(meta); err != nil {
return
}
diff --git a/cmd/cql-utils/rpc.go b/cmd/cql-utils/rpc.go
index b0a8793b1..ea689702a 100644
--- a/cmd/cql-utils/rpc.go
+++ b/cmd/cql-utils/rpc.go
@@ -211,10 +211,8 @@ func nestedWalkFillTxNonce(rv reflect.Value, fieldPath string, signCallback func
return
}
return true, nil
- } else {
- if signed, err = nestedWalkFillTxNonce(rv.Field(i), fieldName, signCallback); err != nil || signed {
- return
- }
+ } else if signed, err = nestedWalkFillTxNonce(rv.Field(i), fieldName, signCallback); err != nil || signed {
+ return
}
}
}
diff --git a/cmd/cql/main.go b/cmd/cql/main.go
index 3b17daae8..390c15941 100644
--- a/cmd/cql/main.go
+++ b/cmd/cql/main.go
@@ -261,7 +261,8 @@ func main() {
return
}
- meta = client.ResourceMeta{Node: uint16(nodeCnt)}
+ meta = client.ResourceMeta{}
+ meta.Node = uint16(nodeCnt)
}
dsn, err := client.Create(meta)
From 4768227a982a1b8e66c853164c5feb8ae63bd486 Mon Sep 17 00:00:00 2001
From: leventeliu
Date: Wed, 26 Dec 2018 18:51:08 +0800
Subject: [PATCH 197/278] Fix bug: BP returns nil error if database not found
---
blockproducer/rpc.go | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/blockproducer/rpc.go b/blockproducer/rpc.go
index 2ff9c790f..4521a4189 100644
--- a/blockproducer/rpc.go
+++ b/blockproducer/rpc.go
@@ -124,7 +124,7 @@ func (s *ChainRPCService) QuerySQLChainProfile(req *types.QuerySQLChainProfileRe
resp.Profile = *p
return
}
- err = errors.Wrap(err, "rpc query sqlchain profile failed")
+ err = errors.Wrap(ErrDatabaseNotFound, "rpc query sqlchain profile failed")
return
}
From 46aec6ae6fd5e9a94a6f58896fac04ab3b129a3c Mon Sep 17 00:00:00 2001
From: Qi Xiao
Date: Wed, 26 Dec 2018 18:56:16 +0800
Subject: [PATCH 198/278] Golint issues
---
client/clientbench_test.go | 4 +++-
cmd/cql-fuse/block_test.go | 4 +++-
cmd/cql-minerd/integration_test.go | 8 ++++++--
cmd/cql-observer/observation_test.go | 8 ++++++--
crypto/kms/privatekeystore.go | 6 +++---
proto/proto.go | 10 +++++-----
proto/proto_test.go | 3 ++-
rpc/rpcutil.go | 2 +-
sqlchain/chain.go | 4 ++--
sqlchain/chainbusservice.go | 4 ++++
types/account.go | 5 +++--
types/chainstate.go | 9 +++++++++
12 files changed, 47 insertions(+), 20 deletions(-)
diff --git a/client/clientbench_test.go b/client/clientbench_test.go
index b19fb2c85..e41208c15 100644
--- a/client/clientbench_test.go
+++ b/client/clientbench_test.go
@@ -54,7 +54,9 @@ func BenchmarkCovenantSQLDriver(b *testing.B) {
})
// create
- dsn, err := Create(ResourceMeta{Node: 3})
+ meta := ResourceMeta{}
+ meta.Node = 3
+ dsn, err := Create(meta)
if err != nil {
b.Fatal(err)
}
diff --git a/cmd/cql-fuse/block_test.go b/cmd/cql-fuse/block_test.go
index 836b15132..20e06119f 100644
--- a/cmd/cql-fuse/block_test.go
+++ b/cmd/cql-fuse/block_test.go
@@ -240,7 +240,9 @@ func initTestDB() (*sql.DB, func()) {
}
// create
- dsn, err := client.Create(client.ResourceMeta{Node: 1})
+ meta := client.ResourceMeta{}
+ meta.Node = 1
+ dsn, err := client.Create(meta)
if err != nil {
log.Errorf("create db failed: %v", err)
return nil, stopNodes
diff --git a/cmd/cql-minerd/integration_test.go b/cmd/cql-minerd/integration_test.go
index f98bfc23a..5529988d2 100644
--- a/cmd/cql-minerd/integration_test.go
+++ b/cmd/cql-minerd/integration_test.go
@@ -747,7 +747,9 @@ func benchMiner(b *testing.B, minerCount uint16, bypassSign bool) {
var dsn string
if minerCount > 0 {
// create
- dsn, err = client.Create(client.ResourceMeta{Node: minerCount})
+ meta := client.ResourceMeta{}
+ meta.Node = minerCount
+ dsn, err = client.Create(meta)
So(err, ShouldBeNil)
log.Infof("the created database dsn is %v", dsn)
@@ -826,7 +828,9 @@ func benchGNTEMiner(b *testing.B, minerCount uint16, bypassSign bool) {
var dsn string
if minerCount > 0 {
// create
- dsn, err = client.Create(client.ResourceMeta{Node: minerCount})
+ meta := client.ResourceMeta{}
+ meta.Node = minerCount
+ dsn, err = client.Create(meta)
So(err, ShouldBeNil)
log.Infof("the created database dsn is %v", dsn)
diff --git a/cmd/cql-observer/observation_test.go b/cmd/cql-observer/observation_test.go
index 76a1b57c1..4d7d0b4f0 100644
--- a/cmd/cql-observer/observation_test.go
+++ b/cmd/cql-observer/observation_test.go
@@ -245,7 +245,9 @@ func TestFullProcess(t *testing.T) {
So(err, ShouldBeNil)
// create
- dsn, err := client.Create(client.ResourceMeta{Node: 1})
+ meta := client.ResourceMeta{}
+ meta.Node = 1
+ dsn, err := client.Create(meta)
So(err, ShouldBeNil)
log.Infof("the created database dsn is %v", dsn)
@@ -304,7 +306,9 @@ func TestFullProcess(t *testing.T) {
So(err, ShouldBeNil)
// create
- dsn2, err := client.Create(client.ResourceMeta{Node: 1})
+ meta = client.ResourceMeta{}
+ meta.Node = 1
+ dsn2, err := client.Create(meta)
So(err, ShouldBeNil)
log.Infof("the created database dsn is %v", dsn2)
diff --git a/crypto/kms/privatekeystore.go b/crypto/kms/privatekeystore.go
index 64197d821..0e3aa01d8 100644
--- a/crypto/kms/privatekeystore.go
+++ b/crypto/kms/privatekeystore.go
@@ -35,11 +35,11 @@ var (
ErrNotKeyFile = errors.New("private key file empty")
// ErrHashNotMatch indicates specified key hash is wrong
ErrHashNotMatch = errors.New("private key hash not match")
- // ErrPrivateKeyVersion indicates specified key is not base58 version
+ // ErrInvalidBase58Version indicates specified key is not base58 version
ErrInvalidBase58Version = errors.New("invalid base58 version")
- // ErrPrivateKeyChecksum indicates specified key is not base58 checksum
+ // ErrInvalidBase58Checksum indicates specified key checksum is not base58 checksum
ErrInvalidBase58Checksum = errors.New("invalid base58 checksum")
-
+ // PrivateKeyStoreVersion defines the private key version byte.
PrivateKeyStoreVersion byte = 0x23
)
diff --git a/proto/proto.go b/proto/proto.go
index 49d5b0426..ab92ba8f4 100644
--- a/proto/proto.go
+++ b/proto/proto.go
@@ -46,11 +46,11 @@ type EnvelopeAPI interface {
// Envelope is the protocol header
type Envelope struct {
- Version string `json:"v"`
- TTL time.Duration `json:"t"`
- Expire time.Duration `json:"e"`
- NodeID *RawNodeID `json:"id"`
- _ctx context.Context `json:"-"`
+ Version string `json:"v"`
+ TTL time.Duration `json:"t"`
+ Expire time.Duration `json:"e"`
+ NodeID *RawNodeID `json:"id"`
+ _ctx context.Context
}
// PingReq is Ping RPC request
diff --git a/proto/proto_test.go b/proto/proto_test.go
index 8dfb0a56c..9cf907cd8 100644
--- a/proto/proto_test.go
+++ b/proto/proto_test.go
@@ -45,7 +45,8 @@ func TestEnvelope_GetSet(t *testing.T) {
ctx := env.GetContext()
So(ctx, ShouldEqual, context.Background())
- cldCtx, _ := context.WithCancel(ctx)
+ cldCtx, cancel := context.WithCancel(ctx)
+ defer cancel()
env.SetContext(cldCtx)
So(env.GetContext(), ShouldEqual, cldCtx)
})
diff --git a/rpc/rpcutil.go b/rpc/rpcutil.go
index 29ac19a91..96e2aca11 100644
--- a/rpc/rpcutil.go
+++ b/rpc/rpcutil.go
@@ -354,7 +354,7 @@ func SetCurrentBP(bpNodeID proto.NodeID) {
currentBP = bpNodeID
}
-// RequstBP sends request to main chain.
+// RequestBP sends request to main chain.
func RequestBP(method string, req interface{}, resp interface{}) (err error) {
var bp proto.NodeID
if bp, err = GetCurrentBP(); err != nil {
diff --git a/sqlchain/chain.go b/sqlchain/chain.go
index 7f73e4947..bcb393354 100644
--- a/sqlchain/chain.go
+++ b/sqlchain/chain.go
@@ -1557,10 +1557,10 @@ func (c *Chain) billing(node *blockNode) (ub *types.UpdateBilling, err error) {
Miner: k1,
Income: v1,
}
- j += 1
+ j++
}
j = 0
- i += 1
+ i++
}
ub.Receiver, err = c.databaseID.AccountAddress()
return
diff --git a/sqlchain/chainbusservice.go b/sqlchain/chainbusservice.go
index 848a711d8..b159bd4e5 100644
--- a/sqlchain/chainbusservice.go
+++ b/sqlchain/chainbusservice.go
@@ -32,6 +32,7 @@ import (
"github.com/CovenantSQL/CovenantSQL/utils/log"
)
+// BusService defines the man chain bus service type.
type BusService struct {
chainbus.Bus
@@ -49,6 +50,7 @@ type BusService struct {
sqlChainProfiles map[proto.DatabaseID]*types.SQLChainProfile
}
+// NewBusService creates a new chain bus instance.
func NewBusService(
ctx context.Context, addr proto.AccountAddress, checkInterval time.Duration) (_ *BusService,
) {
@@ -68,6 +70,7 @@ func NewBusService(
return bs
}
+// GetCurrentDBMapping returns current cached db mapping.
func (bs *BusService) GetCurrentDBMapping() (dbMap map[proto.DatabaseID]*types.SQLChainProfile) {
dbMap = make(map[proto.DatabaseID]*types.SQLChainProfile)
bs.lock.Lock()
@@ -174,6 +177,7 @@ func (bs *BusService) requestLastBlock() (
return
}
+// RequestSQLProfile get specified database profile.
func (bs *BusService) RequestSQLProfile(dbid *proto.DatabaseID) (p *types.SQLChainProfile, ok bool) {
bs.lock.Lock()
defer bs.lock.Unlock()
diff --git a/types/account.go b/types/account.go
index 3bc209ce6..5ff67308c 100644
--- a/types/account.go
+++ b/types/account.go
@@ -39,7 +39,7 @@ const (
type UserPermission int32
const (
- // Unknown defines the initial permission.
+ // UnknownPerm defines the initial permission.
UnknownPerm UserPermission = iota
// Admin defines the admin user permission.
Admin
@@ -70,7 +70,7 @@ func (up *UserPermission) CheckAdmin() bool {
type Status int32
const (
- // Unknown defines initial status.
+ // UnknownStatus defines initial status.
UnknownStatus Status = iota
// Normal defines no bad thing happens.
Normal
@@ -84,6 +84,7 @@ const (
NumberOfStatus
)
+// EnableQuery indicates whether the account is permitted to query.
func (s *Status) EnableQuery() bool {
return *s >= Normal && *s <= Reminder
}
diff --git a/types/chainstate.go b/types/chainstate.go
index 70f657f8f..0d3a868c0 100644
--- a/types/chainstate.go
+++ b/types/chainstate.go
@@ -20,21 +20,25 @@ import (
"github.com/CovenantSQL/CovenantSQL/proto"
)
+// PermStat defines the permissions status structure.
type PermStat struct {
Permission UserPermission
Status Status
}
+// UserState defines the user state structure.
type UserState struct {
State map[proto.AccountAddress]*PermStat
}
+// NewUserState returns new user state instance.
func NewUserState() *UserState {
return &UserState{
State: make(map[proto.AccountAddress]*PermStat),
}
}
+// UpdatePermission sets account permission.
func (us *UserState) UpdatePermission(user proto.AccountAddress, perm UserPermission) {
if state, ok := us.State[user]; ok {
state.Permission = perm
@@ -45,10 +49,12 @@ func (us *UserState) UpdatePermission(user proto.AccountAddress, perm UserPermis
}
}
+// AddPermission updates account permission.
func (us *UserState) AddPermission(user proto.AccountAddress, perm UserPermission) {
us.UpdatePermission(user, perm)
}
+// UpdateStatus update account status.
func (us *UserState) UpdateStatus(user proto.AccountAddress, stat Status) {
if state, ok := us.State[user]; ok {
state.Status = stat
@@ -59,16 +65,19 @@ func (us *UserState) UpdateStatus(user proto.AccountAddress, stat Status) {
}
}
+// AddStatus is an alias for UpdateStatus.
func (us *UserState) AddStatus(user proto.AccountAddress, stat Status) {
us.UpdateStatus(user, stat)
}
+// GetPermission returns the account permission.
func (us *UserState) GetPermission(user proto.AccountAddress) (up UserPermission, ok bool) {
permstat, ok := us.State[user]
up = permstat.Permission
return
}
+// GetStatus returns the account status.
func (us *UserState) GetStatus(user proto.AccountAddress) (stat Status, ok bool) {
permstat, ok := us.State[user]
stat = permstat.Status
From aa13006cff0bd2a96cb1148b0374c5366a148dee Mon Sep 17 00:00:00 2001
From: Qi Xiao
Date: Wed, 26 Dec 2018 19:06:32 +0800
Subject: [PATCH 199/278] Add hash.Hash json marshal/unmarshal handler
---
crypto/hash/hash.go | 18 ++++++++++++++++++
crypto/hash/hash_test.go | 22 +++++++++++++++++++---
2 files changed, 37 insertions(+), 3 deletions(-)
diff --git a/crypto/hash/hash.go b/crypto/hash/hash.go
index 75ad51858..f98a7d733 100644
--- a/crypto/hash/hash.go
+++ b/crypto/hash/hash.go
@@ -18,6 +18,7 @@ package hash
import (
"encoding/hex"
+ "encoding/json"
"fmt"
"math/bits"
@@ -129,6 +130,23 @@ func (h *Hash) Difficulty() (difficulty int) {
return HashSize * 8
}
+// MarshalJSON implements the json.Marshaler interface.
+func (h Hash) MarshalJSON() ([]byte, error) {
+ return json.Marshal(h.String())
+}
+
+// UnmarshalJSON implements the json.Unmarshaler interface.
+func (h *Hash) UnmarshalJSON(data []byte) (err error) {
+ var s string
+ if err = json.Unmarshal(data, &s); err != nil {
+ return
+ }
+ if err = Decode(h, s); err != nil {
+ return
+ }
+ return nil
+}
+
// MarshalYAML implements the yaml.Marshaler interface.
func (h Hash) MarshalYAML() (interface{}, error) {
return h.String(), nil
diff --git a/crypto/hash/hash_test.go b/crypto/hash/hash_test.go
index 9dede44d6..abb2bdf63 100644
--- a/crypto/hash/hash_test.go
+++ b/crypto/hash/hash_test.go
@@ -19,6 +19,7 @@ package hash
import (
"bytes"
"encoding/hex"
+ "encoding/json"
"strings"
"testing"
@@ -280,7 +281,7 @@ func TestHash_Difficulty(t *testing.T) {
}
}
-func unmarshalAndMarshal(str string) string {
+func unmarshalAndMarshalYAML(str string) string {
var hash Hash
yaml.Unmarshal([]byte(str), &hash)
ret, _ := yaml.Marshal(hash)
@@ -288,9 +289,24 @@ func unmarshalAndMarshal(str string) string {
return strings.TrimSpace(string(ret))
}
+func unmarshalAndMarshalJSON(str string) string {
+ var hash Hash
+ json.Unmarshal([]byte(str), &hash)
+ ret, _ := json.Marshal(hash)
+
+ return strings.TrimSpace(string(ret))
+}
+
func TestHash_MarshalYAML(t *testing.T) {
Convey("marshal unmarshal yaml", t, func() {
- So(unmarshalAndMarshal("029e54e333da9ff38acb0f1afd8b425d57ba301539bc7b26a94f1ab663605efb"), ShouldEqual, "029e54e333da9ff38acb0f1afd8b425d57ba301539bc7b26a94f1ab663605efb")
- So(unmarshalAndMarshal("02c76216704d797c64c58bc11519fb68582e8e63de7e5b3b2dbbbe8733efe5fd"), ShouldEqual, "02c76216704d797c64c58bc11519fb68582e8e63de7e5b3b2dbbbe8733efe5fd")
+ So(unmarshalAndMarshalYAML("029e54e333da9ff38acb0f1afd8b425d57ba301539bc7b26a94f1ab663605efb"), ShouldEqual, "029e54e333da9ff38acb0f1afd8b425d57ba301539bc7b26a94f1ab663605efb")
+ So(unmarshalAndMarshalYAML("02c76216704d797c64c58bc11519fb68582e8e63de7e5b3b2dbbbe8733efe5fd"), ShouldEqual, "02c76216704d797c64c58bc11519fb68582e8e63de7e5b3b2dbbbe8733efe5fd")
+ })
+}
+
+func TestHash_MarshalJSON(t *testing.T) {
+ Convey("marshal unmarshal yaml", t, func() {
+ So(unmarshalAndMarshalJSON(`"029e54e333da9ff38acb0f1afd8b425d57ba301539bc7b26a94f1ab663605efb"`), ShouldEqual, `"029e54e333da9ff38acb0f1afd8b425d57ba301539bc7b26a94f1ab663605efb"`)
+ So(unmarshalAndMarshalJSON(`"02c76216704d797c64c58bc11519fb68582e8e63de7e5b3b2dbbbe8733efe5fd"`), ShouldEqual, `"02c76216704d797c64c58bc11519fb68582e8e63de7e5b3b2dbbbe8733efe5fd"`)
})
}
From 7496ddd0c363f72782be9056b1ac3c54fd84d361 Mon Sep 17 00:00:00 2001
From: Qi Xiao
Date: Wed, 26 Dec 2018 19:24:14 +0800
Subject: [PATCH 200/278] Make cql create database with target miners use Hash
string instead of byte array
---
cmd/cql-utils/addrgen.go | 5 +++++
proto/nodeinfo.go | 10 ++++++++++
2 files changed, 15 insertions(+)
diff --git a/cmd/cql-utils/addrgen.go b/cmd/cql-utils/addrgen.go
index d0df440cf..b639f5a63 100644
--- a/cmd/cql-utils/addrgen.go
+++ b/cmd/cql-utils/addrgen.go
@@ -64,9 +64,14 @@ func runAddrgen() {
os.Exit(1)
}
+ keyHash, err := crypto.PubKeyHash(publicKey)
+ if err != nil {
+ log.WithError(err).Fatal("unexpected error")
+ }
addr, err := crypto.PubKey2Addr(publicKey, crypto.TestNet)
if err != nil {
log.WithError(err).Fatal("unexpected error")
}
+ fmt.Printf("wallet address hash: %s\n", keyHash.String())
fmt.Printf("wallet address: %s\n", addr)
}
diff --git a/proto/nodeinfo.go b/proto/nodeinfo.go
index b066b6950..32b315d7d 100644
--- a/proto/nodeinfo.go
+++ b/proto/nodeinfo.go
@@ -53,6 +53,16 @@ type NodeID string
// AccountAddress is wallet address, will be generated from Hash(nodePublicKey).
type AccountAddress hash.Hash
+// UnmarshalJSON implements the json.Unmarshaler interface.
+func (z *AccountAddress) UnmarshalJSON(data []byte) error {
+ return ((*hash.Hash)(z)).UnmarshalJSON(data)
+}
+
+// MarshalJSON implements the json.Marshaler interface.
+func (z AccountAddress) MarshalJSON() ([]byte, error) {
+ return ((hash.Hash)(z)).MarshalJSON()
+}
+
// NodeKey is node key on consistent hash ring, generate from Hash(NodeID).
type NodeKey RawNodeID
From 2ba5805cf0b5ce7566c54fc821df92f51fd7d2b3 Mon Sep 17 00:00:00 2001
From: Qi Xiao
Date: Wed, 26 Dec 2018 19:46:46 +0800
Subject: [PATCH 201/278] Update client dsn FormatDSN function to strip default
parameters
---
client/config.go | 18 ++++++++++++++----
client/config_test.go | 20 ++++++++++++++++++++
2 files changed, 34 insertions(+), 4 deletions(-)
diff --git a/client/config.go b/client/config.go
index cde8eec94..b9bf5e936 100644
--- a/client/config.go
+++ b/client/config.go
@@ -22,6 +22,11 @@ import (
"strings"
)
+const (
+ paramUseLeader = "use_leader"
+ paramUseFollower = "use_follower"
+)
+
// Config is a configuration parsed from a DSN string.
type Config struct {
DatabaseID string
@@ -52,8 +57,13 @@ func (cfg *Config) FormatDSN() string {
}
newQuery := u.Query()
- newQuery.Add("use_leader", strconv.FormatBool(cfg.UseLeader))
- newQuery.Add("use_follower", strconv.FormatBool(cfg.UseFollower))
+ if cfg.UseFollower {
+ newQuery.Add(paramUseFollower, strconv.FormatBool(cfg.UseFollower))
+
+ if cfg.UseLeader {
+ newQuery.Add(paramUseLeader, strconv.FormatBool(cfg.UseLeader))
+ }
+ }
u.RawQuery = newQuery.Encode()
return u.String()
@@ -75,8 +85,8 @@ func ParseDSN(dsn string) (cfg *Config, err error) {
q := u.Query()
// option: use_leader, use_follower
- cfg.UseLeader, _ = strconv.ParseBool(q.Get("use_leader"))
- cfg.UseFollower, _ = strconv.ParseBool(q.Get("use_follower"))
+ cfg.UseLeader, _ = strconv.ParseBool(q.Get(paramUseLeader))
+ cfg.UseFollower, _ = strconv.ParseBool(q.Get(paramUseFollower))
if !cfg.UseLeader && !cfg.UseFollower {
cfg.UseLeader = true
}
diff --git a/client/config_test.go b/client/config_test.go
index cbfb7a60d..a9b49d0b5 100644
--- a/client/config_test.go
+++ b/client/config_test.go
@@ -71,4 +71,24 @@ func TestConfig(t *testing.T) {
So(err, ShouldBeNil)
So(cfg, ShouldResemble, recoveredCfg)
})
+
+ Convey("test dsn with use all kinds of options", t, func(c C) {
+ testFormatAndParse := func(cfg *Config) {
+ newCfg, err := ParseDSN(cfg.FormatDSN())
+ c.So(err, ShouldBeNil)
+ c.So(newCfg, ShouldResemble, cfg)
+ }
+ testFormatAndParse(&Config{
+ UseLeader: true,
+ UseFollower: false,
+ })
+ testFormatAndParse(&Config{
+ UseLeader: false,
+ UseFollower: true,
+ })
+ testFormatAndParse(&Config{
+ UseLeader: true,
+ UseFollower: true,
+ })
+ })
}
From cd84fa273250f8965021c2fabf6e9cac4296d839 Mon Sep 17 00:00:00 2001
From: leventeliu
Date: Wed, 26 Dec 2018 19:53:29 +0800
Subject: [PATCH 202/278] Add blocking method to wait for database creation
---
blockproducer/rpc.go | 39 +++++++++++++++++++++++++++++++++++++++
1 file changed, 39 insertions(+)
diff --git a/blockproducer/rpc.go b/blockproducer/rpc.go
index 4521a4189..ab98adfad 100644
--- a/blockproducer/rpc.go
+++ b/blockproducer/rpc.go
@@ -17,6 +17,12 @@
package blockproducer
import (
+ "context"
+ "time"
+
+ "github.com/CovenantSQL/CovenantSQL/proto"
+ "github.com/CovenantSQL/CovenantSQL/route"
+ "github.com/CovenantSQL/CovenantSQL/rpc"
"github.com/CovenantSQL/CovenantSQL/types"
"github.com/CovenantSQL/CovenantSQL/utils/log"
"github.com/pkg/errors"
@@ -134,3 +140,36 @@ func (s *ChainRPCService) Sub(req *types.SubReq, resp *types.SubResp) (err error
s.chain.cl.CallNode(req.NodeID.ToNodeID(), req.Callback, request, response)
})
}
+
+func WaitDatabaseCreation(
+ ctx context.Context, dbid proto.DatabaseID, period time.Duration) (err error,
+) {
+ var (
+ timer = time.NewTimer(0)
+ req = &types.QuerySQLChainProfileReq{
+ DBID: dbid,
+ }
+ resp = &types.QuerySQLChainProfileResp{}
+ )
+ defer func() {
+ if !timer.Stop() {
+ <-timer.C
+ }
+ }()
+ for {
+ select {
+ case <-timer.C:
+ if err = rpc.RequestBP(
+ route.MCCQuerySQLChainProfile.String(), req, resp,
+ ); err != ErrDatabaseNotFound {
+ // err == nil (creation done), or
+ // err != nil && err != ErrDatabaseNotFound (unexpected error)
+ return
+ }
+ timer.Reset(period)
+ case <-ctx.Done():
+ err = ctx.Err()
+ return
+ }
+ }
+}
From 84bdccb3c30e003871618b6d01a0e0c59d181f36 Mon Sep 17 00:00:00 2001
From: zeqing-guo
Date: Wed, 26 Dec 2018 19:55:18 +0800
Subject: [PATCH 203/278] Add obeserver permission module
---
route/acl.go | 8 +++++
sqlchain/chain.go | 6 ++--
sqlchain/rpc.go | 4 +--
worker/dbms.go | 84 ++++++++++++++++++++++++++++++++++++++++++----
worker/dbms_rpc.go | 33 ++++++++++++++++++
5 files changed, 124 insertions(+), 11 deletions(-)
diff --git a/route/acl.go b/route/acl.go
index b28591630..bc171c0db 100644
--- a/route/acl.go
+++ b/route/acl.go
@@ -77,6 +77,10 @@ const (
DBSAck
// DBSDeploy is used by BP to create/drop/update database
DBSDeploy
+ // DBSSubscribeTransactions is used by dbms to handle observer subscription request
+ DBSSubscribeTransactions
+ // DBSCancelSubscription is used by dbms to handle observer subscription cancellation request
+ DBSCancelSubscription
// DBCCall is used by Miner for data consistency
DBCCall
// BPDBCreateDatabase is used by client to create database
@@ -163,6 +167,10 @@ func (s RemoteFunc) String() string {
return "DBS.Ack"
case DBSDeploy:
return "DBS.Deploy"
+ case DBSSubscribeTransactions:
+ return "DBS.SubscribeTransactions"
+ case DBSCancelSubscription:
+ return "DBS.CancelSubscription"
case DBCCall:
return "DBC.Call"
case BPDBCreateDatabase:
diff --git a/sqlchain/chain.go b/sqlchain/chain.go
index 7f73e4947..3b4fcda7e 100644
--- a/sqlchain/chain.go
+++ b/sqlchain/chain.go
@@ -1344,7 +1344,8 @@ func (c *Chain) SignBilling(req *types.BillingRequest) (
return
}
-func (c *Chain) addSubscription(nodeID proto.NodeID, startHeight int32) (err error) {
+// AddSubscription is used by dbms to add an observer.
+func (c *Chain) AddSubscription(nodeID proto.NodeID, startHeight int32) (err error) {
// send previous height and transactions using AdviseAckedQuery/AdviseNewBlock RPC method
// add node to subscriber list
c.observerLock.Lock()
@@ -1354,7 +1355,8 @@ func (c *Chain) addSubscription(nodeID proto.NodeID, startHeight int32) (err err
return
}
-func (c *Chain) cancelSubscription(nodeID proto.NodeID) (err error) {
+// CancelSubscription is used by dbms to cancel an observer.
+func (c *Chain) CancelSubscription(nodeID proto.NodeID) (err error) {
// remove node from subscription list
c.observerLock.Lock()
defer c.observerLock.Unlock()
diff --git a/sqlchain/rpc.go b/sqlchain/rpc.go
index 1825fb47a..e9e8ff217 100644
--- a/sqlchain/rpc.go
+++ b/sqlchain/rpc.go
@@ -145,10 +145,10 @@ func (s *ChainRPCService) LaunchBilling(req *LaunchBillingReq, _ *LaunchBillingR
// SubscribeTransactions is the RPC method to fetch subscribe new packed and confirmed transactions from the target server.
func (s *ChainRPCService) SubscribeTransactions(req *SubscribeTransactionsReq, _ *SubscribeTransactionsResp) error {
- return s.chain.addSubscription(req.SubscriberID, req.Height)
+ return s.chain.AddSubscription(req.SubscriberID, req.Height)
}
// CancelSubscription is the RPC method to cancel subscription in the target server.
func (s *ChainRPCService) CancelSubscription(req *CancelSubscriptionReq, _ *CancelSubscriptionResp) error {
- return s.chain.cancelSubscription(req.SubscriberID)
+ return s.chain.CancelSubscription(req.SubscriberID)
}
diff --git a/worker/dbms.go b/worker/dbms.go
index 461c18ca5..c18a2b485 100644
--- a/worker/dbms.go
+++ b/worker/dbms.go
@@ -180,7 +180,6 @@ func (dbms *DBMS) Init() (err error) {
return
}
- dbms.busService.Start()
if err = dbms.busService.Subscribe("/CreateDatabase/", dbms.createDatabase); err != nil {
err = errors.Wrap(err, "init chain bus failed")
return
@@ -193,6 +192,7 @@ func (dbms *DBMS) Init() (err error) {
err = errors.Wrap(err, "init chain bus failed")
return
}
+ dbms.busService.Start()
return
}
@@ -485,7 +485,7 @@ func (dbms *DBMS) Query(req *types.Request) (res *types.Response, err error) {
if err != nil {
return
}
- err = dbms.checkPermission(addr, req)
+ err = dbms.checkPermission(addr, req.Header.DatabaseID, req.Header.QueryType)
if err != nil {
return
}
@@ -539,9 +539,10 @@ func (dbms *DBMS) removeMeta(dbID proto.DatabaseID) (err error) {
return dbms.writeMeta()
}
-func (dbms *DBMS) checkPermission(addr proto.AccountAddress, req *types.Request) (err error) {
- log.Debugf("in checkPermission, database id: %s, user addr: %s", req.Header.DatabaseID, addr.String())
- state, loaded := dbms.chainMap.Load(req.Header.DatabaseID)
+func (dbms *DBMS) checkPermission(addr proto.AccountAddress,
+ dbID proto.DatabaseID, queryType types.QueryType) (err error) {
+ log.Debugf("in checkPermission, database id: %s, user addr: %s", dbID, addr.String())
+ state, loaded := dbms.chainMap.Load(dbID)
if !loaded {
err = errors.Wrap(ErrNotExists, "check permission failed")
return
@@ -557,13 +558,13 @@ func (dbms *DBMS) checkPermission(addr proto.AccountAddress, req *types.Request)
log.WithError(err).Debugf("cannot query, status: %d", permStat.Status)
return
}
- if req.Header.QueryType == types.ReadQuery {
+ if queryType == types.ReadQuery {
if !permStat.Permission.CheckRead() {
err = ErrPermissionDeny
log.WithError(err).Debugf("cannot read, permission: %d", permStat.Permission)
return
}
- } else if req.Header.QueryType == types.WriteQuery {
+ } else if queryType == types.WriteQuery {
if !permStat.Permission.CheckWrite() {
err = ErrPermissionDeny
log.WithError(err).Debugf("cannot write, permission: %d", permStat.Permission)
@@ -584,6 +585,75 @@ func (dbms *DBMS) checkPermission(addr proto.AccountAddress, req *types.Request)
return
}
+func (dbms *DBMS) addTxSubscription(dbID proto.DatabaseID, nodeID proto.NodeID, startHeight int32) (err error) {
+ // check permission
+ pubkey, err := kms.GetPublicKey(nodeID)
+ if err != nil {
+ log.WithFields(log.Fields{
+ "databaseID": dbID,
+ "nodeID": nodeID,
+ }).WithError(err).Warning("get pubkey failed in addTxSubscription")
+ return
+ }
+ addr, err := crypto.PubKeyHash(pubkey)
+ if err != nil {
+ log.WithFields(log.Fields{
+ "databaseID": dbID,
+ "nodeID": nodeID,
+ }).WithError(err).Warning("generate addr failed in addTxSubscription")
+ return
+ }
+ err = dbms.checkPermission(addr, dbID, types.ReadQuery)
+ if err != nil {
+ log.WithFields(log.Fields{"dbid": dbID, "addr": addr}).WithError(err).Warning("permission deny")
+ return
+ }
+
+ rawDB, ok := dbms.dbMap.Load(dbID)
+ if !ok {
+ err = ErrNotExists
+ log.WithFields(log.Fields{
+ "databaseID": dbID,
+ "nodeID": nodeID,
+ "startHeight": startHeight,
+ }).WithError(err).Warning("unexpected error in addTxSubscription")
+ return
+ }
+ db := rawDB.(*Database)
+ err = db.chain.AddSubscription(nodeID, startHeight)
+ if err != nil {
+ log.WithFields(log.Fields{
+ "databaseID": dbID,
+ "nodeID": nodeID,
+ "startHeight": startHeight,
+ }).WithError(err).Warning("unexpected error in addTxSubscription")
+ return
+ }
+ return
+}
+
+func (dbms *DBMS) cancelTxSubscription(dbID proto.DatabaseID, nodeID proto.NodeID) (err error) {
+ rawDB, ok := dbms.dbMap.Load(dbID)
+ if !ok {
+ err = ErrNotExists
+ log.WithFields(log.Fields{
+ "databaseID": dbID,
+ "nodeID": nodeID,
+ }).WithError(err).Warning("unexpected error in cancelTxSubscription")
+ return
+ }
+ db := rawDB.(*Database)
+ err = db.chain.CancelSubscription(nodeID)
+ if err != nil {
+ log.WithFields(log.Fields{
+ "databaseID": dbID,
+ "nodeID": nodeID,
+ }).WithError(err).Warning("unexpected error in cancelTxSubscription")
+ return
+ }
+ return
+}
+
// Shutdown defines dbms shutdown logic.
func (dbms *DBMS) Shutdown() (err error) {
dbms.dbMap.Range(func(_, rawDB interface{}) bool {
diff --git a/worker/dbms_rpc.go b/worker/dbms_rpc.go
index 040421961..86c5f26c1 100644
--- a/worker/dbms_rpc.go
+++ b/worker/dbms_rpc.go
@@ -17,6 +17,7 @@
package worker
import (
+ "github.com/CovenantSQL/CovenantSQL/proto"
//"context"
//"runtime/trace"
"github.com/CovenantSQL/CovenantSQL/route"
@@ -31,6 +32,26 @@ var (
dbQueryFailCounter metrics.Meter
)
+// SubscribeTransactionsReq defines a request of SubscribeTransaction RPC method.
+type SubscribeTransactionsReq struct {
+ DatabaseID proto.DatabaseID
+ SubscriberID proto.NodeID
+ Height int32
+}
+
+// SubscribeTransactionsResp defines a response of SubscribeTransaction RPC method.
+type SubscribeTransactionsResp struct {
+}
+
+// CancelSubscriptionReq defines a request of CancelSubscription RPC method.
+type CancelSubscriptionReq struct {
+ DatabaseID proto.DatabaseID
+ SubscriberID proto.NodeID
+}
+
+// CancelSubscriptionResp defines a response of CancelSubscription RPC method.
+type CancelSubscriptionResp struct{}
+
// DBMSRPCService is the rpc endpoint of database management.
type DBMSRPCService struct {
dbms *DBMS
@@ -130,3 +151,15 @@ func (rpc *DBMSRPCService) Deploy(req *types.UpdateService, _ *types.UpdateServi
return
}
+
+// SubscribeTransactions is the RPC method to fetch subscribe new packed and confirmed transactions from the target server.
+func (rpc *DBMSRPCService) SubscribeTransactions(req *SubscribeTransactionsReq, resp *SubscribeTransactionsResp) (err error) {
+ err = rpc.dbms.addTxSubscription(req.DatabaseID, req.SubscriberID, req.Height)
+ return
+}
+
+// CancelSubscription is the RPC method to cancel subscription in the target server.
+func (rpc *DBMSRPCService) CancelSubscription(req *CancelSubscriptionReq, _ *CancelSubscriptionResp) (err error) {
+ err = rpc.dbms.cancelTxSubscription(req.DatabaseID, req.SubscriberID)
+ return
+}
From 87a1b4a0c58711e05cbd014ba519b26ce6589b20 Mon Sep 17 00:00:00 2001
From: Qi Xiao
Date: Wed, 26 Dec 2018 20:15:55 +0800
Subject: [PATCH 204/278] Update client README to compatible with chain bus new
scheme
---
client/README.md | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/client/README.md b/client/README.md
index 394022647..f3e048bf8 100644
--- a/client/README.md
+++ b/client/README.md
@@ -51,8 +51,12 @@ client.Init(configFile, masterKey)
To create a new SQL Chain, the number of node should be provided:
```go
-var dsn string
-dsn, err = client.Create(client.ResourceMeta{Node: uint16(nodeCount)})
+var (
+ dsn string
+ meta client.ResourceMeta
+)
+meta.Node = uint16(nodeCount)
+dsn, err = client.Create(meta)
// process err
```
And you will get a dsn string. It represents a database instance, use it for queries.
From 55a704e357b854427b3d9df5bbd4bb0083fcb505 Mon Sep 17 00:00:00 2001
From: zeqing-guo
Date: Wed, 26 Dec 2018 21:03:41 +0800
Subject: [PATCH 205/278] Fix bug: loadOrStore do not store object when it has
stored the object
---
blockproducer/metastate.go | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/blockproducer/metastate.go b/blockproducer/metastate.go
index 8a74f63d7..a1feea837 100644
--- a/blockproducer/metastate.go
+++ b/blockproducer/metastate.go
@@ -605,7 +605,7 @@ func (s *metaState) updateProviderList(tx *types.ProvideService) (err error) {
GasPrice: tx.GasPrice,
NodeID: tx.NodeID,
}
- s.loadOrStoreProviderObject(sender, &pp)
+ s.dirty.provider[sender] = &pp
return
}
@@ -736,8 +736,8 @@ func (s *metaState) matchProvidersWithUser(tx *types.CreateDatabase) (err error)
err = errors.Wrapf(ErrDatabaseExists, "database exists: %s", string(*dbID))
return
}
- s.loadOrStoreAccountObject(dbAddr, &types.Account{Address: dbAddr})
- s.loadOrStoreSQLChainObject(*dbID, sp)
+ s.dirty.accounts[dbAddr] = &types.Account{Address: dbAddr}
+ s.dirty.databases[*dbID] = sp
for _, miner := range tx.ResourceMeta.TargetMiners {
s.deleteProviderObject(miner)
}
@@ -967,7 +967,7 @@ func (s *metaState) transferSQLChainTokenBalance(transfer *types.Transfer) (err
return err
}
}
- s.loadOrStoreSQLChainObject(transfer.Sender.DatabaseID(), sqlchain)
+ s.dirty.databases[transfer.Sender.DatabaseID()] = sqlchain
return
}
}
From 42e00c18d6c46b82b74b7c8d359802f802b6aaef Mon Sep 17 00:00:00 2001
From: leventeliu
Date: Wed, 26 Dec 2018 21:13:31 +0800
Subject: [PATCH 206/278] Update test config: add base accounts
---
test/observation/node_0/config.yaml | 13 +++++++++++++
test/observation/node_1/config.yaml | 13 +++++++++++++
test/observation/node_2/config.yaml | 13 +++++++++++++
3 files changed, 39 insertions(+)
diff --git a/test/observation/node_0/config.yaml b/test/observation/node_0/config.yaml
index a478926e9..267052898 100644
--- a/test/observation/node_0/config.yaml
+++ b/test/observation/node_0/config.yaml
@@ -37,6 +37,19 @@ BlockProducer:
MerkleRoot: 0000000000000000000000000000000000000000000000000000000000000001
ParentHash: 0000000000000000000000000000000000000000000000000000000000000001
Timestamp: 2018-08-13T21:59:59.12Z
+ BaseAccounts:
+ - Address: ba0ba731c7a76ccef2c1170f42038f7e228dfb474ef0190dfe35d9a37911ed37
+ StableCoinBalance: 1000000000
+ CovenantCoinBalance: 1000000000
+ - Address: 1a7b0959bbd0d0ec529278a61c0056c277bffe75b2646e1699b46b10a90210be
+ StableCoinBalance: 1000000000
+ CovenantCoinBalance: 1000000000
+ - Address: 9235bc4130a2ed4e6c35ea189dab35198ebb105640bedb97dd5269cc80863b16
+ StableCoinBalance: 1000000000
+ CovenantCoinBalance: 1000000000
+ - Address: 9e1618775cceeb19f110e04fbc6c5bca6c8e4e9b116e193a42fe69bf602e7bcd
+ StableCoinBalance: 1000000000
+ CovenantCoinBalance: 1000000000
KnownNodes:
- ID: 00000bef611d346c0cbe1beaa76e7f0ed705a194fdf9ac3a248ec70e9c198bf9
Nonce:
diff --git a/test/observation/node_1/config.yaml b/test/observation/node_1/config.yaml
index 70d5c2b78..5dd333848 100644
--- a/test/observation/node_1/config.yaml
+++ b/test/observation/node_1/config.yaml
@@ -37,6 +37,19 @@ BlockProducer:
MerkleRoot: 0000000000000000000000000000000000000000000000000000000000000001
ParentHash: 0000000000000000000000000000000000000000000000000000000000000001
Timestamp: 2018-08-13T21:59:59.12Z
+ BaseAccounts:
+ - Address: ba0ba731c7a76ccef2c1170f42038f7e228dfb474ef0190dfe35d9a37911ed37
+ StableCoinBalance: 1000000000
+ CovenantCoinBalance: 1000000000
+ - Address: 1a7b0959bbd0d0ec529278a61c0056c277bffe75b2646e1699b46b10a90210be
+ StableCoinBalance: 1000000000
+ CovenantCoinBalance: 1000000000
+ - Address: 9235bc4130a2ed4e6c35ea189dab35198ebb105640bedb97dd5269cc80863b16
+ StableCoinBalance: 1000000000
+ CovenantCoinBalance: 1000000000
+ - Address: 9e1618775cceeb19f110e04fbc6c5bca6c8e4e9b116e193a42fe69bf602e7bcd
+ StableCoinBalance: 1000000000
+ CovenantCoinBalance: 1000000000
KnownNodes:
- ID: 00000bef611d346c0cbe1beaa76e7f0ed705a194fdf9ac3a248ec70e9c198bf9
Nonce:
diff --git a/test/observation/node_2/config.yaml b/test/observation/node_2/config.yaml
index bd17c54d7..45420f804 100644
--- a/test/observation/node_2/config.yaml
+++ b/test/observation/node_2/config.yaml
@@ -37,6 +37,19 @@ BlockProducer:
MerkleRoot: 0000000000000000000000000000000000000000000000000000000000000001
ParentHash: 0000000000000000000000000000000000000000000000000000000000000001
Timestamp: 2018-08-13T21:59:59.12Z
+ BaseAccounts:
+ - Address: ba0ba731c7a76ccef2c1170f42038f7e228dfb474ef0190dfe35d9a37911ed37
+ StableCoinBalance: 1000000000
+ CovenantCoinBalance: 1000000000
+ - Address: 1a7b0959bbd0d0ec529278a61c0056c277bffe75b2646e1699b46b10a90210be
+ StableCoinBalance: 1000000000
+ CovenantCoinBalance: 1000000000
+ - Address: 9235bc4130a2ed4e6c35ea189dab35198ebb105640bedb97dd5269cc80863b16
+ StableCoinBalance: 1000000000
+ CovenantCoinBalance: 1000000000
+ - Address: 9e1618775cceeb19f110e04fbc6c5bca6c8e4e9b116e193a42fe69bf602e7bcd
+ StableCoinBalance: 1000000000
+ CovenantCoinBalance: 1000000000
KnownNodes:
- ID: 00000bef611d346c0cbe1beaa76e7f0ed705a194fdf9ac3a248ec70e9c198bf9
Nonce:
From 18f0b28302ce1e593c80e6ba50090d546bed6914 Mon Sep 17 00:00:00 2001
From: leventeliu
Date: Wed, 26 Dec 2018 21:14:13 +0800
Subject: [PATCH 207/278] Add detail log in worker/dbms
---
worker/dbms.go | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/worker/dbms.go b/worker/dbms.go
index c18a2b485..5e9932c28 100644
--- a/worker/dbms.go
+++ b/worker/dbms.go
@@ -237,15 +237,19 @@ func (dbms *DBMS) createDatabase(tx interfaces.Transaction, count uint32) {
return
}
- log.Debugf("create database with owner: %s, nonce: %d", cd.Owner.String(), cd.Nonce)
var (
dbid = proto.FromAccountAndNonce(cd.Owner, uint32(cd.Nonce))
isTargetMiner = false
)
+ log.WithFields(log.Fields{
+ "databaseid": *dbid,
+ "owner": cd.Owner.String(),
+ "nonce": cd.Nonce,
+ }).Debug("create database with owner")
p, ok := dbms.busService.RequestSQLProfile(dbid)
if !ok {
log.WithFields(log.Fields{
- "databaseid": &dbid,
+ "databaseid": *dbid,
}).Warning("database profile not found")
return
}
From ebf2a7ac24c70083e9776ea1854946d17bd9209a Mon Sep 17 00:00:00 2001
From: leventeliu
Date: Wed, 26 Dec 2018 21:14:31 +0800
Subject: [PATCH 208/278] Fix observer testing
---
cmd/cql-observer/observation_test.go | 46 ++++++++++++++++++++--------
1 file changed, 33 insertions(+), 13 deletions(-)
diff --git a/cmd/cql-observer/observation_test.go b/cmd/cql-observer/observation_test.go
index 4d7d0b4f0..3dc7d0519 100644
--- a/cmd/cql-observer/observation_test.go
+++ b/cmd/cql-observer/observation_test.go
@@ -34,7 +34,9 @@ import (
"testing"
"time"
+ bp "github.com/CovenantSQL/CovenantSQL/blockproducer"
"github.com/CovenantSQL/CovenantSQL/client"
+ "github.com/CovenantSQL/CovenantSQL/proto"
"github.com/CovenantSQL/CovenantSQL/types"
"github.com/CovenantSQL/CovenantSQL/utils"
"github.com/CovenantSQL/CovenantSQL/utils/log"
@@ -235,7 +237,14 @@ func TestFullProcess(t *testing.T) {
log.SetLevel(log.DebugLevel)
Convey("test full process", t, func() {
- var err error
+ var (
+ err error
+ dsn, dsn2 string
+ cfg, cfg2 *client.Config
+ dbid, dbid2 string
+ ctx, ctx2 context.Context
+ ccl, ccl2 context.CancelFunc
+ )
startNodes()
defer stopNodes()
@@ -247,11 +256,19 @@ func TestFullProcess(t *testing.T) {
// create
meta := client.ResourceMeta{}
meta.Node = 1
- dsn, err := client.Create(meta)
+ dsn, err = client.Create(meta)
So(err, ShouldBeNil)
-
log.Infof("the created database dsn is %v", dsn)
+ // wait
+ cfg, err = client.ParseDSN(dsn)
+ So(err, ShouldBeNil)
+ dbid = cfg.DatabaseID
+ ctx, ccl = context.WithTimeout(context.Background(), 30*time.Second)
+ defer ccl()
+ err = bp.WaitDatabaseCreation(ctx, proto.DatabaseID(dbid), 3*time.Second)
+ So(err, ShouldBeNil)
+
db, err := sql.Open("covenantsql", dsn)
So(err, ShouldBeNil)
@@ -308,17 +325,23 @@ func TestFullProcess(t *testing.T) {
// create
meta = client.ResourceMeta{}
meta.Node = 1
- dsn2, err := client.Create(meta)
+ dsn2, err = client.Create(meta)
So(err, ShouldBeNil)
log.Infof("the created database dsn is %v", dsn2)
- db2, err := sql.Open("covenantsql", dsn2)
+ // wait
+ cfg2, err = client.ParseDSN(dsn2)
+ So(err, ShouldBeNil)
+ dbid2 = cfg2.DatabaseID
+ So(dbID, ShouldNotResemble, dbid2)
+ ctx2, ccl2 = context.WithTimeout(context.Background(), 30*time.Second)
+ defer ccl2()
+ err = bp.WaitDatabaseCreation(ctx2, proto.DatabaseID(dbid2), 3*time.Second)
So(err, ShouldBeNil)
- cfg2, err := client.ParseDSN(dsn2)
- dbID2 := cfg2.DatabaseID
- So(dbID, ShouldNotResemble, dbID2)
+ db2, err := sql.Open("covenantsql", dsn2)
+ So(err, ShouldBeNil)
_, err = db2.Exec("CREATE TABLE test (test int)")
So(err, ShouldBeNil)
@@ -340,9 +363,6 @@ func TestFullProcess(t *testing.T) {
err = utils.WaitForPorts(context.Background(), "127.0.0.1", []int{4663}, time.Millisecond*200)
So(err, ShouldBeNil)
- cfg, err := client.ParseDSN(dsn)
- dbID := cfg.DatabaseID
-
// remove previous observation result
os.Remove(FJ(testWorkingDir, "./observation/node_observer/observer.db"))
@@ -432,12 +452,12 @@ func TestFullProcess(t *testing.T) {
So(ensureSuccess(res.String("request", "queries", "0", "pattern")), ShouldNotBeEmpty)
// test get genesis block by height
- res, err = getJSON("v3/height/%v/0", dbID2)
+ res, err = getJSON("v3/height/%v/0", dbid2)
So(err, ShouldNotBeNil)
log.Info(err, res)
// test get genesis block by height
- res, err = getJSON("v3/head/%v", dbID2)
+ res, err = getJSON("v3/head/%v", dbid2)
So(err, ShouldBeNil)
So(ensureSuccess(res.Interface("block")), ShouldNotBeNil)
So(ensureSuccess(res.Int("block", "height")), ShouldEqual, 0)
From 1438d3f98306581f1447e1aeaa664da3704e544a Mon Sep 17 00:00:00 2001
From: leventeliu
Date: Wed, 26 Dec 2018 22:13:25 +0800
Subject: [PATCH 209/278] Set resource meta for testing
---
cmd/cql-observer/observation_test.go | 42 ++++++++++++++++++++++++++--
1 file changed, 39 insertions(+), 3 deletions(-)
diff --git a/cmd/cql-observer/observation_test.go b/cmd/cql-observer/observation_test.go
index 3dc7d0519..846e46ebe 100644
--- a/cmd/cql-observer/observation_test.go
+++ b/cmd/cql-observer/observation_test.go
@@ -36,6 +36,9 @@ import (
bp "github.com/CovenantSQL/CovenantSQL/blockproducer"
"github.com/CovenantSQL/CovenantSQL/client"
+ "github.com/CovenantSQL/CovenantSQL/crypto"
+ "github.com/CovenantSQL/CovenantSQL/crypto/asymmetric"
+ "github.com/CovenantSQL/CovenantSQL/crypto/kms"
"github.com/CovenantSQL/CovenantSQL/proto"
"github.com/CovenantSQL/CovenantSQL/types"
"github.com/CovenantSQL/CovenantSQL/utils"
@@ -54,6 +57,17 @@ var nodeCmds []*utils.CMD
var FJ = filepath.Join
+func privKeyStoreToAccountAddr(path string, master []byte) (addr proto.AccountAddress, err error) {
+ var (
+ priv *asymmetric.PrivateKey
+ )
+ if priv, err = kms.LoadPrivateKey(path, master); err != nil {
+ return
+ }
+ addr, err = crypto.PubKeyHash(priv.PubKey())
+ return
+}
+
func startNodes() {
// wait for ports to be available
var err error
@@ -239,6 +253,7 @@ func TestFullProcess(t *testing.T) {
Convey("test full process", t, func() {
var (
err error
+ addr, addr2 proto.AccountAddress
dsn, dsn2 string
cfg, cfg2 *client.Config
dbid, dbid2 string
@@ -253,9 +268,23 @@ func TestFullProcess(t *testing.T) {
err = client.Init(FJ(testWorkingDir, "./observation/node_c/config.yaml"), []byte(""))
So(err, ShouldBeNil)
+ // get miner addresses
+ addr, err = privKeyStoreToAccountAddr(
+ FJ(testWorkingDir, "./observation/node_miner_0/private.key"), []byte{})
+ So(err, ShouldBeNil)
+ addr2, err = privKeyStoreToAccountAddr(
+ FJ(testWorkingDir, "./observation/node_miner_1/private.key"), []byte{})
+ So(err, ShouldBeNil)
+
// create
- meta := client.ResourceMeta{}
- meta.Node = 1
+ meta := client.ResourceMeta{
+ ResourceMeta: types.ResourceMeta{
+ TargetMiners: []proto.AccountAddress{addr},
+ Node: 1,
+ },
+ GasPrice: 0,
+ AdvancePayment: 10000000,
+ }
dsn, err = client.Create(meta)
So(err, ShouldBeNil)
log.Infof("the created database dsn is %v", dsn)
@@ -323,7 +352,14 @@ func TestFullProcess(t *testing.T) {
So(err, ShouldBeNil)
// create
- meta = client.ResourceMeta{}
+ meta = client.ResourceMeta{
+ ResourceMeta: types.ResourceMeta{
+ TargetMiners: []proto.AccountAddress{addr2},
+ Node: 1,
+ },
+ GasPrice: 0,
+ AdvancePayment: 10000000,
+ }
meta.Node = 1
dsn2, err = client.Create(meta)
So(err, ShouldBeNil)
From 67dd87340e7c6a5b3221a50b24e6889393d2c385 Mon Sep 17 00:00:00 2001
From: Qi Xiao
Date: Wed, 26 Dec 2018 22:18:28 +0800
Subject: [PATCH 210/278] Auto provide service on miner start
---
blockproducer/db_service.go | 563 ----------------------
blockproducer/db_service_map.go | 175 -------
blockproducer/db_service_map_test.go | 124 -----
blockproducer/db_service_test.go | 235 ---------
blockproducer/helper_test.go | 246 ----------
client/driver.go | 14 +-
client/helper_test.go | 97 +---
cmd/cql-minerd/integration_test.go | 78 +--
cmd/cql-minerd/main.go | 27 +-
cmd/cql-minerd/provide_service.go | 168 +++++++
cmd/cql-utils/rpc.go | 1 -
cmd/cqld/bootstrap.go | 38 --
metric/nodemetricmap.go | 142 ------
metric/nodemetricmap_test.go | 96 ----
metric/rpc.go | 152 ------
metric/rpc_test.go | 82 ----
route/acl.go | 27 +-
sqlchain/chain_test.go | 5 -
test/integration/node_miner_0/config.yaml | 2 +-
test/integration/node_miner_1/config.yaml | 2 +-
test/integration/node_miner_2/config.yaml | 2 +-
types/account.go | 6 +-
types/account_gen.go | 6 +-
types/init_service_type.go | 2 +-
types/init_service_type_gen.go | 43 +-
types/no_ack_report_type_gen.go | 21 +-
types/provideservice.go | 6 +-
types/provideservice_gen.go | 6 +-
types/request_type_gen.go | 23 +-
worker/db_test.go | 85 ----
30 files changed, 271 insertions(+), 2203 deletions(-)
delete mode 100644 blockproducer/db_service.go
delete mode 100644 blockproducer/db_service_map.go
delete mode 100644 blockproducer/db_service_map_test.go
delete mode 100644 blockproducer/db_service_test.go
delete mode 100644 blockproducer/helper_test.go
create mode 100644 cmd/cql-minerd/provide_service.go
delete mode 100644 metric/nodemetricmap.go
delete mode 100644 metric/nodemetricmap_test.go
delete mode 100644 metric/rpc.go
delete mode 100644 metric/rpc_test.go
diff --git a/blockproducer/db_service.go b/blockproducer/db_service.go
deleted file mode 100644
index 463d925c8..000000000
--- a/blockproducer/db_service.go
+++ /dev/null
@@ -1,563 +0,0 @@
-/*
- * Copyright 2018 The CovenantSQL Authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package blockproducer
-
-import (
- "sort"
- "sync"
- "time"
-
- "github.com/CovenantSQL/CovenantSQL/consistent"
- "github.com/CovenantSQL/CovenantSQL/crypto/asymmetric"
- "github.com/CovenantSQL/CovenantSQL/crypto/hash"
- "github.com/CovenantSQL/CovenantSQL/crypto/kms"
- "github.com/CovenantSQL/CovenantSQL/metric"
- "github.com/CovenantSQL/CovenantSQL/pow/cpuminer"
- "github.com/CovenantSQL/CovenantSQL/proto"
- "github.com/CovenantSQL/CovenantSQL/route"
- "github.com/CovenantSQL/CovenantSQL/rpc"
- "github.com/CovenantSQL/CovenantSQL/types"
- "github.com/CovenantSQL/CovenantSQL/utils/log"
- dto "github.com/prometheus/client_model/go"
-)
-
-const (
- // DefaultAllocationRounds defines max rounds to try allocate peers for database creation.
- DefaultAllocationRounds = 3
-)
-
-var (
- // MetricKeyFreeMemory enumerates possible free memory metric keys.
- MetricKeyFreeMemory = []string{
- "node_memory_free_bytes_total", // mac
- "node_memory_MemFree_bytes", // linux
- }
-)
-
-type allocatedNode struct {
- NodeID proto.NodeID
- MemoryMetric uint64
-}
-
-// DBService defines block producer database service rpc endpoint.
-type DBService struct {
- AllocationRounds int
- ServiceMap *DBServiceMap
- Consistent *consistent.Consistent
- NodeMetrics *metric.NodeMetricMap
-
- // include block producer nodes for database allocation, for test case injection
- includeBPNodesForAllocation bool
-}
-
-// CreateDatabase defines block producer create database logic.
-func (s *DBService) CreateDatabase(req *types.CreateDatabaseRequest, resp *types.CreateDatabaseResponse) (err error) {
- // verify signature
- if err = req.Verify(); err != nil {
- return
- }
-
- // TODO(xq262144): verify identity
- // verify identity
-
- defer func() {
- log.WithFields(log.Fields{
- "meta": req.Header.ResourceMeta,
- "node": req.GetNodeID().String(),
- }).WithError(err).Debug("create database")
- }()
-
- // create random DatabaseID
- var dbID proto.DatabaseID
- if dbID, err = s.generateDatabaseID(req.GetNodeID()); err != nil {
- return
- }
-
- log.WithField("db", dbID).Debug("generated database id")
-
- // allocate nodes
- var peers *proto.Peers
- if peers, err = s.allocateNodes(0, dbID, req.Header.ResourceMeta); err != nil {
- return
- }
-
- log.WithField("peers", peers).Debug("generated peers info")
-
- // TODO(lambda): call accounting features, top up deposit
- var genesisBlock *types.Block
- if genesisBlock, err = s.generateGenesisBlock(dbID, req.Header.ResourceMeta); err != nil {
- return
- }
-
- log.WithField("block", genesisBlock).Debug("generated genesis block")
-
- defer func() {
- if err != nil {
- // TODO(lambda): release deposit on error
- }
- }()
-
- // call miner nodes to provide service
- var privateKey *asymmetric.PrivateKey
- if privateKey, err = kms.GetLocalPrivateKey(); err != nil {
- return
- }
-
- initSvcReq := new(types.UpdateService)
- initSvcReq.Header.Op = types.CreateDB
- initSvcReq.Header.Instance = types.ServiceInstance{
- DatabaseID: dbID,
- Peers: peers,
- GenesisBlock: genesisBlock,
- }
- if err = initSvcReq.Sign(privateKey); err != nil {
- return
- }
-
- rollbackReq := new(types.UpdateService)
- rollbackReq.Header.Op = types.DropDB
- rollbackReq.Header.Instance = types.ServiceInstance{
- DatabaseID: dbID,
- }
- if err = rollbackReq.Sign(privateKey); err != nil {
- return
- }
-
- if err = s.batchSendSvcReq(initSvcReq, rollbackReq, peers.Servers); err != nil {
- return
- }
-
- // save to meta
- instanceMeta := types.ServiceInstance{
- DatabaseID: dbID,
- Peers: peers,
- ResourceMeta: req.Header.ResourceMeta,
- GenesisBlock: genesisBlock,
- }
-
- log.WithField("meta", instanceMeta).Debug("generated instance meta")
-
- if err = s.ServiceMap.Set(instanceMeta); err != nil {
- // critical error
- // TODO(xq262144): critical error recover
- return err
- }
-
- // send response to client
- resp.Header.InstanceMeta = instanceMeta
-
- // sign the response
- err = resp.Sign(privateKey)
-
- return
-}
-
-// DropDatabase defines block producer drop database logic.
-func (s *DBService) DropDatabase(req *types.DropDatabaseRequest, resp *types.DropDatabaseResponse) (err error) {
- // verify signature
- if err = req.Verify(); err != nil {
- return
- }
-
- // TODO(xq262144): verify identity
- // verify identity and database belonging
-
- defer func() {
- log.WithFields(log.Fields{
- "db": req.Header.DatabaseID,
- "node": req.GetNodeID().String(),
- }).Debug("drop database")
- }()
-
- // get database peers
- var instanceMeta types.ServiceInstance
- if instanceMeta, err = s.ServiceMap.Get(req.Header.DatabaseID); err != nil {
- return
- }
-
- // call miner nodes to drop database
- dropDBSvcReq := new(types.UpdateService)
- dropDBSvcReq.Header.Op = types.DropDB
- dropDBSvcReq.Header.Instance = types.ServiceInstance{
- DatabaseID: req.Header.DatabaseID,
- }
- if dropDBSvcReq.Header.Signee, err = kms.GetLocalPublicKey(); err != nil {
- return
- }
- var privateKey *asymmetric.PrivateKey
- if privateKey, err = kms.GetLocalPrivateKey(); err != nil {
- return
- }
- if dropDBSvcReq.Sign(privateKey); err != nil {
- return
- }
-
- if err = s.batchSendSvcReq(dropDBSvcReq, nil, instanceMeta.Peers.Servers); err != nil {
- return
- }
-
- // withdraw deposit from sqlchain
- // TODO(lambda): withdraw deposit and record drop database request
-
- // remove from meta
- if err = s.ServiceMap.Delete(req.Header.DatabaseID); err != nil {
- // critical error
- // TODO(xq262144): critical error recover
- return
- }
-
- // send response to client
- // nothing to set on response, only error flag
-
- return
-}
-
-// GetDatabase defines block producer get database logic.
-func (s *DBService) GetDatabase(req *types.GetDatabaseRequest, resp *types.GetDatabaseResponse) (err error) {
- // verify signature
- if err = req.Verify(); err != nil {
- return
- }
-
- // TODO(xq262144): verify identity
- // verify identity and database belonging
-
- defer func() {
- log.WithFields(log.Fields{
- "db": req.Header.DatabaseID,
- "node": req.GetNodeID().String(),
- }).Debug("get database")
- }()
-
- // fetch from meta
- var instanceMeta types.ServiceInstance
- if instanceMeta, err = s.ServiceMap.Get(req.Header.DatabaseID); err != nil {
- return
- }
-
- // send response to client
- resp.Header.InstanceMeta = instanceMeta
- if resp.Header.Signee, err = kms.GetLocalPublicKey(); err != nil {
- return
- }
-
- var privateKey *asymmetric.PrivateKey
- if privateKey, err = kms.GetLocalPrivateKey(); err != nil {
- return
- }
-
- // sign the response
- err = resp.Sign(privateKey)
-
- return
-}
-
-// GetNodeDatabases defines block producer get node databases logic.
-func (s *DBService) GetNodeDatabases(req *types.InitService, resp *types.InitServiceResponse) (err error) {
- // fetch from meta
- var instances []types.ServiceInstance
- if instances, err = s.ServiceMap.GetDatabases(req.GetNodeID().ToNodeID()); err != nil {
- return
- }
-
- log.WithFields(log.Fields{
- "node": req.GetNodeID().String(),
- "databases": instances,
- }).Debug("get node databases")
-
- // send response to client
- resp.Header.Instances = instances
- var privateKey *asymmetric.PrivateKey
- if privateKey, err = kms.GetLocalPrivateKey(); err != nil {
- return
- }
- err = resp.Sign(privateKey)
-
- return
-}
-
-func (s *DBService) generateDatabaseID(reqNodeID *proto.RawNodeID) (dbID proto.DatabaseID, err error) {
- var startNonce cpuminer.Uint256
-
- for {
- nonceCh := make(chan cpuminer.NonceInfo)
- quitCh := make(chan struct{})
- miner := cpuminer.NewCPUMiner(quitCh)
- go miner.ComputeBlockNonce(cpuminer.MiningBlock{
- Data: reqNodeID.CloneBytes(),
- NonceChan: nonceCh,
- Stop: nil,
- }, startNonce, 4)
-
- nonce := <-nonceCh
- close(quitCh)
- close(nonceCh)
-
- // set start nonceCh
- startNonce = nonce.Nonce
- startNonce.Inc()
- dbID = proto.DatabaseID(nonce.Hash.String())
-
- log.WithField("db", dbID).Debug("try generate database id")
-
- // check existence
- if _, err = s.ServiceMap.Get(dbID); err == ErrNoSuchDatabase {
- err = nil
- return
- }
- }
-}
-
-func (s *DBService) allocateNodes(lastTerm uint64, dbID proto.DatabaseID, resourceMeta types.ResourceMeta) (peers *proto.Peers, err error) {
- curRange := int(resourceMeta.Node)
- excludeNodes := make(map[proto.NodeID]bool)
- var allocated []allocatedNode
-
- defer func() {
- log.WithFields(log.Fields{
- "db": dbID,
- "meta": resourceMeta,
- "peers": peers,
- }).WithError(err).Debug("try allocated nodes")
- }()
-
- if resourceMeta.Node <= 0 {
- err = ErrDatabaseAllocation
- return
- }
-
- if !s.includeBPNodesForAllocation {
- // add block producer nodes to exclude node list
- for _, nodeID := range route.GetBPs() {
- excludeNodes[nodeID] = true
- }
- }
-
- for i := 0; i != s.AllocationRounds; i++ {
- log.WithField("round", i).Debug("try allocation node")
-
- var nodes []proto.Node
-
- // clear previous allocated
- allocated = allocated[:0]
- rolesFilter := []proto.ServerRole{
- proto.Miner,
- }
-
- if s.includeBPNodesForAllocation {
- rolesFilter = append(rolesFilter, proto.Leader, proto.Follower)
- }
-
- nodes, err = s.Consistent.GetNeighborsEx(string(dbID), curRange, proto.ServerRoles(rolesFilter))
-
- log.WithField("nodeCount", len(nodes)).Debug("found nodes to try dispatch")
-
- // TODO(xq262144): brute force implementation to be optimized
- var nodeIDs []proto.NodeID
-
- for _, node := range nodes {
- if _, ok := excludeNodes[node.ID]; !ok {
- nodeIDs = append(nodeIDs, node.ID)
- }
- }
-
- log.WithFields(log.Fields{
- "nodeCount": len(nodeIDs),
- "totalCount": len(nodes),
- "nodes": nodeIDs,
- }).Debug("found nodes to dispatch")
-
- if len(nodeIDs) < int(resourceMeta.Node) {
- continue
- }
-
- // check node resource status
- metrics := s.NodeMetrics.GetMetrics(nodeIDs)
-
- log.WithFields(log.Fields{
- "recordCount": len(metrics),
- "nodeCount": len(nodeIDs),
- }).Debug("found metric records to dispatch")
-
- for nodeID, nodeMetric := range metrics {
- log.WithField("node", nodeID).Debug("parse metric")
-
- var metricValue uint64
-
- // get metric
- if metricValue, err = s.getMetric(nodeMetric, MetricKeyFreeMemory); err != nil {
- log.WithField("node", nodeID).Debug("get memory metric failed")
-
- // add to excludes
- excludeNodes[nodeID] = true
- continue
- }
-
- // TODO(xq262144): left reserved resources check is required
- // TODO(xq262144): filesystem check to be implemented
-
- if resourceMeta.Memory < metricValue {
- // can allocate
- allocated = append(allocated, allocatedNode{
- NodeID: nodeID,
- MemoryMetric: metricValue,
- })
- } else {
- log.WithFields(log.Fields{
- "actual": metricValue,
- "expected": resourceMeta.Memory,
- "node": nodeID,
- }).Debug("node memory node meets requirement")
- excludeNodes[nodeID] = true
- }
- }
-
- if len(allocated) >= int(resourceMeta.Node) {
- // sort allocated node by metric
- sort.Slice(allocated, func(i, j int) bool {
- return allocated[i].MemoryMetric > allocated[j].MemoryMetric
- })
-
- allocated = allocated[:int(resourceMeta.Node)]
-
- // build plain allocated slice
- nodeAllocated := make([]proto.NodeID, 0, len(allocated))
-
- for _, node := range allocated {
- nodeAllocated = append(nodeAllocated, node.NodeID)
- }
-
- // build peers
- return s.buildPeers(lastTerm+1, nodeAllocated)
- }
-
- curRange += int(resourceMeta.Node)
- }
-
- // allocation failed
- err = ErrDatabaseAllocation
- return
-}
-
-func (s *DBService) getMetric(metric metric.MetricMap, keys []string) (value uint64, err error) {
- for _, key := range keys {
- var rawMetric *dto.MetricFamily
- var ok bool
-
- if rawMetric, ok = metric[key]; !ok || rawMetric == nil {
- continue
- }
-
- switch rawMetric.GetType() {
- case dto.MetricType_GAUGE:
- value = uint64(rawMetric.GetMetric()[0].GetGauge().GetValue())
- return
- case dto.MetricType_COUNTER:
- value = uint64(rawMetric.GetMetric()[0].GetCounter().GetValue())
- return
- }
- }
-
- err = ErrMetricNotCollected
-
- return
-}
-
-func (s *DBService) buildPeers(term uint64, allocated []proto.NodeID) (peers *proto.Peers, err error) {
- log.WithFields(log.Fields{
- "term": term,
- "nodes": allocated,
- }).Debug("build peers for term/nodes")
-
- // get local private key
- var privKey *asymmetric.PrivateKey
- if privKey, err = kms.GetLocalPrivateKey(); err != nil {
- return
- }
-
- // get allocated node info
- peers = &proto.Peers{
- PeersHeader: proto.PeersHeader{
- Term: term,
- Servers: allocated,
- },
- }
- // choose the first node as leader, allocateNodes sort the allocated node list by memory size
- peers.Leader = peers.Servers[0]
-
- // sign the peers structure
- err = peers.Sign(privKey)
-
- return
-}
-
-func (s *DBService) generateGenesisBlock(dbID proto.DatabaseID, resourceMeta types.ResourceMeta) (genesisBlock *types.Block, err error) {
- // TODO(xq262144): following is stub code, real logic should be implemented in the future
- emptyHash := hash.Hash{}
-
- var privKey *asymmetric.PrivateKey
- if privKey, err = kms.GetLocalPrivateKey(); err != nil {
- return
- }
- var nodeID proto.NodeID
- if nodeID, err = kms.GetLocalNodeID(); err != nil {
- return
- }
-
- genesisBlock = &types.Block{
- SignedHeader: types.SignedHeader{
- Header: types.Header{
- Version: 0x01000000,
- Producer: nodeID,
- GenesisHash: emptyHash,
- ParentHash: emptyHash,
- Timestamp: time.Now().UTC(),
- },
- },
- }
- err = genesisBlock.PackAndSignBlock(privKey)
-
- return
-}
-
-func (s *DBService) batchSendSvcReq(req *types.UpdateService, rollbackReq *types.UpdateService, nodes []proto.NodeID) (err error) {
- if err = s.batchSendSingleSvcReq(req, nodes); err != nil {
- s.batchSendSingleSvcReq(rollbackReq, nodes)
- }
-
- return
-}
-
-func (s *DBService) batchSendSingleSvcReq(req *types.UpdateService, nodes []proto.NodeID) (err error) {
- var wg sync.WaitGroup
- errCh := make(chan error, len(nodes))
-
- for _, node := range nodes {
- wg.Add(1)
- go func(s proto.NodeID, ec chan error) {
- defer wg.Done()
- var resp types.UpdateServiceResponse
- ec <- rpc.NewCaller().CallNode(s, route.DBSDeploy.String(), req, &resp)
- }(node, errCh)
- }
-
- wg.Wait()
- close(errCh)
- err = <-errCh
-
- return
-}
diff --git a/blockproducer/db_service_map.go b/blockproducer/db_service_map.go
deleted file mode 100644
index 1a56042a7..000000000
--- a/blockproducer/db_service_map.go
+++ /dev/null
@@ -1,175 +0,0 @@
-/*
- * Copyright 2018 The CovenantSQL Authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package blockproducer
-
-import (
- "sync"
-
- "github.com/CovenantSQL/CovenantSQL/proto"
- "github.com/CovenantSQL/CovenantSQL/types"
- "github.com/pkg/errors"
-)
-
-// DBMetaPersistence defines database meta persistence api.
-type DBMetaPersistence interface {
- GetDatabase(dbID proto.DatabaseID) (types.ServiceInstance, error)
- SetDatabase(meta types.ServiceInstance) error
- DeleteDatabase(dbID proto.DatabaseID) error
- GetAllDatabases() ([]types.ServiceInstance, error)
-}
-
-// DBServiceMap defines database instance meta.
-type DBServiceMap struct {
- dbMap map[proto.DatabaseID]types.ServiceInstance
- nodeMap map[proto.NodeID]map[proto.DatabaseID]bool
- persist DBMetaPersistence
- sync.RWMutex
-}
-
-// InitServiceMap init database service map.
-func InitServiceMap(persistImpl DBMetaPersistence) (s *DBServiceMap, err error) {
- s = &DBServiceMap{
- persist: persistImpl,
- dbMap: make(map[proto.DatabaseID]types.ServiceInstance),
- nodeMap: make(map[proto.NodeID]map[proto.DatabaseID]bool),
- }
-
- // load from persistence
- s.Lock()
- defer s.Unlock()
-
- var allDatabases []types.ServiceInstance
-
- if allDatabases, err = s.persist.GetAllDatabases(); err != nil {
- return
- }
-
- for _, meta := range allDatabases {
- s.dbMap[meta.DatabaseID] = meta
-
- for _, server := range meta.Peers.Servers {
- if s.nodeMap[server] == nil {
- s.nodeMap[server] = make(map[proto.DatabaseID]bool)
- }
- s.nodeMap[server][meta.DatabaseID] = true
- }
- }
-
- return
-}
-
-// Set add database to meta.
-func (c *DBServiceMap) Set(meta types.ServiceInstance) (err error) {
- c.Lock()
- defer c.Unlock()
-
- if err = meta.Peers.Verify(); err != nil {
- return errors.Wrap(err, "verify peers failed")
- }
-
- // remove previous records
- var oldMeta types.ServiceInstance
- var ok bool
-
- if oldMeta, ok = c.dbMap[meta.DatabaseID]; ok {
- for _, s := range oldMeta.Peers.Servers {
- if c.nodeMap[s] != nil {
- delete(c.nodeMap[s], meta.DatabaseID)
- }
- }
- }
-
- // set new records
- c.dbMap[meta.DatabaseID] = meta
-
- for _, s := range meta.Peers.Servers {
- if c.nodeMap[s] == nil {
- c.nodeMap[s] = make(map[proto.DatabaseID]bool)
- }
- c.nodeMap[s][meta.DatabaseID] = true
- }
-
- // set to persistence
- err = c.persist.SetDatabase(meta)
-
- return
-}
-
-// Get find database from meta.
-func (c *DBServiceMap) Get(dbID proto.DatabaseID) (meta types.ServiceInstance, err error) {
- c.RLock()
- defer c.RUnlock()
-
- var ok bool
-
- // get from cache
- if meta, ok = c.dbMap[dbID]; ok {
- return
- }
-
- // get from persistence
- if meta, err = c.persist.GetDatabase(dbID); err == nil {
- // set from persistence
- c.dbMap[dbID] = meta
- }
-
- return
-}
-
-// Delete removes database from meta.
-func (c *DBServiceMap) Delete(dbID proto.DatabaseID) (err error) {
- c.Lock()
- defer c.Unlock()
-
- var meta types.ServiceInstance
- var ok bool
-
- // delete from cache
- if meta, ok = c.dbMap[dbID]; ok {
- for _, s := range meta.Peers.Servers {
- if c.nodeMap[s] != nil {
- delete(c.nodeMap[s], dbID)
- }
- }
- }
-
- delete(c.dbMap, dbID)
-
- // delete from persistence
- err = c.persist.DeleteDatabase(dbID)
-
- return
-}
-
-// GetDatabases return database config.
-func (c *DBServiceMap) GetDatabases(nodeID proto.NodeID) (dbs []types.ServiceInstance, err error) {
- c.RLock()
- defer c.RUnlock()
-
- dbs = make([]types.ServiceInstance, 0)
-
- for dbID, ok := range c.nodeMap[nodeID] {
- if ok {
- var db types.ServiceInstance
- if db, ok = c.dbMap[dbID]; ok {
- dbs = append(dbs, db)
- }
- }
- }
-
- return
-}
diff --git a/blockproducer/db_service_map_test.go b/blockproducer/db_service_map_test.go
deleted file mode 100644
index b5fe441e9..000000000
--- a/blockproducer/db_service_map_test.go
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * Copyright 2018 The CovenantSQL Authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package blockproducer
-
-import (
- "os"
- "sync"
- "testing"
-
- "github.com/CovenantSQL/CovenantSQL/conf"
- "github.com/CovenantSQL/CovenantSQL/crypto/asymmetric"
- "github.com/CovenantSQL/CovenantSQL/crypto/kms"
- "github.com/CovenantSQL/CovenantSQL/proto"
- "github.com/CovenantSQL/CovenantSQL/route"
- "github.com/CovenantSQL/CovenantSQL/types"
- . "github.com/smartystreets/goconvey/convey"
-)
-
-func TestServiceMap(t *testing.T) {
- Convey("test service map", t, func() {
- // load test config
- var err error
- conf.GConf, err = conf.LoadConfig("../test/node_standalone/config.yaml")
- So(err, ShouldBeNil)
-
- privKeyFile := "../test/node_standalone/private.key"
- pubKeyFile := "../test/node_standalone/public.keystore"
- os.Remove(pubKeyFile)
- defer os.Remove(pubKeyFile)
- route.Once = sync.Once{}
- route.InitKMS(pubKeyFile)
- err = kms.InitLocalKeyPair(privKeyFile, []byte(""))
- So(err, ShouldBeNil)
-
- stubPersistence := &stubDBMetaPersistence{}
- var svcMap *DBServiceMap
- var nodeID proto.NodeID
-
- // get local node id for test
- nodeID, err = kms.GetLocalNodeID()
- So(err, ShouldBeNil)
-
- svcMap, err = InitServiceMap(stubPersistence)
- So(err, ShouldBeNil)
-
- So(svcMap.dbMap, ShouldContainKey, proto.DatabaseID("db"))
- So(svcMap.nodeMap, ShouldContainKey, nodeID)
- So(svcMap.nodeMap[nodeID], ShouldContainKey, proto.DatabaseID("db"))
-
- // test get non-exists
- _, err = svcMap.Get(proto.DatabaseID("not_exists_db"))
- So(err, ShouldNotBeNil)
-
- // test get exists
- var instance types.ServiceInstance
- instance, err = svcMap.Get(proto.DatabaseID("db"))
- So(instance.DatabaseID, ShouldResemble, proto.DatabaseID("db"))
-
- // test get in persist not in cache
- instance, err = svcMap.Get(proto.DatabaseID("db2"))
- So(instance.DatabaseID, ShouldResemble, proto.DatabaseID("db2"))
-
- // test set
- So(svcMap.dbMap, ShouldNotContainKey, proto.DatabaseID("db3"))
- instance.DatabaseID = proto.DatabaseID("db3")
- err = svcMap.Set(instance)
- So(err, ShouldBeNil)
- So(svcMap.dbMap, ShouldContainKey, proto.DatabaseID("db3"))
- instance, err = svcMap.Get(proto.DatabaseID("db3"))
- So(instance.DatabaseID, ShouldResemble, proto.DatabaseID("db3"))
-
- // test set existing
- err = svcMap.Set(instance)
- So(err, ShouldBeNil)
- So(svcMap.dbMap, ShouldContainKey, proto.DatabaseID("db3"))
- So(svcMap.nodeMap, ShouldContainKey, nodeID)
- So(svcMap.nodeMap[nodeID], ShouldContainKey, proto.DatabaseID("db3"))
-
- // test set invalid peers
- instance.Peers.Term = 2
- err = svcMap.Set(instance)
- So(err, ShouldNotBeNil)
-
- // test set with extra nodes
- var privKey *asymmetric.PrivateKey
- privKey, err = kms.GetLocalPrivateKey()
- So(err, ShouldBeNil)
- instance.Peers.Servers = append(instance.Peers.Servers, instance.Peers.Servers[0])
- // something new
- instance.Peers.Servers[1] = proto.NodeID("00000381d46fd6cf7742d7fb94e2422033af989c0e348b5781b3219599a3af35")
- err = instance.Peers.Sign(privKey)
- So(err, ShouldBeNil)
- err = svcMap.Set(instance)
- So(err, ShouldBeNil)
-
- // test delete
- err = svcMap.Delete(proto.DatabaseID("db3"))
- So(err, ShouldBeNil)
- So(svcMap.dbMap, ShouldNotContainKey, proto.DatabaseID("db3"))
- err = svcMap.Delete(proto.DatabaseID("db2"))
- So(err, ShouldBeNil)
- So(svcMap.dbMap, ShouldNotContainKey, proto.DatabaseID("db2"))
-
- // test get databases
- var instances []types.ServiceInstance
- instances, err = svcMap.GetDatabases(nodeID)
- So(instances, ShouldHaveLength, 1)
- So(instances[0].DatabaseID, ShouldResemble, proto.DatabaseID("db"))
- })
-}
diff --git a/blockproducer/db_service_test.go b/blockproducer/db_service_test.go
deleted file mode 100644
index fb1ca6b84..000000000
--- a/blockproducer/db_service_test.go
+++ /dev/null
@@ -1,235 +0,0 @@
-/*
- * Copyright 2018 The CovenantSQL Authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package blockproducer
-
-import (
- "testing"
- "time"
-
- "github.com/CovenantSQL/CovenantSQL/crypto"
- "github.com/CovenantSQL/CovenantSQL/crypto/asymmetric"
- "github.com/CovenantSQL/CovenantSQL/crypto/kms"
- "github.com/CovenantSQL/CovenantSQL/metric"
- "github.com/CovenantSQL/CovenantSQL/proto"
- "github.com/CovenantSQL/CovenantSQL/route"
- "github.com/CovenantSQL/CovenantSQL/rpc"
- "github.com/CovenantSQL/CovenantSQL/types"
- "github.com/CovenantSQL/CovenantSQL/worker"
- . "github.com/smartystreets/goconvey/convey"
-)
-
-func TestService(t *testing.T) {
- Convey("test db service", t, func() {
- // init node
- var (
- cleanup func()
- dht *route.DHTService
- metricService *metric.CollectServer
- server *rpc.Server
- dbms *worker.DBMS
- err error
- )
-
- cleanup, dht, metricService, server, dbms, err = initNode(
- "../test/node_standalone/config.yaml",
- "../test/node_standalone/private.key",
- )
- defer cleanup()
-
- // get keys
- var privateKey *asymmetric.PrivateKey
- privateKey, err = kms.GetLocalPrivateKey()
- So(err, ShouldBeNil)
-
- // create service
- stubPersistence := &stubDBMetaPersistence{}
- svcMap, err := InitServiceMap(stubPersistence)
- So(err, ShouldBeNil)
- dbService := &DBService{
- AllocationRounds: DefaultAllocationRounds,
- ServiceMap: svcMap,
- Consistent: dht.Consistent,
- NodeMetrics: &metricService.NodeMetric,
- }
-
- // register BPDB service to rpc
- err = server.RegisterService(route.BPDBRPCName, dbService)
- So(err, ShouldBeNil)
-
- // get database
- var nodeID proto.NodeID
- nodeID, err = kms.GetLocalNodeID()
- So(err, ShouldBeNil)
-
- // test get database
- getReq := new(types.GetDatabaseRequest)
- getReq.Header.DatabaseID = proto.DatabaseID("db")
- err = getReq.Sign(privateKey)
- So(err, ShouldBeNil)
-
- getRes := new(types.GetDatabaseResponse)
- err = rpc.NewCaller().CallNode(nodeID, route.BPDBGetDatabase.String(), getReq, getRes)
- So(err, ShouldBeNil)
- So(getReq.Verify(), ShouldBeNil)
- So(getRes.Header.InstanceMeta.DatabaseID, ShouldResemble, proto.DatabaseID("db"))
-
- // get node databases
- getAllReq := new(types.InitService)
- getAllRes := new(types.InitServiceResponse)
- err = rpc.NewCaller().CallNode(nodeID, route.BPDBGetNodeDatabases.String(), getAllReq, getAllRes)
- So(err, ShouldBeNil)
- So(getAllRes.Verify(), ShouldBeNil)
- So(getAllRes.Header.Instances, ShouldHaveLength, 1)
- So(getAllRes.Header.Instances[0].DatabaseID, ShouldResemble, proto.DatabaseID("db"))
-
- // create database, no metric received, should failed
- createDBReq := new(types.CreateDatabaseRequest)
- createDBReq.Header.ResourceMeta = types.ResourceMeta{
- Node: 1,
- }
- err = createDBReq.Sign(privateKey)
- So(err, ShouldBeNil)
- createDBRes := new(types.CreateDatabaseResponse)
- err = rpc.NewCaller().CallNode(nodeID, route.BPDBCreateDatabase.String(), createDBReq, createDBRes)
- So(err, ShouldNotBeNil)
-
- // trigger metrics, but does not allow block producer to service as miner
- metric.NewCollectClient().UploadMetrics(nodeID)
- createDBRes = new(types.CreateDatabaseResponse)
- err = rpc.NewCaller().CallNode(nodeID, route.BPDBCreateDatabase.String(), createDBReq, createDBRes)
- So(err, ShouldNotBeNil)
-
- // allow block producer to service as miner, only use this in test case
- dbService.includeBPNodesForAllocation = true
- createDBRes = new(types.CreateDatabaseResponse)
- err = rpc.NewCaller().CallNode(nodeID, route.BPDBCreateDatabase.String(), createDBReq, createDBRes)
- So(err, ShouldBeNil)
- So(createDBRes.Verify(), ShouldBeNil)
- So(createDBRes.Header.InstanceMeta.DatabaseID, ShouldNotBeEmpty)
-
- // get all databases, this new database should exists
- err = rpc.NewCaller().CallNode(nodeID, route.BPDBGetNodeDatabases.String(), getAllReq, getAllRes)
- So(err, ShouldBeNil)
- So(getAllRes.Verify(), ShouldBeNil)
- So(getAllRes.Header.Instances, ShouldHaveLength, 2)
- So(getAllRes.Header.Instances[0].DatabaseID, ShouldBeIn, []proto.DatabaseID{
- proto.DatabaseID("db"),
- createDBRes.Header.InstanceMeta.DatabaseID,
- })
- So(getAllRes.Header.Instances[1].DatabaseID, ShouldBeIn, []proto.DatabaseID{
- proto.DatabaseID("db"),
- createDBRes.Header.InstanceMeta.DatabaseID,
- })
-
- // update private key permission in dbms for query
- addr, err := crypto.PubKeyHash(privateKey.PubKey())
- So(err, ShouldBeNil)
- permStat := &types.PermStat{
- Permission: types.Admin,
- Status: types.Normal,
- }
- err = dbms.UpdatePermission(createDBRes.Header.InstanceMeta.DatabaseID, proto.AccountAddress(addr), permStat)
- So(err, ShouldBeNil)
-
- // use the database
- serverID := createDBRes.Header.InstanceMeta.Peers.Leader
- dbID := createDBRes.Header.InstanceMeta.DatabaseID
- var queryReq *types.Request
- queryReq, err = buildQuery(types.WriteQuery, 1, 1, dbID, []string{
- "create table test (test int)",
- "insert into test values(1)",
- })
- So(err, ShouldBeNil)
- queryRes := new(types.Response)
- err = rpc.NewCaller().CallNode(serverID, route.DBSQuery.String(), queryReq, queryRes)
- So(err, ShouldBeNil)
- queryReq, err = buildQuery(types.ReadQuery, 1, 2, dbID, []string{
- "select * from test",
- })
- So(err, ShouldBeNil)
- err = rpc.NewCaller().CallNode(serverID, route.DBSQuery.String(), queryReq, queryRes)
- So(err, ShouldBeNil)
- err = queryRes.Verify()
- So(err, ShouldBeNil)
- So(queryRes.Header.RowCount, ShouldEqual, uint64(1))
- So(queryRes.Payload.Columns, ShouldResemble, []string{"test"})
- So(queryRes.Payload.DeclTypes, ShouldResemble, []string{"int"})
- So(queryRes.Payload.Rows, ShouldNotBeEmpty)
- So(queryRes.Payload.Rows[0].Values, ShouldNotBeEmpty)
- So(queryRes.Payload.Rows[0].Values[0], ShouldEqual, 1)
-
- // drop database
- dropDBReq := new(types.DropDatabaseRequest)
- dropDBReq.Header.DatabaseID = createDBRes.Header.InstanceMeta.DatabaseID
- err = dropDBReq.Sign(privateKey)
- So(err, ShouldBeNil)
- dropDBRes := new(types.DropDatabaseResponse)
- err = rpc.NewCaller().CallNode(nodeID, route.BPDBDropDatabase.String(), dropDBReq, dropDBRes)
- So(err, ShouldBeNil)
-
- // get this database again to test if it is dropped
- getReq = new(types.GetDatabaseRequest)
- getReq.Header.DatabaseID = createDBRes.Header.InstanceMeta.DatabaseID
- err = getReq.Sign(privateKey)
- So(err, ShouldBeNil)
- err = rpc.NewCaller().CallNode(nodeID, route.BPDBGetDatabase.String(), getReq, getRes)
- So(err, ShouldNotBeNil)
- })
-}
-
-func buildQuery(queryType types.QueryType, connID uint64, seqNo uint64, databaseID proto.DatabaseID, queries []string) (query *types.Request, err error) {
- // get node id
- var nodeID proto.NodeID
- if nodeID, err = kms.GetLocalNodeID(); err != nil {
- return
- }
-
- // get private key
- var privateKey *asymmetric.PrivateKey
- if privateKey, err = kms.GetLocalPrivateKey(); err != nil {
- return
- }
-
- tm := time.Now().UTC()
-
- // build queries
- realQueries := make([]types.Query, len(queries))
-
- for i, v := range queries {
- realQueries[i].Pattern = v
- }
-
- query = &types.Request{
- Header: types.SignedRequestHeader{
- RequestHeader: types.RequestHeader{
- DatabaseID: databaseID,
- QueryType: queryType,
- NodeID: nodeID,
- ConnectionID: connID,
- SeqNo: seqNo,
- Timestamp: tm,
- },
- },
- Payload: types.RequestPayload{
- Queries: realQueries,
- },
- }
-
- err = query.Sign(privateKey)
-
- return
-}
diff --git a/blockproducer/helper_test.go b/blockproducer/helper_test.go
deleted file mode 100644
index 69456e817..000000000
--- a/blockproducer/helper_test.go
+++ /dev/null
@@ -1,246 +0,0 @@
-/*
- * Copyright 2018 The CovenantSQL Authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package blockproducer
-
-import (
- "bytes"
- "fmt"
- "io/ioutil"
- "math/rand"
- "os"
- "path/filepath"
- "runtime"
- "strings"
- "sync"
- "time"
-
- "github.com/CovenantSQL/CovenantSQL/conf"
- "github.com/CovenantSQL/CovenantSQL/consistent"
- "github.com/CovenantSQL/CovenantSQL/crypto/asymmetric"
- "github.com/CovenantSQL/CovenantSQL/crypto/hash"
- "github.com/CovenantSQL/CovenantSQL/crypto/kms"
- "github.com/CovenantSQL/CovenantSQL/metric"
- "github.com/CovenantSQL/CovenantSQL/pow/cpuminer"
- "github.com/CovenantSQL/CovenantSQL/proto"
- "github.com/CovenantSQL/CovenantSQL/route"
- "github.com/CovenantSQL/CovenantSQL/rpc"
- "github.com/CovenantSQL/CovenantSQL/types"
- "github.com/CovenantSQL/CovenantSQL/utils"
- "github.com/CovenantSQL/CovenantSQL/utils/log"
- "github.com/CovenantSQL/CovenantSQL/worker"
-)
-
-const (
- PubKeyStorePath = "./pubkey.store"
-)
-
-var (
- rootHash = hash.Hash{}
-)
-
-// copied from sqlchain.xxx_test.
-func createRandomBlock(parent hash.Hash, isGenesis bool) (b *types.Block, err error) {
- // Generate key pair
- priv, pub, err := asymmetric.GenSecp256k1KeyPair()
-
- if err != nil {
- return
- }
-
- h := hash.Hash{}
- rand.Read(h[:])
-
- b = &types.Block{
- SignedHeader: types.SignedHeader{
- Header: types.Header{
- Version: 0x01000000,
- Producer: proto.NodeID(h.String()),
- GenesisHash: rootHash,
- ParentHash: parent,
- Timestamp: time.Now().UTC(),
- },
- },
- }
-
- if isGenesis {
- // Compute nonce with public key
- nonceCh := make(chan cpuminer.NonceInfo)
- quitCh := make(chan struct{})
- miner := cpuminer.NewCPUMiner(quitCh)
- go miner.ComputeBlockNonce(cpuminer.MiningBlock{
- Data: pub.Serialize(),
- NonceChan: nonceCh,
- Stop: nil,
- }, cpuminer.Uint256{A: 0, B: 0, C: 0, D: 0}, 4)
- nonce := <-nonceCh
- close(quitCh)
- close(nonceCh)
- // Add public key to KMS
- id := cpuminer.HashBlock(pub.Serialize(), nonce.Nonce)
- b.SignedHeader.Header.Producer = proto.NodeID(id.String())
- err = kms.SetPublicKey(proto.NodeID(id.String()), nonce.Nonce, pub)
-
- if err != nil {
- return nil, err
- }
- }
-
- err = b.PackAndSignBlock(priv)
- return
-}
-
-// fake a persistence driver.
-type stubDBMetaPersistence struct{}
-
-func (p *stubDBMetaPersistence) GetDatabase(dbID proto.DatabaseID) (instance types.ServiceInstance, err error) {
- // for test purpose, name with db prefix consider it exists
- if !strings.HasPrefix(string(dbID), "db") {
- err = ErrNoSuchDatabase
- return
- }
-
- return p.getInstanceMeta(dbID)
-}
-
-func (p *stubDBMetaPersistence) SetDatabase(meta types.ServiceInstance) (err error) {
- return
-}
-
-func (p *stubDBMetaPersistence) DeleteDatabase(dbID proto.DatabaseID) (err error) {
- return
-}
-
-func (p *stubDBMetaPersistence) GetAllDatabases() (instances []types.ServiceInstance, err error) {
- instances = make([]types.ServiceInstance, 1)
- instances[0], err = p.getInstanceMeta("db")
- return
-}
-
-func (p *stubDBMetaPersistence) getInstanceMeta(dbID proto.DatabaseID) (instance types.ServiceInstance, err error) {
- var privKey *asymmetric.PrivateKey
- if privKey, err = kms.GetLocalPrivateKey(); err != nil {
- return
- }
-
- var nodeID proto.NodeID
- if nodeID, err = kms.GetLocalNodeID(); err != nil {
- return
- }
-
- instance.DatabaseID = proto.DatabaseID(dbID)
- instance.Peers = &proto.Peers{
- PeersHeader: proto.PeersHeader{
- Term: 1,
- Leader: nodeID,
- Servers: []proto.NodeID{nodeID},
- },
- }
- if err = instance.Peers.Sign(privKey); err != nil {
- return
- }
- instance.GenesisBlock, err = createRandomBlock(rootHash, true)
-
- return
-}
-
-func initNode(confRP, privateKeyRP string) (cleanupFunc func(), dht *route.DHTService, metricService *metric.CollectServer, server *rpc.Server, dbms *worker.DBMS, err error) {
- var d string
- if d, err = ioutil.TempDir("", "db_test_"); err != nil {
- return
- }
- log.WithField("d", d).Debug("created temp dir")
-
- // init conf
- _, testFile, _, _ := runtime.Caller(0)
- pubKeyStoreFile := filepath.Join(d, PubKeyStorePath)
- os.Remove(pubKeyStoreFile)
- clientPubKeyStoreFile := filepath.Join(d, PubKeyStorePath+"_c")
- os.Remove(clientPubKeyStoreFile)
- dupConfFile := filepath.Join(d, "config.yaml")
- confFile := filepath.Join(filepath.Dir(testFile), confRP)
- if err = dupConf(confFile, dupConfFile); err != nil {
- return
- }
- privateKeyPath := filepath.Join(filepath.Dir(testFile), privateKeyRP)
-
- conf.GConf, _ = conf.LoadConfig(dupConfFile)
- log.Debugf("GConf: %#v", conf.GConf)
- // reset the once
- route.Once = sync.Once{}
- route.InitKMS(clientPubKeyStoreFile)
-
- // init dht
- dht, err = route.NewDHTService(pubKeyStoreFile, new(consistent.KMSStorage), true)
- if err != nil {
- return
- }
-
- // init rpc
- if server, err = rpc.NewServerWithService(rpc.ServiceMap{route.DHTRPCName: dht}); err != nil {
- return
- }
-
- // register metric service
- metricService = metric.NewCollectServer()
- if err = server.RegisterService(metric.MetricServiceName, metricService); err != nil {
- log.WithError(err).Error("init metric service failed")
- return
- }
-
- // register database service
- dbms, err = worker.NewDBMS(&worker.DBMSConfig{
- RootDir: d,
- Server: server,
- MaxReqTimeGap: worker.DefaultMaxReqTimeGap,
- })
-
- // init private key
- masterKey := []byte("")
- if err = server.InitRPCServer(conf.GConf.ListenAddr, privateKeyPath, masterKey); err != nil {
- return
- }
-
- // start server
- go server.Serve()
-
- cleanupFunc = func() {
- os.RemoveAll(d)
- server.Listener.Close()
- server.Stop()
- rpc.GetSessionPoolInstance().Close()
- }
-
- return
-}
-
-// duplicate conf file using random new listen addr to avoid failure on concurrent test cases.
-func dupConf(confFile string, newConfFile string) (err error) {
- // replace port in confFile
- var fileBytes []byte
- if fileBytes, err = ioutil.ReadFile(confFile); err != nil {
- return
- }
-
- var ports []int
- if ports, err = utils.GetRandomPorts("127.0.0.1", 3000, 4000, 1); err != nil {
- return
- }
-
- newConfBytes := bytes.Replace(fileBytes, []byte(":2230"), []byte(fmt.Sprintf(":%v", ports[0])), -1)
-
- return ioutil.WriteFile(newConfFile, newConfBytes, 0644)
-}
diff --git a/client/driver.go b/client/driver.go
index a7d09a2fc..d6e6571c4 100644
--- a/client/driver.go
+++ b/client/driver.go
@@ -199,17 +199,9 @@ func Drop(dsn string) (err error) {
return
}
- req := new(types.DropDatabaseRequest)
- req.Header.DatabaseID = proto.DatabaseID(cfg.DatabaseID)
- var privateKey *asymmetric.PrivateKey
- if privateKey, err = kms.GetLocalPrivateKey(); err != nil {
- return
- }
- if err = req.Sign(privateKey); err != nil {
- return
- }
- res := new(types.DropDatabaseResponse)
- err = requestBP(route.BPDBDropDatabase, req, res)
+ _ = cfg
+
+ // currently not supported
return
}
diff --git a/client/helper_test.go b/client/helper_test.go
index b803c8e22..66296969c 100644
--- a/client/helper_test.go
+++ b/client/helper_test.go
@@ -54,99 +54,19 @@ var (
)
// fake BPDB service
-type stubBPDBService struct{}
+type stubBPService struct{}
-func (s *stubBPDBService) CreateDatabase(req *types.CreateDatabaseRequest, resp *types.CreateDatabaseResponse) (err error) {
- if resp.Header.InstanceMeta, err = s.getInstanceMeta(proto.DatabaseID("db")); err != nil {
- return
- }
- if resp.Header.Signee, err = kms.GetLocalPublicKey(); err != nil {
- return
- }
- var privateKey *asymmetric.PrivateKey
- if privateKey, err = kms.GetLocalPrivateKey(); err != nil {
- return
- }
-
- err = resp.Sign(privateKey)
-
- return
-}
-
-func (s *stubBPDBService) DropDatabase(req *types.DropDatabaseRequest, resp *types.DropDatabaseRequest) (err error) {
- return
-}
-
-func (s *stubBPDBService) GetDatabase(req *types.GetDatabaseRequest, resp *types.GetDatabaseResponse) (err error) {
- if resp.Header.InstanceMeta, err = s.getInstanceMeta(req.Header.DatabaseID); err != nil {
- return
- }
- if resp.Header.Signee, err = kms.GetLocalPublicKey(); err != nil {
- return
- }
- var privateKey *asymmetric.PrivateKey
- if privateKey, err = kms.GetLocalPrivateKey(); err != nil {
- return
- }
-
- err = resp.Sign(privateKey)
-
- return
-}
-
-func (s *stubBPDBService) GetNodeDatabases(req *types.InitService, resp *types.InitServiceResponse) (err error) {
- resp.Header.Instances = make([]types.ServiceInstance, 0)
- if resp.Header.Signee, err = kms.GetLocalPublicKey(); err != nil {
- return
- }
- var privateKey *asymmetric.PrivateKey
- if privateKey, err = kms.GetLocalPrivateKey(); err != nil {
- return
- }
- if resp.Sign(privateKey); err != nil {
- return
- }
- return
-}
-
-func (s *stubBPDBService) getInstanceMeta(dbID proto.DatabaseID) (instance types.ServiceInstance, err error) {
- var privKey *asymmetric.PrivateKey
- if privKey, err = kms.GetLocalPrivateKey(); err != nil {
- return
- }
-
- var nodeID proto.NodeID
- if nodeID, err = kms.GetLocalNodeID(); err != nil {
- return
- }
-
- instance.DatabaseID = proto.DatabaseID(dbID)
- instance.Peers = &proto.Peers{
- PeersHeader: proto.PeersHeader{
- Term: 1,
- Leader: nodeID,
- Servers: []proto.NodeID{nodeID},
- },
- }
- if err = instance.Peers.Sign(privKey); err != nil {
- return
- }
- instance.GenesisBlock, err = createRandomBlock(rootHash, true)
-
- return
-}
-
-func (s *stubBPDBService) QueryAccountStableBalance(req *types.QueryAccountStableBalanceReq,
+func (s *stubBPService) QueryAccountStableBalance(req *types.QueryAccountStableBalanceReq,
resp *types.QueryAccountStableBalanceResp) (err error) {
return
}
-func (s *stubBPDBService) QueryAccountCovenantBalance(req *types.QueryAccountCovenantBalanceReq,
+func (s *stubBPService) QueryAccountCovenantBalance(req *types.QueryAccountCovenantBalanceReq,
resp *types.QueryAccountCovenantBalanceResp) (err error) {
return
}
-func (s *stubBPDBService) QuerySQLChainProfile(req *types.QuerySQLChainProfileReq,
+func (s *stubBPService) QuerySQLChainProfile(req *types.QuerySQLChainProfileReq,
resp *types.QuerySQLChainProfileResp) (err error) {
var nodeID proto.NodeID
if nodeID, err = kms.GetLocalNodeID(); err != nil {
@@ -154,7 +74,7 @@ func (s *stubBPDBService) QuerySQLChainProfile(req *types.QuerySQLChainProfileRe
}
resp.Profile = types.SQLChainProfile{
Miners: []*types.MinerInfo{
- &types.MinerInfo{
+ {
NodeID: nodeID,
},
},
@@ -303,13 +223,8 @@ func initNode() (cleanupFunc func(), tempDir string, server *rpc.Server, err err
return
}
- // register bpdb service
- if err = server.RegisterService(route.BPDBRPCName, &stubBPDBService{}); err != nil {
- return
- }
-
// register fake chain service
- if err = server.RegisterService(route.BlockProducerRPCName, &stubBPDBService{}); err != nil {
+ if err = server.RegisterService(route.BlockProducerRPCName, &stubBPService{}); err != nil {
return
}
diff --git a/cmd/cql-minerd/integration_test.go b/cmd/cql-minerd/integration_test.go
index 5529988d2..4d94767c1 100644
--- a/cmd/cql-minerd/integration_test.go
+++ b/cmd/cql-minerd/integration_test.go
@@ -46,7 +46,7 @@ import (
"github.com/CovenantSQL/CovenantSQL/types"
"github.com/CovenantSQL/CovenantSQL/utils"
"github.com/CovenantSQL/CovenantSQL/utils/log"
- sqlite3 "github.com/CovenantSQL/go-sqlite3-encrypt"
+ "github.com/CovenantSQL/go-sqlite3-encrypt"
. "github.com/smartystreets/goconvey/convey"
)
@@ -346,7 +346,6 @@ func TestFullProcess(t *testing.T) {
minersPrivKeys = make([]*asymmetric.PrivateKey, 3)
minersAddrs = make([]proto.AccountAddress, 3)
- minersNodeID = make([]proto.NodeID, 3)
)
// get miners' private keys
@@ -369,74 +368,31 @@ func TestFullProcess(t *testing.T) {
clientAddr, err = crypto.PubKeyHash(clientPrivKey.PubKey())
So(err, ShouldBeNil)
- // get miners' node id
- cfg, err := conf.LoadConfig(FJ(testWorkingDir, "./integration/node_miner_0/config.yaml"))
- So(err, ShouldBeNil)
- minersNodeID[0] = cfg.ThisNodeID
- cfg, err = conf.LoadConfig(FJ(testWorkingDir, "./integration/node_miner_1/config.yaml"))
- So(err, ShouldBeNil)
- minersNodeID[1] = cfg.ThisNodeID
- cfg, err = conf.LoadConfig(FJ(testWorkingDir, "./integration/node_miner_2/config.yaml"))
- So(err, ShouldBeNil)
- minersNodeID[2] = cfg.ThisNodeID
-
- // miners provide service
- for i := range minersAddrs {
- nonce, err := getNonce(minersAddrs[i])
- So(err, ShouldBeNil)
-
- req := &types.AddTxReq{}
- resp := &types.AddTxResp{}
-
- req.Tx = types.NewProvideService(
- &types.ProvideServiceHeader{
- GasPrice: testGasPrice,
- TokenType: types.Particle,
- TargetUser: clientAddr,
- NodeID: minersNodeID[i],
- Nonce: nonce,
- },
- )
- err = req.Tx.Sign(minersPrivKeys[i])
- So(err, ShouldBeNil)
- err = rpc.RequestBP(route.MCCAddTx.String(), req, resp)
- So(err, ShouldBeNil)
- }
-
time.Sleep(20 * time.Second)
// client send create database transaction
- nonce, err := getNonce(clientAddr)
- So(err, ShouldBeNil)
- req := &types.AddTxReq{}
- resp := &types.AddTxResp{}
- req.Tx = types.NewCreateDatabase(
- &types.CreateDatabaseHeader{
- Owner: clientAddr,
- ResourceMeta: types.ResourceMeta{
- TargetMiners: minersAddrs,
- },
- GasPrice: testGasPrice,
- AdvancePayment: testAdvancePayment,
- TokenType: types.Particle,
- Nonce: nonce,
+ meta := client.ResourceMeta{
+ ResourceMeta: types.ResourceMeta{
+ TargetMiners: minersAddrs,
},
- )
- err = req.Tx.Sign(clientPrivKey)
- So(err, ShouldBeNil)
- err = rpc.RequestBP(route.MCCAddTx.String(), req, resp)
- So(err, ShouldBeNil)
+ GasPrice: testGasPrice,
+ AdvancePayment: testAdvancePayment,
+ }
+
+ dsn, err := client.Create(meta)
+ dsnCfg, err := client.ParseDSN(dsn)
+
time.Sleep(20 * time.Second)
// check sqlchain profile exist
- dbID := proto.FromAccountAndNonce(clientAddr, uint32(nonce))
+ dbID := proto.DatabaseID(dsnCfg.DatabaseID)
profileReq := &types.QuerySQLChainProfileReq{}
profileResp := &types.QuerySQLChainProfileResp{}
- profileReq.DBID = *dbID
+ profileReq.DBID = dbID
err = rpc.RequestBP(route.MCCQuerySQLChainProfile.String(), profileReq, profileResp)
So(err, ShouldBeNil)
profile := profileResp.Profile
- So(profile.Address.DatabaseID(), ShouldEqual, *dbID)
+ So(profile.Address.DatabaseID(), ShouldEqual, dbID)
So(profile.Owner.String(), ShouldEqual, clientAddr.String())
So(profile.TokenType, ShouldEqual, types.Particle)
minersMap := make(map[proto.AccountAddress]bool)
@@ -459,10 +415,6 @@ func TestFullProcess(t *testing.T) {
So(permStat.Status, ShouldEqual, types.Normal)
// create dsn
- dsncfg := client.NewConfig()
- dsncfg.DatabaseID = string(*dbID)
- dsn := dsncfg.FormatDSN()
-
log.Infof("the created database dsn is %v", dsn)
db, err := sql.Open("covenantsql", dsn)
@@ -581,7 +533,7 @@ func TestFullProcess(t *testing.T) {
profileReq = &types.QuerySQLChainProfileReq{}
profileResp = &types.QuerySQLChainProfileResp{}
- profileReq.DBID = *dbID
+ profileReq.DBID = dbID
err = rpc.RequestBP(route.MCCQuerySQLChainProfile.String(), profileReq, profileResp)
So(err, ShouldBeNil)
for _, user := range profileResp.Profile.Users {
diff --git a/cmd/cql-minerd/main.go b/cmd/cql-minerd/main.go
index db032512b..801513703 100644
--- a/cmd/cql-minerd/main.go
+++ b/cmd/cql-minerd/main.go
@@ -26,6 +26,9 @@ import (
"os"
"os/signal"
"runtime"
+
+ "github.com/CovenantSQL/CovenantSQL/metric"
+
//"runtime/trace"
"syscall"
"time"
@@ -33,8 +36,6 @@ import (
"github.com/CovenantSQL/CovenantSQL/conf"
"github.com/CovenantSQL/CovenantSQL/crypto/asymmetric"
"github.com/CovenantSQL/CovenantSQL/crypto/kms"
- "github.com/CovenantSQL/CovenantSQL/metric"
- "github.com/CovenantSQL/CovenantSQL/route"
"github.com/CovenantSQL/CovenantSQL/rpc"
"github.com/CovenantSQL/CovenantSQL/utils"
"github.com/CovenantSQL/CovenantSQL/utils/log"
@@ -183,28 +184,16 @@ func main() {
}()
}
- // start metric collector
+ // start period provide service transaction generator
go func() {
- mc := metric.NewCollectClient()
+ // start prometheus collector
+ reg := metric.StartMetricCollector()
+
tick := time.NewTicker(conf.GConf.Miner.MetricCollectInterval)
defer tick.Stop()
for {
- // if in test mode, upload metrics to all block producer
- if conf.GConf.Miner.IsTestMode {
- // upload to all block producer
- for _, bpNodeID := range route.GetBPs() {
- mc.UploadMetrics(bpNodeID)
- }
- } else {
- // choose block producer
- if bpID, err := rpc.GetCurrentBP(); err != nil {
- log.Error(err)
- continue
- } else {
- mc.UploadMetrics(bpID)
- }
- }
+ sendProvideService(reg)
select {
case <-stopCh:
diff --git a/cmd/cql-minerd/provide_service.go b/cmd/cql-minerd/provide_service.go
new file mode 100644
index 000000000..b79a42528
--- /dev/null
+++ b/cmd/cql-minerd/provide_service.go
@@ -0,0 +1,168 @@
+/*
+ * Copyright 2018 The CovenantSQL Authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package main
+
+import (
+ "github.com/CovenantSQL/CovenantSQL/crypto"
+ "github.com/CovenantSQL/CovenantSQL/crypto/asymmetric"
+ "github.com/CovenantSQL/CovenantSQL/crypto/kms"
+ "github.com/CovenantSQL/CovenantSQL/proto"
+ "github.com/CovenantSQL/CovenantSQL/route"
+ "github.com/CovenantSQL/CovenantSQL/rpc"
+ "github.com/CovenantSQL/CovenantSQL/types"
+ "github.com/CovenantSQL/CovenantSQL/utils/log"
+ "github.com/ethereum/go-ethereum/common/math"
+ "github.com/prometheus/client_golang/prometheus"
+ dto "github.com/prometheus/client_model/go"
+)
+
+const (
+ defaultGasPrice = 1
+)
+
+var (
+ metricKeyMemory = "node_memory_MemAvailable_bytes"
+ metricKeyLoadAvg = "node_load15"
+ metricKeyCpuCount = "node_cpu_count"
+ metricKeySpace = "node_filesystem_free_bytes"
+)
+
+func sendProvideService(reg *prometheus.Registry) {
+ var (
+ memoryBytes uint64
+ cpuCount float64
+ loadAvg float64
+ keySpace uint64
+ nodeID proto.NodeID
+ privateKey *asymmetric.PrivateKey
+ mf []*dto.MetricFamily
+ err error
+ minerAddr proto.AccountAddress
+ )
+
+ if nodeID, err = kms.GetLocalNodeID(); err != nil {
+ log.WithError(err).Error("get local node id failed")
+ return
+ }
+
+ if privateKey, err = kms.GetLocalPrivateKey(); err != nil {
+ log.WithError(err).Error("get local private key failed")
+ return
+ }
+
+ if minerAddr, err = crypto.PubKeyHash(privateKey.PubKey()); err != nil {
+ log.WithError(err).Error("get miner account address failed")
+ return
+ }
+
+ if mf, err = reg.Gather(); err != nil {
+ log.WithError(err).Error("gathering node metrics failed")
+ return
+ }
+
+ for _, m := range mf {
+ switch m.GetName() {
+ case metricKeyMemory, metricKeyCpuCount, metricKeyLoadAvg, metricKeySpace:
+ default:
+ continue
+ }
+
+ var metricVal float64
+
+ switch m.GetType() {
+ case dto.MetricType_GAUGE:
+ metricVal = m.GetMetric()[0].GetGauge().GetValue()
+ case dto.MetricType_COUNTER:
+ metricVal = m.GetMetric()[0].GetCounter().GetValue()
+ case dto.MetricType_HISTOGRAM:
+ metricVal = m.GetMetric()[0].GetHistogram().GetBucket()[0].GetUpperBound()
+ case dto.MetricType_SUMMARY:
+ metricVal = m.GetMetric()[0].GetSummary().GetQuantile()[0].GetValue()
+ case dto.MetricType_UNTYPED:
+ metricVal = m.GetMetric()[0].GetUntyped().GetValue()
+ default:
+ continue
+ }
+
+ switch m.GetName() {
+ case metricKeyMemory:
+ if metricVal > 0 && metricVal < math.MaxUint64 {
+ memoryBytes = uint64(metricVal)
+ }
+ case metricKeyCpuCount:
+ cpuCount = metricVal
+ case metricKeyLoadAvg:
+ loadAvg = metricVal
+ case metricKeySpace:
+ if metricVal > 0 && metricVal < math.MaxUint64 {
+ keySpace = uint64(metricVal)
+ }
+ default:
+ }
+ }
+
+ if cpuCount > 0 {
+ loadAvg = loadAvg / cpuCount
+ }
+
+ log.WithFields(log.Fields{
+ "memory": memoryBytes,
+ "loadAvg": loadAvg,
+ "space": keySpace,
+ }).Info("sending provide service transaction with resource parameters")
+
+ var (
+ nonceReq = new(types.NextAccountNonceReq)
+ nonceResp = new(types.NextAccountNonceResp)
+ req = new(types.AddTxReq)
+ resp = new(types.AddTxResp)
+ )
+
+ nonceReq.Addr = minerAddr
+
+ if err = rpc.RequestBP(route.MCCNextAccountNonce.String(), nonceReq, nonceResp); err != nil {
+ // allocate nonce failed
+ log.WithError(err).Error("allocate nonce for transaction failed")
+ return
+ }
+
+ tx := types.NewProvideService(
+ &types.ProvideServiceHeader{
+ Space: keySpace,
+ Memory: memoryBytes,
+ LoadAvgPerCPU: loadAvg,
+ GasPrice: defaultGasPrice,
+ TokenType: types.Particle,
+ NodeID: nodeID,
+ },
+ )
+
+ tx.Nonce = nonceResp.Nonce
+
+ if err = tx.Sign(privateKey); err != nil {
+ log.WithError(err).Error("sign provide service transaction failed")
+ return
+ }
+
+ req.Tx = tx
+
+ if err = rpc.RequestBP(route.MCCAddTx.String(), req, resp); err != nil {
+ // add transaction failed
+ log.WithError(err).Error("send provide service transaction failed")
+ return
+ }
+}
diff --git a/cmd/cql-utils/rpc.go b/cmd/cql-utils/rpc.go
index ea689702a..775af1b97 100644
--- a/cmd/cql-utils/rpc.go
+++ b/cmd/cql-utils/rpc.go
@@ -43,7 +43,6 @@ var (
rpcServiceMap = map[string]interface{}{
route.DHTRPCName: &route.DHTService{},
route.DBRPCName: &worker.DBMSRPCService{},
- route.BPDBRPCName: &bp.DBService{},
route.SQLChainRPCName: &sqlchain.MuxService{},
route.BlockProducerRPCName: &bp.ChainRPCService{},
}
diff --git a/cmd/cqld/bootstrap.go b/cmd/cqld/bootstrap.go
index f2f7971d4..677970815 100644
--- a/cmd/cqld/bootstrap.go
+++ b/cmd/cqld/bootstrap.go
@@ -30,7 +30,6 @@ import (
"github.com/CovenantSQL/CovenantSQL/kayak"
kt "github.com/CovenantSQL/CovenantSQL/kayak/types"
kl "github.com/CovenantSQL/CovenantSQL/kayak/wal"
- "github.com/CovenantSQL/CovenantSQL/metric"
"github.com/CovenantSQL/CovenantSQL/proto"
"github.com/CovenantSQL/CovenantSQL/route"
"github.com/CovenantSQL/CovenantSQL/rpc"
@@ -125,26 +124,6 @@ func runNode(nodeID proto.NodeID, listenAddr string) (err error) {
return
}
- // init metrics
- log.Info("register metric service rpc")
- metricService := metric.NewCollectServer()
- if err = server.RegisterService(metric.MetricServiceName, metricService); err != nil {
- log.WithError(err).Error("init metric service failed")
- return
- }
-
- // init block producer database service
- log.Info("register block producer database service rpc")
- var dbService *bp.DBService
- if dbService, err = initDBService(kvServer, metricService); err != nil {
- log.WithError(err).Error("init block producer db service failed")
- return
- }
- if err = server.RegisterService(route.BPDBRPCName, dbService); err != nil {
- log.WithError(err).Error("init block producer db service failed")
- return
- }
-
// init main chain service
log.Info("register main chain service rpc")
chainConfig := bp.NewConfig(
@@ -245,23 +224,6 @@ func initKayakTwoPC(rootDir string, node *proto.Node, peers *proto.Peers, h kt.H
return
}
-func initDBService(kvServer *KayakKVServer, metricService *metric.CollectServer) (dbService *bp.DBService, err error) {
- var serviceMap *bp.DBServiceMap
- if serviceMap, err = bp.InitServiceMap(kvServer); err != nil {
- log.WithError(err).Error("init bp database service map failed")
- return
- }
-
- dbService = &bp.DBService{
- AllocationRounds: bp.DefaultAllocationRounds, //
- ServiceMap: serviceMap,
- Consistent: kvServer.KVStorage.consistent,
- NodeMetrics: &metricService.NodeMetric,
- }
-
- return
-}
-
func loadGenesis() *types.BPBlock {
genesisInfo := conf.GConf.BP.BPGenesis
log.WithField("config", genesisInfo).Info("load genesis config")
diff --git a/metric/nodemetricmap.go b/metric/nodemetricmap.go
deleted file mode 100644
index 8d8875570..000000000
--- a/metric/nodemetricmap.go
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- * Copyright 2018 The CovenantSQL Authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package metric
-
-import (
- "sync"
-
- "github.com/CovenantSQL/CovenantSQL/proto"
- "github.com/CovenantSQL/CovenantSQL/utils/log"
- dto "github.com/prometheus/client_model/go"
-)
-
-// MetricMap is map from metric name to MetricFamily.
-type MetricMap map[string]*dto.MetricFamily
-
-// NodeCrucialMetricMap is map[NodeID][MetricName]Value
-type NodeCrucialMetricMap map[proto.NodeID]map[string]float64
-
-// FilterFunc is a function that knows how to filter a specific node
-// that match the metric limits. if node picked return true else false.
-type FilterFunc func(key proto.NodeID, value MetricMap) bool
-
-// NodeMetricMap is sync.Map version of map[proto.NodeID]MetricMap.
-type NodeMetricMap struct {
- sync.Map // map[proto.NodeID]MetricMap
-}
-
-// FilterNode return node id slice make filterFunc return true.
-func (nmm *NodeMetricMap) FilterNode(filterFunc FilterFunc) (ret []proto.NodeID) {
- nodePicker := func(key, value interface{}) bool {
- id, ok := key.(proto.NodeID)
- if !ok {
- return true // continue iteration
- }
- metrics, ok := value.(MetricMap)
- if !ok {
- return true // continue iteration
- }
- if filterFunc(id, metrics) {
- ret = append(ret, id)
- }
- return true
- }
- nmm.Range(nodePicker)
- return
-}
-
-// GetMetrics returns nodes metrics.
-func (nmm *NodeMetricMap) GetMetrics(nodes []proto.NodeID) (metrics map[proto.NodeID]MetricMap) {
- metrics = make(map[proto.NodeID]MetricMap)
-
- for _, node := range nodes {
- var ok bool
- var rawNodeMetrics interface{}
-
- if rawNodeMetrics, ok = nmm.Load(node); !ok {
- continue
- }
-
- var nodeMetrics MetricMap
-
- if nodeMetrics, ok = rawNodeMetrics.(MetricMap); !ok {
- continue
- }
-
- metrics[node] = nodeMetrics
- }
-
- return
-}
-
-// FilterCrucialMetrics filters crucial metrics and also add cpu_count
-func (mfm *MetricMap) FilterCrucialMetrics() (ret map[string]float64) {
- crucialMetricNameMap := map[string]string{
- "node_memory_MemAvailable_bytes": "mem_avail",
- "node_load1": "load1",
- "node_load5": "load5",
- "node_load15": "load15",
- "node_ntp_offset_seconds": "ntp_offset",
- "node_filesystem_free_bytes": "fs_avail",
- "node_cpu_count": "cpu_count",
- }
- ret = make(map[string]float64)
- for _, v := range *mfm {
- if newName, ok := crucialMetricNameMap[*v.Name]; ok {
- var metricVal float64
- switch v.GetType() {
- case dto.MetricType_GAUGE:
- metricVal = v.GetMetric()[0].GetGauge().GetValue()
- case dto.MetricType_COUNTER:
- metricVal = v.GetMetric()[0].GetCounter().GetValue()
- case dto.MetricType_HISTOGRAM:
- metricVal = v.GetMetric()[0].GetHistogram().GetBucket()[0].GetUpperBound()
- case dto.MetricType_SUMMARY:
- metricVal = v.GetMetric()[0].GetSummary().GetQuantile()[0].GetValue()
- case dto.MetricType_UNTYPED:
- metricVal = v.GetMetric()[0].GetUntyped().GetValue()
- default:
- continue
- }
- ret[newName] = metricVal
- }
- }
- log.Debugf("crucial Metric added: %v", ret)
-
- return
-}
-
-// GetCrucialMetrics gets NodeCrucialMetricMap from NodeMetricMap
-func (nmm *NodeMetricMap) GetCrucialMetrics() (ret NodeCrucialMetricMap) {
- ret = make(NodeCrucialMetricMap)
- metricsPicker := func(key, value interface{}) bool {
- nodeID, ok := key.(proto.NodeID)
- if !ok {
- return true // continue iteration
- }
- mfm, ok := value.(MetricMap)
- if !ok {
- return true // continue iteration
- }
-
- ret[nodeID] = mfm.FilterCrucialMetrics()
- return true // continue iteration
- }
- nmm.Range(metricsPicker)
-
- return
-}
diff --git a/metric/nodemetricmap_test.go b/metric/nodemetricmap_test.go
deleted file mode 100644
index f8ae9103a..000000000
--- a/metric/nodemetricmap_test.go
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Copyright 2018 The CovenantSQL Authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package metric
-
-import (
- "testing"
-
- "github.com/CovenantSQL/CovenantSQL/proto"
- "github.com/CovenantSQL/CovenantSQL/utils/log"
- dto "github.com/prometheus/client_model/go"
- . "github.com/smartystreets/goconvey/convey"
-)
-
-func TestCollectServer_FilterNode(t *testing.T) {
- log.SetLevel(log.DebugLevel)
- filterTrue := func(key proto.NodeID, value MetricMap) bool {
- log.Debugf("key: %s, value: %#v", key, value)
- return true
- }
- filterFalse := func(key proto.NodeID, value MetricMap) bool {
- log.Debugf("key: %s, value: %#v", key, value)
- return false
- }
- filterMem1MB := func(key proto.NodeID, value MetricMap) bool {
- log.Debugf("key: %s, value: %#v", key, value)
- var v *dto.MetricFamily
- v, ok := value["node_memory_bytes_total"]
- if !ok {
- v, ok = value["node_memory_MemTotal_bytes"]
- }
- if ok && len(v.Metric) > 0 &&
- v.Metric[0].GetGauge() != nil &&
- v.Metric[0].GetGauge().Value != nil &&
- *v.Metric[0].GetGauge().Value > float64(1*MB) {
- log.Debugf("has memory: %fGB", *v.Metric[0].GetGauge().Value/float64(GB))
- return true
- }
-
- return false
- }
- Convey("filter node", t, func() {
- cc := NewCollectClient()
- mfs, _ := cc.Registry.Gather()
- mm := make(MetricMap, 0)
- for _, mf := range mfs {
- mm[*mf.Name] = mf
- log.Debugf("gathered node: %v", mf)
- }
- nmm := NodeMetricMap{}
- nmm.Store(proto.NodeID("node1"), mm)
- nmm.Store(proto.NodeID("node2"), nil)
- nmm.Store(proto.NodeID("node3"), mm)
- So(len(mm), ShouldEqual, len(mfs))
- So(len(mm), ShouldBeGreaterThan, 2)
-
- ids := nmm.FilterNode(filterTrue)
- So(len(ids), ShouldEqual, 2)
-
- ids1 := nmm.FilterNode(filterMem1MB)
- So(len(ids1), ShouldEqual, 2)
-
- ids2 := nmm.FilterNode(filterFalse)
- So(len(ids2), ShouldEqual, 0)
- })
- Convey("filter metrics", t, func() {
- cc := NewCollectClient()
- mfs, _ := cc.Registry.Gather()
- mm := make(MetricMap, 0)
- for _, mf := range mfs {
- mm[*mf.Name] = mf
- log.Debugf("gathered node: %v", mf)
- }
- nmm := NodeMetricMap{}
- nmm.Store(proto.NodeID("node1"), mm)
- nmm.Store(proto.NodeID("node2"), nil)
-
- cmm := nmm.GetCrucialMetrics()
- So(len(cmm), ShouldEqual, 1)
- So(len(cmm["node1"]), ShouldBeGreaterThanOrEqualTo, 6)
- })
-
-}
diff --git a/metric/rpc.go b/metric/rpc.go
deleted file mode 100644
index 94f98da54..000000000
--- a/metric/rpc.go
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
- * Copyright 2018 The CovenantSQL Authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package metric
-
-import (
- "bytes"
- "errors"
- "fmt"
-
- "github.com/CovenantSQL/CovenantSQL/proto"
- "github.com/CovenantSQL/CovenantSQL/route"
- "github.com/CovenantSQL/CovenantSQL/rpc"
- "github.com/CovenantSQL/CovenantSQL/utils/log"
- "github.com/prometheus/client_golang/prometheus"
- "github.com/prometheus/common/expfmt"
-)
-
-// MetricServiceName is the RPC name
-const MetricServiceName = "Metric"
-
-// CollectClient is the Metric Collect Client
-type CollectClient struct {
- Registry *prometheus.Registry
-}
-
-// NewCollectClient returns a new CollectClient
-func NewCollectClient() *CollectClient {
- reg := StartMetricCollector()
- if reg == nil {
- log.Fatal("StartMetricCollector failed")
- }
-
- return &CollectClient{
- Registry: reg,
- }
-}
-
-// CollectServer is the Metric receiver side
-type CollectServer struct {
- NodeMetric NodeMetricMap // map[proto.NodeID]MetricMap
-}
-
-// NewCollectServer returns a new CollectServer
-func NewCollectServer() *CollectServer {
- return &CollectServer{
- NodeMetric: NodeMetricMap{},
- }
-}
-
-// UploadMetrics RPC uploads metric info
-func (cs *CollectServer) UploadMetrics(req *proto.UploadMetricsReq, resp *proto.UploadMetricsResp) (err error) {
- reqNodeID := req.GetNodeID().ToNodeID()
- if reqNodeID.IsEmpty() {
- err = errors.New("empty node id")
- log.Error(err)
- return
- }
- if !route.IsPermitted(&req.Envelope, route.MetricUploadMetrics) {
- err = fmt.Errorf("calling from node %s is not permitted", reqNodeID)
- log.Error(err)
- return
- }
-
- mfm := make(MetricMap, len(req.MFBytes))
- log.Debugf("RPC received MFS len %d", len(req.MFBytes))
- for _, mf := range req.MFBytes[:] {
- bufReader := bytes.NewReader(mf)
- //mf := new(dto.MetricFamily)
- //dec := expfmt.NewDecoder(bufReader, expfmt.FmtProtoCompact)
- //err = dec.Decode(mf)
- tp := expfmt.TextParser{}
- mf, err := tp.TextToMetricFamilies(bufReader)
- if err != nil {
- log.Warnf("decode MetricFamily failed: %s", err)
- continue
- }
- //log.Debugf("RPC received MF: %#v", mf)
- for k, v := range mf {
- mfm[k] = v
- }
- }
- //log.Debugf("MetricFamily uploaded: %v, %v", reqNodeID, mfm)
- if len(mfm) > 0 {
- cs.NodeMetric.Store(reqNodeID, mfm)
- } else {
- err = errors.New("no valid metric received")
- log.Error(err)
- }
- return
-}
-
-// GatherMetricBytes gathers the registered metric info and encode it to [][]byte
-func (cc *CollectClient) GatherMetricBytes() (mfb [][]byte, err error) {
- mfs, err := cc.Registry.Gather()
- if err != nil {
- log.Errorf("gather metrics failed: %s", err)
- return
- }
- mfb = make([][]byte, 0, len(mfs))
- for _, mf := range mfs[:] {
- //log.Debugf("mf: %s", mf.String())
- buf := new(bytes.Buffer)
- //enc := expfmt.NewEncoder(buf, expfmt.FmtProtoCompact)
- //err = enc.Encode(mf)
- expfmt.MetricFamilyToText(buf, mf)
- if err != nil {
- log.Warnf("encode MetricFamily failed: %s", err)
- continue
- }
- mfb = append(mfb, buf.Bytes())
- }
- if len(mfb) == 0 {
- err = errors.New("no valid metric gathered")
- }
-
- return
-}
-
-// UploadMetrics calls RPC UploadMetrics to upload its metric info
-func (cc *CollectClient) UploadMetrics(BPNodeID proto.NodeID) (err error) {
- mfb, err := cc.GatherMetricBytes()
- if err != nil {
- log.Errorf("GatherMetricBytes failed: %s", err)
- return
- }
- log.Debugf("calling BP: %s", BPNodeID)
- reqType := MetricServiceName + ".UploadMetrics"
- req := &proto.UploadMetricsReq{
- MFBytes: mfb,
- }
- resp := new(proto.UploadMetricsResp)
- err = rpc.NewCaller().CallNode(BPNodeID, reqType, req, resp)
- if err != nil {
- log.Errorf("calling RPC %s failed: %s", reqType, err)
- }
- log.Debugf("resp %s: %v", reqType, resp)
- return
-}
diff --git a/metric/rpc_test.go b/metric/rpc_test.go
deleted file mode 100644
index 90c7d7af3..000000000
--- a/metric/rpc_test.go
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright 2018 The CovenantSQL Authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package metric
-
-import (
- "os"
- "testing"
- "time"
-
- "github.com/CovenantSQL/CovenantSQL/consistent"
- "github.com/CovenantSQL/CovenantSQL/crypto/asymmetric"
- "github.com/CovenantSQL/CovenantSQL/crypto/kms"
- "github.com/CovenantSQL/CovenantSQL/proto"
- "github.com/CovenantSQL/CovenantSQL/route"
- "github.com/CovenantSQL/CovenantSQL/rpc"
- "github.com/CovenantSQL/CovenantSQL/utils/log"
- . "github.com/smartystreets/goconvey/convey"
-)
-
-const PubKeyStorePath = "./public.keystore"
-
-func TestCollectClient_UploadMetrics(t *testing.T) {
- defer os.Remove(PubKeyStorePath)
- log.SetLevel(log.DebugLevel)
- addr := "127.0.0.1:0"
- masterKey := []byte("abc")
-
- cc := NewCollectClient()
- cs := NewCollectServer()
-
- server, err := rpc.NewServerWithService(rpc.ServiceMap{MetricServiceName: cs})
- if err != nil {
- log.Fatal(err)
- }
-
- route.NewDHTService(PubKeyStorePath, new(consistent.KMSStorage), false)
- server.InitRPCServer(addr, "../keys/test.key", masterKey)
- go server.Serve()
-
- publicKey, err := kms.GetLocalPublicKey()
- nonce := asymmetric.GetPubKeyNonce(publicKey, 10, 100*time.Millisecond, nil)
- serverNodeID := proto.NodeID(nonce.Hash.String())
- kms.SetPublicKey(serverNodeID, nonce.Nonce, publicKey)
- kms.SetLocalNodeIDNonce(nonce.Hash.CloneBytes(), &nonce.Nonce)
- route.SetNodeAddrCache(&proto.RawNodeID{Hash: nonce.Hash}, server.Listener.Addr().String())
-
- Convey("get metric and upload by RPC", t, func() {
- err = cc.UploadMetrics(serverNodeID)
- v, ok := cs.NodeMetric.Load(serverNodeID)
- So(ok, ShouldBeTrue)
- //log.Debugf("NodeMetric:%#v", v)
-
- m, _ := v.(MetricMap)
- mfb, err := cc.GatherMetricBytes()
- So(err, ShouldBeNil)
- So(len(m), ShouldEqual, len(mfb))
- So(len(m), ShouldBeGreaterThan, 2)
- })
-
- Convey("get metric and upload by simply called without node id", t, func() {
- req := &proto.UploadMetricsReq{
- MFBytes: nil,
- Envelope: proto.Envelope{},
- }
- err = cs.UploadMetrics(req, &proto.UploadMetricsResp{})
- So(err, ShouldNotBeNil)
- })
-}
diff --git a/route/acl.go b/route/acl.go
index bc171c0db..2abcc9ad9 100644
--- a/route/acl.go
+++ b/route/acl.go
@@ -38,9 +38,6 @@ ACLs:
BP -> Miner, Request for Creating DB:
ACL: Open to BP
- Miner -> BP, Metric.UploadMetrics():
- ACL: Open to Registered Miner
-
Miner -> Miner, Kayak.Call():
ACL: Open to Miner Leader.
@@ -67,8 +64,6 @@ const (
DHTFindNeighbor
// DHTFindNode gets node info
DHTFindNode
- // MetricUploadMetrics uploads node metrics
- MetricUploadMetrics
// KayakCall is used by BP for data consistency
KayakCall
// DBSQuery is used by client to read/write database
@@ -83,14 +78,6 @@ const (
DBSCancelSubscription
// DBCCall is used by Miner for data consistency
DBCCall
- // BPDBCreateDatabase is used by client to create database
- BPDBCreateDatabase
- // BPDBDropDatabase is used by client to drop database
- BPDBDropDatabase
- // BPDBGetDatabase is used by client to get database meta
- BPDBGetDatabase
- // BPDBGetNodeDatabases is used by miner to node residential databases
- BPDBGetNodeDatabases
// SQLCAdviseNewBlock is used by sqlchain to advise new block between adjacent node
SQLCAdviseNewBlock
// SQLCAdviseBinLog is usd by sqlchain to advise binlog between adjacent node
@@ -142,8 +129,6 @@ const (
SQLChainRPCName = "SQLC"
// DBRPCName defines the sql chain db service rpc name
DBRPCName = "DBS"
- // BPDBRPCName defines the block producer db service rpc name
- BPDBRPCName = "BPDB"
// ObserverRPCName defines the observer node service rpc name
ObserverRPCName = "OBS"
)
@@ -157,8 +142,6 @@ func (s RemoteFunc) String() string {
return "DHT.FindNeighbor"
case DHTFindNode:
return "DHT.FindNode"
- case MetricUploadMetrics:
- return "Metric.UploadMetrics"
case KayakCall:
return "Kayak.Call"
case DBSQuery:
@@ -173,14 +156,6 @@ func (s RemoteFunc) String() string {
return "DBS.CancelSubscription"
case DBCCall:
return "DBC.Call"
- case BPDBCreateDatabase:
- return "BPDB.CreateDatabase"
- case BPDBDropDatabase:
- return "BPDB.DropDatabase"
- case BPDBGetDatabase:
- return "BPDB.GetDatabase"
- case BPDBGetNodeDatabases:
- return "BPDB.GetNodeDatabases"
case SQLCAdviseNewBlock:
return "SQLC.AdviseNewBlock"
case SQLCAdviseBinLog:
@@ -246,7 +221,7 @@ func IsPermitted(callerEnvelope *proto.Envelope, funcName RemoteFunc) (ok bool)
// non BP
switch funcName {
// DHT related
- case DHTPing, DHTFindNode, DHTFindNeighbor, MetricUploadMetrics:
+ case DHTPing, DHTFindNode, DHTFindNeighbor:
return true
// Kayak related
case KayakCall:
diff --git a/sqlchain/chain_test.go b/sqlchain/chain_test.go
index 2a030d5ef..16ab4238b 100644
--- a/sqlchain/chain_test.go
+++ b/sqlchain/chain_test.go
@@ -30,7 +30,6 @@ import (
"github.com/CovenantSQL/CovenantSQL/consistent"
"github.com/CovenantSQL/CovenantSQL/crypto/hash"
"github.com/CovenantSQL/CovenantSQL/crypto/kms"
- "github.com/CovenantSQL/CovenantSQL/metric"
"github.com/CovenantSQL/CovenantSQL/proto"
"github.com/CovenantSQL/CovenantSQL/route"
"github.com/CovenantSQL/CovenantSQL/rpc"
@@ -246,10 +245,6 @@ func TestMultiChain(t *testing.T) {
t.Fatalf("error occurred: %v", err)
}
- if err = bpsvr.RegisterService(metric.MetricServiceName, metric.NewCollectServer()); err != nil {
- t.Fatalf("error occurred: %v", err)
- }
-
for _, n := range conf.GConf.KnownNodes {
rawNodeID := n.ID.ToRawNodeID()
route.SetNodeAddrCache(rawNodeID, n.Addr)
diff --git a/test/integration/node_miner_0/config.yaml b/test/integration/node_miner_0/config.yaml
index 399addb89..f0eb80ca1 100644
--- a/test/integration/node_miner_0/config.yaml
+++ b/test/integration/node_miner_0/config.yaml
@@ -45,7 +45,7 @@ Miner:
IsTestMode: true
RootDir: "./data"
MaxReqTimeGap: "2s"
- MetricCollectInterval: "1h"
+ MetricCollectInterval: "60s"
KnownNodes:
- ID: 00000bef611d346c0cbe1beaa76e7f0ed705a194fdf9ac3a248ec70e9c198bf9
Nonce:
diff --git a/test/integration/node_miner_1/config.yaml b/test/integration/node_miner_1/config.yaml
index a29583f67..a9ab6ce93 100644
--- a/test/integration/node_miner_1/config.yaml
+++ b/test/integration/node_miner_1/config.yaml
@@ -45,7 +45,7 @@ Miner:
IsTestMode: true
RootDir: "./data"
MaxReqTimeGap: "2s"
- MetricCollectInterval: "1h"
+ MetricCollectInterval: "60s"
KnownNodes:
- ID: 00000bef611d346c0cbe1beaa76e7f0ed705a194fdf9ac3a248ec70e9c198bf9
Nonce:
diff --git a/test/integration/node_miner_2/config.yaml b/test/integration/node_miner_2/config.yaml
index da6b5626c..f6665898c 100644
--- a/test/integration/node_miner_2/config.yaml
+++ b/test/integration/node_miner_2/config.yaml
@@ -45,7 +45,7 @@ Miner:
IsTestMode: true
RootDir: "./data"
MaxReqTimeGap: "2s"
- MetricCollectInterval: "1h"
+ MetricCollectInterval: "60s"
KnownNodes:
- ID: 00000bef611d346c0cbe1beaa76e7f0ed705a194fdf9ac3a248ec70e9c198bf9
Nonce:
diff --git a/types/account.go b/types/account.go
index 5ff67308c..4b652e719 100644
--- a/types/account.go
+++ b/types/account.go
@@ -142,9 +142,9 @@ type SQLChainProfile struct {
// ProviderProfile defines a provider list.
type ProviderProfile struct {
Provider proto.AccountAddress
- Space uint64 // reserved storage space in bytes
- Memory uint64 // reserved memory in bytes
- LoadAvgPerCPU uint64 // max loadAvg15 per CPU
+ Space uint64 // reserved storage space in bytes
+ Memory uint64 // reserved memory in bytes
+ LoadAvgPerCPU float64 // max loadAvg15 per CPU
TargetUser proto.AccountAddress
Deposit uint64 // default 10 Particle
GasPrice uint64
diff --git a/types/account_gen.go b/types/account_gen.go
index 7b5c4dbb8..960d26425 100644
--- a/types/account_gen.go
+++ b/types/account_gen.go
@@ -114,6 +114,8 @@ func (z *ProviderProfile) MarshalHash() (o []byte, err error) {
o = hsp.AppendBytes(o, oTemp)
}
o = append(o, 0x89)
+ o = hsp.AppendFloat64(o, z.LoadAvgPerCPU)
+ o = append(o, 0x89)
if oTemp, err := z.Provider.MarshalHash(); err != nil {
return nil, err
} else {
@@ -132,8 +134,6 @@ func (z *ProviderProfile) MarshalHash() (o []byte, err error) {
o = hsp.AppendBytes(o, oTemp)
}
o = append(o, 0x89)
- o = hsp.AppendUint64(o, z.LoadAvgPerCPU)
- o = append(o, 0x89)
o = hsp.AppendUint64(o, z.Deposit)
o = append(o, 0x89)
o = hsp.AppendUint64(o, z.GasPrice)
@@ -146,7 +146,7 @@ func (z *ProviderProfile) MarshalHash() (o []byte, err error) {
// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (z *ProviderProfile) Msgsize() (s int) {
- s = 1 + 10 + z.TokenType.Msgsize() + 9 + z.Provider.Msgsize() + 11 + z.TargetUser.Msgsize() + 7 + z.NodeID.Msgsize() + 14 + hsp.Uint64Size + 8 + hsp.Uint64Size + 9 + hsp.Uint64Size + 6 + hsp.Uint64Size + 7 + hsp.Uint64Size
+ s = 1 + 10 + z.TokenType.Msgsize() + 14 + hsp.Float64Size + 9 + z.Provider.Msgsize() + 11 + z.TargetUser.Msgsize() + 7 + z.NodeID.Msgsize() + 8 + hsp.Uint64Size + 9 + hsp.Uint64Size + 6 + hsp.Uint64Size + 7 + hsp.Uint64Size
return
}
diff --git a/types/init_service_type.go b/types/init_service_type.go
index 9f3292ae3..3267445b5 100644
--- a/types/init_service_type.go
+++ b/types/init_service_type.go
@@ -35,7 +35,7 @@ type ResourceMeta struct {
Node uint16 // reserved node count
Space uint64 // reserved storage space in bytes
Memory uint64 // reserved memory in bytes
- LoadAvgPerCPU uint64 // max loadAvg15 per CPU
+ LoadAvgPerCPU float64 // max loadAvg15 per CPU
EncryptionKey string // encryption key for database instance
UseEventualConsistency bool // use eventual consistency replication if enabled
ConsistencyLevel float64 // customized strong consistency level
diff --git a/types/init_service_type_gen.go b/types/init_service_type_gen.go
index 7ff4eb63a..b289ec50d 100644
--- a/types/init_service_type_gen.go
+++ b/types/init_service_type_gen.go
@@ -31,19 +31,8 @@ func (z *InitServiceResponse) MarshalHash() (o []byte, err error) {
var b []byte
o = hsp.Require(b, z.Msgsize())
// map header, size 1
- // map header, size 2
- // map header, size 1
- o = append(o, 0x81, 0x81, 0x82, 0x82, 0x81, 0x81)
- o = hsp.AppendArrayHeader(o, uint32(len(z.Header.InitServiceResponseHeader.Instances)))
- for za0001 := range z.Header.InitServiceResponseHeader.Instances {
- if oTemp, err := z.Header.InitServiceResponseHeader.Instances[za0001].MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
- }
- }
- o = append(o, 0x82)
- if oTemp, err := z.Header.DefaultHashSignVerifierImpl.MarshalHash(); err != nil {
+ o = append(o, 0x81, 0x81)
+ if oTemp, err := z.Header.MarshalHash(); err != nil {
return nil, err
} else {
o = hsp.AppendBytes(o, oTemp)
@@ -53,11 +42,7 @@ func (z *InitServiceResponse) MarshalHash() (o []byte, err error) {
// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (z *InitServiceResponse) Msgsize() (s int) {
- s = 1 + 7 + 1 + 26 + 1 + 10 + hsp.ArrayHeaderSize
- for za0001 := range z.Header.InitServiceResponseHeader.Instances {
- s += z.Header.InitServiceResponseHeader.Instances[za0001].Msgsize()
- }
- s += 28 + z.Header.DefaultHashSignVerifierImpl.Msgsize()
+ s = 1 + 7 + z.Header.Msgsize()
return
}
@@ -91,8 +76,8 @@ func (z *InitServiceResponseHeader) Msgsize() (s int) {
func (z *ResourceMeta) MarshalHash() (o []byte, err error) {
var b []byte
o = hsp.Require(b, z.Msgsize())
- // map header, size 5
- o = append(o, 0x85, 0x85)
+ // map header, size 8
+ o = append(o, 0x88, 0x88)
o = hsp.AppendArrayHeader(o, uint32(len(z.TargetMiners)))
for za0001 := range z.TargetMiners {
if oTemp, err := z.TargetMiners[za0001].MarshalHash(); err != nil {
@@ -101,14 +86,20 @@ func (z *ResourceMeta) MarshalHash() (o []byte, err error) {
o = hsp.AppendBytes(o, oTemp)
}
}
- o = append(o, 0x85)
+ o = append(o, 0x88)
+ o = hsp.AppendBool(o, z.UseEventualConsistency)
+ o = append(o, 0x88)
+ o = hsp.AppendFloat64(o, z.ConsistencyLevel)
+ o = append(o, 0x88)
+ o = hsp.AppendFloat64(o, z.LoadAvgPerCPU)
+ o = append(o, 0x88)
+ o = hsp.AppendString(o, z.EncryptionKey)
+ o = append(o, 0x88)
o = hsp.AppendUint16(o, z.Node)
- o = append(o, 0x85)
+ o = append(o, 0x88)
o = hsp.AppendUint64(o, z.Space)
- o = append(o, 0x85)
+ o = append(o, 0x88)
o = hsp.AppendUint64(o, z.Memory)
- o = append(o, 0x85)
- o = hsp.AppendUint64(o, z.LoadAvgPerCPU)
return
}
@@ -118,7 +109,7 @@ func (z *ResourceMeta) Msgsize() (s int) {
for za0001 := range z.TargetMiners {
s += z.TargetMiners[za0001].Msgsize()
}
- s += 5 + hsp.Uint16Size + 6 + hsp.Uint64Size + 7 + hsp.Uint64Size + 14 + hsp.Uint64Size
+ s += 23 + hsp.BoolSize + 17 + hsp.Float64Size + 14 + hsp.Float64Size + 14 + hsp.StringPrefixSize + len(z.EncryptionKey) + 5 + hsp.Uint16Size + 6 + hsp.Uint64Size + 7 + hsp.Uint64Size
return
}
diff --git a/types/no_ack_report_type_gen.go b/types/no_ack_report_type_gen.go
index e9e89abc6..374a39fea 100644
--- a/types/no_ack_report_type_gen.go
+++ b/types/no_ack_report_type_gen.go
@@ -57,7 +57,24 @@ func (z *AggrNoAckReportHeader) MarshalHash() (o []byte, err error) {
o = append(o, 0x84)
o = hsp.AppendArrayHeader(o, uint32(len(z.Reports)))
for za0001 := range z.Reports {
- if oTemp, err := z.Reports[za0001].MarshalHash(); err != nil {
+ // map header, size 2
+ // map header, size 3
+ o = append(o, 0x82, 0x82, 0x83, 0x83)
+ if oTemp, err := z.Reports[za0001].NoAckReportHeader.NodeID.MarshalHash(); err != nil {
+ return nil, err
+ } else {
+ o = hsp.AppendBytes(o, oTemp)
+ }
+ o = append(o, 0x83)
+ o = hsp.AppendTime(o, z.Reports[za0001].NoAckReportHeader.Timestamp)
+ o = append(o, 0x83)
+ if oTemp, err := z.Reports[za0001].NoAckReportHeader.Response.MarshalHash(); err != nil {
+ return nil, err
+ } else {
+ o = hsp.AppendBytes(o, oTemp)
+ }
+ o = append(o, 0x82)
+ if oTemp, err := z.Reports[za0001].DefaultHashSignVerifierImpl.MarshalHash(); err != nil {
return nil, err
} else {
o = hsp.AppendBytes(o, oTemp)
@@ -84,7 +101,7 @@ func (z *AggrNoAckReportHeader) Msgsize() (s int) {
}
s += 8 + hsp.ArrayHeaderSize
for za0001 := range z.Reports {
- s += z.Reports[za0001].Msgsize()
+ s += 1 + 18 + 1 + 7 + z.Reports[za0001].NoAckReportHeader.NodeID.Msgsize() + 10 + hsp.TimeSize + 9 + z.Reports[za0001].NoAckReportHeader.Response.Msgsize() + 28 + z.Reports[za0001].DefaultHashSignVerifierImpl.Msgsize()
}
s += 7 + z.NodeID.Msgsize() + 10 + hsp.TimeSize
return
diff --git a/types/provideservice.go b/types/provideservice.go
index 4c99ddd41..bca7e60cd 100644
--- a/types/provideservice.go
+++ b/types/provideservice.go
@@ -28,9 +28,9 @@ import (
// ProvideServiceHeader define the miner providing service transaction header.
type ProvideServiceHeader struct {
- Space uint64 // reserved storage space in bytes
- Memory uint64 // reserved memory in bytes
- LoadAvgPerCPU uint64 // max loadAvg15 per CPU
+ Space uint64 // reserved storage space in bytes
+ Memory uint64 // reserved memory in bytes
+ LoadAvgPerCPU float64 // max loadAvg15 per CPU
TargetUser proto.AccountAddress
GasPrice uint64
TokenType TokenType
diff --git a/types/provideservice_gen.go b/types/provideservice_gen.go
index d64e178d7..e6c882c85 100644
--- a/types/provideservice_gen.go
+++ b/types/provideservice_gen.go
@@ -50,6 +50,8 @@ func (z *ProvideServiceHeader) MarshalHash() (o []byte, err error) {
o = hsp.AppendBytes(o, oTemp)
}
o = append(o, 0x88)
+ o = hsp.AppendFloat64(o, z.LoadAvgPerCPU)
+ o = append(o, 0x88)
if oTemp, err := z.Nonce.MarshalHash(); err != nil {
return nil, err
} else {
@@ -68,8 +70,6 @@ func (z *ProvideServiceHeader) MarshalHash() (o []byte, err error) {
o = hsp.AppendBytes(o, oTemp)
}
o = append(o, 0x88)
- o = hsp.AppendUint64(o, z.LoadAvgPerCPU)
- o = append(o, 0x88)
o = hsp.AppendUint64(o, z.GasPrice)
o = append(o, 0x88)
o = hsp.AppendUint64(o, z.Space)
@@ -80,6 +80,6 @@ func (z *ProvideServiceHeader) MarshalHash() (o []byte, err error) {
// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (z *ProvideServiceHeader) Msgsize() (s int) {
- s = 1 + 10 + z.TokenType.Msgsize() + 6 + z.Nonce.Msgsize() + 11 + z.TargetUser.Msgsize() + 7 + z.NodeID.Msgsize() + 14 + hsp.Uint64Size + 9 + hsp.Uint64Size + 6 + hsp.Uint64Size + 7 + hsp.Uint64Size
+ s = 1 + 10 + z.TokenType.Msgsize() + 14 + hsp.Float64Size + 6 + z.Nonce.Msgsize() + 11 + z.TargetUser.Msgsize() + 7 + z.NodeID.Msgsize() + 9 + hsp.Uint64Size + 6 + hsp.Uint64Size + 7 + hsp.Uint64Size
return
}
diff --git a/types/request_type_gen.go b/types/request_type_gen.go
index 709e66bb9..7033d7aa6 100644
--- a/types/request_type_gen.go
+++ b/types/request_type_gen.go
@@ -106,10 +106,20 @@ func (z *Request) MarshalHash() (o []byte, err error) {
o = append(o, 0x83, 0x83, 0x81, 0x81)
o = hsp.AppendArrayHeader(o, uint32(len(z.Payload.Queries)))
for za0001 := range z.Payload.Queries {
- if oTemp, err := z.Payload.Queries[za0001].MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
+ // map header, size 2
+ o = append(o, 0x82, 0x82)
+ o = hsp.AppendString(o, z.Payload.Queries[za0001].Pattern)
+ o = append(o, 0x82)
+ o = hsp.AppendArrayHeader(o, uint32(len(z.Payload.Queries[za0001].Args)))
+ for za0002 := range z.Payload.Queries[za0001].Args {
+ // map header, size 2
+ o = append(o, 0x82, 0x82)
+ o = hsp.AppendString(o, z.Payload.Queries[za0001].Args[za0002].Name)
+ o = append(o, 0x82)
+ o, err = hsp.AppendIntf(o, z.Payload.Queries[za0001].Args[za0002].Value)
+ if err != nil {
+ return
+ }
}
}
// map header, size 2
@@ -138,7 +148,10 @@ func (z *Request) MarshalHash() (o []byte, err error) {
func (z *Request) Msgsize() (s int) {
s = 1 + 8 + 1 + 8 + hsp.ArrayHeaderSize
for za0001 := range z.Payload.Queries {
- s += z.Payload.Queries[za0001].Msgsize()
+ s += 1 + 8 + hsp.StringPrefixSize + len(z.Payload.Queries[za0001].Pattern) + 5 + hsp.ArrayHeaderSize
+ for za0002 := range z.Payload.Queries[za0001].Args {
+ s += 1 + 5 + hsp.StringPrefixSize + len(z.Payload.Queries[za0001].Args[za0002].Name) + 6 + hsp.GuessSize(z.Payload.Queries[za0001].Args[za0002].Value)
+ }
}
s += 7 + 1 + 14 + z.Header.RequestHeader.Msgsize() + 28 + z.Header.DefaultHashSignVerifierImpl.Msgsize() + 9 + z.Envelope.Msgsize()
return
diff --git a/worker/db_test.go b/worker/db_test.go
index 29ecde74b..bc872d172 100644
--- a/worker/db_test.go
+++ b/worker/db_test.go
@@ -719,11 +719,6 @@ func initNode() (cleanupFunc func(), server *rpc.Server, err error) {
return
}
- // register bpdb service
- if err = server.RegisterService(route.BPDBRPCName, &stubBPDBService{}); err != nil {
- return
- }
-
// init private key
masterKey := []byte("")
if err = server.InitRPCServer(conf.GConf.ListenAddr, privateKeyPath, masterKey); err != nil {
@@ -795,86 +790,6 @@ func createRandomBlock(parent hash.Hash, isGenesis bool) (b *types.Block, err er
return
}
-// fake BPDB service
-type stubBPDBService struct{}
-
-func (s *stubBPDBService) CreateDatabase(req *types.CreateDatabaseRequest, resp *types.CreateDatabaseResponse) (err error) {
- if resp.Header.InstanceMeta, err = s.getInstanceMeta("db2"); err != nil {
- return
- }
- if resp.Header.Signee, err = kms.GetLocalPublicKey(); err != nil {
- return
- }
- var privateKey *asymmetric.PrivateKey
- if privateKey, err = kms.GetLocalPrivateKey(); err != nil {
- return
- }
- err = resp.Sign(privateKey)
- return
-}
-
-func (s *stubBPDBService) DropDatabase(req *types.DropDatabaseRequest, resp *types.DropDatabaseRequest) (err error) {
- return
-}
-
-func (s *stubBPDBService) GetDatabase(req *types.GetDatabaseRequest, resp *types.GetDatabaseResponse) (err error) {
- if resp.Header.InstanceMeta, err = s.getInstanceMeta(req.Header.DatabaseID); err != nil {
- return
- }
- if resp.Header.Signee, err = kms.GetLocalPublicKey(); err != nil {
- return
- }
- var privateKey *asymmetric.PrivateKey
- if privateKey, err = kms.GetLocalPrivateKey(); err != nil {
- return
- }
- err = resp.Sign(privateKey)
- return
-}
-
-func (s *stubBPDBService) GetNodeDatabases(req *types.InitService, resp *types.InitServiceResponse) (err error) {
- resp.Header.Instances = make([]types.ServiceInstance, 1)
- resp.Header.Instances[0], err = s.getInstanceMeta("db2")
- if resp.Header.Signee, err = kms.GetLocalPublicKey(); err != nil {
- return
- }
-
- var privateKey *asymmetric.PrivateKey
- if privateKey, err = kms.GetLocalPrivateKey(); err != nil {
- return
- }
- err = resp.Sign(privateKey)
-
- return
-}
-
-func (s *stubBPDBService) getInstanceMeta(dbID proto.DatabaseID) (instance types.ServiceInstance, err error) {
- var privKey *asymmetric.PrivateKey
- if privKey, err = kms.GetLocalPrivateKey(); err != nil {
- return
- }
-
- var nodeID proto.NodeID
- if nodeID, err = kms.GetLocalNodeID(); err != nil {
- return
- }
-
- instance.DatabaseID = proto.DatabaseID(dbID)
- instance.Peers = &proto.Peers{
- PeersHeader: proto.PeersHeader{
- Term: 1,
- Leader: nodeID,
- Servers: []proto.NodeID{nodeID},
- },
- }
- if err = instance.Peers.Sign(privKey); err != nil {
- return
- }
- instance.GenesisBlock, err = createRandomBlock(rootHash, true)
-
- return
-}
-
// duplicate conf file using random new listen addr to avoid failure on concurrent test cases
func dupConf(confFile string, newConfFile string) (err error) {
// replace port in confFile
From 631bbbac5756045d2081890f05f33b2c3ed40ba5 Mon Sep 17 00:00:00 2001
From: auxten
Date: Wed, 26 Dec 2018 23:01:55 +0800
Subject: [PATCH 211/278] MatchProvidersWithUser scan TargetMiners then tries
best to get enought miners
---
blockproducer/errors.go | 4 +-
blockproducer/metastate.go | 145 +++++++++++++++++++++++------
cmd/cql-minerd/integration_test.go | 12 ++-
types/account.go | 2 +-
types/provideservice.go | 3 +-
5 files changed, 128 insertions(+), 38 deletions(-)
diff --git a/blockproducer/errors.go b/blockproducer/errors.go
index dd05596ca..81d88a83b 100644
--- a/blockproducer/errors.go
+++ b/blockproducer/errors.go
@@ -84,14 +84,14 @@ var (
ErrInvalidPermission = errors.New("invalid permission")
// ErrMinerUserNotMatch indicates that the miner and user do not match.
ErrMinerUserNotMatch = errors.New("miner and user do not match")
- // ErrGasPriceMismatch indicates that the gas price of miner and user do not match.
- ErrGasPriceMismatch = errors.New("gas price mismatches")
// ErrInsufficientAdvancePayment indicates that the advance payment is insufficient.
ErrInsufficientAdvancePayment = errors.New("insufficient advance payment")
// ErrMultipleGenesis indicates that there're multiple genesis blocks while loading.
ErrMultipleGenesis = errors.New("multiple genesis blocks")
// ErrInvalidGasPrice indicates that the gas price is invalid.
ErrInvalidGasPrice = errors.New("gas price is invalid")
+ // ErrInvalidMinerCount indicates that the miner node count is invalid.
+ ErrInvalidMinerCount = errors.New("miner node count is invalid")
// ErrLocalNodeNotFound indicates that the local node id is not found in the given peer list.
ErrLocalNodeNotFound = errors.New("local node id not found in peer list")
// ErrNoAvailableBranch indicates that there is no available branch from the state storage.
diff --git a/blockproducer/metastate.go b/blockproducer/metastate.go
index 39ff03089..5bcde5be6 100644
--- a/blockproducer/metastate.go
+++ b/blockproducer/metastate.go
@@ -20,6 +20,9 @@ import (
"bytes"
"time"
+ "github.com/mohae/deepcopy"
+ "github.com/pkg/errors"
+
pi "github.com/CovenantSQL/CovenantSQL/blockproducer/interfaces"
"github.com/CovenantSQL/CovenantSQL/conf"
"github.com/CovenantSQL/CovenantSQL/crypto"
@@ -30,8 +33,6 @@ import (
"github.com/CovenantSQL/CovenantSQL/types"
"github.com/CovenantSQL/CovenantSQL/utils"
"github.com/CovenantSQL/CovenantSQL/utils/log"
- "github.com/mohae/deepcopy"
- "github.com/pkg/errors"
)
var (
@@ -549,11 +550,14 @@ func (s *metaState) matchProvidersWithUser(tx *types.CreateDatabase) (err error)
err = ErrInvalidGasPrice
return
}
+ if tx.ResourceMeta.Node <= 0 {
+ err = ErrInvalidMinerCount
+ return
+ }
+ minerCount := uint64(tx.ResourceMeta.Node)
+ minAdvancePayment := uint64(tx.GasPrice) * uint64(conf.GConf.QPS) *
+ uint64(conf.GConf.UpdatePeriod) * minerCount
- var (
- minAdvancePayment = uint64(tx.GasPrice) * uint64(conf.GConf.QPS) *
- uint64(conf.GConf.UpdatePeriod) * uint64(len(tx.ResourceMeta.TargetMiners))
- )
if tx.AdvancePayment < minAdvancePayment {
err = ErrInsufficientAdvancePayment
log.WithError(err).Warningf("tx.AdvancePayment: %d, minAdvancePayment: %d",
@@ -561,43 +565,50 @@ func (s *metaState) matchProvidersWithUser(tx *types.CreateDatabase) (err error)
return
}
- var (
- miners = make([]*types.MinerInfo, len(tx.ResourceMeta.TargetMiners))
- )
+ miners := make([]*types.MinerInfo, 0, minerCount)
- for i := range tx.ResourceMeta.TargetMiners {
- if po, loaded := s.loadProviderObject(tx.ResourceMeta.TargetMiners[i]); !loaded {
+ for _, m := range tx.ResourceMeta.TargetMiners {
+ if po, loaded := s.loadProviderObject(m); !loaded {
log.WithFields(log.Fields{
- "miner_addr": tx.ResourceMeta.TargetMiners[i].String(),
+ "miner_addr": m.String(),
"user_addr": sender.String(),
}).Error(err)
err = ErrNoSuchMiner
- break
+ continue
} else {
- if po.TargetUser != sender {
- log.WithFields(log.Fields{
- "miner_addr": tx.ResourceMeta.TargetMiners[i].String(),
- "user_addr": sender.String(),
- }).Error(ErrMinerUserNotMatch)
- err = ErrMinerUserNotMatch
- break
+ miners, _ := filterAndAppendMiner(miners, po, tx, sender)
+ // if got enough, break
+ if uint64(len(miners)) == minerCount {
+ continue
}
- if po.GasPrice > tx.GasPrice {
- err = ErrGasPriceMismatch
- log.WithError(err).Warningf("miner's gas price: %d, user's gas price: %d",
- po.GasPrice, tx.GasPrice)
+ }
+ }
+
+ // not enough, find more miner(s)
+ if uint64(len(miners)) < minerCount {
+ if uint64(len(tx.ResourceMeta.TargetMiners)) >= minerCount {
+ err = errors.New("miners match target are not enough")
+ return
+ }
+ // try old miners first
+ for _, po := range s.readonly.provider {
+ miners, _ := filterAndAppendMiner(miners, po, tx, sender)
+ // if got enough, break
+ if uint64(len(miners)) == minerCount {
break
}
- miners[i] = &types.MinerInfo{
- Address: po.Provider,
- NodeID: po.NodeID,
- Deposit: po.Deposit,
+ }
+ // try fresh miners
+ if uint64(len(miners)) < minerCount {
+ for _, po := range s.dirty.provider {
+ miners, _ := filterAndAppendMiner(miners, po, tx, sender)
+ // if got enough, break
+ if uint64(len(miners)) == minerCount {
+ break
+ }
}
}
}
- if err != nil {
- return
- }
// generate new sqlchain id and address
dbID := proto.FromAccountAndNonce(tx.Owner, uint32(tx.Nonce))
@@ -669,6 +680,78 @@ func (s *metaState) matchProvidersWithUser(tx *types.CreateDatabase) (err error)
return
}
+func filterAndAppendMiner(
+ miners []*types.MinerInfo,
+ po *types.ProviderProfile,
+ req *types.CreateDatabase,
+ user proto.AccountAddress,
+) (newMiners []*types.MinerInfo, err error) {
+ newMiners = miners
+ if !isProviderUserMatch(po.TargetUser, user) {
+ err = errors.New("user not in target user")
+ return
+ }
+ var match bool
+ if match, err = isProviderReqMatch(po, req); !match {
+ return
+ }
+ newMiners = append(miners, &types.MinerInfo{
+ Address: po.Provider,
+ NodeID: po.NodeID,
+ Deposit: po.Deposit,
+ })
+ return
+}
+
+func isProviderUserMatch(targetUsers []proto.AccountAddress, user proto.AccountAddress) (match bool) {
+ if len(targetUsers) > 0 {
+ for _, u := range targetUsers {
+ if u == user {
+ match = true
+ }
+ }
+ } else {
+ match = true
+ }
+ return
+}
+
+func isProviderReqMatch(po *types.ProviderProfile, req *types.CreateDatabase) (match bool, err error) {
+
+ if po.GasPrice > req.GasPrice {
+ err = errors.New("gas price mismatch")
+ log.WithError(err).Debugf("miner's gas price: %d, user's gas price: %d",
+ po.GasPrice, req.GasPrice)
+ return
+ }
+ if po.LoadAvgPerCPU > req.ResourceMeta.LoadAvgPerCPU {
+ err = errors.New("load average mismatch")
+ log.WithError(err).Debugf("miner's LoadAvgPerCPU: %d, user's LoadAvgPerCPU: %d",
+ po.LoadAvgPerCPU, req.ResourceMeta.LoadAvgPerCPU)
+ return
+ }
+ if po.Memory < req.ResourceMeta.Memory {
+ err = errors.New("memory mismatch")
+ log.WithError(err).Debugf("miner's memory: %d, user's memory: %d",
+ po.Memory, req.ResourceMeta.Memory)
+ return
+ }
+ if po.Space < req.ResourceMeta.Space {
+ err = errors.New("disk space mismatch")
+ log.WithError(err).Debugf("miner's disk space: %d, user's disk space: %d",
+ po.Space, req.ResourceMeta.Space)
+ return
+ }
+ if po.TokenType != req.TokenType {
+ err = errors.New("token type mismatch")
+ log.WithError(err).Debugf("miner's token type: %s, user's token type: %s",
+ po.TokenType.String(), req.TokenType.String())
+ return
+ }
+
+ return true, nil
+}
+
func (s *metaState) updatePermission(tx *types.UpdatePermission) (err error) {
sender, err := crypto.PubKeyHash(tx.Signee)
if err != nil {
diff --git a/cmd/cql-minerd/integration_test.go b/cmd/cql-minerd/integration_test.go
index f98bfc23a..faf1d2882 100644
--- a/cmd/cql-minerd/integration_test.go
+++ b/cmd/cql-minerd/integration_test.go
@@ -34,6 +34,9 @@ import (
"testing"
"time"
+ sqlite3 "github.com/CovenantSQL/go-sqlite3-encrypt"
+ . "github.com/smartystreets/goconvey/convey"
+
"github.com/CovenantSQL/CovenantSQL/blockproducer/interfaces"
"github.com/CovenantSQL/CovenantSQL/client"
"github.com/CovenantSQL/CovenantSQL/conf"
@@ -46,8 +49,6 @@ import (
"github.com/CovenantSQL/CovenantSQL/types"
"github.com/CovenantSQL/CovenantSQL/utils"
"github.com/CovenantSQL/CovenantSQL/utils/log"
- sqlite3 "github.com/CovenantSQL/go-sqlite3-encrypt"
- . "github.com/smartystreets/goconvey/convey"
)
var (
@@ -392,7 +393,7 @@ func TestFullProcess(t *testing.T) {
&types.ProvideServiceHeader{
GasPrice: testGasPrice,
TokenType: types.Particle,
- TargetUser: clientAddr,
+ TargetUser: []proto.AccountAddress{clientAddr},
NodeID: minersNodeID[i],
Nonce: nonce,
},
@@ -404,6 +405,7 @@ func TestFullProcess(t *testing.T) {
}
time.Sleep(20 * time.Second)
+ time.Sleep(time.Hour)
// client send create database transaction
nonce, err := getNonce(clientAddr)
@@ -433,6 +435,10 @@ func TestFullProcess(t *testing.T) {
profileReq := &types.QuerySQLChainProfileReq{}
profileResp := &types.QuerySQLChainProfileResp{}
profileReq.DBID = *dbID
+
+ //b, _ := json.Marshal(profileReq)
+ //log.Fatalf("MCCQuerySQLChainProfile %s", string(b))
+
err = rpc.RequestBP(route.MCCQuerySQLChainProfile.String(), profileReq, profileResp)
So(err, ShouldBeNil)
profile := profileResp.Profile
diff --git a/types/account.go b/types/account.go
index 3bc209ce6..0b011f65e 100644
--- a/types/account.go
+++ b/types/account.go
@@ -144,7 +144,7 @@ type ProviderProfile struct {
Space uint64 // reserved storage space in bytes
Memory uint64 // reserved memory in bytes
LoadAvgPerCPU uint64 // max loadAvg15 per CPU
- TargetUser proto.AccountAddress
+ TargetUser []proto.AccountAddress
Deposit uint64 // default 10 Particle
GasPrice uint64
TokenType TokenType // default Particle
diff --git a/types/provideservice.go b/types/provideservice.go
index 4c99ddd41..90b1e08b5 100644
--- a/types/provideservice.go
+++ b/types/provideservice.go
@@ -26,12 +26,13 @@ import (
//go:generate hsp
+//TODO(guozeqing): merge similar part of types.ProviderProfile
// ProvideServiceHeader define the miner providing service transaction header.
type ProvideServiceHeader struct {
Space uint64 // reserved storage space in bytes
Memory uint64 // reserved memory in bytes
LoadAvgPerCPU uint64 // max loadAvg15 per CPU
- TargetUser proto.AccountAddress
+ TargetUser []proto.AccountAddress
GasPrice uint64
TokenType TokenType
NodeID proto.NodeID
From ea3effc78695a36afdf9c77e5444530cff1287be Mon Sep 17 00:00:00 2001
From: zeqing-guo
Date: Wed, 26 Dec 2018 23:04:49 +0800
Subject: [PATCH 212/278] Add dbms test case
---
worker/dbms.go | 8 --
worker/dbms_test.go | 206 +++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 202 insertions(+), 12 deletions(-)
diff --git a/worker/dbms.go b/worker/dbms.go
index c18a2b485..d5b5f1e18 100644
--- a/worker/dbms.go
+++ b/worker/dbms.go
@@ -621,14 +621,6 @@ func (dbms *DBMS) addTxSubscription(dbID proto.DatabaseID, nodeID proto.NodeID,
}
db := rawDB.(*Database)
err = db.chain.AddSubscription(nodeID, startHeight)
- if err != nil {
- log.WithFields(log.Fields{
- "databaseID": dbID,
- "nodeID": nodeID,
- "startHeight": startHeight,
- }).WithError(err).Warning("unexpected error in addTxSubscription")
- return
- }
return
}
diff --git a/worker/dbms_test.go b/worker/dbms_test.go
index 70e06c7fc..65a1efbc7 100644
--- a/worker/dbms_test.go
+++ b/worker/dbms_test.go
@@ -30,6 +30,7 @@ import (
"github.com/CovenantSQL/CovenantSQL/route"
"github.com/CovenantSQL/CovenantSQL/rpc"
"github.com/CovenantSQL/CovenantSQL/types"
+ "github.com/pkg/errors"
. "github.com/smartystreets/goconvey/convey"
)
@@ -72,9 +73,14 @@ func TestDBMS(t *testing.T) {
var res types.UpdateServiceResponse
var peers *proto.Peers
var block *types.Block
+ var nodeID proto.NodeID
+
+ nodeID, err = kms.GetLocalNodeID()
dbAddr := proto.AccountAddress(hash.HashH([]byte{'d', 'b'}))
dbID := dbAddr.DatabaseID()
+ dbAddr2 := proto.AccountAddress(hash.HashH([]byte{'a', 'b'}))
+ dbID2 := dbAddr2.DatabaseID()
userAddr, err := crypto.PubKeyHash(publicKey)
So(err, ShouldBeNil)
@@ -102,12 +108,36 @@ func TestDBMS(t *testing.T) {
err = testRequest(route.DBSDeploy, req, &res)
So(err, ShouldBeNil)
- // grant permission
+ Convey("query should fail", func() {
+ // sending write query
+ var writeQuery *types.Request
+ var queryRes *types.Response
+ writeQuery, err = buildQueryWithDatabaseID(types.WriteQuery, 1, 1, dbID, []string{
+ "create table test (test int)",
+ "insert into test values(1)",
+ })
+ So(err, ShouldBeNil)
+
+ err = testRequest(route.DBSQuery, writeQuery, &queryRes)
+ So(err.Error(), ShouldEqual, ErrPermissionDeny.Error())
+
+ // sending read query
+ var readQuery *types.Request
+ readQuery, err = buildQueryWithDatabaseID(types.ReadQuery, 1, 2, dbID, []string{
+ "select * from test",
+ })
+ So(err, ShouldBeNil)
+
+ err = testRequest(route.DBSQuery, readQuery, &queryRes)
+ So(err.Error(), ShouldEqual, ErrPermissionDeny.Error())
+ })
+
+ // grant read permission
up := &types.UpdatePermission{
UpdatePermissionHeader: types.UpdatePermissionHeader{
TargetSQLChain: dbAddr,
TargetUser: userAddr,
- Permission: types.Admin,
+ Permission: types.Write,
},
}
err = up.Sign(privateKey)
@@ -118,14 +148,14 @@ func TestDBMS(t *testing.T) {
userState := us.(types.UserState)
perm, ok := userState.GetPermission(userAddr)
So(ok, ShouldBeTrue)
- So(perm, ShouldEqual, types.Admin)
+ So(perm, ShouldEqual, types.Write)
stat, ok := userState.GetStatus(userAddr)
So(ok, ShouldBeTrue)
So(stat, ShouldEqual, types.UnknownStatus)
userState.UpdateStatus(userAddr, types.Normal)
dbms.chainMap.Store(dbID, userState)
- Convey("queries", func() {
+ Convey("success write and read", func() {
// sending write query
var writeQuery *types.Request
var queryRes *types.Response
@@ -167,6 +197,174 @@ func TestDBMS(t *testing.T) {
var ackRes types.AckResponse
err = testRequest(route.DBSAck, ack, &ackRes)
So(err, ShouldBeNil)
+
+ err = dbms.addTxSubscription(dbID2, nodeID, 1)
+ So(errors.Cause(err), ShouldEqual, ErrNotExists)
+ err = dbms.addTxSubscription(dbID, nodeID, 1)
+ So(err, ShouldBeNil)
+ err = dbms.cancelTxSubscription(dbID, nodeID)
+ So(err, ShouldBeNil)
+
+ // grant read permission
+ up = &types.UpdatePermission{
+ UpdatePermissionHeader: types.UpdatePermissionHeader{
+ TargetSQLChain: dbAddr,
+ TargetUser: userAddr,
+ Permission: types.Read,
+ },
+ }
+ err = up.Sign(privateKey)
+ So(err, ShouldBeNil)
+ dbms.updatePermission(up, 0)
+
+ Convey("success reading and fail to write", func() {
+ // sending write query
+ var writeQuery *types.Request
+ var queryRes *types.Response
+ writeQuery, err = buildQueryWithDatabaseID(types.WriteQuery, 1, 3, dbID, []string{
+ "create table test (test int)",
+ "insert into test values(1)",
+ })
+ So(err, ShouldBeNil)
+
+ err = testRequest(route.DBSQuery, writeQuery, &queryRes)
+ So(err.Error(), ShouldEqual, ErrPermissionDeny.Error())
+
+ // sending read query
+ var readQuery *types.Request
+ readQuery, err = buildQueryWithDatabaseID(types.ReadQuery, 1, 4, dbID, []string{
+ "select * from test",
+ })
+ So(err, ShouldBeNil)
+
+ err = testRequest(route.DBSQuery, readQuery, &queryRes)
+ So(err, ShouldBeNil)
+
+ err = dbms.addTxSubscription(dbID, nodeID, 1)
+ So(err, ShouldBeNil)
+ })
+ })
+
+ // grant invalid permission
+ up = &types.UpdatePermission{
+ UpdatePermissionHeader: types.UpdatePermissionHeader{
+ TargetSQLChain: dbAddr,
+ TargetUser: userAddr,
+ Permission: types.NumberOfUserPermission,
+ },
+ }
+ err = up.Sign(privateKey)
+ So(err, ShouldBeNil)
+ dbms.updatePermission(up, 0)
+
+ Convey("invalid permission query should fail", func() {
+ // sending write query
+ var writeQuery *types.Request
+ var queryRes *types.Response
+ writeQuery, err = buildQueryWithDatabaseID(types.WriteQuery, 1, 5, dbID, []string{
+ "create table test (test int)",
+ "insert into test values(1)",
+ })
+ So(err, ShouldBeNil)
+
+ err = testRequest(route.DBSQuery, writeQuery, &queryRes)
+ So(err.Error(), ShouldEqual, ErrPermissionDeny.Error())
+
+ // sending read query
+ var readQuery *types.Request
+ readQuery, err = buildQueryWithDatabaseID(types.ReadQuery, 1, 6, dbID, []string{
+ "select * from test",
+ })
+ So(err, ShouldBeNil)
+
+ err = testRequest(route.DBSQuery, readQuery, &queryRes)
+ So(err.Error(), ShouldEqual, ErrPermissionDeny.Error())
+
+ err = dbms.addTxSubscription(dbID, nodeID, 1)
+ So(err, ShouldEqual, ErrPermissionDeny)
+ })
+
+ // switch user to arrears
+ us, ok = dbms.chainMap.Load(dbID)
+ So(ok, ShouldBeTrue)
+ userState = us.(types.UserState)
+ userState.UpdatePermission(userAddr, types.Admin)
+ userState.UpdateStatus(userAddr, types.Arrears)
+ dbms.chainMap.Store(dbID, userState)
+
+ Convey("arrears query should fail", func() {
+ // sending write query
+ var writeQuery *types.Request
+ var queryRes *types.Response
+ writeQuery, err = buildQueryWithDatabaseID(types.WriteQuery, 1, 7, dbID, []string{
+ "create table test (test int)",
+ "insert into test values(1)",
+ })
+ So(err, ShouldBeNil)
+
+ err = testRequest(route.DBSQuery, writeQuery, &queryRes)
+ So(err.Error(), ShouldEqual, ErrPermissionDeny.Error())
+
+ // sending read query
+ var readQuery *types.Request
+ readQuery, err = buildQueryWithDatabaseID(types.ReadQuery, 1, 8, dbID, []string{
+ "select * from test",
+ })
+ So(err, ShouldBeNil)
+
+ err = testRequest(route.DBSQuery, readQuery, &queryRes)
+ So(err.Error(), ShouldEqual, ErrPermissionDeny.Error())
+ })
+
+ // switch user to normal
+ us, ok = dbms.chainMap.Load(dbID)
+ So(ok, ShouldBeTrue)
+ userState = us.(types.UserState)
+ userState.UpdateStatus(userAddr, types.Normal)
+ dbms.chainMap.Store(dbID, userState)
+
+ Convey("queries", func() {
+ // sending write query
+ var writeQuery *types.Request
+ var queryRes *types.Response
+ writeQuery, err = buildQueryWithDatabaseID(types.WriteQuery, 1, 9, dbID, []string{
+ "create table test (test int)",
+ "insert into test values(1)",
+ })
+ So(err, ShouldBeNil)
+
+ err = testRequest(route.DBSQuery, writeQuery, &queryRes)
+ So(err, ShouldBeNil)
+ err = queryRes.Verify()
+ So(err, ShouldBeNil)
+ So(queryRes.Header.RowCount, ShouldEqual, 0)
+
+ // sending read query
+ var readQuery *types.Request
+ readQuery, err = buildQueryWithDatabaseID(types.ReadQuery, 1, 10, dbID, []string{
+ "select * from test",
+ })
+ So(err, ShouldBeNil)
+
+ err = testRequest(route.DBSQuery, readQuery, &queryRes)
+ So(err, ShouldBeNil)
+ err = queryRes.Verify()
+ So(err, ShouldBeNil)
+ So(queryRes.Header.RowCount, ShouldEqual, uint64(1))
+ So(queryRes.Payload.Columns, ShouldResemble, []string{"test"})
+ So(queryRes.Payload.DeclTypes, ShouldResemble, []string{"int"})
+ So(queryRes.Payload.Rows, ShouldNotBeEmpty)
+ So(queryRes.Payload.Rows[0].Values, ShouldNotBeEmpty)
+ So(queryRes.Payload.Rows[0].Values[0], ShouldEqual, 1)
+
+ // sending read ack
+ var ack *types.Ack
+ ack, err = buildAck(queryRes)
+ So(err, ShouldBeNil)
+
+ var ackRes types.AckResponse
+ err = testRequest(route.DBSAck, ack, &ackRes)
+ So(err, ShouldBeNil)
})
Convey("query non-existent database", func() {
From 9afc56d8bff0b0155f689ae06dd52f178607bc59 Mon Sep 17 00:00:00 2001
From: auxten
Date: Wed, 26 Dec 2018 23:15:26 +0800
Subject: [PATCH 213/278] Fix stupid commit
---
cmd/cql-minerd/integration_test.go | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/cmd/cql-minerd/integration_test.go b/cmd/cql-minerd/integration_test.go
index 2eed539c3..9824d8ae2 100644
--- a/cmd/cql-minerd/integration_test.go
+++ b/cmd/cql-minerd/integration_test.go
@@ -370,12 +370,12 @@ func TestFullProcess(t *testing.T) {
So(err, ShouldBeNil)
time.Sleep(20 * time.Second)
- time.Sleep(time.Hour)
// client send create database transaction
meta := client.ResourceMeta{
ResourceMeta: types.ResourceMeta{
TargetMiners: minersAddrs,
+ Node: uint16(len(minersAddrs)),
},
GasPrice: testGasPrice,
AdvancePayment: testAdvancePayment,
From dfb44a114d6c91a50047b18e531fd5bfec4ec500 Mon Sep 17 00:00:00 2001
From: auxten
Date: Wed, 26 Dec 2018 23:16:51 +0800
Subject: [PATCH 214/278] Regen types
---
types/account_gen.go | 21 ++++++++++++++-------
types/init_service_type_gen.go | 21 ++++++++++++++++++---
types/no_ack_report_type_gen.go | 21 ++-------------------
types/provideservice_gen.go | 21 ++++++++++++++-------
4 files changed, 48 insertions(+), 36 deletions(-)
diff --git a/types/account_gen.go b/types/account_gen.go
index 960d26425..e69e63642 100644
--- a/types/account_gen.go
+++ b/types/account_gen.go
@@ -114,6 +114,15 @@ func (z *ProviderProfile) MarshalHash() (o []byte, err error) {
o = hsp.AppendBytes(o, oTemp)
}
o = append(o, 0x89)
+ o = hsp.AppendArrayHeader(o, uint32(len(z.TargetUser)))
+ for za0001 := range z.TargetUser {
+ if oTemp, err := z.TargetUser[za0001].MarshalHash(); err != nil {
+ return nil, err
+ } else {
+ o = hsp.AppendBytes(o, oTemp)
+ }
+ }
+ o = append(o, 0x89)
o = hsp.AppendFloat64(o, z.LoadAvgPerCPU)
o = append(o, 0x89)
if oTemp, err := z.Provider.MarshalHash(); err != nil {
@@ -122,12 +131,6 @@ func (z *ProviderProfile) MarshalHash() (o []byte, err error) {
o = hsp.AppendBytes(o, oTemp)
}
o = append(o, 0x89)
- if oTemp, err := z.TargetUser.MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
- }
- o = append(o, 0x89)
if oTemp, err := z.NodeID.MarshalHash(); err != nil {
return nil, err
} else {
@@ -146,7 +149,11 @@ func (z *ProviderProfile) MarshalHash() (o []byte, err error) {
// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (z *ProviderProfile) Msgsize() (s int) {
- s = 1 + 10 + z.TokenType.Msgsize() + 14 + hsp.Float64Size + 9 + z.Provider.Msgsize() + 11 + z.TargetUser.Msgsize() + 7 + z.NodeID.Msgsize() + 8 + hsp.Uint64Size + 9 + hsp.Uint64Size + 6 + hsp.Uint64Size + 7 + hsp.Uint64Size
+ s = 1 + 10 + z.TokenType.Msgsize() + 11 + hsp.ArrayHeaderSize
+ for za0001 := range z.TargetUser {
+ s += z.TargetUser[za0001].Msgsize()
+ }
+ s += 14 + hsp.Float64Size + 9 + z.Provider.Msgsize() + 7 + z.NodeID.Msgsize() + 8 + hsp.Uint64Size + 9 + hsp.Uint64Size + 6 + hsp.Uint64Size + 7 + hsp.Uint64Size
return
}
diff --git a/types/init_service_type_gen.go b/types/init_service_type_gen.go
index b289ec50d..ae24575c7 100644
--- a/types/init_service_type_gen.go
+++ b/types/init_service_type_gen.go
@@ -31,8 +31,19 @@ func (z *InitServiceResponse) MarshalHash() (o []byte, err error) {
var b []byte
o = hsp.Require(b, z.Msgsize())
// map header, size 1
- o = append(o, 0x81, 0x81)
- if oTemp, err := z.Header.MarshalHash(); err != nil {
+ // map header, size 2
+ // map header, size 1
+ o = append(o, 0x81, 0x81, 0x82, 0x82, 0x81, 0x81)
+ o = hsp.AppendArrayHeader(o, uint32(len(z.Header.InitServiceResponseHeader.Instances)))
+ for za0001 := range z.Header.InitServiceResponseHeader.Instances {
+ if oTemp, err := z.Header.InitServiceResponseHeader.Instances[za0001].MarshalHash(); err != nil {
+ return nil, err
+ } else {
+ o = hsp.AppendBytes(o, oTemp)
+ }
+ }
+ o = append(o, 0x82)
+ if oTemp, err := z.Header.DefaultHashSignVerifierImpl.MarshalHash(); err != nil {
return nil, err
} else {
o = hsp.AppendBytes(o, oTemp)
@@ -42,7 +53,11 @@ func (z *InitServiceResponse) MarshalHash() (o []byte, err error) {
// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (z *InitServiceResponse) Msgsize() (s int) {
- s = 1 + 7 + z.Header.Msgsize()
+ s = 1 + 7 + 1 + 26 + 1 + 10 + hsp.ArrayHeaderSize
+ for za0001 := range z.Header.InitServiceResponseHeader.Instances {
+ s += z.Header.InitServiceResponseHeader.Instances[za0001].Msgsize()
+ }
+ s += 28 + z.Header.DefaultHashSignVerifierImpl.Msgsize()
return
}
diff --git a/types/no_ack_report_type_gen.go b/types/no_ack_report_type_gen.go
index 374a39fea..e9e89abc6 100644
--- a/types/no_ack_report_type_gen.go
+++ b/types/no_ack_report_type_gen.go
@@ -57,24 +57,7 @@ func (z *AggrNoAckReportHeader) MarshalHash() (o []byte, err error) {
o = append(o, 0x84)
o = hsp.AppendArrayHeader(o, uint32(len(z.Reports)))
for za0001 := range z.Reports {
- // map header, size 2
- // map header, size 3
- o = append(o, 0x82, 0x82, 0x83, 0x83)
- if oTemp, err := z.Reports[za0001].NoAckReportHeader.NodeID.MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
- }
- o = append(o, 0x83)
- o = hsp.AppendTime(o, z.Reports[za0001].NoAckReportHeader.Timestamp)
- o = append(o, 0x83)
- if oTemp, err := z.Reports[za0001].NoAckReportHeader.Response.MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
- }
- o = append(o, 0x82)
- if oTemp, err := z.Reports[za0001].DefaultHashSignVerifierImpl.MarshalHash(); err != nil {
+ if oTemp, err := z.Reports[za0001].MarshalHash(); err != nil {
return nil, err
} else {
o = hsp.AppendBytes(o, oTemp)
@@ -101,7 +84,7 @@ func (z *AggrNoAckReportHeader) Msgsize() (s int) {
}
s += 8 + hsp.ArrayHeaderSize
for za0001 := range z.Reports {
- s += 1 + 18 + 1 + 7 + z.Reports[za0001].NoAckReportHeader.NodeID.Msgsize() + 10 + hsp.TimeSize + 9 + z.Reports[za0001].NoAckReportHeader.Response.Msgsize() + 28 + z.Reports[za0001].DefaultHashSignVerifierImpl.Msgsize()
+ s += z.Reports[za0001].Msgsize()
}
s += 7 + z.NodeID.Msgsize() + 10 + hsp.TimeSize
return
diff --git a/types/provideservice_gen.go b/types/provideservice_gen.go
index e6c882c85..c3925d3b1 100644
--- a/types/provideservice_gen.go
+++ b/types/provideservice_gen.go
@@ -50,6 +50,15 @@ func (z *ProvideServiceHeader) MarshalHash() (o []byte, err error) {
o = hsp.AppendBytes(o, oTemp)
}
o = append(o, 0x88)
+ o = hsp.AppendArrayHeader(o, uint32(len(z.TargetUser)))
+ for za0001 := range z.TargetUser {
+ if oTemp, err := z.TargetUser[za0001].MarshalHash(); err != nil {
+ return nil, err
+ } else {
+ o = hsp.AppendBytes(o, oTemp)
+ }
+ }
+ o = append(o, 0x88)
o = hsp.AppendFloat64(o, z.LoadAvgPerCPU)
o = append(o, 0x88)
if oTemp, err := z.Nonce.MarshalHash(); err != nil {
@@ -58,12 +67,6 @@ func (z *ProvideServiceHeader) MarshalHash() (o []byte, err error) {
o = hsp.AppendBytes(o, oTemp)
}
o = append(o, 0x88)
- if oTemp, err := z.TargetUser.MarshalHash(); err != nil {
- return nil, err
- } else {
- o = hsp.AppendBytes(o, oTemp)
- }
- o = append(o, 0x88)
if oTemp, err := z.NodeID.MarshalHash(); err != nil {
return nil, err
} else {
@@ -80,6 +83,10 @@ func (z *ProvideServiceHeader) MarshalHash() (o []byte, err error) {
// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (z *ProvideServiceHeader) Msgsize() (s int) {
- s = 1 + 10 + z.TokenType.Msgsize() + 14 + hsp.Float64Size + 6 + z.Nonce.Msgsize() + 11 + z.TargetUser.Msgsize() + 7 + z.NodeID.Msgsize() + 9 + hsp.Uint64Size + 6 + hsp.Uint64Size + 7 + hsp.Uint64Size
+ s = 1 + 10 + z.TokenType.Msgsize() + 11 + hsp.ArrayHeaderSize
+ for za0001 := range z.TargetUser {
+ s += z.TargetUser[za0001].Msgsize()
+ }
+ s += 14 + hsp.Float64Size + 6 + z.Nonce.Msgsize() + 7 + z.NodeID.Msgsize() + 9 + hsp.Uint64Size + 6 + hsp.Uint64Size + 7 + hsp.Uint64Size
return
}
From cc664bc72071c1ecdafe28f21a64937ca96df929 Mon Sep 17 00:00:00 2001
From: leventeliu
Date: Wed, 26 Dec 2018 23:21:25 +0800
Subject: [PATCH 215/278] Fix observer testing
---
blockproducer/rpc.go | 54 ++++++++++++++++++++++++++++
cmd/cql-observer/observation_test.go | 39 ++++++++------------
cmd/cql-observer/service.go | 44 ++++++++++++++++++-----
3 files changed, 103 insertions(+), 34 deletions(-)
diff --git a/blockproducer/rpc.go b/blockproducer/rpc.go
index ab98adfad..7a0f7fe6c 100644
--- a/blockproducer/rpc.go
+++ b/blockproducer/rpc.go
@@ -18,8 +18,11 @@ package blockproducer
import (
"context"
+ "fmt"
"time"
+ "github.com/CovenantSQL/CovenantSQL/crypto"
+ "github.com/CovenantSQL/CovenantSQL/crypto/asymmetric"
"github.com/CovenantSQL/CovenantSQL/proto"
"github.com/CovenantSQL/CovenantSQL/route"
"github.com/CovenantSQL/CovenantSQL/rpc"
@@ -173,3 +176,54 @@ func WaitDatabaseCreation(
}
}
}
+
+func Create(
+ meta types.ResourceMeta,
+ gasPrice uint64,
+ advancePayment uint64,
+ privateKey *asymmetric.PrivateKey,
+) (
+ databaseid proto.DatabaseID, dsn string, err error,
+) {
+ var (
+ nonceReq = new(types.NextAccountNonceReq)
+ nonceResp = new(types.NextAccountNonceResp)
+ req = new(types.AddTxReq)
+ resp = new(types.AddTxResp)
+ clientAddr proto.AccountAddress
+ )
+ if clientAddr, err = crypto.PubKeyHash(privateKey.PubKey()); err != nil {
+ err = errors.Wrap(err, "get local account address failed")
+ return
+ }
+ // allocate nonce
+ nonceReq.Addr = clientAddr
+
+ if err = rpc.RequestBP(route.MCCNextAccountNonce.String(), nonceReq, nonceResp); err != nil {
+ err = errors.Wrap(err, "allocate create database transaction nonce failed")
+ return
+ }
+
+ req.Tx = types.NewCreateDatabase(&types.CreateDatabaseHeader{
+ Owner: clientAddr,
+ ResourceMeta: meta,
+ GasPrice: gasPrice,
+ AdvancePayment: advancePayment,
+ TokenType: types.Particle,
+ Nonce: nonceResp.Nonce,
+ })
+
+ if err = req.Tx.Sign(privateKey); err != nil {
+ err = errors.Wrap(err, "sign request failed")
+ return
+ }
+
+ if err = rpc.RequestBP(route.MCCAddTx.String(), req, resp); err != nil {
+ err = errors.Wrap(err, "call create database transaction failed")
+ return
+ }
+
+ databaseid = *proto.FromAccountAndNonce(clientAddr, uint32(nonceResp.Nonce))
+ dsn = fmt.Sprintf("cql://%s?use_leader=1&use_follower=0", string(databaseid))
+ return
+}
diff --git a/cmd/cql-observer/observation_test.go b/cmd/cql-observer/observation_test.go
index 846e46ebe..1c463122e 100644
--- a/cmd/cql-observer/observation_test.go
+++ b/cmd/cql-observer/observation_test.go
@@ -57,10 +57,9 @@ var nodeCmds []*utils.CMD
var FJ = filepath.Join
-func privKeyStoreToAccountAddr(path string, master []byte) (addr proto.AccountAddress, err error) {
- var (
- priv *asymmetric.PrivateKey
- )
+func privKeyStoreToAccountAddr(
+ path string, master []byte) (priv *asymmetric.PrivateKey, addr proto.AccountAddress, err error,
+) {
if priv, err = kms.LoadPrivateKey(path, master); err != nil {
return
}
@@ -253,6 +252,7 @@ func TestFullProcess(t *testing.T) {
Convey("test full process", t, func() {
var (
err error
+ priv, priv2 *asymmetric.PrivateKey
addr, addr2 proto.AccountAddress
dsn, dsn2 string
cfg, cfg2 *client.Config
@@ -269,23 +269,18 @@ func TestFullProcess(t *testing.T) {
So(err, ShouldBeNil)
// get miner addresses
- addr, err = privKeyStoreToAccountAddr(
+ priv, addr, err = privKeyStoreToAccountAddr(
FJ(testWorkingDir, "./observation/node_miner_0/private.key"), []byte{})
So(err, ShouldBeNil)
- addr2, err = privKeyStoreToAccountAddr(
+ priv2, addr2, err = privKeyStoreToAccountAddr(
FJ(testWorkingDir, "./observation/node_miner_1/private.key"), []byte{})
So(err, ShouldBeNil)
// create
- meta := client.ResourceMeta{
- ResourceMeta: types.ResourceMeta{
- TargetMiners: []proto.AccountAddress{addr},
- Node: 1,
- },
- GasPrice: 0,
- AdvancePayment: 10000000,
- }
- dsn, err = client.Create(meta)
+ _, dsn, err = bp.Create(types.ResourceMeta{
+ TargetMiners: []proto.AccountAddress{addr},
+ Node: 1,
+ }, 1, 10000000, priv)
So(err, ShouldBeNil)
log.Infof("the created database dsn is %v", dsn)
@@ -352,16 +347,10 @@ func TestFullProcess(t *testing.T) {
So(err, ShouldBeNil)
// create
- meta = client.ResourceMeta{
- ResourceMeta: types.ResourceMeta{
- TargetMiners: []proto.AccountAddress{addr2},
- Node: 1,
- },
- GasPrice: 0,
- AdvancePayment: 10000000,
- }
- meta.Node = 1
- dsn2, err = client.Create(meta)
+ _, dsn2, err = bp.Create(types.ResourceMeta{
+ TargetMiners: []proto.AccountAddress{addr2},
+ Node: 1,
+ }, 1, 10000000, priv2)
So(err, ShouldBeNil)
log.Infof("the created database dsn is %v", dsn2)
diff --git a/cmd/cql-observer/service.go b/cmd/cql-observer/service.go
index 936e678bc..a9fa9d546 100644
--- a/cmd/cql-observer/service.go
+++ b/cmd/cql-observer/service.go
@@ -487,21 +487,47 @@ func (s *Service) getUpstream(dbID proto.DatabaseID) (instance *types.ServiceIns
return
}
- req := &types.GetDatabaseRequest{}
- req.Header.DatabaseID = dbID
- if err = req.Sign(privateKey); err != nil {
+ var (
+ req = &types.QuerySQLChainProfileReq{
+ DBID: dbID,
+ }
+ resp = &types.QuerySQLChainProfileResp{}
+ )
+ // get peers list from block producer
+ if err = s.caller.CallNode(
+ curBP, route.MCCQuerySQLChainProfile.String(), req, resp,
+ ); err != nil {
return
}
- resp := &types.GetDatabaseResponse{}
- // get peers list from block producer
- if err = s.caller.CallNode(curBP, route.BPDBGetDatabase.String(), req, resp); err != nil {
+
+ // Build server instance from sqlchain profile
+ var (
+ profile = resp.Profile
+ nodeids = make([]proto.NodeID, len(profile.Miners))
+ peers *proto.Peers
+ genesis = &types.Block{}
+ )
+ for i, v := range profile.Miners {
+ nodeids[i] = v.NodeID
+ }
+ peers = &proto.Peers{
+ PeersHeader: proto.PeersHeader{
+ Leader: nodeids[0],
+ Servers: nodeids[:],
+ },
+ }
+ if err = peers.Sign(privateKey); err != nil {
return
}
- if err = resp.Verify(); err != nil {
+ if err = utils.DecodeMsgPack(profile.EncodedGenesis, genesis); err != nil {
return
}
-
- instance = &resp.Header.InstanceMeta
+ instance = &types.ServiceInstance{
+ DatabaseID: profile.ID,
+ Peers: peers,
+ ResourceMeta: profile.Meta,
+ GenesisBlock: genesis,
+ }
s.upstreamServers.Store(dbID, instance)
return
From b4a2511f8c648a64cf79bd16b650f33b991d2fe0 Mon Sep 17 00:00:00 2001
From: auxten
Date: Wed, 26 Dec 2018 23:35:42 +0800
Subject: [PATCH 216/278] Fix miners append error
---
blockproducer/metastate.go | 17 ++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)
diff --git a/blockproducer/metastate.go b/blockproducer/metastate.go
index 4e973afc6..f74c99561 100644
--- a/blockproducer/metastate.go
+++ b/blockproducer/metastate.go
@@ -652,10 +652,13 @@ func (s *metaState) matchProvidersWithUser(tx *types.CreateDatabase) (err error)
err = ErrNoSuchMiner
continue
} else {
- miners, _ := filterAndAppendMiner(miners, po, tx, sender)
+ miners, err = filterAndAppendMiner(miners, po, tx, sender)
+ if err != nil {
+ log.Warnf("miner filtered %v", err)
+ }
// if got enough, break
if uint64(len(miners)) == minerCount {
- continue
+ break
}
}
}
@@ -663,12 +666,12 @@ func (s *metaState) matchProvidersWithUser(tx *types.CreateDatabase) (err error)
// not enough, find more miner(s)
if uint64(len(miners)) < minerCount {
if uint64(len(tx.ResourceMeta.TargetMiners)) >= minerCount {
- err = errors.New("miners match target are not enough")
+ err = errors.Errorf("miners match target are not enough %d:%d", len(miners), minerCount)
return
}
// try old miners first
for _, po := range s.readonly.provider {
- miners, _ := filterAndAppendMiner(miners, po, tx, sender)
+ miners, _ = filterAndAppendMiner(miners, po, tx, sender)
// if got enough, break
if uint64(len(miners)) == minerCount {
break
@@ -677,7 +680,7 @@ func (s *metaState) matchProvidersWithUser(tx *types.CreateDatabase) (err error)
// try fresh miners
if uint64(len(miners)) < minerCount {
for _, po := range s.dirty.provider {
- miners, _ := filterAndAppendMiner(miners, po, tx, sender)
+ miners, _ = filterAndAppendMiner(miners, po, tx, sender)
// if got enough, break
if uint64(len(miners)) == minerCount {
break
@@ -800,9 +803,9 @@ func isProviderReqMatch(po *types.ProviderProfile, req *types.CreateDatabase) (m
po.GasPrice, req.GasPrice)
return
}
- if po.LoadAvgPerCPU > req.ResourceMeta.LoadAvgPerCPU {
+ if req.ResourceMeta.LoadAvgPerCPU > 0.0 && po.LoadAvgPerCPU > req.ResourceMeta.LoadAvgPerCPU {
err = errors.New("load average mismatch")
- log.WithError(err).Debugf("miner's LoadAvgPerCPU: %d, user's LoadAvgPerCPU: %d",
+ log.WithError(err).Debugf("miner's LoadAvgPerCPU: %f, user's LoadAvgPerCPU: %f",
po.LoadAvgPerCPU, req.ResourceMeta.LoadAvgPerCPU)
return
}
From 334e7854229b99e2a244aa3b13933a7ae97c0af6 Mon Sep 17 00:00:00 2001
From: zeqing-guo
Date: Wed, 26 Dec 2018 23:37:56 +0800
Subject: [PATCH 217/278] Fix bug: type not match
---
blockproducer/metastate.go | 3 +--
blockproducer/metastate_test.go | 4 ++--
2 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/blockproducer/metastate.go b/blockproducer/metastate.go
index 4e973afc6..dff1c1574 100644
--- a/blockproducer/metastate.go
+++ b/blockproducer/metastate.go
@@ -793,7 +793,6 @@ func isProviderUserMatch(targetUsers []proto.AccountAddress, user proto.AccountA
}
func isProviderReqMatch(po *types.ProviderProfile, req *types.CreateDatabase) (match bool, err error) {
-
if po.GasPrice > req.GasPrice {
err = errors.New("gas price mismatch")
log.WithError(err).Debugf("miner's gas price: %d, user's gas price: %d",
@@ -802,7 +801,7 @@ func isProviderReqMatch(po *types.ProviderProfile, req *types.CreateDatabase) (m
}
if po.LoadAvgPerCPU > req.ResourceMeta.LoadAvgPerCPU {
err = errors.New("load average mismatch")
- log.WithError(err).Debugf("miner's LoadAvgPerCPU: %d, user's LoadAvgPerCPU: %d",
+ log.WithError(err).Debugf("miner's LoadAvgPerCPU: %f, user's LoadAvgPerCPU: %f",
po.LoadAvgPerCPU, req.ResourceMeta.LoadAvgPerCPU)
return
}
diff --git a/blockproducer/metastate_test.go b/blockproducer/metastate_test.go
index fba240cb5..f80e74183 100644
--- a/blockproducer/metastate_test.go
+++ b/blockproducer/metastate_test.go
@@ -664,7 +664,7 @@ func TestMetaState(t *testing.T) {
Convey("When provider transaction is invalid", func() {
invalidPs := types.ProvideService{
ProvideServiceHeader: types.ProvideServiceHeader{
- TargetUser: addr1,
+ TargetUser: []proto.AccountAddress{addr1},
Nonce: 1,
},
}
@@ -733,7 +733,7 @@ func TestMetaState(t *testing.T) {
Convey("When SQLChain create", func() {
ps := types.ProvideService{
ProvideServiceHeader: types.ProvideServiceHeader{
- TargetUser: addr1,
+ TargetUser: []proto.AccountAddress{addr1},
GasPrice: 1,
TokenType: types.Particle,
Nonce: 1,
From 05f84f06cdd63ff79bfcaf67c59aacf1d1f4d293 Mon Sep 17 00:00:00 2001
From: Levente Liu
Date: Wed, 26 Dec 2018 23:44:49 +0800
Subject: [PATCH 218/278] Add README-zh for cql-utils
---
cmd/cql-utils/README-zh.md | 34 ++++++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+)
create mode 100644 cmd/cql-utils/README-zh.md
diff --git a/cmd/cql-utils/README-zh.md b/cmd/cql-utils/README-zh.md
new file mode 100644
index 000000000..8f9d27e9b
--- /dev/null
+++ b/cmd/cql-utils/README-zh.md
@@ -0,0 +1,34 @@
+cql-utils 是 CovenantSQL 的一个命令行工具,具体用法如下。
+
+## 安装
+下载最新发布版本 [Latest Release](https://github.com/CovenantSQL/CovenantSQL/releases) 或从源码直接编译:
+```bash
+$ go get github.com/CovenantSQL/CovenantSQL/cmd/cql-utils
+```
+*保证 Golang 环境变量 `$GOPATH/bin` 已在 `$PATH` 中*
+
+## 使用
+### 生成公私钥对
+
+```
+$ cql-utils -tool keygen
+Enter master key(press Enter for default: ""):
+⏎
+Private key file: private.key
+Public key's hex: 03bc9e90e3301a2f5ae52bfa1f9e033cde81b6b6e7188b11831562bf5847bff4c0
+```
+
+生成的 private.key 文件即是使用主密码加密过的私钥文件,而输出到屏幕上的字符串就是你的公钥十六进制编码。
+
+### 使用私钥文件或公钥生成钱包地址
+
+```
+$ cql-utils -tool addrgen -private private.key
+Enter master key(default: ""):
+⏎
+wallet address: 4jXvNvPHKNPU8Sncz5u5F5WSGcgXmzC1g8RuAXTCJzLsbF9Dsf9
+$ cql-utils -tool addrgen -public 02f2707c1c6955a9019cd9d02ade37b931fbfa286a1163dfc1de965ec01a5c4ff8
+wallet address: 4jXvNvPHKNPU8Sncz5u5F5WSGcgXmzC1g8RuAXTCJzLsbF9Dsf9
+```
+
+你可以通过指定私钥文件,或者把上述的公钥十六进制编码字符串作为命令行参数来直接生成钱包地址。
\ No newline at end of file
From 99446da7546d3a05b8929c3776d96ade0ffd62be Mon Sep 17 00:00:00 2001
From: Levente Liu
Date: Wed, 26 Dec 2018 23:49:17 +0800
Subject: [PATCH 219/278] Minor change
---
cmd/cql-utils/README-zh.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/cmd/cql-utils/README-zh.md b/cmd/cql-utils/README-zh.md
index 8f9d27e9b..2a1e092ba 100644
--- a/cmd/cql-utils/README-zh.md
+++ b/cmd/cql-utils/README-zh.md
@@ -18,7 +18,7 @@ Private key file: private.key
Public key's hex: 03bc9e90e3301a2f5ae52bfa1f9e033cde81b6b6e7188b11831562bf5847bff4c0
```
-生成的 private.key 文件即是使用主密码加密过的私钥文件,而输出到屏幕上的字符串就是你的公钥十六进制编码。
+生成的 private.key 文件即是使用主密码加密过的私钥文件,而输出到屏幕上的字符串就是使用十六进制进行编码的公钥。
### 使用私钥文件或公钥生成钱包地址
From 144c0a31433fdf8bc0b6101f1b725b85b1396eb9 Mon Sep 17 00:00:00 2001
From: Levente Liu
Date: Wed, 26 Dec 2018 23:49:17 +0800
Subject: [PATCH 220/278] Minor change
---
cmd/cql-utils/README-zh.md | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/cmd/cql-utils/README-zh.md b/cmd/cql-utils/README-zh.md
index 8f9d27e9b..cb36fd688 100644
--- a/cmd/cql-utils/README-zh.md
+++ b/cmd/cql-utils/README-zh.md
@@ -1,7 +1,7 @@
cql-utils 是 CovenantSQL 的一个命令行工具,具体用法如下。
## 安装
-下载最新发布版本 [Latest Release](https://github.com/CovenantSQL/CovenantSQL/releases) 或从源码直接编译:
+下载 [最新发布版本](https://github.com/CovenantSQL/CovenantSQL/releases) 或直接从源码编译:
```bash
$ go get github.com/CovenantSQL/CovenantSQL/cmd/cql-utils
```
@@ -18,7 +18,7 @@ Private key file: private.key
Public key's hex: 03bc9e90e3301a2f5ae52bfa1f9e033cde81b6b6e7188b11831562bf5847bff4c0
```
-生成的 private.key 文件即是使用主密码加密过的私钥文件,而输出到屏幕上的字符串就是你的公钥十六进制编码。
+生成的 private.key 文件即是使用主密码加密过的私钥文件,而输出到屏幕上的字符串就是使用十六进制进行编码的公钥。
### 使用私钥文件或公钥生成钱包地址
From 1a772d0964982e0f2574e28c9b2b74547a467ab0 Mon Sep 17 00:00:00 2001
From: Qi Xiao
Date: Thu, 27 Dec 2018 00:14:20 +0800
Subject: [PATCH 221/278] Remove ethereum math dependency
---
cmd/cql-minerd/provide_service.go | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/cmd/cql-minerd/provide_service.go b/cmd/cql-minerd/provide_service.go
index b79a42528..b8a2d61d8 100644
--- a/cmd/cql-minerd/provide_service.go
+++ b/cmd/cql-minerd/provide_service.go
@@ -25,13 +25,13 @@ import (
"github.com/CovenantSQL/CovenantSQL/rpc"
"github.com/CovenantSQL/CovenantSQL/types"
"github.com/CovenantSQL/CovenantSQL/utils/log"
- "github.com/ethereum/go-ethereum/common/math"
"github.com/prometheus/client_golang/prometheus"
dto "github.com/prometheus/client_model/go"
)
const (
defaultGasPrice = 1
+ maxUint64 = 1<<64 - 1
)
var (
@@ -100,17 +100,17 @@ func sendProvideService(reg *prometheus.Registry) {
switch m.GetName() {
case metricKeyMemory:
- if metricVal > 0 && metricVal < math.MaxUint64 {
+ if metricVal > 0 && metricVal < maxUint64 {
memoryBytes = uint64(metricVal)
}
+ case metricKeySpace:
+ if metricVal > 0 && metricVal < maxUint64 {
+ keySpace = uint64(metricVal)
+ }
case metricKeyCpuCount:
cpuCount = metricVal
case metricKeyLoadAvg:
loadAvg = metricVal
- case metricKeySpace:
- if metricVal > 0 && metricVal < math.MaxUint64 {
- keySpace = uint64(metricVal)
- }
default:
}
}
From 9ba9e7bb731b514abdf095f6a57997cbc83588ea Mon Sep 17 00:00:00 2001
From: laodouya
Date: Thu, 27 Dec 2018 00:25:57 +0800
Subject: [PATCH 222/278] Add Chinese version of client readme
---
client/README-zh.md | 103 ++++++++++++++++++++++++++++++++++++++++++++
client/README.md | 4 +-
2 files changed, 105 insertions(+), 2 deletions(-)
create mode 100644 client/README-zh.md
diff --git a/client/README-zh.md b/client/README-zh.md
new file mode 100644
index 000000000..0e772a6c6
--- /dev/null
+++ b/client/README-zh.md
@@ -0,0 +1,103 @@
+本文档介绍CovenantSQL客户端的使用方式. 客户端用来创建、查询、更新和删除SQLChain以及绑定的数据库。
+
+## 开始之前
+
+确保`$GOPATH/bin`目录在环境变量`$PATH`中,执行以下命令
+
+```bash
+$ go get github.com/CovenantSQL/CovenantSQL/client
+$ go get github.com/CovenantSQL/CovenantSQL/cmd/cql-utils
+```
+
+然后在你的go代码中import 第一个`client`包。
+
+
+## 初始化一个CovenantSQL客户端
+
+首先需要一个config文件和master key来初始化。master key用来加密解密本地密钥对。以下是如何用一个自定义master key来生成默认的config文件:
+
+### 生成默认的配置文件
+
+运行以下`cql-utils`命令,输入master key (类似密码)来生成本地密钥对。等待几十秒,会在`conf`文件夹中,生成一个私钥文件和一个名为`config.yaml`的配置文件。
+
+```bash
+$ cql-utils -tool confgen -root conf
+Generating key pair...
+Enter master key(press Enter for default: ""):
+⏎
+Private key file: conf/private.key
+Public key's hex: 025abec9b0072615170f4acf4a2fa1162a13864bb66bc3f140b29f6bf50ceafc75
+Generated key pair.
+Generating nonce...
+INFO[0005] cpu: 1
+INFO[0005] position: 0, shift: 0x0, i: 0
+nonce: {{1450338416 0 0 0} 26 0000002dd8bdb50ba0270642e4c4bc593c1630ef7784653f311b3c3d6374e514}
+node id: 0000002dd8bdb50ba0270642e4c4bc593c1630ef7784653f311b3c3d6374e514
+Generated nonce.
+Generating config file...
+Generated nonce.
+```
+
+有了配置文件之后,可以通过以下go代码来初始化CovenantSQL客户端:
+
+```go
+client.Init(configFile, masterKey)
+```
+
+## 客户端使用方式
+
+### 创建一个SQLChain数据库
+
+创建SQLChain数据库需要指明需要几个节点(nodeCount变量):
+
+```go
+var (
+ dsn string
+ meta client.ResourceMeta
+)
+meta.Node = uint16(nodeCount)
+dsn, err = client.Create(meta)
+// process err
+```
+创建完毕会返回一个dsn字符串,用来访问这个数据库。
+
+### 查询和执行
+
+拿到dsn字符串后,可以通过以下代码在SQLChain中执行SQL语句:
+
+```go
+
+ db, err := sql.Open("covenantsql", dsn)
+ // process err
+
+ _, err = db.Exec("CREATE TABLE testSimple ( column int );")
+ // process err
+
+ _, err = db.Exec("INSERT INTO testSimple VALUES(?);", 42)
+ // process err
+
+ row := db.QueryRow("SELECT column FROM testSimple LIMIT 1;")
+
+ var result int
+ err = row.Scan(&result)
+ // process err
+ fmt.Printf("SELECT column FROM testSimple LIMIT 1; result %d\n", result)
+
+ err = db.Close()
+ // process err
+
+```
+用法和其他go sql driver一致。
+
+### 删除数据库
+
+使用dsn来删除数据库:
+
+```go
+ err = client.Drop(dsn)
+ // process err
+```
+
+### 完整示例
+
+在以下目录中有一个简单示例和复杂示例可以参考 [client/_example](_example/)
\ No newline at end of file
diff --git a/client/README.md b/client/README.md
index f3e048bf8..ba53a074a 100644
--- a/client/README.md
+++ b/client/README.md
@@ -1,4 +1,4 @@
-This doc introduce the usage of covenantSQL client. Client is used for creating, querying, updating, and deleting the SQLChain and database adhere to the SQLChain.
+This doc introduce the usage of CovenantSQL client. Client is used for creating, querying, updating, and deleting the SQLChain and database adhere to the SQLChain.
## Prerequisites
@@ -100,4 +100,4 @@ Drop your database on SQL Chain is very easy with your dsn string:
### Full Example
-simple and complex client examples can be found in [client/_example](_example/)
\ No newline at end of file
+simple and complex client examples can be found in [client/_example](_example/)
From 8956354b11f31507666232e0911fc0da902e3d98 Mon Sep 17 00:00:00 2001
From: auxten
Date: Thu, 27 Dec 2018 10:19:21 +0800
Subject: [PATCH 223/278] Give some coin for test in BaseAccounts
---
test/service/node_0/config.yaml | 13 +++++++++++++
test/service/node_1/config.yaml | 13 +++++++++++++
test/service/node_2/config.yaml | 13 +++++++++++++
3 files changed, 39 insertions(+)
diff --git a/test/service/node_0/config.yaml b/test/service/node_0/config.yaml
index 7f252f42a..ab177be53 100644
--- a/test/service/node_0/config.yaml
+++ b/test/service/node_0/config.yaml
@@ -37,6 +37,19 @@ BlockProducer:
MerkleRoot: 0000000000000000000000000000000000000000000000000000000000000001
ParentHash: 0000000000000000000000000000000000000000000000000000000000000001
Timestamp: 2018-08-13T21:59:59.12Z
+ BaseAccounts:
+ - Address: ba0ba731c7a76ccef2c1170f42038f7e228dfb474ef0190dfe35d9a37911ed37
+ StableCoinBalance: 1000000000
+ CovenantCoinBalance: 1000000000
+ - Address: 1a7b0959bbd0d0ec529278a61c0056c277bffe75b2646e1699b46b10a90210be
+ StableCoinBalance: 1000000000
+ CovenantCoinBalance: 1000000000
+ - Address: 9235bc4130a2ed4e6c35ea189dab35198ebb105640bedb97dd5269cc80863b16
+ StableCoinBalance: 1000000000
+ CovenantCoinBalance: 1000000000
+ - Address: 9e1618775cceeb19f110e04fbc6c5bca6c8e4e9b116e193a42fe69bf602e7bcd
+ StableCoinBalance: 1000000000
+ CovenantCoinBalance: 1000000000
KnownNodes:
- ID: 00000bef611d346c0cbe1beaa76e7f0ed705a194fdf9ac3a248ec70e9c198bf9
Nonce:
diff --git a/test/service/node_1/config.yaml b/test/service/node_1/config.yaml
index 06818bf09..8016c2377 100644
--- a/test/service/node_1/config.yaml
+++ b/test/service/node_1/config.yaml
@@ -37,6 +37,19 @@ BlockProducer:
MerkleRoot: 0000000000000000000000000000000000000000000000000000000000000001
ParentHash: 0000000000000000000000000000000000000000000000000000000000000001
Timestamp: 2018-08-13T21:59:59.12Z
+ BaseAccounts:
+ - Address: ba0ba731c7a76ccef2c1170f42038f7e228dfb474ef0190dfe35d9a37911ed37
+ StableCoinBalance: 1000000000
+ CovenantCoinBalance: 1000000000
+ - Address: 1a7b0959bbd0d0ec529278a61c0056c277bffe75b2646e1699b46b10a90210be
+ StableCoinBalance: 1000000000
+ CovenantCoinBalance: 1000000000
+ - Address: 9235bc4130a2ed4e6c35ea189dab35198ebb105640bedb97dd5269cc80863b16
+ StableCoinBalance: 1000000000
+ CovenantCoinBalance: 1000000000
+ - Address: 9e1618775cceeb19f110e04fbc6c5bca6c8e4e9b116e193a42fe69bf602e7bcd
+ StableCoinBalance: 1000000000
+ CovenantCoinBalance: 1000000000
KnownNodes:
- ID: 00000bef611d346c0cbe1beaa76e7f0ed705a194fdf9ac3a248ec70e9c198bf9
Nonce:
diff --git a/test/service/node_2/config.yaml b/test/service/node_2/config.yaml
index d354502d0..16e26d2dc 100644
--- a/test/service/node_2/config.yaml
+++ b/test/service/node_2/config.yaml
@@ -37,6 +37,19 @@ BlockProducer:
MerkleRoot: 0000000000000000000000000000000000000000000000000000000000000001
ParentHash: 0000000000000000000000000000000000000000000000000000000000000001
Timestamp: 2018-08-13T21:59:59.12Z
+ BaseAccounts:
+ - Address: ba0ba731c7a76ccef2c1170f42038f7e228dfb474ef0190dfe35d9a37911ed37
+ StableCoinBalance: 1000000000
+ CovenantCoinBalance: 1000000000
+ - Address: 1a7b0959bbd0d0ec529278a61c0056c277bffe75b2646e1699b46b10a90210be
+ StableCoinBalance: 1000000000
+ CovenantCoinBalance: 1000000000
+ - Address: 9235bc4130a2ed4e6c35ea189dab35198ebb105640bedb97dd5269cc80863b16
+ StableCoinBalance: 1000000000
+ CovenantCoinBalance: 1000000000
+ - Address: 9e1618775cceeb19f110e04fbc6c5bca6c8e4e9b116e193a42fe69bf602e7bcd
+ StableCoinBalance: 1000000000
+ CovenantCoinBalance: 1000000000
KnownNodes:
- ID: 00000bef611d346c0cbe1beaa76e7f0ed705a194fdf9ac3a248ec70e9c198bf9
Nonce:
From 32fb656631ff80c99e0914e092d6055250260d6c Mon Sep 17 00:00:00 2001
From: leventeliu
Date: Thu, 27 Dec 2018 11:13:37 +0800
Subject: [PATCH 224/278] Fix wait creation method
---
blockproducer/rpc.go | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/blockproducer/rpc.go b/blockproducer/rpc.go
index 7a0f7fe6c..dbe2a0ed4 100644
--- a/blockproducer/rpc.go
+++ b/blockproducer/rpc.go
@@ -162,14 +162,14 @@ func WaitDatabaseCreation(
for {
select {
case <-timer.C:
+ timer.Reset(period)
if err = rpc.RequestBP(
route.MCCQuerySQLChainProfile.String(), req, resp,
- ); err != ErrDatabaseNotFound {
+ ); err == nil || err.Error() != "rpc query sqlchain profile failed: database not found" {
// err == nil (creation done), or
// err != nil && err != ErrDatabaseNotFound (unexpected error)
return
}
- timer.Reset(period)
case <-ctx.Done():
err = ctx.Err()
return
From 587a287644c7329cca34345c9bb7d5c1a523ea6f Mon Sep 17 00:00:00 2001
From: Qi Xiao
Date: Thu, 27 Dec 2018 11:34:30 +0800
Subject: [PATCH 225/278] Use global constant for chain period/tick and fix
golint issues
---
blockproducer/config.go | 5 +----
blockproducer/metastate.go | 5 ++---
blockproducer/metastate_test.go | 4 ++--
blockproducer/rpc.go | 12 +++++++-----
cmd/cql-minerd/provide_service.go | 6 +++---
cmd/cql-observer/observation_test.go | 3 ++-
cmd/cql-observer/service.go | 6 +-----
cmd/cqld/bootstrap.go | 5 ++---
types/provideservice.go | 3 ++-
worker/db.go | 11 +++++------
worker/dbms.go | 2 --
11 files changed, 27 insertions(+), 35 deletions(-)
diff --git a/blockproducer/config.go b/blockproducer/config.go
index 4ab8c9d63..ff56602e9 100644
--- a/blockproducer/config.go
+++ b/blockproducer/config.go
@@ -42,14 +42,12 @@ type Config struct {
Period time.Duration
Tick time.Duration
-
- QPS uint32
}
// NewConfig creates new config.
func NewConfig(genesis *types.BPBlock, dataFile string,
server *rpc.Server, peers *proto.Peers,
- nodeID proto.NodeID, period time.Duration, tick time.Duration, qps uint32) *Config {
+ nodeID proto.NodeID, period time.Duration, tick time.Duration) *Config {
config := Config{
Genesis: genesis,
DataFile: dataFile,
@@ -58,7 +56,6 @@ func NewConfig(genesis *types.BPBlock, dataFile string,
NodeID: nodeID,
Period: period,
Tick: tick,
- QPS: qps,
}
return &config
}
diff --git a/blockproducer/metastate.go b/blockproducer/metastate.go
index f74c99561..f8776a685 100644
--- a/blockproducer/metastate.go
+++ b/blockproducer/metastate.go
@@ -20,9 +20,6 @@ import (
"bytes"
"time"
- "github.com/mohae/deepcopy"
- "github.com/pkg/errors"
-
pi "github.com/CovenantSQL/CovenantSQL/blockproducer/interfaces"
"github.com/CovenantSQL/CovenantSQL/conf"
"github.com/CovenantSQL/CovenantSQL/crypto"
@@ -33,6 +30,8 @@ import (
"github.com/CovenantSQL/CovenantSQL/types"
"github.com/CovenantSQL/CovenantSQL/utils"
"github.com/CovenantSQL/CovenantSQL/utils/log"
+ "github.com/mohae/deepcopy"
+ "github.com/pkg/errors"
)
var (
diff --git a/blockproducer/metastate_test.go b/blockproducer/metastate_test.go
index fba240cb5..f80e74183 100644
--- a/blockproducer/metastate_test.go
+++ b/blockproducer/metastate_test.go
@@ -664,7 +664,7 @@ func TestMetaState(t *testing.T) {
Convey("When provider transaction is invalid", func() {
invalidPs := types.ProvideService{
ProvideServiceHeader: types.ProvideServiceHeader{
- TargetUser: addr1,
+ TargetUser: []proto.AccountAddress{addr1},
Nonce: 1,
},
}
@@ -733,7 +733,7 @@ func TestMetaState(t *testing.T) {
Convey("When SQLChain create", func() {
ps := types.ProvideService{
ProvideServiceHeader: types.ProvideServiceHeader{
- TargetUser: addr1,
+ TargetUser: []proto.AccountAddress{addr1},
GasPrice: 1,
TokenType: types.Particle,
Nonce: 1,
diff --git a/blockproducer/rpc.go b/blockproducer/rpc.go
index dbe2a0ed4..7f41fa61e 100644
--- a/blockproducer/rpc.go
+++ b/blockproducer/rpc.go
@@ -144,13 +144,14 @@ func (s *ChainRPCService) Sub(req *types.SubReq, resp *types.SubResp) (err error
})
}
+// WaitDatabaseCreation waits for database creation complete.
func WaitDatabaseCreation(
- ctx context.Context, dbid proto.DatabaseID, period time.Duration) (err error,
+ ctx context.Context, dbID proto.DatabaseID, period time.Duration) (err error,
) {
var (
timer = time.NewTimer(0)
req = &types.QuerySQLChainProfileReq{
- DBID: dbid,
+ DBID: dbID,
}
resp = &types.QuerySQLChainProfileResp{}
)
@@ -177,13 +178,14 @@ func WaitDatabaseCreation(
}
}
+// Create allocates new database.
func Create(
meta types.ResourceMeta,
gasPrice uint64,
advancePayment uint64,
privateKey *asymmetric.PrivateKey,
) (
- databaseid proto.DatabaseID, dsn string, err error,
+ dbID proto.DatabaseID, dsn string, err error,
) {
var (
nonceReq = new(types.NextAccountNonceReq)
@@ -223,7 +225,7 @@ func Create(
return
}
- databaseid = *proto.FromAccountAndNonce(clientAddr, uint32(nonceResp.Nonce))
- dsn = fmt.Sprintf("cql://%s?use_leader=1&use_follower=0", string(databaseid))
+ dbID = *proto.FromAccountAndNonce(clientAddr, uint32(nonceResp.Nonce))
+ dsn = fmt.Sprintf("cql://%s", string(dbID))
return
}
diff --git a/cmd/cql-minerd/provide_service.go b/cmd/cql-minerd/provide_service.go
index b8a2d61d8..a2e0f78b5 100644
--- a/cmd/cql-minerd/provide_service.go
+++ b/cmd/cql-minerd/provide_service.go
@@ -37,7 +37,7 @@ const (
var (
metricKeyMemory = "node_memory_MemAvailable_bytes"
metricKeyLoadAvg = "node_load15"
- metricKeyCpuCount = "node_cpu_count"
+ metricKeyCPUCount = "node_cpu_count"
metricKeySpace = "node_filesystem_free_bytes"
)
@@ -76,7 +76,7 @@ func sendProvideService(reg *prometheus.Registry) {
for _, m := range mf {
switch m.GetName() {
- case metricKeyMemory, metricKeyCpuCount, metricKeyLoadAvg, metricKeySpace:
+ case metricKeyMemory, metricKeyCPUCount, metricKeyLoadAvg, metricKeySpace:
default:
continue
}
@@ -107,7 +107,7 @@ func sendProvideService(reg *prometheus.Registry) {
if metricVal > 0 && metricVal < maxUint64 {
keySpace = uint64(metricVal)
}
- case metricKeyCpuCount:
+ case metricKeyCPUCount:
cpuCount = metricVal
case metricKeyLoadAvg:
loadAvg = metricVal
diff --git a/cmd/cql-observer/observation_test.go b/cmd/cql-observer/observation_test.go
index 1c463122e..7cf2f43f7 100644
--- a/cmd/cql-observer/observation_test.go
+++ b/cmd/cql-observer/observation_test.go
@@ -36,6 +36,7 @@ import (
bp "github.com/CovenantSQL/CovenantSQL/blockproducer"
"github.com/CovenantSQL/CovenantSQL/client"
+ "github.com/CovenantSQL/CovenantSQL/conf"
"github.com/CovenantSQL/CovenantSQL/crypto"
"github.com/CovenantSQL/CovenantSQL/crypto/asymmetric"
"github.com/CovenantSQL/CovenantSQL/crypto/kms"
@@ -408,7 +409,7 @@ func TestFullProcess(t *testing.T) {
}()
// wait for the observer to collect blocks, two periods is enough
- time.Sleep(blockProducePeriod * 2)
+ time.Sleep(conf.SQLChainPeriod * 2)
// test get genesis block by height
res, err := getJSON("v1/height/%v/0", dbID)
diff --git a/cmd/cql-observer/service.go b/cmd/cql-observer/service.go
index a9fa9d546..8f2c3971e 100644
--- a/cmd/cql-observer/service.go
+++ b/cmd/cql-observer/service.go
@@ -23,7 +23,6 @@ import (
"path/filepath"
"sync"
"sync/atomic"
- "time"
"github.com/CovenantSQL/CovenantSQL/conf"
"github.com/CovenantSQL/CovenantSQL/crypto/hash"
@@ -91,9 +90,6 @@ var (
subscriptionBucket = []byte("subscription")
blockHeightBucket = []byte("height")
-
- // blockProducePeriod defines the block producing interval
- blockProducePeriod = 60 * time.Second
)
// Service defines the observer service structure.
@@ -370,7 +366,7 @@ func (s *Service) addQueryTracker(dbID proto.DatabaseID, height int32, offset in
func (s *Service) addBlock(dbID proto.DatabaseID, count int32, b *types.Block) (err error) {
instance, err := s.getUpstream(dbID)
- h := int32(b.Timestamp().Sub(instance.GenesisBlock.Timestamp()) / blockProducePeriod)
+ h := int32(b.Timestamp().Sub(instance.GenesisBlock.Timestamp()) / conf.SQLChainPeriod)
key := utils.ConcatAll(int32ToBytes(h), b.BlockHash().AsBytes(), int32ToBytes(count))
// It's actually `countToBytes`
ckey := int32ToBytes(count)
diff --git a/cmd/cqld/bootstrap.go b/cmd/cqld/bootstrap.go
index 677970815..d81e6dcc3 100644
--- a/cmd/cqld/bootstrap.go
+++ b/cmd/cqld/bootstrap.go
@@ -132,9 +132,8 @@ func runNode(nodeID proto.NodeID, listenAddr string) (err error) {
server,
peers,
nodeID,
- 3*time.Second,
- 1*time.Second,
- conf.GConf.QPS,
+ conf.BPPeriod,
+ conf.BPTick,
)
chain, err := bp.NewChain(chainConfig)
if err != nil {
diff --git a/types/provideservice.go b/types/provideservice.go
index 607f66144..18d6fddff 100644
--- a/types/provideservice.go
+++ b/types/provideservice.go
@@ -26,7 +26,8 @@ import (
//go:generate hsp
-//TODO(guozeqing): merge similar part of types.ProviderProfile
+//TODO(lambda): merge similar part of types.ProviderProfile
+
// ProvideServiceHeader define the miner providing service transaction header.
type ProvideServiceHeader struct {
Space uint64 // reserved storage space in bytes
diff --git a/worker/db.go b/worker/db.go
index c91b43b57..8aa21a3de 100644
--- a/worker/db.go
+++ b/worker/db.go
@@ -21,6 +21,8 @@ import (
"os"
"path/filepath"
+ "github.com/CovenantSQL/CovenantSQL/conf"
+
//"runtime/trace"
"sync"
"time"
@@ -123,7 +125,6 @@ func NewDatabase(cfg *DBConfig, peers *proto.Peers,
return
}
- // TODO(xq262144): make sqlchain config use of global config object
chainCfg := &sqlchain.Config{
DatabaseID: cfg.DatabaseID,
ChainFilePrefix: chainFile,
@@ -131,15 +132,13 @@ func NewDatabase(cfg *DBConfig, peers *proto.Peers,
Genesis: genesis,
Peers: peers,
- // TODO(xq262144): should refactor server/node definition to conf/proto package
// currently sqlchain package only use Server.ID as node id
MuxService: cfg.ChainMux,
Server: db.nodeID,
- // TODO(xq262144): currently using fixed period/resolution from sqlchain test case
- Period: 3 * time.Second,
- Tick: 1 * time.Second,
- QueryTTL: 10,
+ Period: conf.SQLChainPeriod,
+ Tick: conf.SQLChainTick,
+ QueryTTL: conf.SQLChainTTL,
UpdatePeriod: cfg.UpdatePeriod,
}
diff --git a/worker/dbms.go b/worker/dbms.go
index 5e9932c28..f2ff0d9f5 100644
--- a/worker/dbms.go
+++ b/worker/dbms.go
@@ -48,8 +48,6 @@ const (
// CheckInterval defines the bus service period.
CheckInterval = time.Second
-
- // UpdatePeriod defines the
)
// DBMS defines a database management instance.
From fac146e706ca693c4738c8ec937e85f81e5ba1db Mon Sep 17 00:00:00 2001
From: Qi Xiao
Date: Thu, 27 Dec 2018 12:12:21 +0800
Subject: [PATCH 226/278] Add missing conf/parameters.go
---
conf/parameters.go | 32 ++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+)
create mode 100644 conf/parameters.go
diff --git a/conf/parameters.go b/conf/parameters.go
new file mode 100644
index 000000000..8fbc04951
--- /dev/null
+++ b/conf/parameters.go
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2018 The CovenantSQL Authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package conf
+
+import "time"
+
+const (
+ // BPPeriod is the block producer block produce period.
+ BPPeriod = 3 * time.Second
+ // BPTick is the block produce block fetch tick.
+ BPTick = 1 * time.Second
+ // SQLChainPeriod is the sqlchain block produce period.
+ SQLChainPeriod = 3 * time.Second
+ // SQLChainTick is the sqlchain block fetch tick.
+ SQLChainTick = 1 * time.Second
+ // SQLChainTTL is the sqlchain unack query billing ttl.
+ SQLChainTTL = 10
+)
From 20fa8dd581aab4e03998249de3855e87ff1fd5cf Mon Sep 17 00:00:00 2001
From: Qi Xiao
Date: Thu, 27 Dec 2018 12:13:06 +0800
Subject: [PATCH 227/278] Remove conf* from gitignore
---
.gitignore | 1 -
1 file changed, 1 deletion(-)
diff --git a/.gitignore b/.gitignore
index 4ae821fc2..848756ec3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,4 @@
*.trace
-conf*
..bfg-report
pprof.txt
.dsn
From f6164866a31fe31282cea04b49e66889c3ef3f97 Mon Sep 17 00:00:00 2001
From: leventeliu
Date: Thu, 27 Dec 2018 11:42:52 +0800
Subject: [PATCH 228/278] Fix issue: using wrong key to create db
---
cmd/cql-observer/observation_test.go | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/cmd/cql-observer/observation_test.go b/cmd/cql-observer/observation_test.go
index 7cf2f43f7..fef15e141 100644
--- a/cmd/cql-observer/observation_test.go
+++ b/cmd/cql-observer/observation_test.go
@@ -253,7 +253,7 @@ func TestFullProcess(t *testing.T) {
Convey("test full process", t, func() {
var (
err error
- priv, priv2 *asymmetric.PrivateKey
+ cliPriv *asymmetric.PrivateKey
addr, addr2 proto.AccountAddress
dsn, dsn2 string
cfg, cfg2 *client.Config
@@ -270,10 +270,13 @@ func TestFullProcess(t *testing.T) {
So(err, ShouldBeNil)
// get miner addresses
- priv, addr, err = privKeyStoreToAccountAddr(
+ cliPriv, _, err = privKeyStoreToAccountAddr(
+ FJ(testWorkingDir, "./observation/node_c/private.key"), []byte{})
+ So(err, ShouldBeNil)
+ _, addr, err = privKeyStoreToAccountAddr(
FJ(testWorkingDir, "./observation/node_miner_0/private.key"), []byte{})
So(err, ShouldBeNil)
- priv2, addr2, err = privKeyStoreToAccountAddr(
+ _, addr2, err = privKeyStoreToAccountAddr(
FJ(testWorkingDir, "./observation/node_miner_1/private.key"), []byte{})
So(err, ShouldBeNil)
@@ -281,7 +284,7 @@ func TestFullProcess(t *testing.T) {
_, dsn, err = bp.Create(types.ResourceMeta{
TargetMiners: []proto.AccountAddress{addr},
Node: 1,
- }, 1, 10000000, priv)
+ }, 1, 10000000, cliPriv)
So(err, ShouldBeNil)
log.Infof("the created database dsn is %v", dsn)
@@ -351,7 +354,7 @@ func TestFullProcess(t *testing.T) {
_, dsn2, err = bp.Create(types.ResourceMeta{
TargetMiners: []proto.AccountAddress{addr2},
Node: 1,
- }, 1, 10000000, priv2)
+ }, 1, 10000000, cliPriv)
So(err, ShouldBeNil)
log.Infof("the created database dsn is %v", dsn2)
From eb7c81e282450e6aff30a70d9fb7050f1237de5b Mon Sep 17 00:00:00 2001
From: leventeliu