Permalink
Browse files

add a new IsStandard rule

  • Loading branch information...
1 parent 5d14f17 commit 28e1f48aaf3462a4196ef23680e28a9fce9cf806 @DavidVorick DavidVorick committed Jul 14, 2015
Showing with 25 additions and 0 deletions.
  1. +2 −0 doc/Standard.md
  2. +23 −0 modules/transactionpool/standard.go
View
@@ -11,6 +11,8 @@ Transaction Size
Consensus rules limit the size of a block, but not the size of a transaction.
Standard rules however limit the size of a single transaction to 16kb.
+A chain of dependent transactions cannot exceed 500kb.
+
Double Spend Rules
------------------
@@ -34,8 +34,13 @@ import (
// if they include arbitrary data which has meanings that the legacy miner
// doesn't understand.
+const (
+ TransactionSetLimit = 500e3
+)
+
var (
ErrLargeTransaction = errors.New("transaction is too large")
+ ErrLargeTransactionSet = errors.New("transaction set is too large")
)
// checkUnlockConditions looks at the UnlockConditions and verifies that all
@@ -116,3 +121,21 @@ func (tp *TransactionPool) IsStandardTransaction(t types.Transaction) error {
}
return nil
}
+
+func (tp *TransactionPool) IsStandardTransacitonSet(ts []types.Transaction) error {
+ for i := range ts {
+ err := tp.IsStandardTransaction(ts[i])
+ if err != nil {
+ return err
+ }
+ }
+
+ totalSize := 0
+ for i := range ts {
+ totalSize += len(encoding.Marshal(ts[i]))
+ if totalSize > TransactionSetLimit {
+ return ErrLargeTransactionSet
+ }
+ }
+ return nil
+}

0 comments on commit 28e1f48

Please sign in to comment.