Improve transaction creation

This commit is contained in:
Slavomir 2021-09-21 17:33:48 +02:00
parent c632e33ffc
commit 96d168d4d4
2 changed files with 5 additions and 8 deletions

View File

@ -73,14 +73,11 @@ func NewAccountMeta(
}
func (a *AccountMeta) less(act *AccountMeta) bool {
if a.IsSigner && !act.IsSigner {
return true
} else if !a.IsSigner && act.IsSigner {
return false
if a.IsSigner != act.IsSigner {
return a.IsSigner
}
if a.IsWritable {
return true
if a.IsWritable != act.IsWritable {
return a.IsWritable
}
return false
}

View File

@ -127,7 +127,7 @@ func NewTransaction(instructions []Instruction, recentBlockHash Hash, opts ...Tr
}
// Sort. Prioritizing first by signer, then by writable
sort.Slice(accounts, func(i, j int) bool {
sort.SliceStable(accounts, func(i, j int) bool {
return accounts[i].less(accounts[j])
})