From 48d2a8b8ee9621810a988e3561e4213749c54da7 Mon Sep 17 00:00:00 2001 From: obscuren Date: Fri, 2 Jan 2015 12:09:38 +0100 Subject: Refactored tx pool and added extra fields to block * chain manager sets td on block + td output w/ String * added tx pool tests for removing/adding/validating * tx pool now uses a set for txs instead of list.List --- core/types/block.go | 4 ++-- core/types/transaction.go | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) (limited to 'core/types') diff --git a/core/types/block.go b/core/types/block.go index 7b4695f73..b59044bfc 100644 --- a/core/types/block.go +++ b/core/types/block.go @@ -209,7 +209,7 @@ func (self *Block) HashNoNonce() []byte { } func (self *Block) String() string { - return fmt.Sprintf(`BLOCK(%x): Size: %v { + return fmt.Sprintf(`BLOCK(%x): Size: %v TD: %v { Header: [ %v @@ -219,7 +219,7 @@ Transactions: Uncles: %v } -`, self.header.Hash(), self.Size(), self.header, self.transactions, self.uncles) +`, self.header.Hash(), self.Size(), self.Td, self.header, self.transactions, self.uncles) } func (self *Header) String() string { diff --git a/core/types/transaction.go b/core/types/transaction.go index 59244adc3..83d76648f 100644 --- a/core/types/transaction.go +++ b/core/types/transaction.go @@ -2,6 +2,7 @@ package types import ( "bytes" + "crypto/ecdsa" "fmt" "math/big" @@ -139,6 +140,10 @@ func (tx *Transaction) Sign(privk []byte) error { return nil } +func (tx *Transaction) SignECDSA(key *ecdsa.PrivateKey) error { + return tx.Sign(crypto.FromECDSA(key)) +} + func (tx *Transaction) RlpData() interface{} { data := []interface{}{tx.AccountNonce, tx.Price, tx.GasLimit, tx.Recipient, tx.Amount, tx.Payload} -- cgit v1.2.3