mirror of https://github.com/poanetwork/gecko.git
Merge branch 'master' into rpc-host
This commit is contained in:
commit
18f43ee406
|
@ -218,7 +218,7 @@ func (ks *Keystore) ExportUser(_ *http.Request, args *ExportUserArgs, reply *Exp
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if !usr.CheckPassword(args.Password) {
|
if !usr.CheckPassword(args.Password) {
|
||||||
return fmt.Errorf("incorrect password for %s", args.Username)
|
return fmt.Errorf("incorrect password for user %q", args.Username)
|
||||||
}
|
}
|
||||||
|
|
||||||
userDB := prefixdb.New([]byte(args.Username), ks.bcDB)
|
userDB := prefixdb.New([]byte(args.Username), ks.bcDB)
|
||||||
|
@ -274,6 +274,9 @@ func (ks *Keystore) ImportUser(r *http.Request, args *ImportUserArgs, reply *Imp
|
||||||
if err := ks.codec.Unmarshal(args.User.Bytes, &userData); err != nil {
|
if err := ks.codec.Unmarshal(args.User.Bytes, &userData); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
if !userData.User.CheckPassword(args.Password) {
|
||||||
|
return fmt.Errorf("incorrect password for user %q", args.Username)
|
||||||
|
}
|
||||||
|
|
||||||
usrBytes, err := ks.codec.Marshal(&userData.User)
|
usrBytes, err := ks.codec.Marshal(&userData.User)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -383,7 +386,7 @@ func (ks *Keystore) GetDatabase(bID ids.ID, username, password string) (database
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if !usr.CheckPassword(password) {
|
if !usr.CheckPassword(password) {
|
||||||
return nil, fmt.Errorf("incorrect password for user '%s'", username)
|
return nil, fmt.Errorf("incorrect password for user %q", username)
|
||||||
}
|
}
|
||||||
|
|
||||||
userDB := prefixdb.New([]byte(username), ks.bcDB)
|
userDB := prefixdb.New([]byte(username), ks.bcDB)
|
||||||
|
|
|
@ -255,6 +255,17 @@ func TestServiceExportImport(t *testing.T) {
|
||||||
newKS := Keystore{}
|
newKS := Keystore{}
|
||||||
newKS.Initialize(logging.NoLog{}, memdb.New())
|
newKS.Initialize(logging.NoLog{}, memdb.New())
|
||||||
|
|
||||||
|
{
|
||||||
|
reply := ImportUserReply{}
|
||||||
|
if err := newKS.ImportUser(nil, &ImportUserArgs{
|
||||||
|
Username: "bob",
|
||||||
|
Password: "",
|
||||||
|
User: exportReply.User,
|
||||||
|
}, &reply); err == nil {
|
||||||
|
t.Fatal("Should have errored due to incorrect password")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
reply := ImportUserReply{}
|
reply := ImportUserReply{}
|
||||||
if err := newKS.ImportUser(nil, &ImportUserArgs{
|
if err := newKS.ImportUser(nil, &ImportUserArgs{
|
||||||
|
|
|
@ -515,7 +515,7 @@ func (nm *Handshake) disconnectedFromPeer(peer salticidae.PeerID) {
|
||||||
nm.connections.Remove(peer, cert)
|
nm.connections.Remove(peer, cert)
|
||||||
nm.numPeers.Set(float64(nm.connections.Len()))
|
nm.numPeers.Set(float64(nm.connections.Len()))
|
||||||
|
|
||||||
if nm.vdrs.Contains(cert) {
|
if !nm.enableStaking || nm.vdrs.Contains(cert) {
|
||||||
nm.reconnectTimeout.Put(peerID, func() {
|
nm.reconnectTimeout.Put(peerID, func() {
|
||||||
nm.pending.Remove(peer, cert)
|
nm.pending.Remove(peer, cert)
|
||||||
nm.connections.Remove(peer, cert)
|
nm.connections.Remove(peer, cert)
|
||||||
|
|
|
@ -36,7 +36,7 @@ type AtomicTx interface {
|
||||||
// AtomicBlock being accepted results in the transaction contained in the
|
// AtomicBlock being accepted results in the transaction contained in the
|
||||||
// block to be accepted and committed to the chain.
|
// block to be accepted and committed to the chain.
|
||||||
type AtomicBlock struct {
|
type AtomicBlock struct {
|
||||||
SingleDecisionBlock `serialize:"true"`
|
CommonDecisionBlock `serialize:"true"`
|
||||||
|
|
||||||
Tx AtomicTx `serialize:"true"`
|
Tx AtomicTx `serialize:"true"`
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ type AtomicBlock struct {
|
||||||
|
|
||||||
// initialize this block
|
// initialize this block
|
||||||
func (ab *AtomicBlock) initialize(vm *VM, bytes []byte) error {
|
func (ab *AtomicBlock) initialize(vm *VM, bytes []byte) error {
|
||||||
if err := ab.SingleDecisionBlock.initialize(vm, bytes); err != nil {
|
if err := ab.CommonDecisionBlock.initialize(vm, bytes); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return ab.Tx.initialize(vm)
|
return ab.Tx.initialize(vm)
|
||||||
|
@ -123,9 +123,6 @@ func (ab *AtomicBlock) Accept() {
|
||||||
ab.onAcceptFunc()
|
ab.onAcceptFunc()
|
||||||
}
|
}
|
||||||
|
|
||||||
parent := ab.parentBlock()
|
|
||||||
// remove this block and its parent from memory
|
|
||||||
parent.free()
|
|
||||||
ab.free()
|
ab.free()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -133,11 +130,9 @@ func (ab *AtomicBlock) Accept() {
|
||||||
// decision block, has ID [parentID].
|
// decision block, has ID [parentID].
|
||||||
func (vm *VM) newAtomicBlock(parentID ids.ID, tx AtomicTx) (*AtomicBlock, error) {
|
func (vm *VM) newAtomicBlock(parentID ids.ID, tx AtomicTx) (*AtomicBlock, error) {
|
||||||
ab := &AtomicBlock{
|
ab := &AtomicBlock{
|
||||||
SingleDecisionBlock: SingleDecisionBlock{CommonDecisionBlock: CommonDecisionBlock{
|
CommonDecisionBlock: CommonDecisionBlock{CommonBlock: CommonBlock{
|
||||||
CommonBlock: CommonBlock{
|
Block: core.NewBlock(parentID),
|
||||||
Block: core.NewBlock(parentID),
|
vm: vm,
|
||||||
vm: vm,
|
|
||||||
},
|
|
||||||
}},
|
}},
|
||||||
Tx: tx,
|
Tx: tx,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue