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
|
||||
}
|
||||
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)
|
||||
|
@ -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 {
|
||||
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)
|
||||
if err != nil {
|
||||
|
@ -383,7 +386,7 @@ func (ks *Keystore) GetDatabase(bID ids.ID, username, password string) (database
|
|||
return nil, err
|
||||
}
|
||||
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)
|
||||
|
|
|
@ -255,6 +255,17 @@ func TestServiceExportImport(t *testing.T) {
|
|||
newKS := Keystore{}
|
||||
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{}
|
||||
if err := newKS.ImportUser(nil, &ImportUserArgs{
|
||||
|
|
|
@ -515,7 +515,7 @@ func (nm *Handshake) disconnectedFromPeer(peer salticidae.PeerID) {
|
|||
nm.connections.Remove(peer, cert)
|
||||
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.pending.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
|
||||
// block to be accepted and committed to the chain.
|
||||
type AtomicBlock struct {
|
||||
SingleDecisionBlock `serialize:"true"`
|
||||
CommonDecisionBlock `serialize:"true"`
|
||||
|
||||
Tx AtomicTx `serialize:"true"`
|
||||
|
||||
|
@ -45,7 +45,7 @@ type AtomicBlock struct {
|
|||
|
||||
// initialize this block
|
||||
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 ab.Tx.initialize(vm)
|
||||
|
@ -123,9 +123,6 @@ func (ab *AtomicBlock) Accept() {
|
|||
ab.onAcceptFunc()
|
||||
}
|
||||
|
||||
parent := ab.parentBlock()
|
||||
// remove this block and its parent from memory
|
||||
parent.free()
|
||||
ab.free()
|
||||
}
|
||||
|
||||
|
@ -133,11 +130,9 @@ func (ab *AtomicBlock) Accept() {
|
|||
// decision block, has ID [parentID].
|
||||
func (vm *VM) newAtomicBlock(parentID ids.ID, tx AtomicTx) (*AtomicBlock, error) {
|
||||
ab := &AtomicBlock{
|
||||
SingleDecisionBlock: SingleDecisionBlock{CommonDecisionBlock: CommonDecisionBlock{
|
||||
CommonBlock: CommonBlock{
|
||||
Block: core.NewBlock(parentID),
|
||||
vm: vm,
|
||||
},
|
||||
CommonDecisionBlock: CommonDecisionBlock{CommonBlock: CommonBlock{
|
||||
Block: core.NewBlock(parentID),
|
||||
vm: vm,
|
||||
}},
|
||||
Tx: tx,
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue